Fixed Bug #438896: Platform destroyed in fog of war
Fixed Bug #676724: Buildings Not Updated Until seen in viewport
This commit is contained in:
parent
02f05991d0
commit
fee9ec2f6e
7 changed files with 84 additions and 28 deletions
|
@ -153,7 +153,7 @@ local int MoveToResource(Unit* unit,const Resource* resource)
|
|||
goal->Frame=resource->Frame;
|
||||
CheckUnitToBeDrawn(goal);
|
||||
}
|
||||
|
||||
UnitMarkSeen(goal);
|
||||
//
|
||||
// Place unit inside the resource
|
||||
//
|
||||
|
@ -239,6 +239,7 @@ local int WaitInResource(Unit* unit,const Resource* resource)
|
|||
source->Frame=0;
|
||||
CheckUnitToBeDrawn(source);
|
||||
}
|
||||
UnitMarkSeen(source);
|
||||
if( IsOnlySelected(source) ) {
|
||||
MustRedraw|=RedrawInfoPanel;
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@ global void ActionStillGeneric(Unit* unit,int ground)
|
|||
if( unit->State==1 && type->GivesOil ) {
|
||||
unit->Frame=unit->Data.Resource.Active ? 2 : 0;
|
||||
}
|
||||
UnitMarkSeen(unit);
|
||||
}
|
||||
|
||||
if( !unit->Reset ) { // animation can't be aborted here
|
||||
|
|
|
@ -65,6 +65,7 @@ global void HandleActionUpgradeTo(Unit* unit)
|
|||
type=unit->Orders[0].Type;
|
||||
stats=&type->Stats[player->Player];
|
||||
|
||||
UnitMarkSeen(unit);
|
||||
// FIXME: Should count down here
|
||||
unit->Data.UpgradeTo.Ticks+=SpeedUpgrade;
|
||||
if( unit->Data.UpgradeTo.Ticks>=stats->Costs[TimeCost] ) {
|
||||
|
|
|
@ -749,6 +749,10 @@ extern int UnitVisibleOnMap(const Unit* unit);
|
|||
/// Returns true, if building is known on the map
|
||||
extern int BuildingVisibleOnMap(Unit* unit);
|
||||
#endif
|
||||
/// Updates seen data
|
||||
extern void UnitsMarkSeen(int x,int y);
|
||||
/// Checks and updates if a Unit's seen information
|
||||
extern void UnitMarkSeen(Unit* unit);
|
||||
/// Returns true, if unit is known on the map
|
||||
extern int UnitKnownOnMap(const Unit* unit);
|
||||
|
||||
|
|
|
@ -310,6 +310,7 @@ global void MapMarkSight(const Player* player,int tx,int ty,int range)
|
|||
if( i >= (*corpses)->X && y >= (*corpses)->Y
|
||||
&& i < (*corpses)->X+w && y < (*corpses)->Y+h ) {
|
||||
(*corpses)->Visible &= ~(1 << player->Player);
|
||||
UnitMarkSeen(*corpses);
|
||||
}
|
||||
}
|
||||
remove = corpses;
|
||||
|
@ -322,6 +323,7 @@ global void MapMarkSight(const Player* player,int tx,int ty,int range)
|
|||
#endif
|
||||
if( IsTileVisible(ThisPlayer,i,y) > 1) {
|
||||
MapMarkSeenTile(i,y);
|
||||
UnitsMarkSeen(i,y);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -404,6 +406,7 @@ global void MapUnmarkSight(const Player* player,int tx,int ty,int range)
|
|||
// Check visible Tile, then deduct...
|
||||
if( IsTileVisible(ThisPlayer,i,y) > 1) {
|
||||
MapMarkSeenTile(i,y);
|
||||
UnitsMarkSeen(i,y);
|
||||
}
|
||||
default: // seen -> seen
|
||||
TheMap.Fields[i+y*TheMap.Width].Visible[p]=v-1;
|
||||
|
@ -427,8 +430,9 @@ global void MapUnmarkSight(const Player* player,int tx,int ty,int range)
|
|||
global void MapMarkNewSight(const Player* player,int tx,int ty,int range
|
||||
,int dx __attribute__((unused)),int dy __attribute__((unused)))
|
||||
{
|
||||
MapUnmarkSight(player,tx-dx,ty-dy,range);
|
||||
/// It's faster to mark then unmark.
|
||||
MapMarkSight(player,tx,ty,range);
|
||||
MapUnmarkSight(player,tx-dx,ty-dy,range);
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
@ -561,6 +561,7 @@ global void PlaceUnit(Unit* unit,int x,int y)
|
|||
|
||||
MustRedraw|=RedrawMinimap;
|
||||
CheckUnitToBeDrawn(unit);
|
||||
UnitMarkSeen(unit);
|
||||
|
||||
//
|
||||
// Building oil-platform, must remove oil-patch.
|
||||
|
@ -1097,6 +1098,62 @@ global int BuildingVisibleOnMap(Unit* unit)
|
|||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
** @param x x location to check if building is on, and mark as seen
|
||||
** @param y y location to check if building is on, and mark as seen
|
||||
**
|
||||
**/
|
||||
global void UnitsMarkSeen(int x,int y)
|
||||
{
|
||||
int n;
|
||||
Unit* units[4];
|
||||
|
||||
n = UnitCacheOnTile(x,y,units);
|
||||
// FIXME: need to handle Dead buldings
|
||||
while( n ) {
|
||||
units[n-1]->SeenIY=units[n-1]->IY;
|
||||
units[n-1]->SeenIX=units[n-1]->IX;
|
||||
units[n-1]->SeenFrame = units[n-1]->Frame;
|
||||
units[n-1]->SeenType = units[n-1]->Type;
|
||||
units[n-1]->SeenState = (units[n-1]->Orders[0].Action==UnitActionBuilded) |
|
||||
((units[n-1]->Orders[0].Action==UnitActionUpgradeTo) << 1);
|
||||
units[n-1]->SeenConstructed = units[n-1]->Constructed;
|
||||
--n;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** @param unit pointer to the unit to check if seen
|
||||
**
|
||||
**/
|
||||
global void UnitMarkSeen(Unit* unit)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
|
||||
// Update Building Seen
|
||||
if( !unit->Type ) {
|
||||
DebugLevel0Fn("UnitMarkSeen: Type is NULL\n" );
|
||||
return;
|
||||
}
|
||||
for (x=0; x<unit->Type->TileWidth; x++) {
|
||||
for (y=0; y<unit->Type->TileHeight; y++) {
|
||||
if( IsMapFieldVisible(ThisPlayer,unit->X+x,unit->Y+y) ) {
|
||||
unit->SeenIY=unit->IY;
|
||||
unit->SeenIX=unit->IX;
|
||||
unit->SeenFrame = unit->Frame;
|
||||
unit->SeenType = unit->Type;
|
||||
unit->SeenState = (unit->Orders[0].Action==UnitActionBuilded) |
|
||||
((unit->Orders[0].Action==UnitActionUpgradeTo) << 1);
|
||||
unit->SeenConstructed = unit->Constructed;
|
||||
x=unit->Type->TileWidth;
|
||||
y=unit->Type->TileHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Returns true, if unit is known on the map. Special case for buildings.
|
||||
**
|
||||
|
@ -3372,10 +3429,12 @@ global void LetUnitDie(Unit* unit)
|
|||
#else
|
||||
CorpseCacheInsert(unit);
|
||||
#endif
|
||||
UnitMarkSeen(unit);
|
||||
return;
|
||||
}
|
||||
|
||||
// no corpse available
|
||||
UnitMarkSeen(unit);
|
||||
ReleaseUnit(unit);
|
||||
return;
|
||||
}
|
||||
|
@ -3411,9 +3470,7 @@ global void LetUnitDie(Unit* unit)
|
|||
unit->Reset=0;
|
||||
unit->Wait=1;
|
||||
unit->Orders[0].Action=UnitActionDie;
|
||||
// if( unit->Type->CorpseType || unit->Type->Vanishes ) {
|
||||
CorpseCacheInsert(unit); //Insert into corpse list
|
||||
// }
|
||||
CorpseCacheInsert(unit); //Insert into corpse list
|
||||
|
||||
#ifdef NEW_FOW
|
||||
if( unit->Type->CorpseType ) {
|
||||
|
|
|
@ -1755,27 +1755,6 @@ local void DrawBuilding(Unit* unit)
|
|||
#else
|
||||
visible=UnitVisibleOnMap(unit);
|
||||
#endif
|
||||
// FIXME: is this the correct place? No, but now correct working.
|
||||
if( visible ) {
|
||||
y=unit->SeenIY=unit->IY;
|
||||
x=unit->SeenIX=unit->IX;
|
||||
frame = unit->SeenFrame = unit->Frame;
|
||||
type = unit->SeenType = unit->Type;
|
||||
state = unit->SeenState = (unit->Orders[0].Action==UnitActionBuilded) |
|
||||
((unit->Orders[0].Action==UnitActionUpgradeTo) << 1);
|
||||
constructed = unit->SeenConstructed = unit->Constructed;
|
||||
|
||||
} else {
|
||||
y=unit->SeenIY;
|
||||
x=unit->SeenIX;
|
||||
frame = unit->SeenFrame;
|
||||
type = unit->SeenType;
|
||||
constructed = unit->SeenConstructed;
|
||||
state = unit->SeenState;
|
||||
if( !ReplayRevealMap ) {
|
||||
DebugCheck( frame==UnitNotSeen );
|
||||
}
|
||||
}
|
||||
|
||||
if( ReplayRevealMap ) {
|
||||
type = unit->Type;
|
||||
|
@ -1785,8 +1764,17 @@ local void DrawBuilding(Unit* unit)
|
|||
state = (unit->Orders[0].Action==UnitActionBuilded) |
|
||||
((unit->Orders[0].Action==UnitActionUpgradeTo) << 1);
|
||||
constructed = unit->Constructed;
|
||||
} else {
|
||||
y=unit->SeenIY;
|
||||
x=unit->SeenIX;
|
||||
frame = unit->SeenFrame;
|
||||
type = unit->SeenType;
|
||||
constructed = unit->SeenConstructed;
|
||||
state = unit->SeenState;
|
||||
}
|
||||
|
||||
|
||||
DebugCheck( frame==UnitNotSeen );
|
||||
|
||||
x+=Map2ViewportX(CurrentViewport,unit->X);
|
||||
y+=Map2ViewportY(CurrentViewport,unit->Y);
|
||||
|
||||
|
@ -1924,7 +1912,7 @@ global void DrawUnits(const void* v)
|
|||
//
|
||||
corpses = &DestroyedBuildings;
|
||||
while( *corpses ) {
|
||||
if( UnitVisibleInViewport(vp,*corpses) && (*corpses)->Visible&(1 << ThisPlayer->Player) ) {
|
||||
if( UnitVisibleInViewport(vp,*corpses) ) {
|
||||
DrawBuilding(*corpses);
|
||||
}
|
||||
corpses=&(*corpses)->Next;
|
||||
|
|
Loading…
Add table
Reference in a new issue