summaryrefslogtreecommitdiff
path: root/ai/trolly/shared.c
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-01-02 19:19:48 +0000
committerrubidium <rubidium@openttd.org>2007-01-02 19:19:48 +0000
commit66bbf336c6af7353ef0aeed58002c46543b30635 (patch)
treead4a63860df2626b22f77e7dac712e958bea54cb /ai/trolly/shared.c
parentccc0a3f4dbf58c005b22341ac8874252924690cd (diff)
downloadopenttd-66bbf336c6af7353ef0aeed58002c46543b30635.tar.xz
(svn r7759) -Merge: makefile rewrite. This merge features:
- A proper ./configure, so everything needs to be configured only once, not for every make. - Usage of makedepend when available. This greatly reduces the time needed for generating the dependencies. - A generator for all project files. There is a single file with sources, which is used to generate Makefiles and the project files for MSVC. - Proper support for OSX universal binaries. - Object files for non-MSVC compiles are also placed in separate directories, making is faster to switch between debug and release compiles and it does not touch the directory with the source files. - Functionality to make a bundle of all needed files for for example a nightly or distribution of a binary with all needed GRFs and language files. Note: as this merge moves almost all files, it is recommended to make a backup of your working copy before updating your working copy.
Diffstat (limited to 'ai/trolly/shared.c')
-rw-r--r--ai/trolly/shared.c118
1 files changed, 0 insertions, 118 deletions
diff --git a/ai/trolly/shared.c b/ai/trolly/shared.c
deleted file mode 100644
index e683b60ea..000000000
--- a/ai/trolly/shared.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/* $Id$ */
-
-#include "../../stdafx.h"
-#include "../../openttd.h"
-#include "../../debug.h"
-#include "../../map.h"
-#include "trolly.h"
-#include "../../vehicle.h"
-
-int AiNew_GetRailDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c)
-{
- // 0 = vert
- // 1 = horz
- // 2 = dig up-left
- // 3 = dig down-right
- // 4 = dig down-left
- // 5 = dig up-right
-
- uint x1 = TileX(tile_a);
- uint x2 = TileX(tile_b);
- uint x3 = TileX(tile_c);
-
- uint y1 = TileY(tile_a);
- uint y2 = TileY(tile_b);
- uint y3 = TileY(tile_c);
-
- if (y1 == y2 && y2 == y3) return 0;
- if (x1 == x2 && x2 == x3) return 1;
- if (y2 > y1) return x2 > x3 ? 2 : 4;
- if (x2 > x1) return y2 > y3 ? 2 : 5;
- if (y1 > y2) return x2 > x3 ? 5 : 3;
- if (x1 > x2) return y2 > y3 ? 4 : 3;
-
- return 0;
-}
-
-int AiNew_GetRoadDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c)
-{
- int x1, x2, x3;
- int y1, y2, y3;
- int r;
-
- x1 = TileX(tile_a);
- x2 = TileX(tile_b);
- x3 = TileX(tile_c);
-
- y1 = TileY(tile_a);
- y2 = TileY(tile_b);
- y3 = TileY(tile_c);
-
- r = 0;
-
- if (x1 < x2) r += 8;
- if (y1 < y2) r += 1;
- if (x1 > x2) r += 2;
- if (y1 > y2) r += 4;
-
- if (x2 < x3) r += 2;
- if (y2 < y3) r += 4;
- if (x2 > x3) r += 8;
- if (y2 > y3) r += 1;
-
- return r;
-}
-
-// Get's the direction between 2 tiles seen from tile_a
-DiagDirection AiNew_GetDirection(TileIndex tile_a, TileIndex tile_b)
-{
- if (TileY(tile_a) < TileY(tile_b)) return DIAGDIR_SE;
- if (TileY(tile_a) > TileY(tile_b)) return DIAGDIR_NW;
- if (TileX(tile_a) < TileX(tile_b)) return DIAGDIR_SW;
- return DIAGDIR_NE;
-}
-
-
-// This functions looks up if this vehicle is special for this AI
-// and returns his flag
-uint AiNew_GetSpecialVehicleFlag(Player* p, Vehicle* v)
-{
- uint i;
-
- for (i = 0; i < AI_MAX_SPECIAL_VEHICLES; i++) {
- if (p->ainew.special_vehicles[i].veh_id == v->index) {
- return p->ainew.special_vehicles[i].flag;
- }
- }
-
- // Not found :(
- return 0;
-}
-
-
-bool AiNew_SetSpecialVehicleFlag(Player* p, Vehicle* v, uint flag)
-{
- int new_id = -1;
- uint i;
-
- for (i = 0; i < AI_MAX_SPECIAL_VEHICLES; i++) {
- if (p->ainew.special_vehicles[i].veh_id == v->index) {
- p->ainew.special_vehicles[i].flag |= flag;
- return true;
- }
- if (new_id == -1 &&
- p->ainew.special_vehicles[i].veh_id == 0 &&
- p->ainew.special_vehicles[i].flag == 0) {
- new_id = i;
- }
- }
-
- // Out of special_vehicle spots :s
- if (new_id == -1) {
- DEBUG(ai, 1, "special_vehicles list is too small");
- return false;
- }
- p->ainew.special_vehicles[new_id].veh_id = v->index;
- p->ainew.special_vehicles[new_id].flag = flag;
- return true;
-}