From 4e852a691b180e4a3d87b46fb6a780e6e7866351 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sat, 24 Oct 2015 20:25:48 +0200 Subject: TINSEL: DW1: Improve timbre file error message it now mentions all the possible file names. --- engines/tinsel/music.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/music.cpp b/engines/tinsel/music.cpp index 9b4e2494e0..2a9804263a 100644 --- a/engines/tinsel/music.cpp +++ b/engines/tinsel/music.cpp @@ -418,9 +418,12 @@ MidiMusicPlayer::MidiMusicPlayer(TinselEngine *vm) { // Version 2: drivers got installed and fat.opl got copied over by the user _driver = Audio::MidiDriver_Miles_AdLib_create("MIDPAK.AD", ""); } else { - // Version 1: sample.ad / sample.opl, have to be copied over by the user for this version - // That's why we check those last, because then the user gets a proper error message for them - _driver = Audio::MidiDriver_Miles_AdLib_create("SAMPLE.AD", "SAMPLE.OPL"); + if ((fileClass.exists("SAMPLE.AD")) || (fileClass.exists("SAMPLE.OPL"))) { + // Version 1: sample.ad / sample.opl, have to be copied over by the user for this version + _driver = Audio::MidiDriver_Miles_AdLib_create("SAMPLE.AD", "SAMPLE.OPL"); + } else { + error("MILES-ADLIB: timbre file not found (may be called FAT.OPL, MIDPAK.AD, SAMPLE.AD or SAMPLE.OPL, may be in a subdirectory)"); + } } } break; -- cgit v1.2.3 From bf4ab6d52af065b424ec29e1fb8205527af5a060 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 1 Dec 2015 21:48:14 -0500 Subject: TINSEL: Remove redundant assert check in SetHookScene In the original, a second SetHookScene call can validly occur due to first placing the cover-switched book in the bookcase, and then by the thief leaving if his arrival happens immediately. --- engines/tinsel/tinsel.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp index 6dc8e3bb35..77932a5cdf 100644 --- a/engines/tinsel/tinsel.cpp +++ b/engines/tinsel/tinsel.cpp @@ -528,8 +528,6 @@ void SetNewScene(SCNHANDLE scene, int entrance, int transition) { * Store a scene as hooked */ void SetHookScene(SCNHANDLE scene, int entrance, int transition) { - assert(g_HookScene.scene == 0); // scene already hooked - g_HookScene.scene = scene; g_HookScene.entry = entrance; g_HookScene.trans = transition; -- cgit v1.2.3 From d8045c67273faedd806c0e0f11801df2bb9ce4c6 Mon Sep 17 00:00:00 2001 From: Ori Avtalion Date: Thu, 7 Jan 2016 14:52:11 +0200 Subject: JANITORIAL: Fix clang printf warnings --- engines/tinsel/anim.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/anim.cpp b/engines/tinsel/anim.cpp index 19e180b57e..e241c7cba0 100644 --- a/engines/tinsel/anim.cpp +++ b/engines/tinsel/anim.cpp @@ -43,7 +43,7 @@ SCRIPTSTATE DoNextFrame(ANIM *pAnim) { while (1) { // repeat until a real image debugC(DEBUG_DETAILED, kTinselDebugAnimations, - "DoNextFrame %ph index=%d, op=%xh", (byte *)pAnim, pAnim->scriptIndex, + "DoNextFrame %ph index=%d, op=%xh", (const void *)pAnim, pAnim->scriptIndex, FROM_32(pAni[pAnim->scriptIndex].op)); switch ((int32)FROM_32(pAni[pAnim->scriptIndex].op)) { @@ -217,7 +217,7 @@ void InitStepAnimScript(ANIM *pAnim, OBJECT *pAniObj, SCNHANDLE hNewScript, int "InitStepAnimScript Object=(%d,%d,%xh) script=%xh aniSpeed=%d rec=%ph", !pAniObj ? 0 : fracToInt(pAniObj->xPos), !pAniObj ? 0 : fracToInt(pAniObj->yPos), - !pAniObj ? 0 : pAniObj->hImg, hNewScript, aniSpeed, (byte *)pAnim); + !pAniObj ? 0 : pAniObj->hImg, hNewScript, aniSpeed, (void *)pAnim); pAnim->aniDelta = 1; // will animate on next call to NextAnimRate pAnim->pObject = pAniObj; // set object to animate -- cgit v1.2.3 From c7695cc92977a3bedf36cfb73cf6376964ee4fe0 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 10 Jan 2016 02:22:26 +0100 Subject: TINSEL: Added detection for DW1 fan translation --- engines/tinsel/detection_tables.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'engines/tinsel') diff --git a/engines/tinsel/detection_tables.h b/engines/tinsel/detection_tables.h index a2ea67b3e6..6c1a3a39f4 100644 --- a/engines/tinsel/detection_tables.h +++ b/engines/tinsel/detection_tables.h @@ -556,6 +556,27 @@ static const TinselGameDescription gameDescriptions[] = { TINSEL_V1, }, + { // Russian Discworld 1. Fan translation v1.1 + { + "dw", + "CD v1.1", + { + {"dw.scn", 0, "133041bde59d05c1bf084fd6f1bdce4b", 776524}, + {"english.txt", 0, "317542cf2e50106d9c9421ddcf821e22", 221656}, + {"english.smp", 0, NULL, -1}, + {NULL, 0, NULL, 0} + }, + Common::RU_RUS, + Common::kPlatformDOS, + ADGF_CD, + GUIO1(GUIO_NOASPECT) + }, + GID_DW1, + 0, + GF_SCNFILES | GF_ENHANCED_AUDIO_SUPPORT, + TINSEL_V1, + }, + { // Polish fan translaction Discworld 1 { "dw", -- cgit v1.2.3 From 140d571f2297d7463323467573959c33ecaa11b2 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 26 Jan 2016 02:45:30 +0100 Subject: TINSEL: Only request actual save slots in listSaves. --- engines/tinsel/detection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/detection.cpp b/engines/tinsel/detection.cpp index c7a62dacad..7cb291275c 100644 --- a/engines/tinsel/detection.cpp +++ b/engines/tinsel/detection.cpp @@ -134,7 +134,7 @@ extern int getList(Common::SaveFileManager *saveFileMan, const Common::String &t SaveStateList TinselMetaEngine::listSaves(const char *target) const { Common::String pattern = target; - pattern = pattern + ".???"; + pattern = pattern + ".###"; Common::StringArray files = g_system->getSavefileManager()->listSavefiles(pattern); sort(files.begin(), files.end()); // Sort (hopefully ensuring we are sorted numerically..) -- cgit v1.2.3 From 9b7ab59fbb038394a61fad11b919c065db2d09b6 Mon Sep 17 00:00:00 2001 From: Marcus Comstedt Date: Sun, 7 Feb 2016 13:03:01 +0100 Subject: TINSEL: Fix crash when error() is called early --- engines/tinsel/tinsel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp index 77932a5cdf..2adddca4fd 100644 --- a/engines/tinsel/tinsel.cpp +++ b/engines/tinsel/tinsel.cpp @@ -820,7 +820,7 @@ const char *const TinselEngine::_textFiles[][3] = { TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _random("tinsel"), - _sound(0), _midiMusic(0), _pcmMusic(0), _bmv(0) { + _console(0), _sound(0), _midiMusic(0), _pcmMusic(0), _bmv(0) { _vm = this; _config = new Config(this); -- cgit v1.2.3 From 2a1b80fe187dd3e67fe02373aa0f1173bb45f467 Mon Sep 17 00:00:00 2001 From: Marcus Comstedt Date: Mon, 8 Feb 2016 21:24:56 +0100 Subject: TINSEL: Fix crash on big-endian hosts --- engines/tinsel/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/graphics.cpp b/engines/tinsel/graphics.cpp index 0282aff3cb..2ff96a9b64 100644 --- a/engines/tinsel/graphics.cpp +++ b/engines/tinsel/graphics.cpp @@ -164,7 +164,7 @@ static void t0WrtNonZero(DRAWOBJECT *pObj, uint8 *srcP, uint8 *destP, bool apply // Horizontal loop for (int x = 0; x < pObj->width; ) { - uint32 numBytes = READ_UINT32(srcP); + uint32 numBytes = READ_LE_UINT32(srcP); srcP += sizeof(uint32); bool repeatFlag = (numBytes & 0x80000000L) != 0; numBytes &= 0x7fffffff; -- cgit v1.2.3 From 1d8646ee015fbf34e5d9fcc7e5f4ff589762a830 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Tue, 9 Feb 2016 02:14:08 +0100 Subject: TINSEL: Enable Miles Audio for DW1+DW1CD Demo only DW1 floppy demo doesn't seem to have audio at all --- engines/tinsel/music.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/music.cpp b/engines/tinsel/music.cpp index 2a9804263a..e0c1f8d1f9 100644 --- a/engines/tinsel/music.cpp +++ b/engines/tinsel/music.cpp @@ -381,11 +381,25 @@ MidiMusicPlayer::MidiMusicPlayer(TinselEngine *vm) { bool milesAudioEnabled = false; if (vm->getPlatform() == Common::kPlatformDOS) { - // Enable Miles Audio for DOS only - milesAudioEnabled = true; + // Enable Miles Audio for DOS platform only... + switch (vm->getGameID()) { + case GID_DW1: + if (!vm->getIsADGFDemo()) { + // ...for Discworld 1 + milesAudioEnabled = true; + } else { + if (vm->isV1CD()) { + // ...and for Discworld 1 CD Demo + milesAudioEnabled = true; + } + } + break; + default: + break; + } } - if ((vm->getGameId() == GID_DW1) && (milesAudioEnabled)) { + if (milesAudioEnabled) { // Discworld 1 (DOS) uses Miles Audio 3 // use our own Miles Audio drivers // -- cgit v1.2.3 From cae26227a0a7a417f8183edb58e2cbd78b983f8d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 25 Feb 2016 19:55:14 +0100 Subject: TINSEL: Let listSaves return list sorted on slot numbers. --- engines/tinsel/detection.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/detection.cpp b/engines/tinsel/detection.cpp index 7cb291275c..0c7d0b0665 100644 --- a/engines/tinsel/detection.cpp +++ b/engines/tinsel/detection.cpp @@ -136,7 +136,6 @@ SaveStateList TinselMetaEngine::listSaves(const char *target) const { Common::String pattern = target; pattern = pattern + ".###"; Common::StringArray files = g_system->getSavefileManager()->listSavefiles(pattern); - sort(files.begin(), files.end()); // Sort (hopefully ensuring we are sorted numerically..) SaveStateList saveList; int slotNum = 0; @@ -160,6 +159,8 @@ SaveStateList TinselMetaEngine::listSaves(const char *target) const { } } + // Sort saves based on slot number. + Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator()); return saveList; } -- cgit v1.2.3 From 0b6befdcc5f5f8d6d5deb2831104fb7abc0f7466 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 8 Mar 2016 18:30:58 +0100 Subject: ENGINES: Make variable names of AdvancedMetaEngine conform to our guidelines. _singleid -> _singleId _gameids -> _gameIds _guioptions -> _guiOptions --- engines/tinsel/detection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/detection.cpp b/engines/tinsel/detection.cpp index 0c7d0b0665..cf40b0324c 100644 --- a/engines/tinsel/detection.cpp +++ b/engines/tinsel/detection.cpp @@ -85,7 +85,7 @@ static const PlainGameDescriptor tinselGames[] = { class TinselMetaEngine : public AdvancedMetaEngine { public: TinselMetaEngine() : AdvancedMetaEngine(Tinsel::gameDescriptions, sizeof(Tinsel::TinselGameDescription), tinselGames) { - _singleid = "tinsel"; + _singleId = "tinsel"; } virtual const char *getName() const { -- cgit v1.2.3 From 3aecd8ef2a79dbbd43dd0e39e42b11409720361f Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 8 Mar 2016 18:53:55 +0100 Subject: ENGINES: Make variable names of ADGameDescription conform to our guidelines. gameid -> gameId guioptions -> guiOptions --- engines/tinsel/detection.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/detection.cpp b/engines/tinsel/detection.cpp index cf40b0324c..2fde6e788a 100644 --- a/engines/tinsel/detection.cpp +++ b/engines/tinsel/detection.cpp @@ -228,8 +228,8 @@ const ADGameDescription *TinselMetaEngine::fallbackDetect(const FileMap &allFile // Check which files are included in some dw2 ADGameDescription *and* present // in fslist without a '1' suffix character. Compute MD5s and file sizes for these files. - for (g = &Tinsel::gameDescriptions[0]; g->desc.gameid != 0; ++g) { - if (strcmp(g->desc.gameid, "dw2") != 0) + for (g = &Tinsel::gameDescriptions[0]; g->desc.gameId != 0; ++g) { + if (strcmp(g->desc.gameId, "dw2") != 0) continue; for (fileDesc = g->desc.filesDescriptions; fileDesc->fileName; fileDesc++) { @@ -265,8 +265,8 @@ const ADGameDescription *TinselMetaEngine::fallbackDetect(const FileMap &allFile int maxFilesMatched = 0; // MD5 based matching - for (g = &Tinsel::gameDescriptions[0]; g->desc.gameid != 0; ++g) { - if (strcmp(g->desc.gameid, "dw2") != 0) + for (g = &Tinsel::gameDescriptions[0]; g->desc.gameId != 0; ++g) { + if (strcmp(g->desc.gameId, "dw2") != 0) continue; bool fileMissing = false; -- cgit v1.2.3 From fb6fe1332aaa9ab4d0ec0ad4ee8015ce4076bd85 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Tue, 29 Sep 2015 21:00:56 -0400 Subject: BACKENDS: Move to an openCD() without parameters as the public API --- engines/tinsel/tinsel.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp index 2adddca4fd..782dd7ae48 100644 --- a/engines/tinsel/tinsel.cpp +++ b/engines/tinsel/tinsel.cpp @@ -841,9 +841,7 @@ TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc) if (!scumm_stricmp(g->gameid, gameid)) _gameId = g->id; - int cd_num = ConfMan.getInt("cdrom"); - if (cd_num >= 0) - _system->getAudioCDManager()->openCD(cd_num); + _system->getAudioCDManager()->openCD(); _mousePos.x = 0; _mousePos.y = 0; -- cgit v1.2.3 From aa6ff444408bfd17bcca1d8364e86ce62da327ef Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Tue, 6 Oct 2015 22:10:34 -0400 Subject: BACKENDS: Only expose one set of functions for AudioCDManager Engines should only have to call one set of functions and not decide between the two. In fact, the 'emulation' API was documented to just call the 'real CD' API. --- engines/tinsel/tinsel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp index 782dd7ae48..1b733a08ba 100644 --- a/engines/tinsel/tinsel.cpp +++ b/engines/tinsel/tinsel.cpp @@ -841,7 +841,7 @@ TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc) if (!scumm_stricmp(g->gameid, gameid)) _gameId = g->id; - _system->getAudioCDManager()->openCD(); + _system->getAudioCDManager()->open(); _mousePos.x = 0; _mousePos.y = 0; @@ -973,7 +973,7 @@ Common::Error TinselEngine::run() { // Check for time to do next game cycle if ((g_system->getMillis() > timerVal + GAME_FRAME_DELAY)) { timerVal = g_system->getMillis(); - _system->getAudioCDManager()->updateCD(); + _system->getAudioCDManager()->update(); NextGameCycle(); } -- cgit v1.2.3 From 356403233047e260e34887ba0144892be322f472 Mon Sep 17 00:00:00 2001 From: Ori Avtalion Date: Thu, 14 Apr 2016 16:10:21 +0300 Subject: JANITORIAL: Reduce audio header dependencies --- engines/tinsel/bmv.cpp | 1 + engines/tinsel/bmv.h | 5 ++++- engines/tinsel/music.cpp | 1 - engines/tinsel/sound.cpp | 2 -- 4 files changed, 5 insertions(+), 4 deletions(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/bmv.cpp b/engines/tinsel/bmv.cpp index f28cd684f9..22c3798fc6 100644 --- a/engines/tinsel/bmv.cpp +++ b/engines/tinsel/bmv.cpp @@ -39,6 +39,7 @@ #include "tinsel/tinlib.h" #include "tinsel/tinsel.h" +#include "audio/audiostream.h" #include "audio/decoders/raw.h" #include "common/textconsole.h" diff --git a/engines/tinsel/bmv.h b/engines/tinsel/bmv.h index e52297f9de..888f910627 100644 --- a/engines/tinsel/bmv.h +++ b/engines/tinsel/bmv.h @@ -27,12 +27,15 @@ #include "common/coroutines.h" #include "common/file.h" -#include "audio/audiostream.h" #include "audio/mixer.h" #include "tinsel/object.h" #include "tinsel/palette.h" +namespace Audio { +class QueuingAudioStream; +} + namespace Tinsel { diff --git a/engines/tinsel/music.cpp b/engines/tinsel/music.cpp index e0c1f8d1f9..32d5abb865 100644 --- a/engines/tinsel/music.cpp +++ b/engines/tinsel/music.cpp @@ -29,7 +29,6 @@ #include "audio/midiparser.h" // Miles Audio for Discworld 1 #include "audio/miles.h" -#include "audio/decoders/adpcm.h" #include "backends/audiocd/audiocd.h" diff --git a/engines/tinsel/sound.cpp b/engines/tinsel/sound.cpp index 3d87a17331..a13e91fb3c 100644 --- a/engines/tinsel/sound.cpp +++ b/engines/tinsel/sound.cpp @@ -27,7 +27,6 @@ #include "tinsel/dw.h" #include "tinsel/config.h" #include "tinsel/music.h" -#include "tinsel/strres.h" #include "tinsel/tinsel.h" #include "tinsel/sysvar.h" #include "tinsel/background.h" @@ -37,7 +36,6 @@ #include "common/system.h" #include "audio/mixer.h" -#include "audio/decoders/adpcm.h" #include "audio/decoders/flac.h" #include "audio/decoders/mp3.h" #include "audio/decoders/raw.h" -- cgit v1.2.3 From ea5ac5e626324fbc28d4bd869ea5700c57c22ff6 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 9 May 2016 14:36:59 +0200 Subject: TINSEL: Fix number of buffer overruns --- engines/tinsel/dialogs.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp index a84dad942c..4bc28ffb53 100644 --- a/engines/tinsel/dialogs.cpp +++ b/engines/tinsel/dialogs.cpp @@ -3676,13 +3676,13 @@ extern void HideConversation(bool bHide) { ConstructInventory(FULL); else { // Move it all back on-screen - for (i = 0; g_objArray[i] && i < MAX_WCOMP; i++) { + for (i = 0; i < MAX_WCOMP && g_objArray[i]; i++) { MultiAdjustXY(g_objArray[i], -2 * SCREEN_WIDTH, 0); } // Don't flash if items changed. If they have, will be redrawn anyway. if (TinselV2 || !g_ItemsChanged) { - for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++) { + for (i = 0; i < MAX_ICONS && g_iconArray[i]; i++) { MultiAdjustXY(g_iconArray[i], -2*SCREEN_WIDTH, 0); } } @@ -3739,10 +3739,10 @@ extern void HideConversation(bool bHide) { deltay = g_InvD[INV_CONV].inventoryY - deltay; // Move it all - for (i = 0; g_objArray[i] && i < MAX_WCOMP; i++) { + for (i = 0; i < MAX_WCOMP && g_objArray[i]; i++) { MultiMoveRelXY(g_objArray[i], x - center, deltay); } - for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++) { + for (i = 0; i < MAX_ICONS && g_iconArray[i]; i++) { MultiMoveRelXY(g_iconArray[i], x - center, deltay); } g_InvD[INV_CONV].inventoryX += x - center; @@ -3771,10 +3771,10 @@ extern void HideConversation(bool bHide) { y = 0; if (x || y) { - for (i = 0; g_objArray[i] && i < MAX_WCOMP; i++) { + for (i = 0; i < MAX_WCOMP && g_objArray[i]; i++) { MultiMoveRelXY(g_objArray[i], x, y); } - for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++) { + for (i = 0; i < MAX_ICONS && g_iconArray[i]; i++) { MultiMoveRelXY(g_iconArray[i], x, y); } g_InvD[INV_CONV].inventoryX += x; @@ -3786,10 +3786,10 @@ extern void HideConversation(bool bHide) { */ if (MultiLowest(g_RectObject) > SCREEN_BOX_HEIGHT2 - SysVar(SV_CONV_MINY)) { y = (SCREEN_BOX_HEIGHT2 - SysVar(SV_CONV_MINY)) - MultiLowest(g_RectObject); - for (i = 0; g_objArray[i] && i < MAX_WCOMP; i++) { + for (i = 0; i < MAX_WCOMP && g_objArray[i]; i++) { MultiMoveRelXY(g_objArray[i], 0, y); } - for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++) { + for (i = 0; i < MAX_ICONS && g_iconArray[i]; i++) { MultiMoveRelXY(g_iconArray[i], 0, y); } g_InvD[INV_CONV].inventoryY += y; -- cgit v1.2.3 From a57aa559991dc47b0d3633b0a59ffff35358b236 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 11 May 2016 12:32:18 +0200 Subject: TINSEL: Safer string manipulation --- engines/tinsel/bmv.cpp | 4 ++-- engines/tinsel/detection.cpp | 4 ++-- engines/tinsel/dialogs.cpp | 6 +++--- engines/tinsel/handle.cpp | 2 +- engines/tinsel/saveload.cpp | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/bmv.cpp b/engines/tinsel/bmv.cpp index 22c3798fc6..cfe97e6ec1 100644 --- a/engines/tinsel/bmv.cpp +++ b/engines/tinsel/bmv.cpp @@ -567,8 +567,8 @@ void BMVPlayer::PlayBMV(CORO_PARAM, SCNHANDLE hFileStem, int myEscape) { assert(!bMovieOn); - strcpy(szMovieFile, (char *)LockMem(hFileStem)); - strcat(szMovieFile, BMOVIE_EXTENSION); + Common::strlcpy(szMovieFile, (char *)LockMem(hFileStem), 14); + Common::strlcat(szMovieFile, BMOVIE_EXTENSION, 14); assert(strlen(szMovieFile) <= 12); diff --git a/engines/tinsel/detection.cpp b/engines/tinsel/detection.cpp index 2fde6e788a..c44f1f4ef3 100644 --- a/engines/tinsel/detection.cpp +++ b/engines/tinsel/detection.cpp @@ -235,7 +235,7 @@ const ADGameDescription *TinselMetaEngine::fallbackDetect(const FileMap &allFile for (fileDesc = g->desc.filesDescriptions; fileDesc->fileName; fileDesc++) { // Get the next filename, stripping off any '1' suffix character char tempFilename[50]; - strcpy(tempFilename, fileDesc->fileName); + Common::strlcpy(tempFilename, fileDesc->fileName, 50); char *pOne = strchr(tempFilename, '1'); if (pOne) { do { @@ -275,7 +275,7 @@ const ADGameDescription *TinselMetaEngine::fallbackDetect(const FileMap &allFile for (fileDesc = g->desc.filesDescriptions; fileDesc->fileName; fileDesc++) { // Get the next filename, stripping off any '1' suffix character char tempFilename[50]; - strcpy(tempFilename, fileDesc->fileName); + Common::strlcpy(tempFilename, fileDesc->fileName, 50); char *pOne = strchr(tempFilename, '1'); if (pOne) { do { diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp index 4bc28ffb53..ad20253b9c 100644 --- a/engines/tinsel/dialogs.cpp +++ b/engines/tinsel/dialogs.cpp @@ -1671,10 +1671,10 @@ static void Select(int i, bool force) { #else // Current description with cursor appended if (cd.box[i].boxText != NULL) { - strcpy(g_sedit, cd.box[i].boxText); - strcat(g_sedit, sCursor); + Common::strlcpy(g_sedit, cd.box[i].boxText, SG_DESC_LEN+2); + Common::strlcat(g_sedit, sCursor, SG_DESC_LEN+2); } else { - strcpy(g_sedit, sCursor); + Common::strlcpy(g_sedit, sCursor, SG_DESC_LEN+2); } #endif diff --git a/engines/tinsel/handle.cpp b/engines/tinsel/handle.cpp index 62d244e449..9ffd477c4a 100644 --- a/engines/tinsel/handle.cpp +++ b/engines/tinsel/handle.cpp @@ -258,7 +258,7 @@ void LoadExtraGraphData(SCNHANDLE start, SCNHANDLE next) { } void SetCdPlaySceneDetails(int fileNum, const char *fileName) { - strcpy(g_szCdPlayFile, fileName); + Common::strlcpy(g_szCdPlayFile, fileName, 100); } void SetCdPlayHandle(int fileNum) { diff --git a/engines/tinsel/saveload.cpp b/engines/tinsel/saveload.cpp index 88cd80b78a..226cbb51c0 100644 --- a/engines/tinsel/saveload.cpp +++ b/engines/tinsel/saveload.cpp @@ -563,7 +563,7 @@ static void DoSave() { while (1) { Common::String fname = _vm->getSavegameFilename(ano); - strcpy(tmpName, fname.c_str()); + Common::strlcpy(tmpName, fname.c_str(), FNAMELEN); for (i = 0; i < g_numSfiles; i++) if (!strcmp(g_savedFiles[i].name, tmpName)) -- cgit v1.2.3 From 33abb6118f9551c6a4afc05ad35de6f630ccb152 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 17 May 2016 18:20:01 +0200 Subject: ALL: Change main engine header guard defines to __H Recently we started to use this as new semantics, although in the past we used simly _H. Now these guard defines are consistent with rest of the files which are used in the engines. --- engines/tinsel/tinsel.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/tinsel.h b/engines/tinsel/tinsel.h index c83bc80ead..9e4ce61b04 100644 --- a/engines/tinsel/tinsel.h +++ b/engines/tinsel/tinsel.h @@ -20,8 +20,8 @@ * */ -#ifndef TINSEL_H -#define TINSEL_H +#ifndef TINSEL_TINSEL_H +#define TINSEL_TINSEL_H #include "common/scummsys.h" #include "common/system.h" @@ -251,4 +251,4 @@ void CdHasChanged(); } // End of namespace Tinsel -#endif /* TINSEL_H */ +#endif /* TINSEL_TINSEL_H */ -- cgit v1.2.3 From 843694933dd8c0e31a8964910730f4ce9d6b3995 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 18 May 2016 12:37:56 +0200 Subject: TINSEL: Fix out-of-bounds array access --- engines/tinsel/dialogs.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/dialogs.cpp b/engines/tinsel/dialogs.cpp index ad20253b9c..b5d090ec15 100644 --- a/engines/tinsel/dialogs.cpp +++ b/engines/tinsel/dialogs.cpp @@ -4617,9 +4617,9 @@ extern void Xmovement(int x) { GetAniPosition(g_objArray[0], &g_InvD[g_ino].inventoryX, &aniY); g_InvD[g_ino].inventoryX +=x; MultiSetAniX(g_objArray[0], g_InvD[g_ino].inventoryX); - for (i = 1; g_objArray[i] && i < MAX_WCOMP; i++) + for (i = 1; i < MAX_WCOMP && g_objArray[i]; i++) MultiMoveRelXY(g_objArray[i], x, 0); - for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++) + for (i = 0; i < MAX_ICONS && g_iconArray[i]; i++) MultiMoveRelXY(g_iconArray[i], x, 0); break; @@ -4665,9 +4665,9 @@ extern void Ymovement(int y) { GetAniPosition(g_objArray[0], &aniX, &g_InvD[g_ino].inventoryY); g_InvD[g_ino].inventoryY +=y; MultiSetAniY(g_objArray[0], g_InvD[g_ino].inventoryY); - for (i = 1; g_objArray[i] && i < MAX_WCOMP; i++) + for (i = 1; i < MAX_WCOMP && g_objArray[i]; i++) MultiMoveRelXY(g_objArray[i], 0, y); - for (i = 0; g_iconArray[i] && i < MAX_ICONS; i++) + for (i = 0; i < MAX_ICONS && g_iconArray[i]; i++) MultiMoveRelXY(g_iconArray[i], 0, y); break; -- cgit v1.2.3 From cf42883f5e4820da34ece065e3dcec30ccd4e0c8 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 31 May 2016 13:29:33 +0200 Subject: TOON: Init memory before usage --- engines/tinsel/palette.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/tinsel') diff --git a/engines/tinsel/palette.cpp b/engines/tinsel/palette.cpp index 918894cf6f..495049d1a2 100644 --- a/engines/tinsel/palette.cpp +++ b/engines/tinsel/palette.cpp @@ -132,6 +132,8 @@ void PalettesToVideoDAC() { VIDEO_DAC_Q *pDACtail = g_vidDACdata; // set tail pointer byte pal[768]; + memset(pal, 0, sizeof(pal)); + // while Q is not empty while (g_pDAChead != pDACtail) { const PALETTE *pPalette; // pointer to hardware palette -- cgit v1.2.3 From 89890523c236681ebf32922d956587c9b44e270d Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 31 May 2016 13:32:04 +0200 Subject: TINSEL: Guard against illegal memory writes --- engines/tinsel/play.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines/tinsel') diff --git a/engines/tinsel/play.cpp b/engines/tinsel/play.cpp index ef3127233d..a4f5bc8261 100644 --- a/engines/tinsel/play.cpp +++ b/engines/tinsel/play.cpp @@ -159,6 +159,9 @@ static int RegisterSoundReel(SCNHANDLE hFilm, int column, int actorCol) { } } + if (i == MAX_SOUNDREELS) + error("Out of sound reels in RegisterSoundReel()"); + g_soundReelNumbers[i]++; return i; } -- cgit v1.2.3 From f225442ad00b4f6a9210731e33bbb5b8a9705ffa Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 31 May 2016 13:36:37 +0200 Subject: TINSEL: Fix illegal memory reads. In case of "unnamed" case (see line 582) we were memcpy'ing 31 byte from the heap. --- engines/tinsel/saveload.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/saveload.cpp b/engines/tinsel/saveload.cpp index 226cbb51c0..c8fe5f898c 100644 --- a/engines/tinsel/saveload.cpp +++ b/engines/tinsel/saveload.cpp @@ -594,8 +594,8 @@ static void DoSave() { hdr.id = SAVEGAME_ID; hdr.size = SAVEGAME_HEADER_SIZE; hdr.ver = CURRENT_VER; - memcpy(hdr.desc, g_SaveSceneDesc, SG_DESC_LEN); - hdr.desc[SG_DESC_LEN - 1] = 0; + memset(hdr.desc, 0, SG_DESC_LEN); + Common::strlcpy(hdr.desc, g_SaveSceneDesc, SG_DESC_LEN); g_system->getTimeAndDate(hdr.dateTime); hdr.scnFlag = _vm->getFeatures() & GF_SCNFILES; hdr.language = _vm->_config->_language; -- cgit v1.2.3 From 4dc60b525d4d7f36ce161e705a2752cd4ac142b4 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 17 Jun 2016 11:49:54 +0200 Subject: TINSEL: Fix class initialization --- engines/tinsel/music.cpp | 6 +++++- engines/tinsel/tinsel.cpp | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/music.cpp b/engines/tinsel/music.cpp index 32d5abb865..dc7ca67cfe 100644 --- a/engines/tinsel/music.cpp +++ b/engines/tinsel/music.cpp @@ -401,7 +401,7 @@ MidiMusicPlayer::MidiMusicPlayer(TinselEngine *vm) { if (milesAudioEnabled) { // Discworld 1 (DOS) uses Miles Audio 3 // use our own Miles Audio drivers - // + // // It seems that there are multiple versions of Discworld 1 // // Version 1: @@ -639,10 +639,14 @@ PCMMusicPlayer::PCMMusicPlayer() { _dimmed = false; _dimmedTinsel = false; _dimIteration = 0; + _dimmedVolume = 0; + _dimPosition = 0; _fadeOutVolume = 0; _fadeOutIteration = 0; + _hScript = _hSegment = 0; + _end = true; _vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp index 1b733a08ba..44e81494f7 100644 --- a/engines/tinsel/tinsel.cpp +++ b/engines/tinsel/tinsel.cpp @@ -823,6 +823,9 @@ TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc) _console(0), _sound(0), _midiMusic(0), _pcmMusic(0), _bmv(0) { _vm = this; + _gameId = 0; + _driver = NULL; + _config = new Config(this); // Register debug flags -- cgit v1.2.3