diff options
author | Max Horn | 2004-03-17 01:50:15 +0000 |
---|---|---|
committer | Max Horn | 2004-03-17 01:50:15 +0000 |
commit | faa12496e48b2eef79f92ae8e8ec69241cfd7d86 (patch) | |
tree | a319fe1df6df4609e987d73d1fb87abb94d64431 /scumm/object.cpp | |
parent | 93ef5161a52f8a0dc6f36439c6441f97c4187cd8 (diff) | |
download | scummvm-rg350-faa12496e48b2eef79f92ae8e8ec69241cfd7d86.tar.gz scummvm-rg350-faa12496e48b2eef79f92ae8e8ec69241cfd7d86.tar.bz2 scummvm-rg350-faa12496e48b2eef79f92ae8e8ec69241cfd7d86.zip |
Fix for bug #893254 (MI1VGA: Changes in object names are not saved); this may introduce regressions, please report them (overall, this is a neat patch, it removes so many ugly hacks :-)
svn-id: r13325
Diffstat (limited to 'scumm/object.cpp')
-rw-r--r-- | scumm/object.cpp | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/scumm/object.cpp b/scumm/object.cpp index 1c96e3c5b3..8a305a127b 100644 --- a/scumm/object.cpp +++ b/scumm/object.cpp @@ -892,13 +892,10 @@ const byte *ScummEngine::getObjOrActorName(int obj) { if (obj < _numActors) return derefActor(obj, "getObjOrActorName")->getActorName(); - if (_version >= 6) { - for (i = 0; i < _numNewNames; i++) { - if (_newNames[i] == obj) { - debug(5, "Found new name for object %d at _newNames[%d]", obj, i); - return getResourceAddress(rtObjectName, i); - break; - } + for (i = 0; i < _numNewNames; i++) { + if (_newNames[i] == obj) { + debug(5, "Found new name for object %d at _newNames[%d]", obj, i); + return getResourceAddress(rtObjectName, i); } } @@ -922,6 +919,41 @@ const byte *ScummEngine::getObjOrActorName(int obj) { return findResourceData(MKID('OBNA'), objptr); } +void ScummEngine::setObjectName(int obj) { + int i; + + if (obj < _numActors) + error("Can't set actor %d name with new-name-of", obj); + + const byte *objptr = getOBCDFromObject(obj); + if (_version <= 5 && !objptr) { + // WORKAROUND bug #587553 and possibly other related script bug. + // We do not error out but rather just generate a warning. + debug(2, "Can't find OBCD to rename object %d", obj); + return; + } else if (_version == 6 && !objptr) + error("Can't set name of object %d", obj); + + for (i = 0; i < _numNewNames; i++) { + if (_newNames[i] == obj) { + nukeResource(rtObjectName, i); + _newNames[i] = 0; + break; + } + } + + for (i = 0; i < _numNewNames; i++) { + if (_newNames[i] == 0) { + loadPtrToResource(rtObjectName, i, NULL); + _newNames[i] = obj; + runInventoryScript(0); + return; + } + } + + error("New name of %d overflows name table (max = %d)", obj, _numNewNames); +} + uint32 ScummEngine::getOBCDOffs(int object) const { int i; |