Mercurial > hg > openttd
comparison src/station_cmd.cpp @ 5836:0b68d5a508a2 draft
(svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
author | celestar <celestar@openttd.org> |
---|---|
date | Thu, 25 Jan 2007 10:06:58 +0000 |
parents | f9e0c80cf037 |
children | e18480817d2c |
comparison
equal
deleted
inserted
replaced
5835:60c031ec09c7 | 5836:0b68d5a508a2 |
---|---|
79 | 79 |
80 | 80 |
81 extern void UpdateAirplanesOnNewStation(Station *st); | 81 extern void UpdateAirplanesOnNewStation(Station *st); |
82 | 82 |
83 | 83 |
84 RoadStop* GetPrimaryRoadStop(const Station* st, RoadStopType type) | 84 RoadStop* GetPrimaryRoadStop(const Station* st, RoadStop::Type type) |
85 { | 85 { |
86 switch (type) { | 86 switch (type) { |
87 case RS_BUS: return st->bus_stops; | 87 case RoadStop::BUS: return st->bus_stops; |
88 case RS_TRUCK: return st->truck_stops; | 88 case RoadStop::TRUCK: return st->truck_stops; |
89 default: NOT_REACHED(); | 89 default: NOT_REACHED(); |
90 } | 90 } |
91 | 91 |
92 return NULL; | 92 return NULL; |
93 } | 93 } |
94 | 94 |
95 RoadStop* GetRoadStopByTile(TileIndex tile, RoadStopType type) | 95 RoadStop* GetRoadStopByTile(TileIndex tile, RoadStop::Type type) |
96 { | 96 { |
97 const Station* st = GetStationByTile(tile); | 97 const Station* st = GetStationByTile(tile); |
98 RoadStop* rs; | 98 RoadStop* rs; |
99 | 99 |
100 for (rs = GetPrimaryRoadStop(st, type); rs->xy != tile; rs = rs->next) { | 100 for (rs = GetPrimaryRoadStop(st, type); rs->xy != tile; rs = rs->next) { |
102 } | 102 } |
103 | 103 |
104 return rs; | 104 return rs; |
105 } | 105 } |
106 | 106 |
107 uint GetNumRoadStopsInStation(const Station* st, RoadStopType type) | 107 uint GetNumRoadStopsInStation(const Station* st, RoadStop::Type type) |
108 { | 108 { |
109 uint num = 0; | 109 uint num = 0; |
110 const RoadStop *rs; | 110 const RoadStop *rs; |
111 | 111 |
112 assert(st != NULL); | 112 assert(st != NULL); |
1297 * obtaining a triple pointer (***currstop). When finished, **currstop | 1297 * obtaining a triple pointer (***currstop). When finished, **currstop |
1298 * in CmdBuildRoadStop will contain the address of the pointer which will | 1298 * in CmdBuildRoadStop will contain the address of the pointer which will |
1299 * then point into the global roadstop array. *prev (in CmdBuildRoadStop) | 1299 * then point into the global roadstop array. *prev (in CmdBuildRoadStop) |
1300 * is the pointer tino the global roadstop array which has *currstop in | 1300 * is the pointer tino the global roadstop array which has *currstop in |
1301 * its ->next element. | 1301 * its ->next element. |
1302 * @param[in] truck_station Determines whether a stop is RS_BUS or RS_TRUCK | 1302 * @param[in] truck_station Determines whether a stop is RoadStop::BUS or RoadStop::TRUCK |
1303 * @param[in] station The station to do the whole procedure for | 1303 * @param[in] station The station to do the whole procedure for |
1304 * @param[out] currstop See the detailed function description | 1304 * @param[out] currstop See the detailed function description |
1305 * @param prev See the detailed function description | 1305 * @param prev See the detailed function description |
1306 */ | 1306 */ |
1307 static void FindRoadStopSpot(bool truck_station, Station* st, RoadStop*** currstop, RoadStop** prev) | 1307 static void FindRoadStopSpot(bool truck_station, Station* st, RoadStop*** currstop, RoadStop** prev) |
1367 | 1367 |
1368 /* ensure that in case of error (or no DC_EXEC) the new road stop gets deleted upon return */ | 1368 /* ensure that in case of error (or no DC_EXEC) the new road stop gets deleted upon return */ |
1369 std::auto_ptr<RoadStop> rs_auto_delete(road_stop); | 1369 std::auto_ptr<RoadStop> rs_auto_delete(road_stop); |
1370 | 1370 |
1371 if (st != NULL && | 1371 if (st != NULL && |
1372 GetNumRoadStopsInStation(st, RS_BUS) + GetNumRoadStopsInStation(st, RS_TRUCK) >= ROAD_STOP_LIMIT) { | 1372 GetNumRoadStopsInStation(st, RoadStop::BUS) + GetNumRoadStopsInStation(st, RoadStop::TRUCK) >= ROAD_STOP_LIMIT) { |
1373 return_cmd_error(type ? STR_3008B_TOO_MANY_TRUCK_STOPS : STR_3008A_TOO_MANY_BUS_STOPS); | 1373 return_cmd_error(type ? STR_3008B_TOO_MANY_TRUCK_STOPS : STR_3008A_TOO_MANY_BUS_STOPS); |
1374 } | 1374 } |
1375 | 1375 |
1376 /* In case of new station if DC_EXEC is NOT set we still need to create the station | 1376 /* In case of new station if DC_EXEC is NOT set we still need to create the station |
1377 * to test if everything is OK. In this case we need to delete it before return. */ | 1377 * to test if everything is OK. In this case we need to delete it before return. */ |
1416 road_stop->prev = prev; | 1416 road_stop->prev = prev; |
1417 st->AddFacility((type) ? FACIL_TRUCK_STOP : FACIL_BUS_STOP, tile); | 1417 st->AddFacility((type) ? FACIL_TRUCK_STOP : FACIL_BUS_STOP, tile); |
1418 | 1418 |
1419 st->rect.BeforeAddTile(tile, StationRect::ADD_TRY); | 1419 st->rect.BeforeAddTile(tile, StationRect::ADD_TRY); |
1420 | 1420 |
1421 MakeRoadStop(tile, st->owner, st->index, type ? RS_TRUCK : RS_BUS, (DiagDirection)p1); | 1421 MakeRoadStop(tile, st->owner, st->index, type ? RoadStop::TRUCK : RoadStop::BUS, (DiagDirection)p1); |
1422 | 1422 |
1423 UpdateStationVirtCoordDirty(st); | 1423 UpdateStationVirtCoordDirty(st); |
1424 UpdateStationAcceptance(st, false); | 1424 UpdateStationAcceptance(st, false); |
1425 RebuildStationLists(); | 1425 RebuildStationLists(); |
1426 InvalidateWindow(WC_STATION_LIST, st->owner); | 1426 InvalidateWindow(WC_STATION_LIST, st->owner); |
1442 return CMD_ERROR; | 1442 return CMD_ERROR; |
1443 } | 1443 } |
1444 | 1444 |
1445 if (is_truck) { // truck stop | 1445 if (is_truck) { // truck stop |
1446 primary_stop = &st->truck_stops; | 1446 primary_stop = &st->truck_stops; |
1447 cur_stop = GetRoadStopByTile(tile, RS_TRUCK); | 1447 cur_stop = GetRoadStopByTile(tile, RoadStop::TRUCK); |
1448 } else { | 1448 } else { |
1449 primary_stop = &st->bus_stops; | 1449 primary_stop = &st->bus_stops; |
1450 cur_stop = GetRoadStopByTile(tile, RS_BUS); | 1450 cur_stop = GetRoadStopByTile(tile, RoadStop::BUS); |
1451 } | 1451 } |
1452 | 1452 |
1453 assert(cur_stop != NULL); | 1453 assert(cur_stop != NULL); |
1454 | 1454 |
1455 if (!EnsureNoVehicle(tile)) return CMD_ERROR; | 1455 if (!EnsureNoVehicle(tile)) return CMD_ERROR; |