Skip to content

Commit

Permalink
Make newly-built structures and droids instantly visible to allies.
Browse files Browse the repository at this point in the history
This prevents ally blueprints from disappearing before the structure is visible.

And fix DROID::seenThisTick uninitialised due to wrong memset, might have been a possible cause of desynch.
  • Loading branch information
Cyp committed Nov 24, 2011
1 parent 7c3f9ba commit db86404
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/droid.cpp
Expand Up @@ -2255,9 +2255,11 @@ DROID *reallyBuildDroid(DROID_TEMPLATE *pTemplate, Position pos, UDWORD player,
//init the resistance to indicate no EW performed on this droid
psDroid->resistance = ACTION_START_TIME;

memset(psDroid->visible, 0, sizeof(psDroid->visible));
memset(psDroid->visible, 0, sizeof(psDroid->seenThisTick));
psDroid->visible[psDroid->player] = UBYTE_MAX;
for (unsigned vPlayer = 0; vPlayer < MAX_PLAYERS; ++vPlayer)
{
psDroid->visible[vPlayer] = hasSharedVision(vPlayer, player)? UINT8_MAX : 0;
}
memset(psDroid->seenThisTick, 0, sizeof(psDroid->seenThisTick));
psDroid->died = 0;
psDroid->inFire = 0;
psDroid->burnStart = 0;
Expand Down
8 changes: 5 additions & 3 deletions src/structure.cpp
Expand Up @@ -1647,11 +1647,13 @@ STRUCTURE* buildStructureDir(STRUCTURE_STATS *pStructureType, UDWORD x, UDWORD y
psBuilding->lastResistance = ACTION_START_TIME;

// Do the visibility stuff before setFunctionality - so placement of DP's can work
memset(psBuilding->visible, 0, sizeof(psBuilding->visible));
memset(psBuilding->seenThisTick, 0, sizeof(psBuilding->seenThisTick));

/* Structure is trivially visible to the builder (owner) */
psBuilding->visible[player] = UBYTE_MAX;
// Structure is visible to anyone with shared vision.
for (unsigned vPlayer = 0; vPlayer < MAX_PLAYERS; ++vPlayer)
{
psBuilding->visible[vPlayer] = hasSharedVision(vPlayer, player)? UINT8_MAX : 0;
}

// Reveal any tiles that can be seen by the structure
visTilesUpdate(psBuilding);
Expand Down

0 comments on commit db86404

Please sign in to comment.