diff options
author | tron <tron@openttd.org> | 2006-02-06 09:18:04 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-02-06 09:18:04 +0000 |
commit | 453b30e387f8d8ab1839d96b0d1f9a8fea841292 (patch) | |
tree | 3a4002304d8204d11c37ba706d6ffbd2e5dfac1b /station_cmd.c | |
parent | 0755bbead0240f519c9d78bb88ef4629d5ab8fa5 (diff) | |
download | openttd-453b30e387f8d8ab1839d96b0d1f9a8fea841292.tar.xz |
(svn r3564) Several smaller changes:
- Don't treat non-booleans as booleans
- Reduce variable scope
- Bracing
- Use DeMorgan's law to make conditionals easier to read
- if cascade -> switch
- Replace some magic numbers by symbolic names
- Avoid assignments within other statements
Diffstat (limited to 'station_cmd.c')
-rw-r--r-- | station_cmd.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/station_cmd.c b/station_cmd.c index 942a93cdc..ba61b8f4e 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -1325,7 +1325,7 @@ int32 CmdBuildRoadStop(int x, int y, uint32 flags, uint32 p1, uint32 p2) /* Find a station close to us */ if (st == NULL) { st = GetClosestStationFromTile(tile, 8, _current_player); - if (st != NULL && st->facilities) st = NULL; + if (st != NULL && st->facilities != 0) st = NULL; } //give us a road stop in the list, and check if something went wrong @@ -1334,7 +1334,8 @@ int32 CmdBuildRoadStop(int x, int y, uint32 flags, uint32 p1, uint32 p2) return_cmd_error(type ? STR_3008B_TOO_MANY_TRUCK_STOPS : STR_3008A_TOO_MANY_BUS_STOPS); } - if (st != NULL && GetNumRoadStops(st, RS_BUS) + GetNumRoadStops(st, RS_TRUCK) >= ROAD_STOP_LIMIT) { + if (st != NULL && + GetNumRoadStops(st, RS_BUS) + GetNumRoadStops(st, RS_TRUCK) >= ROAD_STOP_LIMIT) { return_cmd_error(type ? STR_3008B_TOO_MANY_TRUCK_STOPS : STR_3008A_TOO_MANY_BUS_STOPS); } @@ -2172,19 +2173,18 @@ static const byte _enter_station_speedtable[12] = { static uint32 VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y) { - StationID station_id; - byte dir; - if (v->type == VEH_Train) { if (IS_BYTE_INSIDE(_m[tile].m5, 0, 8) && IsFrontEngine(v) && !IsCompatibleTrainStationTile(tile + TileOffsByDir(v->direction >> 1), tile)) { + StationID station_id = _m[tile].m2; - station_id = _m[tile].m2; if ((!(v->current_order.flags & OF_NON_STOP) && !_patches.new_nonstop) || (v->current_order.type == OT_GOTO_STATION && v->current_order.station == station_id)) { if (!(_patches.new_nonstop && v->current_order.flags & OF_NON_STOP) && v->current_order.type != OT_LEAVESTATION && v->last_station_visited != station_id) { + byte dir; + x &= 0xF; y &= 0xF; |