diff options
author | celestar <celestar@openttd.org> | 2007-01-25 10:06:58 +0000 |
---|---|---|
committer | celestar <celestar@openttd.org> | 2007-01-25 10:06:58 +0000 |
commit | b0a0086e7cd09d4bd28838fb3aa0fec6b9fc7857 (patch) | |
tree | dd1d248343ebc3dd9af716726f0d4ebc74c285f0 /src | |
parent | 600cb8a314eb1165bcef1309ebe3b7fd237e9778 (diff) | |
download | openttd-b0a0086e7cd09d4bd28838fb3aa0fec6b9fc7857.tar.xz |
(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
Diffstat (limited to 'src')
-rw-r--r-- | src/ai/default/default.cpp | 4 | ||||
-rw-r--r-- | src/ai/trolly/build.cpp | 4 | ||||
-rw-r--r-- | src/road_gui.cpp | 4 | ||||
-rw-r--r-- | src/roadveh_cmd.cpp | 6 | ||||
-rw-r--r-- | src/station.h | 37 | ||||
-rw-r--r-- | src/station_cmd.cpp | 20 | ||||
-rw-r--r-- | src/station_map.h | 8 |
7 files changed, 43 insertions, 40 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp index 9fc07abd5..7316b5648 100644 --- a/src/ai/default/default.cpp +++ b/src/ai/default/default.cpp @@ -2591,10 +2591,10 @@ static int32 AiDoBuildDefaultRoadBlock(TileIndex tile, const AiDefaultBlockData } else if (p->mode == 1) { if (_want_road_truck_station) { // Truck station - ret = DoCommand(c, p->attr, RS_TRUCK, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_ROAD_STOP); + ret = DoCommand(c, p->attr, RoadStop::TRUCK, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_ROAD_STOP); } else { // Bus station - ret = DoCommand(c, p->attr, RS_BUS, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_ROAD_STOP); + ret = DoCommand(c, p->attr, RoadStop::BUS, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_ROAD_STOP); } clear_town_stuff:; diff --git a/src/ai/trolly/build.cpp b/src/ai/trolly/build.cpp index 9959d0d04..62ae8b6d0 100644 --- a/src/ai/trolly/build.cpp +++ b/src/ai/trolly/build.cpp @@ -42,9 +42,9 @@ int AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte return AI_DoCommand(tile, direction + (numtracks << 8) + (length << 16), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_RAILROAD_STATION); if (type == AI_BUS) - return AI_DoCommand(tile, direction, RS_BUS, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP); + return AI_DoCommand(tile, direction, RoadStop::BUS, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP); - return AI_DoCommand(tile, direction, RS_TRUCK, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP); + return AI_DoCommand(tile, direction, RoadStop::TRUCK, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP); } diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 4f9fb134b..3b8437c34 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -94,12 +94,12 @@ static void PlaceRoad_Depot(TileIndex tile) static void PlaceRoad_BusStation(TileIndex tile) { - DoCommandP(tile, _road_station_picker_orientation, RS_BUS, CcRoadDepot, CMD_BUILD_ROAD_STOP | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1808_CAN_T_BUILD_BUS_STATION)); + DoCommandP(tile, _road_station_picker_orientation, RoadStop::BUS, CcRoadDepot, CMD_BUILD_ROAD_STOP | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1808_CAN_T_BUILD_BUS_STATION)); } static void PlaceRoad_TruckStation(TileIndex tile) { - DoCommandP(tile, _road_station_picker_orientation, RS_TRUCK, CcRoadDepot, CMD_BUILD_ROAD_STOP | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1809_CAN_T_BUILD_TRUCK_STATION)); + DoCommandP(tile, _road_station_picker_orientation, RoadStop::TRUCK, CcRoadDepot, CMD_BUILD_ROAD_STOP | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1809_CAN_T_BUILD_TRUCK_STATION)); } static void PlaceRoad_DemolishArea(TileIndex tile) diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 4e35d0a41..63d02107d 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -695,7 +695,7 @@ static void ProcessRoadVehOrder(Vehicle *v) rs = GetPrimaryRoadStop( GetStation(order->dest), - v->cargo_type == CT_PASSENGERS ? RS_BUS : RS_TRUCK + v->cargo_type == CT_PASSENGERS ? RoadStop::BUS : RoadStop::TRUCK ); if (rs != NULL) { @@ -1077,7 +1077,7 @@ static int RoadFindPathToDest(Vehicle* v, TileIndex tile, DiagDirection enterdir bitmask = 0; } else { /* Our station */ - RoadStopType rstype = (v->cargo_type == CT_PASSENGERS) ? RS_BUS : RS_TRUCK; + RoadStop::Type rstype = (v->cargo_type == CT_PASSENGERS) ? RoadStop::BUS : RoadStop::TRUCK; if (GetRoadStopType(tile) != rstype) { // wrong station type @@ -1663,7 +1663,7 @@ void OnNewDay_RoadVeh(Vehicle *v) /* update destination */ if (v->current_order.type == OT_GOTO_STATION && v->u.road.slot == NULL && !(v->vehstatus & VS_CRASHED)) { Station* st = GetStation(v->current_order.dest); - RoadStop* rs = GetPrimaryRoadStop(st, v->cargo_type == CT_PASSENGERS ? RS_BUS : RS_TRUCK); + RoadStop* rs = GetPrimaryRoadStop(st, v->cargo_type == CT_PASSENGERS ? RoadStop::BUS : RoadStop::TRUCK); RoadStop* best = NULL; if (rs != NULL) { diff --git a/src/station.h b/src/station.h index 0202e7209..178ac665e 100644 --- a/src/station.h +++ b/src/station.h @@ -35,24 +35,27 @@ typedef struct GoodsEntry { int32 feeder_profit; } GoodsEntry; -typedef enum RoadStopType { - RS_BUS, - RS_TRUCK -} RoadStopType; - enum { ROAD_STOP_LIMIT = 16, }; -typedef struct RoadStop { - TileIndex xy; - RoadStopID index; - byte status; - byte num_vehicles; - struct RoadStop *next; - struct RoadStop *prev; +/** A Stop for a Road Vehicle */ +struct RoadStop { + /** Types of RoadStops */ + enum Type { + BUS, ///< A standard stop for buses + TRUCK ///< A standard stop for trucks + }; - static const int cDebugCtorLevel = 3; + static const int cDebugCtorLevel = 3; ///< Debug level on which Contructor / Destructor messages are printed + static const int LIMIT = 16; ///< The maximum amount of roadstops that are allowed at a single station + + TileIndex xy; ///< Position on the map + RoadStopID index; ///< Global (i.e. pool-wide) index + byte status; ///< Current status of the Stop. Like which spot is taken. TODO - enumify this + byte num_vehicles; ///< Number of vehicles currently slotted to this stop + struct RoadStop *next; ///< Next stop of the given type at this station + struct RoadStop *prev; ///< Previous stop of the given type at this station RoadStop(TileIndex tile); ~RoadStop(); @@ -67,7 +70,7 @@ typedef struct RoadStop { bool IsValid() const; protected: static RoadStop *AllocateRaw(void); -} RoadStop; +}; typedef struct StationSpecList { const StationSpec *spec; @@ -271,9 +274,9 @@ uint GetPlatformLength(TileIndex tile, DiagDirection dir); const DrawTileSprites *GetStationTileLayout(byte gfx); void StationPickerDrawSprite(int x, int y, RailType railtype, int image); -RoadStop * GetRoadStopByTile(TileIndex tile, RoadStopType type); -RoadStop * GetPrimaryRoadStop(const Station *st, RoadStopType type); -uint GetNumRoadStops(const Station* st, RoadStopType type); +RoadStop * GetRoadStopByTile(TileIndex tile, RoadStop::Type type); +RoadStop * GetPrimaryRoadStop(const Station *st, RoadStop::Type type); +uint GetNumRoadStops(const Station* st, RoadStop::Type type); RoadStop * AllocateRoadStop( void ); void ClearSlot(Vehicle *v); diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 8cef0f4bc..49af7243a 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -81,18 +81,18 @@ DEFINE_OLD_POOL(RoadStop, RoadStop, RoadStopPoolNewBlock, NULL) extern void UpdateAirplanesOnNewStation(Station *st); -RoadStop* GetPrimaryRoadStop(const Station* st, RoadStopType type) +RoadStop* GetPrimaryRoadStop(const Station* st, RoadStop::Type type) { switch (type) { - case RS_BUS: return st->bus_stops; - case RS_TRUCK: return st->truck_stops; + case RoadStop::BUS: return st->bus_stops; + case RoadStop::TRUCK: return st->truck_stops; default: NOT_REACHED(); } return NULL; } -RoadStop* GetRoadStopByTile(TileIndex tile, RoadStopType type) +RoadStop* GetRoadStopByTile(TileIndex tile, RoadStop::Type type) { const Station* st = GetStationByTile(tile); RoadStop* rs; @@ -104,7 +104,7 @@ RoadStop* GetRoadStopByTile(TileIndex tile, RoadStopType type) return rs; } -uint GetNumRoadStopsInStation(const Station* st, RoadStopType type) +uint GetNumRoadStopsInStation(const Station* st, RoadStop::Type type) { uint num = 0; const RoadStop *rs; @@ -1299,7 +1299,7 @@ int32 DoConvertStationRail(TileIndex tile, RailType totype, bool exec) * then point into the global roadstop array. *prev (in CmdBuildRoadStop) * is the pointer tino the global roadstop array which has *currstop in * its ->next element. - * @param[in] truck_station Determines whether a stop is RS_BUS or RS_TRUCK + * @param[in] truck_station Determines whether a stop is RoadStop::BUS or RoadStop::TRUCK * @param[in] station The station to do the whole procedure for * @param[out] currstop See the detailed function description * @param prev See the detailed function description @@ -1369,7 +1369,7 @@ int32 CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) std::auto_ptr<RoadStop> rs_auto_delete(road_stop); if (st != NULL && - GetNumRoadStopsInStation(st, RS_BUS) + GetNumRoadStopsInStation(st, RS_TRUCK) >= ROAD_STOP_LIMIT) { + GetNumRoadStopsInStation(st, RoadStop::BUS) + GetNumRoadStopsInStation(st, RoadStop::TRUCK) >= ROAD_STOP_LIMIT) { return_cmd_error(type ? STR_3008B_TOO_MANY_TRUCK_STOPS : STR_3008A_TOO_MANY_BUS_STOPS); } @@ -1418,7 +1418,7 @@ int32 CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) st->rect.BeforeAddTile(tile, StationRect::ADD_TRY); - MakeRoadStop(tile, st->owner, st->index, type ? RS_TRUCK : RS_BUS, (DiagDirection)p1); + MakeRoadStop(tile, st->owner, st->index, type ? RoadStop::TRUCK : RoadStop::BUS, (DiagDirection)p1); UpdateStationVirtCoordDirty(st); UpdateStationAcceptance(st, false); @@ -1444,10 +1444,10 @@ static int32 RemoveRoadStop(Station *st, uint32 flags, TileIndex tile) if (is_truck) { // truck stop primary_stop = &st->truck_stops; - cur_stop = GetRoadStopByTile(tile, RS_TRUCK); + cur_stop = GetRoadStopByTile(tile, RoadStop::TRUCK); } else { primary_stop = &st->bus_stops; - cur_stop = GetRoadStopByTile(tile, RS_BUS); + cur_stop = GetRoadStopByTile(tile, RoadStop::BUS); } assert(cur_stop != NULL); diff --git a/src/station_map.h b/src/station_map.h index c52769b14..460df15f8 100644 --- a/src/station_map.h +++ b/src/station_map.h @@ -75,10 +75,10 @@ typedef enum StationType { StationType GetStationType(TileIndex); -static inline RoadStopType GetRoadStopType(TileIndex t) +static inline RoadStop::Type GetRoadStopType(TileIndex t) { assert(GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS); - return GetStationType(t) == STATION_TRUCK ? RS_TRUCK : RS_BUS; + return GetStationType(t) == STATION_TRUCK ? RoadStop::TRUCK : RoadStop::BUS; } static inline StationGfx GetStationGfx(TileIndex t) @@ -275,9 +275,9 @@ static inline void MakeRailStation(TileIndex t, Owner o, StationID sid, Axis a, SetRailType(t, rt); } -static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, DiagDirection d) +static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, DiagDirection d) { - MakeStation(t, o, sid, (rst == RS_BUS ? GFX_BUS_BASE : GFX_TRUCK_BASE) + d); + MakeStation(t, o, sid, (rst == RoadStop::BUS ? GFX_BUS_BASE : GFX_TRUCK_BASE) + d); } static inline void MakeAirport(TileIndex t, Owner o, StationID sid, byte section) |