(svn r12702) [NoAI] -Codechange: some coding style cleanups.
--- a/src/squirrel.cpp Sun Apr 13 09:10:59 2008 +0000
+++ b/src/squirrel.cpp Mon Apr 14 15:24:16 2008 +0000
@@ -35,8 +35,11 @@
/* 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);
+ if (func == NULL) {
+ scfprintf(stderr, _SC("%s"), buf);
+ } else {
+ (*func)(true, buf);
+ }
}
void Squirrel::RunError(HSQUIRRELVM vm, const SQChar *error)
@@ -49,8 +52,11 @@
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) scfprintf(stderr, _SC("%s"), buf);
- else (*func)(true, 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 */
sqstd_printcallstack(vm);
@@ -85,8 +91,11 @@
/* Check if we have a custom print function */
SQPrintFunc *func = ((Squirrel *)sq_getforeignptr(vm))->print_func;
- if (func == NULL) scprintf(_SC("%s"), buf);
- else (*func)(false, buf);
+ if (func == NULL) {
+ scprintf(_SC("%s"), buf);
+ } else {
+ (*func)(false, buf);
+ }
}
void Squirrel::AddMethod(const char *method_name, SQFUNCTION proc, uint nparam, const char *params, void *userdata, int size)
@@ -94,8 +103,7 @@
sq_pushstring(this->vm, OTTD2FS(method_name), -1);
if (size != 0) {
- void *ptr;
- ptr = sq_newuserdata(vm, size);
+ void *ptr = sq_newuserdata(vm, size);
memcpy(ptr, userdata, size);
}
--- a/src/thread_none.cpp Sun Apr 13 09:10:59 2008 +0000
+++ b/src/thread_none.cpp Mon Apr 14 15:24:16 2008 +0000
@@ -5,14 +5,17 @@
#include "stdafx.h"
#include "thread.h"
-OTTDThread *OTTDCreateThread(OTTDThreadFunc function, void *arg) {
+OTTDThread *OTTDCreateThread(OTTDThreadFunc function, void *arg)
+{
return NULL;
}
-void *OTTDJoinThread(OTTDThread *t) {
+void *OTTDJoinThread(OTTDThread *t)
+{
return NULL;
}
-void OTTDExitThread() {
+void OTTDExitThread()
+{
NOT_REACHED();
}
--- a/src/thread_os2.cpp Sun Apr 13 09:10:59 2008 +0000
+++ b/src/thread_os2.cpp Mon Apr 14 15:24:16 2008 +0000
@@ -29,8 +29,6 @@
{
OTTDThread *t = MallocT<OTTDThread>(1);
- if (t == NULL) return NULL;
-
t->func = function;
t->arg = arg;
t->thread = _beginthread(Proxy, NULL, 32768, t);
@@ -44,12 +42,10 @@
void *OTTDJoinThread(OTTDThread *t)
{
- void *ret;
-
if (t == NULL) return NULL;
DosWaitThread(&t->thread, DCWW_WAIT);
- ret = t->ret;
+ void *ret = t->ret;
free(t);
return ret;
}
--- a/src/thread_pthread.cpp Sun Apr 13 09:10:59 2008 +0000
+++ b/src/thread_pthread.cpp Mon Apr 14 15:24:16 2008 +0000
@@ -19,8 +19,6 @@
{
OTTDThread *t = MallocT<OTTDThread>(1);
- if (t == NULL) return NULL;
-
if (pthread_create(&t->thread, NULL, function, arg) == 0) {
return t;
} else {
@@ -31,7 +29,7 @@
void *OTTDJoinThread(OTTDThread *t)
{
- void* ret;
+ void *ret;
if (t == NULL) return NULL;
--- a/src/thread_win32.cpp Sun Apr 13 09:10:59 2008 +0000
+++ b/src/thread_win32.cpp Mon Apr 14 15:24:16 2008 +0000
@@ -29,8 +29,6 @@
{
OTTDThread *t = MallocT<OTTDThread>(1);
- if (t == NULL) return NULL;
-
t->func = function;
t->arg = arg;
t->thread = (HANDLE)_beginthreadex(NULL, 0, Proxy, t, 0, &t->thread_id);
@@ -45,13 +43,11 @@
void *OTTDJoinThread(OTTDThread *t)
{
- void *ret;
-
if (t == NULL) return NULL;
WaitForSingleObject(t->thread, INFINITE);
CloseHandle(t->thread);
- ret = t->ret;
+ void *ret = t->ret;
free(t);
return ret;
}