Simplify the vision code a bit. Behaviour should be exactly identical.

master
per 2013-12-08 11:28:27 +01:00
parent eb9e6ee9f3
commit 5057823792
1 changed files with 9 additions and 20 deletions

View File

@ -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)