Skip to content

Commit

Permalink
Attempt to fix the visibility voodoo that doesn't account for mission…
Browse files Browse the repository at this point in the history
… swapping

voodoo that is bad juju.

refs ticket:2265
refs ticket:2256
  • Loading branch information
buginator committed Oct 27, 2010
1 parent f340607 commit c32f6f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/mission.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,7 @@ BOOL missionShutDown(void)
{
UDWORD inc;

debug(LOG_SAVE, "called, mission is %s",
missionIsOffworld() ? "off-world" : "main map");
debug(LOG_SAVE, "called, mission is %s", missionIsOffworld() ? "off-world" : "main map");
if (missionIsOffworld())
{
//clear out the audio
Expand Down Expand Up @@ -1366,7 +1365,8 @@ static void processMission(void)
psNext = psDroid->psNext;
//reset order - do this to all the droids that are returning from offWorld
orderDroid(psDroid, DORDER_STOP);

// clean up visibility
visRemoveVisibility(psDroid);
//remove out of stored list and add to current Droid list
if (droidRemove(psDroid, apsDroidLists))
{
Expand Down Expand Up @@ -1446,6 +1446,8 @@ void processMissionLimbo(void)

/*switch the pointers for the map and droid lists so that droid placement
and orientation can occur on the map they will appear on*/
// NOTE: This is one huge hack for campaign games!
// Pay special attention on what is getting swapped!
void swapMissionPointers(void)
{
void *pVoid;
Expand Down
7 changes: 6 additions & 1 deletion src/visibility.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ BOOL visTilesPending(BASE_OBJECT *psObj)
/* Remove tile visibility from object */
void visRemoveVisibility(BASE_OBJECT *psObj)
{
if (psObj->watchedTiles && psObj->numWatchedTiles > 0)
if (psObj->watchedTiles && psObj->numWatchedTiles > 0 && mapWidth && mapHeight)
{
int i = 0;

Expand All @@ -287,6 +287,11 @@ void visRemoveVisibility(BASE_OBJECT *psObj)
const TILEPOS pos = psObj->watchedTiles[i];
MAPTILE *psTile = mapTile(pos.x, pos.y);

// FIXME: the mapTile might have been swapped out, see swapMissionPointers()
if (psTile->watchers[psObj->player] == 0 && game.type == CAMPAIGN)
{
continue;
}
ASSERT(psTile->watchers[psObj->player] > 0, "Not watching watched tile (%d, %d)", (int)pos.x, (int)pos.y);
psTile->watchers[psObj->player]--;
}
Expand Down

0 comments on commit c32f6f5

Please sign in to comment.