summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/aircraft.h9
-rw-r--r--src/aircraft_gui.cpp20
-rw-r--r--src/build_vehicle_gui.cpp9
-rw-r--r--src/callback_table.cpp60
-rw-r--r--src/command_func.h2
-rw-r--r--src/roadveh.h2
-rw-r--r--src/roadveh_gui.cpp14
-rw-r--r--src/ship.h1
-rw-r--r--src/ship_gui.cpp13
-rw-r--r--src/train.h1
-rw-r--r--src/train_gui.cpp12
-rw-r--r--src/vehicle_gui.cpp20
12 files changed, 48 insertions, 115 deletions
diff --git a/src/aircraft.h b/src/aircraft.h
index 7ad8c92ea..1f28b2ea5 100644
--- a/src/aircraft.h
+++ b/src/aircraft.h
@@ -28,15 +28,6 @@ enum AircraftSubType {
};
-/**
- * This is the Callback method after the construction attempt of an aircraft
- * @param success indicates completion (or not) of the operation
- * @param tile of depot where aircraft is built
- * @param p1 unused
- * @param p2 unused
- */
-void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2);
-
/** Handle Aircraft specific tasks when a an Aircraft enters a hangar
* @param *v Vehicle that enters the hangar
*/
diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp
index 51463522b..202a8275d 100644
--- a/src/aircraft_gui.cpp
+++ b/src/aircraft_gui.cpp
@@ -102,23 +102,3 @@ void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID s
DrawFrameRect(x - 1, y - 1, x + real_sprite->width + 1, y + real_sprite->height + (helicopter ? 5 : 0) + 1, COLOUR_WHITE, FR_BORDERONLY);
}
}
-
-/**
- * This is the Callback method after the construction attempt of an aircraft
- * @param success indicates completion (or not) of the operation
- * @param tile of depot where aircraft is built
- * @param p1 unused
- * @param p2 unused
- */
-void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2)
-{
- if (success) {
- const Vehicle *v = Vehicle::Get(_new_vehicle_id);
-
- if (v->tile == _backup_orders_tile) {
- _backup_orders_tile = 0;
- RestoreVehicleOrders(v);
- }
- ShowVehicleViewWindow(v);
- }
-}
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index 82e8c5403..a0660d4ed 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -1034,14 +1034,7 @@ struct BuildVehicleWindow : Window {
case BUILD_VEHICLE_WIDGET_BUILD: {
EngineID sel_eng = this->sel_engine;
if (sel_eng != INVALID_ENGINE) {
- CommandCallback *callback;
- switch (this->vehicle_type) {
- default: NOT_REACHED();
- case VEH_TRAIN: callback = (RailVehInfo(sel_eng)->railveh_type == RAILVEH_WAGON) ? CcBuildWagon : CcBuildLoco; break;
- case VEH_ROAD: callback = CcBuildRoadVeh; break;
- case VEH_SHIP: callback = CcBuildShip; break;
- case VEH_AIRCRAFT: callback = CcBuildAircraft; break;
- }
+ CommandCallback *callback = (this->vehicle_type == VEH_TRAIN && RailVehInfo(sel_eng)->railveh_type == RAILVEH_WAGON) ? CcBuildWagon : CcBuildPrimaryVehicle;
DoCommandP(this->window_number, sel_eng, 0, GetCmdBuildVeh(this->vehicle_type), callback);
}
break;
diff --git a/src/callback_table.cpp b/src/callback_table.cpp
index 981b305c9..ff369d076 100644
--- a/src/callback_table.cpp
+++ b/src/callback_table.cpp
@@ -17,8 +17,8 @@
* see below for the full list!
* If you don't do it, it won't work across the network!! */
-/* aircraft_gui.cpp */
-CommandCallback CcBuildAircraft;
+/* ai/ai_core.cpp */
+CommandCallback CcAI;
/* airport_gui.cpp */
CommandCallback CcBuildAirport;
@@ -33,6 +33,9 @@ CommandCallback CcBuildCanal;
/* depot_gui.cpp */
CommandCallback CcCloneVehicle;
+/* group_gui.cpp */
+CommandCallback CcCreateGroup;
+
/* main_gui.cpp */
CommandCallback CcPlaySound10;
CommandCallback CcPlaceSign;
@@ -50,53 +53,40 @@ CommandCallback CcPlaySound1D;
CommandCallback CcBuildRoadTunnel;
CommandCallback CcRoadDepot;
-/* roadveh_gui.cpp */
-CommandCallback CcBuildRoadVeh;
-
-/* ship_gui.cpp */
-CommandCallback CcBuildShip;
-
/* train_gui.cpp */
CommandCallback CcBuildWagon;
-CommandCallback CcBuildLoco;
/* town_gui.cpp */
CommandCallback CcFoundTown;
CommandCallback CcFoundRandomTown;
-/* group_gui.cpp */
-CommandCallback CcCreateGroup;
-
-/* ai/ai_core.cpp */
-CommandCallback CcAI;
+/* vehicle_gui.cpp */
+CommandCallback CcBuildPrimaryVehicle;
CommandCallback * const _callback_table[] = {
/* 0x00 */ NULL,
- /* 0x01 */ CcBuildAircraft,
+ /* 0x01 */ CcBuildPrimaryVehicle,
/* 0x02 */ CcBuildAirport,
/* 0x03 */ CcBuildBridge,
/* 0x04 */ CcBuildCanal,
/* 0x05 */ CcBuildDocks,
- /* 0x06 */ CcBuildLoco,
- /* 0x07 */ CcBuildRoadVeh,
- /* 0x08 */ CcBuildShip,
- /* 0x09 */ CcFoundTown,
- /* 0x0A */ CcBuildRoadTunnel,
- /* 0x0B */ CcBuildRailTunnel,
- /* 0x0C */ CcBuildWagon,
- /* 0x0D */ CcRoadDepot,
- /* 0x0E */ CcRailDepot,
- /* 0x0F */ CcPlaceSign,
- /* 0x10 */ CcPlaySound10,
- /* 0x11 */ CcPlaySound1D,
- /* 0x12 */ CcPlaySound1E,
- /* 0x13 */ CcStation,
- /* 0x14 */ CcTerraform,
- /* 0x15 */ CcAI,
- /* 0x16 */ CcCloneVehicle,
- /* 0x17 */ CcGiveMoney,
- /* 0x18 */ CcCreateGroup,
- /* 0x19 */ CcFoundRandomTown,
+ /* 0x06 */ CcFoundTown,
+ /* 0x07 */ CcBuildRoadTunnel,
+ /* 0x08 */ CcBuildRailTunnel,
+ /* 0x09 */ CcBuildWagon,
+ /* 0x0A */ CcRoadDepot,
+ /* 0x0B */ CcRailDepot,
+ /* 0x0C */ CcPlaceSign,
+ /* 0x0D */ CcPlaySound10,
+ /* 0x0E */ CcPlaySound1D,
+ /* 0x0F */ CcPlaySound1E,
+ /* 0x10 */ CcStation,
+ /* 0x11 */ CcTerraform,
+ /* 0x12 */ CcAI,
+ /* 0x13 */ CcCloneVehicle,
+ /* 0x14 */ CcGiveMoney,
+ /* 0x15 */ CcCreateGroup,
+ /* 0x16 */ CcFoundRandomTown,
};
const int _callback_table_count = lengthof(_callback_table);
diff --git a/src/command_func.h b/src/command_func.h
index bd0131018..5f6bf910e 100644
--- a/src/command_func.h
+++ b/src/command_func.h
@@ -107,4 +107,6 @@ static inline DoCommandFlag CommandFlagsToDCFlags(uint cmd_flags)
return flags;
}
+CommandCallback CcBuildPrimaryVehicle;
+
#endif /* COMMAND_FUNC_H */
diff --git a/src/roadveh.h b/src/roadveh.h
index 2ff51de5c..09e37b6ba 100644
--- a/src/roadveh.h
+++ b/src/roadveh.h
@@ -79,8 +79,6 @@ enum RoadVehicleSubType {
};
-void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2);
-
void RoadVehUpdateCache(RoadVehicle *v);
/** Cached oftenly queried (NewGRF) values */
diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp
index 7383cf77b..c046c5891 100644
--- a/src/roadveh_gui.cpp
+++ b/src/roadveh_gui.cpp
@@ -154,17 +154,3 @@ void DrawRoadVehImage(const Vehicle *v, int left, int right, int y, VehicleID se
DrawFrameRect((rtl ? pos : left) - 1, y - 1, (rtl ? pos : right) - 1, y + 12, COLOUR_WHITE, FR_BORDERONLY);
}
}
-
-void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2)
-{
- const Vehicle *v;
-
- if (!success) return;
-
- v = Vehicle::Get(_new_vehicle_id);
- if (v->tile == _backup_orders_tile) {
- _backup_orders_tile = 0;
- RestoreVehicleOrders(v);
- }
- ShowVehicleViewWindow(v);
-}
diff --git a/src/ship.h b/src/ship.h
index 09b876341..cc0973a75 100644
--- a/src/ship.h
+++ b/src/ship.h
@@ -17,7 +17,6 @@
#include "engine_base.h"
#include "economy_func.h"
-void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2);
void RecalcShipStuff(Vehicle *v);
void GetShipSpriteSize(EngineID engine, uint &width, uint &height);
diff --git a/src/ship_gui.cpp b/src/ship_gui.cpp
index ec426a749..34d88f2e9 100644
--- a/src/ship_gui.cpp
+++ b/src/ship_gui.cpp
@@ -46,19 +46,6 @@ void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selec
}
}
-void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2)
-{
- const Vehicle *v;
- if (!success) return;
-
- v = Vehicle::Get(_new_vehicle_id);
- if (v->tile == _backup_orders_tile) {
- _backup_orders_tile = 0;
- RestoreVehicleOrders(v);
- }
- ShowVehicleViewWindow(v);
-}
-
/**
* Draw the details for the given vehicle at the given position
*
diff --git a/src/train.h b/src/train.h
index ba8a4dcb1..d8979e29d 100644
--- a/src/train.h
+++ b/src/train.h
@@ -44,7 +44,6 @@ enum VehicleRailFlags {
VRF_TRAIN_STUCK = 8,
};
-void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2);
void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2);
byte FreightWagonMult(CargoID cargo);
diff --git a/src/train_gui.cpp b/src/train_gui.cpp
index 9efe67d51..40be8f10f 100644
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -47,18 +47,6 @@ void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)
}
}
-void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2)
-{
- if (!success) return;
-
- const Vehicle *v = Vehicle::Get(_new_vehicle_id);
- if (tile == _backup_orders_tile) {
- _backup_orders_tile = 0;
- RestoreVehicleOrders(v);
- }
- ShowVehicleViewWindow(v);
-}
-
/**
* Draws an image of a whole train
* @param v Front vehicle
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 59e92d9c9..ee42e15e8 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -2141,3 +2141,23 @@ void StopGlobalFollowVehicle(const Vehicle *v)
w->viewport->follow_vehicle = INVALID_VEHICLE;
}
}
+
+
+/**
+ * This is the Callback method after the construction attempt of a primary vehicle
+ * @param success indicates completion (or not) of the operation
+ * @param tile unused
+ * @param p1 unused
+ * @param p2 unused
+ */
+void CcBuildPrimaryVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2)
+{
+ if (!success) return;
+
+ const Vehicle *v = Vehicle::Get(_new_vehicle_id);
+ if (v->tile == _backup_orders_tile) {
+ _backup_orders_tile = 0;
+ RestoreVehicleOrders(v);
+ }
+ ShowVehicleViewWindow(v);
+}