diff --git a/doomsday/engine/api/dd_infine.h b/doomsday/engine/api/dd_infine.h index f72d689710..2c71a7b6c1 100644 --- a/doomsday/engine/api/dd_infine.h +++ b/doomsday/engine/api/dd_infine.h @@ -62,7 +62,7 @@ struct fi_page_s; // Base fi_objects_t elements. All objects MUST use this as their basis. #define FIOBJECT_BASE_ELEMENTS() \ fi_objectid_t id; /* Unique id of the object. */ \ - fi_objectname_t name; /* Object names are unique among objects of the same type and spawned by the same script. */ \ + fi_objectname_t name; /* Nice name. */ \ fi_obtype_e type; /* Type of the object. */ \ animatorvector3_t pos; \ animator_t angle; \ diff --git a/doomsday/engine/portable/include/fi_main.h b/doomsday/engine/portable/include/fi_main.h index 6c6e345f42..934172fbdb 100644 --- a/doomsday/engine/portable/include/fi_main.h +++ b/doomsday/engine/portable/include/fi_main.h @@ -46,15 +46,14 @@ typedef struct fi_object_s { fi_object_t* FI_NewObject(fi_obtype_e type, const char* name); void FI_DeleteObject(fi_object_t* obj); -/// \todo Should be private. -typedef struct fi_namespace_s { +typedef struct fi_object_collection_s { uint num; fi_object_t** vector; -} fi_namespace_t; +} fi_object_collection_t; typedef struct fi_page_s { - // Known symbols (to this script). - fi_namespace_t _namespace; + // Objects visible on this page. + fi_object_collection_t _objects; struct material_s* bgMaterial; animatorvector4_t bgColor; @@ -70,7 +69,6 @@ void FIPage_RunTic(fi_page_t* page); fi_object_t* FIPage_AddObject(fi_page_t* page, fi_object_t* obj); fi_object_t* FIPage_RemoveObject(fi_page_t* page, fi_object_t* obj); boolean FIPage_HasObject(fi_page_t* page, fi_object_t* obj); -fi_objectid_t FIPage_ObjectIdForName(fi_page_t* page, const char* name, fi_obtype_e type); void FIPage_SetBackground(fi_page_t* page, struct material_s* mat); void FIPage_SetBackgroundColor(fi_page_t* page, float red, float green, float blue, int steps); diff --git a/doomsday/engine/portable/include/finaleinterpreter.h b/doomsday/engine/portable/include/finaleinterpreter.h index fc028991b1..88c4a5d90b 100644 --- a/doomsday/engine/portable/include/finaleinterpreter.h +++ b/doomsday/engine/portable/include/finaleinterpreter.h @@ -47,6 +47,12 @@ typedef struct fi_handler_s { fi_objectname_t marker; } fi_handler_t; +/// \todo Should be private. +typedef struct fi_namespace_s { + uint num; + struct fi_namespace_record_s* vector; +} fi_namespace_t; + typedef struct finaleinterpreter_t { finale_mode_t mode; struct finaleinterpreter_flags_s { @@ -72,6 +78,9 @@ typedef struct finaleinterpreter_t { uint numEventHandlers; fi_handler_t* eventHandlers; + // Known symbols (to the loaded script). + fi_namespace_t _namespace; + // The page all our objects are on. struct fi_page_s* _page; diff --git a/doomsday/engine/portable/src/fi_main.c b/doomsday/engine/portable/src/fi_main.c index 3081d32fcc..2536b6c81f 100644 --- a/doomsday/engine/portable/src/fi_main.c +++ b/doomsday/engine/portable/src/fi_main.c @@ -50,11 +50,6 @@ // TYPES ------------------------------------------------------------------- -typedef struct fi_object_collection_s { - uint num; - fi_object_t** vector; -} fi_object_collection_t; - // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- @@ -70,8 +65,6 @@ void P_DestroyPic(fidata_pic_t* pic); // PRIVATE FUNCTION PROTOTYPES --------------------------------------------- -static fi_objectid_t toObjectId(fi_namespace_t* names, const char* name, fi_obtype_e type); - // EXTERNAL DATA DECLARATIONS ---------------------------------------------- // PUBLIC DATA DEFINITIONS ------------------------------------------------- @@ -120,15 +113,15 @@ static void useColor(animator_t *color, int components) static void objectSetName(fi_object_t* obj, const char* name) { - strncpy(obj->name, name, sizeof(obj->name) - 1); + dd_snprintf(obj->name, FI_NAME_MAX_LENGTH, "%s", name); } -static void thinkObjectsInScope(fi_namespace_t* names) +static void thinkObjectsInScope(fi_object_collection_t* c) { uint i; - for(i = 0; i < names->num; ++i) + for(i = 0; i < c->num; ++i) { - fi_object_t* obj = names->vector[i]; + fi_object_t* obj = c->vector[i]; switch(obj->type) { case FI_PIC: FIData_PicThink((fidata_pic_t*)obj); break; @@ -138,13 +131,13 @@ static void thinkObjectsInScope(fi_namespace_t* names) } } -static void drawObjectsInScope2(fi_namespace_t* names, fi_obtype_e type, float picOffsetX, float picOffsetY) +static void drawObjectsInScope2(fi_object_collection_t* c, fi_obtype_e type, float picOffsetX, float picOffsetY) { static const vec3_t worldOrigin = { 0, 0, 0 }; uint i; - for(i = 0; i < names->num; ++i) + for(i = 0; i < c->num; ++i) { - fi_object_t* obj = names->vector[i]; + fi_object_t* obj = c->vector[i]; if(obj->type != type) continue; switch(obj->type) @@ -162,45 +155,70 @@ static void drawObjectsInScope2(fi_namespace_t* names, fi_obtype_e type, float p } } -static void drawObjectsInScope(fi_namespace_t* names, float picXOffset, float picYOffset) +static void drawObjectsInScope(fi_object_collection_t* c, float picXOffset, float picYOffset) { // Images first, then text. - drawObjectsInScope2(names, FI_PIC, picXOffset, picYOffset); - drawObjectsInScope2(names, FI_TEXT, 0, 0); + drawObjectsInScope2(c, FI_PIC, picXOffset, picYOffset); + drawObjectsInScope2(c, FI_TEXT, 0, 0); +} + +static uint objectsToIndex(fi_object_collection_t* c, fi_object_t* obj) +{ + if(obj) + { + uint i; + for(i = 0; i < c->num; ++i) + { + fi_object_t* other = c->vector[i]; + if(other == obj) + return i+1; + } + } + return 0; +} + +static __inline boolean objectsIsPresent(fi_object_collection_t* c, fi_object_t* obj) +{ + return objectsToIndex(c, obj) != 0; } +/** + * Does not check if the object already exists in this scope. Assumes the caller + * knows what they are doing. + */ static fi_object_t* objectsAdd(fi_object_collection_t* c, fi_object_t* obj) { - // Link with this page. c->vector = Z_Realloc(c->vector, sizeof(*c->vector) * ++c->num, PU_STATIC); c->vector[c->num-1] = obj; return obj; } -static void objectsRemove(fi_object_collection_t* c, fi_object_t* obj) +/** + * Assumes there is at most one reference to the obj in the scope and that the + * caller knows what they are doing. + */ +static fi_object_t* objectsRemove(fi_object_collection_t* c, fi_object_t* obj) { - uint i; - for(i = 0; i < c->num; ++i) + uint idx; + if((idx = objectsToIndex(c, obj))) { - fi_object_t* other = c->vector[i]; - if(other == obj) - { - if(i != c->num-1) - memmove(&c->vector[i], &c->vector[i+1], sizeof(*c->vector) * (c->num-i)); + idx -= 1; // Indices are 1-based. - if(c->num > 1) - { - c->vector = Z_Realloc(c->vector, sizeof(*c->vector) * --c->num, PU_STATIC); - } - else - { - Z_Free(c->vector); - c->vector = NULL; - c->num = 0; - } - return; + if(idx != c->num-1) + memmove(&c->vector[idx], &c->vector[idx+1], sizeof(*c->vector) * (c->num-idx)); + + if(c->num > 1) + { + c->vector = Z_Realloc(c->vector, sizeof(*c->vector) * --c->num, PU_STATIC); + } + else + { + Z_Free(c->vector); + c->vector = 0; + c->num = 0; } } + return obj; } static void objectsEmpty(fi_object_collection_t* c) @@ -215,6 +233,8 @@ static void objectsEmpty(fi_object_collection_t* c) { case FI_PIC: P_DestroyPic((fidata_pic_t*)obj); break; case FI_TEXT: P_DestroyText((fidata_text_t*)obj); break; + default: + Con_Error("InFine: Unknown object type %i in objectsEmpty.", (int)obj->type); } } Z_Free(c->vector); @@ -223,59 +243,6 @@ static void objectsEmpty(fi_object_collection_t* c) c->num = 0; } -static void destroyObjectsInScope(fi_namespace_t* names) -{ - // Delete external images, text strings etc. - if(names->vector) - { - uint i; - for(i = 0; i < names->num; ++i) - { - fi_object_t* obj = names->vector[i]; - objectsRemove(&objects, obj); - switch(obj->type) - { - case FI_PIC: P_DestroyPic((fidata_pic_t*)obj); break; - case FI_TEXT: P_DestroyText((fidata_text_t*)obj); break; - default: - break; - } - } - Z_Free(names->vector); - } - names->vector = NULL; - names->num = 0; -} - -static fi_objectid_t findIdForName(fi_namespace_t* names, const char* name) -{ - fi_objectid_t id; - // First check all pics. - id = toObjectId(names, name, FI_PIC); - // Then check text objects. - if(!id) - id = toObjectId(names, name, FI_TEXT); - return id; -} - -static fi_objectid_t toObjectId(fi_namespace_t* names, const char* name, fi_obtype_e type) -{ - assert(name && name[0]); - if(type == FI_NONE) - { // Use a priority-based search. - return findIdForName(names, name); - } - - {uint i; - for(i = 0; i < names->num; ++i) - { - fi_object_t* obj = names->vector[i]; - if(obj->type == type && !stricmp(obj->name, name)) - return obj->id; - }} - return 0; -} - static fi_object_t* objectsById(fi_object_collection_t* c, fi_objectid_t id) { if(id != 0) @@ -309,7 +276,12 @@ static void pageClear(fi_page_t* p) p->timer = 0; p->bgMaterial = NULL; // No background material. - destroyObjectsInScope(&p->_namespace); + if(p->_objects.vector) + { + Z_Free(p->_objects.vector); + } + p->_objects.vector = 0; + p->_objects.num = 0; AnimatorVector4_Init(p->filter, 0, 0, 0, 0); AnimatorVector2_Init(p->imgOffset, 0, 0); @@ -352,6 +324,8 @@ Con_Printf("InFine: Attempt to pop empty stack\n"); return false; } + P_DestroyFinaleInterpreter(fi); + // Should we go back to NULL? if(finaleStackSize > 1) { // Return to previous state. @@ -365,9 +339,6 @@ Con_Printf("InFine: Attempt to pop empty stack\n"); active = false; } - FI_DeletePage(fi->_page); fi->_page = 0; - P_DestroyFinaleInterpreter(fi); - return active; } @@ -394,69 +365,9 @@ static void scriptTerminate(finaleinterpreter_t* fi) active = false; } - FI_DeletePage(fi->_page); fi->_page = 0; P_DestroyFinaleInterpreter(fi); } -static uint objectIndexInNamespace(fi_namespace_t* names, fi_object_t* obj) -{ - if(obj) - { - uint i; - for(i = 0; i < names->num; ++i) - { - fi_object_t* other = names->vector[i]; - if(other == obj) - return i+1; - } - } - return 0; -} - -static __inline boolean objectInNamespace(fi_namespace_t* names, fi_object_t* obj) -{ - return objectIndexInNamespace(names, obj) != 0; -} - -/** - * Does not check if the object already exists in this scope. Assumes the caller - * knows what they are doing. - */ -static fi_object_t* addObjectToNamespace(fi_namespace_t* names, fi_object_t* obj) -{ - names->vector = Z_Realloc(names->vector, sizeof(*names->vector) * ++names->num, PU_STATIC); - names->vector[names->num-1] = obj; - return obj; -} - -/** - * Assumes there is at most one reference to the obj in the scope and that the - * caller knows what they are doing. - */ -static fi_object_t* removeObjectInNamespace(fi_namespace_t* names, fi_object_t* obj) -{ - uint idx; - if((idx = objectIndexInNamespace(names, obj))) - { - idx -= 1; // Indices are 1-based. - - if(idx != names->num-1) - memmove(&names->vector[idx], &names->vector[idx+1], sizeof(*names->vector) * (names->num-idx)); - - if(names->num > 1) - { - names->vector = Z_Realloc(names->vector, sizeof(*names->vector) * --names->num, PU_STATIC); - } - else - { - Z_Free(names->vector); - names->vector = NULL; - names->num = 0; - } - } - return obj; -} - static void rotate(float angle) { // Counter the VGA aspect ratio. @@ -482,7 +393,7 @@ static void pageDraw(fi_page_t* p) DGL_Enable(DGL_TEXTURING); } - drawObjectsInScope(&p->_namespace, -p->imgOffset[0].value, -p->imgOffset[1].value); + drawObjectsInScope(&p->_objects, -p->imgOffset[0].value, -p->imgOffset[1].value); // Filter on top of everything. Only draw if necessary. if(p->filter[3].value > 0) @@ -504,19 +415,16 @@ static void pageDraw(fi_page_t* p) /** * Reset the entire InFine state stack. */ -static void doReset(boolean doingShutdown) +static void doReset(void) { finaleinterpreter_t* fi; if((fi = stackTop()) && active) { - if(!doingShutdown) - { - // The state is suspended when the PlayDemo command is used. - // Being suspended means that InFine is currently not active, but - // will be restored at a later time. - if(FinaleInterpreter_IsSuspended(fi)) - return; - } + // The state is suspended when the PlayDemo command is used. + // Being suspended means that InFine is currently not active, but + // will be restored at a later time. + if(FinaleInterpreter_IsSuspended(fi)) + return; // Pop all the states. while(stackPop()); @@ -620,6 +528,7 @@ void FIObject_Destructor(fi_object_t* obj) FIPage_RemoveObject(fi->_page, obj); } } + objectsRemove(&objects, obj); Z_Free(obj); } @@ -721,9 +630,22 @@ void FI_Shutdown(void) { if(!inited) return; // Huh? - doReset(true); + + if(finaleStackSize) + { + uint i; + for(i = 0; i < finaleStackSize; ++i) + { + P_DestroyFinaleInterpreter(finaleStack[i]); + } + Z_Free(finaleStack); + } + finaleStack = 0; + finaleStackSize = 0; + // Garbage collection. objectsEmpty(&objects); + active = false; inited = false; } @@ -753,7 +675,7 @@ void FI_Reset(void) #endif return; } - doReset(false); + doReset(); } fi_page_t* FI_NewPage(void) @@ -881,7 +803,6 @@ void FI_DeleteObject(fi_object_t* obj) #endif return; } - objectsRemove(&objects, obj); switch(obj->type) { case FI_PIC: P_DestroyPic((fidata_pic_t*)obj); break; @@ -897,7 +818,7 @@ void FIPage_RunTic(fi_page_t* p) p->timer++; - thinkObjectsInScope(&p->_namespace); + thinkObjectsInScope(&p->_objects); // Interpolateable values. AnimatorVector4_Think(p->bgColor); @@ -909,26 +830,18 @@ void FIPage_RunTic(fi_page_t* p) } } -fi_objectid_t FIPage_ObjectIdForName(fi_page_t* p, const char* name, fi_obtype_e type) -{ - if(!p) Con_Error("FIPage_ObjectIdForName: Invalid page."); - if(!name || !name[0]) - return 0; - return toObjectId(&p->_namespace, name, type); -} - boolean FIPage_HasObject(fi_page_t* p, fi_object_t* obj) { if(!p) Con_Error("FIPage_HasObject: Invalid page."); - return objectInNamespace(&p->_namespace, obj); + return objectsIsPresent(&p->_objects, obj); } fi_object_t* FIPage_AddObject(fi_page_t* p, fi_object_t* obj) { if(!p) Con_Error("FIPage_AddObject: Invalid page."); - if(obj && !objectIndexInNamespace(&p->_namespace, obj)) + if(obj && !objectsToIndex(&p->_objects, obj)) { - return addObjectToNamespace(&p->_namespace, obj); + return objectsAdd(&p->_objects, obj); } return obj; } @@ -936,9 +849,9 @@ fi_object_t* FIPage_AddObject(fi_page_t* p, fi_object_t* obj) fi_object_t* FIPage_RemoveObject(fi_page_t* p, fi_object_t* obj) { if(!p) Con_Error("FIPage_RemoveObject: Invalid page."); - if(obj && objectIndexInNamespace(&p->_namespace, obj)) + if(obj && objectsToIndex(&p->_objects, obj)) { - return removeObjectInNamespace(&p->_namespace, obj); + return objectsRemove(&p->_objects, obj); } return obj; } diff --git a/doomsday/engine/portable/src/finaleinterpreter.c b/doomsday/engine/portable/src/finaleinterpreter.c index 56f842dc7a..3a65fb6332 100644 --- a/doomsday/engine/portable/src/finaleinterpreter.c +++ b/doomsday/engine/portable/src/finaleinterpreter.c @@ -84,6 +84,11 @@ typedef struct command_s { } flags; } command_t; +typedef struct fi_namespace_record_s { + fi_objectname_t name; // Unique among objects of the same type and spawned by the same script. + fi_objectid_t objectId; +} fi_namespace_record_t; + // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- @@ -181,6 +186,8 @@ DEFFC(NoShowMenu); // PRIVATE FUNCTION PROTOTYPES --------------------------------------------- +static fi_objectid_t toObjectId(fi_namespace_t* names, const char* name, fi_obtype_e type); + // EXTERNAL DATA DECLARATIONS ---------------------------------------------- // PUBLIC DATA DEFINITIONS ------------------------------------------------- @@ -311,6 +318,124 @@ static void* defaultState = 0; // CODE -------------------------------------------------------------------- +static fi_objectid_t findIdForName(fi_namespace_t* names, const char* name) +{ + fi_objectid_t id; + // First check all pics. + id = toObjectId(names, name, FI_PIC); + // Then check text objects. + if(!id) + id = toObjectId(names, name, FI_TEXT); + return id; +} + +static fi_objectid_t toObjectId(fi_namespace_t* names, const char* name, fi_obtype_e type) +{ + assert(name && name[0]); + if(type == FI_NONE) + { // Use a priority-based search. + return findIdForName(names, name); + } + + {uint i; + for(i = 0; i < names->num; ++i) + { + fi_namespace_record_t* rec = &names->vector[i]; + if(!stricmp(rec->name, name) && FI_Object(rec->objectId)->type == type) + return rec->objectId; + }} + return 0; +} + +static void destroyObjectsInScope(fi_namespace_t* names) +{ + // Delete external images, text strings etc. + if(names->vector) + { + uint i; + for(i = 0; i < names->num; ++i) + { + fi_namespace_record_t* rec = &names->vector[i]; + FI_DeleteObject(FI_Object(rec->objectId)); + } + Z_Free(names->vector); + } + names->vector = NULL; + names->num = 0; +} + +static uint objectIndexInNamespace(fi_namespace_t* names, fi_object_t* obj) +{ + if(obj) + { + uint i; + for(i = 0; i < names->num; ++i) + { + fi_namespace_record_t* rec = &names->vector[i]; + if(rec->objectId == obj->id) + return i+1; + } + } + return 0; +} + +static __inline boolean objectInNamespace(fi_namespace_t* names, fi_object_t* obj) +{ + return objectIndexInNamespace(names, obj) != 0; +} + +/** + * Does not check if the object already exists in this scope. Assumes the caller + * knows what they are doing. + */ +static fi_object_t* addObjectToNamespace(fi_namespace_t* names, const char* name, fi_object_t* obj) +{ + fi_namespace_record_t* rec; + names->vector = Z_Realloc(names->vector, sizeof(*names->vector) * ++names->num, PU_STATIC); + rec = &names->vector[names->num-1]; + + rec->objectId = obj->id; + memset(rec->name, 0, sizeof(rec->name)); + dd_snprintf(rec->name, FI_NAME_MAX_LENGTH, "%s", name); + + return obj; +} + +/** + * Assumes there is at most one reference to the obj in the scope and that the + * caller knows what they are doing. + */ +static fi_object_t* removeObjectInNamespace(fi_namespace_t* names, fi_object_t* obj) +{ + uint idx; + if((idx = objectIndexInNamespace(names, obj))) + { + idx -= 1; // Indices are 1-based. + + if(idx != names->num-1) + memmove(&names->vector[idx], &names->vector[idx+1], sizeof(*names->vector) * (names->num-idx)); + + if(names->num > 1) + { + names->vector = Z_Realloc(names->vector, sizeof(*names->vector) * --names->num, PU_STATIC); + } + else + { + Z_Free(names->vector); + names->vector = NULL; + names->num = 0; + } + } + return obj; +} + +static fi_objectid_t findObjectIdForName(fi_namespace_t* names, const char* name, fi_obtype_e type) +{ + if(!name || !name[0]) + return 0; + return toObjectId(names, name, type); +} + static void changeMode(finaleinterpreter_t* fi, finale_mode_t mode) { fi->mode = mode; @@ -475,7 +600,7 @@ static fi_operand_t* parseCommandArguments(finaleinterpreter_t* fi, const comman break; } case FVT_OBJECT: - op->data.obj = FI_Object(FIPage_ObjectIdForName(fi->_page, token, FI_NONE)); + op->data.obj = FI_Object(findObjectIdForName(&fi->_namespace, token, FI_NONE)); break; } } while(++i < numOperands);} @@ -590,15 +715,15 @@ static boolean executeNextCommand(finaleinterpreter_t* fi) * a) Existing object associated with unique @a name. * b) New object with unique @a name. */ -static fi_object_t* getObject(fi_page_t* p, fi_obtype_e type, const char* name) +static fi_object_t* getObject(finaleinterpreter_t* fi, fi_obtype_e type, const char* name) { assert(name && name); { fi_objectid_t id; // An existing object? - if((id = FIPage_ObjectIdForName(p, name, type))) + if((id = findObjectIdForName(&fi->_namespace, name, type))) return FI_Object(id); - return FIPage_AddObject(p, FI_NewObject(type, name)); + return FIPage_AddObject(fi->_page, addObjectToNamespace(&fi->_namespace, name, FI_NewObject(type, name))); } } @@ -741,6 +866,8 @@ void P_DestroyFinaleInterpreter(finaleinterpreter_t* fi) stopScript(fi); clearEventHandlers(fi); releaseScript(fi); + destroyObjectsInScope(&fi->_namespace); + FI_DeletePage(fi->_page); Z_Free(fi); } @@ -1062,12 +1189,12 @@ DEFFC(Wait) DEFFC(WaitText) { - fi->waitingText = getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fi->waitingText = getObject(fi, FI_TEXT, ops[0].data.cstring); } DEFFC(WaitAnim) { - fi->waitingPic = getObject(fi->_page, FI_PIC, ops[0].data.cstring); + fi->waitingPic = getObject(fi, FI_PIC, ops[0].data.cstring); } DEFFC(Color) @@ -1210,12 +1337,12 @@ DEFFC(Marker) DEFFC(Delete) { if(ops[0].data.obj) - FI_DeleteObject(ops[0].data.obj); + FI_DeleteObject(removeObjectInNamespace(&fi->_namespace, ops[0].data.obj)); } DEFFC(Image) { - fidata_pic_t* obj = (fidata_pic_t*) getObject(fi->_page, FI_PIC, ops[0].data.cstring); + fidata_pic_t* obj = (fidata_pic_t*) getObject(fi, FI_PIC, ops[0].data.cstring); const char* name = ops[1].data.cstring; lumpnum_t lumpNum; @@ -1231,7 +1358,7 @@ DEFFC(Image) DEFFC(ImageAt) { - fidata_pic_t* obj = (fidata_pic_t*) getObject(fi->_page, FI_PIC, ops[0].data.cstring); + fidata_pic_t* obj = (fidata_pic_t*) getObject(fi, FI_PIC, ops[0].data.cstring); float x = ops[1].data.flt; float y = ops[2].data.flt; const char* name = ops[3].data.cstring; @@ -1260,7 +1387,7 @@ static DGLuint loadGraphics(ddresourceclass_t resClass, const char* name, DEFFC(XImage) { - fidata_pic_t* obj = (fidata_pic_t*) getObject(fi->_page, FI_PIC, ops[0].data.cstring); + fidata_pic_t* obj = (fidata_pic_t*) getObject(fi, FI_PIC, ops[0].data.cstring); const char* fileName = ops[1].data.cstring; DGLuint tex; @@ -1277,7 +1404,7 @@ DEFFC(XImage) DEFFC(Patch) { - fidata_pic_t* obj = (fidata_pic_t*) getObject(fi->_page, FI_PIC, ops[0].data.cstring); + fidata_pic_t* obj = (fidata_pic_t*) getObject(fi, FI_PIC, ops[0].data.cstring); float x = ops[1].data.flt; float y = ops[2].data.flt; const char* name = ops[3].data.cstring; @@ -1296,7 +1423,7 @@ DEFFC(Patch) DEFFC(SetPatch) { - fidata_pic_t* obj = (fidata_pic_t*) getObject(fi->_page, FI_PIC, ops[0].data.cstring); + fidata_pic_t* obj = (fidata_pic_t*) getObject(fi, FI_PIC, ops[0].data.cstring); const char* name = ops[1].data.cstring; patchid_t patch; @@ -1331,7 +1458,7 @@ DEFFC(ClearAnim) DEFFC(Anim) { - fidata_pic_t* obj = (fidata_pic_t*) getObject(fi->_page, FI_PIC, ops[0].data.cstring); + fidata_pic_t* obj = (fidata_pic_t*) getObject(fi, FI_PIC, ops[0].data.cstring); const char* name = ops[1].data.cstring; int tics = FRACSECS_TO_TICKS(ops[2].data.flt); patchid_t patch; @@ -1348,7 +1475,7 @@ DEFFC(Anim) DEFFC(AnimImage) { - fidata_pic_t* obj = (fidata_pic_t*) getObject(fi->_page, FI_PIC, ops[0].data.cstring); + fidata_pic_t* obj = (fidata_pic_t*) getObject(fi, FI_PIC, ops[0].data.cstring); const char* name = ops[1].data.cstring; int tics = FRACSECS_TO_TICKS(ops[2].data.flt); lumpnum_t lumpNum; @@ -1364,13 +1491,13 @@ DEFFC(AnimImage) DEFFC(Repeat) { - fidata_pic_t* obj = (fidata_pic_t*) getObject(fi->_page, FI_PIC, ops[0].data.cstring); + fidata_pic_t* obj = (fidata_pic_t*) getObject(fi, FI_PIC, ops[0].data.cstring); obj->flags.looping = true; } DEFFC(StateAnim) { - fidata_pic_t* obj = (fidata_pic_t*) getObject(fi->_page, FI_PIC, ops[0].data.cstring); + fidata_pic_t* obj = (fidata_pic_t*) getObject(fi, FI_PIC, ops[0].data.cstring); int stateId = Def_Get(DD_DEF_STATE, ops[1].data.cstring, 0); int count = ops[2].data.integer; @@ -1391,7 +1518,7 @@ DEFFC(StateAnim) DEFFC(PicSound) { - fidata_pic_t* obj = (fidata_pic_t*) getObject(fi->_page, FI_PIC, ops[0].data.cstring); + fidata_pic_t* obj = (fidata_pic_t*) getObject(fi, FI_PIC, ops[0].data.cstring); int sound = Def_Get(DD_DEF_SOUND, ops[1].data.cstring, 0); if(!obj->numFrames) { @@ -1552,7 +1679,7 @@ DEFFC(ObjectAngle) DEFFC(Rect) { - fidata_pic_t* obj = (fidata_pic_t*) getObject(fi->_page, FI_PIC, ops[0].data.cstring); + fidata_pic_t* obj = (fidata_pic_t*) getObject(fi, FI_PIC, ops[0].data.cstring); /** * We may be converting an existing Pic to a Rect, so re-init the expected @@ -1690,7 +1817,7 @@ DEFFC(Filter) DEFFC(Text) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); AnimatorVector3_Init(tex->pos, ops[1].data.flt, ops[2].data.flt, 0); FIData_TextCopy(tex, ops[3].data.cstring); tex->cursorPos = 0; // Restart the text. @@ -1698,7 +1825,7 @@ DEFFC(Text) DEFFC(TextFromDef) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); char* str; AnimatorVector3_Init(tex->pos, ops[1].data.flt, ops[2].data.flt, 0); if(!Def_Get(DD_DEF_TEXT, (char*)ops[3].data.cstring, &str)) @@ -1709,7 +1836,7 @@ DEFFC(TextFromDef) DEFFC(TextFromLump) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); int lnum; AnimatorVector3_Init(tex->pos, ops[1].data.flt, ops[2].data.flt, 0); @@ -1750,13 +1877,13 @@ DEFFC(TextFromLump) DEFFC(SetText) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); FIData_TextCopy(tex, ops[1].data.cstring); } DEFFC(SetTextDef) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); char* str; if(!Def_Get(DD_DEF_TEXT, ops[1].data.cstring, &str)) str = "(undefined)"; // Not found! @@ -1766,7 +1893,7 @@ DEFFC(SetTextDef) DEFFC(DeleteText) { if(ops[0].data.obj) - FI_DeleteObject(ops[0].data.obj); + FI_DeleteObject(removeObjectInNamespace(&fi->_namespace, ops[0].data.obj)); } DEFFC(PredefinedTextColor) @@ -1776,68 +1903,68 @@ DEFFC(PredefinedTextColor) DEFFC(TextRGB) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); AnimatorVector3_Set(tex->color, ops[1].data.flt, ops[2].data.flt, ops[3].data.flt, fi->inTime); } DEFFC(TextAlpha) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); Animator_Set(&tex->color[CA], ops[1].data.flt, fi->inTime); } DEFFC(TextOffX) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); Animator_Set(&tex->pos[0], ops[1].data.flt, fi->inTime); } DEFFC(TextOffY) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); Animator_Set(&tex->pos[1], ops[1].data.flt, fi->inTime); } DEFFC(TextCenter) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); tex->textFlags &= ~(DTF_ALIGN_LEFT|DTF_ALIGN_RIGHT); } DEFFC(TextNoCenter) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); tex->textFlags |= DTF_ALIGN_LEFT; } DEFFC(TextScroll) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); tex->scrollWait = ops[1].data.integer; tex->scrollTimer = 0; } DEFFC(TextPos) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); tex->cursorPos = ops[1].data.integer; } DEFFC(TextRate) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); tex->wait = ops[1].data.integer; } DEFFC(TextLineHeight) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); tex->lineheight = ops[1].data.flt; } DEFFC(Font) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); const char* fontName = ops[1].data.cstring; compositefontid_t font; if((font = R_CompositeFontNumForName(fontName))) @@ -1850,13 +1977,13 @@ DEFFC(Font) DEFFC(FontA) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); tex->font = R_CompositeFontNumForName("a"); } DEFFC(FontB) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); tex->font = R_CompositeFontNumForName("b"); } @@ -1868,19 +1995,19 @@ DEFFC(NoMusic) DEFFC(TextScaleX) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); Animator_Set(&tex->scale[0], ops[1].data.flt, fi->inTime); } DEFFC(TextScaleY) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); Animator_Set(&tex->scale[1], ops[1].data.flt, fi->inTime); } DEFFC(TextScale) { - fidata_text_t* tex = (fidata_text_t*) getObject(fi->_page, FI_TEXT, ops[0].data.cstring); + fidata_text_t* tex = (fidata_text_t*) getObject(fi, FI_TEXT, ops[0].data.cstring); AnimatorVector2_Set(tex->scale, ops[1].data.flt, ops[2].data.flt, fi->inTime); }