diff --git a/src/action/action_attack.cpp b/src/action/action_attack.cpp index 5c0757887..2e4300746 100644 --- a/src/action/action_attack.cpp +++ b/src/action/action_attack.cpp @@ -10,7 +10,7 @@ // /**@name action_attack.c - The attack action. */ // -// (c) Copyright 1998-2000 by Lutz Sammer +// (c) Copyright 1998-2001 by Lutz Sammer // // $Id$ @@ -130,14 +130,18 @@ 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 if( !--goal->Refs ) { ReleaseUnit(goal); } unit->Command.Data.Move.Goal=goal=NoUnitP; } else if( !goal->HP || goal->Command.Action==UnitActionDie ) { --goal->Refs; +#ifdef REFS_DEBUG DebugCheck( !goal->Refs ); +#endif unit->Command.Data.Move.Goal=goal=NoUnitP; } } @@ -174,7 +178,9 @@ local void MoveToTarget(Unit* unit) temp=AttackUnitsInReactRange(unit); if( temp && temp->Type->Priority>goal->Type->Priority ) { goal->Refs--; +#ifdef REFS_DEBUG DebugCheck( !goal->Refs ); +#endif temp->Refs++; if( unit->SavedCommand.Action==UnitActionStill ) { // Save current command to come back. @@ -253,7 +259,9 @@ local void AttackTarget(Unit* unit) if( goal ) { if( goal->Destroyed ) { DebugLevel0Fn("destroyed unit\n"); +#ifdef REFS_DEBUG DebugCheck( !goal->Refs ); +#endif if( !--goal->Refs ) { ReleaseUnit(goal); } @@ -261,7 +269,9 @@ local void AttackTarget(Unit* unit) } else if( !goal->HP || goal->Command.Action==UnitActionDie ) { // FIXME: goal->Removed??? --goal->Refs; +#ifdef REFS_DEBUG DebugCheck( !goal->Refs ); +#endif unit->Command.Data.Move.Goal=goal=NoUnitP; } } @@ -301,7 +311,9 @@ local void AttackTarget(Unit* unit) temp=AttackUnitsInReactRange(unit); if( temp && temp->Type->Priority>goal->Type->Priority ) { goal->Refs--; +#ifdef REFS_DEBUG DebugCheck( !goal->Refs ); +#endif temp->Refs++; if( unit->SavedCommand.Action==UnitActionStill ) { // Save current command to come back. diff --git a/src/action/action_board.cpp b/src/action/action_board.cpp index b0253dcc6..b18c30514 100644 --- a/src/action/action_board.cpp +++ b/src/action/action_board.cpp @@ -72,7 +72,9 @@ local int WaitForTransporter(Unit* unit) } if( trans->Destroyed ) { DebugLevel0Fn("Destroyed unit\n"); +#ifdef REFS_DEBUG DebugCheck( !trans->Refs ); +#endif if( !--trans->Refs ) { ReleaseUnit(trans); } @@ -80,9 +82,13 @@ local int WaitForTransporter(Unit* unit) return 0; } else if( trans->Removed || !trans->HP || trans->Command.Action==UnitActionDie ) { +#ifdef REFS_DEBUG DebugCheck( !trans->Refs ); +#endif --trans->Refs; +#ifdef REFS_DEBUG DebugCheck( !trans->Refs ); +#endif unit->Command.Data.Move.Goal=trans=NoUnitP; return 0; } @@ -114,7 +120,9 @@ local void EnterTransporter(Unit* unit) transporter=unit->Command.Data.Move.Goal; if( transporter->Destroyed ) { DebugLevel0Fn("Destroyed unit\n"); +#ifdef REFS_DEBUG DebugCheck( !transporter->Refs ); +#endif if( !--transporter->Refs ) { ReleaseUnit(transporter); } @@ -122,15 +130,23 @@ local void EnterTransporter(Unit* unit) return; } else if( transporter->Removed || !transporter->HP || transporter->Command.Action==UnitActionDie ) { +#ifdef REFS_DEBUG DebugCheck( !transporter->Refs ); +#endif --transporter->Refs; +#ifdef REFS_DEBUG DebugCheck( !transporter->Refs ); +#endif unit->Command.Data.Move.Goal=NoUnitP; return; } +#ifdef REFS_DEBUG DebugCheck( !transporter->Refs ); +#endif --transporter->Refs; +#ifdef REFS_DEBUG DebugCheck( !transporter->Refs ); +#endif unit->Command.Data.Move.Goal=NoUnitP; // @@ -194,9 +210,13 @@ global void HandleActionBoard(Unit* unit) unit->Command.Action=UnitActionStill; if( unit->Command.Data.Move.Goal ) { +#ifdef REFS_DEBUG DebugCheck(!unit->Command.Data.Move.Goal->Refs); +#endif --unit->Command.Data.Move.Goal->Refs; +#ifdef REFS_DEBUG DebugCheck(!unit->Command.Data.Move.Goal->Refs); +#endif unit->Command.Data.Move.Goal=NoUnitP; } unit->SubAction=0;