void setObjectPosition(int16 ovlIdx, int16 objIdx, int16 param3, int16 param4) { objDataStruct *ptr = getObjectDataFromOverlay(ovlIdx, objIdx); if (!ptr) return; //overlayTable[param1].ovlData switch (ptr->_class) { case THEME: case MULTIPLE: { if (param3 != 5) return; globalVars[overlayTable[ovlIdx].state + ptr->_stateTableIdx] = param4; sortCells(ovlIdx, objIdx, &cellHead); break; } case UNIQUE: return; case VARIABLE: { objectParams *ptr2 = &overlayTable[ovlIdx].ovlData->arrayObjVar[ptr->_varTableIdx]; switch (param3) { case 0: { // x ptr2->X = param4; break; } case 1: { // y ptr2->Y = param4; break; } case 2: { // z ptr2->Z = param4; sortCells(ovlIdx, objIdx, &cellHead); break; } case 3: { ptr2->frame = param4; break; } case 4: { // scale ptr2->scale = param4; break; } case 5: { // state ptr2->state = param4; break; } default: { assert(0); } } break; } default: { assert(0); } } }
int16 getMultipleObjectParam(int16 overlayIdx, int16 objectIdx, objectParamsQuery *returnParam) { objectParams *ptr2 = 0; objDataStruct *ptr; ovlDataStruct *ovlData; // int16 type; int state = 0; int state2 = 0; ptr = getObjectDataFromOverlay(overlayIdx, objectIdx); if (!ptr) return -11; ovlData = overlayTable[overlayIdx].ovlData; switch (ptr->_class) { case THEME: case MULTIPLE: { state = globalVars[overlayTable[overlayIdx].state + ptr->_stateTableIdx]; ptr2 = &ovlData->arrayStates[ptr->_firstStateIdx + state]; if (ptr->_firstStateIdx + state < 0) { debug(0, "Invalid Negative arrayState index in getMultipleObjectParam(overlayIdx: %d, objectIdx: %d)... Forcing to 0", overlayIdx, objectIdx); ptr2 = &ovlData->arrayStates[0]; } state2 = ptr2->state; break; } case VARIABLE: { ptr2 = &ovlData->arrayObjVar[ptr->_varTableIdx]; state = ptr2->state; state2 = state; if (ptr->_firstStateIdx + state < ovlData->size8) { objectParams *ptr3 = &ovlData->arrayStates[ptr->_firstStateIdx + state]; state2 = ptr3->state; } break; } default: { error("Unsupported case %d in getMultipleObjectParam", ptr->_class); } } returnParam->X = ptr2->X; returnParam->Y = ptr2->Y; returnParam->baseFileIdx = ptr2->Z; returnParam->fileIdx = ptr2->frame; returnParam->scale = ptr2->scale; returnParam->state = state; returnParam->state2 = state2; returnParam->nbState = ptr->_numStates; return 0; }
int getObjectClass(int overlayIdx, int objIdx) { objDataStruct *pObjectData = getObjectDataFromOverlay(overlayIdx, objIdx); if (pObjectData) { return pObjectData->_class; } else { return -11; } }
int16 objInit(int ovlIdx, int objIdx, int newState) { objDataStruct *ptr; // uint16 param; ovlDataStruct *ovlData; ptr = getObjectDataFromOverlay(ovlIdx, objIdx); if (!ptr) return -11; ovlData = overlayTable[ovlIdx].ovlData; switch (ptr->_class) { case THEME: case MULTIPLE: { globalVars[overlayTable[ovlIdx].state + ptr->_stateTableIdx] = newState; sortCells(ovlIdx, objIdx, &cellHead); break; } case UNIQUE: break; case VARIABLE: { objectParams *destEntry; objectParams *sourceEntry; if (ptr->_firstStateIdx + newState > ovlData->size8) { return 0; } destEntry = &ovlData->arrayObjVar[ptr->_varTableIdx]; sourceEntry = &ovlData->arrayStates[ptr->_firstStateIdx + newState]; memcpy(destEntry, sourceEntry, sizeof(objectParams)); destEntry->state = newState; sortCells(ovlIdx, objIdx, &cellHead); break; } default: { warning("Unsupported param = %d in objInit", ptr->_class); // exit(1); } } return 0; }
int16 getSingleObjectParam(int16 overlayIdx, int16 param2, int16 param3, int16 *returnParam) { int state = 0; //char* ptr3 = NULL; objDataStruct *ptr; ovlDataStruct *ovlData; objectParams *ptr2 = 0; ptr = getObjectDataFromOverlay(overlayIdx, param2); if (!ptr) return -11; ovlData = overlayTable[overlayIdx].ovlData; switch (ptr->_class) { case THEME: case MULTIPLE: { state = globalVars[overlayTable[overlayIdx].state + ptr->_stateTableIdx]; ptr2 = &ovlData->arrayStates[ptr->_firstStateIdx + state]; break; } case VARIABLE: { ptr2 = &ovlData->arrayObjVar[ptr->_varTableIdx]; state = ptr2->state; break; } default: { error("Unsupported case %d in getSingleObjectParam", ptr->_class); } } switch (param3) { case 0: { *returnParam = ptr2->X; break; } case 1: { *returnParam = ptr2->Y; break; } case 2: { *returnParam = ptr2->Z; break; } case 3: { *returnParam = ptr2->frame; break; } case 4: { *returnParam = ptr2->scale; break; } case 5: { *returnParam = state; break; } default: { error("Unsupported case %d in getSingleObjectParam case 1", param3); } } return 0; }
bool findRelation(int objOvl, int objIdx, int x, int y) { bool found = false; bool first = true; int testState = -1; int j; int16 objectState; getSingleObjectParam(objOvl, objIdx, 5, &objectState); for (j = 1; j < numOfLoadedOverlay; j++) { if (overlayTable[j].alreadyLoaded) { int idHeader = overlayTable[j].ovlData->numMsgRelHeader; for (int i = 0; i < idHeader; i++) { linkDataStruct* ptrHead = &overlayTable[j].ovlData->arrayMsgRelHeader[i]; int thisOvl = ptrHead->obj1Overlay; if (!thisOvl) { thisOvl = j; } //const char* pName = getObjectName(ptrHead->obj1Number, overlayTable[thisOvl].ovlData->arrayNameObj); objDataStruct* pObject = getObjectDataFromOverlay(thisOvl, ptrHead->obj1Number); if ((thisOvl == objOvl) && (objIdx == ptrHead->obj1Number) && pObject && (pObject->_class != THEME)) { int verbeOvl = ptrHead->verbOverlay; int obj1Ovl = ptrHead->obj1Overlay; int obj2Ovl = ptrHead->obj2Overlay; if (!verbeOvl) verbeOvl = j; if (!obj1Ovl) obj1Ovl = j; if (!obj2Ovl) obj2Ovl = j; char verbe_name[80]; char obj1_name[80]; char obj2_name[80]; char r_verbe_name[80]; char r_obj1_name[80]; char r_obj2_name[80]; verbe_name[0] = 0; obj1_name[0] = 0; obj2_name[0] = 0; r_verbe_name[0] = 0; r_obj1_name[0] = 0; r_obj2_name[0] = 0; ovlDataStruct *ovl2 = NULL; ovlDataStruct *ovl3 = NULL; ovlDataStruct *ovl4 = NULL; if (verbeOvl > 0) ovl2 = overlayTable[verbeOvl].ovlData; if (obj1Ovl > 0) ovl3 = overlayTable[obj1Ovl].ovlData; if (obj2Ovl > 0) ovl4 = overlayTable[obj2Ovl].ovlData; if ((ovl3) && (ptrHead->obj1Number >= 0)) { testState = ptrHead->obj1OldState; if ((first) && (ovl3->arrayNameObj) && ((testState == -1) || (testState == objectState))) { const char *ptrName = getObjectName(ptrHead->obj1Number, ovl3->arrayNameObj); menuTable[0] = createMenu(x, y, ptrName); first = false; } } if ((ovl2) && (ptrHead->verbNumber >= 0)) { if (ovl2->nameVerbGlob) { const char *ptr = getObjectName(ptrHead->verbNumber, ovl2->nameVerbGlob); strcpy(verbe_name, ptr); if ((!first) && ((testState == -1) || (testState == objectState))) { if (!strlen(verbe_name)) { if (currentScriptPtr) { attacheNewScriptToTail(&relHead, j, ptrHead->id, 30, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_REL); } else { attacheNewScriptToTail(&relHead, j, ptrHead->id, 30, 0, 0, scriptType_REL); } } else if (ovl2->nameVerbGlob) { found = true; ptr = getObjectName(ptrHead->verbNumber, ovl2->nameVerbGlob); addSelectableMenuEntry(j, i, menuTable[0], 1, -1, ptr); } } } } } } } } return found; }
bool createDialog(int objOvl, int objIdx, int x, int y) { bool found = false; int testState1 = -1; int testState2 = -1; int j; int16 objectState; int16 objectState2; getSingleObjectParam(objOvl, objIdx, 5, &objectState); menuTable[0] = createMenu(x, y, _vm->langString(ID_SPEAK_ABOUT)); for (j = 1; j < numOfLoadedOverlay; j++) { if (overlayTable[j].alreadyLoaded) { int idHeader = overlayTable[j].ovlData->numMsgRelHeader; for (int i = 0; i < idHeader; i++) { linkDataStruct* ptrHead = &overlayTable[j].ovlData->arrayMsgRelHeader[i]; int thisOvl = ptrHead->obj1Overlay; if (!thisOvl) { thisOvl = j; } objDataStruct* pObject = getObjectDataFromOverlay(thisOvl, ptrHead->obj1Number); getSingleObjectParam(thisOvl, ptrHead->obj1Number, 5, &objectState2); if (pObject && (pObject->_class == THEME) && (objectState2 < -1)) { thisOvl = ptrHead->obj2Overlay; if (!thisOvl) { thisOvl = j; } if ((thisOvl == objOvl) && (ptrHead->obj2Number == objIdx)) { int verbeOvl = ptrHead->verbOverlay; int obj1Ovl = ptrHead->obj1Overlay; int obj2Ovl = ptrHead->obj2Overlay; if (!verbeOvl) verbeOvl = j; if (!obj1Ovl) obj1Ovl = j; if (!obj2Ovl) obj2Ovl = j; char verbe_name[80]; char obj1_name[80]; char obj2_name[80]; char r_verbe_name[80]; char r_obj1_name[80]; char r_obj2_name[80]; verbe_name[0] = 0; obj1_name[0] = 0; obj2_name[0] = 0; r_verbe_name[0] = 0; r_obj1_name[0] = 0; r_obj2_name[0] = 0; ovlDataStruct *ovl2 = NULL; ovlDataStruct *ovl3 = NULL; ovlDataStruct *ovl4 = NULL; if (verbeOvl > 0) ovl2 = overlayTable[verbeOvl].ovlData; if (obj1Ovl > 0) ovl3 = overlayTable[obj1Ovl].ovlData; if (obj2Ovl > 0) ovl4 = overlayTable[obj2Ovl].ovlData; if ((ovl3) && (ptrHead->obj1Number >= 0)) { testState1 = ptrHead->obj1OldState; } if ((ovl4) && (ptrHead->obj2Number >= 0)) { testState2 = ptrHead->obj2OldState; } if ((ovl4) && (ptrHead->verbNumber >= 0) && ((testState1 == -1) || (testState1 == objectState2)) && ((testState2 == -1) || (testState2 == objectState))) { if (ovl2->nameVerbGlob) { const char *ptr = getObjectName(ptrHead->verbNumber, ovl2->nameVerbGlob); strcpy(verbe_name, ptr); if (!strlen(verbe_name)) attacheNewScriptToTail(&relHead, j, ptrHead->id, 30, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_REL); else if (ovl2->nameVerbGlob) { found = true; int color; if (objectState2 == -2) color = subColor; else color = -1; ptr = getObjectName(ptrHead->obj1Number, ovl3->arrayNameObj); addSelectableMenuEntry(j, i, menuTable[0], 1, color, ptr); } } } } } } } } return found; }