diff options
Diffstat (limited to 'engines/cruise')
-rw-r--r-- | engines/cruise/cruise.h | 10 | ||||
-rw-r--r-- | engines/cruise/cruise_main.cpp | 44 | ||||
-rw-r--r-- | engines/cruise/detection.cpp | 53 | ||||
-rw-r--r-- | engines/cruise/mainDraw.cpp | 8 | ||||
-rw-r--r-- | engines/cruise/module.mk | 1 | ||||
-rw-r--r-- | engines/cruise/saveload.cpp | 7 | ||||
-rw-r--r-- | engines/cruise/script.cpp | 4 | ||||
-rw-r--r-- | engines/cruise/sound.cpp | 1 | ||||
-rw-r--r-- | engines/cruise/sound.h | 4 |
9 files changed, 59 insertions, 73 deletions
diff --git a/engines/cruise/cruise.h b/engines/cruise/cruise.h index 900f677975..94f8759d01 100644 --- a/engines/cruise/cruise.h +++ b/engines/cruise/cruise.h @@ -108,7 +108,15 @@ public: Common::RandomSource _rnd; - Common::List<byte *> _memList; + struct MemInfo { + int32 lineNum; + char fname[64]; + uint32 magic; + + static uint32 const cookie = 0x41424344; + }; + + Common::List<MemInfo*> _memList; typedef Common::List<Common::Rect> RectList; diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp index a97583c972..d0340238cd 100644 --- a/engines/cruise/cruise_main.cpp +++ b/engines/cruise/cruise_main.cpp @@ -40,19 +40,21 @@ unsigned int timer = 0; gfxEntryStruct* linkedMsgList = NULL; +typedef CruiseEngine::MemInfo MemInfo; + void MemoryList() { if (!_vm->_memList.empty()) { debug("Current list of un-freed memory blocks:"); - Common::List<byte *>::iterator i; + Common::List<MemInfo*>::iterator i; for (i = _vm->_memList.begin(); i != _vm->_memList.end(); ++i) { - byte *v = *i; - debug("%s - %d", (const char *)(v - 68), *((int32 *)(v - 72))); + MemInfo const *const v = *i; + debug("%s - %d", v->fname, v->lineNum); } } } void *MemoryAlloc(uint32 size, bool clearFlag, int32 lineNum, const char *fname) { - byte *result; + void *result; if (gDebugLevel > 0) { // Find the point after the final slash @@ -61,17 +63,17 @@ void *MemoryAlloc(uint32 size, bool clearFlag, int32 lineNum, const char *fname) --fnameP; // Create the new memory block and add it to the memory list - byte *v = (byte *)malloc(size + 64 + 8); - *((int32 *) v) = lineNum; - strncpy((char *)v + 4, fnameP, 63); - *((char *)v + 4 + 63) = '\0'; - *((uint32 *) (v + 68)) = 0x41424344; + MemInfo *const v = (MemInfo *)malloc(sizeof(MemInfo) + size); + v->lineNum = lineNum; + strncpy(v->fname, fnameP, sizeof(v->fname)); + v->fname[ARRAYSIZE(v->fname) - 1] = '\0'; + v->magic = MemInfo::cookie; // Add the block to the memory list - result = v + 64 + 8; - _vm->_memList.push_back(result); + _vm->_memList.push_back(v); + result = v + 1; } else - result = (byte *)malloc(size); + result = malloc(size); if (clearFlag) memset(result, 0, size); @@ -84,11 +86,11 @@ void MemoryFree(void *v) { return; if (gDebugLevel > 0) { - byte *p = (byte *)v; - assert(*((uint32 *) (p - 4)) == 0x41424344); + MemInfo *const p = (MemInfo *)v - 1; + assert(p->magic == MemInfo::cookie); _vm->_memList.remove(p); - free(p - 8 - 64); + free(p); } else free(v); } @@ -902,18 +904,8 @@ bool createDialog(int objOvl, int objIdx, int x, int y) { 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; @@ -1812,6 +1804,8 @@ void CruiseEngine::mainLoop() { bool skipEvents = false; do { + g_system->updateScreen(); + g_system->delayMillis(10); currentTick = g_system->getMillis(); diff --git a/engines/cruise/detection.cpp b/engines/cruise/detection.cpp index 5be2fdeeea..a482e263a2 100644 --- a/engines/cruise/detection.cpp +++ b/engines/cruise/detection.cpp @@ -66,8 +66,6 @@ static const PlainGameDescriptor cruiseGames[] = { namespace Cruise { -using Common::GUIO_NONE; - static const CRUISEGameDescription gameDescriptions[] = { { { @@ -77,7 +75,7 @@ static const CRUISEGameDescription gameDescriptions[] = { Common::EN_GRB, Common::kPlatformPC, ADGF_NO_FLAGS, - GUIO_NONE + GUIO1(GUIO_NONE) }, GType_CRUISE, 0, @@ -90,7 +88,7 @@ static const CRUISEGameDescription gameDescriptions[] = { Common::FR_FRA, Common::kPlatformPC, ADGF_NO_FLAGS, - GUIO_NONE + GUIO1(GUIO_NONE) }, GType_CRUISE, 0, @@ -103,7 +101,7 @@ static const CRUISEGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformPC, ADGF_NO_FLAGS, - GUIO_NONE + GUIO1(GUIO_NONE) }, GType_CRUISE, 0, @@ -116,7 +114,7 @@ static const CRUISEGameDescription gameDescriptions[] = { Common::FR_FRA, Common::kPlatformPC, ADGF_NO_FLAGS, - GUIO_NONE + GUIO1(GUIO_NONE) }, GType_CRUISE, 0, @@ -129,7 +127,7 @@ static const CRUISEGameDescription gameDescriptions[] = { Common::DE_DEU, Common::kPlatformPC, ADGF_NO_FLAGS, - GUIO_NONE + GUIO1(GUIO_NONE) }, GType_CRUISE, 0, @@ -142,7 +140,7 @@ static const CRUISEGameDescription gameDescriptions[] = { Common::DE_DEU, Common::kPlatformPC, ADGF_NO_FLAGS, - GUIO_NONE + GUIO1(GUIO_NONE) }, GType_CRUISE, 0, @@ -155,7 +153,7 @@ static const CRUISEGameDescription gameDescriptions[] = { Common::DE_DEU, Common::kPlatformAmiga, ADGF_NO_FLAGS, - GUIO_NONE + GUIO1(GUIO_NONE) }, GType_CRUISE, 0, @@ -168,7 +166,7 @@ static const CRUISEGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformAmiga, ADGF_NO_FLAGS, - GUIO_NONE + GUIO1(GUIO_NONE) }, GType_CRUISE, 0, @@ -181,7 +179,7 @@ static const CRUISEGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformAtariST, ADGF_NO_FLAGS, - GUIO_NONE + GUIO1(GUIO_NONE) }, GType_CRUISE, 0, @@ -194,7 +192,7 @@ static const CRUISEGameDescription gameDescriptions[] = { Common::IT_ITA, Common::kPlatformPC, ADGF_NO_FLAGS, - GUIO_NONE + GUIO1(GUIO_NONE) }, GType_CRUISE, 0, @@ -207,7 +205,7 @@ static const CRUISEGameDescription gameDescriptions[] = { Common::ES_ESP, Common::kPlatformPC, ADGF_NO_FLAGS, - GUIO_NONE + GUIO1(GUIO_NONE) }, GType_CRUISE, 0, @@ -221,7 +219,7 @@ class CruiseMetaEngine : public AdvancedMetaEngine { public: CruiseMetaEngine() : AdvancedMetaEngine(Cruise::gameDescriptions, sizeof(Cruise::CRUISEGameDescription), cruiseGames) { _singleid = "cruise"; - _guioptions = Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI; + _guioptions = GUIO2(GUIO_NOSPEECH, GUIO_NOMIDI); } virtual const char *getName() const { @@ -284,19 +282,22 @@ void CruiseMetaEngine::removeSaveState(const char *target, int slot) const { SaveStateDescriptor CruiseMetaEngine::querySaveMetaInfos(const char *target, int slot) const { Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading( Cruise::CruiseEngine::getSavegameFile(slot)); - assert(f); - - Cruise::CruiseSavegameHeader header; - Cruise::readSavegameHeader(f, header); - delete f; - - // Create the return descriptor - SaveStateDescriptor desc(slot, header.saveName); - desc.setDeletableFlag(true); - desc.setWriteProtectedFlag(false); - desc.setThumbnail(header.thumbnail); + + if (f) { + Cruise::CruiseSavegameHeader header; + Cruise::readSavegameHeader(f, header); + delete f; + + // Create the return descriptor + SaveStateDescriptor desc(slot, header.saveName); + desc.setDeletableFlag(true); + desc.setWriteProtectedFlag(false); + desc.setThumbnail(header.thumbnail); + + return desc; + } - return desc; + return SaveStateDescriptor(); } bool CruiseMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { diff --git a/engines/cruise/mainDraw.cpp b/engines/cruise/mainDraw.cpp index 814d0aa9e9..14b6daf4bb 100644 --- a/engines/cruise/mainDraw.cpp +++ b/engines/cruise/mainDraw.cpp @@ -440,7 +440,6 @@ void buildSegment() { // is segment on screen ? if (!((tempAX > 199) || (tempDX < 0))) { - int dx = Y1; int cx = X2 - X1; if (cx == 0) { // vertical line @@ -473,7 +472,6 @@ void buildSegment() { } else { if (cx < 0) { cx = -cx; - dx = Y2; SWAP(X1, X2); SWAP(Y1, Y2); @@ -1490,9 +1488,6 @@ void mainDraw(int16 param) { if (currentObjPtr->animLoop > 0) currentObjPtr->animLoop--; } else { - int16 data2; - data2 = currentObjPtr->animStart; - change = false; currentObjPtr->animStep = 0; @@ -1512,9 +1507,6 @@ void mainDraw(int16 param) { if (currentObjPtr->animLoop > 0) currentObjPtr->animLoop--; } else { - int16 data2; - data2 = currentObjPtr->animStart; - change = false; currentObjPtr->animStep = 0; diff --git a/engines/cruise/module.mk b/engines/cruise/module.mk index 5c36b2a7c1..ae07d20956 100644 --- a/engines/cruise/module.mk +++ b/engines/cruise/module.mk @@ -40,4 +40,3 @@ endif # Include common rules include $(srcdir)/rules.mk - diff --git a/engines/cruise/saveload.cpp b/engines/cruise/saveload.cpp index 6392009373..c3d1ea6643 100644 --- a/engines/cruise/saveload.cpp +++ b/engines/cruise/saveload.cpp @@ -62,12 +62,9 @@ bool readSavegameHeader(Common::InSaveFile *in, CruiseSavegameHeader &header) { while ((ch = (char)in->readByte()) != '\0') header.saveName += ch; // Get the thumbnail - header.thumbnail = new Graphics::Surface(); - if (!Graphics::loadThumbnail(*in, *header.thumbnail)) { - delete header.thumbnail; - header.thumbnail = NULL; + header.thumbnail = Graphics::loadThumbnail(*in); + if (!header.thumbnail) return false; - } return true; } diff --git a/engines/cruise/script.cpp b/engines/cruise/script.cpp index 4e76194a45..cf28548e7d 100644 --- a/engines/cruise/script.cpp +++ b/engines/cruise/script.cpp @@ -231,9 +231,7 @@ int32 opcodeType2() { int type = getByteFromScript(); int overlay = getByteFromScript(); - int firstOffset; - int offset; - firstOffset = offset = getShortFromScript(); + int offset = getShortFromScript(); offset += index; int typ7 = type & 7; diff --git a/engines/cruise/sound.cpp b/engines/cruise/sound.cpp index 290cc220d4..21d9a75297 100644 --- a/engines/cruise/sound.cpp +++ b/engines/cruise/sound.cpp @@ -31,6 +31,7 @@ #include "audio/audiostream.h" #include "audio/fmopl.h" +#include "audio/mixer.h" #include "audio/mods/soundfx.h" namespace Cruise { diff --git a/engines/cruise/sound.h b/engines/cruise/sound.h index 11aec0b04e..c1975dc579 100644 --- a/engines/cruise/sound.h +++ b/engines/cruise/sound.h @@ -23,10 +23,6 @@ #ifndef CRUISE_SOUND_H #define CRUISE_SOUND_H -#include "audio/mididrv.h" -#include "audio/midiparser.h" -#include "audio/mixer.h" - #include "common/config-manager.h" #include "common/serializer.h" |