New unit allocation code prepared, not ready! #define NEW_UNIT.
This commit is contained in:
parent
f765879520
commit
a1910d9679
14 changed files with 226 additions and 47 deletions
doc
src
action
include
map
network
sound
stratagus
ui
unit
|
@ -48,6 +48,7 @@
|
|||
<LI>Let target of attack command blink, if selected (like right click)
|
||||
<LI>gryphon rider attack animation could trigger oops (internal error).
|
||||
<LI>Wood counter should be reseted, avoiding evil tricks.
|
||||
<LI>Win32 version default.pud, both players are red! Linux SDL is ok!
|
||||
<LI>More suggestions?
|
||||
</UL>
|
||||
|
||||
|
|
|
@ -228,6 +228,11 @@ local void HandleUnitAction(Unit* unit)
|
|||
*/
|
||||
global void UnitActions(void)
|
||||
{
|
||||
#ifdef NEW_UNIT
|
||||
UnitConflicts(); // start attacking
|
||||
|
||||
DebugLevel0("FIXME:\n");
|
||||
#else
|
||||
Unit* unit;
|
||||
int i;
|
||||
|
||||
|
@ -243,6 +248,7 @@ global void UnitActions(void)
|
|||
}
|
||||
HandleUnitAction(unit);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//@}
|
||||
|
|
|
@ -163,8 +163,10 @@ typedef enum _unit_voice_group_ {
|
|||
*/
|
||||
struct _unit_ {
|
||||
#ifdef NEW_UNIT
|
||||
short Count; /// Reference counter
|
||||
short Refs; /// Reference counter
|
||||
UnitRef Slot; /// Assignd slot number
|
||||
UnitRef UnitSlot; /// slot number in Units
|
||||
UnitRef PlayerSlot; /// slot number in Player->Units
|
||||
Unit* Next; /// generic link pointer
|
||||
#else
|
||||
// FIXME: this will be removed
|
||||
|
@ -188,10 +190,10 @@ struct _unit_ {
|
|||
|
||||
unsigned Attacked : 1; /// unit is attacked
|
||||
// FIXME: next not used!
|
||||
unsigned Visible : 1; /// unit is visible (submarine)
|
||||
//unsigned Visible : 1; /// unit is visible (submarine)
|
||||
unsigned Destroyed : 1; /// unit is destroyed pending reference
|
||||
unsigned Removed : 1; /// unit is removed (not on map)
|
||||
unsigned Selected : 1; /// unit is selected
|
||||
// FIXME: next not used!
|
||||
unsigned Constructed : 1; /// unit is in construction
|
||||
|
||||
unsigned Mana : 8; /// mana points
|
||||
|
@ -282,8 +284,7 @@ struct _unit_ {
|
|||
#ifdef NEW_UNIT
|
||||
#define UnitNumber(unit) ((unit)->Slot)
|
||||
#else
|
||||
#define UnitNumber(unit) \
|
||||
((unit) - UnitsPool)
|
||||
#define UnitNumber(unit) ((unit)-UnitsPool)
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -306,8 +307,11 @@ struct _unit_ {
|
|||
----------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef NEW_UNIT
|
||||
extern Unit* UnitSlots[MAX_UNIT_SLOTS]; /// All units
|
||||
extern Unit* UnitSlots[MAX_UNIT_SLOTS]; /// All possible units
|
||||
extern Unit** UnitSlotFree; /// First free unit slot
|
||||
|
||||
extern Unit* Units[MAX_UNIT_SLOTS]; /// Units used
|
||||
extern int NumUnits; /// Number of units used
|
||||
#else
|
||||
extern int NumUnits; /// Number of units used
|
||||
extern Unit** Units; /// Units used
|
||||
|
|
|
@ -68,6 +68,7 @@ typedef struct __animations__ {
|
|||
*/
|
||||
typedef struct _missile_config_ {
|
||||
char* Name; /// config missile name
|
||||
// FIXME: void* is needed,because of recursive headers :(
|
||||
void* Missile; /// identifier to use to run time
|
||||
} MissileConfig;
|
||||
|
||||
|
|
|
@ -211,18 +211,20 @@ global void CreateMinimap(void)
|
|||
*/
|
||||
global void DrawMinimap(int vx,int vy)
|
||||
{
|
||||
Unit* unit;
|
||||
static int RedPhase;
|
||||
int mx;
|
||||
int my;
|
||||
int flags;
|
||||
int x;
|
||||
int y;
|
||||
#ifndef NEW_UNIT
|
||||
UnitType* type;
|
||||
Unit* unit;
|
||||
int i;
|
||||
int w;
|
||||
int h;
|
||||
int h0;
|
||||
UnitType* type;
|
||||
int flags;
|
||||
static int RedPhase;
|
||||
int i;
|
||||
int x;
|
||||
int y;
|
||||
#endif
|
||||
|
||||
RedPhase^=1;
|
||||
|
||||
|
@ -250,6 +252,9 @@ global void DrawMinimap(int vx,int vy)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef NEW_UNIT
|
||||
DebugLevel0("FIXME:");
|
||||
#else
|
||||
//
|
||||
// Draw units on map
|
||||
//
|
||||
|
@ -309,6 +314,7 @@ global void DrawMinimap(int vx,int vy)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
local int OldMinimapCursorX; /// Save MinimapCursorX
|
||||
|
|
|
@ -917,18 +917,16 @@ local void Abort(void) { abort(); }
|
|||
*/
|
||||
local Unit* NetworkValidUnit(int nr,int id)
|
||||
{
|
||||
Unit* unit;
|
||||
#if 0
|
||||
// Old code. deadlocks abound.
|
||||
unit=UnitsPool+ntohl(nr);
|
||||
#ifdef NEW_UNIT
|
||||
nr = ntohl(nr);
|
||||
|
||||
// Id is incremented when the unit's slot is freed.
|
||||
if( unit->Id!=ntohl(id) ) {
|
||||
DebugLevel0("Unit slot reused or empty?\n");
|
||||
Abort();
|
||||
return NoUnitP;
|
||||
if( UnitSlots[nr]->Slot==nr ) {
|
||||
return UnitSlots[nr];
|
||||
}
|
||||
DebugLevel0("Couldn't find unit %x", nr);
|
||||
return NoUnitP;
|
||||
#else
|
||||
Unit* unit;
|
||||
int i;
|
||||
|
||||
nr = ntohl(nr);
|
||||
|
@ -936,21 +934,26 @@ local Unit* NetworkValidUnit(int nr,int id)
|
|||
if (UnitsPool[i].Id == nr)
|
||||
break;
|
||||
}
|
||||
if (i >= NumUnits) {
|
||||
DebugLevel0("Couldn't find unit %x", nr);
|
||||
Abort();
|
||||
return NoUnitP;
|
||||
}
|
||||
unit = UnitsPool + i;
|
||||
#endif
|
||||
IfDebug(
|
||||
if (i >= NumUnits) {
|
||||
DebugLevel0("Couldn't find unit %x", nr);
|
||||
Abort();
|
||||
return NoUnitP;
|
||||
}
|
||||
);
|
||||
|
||||
if( UnitUnusable(unit) ) {
|
||||
DebugLevel0("Unit Dying?\n");
|
||||
Abort();
|
||||
return NoUnitP;
|
||||
}
|
||||
unit = UnitsPool + i;
|
||||
|
||||
IfDebug(
|
||||
if( UnitUnusable(unit) ) {
|
||||
DebugLevel0("Unit Dying?\n");
|
||||
Abort();
|
||||
return NoUnitP;
|
||||
}
|
||||
);
|
||||
|
||||
return unit;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1298,13 +1301,22 @@ global void NetworkSendCommand(int command,Unit* unit,int x,int y
|
|||
// We must find another solution than this one...
|
||||
// guess this is a networked crash :)
|
||||
message.Data.Command.UnitNr=htonl(UnitNumber(unit));
|
||||
#ifdef NEW_UNIT
|
||||
message.Data.Command.DestId=0;
|
||||
#else
|
||||
message.Data.Command.UnitId=htonl(unit->Id);
|
||||
#endif
|
||||
message.Data.Command.X=htonl(x);
|
||||
message.Data.Command.Y=htonl(y);
|
||||
if( dest ) {
|
||||
// We must find another solution than this one...
|
||||
#ifdef NEW_UNIT
|
||||
message.Data.Command.DestNr=htonl(UnitNumber(dest));
|
||||
message.Data.Command.DestId=0;
|
||||
#else
|
||||
message.Data.Command.DestNr=htonl(UnitNumber(dest));
|
||||
message.Data.Command.DestId=htonl(dest->Id);
|
||||
#endif
|
||||
} else {
|
||||
message.Data.Command.DestNr=htonl(-1);
|
||||
message.Data.Command.DestId=htonl(-1);
|
||||
|
|
|
@ -167,6 +167,9 @@ local SoundId ChooseUnitVoiceSoundId(Unit *unit,UnitVoiceGroup voice) {
|
|||
*/
|
||||
global void PlayUnitSound(Unit* unit,UnitVoiceGroup unit_voice_group)
|
||||
{
|
||||
#ifdef NEW_UNIT
|
||||
DebugLevel0("FIXME:\n");
|
||||
#else
|
||||
InsertSoundRequest(unit,
|
||||
unit->Id,
|
||||
ViewPointDistanceToUnit(unit),
|
||||
|
@ -176,6 +179,7 @@ global void PlayUnitSound(Unit* unit,UnitVoiceGroup unit_voice_group)
|
|||
||unit_voice_group==VoiceBuilding),
|
||||
0);
|
||||
DebugLevel3("Playing %d\n",unit_voice_group);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -514,9 +514,15 @@ global void FireMissile(Unit* unit)
|
|||
dx=unit->Command.Data.Move.DX;
|
||||
dy=unit->Command.Data.Move.DY;
|
||||
if( WallOnMap(dx,dy) ) {
|
||||
// FIXME: don't use UnitTypeByIdent here, this is slow!
|
||||
HitWall(dx,dy,CalculateDamageStats(unit->Stats,
|
||||
UnitTypeByIdent("unit-human-wall")->Stats));
|
||||
if( HumanWallOnMap(dx,dy) ) {
|
||||
// FIXME: don't use UnitTypeByIdent here, this is slow!
|
||||
HitWall(dx,dy,CalculateDamageStats(unit->Stats,
|
||||
UnitTypeByIdent("unit-human-wall")->Stats));
|
||||
} else {
|
||||
// FIXME: don't use UnitTypeByIdent here, this is slow!
|
||||
HitWall(dx,dy,CalculateDamageStats(unit->Stats,
|
||||
UnitTypeByIdent("unit-orc-wall")->Stats));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -525,11 +531,17 @@ global void FireMissile(Unit* unit)
|
|||
}
|
||||
|
||||
// FIXME: make sure thats the correct unit.
|
||||
#ifdef NEW_UNIT
|
||||
// Check if goal is correct unit.
|
||||
|
||||
#endif
|
||||
|
||||
if( goal->Removed ) {
|
||||
DebugLevel1("Missile-none hits removed unit!\n");
|
||||
return;
|
||||
}
|
||||
if( !goal->HP || goal->Command.Action==UnitActionDie ) {
|
||||
DebugLevel1("Missile-none hits dead unit!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -344,7 +344,7 @@ local const char* MapName; /// Filename for the map to load
|
|||
|
||||
/// Name, Version, Copyright
|
||||
local char NameLine[] =
|
||||
"ALE Clone V" VERSION ", (c) 1998-2000 by The FreeCraft Project.";
|
||||
"FreeCraft V" VERSION ", (c) 1998-2000 by The FreeCraft Project.";
|
||||
|
||||
/**
|
||||
** Main, called from guile main.
|
||||
|
@ -507,7 +507,7 @@ global volatile void Exit(int err)
|
|||
,PfCounterFail,PfCounterNotReachable
|
||||
,PfCounterOk,PfCounterDepth);
|
||||
);
|
||||
fprintf(stderr,"Thanks for playing ALE Clone.\n");
|
||||
fprintf(stderr,"Thanks for playing FreeCraft.\n");
|
||||
exit(err);
|
||||
}
|
||||
|
||||
|
|
|
@ -247,7 +247,7 @@ local SCM CclDefineUI(SCM list)
|
|||
}
|
||||
}
|
||||
if( !ui ) {
|
||||
ui=calloc(sizeof(UI),1);
|
||||
ui=calloc(1,sizeof(UI));
|
||||
v=malloc(sizeof(UI*)*(i+2));
|
||||
memcpy(v,UI_Table,i*sizeof(UI*));
|
||||
CclFree(UI_Table);
|
||||
|
|
|
@ -619,7 +619,7 @@ local Animation * GetSingleAnimation(SCM list){
|
|||
//printf("list %p %d",list,gh_list_p(list));
|
||||
length = gh_length(list);
|
||||
|
||||
finallist = (Animation *)calloc(sizeof(Animation),length);
|
||||
finallist = (Animation *)calloc(length,sizeof(Animation));
|
||||
while(list){
|
||||
SCM value;
|
||||
Animation anim;
|
||||
|
@ -667,7 +667,7 @@ local SCM CclAnimType(SCM list)
|
|||
{
|
||||
int length = gh_length(list)-1;
|
||||
Animation ** whole_animation =
|
||||
(Animation **)calloc(sizeof(Animation*),length);
|
||||
(Animation **)calloc(length,sizeof(Animation*));
|
||||
int type = gh_scm2int(gh_car(list));
|
||||
int cur = 0;
|
||||
|
||||
|
@ -686,7 +686,7 @@ local SCM CclAnimType(SCM list)
|
|||
for( i=0; i<UnitTypeInternalMax; ++i ) {
|
||||
unittype=UnitTypeByWcNum(i);
|
||||
if( !unittype->Animations ) {
|
||||
unittype->Animations=calloc(sizeof(*unittype->Animations),1);
|
||||
unittype->Animations=calloc(1,sizeof(*unittype->Animations));
|
||||
}
|
||||
// FIXME: animations are shared?
|
||||
CclFree(unittype->Animations->Still);
|
||||
|
@ -699,7 +699,7 @@ local SCM CclAnimType(SCM list)
|
|||
for( i=0; i<UnitTypeInternalMax; ++i ) {
|
||||
unittype=UnitTypeByWcNum(i);
|
||||
if( !unittype->Animations ) {
|
||||
unittype->Animations=calloc(sizeof(*unittype->Animations),1);
|
||||
unittype->Animations=calloc(1,sizeof(*unittype->Animations));
|
||||
}
|
||||
CclFree(unittype->Animations->Move);
|
||||
unittype->Animations->Move=whole_animation[i];
|
||||
|
@ -711,7 +711,7 @@ local SCM CclAnimType(SCM list)
|
|||
for( i=0; i<UnitTypeInternalMax; ++i ) {
|
||||
unittype=UnitTypeByWcNum(i);
|
||||
if( !unittype->Animations ) {
|
||||
unittype->Animations=calloc(sizeof(*unittype->Animations),1);
|
||||
unittype->Animations=calloc(1,sizeof(*unittype->Animations));
|
||||
}
|
||||
CclFree(unittype->Animations->Die);
|
||||
unittype->Animations->Die=whole_animation[i];
|
||||
|
@ -723,7 +723,7 @@ local SCM CclAnimType(SCM list)
|
|||
for( i=0; i<UnitTypeInternalMax; ++i ) {
|
||||
unittype=UnitTypeByWcNum(i);
|
||||
if( !unittype->Animations ) {
|
||||
unittype->Animations=calloc(sizeof(*unittype->Animations),1);
|
||||
unittype->Animations=calloc(1,sizeof(*unittype->Animations));
|
||||
}
|
||||
CclFree(unittype->Animations->Attack);
|
||||
unittype->Animations->Attack=whole_animation[i];
|
||||
|
|
|
@ -46,6 +46,13 @@
|
|||
-- Variables
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef NEW_UNIT
|
||||
global Unit* UnitSlots[MAX_UNIT_SLOTS]; /// All possible units
|
||||
global Unit** UnitSlotFree; /// First free unit slot
|
||||
|
||||
global Unit* Units[MAX_UNIT_SLOTS]; /// Array of used slots
|
||||
global int NumUnits; /// Number of slots used
|
||||
#else
|
||||
// The pool is currently hardcoded to MAX_UNITS
|
||||
global Unit* UnitsPool; /// All units in play
|
||||
|
||||
|
@ -54,6 +61,7 @@ global Unit** Units; /// Array of used slots
|
|||
|
||||
static Unit** FreeUnits; /// Array of free slots
|
||||
static int NumFreeUnits; /// Number of free slots
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Functions
|
||||
|
@ -64,6 +72,18 @@ static int NumFreeUnits; /// Number of free slots
|
|||
*/
|
||||
global void InitUnitsMemory(void)
|
||||
{
|
||||
#ifdef NEW_UNIT
|
||||
Unit** slot;
|
||||
|
||||
// Initiallize the "list" of free unit slots
|
||||
|
||||
slot=UnitSlots+MAX_UNIT_SLOTS;
|
||||
*--slot=NULL;
|
||||
do {
|
||||
slot[-1]=(void*)slot;
|
||||
} while( --slot>UnitSlots );
|
||||
UnitSlotFree=slot;
|
||||
#else
|
||||
int i;
|
||||
|
||||
UnitsPool=(Unit*)calloc(MAX_UNITS,sizeof(Unit));
|
||||
|
@ -92,6 +112,7 @@ global void InitUnitsMemory(void)
|
|||
while( i-->0 ) {
|
||||
FreeUnits[i]=&UnitsPool[MAX_UNITS-1-i];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,6 +122,34 @@ global void InitUnitsMemory(void)
|
|||
*/
|
||||
global void FreeUnitMemory(Unit* unit)
|
||||
{
|
||||
#ifdef NEW_UNIT
|
||||
Player* player;
|
||||
Unit** slot;
|
||||
|
||||
if( unit->Refs>1 ) {
|
||||
DebugLevel0(__FUNCTION__": too much references\n");
|
||||
}
|
||||
|
||||
// Remove the unit from the player's units list.
|
||||
// FIXME: a backpointer is faster
|
||||
|
||||
player=unit->Player;
|
||||
if( player ) {
|
||||
// looking for the unit slot...
|
||||
for( slot=player->Units; *slot!=unit; slot++ ) {
|
||||
;
|
||||
}
|
||||
*slot=player->Units[--player->TotalNumUnits];
|
||||
player->Units[player->TotalNumUnits]=NULL;
|
||||
}
|
||||
|
||||
slot=UnitSlots+unit->Slot;
|
||||
DebugCheck( *slot!=unit );
|
||||
|
||||
*slot=(void*)UnitSlotFree;
|
||||
free(unit);
|
||||
|
||||
#else
|
||||
Unit** tmp;
|
||||
unsigned tmp_id;
|
||||
Player* player;
|
||||
|
@ -132,6 +181,7 @@ global void FreeUnitMemory(Unit* unit)
|
|||
|
||||
// Update the 'free slots' array
|
||||
FreeUnits[NumFreeUnits++]=unit;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -145,6 +195,9 @@ global void FreeUnitMemory(Unit* unit)
|
|||
global Unit* MakeUnit(UnitType* type,Player* player)
|
||||
{
|
||||
Unit* unit;
|
||||
#ifdef NEW_UNIT
|
||||
Unit** slot;
|
||||
#endif
|
||||
|
||||
IfDebug(
|
||||
if( type>UnitTypes+sizeof(UnitTypes)/sizeof(*UnitTypes)
|
||||
|
@ -156,6 +209,18 @@ global Unit* MakeUnit(UnitType* type,Player* player)
|
|||
|
||||
DebugLevel3(__FUNCTION__": %s(%Zd)\n",type->Name,player-Players);
|
||||
|
||||
#ifdef NEW_UNIT
|
||||
if( !(slot=UnitSlotFree) ) { // should not happen!
|
||||
DebugLevel0(__FUNCTION__": Maximum of units reached\n");
|
||||
return NoUnitP;
|
||||
}
|
||||
UnitSlotFree=(void*)*slot;
|
||||
*slot=unit=calloc(1,sizeof(Unit));
|
||||
unit->Refs=1;
|
||||
unit->Slot=slot-UnitSlots;
|
||||
|
||||
...
|
||||
#else
|
||||
if( NumFreeUnits ) {
|
||||
unit=FreeUnits[--NumFreeUnits];
|
||||
FreeUnits[NumFreeUnits]=NULL;
|
||||
|
@ -164,6 +229,7 @@ global Unit* MakeUnit(UnitType* type,Player* player)
|
|||
DebugLevel0("Maximum of units reached\n");
|
||||
return NoUnitP;
|
||||
}
|
||||
#endif
|
||||
|
||||
DebugLevel3(__FUNCTION__": %p %Zd\n",unit,UnitNumber(unit));
|
||||
|
||||
|
@ -597,6 +663,9 @@ global int UnitVisible(const Unit* unit)
|
|||
*/
|
||||
global void UnitIncrementMana(void)
|
||||
{
|
||||
#ifdef NEW_UNIT
|
||||
DebugLevel0("FIXME:");
|
||||
#else
|
||||
Unit* unit;
|
||||
int i;
|
||||
|
||||
|
@ -620,6 +689,7 @@ global void UnitIncrementMana(void)
|
|||
--unit->Blink;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -953,6 +1023,9 @@ global void DropOutNearest(Unit* unit,int gx,int gy,int addx,int addy)
|
|||
*/
|
||||
global void DropOutAll(const Unit* source)
|
||||
{
|
||||
#ifdef NEW_UNIT
|
||||
DebugLevel0("FIXME:");
|
||||
#else
|
||||
Unit* unit;
|
||||
int i;
|
||||
|
||||
|
@ -968,6 +1041,7 @@ global void DropOutAll(const Unit* source)
|
|||
,source->Type->TileHeight);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
@ -989,9 +1063,11 @@ global int CanBuildHere(UnitType* type,unsigned x,unsigned y)
|
|||
Unit* table[MAX_UNITS];
|
||||
int n;
|
||||
int i;
|
||||
#ifndef NEW_UNIT
|
||||
Unit* unit;
|
||||
int dx;
|
||||
int dy;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Can't build outside the map
|
||||
|
@ -1008,6 +1084,9 @@ global int CanBuildHere(UnitType* type,unsigned x,unsigned y)
|
|||
// Gold deposit can't be build too near to gold-mine.
|
||||
//
|
||||
// FIXME: use unit-cache here.
|
||||
#ifdef NEW_UNIT
|
||||
DebugLevel0("FIXME:");
|
||||
#else
|
||||
int i;
|
||||
for( i=0; i<NumUnits; i++ ) {
|
||||
unit=Units[i];
|
||||
|
@ -1030,6 +1109,7 @@ global int CanBuildHere(UnitType* type,unsigned x,unsigned y)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1056,6 +1136,9 @@ next:
|
|||
//
|
||||
// Oil deposit can't be build too near to oil-patch.
|
||||
//
|
||||
#ifdef NEW_UNIT
|
||||
DebugLevel0("FIXME:");
|
||||
#else
|
||||
// FIXME: use unit-cache here.
|
||||
int i;
|
||||
for( i=0; i<NumUnits; i++ ) {
|
||||
|
@ -1079,6 +1162,7 @@ next:
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if( type->GivesOil ) {
|
||||
|
@ -1192,6 +1276,11 @@ global int CanBuildUnitType(Unit* unit,UnitType* type,int x,int y)
|
|||
*/
|
||||
global Unit* FindGoldMine(int x,int y)
|
||||
{
|
||||
#ifdef NEW_UNIT
|
||||
DebugLevel0("FIXME:");
|
||||
|
||||
return NULL;
|
||||
#else
|
||||
Unit* unit;
|
||||
Unit* best;
|
||||
int best_d;
|
||||
|
@ -1219,6 +1308,7 @@ global Unit* FindGoldMine(int x,int y)
|
|||
}
|
||||
DebugLevel3(__FUNCTION__": %Zd %d,%d\n",UnitNumber(best),best->X,best->Y);
|
||||
return best;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1226,6 +1316,10 @@ global Unit* FindGoldMine(int x,int y)
|
|||
*/
|
||||
global Unit* GoldDepositOnMap(int tx,int ty)
|
||||
{
|
||||
#ifdef NEW_UNIT
|
||||
DebugLevel0("FIXME:");
|
||||
return NULL;
|
||||
#else
|
||||
Unit* unit;
|
||||
UnitType* type;
|
||||
int i;
|
||||
|
@ -1247,6 +1341,7 @@ global Unit* GoldDepositOnMap(int tx,int ty)
|
|||
return unit;
|
||||
}
|
||||
return NoUnitP;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1256,6 +1351,10 @@ global Unit* GoldDepositOnMap(int tx,int ty)
|
|||
*/
|
||||
global Unit* FindGoldDeposit(const Player* player,int x,int y)
|
||||
{
|
||||
#ifdef NEW_UNIT
|
||||
DebugLevel0("FIXME:");
|
||||
return NULL;
|
||||
#else
|
||||
Unit* unit;
|
||||
Unit* best;
|
||||
Unit** units;
|
||||
|
@ -1289,6 +1388,7 @@ global Unit* FindGoldDeposit(const Player* player,int x,int y)
|
|||
|
||||
DebugLevel3(__FUNCTION__": %Zd %d,%d\n",UnitNumber(best),best->X,best->Y);
|
||||
return best;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1296,6 +1396,10 @@ global Unit* FindGoldDeposit(const Player* player,int x,int y)
|
|||
*/
|
||||
global Unit* WoodDepositOnMap(int tx,int ty)
|
||||
{
|
||||
#ifdef NEW_UNIT
|
||||
DebugLevel0("FIXME:");
|
||||
return NULL;
|
||||
#else
|
||||
Unit* unit;
|
||||
UnitType* type;
|
||||
int i;
|
||||
|
@ -1317,6 +1421,7 @@ global Unit* WoodDepositOnMap(int tx,int ty)
|
|||
return unit;
|
||||
}
|
||||
return NoUnitP;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1574,6 +1679,10 @@ global Unit* FindOilDeposit(const Player* player,int x,int y)
|
|||
*/
|
||||
global Unit* UnitOnScreen(Unit* ounit,unsigned x,unsigned y)
|
||||
{
|
||||
#ifdef NEW_UNIT
|
||||
DebugLevel0("FIXME:");
|
||||
return NULL;
|
||||
#else
|
||||
Unit* unit;
|
||||
Unit* nunit;
|
||||
Unit* funit; // first possible unit
|
||||
|
@ -1635,6 +1744,7 @@ global Unit* UnitOnScreen(Unit* ounit,unsigned x,unsigned y)
|
|||
return funit;
|
||||
}
|
||||
return nunit;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
@ -1816,6 +1926,9 @@ global void DestroyAllInside(Unit* source)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef NEW_UNIT
|
||||
DebugLevel0("FIXME:");
|
||||
#else
|
||||
//
|
||||
// Destroy all units in buildings or Resources (mines...)
|
||||
//
|
||||
|
@ -1828,6 +1941,7 @@ global void DestroyAllInside(Unit* source)
|
|||
DestroyUnit(unit);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2237,9 +2351,11 @@ global void SaveUnit(const Unit* unit,FILE* file)
|
|||
if( unit->Attacked ) {
|
||||
fprintf(file,"\t'attacked\n");
|
||||
}
|
||||
/*
|
||||
if( unit->Visible ) {
|
||||
fprintf(file,"\t'visible\n");
|
||||
}
|
||||
*/
|
||||
if( unit->Removed ) {
|
||||
fprintf(file,"\t'removed\n");
|
||||
}
|
||||
|
@ -2281,6 +2397,9 @@ global void SaveUnit(const Unit* unit,FILE* file)
|
|||
*/
|
||||
global void SaveUnits(FILE* file)
|
||||
{
|
||||
#ifdef NEW_UNIT
|
||||
DebugLevel0("FIXME:");
|
||||
#else
|
||||
Unit** unit;
|
||||
|
||||
fprintf(file,"\n;;; -----------------------------------------\n");
|
||||
|
@ -2288,6 +2407,7 @@ global void SaveUnits(FILE* file)
|
|||
for( unit=Units; unit<&Units[NumUnits]; ++unit ) {
|
||||
SaveUnit(*unit,file);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//@}
|
||||
|
|
|
@ -681,12 +681,16 @@ global void DrawUnits(void)
|
|||
//
|
||||
// 2a) corpse aren't in the cache.
|
||||
//
|
||||
#ifdef NEW_UNIT
|
||||
DebugLevel0("FIXME:");
|
||||
#else
|
||||
for( i=0; i<NumUnits; ++i ) {
|
||||
unit=Units[i];
|
||||
if( unit->Type->Vanishes || unit->Command.Action==UnitActionDie ) {
|
||||
DrawUnit(unit);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//
|
||||
// 2b) buildings
|
||||
//
|
||||
|
|
|
@ -57,6 +57,10 @@ global int SelectUnits(int x1,int y1,int x2,int y2,Unit** table)
|
|||
*/
|
||||
global int FindUnitsByType(int type,Unit** table)
|
||||
{
|
||||
#ifdef NEW_UNIT
|
||||
DebugLevel0("FIXME:");
|
||||
return 1;
|
||||
#else
|
||||
Unit* unit;
|
||||
int num,i;
|
||||
|
||||
|
@ -67,6 +71,7 @@ global int FindUnitsByType(int type,Unit** table)
|
|||
}
|
||||
}
|
||||
return num;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,6 +139,9 @@ global Unit* UnitOnMapTile(unsigned tx,unsigned ty)
|
|||
*/
|
||||
global Unit* TargetOnMapTile(Unit* source,unsigned tx,unsigned ty)
|
||||
{
|
||||
#ifdef NEW_UNIT
|
||||
DebugLevel0("FIXME:");
|
||||
#else
|
||||
Unit* unit;
|
||||
UnitType* type;
|
||||
int i;
|
||||
|
@ -143,7 +151,7 @@ global Unit* TargetOnMapTile(Unit* source,unsigned tx,unsigned ty)
|
|||
for( i=0; i<NumUnits; i++ ) {
|
||||
unit=Units[i];
|
||||
// unusable unit ?
|
||||
// if( UnitUnusable(unit) ) {
|
||||
// if( UnitUnusable(unit) )
|
||||
if( unit->Removed || unit->Command.Action==UnitActionDie ) {
|
||||
continue;
|
||||
}
|
||||
|
@ -157,6 +165,7 @@ global Unit* TargetOnMapTile(Unit* source,unsigned tx,unsigned ty)
|
|||
}
|
||||
return unit;
|
||||
}
|
||||
#endif
|
||||
return NoUnitP;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue