(svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
--- a/src/aircraft.h Sun Aug 26 20:43:22 2007 +0000
+++ b/src/aircraft.h Sun Aug 26 21:21:59 2007 +0000
@@ -82,15 +82,6 @@
*/
void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2);
-/**
- * This is the Callback method after the cloning attempt of an aircraft
- * @param success indicates completion (or not) of the operation
- * @param tile unused
- * @param p1 unused
- * @param p2 unused
- */
-void CcCloneAircraft(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
*/
--- a/src/aircraft_gui.cpp Sun Aug 26 20:43:22 2007 +0000
+++ b/src/aircraft_gui.cpp Sun Aug 26 21:21:59 2007 +0000
@@ -57,18 +57,6 @@
}
}
-/**
- * This is the Callback method after the cloning attempt of an aircraft
- * @param success indicates completion (or not) of the operation
- * @param tile unused
- * @param p1 unused
- * @param p2 unused
- */
-void CcCloneAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2)
-{
- if (success) ShowAircraftViewWindow(GetVehicle(_new_vehicle_id));
-}
-
static void AircraftDetailsWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
@@ -343,7 +331,7 @@
break;
case 11:
/* clone vehicle */
- DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, CcCloneAircraft, CMD_CLONE_VEHICLE | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT));
+ DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, CcCloneVehicle, CMD_CLONE_VEHICLE | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT));
break;
}
} break;
--- a/src/callback_table.cpp Sun Aug 26 20:43:22 2007 +0000
+++ b/src/callback_table.cpp Sun Aug 26 21:21:59 2007 +0000
@@ -13,7 +13,6 @@
/* aircraft_gui.cpp */
CommandCallback CcBuildAircraft;
-CommandCallback CcCloneAircraft;
/* airport_gui.cpp */
CommandCallback CcBuildAirport;
@@ -48,16 +47,13 @@
/* roadveh_gui.cpp */
CommandCallback CcBuildRoadVeh;
-CommandCallback CcCloneRoadVeh;
/* ship_gui.cpp */
CommandCallback CcBuildShip;
-CommandCallback CcCloneShip;
/* train_gui.cpp */
CommandCallback CcBuildWagon;
CommandCallback CcBuildLoco;
-CommandCallback CcCloneTrain;
CommandCallback CcAI;
@@ -83,13 +79,9 @@
/* 0x12 */ CcPlaySound1E,
/* 0x13 */ CcStation,
/* 0x14 */ CcTerraform,
- /* 0x15 */ CcCloneAircraft,
- /* 0x16 */ CcCloneRoadVeh,
- /* 0x17 */ CcCloneShip,
- /* 0x18 */ CcCloneTrain,
- /* 0x19 */ CcAI,
- /* 0x1A */ CcCloneVehicle,
- /* 0x1B */ CcGiveMoney,
+ /* 0x15 */ CcAI,
+ /* 0x16 */ CcCloneVehicle,
+ /* 0x17 */ CcGiveMoney,
};
const int _callback_table_count = lengthof(_callback_table);
--- a/src/depot_gui.cpp Sun Aug 26 20:43:22 2007 +0000
+++ b/src/depot_gui.cpp Sun Aug 26 21:21:59 2007 +0000
@@ -130,14 +130,24 @@
extern int WagonLengthToPixels(int len);
+/**
+ * This is the Callback method after the cloning attempt of a vehicle
+ * @param success indicates completion (or not) of the operation
+ * @param tile unused
+ * @param p1 unused
+ * @param p2 unused
+ */
void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
if (!success) return;
+
+ Vehicle *v = GetVehicle(_new_vehicle_id);
+
switch(GetVehicle(p1)->type) {
- case VEH_TRAIN: CcCloneTrain( true, tile, p1, p2); break;
- case VEH_ROAD: CcCloneRoadVeh( true, tile, p1, p2); break;
- case VEH_SHIP: CcCloneShip( true, tile, p1, p2); break;
- case VEH_AIRCRAFT: CcCloneAircraft(true, tile, p1, p2); break;
+ case VEH_TRAIN: ShowTrainViewWindow(v); break;
+ case VEH_ROAD: ShowRoadVehViewWindow(v); break;
+ case VEH_SHIP: ShowShipViewWindow(v); break;
+ case VEH_AIRCRAFT: ShowAircraftViewWindow(v); break;
default: NOT_REACHED();
}
}
--- a/src/roadveh.h Sun Aug 26 20:43:22 2007 +0000
+++ b/src/roadveh.h Sun Aug 26 21:21:59 2007 +0000
@@ -56,7 +56,6 @@
}
void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2);
-void CcCloneRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2);
/**
--- a/src/roadveh_gui.cpp Sun Aug 26 20:43:22 2007 +0000
+++ b/src/roadveh_gui.cpp Sun Aug 26 21:21:59 2007 +0000
@@ -263,11 +263,6 @@
w->caption_color = v->owner;
}
-void CcCloneRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2)
-{
- if (success) ShowRoadVehViewWindow(GetVehicle(_new_vehicle_id));
-}
-
static void RoadVehViewWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
@@ -357,7 +352,7 @@
ShowRoadVehDetailsWindow(v);
break;
case 11: /* clone vehicle */
- DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, CcCloneRoadVeh, CMD_CLONE_VEHICLE | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE));
+ DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, CcCloneVehicle, CMD_CLONE_VEHICLE | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE));
break;
case 12: /* Refit vehicle */
ShowVehicleRefitWindow(v, INVALID_VEH_ORDER_ID);
--- a/src/ship.h Sun Aug 26 20:43:22 2007 +0000
+++ b/src/ship.h Sun Aug 26 21:21:59 2007 +0000
@@ -8,7 +8,6 @@
#include "vehicle.h"
void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2);
-void CcCloneShip(bool success, TileIndex tile, uint32 p1, uint32 p2);
void RecalcShipStuff(Vehicle *v);
void GetShipSpriteSize(EngineID engine, uint &width, uint &height);
--- a/src/ship_gui.cpp Sun Aug 26 20:43:22 2007 +0000
+++ b/src/ship_gui.cpp Sun Aug 26 21:21:59 2007 +0000
@@ -187,11 +187,6 @@
ShowShipViewWindow(v);
}
-void CcCloneShip(bool success, TileIndex tile, uint32 p1, uint32 p2)
-{
- if (success) ShowShipViewWindow(GetVehicle(_new_vehicle_id));
-}
-
static void ShipViewWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
@@ -280,7 +275,7 @@
break;
case 11: {
/* clone vehicle */
- DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, CcCloneShip, CMD_CLONE_VEHICLE | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP));
+ DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, CcCloneVehicle, CMD_CLONE_VEHICLE | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP));
} break;
}
} break;
--- a/src/train.h Sun Aug 26 20:43:22 2007 +0000
+++ b/src/train.h Sun Aug 26 21:21:59 2007 +0000
@@ -245,7 +245,6 @@
int CheckTrainInDepot(const Vehicle *v, bool needs_to_be_stopped);
void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2);
void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2);
-void CcCloneTrain(bool success, TileIndex tile, uint32 p1, uint32 p2);
byte FreightWagonMult(CargoID cargo);
--- a/src/train_gui.cpp Sun Aug 26 20:43:22 2007 +0000
+++ b/src/train_gui.cpp Sun Aug 26 21:21:59 2007 +0000
@@ -59,11 +59,6 @@
ShowTrainViewWindow(v);
}
-void CcCloneTrain(bool success, TileIndex tile, uint32 p1, uint32 p2)
-{
- if (success) ShowTrainViewWindow(GetVehicle(_new_vehicle_id));
-}
-
/**
* Get the number of pixels for the given wagon length.
* @param len Length measured in 1/8ths of a standard wagon.
@@ -268,7 +263,7 @@
ShowVehicleRefitWindow(v, INVALID_VEH_ORDER_ID);
break;
case 13:
- DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, NULL, CMD_CLONE_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE));
+ DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, CcCloneVehicle, CMD_CLONE_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE));
break;
}
} break;
--- a/src/vehicle.h Sun Aug 26 20:43:22 2007 +0000
+++ b/src/vehicle.h Sun Aug 26 21:21:59 2007 +0000
@@ -572,6 +572,8 @@
CommandCost MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs);
bool CanBuildVehicleInfrastructure(VehicleType type);
+void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2);
+
/* Flags to add to p2 for goto depot commands */
/* Note: bits 8-10 are used for VLW flags */
enum {