--- a/src/squirrel.cpp Tue May 20 13:09:34 2008 +0000
+++ b/src/squirrel.cpp Tue May 20 15:25:47 2008 +0000
@@ -13,15 +13,21 @@
void Squirrel::CompileError(HSQUIRRELVM vm, const SQChar *desc, const SQChar *source, SQInteger line, SQInteger column)
{
- char *src = strdup(FS2OTTD(source));
- char *dsc = strdup(FS2OTTD(desc));
+ SQChar buf[1024];
+
#ifdef _SQ64
- DEBUG(misc, 0, "Error %s:%ld/%ld: %s", src, line, column, dsc);
+ scsnprintf(buf, lengthof(buf), _SC("Error %s:%ld/%ld: %s"), source, line, column, desc);
#else
- DEBUG(misc, 0, "Error %s:%d/%d: %s", src, line, column, dsc);
+ scsnprintf(buf, lengthof(buf), _SC("Error %s:%d/%d: %s"), source, line, column, desc);
#endif
- free(src);
- free(dsc);
+
+ /* Check if we have a custom print function */
+ SQPrintFunc *func = ((Squirrel *)sq_getforeignptr(vm))->print_func;
+ if (func == NULL) {
+ scfprintf(stderr, _SC("%s"), buf);
+ } else {
+ (*func)(true, buf);
+ }
}
void Squirrel::ErrorPrintFunc(HSQUIRRELVM vm, const SQChar *s, ...)