Simplify the vision code a bit. Behaviour should be exactly identical.
parent
eb9e6ee9f3
commit
5057823792
|
@ -329,7 +329,7 @@ static void doWaveTerrain(const BASE_OBJECT *psObj, TILEPOS *recordTilePos, int
|
|||
/* Remove tile visibility from object */
|
||||
void visRemoveVisibility(BASE_OBJECT *psObj)
|
||||
{
|
||||
if (psObj->watchedTiles && psObj->numWatchedTiles > 0 && mapWidth && mapHeight)
|
||||
if (psObj->watchedTiles && mapWidth && mapHeight)
|
||||
{
|
||||
for (int i = 0; i < psObj->numWatchedTiles; i++)
|
||||
{
|
||||
|
@ -338,24 +338,13 @@ void visRemoveVisibility(BASE_OBJECT *psObj)
|
|||
MAPTILE *psTile = mapTile(pos.x, pos.y);
|
||||
|
||||
ASSERT(pos.type < 2, "Invalid visibility type %d", (int)pos.type);
|
||||
if (pos.type == 1)
|
||||
uint8_t *visionType = (pos.type == 0) ? psTile->sensors : psTile->watchers;
|
||||
if (visionType[psObj->player] == 0 && game.type == CAMPAIGN) // hack
|
||||
{
|
||||
if (psTile->watchers[psObj->player] == 0 && game.type == CAMPAIGN) // hack
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ASSERT(psTile->watchers[psObj->player] > 0, "Not watching watched tile (%d, %d)", (int)pos.x, (int)pos.y);
|
||||
psTile->watchers[psObj->player]--;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (psTile->sensors[psObj->player] == 0 && game.type == CAMPAIGN) // hack
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ASSERT(psTile->sensors[psObj->player] > 0, "No sensor on tile (%d, %d)", (int)pos.x, (int)pos.y);
|
||||
psTile->sensors[psObj->player]--;
|
||||
continue;
|
||||
}
|
||||
ASSERT(visionType[psObj->player] > 0, "No %s on watched tile (%d, %d)", pos.type ? "radar" : "vision", (int)pos.x, (int)pos.y);
|
||||
visionType[psObj->player]--;
|
||||
if (objJammerPower(psObj) > 0) // we are a jammer object
|
||||
{
|
||||
// No jammers in campaign, no need for special hack
|
||||
|
@ -368,10 +357,10 @@ void visRemoveVisibility(BASE_OBJECT *psObj)
|
|||
}
|
||||
updateTileVis(psTile);
|
||||
}
|
||||
free(psObj->watchedTiles);
|
||||
psObj->watchedTiles = NULL;
|
||||
psObj->numWatchedTiles = 0;
|
||||
}
|
||||
free(psObj->watchedTiles);
|
||||
psObj->watchedTiles = NULL;
|
||||
psObj->numWatchedTiles = 0;
|
||||
}
|
||||
|
||||
void visRemoveVisibilityOffWorld(BASE_OBJECT *psObj)
|
||||
|
|
Loading…
Reference in New Issue