diff options
Diffstat (limited to 'engines/cine')
-rw-r--r-- | engines/cine/anim.cpp | 2 | ||||
-rw-r--r-- | engines/cine/bg.cpp | 4 | ||||
-rw-r--r-- | engines/cine/cine.cpp | 8 | ||||
-rw-r--r-- | engines/cine/gfx.cpp | 6 | ||||
-rw-r--r-- | engines/cine/pal.cpp | 4 | ||||
-rw-r--r-- | engines/cine/part.cpp | 2 | ||||
-rw-r--r-- | engines/cine/script_fw.cpp | 8 | ||||
-rw-r--r-- | engines/cine/sound.cpp | 2 | ||||
-rw-r--r-- | engines/cine/various.cpp | 114 | ||||
-rw-r--r-- | engines/cine/various.h | 2 |
10 files changed, 100 insertions, 52 deletions
diff --git a/engines/cine/anim.cpp b/engines/cine/anim.cpp index f47b33bf16..c6099447d8 100644 --- a/engines/cine/anim.cpp +++ b/engines/cine/anim.cpp @@ -287,7 +287,7 @@ void AnimData::load(byte *d, int type, uint16 w, uint16 h, int16 file, _fileIdx = file; _frameIdx = frame; memset(_name, 0, sizeof(_name)); - strcpy(_name, n); + Common::strlcpy(_name, n, sizeof(_name)); _realWidth = w; switch (type) { diff --git a/engines/cine/bg.cpp b/engines/cine/bg.cpp index 3b80a9c037..ce808e0f6a 100644 --- a/engines/cine/bg.cpp +++ b/engines/cine/bg.cpp @@ -48,7 +48,7 @@ byte loadCtFW(const char *ctName) { } if (currentCtName != ctName) - strcpy(currentCtName, ctName); + Common::strlcpy(currentCtName, ctName, sizeof(currentCtName)); ptr = dataPtr = readBundleFile(foundFileIdx); @@ -75,7 +75,7 @@ byte loadCtOS(const char *ctName) { } if (currentCtName != ctName) - strcpy(currentCtName, ctName); + Common::strlcpy(currentCtName, ctName, sizeof(currentCtName)); ptr = dataPtr = readBundleFile(foundFileIdx); diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp index 797bc38938..a4af8f2201 100644 --- a/engines/cine/cine.cpp +++ b/engines/cine/cine.cpp @@ -55,6 +55,14 @@ CineEngine::CineEngine(OSystem *syst, const CINEGameDescription *gameDesc) _console = new CineConsole(this); g_cine = this; + + for (int i = 0; i < NUM_FONT_CHARS; i++) { + _textHandler.fontParamTable[i].characterIdx = 0; + _textHandler.fontParamTable[i].characterWidth = 0; + } + _restartRequested = false; + _preLoad = false; + _timerDelayMultiplier = 12; } CineEngine::~CineEngine() { diff --git a/engines/cine/gfx.cpp b/engines/cine/gfx.cpp index ab83594054..f6419ecafc 100644 --- a/engines/cine/gfx.cpp +++ b/engines/cine/gfx.cpp @@ -730,7 +730,7 @@ void FWRenderer::loadBg16(const byte *bg, const char *name, unsigned int idx) { assert(_background); - strcpy(_bgName, name); + Common::strlcpy(_bgName, name, sizeof(_bgName)); // Load the 16 color palette _backupPal.load(bg, kLowPalNumBytes, kLowPalFormat, kLowPalNumColors, CINE_BIG_ENDIAN); @@ -1403,7 +1403,7 @@ void OSRenderer::loadBg16(const byte *bg, const char *name, unsigned int idx) { assert(_bgTable[idx].bg); - strcpy(_bgTable[idx].name, name); + Common::strlcpy(_bgTable[idx].name, name, sizeof(_bgTable[idx].name)); // Load the 16 color palette _bgTable[idx].pal.load(bg, kLowPalNumBytes, kLowPalFormat, kLowPalNumColors, CINE_BIG_ENDIAN); @@ -1441,7 +1441,7 @@ void OSRenderer::loadBg256(const byte *bg, const char *name, unsigned int idx) { assert(_bgTable[idx].bg); - strcpy(_bgTable[idx].name, name); + Common::strlcpy(_bgTable[idx].name, name, sizeof(_bgTable[idx].name)); _bgTable[idx].pal.load(bg, kHighPalNumBytes, kHighPalFormat, kHighPalNumColors, CINE_LITTLE_ENDIAN); memcpy(_bgTable[idx].bg, bg + kHighPalNumBytes, _screenSize); } diff --git a/engines/cine/pal.cpp b/engines/cine/pal.cpp index a1d9b49133..f3985c691e 100644 --- a/engines/cine/pal.cpp +++ b/engines/cine/pal.cpp @@ -62,9 +62,9 @@ int16 findPaletteFromName(const char *fileName) { uint16 position = 0; uint16 i; - strcpy(buffer, fileName); + Common::strlcpy(buffer, fileName, sizeof(buffer)); - while (position < strlen(fileName)) { + while (position < strlen(buffer)) { if (buffer[position] > 'a' && buffer[position] < 'z') { buffer[position] += 'A' - 'a'; } diff --git a/engines/cine/part.cpp b/engines/cine/part.cpp index c55972bf56..30d9461a6a 100644 --- a/engines/cine/part.cpp +++ b/engines/cine/part.cpp @@ -47,7 +47,7 @@ void loadPart(const char *partName) { g_cine->_partFileHandle.readUint16BE(); // entry size if (currentPartName != partName) - strcpy(currentPartName, partName); + Common::strlcpy(currentPartName, partName, sizeof(currentPartName)); for (uint16 i = 0; i < g_cine->_partBuffer.size(); i++) { g_cine->_partFileHandle.read(g_cine->_partBuffer[i].partName, 14); diff --git a/engines/cine/script_fw.cpp b/engines/cine/script_fw.cpp index c02868d5b0..c0b0c1f5da 100644 --- a/engines/cine/script_fw.cpp +++ b/engines/cine/script_fw.cpp @@ -1419,19 +1419,19 @@ int FWScript::o1_loadNewPrcName() { switch (param1) { case 0: debugC(5, kCineDebugScript, "Line: %d: loadPrc(\"%s\")", _line, param2); - strcpy(newPrcName, param2); + Common::strlcpy(newPrcName, param2, sizeof(newPrcName)); break; case 1: debugC(5, kCineDebugScript, "Line: %d: loadRel(\"%s\")", _line, param2); - strcpy(newRelName, param2); + Common::strlcpy(newRelName, param2, sizeof(newRelName)); break; case 2: debugC(5, kCineDebugScript, "Line: %d: loadObject(\"%s\")", _line, param2); - strcpy(newObjectName, param2); + Common::strlcpy(newObjectName, param2, sizeof(newObjectName)); break; case 3: debugC(5, kCineDebugScript, "Line: %d: loadMsg(\"%s\")", _line, param2); - strcpy(newMsgName, param2); + Common::strlcpy(newMsgName, param2, sizeof(newMsgName)); break; } return 0; diff --git a/engines/cine/sound.cpp b/engines/cine/sound.cpp index e2d9d22e6f..069a4787ac 100644 --- a/engines/cine/sound.cpp +++ b/engines/cine/sound.cpp @@ -813,7 +813,7 @@ bool PCSoundFxPlayer::load(const char *song) { if (dot) { *dot = '\0'; } - strcat(instrument, _driver->getInstrumentExtension()); + Common::strlcat(instrument, _driver->getInstrumentExtension(), sizeof(instrument)); uint32 instrumentSize; _instrumentsData[i] = readBundleSoundFile(instrument, &instrumentSize); if (!_instrumentsData[i]) { diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp index aa1c22c165..8687699a44 100644 --- a/engines/cine/various.cpp +++ b/engines/cine/various.cpp @@ -557,12 +557,20 @@ int16 selectSubObject(int16 x, int16 y, int16 param) { } } + if (selectedObject >= 20) + error("Invalid value for selectedObject: %d", selectedObject); return objListTab[selectedObject]; } -// TODO: Make separate functions for Future Wars's and Operation Stealth's version of this function, this is getting too messy -// TODO: Add support for using the different prepositions for different verbs (Doesn't work currently) void makeCommandLine() { + if (g_cine->getGameType() == Cine::GType_FW) + makeFWCommandLine(); + else + makeOSCommandLine(); +} + +// TODO: Add support for using the different prepositions for different verbs (Doesn't work currently) +void makeOSCommandLine() { uint16 x, y; commandVar1 = 0; @@ -578,28 +586,16 @@ void makeCommandLine() { int16 si; getMouseData(mouseUpdateStatus, &dummyU16, &x, &y); - - if (g_cine->getGameType() == Cine::GType_FW) { - si = selectSubObject(x, y + 8, -2); - } else { - si = selectSubObject(x, y + 8, -subObjectUseTable[playerCommand]); - } + si = selectSubObject(x, y + 8, -subObjectUseTable[playerCommand]); if (si < 0) { - if (g_cine->getGameType() == Cine::GType_OS) { - canUseOnObject = 0; - } else { // Future Wars - playerCommand = -1; - g_cine->_commandBuffer = ""; - } + canUseOnObject = 0; } else { - if (g_cine->getGameType() == Cine::GType_OS) { - if (si >= 8000) { - si -= 8000; - canUseOnObject = canUseOnItemTable[playerCommand]; - } else { - canUseOnObject = 0; - } + if (si >= 8000) { + si -= 8000; + canUseOnObject = canUseOnItemTable[playerCommand]; + } else { + canUseOnObject = 0; } commandVar3[0] = si; @@ -607,27 +603,21 @@ void makeCommandLine() { g_cine->_commandBuffer += " "; g_cine->_commandBuffer += g_cine->_objectTable[commandVar3[0]].name; g_cine->_commandBuffer += " "; - if (g_cine->getGameType() == Cine::GType_OS) { - g_cine->_commandBuffer += commandPrepositionTable[playerCommand]; - } else { // Future Wars - g_cine->_commandBuffer += defaultCommandPreposition; - } + g_cine->_commandBuffer += commandPrepositionTable[playerCommand]; } } - if (g_cine->getGameType() == Cine::GType_OS || !(playerCommand != -1 && choiceResultTable[playerCommand] == 2)) { - if (playerCommand == 2) { - getMouseData(mouseUpdateStatus, &dummyU16, &x, &y); - CursorMan.showMouse(false); - processInventory(x, y + 8); - playerCommand = -1; - commandVar1 = 0; - g_cine->_commandBuffer = ""; - CursorMan.showMouse(true); - } + if (playerCommand == 2) { + getMouseData(mouseUpdateStatus, &dummyU16, &x, &y); + CursorMan.showMouse(false); + processInventory(x, y + 8); + playerCommand = -1; + commandVar1 = 0; + g_cine->_commandBuffer = ""; + CursorMan.showMouse(true); } - if (g_cine->getGameType() == Cine::GType_OS && playerCommand != 2) { + if (playerCommand != 2) { if (playerCommand != -1 && canUseOnObject != 0) { // call use on sub object int16 si; @@ -665,7 +655,55 @@ void makeCommandLine() { } } - if (g_cine->getGameType() == Cine::GType_OS || !disableSystemMenu) { + isDrawCommandEnabled = 1; + renderer->setCommand(g_cine->_commandBuffer); +} + +// TODO: Add support for using the different prepositions for different verbs (Doesn't work currently) +void makeFWCommandLine() { + uint16 x, y; + + commandVar1 = 0; + commandVar2 = -10; + + if (playerCommand != -1) { + g_cine->_commandBuffer = defaultActionCommand[playerCommand]; + } else { + g_cine->_commandBuffer = ""; + } + + if ((playerCommand != -1) && (choiceResultTable[playerCommand] == 2)) { // need object selection? + int16 si; + + getMouseData(mouseUpdateStatus, &dummyU16, &x, &y); + si = selectSubObject(x, y + 8, -2); + + if (si < 0) { + playerCommand = -1; + g_cine->_commandBuffer = ""; + } else { + commandVar3[0] = si; + commandVar1 = 1; + g_cine->_commandBuffer += " "; + g_cine->_commandBuffer += g_cine->_objectTable[commandVar3[0]].name; + g_cine->_commandBuffer += " "; + g_cine->_commandBuffer += defaultCommandPreposition; + } + } + + if (!(playerCommand != -1 && choiceResultTable[playerCommand] == 2)) { + if (playerCommand == 2) { + getMouseData(mouseUpdateStatus, &dummyU16, &x, &y); + CursorMan.showMouse(false); + processInventory(x, y + 8); + playerCommand = -1; + commandVar1 = 0; + g_cine->_commandBuffer = ""; + CursorMan.showMouse(true); + } + } + + if (!disableSystemMenu) { isDrawCommandEnabled = 1; renderer->setCommand(g_cine->_commandBuffer); } diff --git a/engines/cine/various.h b/engines/cine/various.h index 04f2d47743..eb6312997d 100644 --- a/engines/cine/various.h +++ b/engines/cine/various.h @@ -37,6 +37,8 @@ void initLanguage(Common::Language lang); int16 makeMenuChoice(const CommandeType commandList[], uint16 height, uint16 X, uint16 Y, uint16 width, bool recheckValue = false); void makeCommandLine(); +void makeFWCommandLine(); +void makeOSCommandLine(); void makeActionMenu(); void waitPlayerInput(); void setTextWindow(uint16 param1, uint16 param2, uint16 param3, uint16 param4); |