(svn r12880) [NoAI] -Add: introduces ai_types.hpp, which has all NNNId like VehicleID. This simplifies the include-mess, and avoids including tons of _type.h for just a single typedef.
-Note: this is perfectly safe; when a type changes, any sane compiler starts complaining about redefining the typedef to an other type
--- a/projects/openttd_vs80.vcproj Thu Apr 24 23:29:01 2008 +0000
+++ b/projects/openttd_vs80.vcproj Thu Apr 24 23:39:18 2008 +0000
@@ -2356,11 +2356,15 @@
>
</File>
<File
+ RelativePath=".\..\src\ai\api\ai_transactionmode.hpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\ai\api\ai_tunnel.hpp"
>
</File>
<File
- RelativePath=".\..\src\ai\api\ai_transactionmode.hpp"
+ RelativePath=".\..\src\ai\api\ai_types.hpp"
>
</File>
<File
@@ -2516,14 +2520,14 @@
>
</File>
<File
+ RelativePath=".\..\src\ai\api\ai_transactionmode.cpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\ai\api\ai_tunnel.cpp"
>
</File>
<File
- RelativePath=".\..\src\ai\api\ai_transactionmode.cpp"
- >
- </File>
- <File
RelativePath=".\..\src\ai\api\ai_vehicle.cpp"
>
</File>
--- a/projects/openttd_vs90.vcproj Thu Apr 24 23:29:01 2008 +0000
+++ b/projects/openttd_vs90.vcproj Thu Apr 24 23:39:18 2008 +0000
@@ -2353,11 +2353,15 @@
>
</File>
<File
+ RelativePath=".\..\src\ai\api\ai_transactionmode.hpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\ai\api\ai_tunnel.hpp"
>
</File>
<File
- RelativePath=".\..\src\ai\api\ai_transactionmode.hpp"
+ RelativePath=".\..\src\ai\api\ai_types.hpp"
>
</File>
<File
@@ -2513,14 +2517,14 @@
>
</File>
<File
+ RelativePath=".\..\src\ai\api\ai_transactionmode.cpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\ai\api\ai_tunnel.cpp"
>
</File>
<File
- RelativePath=".\..\src\ai\api\ai_transactionmode.cpp"
- >
- </File>
- <File
RelativePath=".\..\src\ai\api\ai_vehicle.cpp"
>
</File>
--- a/source.list Thu Apr 24 23:29:01 2008 +0000
+++ b/source.list Thu Apr 24 23:39:18 2008 +0000
@@ -532,8 +532,9 @@
ai/api/ai_tilelist.hpp
ai/api/ai_town.hpp
ai/api/ai_townlist.hpp
+ai/api/ai_transactionmode.hpp
ai/api/ai_tunnel.hpp
-ai/api/ai_transactionmode.hpp
+ai/api/ai_types.hpp
ai/api/ai_vehicle.hpp
ai/api/ai_vehiclelist.hpp
@@ -573,8 +574,8 @@
ai/api/ai_tilelist.cpp
ai/api/ai_town.cpp
ai/api/ai_townlist.cpp
+ai/api/ai_transactionmode.cpp
ai/api/ai_tunnel.cpp
-ai/api/ai_transactionmode.cpp
ai/api/ai_vehicle.cpp
ai/api/ai_vehiclelist.cpp
#end
--- a/src/ai/api/ai_bridge.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_bridge.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -3,7 +3,7 @@
/** @file ai_bridge.cpp Implementation of AIBridge. */
#include "ai_bridge.hpp"
-#include "../../bridge.h"
+#include "../../openttd.h"
#include "../../bridge_map.h"
#include "../../strings_func.h"
#include "../../core/alloc_func.hpp"
--- a/src/ai/api/ai_bridge.hpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_bridge.hpp Thu Apr 24 23:39:18 2008 +0000
@@ -8,7 +8,6 @@
#include "ai_object.hpp"
#include "ai_vehicle.hpp"
#include "ai_error.hpp"
-#include "../../bridge.h"
/** In OpenTTD Core 'BridgeID' is called 'BridgeType', so map it to make this API more logic. */
typedef BridgeType BridgeID;
--- a/src/ai/api/ai_bridgelist.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_bridgelist.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -3,6 +3,7 @@
/** @file ai_bridgelist.cpp Implementation of AIBridgeList and friends. */
#include "ai_bridgelist.hpp"
+#include "../../openttd.h"
#include "../../bridge.h"
#include "../../date_func.h"
--- a/src/ai/api/ai_cargo.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_cargo.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -3,6 +3,7 @@
/** @file ai_cargo.cpp Implementation of AICargo. */
#include "ai_cargo.hpp"
+#include "../../openttd.h"
#include "../../cargotype.h"
#include "../../economy_func.h"
#include "../../core/alloc_func.hpp"
--- a/src/ai/api/ai_cargolist.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_cargolist.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -3,6 +3,7 @@
/** @file ai_cargolist.cpp Implementation of AICargoList and friends. */
#include "ai_cargolist.hpp"
+#include "../../openttd.h"
#include "../../cargotype.h"
AICargoList::AICargoList()
--- a/src/ai/api/ai_company.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_company.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -4,6 +4,7 @@
#include "ai_company.hpp"
#include "ai_error.hpp"
+#include "../../openttd.h"
#include "../../command_func.h"
#include "../../player_func.h"
#include "../../player_base.h"
--- a/src/ai/api/ai_engine.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_engine.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -4,13 +4,13 @@
#include "ai_engine.hpp"
#include "ai_cargo.hpp"
+#include "../../openttd.h"
#include "../../player_func.h"
#include "../../strings_func.h"
#include "../../roadveh.h"
#include "../../train.h"
#include "../../ship.h"
#include "../../aircraft.h"
-#include "../../cargotype.h"
#include "../../vehicle_func.h"
#include "../../core/alloc_func.hpp"
#include "../../economy_func.h"
--- a/src/ai/api/ai_event_types.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_event_types.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -3,6 +3,8 @@
/** @file ai_event_types.cpp Implementation of all EventTypes. */
#include "ai_event_types.hpp"
+#include "../../openttd.h"
+#include "../../core/alloc_func.hpp"
#include "../../strings_func.h"
#include "../../roadveh.h"
#include "../../train.h"
--- a/src/ai/api/ai_execmode.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_execmode.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -3,6 +3,7 @@
/** @file ai_execmode.cpp Implementation of AIExecMode. */
#include "ai_execmode.hpp"
+#include "../../command_type.h"
bool AIExecMode::ModeProc(TileIndex tile, uint32 p1, uint32 p2, uint procc, CommandCost costs)
{
--- a/src/ai/api/ai_industry.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_industry.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -5,7 +5,9 @@
#include "ai_industry.hpp"
#include "ai_cargo.hpp"
#include "ai_map.hpp"
+#include "../../openttd.h"
#include "../../industry.h"
+#include "../../tile_type.h"
#include "../../strings_func.h"
#include "table/strings.h"
--- a/src/ai/api/ai_industry.hpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_industry.hpp Thu Apr 24 23:39:18 2008 +0000
@@ -6,7 +6,6 @@
#define AI_INDUSTRY_HPP
#include "ai_object.hpp"
-#include "../../industry.h"
/**
* Class that handles all industry related functions.
--- a/src/ai/api/ai_industrylist.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_industrylist.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -3,6 +3,7 @@
/** @file ai_industrylist.cpp Implementation of AIIndustryList and friends. */
#include "ai_industrylist.hpp"
+#include "../../openttd.h"
#include "../../industry.h"
AIIndustryList::AIIndustryList()
--- a/src/ai/api/ai_map.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_map.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -3,7 +3,6 @@
/** @file ai_map.cpp Implementation of AIMap. */
#include "ai_map.hpp"
-#include "../../command_type.h"
#include "../../map_func.h"
#include "../../tile_map.h"
--- a/src/ai/api/ai_marine.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_marine.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -3,6 +3,7 @@
/** @file ai_marine.cpp Implementation of AIMarine. */
#include "ai_marine.hpp"
+#include "../../openttd.h"
#include "../../command_type.h"
#include "../../variables.h"
#include "../../station_map.h"
--- a/src/ai/api/ai_object.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_object.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -6,6 +6,7 @@
#include "ai_log.hpp"
#include "ai_error.hpp"
#include "table/strings.h"
+#include "../../openttd.h"
#include "../../command_func.h"
#include "../../network/network.h"
#include "../../player_func.h"
@@ -14,6 +15,19 @@
#include "../ai.h"
#include "../ai_threads.h"
+struct AIObject::AIDoCommandStruct {
+ AIModeProc *mode;
+ AIObject *mode_instance;
+ uint delay;
+ CommandCost costs;
+ uint last_error;
+ bool last_command_res;
+ VehicleID new_vehicle_id;
+ SignID new_sign_id;
+ void *event_data;
+ void *log_data;
+};
+
void AIObject::SetDoCommandDelay(uint ticks)
{
assert(ticks > 0);
--- a/src/ai/api/ai_object.hpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_object.hpp Thu Apr 24 23:39:18 2008 +0000
@@ -6,21 +6,9 @@
#define AI_OBJECT_HPP
#include "../../stdafx.h"
-#include "../../openttd.h"
#include "../../misc/countedptr.hpp"
-#include "../../signs_type.h"
-#include "../../strings_type.h"
-#include "../../command_type.h"
-#include "../../vehicle_type.h"
-#include "../../tile_type.h"
-#include "../../player_type.h"
-#ifndef _SQUIRREL_H_
-/* Life becomes easier when we can tell about a function it needs the VM, but
- * without really including 'squirrel.h'. */
-typedef void *HSQUIRRELVM;
-typedef int SQInteger;
-#endif
+#include "ai_types.hpp"
/**
* The type (an alias) for all errors the AI API knows.
@@ -40,18 +28,7 @@
*/
class AIObject : public SimpleCountedObject {
private:
- struct AIDoCommandStruct {
- AIModeProc *mode;
- AIObject *mode_instance;
- uint delay;
- CommandCost costs;
- uint last_error;
- bool last_command_res;
- VehicleID new_vehicle_id;
- SignID new_sign_id;
- void *event_data;
- void *log_data;
- };
+ struct AIDoCommandStruct;
/**
* The current mode of the AI players.
--- a/src/ai/api/ai_order.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_order.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -5,7 +5,7 @@
#include "ai_order.hpp"
#include "ai_map.hpp"
#include "ai_vehicle.hpp"
-#include "../../command_type.h"
+#include "../../openttd.h"
#include "../../vehicle_base.h"
#include "../../depot_base.h"
#include "../../landscape.h"
--- a/src/ai/api/ai_road.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_road.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -3,6 +3,7 @@
/** @file ai_road.cpp Implementation of AIRoad. */
#include "ai_road.hpp"
+#include "../../openttd.h"
#include "../../road_map.h"
#include "../../station_map.h"
--- a/src/ai/api/ai_sign.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_sign.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -4,6 +4,7 @@
#include "ai_sign.hpp"
#include "table/strings.h"
+#include "../../openttd.h"
#include "../../command_func.h"
#include "../../core/alloc_func.hpp"
#include "../../signs_base.h"
--- a/src/ai/api/ai_station.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_station.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -5,6 +5,7 @@
#include "ai_station.hpp"
#include "ai_cargo.hpp"
#include "ai_map.hpp"
+#include "../../openttd.h"
#include "../../debug.h"
#include "../../station_map.h"
#include "../../variables.h"
--- a/src/ai/api/ai_station.hpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_station.hpp Thu Apr 24 23:39:18 2008 +0000
@@ -7,7 +7,6 @@
#include "ai_object.hpp"
#include "ai_error.hpp"
-#include "../../station_type.h"
/**
* Class that handles all station related functions.
--- a/src/ai/api/ai_stationlist.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_stationlist.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -4,6 +4,7 @@
#include "ai_stationlist.hpp"
#include "ai_vehicle.hpp"
+#include "../../openttd.h"
#include "../../player_func.h"
#include "../../station_base.h"
#include "../../vehicle_base.h"
--- a/src/ai/api/ai_testmode.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_testmode.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -3,6 +3,7 @@
/** @file ai_testmode.cpp Implementation of AITestMode. */
#include "ai_testmode.hpp"
+#include "../../command_type.h"
bool AITestMode::ModeProc(TileIndex tile, uint32 p1, uint32 p2, uint procc, CommandCost costs)
{
--- a/src/ai/api/ai_tile.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_tile.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -4,6 +4,7 @@
#include "ai_tile.hpp"
#include "ai_map.hpp"
+#include "../../openttd.h"
#include "../../tile_map.h"
#include "../../map_func.h"
#include "../../variables.h"
--- a/src/ai/api/ai_tilelist.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_tilelist.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -4,7 +4,7 @@
#include "ai_tilelist.hpp"
#include "ai_industry.hpp"
-
+#include "../../openttd.h"
#include "../../landscape.h"
#include "../../settings_type.h"
#include "../../station_func.h"
--- a/src/ai/api/ai_tilelist.hpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_tilelist.hpp Thu Apr 24 23:39:18 2008 +0000
@@ -6,7 +6,6 @@
#define AI_TILELIST_HPP
#include "ai_abstractlist.hpp"
-#include "../../industry.h"
/**
* Creates an empty list, in which you can add tiles.
--- a/src/ai/api/ai_town.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_town.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -4,9 +4,9 @@
#include "ai_town.hpp"
#include "ai_map.hpp"
+#include "../../openttd.h"
#include "../../town.h"
#include "../../strings_func.h"
-#include "../../town_type.h"
#include "../../core/alloc_func.hpp"
#include "table/strings.h"
--- a/src/ai/api/ai_town.hpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_town.hpp Thu Apr 24 23:39:18 2008 +0000
@@ -6,7 +6,6 @@
#define AI_TOWN_HPP
#include "ai_object.hpp"
-#include "../../town_type.h"
/**
* Class that handles all town related functions.
--- a/src/ai/api/ai_townlist.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_townlist.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -3,6 +3,7 @@
/** @file ai_townlist.cpp Implementation of AITownList and friends. */
#include "ai_townlist.hpp"
+#include "../../openttd.h"
#include "../../town.h"
AITownList::AITownList()
--- a/src/ai/api/ai_transactionmode.hpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_transactionmode.hpp Thu Apr 24 23:39:18 2008 +0000
@@ -6,6 +6,7 @@
#define AI_TRANSACTIONMODE_HPP
#include "ai_object.hpp"
+#include "../../command_type.h"
#include <queue>
/**
--- a/src/ai/api/ai_tunnel.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_tunnel.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -4,6 +4,7 @@
#include "ai_tunnel.hpp"
#include "ai_map.hpp"
+#include "../../openttd.h"
#include "../../landscape.h"
#include "../../tunnel_map.h"
#include "../../road_type.h"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ai/api/ai_types.hpp Thu Apr 24 23:39:18 2008 +0000
@@ -0,0 +1,32 @@
+/* $Id$ */
+
+/** @file ai_types.hpp Defines all the types of the game, like VehicleID, .... */
+
+#ifndef AI_TYPES_HPP
+#define AI_TYPES_HPP
+
+#include "../../core/overflowsafe_type.hpp"
+#include "../../player_type.h"
+
+/* Define all types here, so we don't have to include the whole _type.h maze */
+typedef uint BridgeType;
+typedef byte CargoID;
+class CommandCost;
+typedef uint16 EngineID;
+typedef uint16 IndustryID;
+typedef OverflowSafeInt64 Money;
+typedef uint16 SignID;
+typedef uint16 StationID;
+typedef uint16 StringID;
+typedef uint32 TileIndex;
+typedef uint16 TownID;
+typedef uint16 VehicleID;
+
+#ifndef _SQUIRREL_H_
+/* Life becomes easier when we can tell about a function it needs the VM, but
+ * without really including 'squirrel.h'. */
+typedef void *HSQUIRRELVM;
+typedef int SQInteger;
+#endif
+
+#endif /* AI_TYPES_HPP */
--- a/src/ai/api/ai_vehicle.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_vehicle.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -6,12 +6,12 @@
#include "ai_engine.hpp"
#include "ai_cargo.hpp"
#include "ai_order.hpp"
+#include "../../openttd.h"
#include "../../player_func.h"
#include "../../aircraft.h"
#include "../../string_func.h"
#include "../../strings_func.h"
#include "../../core/alloc_func.hpp"
-#include "../../command_type.h"
#include "../../command_func.h"
#include "table/strings.h"
--- a/src/ai/api/ai_vehicle.hpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_vehicle.hpp Thu Apr 24 23:39:18 2008 +0000
@@ -7,7 +7,6 @@
#include "ai_object.hpp"
#include "ai_error.hpp"
-#include "../../engine_type.h"
/**
* Class that handles all vehicle related functions.
--- a/src/ai/api/ai_vehiclelist.cpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_vehiclelist.cpp Thu Apr 24 23:39:18 2008 +0000
@@ -4,6 +4,7 @@
#include "ai_vehiclelist.hpp"
#include "ai_station.hpp"
+#include "../../openttd.h"
#include "../../player_func.h"
#include "../../vehicle_base.h"
--- a/src/ai/api/ai_vehiclelist.hpp Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/ai_vehiclelist.hpp Thu Apr 24 23:39:18 2008 +0000
@@ -6,7 +6,6 @@
#define AI_VEHICLELIST_HPP
#include "ai_abstractlist.hpp"
-#include "../../station_type.h"
/**
* Creates a list of vehicles of which you are the owner.
--- a/src/ai/api/squirrel_export.sh Thu Apr 24 23:29:01 2008 +0000
+++ b/src/ai/api/squirrel_export.sh Thu Apr 24 23:39:18 2008 +0000
@@ -6,7 +6,7 @@
for f in `ls *.hpp`; do
case "${f}" in
# these files should not be changed by this script
- "ai_controller.hpp" | "ai_object.hpp") continue;
+ "ai_controller.hpp" | "ai_object.hpp" | "ai_types.hpp" ) continue;
esac
awk -f squirrel_export.awk ${f} > ${f}.tmp
if ! [ -f "${f}.sq" ] || [ -n "`diff -I '$Id' -b ${f}.tmp ${f}.sq 2> /dev/null || echo boo`" ]; then