[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src action/action_attack.c action/act...
From: |
Russell Smith |
Subject: |
[Stratagus-CVS] stratagus/src action/action_attack.c action/act... |
Date: |
Sun, 14 Sep 2003 00:45:53 -0400 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Russell Smith <address@hidden> 03/09/14 00:45:53
Modified files:
src/action : action_attack.c action_board.c
action_demolish.c action_repair.c
action_resource.c action_spellcast.c
src/clone : unit.c
src/map : map_fog.c
Log message:
MapDistance Updates, Use the best function for the job (Allows for Big
Units later on)
Fix Bug in MapDistanceBetweenUnits
Update FOW debug option to allow distance showing.
Patches:
Index: stratagus/src/action/action_attack.c
diff -u stratagus/src/action/action_attack.c:1.82
stratagus/src/action/action_attack.c:1.83
--- stratagus/src/action/action_attack.c:1.82 Thu Sep 11 06:49:09 2003
+++ stratagus/src/action/action_attack.c Sun Sep 14 00:45:52 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: action_attack.c,v 1.82 2003/09/11 10:49:09 n0body Exp $
+// $Id: action_attack.c,v 1.83 2003/09/14 04:45:52 mr-russ Exp $
//@{
@@ -297,7 +297,7 @@
//
// Have reached target? FIXME: could use the new return code?
//
- if( goal && MapDistanceToUnit(unit->X,unit->Y,goal)
+ if( goal && MapDistanceBetweenUnits(unit,goal)
<=unit->Stats->AttackRange ) {
DebugLevel3Fn("Reached another unit, now attacking it.\n");
unit->State=0;
@@ -316,8 +316,7 @@
//
if( !goal && (WallOnMap(unit->Orders[0].X,unit->Orders[0].Y)
|| unit->Orders[0].Action==UnitActionAttackGround)
- && MapDistance(unit->X,unit->Y
- ,unit->Orders[0].X,unit->Orders[0].Y)
+ &&
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;
@@ -519,7 +518,7 @@
//
// Still near to target, if not goto target.
//
- if( MapDistanceToUnit(unit->X,unit->Y,goal)
+ if( MapDistanceBetweenUnits(unit,goal)
>unit->Stats->AttackRange ) {
if( unit->SavedOrder.Action==UnitActionStill ) {
// Save current order to come back or to continue it.
Index: stratagus/src/action/action_board.c
diff -u stratagus/src/action/action_board.c:1.40
stratagus/src/action/action_board.c:1.41
--- stratagus/src/action/action_board.c:1.40 Thu Aug 21 03:12:03 2003
+++ stratagus/src/action/action_board.c Sun Sep 14 00:45:52 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: action_board.c,v 1.40 2003/08/21 07:12:03 n0body Exp $
+// $Id: action_board.c,v 1.41 2003/09/14 04:45:52 mr-russ Exp $
//@{
@@ -114,7 +114,7 @@
return 0;
}
- if( MapDistanceToUnit(unit->X,unit->Y,trans)==1 ) {
+ if( MapDistanceBetweenUnits(unit,trans)==1 ) {
DebugLevel3Fn("Enter transporter\n");
return 1;
}
Index: stratagus/src/action/action_demolish.c
diff -u stratagus/src/action/action_demolish.c:1.36
stratagus/src/action/action_demolish.c:1.37
--- stratagus/src/action/action_demolish.c:1.36 Sat Sep 13 22:46:36 2003
+++ stratagus/src/action/action_demolish.c Sun Sep 14 00:45:52 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: action_demolish.c,v 1.36 2003/09/14 02:46:36 mr-russ Exp $
+// $Id: action_demolish.c,v 1.37 2003/09/14 04:45:52 mr-russ Exp $
//@{
@@ -78,14 +78,14 @@
// Already at target? FIXME: duplicate code.
//
if( (goal=unit->Orders[0].Goal) ) {
- if( MapDistanceToUnit(unit->X,unit->Y,goal)<=1 ) {
+ if( MapDistanceBetweenUnits(unit,goal)<=1 ) {
unit->State=0;
unit->SubAction=2;
HandleActionDemolish(unit);
return;
}
- } else if( MapDistance(unit->X,unit->Y
- ,unit->Orders[0].X,unit->Orders[0].Y)<=1 ) {
+ } else if( MapDistanceToUnit(unit->Orders[0].X,
+ unit->Orders[0].Y,unit)<=1 ) {
unit->State=0;
unit->SubAction=2;
HandleActionDemolish(unit);
@@ -130,12 +130,12 @@
// Have reached target? FIXME: could use pathfinder result?
//
if( goal ) {
- if( MapDistanceToUnit(unit->X,unit->Y,goal)<=1 ) {
+ if( MapDistanceBetweenUnits(unit,goal)<=1 ) {
unit->State=0;
unit->SubAction=2;
}
- } else if( MapDistance(unit->X,unit->Y
- ,unit->Orders[0].X,unit->Orders[0].Y)<=1 ) {
+ } else if( MapDistanceToUnit(unit->Orders[0].X,unit->Orders[0].Y
+ ,unit )<=1 ) {
unit->State=0;
unit->SubAction=2;
} else if( err==PF_UNREACHABLE ) {
Index: stratagus/src/action/action_repair.c
diff -u stratagus/src/action/action_repair.c:1.52
stratagus/src/action/action_repair.c:1.53
--- stratagus/src/action/action_repair.c:1.52 Fri Sep 12 13:44:36 2003
+++ stratagus/src/action/action_repair.c Sun Sep 14 00:45:52 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: action_repair.c,v 1.52 2003/09/12 17:44:36 n0body Exp $
+// $Id: action_repair.c,v 1.53 2003/09/14 04:45:52 mr-russ Exp $
//@{
@@ -254,7 +254,7 @@
//
// Have reached target? FIXME: could use return value
//
-
if(goal&&MapDistanceToUnit(unit->X,unit->Y,goal)<=unit->Type->RepairRange
+
if(goal&&MapDistanceBetweenUnits(unit,goal)<=unit->Type->RepairRange
&&goal->HP<goal->Type->Stats->HitPoints) {
unit->State=0;
unit->SubAction=2;
Index: stratagus/src/action/action_resource.c
diff -u stratagus/src/action/action_resource.c:1.54
stratagus/src/action/action_resource.c:1.55
--- stratagus/src/action/action_resource.c:1.54 Fri Sep 12 13:44:36 2003
+++ stratagus/src/action/action_resource.c Sun Sep 14 00:45:52 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: action_resource.c,v 1.54 2003/09/12 17:44:36 n0body Exp $
+// $Id: action_resource.c,v 1.55 2003/09/14 04:45:52 mr-russ Exp $
//@{
@@ -191,8 +191,8 @@
}
// FIXME: 0 can happen, if to near placed by map designer.
- DebugLevel3Fn("%d\n" _C_ MapDistanceToUnit(unit->X,unit->Y,goal) );
- DebugCheck( MapDistanceToUnit(unit->X,unit->Y,goal)>1 );
+ DebugLevel3Fn("%d\n" _C_ MapDistanceBetweenUnits(unit,goal) );
+ DebugCheck( MapDistanceBetweenUnits(unit,goal)>1 );
//
// Update the heading of a harvesting unit to looks straight at the
resource.
Index: stratagus/src/action/action_spellcast.c
diff -u stratagus/src/action/action_spellcast.c:1.31
stratagus/src/action/action_spellcast.c:1.32
--- stratagus/src/action/action_spellcast.c:1.31 Fri Jul 11 10:35:29 2003
+++ stratagus/src/action/action_spellcast.c Sun Sep 14 00:45:52 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: action_spellcast.c,v 1.31 2003/07/11 14:35:29 n0body Exp $
+// $Id: action_spellcast.c,v 1.32 2003/09/14 04:45:52 mr-russ Exp $
/*
** This is inherited from action_attack.c, actually spell casting will
@@ -111,7 +111,7 @@
// FIXME: use return codes from pathfinder
goal = unit->Orders[0].Goal;
- if (goal && MapDistanceToUnit(unit->X, unit->Y, goal)
+ if (goal && MapDistanceBetweenUnits(unit, goal)
<= unit->Orders[0].RangeX) {
// there is goal and it is in range
@@ -124,8 +124,8 @@
}
unit->SubAction++; // cast the spell
return;
- } else if (!goal && MapDistance(unit->X, unit->Y, unit->Orders[0].X,
- unit->Orders[0].Y) <= unit->Orders[0].RangeX) {
+ } else if (!goal && MapDistanceToUnit(unit->Orders[0].X,
+ unit->Orders[0].Y,unit) <= unit->Orders[0].RangeX) {
// there is no goal and target spot is in range
unit->State = 0;
if( !unit->Type->Building ) {
Index: stratagus/src/clone/unit.c
diff -u stratagus/src/clone/unit.c:1.294 stratagus/src/clone/unit.c:1.295
--- stratagus/src/clone/unit.c:1.294 Thu Sep 11 18:07:53 2003
+++ stratagus/src/clone/unit.c Sun Sep 14 00:45:52 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: unit.c,v 1.294 2003/09/11 22:07:53 n0body Exp $
+// $Id: unit.c,v 1.295 2003/09/14 04:45:52 mr-russ Exp $
//@{
@@ -3440,21 +3440,21 @@
y2=dst->Y;
if( x1+src->Type->TileWidth<=x2 ) {
- dx=x2-x1-src->Type->TileWidth;
+ dx=x2-x1-src->Type->TileWidth+1;
if( dx<0 ) {
dx=0;
}
} else {
- dx=x1-x2-dst->Type->TileWidth;
+ dx=x1-x2-dst->Type->TileWidth+1;
if( dx<0 ) {
dx=0;
}
}
if( y1+src->Type->TileHeight<=y2 ) {
- dy=y2-y1-src->Type->TileHeight;
+ dy=y2-y1-src->Type->TileHeight+1;
} else {
- dy=y1-y2-dst->Type->TileHeight;
+ dy=y1-y2-dst->Type->TileHeight+1;
if( dy<0 ) {
dy=0;
}
@@ -3964,7 +3964,7 @@
int InRun, RunStart;
CLprintf(file,"\n;;; -----------------------------------------\n");
- CLprintf(file,";;; MODULE: units $Id: unit.c,v 1.294 2003/09/11 22:07:53
n0body Exp $\n\n");
+ CLprintf(file,";;; MODULE: units $Id: unit.c,v 1.295 2003/09/14 04:45:52
mr-russ Exp $\n\n");
//
// Local variables
Index: stratagus/src/map/map_fog.c
diff -u stratagus/src/map/map_fog.c:1.101 stratagus/src/map/map_fog.c:1.102
--- stratagus/src/map/map_fog.c:1.101 Thu Sep 11 18:07:53 2003
+++ stratagus/src/map/map_fog.c Sun Sep 14 00:45:53 2003
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: map_fog.c,v 1.101 2003/09/11 22:07:53 n0body Exp $
+// $Id: map_fog.c,v 1.102 2003/09/14 04:45:53 mr-russ Exp $
//@{
@@ -2634,14 +2634,28 @@
char seen[7];
int x=(dx-vp->X)/TileSizeX + vp->MapX;
int y=(dy-vp->Y)/TileSizeY + vp->MapY;
- // Really long and ugly:
-
//sprintf(seen,"%d(%d)",TheMap.Fields[y*TheMap.Width+x].Visible[ThisPlayer->Player],IsMapFieldVisible(ThisPlayer,x,y));
- // Shorter version:
+
+#if 0
+ // Fog of War Vision
+ // Really long and ugly, shared and own vision:
+ //
sprintf(seen,"%d(%d)",TheMap.Fields[y*TheMap.Width+x].Visible[ThisPlayer->Player],IsMapFieldVisible(ThisPlayer,x,y));
+ // Shorter version, but no shared vision:
sprintf(seen,"%d",TheMap.Fields[y*TheMap.Width+x].Visible[ThisPlayer->Player]);
if( TheMap.Fields[y*TheMap.Width+x].Visible[0] ) {
VideoDrawText(dx,dy, GameFont,seen);
}
+#endif
+#if 1
+ // Unit Distance Checks
+ if( Selected[1] && Selected[0] ) {
+ sprintf(seen,"%d",MapDistanceBetweenUnits(Selected[0],Selected[1]));
+ VideoDrawText(dx,dy, GameFont,seen);
+ } else if( Selected[0] ) {
+ sprintf(seen,"%d",MapDistanceToUnit(x,y,Selected[0]));
+ VideoDrawText(dx,dy, GameFont,seen);
+ }
}
+#endif
#endif
#if defined(HIERARCHIC_PATHFINDER) && defined(DEBUG) && 0
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src action/action_attack.c action/act...,
Russell Smith <=