45 /* And now we concat, so we are relative from the current script |
44 /* And now we concat, so we are relative from the current script |
46 * First, we have to make sure we have enough space for the full path */ |
45 * First, we have to make sure we have enough space for the full path */ |
47 real_filename = ReallocT(real_filename, scstrlen(real_filename) + scstrlen(filename) + 1); |
46 real_filename = ReallocT(real_filename, scstrlen(real_filename) + scstrlen(filename) + 1); |
48 scstrcat(real_filename, filename); |
47 scstrcat(real_filename, filename); |
49 |
48 |
50 /* Make sure we are in the root-table, so everything is included in the root-level */ |
49 bool ret = Squirrel::LoadScript(vm, FS2OTTD(real_filename)); |
51 sq_pushroottable(vm); |
|
52 |
50 |
53 SQInteger ret = 0; |
|
54 |
|
55 /* Compile and load the file */ |
|
56 if (!SQ_SUCCEEDED(sqstd_dofile(vm, real_filename, SQFalse, SQTrue))) { |
|
57 DEBUG(misc, 0, "[squirrel] Failed to compile '%s'", filename); |
|
58 ret = SQ_ERROR; |
|
59 } |
|
60 /* Reset the top, so the stack stays correct */ |
51 /* Reset the top, so the stack stays correct */ |
61 sq_settop(vm, top); |
52 sq_settop(vm, top); |
62 free(real_filename); |
53 free(real_filename); |
63 |
54 |
64 return ret; |
55 return ret ? 0: SQ_ERROR; |
65 } |
56 } |
66 |
57 |
67 void squirrel_register_global_std(Squirrel *engine) |
58 void squirrel_register_global_std(Squirrel *engine) |
68 { |
59 { |
69 /* We don't use squirrel_helper here, as we want to register to the global |
60 /* We don't use squirrel_helper here, as we want to register to the global |