summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRogier Polak <rogier.l.a.polak@gmail.com>2007-03-13 00:51:10 +0000
committerRogier Polak <rogier.l.a.polak@gmail.com>2007-03-13 00:51:10 +0000
commitd69f5bc43d0d08f9b47465598d6b53552a252dfc (patch)
treee8844d9bd83ef3dd3ccb43e621d1af9d005ed9ea /src
parent3b19be3a6408a8e1b36867a83822807876f9021e (diff)
downloadmanaserv-d69f5bc43d0d08f9b47465598d6b53552a252dfc.tar.gz
manaserv-d69f5bc43d0d08f9b47465598d6b53552a252dfc.tar.bz2
manaserv-d69f5bc43d0d08f9b47465598d6b53552a252dfc.tar.xz
manaserv-d69f5bc43d0d08f9b47465598d6b53552a252dfc.zip
Fixed the indentation, I broke previously.
Diffstat (limited to 'src')
-rw-r--r--src/script-squirrel.cpp156
1 files changed, 82 insertions, 74 deletions
diff --git a/src/script-squirrel.cpp b/src/script-squirrel.cpp
index ec2d6c39..7f7739b0 100644
--- a/src/script-squirrel.cpp
+++ b/src/script-squirrel.cpp
@@ -33,44 +33,46 @@ bool functionCall(HSQUIRRELVM v, const char *fn, const char *args, ...)
int top = sq_gettop(v); //save stack
sq_pushroottable(v); //pushes global table
sq_pushstring(v, _SC(fn), -1);
+
if (SQ_SUCCEEDED(sq_get(v, -2)))
{
- sq_pushroottable(v); //push 'this'
+ sq_pushroottable(v); //push 'this'
- if (args != NULL)
- {
- for (int i = 0; i < strlen(args); i++)
+ if (args != NULL)
{
- switch (args[i])
- {
- case 'S':
- case 's':
- //string
- argCount++;
- sq_pushstring(v, va_arg(arglist, char*), -1);
- break;
- case 'I':
- case 'i':
- //integer
- argCount++;
- sq_pushinteger(v, va_arg(arglist, int));
- break;
- case 'F':
- case 'f':
- //float
- argCount++;
- sq_pushfloat(v, va_arg(arglist, float));
- break;
- }
+ for (int i = 0; i < strlen(args); i++)
+ {
+ switch (args[i])
+ {
+ case 'S':
+ case 's':
+ //string
+ argCount++;
+ sq_pushstring(v, va_arg(arglist, char*), -1);
+ break;
+ case 'I':
+ case 'i':
+ //integer
+ argCount++;
+ sq_pushinteger(v, va_arg(arglist, int));
+ break;
+ case 'F':
+ case 'f':
+ //float
+ argCount++;
+ sq_pushfloat(v, va_arg(arglist, float));
+ break;
+ }
+ }
}
+
+ sq_call(v, argCount + 1, 0);
}
+ else return false;
- sq_call(v, argCount + 1, 0);
- } else
- return false;
sq_settop(v, top);
-
va_end(arglist);
+
return true;
}
@@ -95,46 +97,48 @@ int testFunc(HSQUIRRELVM v)
{
int nargs = sq_gettop(v);
- for (int n = 1; n <= nargs; n++) {
- printf("arg: %d is ", n);
- switch (sq_gettype(v, n))
+ for (int n = 1; n <= nargs; n++)
{
- case OT_NULL:
- printf("null");
- break;
- case OT_INTEGER:
- printf("integer");
- break;
- case OT_FLOAT:
- printf("float");
- break;
- case OT_STRING:
- printf("string");
- break;
- case OT_TABLE:
- printf("table");
- break;
- case OT_ARRAY:
- printf("array");
- break;
- case OT_USERDATA:
- printf("userdata");
- break;
- case OT_CLOSURE:
- printf("closure");
- break;
- case OT_NATIVECLOSURE:
- printf("nativeclosure");
- break;
- case OT_GENERATOR:
- printf("generator");
- break;
- case OT_USERPOINTER:
- printf("userpointer");
- break;
- default:
- printf("unknown");
- }
+ printf("arg: %d is ", n);
+
+ switch (sq_gettype(v, n))
+ {
+ case OT_NULL:
+ printf("null");
+ break;
+ case OT_INTEGER:
+ printf("integer");
+ break;
+ case OT_FLOAT:
+ printf("float");
+ break;
+ case OT_STRING:
+ printf("string");
+ break;
+ case OT_TABLE:
+ printf("table");
+ break;
+ case OT_ARRAY:
+ printf("array");
+ break;
+ case OT_USERDATA:
+ printf("userdata");
+ break;
+ case OT_CLOSURE:
+ printf("closure");
+ break;
+ case OT_NATIVECLOSURE:
+ printf("nativeclosure");
+ break;
+ case OT_GENERATOR:
+ printf("generator");
+ break;
+ case OT_USERPOINTER:
+ printf("userpointer");
+ break;
+ default:
+ printf("unknown");
+ }
}
printf("\n");
sq_pushinteger(v, nargs);
@@ -151,14 +155,18 @@ ScriptSquirrel::ScriptSquirrel(const std::string &file) :
sq_setprintfunc(vm, printfunc);
sq_pushroottable(vm);
- if (!SQ_SUCCEEDED(sqstd_dofile(vm, _SC(scriptName.c_str()), 0, 1))) {
- std::cerr << "Error: ScriptSquirrel: could not execute " <<
- scriptName << std::endl;
- } else {
+
+ if (!SQ_SUCCEEDED(sqstd_dofile(vm, _SC(scriptName.c_str()), 0, 1)))
+ {
+ std::cerr << "Error: ScriptSquirrel: could not execute "
+ << scriptName << std::endl;
+ }
+ else
+ {
registerStdLib(vm);
- functionCall(vm, "", NULL);
- functionCall(vm, "init", NULL);
+ functionCall(vm, "", NULL);
+ functionCall(vm, "init", NULL);
}
}