diff options
author | rubidium <rubidium@openttd.org> | 2007-08-26 21:21:59 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-08-26 21:21:59 +0000 |
commit | 3c919e36a7408b681f9ff7b4a1e5fe6a4d75fe1e (patch) | |
tree | 285ea97aaef2e294fbb6fc9955cd0062ce164eb3 | |
parent | a5b32d8d7238ae769a9dc3bcc71aaaba213058b9 (diff) | |
download | openttd-3c919e36a7408b681f9ff7b4a1e5fe6a4d75fe1e.tar.xz |
(svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
-rw-r--r-- | src/aircraft.h | 9 | ||||
-rw-r--r-- | src/aircraft_gui.cpp | 14 | ||||
-rw-r--r-- | src/callback_table.cpp | 14 | ||||
-rw-r--r-- | src/depot_gui.cpp | 18 | ||||
-rw-r--r-- | src/roadveh.h | 1 | ||||
-rw-r--r-- | src/roadveh_gui.cpp | 7 | ||||
-rw-r--r-- | src/ship.h | 1 | ||||
-rw-r--r-- | src/ship_gui.cpp | 7 | ||||
-rw-r--r-- | src/train.h | 1 | ||||
-rw-r--r-- | src/train_gui.cpp | 7 | ||||
-rw-r--r-- | src/vehicle.h | 2 |
11 files changed, 23 insertions, 58 deletions
diff --git a/src/aircraft.h b/src/aircraft.h index 8c132ac02..1af9942ad 100644 --- a/src/aircraft.h +++ b/src/aircraft.h @@ -82,15 +82,6 @@ uint16 AircraftDefaultCargoCapacity(CargoID cid, const AircraftVehicleInfo *avi) */ 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 */ diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp index 20828d67c..b90ddb3f1 100644 --- a/src/aircraft_gui.cpp +++ b/src/aircraft_gui.cpp @@ -57,18 +57,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) -{ - if (success) ShowAircraftViewWindow(GetVehicle(_new_vehicle_id)); -} - static void AircraftDetailsWndProc(Window *w, WindowEvent *e) { switch (e->event) { @@ -343,7 +331,7 @@ static void AircraftViewWndProc(Window *w, WindowEvent *e) 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; diff --git a/src/callback_table.cpp b/src/callback_table.cpp index 21bd39a4c..7146478bf 100644 --- a/src/callback_table.cpp +++ b/src/callback_table.cpp @@ -13,7 +13,6 @@ /* aircraft_gui.cpp */ CommandCallback CcBuildAircraft; -CommandCallback CcCloneAircraft; /* airport_gui.cpp */ CommandCallback CcBuildAirport; @@ -48,16 +47,13 @@ CommandCallback CcRoadDepot; /* 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 @@ CommandCallback *_callback_table[] = { /* 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); diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index fda51d5a8..dc90e50de 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -130,14 +130,24 @@ static const WindowDesc _aircraft_depot_desc = { 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(); } } diff --git a/src/roadveh.h b/src/roadveh.h index 8764d8125..8547a2610 100644 --- a/src/roadveh.h +++ b/src/roadveh.h @@ -56,7 +56,6 @@ static inline bool IsRoadVehInDepotStopped(const Vehicle *v) } void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2); -void CcCloneRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2); /** diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp index f885df017..d301a482e 100644 --- a/src/roadveh_gui.cpp +++ b/src/roadveh_gui.cpp @@ -263,11 +263,6 @@ static void ShowRoadVehDetailsWindow(const Vehicle *v) 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 @@ static void RoadVehViewWndProc(Window *w, WindowEvent *e) 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); diff --git a/src/ship.h b/src/ship.h index d60a4521d..cd7b4c3c1 100644 --- a/src/ship.h +++ b/src/ship.h @@ -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); diff --git a/src/ship_gui.cpp b/src/ship_gui.cpp index 44497a08f..d1e64d39a 100644 --- a/src/ship_gui.cpp +++ b/src/ship_gui.cpp @@ -187,11 +187,6 @@ void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2) 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 @@ static void ShipViewWndProc(Window *w, WindowEvent *e) 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; diff --git a/src/train.h b/src/train.h index f33803781..db9aa5b2d 100644 --- a/src/train.h +++ b/src/train.h @@ -245,7 +245,6 @@ uint CountArticulatedParts(EngineID engine_type); 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); diff --git a/src/train_gui.cpp b/src/train_gui.cpp index b61c1c598..378d874ad 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -59,11 +59,6 @@ void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2) 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 @@ static void TrainViewWndProc(Window *w, WindowEvent *e) 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; diff --git a/src/vehicle.h b/src/vehicle.h index cb0c78809..f036a2e8d 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -572,6 +572,8 @@ void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g); 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 { |