equal
deleted
inserted
replaced
183 |
183 |
184 /* Create a fake internal name */ |
184 /* Create a fake internal name */ |
185 char fake_class[1024]; |
185 char fake_class[1024]; |
186 snprintf(fake_class, sizeof(fake_class), "_internalNA%d", ++this->library_instance_count); |
186 snprintf(fake_class, sizeof(fake_class), "_internalNA%d", ++this->library_instance_count); |
187 |
187 |
|
188 /* Get the current table/class we belong to */ |
|
189 HSQOBJECT parent; |
|
190 sq_getstackobj(vm, 1, &parent); |
|
191 |
188 /* Load the library in a 'fake' namespace, so we can link it to the name the user requested */ |
192 /* Load the library in a 'fake' namespace, so we can link it to the name the user requested */ |
189 sq_pushroottable(vm); |
193 sq_pushroottable(vm); |
190 sq_pushstring(vm, OTTD2FS(fake_class), -1); |
194 sq_pushstring(vm, OTTD2FS(fake_class), -1); |
191 sq_newclass(vm, SQFalse); |
195 sq_newclass(vm, SQFalse); |
192 /* Load the library */ |
196 /* Load the library */ |
216 } |
220 } |
217 HSQOBJECT obj; |
221 HSQOBJECT obj; |
218 sq_getstackobj(vm, -1, &obj); |
222 sq_getstackobj(vm, -1, &obj); |
219 sq_pop(vm, 3); |
223 sq_pop(vm, 3); |
220 |
224 |
|
225 if (StrEmpty(class_name)) { |
|
226 sq_pushobject(vm, obj); |
|
227 return true; |
|
228 } |
|
229 |
221 /* Now link the name the user wanted to our 'fake' class */ |
230 /* Now link the name the user wanted to our 'fake' class */ |
222 sq_pushroottable(vm); |
231 sq_pushobject(vm, parent); |
223 sq_pushstring(vm, OTTD2FS(class_name), -1); |
232 sq_pushstring(vm, OTTD2FS(class_name), -1); |
224 sq_pushobject(vm, obj); |
233 sq_pushobject(vm, obj); |
225 sq_newclass(vm, SQTrue); |
234 sq_newclass(vm, SQTrue); |
226 sq_newslot(vm, -3, SQFalse); |
235 sq_newslot(vm, -3, SQFalse); |
227 sq_pop(vm, 1); |
236 sq_pop(vm, 1); |
228 |
237 |
|
238 sq_pushobject(vm, obj); |
229 return true; |
239 return true; |
230 } |
240 } |
231 |
241 |
232 void AISquirrel::RegisterLibrary(AILibrary *library) |
242 void AISquirrel::RegisterLibrary(AILibrary *library) |
233 { |
243 { |