Removed NEW_FOW tags, to make it the new and only fog of war.
This commit is contained in:
parent
01188dcaeb
commit
b88fc1ad35
24 changed files with 38 additions and 553 deletions
src
action
game
include
map
stratagus
ui
unit
|
@ -189,14 +189,11 @@ global void HandleActionBuild(Unit* unit)
|
|||
|
||||
build=MakeUnit(type,unit->Player);
|
||||
build->Constructed=1;
|
||||
#ifdef NEW_FOW
|
||||
build->CurrentSightRange=0;
|
||||
#endif
|
||||
PlaceUnit(build,x,y);
|
||||
#ifdef NEW_FOW
|
||||
build->CurrentSightRange=build->Type->TileWidth < build->Type->TileHeight
|
||||
? build->Type->TileHeight : build->Type->TileWidth;
|
||||
#endif
|
||||
|
||||
|
||||
/* Done by PlaceUnit now
|
||||
#ifdef HIERARCHIC_PATHFINDER
|
||||
|
@ -249,9 +246,7 @@ global void HandleActionBuild(Unit* unit)
|
|||
unit->Value=build->Value; // worker holding value while building
|
||||
|
||||
RemoveUnit(unit,build); // automaticly: CheckUnitToBeDrawn(unit)
|
||||
#ifdef NEW_FOW
|
||||
build->CurrentSightRange=0;
|
||||
#endif
|
||||
unit->X=x;
|
||||
unit->Y=y;
|
||||
unit->Orders[0].Action=UnitActionStill;
|
||||
|
@ -373,12 +368,10 @@ global void HandleActionBuilded(Unit* unit)
|
|||
} else if( unit->Player==ThisPlayer ) {
|
||||
UpdateButtonPanel();
|
||||
}
|
||||
#ifdef NEW_FOW
|
||||
unit->CurrentSightRange=unit->Stats->SightRange;
|
||||
MapMarkSight(unit->Player,unit->X+unit->Type->TileWidth/2,
|
||||
unit->Y+unit->Type->TileWidth/2,
|
||||
unit->CurrentSightRange);
|
||||
#endif
|
||||
CheckUnitToBeDrawn(unit);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -72,11 +72,9 @@ global void HandleActionDie(Unit* unit)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef NEW_FOW
|
||||
//Fixes sight from death
|
||||
MapUnmarkSight(unit->Player,unit->X,unit->Y,unit->CurrentSightRange);
|
||||
//unit->CurrentSightRange=unit->Type->Stats->SightRange;
|
||||
#endif
|
||||
|
||||
unit->State=unit->Type->CorpseScript;
|
||||
unit->Type=unit->Type->CorpseType;
|
||||
|
|
|
@ -147,7 +147,7 @@ local int ActionMoveGeneric(Unit* unit,const Animation* anim)
|
|||
//
|
||||
x+=unit->Type->TileWidth/2;
|
||||
y+=unit->Type->TileHeight/2;
|
||||
#ifdef NEW_FOW
|
||||
|
||||
MapMarkNewSight(unit->Player,x,y,unit->Stats->SightRange,xd,yd);
|
||||
if ( unit->Type->Transporter ) {
|
||||
for( i=0; i<MAX_UNITS_ONBOARD; ++i ) {
|
||||
|
@ -157,11 +157,7 @@ local int ActionMoveGeneric(Unit* unit,const Animation* anim)
|
|||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if( unit->Player==ThisPlayer ) {
|
||||
MapMarkNewSight(x,y,unit->Stats->SightRange,xd,yd);
|
||||
}
|
||||
#endif
|
||||
|
||||
if( unit->Type->CanSeeSubmarine ) {
|
||||
MarkSubmarineSeen(unit->Player,x,y,unit->Stats->SightRange);
|
||||
}
|
||||
|
|
|
@ -109,10 +109,9 @@ global void HandleActionTrain(Unit* unit)
|
|||
nunit->X=unit->X;
|
||||
nunit->Y=unit->Y;
|
||||
type=unit->Type;
|
||||
#ifdef NEW_FOW
|
||||
// Set unit to belong to the building building it.
|
||||
nunit->Next=unit;
|
||||
#endif
|
||||
|
||||
DropOutOnSide(nunit,LookingW,type->TileWidth,type->TileHeight);
|
||||
|
||||
// set life span
|
||||
|
|
|
@ -149,7 +149,6 @@ 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)) ) {
|
||||
|
@ -164,7 +163,6 @@ global void CommandQuit(int player)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Players[i].SharedVision&=~(1<<player);
|
||||
Players[player].Allied&=~(1<<i);
|
||||
Players[player].Enemy&=~(1<<i);
|
||||
|
@ -1405,7 +1403,6 @@ 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)) ) {
|
||||
|
@ -1420,11 +1417,9 @@ global void CommandSharedVision(int player,int state,int opponent)
|
|||
}
|
||||
}
|
||||
}
|
||||
#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)
|
||||
|
@ -1440,7 +1435,6 @@ global void CommandSharedVision(int player,int state,int opponent)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// MUST update seen buildings when vision is shared or unshared
|
||||
for( i=0; i<NumUnits; ++i ) {
|
||||
|
|
|
@ -312,12 +312,6 @@ global void CreateGame(char* filename, WorldMap* map)
|
|||
}
|
||||
//GamePaused=1;
|
||||
|
||||
if( NetworkFildes!=-1 && TheMap.NoFogOfWar ) {
|
||||
// FIXME: In multiplayer the map setup didn't reveal placed units.
|
||||
TheMap.NoFogOfWar = 0;
|
||||
MapUpdateVisible();
|
||||
TheMap.NoFogOfWar = 1;
|
||||
}
|
||||
if( FlagRevealMap ) {
|
||||
RevealMap();
|
||||
}
|
||||
|
|
|
@ -220,9 +220,7 @@ typedef struct _map_field_ {
|
|||
// FIXME: Value can be removed, walls and regeneration can be handled
|
||||
// different.
|
||||
unsigned char Value; /// HP for walls/ Wood Regeneration
|
||||
#ifdef NEW_FOW
|
||||
unsigned char Visible[PlayerMax]; /// Seen counter 0 unexplored
|
||||
#endif
|
||||
#ifdef UNIT_ON_MAP
|
||||
union {
|
||||
Unit* Units; /// An unit on the map field
|
||||
|
@ -253,11 +251,6 @@ typedef struct _map_field_ {
|
|||
#endif
|
||||
} MapField;
|
||||
|
||||
#ifndef NEW_FOW
|
||||
// 0 Unexplored, 1 Explored, 2 PartialVisible, 3 CompleteVisible
|
||||
#define MapFieldExplored 0x0002 /// Field explored
|
||||
#endif
|
||||
|
||||
// Not used until now:
|
||||
//#define MapFieldArray 0x0004 /// More than one unit on the field
|
||||
|
||||
|
@ -400,7 +393,6 @@ extern void MarkDrawEntireMap(void);
|
|||
//
|
||||
// in map_fog.c
|
||||
//
|
||||
#ifdef NEW_FOW
|
||||
/// Mark the sight in range
|
||||
extern void MapMarkSight(const Player*,int,int,int);
|
||||
/// Mark the new sight in range
|
||||
|
@ -409,18 +401,10 @@ extern void MapMarkNewSight(const Player*,int,int,int,int,int);
|
|||
extern void MapUnmarkSight(const Player*,int,int,int);
|
||||
/// Find if a tile is visible (With shared vision)
|
||||
extern int IsTileVisible(const Player* player, int x, int y);
|
||||
#else
|
||||
/// Mark the sight in range
|
||||
extern void MapMarkSight(int tx,int ty,int range);
|
||||
/// Mark the new sight in range
|
||||
extern void MapMarkNewSight(int,int,int,int,int);
|
||||
#endif
|
||||
/// Mark tiles with fog of war to be redrawn
|
||||
extern void MapUpdateFogOfWar(int x,int y);
|
||||
/// Update fog of war
|
||||
extern void UpdateFogOfWarChange(void);
|
||||
/// Update visible areas for fog of war
|
||||
extern void MapUpdateVisible(void);
|
||||
|
||||
/// Draw the map fog of war
|
||||
extern void DrawMapFogOfWar(const Viewport* vp,int x,int y);
|
||||
|
@ -556,7 +540,6 @@ extern void MapSetWall(unsigned x,unsigned y,int humanwall);
|
|||
#define CanMoveToMask(x,y,mask) \
|
||||
!(TheMap.Fields[(x)+(y)*TheMap.Width].Flags&(mask))
|
||||
|
||||
#ifdef NEW_FOW
|
||||
|
||||
/// Check if a field for the user is explored
|
||||
#define IsMapFieldExplored(player,x,y) \
|
||||
|
@ -566,19 +549,6 @@ extern void MapSetWall(unsigned x,unsigned y,int humanwall);
|
|||
#define IsMapFieldVisible(player,x,y) \
|
||||
(IsTileVisible((player),(x),(y))>1)
|
||||
|
||||
#else
|
||||
|
||||
/// Check if a field for the user is explored
|
||||
#define IsMapFieldExplored(player,x,y) \
|
||||
(TheMap.Fields[(y)*TheMap.Width+(x)].Flags&MapFieldExplored)
|
||||
|
||||
/// Check if a field for the user is visibile
|
||||
#define IsMapFieldVisible(player,x,y) \
|
||||
(TheMap.Visible[0][((y)*TheMap.Width+(x))/32] \
|
||||
&(1<<(((y)*TheMap.Width+(x))%32)))
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef UNITS_ON_MAP
|
||||
/// Is there a building on this field
|
||||
#define BuildingOnMapField(mf) ((mf)->Building != 0xffff)
|
||||
|
|
|
@ -485,9 +485,7 @@ struct _unit_ {
|
|||
UnitType* SeenType; /// Pointer to last seen unit-type
|
||||
Player* Player; /// Owner of this unit
|
||||
UnitStats* Stats; /// Current unit stats
|
||||
#ifdef NEW_FOW
|
||||
int CurrentSightRange; /// Unit's Current Sight Range
|
||||
#endif
|
||||
|
||||
// DISPLAY:
|
||||
UnitColors Colors; /// Player colors
|
||||
|
@ -680,9 +678,7 @@ extern Unit** UnitSlotFree; /// First free unit slot
|
|||
|
||||
extern Unit* Units[MAX_UNIT_SLOTS]; /// Units used
|
||||
extern int NumUnits; /// Number of units used
|
||||
#if defined(NEW_FOW) && defined(BUILDING_DESTROYED)
|
||||
extern Unit* DestroyedBuildings; /// List of DestroyedBuildings
|
||||
#endif
|
||||
extern Unit* CorpseList; /// List of Corpses On Map
|
||||
|
||||
// in unit_draw.c (FIXME: could be moved into the user interface?)
|
||||
|
@ -746,10 +742,9 @@ extern void NearestOfUnit(const Unit* unit,int tx,int ty,int *dx,int *dy);
|
|||
extern void MarkSubmarineSeen(const Player* player,int x,int y,int range);
|
||||
/// Returns true, if unit is visible on the map
|
||||
extern int UnitVisibleOnMap(const Unit* unit);
|
||||
#if defined(NEW_FOW) && defined(BUILDING_DESTROYED)
|
||||
/// Returns true, if building is known on the map
|
||||
extern int BuildingVisibleOnMap(Unit* unit);
|
||||
#endif
|
||||
extern int BuildingVisibleOnMap(const Unit* unit);
|
||||
|
||||
/// Updates seen data
|
||||
extern void UnitsMarkSeen(int x,int y);
|
||||
/// Checks and updates if a Unit's seen information
|
||||
|
|
|
@ -132,21 +132,12 @@ global void RevealMap(void)
|
|||
|
||||
for (ix = 0; ix < TheMap.Width; ++ix) {
|
||||
for (iy = 0; iy < TheMap.Height; ++iy) {
|
||||
#ifdef NEW_FOW
|
||||
int i;
|
||||
for (i = 0; i < PlayerMax; ++i) {
|
||||
if (!TheMap.Fields[ix+iy*TheMap.Width].Visible[i]) {
|
||||
TheMap.Fields[ix+iy*TheMap.Width].Visible[i]=1;
|
||||
}
|
||||
}
|
||||
#else
|
||||
TheMap.Fields[ix+iy*TheMap.Width].Flags |= MapFieldExplored;
|
||||
|
||||
if (TheMap.NoFogOfWar) {
|
||||
TheMap.Visible[0][((iy)*TheMap.Width+(ix))/32] |=
|
||||
(1<<(((iy)*TheMap.Width+(ix))%32));
|
||||
}
|
||||
#endif
|
||||
MapMarkSeenTile(ix, iy);
|
||||
UnitsMarkSeen(ix, iy);
|
||||
}
|
||||
|
|
|
@ -150,23 +150,6 @@ local void* FogOfWarAlphaTable;
|
|||
-- Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef NEW_FOW
|
||||
/**
|
||||
** Mask
|
||||
*/
|
||||
local int MapExploredMask(void)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
/**
|
||||
** Mask
|
||||
*/
|
||||
local int MapVisibleMask(void)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
/**
|
||||
** Find the Number of Units that can see this square using a long
|
||||
** lookup. So when a 225 Viewed square can be calculated properly.
|
||||
|
@ -255,13 +238,11 @@ global void MapMarkSight(const Player* player,int tx,int ty,int range)
|
|||
int width;
|
||||
int v;
|
||||
int p;
|
||||
#if defined(NEW_FOW) && defined(BUILDING_DESTROYED)
|
||||
int w;
|
||||
int h;
|
||||
Unit** corpses;
|
||||
Unit* unit;
|
||||
Unit* remove;
|
||||
#endif
|
||||
|
||||
// Mark as seen
|
||||
if( !range ) { // zero sight range is zero sight range
|
||||
|
@ -302,7 +283,6 @@ global void MapMarkSight(const Player* player,int tx,int ty,int range)
|
|||
case 1: // Unseen
|
||||
// FIXME: mark for screen update
|
||||
TheMap.Fields[i+y*TheMap.Width].Visible[p]=2;
|
||||
#ifdef BUILDING_DESTROYED
|
||||
if( player->Type == PlayerPerson ) {
|
||||
corpses = &DestroyedBuildings;
|
||||
while( *corpses ) {
|
||||
|
@ -324,7 +304,6 @@ 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);
|
||||
|
@ -392,7 +371,6 @@ global void MapUnmarkSight(const Player* player,int tx,int ty,int range)
|
|||
p=player->Player;
|
||||
++range;
|
||||
range=range*range;
|
||||
// FIXME: Can be speed optimized, no * += ...
|
||||
while( height-->=0 ) {
|
||||
for( i=x; i<=x+width; ++i ) {
|
||||
if( PythagTree[abs(i-tx)][abs(y-ty)]<=range ) {
|
||||
|
@ -401,10 +379,11 @@ global void MapUnmarkSight(const Player* player,int tx,int ty,int range)
|
|||
case 255:
|
||||
TheMap.Fields[i+y*TheMap.Width].Visible[p] =
|
||||
LookupSight(player,i,y);
|
||||
++TheMap.Fields[i+y*TheMap.Width].Visible[p];
|
||||
DebugCheck( TheMap.Fields[i+y*TheMap.Width].Visible[p] < 254 );
|
||||
case 0: // Unexplored
|
||||
case 1:
|
||||
// We are at minimum, don't do anything.
|
||||
// We are at minimum, don't do anything shouldn't happen.
|
||||
DebugCheck( 1 );
|
||||
break;
|
||||
case 2:
|
||||
// Check visible Tile, then deduct...
|
||||
|
@ -441,86 +420,6 @@ global void MapMarkNewSight(const Player* player,int tx,int ty,int range
|
|||
MapUnmarkSight(player,tx-dx,ty-dy,range);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
** Mark the sight of unit. (Explore and make visible.)
|
||||
**
|
||||
** @param tx X center position.
|
||||
** @param ty Y center position.
|
||||
** @param range Radius to mark.
|
||||
*/
|
||||
global void MapMarkSight(int tx,int ty,int range)
|
||||
{
|
||||
int i;
|
||||
int x;
|
||||
int y;
|
||||
int height;
|
||||
int width;
|
||||
|
||||
if( !range ) { // zero sight range is zero sight range
|
||||
DebugLevel0Fn("Zero sight range\n");
|
||||
return;
|
||||
}
|
||||
|
||||
x=tx-range;
|
||||
y=ty-range;
|
||||
width=height=range+range;
|
||||
|
||||
// Clipping
|
||||
if( y<0 ) {
|
||||
height+=y;
|
||||
y=0;
|
||||
}
|
||||
if( x<0 ) {
|
||||
width+=x;
|
||||
x=0;
|
||||
}
|
||||
if( y+height>=TheMap.Height ) {
|
||||
height=TheMap.Height-y-1;
|
||||
}
|
||||
if( x+width>=TheMap.Width ) {
|
||||
width=TheMap.Width-x-1;
|
||||
}
|
||||
|
||||
++range;
|
||||
range=range*range;
|
||||
while( height-->=0 ) {
|
||||
for( i=x; i<=x+width; ++i ) {
|
||||
if( PythagTree[abs(i-tx)][abs(y-ty)]<=range ) {
|
||||
// FIXME: can combine more bits
|
||||
if( !IsMapFieldVisible(ThisPlayer,i,y) ) {
|
||||
TheMap.Fields[i+y*TheMap.Width].Flags |= MapFieldExplored;
|
||||
TheMap.Visible[0][(i+y*TheMap.Width)/32]
|
||||
|= 1<<((i+y*TheMap.Width)%32);
|
||||
MapMarkSeenTile(i,y);
|
||||
//MustRedrawRow[y]=NEW_MAPDRAW;
|
||||
//MustRedrawTile[y*MapWidth+i]=NEW_MAPDRAW;
|
||||
}
|
||||
}
|
||||
}
|
||||
++y;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Mark the new sight of unit. (Explore and make visible.)
|
||||
**
|
||||
** @param tx X map tile position of center.
|
||||
** @param ty Y map tile position of center.
|
||||
** @param range Radius to mark.
|
||||
** @param dx Unused: Delta in tiles in X direction.
|
||||
** @param dy Unused: Delta in tiles in Y direction.
|
||||
*/
|
||||
global void MapMarkNewSight(int tx,int ty,int range
|
||||
,int dx __attribute__((unused)),int dy __attribute__((unused)))
|
||||
{
|
||||
// FIXME: must write this
|
||||
MapMarkSight(tx,ty,range);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Update the fog of war, for the view point. Called from UpdateDisplay.
|
||||
**
|
||||
|
@ -540,10 +439,8 @@ global void MapUpdateFogOfWar(int x,int y)
|
|||
int n;
|
||||
int i;
|
||||
int sx,sy,ex,ey,dx,dy;
|
||||
#ifndef NEW_FOW
|
||||
int vis;
|
||||
int last;
|
||||
#endif
|
||||
|
||||
// Tiles not visible last frame but are this frame must be redrawn.
|
||||
redraw_row=MustRedrawRow;
|
||||
|
@ -557,7 +454,6 @@ global void MapUpdateFogOfWar(int x,int y)
|
|||
while( dy<=ey ) {
|
||||
sx=x+sy;
|
||||
dx=TheUI.MapX;
|
||||
#ifdef NEW_FOW
|
||||
while( dx<=ex ) {
|
||||
#ifdef NEW_MAPDRAW
|
||||
*redraw_row=NEW_MAPDRAW;
|
||||
|
@ -570,29 +466,6 @@ global void MapUpdateFogOfWar(int x,int y)
|
|||
++sx;
|
||||
dx+=TileSizeX;
|
||||
}
|
||||
#else
|
||||
while( dx<=ex ) {
|
||||
last=TheMap.Fields[sx].VisibleLastFrame;
|
||||
#ifdef NEW_FOW
|
||||
vis=IsTileVisible(ThisPlayer->Player,x,y);
|
||||
if( vis > 1 && (!last || last&MapFieldPartiallyVisible) ) {
|
||||
#else
|
||||
vis=TheMap.Fields[sx].Flags&MapFieldVisible;
|
||||
if( vis && (!last || last&MapFieldPartiallyVisible) ) {
|
||||
#endif
|
||||
#ifdef NEW_MAPDRAW
|
||||
*redraw_row=NEW_MAPDRAW;
|
||||
*redraw_tile=NEW_MAPDRAW;
|
||||
#else
|
||||
*redraw_row=*redraw_tile=1;
|
||||
#endif
|
||||
}
|
||||
|
||||
++redraw_tile;
|
||||
++sx;
|
||||
dx+=TileSizeX;
|
||||
}
|
||||
#endif
|
||||
++redraw_row;
|
||||
sy+=TheMap.Width;
|
||||
dy+=TileSizeY;
|
||||
|
@ -628,9 +501,6 @@ global void UpdateFogOfWarChange(void)
|
|||
for( y=0; y<TheMap.Height; y++ ) {
|
||||
for( x=0; x<TheMap.Width; ++x ) {
|
||||
if( IsMapFieldExplored(ThisPlayer,x,y) ) {
|
||||
#ifndef NEW_FOW
|
||||
TheMap.Visible[0][(x+y*w)/32] |= 1<<((x+y*w)%32);
|
||||
#endif
|
||||
MapMarkSeenTile( x,y );
|
||||
UnitsMarkSeen( x,y );
|
||||
}
|
||||
|
@ -640,132 +510,6 @@ global void UpdateFogOfWarChange(void)
|
|||
MarkDrawEntireMap();
|
||||
}
|
||||
|
||||
/**
|
||||
** Update visible of the map.
|
||||
**
|
||||
** @todo This function could be improved in speed and functionality.
|
||||
** and is not needed in new fog of war.
|
||||
*/
|
||||
global void MapUpdateVisible(void)
|
||||
{
|
||||
#ifdef NEW_FOW
|
||||
return;
|
||||
#else
|
||||
int x;
|
||||
int y;
|
||||
Unit* unit;
|
||||
Unit** units;
|
||||
Unit* mine;
|
||||
int nunits;
|
||||
int i;
|
||||
int j;
|
||||
int shared_vision;
|
||||
#ifdef DEBUG
|
||||
unsigned long t;
|
||||
#endif
|
||||
|
||||
shared_vision=0;
|
||||
|
||||
// No fog - only update revealers for holy vision
|
||||
if ( TheMap.NoFogOfWar ) {
|
||||
for( j=0; j<NumPlayers; ++j ) {
|
||||
if( &Players[j]!=ThisPlayer &&
|
||||
!( (ThisPlayer->SharedVision&(1<<j)) &&
|
||||
(Players[j].SharedVision&(1<<ThisPlayer->Player)) ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nunits=Players[j].TotalNumUnits;
|
||||
units=Players[j].Units;
|
||||
|
||||
if( &Players[j]==ThisPlayer ) {
|
||||
for( i=0; i<nunits; ++i ) {
|
||||
unit=units[i];
|
||||
x=unit->X+unit->Type->TileWidth/2;
|
||||
y=unit->Y+unit->Type->TileHeight/2;
|
||||
if( unit->Removed && unit->Revealer ) {
|
||||
MapMarkSight(x,y,10);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
shared_vision=1;
|
||||
}
|
||||
}
|
||||
if( !shared_vision ) {
|
||||
// No shared vision, nothing else to update
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: rewrite this function, faster and better
|
||||
#ifdef DEBUG
|
||||
t=GetTicks();
|
||||
#endif
|
||||
|
||||
//
|
||||
// Clear all visible flags.
|
||||
//
|
||||
if( !shared_vision ) {
|
||||
memset(TheMap.Visible[0],0,(TheMap.Width*TheMap.Height)/8);
|
||||
}
|
||||
|
||||
DebugLevel3Fn("Ticks Clear %lu\n" _C_ GetTicks()-t);
|
||||
|
||||
MarkDrawEntireMap();
|
||||
|
||||
DebugLevel3Fn("Ticks Mark %lu\n" _C_ GetTicks()-t);
|
||||
|
||||
//
|
||||
// Mark all units visible range.
|
||||
//
|
||||
for( j=0; j<NumPlayers; ++j ) {
|
||||
if( &Players[j]!=ThisPlayer &&
|
||||
!( (ThisPlayer->SharedVision&(1<<j)) &&
|
||||
(Players[j].SharedVision&(1<<ThisPlayer->Player)) ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nunits=Players[j].TotalNumUnits;
|
||||
units=Players[j].Units;
|
||||
for( i=0; i<nunits; i++ ) {
|
||||
unit=units[i];
|
||||
x=unit->X+unit->Type->TileWidth/2;
|
||||
y=unit->Y+unit->Type->TileHeight/2;
|
||||
if( unit->Removed ) {
|
||||
if( unit->Revealer ) {
|
||||
MapMarkSight(x,y,10);
|
||||
continue;
|
||||
}
|
||||
//
|
||||
// If peon is in the mine, the mine has a sight range too.
|
||||
// This is quite dirty code...
|
||||
// This is not a big deal as far as only mines are
|
||||
// concerned, but for more units (like parasited ones
|
||||
// in *craft), maybe we should create a dedicated queue...
|
||||
if( unit->Orders[0].Action==UnitActionMineGold ) {
|
||||
mine=GoldMineOnMap(unit->X,unit->Y);
|
||||
if( mine ) { // Somtimes, the peon is at home :).
|
||||
MapMarkSight(mine->X+mine->Type->TileWidth/2
|
||||
,mine->Y+mine->Type->TileHeight/2
|
||||
,mine->Stats->SightRange);
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if( unit->Orders[0].Action==UnitActionBuilded ) {
|
||||
MapMarkSight(x,y,3);
|
||||
} else {
|
||||
MapMarkSight(x,y,unit->Stats->SightRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DebugLevel3Fn("Ticks Total %lu\n" _C_ GetTicks()-t);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Draw fog solid
|
||||
----------------------------------------------------------------------------*/
|
||||
|
@ -1941,11 +1685,10 @@ global void DrawMapFogOfWar(const Viewport* vp, int x,int y)
|
|||
int ey;
|
||||
char* redraw_row;
|
||||
char* redraw_tile;
|
||||
#ifdef NEW_FOW
|
||||
int p;
|
||||
int my;
|
||||
int mx;
|
||||
#endif
|
||||
|
||||
#ifdef TIMEIT
|
||||
u_int64_t sv=rdtsc();
|
||||
u_int64_t ev;
|
||||
|
@ -1955,9 +1698,7 @@ global void DrawMapFogOfWar(const Viewport* vp, int x,int y)
|
|||
redraw_row=MustRedrawRow; // flags must redraw or not
|
||||
redraw_tile=MustRedrawTile;
|
||||
|
||||
#ifdef NEW_FOW
|
||||
p=ThisPlayer->Player;
|
||||
#endif
|
||||
|
||||
ex = vp->EndX;
|
||||
sy = y*TheMap.Width;
|
||||
|
@ -1979,7 +1720,6 @@ global void DrawMapFogOfWar(const Viewport* vp, int x,int y)
|
|||
(*redraw_tile)--;
|
||||
#else
|
||||
*redraw_tile=0;
|
||||
#ifdef NEW_FOW
|
||||
mx=(dx-vp->X)/TileSizeX + vp->MapX;
|
||||
my=(dy-vp->Y)/TileSizeY + vp->MapY;
|
||||
if( IsTileVisible(ThisPlayer,mx,my) || ReplayRevealMap ) {
|
||||
|
@ -1991,20 +1731,10 @@ global void DrawMapFogOfWar(const Viewport* vp, int x,int y)
|
|||
VideoDrawTile(TheMap.Tiles[UNEXPLORED_TILE],dx,dy);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
if( TheMap.Fields[sx].Flags&MapFieldExplored || ReplayRevealMap ) {
|
||||
DrawFogOfWarTile(sx,sy,dx,dy);
|
||||
} else {
|
||||
#ifdef USE_OPENGL
|
||||
MapDrawTile(UNEXPLORED_TILE,dx,dy);
|
||||
#else
|
||||
VideoDrawTile(TheMap.Tiles[UNEXPLORED_TILE],dx,dy);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(NEW_FOW) && defined(DEBUG) && !defined(HIERARCHIC_PATHFINDER) && 0
|
||||
// Used to debug NEW_FOW problems
|
||||
#if !defined(HIERARCHIC_PATHFINDER) && 0
|
||||
extern int VideoDrawText(int x,int y,unsigned font,const unsigned char* text);
|
||||
#define GameFont 1
|
||||
{
|
||||
|
|
|
@ -60,9 +60,7 @@ global void SaveMap(FILE* file)
|
|||
{
|
||||
int w;
|
||||
int h;
|
||||
#ifdef NEW_FOW
|
||||
int i;
|
||||
#endif
|
||||
|
||||
fprintf(file,"\n;;; -----------------------------------------\n");
|
||||
fprintf(file,";;; MODULE: map $Id$\n");
|
||||
|
@ -93,20 +91,11 @@ global void SaveMap(FILE* file)
|
|||
if( mf->Value ) {
|
||||
fprintf(file," %d",mf->Value);
|
||||
}
|
||||
#ifdef NEW_FOW
|
||||
for( i=0; i < PlayerMax; ++i ) {
|
||||
if( mf->Visible[i] == 1) {
|
||||
fprintf(file," explored %d",i);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if( IsMapFieldVisible(ThisPlayer,w,h) ) {
|
||||
fprintf(file," visible");
|
||||
}
|
||||
if( mf->Flags&MapFieldExplored ) {
|
||||
fprintf(file," explored");
|
||||
}
|
||||
#endif
|
||||
if( mf->Flags&MapFieldHuman ) {
|
||||
fprintf(file," human");
|
||||
}
|
||||
|
|
|
@ -234,9 +234,6 @@ global void DrawMinimap(int vx __attribute__((unused)),
|
|||
int w;
|
||||
int h;
|
||||
int h0;
|
||||
#ifndef NEW_FOW
|
||||
int flags;
|
||||
#endif
|
||||
|
||||
x=(FrameCounter/FRAMES_PER_SECOND)&1;
|
||||
if( (new_phase=red_phase-x) ) {
|
||||
|
@ -259,7 +256,6 @@ global void DrawMinimap(int vx __attribute__((unused)),
|
|||
if( MinimapWithTerrain ) {
|
||||
for( my=0; my<MINIMAP_H; ++my ) {
|
||||
for( mx=0; mx<MINIMAP_W; ++mx ) {
|
||||
#ifdef NEW_FOW
|
||||
if( IsMapFieldVisible(ThisPlayer,Minimap2MapX[mx],(Minimap2MapY[my]/TheMap.Width))
|
||||
|| (IsMapFieldExplored(ThisPlayer,Minimap2MapX[mx],
|
||||
(Minimap2MapY[my]/TheMap.Width)) &&
|
||||
|
@ -268,16 +264,6 @@ global void DrawMinimap(int vx __attribute__((unused)),
|
|||
VideoDrawPixel(((unsigned char*)MinimapGraphic->Frames)
|
||||
[mx+my*MINIMAP_W],x+mx,y+my);
|
||||
}
|
||||
#else
|
||||
flags=Minimap2MapX[mx]+Minimap2MapY[my];
|
||||
if( (TheMap.Fields[flags].Flags&MapFieldExplored &&
|
||||
( (TheMap.Visible[0][flags/32]&(1<<(flags%32)))
|
||||
|| ((mx&1)==(my&1)) ))
|
||||
|| ReplayRevealMap ) {
|
||||
VideoDrawPixel(((unsigned char*)MinimapGraphic->Frames)
|
||||
[mx+my*MINIMAP_W],x+mx,y+my);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,21 +160,10 @@ local SCM CclFreeCraftMap(SCM list)
|
|||
if( gh_exact_p(gh_car(field)) ) {
|
||||
TheMap.Fields[i].Value=
|
||||
gh_scm2int(gh_car(field));
|
||||
|
||||
#ifdef NEW_FOW
|
||||
} else if( gh_eq_p(gh_car(field),
|
||||
gh_symbol2scm("explored")) ) {
|
||||
field=gh_cdr(field);
|
||||
TheMap.Fields[i].Visible[gh_scm2int(gh_car(field))] = 1;
|
||||
#else
|
||||
} else if( gh_eq_p(gh_car(field),
|
||||
gh_symbol2scm("visible")) ) {
|
||||
TheMap.Visible[0][i/32] |= 1<<(i%32);
|
||||
} else if( gh_eq_p(gh_car(field),
|
||||
gh_symbol2scm("explored")) ) {
|
||||
TheMap.Fields[i].Flags|=MapFieldExplored;
|
||||
#endif
|
||||
|
||||
} else if( gh_eq_p(gh_car(field),
|
||||
gh_symbol2scm("human")) ) {
|
||||
TheMap.Fields[i].Flags|=MapFieldHuman;
|
||||
|
|
|
@ -695,22 +695,19 @@ global void GameMainLoop(void)
|
|||
case 1:
|
||||
UnitIncrementHealth(); // berserker healing
|
||||
break;
|
||||
case 2: // fog of war calculations
|
||||
MapUpdateVisible();
|
||||
break;
|
||||
case 3: // minimap update
|
||||
case 2: // minimap update
|
||||
MustRedraw|=RedrawMinimap;
|
||||
break;
|
||||
case 4: // computer players
|
||||
case 3: // computer players
|
||||
PlayersEachSecond();
|
||||
break;
|
||||
case 5: // forest grow
|
||||
case 4: // forest grow
|
||||
RegenerateForest();
|
||||
break;
|
||||
case 6: // overtaking units
|
||||
case 5: // overtaking units
|
||||
RescueUnits();
|
||||
break;
|
||||
case 7:
|
||||
case 6:
|
||||
BurnBuildings(); // burn buildings
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -599,7 +599,6 @@ global void FireMissile(Unit* unit)
|
|||
}
|
||||
|
||||
if( goal && RevealAttacker ) { // attacking units are seen
|
||||
#ifdef NEW_FOW
|
||||
Unit* target;
|
||||
// FIXME: Don't use UnitTypeByIdent during runtime.
|
||||
target = MakeUnit(UnitTypeByIdent("unit-reveal-attacker"), unit->Player);
|
||||
|
@ -611,11 +610,6 @@ global void FireMissile(Unit* unit)
|
|||
target->CurrentSightRange=target->Stats->SightRange;
|
||||
MapMarkSight(target->Player,unit->X,unit->Y,target->CurrentSightRange);
|
||||
CheckUnitToBeDrawn(target);
|
||||
#else
|
||||
if( goal->Player==ThisPlayer || IsSharedVision(ThisPlayer,goal) ) {
|
||||
MapMarkSight(unit->X,unit->Y,1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -737,9 +737,6 @@ global void InitCcl(void)
|
|||
#ifdef HIERARCHIC_PATHFINDER
|
||||
gh_define("freecraft-feature-hierarchic-pathfinder",SCM_BOOL_T);
|
||||
#endif
|
||||
#ifdef NEW_FOW
|
||||
gh_define("freecraft-feature-new-fow",SCM_BOOL_T);
|
||||
#endif
|
||||
#ifdef NEW_AI
|
||||
gh_define("freecraft-feature-new-ai",SCM_BOOL_T);
|
||||
#endif
|
||||
|
|
|
@ -1545,10 +1545,9 @@ local int CastHolyVision(Unit* unit, const SpellType* spell, Unit* target,
|
|||
target->X = x;
|
||||
target->Y = y;
|
||||
target->TTL=GameCycle+CYCLES_PER_SECOND+CYCLES_PER_SECOND/2;
|
||||
#ifdef NEW_FOW
|
||||
target->CurrentSightRange=target->Stats->SightRange;
|
||||
MapMarkSight(target->Player,x,y,target->CurrentSightRange);
|
||||
#endif
|
||||
|
||||
//target->TTL=GameCycle+target->Type->DecayRate*6*CYCLES_PER_SECOND;
|
||||
CheckUnitToBeDrawn(target);
|
||||
PlayGameSound(spell->Casted.Sound,MaxSampleVolume);
|
||||
|
|
|
@ -1217,9 +1217,6 @@ local void PrintHeader(void)
|
|||
#ifdef NEW_MAPDRAW
|
||||
"NEW-MAPDRAW "
|
||||
#endif
|
||||
#ifdef NEW_FOW
|
||||
"NEW-FOW "
|
||||
#endif
|
||||
#ifdef NEW_AI
|
||||
"NEW-AI "
|
||||
#endif
|
||||
|
|
|
@ -987,12 +987,10 @@ global int HandleCheats(const char* Input)
|
|||
} else if (strcmp(Input, "fow on") == 0) {
|
||||
TheMap.NoFogOfWar = 0;
|
||||
UpdateFogOfWarChange();
|
||||
MapUpdateVisible();
|
||||
SetMessage("Fog Of War is now ON");
|
||||
} else if (strcmp(Input, "fow off") == 0) {
|
||||
TheMap.NoFogOfWar = 1;
|
||||
UpdateFogOfWarChange();
|
||||
MapUpdateVisible();
|
||||
SetMessage("Fog Of War is now OFF");
|
||||
} else if (strcmp(Input, "fast debug") == 0) {
|
||||
SpeedMine = 10; // speed factor for mine gold
|
||||
|
|
|
@ -1859,12 +1859,10 @@ local void SetFogOfWar(Menuitem *mi __attribute__((unused)))
|
|||
if (!TheMap.NoFogOfWar) {
|
||||
TheMap.NoFogOfWar = 1;
|
||||
UpdateFogOfWarChange();
|
||||
MapUpdateVisible();
|
||||
CommandLog("input", NoUnitP, FlushCommands, -1, -1, NoUnitP, "fow off", -1);
|
||||
} else {
|
||||
TheMap.NoFogOfWar = 0;
|
||||
UpdateFogOfWarChange();
|
||||
MapUpdateVisible();
|
||||
CommandLog("input", NoUnitP, FlushCommands, -1, -1, NoUnitP, "fow on", -1);
|
||||
}
|
||||
MustRedraw &= ~RedrawMinimap;
|
||||
|
|
|
@ -553,21 +553,6 @@ local SCM CclUnit(SCM list)
|
|||
} else if( gh_eq_p(value,gh_symbol2scm("next")) ) {
|
||||
unit->Next=UnitSlots[gh_scm2int(gh_car(list))];
|
||||
list=gh_cdr(list);
|
||||
DebugLevel0Fn("FIXME: 'next of unit %d\n" _C_ slot);
|
||||
#if 0
|
||||
// This is currently not used.
|
||||
if( !gh_null_p(value) ) {
|
||||
str=gh_scm2newstr(value,NULL);
|
||||
|
||||
slot=strtol(str+1,NULL,16);
|
||||
unit->Next=UnitSlots[slot];
|
||||
if( !UnitSlots[slot] ) {
|
||||
DebugLevel0Fn("FIXME: Forward reference not supported\n");
|
||||
}
|
||||
free(str);
|
||||
}
|
||||
#endif
|
||||
#ifdef NEW_FOW
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("current-sight-range")) ) {
|
||||
unit->CurrentSightRange=gh_scm2int(gh_car(list));
|
||||
list=gh_cdr(list);
|
||||
|
@ -576,8 +561,7 @@ local SCM CclUnit(SCM list)
|
|||
list=gh_cdr(list);
|
||||
MapMarkSight(player,gh_scm2int(gh_car(value)),
|
||||
gh_scm2int(gh_cadr(value)),
|
||||
unit->CurrentSightRange);
|
||||
#endif
|
||||
unit->CurrentSightRange);
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("tile")) ) {
|
||||
value=gh_car(list);
|
||||
list=gh_cdr(list);
|
||||
|
@ -743,27 +727,19 @@ local SCM CclUnit(SCM list)
|
|||
// HACK: the building is not ready yet
|
||||
unit->Player->UnitTypesCount[type->Type]--;
|
||||
}
|
||||
// FIXME: Does not load CorpseList Properly
|
||||
#if defined(NEW_FOW) && defined(BUILDING_DESTROYED)
|
||||
// FIXME: (mr-russ) Does not load CorpseList Properly
|
||||
if( unit->Type->Building &&
|
||||
( unit->Orders[0].Action==UnitActionDie || unit->Destroyed )) {
|
||||
DeadBuildingCacheInsert(unit);
|
||||
} else if( unit->Orders[0].Action==UnitActionDie ) {
|
||||
CorpseCacheInsert(unit);
|
||||
}
|
||||
#else
|
||||
if( unit->Orders[0].Action==UnitActionDie ) {
|
||||
CorpseCacheInsert(unit);
|
||||
}
|
||||
#endif
|
||||
#ifdef NEW_FOW
|
||||
if( unit->Orders[0].Action==UnitActionDie &&
|
||||
unit->Type->CorpseScript ) {
|
||||
MapMarkSight(unit->Player,unit->X+unit->Type->TileWidth/2,
|
||||
unit->Y+unit->Type->TileHeight/2,
|
||||
unit->CurrentSightRange);
|
||||
}
|
||||
#endif
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("saved-order")) ) {
|
||||
value=gh_car(list);
|
||||
list=gh_cdr(list);
|
||||
|
|
|
@ -164,7 +164,6 @@ global void ReleaseUnit(Unit* unit)
|
|||
//
|
||||
unit->Destroyed=1; // mark as destroyed
|
||||
|
||||
#if defined(NEW_FOW) && defined(BUILDING_DESTROYED)
|
||||
// Mark building as can't be destroyed, since it's still seen
|
||||
if( unit->Type->Building ) {
|
||||
int i;
|
||||
|
@ -196,7 +195,6 @@ global void ReleaseUnit(Unit* unit)
|
|||
if( unit->Type->Building && unit->Visible != 0x0000 ) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
RefsDebugCheck( !unit->Refs );
|
||||
if( --unit->Refs>0 ) {
|
||||
DebugLevel2Fn("%lu:More references of %d #%d\n" _C_ GameCycle
|
||||
|
@ -210,15 +208,11 @@ global void ReleaseUnit(Unit* unit)
|
|||
|
||||
// Update Corpse Cache
|
||||
if( unit->Orders[0].Action == UnitActionDie ) {
|
||||
#if defined(NEW_FOW) && defined(BUILDING_DESTROYED)
|
||||
if( unit->Type->Building ) {
|
||||
DeadBuildingCacheRemove(unit);
|
||||
} else {
|
||||
CorpseCacheRemove(unit);
|
||||
}
|
||||
#else
|
||||
CorpseCacheRemove(unit);
|
||||
#endif
|
||||
}
|
||||
|
||||
RefsDebugCheck( unit->Refs );
|
||||
|
@ -541,7 +535,6 @@ global void PlaceUnit(Unit* unit,int x,int y)
|
|||
// Units under construction have no sight range.
|
||||
//
|
||||
if( !unit->Constructed ) {
|
||||
#ifdef NEW_FOW
|
||||
//
|
||||
// Update fog of war, if unit belongs to player on this computer
|
||||
//
|
||||
|
@ -553,12 +546,7 @@ global void PlaceUnit(Unit* unit,int x,int y)
|
|||
unit->Next = NULL;
|
||||
unit->CurrentSightRange=unit->Stats->SightRange;
|
||||
MapMarkSight(unit->Player,x,y,unit->CurrentSightRange);
|
||||
#else
|
||||
if( unit->Player==ThisPlayer ||
|
||||
(ThisPlayer && IsSharedVision(ThisPlayer,unit)) ) {
|
||||
MapMarkSight(x,y,unit->Stats->SightRange);
|
||||
}
|
||||
#endif
|
||||
|
||||
if( type->CanSeeSubmarine ) {
|
||||
MarkSubmarineSeen(unit->Player,x,y,unit->Stats->SightRange);
|
||||
}
|
||||
|
@ -635,7 +623,6 @@ global void RemoveUnit(Unit* unit, Unit* host)
|
|||
const UnitType* type;
|
||||
unsigned flags;
|
||||
|
||||
#ifdef NEW_FOW
|
||||
if( unit->Removed && unit->Next ) {
|
||||
MapUnmarkSight(unit->Player,unit->Next->X+unit->Next->Type->TileWidth/2
|
||||
,unit->Next->Y+unit->Next->Type->TileHeight/2
|
||||
|
@ -651,7 +638,6 @@ global void RemoveUnit(Unit* unit, Unit* host)
|
|||
host->Y+host->Type->TileWidth/2,
|
||||
unit->CurrentSightRange);
|
||||
}
|
||||
#endif
|
||||
|
||||
if( unit->Removed ) { // could happen!
|
||||
// If unit is removed (inside) and building is destroyed.
|
||||
|
@ -1070,7 +1056,6 @@ global int UnitVisibleOnMap(const Unit* unit)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if defined(NEW_FOW) && defined(BUILDING_DESTROYED)
|
||||
/**
|
||||
** Returns true, if unit is visible for this player on the map.
|
||||
** An unit is visible, if any field could be seen.
|
||||
|
@ -1080,7 +1065,7 @@ global int UnitVisibleOnMap(const Unit* unit)
|
|||
** @param unit Unit to be checked.
|
||||
** @return True if visible, false otherwise.
|
||||
*/
|
||||
global int BuildingVisibleOnMap(Unit* unit)
|
||||
global int BuildingVisibleOnMap(const Unit* unit)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
|
@ -1109,7 +1094,6 @@ global int BuildingVisibleOnMap(Unit* unit)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
** FIXME: docu
|
||||
|
@ -1267,11 +1251,7 @@ global int UnitVisibleInViewport(const Viewport* vp, const Unit* unit)
|
|||
return 0;
|
||||
}
|
||||
// Visible submarine
|
||||
#if defined(NEW_FOW) && defined(BUILDING_DESTROYED)
|
||||
if ( !(unit->Visible&(1<<ThisPlayer->Player)) && !unit->Type->Building ) {
|
||||
#else
|
||||
if ( !(unit->Visible&(1<<ThisPlayer->Player)) ) {
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1785,14 +1765,12 @@ global void ChangeUnitOwner(Unit* unit,Player* oldplayer,Player* newplayer)
|
|||
*unit->PlayerSlot=unit;
|
||||
|
||||
unit->Player=newplayer;
|
||||
#ifdef NEW_FOW
|
||||
MapUnmarkSight(oldplayer,unit->X+unit->Type->TileWidth/2
|
||||
,unit->Y+unit->Type->TileHeight/2
|
||||
,unit->CurrentSightRange);
|
||||
MapMarkSight(unit->Player,unit->X+unit->Type->TileWidth/2
|
||||
,unit->Y+unit->Type->TileHeight/2
|
||||
,unit->CurrentSightRange);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Must change food/gold and other.
|
||||
|
@ -2042,18 +2020,12 @@ global void DropOutOnSide(Unit* unit,int heading,int addx,int addy)
|
|||
int y;
|
||||
int i;
|
||||
int mask;
|
||||
#ifndef NEW_FOW
|
||||
int n;
|
||||
int nb;
|
||||
Unit* table[UnitMax];
|
||||
#endif
|
||||
|
||||
//FIXME: vladi: this debug check fails when used for teleporting...
|
||||
//DebugCheck( !unit->Removed );
|
||||
|
||||
// FIXME: better and quicker solution, to find the building.
|
||||
x=y=-1;
|
||||
#ifdef NEW_FOW
|
||||
if( unit->Next ) {
|
||||
x=unit->Next->X;
|
||||
y=unit->Next->Y;
|
||||
|
@ -2062,24 +2034,7 @@ global void DropOutOnSide(Unit* unit,int heading,int addx,int addy)
|
|||
y=unit->Y;
|
||||
DebugLevel0Fn("No building?\n");
|
||||
}
|
||||
#else
|
||||
n=SelectUnitsOnTile(unit->X,unit->Y,table);
|
||||
for( nb=i=0; i<n; ++i ) {
|
||||
if( UnitUnusable(table[i]) ) {
|
||||
continue;
|
||||
}
|
||||
if( table[i]->Type->Building ) {
|
||||
nb++;
|
||||
x=table[i]->X;
|
||||
y=table[i]->Y;
|
||||
}
|
||||
}
|
||||
if (!nb) { //Check if there actually is a building.
|
||||
DebugLevel0Fn("No building?\n");
|
||||
x=unit->X;
|
||||
y=unit->Y;
|
||||
}
|
||||
#endif
|
||||
|
||||
mask=UnitMovementMask(unit);
|
||||
|
||||
if( heading<LookingNE || heading>LookingNW) {
|
||||
|
@ -2176,16 +2131,12 @@ global void DropOutNearest(Unit* unit,int gx,int gy,int addx,int addy)
|
|||
int bestd;
|
||||
int mask;
|
||||
int n;
|
||||
#ifndef NEW_FOW
|
||||
Unit* table[UnitMax];
|
||||
#endif
|
||||
|
||||
DebugLevel3Fn("%d\n" _C_ UnitNumber(unit));
|
||||
DebugCheck( !unit->Removed );
|
||||
|
||||
// FIXME: better and quicker solution, to find the building.
|
||||
x=y=-1;
|
||||
#ifdef NEW_FOW
|
||||
if( unit->Next ) {
|
||||
x=unit->Next->X;
|
||||
y=unit->Next->Y;
|
||||
|
@ -2194,18 +2145,7 @@ global void DropOutNearest(Unit* unit,int gx,int gy,int addx,int addy)
|
|||
x=unit->X;
|
||||
y=unit->Y;
|
||||
}
|
||||
#else
|
||||
n=SelectUnitsOnTile(unit->X,unit->Y,table);
|
||||
for( i=0; i<n; ++i ) {
|
||||
if( UnitUnusable(table[i]) ) {
|
||||
continue;
|
||||
}
|
||||
if( table[i]->Type->Building ) {
|
||||
x=table[i]->X;
|
||||
y=table[i]->Y;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
DebugCheck( x==-1 || y==-1 );
|
||||
mask=UnitMovementMask(unit);
|
||||
|
||||
|
@ -2280,6 +2220,8 @@ global void DropOutAll(const Unit* source)
|
|||
{
|
||||
// FIXME: Rewrite this use source->Next;
|
||||
// FIXME: above is wrong, NEW_FOW use Next in another way.
|
||||
// FIXME: (mr-russ) can't use source->Next, it's on map, and Next
|
||||
// points to next unit on tile.
|
||||
Unit** table;
|
||||
Unit* unit;
|
||||
int i;
|
||||
|
@ -2723,11 +2665,7 @@ global Unit* FindGoldMine(const Unit* unit,int x,int y)
|
|||
//
|
||||
// Look if there is a mine
|
||||
//
|
||||
#ifdef NEW_FOW
|
||||
if ( (mine=GoldMineOnMap(x,y)) && IsMapFieldExplored(unit->Player,x,y) ) {
|
||||
#else
|
||||
if ( (mine=GoldMineOnMap(x,y)) ) {
|
||||
#endif
|
||||
if( destu ) {
|
||||
n=max(abs(destx-x),abs(desty-y));
|
||||
if( n<bestd ) {
|
||||
|
@ -3110,11 +3048,7 @@ global int FindWoodInSight(const Unit* unit,int* px,int* py)
|
|||
//
|
||||
// Look if there is wood
|
||||
//
|
||||
#ifdef NEW_FOW
|
||||
if ( ForestOnMap(x,y) && IsMapFieldExplored(unit->Player,x,y) ) {
|
||||
#else
|
||||
if ( ForestOnMap(x,y) ) {
|
||||
#endif
|
||||
if( destu ) {
|
||||
n=max(abs(destx-x),abs(desty-y));
|
||||
if( n<bestd ) {
|
||||
|
@ -3505,31 +3439,21 @@ global void LetUnitDie(Unit* unit)
|
|||
|| !unit->Type->Animations->Die );
|
||||
UnitShowAnimation(unit,unit->Type->Animations->Die);
|
||||
DebugLevel0Fn("Frame %d\n" _C_ unit->Frame);
|
||||
#if defined(NEW_FOW) && defined(BUILDING_DESTROYED)
|
||||
unit->Visible = 0xffff;
|
||||
DeadBuildingCacheInsert(unit); //Insert into corpse list
|
||||
#else
|
||||
CorpseCacheInsert(unit);
|
||||
#endif
|
||||
#ifdef NEW_FOW
|
||||
MapMarkSight(unit->Player,unit->X,unit->Y,1);
|
||||
#endif
|
||||
UnitMarkSeen(unit);
|
||||
#ifdef NEW_FOW
|
||||
MapUnmarkSight(unit->Player,unit->X,unit->Y,1);
|
||||
#endif
|
||||
// FIXME: (mr-russ) Hack to make sure we see our own building destroyed
|
||||
MapMarkSight(unit->Player,unit->X,unit->Y,1);
|
||||
UnitMarkSeen(unit);
|
||||
MapUnmarkSight(unit->Player,unit->X,unit->Y,1);
|
||||
UnitMarkSeen(unit);
|
||||
return;
|
||||
}
|
||||
|
||||
// no corpse available
|
||||
#ifdef NEW_FOW
|
||||
// FIXME: (mr-russ) Hack to make sure we see our own building destroyed
|
||||
MapMarkSight(unit->Player,unit->X,unit->Y,1);
|
||||
#endif
|
||||
UnitMarkSeen(unit);
|
||||
#ifdef NEW_FOW
|
||||
MapUnmarkSight(unit->Player,unit->X,unit->Y,1);
|
||||
#endif
|
||||
ReleaseUnit(unit);
|
||||
return;
|
||||
}
|
||||
|
@ -3567,14 +3491,12 @@ global void LetUnitDie(Unit* unit)
|
|||
unit->Orders[0].Action=UnitActionDie;
|
||||
CorpseCacheInsert(unit); //Insert into corpse list
|
||||
|
||||
#ifdef NEW_FOW
|
||||
if( unit->Type->CorpseType ) {
|
||||
unit->CurrentSightRange=unit->Type->CorpseType->Stats->SightRange;
|
||||
} else {
|
||||
unit->CurrentSightRange=0;
|
||||
}
|
||||
MapMarkSight(unit->Player,unit->X,unit->Y,unit->CurrentSightRange);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4267,9 +4189,7 @@ global void SaveUnit(const Unit* unit,FILE* file)
|
|||
}
|
||||
fprintf(file,"'direction %d\n ",unit->Direction);
|
||||
fprintf(file,"'attacked %d\n ",unit->Attacked);
|
||||
#ifdef NEW_FOW
|
||||
fprintf(file," 'current-sight-range %d",unit->CurrentSightRange);
|
||||
#endif
|
||||
if( unit->Burning ) {
|
||||
fprintf(file," 'burning");
|
||||
}
|
||||
|
@ -4285,13 +4205,11 @@ global void SaveUnit(const Unit* unit,FILE* file)
|
|||
if( unit->Selected ) {
|
||||
fprintf(file," 'selected");
|
||||
}
|
||||
#ifdef NEW_FOW
|
||||
if( unit->Next && unit->Removed ) {
|
||||
fprintf(file," 'host-tile '(%d %d) ",
|
||||
unit->Next->X+unit->Next->Type->TileWidth/2,
|
||||
unit->Next->Y+unit->Next->Type->TileHeight/2);
|
||||
}
|
||||
#endif
|
||||
fprintf(file," 'visible \"");
|
||||
for( i=0; i<PlayerMax; ++i ) {
|
||||
fputc((unit->Visible&(1<<i)) ? 'X' : '_',file);
|
||||
|
|
|
@ -1757,11 +1757,7 @@ local void DrawBuilding(Unit* unit)
|
|||
int constructed;
|
||||
|
||||
|
||||
#if defined(NEW_FOW) && defined(BUILDING_DESTROYED)
|
||||
visible=BuildingVisibleOnMap(unit);
|
||||
#else
|
||||
visible=UnitVisibleOnMap(unit);
|
||||
#endif
|
||||
|
||||
if( ReplayRevealMap ) {
|
||||
type = unit->Type;
|
||||
|
@ -1913,7 +1909,6 @@ global void DrawUnits(const void* v)
|
|||
corpses=&(*corpses)->Next;
|
||||
}
|
||||
|
||||
#if defined(NEW_FOW) && defined(BUILDING_DESTROYED)
|
||||
//
|
||||
// 2a1) Destroyed Buildings
|
||||
//
|
||||
|
@ -1926,7 +1921,6 @@ global void DrawUnits(const void* v)
|
|||
}
|
||||
corpses=&(*corpses)->Next;
|
||||
}
|
||||
#endif
|
||||
//
|
||||
// 2b) buildings
|
||||
//
|
||||
|
|
|
@ -40,9 +40,7 @@
|
|||
#include "depend.h"
|
||||
#include "interface.h"
|
||||
|
||||
#ifdef NEW_FOW
|
||||
#include "map.h"
|
||||
#endif
|
||||
|
||||
#include "myendian.h"
|
||||
|
||||
|
@ -1278,17 +1276,15 @@ local void ConvertUnitTypeTo(Player* player,const UnitType* src,UnitType* dst)
|
|||
-unit->Stats->HitPoints;
|
||||
// don't have such unit now
|
||||
player->UnitTypesCount[src->Type]--;
|
||||
#ifdef NEW_FOW
|
||||
// UnMark the Unit sight for conversion
|
||||
if (unit->CurrentSightRange != dst->Stats[player->Player].SightRange ||
|
||||
// UnMark the Unit sight for conversion if on map
|
||||
if ((unit->CurrentSightRange != dst->Stats[player->Player].SightRange ||
|
||||
src->TileWidth != dst->TileWidth ||
|
||||
src->TileHeight != dst->TileHeight) {
|
||||
src->TileHeight != dst->TileHeight) && !unit->Removed) {
|
||||
MapUnmarkSight(player,
|
||||
unit->X+unit->Type->TileWidth/2,
|
||||
unit->Y+unit->Type->TileHeight/2,
|
||||
unit->CurrentSightRange);
|
||||
}
|
||||
#endif
|
||||
unit->Type=dst;
|
||||
unit->Stats=&dst->Stats[player->Player];
|
||||
// and we have new one...
|
||||
|
@ -1297,17 +1293,15 @@ local void ConvertUnitTypeTo(Player* player,const UnitType* src,UnitType* dst)
|
|||
if( dst->CanCastSpell ) {
|
||||
unit->Mana=MAGIC_FOR_NEW_UNITS;
|
||||
}
|
||||
#ifdef NEW_FOW
|
||||
if (unit->CurrentSightRange != dst->Stats[player->Player].SightRange ||
|
||||
if ((unit->CurrentSightRange != dst->Stats[player->Player].SightRange ||
|
||||
src->TileWidth != dst->TileWidth ||
|
||||
src->TileHeight != dst->TileHeight) {
|
||||
src->TileHeight != dst->TileHeight) && !unit->Removed) {
|
||||
unit->CurrentSightRange=dst->Stats[player->Player].SightRange;
|
||||
MapMarkSight(player,
|
||||
unit->X+unit->Type->TileWidth/2,
|
||||
unit->Y+unit->Type->TileHeight/2,
|
||||
unit->CurrentSightRange);
|
||||
}
|
||||
#endif
|
||||
|
||||
CheckUnitToBeDrawn(unit);
|
||||
//
|
||||
|
@ -1391,7 +1385,6 @@ local void ApplyUpgradeModifier(Player * player, const UpgradeModifier * um)
|
|||
// upgrade stats
|
||||
UnitTypes[z].Stats[pn].AttackRange += um->Modifier.AttackRange;
|
||||
UnitTypes[z].Stats[pn].SightRange += um->Modifier.SightRange;
|
||||
#ifdef NEW_FOW
|
||||
//If Sight range is upgraded, we need to change EVERY unit
|
||||
//to the new range, otherwise the counters get confused.
|
||||
if (um->Modifier.SightRange) {
|
||||
|
@ -1401,7 +1394,8 @@ local void ApplyUpgradeModifier(Player * player, const UpgradeModifier * um)
|
|||
numunits = FindUnitsByType(&UnitTypes[z],sightupgrade);
|
||||
numunits--; // Change to 0 Start not 1 start
|
||||
while (numunits >= 0) {
|
||||
if (sightupgrade[numunits]->Player->Player == player->Player) {
|
||||
if (sightupgrade[numunits]->Player->Player == player->Player &&
|
||||
!sightupgrade[numunits]->Removed) {
|
||||
/// Marking First is faster
|
||||
MapMarkSight(player,
|
||||
sightupgrade[numunits]->X+UnitTypes[z].TileWidth/2,
|
||||
|
@ -1416,7 +1410,6 @@ local void ApplyUpgradeModifier(Player * player, const UpgradeModifier * um)
|
|||
numunits--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
UnitTypes[z].Stats[pn].BasicDamage += um->Modifier.BasicDamage;
|
||||
UnitTypes[z].Stats[pn].PiercingDamage
|
||||
+= um->Modifier.PiercingDamage;
|
||||
|
|
Loading…
Add table
Reference in a new issue