src/hcode/btech/btspath.c File Reference

#include "mech.h"

Include dependency graph for btspath.c:

Go to the source code of this file.

Defines

#define XSIZE   spath_map->map_width
#define YSIZE   spath_map->map_height

Functions

int MechTileCost (int fx, int fy, int tx, int ty)
int HoverTankTileCost (int fx, int fy, int tx, int ty)
int TrackedTankTileCost (int fx, int fy, int tx, int ty)

Variables

MAPspath_map
int(*) TileCost (int fx, int fy, int tx, int ty)


Define Documentation

#define XSIZE   spath_map->map_width

Definition at line 19 of file btspath.c.

Referenced by HoverTankTileCost(), MechTileCost(), and TrackedTankTileCost().

#define YSIZE   spath_map->map_height

Definition at line 20 of file btspath.c.

Referenced by HoverTankTileCost(), MechTileCost(), and TrackedTankTileCost().


Function Documentation

int HoverTankTileCost ( int  fx,
int  fy,
int  tx,
int  ty 
)

Definition at line 54 of file btspath.c.

References Elevation, GetRTerrain, GRASSLAND, HEAVY_FOREST, LIGHT_FOREST, MOUNTAINS, ROUGH, spath_map, WATER, XSIZE, and YSIZE.

00055 {
00056         int z1, z2;
00057         int bonus;
00058         char terr;
00059 
00060         if(tx < 0 || ty >= XSIZE || ty < 0 || ty >= YSIZE)
00061                 return 0;
00062         z1 = Elevation(spath_map, fx, fy);
00063         z2 = Elevation(spath_map, tx, ty);
00064         if((bonus = abs(z1 - z2)) > 1)
00065                 return 0;
00066         terr = GetRTerrain(spath_map, tx, ty);
00067         if(terr == WATER)                       /* Hovers LOVE water */
00068                 return 1;
00069         if(terr == GRASSLAND)
00070                 return 1 + bonus;
00071         if(terr == HEAVY_FOREST)
00072                 return 0;
00073         switch (terr) {
00074         case LIGHT_FOREST:
00075         case ROUGH:
00076                 bonus++;
00077                 break;
00078         case MOUNTAINS:
00079                 bonus += 2;
00080                 break;
00081         }
00082         return bonus + 1;
00083 }

int MechTileCost ( int  fx,
int  fy,
int  tx,
int  ty 
)

Definition at line 24 of file btspath.c.

References Elevation, GetRTerrain, GRASSLAND, HEAVY_FOREST, LIGHT_FOREST, MOUNTAINS, ROUGH, spath_map, WATER, XSIZE, and YSIZE.

00025 {
00026         int z1, z2;
00027         int bonus;
00028         char terr;
00029 
00030         if(tx < 0 || ty >= XSIZE || ty < 0 || ty >= YSIZE)
00031                 return 0;
00032         z1 = Elevation(spath_map, fx, fy);
00033         z2 = Elevation(spath_map, tx, ty);
00034         if((bonus = abs(z1 - z2)) > 2)
00035                 return 0;
00036         terr = GetRTerrain(spath_map, tx, ty);
00037         if(terr == WATER && z2)         /* No waterwalking, yet */
00038                 return 0;
00039         if(terr == GRASSLAND)
00040                 return 1 + bonus;
00041         switch (terr) {
00042         case LIGHT_FOREST:
00043         case ROUGH:
00044                 bonus++;
00045                 break;
00046         case HEAVY_FOREST:
00047         case MOUNTAINS:
00048                 bonus += 2;
00049                 break;
00050         }
00051         return bonus + 1;
00052 }

int TrackedTankTileCost ( int  fx,
int  fy,
int  tx,
int  ty 
)

Definition at line 85 of file btspath.c.

References Elevation, GetRTerrain, GRASSLAND, HEAVY_FOREST, LIGHT_FOREST, MOUNTAINS, ROUGH, spath_map, WATER, XSIZE, and YSIZE.

00086 {
00087         int z1, z2;
00088         int bonus;
00089         char terr;
00090 
00091         if(tx < 0 || ty >= XSIZE || ty < 0 || ty >= YSIZE)
00092                 return 0;
00093         z1 = Elevation(spath_map, fx, fy);
00094         z2 = Elevation(spath_map, tx, ty);
00095         if((bonus = abs(z1 - z2)) > 1)
00096                 return 0;
00097         terr = GetRTerrain(spath_map, tx, ty);
00098         if(terr == GRASSLAND)
00099                 return 1 + bonus;
00100         if(terr == WATER)
00101                 return 0;
00102         if(terr == HEAVY_FOREST)
00103                 return 0;
00104         switch (terr) {
00105         case LIGHT_FOREST:
00106         case ROUGH:
00107                 bonus++;
00108                 break;
00109         case HEAVY_FOREST:
00110         case MOUNTAINS:
00111                 bonus += 2;
00112                 break;
00113         }
00114         return bonus + 1;
00115 }


Variable Documentation

MAP* spath_map

Definition at line 686 of file map.c.

Referenced by HoverTankTileCost(), map_pathfind(), MechTileCost(), and TrackedTankTileCost().

int(*) TileCost(int fx, int fy, int tx, int ty)


Generated on Mon May 28 04:25:33 2007 for BattletechMUX by  doxygen 1.4.7