(svn r12286) [NoAI] -Fix (r12277): restore compilation with _UNICODE noai
authorglx
Wed, 27 Feb 2008 00:29:35 +0000
branchnoai
changeset 9789 33d3214a2fce
parent 9788 e9dbd4ec1784
child 9790 cf20a184fea5
(svn r12286) [NoAI] -Fix (r12277): restore compilation with _UNICODE
src/ai/ai_squirrel.hpp
src/squirrel.cpp
src/squirrel.hpp
--- a/src/ai/ai_squirrel.hpp	Tue Feb 26 23:47:37 2008 +0000
+++ b/src/ai/ai_squirrel.hpp	Wed Feb 27 00:29:35 2008 +0000
@@ -26,7 +26,7 @@
 
 	uint GetTick() { return AIController::GetTick(); }
 	void Sleep(uint ticks) { return AIController::Sleep(ticks); }
-	static void PrintFunc(bool error_msg, const char *message) { AIController::Print(error_msg, message); }
+	static void PrintFunc(bool error_msg, const SQChar *message) { AIController::Print(error_msg, FS2OTTD(message)); }
 };
 
 class FSquirrel: public AIFactory<FSquirrel> {
--- a/src/squirrel.cpp	Tue Feb 26 23:47:37 2008 +0000
+++ b/src/squirrel.cpp	Wed Feb 27 00:29:35 2008 +0000
@@ -27,29 +27,29 @@
 void Squirrel::ErrorPrintFunc(HSQUIRRELVM vm, const SQChar *s, ...)
 {
 	va_list arglist;
-	char buf[1024];
+	SQChar buf[1024];
 
 	va_start(arglist, s);
-	vsnprintf(buf, lengthof(buf), s, arglist);
+	scvsnprintf(buf, lengthof(buf), s, arglist);
 	va_end(arglist);
 
 	/* Check if we have a custom print function */
 	SQPrintFunc *func = ((Squirrel *)sq_getforeignptr(vm))->print_func;
-	if (func == NULL) fprintf(stderr, "%s", buf);
+	if (func == NULL) scfprintf(stderr, _SC("%s"), buf);
 	else (*func)(true, buf);
 }
 
-void Squirrel::RunError(HSQUIRRELVM vm, const char *error)
+void Squirrel::RunError(HSQUIRRELVM vm, const SQChar *error)
 {
 	/* Set the print function to something that prints to stderr */
 	SQPRINTFUNCTION pf = sq_getprintfunc(vm);
 	sq_setprintfunc(vm, &Squirrel::ErrorPrintFunc);
 
 	/* Check if we have a custom print function */
-	char buf[1024];
-	snprintf(buf, lengthof(buf), "Your script made an error: %s\n", error);
+	SQChar buf[1024];
+	scsnprintf(buf, lengthof(buf), _SC("Your script made an error: %s\n"), error);
 	SQPrintFunc *func = ((Squirrel *)sq_getforeignptr(vm))->print_func;
-	if (func == NULL) fprintf(stderr, "%s", buf);
+	if (func == NULL) scfprintf(stderr, _SC("%s"), buf);
 	else (*func)(true, buf);
 
 	/* Print below the error the stack, so the users knows what is happening */
@@ -64,28 +64,28 @@
 
 	if (sq_gettop(vm) >= 1) {
 		if (SQ_SUCCEEDED(sq_getstring(vm, -1, &sErr))) {
-			Squirrel::RunError(vm, FS2OTTD(sErr));
+			Squirrel::RunError(vm, sErr);
 			return 0;
 		}
 	}
 
-	Squirrel::RunError(vm, "unknown error");
+	Squirrel::RunError(vm, _SC("unknown error"));
 	return 0;
 }
 
 void Squirrel::PrintFunc(HSQUIRRELVM vm, const SQChar *s, ...)
 {
 	va_list arglist;
-	char buf[1024];
+	SQChar buf[1024];
 
 	va_start(arglist, s);
-	vsnprintf(buf, lengthof(buf) - 2, s, arglist);
+	scvsnprintf(buf, lengthof(buf) - 2, s, arglist);
 	va_end(arglist);
-	strcat(buf, "\n");
+	scstrcat(buf, _SC("\n"));
 
 	/* Check if we have a custom print function */
 	SQPrintFunc *func = ((Squirrel *)sq_getforeignptr(vm))->print_func;
-	if (func == NULL) printf("%s", buf);
+	if (func == NULL) scprintf(_SC("%s"), buf);
 	else (*func)(false, buf);
 }
 
--- a/src/squirrel.hpp	Tue Feb 26 23:47:37 2008 +0000
+++ b/src/squirrel.hpp	Wed Feb 27 00:29:35 2008 +0000
@@ -7,7 +7,7 @@
 
 class Squirrel {
 private:
-	typedef void (SQPrintFunc)(bool error_msg, const char *message);
+	typedef void (SQPrintFunc)(bool error_msg, const SQChar *message);
 
 	HSQUIRRELVM vm;          ///< The VirtualMachine instnace for squirrel
 	void *global_pointer;    ///< Can be set by who ever initializes Squirrel
@@ -27,7 +27,7 @@
 	/**
 	 * The RunError handler.
 	 */
-	static void RunError(HSQUIRRELVM vm, const char *error);
+	static void RunError(HSQUIRRELVM vm, const SQChar *error);
 
 	/**
 	 * If a user runs 'print' inside a script, this function gets the params.