btmux/autom4te.cache/
btmux/doc/.svn/
btmux/event/.svn/
btmux/game/.svn/
btmux/game/bin/.svn/
btmux/game/data/.svn/
btmux/game/logs/.svn/
btmux/game/maps/
btmux/game/maps/.svn/
btmux/game/maps/.svn/prop-base/
btmux/game/maps/.svn/props/
btmux/game/maps/.svn/text-base/
btmux/game/maps/.svn/wcprops/
btmux/game/mechs/
btmux/game/mechs/.svn/
btmux/game/mechs/.svn/prop-base/
btmux/game/mechs/.svn/props/
btmux/game/mechs/.svn/text-base/
btmux/game/mechs/.svn/wcprops/
btmux/game/text/.svn/
btmux/include/.svn/
btmux/misc/
btmux/misc/.svn/
btmux/misc/.svn/prop-base/
btmux/misc/.svn/props/
btmux/misc/.svn/text-base/
btmux/misc/.svn/wcprops/
btmux/python/
btmux/python/.svn/
btmux/python/.svn/prop-base/
btmux/python/.svn/props/
btmux/python/.svn/text-base/
btmux/python/.svn/wcprops/
btmux/src/.svn/prop-base/
btmux/src/.svn/props/
btmux/src/.svn/text-base/
btmux/src/.svn/wcprops/
btmux/src/hcode/.svn/
btmux/src/hcode/btech/
btmux/src/hcode/btech/.svn/
btmux/src/hcode/btech/.svn/prop-base/
btmux/src/hcode/btech/.svn/props/
btmux/src/hcode/btech/.svn/text-base/
btmux/src/hcode/btech/.svn/wcprops/
btmux/src/hcode/include/.svn/
/*
 * $Id: btspath.c,v 1.1.1.1 2005/01/11 21:18:04 kstevens Exp $
 *
 * Author: Markus Stenberg <fingon@iki.fi>
 *
 *  Copyright (c) 1997 Markus Stenberg
 *       All rights reserved
 *
 * Created: Tue Sep 23 19:49:20 1997 fingon
 * Last modified: Thu Mar  5 18:50:58 1998 fingon
 *
 */

#include "mech.h"

extern MAP *spath_map;

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

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

int MechTileCost(int fx, int fy, int tx, int ty)
{
    int z1, z2;
    int bonus;
    char terr;

    if (tx < 0 || ty >= XSIZE || ty < 0 || ty >= YSIZE)
	return 0;
    z1 = Elevation(spath_map, fx, fy);
    z2 = Elevation(spath_map, tx, ty);
    if ((bonus = abs(z1 - z2)) > 2)
	return 0;
    terr = GetRTerrain(spath_map, tx, ty);
    if (terr == WATER && z2)	/* No waterwalking, yet */
	return 0;
    if (terr == GRASSLAND)
	return 1 + bonus;
    switch (terr) {
    case LIGHT_FOREST:
    case ROUGH:
	bonus++;
	break;
    case HEAVY_FOREST:
    case MOUNTAINS:
	bonus += 2;
	break;
    }
    return bonus + 1;
}

int HoverTankTileCost(int fx, int fy, int tx, int ty)
{
    int z1, z2;
    int bonus;
    char terr;

    if (tx < 0 || ty >= XSIZE || ty < 0 || ty >= YSIZE)
	return 0;
    z1 = Elevation(spath_map, fx, fy);
    z2 = Elevation(spath_map, tx, ty);
    if ((bonus = abs(z1 - z2)) > 1)
	return 0;
    terr = GetRTerrain(spath_map, tx, ty);
    if (terr == WATER)		/* Hovers LOVE water */
	return 1;
    if (terr == GRASSLAND)
	return 1 + bonus;
    if (terr == HEAVY_FOREST)
	return 0;
    switch (terr) {
    case LIGHT_FOREST:
    case ROUGH:
	bonus++;
	break;
    case MOUNTAINS:
	bonus += 2;
	break;
    }
    return bonus + 1;
}

int TrackedTankTileCost(int fx, int fy, int tx, int ty)
{
    int z1, z2;
    int bonus;
    char terr;

    if (tx < 0 || ty >= XSIZE || ty < 0 || ty >= YSIZE)
	return 0;
    z1 = Elevation(spath_map, fx, fy);
    z2 = Elevation(spath_map, tx, ty);
    if ((bonus = abs(z1 - z2)) > 1)
	return 0;
    terr = GetRTerrain(spath_map, tx, ty);
    if (terr == GRASSLAND)
	return 1 + bonus;
    if (terr == WATER)
	return 0;
    if (terr == HEAVY_FOREST)
	return 0;
    switch (terr) {
    case LIGHT_FOREST:
    case ROUGH:
	bonus++;
	break;
    case HEAVY_FOREST:
    case MOUNTAINS:
	bonus += 2;
	break;
    }
    return bonus + 1;
}