SAGA2: Fix nullptr access in Sector iterators

This commit is contained in:
a/ 2021-08-15 08:36:30 +09:00
parent ec88076e91
commit 29c5f6e749
2 changed files with 13 additions and 3 deletions

View File

@ -3379,6 +3379,10 @@ ObjectID SectorRegionObjectIterator::first(GameObject **obj) {
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;
@ -3625,12 +3629,18 @@ ObjectID RegionalObjectIterator::first(GameObject **obj) {
ObjectID currentObjectID;
currentObjectID = SectorRegionObjectIterator::first(&currentObject);
if (currentObjectID == Nothing)
return Nothing;
while (currentObjectID != Nothing
&& !inRegion(currentObject->getLocation())) {
currentObjectID = SectorRegionObjectIterator::next(&currentObject);
}
if (obj != nullptr) *obj = currentObject;
if (obj != nullptr)
*obj = currentObject;
return currentObjectID;
}

View File

@ -1463,7 +1463,7 @@ void PathRequest::initialize(void) {
baseCoords.v
+ (searchCenter << kTileUVShift) * 2,
0));
GameObject *obj;
GameObject *obj = nullptr;
for (iter.first(&obj);
obj != nullptr;
@ -2497,7 +2497,7 @@ TilePoint selectNearbySite(
baseCoords.v
+ (searchCenter << kTileUVShift) * 2,
0));
GameObject *obj;
GameObject *obj = nullptr;
for (iter.first(&obj);
obj != nullptr;