Made RefsDebugCheck marco.

This commit is contained in:
johns 2001-02-16 23:12:12 +00:00
parent b8d11cf444
commit a58ea32b54
18 changed files with 147 additions and 332 deletions

View file

@ -18,7 +18,7 @@
T H E W A R B E G I N S
FreeCraft - A free fantasy real time strategy game engine
</PRE>
<P><B>(C) Copyright 1998-2000 by The FreeCraft Project. Distributed under the
<P><B>(C) Copyright 1998-2001 by The FreeCraft Project. Distributed under the
<A HREF="artistic-license.html">"Artistic License"</A></B>
<HR>
@ -27,7 +27,6 @@
<UL>
<LI>Ships on oil patches cannot be attacked.
<LI>Worker with gold/wood could go to depot under construction!
<LI>ACT Image file names cannot be used with Win32.
<LI>Some scanline are missing with 640x480 resolution and SDL-win32.
<LI>Worker stops, if a nearer mine cannot be reached.
<LI>Ai can't find any way, tries this to often.

View file

@ -154,9 +154,7 @@ local void MoveToTarget(Unit* unit)
// FIXME: Should be done by Action Move???????
if( goal->Destroyed ) {
DebugLevel0Fn("destroyed unit\n");
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
if( !--goal->Refs ) {
ReleaseUnit(goal);
}
@ -167,10 +165,9 @@ local void MoveToTarget(Unit* unit)
unit->Command.Data.Move.Goal=goal=NoUnitP;
} else if( !goal->HP || goal->Command.Action==UnitActionDie ) {
#endif
RefsDebugCheck( !goal->Refs );
--goal->Refs;
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
#ifdef NEW_ORDERS
unit->Orders[0].Goal=goal=NoUnitP;
#else
@ -230,10 +227,10 @@ local void MoveToTarget(Unit* unit)
temp=AttackUnitsInReactRange(unit);
if( temp && temp->Type->Priority>goal->Type->Priority ) {
RefsDebugCheck( !goal->Refs );
goal->Refs--;
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
RefsDebugCheck( !temp->Refs );
temp->Refs++;
#ifdef NEW_ORDERS
if( unit->SavedOrder.Action==UnitActionStill ) {
@ -363,9 +360,7 @@ local void AttackTarget(Unit* unit)
if( goal ) {
if( goal->Destroyed ) {
DebugLevel0Fn("destroyed unit\n");
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
if( !--goal->Refs ) {
ReleaseUnit(goal);
}
@ -377,10 +372,9 @@ local void AttackTarget(Unit* unit)
} else if( !goal->HP || goal->Command.Action==UnitActionDie ) {
#endif
// FIXME: goal->Removed???
RefsDebugCheck( !goal->Refs );
--goal->Refs;
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
#ifdef NEW_ORDERS
unit->Orders[0].Goal=goal=NoUnitP;
#else
@ -446,10 +440,9 @@ local void AttackTarget(Unit* unit)
temp=AttackUnitsInReactRange(unit);
if( temp && temp->Type->Priority>goal->Type->Priority ) {
RefsDebugCheck( !goal->Refs );
goal->Refs--;
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
temp->Refs++;
#ifdef NEW_ORDERS
if( unit->SavedOrder.Action==UnitActionStill ) {

View file

@ -81,9 +81,7 @@ local int WaitForTransporter(Unit* unit)
}
if( trans->Destroyed ) {
DebugLevel0Fn("Destroyed unit\n");
#ifdef REFS_DEBUG
DebugCheck( !trans->Refs );
#endif
RefsDebugCheck( !trans->Refs );
if( !--trans->Refs ) {
ReleaseUnit(trans);
}
@ -99,13 +97,9 @@ local int WaitForTransporter(Unit* unit)
#else
!trans->HP || trans->Command.Action==UnitActionDie ) {
#endif
#ifdef REFS_DEBUG
DebugCheck( !trans->Refs );
#endif
RefsDebugCheck( !trans->Refs );
--trans->Refs;
#ifdef REFS_DEBUG
DebugCheck( !trans->Refs );
#endif
RefsDebugCheck( !trans->Refs );
#ifdef NEW_ORDERS
unit->Orders[0].Goal=trans=NoUnitP;
#else
@ -149,9 +143,7 @@ local void EnterTransporter(Unit* unit)
#endif
if( transporter->Destroyed ) {
DebugLevel0Fn("Destroyed unit\n");
#ifdef REFS_DEBUG
DebugCheck( !transporter->Refs );
#endif
RefsDebugCheck( !transporter->Refs );
if( !--transporter->Refs ) {
ReleaseUnit(transporter);
}
@ -167,13 +159,9 @@ local void EnterTransporter(Unit* unit)
#else
!transporter->HP || transporter->Command.Action==UnitActionDie ) {
#endif
#ifdef REFS_DEBUG
DebugCheck( !transporter->Refs );
#endif
RefsDebugCheck( !transporter->Refs );
--transporter->Refs;
#ifdef REFS_DEBUG
DebugCheck( !transporter->Refs );
#endif
RefsDebugCheck( !transporter->Refs );
#ifdef NEW_ORDERS
unit->Orders[0].Goal=NoUnitP;
#else
@ -181,13 +169,9 @@ local void EnterTransporter(Unit* unit)
#endif
return;
}
#ifdef REFS_DEBUG
DebugCheck( !transporter->Refs );
#endif
RefsDebugCheck( !transporter->Refs );
--transporter->Refs;
#ifdef REFS_DEBUG
DebugCheck( !transporter->Refs );
#endif
RefsDebugCheck( !transporter->Refs );
#ifdef NEW_ORDERS
unit->Orders[0].Goal=NoUnitP;
#else
@ -256,26 +240,20 @@ global void HandleActionBoard(Unit* unit)
unit->Orders[0].Action=UnitActionStill;
if( unit->Orders[0].Goal ) {
#ifdef REFS_DEBUG
DebugCheck(!unit->Orders[0].Goal->Refs);
#endif
RefsDebugCheck(!unit->Orders[0].Goal->Refs);
--unit->Orders[0].Goal->Refs;
#ifdef REFS_DEBUG
DebugCheck(!unit->Orders[0].Goal->Refs);
#endif
RefsDebugCheck(!unit->Orders[0].Goal->Refs);
unit->Orders[0].Goal=NoUnitP;
}
#else
unit->Command.Action=UnitActionStill;
if( unit->Command.Data.Move.Goal ) {
#ifdef REFS_DEBUG
DebugCheck(!unit->Command.Data.Move.Goal->Refs);
#endif
RefsDebugCheck(!unit->Command.Data.Move.Goal
->Refs);
--unit->Command.Data.Move.Goal->Refs;
#ifdef REFS_DEBUG
DebugCheck(!unit->Command.Data.Move.Goal->Refs);
#endif
RefsDebugCheck(!unit->Command.Data.Move.Goal
->Refs);
unit->Command.Data.Move.Goal=NoUnitP;
}
#endif

View file

@ -58,7 +58,7 @@ global void HandleActionDemolish(Unit* unit)
//
case 0:
// FIXME: reset first!! why? (johns)
err=HandleActionMove(unit);
err=HandleActionMove(unit);
if( unit->Reset ) {
goal=unit->Command.Data.Move.Goal;
//
@ -67,9 +67,7 @@ global void HandleActionDemolish(Unit* unit)
if( goal ) {
if( goal->Destroyed ) {
DebugLevel0Fn("Destroyed unit\n");
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
if( !--goal->Refs ) {
ReleaseUnit(goal);
}
@ -79,13 +77,9 @@ global void HandleActionDemolish(Unit* unit)
return;
} else if( goal->Removed || !goal->HP
|| goal->Command.Action==UnitActionDie ) {
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
--goal->Refs;
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
unit->Command.Data.Move.Goal=goal=NoUnitP;
// FIXME: perhaps I should choose an alternative
unit->Command.Action=UnitActionStill;
@ -119,13 +113,9 @@ global void HandleActionDemolish(Unit* unit)
case 1:
goal=unit->Command.Data.Move.Goal;
if( goal ) {
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
--goal->Refs;
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
unit->Command.Data.Move.Goal=NoUnitP;
}
@ -134,7 +124,7 @@ global void HandleActionDemolish(Unit* unit)
DestroyUnit(unit);
// FIXME: Must play explosion sound
// FIXME: Currently we take the X fields, the original only the O
// FIXME: Currently we take the X fields, the original only the O
// XXXXX ..O..
// XXXXX .OOO.
// XX.XX OO.OO
@ -148,7 +138,7 @@ global void HandleActionDemolish(Unit* unit)
n=SelectUnits(x-2,y-2, x+2, y+2,table);
// FIXME: Don't hit flying units!
for( i=0; i<n; ++i ) {
if ( table[i]->Type->LandUnit )
if ( table[i]->Type->LandUnit )
HitUnit(table[i],DEMOLISH_DAMAGE);
}

View file

@ -364,9 +364,7 @@ local int ReturnWithWood(Unit* unit)
if( destu ) {
if( destu->Destroyed ) {
DebugLevel0Fn("Destroyed unit\n");
#ifdef REFS_DEBUG
DebugCheck( !destu->Refs );
#endif
RefsDebugCheck( !destu->Refs );
if( !--destu->Refs ) {
ReleaseUnit(destu);
}
@ -376,13 +374,9 @@ local int ReturnWithWood(Unit* unit)
return 0;
} else if( destu->Removed || !destu->HP
|| destu->Orders[0].Action==UnitActionDie ) {
#ifdef REFS_DEBUG
DebugCheck( !destu->Refs );
#endif
RefsDebugCheck( !destu->Refs );
--destu->Refs;
#ifdef REFS_DEBUG
DebugCheck( !destu->Refs );
#endif
RefsDebugCheck( !destu->Refs );
unit->Orders[0].Goal=NoUnitP;
// FIXME: perhaps I should choose an alternative
unit->Orders[0].Action=UnitActionStill;
@ -398,9 +392,7 @@ local int ReturnWithWood(Unit* unit)
if( destu ) {
if( destu->Destroyed ) {
DebugLevel0Fn("Destroyed unit\n");
#ifdef REFS_DEBUG
DebugCheck( !destu->Refs );
#endif
RefsDebugCheck( !destu->Refs );
if( !--destu->Refs ) {
ReleaseUnit(destu);
}
@ -410,13 +402,9 @@ local int ReturnWithWood(Unit* unit)
return 0;
} else if( destu->Removed || !destu->HP
|| destu->Command.Action==UnitActionDie ) {
#ifdef REFS_DEBUG
DebugCheck( !destu->Refs );
#endif
RefsDebugCheck( !destu->Refs );
--destu->Refs;
#ifdef REFS_DEBUG
DebugCheck( !destu->Refs );
#endif
RefsDebugCheck( !destu->Refs );
unit->Command.Data.Move.Goal=NoUnitP;
// FIXME: perhaps I should choose an alternative
unit->Command.Action=UnitActionStill;
@ -424,13 +412,9 @@ local int ReturnWithWood(Unit* unit)
}
unit->Command.Data.Move.Goal=NoUnitP;
#endif
#ifdef REFS_DEBUG
DebugCheck( !destu->Refs );
#endif
RefsDebugCheck( !destu->Refs );
--destu->Refs;
#ifdef REFS_DEBUG
DebugCheck( !destu->Refs );
#endif
RefsDebugCheck( !destu->Refs );
}
#ifdef NEW_ORDERS

View file

@ -63,9 +63,7 @@ local int MoveToOilWell(Unit* unit)
well=unit->Orders[0].Goal;
if( well && (well->Destroyed || !well->HP) ) {
#ifdef REFS_DEBUG
DebugCheck( !well->Refs );
#endif
RefsDebugCheck( !well->Refs );
if( !--well->Refs ) {
ReleaseUnit(well);
}
@ -87,22 +85,16 @@ local int MoveToOilWell(Unit* unit)
return -1;
}
#ifdef REFS_DEBUG
DebugCheck( !well->Refs );
#endif
RefsDebugCheck( !well->Refs );
--well->Refs;
#ifdef REFS_DEBUG
DebugCheck( !well->Refs );
#endif
RefsDebugCheck( !well->Refs );
unit->Orders[0].Goal=NoUnitP;
#else
unit->Command.Action=UnitActionHaulOil;
well=unit->Command.Data.Move.Goal;
if( well && (well->Destroyed || !well->HP) ) {
#ifdef REFS_DEBUG
DebugCheck( !well->Refs );
#endif
RefsDebugCheck( !well->Refs );
if( !--well->Refs ) {
ReleaseUnit(well);
}
@ -124,13 +116,9 @@ local int MoveToOilWell(Unit* unit)
return -1;
}
#ifdef REFS_DEBUG
DebugCheck( !well->Refs );
#endif
RefsDebugCheck( !well->Refs );
--well->Refs;
#ifdef REFS_DEBUG
DebugCheck( !well->Refs );
#endif
RefsDebugCheck( !well->Refs );
unit->Command.Data.Move.Goal=NoUnitP;
#endif
@ -347,9 +335,7 @@ local int MoveToOilDepot(Unit* unit)
depot=unit->Orders[0].Goal;
if( depot && (depot->Destroyed || !depot->HP) ) {
#ifdef REFS_DEBUG
DebugCheck( !depot->Refs );
#endif
RefsDebugCheck( !depot->Refs );
if( !--depot->Refs ) {
ReleaseUnit(depot);
}
@ -370,9 +356,7 @@ local int MoveToOilDepot(Unit* unit)
depot=unit->Command.Data.Move.Goal;
if( depot && (depot->Destroyed || !depot->HP) ) {
#ifdef REFS_DEBUG
DebugCheck( !depot->Refs );
#endif
RefsDebugCheck( !depot->Refs );
if( !--depot->Refs ) {
ReleaseUnit(depot);
}
@ -393,13 +377,9 @@ local int MoveToOilDepot(Unit* unit)
DebugCheck( MapDistanceToUnit(unit->X,unit->Y,depot)!=1 );
#ifdef REFS_DEBUG
DebugCheck( !depot->Refs );
#endif
RefsDebugCheck( !depot->Refs );
--depot->Refs;
#ifdef REFS_DEBUG
DebugCheck( !depot->Refs );
#endif
RefsDebugCheck( !depot->Refs );
// FIXME: don't work unit->Command.Data.Move.Goal=NoUnitP;
RemoveUnit(unit);
@ -539,25 +519,17 @@ global void HandleActionHaulOil(Unit* unit)
unit->Orders[0].Action=UnitActionStill;
unit->SubAction=0;
if( unit->Orders[0].Goal ) {
#ifdef REFS_DEBUG
DebugCheck( !unit->Orders[0].Goal->Refs );
#endif
RefsDebugCheck( !unit->Orders[0].Goal->Refs );
--unit->Orders[0].Goal->Refs;
#ifdef REFS_DEBUG
DebugCheck( !unit->Orders[0].Goal->Refs );
#endif
RefsDebugCheck( !unit->Orders[0].Goal->Refs );
unit->Orders[0].Goal=NoUnitP;
#else
unit->Command.Action=UnitActionStill;
unit->SubAction=0;
if( unit->Command.Data.Move.Goal ) {
#ifdef REFS_DEBUG
DebugCheck( !unit->Command.Data.Move.Goal->Refs );
#endif
RefsDebugCheck( !unit->Command.Data.Move.Goal->Refs );
--unit->Command.Data.Move.Goal->Refs;
#ifdef REFS_DEBUG
DebugCheck( !unit->Command.Data.Move.Goal->Refs );
#endif
RefsDebugCheck( !unit->Command.Data.Move.Goal->Refs );
unit->Command.Data.Move.Goal=NoUnitP;
#endif
}
@ -586,25 +558,17 @@ global void HandleActionHaulOil(Unit* unit)
unit->Orders[0].Action=UnitActionStill;
unit->SubAction=0;
if( unit->Orders[0].Goal ) {
#ifdef REFS_DEBUG
DebugCheck( !unit->Orders[0].Goal->Refs );
#endif
RefsDebugCheck( !unit->Orders[0].Goal->Refs );
--unit->Orders[0].Goal->Refs;
#ifdef REFS_DEBUG
DebugCheck( !unit->Orders[0].Goal->Refs );
#endif
RefsDebugCheck( !unit->Orders[0].Goal->Refs );
unit->Orders[0].Goal=NoUnitP;
#else
unit->Command.Action=UnitActionStill;
unit->SubAction=0;
if( unit->Command.Data.Move.Goal ) {
#ifdef REFS_DEBUG
DebugCheck( !unit->Command.Data.Move.Goal->Refs );
#endif
RefsDebugCheck( !unit->Command.Data.Move.Goal->Refs );
--unit->Command.Data.Move.Goal->Refs;
#ifdef REFS_DEBUG
DebugCheck( !unit->Command.Data.Move.Goal->Refs );
#endif
RefsDebugCheck( !unit->Command.Data.Move.Goal->Refs );
unit->Command.Data.Move.Goal=NoUnitP;
#endif
}

View file

@ -60,9 +60,7 @@ local int MoveToGoldMine(Unit* unit)
destu=unit->Orders[0].Goal;
if( destu && (destu->Destroyed || !destu->HP) ) {
DebugLevel1Fn("WAIT after goldmine destroyed %d\n",unit->Wait);
#ifdef REFS_DEBUG
DebugCheck( !destu->Refs );
#endif
RefsDebugCheck( !destu->Refs );
if( !--destu->Refs ) {
ReleaseUnit(destu);
}
@ -81,13 +79,9 @@ local int MoveToGoldMine(Unit* unit)
//
// FIXME: hmmm... we're in trouble here.
// we should check if there's still some gold left in the mine instead.
#ifdef REFS_DEBUG
DebugCheck( !destu->Refs );
#endif
RefsDebugCheck( !destu->Refs );
--destu->Refs;
#ifdef REFS_DEBUG
DebugCheck( !destu->Refs );
#endif
RefsDebugCheck( !destu->Refs );
unit->Orders[0].Goal=NoUnitP;
destu->Data.Resource.Active++;
@ -97,9 +91,7 @@ local int MoveToGoldMine(Unit* unit)
destu=unit->Command.Data.Move.Goal;
if( destu && (destu->Destroyed || !destu->HP) ) {
DebugLevel1Fn("WAIT after goldmine destroyed %d\n",unit->Wait);
#ifdef REFS_DEBUG
DebugCheck( !destu->Refs );
#endif
RefsDebugCheck( !destu->Refs );
if( !--destu->Refs ) {
ReleaseUnit(destu);
}
@ -118,13 +110,9 @@ local int MoveToGoldMine(Unit* unit)
//
// FIXME: hmmm... we're in trouble here.
// we should check if there's still some gold left in the mine instead.
#ifdef REFS_DEBUG
DebugCheck( !destu->Refs );
#endif
RefsDebugCheck( !destu->Refs );
--destu->Refs;
#ifdef REFS_DEBUG
DebugCheck( !destu->Refs );
#endif
RefsDebugCheck( !destu->Refs );
unit->Command.Data.Move.Goal=NoUnitP;
destu->Command.Data.GoldMine.Active++;
@ -314,9 +302,7 @@ local int MoveToGoldDeposit(Unit* unit)
destu=unit->Orders[0].Goal;
if( destu && (destu->Destroyed || !destu->HP) ) {
#ifdef REFS_DEBUG
DebugCheck( !destu->Refs );
#endif
RefsDebugCheck( !destu->Refs );
if( !--destu->Refs ) {
ReleaseUnit(destu);
}
@ -332,9 +318,7 @@ local int MoveToGoldDeposit(Unit* unit)
destu=unit->Command.Data.Move.Goal;
if( destu && (destu->Destroyed || !destu->HP) ) {
#ifdef REFS_DEBUG
DebugCheck( !destu->Refs );
#endif
RefsDebugCheck( !destu->Refs );
if( !--destu->Refs ) {
ReleaseUnit(destu);
}
@ -355,13 +339,9 @@ local int MoveToGoldDeposit(Unit* unit)
return -1;
}
#ifdef REFS_DEBUG
DebugCheck( !destu->Refs );
#endif
RefsDebugCheck( !destu->Refs );
--destu->Refs;
#ifdef REFS_DEBUG
DebugCheck( !destu->Refs );
#endif
RefsDebugCheck( !destu->Refs );
RemoveUnit(unit);
unit->X=destu->X;
@ -509,25 +489,17 @@ global void HandleActionMineGold(Unit* unit)
unit->Orders[0].Action=UnitActionStill;
unit->SubAction=0;
if( unit->Orders[0].Goal ) {
#ifdef REFS_DEBUG
DebugCheck( !unit->Orders[0].Goal->Refs );
#endif
RefsDebugCheck( !unit->Orders[0].Goal->Refs );
--unit->Orders[0].Goal->Refs;
#ifdef REFS_DEBUG
DebugCheck( !unit->Orders[0].Goal->Refs );
#endif
RefsDebugCheck( !unit->Orders[0].Goal->Refs );
unit->Orders[0].Goal=NoUnitP;
#else
unit->Command.Action=UnitActionStill;
unit->SubAction=0;
if( unit->Command.Data.Move.Goal ) {
#ifdef REFS_DEBUG
DebugCheck( !unit->Command.Data.Move.Goal->Refs );
#endif
RefsDebugCheck( !unit->Command.Data.Move.Goal->Refs );
--unit->Command.Data.Move.Goal->Refs;
#ifdef REFS_DEBUG
DebugCheck( !unit->Command.Data.Move.Goal->Refs );
#endif
RefsDebugCheck( !unit->Command.Data.Move.Goal->Refs );
unit->Command.Data.Move.Goal=NoUnitP;
#endif
}
@ -561,26 +533,18 @@ global void HandleActionMineGold(Unit* unit)
unit->Orders[0].Action=UnitActionStill;
unit->SubAction=0;
if( unit->Orders[0].Goal ) {
#ifdef REFS_DEBUG
DebugCheck( !unit->Orders[0].Goal->Refs );
#endif
RefsDebugCheck( !unit->Orders[0].Goal->Refs );
--unit->Orders[0].Goal->Refs;
#ifdef REFS_DEBUG
DebugCheck( !unit->Orders[0].Goal->Refs );
#endif
RefsDebugCheck( !unit->Orders[0].Goal->Refs );
unit->Orders[0].Goal=NoUnitP;
}
#else
unit->Command.Action=UnitActionStill;
unit->SubAction=0;
if( unit->Command.Data.Move.Goal ) {
#ifdef REFS_DEBUG
DebugCheck( !unit->Command.Data.Move.Goal->Refs );
#endif
RefsDebugCheck( !unit->Command.Data.Move.Goal->Refs );
--unit->Command.Data.Move.Goal->Refs;
#ifdef REFS_DEBUG
DebugCheck( !unit->Command.Data.Move.Goal->Refs );
#endif
RefsDebugCheck( !unit->Command.Data.Move.Goal->Refs );
unit->Command.Data.Move.Goal=NoUnitP;
}
#endif

View file

@ -86,9 +86,7 @@ local int ActionMoveGeneric(Unit* unit,const Animation* move)
// FIXME: Can't choose a better target here!
if( goal->Destroyed ) {
DebugLevel0Fn("destroyed unit\n");
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
if( !--goal->Refs ) {
ReleaseUnit(goal);
}
@ -104,13 +102,9 @@ local int ActionMoveGeneric(Unit* unit,const Animation* move)
!goal->HP || goal->Command.Action==UnitActionDie ) {
#endif
DebugLevel0Fn("killed unit\n");
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
--goal->Refs;
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
#ifdef NEW_ORDERS
unit->Orders[0].Goal=goal=NoUnitP;
#else

View file

@ -176,9 +176,7 @@ global int HandleActionRepair(Unit* unit)
if( goal ) {
if( goal->Destroyed ) {
DebugLevel0Fn("destroyed unit\n");
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
if( !--goal->Refs ) {
ReleaseUnit(goal);
}
@ -198,13 +196,9 @@ global int HandleActionRepair(Unit* unit)
goal->Command.Action==UnitActionDie ) {
#endif
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
--goal->Refs;
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
// FIXME: should I clear this here?
#ifdef NEW_ORDERS
unit->Orders[0].X=goal->X;
@ -231,13 +225,9 @@ global int HandleActionRepair(Unit* unit)
DebugCheck( unit->Command.Action!=UnitActionStill );
#endif
if( goal ) { // release reference
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
goal->Refs--;
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
#ifdef NEW_ORDERS
unit->Orders[0].Goal=NoUnitP;
}
@ -274,9 +264,7 @@ global int HandleActionRepair(Unit* unit)
if( goal ) {
if( goal->Destroyed ) {
DebugLevel0Fn("destroyed unit\n");
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
if( !--goal->Refs ) {
ReleaseUnit(goal);
}
@ -314,13 +302,9 @@ global int HandleActionRepair(Unit* unit)
//
if( !goal || goal->HP >= goal->Stats->HitPoints ) {
if( goal ) { // release reference
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
goal->Refs--;
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
#ifdef NEW_ORDERS
unit->Orders[0].Goal=NULL;
}

View file

@ -135,7 +135,7 @@ global void HandleActionSpellCast(Unit* unit)
const SpellType* spell = SpellTypeById( unit->Command.Data.Move.SpellId );
if ( unit->Mana < spell->ManaCost )
{
if( unit->Player==ThisPlayer )
if( unit->Player==ThisPlayer )
{
SetMessage( "%s: not enough mana to cast spell: %s",
unit->Type->Name, spell->Ident );
@ -161,13 +161,9 @@ global void HandleActionSpellCast(Unit* unit)
unit->SubAction=0;
unit->Wait = 1;
if ( unit->Command.Data.Move.Goal )
#ifdef REFS_DEBUG
DebugCheck( !unit->Command.Data.Move.Goal->Refs );
#endif
RefsDebugCheck( !unit->Command.Data.Move.Goal->Refs );
unit->Command.Data.Move.Goal->Refs--;
#ifdef REFS_DEBUG
DebugCheck( !unit->Command.Data.Move.Goal->Refs );
#endif
RefsDebugCheck( !unit->Command.Data.Move.Goal->Refs );
}
}
break;

View file

@ -196,9 +196,7 @@ global void ActionStillGeneric(Unit* unit,int ground)
if( temp && temp->Destroyed ) {
DebugLevel3Fn(" destroyed unit %Zd #%d\n"
,UnitNumber(temp),temp->Refs);
#ifdef REFS_DEBUG
DebugCheck( !temp->Refs );
#endif
RefsDebugCheck( !temp->Refs );
if( !--temp->Refs ) {
ReleaseUnit(temp);
}
@ -213,13 +211,9 @@ global void ActionStillGeneric(Unit* unit,int ground)
if( temp ) {
DebugLevel3Fn(" old unit %Zd #%d\n"
,UnitNumber(temp),temp->Refs);
#ifdef REFS_DEBUG
DebugCheck( !temp->Refs );
#endif
RefsDebugCheck( !temp->Refs );
temp->Refs--;
#ifdef REFS_DEBUG
DebugCheck( !temp->Refs );
#endif
RefsDebugCheck( !temp->Refs );
}
#ifdef NEW_ORDERS
unit->Orders[0].Goal=goal;
@ -245,13 +239,9 @@ global void ActionStillGeneric(Unit* unit,int ground)
#else
if( (temp=unit->Command.Data.Move.Goal) ) {
#endif
#ifdef REFS_DEBUG
DebugCheck( !temp->Refs );
#endif
RefsDebugCheck( !temp->Refs );
temp->Refs--;
#ifdef REFS_DEBUG
DebugCheck( !temp->Refs );
#endif
RefsDebugCheck( !temp->Refs );
#ifdef NEW_ORDERS
unit->Orders[0].Goal=NoUnitP;
#else

View file

@ -56,7 +56,7 @@ local int MoveToCoast(Unit* unit)
return 0;
}
IfDebug(
IfDebug(
if( !CoastOnMap(unit->X,unit->Y) ) {
DebugLevel2Fn("COAST NOT REACHED\n");
return -1;
@ -95,21 +95,15 @@ local void LeaveTransporter(Unit* unit)
#endif
if( goal->Destroyed ) {
DebugLevel0Fn("destroyed unit\n");
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
if( !--goal->Refs ) {
ReleaseUnit(goal);
}
return;
}
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
--goal->Refs;
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
for( i=0; i<MAX_UNITS_ONBOARD; ++i ) {
if( goal==unit->OnBoard[i] ) {
goal->X=unit->X;

View file

@ -126,9 +126,7 @@ local void HandleUnitAction(Unit* unit)
// Release pending references.
//
if( unit->Orders[0].Goal ) {
#ifdef REFS_DEBUG
DebugCheck( !unit->Orders[0].Goal->Refs );
#endif
RefsDebugCheck( !unit->Orders[0].Goal->Refs );
if( !--unit->Orders[0].Goal->Refs ) {
ReleaseUnit(unit->Orders[0].Goal);
}
@ -176,9 +174,7 @@ local void HandleUnitAction(Unit* unit)
// Release pending references.
//
if( unit->Command.Data.Move.Goal ) {
#ifdef REFS_DEBUG
DebugCheck( !unit->Command.Data.Move.Goal->Refs-- );
#endif
RefsDebugCheck( !unit->Command.Data.Move.Goal->Refs );
if !--unit->Command.Data.Move.Goal->Refs ) {
ReleaseUnit(unit->Command.Data.Move.Goal);
}

View file

@ -47,9 +47,7 @@
local void ReleaseOrder(Order* order)
{
if( order->Goal ) {
#ifdef REFS_DEBUG
DebugCheck( !order->Goal->Refs );
#endif
RefsDebugCheck( !order->Goal->Refs );
if( !--order->Goal->Refs ) {
ReleaseUnit(order->Goal);
}

View file

@ -135,6 +135,21 @@
#endif // } !DEBUG
#ifdef REFS_DEBUG // {
/**
** Debug check condition
*/
#define RefsDebugCheck(cond) do{ if( cond ) { \
fprintf(stderr,"DebugCheck at %s:%d\n",__FILE__,__LINE__); \
abort(); } }while( 0 )
#else // }{ REFS_DEBUG
#define RefsDebugCheck(cond) /* disabled */
#endif // } !REFS_DEBUG
/*============================================================================
== Storage types
============================================================================*/

View file

@ -692,9 +692,7 @@ global void FireMissile(Unit* unit)
// Check if goal is correct unit.
if( goal->Destroyed ) {
DebugLevel0Fn("destroyed unit\n");
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
if( !--goal->Refs ) {
ReleaseUnit(goal);
}
@ -709,13 +707,9 @@ global void FireMissile(Unit* unit)
}
if( goal->Removed ) {
DebugLevel3Fn("Missile-none hits removed unit!\n");
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
--goal->Refs;
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
#ifdef NEW_ORDERS
goal=unit->Orders[0].Goal=NULL;
#else
@ -729,13 +723,9 @@ global void FireMissile(Unit* unit)
if( !goal->HP || goal->Command.Action==UnitActionDie ) {
#endif
DebugLevel3Fn("Missile-none hits dead unit!\n");
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
--goal->Refs;
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
#ifdef NEW_ORDERS
goal=unit->Orders[0].Goal=NULL;
#else
@ -761,9 +751,7 @@ global void FireMissile(Unit* unit)
// Check if goal is correct unit.
if( goal->Destroyed ) {
DebugLevel0Fn("destroyed unit\n");
#ifdef REFS_DEBUG
DebugCheck( !goal->Refs );
#endif
RefsDebugCheck( !goal->Refs );
if( !--goal->Refs ) {
ReleaseUnit(goal);
}
@ -1339,9 +1327,7 @@ global void MissileActions(void)
unit=missile->SourceUnit;
if( unit->Destroyed || !unit->HP ) {
#ifdef REFS_DEBUG
DebugCheck( !unit->Refs );
#endif
RefsDebugCheck( !unit->Refs );
if( !--unit->Refs ) {
ReleaseUnit(unit);
}

View file

@ -163,21 +163,13 @@ global int SpellDeathCoilController( void* missile )
int n;
Missile* mis = (Missile*)missile;
#ifdef REFS_DEBUG
DebugCheck( !mis->SourceUnit->Refs );
#endif
RefsDebugCheck( !mis->SourceUnit->Refs );
mis->SourceUnit->Refs--;
#ifdef REFS_DEBUG
DebugCheck( !mis->SourceUnit->Refs );
#endif
RefsDebugCheck( !mis->SourceUnit->Refs );
if ( mis->TargetUnit ) {
#ifdef REFS_DEBUG
DebugCheck( !mis->TargetUnit->Refs );
#endif
RefsDebugCheck( !mis->TargetUnit->Refs );
mis->TargetUnit->Refs--;
#ifdef REFS_DEBUG
DebugCheck( !mis->TargetUnit->Refs );
#endif
RefsDebugCheck( !mis->TargetUnit->Refs );
}
if ( mis->X == mis->DX && mis->Y == mis->DY )
{ // missile has reached target unit/spot
@ -212,7 +204,7 @@ global int SpellDeathCoilController( void* missile )
&& table[i]->Type->Organic != 0);
if ( ec > 0 )
{ // yes organic enemies found
for( i=0; i<n; ++i )
for( i=0; i<n; ++i )
if ( IsEnemy(mis->SourceUnit->Player,table[i])
&& table[i]->Type->Organic != 0 )
{
@ -227,7 +219,7 @@ global int SpellDeathCoilController( void* missile )
else
table[i]->HP = hp;
}
mis->SourceUnit->HP += 50;
mis->SourceUnit->HP += 50;
if ( mis->SourceUnit->HP > mis->SourceUnit->Stats->HitPoints )
mis->SourceUnit->HP = mis->SourceUnit->Stats->HitPoints;
}
@ -505,7 +497,7 @@ global int SpellCast( int SpellId, Unit* unit, Unit* target, int x, int y )
break;
// ---human mages---
case SpellActionFireball:
{ //NOTE: fireball can be casted on spot
{ //NOTE: fireball can be casted on spot
Missile* mis;
int sx = unit->X;
int sy = unit->Y;
@ -530,7 +522,7 @@ global int SpellCast( int SpellId, Unit* unit, Unit* target, int x, int y )
unit->Mana -= spell->ManaCost;
PlayGameSound(SoundIdForName(spell->Casted.Name),MaxSampleVolume); \
PlayGameSound(SoundIdForName(spell->Casted.Name),MaxSampleVolume); \
mis = MakeMissile( MissileTypeByIdent("missile-fireball"),
sx, sy, dx, dy );
@ -595,7 +587,7 @@ global int SpellCast( int SpellId, Unit* unit, Unit* target, int x, int y )
DebugCheck( unit->Mana < 0 );
break;
case SpellActionBlizzard:
{
{
/*
NOTE: vladi: blizzard differs than original in this way:
original: launches 50 shards at 5 random spots x 10 for 25 mana
@ -678,7 +670,7 @@ global int SpellCast( int SpellId, Unit* unit, Unit* target, int x, int y )
break;
// ---orc death knights---
case SpellActionDeathCoil:
if( (target && target->Type->Organic) || (!target) )
if( (target && target->Type->Organic) || (!target) )
{
Missile* mis;
int sx = unit->X;
@ -694,7 +686,7 @@ global int SpellCast( int SpellId, Unit* unit, Unit* target, int x, int y )
unit->Mana -= spell->ManaCost;
PlayGameSound(SoundIdForName(spell->Casted.Name),MaxSampleVolume); \
PlayGameSound(SoundIdForName(spell->Casted.Name),MaxSampleVolume); \
mis = MakeMissile( MissileTypeByIdent("missile-death-coil"),
sx*TileSizeX+TileSizeX/2,
sy*TileSizeX+TileSizeX/2,
@ -706,7 +698,7 @@ global int SpellCast( int SpellId, Unit* unit, Unit* target, int x, int y )
if (target)
{
mis->TargetUnit = target;
target->Refs++;
target->Refs++;
}
mis->Controller = SpellDeathCoilController;
}
@ -739,13 +731,13 @@ global int SpellCast( int SpellId, Unit* unit, Unit* target, int x, int y )
|| Units[i]->Command.Action==UnitActionDie)
&& Units[i]->X == x && Units[i]->Y == y ) {
#endif
//FIXME: URGENT: remove corpse
//FIXME: URGENT: remove corpse
//RemoveUnit( Units[i] );
//UnitLost( Units[i] );
//ReleaseUnit( Units[i] );
MakeUnitAndPlace( x, y, UnitTypeByIdent("unit-skeleton"),
unit->Player );
unit->Mana -= spell->ManaCost;
unit->Mana -= spell->ManaCost;
break;
}
}
@ -759,7 +751,7 @@ global int SpellCast( int SpellId, Unit* unit, Unit* target, int x, int y )
Missile* mis;
unit->Mana -= spell->ManaCost;
PlayGameSound(SoundIdForName(spell->Casted.Name),MaxSampleVolume); \
PlayGameSound(SoundIdForName(spell->Casted.Name),MaxSampleVolume); \
mis = MakeMissile( MissileTypeByIdent("missile-whirlwind"),
x*TileSizeX+TileSizeX/2,
y*TileSizeX+TileSizeX/2,
@ -783,7 +775,7 @@ global int SpellCast( int SpellId, Unit* unit, Unit* target, int x, int y )
DebugCheck( unit->Mana < 0 );
break;
case SpellActionDeathAndDecay:
{
{
/*
See notes about Blizzard spell above...
*/

View file

@ -151,9 +151,7 @@ global void ReleaseUnit(Unit* unit)
}
}
#ifdef REFS_DEBUG
DebugCheck( unit->Refs );
#endif
RefsDebugCheck( unit->Refs );
#ifdef UNIT_ON_MAP
if( 0 ) { // debug check
@ -2268,10 +2266,10 @@ global void HitUnit(Unit* unit,int damage)
DebugCheck( damage==0 || unit->HP==0 || unit->Type->Vanishes );
if ( unit->UnholyArmor > 0 )
{ //NOTE: vladi: units with active UnholyArmour are invulnerable
return;
}
if ( unit->UnholyArmor > 0 ) {
// vladi: units with active UnholyArmour are invulnerable
return;
}
type=unit->Type;
if( !unit->Attacked ) {