[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src/action action_attack.c actions.c ...
From: |
Jimmy Salmon |
Subject: |
[Stratagus-CVS] stratagus/src/action action_attack.c actions.c ... |
Date: |
Fri, 03 Oct 2003 15:58:24 -0400 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Jimmy Salmon <address@hidden> 03/10/03 15:58:24
Modified files:
src/action : action_attack.c actions.c command.c
Log message:
Cleanup
Patches:
Index: stratagus/src/action/action_attack.c
diff -u stratagus/src/action/action_attack.c:1.84
stratagus/src/action/action_attack.c:1.85
--- stratagus/src/action/action_attack.c:1.84 Sat Sep 20 05:03:40 2003
+++ stratagus/src/action/action_attack.c Fri Oct 3 15:58:23 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: action_attack.c,v 1.84 2003/09/20 09:03:40 mr-russ Exp $
+// $Id: action_attack.c,v 1.85 2003/10/03 19:58:23 jsalmon3 Exp $
//@{
@@ -78,13 +78,13 @@
{
int flags;
- flags=UnitShowAnimation(unit,attack);
+ flags = UnitShowAnimation(unit, attack);
- if( (flags&AnimationSound) && (UnitVisibleOnMap(unit) || ReplayRevealMap)
) {
- PlayUnitSound(unit,VoiceAttacking);
+ if ((flags & AnimationSound) && (UnitVisibleOnMap(unit) ||
ReplayRevealMap)) {
+ PlayUnitSound(unit, VoiceAttacking);
}
- if( flags&AnimationMissile ) { // time to fire projectil
+ if (flags & AnimationMissile) { // time to fire projectil
FireMissile(unit);
unit->Invisible = 0; // unit is invisible until attacks
}
@@ -97,9 +97,9 @@
*/
global void AnimateActionAttack(Unit* unit)
{
- if( unit->Type->Animations ) {
- DebugCheck( !unit->Type->Animations->Attack );
- DoActionAttackGeneric(unit,unit->Type->Animations->Attack);
+ if (unit->Type->Animations) {
+ DebugCheck(!unit->Type->Animations->Attack);
+ DoActionAttackGeneric(unit, unit->Type->Animations->Attack);
}
}
@@ -124,56 +124,56 @@
//
// Do we have a goal?
//
- if( (goal=unit->Orders[0].Goal) ) {
- if( goal->Destroyed ) {
+ if ((goal = unit->Orders[0].Goal)) {
+ if (goal->Destroyed) {
//
// Goal is destroyed
//
- unit->Orders[0].X=goal->X+goal->Type->TileWidth/2;
- unit->Orders[0].Y=goal->Y+goal->Type->TileHeight/2;
- unit->Orders[0].RangeX=unit->Orders[0].RangeY=0;
+ unit->Orders[0].X = goal->X + goal->Type->TileWidth / 2;
+ unit->Orders[0].Y = goal->Y + goal->Type->TileHeight / 2;
+ unit->Orders[0].RangeX = unit->Orders[0].RangeY = 0;
DebugLevel0Fn("destroyed unit %d\n" _C_ UnitNumber(goal));
- RefsDebugCheck( !goal->Refs );
- if( !--goal->Refs ) {
+ RefsDebugCheck(!goal->Refs);
+ if (!--goal->Refs) {
ReleaseUnit(goal);
}
- unit->Orders[0].Goal=goal=NoUnitP;
- } else if( !goal->HP || goal->Orders[0].Action==UnitActionDie
- || goal->Removed ) {
+ unit->Orders[0].Goal = goal = NoUnitP;
+ } else if (!goal->HP || goal->Orders[0].Action == UnitActionDie ||
+ goal->Removed) {
//
// Goal is unusable, dies or has entered a building.
//
- unit->Orders[0].X=goal->X+goal->Type->TileWidth/2;
- unit->Orders[0].Y=goal->Y+goal->Type->TileHeight/2;
- unit->Orders[0].RangeX=unit->Orders[0].RangeY=0;
+ unit->Orders[0].X = goal->X + goal->Type->TileWidth / 2;
+ unit->Orders[0].Y = goal->Y + goal->Type->TileHeight / 2;
+ unit->Orders[0].RangeX = unit->Orders[0].RangeY = 0;
- RefsDebugCheck( !goal->Refs );
+ RefsDebugCheck(!goal->Refs);
--goal->Refs;
- RefsDebugCheck( !goal->Refs );
+ RefsDebugCheck(!goal->Refs);
- unit->Orders[0].Goal=goal=NoUnitP;
+ unit->Orders[0].Goal = goal = NoUnitP;
}
- if( !goal ) {
+ if (!goal) {
//
// If we have a saved order continue this saved order.
//
- if( unit->SavedOrder.Action!=UnitActionStill ) {
- unit->Orders[0]=unit->SavedOrder;
- unit->SavedOrder.Action=UnitActionStill;
- unit->SavedOrder.Goal=NoUnitP;
+ if (unit->SavedOrder.Action != UnitActionStill) {
+ unit->Orders[0] = unit->SavedOrder;
+ unit->SavedOrder.Action = UnitActionStill;
+ unit->SavedOrder.Goal = NoUnitP;
- if( unit->Selected && unit->Player==ThisPlayer ) {
+ if (unit->Selected && unit->Player == ThisPlayer) {
#ifndef NEW_UI
- MustRedraw|=RedrawButtonPanel;
+ MustRedraw |= RedrawButtonPanel;
#else
// FIXME: not really used because actions
// cannot yet be shown with NEW_UI
SelectedUnitChanged();
#endif
}
- goal=unit->Orders[0].Goal;
+ goal = unit->Orders[0].Goal;
}
NewResetPath(unit);
}
@@ -195,116 +195,119 @@
//
// Target is dead?
//
- goal=CheckForDeadGoal(unit);
+ goal = CheckForDeadGoal(unit);
// Fall back to last order, only works if this wasn't attack
- if( unit->Orders[0].Action!=UnitActionAttackGround
- && unit->Orders[0].Action!=UnitActionAttack ) {
- unit->State=unit->SubAction=0;
+ if (unit->Orders[0].Action != UnitActionAttackGround &&
+ unit->Orders[0].Action != UnitActionAttack) {
+ unit->State = unit->SubAction = 0;
return 1;
}
//
// No goal: if meeting enemy attack it.
//
- wall=0;
- if( !goal && !(wall=WallOnMap(unit->Orders[0].X,unit->Orders[0].Y))
- && unit->Orders[0].Action!=UnitActionAttackGround ) {
+ wall = 0;
+ if (!goal && !(wall = WallOnMap(unit->Orders[0].X, unit->Orders[0].Y)) &&
+ unit->Orders[0].Action != UnitActionAttackGround) {
goal=AttackUnitsInReactRange(unit);
- if( goal ) {
- if( unit->SavedOrder.Action==UnitActionStill ) {
+ if (goal) {
+ if (unit->SavedOrder.Action == UnitActionStill) {
// Save current command to continue it later.
- DebugCheck( unit->Orders[0].Goal );
- unit->SavedOrder=unit->Orders[0];
+ DebugCheck(unit->Orders[0].Goal);
+ unit->SavedOrder = unit->Orders[0];
}
- RefsDebugCheck( goal->Destroyed || !goal->Refs );
+ RefsDebugCheck(goal->Destroyed || !goal->Refs);
goal->Refs++;
- unit->Orders[0].Goal=goal;
- unit->Orders[0].RangeX=unit->Orders[0].RangeY=
- unit->Stats->AttackRange;
- unit->Orders[0].X=unit->Orders[0].Y=-1;
- unit->SubAction|=WEAK_TARGET; // weak target
+ unit->Orders[0].Goal = goal;
+ unit->Orders[0].RangeX = unit->Orders[0].RangeY =
+ unit->Stats->AttackRange;
+ unit->Orders[0].X = unit->Orders[0].Y = -1;
+ unit->SubAction |= WEAK_TARGET; // weak target
NewResetPath(unit);
- DebugLevel3Fn("%d in react range %d\n"
- _C_ UnitNumber(unit) _C_ UnitNumber(goal));
+ DebugLevel3Fn("%d in react range %d\n" _C_
+ UnitNumber(unit) _C_ UnitNumber(goal));
}
//
// Have a weak target, try a better target.
//
- } else if( goal && (unit->SubAction&WEAK_TARGET) ) {
- temp=AttackUnitsInReactRange(unit);
- if( temp && temp->Type->Priority>goal->Type->Priority ) {
- RefsDebugCheck( !goal->Refs );
+ } else if (goal && (unit->SubAction & WEAK_TARGET)) {
+ temp = AttackUnitsInReactRange(unit);
+ if (temp && temp->Type->Priority > goal->Type->Priority) {
+ RefsDebugCheck(!goal->Refs);
goal->Refs--;
- RefsDebugCheck( !goal->Refs );
- RefsDebugCheck( temp->Destroyed || !temp->Refs );
+ RefsDebugCheck(!goal->Refs);
+ RefsDebugCheck(temp->Destroyed || !temp->Refs);
temp->Refs++;
- if( unit->SavedOrder.Action==UnitActionStill ) {
+ if (unit->SavedOrder.Action == UnitActionStill) {
// Save current command to come back.
- unit->SavedOrder=unit->Orders[0];
- if( (goal=unit->SavedOrder.Goal) ) {
+ unit->SavedOrder = unit->Orders[0];
+ if ((goal = unit->SavedOrder.Goal)) {
DebugLevel0Fn("Have goal to come back %d\n" _C_
- UnitNumber(goal));
- unit->SavedOrder.X=goal->X+goal->Type->TileWidth/2;
- unit->SavedOrder.Y=goal->Y+goal->Type->TileHeight/2;
- unit->SavedOrder.RangeX=unit->SavedOrder.RangeY=0;
- unit->SavedOrder.Goal=NoUnitP;
+ UnitNumber(goal));
+ unit->SavedOrder.X = goal->X + goal->Type->TileWidth / 2;
+ unit->SavedOrder.Y = goal->Y + goal->Type->TileHeight / 2;
+ unit->SavedOrder.RangeX = unit->SavedOrder.RangeY = 0;
+ unit->SavedOrder.Goal = NoUnitP;
}
}
- unit->Orders[0].Goal=goal=temp;
- unit->Orders[0].X=unit->Orders[0].Y=-1;
+ unit->Orders[0].Goal = goal = temp;
+ unit->Orders[0].X = unit->Orders[0].Y = -1;
NewResetPath(unit);
}
}
- DebugCheck( unit->Type->Vanishes || unit->Destroyed || unit->Removed );
- DebugCheck( unit->Orders[0].Action!=UnitActionAttack
- && unit->Orders[0].Action!=UnitActionAttackGround );
+ DebugCheck(unit->Type->Vanishes || unit->Destroyed || unit->Removed);
+ DebugCheck(unit->Orders[0].Action != UnitActionAttack &&
+ unit->Orders[0].Action != UnitActionAttackGround);
return 0;
}
+/**
+** FIXME: docu
+*/
local void MoveToTarget(Unit* unit)
{
Unit* goal;
int err;
- if( !unit->Orders[0].Goal ) {
- if( unit->Orders[0].X==-1 || unit->Orders[0].Y==-1 ) {
+ if (!unit->Orders[0].Goal) {
+ if (unit->Orders[0].X == -1 || unit->Orders[0].Y == -1) {
DebugLevel0Fn("FIXME: Wrong goal position, check where set!\n");
- unit->Orders[0].X=unit->Orders[0].Y=0;
+ unit->Orders[0].X = unit->Orders[0].Y = 0;
}
}
- err=DoActionMove(unit);
+ err = DoActionMove(unit);
- if( unit->Reset ) {
+ if (unit->Reset) {
//
// Look if we have reached the target.
//
- if( CheckForTargetInRange(unit) ) {
+ if (CheckForTargetInRange(unit)) {
return;
}
- goal=unit->Orders[0].Goal;
- if (err>=0) {
+ goal = unit->Orders[0].Goal;
+ if (err >= 0) {
//
// Nothing to do, we're on the way moving.
//
DebugLevel3Fn("Nothing to do.\n");
return;
}
- if (err==PF_REACHED) {
+ if (err == PF_REACHED) {
//
// Have reached target? FIXME: could use the new return code?
//
- if( goal && MapDistanceBetweenUnits(unit,goal)
- <=unit->Stats->AttackRange ) {
+ if (goal && MapDistanceBetweenUnits(unit, goal) <=
+ unit->Stats->AttackRange) {
DebugLevel3Fn("Reached another unit, now attacking it.\n");
- unit->State=0;
- if( unit->Stats->Speed ) {
+ unit->State = 0;
+ if (unit->Stats->Speed) {
UnitHeadingFromDeltaXY(unit,
- goal->X+(goal->Type->TileWidth-1)/2-unit->X,
- goal->Y+(goal->Type->TileHeight-1)/2-unit->Y);
+ goal->X + (goal->Type->TileWidth - 1) / 2 - unit->X,
+ goal->Y + (goal->Type->TileHeight - 1) / 2 - unit->Y);
// FIXME: only if heading changes
CheckUnitToBeDrawn(unit);
}
@@ -314,38 +317,41 @@
//
// Attacking wall or ground.
//
- if( !goal && (WallOnMap(unit->Orders[0].X,unit->Orders[0].Y)
- || unit->Orders[0].Action==UnitActionAttackGround)
- &&
MapDistanceToUnit(unit->Orders[0].X,unit->Orders[0].Y,unit)
- <=unit->Stats->AttackRange ) {
+ if (!goal && (WallOnMap(unit->Orders[0].X, unit->Orders[0].Y) ||
+ unit->Orders[0].Action == UnitActionAttackGround) &&
+ MapDistanceToUnit(unit->Orders[0].X, unit->Orders[0].Y,
unit) <=
+ unit->Stats->AttackRange) {
DebugLevel3Fn("Reached wall or ground, now attacking it.\n");
- unit->State=0;
- if( unit->Stats->Speed ) {
- UnitHeadingFromDeltaXY(unit,unit->Orders[0].X-unit->X
- ,unit->Orders[0].Y-unit->Y);
+ unit->State = 0;
+ if (unit->Stats->Speed) {
+ UnitHeadingFromDeltaXY(unit, unit->Orders[0].X - unit->X,
+ unit->Orders[0].Y - unit->Y);
// FIXME: only if heading changes
CheckUnitToBeDrawn(unit);
}
- unit->SubAction&=WEAK_TARGET;
- unit->SubAction|=ATTACK_TARGET;
+ unit->SubAction &= WEAK_TARGET;
+ unit->SubAction |= ATTACK_TARGET;
return;
}
}
//
// Unreachable.
//
- if( err==PF_UNREACHABLE ) {
- unit->State=unit->SubAction=0;
- DebugLevel3Fn("Target not reachable, unit: %d" _C_
UnitNumber(unit));
- if( goal ) {
- DebugLevel3(", target %d range %d\n" _C_ UnitNumber(goal) _C_
unit->Orders[0].RangeX);
+ if (err == PF_UNREACHABLE) {
+ unit->State = unit->SubAction = 0;
+ DebugLevel3Fn("Target not reachable, unit: %d" _C_
+ UnitNumber(unit));
+ if (goal) {
+ DebugLevel3(", target %d range %d\n" _C_ UnitNumber(goal) _C_
+ unit->Orders[0].RangeX);
} 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 ) {
+ 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) {
// Try again with more range
unit->Orders[0].RangeX++;
unit->Orders[0].RangeY++;
@@ -356,32 +362,32 @@
//
// Return to old task?
//
- unit->State=unit->SubAction=0;
+ unit->State = unit->SubAction = 0;
DebugLevel3Fn("Returning to old task.\n");
- if( unit->Orders[0].Goal ) {
- RefsDebugCheck( !unit->Orders[0].Goal->Refs );
+ if (unit->Orders[0].Goal) {
+ RefsDebugCheck(!unit->Orders[0].Goal->Refs);
unit->Orders[0].Goal->Refs--;
- RefsDebugCheck( !unit->Orders[0].Goal->Refs );
+ RefsDebugCheck(!unit->Orders[0].Goal->Refs);
}
- unit->Orders[0]=unit->SavedOrder;
+ unit->Orders[0] = unit->SavedOrder;
NewResetPath(unit);
// Must finish, if saved command finishes
- unit->SavedOrder.Action=UnitActionStill;
- unit->SavedOrder.Goal=NoUnitP;
+ unit->SavedOrder.Action = UnitActionStill;
+ unit->SavedOrder.Goal = NoUnitP;
- if( unit->Selected && unit->Player==ThisPlayer ) {
+ if (unit->Selected && unit->Player == ThisPlayer) {
#ifndef NEW_UI
- MustRedraw|=RedrawButtonPanel;
+ MustRedraw |= RedrawButtonPanel;
#else
SelectedUnitChanged();
#endif
}
return;
}
- DebugCheck( unit->Type->Vanishes || unit->Destroyed || unit->Removed );
- DebugCheck( unit->Orders[0].Action!=UnitActionAttack
- && unit->Orders[0].Action!=UnitActionAttackGround );
+ DebugCheck(unit->Type->Vanishes || unit->Destroyed || unit->Removed);
+ DebugCheck(unit->Orders[0].Action != UnitActionAttack &&
+ unit->Orders[0].Action != UnitActionAttackGround);
}
/**
@@ -394,21 +400,21 @@
Unit* goal;
Unit* temp;
- if( !unit->Orders[0].Goal ) {
- if( unit->Orders[0].X==-1 || unit->Orders[0].Y==-1 ) {
+ if (!unit->Orders[0].Goal) {
+ if (unit->Orders[0].X == -1 || unit->Orders[0].Y == -1) {
DebugLevel0Fn("FIXME: Wrong goal position, check where set!\n");
- unit->Orders[0].X=unit->Orders[0].Y=0;
+ unit->Orders[0].X = unit->Orders[0].Y = 0;
}
}
AnimateActionAttack(unit);
- if( unit->Reset ) {
+ if (unit->Reset) {
//
// Goal is "weak" or a wall.
//
- goal=unit->Orders[0].Goal;
- if( !goal && (WallOnMap(unit->Orders[0].X,unit->Orders[0].Y)
- || unit->Orders[0].Action==UnitActionAttackGround) ) {
+ goal = unit->Orders[0].Goal;
+ if (!goal && (WallOnMap(unit->Orders[0].X, unit->Orders[0].Y) ||
+ unit->Orders[0].Action == UnitActionAttackGround)) {
DebugLevel3Fn("attack a wall or ground!!!!\n");
return;
}
@@ -416,40 +422,40 @@
//
// Target is dead?
//
- goal=CheckForDeadGoal(unit);
+ goal = CheckForDeadGoal(unit);
// Fall back to last order.
- if( unit->Orders[0].Action!=UnitActionAttackGround
- && unit->Orders[0].Action!=UnitActionAttack ) {
- unit->State=unit->SubAction=0;
+ if (unit->Orders[0].Action != UnitActionAttackGround &&
+ unit->Orders[0].Action != UnitActionAttack) {
+ unit->State = unit->SubAction = 0;
return;
}
//
// No target choose one.
//
- if( !goal ) {
- unit->State=0;
- goal=AttackUnitsInReactRange(unit);
+ if (!goal) {
+ unit->State = 0;
+ goal = AttackUnitsInReactRange(unit);
//
// No new goal, continue way to destination.
//
- if( !goal ) {
- unit->SubAction=MOVE_TO_TARGET;
+ if (!goal) {
+ unit->SubAction = MOVE_TO_TARGET;
// Return to old task?
- if( unit->SavedOrder.Action!=UnitActionStill ) {
- unit->SubAction=0;
- DebugCheck( unit->Orders[0].Goal!=NoUnitP );
- unit->Orders[0]=unit->SavedOrder;
+ if (unit->SavedOrder.Action != UnitActionStill) {
+ unit->SubAction = 0;
+ DebugCheck(unit->Orders[0].Goal != NoUnitP);
+ unit->Orders[0] = unit->SavedOrder;
NewResetPath(unit);
// Must finish, if saved command finishes
- unit->SavedOrder.Action=UnitActionStill;
+ unit->SavedOrder.Action = UnitActionStill;
// This isn't supported
- DebugCheck( unit->SavedOrder.Goal!=NoUnitP );
+ DebugCheck(unit->SavedOrder.Goal != NoUnitP);
- if( unit->Selected && unit->Player==ThisPlayer ) {
+ if (unit->Selected && unit->Player == ThisPlayer) {
#ifndef NEW_UI
- MustRedraw|=RedrawButtonPanel;
+ MustRedraw |= RedrawButtonPanel;
#else
SelectedUnitChanged();
#endif
@@ -461,56 +467,56 @@
//
// Save current command to come back.
//
- if( unit->SavedOrder.Action==UnitActionStill ) {
- unit->SavedOrder=unit->Orders[0];
- if( (temp=unit->SavedOrder.Goal) ) {
+ if (unit->SavedOrder.Action == UnitActionStill) {
+ unit->SavedOrder = unit->Orders[0];
+ if ((temp = unit->SavedOrder.Goal)) {
DebugLevel0Fn("Have unit to come back %d?\n" _C_
- UnitNumber(temp));
- unit->SavedOrder.X=temp->X+temp->Type->TileWidth/2;
- unit->SavedOrder.Y=temp->Y+temp->Type->TileHeight/2;
- unit->SavedOrder.RangeX=unit->SavedOrder.RangeY=0;
- unit->SavedOrder.Goal=NoUnitP;
+ UnitNumber(temp));
+ unit->SavedOrder.X = temp->X + temp->Type->TileWidth / 2;
+ unit->SavedOrder.Y = temp->Y + temp->Type->TileHeight / 2;
+ unit->SavedOrder.RangeX = unit->SavedOrder.RangeY = 0;
+ unit->SavedOrder.Goal = NoUnitP;
}
}
- RefsDebugCheck( goal->Destroyed || !goal->Refs );
+ RefsDebugCheck(goal->Destroyed || !goal->Refs);
goal->Refs++;
- DebugLevel3Fn("%d Unit in react range %d\n"
- _C_ UnitNumber(unit) _C_ UnitNumber(goal));
- unit->Orders[0].Goal=goal;
- unit->Orders[0].X=unit->Orders[0].Y=-1;
- unit->Orders[0].RangeX=unit->Orders[0].RangeY=
- unit->Stats->AttackRange;
+ DebugLevel3Fn("%d Unit in react range %d\n" _C_
+ UnitNumber(unit) _C_ UnitNumber(goal));
+ unit->Orders[0].Goal = goal;
+ unit->Orders[0].X = unit->Orders[0].Y = -1;
+ unit->Orders[0].RangeX = unit->Orders[0].RangeY =
+ unit->Stats->AttackRange;
NewResetPath(unit);
- unit->SubAction|=WEAK_TARGET;
+ unit->SubAction |= WEAK_TARGET;
//
// Have a weak target, try a better target.
// FIXME: if out of range also try another target quick
//
- } else if( goal && (unit->SubAction&WEAK_TARGET) ) {
- temp=AttackUnitsInReactRange(unit);
- if( temp && temp->Type->Priority>goal->Type->Priority ) {
- RefsDebugCheck( !goal->Refs );
+ } else if (goal && (unit->SubAction & WEAK_TARGET)) {
+ temp = AttackUnitsInReactRange(unit);
+ if (temp && temp->Type->Priority > goal->Type->Priority) {
+ RefsDebugCheck(!goal->Refs);
goal->Refs--;
- RefsDebugCheck( !goal->Refs );
- RefsDebugCheck( temp->Destroyed || !temp->Refs );
+ RefsDebugCheck(!goal->Refs);
+ RefsDebugCheck(temp->Destroyed || !temp->Refs);
temp->Refs++;
- if( unit->SavedOrder.Action==UnitActionStill ) {
+ if (unit->SavedOrder.Action == UnitActionStill) {
// Save current order to come back or to continue it.
- unit->SavedOrder=unit->Orders[0];
- if( (goal=unit->SavedOrder.Goal) ) {
+ unit->SavedOrder = unit->Orders[0];
+ if ((goal = unit->SavedOrder.Goal)) {
DebugLevel0Fn("Have goal to come back %d\n" _C_
- UnitNumber(goal));
- unit->SavedOrder.X=goal->X+goal->Type->TileWidth/2;
- unit->SavedOrder.Y=goal->Y+goal->Type->TileHeight/2;
- unit->SavedOrder.RangeX=unit->SavedOrder.RangeY=0;
- unit->SavedOrder.Goal=NoUnitP;
+ UnitNumber(goal));
+ unit->SavedOrder.X = goal->X + goal->Type->TileWidth /
2;
+ unit->SavedOrder.Y = goal->Y + goal->Type->TileHeight /
2;
+ unit->SavedOrder.RangeX = unit->SavedOrder.RangeY = 0;
+ unit->SavedOrder.Goal = NoUnitP;
}
}
- unit->Orders[0].Goal=goal=temp;
- unit->Orders[0].X=unit->Orders[0].Y=-1;
+ unit->Orders[0].Goal = goal = temp;
+ unit->Orders[0].X = unit->Orders[0].Y = -1;
NewResetPath(unit);
}
}
@@ -518,34 +524,33 @@
//
// Still near to target, if not goto target.
//
- if( MapDistanceBetweenUnits(unit,goal)
- >unit->Stats->AttackRange ) {
- if( unit->SavedOrder.Action==UnitActionStill ) {
+ if (MapDistanceBetweenUnits(unit, goal) > unit->Stats->AttackRange) {
+ if (unit->SavedOrder.Action == UnitActionStill) {
// Save current order to come back or to continue it.
- unit->SavedOrder=unit->Orders[0];
- if( (temp=unit->SavedOrder.Goal) ) {
+ unit->SavedOrder = unit->Orders[0];
+ if ((temp = unit->SavedOrder.Goal)) {
DebugLevel0Fn("Have goal to come back %d\n" _C_
- UnitNumber(temp));
- unit->SavedOrder.X=temp->X+temp->Type->TileWidth/2;
- unit->SavedOrder.Y=temp->Y+temp->Type->TileHeight/2;
- unit->SavedOrder.RangeX=unit->SavedOrder.RangeY=0;
- unit->SavedOrder.Goal=NoUnitP;
+ UnitNumber(temp));
+ unit->SavedOrder.X = temp->X + temp->Type->TileWidth / 2;
+ unit->SavedOrder.Y = temp->Y + temp->Type->TileHeight / 2;
+ unit->SavedOrder.RangeX = unit->SavedOrder.RangeY = 0;
+ unit->SavedOrder.Goal = NoUnitP;
}
}
NewResetPath(unit);
- unit->Frame=0;
- unit->State=0;
- unit->SubAction&=WEAK_TARGET;
- unit->SubAction|=MOVE_TO_TARGET;
+ unit->Frame = 0;
+ unit->State = 0;
+ unit->SubAction &= WEAK_TARGET;
+ unit->SubAction |= MOVE_TO_TARGET;
}
//
// Turn always to target
//
- if( unit->Stats->Speed && goal ) {
+ if (unit->Stats->Speed && goal) {
UnitHeadingFromDeltaXY(unit,
- goal->X+(goal->Type->TileWidth-1)/2-unit->X,
- goal->Y+(goal->Type->TileHeight-1)/2-unit->Y);
+ goal->X + (goal->Type->TileWidth - 1) / 2 - unit->X,
+ goal->Y + (goal->Type->TileHeight - 1) / 2 - unit->Y);
// FIXME: only if heading changes
CheckUnitToBeDrawn(unit);
}
@@ -568,25 +573,25 @@
*/
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 r %d,%d\n" _C_ UnitNumber(unit) _C_
+ unit->Orders->RangeX _C_ unit->Orders->RangeY);
- switch( unit->SubAction ) {
+ switch (unit->SubAction) {
//
// First entry
//
case 0:
- unit->SubAction=MOVE_TO_TARGET;
+ unit->SubAction = MOVE_TO_TARGET;
NewResetPath(unit);
//
// FIXME: should use a reachable place to reduce pathfinder time.
//
- DebugCheck( unit->State!=0 );
+ DebugCheck(unit->State != 0);
//
// Look for target, if already in range. Attack if So
//
- if( CheckForTargetInRange(unit) ) {
- unit->SubAction=ATTACK_TARGET;
+ if (CheckForTargetInRange(unit)) {
+ unit->SubAction = ATTACK_TARGET;
return;
}
@@ -595,7 +600,7 @@
// Move near to the target.
//
case MOVE_TO_TARGET:
- case MOVE_TO_TARGET+WEAK_TARGET:
+ case MOVE_TO_TARGET + WEAK_TARGET:
MoveToTarget(unit);
break;
@@ -603,7 +608,7 @@
// Attack the target.
//
case ATTACK_TARGET:
- case ATTACK_TARGET+WEAK_TARGET:
+ case ATTACK_TARGET + WEAK_TARGET:
AttackTarget(unit);
break;
Index: stratagus/src/action/actions.c
diff -u stratagus/src/action/actions.c:1.96 stratagus/src/action/actions.c:1.97
--- stratagus/src/action/actions.c:1.96 Fri Oct 3 06:37:05 2003
+++ stratagus/src/action/actions.c Fri Oct 3 15:58:24 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: actions.c,v 1.96 2003/10/03 10:37:05 n0body Exp $
+// $Id: actions.c,v 1.97 2003/10/03 19:58:24 jsalmon3 Exp $
//@{
@@ -639,11 +639,12 @@
}
fprintf(logf,"%lu: ",GameCycle);
- fprintf(logf,"%d %s S%d/%d-%d P%d Refs %d: %X\n",
+ fprintf(logf,"%d %s S%d/%d-%d P%d Refs %d: %X %d,%d %d,%d\n",
UnitNumber(unit),unit->Type ? unit->Type->Ident : "unit-killed",
unit->State,unit->SubAction,
unit->Orders[0].Action,
- unit->Player ? unit->Player->Player :
-1,unit->Refs,SyncRandSeed);
+ unit->Player ? unit->Player->Player :
-1,unit->Refs,SyncRandSeed,
+ unit->X, unit->Y, unit->IX, unit->IY);
// SaveUnit(unit,logf);
fflush(NULL);
Index: stratagus/src/action/command.c
diff -u stratagus/src/action/command.c:1.106
stratagus/src/action/command.c:1.107
--- stratagus/src/action/command.c:1.106 Fri Oct 3 14:48:23 2003
+++ stratagus/src/action/command.c Fri Oct 3 15:58:24 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: command.c,v 1.106 2003/10/03 18:48:23 jsalmon3 Exp $
+// $Id: command.c,v 1.107 2003/10/03 19:58:24 jsalmon3 Exp $
//@{
@@ -171,7 +171,7 @@
}
Players[i].SharedVision &= ~(1 << player);
Players[player].Allied &= ~(1 << i);
- Players[player].Enemy & =~(1 << i);
+ Players[player].Enemy &= ~(1 << i);
Players[player].SharedVision &= ~(1 << i);
}
SetMessage("Player \"%s\" has left the game", Players[player].Name);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src/action action_attack.c actions.c ...,
Jimmy Salmon <=