SCUMM: Refactor how resource (types) are srepresented
Previously, we had a couple of arrays of size N (where N = number of resource types), one for each attribute of a resource type (such as as the number of resources of that type. Now, we have one array of size N, whose elements are a record aggregating all the attributes of each resource type.
This commit is contained in:
parent
b37463fe59
commit
45e65d7ea0
16 changed files with 157 additions and 152 deletions
|
@ -390,26 +390,26 @@ void ScummEngine::getScriptBaseAddress() {
|
|||
break;
|
||||
_scriptOrgPointer = getResourceAddress(rtInventory, idx);
|
||||
assert(idx < _numInventory);
|
||||
_lastCodePtr = &_res->address[rtInventory][idx];
|
||||
_lastCodePtr = &_res->_types[rtInventory].address[idx];
|
||||
break;
|
||||
|
||||
case WIO_LOCAL:
|
||||
case WIO_ROOM: /* room script */
|
||||
if (_game.version == 8) {
|
||||
_scriptOrgPointer = getResourceAddress(rtRoomScripts, _roomResource);
|
||||
assert(_roomResource < _res->num[rtRoomScripts]);
|
||||
_lastCodePtr = &_res->address[rtRoomScripts][_roomResource];
|
||||
assert(_roomResource < _res->_types[rtRoomScripts].num);
|
||||
_lastCodePtr = &_res->_types[rtRoomScripts].address[_roomResource];
|
||||
} else {
|
||||
_scriptOrgPointer = getResourceAddress(rtRoom, _roomResource);
|
||||
assert(_roomResource < _numRooms);
|
||||
_lastCodePtr = &_res->address[rtRoom][_roomResource];
|
||||
_lastCodePtr = &_res->_types[rtRoom].address[_roomResource];
|
||||
}
|
||||
break;
|
||||
|
||||
case WIO_GLOBAL: /* global script */
|
||||
_scriptOrgPointer = getResourceAddress(rtScript, ss->number);
|
||||
assert(ss->number < _numScripts);
|
||||
_lastCodePtr = &_res->address[rtScript][ss->number];
|
||||
_lastCodePtr = &_res->_types[rtScript].address[ss->number];
|
||||
break;
|
||||
|
||||
case WIO_FLOBJECT: /* flobject script */
|
||||
|
@ -418,7 +418,7 @@ void ScummEngine::getScriptBaseAddress() {
|
|||
idx = _objs[idx].fl_object_index;
|
||||
_scriptOrgPointer = getResourceAddress(rtFlObject, idx);
|
||||
assert(idx < _numFlObject);
|
||||
_lastCodePtr = &_res->address[rtFlObject][idx];
|
||||
_lastCodePtr = &_res->_types[rtFlObject].address[idx];
|
||||
break;
|
||||
default:
|
||||
error("Bad type while getting base address");
|
||||
|
@ -1099,7 +1099,7 @@ void ScummEngine::checkAndRunSentenceScript() {
|
|||
// For now we assume that if there are more than 460 scripts, then
|
||||
// the pair 29/104 is used, else the pair 28/103.
|
||||
|
||||
if (_res->num[rtScript] > 460) {
|
||||
if (_res->_types[rtScript].num > 460) {
|
||||
if (sentenceScript == 104)
|
||||
sentenceScript = 29;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue