Mercurial > hg > openttd
changeset 8786:e2d4956b7251 draft
(svn r12490) -Codechange: rename engine.h to engine_func.h and remove unneeded inclusions of engine.h and/or replace them with engine_type.h.
line wrap: on
line diff
--- a/src/ai/default/default.cpp +++ b/src/ai/default/default.cpp @@ -11,7 +11,6 @@ #include "../../roadveh.h" #include "../../station_map.h" #include "../../tunnel_map.h" -#include "../../engine.h" #include "../../command_func.h" #include "../../town.h" #include "../../industry.h"
--- a/src/ai/trolly/build.cpp +++ b/src/ai/trolly/build.cpp @@ -6,7 +6,7 @@ #include "../../road_map.h" #include "../../command_func.h" #include "trolly.h" -#include "../../engine.h" +#include "../../engine_func.h" #include "../../variables.h" #include "../../bridge.h" #include "../../vehicle_func.h"
--- a/src/ai/trolly/trolly.cpp +++ b/src/ai/trolly/trolly.cpp @@ -27,7 +27,7 @@ #include "../../town.h" #include "../../industry.h" #include "../../station_base.h" -#include "../../engine.h" +#include "../../engine_func.h" #include "../../gui.h" #include "../../depot.h" #include "../../vehicle_base.h"
--- a/src/aircraft.h +++ b/src/aircraft.h @@ -8,7 +8,7 @@ #include "station_map.h" #include "station_base.h" #include "vehicle_base.h" -#include "engine.h" +#include "engine_func.h" /** An aircraft can be one ot those types */ enum AircraftSubType {
--- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -11,7 +11,6 @@ #include "station_map.h" #include "timetable.h" #include "depot.h" -#include "engine.h" #include "news_func.h" #include "aircraft.h" #include "airport.h"
--- a/src/aircraft_gui.cpp +++ b/src/aircraft_gui.cpp @@ -7,7 +7,6 @@ #include "aircraft.h" #include "debug.h" #include "gui.h" -#include "engine.h" #include "depot.h" #include "vehicle_gui.h" #include "newgrf_engine.h"
--- a/src/articulated_vehicles.cpp +++ b/src/articulated_vehicles.cpp @@ -5,7 +5,6 @@ #include "stdafx.h" #include "openttd.h" #include "articulated_vehicles.h" -#include "engine.h" #include "train.h" #include "roadveh.h" #include "newgrf_callbacks.h"
--- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -6,7 +6,6 @@ #include "ship.h" #include "news_func.h" #include "player_func.h" -#include "engine.h" #include "debug.h" #include "vehicle_gui.h" #include "depot.h"
--- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -19,6 +19,7 @@ #include "gfx_func.h" #include "player_func.h" #include "widgets/dropdown_func.h" +#include "engine_func.h" #include "table/sprites.h" #include "table/strings.h"
--- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -13,7 +13,6 @@ #include "articulated_vehicles.h" #include "textbuf_gui.h" #include "command_func.h" -#include "engine.h" #include "player_func.h" #include "depot.h" #include "airport.h"
--- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -6,7 +6,7 @@ #include "openttd.h" #include "console.h" #include "debug.h" -#include "engine.h" +#include "engine_func.h" #include "landscape.h" #include "saveload.h" #include "variables.h" @@ -18,7 +18,6 @@ #include "settings_func.h" #include "fios.h" #include "fileio.h" -#include "station.h" #include "screenshot.h" #include "genworld.h" #include "network/network.h"
--- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -5,7 +5,7 @@ #include "stdafx.h" #include "openttd.h" #include "tile_map.h" -#include "station.h" +#include "station_type.h" #include "gui.h" #include "terraform_gui.h" #include "window_gui.h"
--- a/src/economy.cpp +++ b/src/economy.cpp @@ -14,7 +14,6 @@ #include "town.h" #include "news_func.h" #include "network/network.h" -#include "engine.h" #include "network/network_data.h" #include "variables.h" #include "vehicle_gui.h"
--- a/src/elrail.cpp +++ b/src/elrail.cpp @@ -65,6 +65,7 @@ #include "vehicle_func.h" #include "player_base.h" #include "tunnelbridge.h" +#include "engine_func.h" #include "table/sprites.h" #include "table/elrail_data.h"
--- a/src/engine.cpp +++ b/src/engine.cpp @@ -5,7 +5,6 @@ #include "stdafx.h" #include "openttd.h" #include "debug.h" -#include "engine.h" #include "player_base.h" #include "player_func.h" #include "command_func.h"
deleted file mode 100644 --- a/src/engine.h +++ /dev/null @@ -1,113 +0,0 @@ -/* $Id$ */ - -/** @file engine.h */ - -#ifndef ENGINE_H -#define ENGINE_H - -#include "engine_type.h" - -void SetupEngines(); -void StartupEngines(); - - -void DrawTrainEngine(int x, int y, EngineID engine, SpriteID pal); -void DrawRoadVehEngine(int x, int y, EngineID engine, SpriteID pal); -void DrawShipEngine(int x, int y, EngineID engine, SpriteID pal); -void DrawAircraftEngine(int x, int y, EngineID engine, SpriteID pal); - -void LoadCustomEngineNames(); -void DeleteCustomEngineNames(); - -bool IsEngineBuildable(EngineID engine, VehicleType type, PlayerID player); -CargoID GetEngineCargoType(EngineID engine); - -static inline EngineID GetFirstEngineOfType(VehicleType type) -{ - const EngineID start[] = {0, ROAD_ENGINES_INDEX, SHIP_ENGINES_INDEX, AIRCRAFT_ENGINES_INDEX}; - - return start[type]; -} - -static inline EngineID GetLastEngineOfType(VehicleType type) -{ - const EngineID end[] = { - NUM_TRAIN_ENGINES, - ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES, - SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES, - AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES}; - - return end[type]; -} - -extern Engine _engines[TOTAL_NUM_ENGINES]; -#define FOR_ALL_ENGINES(e) for (e = _engines; e != endof(_engines); e++) -#define FOR_ALL_ENGINEIDS_OF_TYPE(e, type) for (e = GetFirstEngineOfType(type); e != GetLastEngineOfType(type); e++) - - -static inline Engine* GetEngine(EngineID i) -{ - assert(i < lengthof(_engines)); - return &_engines[i]; -} - -static inline bool IsEngineIndex(uint index) -{ - return index < TOTAL_NUM_ENGINES; -} - -/* Access Vehicle Data */ -extern const EngineInfo _orig_engine_info[TOTAL_NUM_ENGINES]; -extern const RailVehicleInfo _orig_rail_vehicle_info[NUM_TRAIN_ENGINES]; -extern const ShipVehicleInfo _orig_ship_vehicle_info[NUM_SHIP_ENGINES]; -extern const AircraftVehicleInfo _orig_aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES]; -extern const RoadVehicleInfo _orig_road_vehicle_info[NUM_ROAD_ENGINES]; - -extern EngineInfo _engine_info[TOTAL_NUM_ENGINES]; -extern RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES]; -extern ShipVehicleInfo _ship_vehicle_info[NUM_SHIP_ENGINES]; -extern AircraftVehicleInfo _aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES]; -extern RoadVehicleInfo _road_vehicle_info[NUM_ROAD_ENGINES]; - -static inline const EngineInfo *EngInfo(EngineID e) -{ - assert(e < lengthof(_engine_info)); - return &_engine_info[e]; -} - -static inline const RailVehicleInfo* RailVehInfo(EngineID e) -{ - assert(e < lengthof(_rail_vehicle_info)); - return &_rail_vehicle_info[e]; -} - -static inline const ShipVehicleInfo* ShipVehInfo(EngineID e) -{ - assert(e >= SHIP_ENGINES_INDEX && e < SHIP_ENGINES_INDEX + lengthof(_ship_vehicle_info)); - return &_ship_vehicle_info[e - SHIP_ENGINES_INDEX]; -} - -static inline const AircraftVehicleInfo* AircraftVehInfo(EngineID e) -{ - assert(e >= AIRCRAFT_ENGINES_INDEX && e < AIRCRAFT_ENGINES_INDEX + lengthof(_aircraft_vehicle_info)); - return &_aircraft_vehicle_info[e - AIRCRAFT_ENGINES_INDEX]; -} - -static inline const RoadVehicleInfo* RoadVehInfo(EngineID e) -{ - assert(e >= ROAD_ENGINES_INDEX && e < ROAD_ENGINES_INDEX + lengthof(_road_vehicle_info)); - return &_road_vehicle_info[e - ROAD_ENGINES_INDEX]; -} - -/* Engine list manipulators - current implementation is only C wrapper of CBlobT<EngineID> class (helpers.cpp) */ -void EngList_Create(EngineList *el); ///< Creates engine list -void EngList_Destroy(EngineList *el); ///< Deallocate and destroy engine list -uint EngList_Count(const EngineList *el); ///< Returns number of items in the engine list -void EngList_Add(EngineList *el, EngineID eid); ///< Append one item at the end of engine list -EngineID* EngList_Items(EngineList *el); ///< Returns engine list items as C array -void EngList_RemoveAll(EngineList *el); ///< Removes all items from engine list -typedef int CDECL EngList_SortTypeFunction(const void*, const void*); ///< argument type for EngList_Sort() -void EngList_Sort(EngineList *el, EngList_SortTypeFunction compare); ///< qsort of the engine list -void EngList_SortPartial(EngineList *el, EngList_SortTypeFunction compare, uint begin, uint num_items); ///< qsort of specified portion of the engine list - -#endif /* ENGINE_H */
new file mode 100644 --- /dev/null +++ b/src/engine_func.h @@ -0,0 +1,113 @@ +/* $Id$ */ + +/** @file engine.h */ + +#ifndef ENGINE_H +#define ENGINE_H + +#include "engine_type.h" + +void SetupEngines(); +void StartupEngines(); + + +void DrawTrainEngine(int x, int y, EngineID engine, SpriteID pal); +void DrawRoadVehEngine(int x, int y, EngineID engine, SpriteID pal); +void DrawShipEngine(int x, int y, EngineID engine, SpriteID pal); +void DrawAircraftEngine(int x, int y, EngineID engine, SpriteID pal); + +void LoadCustomEngineNames(); +void DeleteCustomEngineNames(); + +bool IsEngineBuildable(EngineID engine, VehicleType type, PlayerID player); +CargoID GetEngineCargoType(EngineID engine); + +static inline EngineID GetFirstEngineOfType(VehicleType type) +{ + const EngineID start[] = {0, ROAD_ENGINES_INDEX, SHIP_ENGINES_INDEX, AIRCRAFT_ENGINES_INDEX}; + + return start[type]; +} + +static inline EngineID GetLastEngineOfType(VehicleType type) +{ + const EngineID end[] = { + NUM_TRAIN_ENGINES, + ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES, + SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES, + AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES}; + + return end[type]; +} + +extern Engine _engines[TOTAL_NUM_ENGINES]; +#define FOR_ALL_ENGINES(e) for (e = _engines; e != endof(_engines); e++) +#define FOR_ALL_ENGINEIDS_OF_TYPE(e, type) for (e = GetFirstEngineOfType(type); e != GetLastEngineOfType(type); e++) + + +static inline Engine* GetEngine(EngineID i) +{ + assert(i < lengthof(_engines)); + return &_engines[i]; +} + +static inline bool IsEngineIndex(uint index) +{ + return index < TOTAL_NUM_ENGINES; +} + +/* Access Vehicle Data */ +extern const EngineInfo _orig_engine_info[TOTAL_NUM_ENGINES]; +extern const RailVehicleInfo _orig_rail_vehicle_info[NUM_TRAIN_ENGINES]; +extern const ShipVehicleInfo _orig_ship_vehicle_info[NUM_SHIP_ENGINES]; +extern const AircraftVehicleInfo _orig_aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES]; +extern const RoadVehicleInfo _orig_road_vehicle_info[NUM_ROAD_ENGINES]; + +extern EngineInfo _engine_info[TOTAL_NUM_ENGINES]; +extern RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES]; +extern ShipVehicleInfo _ship_vehicle_info[NUM_SHIP_ENGINES]; +extern AircraftVehicleInfo _aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES]; +extern RoadVehicleInfo _road_vehicle_info[NUM_ROAD_ENGINES]; + +static inline const EngineInfo *EngInfo(EngineID e) +{ + assert(e < lengthof(_engine_info)); + return &_engine_info[e]; +} + +static inline const RailVehicleInfo* RailVehInfo(EngineID e) +{ + assert(e < lengthof(_rail_vehicle_info)); + return &_rail_vehicle_info[e]; +} + +static inline const ShipVehicleInfo* ShipVehInfo(EngineID e) +{ + assert(e >= SHIP_ENGINES_INDEX && e < SHIP_ENGINES_INDEX + lengthof(_ship_vehicle_info)); + return &_ship_vehicle_info[e - SHIP_ENGINES_INDEX]; +} + +static inline const AircraftVehicleInfo* AircraftVehInfo(EngineID e) +{ + assert(e >= AIRCRAFT_ENGINES_INDEX && e < AIRCRAFT_ENGINES_INDEX + lengthof(_aircraft_vehicle_info)); + return &_aircraft_vehicle_info[e - AIRCRAFT_ENGINES_INDEX]; +} + +static inline const RoadVehicleInfo* RoadVehInfo(EngineID e) +{ + assert(e >= ROAD_ENGINES_INDEX && e < ROAD_ENGINES_INDEX + lengthof(_road_vehicle_info)); + return &_road_vehicle_info[e - ROAD_ENGINES_INDEX]; +} + +/* Engine list manipulators - current implementation is only C wrapper of CBlobT<EngineID> class (helpers.cpp) */ +void EngList_Create(EngineList *el); ///< Creates engine list +void EngList_Destroy(EngineList *el); ///< Deallocate and destroy engine list +uint EngList_Count(const EngineList *el); ///< Returns number of items in the engine list +void EngList_Add(EngineList *el, EngineID eid); ///< Append one item at the end of engine list +EngineID* EngList_Items(EngineList *el); ///< Returns engine list items as C array +void EngList_RemoveAll(EngineList *el); ///< Removes all items from engine list +typedef int CDECL EngList_SortTypeFunction(const void*, const void*); ///< argument type for EngList_Sort() +void EngList_Sort(EngineList *el, EngList_SortTypeFunction compare); ///< qsort of the engine list +void EngList_SortPartial(EngineList *el, EngList_SortTypeFunction compare, uint begin, uint num_items); ///< qsort of specified portion of the engine list + +#endif /* ENGINE_H */
--- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -7,7 +7,7 @@ #include "gui.h" #include "window_gui.h" #include "gfx_func.h" -#include "engine.h" +#include "engine_func.h" #include "command_func.h" #include "economy_func.h" #include "news_func.h"
--- a/src/genworld.cpp +++ b/src/genworld.cpp @@ -21,7 +21,7 @@ #include "map_func.h" #include "date_func.h" #include "core/random_func.hpp" -#include "engine.h" +#include "engine_func.h" #include "settings_type.h" #include "newgrf_storage.h" #include "water.h"
--- a/src/group.h +++ b/src/group.h @@ -9,7 +9,7 @@ #include "oldpool.h" #include "player_type.h" #include "vehicle_type.h" -#include "engine.h" +#include "engine_type.h" DECLARE_OLD_POOL(Group, Group, 5, 2047)
--- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -8,7 +8,6 @@ #include "window_gui.h" #include "textbuf_gui.h" #include "command_func.h" -#include "engine.h" #include "vehicle_gui.h" #include "depot.h" #include "train.h"
--- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -5,7 +5,7 @@ #include "stdafx.h" #include "openttd.h" -#include "engine.h" +#include "engine_func.h" #include <new> #include "misc/blob.hpp"
--- a/src/misc.cpp +++ b/src/misc.cpp @@ -8,7 +8,6 @@ #include "landscape.h" #include "news_func.h" #include "saveload.h" -#include "engine.h" #include "vehicle_gui.h" #include "variables.h" #include "ai/ai.h"
--- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -9,7 +9,7 @@ #include "openttd.h" #include "debug.h" #include "fileio.h" -#include "engine.h" +#include "engine_func.h" #include "spritecache.h" #include "sprite.h" #include "newgrf.h"
--- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -6,7 +6,7 @@ #include "openttd.h" #include "variables.h" #include "debug.h" -#include "engine.h" +#include "engine_func.h" #include "train.h" #include "player_func.h" #include "player_base.h"
--- a/src/newgrf_sound.cpp +++ b/src/newgrf_sound.cpp @@ -5,7 +5,7 @@ #include "stdafx.h" #include "openttd.h" #include "oldpool.h" -#include "engine.h" +#include "engine_func.h" #include "newgrf_callbacks.h" #include "newgrf_engine.h" #include "newgrf_sound.h"
--- a/src/newgrf_station.h +++ b/src/newgrf_station.h @@ -5,7 +5,7 @@ #ifndef NEWGRF_STATION_H #define NEWGRF_STATION_H -#include "engine.h" +#include "engine_type.h" #include "newgrf_callbacks.h" #include "newgrf_cargo.h" #include "tile_type.h"
--- a/src/oldloader.cpp +++ b/src/oldloader.cpp @@ -9,7 +9,6 @@ #include "industry.h" #include "player_func.h" #include "player_base.h" -#include "engine.h" #include "aircraft.h" #include "roadveh.h" #include "ship.h"
--- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -28,7 +28,6 @@ #include "town.h" #include "industry.h" #include "news_func.h" -#include "engine.h" #include "fileio.h" #include "fios.h" #include "airport.h"
--- a/src/player_base.h +++ b/src/player_base.h @@ -8,7 +8,7 @@ #include "road_type.h" #include "rail_type.h" #include "date_type.h" -#include "engine.h" +#include "engine_type.h" #include "livery.h" #include "autoreplace_type.h" #include "economy_type.h"
--- a/src/players.cpp +++ b/src/players.cpp @@ -4,7 +4,7 @@ */ #include "stdafx.h" #include "openttd.h" -#include "engine.h" +#include "engine_func.h" #include "player_func.h" #include "player_gui.h" #include "town.h" @@ -14,7 +14,6 @@ #include "network/network.h" #include "network/network_internal.h" #include "variables.h" -#include "engine.h" #include "ai/ai.h" #include "player_face.h" #include "group.h"
--- a/src/rail.cpp +++ b/src/rail.cpp @@ -13,6 +13,7 @@ #include "date_func.h" #include "player_func.h" #include "player_base.h" +#include "engine_func.h" /* XXX: Below 3 tables store duplicate data. Maybe remove some? */
--- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -17,7 +17,7 @@ #include "viewport_func.h" #include "command_func.h" #include "pathfind.h" -#include "engine.h" +#include "engine_func.h" #include "town.h" #include "sprite.h" #include "depot.h"
--- a/src/road.cpp +++ b/src/road.cpp @@ -9,7 +9,7 @@ #include "genworld.h" #include "player_func.h" #include "player_base.h" -#include "engine.h" +#include "engine_func.h" #include "settings_type.h" #include "date_func.h"
--- a/src/roadveh.h +++ b/src/roadveh.h @@ -6,7 +6,7 @@ #define ROADVEH_H #include "vehicle_base.h" -#include "engine.h" +#include "engine_func.h" #include "economy_func.h" enum RoadVehicleSubType {
--- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -11,7 +11,6 @@ #include "roadveh.h" #include "station_map.h" #include "timetable.h" -#include "engine.h" #include "command_func.h" #include "station_base.h" #include "news_func.h"
--- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -9,7 +9,7 @@ #include "window_gui.h" #include "textbuf_gui.h" #include "command_func.h" -#include "engine.h" +#include "engine_func.h" #include "screenshot.h" #include "newgrf.h" #include "network/network.h"
--- a/src/ship.h +++ b/src/ship.h @@ -6,7 +6,7 @@ #define SHIP_H #include "vehicle_base.h" -#include "engine.h" +#include "engine_func.h" #include "economy_func.h" void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2);
--- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -13,7 +13,7 @@ #include "station_map.h" #include "station_base.h" #include "news_func.h" -#include "engine.h" +#include "engine_func.h" #include "player_func.h" #include "player_base.h" #include "npf.h"
--- a/src/strings.cpp +++ b/src/strings.cpp @@ -36,6 +36,7 @@ #include "fios.h" #include "settings_type.h" #include "video/video_driver.hpp" +#include "engine_func.h" #include "table/strings.h" #include "table/control_codes.h"
--- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -17,7 +17,7 @@ #include "variables.h" #include "functions.h" #include "sound_func.h" -#include "station.h" +#include "station_base.h" #include "unmovable_map.h" #include "textbuf_gui.h" #include "genworld.h"
--- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -6,7 +6,6 @@ #include "openttd.h" #include "variables.h" #include "command_func.h" -#include "engine.h" #include "gui.h" #include "window_gui.h" #include "textbuf_gui.h"
--- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -18,7 +18,7 @@ #include "npf.h" #include "station_base.h" #include "news_func.h" -#include "engine.h" +#include "engine_func.h" #include "player_func.h" #include "player_base.h" #include "depot.h"
--- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -17,6 +17,7 @@ #include "vehicle_func.h" #include "settings_type.h" #include "order_func.h" +#include "engine_func.h" #include "table/sprites.h" #include "table/strings.h"
--- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -34,6 +34,7 @@ #include "signal_func.h" #include "tunnelbridge.h" #include "player_base.h" +#include "engine_func.h" #include "table/sprites.h" #include "table/strings.h"