SAGA2: Rename class variables in tile.h

This commit is contained in:
Eugene Sandulenko 2022-09-27 17:24:21 +02:00
parent 9d393ffc61
commit 5b7b40af0b
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
3 changed files with 264 additions and 265 deletions

View File

@ -3425,11 +3425,11 @@ int16 scriptFindMission(int16 *args) {
int16 scriptSetTileCycleSpeed(int16 *args) {
MONOLOG(SetTileCycleSpeed);
extern CyclePtr cycleList; // list of tile cycling info
extern CyclePtr _cycleList; // list of tile cycling info
TileCycleData &tcd = cycleList[args[0]];
TileCycleData &tcd = _cycleList[args[0]];
tcd.cycleSpeed = args[1];
tcd._cycleSpeed = args[1];
return 0;
}
@ -3440,12 +3440,12 @@ int16 scriptSetTileCycleSpeed(int16 *args) {
int16 scriptSetTileCycleState(int16 *args) {
MONOLOG(SetTileCycleState);
extern CyclePtr cycleList; // list of tile cycling info
extern CyclePtr _cycleList; // list of tile cycling info
TileCycleData &tcd = cycleList[args[0]];
TileCycleData &tcd = _cycleList[args[0]];
tcd.currentState = args[1];
tcd.counter = 0;
tcd._currentState = args[1];
tcd._counter = 0;
return 0;
}

View File

@ -163,7 +163,7 @@ extern ObjectID viewCenterObject; // ID of object that view tracks
Tile structure management
* ===================================================================== */
int16 cycleCount;
int16 _cycleCount;
uint16 rippedRoofID;
@ -176,7 +176,7 @@ WorldMapData *mapList; // master map data array
byte **stateArray; // Array of active item instance
// state arrays
CyclePtr cycleList; // list of tile cycling info
CyclePtr _cycleList; // list of tile cycling info
// Platform caching management
PlatformCacheEntry *platformCache;
@ -224,9 +224,9 @@ TileInfo *TileInfo::tileAddress(TileID id) {
ti = tbh->tile(tileNum);
if (ti->attrs.cycleRange > 0) {
TileCycleData &tcd = cycleList[ti->attrs.cycleRange - 1];
TileCycleData &tcd = _cycleList[ti->attrs.cycleRange - 1];
TileID2Bank(tcd.cycleList[tcd.currentState],
TileID2Bank(tcd._cycleList[tcd._currentState],
tileBank,
tileNum);
@ -256,9 +256,9 @@ TileInfo *TileInfo::tileAddress(TileID id, uint8 **imageData) {
ti = tbh->tile(tileNum);
if (ti->attrs.cycleRange > 0) {
TileCycleData &tcd = cycleList[ti->attrs.cycleRange - 1];
TileCycleData &tcd = _cycleList[ti->attrs.cycleRange - 1];
TileID2Bank(tcd.cycleList[tcd.currentState],
TileID2Bank(tcd._cycleList[tcd._currentState],
tileBank,
tileNum);
@ -285,19 +285,19 @@ TileInfo *TileInfo::tileAddress(TileID id, uint8 **imageData) {
// Return the map number of this active item
int16 ActiveItem::getMapNum() {
int16 mapNum;
int16 _mapNum;
// Use a brute force search of all of the maps' active item lists
// to determine which map this active item is on.
for (mapNum = 0; mapNum < worldCount; mapNum++) {
WorldMapData *mapData = &mapList[mapNum];
for (_mapNum = 0; _mapNum < worldCount; _mapNum++) {
WorldMapData *mapData = &mapList[_mapNum];
// Determine if the active item in on this map's list
if (_parent == mapData->activeItemList)
break;
}
return mapNum;
return _mapNum;
}
//-----------------------------------------------------------------------
@ -336,16 +336,16 @@ ActiveItem *ActiveItem::activeItemAddress(ActiveItemID id) {
// Return this active item's ID
ActiveItemID ActiveItem::thisID() {
int16 mapNum = getMapNum();
int16 _mapNum = getMapNum();
return ActiveItemID(mapNum, _index);
return ActiveItemID(_mapNum, _index);
}
//-----------------------------------------------------------------------
// Return this active item's ID
ActiveItemID ActiveItem::thisID(int16 mapNum) {
return ActiveItemID(mapNum, _index);
ActiveItemID ActiveItem::thisID(int16 _mapNum) {
return ActiveItemID(_mapNum, _index);
}
//-----------------------------------------------------------------------
@ -427,8 +427,8 @@ void ActiveItem::playTAGNoise(ActiveItem *ai, int16 tagNoiseID) {
// use() function for ActiveItem group
bool ActiveItem::use(ActiveItem *ins, ObjectID enactor) {
int16 mapNum = getMapNum();
uint16 state = ins->getInstanceState(mapNum);
int16 _mapNum = getMapNum();
uint16 state = ins->getInstanceState(_mapNum);
scriptCallFrame scf;
if (ins->_data.scriptClassID != 0) {
@ -458,7 +458,7 @@ bool ActiveItem::use(ActiveItem *ins, ObjectID enactor) {
switch (ins->builtInBehavior()) {
case builtInLamp:
ins->setInstanceState(mapNum, !state);
ins->setInstanceState(_mapNum, !state);
break;
case builtInDoor:
@ -716,7 +716,7 @@ TilePoint getClosestPointOnTAI(ActiveItem *TAI, GameObject *obj) {
TileRegion TAIReg;
ActiveItem *TAG = TAI->getGroup();
// Compute in points the region of the TAI
// Compute in points the _region of the TAI
TAIReg.min.u = TAI->_data.instance.u << kTileUVShift;
TAIReg.min.v = TAI->_data.instance.v << kTileUVShift;
TAIReg.max.u = TAIReg.min.u
@ -915,7 +915,7 @@ void TileActivityTaskList::read(Common::InSaveFile *in) {
tat = newTask(tai);
if (tat != nullptr)
tat->activityType = activityType;
tat->_activityType = activityType;
}
}
}
@ -928,15 +928,15 @@ void TileActivityTaskList::write(Common::MemoryWriteStreamDynamic *out) {
debugC(3, kDebugSaveload, "... taskCount = %d", taskCount);
for (Common::List<TileActivityTask *>::iterator it = _list.begin(); it != _list.end(); ++it) {
ActiveItem *ai = (*it)->tai;
ActiveItem *ai = (*it)->_tai;
// Store the activeItemID
out->writeSint16LE(ai->thisID().val);
debugC(4, kDebugSaveload, "...... activeItemID = %d", ai->thisID().val);
// Store the task type
out->writeByte((*it)->activityType);
debugC(4, kDebugSaveload, "...... activityType = %d", (*it)->activityType);
out->writeByte((*it)->_activityType);
debugC(4, kDebugSaveload, "...... _activityType = %d", (*it)->_activityType);
}
}
@ -960,7 +960,7 @@ TileActivityTask *TileActivityTaskList::newTask(ActiveItem *activeInstance) {
// Check see if there's already tile activity task associated with
// this instance.
for (Common::List<TileActivityTask *>::iterator it = _list.begin(); it != _list.end(); ++it)
if ((*it)->tai == activeInstance) {
if ((*it)->_tai == activeInstance) {
tat = *it;
break;
}
@ -973,20 +973,20 @@ TileActivityTask *TileActivityTaskList::newTask(ActiveItem *activeInstance) {
tat = new TileActivityTask;
tat->tai = activeInstance;
tat->activityType = TileActivityTask::activityTypeNone;
tat->script = NoThread;
tat->targetState = 0;
tat->_tai = activeInstance;
tat->_activityType = TileActivityTask::activityTypeNone;
tat->_script = NoThread;
tat->_targetState = 0;
_list.push_back(tat);
}
// If we re-used an old task struct, then make sure script gets woken up.
if (tat->script != NoThread) {
if (tat->_script != NoThread) {
debugC(3, kDebugTasks, "Waking up thread TAT");
wakeUpThread(tat->script);
tat->script = NoThread;
wakeUpThread(tat->_script);
tat->_script = NoThread;
}
return tat;
@ -1013,7 +1013,7 @@ void TileActivityTask::openDoor(ActiveItem &activeInstance) {
TileActivityTask *tat;
if ((tat = g_vm->_aTaskList->newTask(&activeInstance)) != nullptr)
tat->activityType = activityTypeOpen;
tat->_activityType = activityTypeOpen;
}
//-----------------------------------------------------------------------
@ -1024,7 +1024,7 @@ void TileActivityTask::closeDoor(ActiveItem &activeInstance) {
TileActivityTask *tat;
if ((tat = g_vm->_aTaskList->newTask(&activeInstance)) != nullptr)
tat->activityType = activityTypeClose;
tat->_activityType = activityTypeClose;
}
//-----------------------------------------------------------------------
@ -1038,9 +1038,9 @@ void TileActivityTask::doScript(ActiveItem &activeInstance, uint8 finalState, Th
if (scr)
debugC(3, kDebugTasks, "TAT Assign Script!");
tat->activityType = activityTypeScript;
tat->targetState = finalState;
tat->script = scr;
tat->_activityType = activityTypeScript;
tat->_targetState = finalState;
tat->_script = scr;
} else {
debugC(3, kDebugTasks, "Waking up thread 'cause newTask Failed");
@ -1056,38 +1056,38 @@ void TileActivityTask::updateActiveItems() {
for (Common::List<TileActivityTask *>::iterator it = g_vm->_aTaskList->_list.begin(); it != g_vm->_aTaskList->_list.end();) {
TileActivityTask *tat = *it;
ActiveItem *activityInstance = tat->tai;
ActiveItem *activityInstance = tat->_tai;
bool activityTaskDone = false;
int16 mapNum = activityInstance->getMapNum();
uint16 state = activityInstance->getInstanceState(mapNum);
int16 _mapNum = activityInstance->getMapNum();
uint16 state = activityInstance->getInstanceState(_mapNum);
// collecting stats
count++;
if (tat->script != NoThread)
if (tat->_script != NoThread)
scriptCount++;
switch (tat->activityType) {
switch (tat->_activityType) {
case activityTypeOpen:
if (state < 3)
activityInstance->setInstanceState(mapNum, state + 1);
activityInstance->setInstanceState(_mapNum, state + 1);
else
activityTaskDone = true;
break;
case activityTypeClose:
if (state > 0)
activityInstance->setInstanceState(mapNum, state - 1);
activityInstance->setInstanceState(_mapNum, state - 1);
else
activityTaskDone = true;
break;
case activityTypeScript:
if (state > tat->targetState)
activityInstance->setInstanceState(mapNum, state - 1);
else if (state < tat->targetState)
activityInstance->setInstanceState(mapNum, state + 1);
if (state > tat->_targetState)
activityInstance->setInstanceState(_mapNum, state - 1);
else if (state < tat->_targetState)
activityInstance->setInstanceState(_mapNum, state + 1);
else
activityTaskDone = true;
break;
@ -1101,10 +1101,10 @@ void TileActivityTask::updateActiveItems() {
if (activityTaskDone) {
// Wake up the script...
if (tat->script != NoThread) {
if (tat->_script != NoThread) {
debugC(3, kDebugTasks, "TAT Wake Up Thread");
wakeUpThread(tat->script);
wakeUpThread(tat->_script);
}
tat->remove();
}
@ -1118,7 +1118,7 @@ void TileActivityTask::updateActiveItems() {
TileActivityTask *TileActivityTask::find(ActiveItem *tai) {
for (Common::List<TileActivityTask *>::iterator it = g_vm->_aTaskList->_list.begin(); it != g_vm->_aTaskList->_list.end(); ++it) {
if (tai == (*it)->tai)
if (tai == (*it)->_tai)
return *it;
}
@ -1134,12 +1134,12 @@ bool TileActivityTask::setWait(ActiveItem *tai, ThreadID script) {
debugC(3, kDebugTasks, "Set Wait TAT\n");
if (tat) {
if (tat->script != NoThread) {
if (tat->_script != NoThread) {
debugC(3, kDebugTasks, "TAT Waking Up Thread\n");
wakeUpThread(tat->script);
wakeUpThread(tat->_script);
}
tat->script = script;
tat->_script = script;
return true;
}
@ -1509,12 +1509,12 @@ void cleanupMaps() {
//-----------------------------------------------------------------------
// Set a new current map
void setCurrentMap(int mapNum) {
g_vm->_currentMapNum = mapNum;
void setCurrentMap(int _mapNum) {
g_vm->_currentMapNum = _mapNum;
if (lastMapNum != g_vm->_currentMapNum) {
lastMapNum = g_vm->_currentMapNum;
freeAllTileBanks();
audioEnvironmentSetWorld(mapNum);
audioEnvironmentSetWorld(_mapNum);
}
lastUpdateTime = gameTime;
@ -1766,7 +1766,7 @@ int16 ptHeight(const TilePoint &tp, uint8 *cornerHeight) {
// REM: This is a likely candidate for downcoding...
TileInfo *Platform::fetchTile(
int16 mapNum,
int16 _mapNum,
const TilePoint &pt,
const TilePoint &origin,
int16 &height_,
@ -1784,7 +1784,7 @@ TileInfo *Platform::fetchTile(
absPos;
groupItem = ActiveItem::activeItemAddress(
ActiveItemID(mapNum, tr->tile));
ActiveItemID(_mapNum, tr->tile));
// Relpos is the relative position of the
// tile within the group
@ -1800,14 +1800,14 @@ TileInfo *Platform::fetchTile(
absPos.z = h;
// Look up the group instance in the hash.
instanceItem = mapList[mapNum].findHashedInstance(
instanceItem = mapList[_mapNum].findHashedInstance(
absPos,
tr->tile);
if (instanceItem) {
state = instanceItem->getInstanceState(mapNum);
state = instanceItem->getInstanceState(_mapNum);
// Get the tile to be drawn from the tile group
tr = &(mapList[mapNum].activeItemData)[
tr = &(mapList[_mapNum].activeItemData)[
groupItem->_data.group.grDataOffset
+ state * groupItem->_data.group.animArea
+ relPos.u * groupItem->_data.group.vSize
@ -1848,7 +1848,7 @@ TileInfo *Platform::fetchTile(
// REM: This is a likely candidate for downcoding...
TileInfo *Platform::fetchTAGInstance(
int16 mapNum,
int16 _mapNum,
const TilePoint &pt,
const TilePoint &origin,
StandingTileInfo &sti) {
@ -1865,7 +1865,7 @@ TileInfo *Platform::fetchTAGInstance(
absPos;
groupItem = ActiveItem::activeItemAddress(
ActiveItemID(mapNum, tr->tile));
ActiveItemID(_mapNum, tr->tile));
// Relpos is the relative position of the
// tile within the group
@ -1881,15 +1881,15 @@ TileInfo *Platform::fetchTAGInstance(
absPos.z = h;
// Look up the group instance in the hash.
instanceItem = mapList[mapNum].findHashedInstance(
instanceItem = mapList[_mapNum].findHashedInstance(
absPos,
tr->tile);
if (instanceItem) {
state = instanceItem->getInstanceState(mapNum);
state = instanceItem->getInstanceState(_mapNum);
sti.surfaceTAG = instanceItem;
// Get the tile to be drawn from the tile group
tr = &(mapList[mapNum].activeItemData)[
tr = &(mapList[_mapNum].activeItemData)[
groupItem->_data.group.grDataOffset
+ state * groupItem->_data.group.animArea
+ relPos.u * groupItem->_data.group.vSize
@ -1922,7 +1922,7 @@ TileInfo *Platform::fetchTAGInstance(
// REM: This is a likely candidate for downcoding...
TileInfo *Platform::fetchTile(
int16 mapNum,
int16 _mapNum,
const TilePoint &pt,
const TilePoint &origin,
uint8 **imageData,
@ -1941,7 +1941,7 @@ TileInfo *Platform::fetchTile(
absPos;
groupItem = ActiveItem::activeItemAddress(
ActiveItemID(mapNum, tr->tile));
ActiveItemID(_mapNum, tr->tile));
// Relpos is the relative position of the
// tile within the group
@ -1957,14 +1957,14 @@ TileInfo *Platform::fetchTile(
absPos.z = h;
// Look up the group instance in the hash.
instanceItem = mapList[mapNum].findHashedInstance(
instanceItem = mapList[_mapNum].findHashedInstance(
absPos,
tr->tile);
if (instanceItem) {
state = instanceItem->getInstanceState(mapNum);
state = instanceItem->getInstanceState(_mapNum);
// Get the tile to be drawn from the tile group
tr = &(mapList[mapNum].activeItemData)[
tr = &(mapList[_mapNum].activeItemData)[
groupItem->_data.group.grDataOffset
+ state * groupItem->_data.group.animArea
+ relPos.u * groupItem->_data.group.vSize
@ -2005,7 +2005,7 @@ TileInfo *Platform::fetchTile(
// REM: This is a likely candidate for downcoding...
TileInfo *Platform::fetchTAGInstance(
int16 mapNum,
int16 _mapNum,
const TilePoint &pt,
const TilePoint &origin,
uint8 **imageData,
@ -2023,7 +2023,7 @@ TileInfo *Platform::fetchTAGInstance(
absPos;
groupItem = ActiveItem::activeItemAddress(
ActiveItemID(mapNum, tr->tile));
ActiveItemID(_mapNum, tr->tile));
// Relpos is the relative position of the
// tile within the group
@ -2039,15 +2039,15 @@ TileInfo *Platform::fetchTAGInstance(
absPos.z = h;
// Look up the group instance in the hash.
instanceItem = mapList[mapNum].findHashedInstance(
instanceItem = mapList[_mapNum].findHashedInstance(
absPos,
tr->tile);
if (instanceItem) {
state = instanceItem->getInstanceState(mapNum);
state = instanceItem->getInstanceState(_mapNum);
sti.surfaceTAG = instanceItem;
// Get the tile to be drawn from the tile group
tr = &(mapList[mapNum].activeItemData)[
tr = &(mapList[_mapNum].activeItemData)[
groupItem->_data.group.grDataOffset
+ state * groupItem->_data.group.animArea
+ relPos.u * groupItem->_data.group.vSize
@ -2108,8 +2108,8 @@ MetaTile *MetaTile::metaTileAddress(MetaTileID id) {
//-----------------------------------------------------------------------
// Return this meta tile's ID
MetaTileID MetaTile::thisID(int16 mapNum) {
return MetaTileID(mapNum, _index);
MetaTileID MetaTile::thisID(int16 _mapNum) {
return MetaTileID(_mapNum, _index);
}
//-----------------------------------------------------------------------
@ -2122,14 +2122,14 @@ metaTileNoise MetaTile::HeavyMetaMusic() {
//-----------------------------------------------------------------------
// Return a pointer to the specified platform
Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
Platform *MetaTile::fetchPlatform(int16 _mapNum, int16 layer) {
const int cacheFlag = 0x8000;
uint16 plIndex = _stack[layer];
PlatformCacheEntry *pce;
Common::SeekableReadStream *stream;
assert(layer >= 0);
assert(_parent == mapList[mapNum].metaList);
assert(_parent == mapList[_mapNum].metaList);
if (plIndex == (uint16)nullID) {
return nullptr;
@ -2142,7 +2142,7 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
pce = &platformCache[plIndex];
assert(pce->metaID != NoMetaTile);
assert(pce->metaID == thisID(mapNum));
assert(pce->metaID == thisID(_mapNum));
// Move to the end of the LRU
g_vm->_platformLRU.remove(plIndex);
@ -2151,7 +2151,7 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
// return the address of the platform
return &pce->pl;
} else {
debugC(2, kDebugLoading, "Fetching platform (%d,%d)", mapNum, layer);
debugC(2, kDebugLoading, "Fetching platform (%d,%d)", _mapNum, layer);
// Since the platform is not in the cache, we need to
// dump something from the cache. Dump the one that
@ -2178,14 +2178,14 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
// Initialize the cache entry to the new platform data.
pce->platformNum = plIndex;
pce->layerNum = layer;
pce->metaID = thisID(mapNum);
pce->metaID = thisID(_mapNum);
_stack[layer] = (cacheIndex | cacheFlag);
assert(plIndex * sizeof(Platform) < tileRes->size(platformID + mapNum));
assert(plIndex * sizeof(Platform) < tileRes->size(platformID + _mapNum));
debugC(3, kDebugLoading, "- plIndex: %d", plIndex);
// Now, load the actual metatile data...
if ((stream = loadResourceToStream(tileRes, platformID + mapNum, "platform"))) {
if ((stream = loadResourceToStream(tileRes, platformID + _mapNum, "platform"))) {
if (stream->skip(plIndex * sizeof(Platform))) {
pce->pl.load(stream);
delete stream;
@ -2193,7 +2193,7 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
}
}
error("Unable to read Platform %d of map %d", plIndex, mapNum);
error("Unable to read Platform %d of map %d", plIndex, _mapNum);
return nullptr;
}
}
@ -2202,8 +2202,8 @@ Platform *MetaTile::fetchPlatform(int16 mapNum, int16 layer) {
// Return a pointer to this metatile's current object ripping
// table
RipTable *MetaTile::ripTable(int16 mapNum) {
WorldMapData *mapData = &mapList[mapNum];
RipTable *MetaTile::ripTable(int16 _mapNum) {
WorldMapData *mapData = &mapList[_mapNum];
return RipTable::ripTableAddress((mapData->ripTableIDList)[_index]);
}
@ -2211,8 +2211,8 @@ RipTable *MetaTile::ripTable(int16 mapNum) {
//-----------------------------------------------------------------------
// Return a reference to this meta tile's rip table ID
RipTableID &MetaTile::ripTableID(int16 mapNum) {
WorldMapData *mapData = &mapList[mapNum];
RipTableID &MetaTile::ripTableID(int16 _mapNum) {
WorldMapData *mapData = &mapList[_mapNum];
return (mapData->ripTableIDList)[_index];
}
@ -2337,9 +2337,9 @@ ActiveItem *WorldMapData::findHashedInstance(
* ====================================================================== */
bool MetaTileIterator::iterate() {
if (++mCoords.v >= region.max.v) {
if (++mCoords.u >= region.max.u) return false;
mCoords.v = region.min.v;
if (++_mCoords.v >= _region.max.v) {
if (++_mCoords.u >= _region.max.u) return false;
_mCoords.v = _region.min.v;
}
return true;
@ -2348,17 +2348,17 @@ bool MetaTileIterator::iterate() {
MetaTile *MetaTileIterator::first(TilePoint *loc) {
MetaTile *mtRes;
mCoords = region.min;
if (mCoords.u >= region.max.u || mCoords.v >= region.max.v)
_mCoords = _region.min;
if (_mCoords.u >= _region.max.u || _mCoords.v >= _region.max.v)
return nullptr;
mtRes = mapList[mapNum].lookupMeta(mCoords);
mtRes = mapList[_mapNum].lookupMeta(_mCoords);
while (mtRes == nullptr) {
if (!iterate()) return nullptr;
mtRes = mapList[mapNum].lookupMeta(mCoords);
mtRes = mapList[_mapNum].lookupMeta(_mCoords);
}
if (loc) *loc = mCoords << kPlatShift;
if (loc) *loc = _mCoords << kPlatShift;
return mtRes;
}
@ -2367,10 +2367,10 @@ MetaTile *MetaTileIterator::next(TilePoint *loc) {
do {
if (!iterate()) return nullptr;
mtRes = mapList[mapNum].lookupMeta(mCoords);
mtRes = mapList[_mapNum].lookupMeta(_mCoords);
} while (mtRes == nullptr);
if (loc) *loc = mCoords << kPlatShift;
if (loc) *loc = _mCoords << kPlatShift;
return mtRes;
}
@ -2379,36 +2379,36 @@ MetaTile *MetaTileIterator::next(TilePoint *loc) {
* ====================================================================== */
bool TileIterator::iterate() {
if (++tCoords.v >= tCoordsReg.max.v) {
if (++tCoords.u >= tCoordsReg.max.u) {
if (++_tCoords.v >= _tCoordsReg.max.v) {
if (++_tCoords.u >= _tCoordsReg.max.u) {
do {
platIndex++;
if (platIndex >= maxPlatforms) {
if ((mt = metaIter.next(&origin)) != nullptr) {
tCoordsReg.min.u = tCoordsReg.min.v = 0;
tCoordsReg.max.u = tCoordsReg.max.v = kPlatformWidth;
_platIndex++;
if (_platIndex >= maxPlatforms) {
if ((_mt = _metaIter.next(&_origin)) != nullptr) {
_tCoordsReg.min.u = _tCoordsReg.min.v = 0;
_tCoordsReg.max.u = _tCoordsReg.max.v = kPlatformWidth;
if (origin.u < region.min.u)
tCoordsReg.min.u = region.min.u & kPlatMask;
if (origin.u + kPlatformWidth > region.max.u)
tCoordsReg.max.u = region.max.u & kPlatMask;
if (origin.v < region.min.v)
tCoordsReg.min.v = region.min.v & kPlatMask;
if (origin.v + kPlatformWidth > region.max.v)
tCoordsReg.max.v = region.max.v & kPlatMask;
if (_origin.u < _region.min.u)
_tCoordsReg.min.u = _region.min.u & kPlatMask;
if (_origin.u + kPlatformWidth > _region.max.u)
_tCoordsReg.max.u = _region.max.u & kPlatMask;
if (_origin.v < _region.min.v)
_tCoordsReg.min.v = _region.min.v & kPlatMask;
if (_origin.v + kPlatformWidth > _region.max.v)
_tCoordsReg.max.v = _region.max.v & kPlatMask;
} else
return false;
platIndex = 0;
_platIndex = 0;
}
platform = mt->fetchPlatform(
metaIter.getMapNum(),
platIndex);
} while (platform == nullptr);
_platform = _mt->fetchPlatform(
_metaIter.getMapNum(),
_platIndex);
} while (_platform == nullptr);
tCoords.u = tCoordsReg.min.u;
_tCoords.u = _tCoordsReg.min.u;
}
tCoords.v = tCoordsReg.min.v;
_tCoords.v = _tCoordsReg.min.v;
}
return true;
@ -2418,49 +2418,49 @@ TileInfo *TileIterator::first(TilePoint *loc, StandingTileInfo *stiResult) {
TileInfo *tiRes;
StandingTileInfo sti;
if (region.max.u <= region.min.u || region.max.v <= region.min.v)
if (_region.max.u <= _region.min.u || _region.max.v <= _region.min.v)
return nullptr;
if ((mt = metaIter.first(&origin)) == nullptr) return nullptr;
if ((_mt = _metaIter.first(&_origin)) == nullptr) return nullptr;
platform = mt->fetchPlatform(metaIter.getMapNum(), platIndex = 0);
while (platform == nullptr) {
platIndex++;
if (platIndex >= maxPlatforms) {
if ((mt = metaIter.next(&origin)) == nullptr) return nullptr;
platIndex = 0;
_platform = _mt->fetchPlatform(_metaIter.getMapNum(), _platIndex = 0);
while (_platform == nullptr) {
_platIndex++;
if (_platIndex >= maxPlatforms) {
if ((_mt = _metaIter.next(&_origin)) == nullptr) return nullptr;
_platIndex = 0;
}
platform = mt->fetchPlatform(metaIter.getMapNum(), platIndex);
_platform = _mt->fetchPlatform(_metaIter.getMapNum(), _platIndex);
}
tCoordsReg.min.u = tCoordsReg.min.v = 0;
tCoordsReg.max.u = tCoordsReg.max.v = kPlatformWidth;
_tCoordsReg.min.u = _tCoordsReg.min.v = 0;
_tCoordsReg.max.u = _tCoordsReg.max.v = kPlatformWidth;
if (origin.u < region.min.u)
tCoordsReg.min.u = region.min.u & kPlatMask;
if (origin.u + kPlatformWidth > region.max.u)
tCoordsReg.max.u = region.max.u & kPlatMask;
if (origin.v < region.min.v)
tCoordsReg.min.v = region.min.v & kPlatMask;
if (origin.v + kPlatformWidth > region.max.v)
tCoordsReg.max.v = region.max.v & kPlatMask;
if (_origin.u < _region.min.u)
_tCoordsReg.min.u = _region.min.u & kPlatMask;
if (_origin.u + kPlatformWidth > _region.max.u)
_tCoordsReg.max.u = _region.max.u & kPlatMask;
if (_origin.v < _region.min.v)
_tCoordsReg.min.v = _region.min.v & kPlatMask;
if (_origin.v + kPlatformWidth > _region.max.v)
_tCoordsReg.max.v = _region.max.v & kPlatMask;
tCoords = tCoordsReg.min;
tiRes = platform->fetchTAGInstance(
metaIter.getMapNum(),
tCoords,
origin,
_tCoords = _tCoordsReg.min;
tiRes = _platform->fetchTAGInstance(
_metaIter.getMapNum(),
_tCoords,
_origin,
sti);
while (tiRes == nullptr) {
if (!iterate()) return nullptr;
tiRes = platform->fetchTAGInstance(
metaIter.getMapNum(),
tCoords,
origin,
tiRes = _platform->fetchTAGInstance(
_metaIter.getMapNum(),
_tCoords,
_origin,
sti);
}
*loc = tCoords + origin;
*loc = _tCoords + _origin;
if (stiResult) *stiResult = sti;
return tiRes;
}
@ -2471,14 +2471,14 @@ TileInfo *TileIterator::next(TilePoint *loc, StandingTileInfo *stiResult) {
do {
if (!iterate()) return nullptr;
tiRes = platform->fetchTAGInstance(
metaIter.getMapNum(),
tCoords,
origin,
tiRes = _platform->fetchTAGInstance(
_metaIter.getMapNum(),
_tCoords,
_origin,
sti);
} while (tiRes == nullptr);
*loc = tCoords + origin;
*loc = _tCoords + _origin;
if (stiResult) *stiResult = sti;
return tiRes;
}
@ -2657,13 +2657,13 @@ void buildRipTable(
// the center view object
void buildRipTables() {
const int16 regionRadius = kTileUVSize * kPlatformWidth * 2;
const int16 _regionRadius = kTileUVSize * kPlatformWidth * 2;
TilePoint actorCoords;
MetaTile *mt;
TileRegion ripTableReg;
MetaTile *mtTable[25]; // Largest region is 5x5
MetaTile *mtTable[25]; // Largest _region is 5x5
int16 mtTableSize = 0;
getViewTrackPos(actorCoords);
@ -2671,14 +2671,14 @@ void buildRipTables() {
ripTableCoords.v = actorCoords.v >> (kTileUVShift + kPlatShift);
ripTableCoords.z = 0;
// Calculate the region of meta tile for which to build object
// Calculate the _region of meta tile for which to build object
// ripping table
ripTableReg.min.u = (actorCoords.u - regionRadius) >> kTileUVShift;
ripTableReg.min.v = (actorCoords.v - regionRadius) >> kTileUVShift;
ripTableReg.min.u = (actorCoords.u - _regionRadius) >> kTileUVShift;
ripTableReg.min.v = (actorCoords.v - _regionRadius) >> kTileUVShift;
ripTableReg.max.u =
(actorCoords.u + regionRadius + kTileUVMask) >> kTileUVShift;
(actorCoords.u + _regionRadius + kTileUVMask) >> kTileUVShift;
ripTableReg.max.v =
(actorCoords.v + regionRadius + kTileUVMask) >> kTileUVShift;
(actorCoords.v + _regionRadius + kTileUVMask) >> kTileUVShift;
MetaTileIterator mIter(g_vm->_currentMapNum, ripTableReg);
@ -3777,7 +3777,7 @@ bool pointOnHiddenSurface(
WorldMapData *curMap = &mapList[g_vm->_currentMapNum];
TilePoint testCoords,
mCoords,
_mCoords,
tCoords,
origin;
MetaTile *mt;
@ -3808,16 +3808,16 @@ bool pointOnHiddenSurface(
adjSubMask = 0x0008 << (testCoords.u & ~kSubTileMask);
}
mCoords = adjTCoords >> kPlatShift;
_mCoords = adjTCoords >> kPlatShift;
// If metatile of adjacent tile does not exist, the pick point
// is valid.
if ((mt = curMap->lookupMeta(mCoords)) == nullptr) return false;
if ((mt = curMap->lookupMeta(_mCoords)) == nullptr) return false;
tCoords.u = adjTCoords.u & kPlatMask;
tCoords.v = adjTCoords.v & kPlatMask;
tCoords.z = 0;
origin = mCoords << kPlatShift;
origin = _mCoords << kPlatShift;
int i;
@ -3880,7 +3880,7 @@ StaticTilePoint pickTile(Point32 pos,
int16 zMax,
zMin,
mag;
TilePoint mCoords,
TilePoint _mCoords,
tCoords,
origin,
testCoords,
@ -3942,14 +3942,14 @@ StaticTilePoint pickTile(Point32 pos,
// Compute which metatile the click occurred on, and the tile
// within that metatile, and the origin coords of the metatile
mCoords = tileCoords >> kPlatShift;
_mCoords = tileCoords >> kPlatShift;
tCoords.u = tileCoords.u & kPlatMask;
tCoords.v = tileCoords.v & kPlatMask;
tCoords.z = 0;
origin = mCoords << kPlatShift;
origin = _mCoords << kPlatShift;
// Lookup the metatile
mt = curMap->lookupMeta(mCoords);
mt = curMap->lookupMeta(_mCoords);
// While we are less than the pick altitude
while (relPos.y < zMax + kTileDX + kMaxStepHeight - ABS(relPos.x >> 1)) {
@ -4032,9 +4032,9 @@ StaticTilePoint pickTile(Point32 pos,
coords.u -= kTileUVSize;
if (tCoords.u < 0) {
tCoords.u = kPlatformWidth - 1;
mCoords.u--;
origin = mCoords << kPlatShift;
mt = curMap->lookupMeta(mCoords);
_mCoords.u--;
origin = _mCoords << kPlatShift;
mt = curMap->lookupMeta(_mCoords);
}
relPos.x += kTileDX;
} else {
@ -4042,9 +4042,9 @@ StaticTilePoint pickTile(Point32 pos,
coords.v -= kTileUVSize;
if (tCoords.v < 0) {
tCoords.v = kPlatformWidth - 1;
mCoords.v--;
origin = mCoords << kPlatShift;
mt = curMap->lookupMeta(mCoords);
_mCoords.v--;
origin = _mCoords << kPlatShift;
mt = curMap->lookupMeta(_mCoords);
}
relPos.x -= kTileDX;
}
@ -4081,22 +4081,22 @@ StaticTilePoint pickTile(Point32 pos,
void cycleTiles(int32 delta) {
if (delta <= 0) return;
for (int i = 0; i < cycleCount; i++) {
TileCycleData &tcd = cycleList[i];
for (int i = 0; i < _cycleCount; i++) {
TileCycleData &tcd = _cycleList[i];
tcd.counter += tcd.cycleSpeed * delta;
if (tcd.counter >= 400) {
tcd.counter = 0;
tcd.currentState++;
if (tcd.currentState >= tcd.numStates)
tcd.currentState = 0;
tcd._counter += tcd._cycleSpeed * delta;
if (tcd._counter >= 400) {
tcd._counter = 0;
tcd._currentState++;
if (tcd._currentState >= tcd._numStates)
tcd._currentState = 0;
}
}
}
struct TileCycleArchive {
int32 counter;
uint8 currentState;
uint8 _currentState;
};
//-----------------------------------------------------------------------
@ -4106,17 +4106,17 @@ void initTileCyclingStates() {
Common::SeekableReadStream *stream;
const int tileCycleDataSize = 40;
cycleCount = tileRes->size(cycleID) / tileCycleDataSize;
cycleList = new TileCycleData[cycleCount];
_cycleCount = tileRes->size(cycleID) / tileCycleDataSize;
_cycleList = new TileCycleData[_cycleCount];
if (cycleList == nullptr)
if (_cycleList == nullptr)
error("Unable to load tile cycling data");
if ((stream = loadResourceToStream(tileRes, cycleID, "cycle list"))) {
for (int i = 0; i < cycleCount; ++i)
cycleList[i].load(stream);
for (int i = 0; i < _cycleCount; ++i)
_cycleList[i].load(stream);
debugC(2, kDebugLoading, "Loaded Cycles: cycleCount = %d", cycleCount);
debugC(2, kDebugLoading, "Loaded Cycles: _cycleCount = %d", _cycleCount);
delete stream;
}
}
@ -4125,14 +4125,14 @@ void saveTileCyclingStates(Common::OutSaveFile *outS) {
debugC(2, kDebugSaveload, "Saving TileCyclingStates");
outS->write("CYCL", 4);
CHUNK_BEGIN;
for (int i = 0; i < cycleCount; i++) {
for (int i = 0; i < _cycleCount; i++) {
debugC(3, kDebugSaveload, "Saving TileCyclingState %d", i);
out->writeSint32LE(cycleList[i].counter);
out->writeByte(cycleList[i].currentState);
out->writeSint32LE(_cycleList[i]._counter);
out->writeByte(_cycleList[i]._currentState);
debugC(4, kDebugSaveload, "... counter = %d", cycleList[i].counter);
debugC(4, kDebugSaveload, "... currentState = %d", cycleList[i].currentState);
debugC(4, kDebugSaveload, "... counter = %d", _cycleList[i]._counter);
debugC(4, kDebugSaveload, "... currentState = %d", _cycleList[i]._currentState);
}
CHUNK_END;
}
@ -4142,13 +4142,13 @@ void loadTileCyclingStates(Common::InSaveFile *in) {
initTileCyclingStates();
for (int i = 0; i < cycleCount; i++) {
for (int i = 0; i < _cycleCount; i++) {
debugC(3, kDebugSaveload, "Loading TileCyclingState %d", i);
cycleList[i].counter = in->readSint32LE();
cycleList[i].currentState = in->readByte();
_cycleList[i]._counter = in->readSint32LE();
_cycleList[i]._currentState = in->readByte();
debugC(4, kDebugSaveload, "... counter = %d", cycleList[i].counter);
debugC(4, kDebugSaveload, "... currentState = %d", cycleList[i].currentState);
debugC(4, kDebugSaveload, "... counter = %d", _cycleList[i]._counter);
debugC(4, kDebugSaveload, "... currentState = %d", _cycleList[i]._currentState);
}
}
@ -4156,9 +4156,9 @@ void loadTileCyclingStates(Common::InSaveFile *in) {
// Cleanup the tile cycling state array
void cleanupTileCyclingStates() {
if (cycleList != nullptr) {
delete[] cycleList;
cycleList = nullptr;
if (_cycleList != nullptr) {
delete[] _cycleList;
_cycleList = nullptr;
}
}
@ -4219,8 +4219,8 @@ uint16 objRoofID(GameObject *obj, int16 objMapNum, const TilePoint &objCoords) {
origin.u = metaU << kPlatShift;
origin.v = metaV << kPlatShift;
// Compute the tile region relative to the origin of this
// meta tile clipped to this meta tile region
// Compute the tile _region relative to the origin of this
// meta tile clipped to this meta tile _region
relTileReg.min.u = MAX(objTileReg.min.u - origin.u, 0);
relTileReg.min.v = MAX(objTileReg.min.v - origin.v, 0);
relTileReg.max.u = MIN(objTileReg.max.u - origin.u, (int)kPlatformWidth);
@ -4327,7 +4327,7 @@ void updateMainDisplay() {
scrollDistance;
TilePoint trackPos,
mCoords;
_mCoords;
lastUpdateTime = gameTime;
@ -4390,13 +4390,13 @@ void updateMainDisplay() {
// encloses the view area, and convert to sector coords.
buildRoofTable();
mCoords.u = trackPos.u >> (kTileUVShift + kPlatShift);
mCoords.v = trackPos.v >> (kTileUVShift + kPlatShift);
mCoords.z = 0;
_mCoords.u = trackPos.u >> (kTileUVShift + kPlatShift);
_mCoords.v = trackPos.v >> (kTileUVShift + kPlatShift);
_mCoords.z = 0;
// If trackPos has crossed a metatile boundry, rebuild object
// ripping tables
if (mCoords != ripTableCoords) buildRipTables();
if (_mCoords != ripTableCoords) buildRipTables();
// Build the list of all displayed objects
buildDisplayList();

View File

@ -304,29 +304,28 @@ void drawMainDisplay();
class TileCycleData {
public:
int32 counter; // cycling counter
uint8 pad; // odd-byte pad
uint8 numStates, // number of animated states
currentState, // current state of animation
cycleSpeed; // speed of cycling (0=none)
int32 _counter; // cycling counter
uint8 _pad; // odd-byte pad
uint8 _numStates, // number of animated states
_currentState, // current state of animation
_cycleSpeed; // speed of cycling (0=none)
TileID cycleList[16]; // array of tiles
TileID _cycleList[16]; // array of tiles
void load(Common::SeekableReadStream *stream) {
counter = stream->readSint32LE();
pad = stream->readByte();
numStates = stream->readByte();
currentState = stream->readByte();
cycleSpeed = stream->readByte();
_counter = stream->readSint32LE();
_pad = stream->readByte();
_numStates = stream->readByte();
_currentState = stream->readByte();
_cycleSpeed = stream->readByte();
for (int i = 0; i < 16; ++i)
cycleList[i] = stream->readUint16LE();
_cycleList[i] = stream->readUint16LE();
}
};
typedef TileCycleData
*CyclePtr, // pointer to cycle data
* *CycleHandle; // handle to cycle data
typedef TileCycleData *CyclePtr, // pointer to cycle data
**CycleHandle; // handle to cycle data
const int maxCycleRanges = 128; // 128 should do for now...
@ -522,8 +521,8 @@ class TileHitZone : public ActiveItem {
public:
// REM: Allow discontiguous regions??
int16 numVertices;
XArray<Point16> vertexList;
int16 _numVertices;
XArray<Point16> _vertexList;
int16 type() {
return activeTypeHitZone;
@ -541,12 +540,12 @@ public:
class ObjectInstance : public ActiveItem {
public:
TileGroupID classID; // ID of object class
TileGroupID _classID; // ID of object class
// An instance of a specific object.
uint16 u, v, h; // where the instance lies
uint8 facing; // which direction it's facing
uint16 _u, _v, _h; // where the instance lies
uint8 _facing; // which direction it's facing
int16 type() {
return activeTypeObject;
@ -569,10 +568,10 @@ class TileActivityTask {
friend class TileActivityTaskList;
friend class ActiveItem;
uint8 activityType; // open or close
uint8 targetState;
ActiveItem *tai; // the tile activity instance
ThreadID script; // script to wake up when task done
uint8 _activityType; // open or close
uint8 _targetState;
ActiveItem *_tai; // the tile activity instance
ThreadID _script; // script to wake up when task done
enum activityTypes {
activityTypeNone, // no activity
@ -915,27 +914,27 @@ struct WorldMapData {
* ===================================================================== */
class MetaTileIterator {
TilePoint mCoords;
TileRegion region;
TilePoint _mCoords;
TileRegion _region;
int16 mapNum;
int16 _mapNum;
bool iterate();
public:
MetaTileIterator(int16 map, const TileRegion &reg) : mapNum(map) {
region.min.u = reg.min.u >> kPlatShift;
region.max.u = (reg.max.u + kPlatMask) >> kPlatShift;
region.min.v = reg.min.v >> kPlatShift;
region.max.v = (reg.max.v + kPlatMask) >> kPlatShift;
region.min.z = region.max.z = 0;
MetaTileIterator(int16 map, const TileRegion &reg) : _mapNum(map) {
_region.min.u = reg.min.u >> kPlatShift;
_region.max.u = (reg.max.u + kPlatMask) >> kPlatShift;
_region.min.v = reg.min.v >> kPlatShift;
_region.max.v = (reg.max.v + kPlatMask) >> kPlatShift;
_region.min.z = _region.max.z = 0;
}
MetaTile *first(TilePoint *loc = NULL);
MetaTile *next(TilePoint *loc = NULL);
int16 getMapNum() {
return mapNum;
return _mapNum;
}
};
@ -944,24 +943,24 @@ public:
* ===================================================================== */
class TileIterator {
MetaTileIterator metaIter;
MetaTile *mt;
int16 platIndex;
Platform *platform;
TilePoint tCoords,
origin;
TileRegion region,
tCoordsReg;
MetaTileIterator _metaIter;
MetaTile *_mt;
int16 _platIndex;
Platform *_platform;
TilePoint _tCoords,
_origin;
TileRegion _region,
_tCoordsReg;
bool iterate();
public:
TileIterator(int16 mapNum, const TileRegion &reg) :
metaIter(mapNum, reg),
region(reg) {
mt = nullptr;
platIndex = 0;
platform = nullptr;
_metaIter(mapNum, reg),
_region(reg) {
_mt = nullptr;
_platIndex = 0;
_platform = nullptr;
}
TileInfo *first(TilePoint *loc, StandingTileInfo *stiResult = NULL);