From 2826dae999bfdb10b23da31f8263d29204f4e10f Mon Sep 17 00:00:00 2001 From: mr-russ <> Date: Mon, 24 Feb 2003 00:02:51 +0000 Subject: [PATCH] Fixed bug #690843: Shared vision tiles aren't explored Fixed bug #691057: Shared vision and destroyed buildings Fixed bug when shared vision didn't update seen tiles when sharing vision --- doc/ChangeLog.html | 6 +++++ src/action/command.cpp | 50 +++++++++++++++++++++++++++++++++++++++++- src/unit/unit.cpp | 1 + src/unit/unit_draw.cpp | 3 ++- 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/doc/ChangeLog.html b/doc/ChangeLog.html index 85fd2ac6d..975c54e89 100644 --- a/doc/ChangeLog.html +++ b/doc/ChangeLog.html @@ -1082,6 +1082,12 @@ <LI>Fixed bug #690171: Crash building oil platform with UNITS_ON_MAP (from Jimmy Salmon). <LI>Fixed bug #690232: AI can't pass walls (from Jimmy Salmon). + <LI>Fixed bug #690843: Shared vision tiles aren't explored (from Russell + Smith). + <LI>Fixed bug #691057: Shared vision and destroyed buildings (from + Russell Smith). + <LI>Fixed bug when shared vision didn't update seen tiles when sharing + vision (from Russell Smith). <LI>+++ </UL> </UL> diff --git a/src/action/command.cpp b/src/action/command.cpp index 14ccd59e5..68094a253 100644 --- a/src/action/command.cpp +++ b/src/action/command.cpp @@ -138,6 +138,7 @@ local void ClearSavedAction(Unit* unit) global void CommandQuit(int player) { int i; + int j; if (Players[player].TotalNumUnits != 0) { // Set player to neutral, remove allied/enemy/shared vision status @@ -148,6 +149,22 @@ global void CommandQuit(int player) } Players[i].Allied &= ~(1 << player); Players[i].Enemy &= ~(1 << player); +#ifdef NEW_FOW + // Check All tiles and mark unseen ones as explored. + if (Players[player].SharedVision&(1<<i) && + (Players[i].SharedVision&(1<<player))) { + for(j=0;j<TheMap.Width*TheMap.Height;j++) { + if (TheMap.Fields[j].Visible[i] && + !TheMap.Fields[j].Visible[player]) { + TheMap.Fields[j].Visible[player]=1; + } + if (TheMap.Fields[j].Visible[player] && + !TheMap.Fields[j].Visible[i]) { + TheMap.Fields[j].Visible[i]=1; + } + } + } +#endif Players[i].SharedVision &= ~(1 << player); Players[player].Allied &= ~(1 << i); Players[player].Enemy &= ~(1 << i); @@ -1388,9 +1405,41 @@ global void CommandSharedVision(int player,int state,int opponent) Unit* unit; if( state==0 ) { +#ifdef NEW_FOW + // Check All tiles and mark unseen ones as explored. + if (Players[player].SharedVision&(1<<opponent) && + (Players[opponent].SharedVision&(1<<player))) { + for(i=0;i<TheMap.Width*TheMap.Height;i++) { + if (TheMap.Fields[i].Visible[opponent] && + !TheMap.Fields[i].Visible[player]) { + TheMap.Fields[i].Visible[player]=1; + } + if (TheMap.Fields[i].Visible[player] && + !TheMap.Fields[i].Visible[opponent]) { + TheMap.Fields[i].Visible[opponent]=1; + } + } + } +#endif Players[player].SharedVision&=~(1<<opponent); } else { Players[player].SharedVision|=(1<<opponent); +#ifdef NEW_FOW + // Check All tiles and mark SeenTiles for wood + if (Players[player].SharedVision&(1<<opponent) && + (Players[opponent].SharedVision&(1<<player)) + && (player==ThisPlayer->Player || opponent==ThisPlayer->Player)) { + int y; + for(i=0;i<TheMap.Width;i++) { + for(y=0;y<TheMap.Height;y++) { + if( IsTileVisible(ThisPlayer,i,y) > 1) { + MapMarkSeenTile(i,y); + UnitsMarkSeen(i,y); + } + } + } + } +#endif } // MUST update seen buildings when vision is shared or unshared for( i=0; i<NumUnits; ++i) { @@ -1398,7 +1447,6 @@ global void CommandSharedVision(int player,int state,int opponent) UnitMarkSeen(unit); } - } //@} diff --git a/src/unit/unit.cpp b/src/unit/unit.cpp index 5be4b2984..fb191ea46 100644 --- a/src/unit/unit.cpp +++ b/src/unit/unit.cpp @@ -184,6 +184,7 @@ global void ReleaseUnit(Unit* unit) for( ; h-->0; ) { for( w=w0; w-->0; ) { if( !IsMapFieldVisible(&Players[i],x+w,y+h) + && IsMapFieldExplored(&Players[i],x+w,y+h) && Players[i].Type == PlayerPerson ) { unit->Visible |= (1 << i); } diff --git a/src/unit/unit_draw.cpp b/src/unit/unit_draw.cpp index a7f2331d1..59187512c 100644 --- a/src/unit/unit_draw.cpp +++ b/src/unit/unit_draw.cpp @@ -1912,7 +1912,8 @@ global void DrawUnits(const void* v) // corpses = &DestroyedBuildings; while( *corpses ) { - if( UnitVisibleInViewport(vp,*corpses) && !(*corpses)->SeenDestroyed ) { + if( UnitVisibleInViewport(vp,*corpses) && !(*corpses)->SeenDestroyed + && ((*corpses)->Visible & 1<<ThisPlayer->Player)) { DrawBuilding(*corpses); } corpses=&(*corpses)->Next;