NEW_ORDERS are now only supported, old code removed.

This commit is contained in:
johns 2001-03-25 23:10:06 +00:00
parent b02d1003b2
commit 73c60057b6
11 changed files with 13 additions and 1035 deletions

View file

@ -50,7 +50,6 @@ global void HandleActionResearch(Unit* unit)
DebugLevel3("Research %Zd\n",UnitNumber(unit));
#ifdef NEW_ORDERS
if( !unit->SubAction ) { // first entry
unit->SubAction=1;
unit->Data.Research.Ticks=0;
@ -60,12 +59,6 @@ global void HandleActionResearch(Unit* unit)
unit->Data.Research.Ticks+=SpeedResearch;
if( unit->Data.Research.Ticks>=upgrade->Costs[TimeCost] ) {
#else
upgrade=unit->Command.Data.Research.What;
unit->Command.Data.Research.Ticks+=SpeedResearch;
if( unit->Command.Data.Research.Ticks>=upgrade->Costs[TimeCost] ) {
#endif
// FIXME: should als speak and tell ai. generic notify/message.
if( unit->Player==ThisPlayer ) {
@ -77,11 +70,7 @@ global void HandleActionResearch(Unit* unit)
UpgradeAcquire(unit->Player,upgrade);
unit->Reset=unit->Wait=1;
#ifdef NEW_ORDERS
unit->Orders[0].Action=UnitActionStill;
#else
unit->Command.Action=UnitActionStill;
#endif
unit->SubAction=0;
// Upgrade can change all

View file

@ -52,7 +52,6 @@ global void HandleActionTrain(Unit* unit)
Player* player;
player=unit->Player;
#ifdef NEW_ORDERS
//
// First entry
//
@ -67,14 +66,6 @@ global void HandleActionTrain(Unit* unit)
if( unit->Data.Train.Ticks
>=unit->Data.Train.What[0]
->Stats[player->Player].Costs[TimeCost] ) {
#else
unit->Command.Data.Train.Ticks+=SpeedTrain;
// FIXME: Should count down
if( unit->Command.Data.Train.Ticks
>=unit->Command.Data.Train.What[0]
->Stats[player->Player].Costs[TimeCost] ) {
#endif
//
// Check if enough food available.
//
@ -89,21 +80,13 @@ global void HandleActionTrain(Unit* unit)
// AiNeedMoreFarms(unit);
}
#ifdef NEW_ORDERS
unit->Data.Train.Ticks-=SpeedTrain;
#else
unit->Command.Data.Train.Ticks-=SpeedTrain;
#endif
unit->Reset=1;
unit->Wait=FRAMES_PER_SECOND/6;
return;
}
#ifdef NEW_ORDERS
nunit=MakeUnit(unit->Data.Train.What[0],player);
#else
nunit=MakeUnit(unit->Command.Data.Train.What[0],player);
#endif
nunit->X=unit->X;
nunit->Y=unit->Y;
type=unit->Type;
@ -119,7 +102,6 @@ global void HandleActionTrain(Unit* unit)
unit->Reset=unit->Wait=1;
#ifdef NEW_ORDERS
if ( --unit->Data.Train.Count ) {
int z;
for( z = 0; z < unit->Data.Train.Count ; z++ ) {
@ -143,30 +125,6 @@ global void HandleActionTrain(Unit* unit)
RefsDebugCheck( !nunit->Orders[0].Goal->Refs );
nunit->Orders[0].Goal->Refs++;
}
#else
if ( --unit->Command.Data.Train.Count ) {
int z;
for( z = 0; z < unit->Command.Data.Train.Count ; z++ ) {
unit->Command.Data.Train.What[z] =
unit->Command.Data.Train.What[z+1];
}
unit->Command.Data.Train.Ticks=0;
} else {
unit->Command.Action=UnitActionStill;
unit->SubAction=0;
}
nunit->Command=unit->PendCommand;
//
// FIXME: Pending command uses any references?
//
if( nunit->Command.Data.Move.Goal ) {
if( nunit->Command.Data.Move.Goal->Destroyed ) {
DebugLevel0Fn("FIXME: you have found a bug, please fix it.\n");
}
nunit->Command.Data.Move.Goal->Refs++;
}
#endif
if( IsSelected(unit) ) {
UpdateButtonPanel();

View file

@ -63,11 +63,7 @@ local int MoveToCoast(Unit* unit)
}
)
#ifdef NEW_ORDERS
unit->Orders[0].Action=UnitActionUnload;
#else
unit->Command.Action=UnitActionUnload;
#endif
DebugCheck( unit->Orders[0].Action!=UnitActionUnload );
return 1;
}
@ -81,18 +77,10 @@ local void LeaveTransporter(Unit* unit)
int i;
Unit* goal;
#ifdef NEW_ORDERS
goal=unit->Orders[0].Goal;
#else
goal=unit->Command.Data.Move.Goal;
#endif
DebugLevel3Fn("Goal %p\n",goal);
if( goal ) {
#ifdef NEW_ORDERS
unit->Orders[0].Goal=NoUnitP;
#else
unit->Command.Data.Move.Goal=NoUnitP;
#endif
if( goal->Destroyed ) {
DebugLevel0Fn("destroyed unit\n");
RefsDebugCheck( !goal->Refs );
@ -132,11 +120,7 @@ local void LeaveTransporter(Unit* unit)
MustRedraw|=RedrawPanels;
}
unit->Wait=1;
#ifdef NEW_ORDERS
unit->Orders[0].Action=UnitActionStill;
#else
unit->Command.Action=UnitActionStill;
#endif
unit->SubAction=0;
}
@ -157,26 +141,16 @@ global void HandleActionUnload(Unit* unit)
// Move the transporter
//
case 0:
#ifdef NEW_ORDERS
NewResetPath(unit);
#endif
unit->SubAction=1;
// FALL THROUGH
case 1:
#ifdef NEW_ORDERS
if( !unit->Orders[0].Goal ) {
#else
if( !unit->Command.Data.Move.Goal ) {
#endif
// NOTE: the Move clears the goal!!
if( (i=MoveToCoast(unit)) ) {
if( i==-1 ) {
if( ++unit->SubAction==1 ) {
#ifdef NEW_ORDERS
unit->Orders[0].Action=UnitActionStill;
#else
unit->Command.Action=UnitActionStill;
#endif
unit->SubAction=0;
}
} else {

View file

@ -49,7 +49,6 @@ global void HandleActionUpgradeTo(Unit* unit)
DebugLevel3Fn(" %Zd\n",UnitNumber(unit));
player=unit->Player;
#ifdef NEW_ORDERS
if( !unit->SubAction ) { // first entry
unit->Data.UpgradeTo.Ticks=0;
unit->SubAction=1;
@ -60,14 +59,6 @@ global void HandleActionUpgradeTo(Unit* unit)
// FIXME: Should count down here
unit->Data.UpgradeTo.Ticks+=SpeedUpgrade;
if( unit->Data.UpgradeTo.Ticks>=stats->Costs[TimeCost] ) {
#else
type=unit->Command.Data.UpgradeTo.What;
stats=&type->Stats[player->Player];
// FIXME: Should count down here
unit->Command.Data.UpgradeTo.Ticks+=SpeedUpgrade;
if( unit->Command.Data.UpgradeTo.Ticks>=stats->Costs[TimeCost] ) {
#endif
unit->HP+=stats->HitPoints-unit->Type->Stats[player->Player].HitPoints;
// don't have such unit now
@ -86,11 +77,7 @@ global void HandleActionUpgradeTo(Unit* unit)
// FIXME: AiUpgradeToComplete(unit,type);
}
unit->Reset=unit->Wait=1;
#ifdef NEW_ORDERS
unit->Orders[0].Action=UnitActionStill;
#else
unit->Command.Action=UnitActionStill;
#endif
unit->SubAction=0;
//

View file

@ -97,13 +97,10 @@ local void HandleUnitAction(Unit* unit)
{
int z;
// FIXME: Johns: What should this do?
// FIXME: Revealer is special unit, that should reveal the map.
// FIXME: Johns: What should this do here?
if ( unit->Revealer ) {
#ifdef NEW_ORDERS
unit->Orders[0].Action = UnitActionDie;
#else
unit->Command.Action = UnitActionDie;
#endif
}
//
@ -111,9 +108,6 @@ local void HandleUnitAction(Unit* unit)
//
if( unit->Reset ) {
unit->Reset=0;
#ifdef NEW_ORDERS
//
// o Look if we have a new order and old finished.
// o Or the order queue should be flushed.
@ -160,52 +154,14 @@ local void HandleUnitAction(Unit* unit)
MustRedraw|=RedrawInfoPanel;
}
}
#else
//
// New command and forced or old ready (= still)
// FIXME: how should we deal with saved commands?
//
if( unit->NextCount
&& (unit->Command.Action == UnitActionStill || unit->NextFlush)
&& !unit->Removed ) {
// Structure assign
unit->Command=unit->NextCommand[0];
// Next line shouldn't affect human players,
// but needed for AI player
unit->NextCommand[0].Action=UnitActionStill;
// cade: shift queue
unit->NextCount--;
for ( z = 0; z < unit->NextCount; z++ ) {
unit->NextCommand[z] = unit->NextCommand[z+1];
}
unit->NextFlush=0;
// Reset for new order
unit->SubAction=unit->State=0;
unit->Wait=1;
if( IsSelected(unit) ) { // update display for new action
UpdateButtonPanel();
MustRedraw|=RedrawInfoPanel;
}
}
#endif
}
// FIXME: fire handling should be moved to here.
//
// Select action.
// Select action. FIXME: should us function pointers|array.
//
#ifdef NEW_ORDERS
switch( unit->Orders[0].Action ) {
#else
switch( unit->Command.Action ) {
#endif
case UnitActionNone:
DebugLevel1Fn("FIXME: Should not happen!\n");
break;
@ -296,11 +252,7 @@ local void HandleUnitAction(Unit* unit)
break;
default:
#ifdef NEW_ORDERS
DebugLevel1Fn("Unknown action %d\n",unit->Orders[0].Action);
#else
DebugLevel1Fn("Unknown action %d\n",unit->Command.Action);
#endif
break;
}
}

File diff suppressed because it is too large Load diff

View file

@ -248,18 +248,11 @@ local int AiFindFreeWorkers(Unit ** table)
//
for (num = i = 0; i < nunits; i++) {
unit = table[i];
#ifdef NEW_ORDERS
if (unit->Orders[0].Action != UnitActionBuild
&& (unit->OrderCount==1
&& (unit->OrderCount==2
|| unit->Orders[1].Action != UnitActionBuild) ) {
table[num++] = unit;
}
#else
if (unit->Command.Action != UnitActionBuild
&& unit->NextCommand[0].Action != UnitActionBuild) {
table[num++] = unit;
}
#endif
}
return num;
}
@ -784,15 +777,9 @@ local int AiTrainCreature(int type)
return -1;
}
while (nunits--) {
#ifdef NEW_ORDERS
if (units[nunits]->Orders[0].Action != UnitActionStill) {
continue;
}
#else
if (units[nunits]->Command.Action != UnitActionStill) {
continue;
}
#endif
player = AiPlayer->Player;
CommandTrainUnit(units[nunits], &UnitTypes[type],FlushCommands);
// FIXME: and if not possible?
@ -937,11 +924,7 @@ local void AiAssignWorker(void)
if (num_worker) {
num_still = num_gold = num_wood = num_repair = 0;
for (w = 0; w < num_worker; ++w) {
#ifdef NEW_ORDERS
action = workers[w]->Orders[0].Action;
#else
action = workers[w]->Command.Action;
#endif
switch (action) {
case UnitActionStill:
++num_still;
@ -972,11 +955,7 @@ local void AiAssignWorker(void)
if (num_still) { // assign the non-working
for (w = 0; w < num_worker; ++w) {
type = workers[w]->Type->Type;
#ifdef NEW_ORDERS
action = workers[w]->Orders[0].Action;
#else
action = workers[w]->Command.Action;
#endif
if (action == UnitActionStill) {
if (type ==
AiChooseRace(UnitTypeHumanWorkerWithGold->Type)
@ -1010,11 +989,7 @@ local void AiAssignWorker(void)
CommandReturnGoods(workers[w],NoUnitP,FlushCommands);
} else {
// FIXME: don't interrupt chopping
#ifdef NEW_ORDERS
action = workers[w]->Orders[0].Action;
#else
action = workers[w]->Command.Action;
#endif
if (action == UnitActionStill
|| action == UnitActionHarvest) {
AiMineGold(workers[w]);
@ -1036,11 +1011,7 @@ local void AiAssignWorker(void)
AiChooseRace(UnitTypeHumanWorkerWithGold->Type)) {
CommandReturnGoods(workers[w],NoUnitP,FlushCommands);
} else {
#ifdef NEW_ORDERS
action = workers[w]->Orders[0].Action;
#else
action = workers[w]->Command.Action;
#endif
if (action == UnitActionStill
|| action == UnitActionMineGold) {
AiHarvest(workers[w]);
@ -1053,11 +1024,7 @@ local void AiAssignWorker(void)
// FIXME: if there is no gold/no wood forget this!
if (num_still) { // assign the non working
for (w = 0; w < num_worker; ++w) {
#ifdef NEW_ORDERS
action = workers[w]->Orders[0].Action;
#else
action = workers[w]->Command.Action;
#endif
if (action == UnitActionStill) {
type = workers[w]->Type->Type;
if (type == AiChooseRace(UnitTypeHumanWorkerWithGold->Type)
@ -1093,11 +1060,7 @@ local void AiAssignWorker(void)
if (num_worker) { // assign the non working
if (AiPlayer->MainHall) {
for (w = 0; w < num_worker; ++w) {
#ifdef NEW_ORDERS
action = workers[w]->Orders[0].Action;
#else
action = workers[w]->Command.Action;
#endif
if (action == UnitActionStill) {
CommandReturnGoods(workers[w],NoUnitP,FlushCommands);
}
@ -1113,11 +1076,7 @@ local void AiAssignWorker(void)
if (num_worker) { // assign the non working
if (AiPlayer->MainHall) {
for (w = 0; w < num_worker; ++w) {
#ifdef NEW_ORDERS
action = workers[w]->Orders[0].Action;
#else
action = workers[w]->Command.Action;
#endif
if (action == UnitActionStill) {
CommandReturnGoods(workers[w],NoUnitP,FlushCommands);
}

View file

@ -688,105 +688,38 @@ global void FireMissile(Unit* unit)
DebugLevel3Fn("\n");
// FIXME: make sure thats the correct unit.
//
// Goal dead?
// FIXME: make sure thats the correct unit.
//
#ifdef NEW_ORDERS
goal=unit->Orders[0].Goal;
#else
goal=unit->Command.Data.Move.Goal;
#endif
if( goal ) {
if( goal->Destroyed ) {
DebugLevel0Fn("destroyed unit\n");
return;
}
if( goal->Removed ) {
DebugLevel3Fn("Missile-none hits removed unit!\n");
return;
}
#ifdef NEW_ORDERS
if( !goal->HP || goal->Orders[0].Action==UnitActionDie ) {
#else
if( !goal->HP || goal->Command.Action==UnitActionDie ) {
#endif
DebugLevel3Fn("Missile-none hits dead unit!\n");
return;
}
// Better let the caller/action handle this.
#if 0
// Check if goal is correct unit.
if( goal->Destroyed ) {
DebugLevel0Fn("destroyed unit\n");
RefsDebugCheck( !goal->Refs );
if( !--goal->Refs ) {
ReleaseUnit(goal);
}
#ifdef NEW_ORDERS
unit->Orders[0].Goal=NULL;
ResetPath(unit->Orders[0]);
#else
unit->Command.Data.Move.DX=goal->X;
unit->Command.Data.Move.DY=goal->Y;
unit->Command.Data.Move.Goal=NULL;
ResetPath(unit->Command);
#endif
return;
}
if( goal->Removed ) {
DebugLevel3Fn("Missile-none hits removed unit!\n");
RefsDebugCheck( !goal->Refs );
--goal->Refs;
RefsDebugCheck( !goal->Refs );
#ifdef NEW_ORDERS
goal=unit->Orders[0].Goal=NULL;
ResetPath(unit->Orders[0]);
#else
unit->Command.Data.Move.Goal=NULL;
ResetPath(unit->Command);
#endif
return;
}
#ifdef NEW_ORDERS
if( !goal->HP || goal->Orders[0].Action==UnitActionDie ) {
#else
if( !goal->HP || goal->Command.Action==UnitActionDie ) {
#endif
DebugLevel3Fn("Missile-none hits dead unit!\n");
RefsDebugCheck( !goal->Refs );
--goal->Refs;
RefsDebugCheck( !goal->Refs );
#ifdef NEW_ORDERS
goal=unit->Orders[0].Goal=NULL;
ResetPath(unit->Orders[0]);
#else
unit->Command.Data.Move.Goal=NULL;
ResetPath(unit->Command);
#endif
return;
}
#endif
}
//
// None missile hits immediately!
//
if( ((MissileType*)unit->Type->Missile.Missile)->Class==MissileClassNone ) {
#ifdef NEW_ORDERS
// No goal, take target coordinates
if( !goal ) {
dx=unit->Orders[0].X;
dy=unit->Orders[0].Y;
#else
if( !goal ) {
dx=unit->Command.Data.Move.DX;
dy=unit->Command.Data.Move.DY;
#endif
if( WallOnMap(dx,dy) ) {
if( HumanWallOnMap(dx,dy) ) {
// FIXME: don't use UnitTypeByIdent here, this is slow!
@ -831,13 +764,8 @@ global void FireMissile(Unit* unit)
}
} else {
#ifdef NEW_ORDERS
dx=unit->Orders[0].X;
dy=unit->Orders[0].Y;
#else
dx=unit->Command.Data.Move.DX;
dy=unit->Command.Data.Move.DY;
#endif
// FIXME: Can this be too near??
}

View file

@ -784,9 +784,6 @@ global void CclInit(void)
#ifdef USE_SDL
gh_symbol2scm("freecraft-feature-use-sdl");
#endif
#ifdef USE_CCL
gh_symbol2scm("freecraft-feature-use-ccl");
#endif
#ifdef USE_ONLYCCL
gh_symbol2scm("freecraft-feature-only-ccl");
#endif
@ -817,9 +814,6 @@ global void CclInit(void)
#ifdef UNIT_ON_MAP
gh_symbol2scm("freecraft-feature-unit-on-map");
#endif
#ifdef NEW_ORDERS
gh_symbol2scm("freecraft-feature-new-orders");
#endif
#ifdef NEW_MAPDRAW
gh_symbol2scm("freecraft-feature-new-mapdraw");
#endif

View file

@ -195,15 +195,9 @@ global int SelectUnitsByType(Unit* base)
// if unit is a cadaver or hidden (not on map)
// no unit can be selected.
#ifdef NEW_ORDERS
if( base->Removed || base->Orders[0].Action==UnitActionDie ) {
return 0;
}
#else
if( base->Removed || base->Command.Action==UnitActionDie ) {
return 0;
}
#endif
UnSelectAll();
Selected[0]=base;
@ -401,17 +395,10 @@ global int SelectUnitsInRectangle(int tx,int ty,int w,int h)
continue;
}
// FIXME: Can we get this?
#ifdef NEW_ORDERS
if( !unit->Removed && unit->Orders[0].Action!=UnitActionDie ) {
SelectSingleUnit(unit);
return 1;
}
#else
if( !unit->Removed && unit->Command.Action!=UnitActionDie ) {
SelectSingleUnit(unit);
return 1;
}
#endif
}
//
@ -450,17 +437,10 @@ global int SelectUnitsInRectangle(int tx,int ty,int w,int h)
// FIXME: isn't it enough to see a field of the building?
continue;
}
#ifdef NEW_ORDERS
if( !unit->Removed && unit->Orders[0].Action!=UnitActionDie ) {
SelectSingleUnit(unit);
return 1;
}
#else
if( !unit->Removed && unit->Command.Action!=UnitActionDie ) {
SelectSingleUnit(unit);
return 1;
}
#endif
}
return 0;

View file

@ -308,9 +308,6 @@ global int main1(int argc __attribute__ ((unused)),
#ifdef UNIT_ON_MAP
"UNIT-ON-MAP "
#endif
#ifdef NEW_ORDERS
"NEW-ORDERS "
#endif
#ifdef NEW_MAPDRAW
"NEW-MAPDRAW "
#endif
@ -326,6 +323,9 @@ global int main1(int argc __attribute__ ((unused)),
#ifdef NEW_SHIPS
"NEW-SHIPS "
#endif
#ifdef NEW_NETMENUS
"NEW-NETMENUS "
#endif
#ifdef SLOW_INPUT
"SLOW-INPUT "
#endif
@ -477,9 +477,6 @@ local void Usage(void)
#ifdef UNIT_ON_MAP
"UNIT-ON-MAP "
#endif
#ifdef NEW_ORDERS
"NEW-ORDERS "
#endif
#ifdef NEW_MAPDRAW
"NEW-MAPDRAW "
#endif
@ -495,6 +492,9 @@ local void Usage(void)
#ifdef NEW_SHIPS
"NEW-SHIPS "
#endif
#ifdef NEW_NETMENUS
"NEW-NETMENUS "
#endif
#ifdef SLOW_INPUT
"SLOW-INPUT "
#endif