Fixed Bug #6006: Crash saving building not built yet

Orders now have Width, Height and Range.
This commit is contained in:
mr-russ 2003-10-17 05:04:32 +00:00
parent 0d413991f7
commit 8fd5698e3e
14 changed files with 96 additions and 129 deletions

View file

@ -36,6 +36,7 @@
<li>Future 2.00 Release<p>
<ul>
<li>++
<li>Fixed Bug #6006: Crash saving building not built yet (from Russell Smith).
<li>Fixed Bug: Failed Building Crashes Engine (from Russell Smith).
<li>Remove old Master Server Code, began implementing a new one (from Russell Smith).
<li>Finished Support for units with MinAttackRange &gt;1 Moving away to attacker (from Russell Smith).

View file

@ -129,7 +129,7 @@ local Unit* CheckForDeadGoal(Unit* unit)
unit->Orders[0].X = goal->X + goal->Type->TileWidth / 2;
unit->Orders[0].Y = goal->Y + goal->Type->TileHeight / 2;
unit->Orders[0].MinRange = 0;
unit->Orders[0].RangeX = unit->Orders[0].RangeY = 0;
unit->Orders[0].Range = 0;
DebugLevel0Fn("destroyed unit %d\n" _C_ UnitNumber(goal));
RefsDebugCheck(!goal->Refs);
@ -146,7 +146,7 @@ local Unit* CheckForDeadGoal(Unit* unit)
unit->Orders[0].X = goal->X + goal->Type->TileWidth / 2;
unit->Orders[0].Y = goal->Y + goal->Type->TileHeight / 2;
unit->Orders[0].MinRange = 0;
unit->Orders[0].RangeX = unit->Orders[0].RangeY = 0;
unit->Orders[0].Range = 0;
RefsDebugCheck(!goal->Refs);
--goal->Refs;
@ -213,8 +213,7 @@ local int CheckForTargetInRange(Unit* unit)
goal->Refs++;
unit->Orders[0].Goal = goal;
unit->Orders[0].MinRange = unit->Type->MinAttackRange;
unit->Orders[0].RangeX = unit->Orders[0].RangeY =
unit->Stats->AttackRange;
unit->Orders[0].Range = unit->Stats->AttackRange;
unit->Orders[0].X = unit->Orders[0].Y = -1;
unit->SubAction |= WEAK_TARGET; // weak target
NewResetPath(unit);
@ -242,7 +241,7 @@ local int CheckForTargetInRange(Unit* unit)
unit->SavedOrder.X = goal->X + goal->Type->TileWidth / 2;
unit->SavedOrder.Y = goal->Y + goal->Type->TileHeight / 2;
unit->SavedOrder.MinRange = 0;
unit->SavedOrder.RangeX = unit->SavedOrder.RangeY = 0;
unit->SavedOrder.Range = 0;
unit->SavedOrder.Goal = NoUnitP;
}
}
@ -338,18 +337,17 @@ local void MoveToTarget(Unit* unit)
UnitNumber(unit));
if (goal) {
DebugLevel3(", target %d range %d\n" _C_ UnitNumber(goal) _C_
unit->Orders[0].RangeX);
unit->Orders[0].Range);
} else {
//
// When attack-moving we have to allow a bigger range
//
DebugLevel3(", (%d,%d) Tring with more range...\n" _C_
unit->Orders[0].X _C_ unit->Orders[0].Y);
if (unit->Orders[0].RangeX < TheMap.Width ||
unit->Orders[0].RangeY < TheMap.Height) {
if (unit->Orders[0].Range < TheMap.Width ||
unit->Orders[0].Range < TheMap.Height) {
// Try again with more range
unit->Orders[0].RangeX++;
unit->Orders[0].RangeY++;
unit->Orders[0].Range++;
return;
}
}
@ -462,7 +460,7 @@ local void AttackTarget(Unit* unit)
unit->SavedOrder.X = temp->X + temp->Type->TileWidth / 2;
unit->SavedOrder.Y = temp->Y + temp->Type->TileHeight / 2;
unit->SavedOrder.MinRange = 0;
unit->SavedOrder.RangeX = unit->SavedOrder.RangeY = 0;
unit->SavedOrder.Range = 0;
unit->SavedOrder.Goal = NoUnitP;
}
}
@ -474,8 +472,7 @@ local void AttackTarget(Unit* unit)
unit->Orders[0].Goal = goal;
unit->Orders[0].X = unit->Orders[0].Y = -1;
unit->Orders[0].MinRange = unit->Type->MinAttackRange;
unit->Orders[0].RangeX = unit->Orders[0].RangeY =
unit->Stats->AttackRange;
unit->Orders[0].Range = unit->Stats->AttackRange;
NewResetPath(unit);
unit->SubAction |= WEAK_TARGET;
@ -501,7 +498,7 @@ local void AttackTarget(Unit* unit)
unit->SavedOrder.X = goal->X + goal->Type->TileWidth / 2;
unit->SavedOrder.Y = goal->Y + goal->Type->TileHeight / 2;
unit->SavedOrder.MinRange = 0;
unit->SavedOrder.RangeX = unit->SavedOrder.RangeY = 0;
unit->SavedOrder.Range = 0;
unit->SavedOrder.Goal = NoUnitP;
}
}
@ -526,7 +523,7 @@ local void AttackTarget(Unit* unit)
unit->SavedOrder.X = temp->X + temp->Type->TileWidth / 2;
unit->SavedOrder.Y = temp->Y + temp->Type->TileHeight / 2;
unit->SavedOrder.MinRange = 0;
unit->SavedOrder.RangeX = unit->SavedOrder.RangeY = 0;
unit->SavedOrder.Range = 0;
unit->SavedOrder.Goal = NoUnitP;
}
}
@ -569,8 +566,8 @@ local void AttackTarget(Unit* unit)
*/
global void HandleActionAttack(Unit* unit)
{
DebugLevel3Fn("Attack %d r %d,%d\n" _C_ UnitNumber(unit) _C_
unit->Orders->RangeX _C_ unit->Orders->RangeY);
DebugLevel3Fn("Attack %d range %d\n" _C_ UnitNumber(unit) _C_
unit->Orders->Range);
switch (unit->SubAction) {
//

View file

@ -68,8 +68,7 @@ local int MoveToTransporter(Unit* unit)
i = DoActionMove(unit);
// We have to reset a lot, or else they will circle each other and stuff.
if (x != unit->X || y != unit->Y) {
unit->Orders[0].RangeX = 1;
unit->Orders[0].RangeY = 1;
unit->Orders[0].Range = 1;
NewResetPath(unit);
}
// New code has this as default.
@ -132,8 +131,7 @@ local int WaitForTransporter(Unit* unit)
// it's there. This is why we reset the search. The transporter
// should be a lot closer now, so it's not as bad as it seems.
unit->SubAction = 0;
unit->Orders[0].RangeX = 1;
unit->Orders[0].RangeY = 1;
unit->Orders[0].Range = 1;
//Uhh wait a bit.
unit->Wait = 10;
@ -258,10 +256,9 @@ global void HandleActionBoard(Unit* unit)
//
// Try with a bigger range.
//
if (unit->Orders[0].RangeX <= TheMap.Width ||
unit->Orders[0].RangeX <= TheMap.Height) {
unit->Orders[0].RangeX++;
unit->Orders[0].RangeY++;
if (unit->Orders[0].Range <= TheMap.Width ||
unit->Orders[0].Range <= TheMap.Height) {
unit->Orders[0].Range++;
unit->SubAction--;
}
}

View file

@ -102,14 +102,6 @@ global void HandleActionBuild(Unit* unit)
type = unit->Orders[0].Type;
// Create the building to find a valid path to any part of it.
// Only create if we didn't already.
if (unit->Orders[0].Goal == NoUnitP) {
unit->Orders[0].Goal = MakeUnit(type, NULL);
unit->Orders[0].Goal->X = unit->Orders[0].X;
unit->Orders[0].Goal->Y = unit->Orders[0].Y;
}
switch (DoActionMove(unit)) { // reached end-point?
case PF_UNREACHABLE:
//
@ -129,10 +121,6 @@ global void HandleActionBuild(Unit* unit)
}
unit->Orders[0].Action = UnitActionStill;
// Release Temporary Building
UnitClearOrders(unit->Orders[0].Goal);
ReleaseUnit(unit->Orders[0].Goal);
unit->Orders[0].Goal = NULL;
unit->SubAction = 0;
if (unit->Selected) { // update display for new action
SelectedUnitChanged();
@ -171,10 +159,6 @@ global void HandleActionBuild(Unit* unit)
}
unit->Orders[0].Action = UnitActionStill;
// Release Temporary Building
UnitClearOrders(unit->Orders[0].Goal);
ReleaseUnit(unit->Orders[0].Goal);
unit->Orders[0].Goal = NULL;
unit->SubAction = 0;
if (unit->Selected) { // update display for new action
SelectedUnitChanged();
@ -204,10 +188,6 @@ global void HandleActionBuild(Unit* unit)
}
unit->Orders[0].Action = UnitActionStill;
// Release Temporary Building
UnitClearOrders(unit->Orders[0].Goal);
ReleaseUnit(unit->Orders[0].Goal);
unit->Orders[0].Goal = NULL;
unit->SubAction = 0;
if (unit->Selected) { // update display for new action
SelectedUnitChanged();
@ -226,10 +206,6 @@ global void HandleActionBuild(Unit* unit)
}
unit->Orders[0].Action = UnitActionStill;
// Release Temporary Building
UnitClearOrders(unit->Orders[0].Goal);
ReleaseUnit(unit->Orders[0].Goal);
unit->Orders[0].Goal = NULL;
unit->SubAction = 0;
if (unit->Selected) { // update display for new action
SelectedUnitChanged();
@ -238,10 +214,7 @@ global void HandleActionBuild(Unit* unit)
}
PlayerSubUnitType(unit->Player, type);
build = unit->Orders[0].Goal;
unit->Orders[0].Goal = NoUnitP;
AssignUnitToPlayer(build, unit->Player);
build=MakeUnit(type,unit->Player);
build->Constructed = 1;
build->CurrentSightRange = 0;
PlaceUnit(build, x, y);
@ -300,7 +273,7 @@ global void HandleActionBuild(Unit* unit)
unit->Orders[0].Action = UnitActionRepair;
unit->Orders[0].Goal = build;
unit->Orders[0].X = unit->Orders[0].Y = -1;
unit->Orders[0].RangeX = unit->Orders[0].RangeY = unit->Type->RepairRange;
unit->Orders[0].Range = unit->Type->RepairRange;
unit->SubAction = 0;
unit->Wait = 1;
RefsDebugCheck(!build->Refs);

View file

@ -103,8 +103,8 @@ global void HandleActionFollow(Unit* unit)
if ((goal->X == unit->Orders[0].X && goal->Y == unit->Orders[0].Y)) {
unit->Reset = 1;
unit->Wait = 10;
if ((unit->Orders[0].RangeX > 1) || (unit->Orders[0].RangeY > 1)) {
unit->Orders[0].RangeX = unit->Orders[0].RangeY = 1;
if (unit->Orders[0].Range > 1) {
unit->Orders[0].Range = 1;
unit->SubAction = 0;
}
return;
@ -124,10 +124,9 @@ global void HandleActionFollow(Unit* unit)
//
// Some tries to reach the goal
//
if (unit->Orders[0].RangeX <= TheMap.Width ||
unit->Orders[0].RangeX <= TheMap.Height) {
unit->Orders[0].RangeX++;
unit->Orders[0].RangeY++;
if (unit->Orders[0].Range <= TheMap.Width ||
unit->Orders[0].Range <= TheMap.Height) {
unit->Orders[0].Range++;
break;
}
// FALL THROUGH

View file

@ -279,10 +279,9 @@ global void HandleActionMove(Unit* unit)
//
// Some tries to reach the goal
//
if (unit->Orders[0].RangeX <= TheMap.Width ||
unit->Orders[0].RangeX <= TheMap.Height) {
unit->Orders[0].RangeX++;
unit->Orders[0].RangeY++;
if (unit->Orders[0].Range <= TheMap.Width ||
unit->Orders[0].Range <= TheMap.Height) {
unit->Orders[0].Range++;
break;
}
// FALL THROUGH

View file

@ -547,7 +547,7 @@ local int StopGathering(Unit* unit)
unit->Orders[0].Goal = depot;
RefsDebugCheck(!depot->Refs);
++depot->Refs;
unit->Orders[0].RangeX = unit->Orders[0].RangeY = 1;
unit->Orders[0].Range = 1;
unit->Orders[0].X = unit->Orders[0].Y = -1;
unit->SubAction = SUB_MOVE_TO_DEPOT;
NewResetPath(unit);
@ -707,7 +707,7 @@ local int WaitInDepot(Unit* unit)
unit->Orders[0].Goal = goal;
RefsDebugCheck(!goal->Refs);
++goal->Refs;
unit->Orders[0].RangeX = unit->Orders[0].RangeY = 1;
unit->Orders[0].Range = 1;
unit->Orders[0].X = unit->Orders[0].Y = -1;
} else {
DropOutOnSide(unit, LookingW, depot->Type->TileWidth, depot->Type->TileHeight);

View file

@ -112,7 +112,7 @@ local void SpellMoveToTarget(Unit* unit)
goal = unit->Orders[0].Goal;
if (goal && MapDistanceBetweenUnits(unit, goal) <=
unit->Orders[0].RangeX) {
unit->Orders[0].Range) {
// there is goal and it is in range
unit->State = 0;
@ -125,7 +125,7 @@ local void SpellMoveToTarget(Unit* unit)
unit->SubAction++; // cast the spell
return;
} else if (!goal && MapDistanceToUnit(unit->Orders[0].X,
unit->Orders[0].Y, unit) <= unit->Orders[0].RangeX) {
unit->Orders[0].Y, unit) <= unit->Orders[0].Range) {
// there is no goal and target spot is in range
unit->State = 0;
if (!unit->Type->Building) {
@ -165,9 +165,9 @@ global void HandleActionSpellCast(Unit* unit)
int flags;
const SpellType* spell;
DebugLevel3Fn("%d %d,%d+%d+%d\n" _C_
DebugLevel3Fn("%d %d,%d+%d\n" _C_
UnitNumber(unit) _C_ unit->Orders[0].X _C_ unit->Orders[0].Y _C_
unit->Orders[0].RangeX _C_ unit->Orders[0].RangeY);
unit->Orders[0].Range);
switch (unit->SubAction) {
case 0: // first entry.

View file

@ -146,7 +146,7 @@ global void ActionStillGeneric(Unit* unit, int ground)
unit->Orders[0].Action = UnitActionMove;
DebugCheck(unit->Orders[0].Goal);
unit->Orders[0].Goal = NoUnitP;
unit->Orders[0].RangeX = unit->Orders[0].RangeY = 0;
unit->Orders[0].Range = 0;
unit->Orders[0].X = x;
unit->Orders[0].Y = y;
unit->State = 0;
@ -179,7 +179,7 @@ global void ActionStillGeneric(Unit* unit, int ground)
DebugCheck(unit->SavedOrder.Action != UnitActionStill);
DebugCheck(unit->SavedOrder.Goal);
unit->SavedOrder.Action = UnitActionAttack;
unit->SavedOrder.RangeX = unit->SavedOrder.RangeY = 0;
unit->SavedOrder.Range = 0;
unit->SavedOrder.X = unit->X;
unit->SavedOrder.Y = unit->Y;
unit->SavedOrder.Goal = NoUnitP;

View file

@ -265,13 +265,13 @@ global void CommandFollow(Unit* unit, Unit* dest, int flush)
order->X = dest->X + dest->Type->TileWidth / 2;
order->Y = dest->Y + dest->Type->TileHeight / 2;
order->Goal = NoUnitP;
order->RangeX = order->RangeY = 0;
order->Range = 0;
} else {
order->X = order->Y = -1;
order->Goal = dest;
RefsDebugCheck(!dest->Refs);
dest->Refs++;
order->RangeX = order->RangeY = 1;
order->Range = 1;
}
order->Type = NULL;
order->Arg1 = NULL;
@ -314,7 +314,7 @@ global void CommandMove(Unit* unit, int x, int y, int flush)
order->Goal = NoUnitP;
order->X = x;
order->Y = y;
order->RangeX = order->RangeY = 0;
order->Range = 0;
order->Type = NULL;
order->Arg1 = NULL;
#ifdef HIERARCHIC_PATHFINDER
@ -368,19 +368,21 @@ global void CommandRepair(Unit* unit, int x, int y, Unit* dest, int flush)
order->X = dest->X + dest->Type->TileWidth / 2;
order->Y = dest->Y + dest->Type->TileHeight / 2;
order->Goal = NoUnitP;
order->RangeX = order->RangeY = 0;
order->Range = 0;
order->Width = order->Height = 0;
} else {
order->X = order->Y = -1;
order->Width = order->Height = 0;
order->Goal = dest;
RefsDebugCheck(!dest->Refs);
dest->Refs++;
order->RangeX = order->RangeY = unit->Type->RepairRange;
order->Range = unit->Type->RepairRange;
}
} else {
order->X = x;
order->Y = y;
order->Goal = NoUnitP;
order->RangeX = order->RangeY = unit->Type->RepairRange;
order->Range = 0;
}
order->Type = NULL;
order->Arg1 = NULL;
@ -431,27 +433,27 @@ global void CommandAttack(Unit* unit, int x, int y, Unit* attack, int flush)
order->X = attack->X + attack->Type->TileWidth / 2;
order->Y = attack->Y + attack->Type->TileHeight / 2;
order->Goal = NoUnitP;
order->RangeX = order->RangeY = 0;
order->Range = 0;
} else {
// Removed, Dying handled by action routine.
order->X = order->Y = -1;
order->Goal = attack;
RefsDebugCheck(!attack->Refs);
attack->Refs++;
order->RangeX = order->RangeY = unit->Stats->AttackRange;
order->Range = unit->Stats->AttackRange;
order->MinRange = unit->Type->MinAttackRange;
}
} else if (WallOnMap(x,y)) {
// FIXME: look into action_attack.c about this ugly problem
order->X = x;
order->Y = y;
order->RangeX = order->RangeY = unit->Stats->AttackRange;
order->Range = unit->Stats->AttackRange;
order->MinRange = unit->Type->MinAttackRange;
order->Goal = NoUnitP;
} else {
order->X = x;
order->Y = y;
order->RangeX = order->RangeY = 0;
order->Range = 0;
order->Goal = NoUnitP;
}
order->Type = NULL;
@ -495,7 +497,7 @@ global void CommandAttackGround(Unit* unit, int x, int y, int flush)
order->Action = UnitActionAttackGround;
order->X = x;
order->Y = y;
order->RangeX = order->RangeY = unit->Stats->AttackRange;
order->Range = unit->Stats->AttackRange;
order->MinRange = unit->Type->MinAttackRange;
order->Goal = NoUnitP;
order->Type = NULL;
@ -543,7 +545,7 @@ global void CommandPatrolUnit(Unit* unit, int x, int y, int flush)
order->Goal = NoUnitP;
order->X = x;
order->Y = y;
order->RangeX = order->RangeY = 0;
order->Range = 0;
order->Type = NULL;
DebugCheck(unit->X & ~0xFFFF || unit->Y & ~0xFFFF);
// BUG-ALERT: encode source into arg1 as two 16 bit values!
@ -589,7 +591,7 @@ global void CommandBoard(Unit* unit, Unit* dest, int flush)
order->Goal = dest;
RefsDebugCheck(!dest->Refs);
dest->Refs++;
order->RangeX = order->RangeY = 1;
order->Range = 1;
order->Type = NULL;
order->Arg1 = NULL;
}
@ -631,7 +633,7 @@ global void CommandUnload(Unit* unit, int x, int y, Unit* what, int flush)
RefsDebugCheck(!what->Refs);
what->Refs++;
}
order->RangeX = order->RangeY = 0;
order->Range = 0;
order->Type = NULL;
order->Arg1 = NULL;
}
@ -666,16 +668,15 @@ global void CommandBuildBuilding(Unit* unit, int x, int y,
order->Action = UnitActionBuild;
order->Goal = NoUnitP;
order->IsRect = 1;
order->X = x;
order->Y = y;
order->Width = what->TileWidth;
order->Height = what->TileHeight;
if (what->BuilderOutside) {
order->RangeX = unit->Type->RepairRange;
order->RangeY = unit->Type->RepairRange;
order->Range = unit->Type->RepairRange;
} else {
// If building inside, but be next to stop
order->RangeX = 1;
order->RangeY = 1;
order->Range = 1;
}
order->Type = what;
order->Arg1 = NULL;
@ -750,7 +751,7 @@ global void CommandResourceLoc(Unit* unit, int x, int y, int flush)
order->X = nx;
order->Y = ny;
order->RangeX = order->RangeY = 1;
order->Range = 1;
order->Goal = NoUnitP;
order->Type = NULL;
order->Arg1 = NULL;
@ -795,7 +796,7 @@ global void CommandResource(Unit* unit, Unit* dest, int flush)
order->Goal = dest;
RefsDebugCheck(!dest->Refs);
dest->Refs++;
order->RangeX = order->RangeY = 1;
order->Range = 1;
order->Type = NULL;
order->Arg1 = NULL;
}
@ -842,7 +843,7 @@ global void CommandReturnGoods(Unit* unit, Unit* goal, int flush)
RefsDebugCheck(!goal->Refs);
goal->Refs++;
}
order->RangeX = order->RangeY = 1;
order->Range = 1;
order->Type = NULL;
order->Arg1 = NULL;
}
@ -1203,23 +1204,23 @@ global void CommandDemolish(Unit* unit, int x, int y, Unit* dest, int flush)
order->X = dest->X + dest->Type->TileWidth / 2;
order->Y = dest->Y + dest->Type->TileHeight / 2;
order->Goal = NoUnitP;
order->RangeX = order->RangeY = 0;
order->Range = 0;
} else {
order->X = order->Y = -1;
order->Goal = dest;
RefsDebugCheck(!dest->Refs);
dest->Refs++;
order->RangeX = order->RangeY = 1;
order->Range = 1;
}
} else if (WallOnMap(x,y) || ForestOnMap(x,y) || RockOnMap(x,y)) {
order->X = x;
order->Y = y;
order->RangeX = order->RangeY = 1;
order->Range = 1;
order->Goal = NoUnitP;
} else {
order->X = x;
order->Y = y;
order->RangeX = order->RangeY = 0;
order->Range = 0;
order->Goal = NoUnitP;
}
order->Type = NULL;
@ -1274,7 +1275,7 @@ global void CommandSpellCast(Unit* unit, int x, int y, Unit* dest,
}
order->Action = UnitActionSpellCast;
order->RangeX = order->RangeY = spell->Range;
order->Range = spell->Range;
if (dest) {
//
// Destination could be killed.
@ -1283,11 +1284,11 @@ global void CommandSpellCast(Unit* unit, int x, int y, Unit* dest,
//
if (dest->Destroyed) {
// FIXME: where check if spell needs an unit as destination?
order->X = dest->X + dest->Type->TileWidth / 2 - order->RangeX;
order->Y = dest->Y + dest->Type->TileHeight / 2 - order->RangeY;
order->X = dest->X + dest->Type->TileWidth / 2 - order->Range;
order->Y = dest->Y + dest->Type->TileHeight / 2 - order->Range;
order->Goal = NoUnitP;
order->RangeX <<= 1;
order->RangeY <<= 1;
order->Range <<= 1;
order->Range <<= 1;
} else {
order->X = order->Y = -1;
order->Goal = dest;
@ -1295,11 +1296,10 @@ global void CommandSpellCast(Unit* unit, int x, int y, Unit* dest,
dest->Refs++;
}
} else {
order->X = x-order->RangeX;
order->Y = y-order->RangeY;
order->X = x-order->Range;
order->Y = y-order->Range;
order->Goal = NoUnitP;
order->RangeX <<= 1;
order->RangeY <<= 1;
order->Range <<= 1;
}
order->Type = NULL;
order->Arg1 = spell;

View file

@ -432,10 +432,10 @@ enum _unit_action_ {
typedef struct _order_ {
unsigned char Action; /// global action
unsigned char Flags; /// Order flags (unused)
int RangeX; /// How near in X direction
int RangeY; /// How near in Y direction
int Range; /// How far away
unsigned int MinRange; /// How far away minimum
unsigned char IsRect:1; /// For goal as a square, not circle
unsigned char Width; /// Goal Width (used when Goal is not)
unsigned char Height; /// Goal Height (used when Goal is not)
Unit* Goal; /// goal of the order (if any)
int X; /// or X tile coordinate of destination

View file

@ -474,24 +474,16 @@ global int NewPath(Unit* unit)
gh=unit->Orders[0].Goal->Type->TileHeight-1;
gx=unit->Orders[0].Goal->X;
gy=unit->Orders[0].Goal->Y;
maxrange=unit->Orders[0].RangeX;
maxrange=unit->Orders[0].Range;
minrange=unit->Orders[0].MinRange;
DebugCheck( unit->Orders[0].RangeX != unit->Orders[0].RangeY );
} else {
// Take care of non square goals :)
// If goal is non square, range states a non-existant goal rather
// than a tile.
if( unit->Orders[0].IsRect ) {
gw = unit->Orders[0].RangeX;
gh = unit->Orders[0].RangeY;
maxrange=0;
minrange=0;
} else {
gw=0;
gh=0;
maxrange=unit->Orders[0].RangeX;
minrange=unit->Orders[0].MinRange;
}
gw = unit->Orders[0].Width;
gh = unit->Orders[0].Height;
maxrange=unit->Orders[0].Range;
minrange=unit->Orders[0].MinRange;
gx=unit->Orders[0].X;
gy=unit->Orders[0].Y;
}

View file

@ -224,11 +224,17 @@ local void CclParseOrder(SCM list,Order* order)
order->Flags = gh_scm2int(value);
} else if (gh_eq_p(value, gh_symbol2scm("range"))) {
sublist = gh_car(list);
order->Range = gh_scm2int(gh_car(list));
list = gh_cdr(list);
} else if (gh_eq_p(value, gh_symbol2scm("min-range"))) {
order->MinRange = gh_scm2int(gh_car(list));
list = gh_cdr(list);
} else if (gh_eq_p(value, gh_symbol2scm("width"))) {
order->Width = gh_scm2int(gh_car(list));
list = gh_cdr(list);
} else if (gh_eq_p(value, gh_symbol2scm("height"))) {
order->Height = gh_scm2int(gh_car(list));
list = gh_cdr(list);
order->RangeX = gh_scm2int(gh_car(sublist));
order->RangeY = gh_scm2int(gh_cadr(sublist));
} else if (gh_eq_p(value, gh_symbol2scm("goal"))) {
char* str;
int slot;

View file

@ -3419,8 +3419,11 @@ local void SaveOrder(const Order* order,CLFile* file)
default:
DebugLevel0Fn("Unknown action in order\n");
}
CLprintf(file," flags %d",order->Flags);
CLprintf(file," range (%d %d)",order->RangeX,order->RangeY);
CLprintf(file," flags %d", order->Flags);
CLprintf(file," range %d", order->Range);
CLprintf(file," width %d", order->Width);
CLprintf(file," height %d", order->Height);
CLprintf(file," min-range %d", order->MinRange);
if( order->Goal ) {
if (order->Goal->Destroyed) {
/* this unit is destroyed so it's not in the global unit