summaryrefslogtreecommitdiff
path: root/ai/trolly/shared.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-06-27 21:25:53 +0000
committertron <tron@openttd.org>2006-06-27 21:25:53 +0000
commit2b27073156f40df263cf653263488b8d72a76236 (patch)
tree1bfdb9c99b43fdc3b07ac13cbed4259a06d34f6f /ai/trolly/shared.c
parentc126ce110ee33bffe07dac5283d8a1648dc662b7 (diff)
downloadopenttd-2b27073156f40df263cf653263488b8d72a76236.tar.xz
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
Diffstat (limited to 'ai/trolly/shared.c')
-rw-r--r--ai/trolly/shared.c60
1 files changed, 27 insertions, 33 deletions
diff --git a/ai/trolly/shared.c b/ai/trolly/shared.c
index c745f31f6..d41544ef0 100644
--- a/ai/trolly/shared.c
+++ b/ai/trolly/shared.c
@@ -16,35 +16,20 @@ int AiNew_GetRailDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c)
// 4 = dig down-left
// 5 = dig up-right
- int x1, x2, x3;
- int y1, y2, y3;
-
- x1 = TileX(tile_a);
- x2 = TileX(tile_b);
- x3 = TileX(tile_c);
+ uint x1 = TileX(tile_a);
+ uint x2 = TileX(tile_b);
+ uint x3 = TileX(tile_c);
- y1 = TileY(tile_a);
- y2 = TileY(tile_b);
- y3 = TileY(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) {
- if (x2 > x3) return 2;
- else return 4;
- }
- if (x2 > x1) {
- if (y2 > y3) return 2;
- else return 5;
- }
- if (y1 > y2) {
- if (x2 > x3) return 5;
- else return 3;
- }
- if (x1 > x2) {
- if (y2 > y3) return 4;
- else return 3;
- }
+ 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;
}
@@ -87,11 +72,14 @@ DiagDirection AiNew_GetDirection(TileIndex tile_a, TileIndex tile_b)
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) {
- int i;
- for (i=0;i<AI_MAX_SPECIAL_VEHICLES;i++) {
+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;
}
@@ -101,16 +89,22 @@ uint AiNew_GetSpecialVehicleFlag(Player *p, Vehicle *v) {
return 0;
}
-bool AiNew_SetSpecialVehicleFlag(Player *p, Vehicle *v, uint flag) {
- int i, new_id = -1;
- for (i=0;i<AI_MAX_SPECIAL_VEHICLES;i++) {
+
+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)
+ 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