From 3ca283c0d0e79f00f70fa81c63278644237da3e5 Mon Sep 17 00:00:00 2001
From: johns <>
Date: Sun, 25 Mar 2001 21:54:33 +0000
Subject: [PATCH] NEW_ORDERS are now only supported, old code removed.

---
 src/action/action_board.cpp  |  2 +
 src/action/action_move.cpp   | 56 +-----------------------
 src/action/action_repair.cpp | 82 ++----------------------------------
 3 files changed, 7 insertions(+), 133 deletions(-)

diff --git a/src/action/action_board.cpp b/src/action/action_board.cpp
index e343f3bad..a430dd360 100644
--- a/src/action/action_board.cpp
+++ b/src/action/action_board.cpp
@@ -163,6 +163,8 @@ local void EnterTransporter(Unit* unit)
 **	The unit boards a transporter.
 **
 **	@todo FIXME: the transporter must drive to the meating point.
+**		While waiting for the transporter the units must defend
+**		themselfs.
 **
 **	@param unit	Pointer to unit.
 */
diff --git a/src/action/action_move.cpp b/src/action/action_move.cpp
index 7d088dfe0..1b837c11e 100644
--- a/src/action/action_move.cpp
+++ b/src/action/action_move.cpp
@@ -70,54 +70,14 @@ local int ActionMoveGeneric(Unit* unit,const Animation* anim)
     // FIXME: Reset flag is cleared by HandleUnitAction.
     if( !(state=unit->State) ) {
 
-	//
-	//	Target killed?
-	//
-#ifdef NEW_ORDERS
-#else
-	Unit* goal;
-
-	if( (goal=unit->Command.Data.Move.Goal) ) {
-	    // FIXME: should this be handled here? JOHNS: No see NEW_ORDERS
-	    // FIXME: Can't choose a better target here!
-	    if( goal->Destroyed ) {
-		DebugLevel0Fn("destroyed unit\n");
-		unit->Command.Data.Move.DX=goal->X+goal->Type->TileWidth/2;
-		unit->Command.Data.Move.DY=goal->Y+goal->Type->TileHeight/2;
-		RefsDebugCheck( !goal->Refs );
-		if( !--goal->Refs ) {
-		    ReleaseUnit(goal);
-		}
-		unit->Command.Data.Move.Goal=NoUnitP;
-		ResetPath(unit->Command);
-	    } else if( goal->Removed ||
-		    !goal->HP || goal->Command.Action==UnitActionDie ) {
-		DebugLevel0Fn("killed unit\n");
-		RefsDebugCheck( !goal->Refs );
-		--goal->Refs;
-		RefsDebugCheck( !goal->Refs );
-		unit->Command.Data.Move.DX=goal->X;
-		unit->Command.Data.Move.DY=goal->Y;
-		unit->Command.Data.Move.Goal=NoUnitP;
-		ResetPath(unit->Command);
-	    }
-	}
-#endif
-
 	switch( d=NextPathElement(unit,&xd,&yd) ) {
 	    case PF_UNREACHABLE:	// Can't reach, stop
 		unit->Reset=unit->Wait=1;
 		unit->Moving=0;
-#ifndef NEW_ORDERS
-		unit->Command.Action=UnitActionStill;
-#endif
 		return d;
 	    case PF_REACHED:		// Reached goal, stop
 		unit->Reset=unit->Wait=1;
 		unit->Moving=0;
-#ifndef NEW_ORDERS
-		unit->Command.Action=UnitActionStill;
-#endif
 		return d;
 	    case PF_WAIT:		// No path, wait
 		unit->Reset=unit->Wait=1;
@@ -254,9 +214,7 @@ global int DoActionMove(Unit* unit)
 */
 global void HandleActionMove(Unit* unit)
 {
-#ifdef NEW_ORDERS
     Unit* goal;
-#endif
 
     DebugLevel3Fn("%Zd: %Zd %d,%d \n",UnitNumber(unit),
 	    unit->Orders[0].Goal ? UnitNumber(unit->Orders[0].Goal) : -1,
@@ -264,7 +222,6 @@ global void HandleActionMove(Unit* unit)
 
     if( !unit->SubAction ) {		// first entry
 	unit->SubAction=1;
-#ifdef NEW_ORDERS
 	NewResetPath(unit);
 	//
 	//	FIXME: should use a reachable place to reduce pathfinder time.
@@ -273,7 +230,6 @@ global void HandleActionMove(Unit* unit)
 	if( !PlaceReachable(unit,unit->Orders[0].X,unit->Orders[0].Y,1) ) {
 	    DebugLevel0Fn("FIXME: should use other goal.\n");
 	});
-#endif
 	DebugCheck( unit->State!=0 );
     }
 
@@ -283,9 +239,6 @@ global void HandleActionMove(Unit* unit)
 	    //	Some tries to reach the goal
 	    //
 	    if( unit->SubAction++<10 ) {
-#ifndef NEW_ORDERS
-		unit->Command.Action=UnitActionMove;
-#endif
 		//	To keep the load low, retry delayed.
 		unit->Wait=FRAMES_PER_SECOND/10+unit->SubAction;
 		// FIXME: Now the units didn't defend themself :(((((((
@@ -294,7 +247,6 @@ global void HandleActionMove(Unit* unit)
 	    // FALL THROUGH
 	case PF_REACHED:
 	    unit->SubAction=0;
-#ifdef NEW_ORDERS
 	    // Release target, if any.
 	    if( (goal=unit->Orders[0].Goal) ) {
 		RefsDebugCheck( !goal->Refs );
@@ -309,16 +261,11 @@ global void HandleActionMove(Unit* unit)
 		UpdateButtonPanel();
 	    }
 	    return;
-#else
-	    if( IsSelected(unit) ) {	// update display for new action
-		UpdateButtonPanel();
-	    }
-#endif
+
 	default:
 	    break;
     }
 
-#ifdef NEW_ORDERS
     //
     //	Target destroyed?
     //
@@ -333,7 +280,6 @@ global void HandleActionMove(Unit* unit)
 	}
 	NewResetPath(unit);
     }
-#endif
 }
 
 //@}
diff --git a/src/action/action_repair.cpp b/src/action/action_repair.cpp
index c2d4e6f9b..6f9cda0c9 100644
--- a/src/action/action_repair.cpp
+++ b/src/action/action_repair.cpp
@@ -153,9 +153,7 @@ global void HandleActionRepair(Unit* unit)
 
     switch( unit->SubAction ) {
 	case 0:
-#ifdef NEW_ORDERS
 	    NewResetPath(unit);
-#endif
 	    unit->SubAction=1;
 	    // FALL THROUGH
 	//
@@ -168,11 +166,7 @@ global void HandleActionRepair(Unit* unit)
 		//
 		//	No goal: if meeting damaged building repair it.
 		//
-#ifdef NEW_ORDERS
 		goal=unit->Orders[0].Goal;
-#else
-		goal=unit->Command.Data.Move.Goal;
-#endif
 
 		//
 		//	Target is dead, choose new one.
@@ -181,7 +175,6 @@ global void HandleActionRepair(Unit* unit)
 		// FIXME: should I do a function for this?
 		if( goal ) {
 		    if( goal->Destroyed ) {
-#ifdef NEW_ORDERS
 			DebugLevel0Fn("destroyed unit\n");
 			unit->Orders[0].X=goal->X;
 			unit->Orders[0].Y=goal->Y;
@@ -192,7 +185,6 @@ global void HandleActionRepair(Unit* unit)
 			// FIXME: should I clear this here?
 			unit->Orders[0].Goal=goal=NULL;
 			NewResetPath(unit);
-			ResetPath(unit->Orders[0]);
 		    } else if( !goal->HP ||
 				goal->Orders[0].Action==UnitActionDie ) {
 			unit->Orders[0].X=goal->X;
@@ -203,29 +195,6 @@ global void HandleActionRepair(Unit* unit)
 			RefsDebugCheck( !goal->Refs );
 			// FIXME: should I clear this here?
 			NewResetPath(unit);
-			ResetPath(unit->Orders[0]);
-#else
-			DebugLevel0Fn("destroyed unit\n");
-			unit->Command.Data.Move.DX=goal->X;
-			unit->Command.Data.Move.DY=goal->Y;
-			RefsDebugCheck( !goal->Refs );
-			if( !--goal->Refs ) {
-			    ReleaseUnit(goal);
-			}
-			// FIXME: should I clear this here?
-			unit->Command.Data.Move.Goal=goal=NULL;
-			ResetPath(unit->Command);
-		    } else if( !goal->HP ||
-				goal->Command.Action==UnitActionDie ) {
-			unit->Command.Data.Move.DX=goal->X;
-			unit->Command.Data.Move.DY=goal->Y;
-			RefsDebugCheck( !goal->Refs );
-			--goal->Refs;
-			RefsDebugCheck( !goal->Refs );
-			// FIXME: should I clear this here?
-			unit->Command.Data.Move.Goal=goal=NULL;
-			ResetPath(unit->Command);
-#endif
 		    }
 		}
 		//
@@ -236,30 +205,19 @@ global void HandleActionRepair(Unit* unit)
 		    unit->State=0;
 		    unit->SubAction=2;
 		} else if( err<0 ) {
-#ifdef NEW_ORDERS
-		    DebugCheck( unit->Orders[0].Action!=UnitActionStill );
 		    if( goal ) {		// release reference
 			RefsDebugCheck( !goal->Refs );
 			goal->Refs--;
 			RefsDebugCheck( !goal->Refs );
 			unit->Orders[0].Goal=NoUnitP;
 		    }
+		    unit->Orders[0].Action=UnitActionStill;
+		    unit->State=0;
+		    unit->SubAction=0;
 		    return;
 		}
 		// FIXME: Should be it already?
-		unit->Orders[0].Action=UnitActionRepair;
-#else
-		    DebugCheck( unit->Command.Action!=UnitActionStill );
-		    if( goal ) {		// release reference
-			RefsDebugCheck( !goal->Refs );
-			goal->Refs--;
-			RefsDebugCheck( !goal->Refs );
-			unit->Command.Data.Move.Goal=NoUnitP;
-		    }
-		    return;
-		}
-		unit->Command.Action=UnitActionRepair;
-#endif
+		DebugCheck( unit->Orders[0].Action!=UnitActionRepair );
 	    }
 	    break;
 
@@ -269,11 +227,7 @@ global void HandleActionRepair(Unit* unit)
 	case 2:
 	    AnimateActionRepair(unit);
 	    if( unit->Reset ) {
-#ifdef NEW_ORDERS
 		goal=unit->Orders[0].Goal;
-#else
-		goal=unit->Command.Data.Move.Goal;
-#endif
 
 		//
 		//	Target is dead, choose new one.
@@ -282,7 +236,6 @@ global void HandleActionRepair(Unit* unit)
 		// FIXME: should I do a function for this?
 		if( goal ) {
 		    if( goal->Destroyed ) {
-#ifdef NEW_ORDERS
 			DebugLevel0Fn("destroyed unit\n");
 			unit->Orders[0].X=goal->X;
 			unit->Orders[0].Y=goal->Y;
@@ -293,7 +246,6 @@ global void HandleActionRepair(Unit* unit)
 			// FIXME: should I clear this here?
 			unit->Orders[0].Goal=goal=NULL;
 			NewResetPath(unit);
-			ResetPath(unit->Orders[0]);
 		    } else if( !goal->HP
 				|| goal->Orders[0].Action==UnitActionDie ) {
 			// FIXME: should I clear this here?
@@ -301,26 +253,6 @@ global void HandleActionRepair(Unit* unit)
 			unit->Orders[0].Y=goal->Y;
 			unit->Orders[0].Goal=goal=NULL;
 			NewResetPath(unit);
-			ResetPath(unit->Orders[0]);
-#else
-			DebugLevel0Fn("destroyed unit\n");
-			unit->Command.Data.Move.DX=goal->X;
-			unit->Command.Data.Move.DY=goal->Y;
-			RefsDebugCheck( !goal->Refs );
-			if( !--goal->Refs ) {
-			    ReleaseUnit(goal);
-			}
-			// FIXME: should I clear this here?
-			unit->Command.Data.Move.Goal=goal=NULL;
-			ResetPath(unit->Command);
-		    } else if( !goal->HP
-				|| goal->Command.Action==UnitActionDie ) {
-			// FIXME: should I clear this here?
-			unit->Command.Data.Move.DX=goal->X;
-			unit->Command.Data.Move.DY=goal->Y;
-			unit->Command.Data.Move.Goal=goal=NULL;
-			ResetPath(unit->Command);
-#endif
 		    }
 		}
 		if( goal ) {
@@ -335,15 +267,9 @@ global void HandleActionRepair(Unit* unit)
 			RefsDebugCheck( !goal->Refs );
 			goal->Refs--;
 			RefsDebugCheck( !goal->Refs );
-#ifdef NEW_ORDERS
 			unit->Orders[0].Goal=NULL;
 		    }
                     unit->Orders[0].Action=UnitActionStill;
-#else
-			unit->Command.Data.Move.Goal=NULL;
-		    }
-                    unit->Command.Action=UnitActionStill;
-#endif
 		    unit->SubAction=0;
 		    unit->State=0;
                     return;