diff options
author | Max Horn | 2005-10-17 15:00:23 +0000 |
---|---|---|
committer | Max Horn | 2005-10-17 15:00:23 +0000 |
commit | bb8afe3839493eac79cb6cc747c0d46d41f183ab (patch) | |
tree | b700102b868350487cba3f8b1aa1f0e378906915 | |
parent | b4a4f779e3f45e5034f5985a5bc50d4dfb9b06f0 (diff) | |
download | scummvm-rg350-bb8afe3839493eac79cb6cc747c0d46d41f183ab.tar.gz scummvm-rg350-bb8afe3839493eac79cb6cc747c0d46d41f183ab.tar.bz2 scummvm-rg350-bb8afe3839493eac79cb6cc747c0d46d41f183ab.zip |
Added ResourceManager::isLocked; made ResourceManager::flags protected; moved some stuff around
svn-id: r19137
-rw-r--r-- | scumm/intern.h | 11 | ||||
-rw-r--r-- | scumm/object.cpp | 6 | ||||
-rw-r--r-- | scumm/resource.cpp | 17 | ||||
-rw-r--r-- | scumm/resource.h | 7 | ||||
-rw-r--r-- | scumm/saveload.cpp | 5 | ||||
-rw-r--r-- | scumm/scumm.h | 78 | ||||
-rw-r--r-- | scumm/string.cpp | 4 |
7 files changed, 74 insertions, 54 deletions
diff --git a/scumm/intern.h b/scumm/intern.h index 58e2700e8d..b2e53019c0 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -254,6 +254,12 @@ protected: const OpcodeEntryV2 *_opcodesV2; + struct V2MouseoverBox { + Common::Rect rect; + byte color; + byte hicolor; + }; + V2MouseoverBox _mouseOverBoxesV2[7]; int8 _mouseOverBoxV2; @@ -1319,6 +1325,11 @@ public: ScummEngine_v7(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16], int substResFileNameIndex); ~ScummEngine_v7(); + struct LangIndexNode { + char tag[12+1]; + int32 offset; + }; + bool _existLanguageFile; char *_languageBuffer; LangIndexNode *_languageIndex; diff --git a/scumm/object.cpp b/scumm/object.cpp index 0fb9895e65..394f2e2ca4 100644 --- a/scumm/object.cpp +++ b/scumm/object.cpp @@ -518,7 +518,7 @@ void ScummEngine::clearRoomObjects() { _objs[i].obj_nr = 0; } else { // Nuke all unlocked flObjects - if (!(res.flags[rtFlObject][_objs[i].fl_object_index] & RF_LOCK)) { + if (!res.isLocked(rtFlObject, _objs[i].fl_object_index)) { res.nukeResource(rtFlObject, _objs[i].fl_object_index); _objs[i].obj_nr = 0; _objs[i].fl_object_index = 0; @@ -1739,8 +1739,8 @@ void ScummEngine::loadFlObject(uint object, uint room) { // Lock room/roomScripts for the given room. They contains the OBCD/OBIM // data, and a call to createResource might expire them, hence we lock them. - isRoomLocked = ((res.flags[rtRoom][room] & RF_LOCK) != 0); - isRoomScriptsLocked = ((res.flags[rtRoomScripts][room] & RF_LOCK) != 0); + isRoomLocked = res.isLocked(rtRoom, room); + isRoomScriptsLocked = res.isLocked(rtRoomScripts, room); if (!isRoomLocked) res.lock(rtRoom, room); if (_version == 8 && !isRoomScriptsLocked) diff --git a/scumm/resource.cpp b/scumm/resource.cpp index 4ddc571c7a..4a08d7518b 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -37,6 +37,14 @@ namespace Scumm { +enum { + RF_LOCK = 0x80, + RF_USAGE = 0x7F, + RF_USAGE_MAX = RF_USAGE +}; + + + extern const char *resTypeFromId(int id); static uint16 newTag2Old(uint32 newTag); @@ -877,7 +885,8 @@ void ResourceManager::nukeResource(int type, int idx) { assert(idx >= 0 && idx < num[type]); - if ((ptr = address[type][idx]) != NULL) { + ptr = address[type][idx]; + if (ptr != NULL) { debugC(DEBUG_RESOURCE, "nukeResource(%s,%d)", resTypeFromId(type), idx); address[type][idx] = 0; flags[type][idx] = 0; @@ -923,6 +932,12 @@ void ResourceManager::unlock(int type, int i) { flags[type][i] &= ~RF_LOCK; } +bool ResourceManager::isLocked(int type, int i) const { + if (!validateResource("Unlocking", type, i)) + return false; + return (flags[type][i] & RF_LOCK) != 0; +} + bool ScummEngine::isResourceInUse(int type, int i) const { if (!res.validateResource("isResourceInUse", type, i)) return false; diff --git a/scumm/resource.h b/scumm/resource.h index 289494aa7c..e9aa8f6531 100644 --- a/scumm/resource.h +++ b/scumm/resource.h @@ -30,13 +30,6 @@ enum { OF_STATE_SHL = 4 }; -enum { - RF_LOCK = 0x80, - RF_USAGE = 0x7F, - RF_USAGE_MAX = RF_USAGE -}; - - class ResourceIterator { uint32 _size; uint32 _pos; diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp index 4e329e101e..935b03d05d 100644 --- a/scumm/saveload.cpp +++ b/scumm/saveload.cpp @@ -238,7 +238,6 @@ bool ScummEngine::loadState(int slot, bool compat) { if (i != rtTemp && i != rtBuffer && (i != rtSound || _saveSound || !compat)) for (j = 0; j < res.num[i]; j++) { res.nukeResource(i, j); - res.flags[i][j] = 0; } initScummVars(); @@ -1135,7 +1134,7 @@ void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) { if (s->isSaving()) { for (i = rtFirst; i <= rtLast; i++) for (j = 1; j < res.num[i]; j++) { - if (res.flags[i][j] & RF_LOCK) { + if (res.isLocked(i, j)) { s->saveByte(i); s->saveUint16(j); } @@ -1144,7 +1143,7 @@ void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) { } else { while ((i = s->loadByte()) != 0xFF) { j = s->loadUint16(); - res.flags[i][j] |= RF_LOCK; + res.lock(i, j); } } diff --git a/scumm/scumm.h b/scumm/scumm.h index b2e9177cab..c353612ed2 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -160,6 +160,13 @@ enum { DEBUG_SMUSH = 1 << 10 // Track SMUSH }; +/** + * Internal header for any memory block allocated by the resource manager. + * + * @todo Hide MemBlkHeader; no code outside the resource manager should + * have to use it, ever. Currently script code needs it to detect whether + * some scripts have moved (in fetchScriptByte()). + */ struct MemBlkHeader { uint32 size; }; @@ -167,38 +174,6 @@ struct MemBlkHeader { struct VerbSlot; struct ObjectData; -struct V2MouseoverBox { - Common::Rect rect; - byte color; - byte hicolor; -}; - -enum ResTypes { - rtFirst = 1, - rtRoom = 1, - rtScript = 2, - rtCostume = 3, - rtSound = 4, - rtInventory = 5, - rtCharset = 6, - rtString = 7, - rtVerb = 8, - rtActorName = 9, - rtBuffer = 10, - rtScaleTable = 11, - rtTemp = 12, - rtFlObject = 13, - rtMatrix = 14, - rtBox = 15, - rtObjectName = 16, - rtRoomScripts = 17, - rtRoomImage = 18, - rtImage = 19, - rtTalkie = 20, - rtLast = 20, - rtNumTypes = 21 -}; - enum { LIGHTMODE_dark = 0, LIGHTMODE_actor_base = 1, @@ -291,11 +266,6 @@ enum WhereIsObject { WIO_FLOBJECT = 4 }; -struct LangIndexNode { - char tag[12+1]; - int32 offset; -}; - struct AuxBlock { bool visible; Common::Rect r; @@ -312,12 +282,39 @@ struct AuxEntry { int subIndex; }; +// TODO: Rename InfoStuff to something more descriptive struct InfoStuff { uint32 date; uint16 time; uint32 playtime; }; +enum ResTypes { + rtFirst = 1, + rtRoom = 1, + rtScript = 2, + rtCostume = 3, + rtSound = 4, + rtInventory = 5, + rtCharset = 6, + rtString = 7, + rtVerb = 8, + rtActorName = 9, + rtBuffer = 10, + rtScaleTable = 11, + rtTemp = 12, + rtFlObject = 13, + rtMatrix = 14, + rtBox = 15, + rtObjectName = 16, + rtRoomScripts = 17, + rtRoomImage = 18, + rtImage = 19, + rtTalkie = 20, + rtLast = 20, + rtNumTypes = 21 +}; + class ResourceManager { friend class ScummDebugger; friend class ScummEngine; @@ -330,7 +327,9 @@ public: uint32 tags[rtNumTypes]; const char *name[rtNumTypes]; byte **address[rtNumTypes]; +protected: byte *flags[rtNumTypes]; +public: byte *roomno[rtNumTypes]; uint32 *roomoffs[rtNumTypes]; uint32 *globsize[rtNumTypes]; @@ -347,17 +346,20 @@ public: void freeResources(); - bool validateResource(const char *str, int type, int index) const; bool isResourceLoaded(int type, int index) const; void lock(int type, int i); void unlock(int type, int i); + bool isLocked(int type, int i) const; void setResourceCounter(int type, int index, byte flag); void increaseResourceCounter(); void resourceStats(); void expireResources(uint32 size); + +protected: + bool validateResource(const char *str, int type, int index) const; }; class ScummEngine : public Engine { diff --git a/scumm/string.cpp b/scumm/string.cpp index 3cd7777adf..539dfb1be1 100644 --- a/scumm/string.cpp +++ b/scumm/string.cpp @@ -860,8 +860,8 @@ void ScummEngine_v6::removeBlastTexts() { #ifndef DISABLE_SCUMM_7_8 int indexCompare(const void *p1, const void *p2) { - const LangIndexNode *i1 = (const LangIndexNode *) p1; - const LangIndexNode *i2 = (const LangIndexNode *) p2; + const ScummEngine_v7::LangIndexNode *i1 = (const ScummEngine_v7::LangIndexNode *) p1; + const ScummEngine_v7::LangIndexNode *i2 = (const ScummEngine_v7::LangIndexNode *) p2; return strcmp(i1->tag, i2->tag); } |