SAGA2: Rename class variables in objects.h

This commit is contained in:
Eugene Sandulenko 2022-09-26 17:21:54 +02:00
parent 1d5f9486b2
commit 4921ae88c2
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
8 changed files with 292 additions and 313 deletions

View File

@ -192,12 +192,12 @@ void AutoMap::locateRegion() {
Common::SeekableReadStream *stream;
hResContext *areaRes; // tile resource handle
int16 regionCount;
WorldMapData *wMap = &mapList[currentWorld->mapNum];
WorldMapData *wMap = &mapList[currentWorld->_mapNum];
areaRes = auxResFile->newContext(MKTAG('A', 'M', 'A', 'P'), "AreaList");
assert(areaRes != nullptr);
stream = loadResourceToStream(areaRes, MKTAG('Z', 'O', 'N', currentWorld->mapNum), "AreaList");
stream = loadResourceToStream(areaRes, MKTAG('Z', 'O', 'N', currentWorld->_mapNum), "AreaList");
regionCount = stream->readUint16LE();
_centerCoords = _trackPos >> (kTileUVShift + kPlatShift);
@ -304,7 +304,7 @@ void AutoMap::pointerMove(gPanelMessage &msg) {
viewRegion.max.u = MIN<int16>(_localAreaRegion.max.u, _baseCoords.u + (int16)kSummaryDiameter) - 1;
viewRegion.min.v = MAX(_localAreaRegion.min.v, _baseCoords.v);
viewRegion.max.v = MIN<int16>(_localAreaRegion.max.v, _baseCoords.v + (int16)kSummaryDiameter) - 1;
char *mtext = getMapFeaturesText(viewRegion, currentWorld->mapNum, _baseCoords, pos) ;
char *mtext = getMapFeaturesText(viewRegion, currentWorld->_mapNum, _baseCoords, pos) ;
g_vm->_mouseInfo->setText(mtext);
} else {
notify(gEventMouseMove, 0);
@ -441,7 +441,7 @@ void AutoMap::draw() { // redraw the window
// create a summary map on the tPort gPixelMap buffer
void AutoMap::createSmallMap() {
WorldMapData *wMap = &mapList[currentWorld->mapNum];
WorldMapData *wMap = &mapList[currentWorld->_mapNum];
uint16 *mapData = wMap->map->mapData;
uint16 *mapRow;
@ -505,7 +505,7 @@ void AutoMap::createSmallMap() {
}
}
drawMapFeatures(viewRegion, currentWorld->mapNum, _baseCoords, _tPort);
drawMapFeatures(viewRegion, currentWorld->_mapNum, _baseCoords, _tPort);
// if (blink)

View File

@ -230,7 +230,7 @@ void initMapFeatures() {
void updateMapFeatures(int16 cWorld) {
extern WorldMapData *mapList;
extern GameWorld *currentWorld;
WorldMapData *wMap = &mapList[currentWorld->mapNum];
WorldMapData *wMap = &mapList[currentWorld->_mapNum];
uint16 *mapData = wMap->map->mapData;

View File

@ -471,8 +471,8 @@ ObjectID *GameObject::getHeadPtr(ObjectID parentID, TilePoint &l) {
int16 u = clamp(0, l.u / kSectorSize, sectors.u - 1),
v = clamp(0, l.v / kSectorSize, sectors.v - 1);
return &(world->sectorArray)[
v * world->sectorArraySize + u].childID;
return &(world->_sectorArray)[
v * world->_sectorArraySize + u]._childID;
} else return &parentObj->_data.childID;
}
@ -1711,7 +1711,7 @@ void GameObject::dropInventoryObject(GameObject *obj, int16 count) {
assert(isWorld(_data.parentID));
int16 dist;
int16 mapNum = getMapNum();
int16 _mapNum = getMapNum();
dist = _prototype->crossSection + obj->proto()->crossSection;
@ -1730,10 +1730,10 @@ void GameObject::dropInventoryObject(GameObject *obj, int16 count) {
probeLoc = _data.location + incDirTable[dir] * dist;
probeLoc.u += g_vm->_rnd->getRandomNumber(3) - 2;
probeLoc.v += g_vm->_rnd->getRandomNumber(3) - 2;
probeLoc.z = tileSlopeHeight(probeLoc, mapNum, obj, &sti);
probeLoc.z = tileSlopeHeight(probeLoc, _mapNum, obj, &sti);
// If _data.location is not blocked, drop the object
if (checkBlocked(obj, mapNum, probeLoc) == blockageNone) {
if (checkBlocked(obj, _mapNum, probeLoc) == blockageNone) {
// If we're dropping the object on a TAI, make sure
// we call the correct drop function
if (sti.surfaceTAG == nullptr) {
@ -2410,57 +2410,57 @@ GameWorld::GameWorld(int16 map) {
int16 mapSize; // Size of map in MetaTiles
mapSize = stream->readSint16LE();
size.u = (mapSize << kPlatShift) << kTileUVShift;
size.v = size.u;
_size.u = (mapSize << kPlatShift) << kTileUVShift;
_size.v = _size.u;
sectorArraySize = size.u / kSectorSize;
sectorArray = new Sector[sectorArraySize * sectorArraySize]();
_sectorArraySize = _size.u / kSectorSize;
_sectorArray = new Sector[_sectorArraySize * _sectorArraySize]();
if (sectorArray == nullptr)
if (_sectorArray == nullptr)
error("Unable to allocate world %d sector array", map);
mapNum = map;
_mapNum = map;
delete stream;
} else {
size.u = size.v = 0;
sectorArraySize = 0;
sectorArray = nullptr;
_size.u = _size.v = 0;
_sectorArraySize = 0;
_sectorArray = nullptr;
mapNum = -1;
_mapNum = -1;
}
}
GameWorld::GameWorld(Common::SeekableReadStream *stream) {
size.u = size.v = stream->readSint16LE();
mapNum = stream->readSint16LE();
_size.u = _size.v = stream->readSint16LE();
_mapNum = stream->readSint16LE();
debugC(3, kDebugSaveload, "... size.u = size.v = %d", size.u);
debugC(3, kDebugSaveload, "... mapNum = %d", mapNum);
debugC(3, kDebugSaveload, "... _size.u = _size.v = %d", _size.u);
debugC(3, kDebugSaveload, "... _mapNum = %d", _mapNum);
if (size.u != 0) {
int32 sectorArrayCount;
if (_size.u != 0) {
int32 _sectorArrayCount;
sectorArraySize = size.u / kSectorSize;
sectorArrayCount = sectorArraySize * sectorArraySize;
sectorArray = new Sector[sectorArrayCount]();
_sectorArraySize = _size.u / kSectorSize;
_sectorArrayCount = _sectorArraySize * _sectorArraySize;
_sectorArray = new Sector[_sectorArrayCount]();
if (sectorArray == nullptr)
error("Unable to allocate world %d sector array", mapNum);
if (_sectorArray == nullptr)
error("Unable to allocate world %d sector array", _mapNum);
for (int i = 0; i < sectorArrayCount; ++i) {
sectorArray[i].read(stream);
debugC(4, kDebugSaveload, "...... sectArray[%d].activationCount = %d", i, sectorArray[i].activationCount);
debugC(4, kDebugSaveload, "...... sectArray[%d].childID = %d", i, sectorArray[i].childID);
for (int i = 0; i < _sectorArrayCount; ++i) {
_sectorArray[i].read(stream);
debugC(4, kDebugSaveload, "...... sectArray[%d].activationCount = %d", i, _sectorArray[i]._activationCount);
debugC(4, kDebugSaveload, "...... sectArray[%d].childID = %d", i, _sectorArray[i]._childID);
}
} else {
sectorArraySize = 0;
sectorArray = nullptr;
_sectorArraySize = 0;
_sectorArray = nullptr;
}
}
GameWorld::~GameWorld() {
if (sectorArray)
delete[] sectorArray;
if (_sectorArray)
delete[] _sectorArray;
}
//-------------------------------------------------------------------
@ -2469,9 +2469,9 @@ GameWorld::~GameWorld() {
int32 GameWorld::archiveSize() {
int32 bytes = 0;
bytes += sizeof(size.u)
+ sizeof(mapNum)
+ sectorArraySize * sectorArraySize * sizeof(Sector);
bytes += sizeof(_size.u)
+ sizeof(_mapNum)
+ _sectorArraySize * _sectorArraySize * sizeof(Sector);
return bytes;
}
@ -2480,9 +2480,9 @@ int32 GameWorld::archiveSize() {
// Cleanup
void GameWorld::cleanup() {
if (sectorArray != nullptr) {
delete[] sectorArray;
sectorArray = nullptr;
if (_sectorArray != nullptr) {
delete[] _sectorArray;
_sectorArray = nullptr;
}
}
@ -2837,7 +2837,7 @@ void initWorlds() {
}
currentWorld = &worldList[0];
setCurrentMap(currentWorld->mapNum);
setCurrentMap(currentWorld->_mapNum);
}
void saveWorlds(Common::OutSaveFile *outS) {
@ -2850,20 +2850,20 @@ void saveWorlds(Common::OutSaveFile *outS) {
debugC(3, kDebugSaveload, "... currentWorld->thisID() = %d", currentWorld->thisID());
for (int i = 0; i < worldCount; ++i) {
Sector *sectArray = worldList[i].sectorArray;
int32 sectorArrayCount = worldList[i].sectorArraySize *
worldList[i].sectorArraySize;
Sector *sectArray = worldList[i]._sectorArray;
int32 _sectorArrayCount = worldList[i]._sectorArraySize *
worldList[i]._sectorArraySize;
out->writeSint16LE(worldList[i].size.u);
out->writeSint16LE(worldList[i].mapNum);
out->writeSint16LE(worldList[i]._size.u);
out->writeSint16LE(worldList[i]._mapNum);
debugC(3, kDebugSaveload, "... worldList[%d].size.u = %d", i, worldList[i].size.u);
debugC(3, kDebugSaveload, "... worldList[%d].mapNum = %d", i, worldList[i].mapNum);
debugC(3, kDebugSaveload, "... worldList[%d]._size.u = %d", i, worldList[i]._size.u);
debugC(3, kDebugSaveload, "... worldList[%d]._mapNum = %d", i, worldList[i]._mapNum);
for (int j = 0; j < sectorArrayCount; ++j) {
for (int j = 0; j < _sectorArrayCount; ++j) {
sectArray[j].write(out);
debugC(4, kDebugSaveload, "...... sectArray[%d].activationCount = %d", j, sectArray[j].activationCount);
debugC(4, kDebugSaveload, "...... sectArray[%d].childID = %d", j, sectArray[j].childID);
debugC(4, kDebugSaveload, "...... sectArray[%d].activationCount = %d", j, sectArray[j]._activationCount);
debugC(4, kDebugSaveload, "...... sectArray[%d].childID = %d", j, sectArray[j]._childID);
}
}
CHUNK_END;
@ -2892,7 +2892,7 @@ void loadWorlds(Common::InSaveFile *in) {
// Reset the current world
currentWorld = (GameWorld *)GameObject::objectAddress(currentWorldID);
setCurrentMap(currentWorld->mapNum);
setCurrentMap(currentWorld->_mapNum);
}
//-------------------------------------------------------------------
@ -3126,8 +3126,8 @@ GameObject *getViewCenterObject() {
// Activate all actors in sector if sector is not alreay active
void Sector::activate() {
if (activationCount++ == 0) {
ObjectID id = childID;
if (_activationCount++ == 0) {
ObjectID id = _childID;
while (id != Nothing) {
GameObject *obj = GameObject::objectAddress(id);
@ -3144,19 +3144,19 @@ void Sector::activate() {
// actors in sector if activation count has reached zero.
void Sector::deactivate() {
assert(activationCount != 0);
assert(_activationCount != 0);
activationCount--;
_activationCount--;
}
void Sector::read(Common::InSaveFile *in) {
activationCount = in->readUint16LE();
childID = in->readUint16LE();
_activationCount = in->readUint16LE();
_childID = in->readUint16LE();
}
void Sector::write(Common::MemoryWriteStreamDynamic *out) {
out->writeUint16LE(activationCount);
out->writeUint16LE(childID);
out->writeUint16LE(_activationCount);
out->writeUint16LE(_childID);
}
@ -3168,64 +3168,64 @@ void Sector::write(Common::MemoryWriteStreamDynamic *out) {
// Update this active region
void ActiveRegion::read(Common::InSaveFile *in) {
anchor = in->readUint16LE();
anchorLoc.load(in);
worldID = in->readUint16LE();
region.read(in);
_anchor = in->readUint16LE();
_anchorLoc.load(in);
_worldID = in->readUint16LE();
_region.read(in);
debugC(4, kDebugSaveload, "... anchor = %d", anchor);
debugC(4, kDebugSaveload, "... anchorLoc = (%d, %d, %d)", anchorLoc.u, anchorLoc.v, anchorLoc.z);
debugC(4, kDebugSaveload, "... worldID = %d", worldID);
debugC(4, kDebugSaveload, "... anchor = %d", _anchor);
debugC(4, kDebugSaveload, "... anchorLoc = (%d, %d, %d)", _anchorLoc.u, _anchorLoc.v, _anchorLoc.z);
debugC(4, kDebugSaveload, "... worldID = %d", _worldID);
debugC(4, kDebugSaveload, "... region = (min: (%d, %d, %d), max: (%d, %d, %d))",
region.min.u, region.min.v, region.min.z, region.max.u, region.max.v, region.max.z);
_region.min.u, _region.min.v, _region.min.z, _region.max.u, _region.max.v, _region.max.z);
}
void ActiveRegion::write(Common::MemoryWriteStreamDynamic *out) {
out->writeUint16LE(anchor);
anchorLoc.write(out);
out->writeUint16LE(worldID);
region.write(out);
out->writeUint16LE(_anchor);
_anchorLoc.write(out);
out->writeUint16LE(_worldID);
_region.write(out);
debugC(4, kDebugSaveload, "... anchor = %d", anchor);
debugC(4, kDebugSaveload, "... anchorLoc = (%d, %d, %d)", anchorLoc.u, anchorLoc.v, anchorLoc.z);
debugC(4, kDebugSaveload, "... worldID = %d", worldID);
debugC(4, kDebugSaveload, "... anchor = %d", _anchor);
debugC(4, kDebugSaveload, "... anchorLoc = (%d, %d, %d)", _anchorLoc.u, _anchorLoc.v, _anchorLoc.z);
debugC(4, kDebugSaveload, "... worldID = %d", _worldID);
debugC(4, kDebugSaveload, "... region = (min: (%d, %d, %d), max: (%d, %d, %d))",
region.min.u, region.min.v, region.min.z, region.max.u, region.max.v, region.max.z);
_region.min.u, _region.min.v, _region.min.z, _region.max.u, _region.max.v, _region.max.z);
}
void ActiveRegion::update() {
GameObject *obj = GameObject::objectAddress(anchor);
GameWorld *world = (GameWorld *)GameObject::objectAddress(worldID);
GameObject *obj = GameObject::objectAddress(_anchor);
GameWorld *world = (GameWorld *)GameObject::objectAddress(_worldID);
ObjectID objWorldID = obj->world()->thisID();
// Determine if the world for this active region has changed
if (worldID != objWorldID) {
if (_worldID != objWorldID) {
int16 u, v;
// Deactivate all of the old sectors
for (u = region.min.u; u < region.max.u; u++) {
for (v = region.min.v; v < region.max.v; v++) {
for (u = _region.min.u; u < _region.max.u; u++) {
for (v = _region.min.v; v < _region.max.v; v++) {
world->getSector(u, v)->deactivate();
}
}
// Initialize active region for new world
worldID = objWorldID;
world = (GameWorld *)GameObject::objectAddress(worldID);
anchorLoc = Nowhere;
region.min = Nowhere;
region.max = Nowhere;
_worldID = objWorldID;
world = (GameWorld *)GameObject::objectAddress(_worldID);
_anchorLoc = Nowhere;
_region.min = Nowhere;
_region.max = Nowhere;
}
TilePoint loc = obj->getLocation();
// Determine if anchor has moved since the last time
if (loc != anchorLoc) {
if (loc != _anchorLoc) {
TileRegion ptRegion,
newRegion;
// Update the anchor _data.location
anchorLoc = loc;
_anchorLoc = loc;
// Determine the active region in points
ptRegion.min.u = loc.u - kSectorSize / 2;
@ -3239,20 +3239,20 @@ void ActiveRegion::update() {
newRegion.max.u = (ptRegion.max.u + kSectorMask) >> kSectorShift;
newRegion.max.v = (ptRegion.max.v + kSectorMask) >> kSectorShift;
if (region.min.u != newRegion.min.u
|| region.min.v != newRegion.min.v
|| region.max.u != newRegion.max.u
|| region.max.v != newRegion.max.v) {
if (_region.min.u != newRegion.min.u
|| _region.min.v != newRegion.min.v
|| _region.max.u != newRegion.max.u
|| _region.max.v != newRegion.max.v) {
int16 u, v;
// Deactivate all sectors from the old region which are
// not in the new region
for (u = region.min.u; u < region.max.u; u++) {
for (u = _region.min.u; u < _region.max.u; u++) {
bool uOutOfRange;
uOutOfRange = u < newRegion.min.u || u >= newRegion.max.u;
for (v = region.min.v; v < region.max.v; v++) {
for (v = _region.min.v; v < _region.max.v; v++) {
if (uOutOfRange
|| v < newRegion.min.v
|| v >= newRegion.max.v) {
@ -3270,12 +3270,12 @@ void ActiveRegion::update() {
for (u = newRegion.min.u; u < newRegion.max.u; u++) {
bool uOutOfRange;
uOutOfRange = u < region.min.u || u >= region.max.u;
uOutOfRange = u < _region.min.u || u >= _region.max.u;
for (v = newRegion.min.v; v < newRegion.max.v; v++) {
if (uOutOfRange
|| v < region.min.v
|| v >= region.max.v) {
|| v < _region.min.v
|| v >= _region.max.v) {
if(Sector *sect = world->getSector(u, v))
sect->activate();
@ -3286,10 +3286,10 @@ void ActiveRegion::update() {
}
// Update the region coordinates
region.min.u = newRegion.min.u;
region.min.v = newRegion.min.v;
region.max.u = newRegion.max.u;
region.max.v = newRegion.max.v;
_region.min.u = newRegion.min.u;
_region.min.v = newRegion.min.v;
_region.max.u = newRegion.max.u;
_region.max.v = newRegion.max.v;
}
}
}
@ -3335,11 +3335,11 @@ void initActiveRegions() {
ActiveRegion *reg = &g_vm->_activeRegionList[i];
ObjectID actorID = getPlayerActorAddress(playerIDArray[i])->getActorID();
reg->anchor = actorID;
reg->anchorLoc = Nowhere;
reg->worldID = Nothing;
reg->region.min = Nowhere;
reg->region.max = Nowhere;
reg->_anchor = actorID;
reg->_anchorLoc = Nowhere;
reg->_worldID = Nothing;
reg->_region.min = Nowhere;
reg->_region.max = Nowhere;
}
}
@ -3372,12 +3372,12 @@ void loadActiveRegions(Common::InSaveFile *in) {
// Constructor
SectorRegionObjectIterator::SectorRegionObjectIterator(GameWorld *world) :
searchWorld(world), _currentObject(nullptr) {
assert(searchWorld != nullptr);
assert(isWorld(searchWorld));
_searchWorld(world), _currentObject(nullptr) {
assert(_searchWorld != nullptr);
assert(isWorld(_searchWorld));
minSector = TilePoint(0, 0, 0);
maxSector = searchWorld->sectorSize();
_minSector = TilePoint(0, 0, 0);
_maxSector = _searchWorld->sectorSize();
}
//------------------------------------------------------------------------
@ -3388,40 +3388,40 @@ ObjectID SectorRegionObjectIterator::first(GameObject **obj) {
_currentObject = nullptr;
sectorCoords = minSector;
currentSector = searchWorld->getSector(sectorCoords.u, sectorCoords.v);
_sectorCoords = _minSector;
currentSector = _searchWorld->getSector(_sectorCoords.u, _sectorCoords.v);
if (currentSector == nullptr)
return Nothing;
while (currentSector->childID == Nothing) {
if (++sectorCoords.v >= maxSector.v) {
sectorCoords.v = minSector.v;
if (++sectorCoords.u >= maxSector.u) {
while (currentSector->_childID == Nothing) {
if (++_sectorCoords.v >= _maxSector.v) {
_sectorCoords.v = _minSector.v;
if (++_sectorCoords.u >= _maxSector.u) {
if (obj != nullptr) *obj = nullptr;
return Nothing;
}
}
currentSector = searchWorld->getSector(
sectorCoords.u,
sectorCoords.v);
currentSector = _searchWorld->getSector(
_sectorCoords.u,
_sectorCoords.v);
}
_currentObject = GameObject::objectAddress(currentSector->childID);
_currentObject = GameObject::objectAddress(currentSector->_childID);
if (obj != nullptr) *obj = _currentObject;
return currentSector->childID;
return currentSector->_childID;
}
//------------------------------------------------------------------------
// Return the next object found
ObjectID SectorRegionObjectIterator::next(GameObject **obj) {
assert(sectorCoords.u >= minSector.u);
assert(sectorCoords.v >= minSector.v);
assert(sectorCoords.u < maxSector.u);
assert(sectorCoords.v < maxSector.v);
assert(_sectorCoords.u >= _minSector.u);
assert(_sectorCoords.v >= _minSector.v);
assert(_sectorCoords.u < _maxSector.u);
assert(_sectorCoords.v < _maxSector.v);
ObjectID currentObjectID;
@ -3431,21 +3431,21 @@ ObjectID SectorRegionObjectIterator::next(GameObject **obj) {
Sector *currentSector;
do {
if (++sectorCoords.v >= maxSector.v) {
sectorCoords.v = minSector.v;
if (++sectorCoords.u >= maxSector.u) {
if (++_sectorCoords.v >= _maxSector.v) {
_sectorCoords.v = _minSector.v;
if (++_sectorCoords.u >= _maxSector.u) {
if (obj != nullptr) *obj = nullptr;
return Nothing;
}
}
currentSector = searchWorld->getSector(
sectorCoords.u,
sectorCoords.v);
currentSector = _searchWorld->getSector(
_sectorCoords.u,
_sectorCoords.v);
} while (currentSector->childID == Nothing);
} while (currentSector->_childID == Nothing);
currentObjectID = currentSector->childID;
currentObjectID = currentSector->_childID;
}
_currentObject = GameObject::objectAddress(currentObjectID);
@ -3500,7 +3500,7 @@ ObjectID RadialObjectIterator::first(GameObject **obj, int16 *dist) {
while (currentObjectID != Nothing
&& (currentDist =
computeDist(currentObject->getLocation()))
> radius) {
> _radius) {
currentObjectID = SectorRegionObjectIterator::next(&currentObject);
}
@ -3520,7 +3520,7 @@ ObjectID RadialObjectIterator::next(GameObject **obj, int16 *dist) {
do {
currentObjectID = SectorRegionObjectIterator::next(&currentObject);
} while (currentObjectID != Nothing
&& (currentDist = computeDist(currentObject->getLocation())) > radius);
&& (currentDist = computeDist(currentObject->getLocation())) > _radius);
if (dist != nullptr)
*dist = currentDist;
@ -3551,7 +3551,7 @@ ObjectID RingObjectIterator::first(GameObject **obj) {
currentObjectID = CircularObjectIterator::first(&currentObject);
while (currentObjectID != Nothing
&& computeDist(currentObject->getLocation()) < innerDist) {
&& computeDist(currentObject->getLocation()) < _innerDist) {
currentObjectID = CircularObjectIterator::next(&currentObject);
}
@ -3567,7 +3567,7 @@ ObjectID RingObjectIterator::next(GameObject **obj) {
do {
currentObjectID = CircularObjectIterator::next(&currentObject);
} while (currentObjectID != Nothing
&& computeDist(currentObject->getLocation()) < innerDist);
&& computeDist(currentObject->getLocation()) < _innerDist);
if (obj != nullptr) *obj = currentObject;
return currentObjectID;
@ -3827,7 +3827,7 @@ TilePoint CenterRegionObjectIterator::MaxCenterRegion() {
//------------------------------------------------------------------------
bool ActiveRegionObjectIterator::firstActiveRegion() {
activeRegionIndex = -1;
_activeRegionIndex = -1;
return nextActiveRegion();
}
@ -3840,22 +3840,22 @@ bool ActiveRegionObjectIterator::nextActiveRegion() {
TilePoint currentRegionSize;
do {
if (++activeRegionIndex >= kPlayerActors)
if (++_activeRegionIndex >= kPlayerActors)
return false;
int16 prevRegionIndex;
currentRegion = &g_vm->_activeRegionList[activeRegionIndex];
currentRegion = &g_vm->_activeRegionList[_activeRegionIndex];
sectorBitMask = 0;
currentRegionSize.u = currentRegion->region.max.u
- currentRegion->region.min.u;
currentRegionSize.v = currentRegion->region.max.v
- currentRegion->region.min.v;
_sectorBitMask = 0;
currentRegionSize.u = currentRegion->_region.max.u
- currentRegion->_region.min.u;
currentRegionSize.v = currentRegion->_region.max.v
- currentRegion->_region.min.v;
currentRegionSectors = currentRegionSize.u * currentRegionSize.v;
for (prevRegionIndex = 0;
prevRegionIndex < activeRegionIndex;
prevRegionIndex < _activeRegionIndex;
prevRegionIndex++) {
ActiveRegion *prevRegion;
@ -3863,32 +3863,32 @@ bool ActiveRegionObjectIterator::nextActiveRegion() {
// Determine if the current region and the previous region
// overlap.
if (currentRegion->worldID != prevRegion->worldID
|| prevRegion->region.min.u >= currentRegion->region.max.u
|| currentRegion->region.min.u >= prevRegion->region.max.u
|| prevRegion->region.min.v >= currentRegion->region.max.v
|| currentRegion->region.min.v >= prevRegion->region.max.v)
if (currentRegion->_worldID != prevRegion->_worldID
|| prevRegion->_region.min.u >= currentRegion->_region.max.u
|| currentRegion->_region.min.u >= prevRegion->_region.max.u
|| prevRegion->_region.min.v >= currentRegion->_region.max.v
|| currentRegion->_region.min.v >= prevRegion->_region.max.v)
continue;
TileRegion intersection;
int16 u, v;
intersection.min.u = MAX(
currentRegion->region.min.u,
prevRegion->region.min.u)
- currentRegion->region.min.u;
currentRegion->_region.min.u,
prevRegion->_region.min.u)
- currentRegion->_region.min.u;
intersection.max.u = MIN(
currentRegion->region.max.u,
prevRegion->region.max.u)
- currentRegion->region.min.u;
currentRegion->_region.max.u,
prevRegion->_region.max.u)
- currentRegion->_region.min.u;
intersection.min.v = MAX(
currentRegion->region.min.v,
prevRegion->region.min.v)
- currentRegion->region.min.v;
currentRegion->_region.min.v,
prevRegion->_region.min.v)
- currentRegion->_region.min.v;
intersection.max.v = MIN(
currentRegion->region.max.v,
prevRegion->region.max.v)
- currentRegion->region.min.v;
currentRegion->_region.max.v,
prevRegion->_region.max.v)
- currentRegion->_region.min.v;
for (u = intersection.min.u;
u < intersection.max.u;
@ -3900,13 +3900,13 @@ bool ActiveRegionObjectIterator::nextActiveRegion() {
sectorBit = 1 << (u * currentRegionSize.v + v);
if (!(sectorBitMask & sectorBit)) {
if (!(_sectorBitMask & sectorBit)) {
currentRegionSectors--;
assert(currentRegionSectors >= 0);
// Set the bit in the bit mask indicating that this
// sector overlaps with a previouse active region
sectorBitMask |= sectorBit;
_sectorBitMask |= sectorBit;
}
}
}
@ -3919,12 +3919,12 @@ bool ActiveRegionObjectIterator::nextActiveRegion() {
} while (currentRegionSectors == 0);
baseSectorCoords.u = currentRegion->region.min.u;
baseSectorCoords.v = currentRegion->region.min.v;
size.u = currentRegionSize.u;
size.v = currentRegionSize.v;
currentWorld = (GameWorld *)GameObject::objectAddress(
currentRegion->worldID);
_baseSectorCoords.u = currentRegion->_region.min.u;
_baseSectorCoords.v = currentRegion->_region.min.v;
_size.u = currentRegionSize.u;
_size.v = currentRegionSize.v;
_currentWorld = (GameWorld *)GameObject::objectAddress(
currentRegion->_worldID);
return true;
}
@ -3935,10 +3935,10 @@ bool ActiveRegionObjectIterator::firstSector() {
if (!firstActiveRegion())
return false;
sectorCoords.u = baseSectorCoords.u;
sectorCoords.v = baseSectorCoords.v;
_sectorCoords.u = _baseSectorCoords.u;
_sectorCoords.v = _baseSectorCoords.v;
if (sectorBitMask & 1) {
if (_sectorBitMask & 1) {
if (!nextSector())
return false;
}
@ -3952,23 +3952,23 @@ bool ActiveRegionObjectIterator::nextSector() {
int16 u, v;
do {
sectorCoords.v++;
_sectorCoords.v++;
if (sectorCoords.v >= baseSectorCoords.v + size.v) {
sectorCoords.v = baseSectorCoords.v;
sectorCoords.u++;
if (_sectorCoords.v >= _baseSectorCoords.v + _size.v) {
_sectorCoords.v = _baseSectorCoords.v;
_sectorCoords.u++;
if (sectorCoords.u >= baseSectorCoords.u + size.u) {
if (_sectorCoords.u >= _baseSectorCoords.u + _size.u) {
if (!nextActiveRegion()) return false;
sectorCoords.u = baseSectorCoords.u;
sectorCoords.v = baseSectorCoords.v;
_sectorCoords.u = _baseSectorCoords.u;
_sectorCoords.v = _baseSectorCoords.v;
}
}
u = sectorCoords.u - baseSectorCoords.u;
v = sectorCoords.v - baseSectorCoords.v;
} while (sectorBitMask & (1 << (u * size.v + v)));
u = _sectorCoords.u - _baseSectorCoords.u;
v = _sectorCoords.v - _baseSectorCoords.v;
} while (_sectorBitMask & (1 << (u * _size.v + v)));
return true;
}
@ -3984,13 +3984,13 @@ ObjectID ActiveRegionObjectIterator::first(GameObject **obj) {
if (firstSector()) {
Sector *currentSector;
currentSector = currentWorld->getSector(
sectorCoords.u,
sectorCoords.v);
currentSector = _currentWorld->getSector(
_sectorCoords.u,
_sectorCoords.v);
assert(currentSector != nullptr);
currentObjectID = currentSector->childID;
currentObjectID = currentSector->_childID;
_currentObject = currentObjectID != Nothing
? GameObject::objectAddress(currentObjectID)
: nullptr;
@ -3998,13 +3998,13 @@ ObjectID ActiveRegionObjectIterator::first(GameObject **obj) {
while (currentObjectID == Nothing) {
if (!nextSector()) break;
currentSector = currentWorld->getSector(
sectorCoords.u,
sectorCoords.v);
currentSector = _currentWorld->getSector(
_sectorCoords.u,
_sectorCoords.v);
assert(currentSector != nullptr);
currentObjectID = currentSector->childID;
currentObjectID = currentSector->_childID;
_currentObject = currentObjectID != Nothing
? GameObject::objectAddress(currentObjectID)
: nullptr;
@ -4019,8 +4019,8 @@ ObjectID ActiveRegionObjectIterator::first(GameObject **obj) {
// Return the next object within the specified region
ObjectID ActiveRegionObjectIterator::next(GameObject **obj) {
assert(activeRegionIndex >= 0);
assert(activeRegionIndex < kPlayerActors);
assert(_activeRegionIndex >= 0);
assert(_activeRegionIndex < kPlayerActors);
ObjectID currentObjectID;
@ -4034,13 +4034,13 @@ ObjectID ActiveRegionObjectIterator::next(GameObject **obj) {
if (!nextSector()) break;
currentSector = currentWorld->getSector(
sectorCoords.u,
sectorCoords.v);
currentSector = _currentWorld->getSector(
_sectorCoords.u,
_sectorCoords.v);
assert(currentSector != nullptr);
currentObjectID = currentSector->childID;
currentObjectID = currentSector->_childID;
_currentObject = currentObjectID != Nothing
? GameObject::objectAddress(currentObjectID)
: nullptr;
@ -4058,19 +4058,19 @@ ObjectID ActiveRegionObjectIterator::next(GameObject **obj) {
ContainerIterator::ContainerIterator(GameObject *container) {
// Get the ID of the 1st object in the sector list
nextID = container->_data.childID;
object = nullptr;
_nextID = container->_data.childID;
_object = nullptr;
}
ObjectID ContainerIterator::next(GameObject **obj) {
ObjectID id = nextID;
ObjectID id = _nextID;
if (id == Nothing) return Nothing;
object = GameObject::objectAddress(id);
nextID = object->_data.siblingID;
_object = GameObject::objectAddress(id);
_nextID = _object->_data.siblingID;
if (obj) *obj = object;
if (obj) *obj = _object;
return id;
}
@ -4135,44 +4135,44 @@ ObjectID RecursiveContainerIterator::next(GameObject **obj) {
// This class iterates through every object within a container
ObjectID RecursiveContainerIterator::first(GameObject **obj) {
GameObject *rootObj = GameObject::objectAddress(root);
GameObject *rootObj = GameObject::objectAddress(_root);
id = rootObj->IDChild();
_id = rootObj->IDChild();
if (obj != nullptr)
*obj = id != Nothing ? GameObject::objectAddress(id) : nullptr;
*obj = _id != Nothing ? GameObject::objectAddress(_id) : nullptr;
return id;
return _id;
}
ObjectID RecursiveContainerIterator::next(GameObject **obj) {
GameObject *currentObj = GameObject::objectAddress(id);
GameObject *currentObj = GameObject::objectAddress(_id);
// If this object has a child, then the next object (id) is the child.
// If it has no child, then check for sibling.
if ((id = currentObj->IDChild()) == 0) {
if ((_id = currentObj->IDChild()) == 0) {
// If this object has a sibling, then the next object (id) is the sibling.
// If it has no sibling, then check for parent.
while ((id = currentObj->IDNext()) == 0) {
while ((_id = currentObj->IDNext()) == 0) {
// If this object has a parent, then the get the parent.
if ((id = currentObj->IDParent()) != 0) {
if ((_id = currentObj->IDParent()) != 0) {
// If the parent is the root, then we're done.
if (id == Nothing || id == root) return 0;
if (_id == Nothing || _id == _root) return 0;
// Set the current object to the parent, and then
// Go around the loop once again and get the sibling of the parent.
// The loop will keep going up until we either find an object that
// has a sibling, or we hit the original root object.
currentObj = GameObject::objectAddress(id);
currentObj = GameObject::objectAddress(_id);
}
}
}
if (obj != nullptr)
*obj = id != Nothing ? GameObject::objectAddress(id) : nullptr;
*obj = _id != Nothing ? GameObject::objectAddress(_id) : nullptr;
return id;
return _id;
}
/* ======================================================================= *
@ -4257,7 +4257,7 @@ bool lineOfSight(GameObject *obj1, GameObject *obj2, uint32 terrainMask) {
obj2Loc.z += obj2proto->height * 7 / 8;
return (lineTerrain(
world->mapNum,
world->_mapNum,
obj1Loc,
obj2Loc,
opaqueTerrain)
@ -4278,7 +4278,7 @@ bool lineOfSight(GameObject *obj, const TilePoint &loc, uint32 terrainMask) {
objLoc.z += proto->height * 7 / 8;
return (lineTerrain(
world->mapNum,
world->_mapNum,
objLoc,
loc,
opaqueTerrain)
@ -4299,7 +4299,7 @@ bool lineOfSight(
uint32 opaqueTerrain = ~terrainMask;
return (lineTerrain(
world->mapNum,
world->_mapNum,
loc1,
loc2,
opaqueTerrain)

View File

@ -736,16 +736,16 @@ public:
class Sector {
public:
uint16 activationCount;
ObjectID childID;
uint16 _activationCount;
ObjectID _childID;
Sector() :
activationCount(0),
childID(Nothing) {
_activationCount(0),
_childID(Nothing) {
}
bool isActivated() {
return activationCount != 0;
return _activationCount != 0;
}
void activate();
@ -776,13 +776,13 @@ class GameWorld : public GameObject {
friend class ObjectIterator;
public:
TilePoint size; // size of world in U/V coords
int16 sectorArraySize; // size of sector array
Sector *sectorArray; // array of sectors
int16 mapNum; // map number for this world.
TilePoint _size; // size of world in U/V coords
int16 _sectorArraySize; // size of sector array
Sector *_sectorArray; // array of sectors
int16 _mapNum; // map number for this world.
// Default constructor
GameWorld() : sectorArraySize(0), sectorArray(nullptr), mapNum(0) {}
GameWorld() : _sectorArraySize(0), _sectorArray(nullptr), _mapNum(0) {}
// Initial constructor
GameWorld(int16 map);
@ -799,22 +799,22 @@ public:
if (u == -1 && v == -1)
return nullptr;
if (v * sectorArraySize + u >= sectorArraySize * sectorArraySize ||
v * sectorArraySize + u < 0) {
warning("Sector::getSector: Invalid sector: (%d, %d) (sectorArraySize = %d)", u, v, sectorArraySize);
if (v * _sectorArraySize + u >= _sectorArraySize * _sectorArraySize ||
v * _sectorArraySize + u < 0) {
warning("Sector::getSector: Invalid sector: (%d, %d) (sectorArraySize = %d)", u, v, _sectorArraySize);
return nullptr;
}
return &(sectorArray)[v * sectorArraySize + u];
return &(_sectorArray)[v * _sectorArraySize + u];
}
TilePoint sectorSize() { // size of map in sectors
return TilePoint(sectorArraySize, sectorArraySize, 0);
return TilePoint(_sectorArraySize, _sectorArraySize, 0);
}
static uint32 IDtoMapNum(ObjectID id) {
assert(isWorld(id));
return ((GameWorld *)GameObject::objectAddress(id))->mapNum;
return ((GameWorld *)GameObject::objectAddress(id))->_mapNum;
}
};
@ -831,12 +831,12 @@ extern GameWorld *currentWorld;
inline int16 GameObject::getMapNum() {
if (world())
return world()->mapNum;
return world()->_mapNum;
else if (_data.siblingID) {
GameObject *sibling = GameObject::objectAddress(_data.siblingID);
return sibling->getMapNum();
} else
return currentWorld->mapNum;
return currentWorld->_mapNum;
}
/* ======================================================================= *
@ -861,10 +861,10 @@ class ActiveRegion {
friend class ActiveRegionObjectIterator;
ObjectID anchor; // ID of object this region is attached to
TilePoint anchorLoc; // Location of anchor
ObjectID worldID;
TileRegion region; // Region coords ( in sectors )
ObjectID _anchor; // ID of object this region is attached to
TilePoint _anchorLoc; // Location of anchor
ObjectID _worldID;
TileRegion _region; // Region coords ( in sectors )
public:
@ -872,7 +872,7 @@ public:
kActiveRegionSize = 22
};
ActiveRegion() : anchor(0), worldID(0) {}
ActiveRegion() : _anchor(0), _worldID(0) {}
void update();
void read(Common::InSaveFile *in);
@ -882,10 +882,10 @@ public:
TileRegion getRegion() {
TileRegion tReg;
tReg.min.u = region.min.u << kSectorShift;
tReg.min.v = region.min.v << kSectorShift;
tReg.max.u = region.max.u << kSectorShift;
tReg.max.v = region.max.v << kSectorShift;
tReg.min.u = _region.min.u << kSectorShift;
tReg.min.v = _region.min.v << kSectorShift;
tReg.max.u = _region.max.u << kSectorShift;
tReg.max.v = _region.max.v << kSectorShift;
tReg.min.z = tReg.max.z = 0;
return tReg;
@ -893,7 +893,7 @@ public:
// Return the region world
GameWorld *getWorld() {
return (GameWorld *)GameObject::objectAddress(worldID);
return (GameWorld *)GameObject::objectAddress(_worldID);
}
};
@ -933,10 +933,10 @@ public:
class SectorRegionObjectIterator : public ObjectIterator {
TilePoint minSector,
maxSector,
sectorCoords;
GameWorld *searchWorld;
TilePoint _minSector,
_maxSector,
_sectorCoords;
GameWorld *_searchWorld;
GameObject *_currentObject;
public:
@ -947,17 +947,17 @@ public:
SectorRegionObjectIterator(
GameWorld *world,
const TileRegion &sectorRegion) :
searchWorld(world),
minSector(sectorRegion.min),
maxSector(sectorRegion.max),
_searchWorld(world),
_minSector(sectorRegion.min),
_maxSector(sectorRegion.max),
_currentObject(nullptr) {
assert(searchWorld != NULL);
assert(isWorld(searchWorld));
assert(_searchWorld != NULL);
assert(isWorld(_searchWorld));
}
protected:
GameWorld *getSearchWorld() {
return searchWorld;
return _searchWorld;
}
public:
@ -976,8 +976,8 @@ public:
class RadialObjectIterator : public SectorRegionObjectIterator {
private:
TilePoint center;
int16 radius;
TilePoint _center;
int16 _radius;
// Compute the region of sectors to pass to the ObjectIterator
// constructor
@ -994,7 +994,7 @@ protected:
// Simply return the center coordinates
TilePoint getCenter() {
return center;
return _center;
}
public:
@ -1010,8 +1010,8 @@ public:
world->sectorSize(),
searchCenter,
distance)),
center(searchCenter),
radius(distance) {
_center(searchCenter),
_radius(distance) {
}
// Return the first object found
@ -1060,7 +1060,7 @@ public:
class RingObjectIterator : public CircularObjectIterator {
private:
int16 innerDist;
int16 _innerDist;
public:
// Constructor
@ -1070,7 +1070,7 @@ public:
int16 outerDistance,
int16 innerDistance) :
CircularObjectIterator(world, searchCenter, outerDistance) {
innerDist = innerDistance;
_innerDist = innerDistance;
}
ObjectID first(GameObject **obj);
@ -1222,12 +1222,12 @@ public:
class ActiveRegionObjectIterator : public ObjectIterator {
int16 activeRegionIndex;
TilePoint baseSectorCoords,
size,
sectorCoords;
uint8 sectorBitMask;
GameWorld *currentWorld;
int16 _activeRegionIndex;
TilePoint _baseSectorCoords,
_size,
_sectorCoords;
uint8 _sectorBitMask;
GameWorld *_currentWorld;
GameObject *_currentObject;
bool firstActiveRegion();
@ -1237,7 +1237,7 @@ class ActiveRegionObjectIterator : public ObjectIterator {
public:
// Constructor
ActiveRegionObjectIterator() : activeRegionIndex(-1), sectorBitMask(0), currentWorld(nullptr), _currentObject(nullptr) {}
ActiveRegionObjectIterator() : _activeRegionIndex(-1), _sectorBitMask(0), _currentWorld(nullptr), _currentObject(nullptr) {}
// Iteration functions
ObjectID first(GameObject **obj);
@ -1251,10 +1251,10 @@ public:
// This class iterates through every object within a container
class ContainerIterator {
ObjectID nextID;
ObjectID _nextID;
public:
GameObject *object;
GameObject *_object;
// Constructor
ContainerIterator(GameObject *container);
@ -1270,40 +1270,19 @@ public:
// This class iterates through every object within a container and
// all of the containers within the container
#if 0
class RecursiveContainerIterator {
ObjectID id;
RecursiveContainerIterator *subIter;
ObjectID _id,
_root;
public:
// Constructor
RecursiveContainerIterator(GameObject *container) :
id(container->IDChild()),
subIter(NULL) {
}
~RecursiveContainerIterator();
_root(container->thisID()), _id(0) {}
// Iteration functions
ObjectID first(GameObject **obj);
ObjectID next(GameObject **obj);
};
#else
class RecursiveContainerIterator {
ObjectID id,
root;
public:
// Constructor
RecursiveContainerIterator(GameObject *container) :
root(container->thisID()), id(0) {}
// Iteration functions
ObjectID first(GameObject **obj);
ObjectID next(GameObject **obj);
};
#endif
/* ============================================================================ *
Object sound effect struct

View File

@ -366,7 +366,7 @@ inline GameWorld *Effectron::world() const {
return parent->world;
}
inline int16 Effectron::getMapNum() const {
return parent->world->mapNum;
return parent->world->_mapNum;
}
inline EffectID Effectron::spellID() {

View File

@ -236,7 +236,7 @@ TilePoint TileTarget::where(GameWorld *world, const TilePoint &tp) const {
tileReg.max.v = (tp.v + maxTileDist - 1 + kTileUVMask)
>> kTileUVShift;
TileIterator tIter(world->mapNum, tileReg);
TileIterator tIter(world->_mapNum, tileReg);
// Get the first tile in tile region
ti = tIter.first(&tileCoords, &sti);
@ -291,7 +291,7 @@ int16 TileTarget::where(
tileReg.max.v = (tp.v + maxTileDist - 1 + kTileUVMask)
>> kTileUVShift;
TileIterator tIter(world->mapNum, tileReg);
TileIterator tIter(world->_mapNum, tileReg);
// Get the first tile in tile region
ti = tIter.first(&tileCoords, &sti);
@ -468,12 +468,12 @@ TilePoint MetaTileTarget::where(
tileReg.max.v = (tp.v + maxMetaDist + kTileUVMask)
>> kTileUVShift;
MetaTileIterator mIter(world->mapNum, tileReg);
MetaTileIterator mIter(world->_mapNum, tileReg);
// get the first metatile in region
mt = mIter.first(&metaCoords);
while (mt != nullptr) {
if (isTarget(mt, world->mapNum, metaCoords)) {
if (isTarget(mt, world->_mapNum, metaCoords)) {
uint16 dist;
metaCoords.u <<= kTileUVShift;
@ -522,12 +522,12 @@ int16 MetaTileTarget::where(
tileReg.max.v = (tp.v + maxMetaDist + kTileUVMask)
>> kTileUVShift;
MetaTileIterator mIter(world->mapNum, tileReg);
MetaTileIterator mIter(world->_mapNum, tileReg);
// Get the first metatile in tile region
mt = mIter.first(&metaCoords);
while (mt != nullptr) {
if (isTarget(mt, world->mapNum, metaCoords)) {
if (isTarget(mt, world->_mapNum, metaCoords)) {
uint16 dist;
metaCoords.u <<= kTileUVShift;

View File

@ -4317,7 +4317,7 @@ void updateMainDisplay() {
if (viewWorld != currentWorld) {
currentWorld = viewWorld;
setCurrentMap(currentWorld->mapNum);
setCurrentMap(currentWorld->_mapNum);
}
WorldMapData *curMap = &mapList[g_vm->_currentMapNum];

View File

@ -655,7 +655,7 @@ void TileModeSetup() {
lastUpdateTime = gameTime;
setCurrentWorld(WorldBaseID);
setCurrentMap(currentWorld->mapNum);
setCurrentMap(currentWorld->_mapNum);
}
//-----------------------------------------------------------------------