NEW_ORDERS are now only supported, old code removed.

This commit is contained in:
johns 2001-03-25 19:59:26 +00:00
parent 3a0b8fdc39
commit 2ec5a0a20f
3 changed files with 11 additions and 82 deletions

View file

@ -57,9 +57,7 @@ global void HandleActionDemolish(Unit* unit)
// Move near to target.
//
case 0: // first entry.
#ifdef NEW_ORDERS
NewResetPath(unit);
#endif
unit->SubAction=1;
// FALL THROUGH
@ -67,11 +65,7 @@ global void HandleActionDemolish(Unit* unit)
// FIXME: reset first!! why? (johns)
err=DoActionMove(unit);
if( unit->Reset ) {
#ifdef NEW_ORDERS
goal=unit->Orders[0].Goal;
#else
goal=unit->Command.Data.Move.Goal;
#endif
//
// Target is dead, stop demolish.
// FIXME: what should I do, go back or explode on place?
@ -84,8 +78,7 @@ global void HandleActionDemolish(Unit* unit)
ReleaseUnit(goal);
}
// FIXME: perhaps I should choose an alternative
#ifdef NEW_ORDERS
unit->Orders[0].Goal=goal=NoUnitP;
unit->Orders[0].Goal=NoUnitP;
unit->Orders[0].Action=UnitActionStill;
unit->SubAction=0;
return;
@ -94,31 +87,16 @@ global void HandleActionDemolish(Unit* unit)
RefsDebugCheck( !goal->Refs );
--goal->Refs;
RefsDebugCheck( !goal->Refs );
unit->Orders[0].Goal=goal=NoUnitP;
unit->Orders[0].Goal=NoUnitP;
// FIXME: perhaps I should choose an alternative
unit->Orders[0].Action=UnitActionStill;
unit->SubAction=0;
#else
unit->Command.Data.Move.Goal=goal=NoUnitP;
unit->Command.Action=UnitActionStill;
unit->SubAction=0;
return;
} else if( goal->Removed || !goal->HP
|| goal->Command.Action==UnitActionDie ) {
RefsDebugCheck( !goal->Refs );
--goal->Refs;
RefsDebugCheck( !goal->Refs );
// FIXME: perhaps I should choose an alternative
unit->Command.Data.Move.Goal=goal=NoUnitP;
unit->Command.Action=UnitActionStill;
unit->SubAction=0;
#endif
return;
}
}
//
// Have reached target? FIXME: could use result?
// Have reached target? FIXME: could use pathfinder result?
//
if( goal ) {
if( MapDistanceToUnit(unit->X,unit->Y,goal)<=1 ) {
@ -126,22 +104,14 @@ global void HandleActionDemolish(Unit* unit)
unit->SubAction=2;
}
} else if( MapDistance(unit->X,unit->Y
#ifdef NEW_ORDERS
,unit->Orders[0].X,unit->Orders[0].Y)<=1 ) {
#else
,unit->Command.Data.Move.DX
,unit->Command.Data.Move.DY)<=1 ) {
#endif
unit->State=0;
unit->SubAction=2;
} else if( err==PF_UNREACHABLE ) {
unit->Orders[0].Action=UnitActionStill;
return;
}
#ifdef NEW_ORDERS
unit->Orders[0].Action=UnitActionDemolish;
#else
unit->Command.Action=UnitActionDemolish;
#endif
DebugCheck( unit->Orders[0].Action!=UnitActionDemolish );
}
break;
@ -149,20 +119,12 @@ global void HandleActionDemolish(Unit* unit)
// Demolish the target.
//
case 2:
#ifdef NEW_ORDERS
goal=unit->Orders[0].Goal;
#else
goal=unit->Command.Data.Move.Goal;
#endif
if( goal ) {
RefsDebugCheck( !goal->Refs );
--goal->Refs;
RefsDebugCheck( !goal->Refs );
#ifdef NEW_ORDERS
unit->Orders[0].Goal=NoUnitP;
#else
unit->Command.Data.Move.Goal=NoUnitP;
#endif
}
x=unit->X;

View file

@ -24,9 +24,6 @@
#include <stdlib.h>
#include "freecraft.h"
#include "video.h"
#include "sound_id.h"
#include "unitsound.h"
#include "unittype.h"
#include "player.h"
#include "unit.h"
@ -57,8 +54,7 @@ global void HandleActionDie(Unit* unit)
UnitShowAnimation(unit,unit->Type->Animations->Die);
} else {
// some units has no death animation
unit->Reset=1;
unit->Wait=1;
unit->Reset=unit->Wait=1;
}
//
@ -73,7 +69,6 @@ global void HandleActionDie(Unit* unit)
unit->State=unit->Type->CorpseScript;
unit->Type=unit->Type->CorpseType;
#ifdef NEW_ORDERS
CommandStopUnit(unit); // This clears all order queues
IfDebug(
if( unit->Orders[0].Action!=UnitActionDie ) {
@ -82,17 +77,9 @@ global void HandleActionDie(Unit* unit)
);
unit->Orders[0].Action=UnitActionDie;
--unit->OrderCount; // remove the stop command
#else
unit->Command.Action=UnitActionDie;
if( unit->NextCount ) {
DebugLevel0Fn("NextCount = %d\n",unit->NextCount);
}
unit->NextCount=0;
#endif
unit->SubAction=0;
unit->Frame=0;
UnitUpdateHeading(unit);
DebugCheck( !unit->Type->Animations || !unit->Type->Animations->Die );
UnitShowAnimation(unit,unit->Type->Animations->Die);
// FIXME: perhaps later or never is better

View file

@ -33,6 +33,8 @@
-- Defines
----------------------------------------------------------------------------*/
#ifndef USE_CCL
#define USE_EXTENSIONS /// Enable our extensions
// Unit lists
@ -79,11 +81,12 @@
#define ORC_AIR_FORCES \
"unit-eye-of-kilrogg,unit-dragon,unit-goblin-zeppelin"
#endif
/*----------------------------------------------------------------------------
-- Declaration
----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
-- Variables
----------------------------------------------------------------------------*/
@ -127,7 +130,6 @@ global int ButtonCheckFalse(const Unit* unit,const ButtonAction* button)
*/
global int ButtonCheckUpgrade(const Unit* unit,const ButtonAction* button)
{
DebugLevel2Fn("%s\n",button->AllowStr);
return UpgradeIdentAllowed(unit->Player,button->AllowStr)=='R';
}
@ -140,7 +142,6 @@ global int ButtonCheckUpgrade(const Unit* unit,const ButtonAction* button)
*/
global int ButtonCheckUnit(const Unit* unit,const ButtonAction* button)
{
DebugLevel3("%s\n",button->AllowStr);
return HaveUnitTypeByIdent(unit->Player,button->AllowStr);
}
@ -157,7 +158,6 @@ global int ButtonCheckUnits(const Unit* unit,const ButtonAction* button)
const char* s;
Player* player;
DebugLevel3("%s\n",button->AllowStr);
player=unit->Player;
buf=alloca(strlen(button->AllowStr)+1);
strcpy(buf,button->AllowStr);
@ -186,6 +186,7 @@ global int ButtonCheckNetwork(const Unit* unit,const ButtonAction* button)
/**
** Check for button enabled, if the unit isn't working.
** Working is training, upgrading, researching.
**
** @param unit Pointer to unit for button.
** @param button Pointer to button to check/enable.
@ -193,17 +194,10 @@ global int ButtonCheckNetwork(const Unit* unit,const ButtonAction* button)
*/
global int ButtonCheckNoWork(const Unit* unit,const ButtonAction* button)
{
#ifdef NEW_ORDERS
return unit->Type->Building
&& unit->Orders[0].Action != UnitActionTrain
&& unit->Orders[0].Action != UnitActionUpgradeTo
&& unit->Orders[0].Action != UnitActionResearch;
#else
return unit->Type->Building
&& unit->Command.Action != UnitActionTrain
&& unit->Command.Action != UnitActionUpgradeTo
&& unit->Command.Action != UnitActionResearch;
#endif
}
/**
@ -215,15 +209,9 @@ global int ButtonCheckNoWork(const Unit* unit,const ButtonAction* button)
*/
global int ButtonCheckNoResearch(const Unit* unit,const ButtonAction* button)
{
#ifdef NEW_ORDERS
return unit->Type->Building
&& unit->Orders[0].Action != UnitActionUpgradeTo
&& unit->Orders[0].Action != UnitActionResearch;
#else
return unit->Type->Building
&& unit->Command.Action != UnitActionUpgradeTo
&& unit->Command.Action != UnitActionResearch;
#endif
}
/**
@ -236,16 +224,9 @@ global int ButtonCheckNoResearch(const Unit* unit,const ButtonAction* button)
*/
global int ButtonCheckUpgradeTo(const Unit* unit,const ButtonAction* button)
{
#ifdef NEW_ORDERS
if ( unit->Orders[0].Action != UnitActionStill ) {
return 0;
}
#else
if ( unit->Command.Action != UnitActionStill ) {
return 0;
}
#endif
DebugLevel3("%s\n",button->ValueStr);
return CheckDependByIdent(unit->Player,button->ValueStr);
}
@ -274,7 +255,6 @@ global int ButtonCheckResearch(const Unit* unit,const ButtonAction* button)
return 0;
}
DebugLevel3("%s\n",button->ValueStr);
// check if allowed
if ( !CheckDependByIdent( ThisPlayer, button->ValueStr ) ) {
return 0;