mirror of https://github.com/OpenTTD/OpenTTD
(svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
parent
a5b32d8d72
commit
3c919e36a7
|
@ -82,15 +82,6 @@ uint16 AircraftDefaultCargoCapacity(CargoID cid, const AircraftVehicleInfo *avi)
|
||||||
*/
|
*/
|
||||||
void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
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
|
/** Handle Aircraft specific tasks when a an Aircraft enters a hangar
|
||||||
* @param *v Vehicle that enters the hangar
|
* @param *v Vehicle that enters the hangar
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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)
|
static void AircraftDetailsWndProc(Window *w, WindowEvent *e)
|
||||||
{
|
{
|
||||||
switch (e->event) {
|
switch (e->event) {
|
||||||
|
@ -343,7 +331,7 @@ static void AircraftViewWndProc(Window *w, WindowEvent *e)
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
/* clone vehicle */
|
/* 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;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
/* aircraft_gui.cpp */
|
/* aircraft_gui.cpp */
|
||||||
CommandCallback CcBuildAircraft;
|
CommandCallback CcBuildAircraft;
|
||||||
CommandCallback CcCloneAircraft;
|
|
||||||
|
|
||||||
/* airport_gui.cpp */
|
/* airport_gui.cpp */
|
||||||
CommandCallback CcBuildAirport;
|
CommandCallback CcBuildAirport;
|
||||||
|
@ -48,16 +47,13 @@ CommandCallback CcRoadDepot;
|
||||||
|
|
||||||
/* roadveh_gui.cpp */
|
/* roadveh_gui.cpp */
|
||||||
CommandCallback CcBuildRoadVeh;
|
CommandCallback CcBuildRoadVeh;
|
||||||
CommandCallback CcCloneRoadVeh;
|
|
||||||
|
|
||||||
/* ship_gui.cpp */
|
/* ship_gui.cpp */
|
||||||
CommandCallback CcBuildShip;
|
CommandCallback CcBuildShip;
|
||||||
CommandCallback CcCloneShip;
|
|
||||||
|
|
||||||
/* train_gui.cpp */
|
/* train_gui.cpp */
|
||||||
CommandCallback CcBuildWagon;
|
CommandCallback CcBuildWagon;
|
||||||
CommandCallback CcBuildLoco;
|
CommandCallback CcBuildLoco;
|
||||||
CommandCallback CcCloneTrain;
|
|
||||||
|
|
||||||
CommandCallback CcAI;
|
CommandCallback CcAI;
|
||||||
|
|
||||||
|
@ -83,13 +79,9 @@ CommandCallback *_callback_table[] = {
|
||||||
/* 0x12 */ CcPlaySound1E,
|
/* 0x12 */ CcPlaySound1E,
|
||||||
/* 0x13 */ CcStation,
|
/* 0x13 */ CcStation,
|
||||||
/* 0x14 */ CcTerraform,
|
/* 0x14 */ CcTerraform,
|
||||||
/* 0x15 */ CcCloneAircraft,
|
/* 0x15 */ CcAI,
|
||||||
/* 0x16 */ CcCloneRoadVeh,
|
/* 0x16 */ CcCloneVehicle,
|
||||||
/* 0x17 */ CcCloneShip,
|
/* 0x17 */ CcGiveMoney,
|
||||||
/* 0x18 */ CcCloneTrain,
|
|
||||||
/* 0x19 */ CcAI,
|
|
||||||
/* 0x1A */ CcCloneVehicle,
|
|
||||||
/* 0x1B */ CcGiveMoney,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const int _callback_table_count = lengthof(_callback_table);
|
const int _callback_table_count = lengthof(_callback_table);
|
||||||
|
|
|
@ -130,14 +130,24 @@ static const WindowDesc _aircraft_depot_desc = {
|
||||||
|
|
||||||
extern int WagonLengthToPixels(int len);
|
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)
|
void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
if (!success) return;
|
if (!success) return;
|
||||||
|
|
||||||
|
Vehicle *v = GetVehicle(_new_vehicle_id);
|
||||||
|
|
||||||
switch(GetVehicle(p1)->type) {
|
switch(GetVehicle(p1)->type) {
|
||||||
case VEH_TRAIN: CcCloneTrain( true, tile, p1, p2); break;
|
case VEH_TRAIN: ShowTrainViewWindow(v); break;
|
||||||
case VEH_ROAD: CcCloneRoadVeh( true, tile, p1, p2); break;
|
case VEH_ROAD: ShowRoadVehViewWindow(v); break;
|
||||||
case VEH_SHIP: CcCloneShip( true, tile, p1, p2); break;
|
case VEH_SHIP: ShowShipViewWindow(v); break;
|
||||||
case VEH_AIRCRAFT: CcCloneAircraft(true, tile, p1, p2); break;
|
case VEH_AIRCRAFT: ShowAircraftViewWindow(v); break;
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,6 @@ static inline bool IsRoadVehInDepotStopped(const Vehicle *v)
|
||||||
}
|
}
|
||||||
|
|
||||||
void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
||||||
void CcCloneRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -263,11 +263,6 @@ static void ShowRoadVehDetailsWindow(const Vehicle *v)
|
||||||
w->caption_color = v->owner;
|
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)
|
static void RoadVehViewWndProc(Window *w, WindowEvent *e)
|
||||||
{
|
{
|
||||||
switch (e->event) {
|
switch (e->event) {
|
||||||
|
@ -357,7 +352,7 @@ static void RoadVehViewWndProc(Window *w, WindowEvent *e)
|
||||||
ShowRoadVehDetailsWindow(v);
|
ShowRoadVehDetailsWindow(v);
|
||||||
break;
|
break;
|
||||||
case 11: /* clone vehicle */
|
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;
|
break;
|
||||||
case 12: /* Refit vehicle */
|
case 12: /* Refit vehicle */
|
||||||
ShowVehicleRefitWindow(v, INVALID_VEH_ORDER_ID);
|
ShowVehicleRefitWindow(v, INVALID_VEH_ORDER_ID);
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include "vehicle.h"
|
#include "vehicle.h"
|
||||||
|
|
||||||
void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
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 RecalcShipStuff(Vehicle *v);
|
||||||
void GetShipSpriteSize(EngineID engine, uint &width, uint &height);
|
void GetShipSpriteSize(EngineID engine, uint &width, uint &height);
|
||||||
|
|
||||||
|
|
|
@ -187,11 +187,6 @@ void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
ShowShipViewWindow(v);
|
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)
|
static void ShipViewWndProc(Window *w, WindowEvent *e)
|
||||||
{
|
{
|
||||||
switch (e->event) {
|
switch (e->event) {
|
||||||
|
@ -280,7 +275,7 @@ static void ShipViewWndProc(Window *w, WindowEvent *e)
|
||||||
break;
|
break;
|
||||||
case 11: {
|
case 11: {
|
||||||
/* clone vehicle */
|
/* 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;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
|
@ -245,7 +245,6 @@ uint CountArticulatedParts(EngineID engine_type);
|
||||||
int CheckTrainInDepot(const Vehicle *v, bool needs_to_be_stopped);
|
int CheckTrainInDepot(const Vehicle *v, bool needs_to_be_stopped);
|
||||||
void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
||||||
void CcBuildWagon(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);
|
byte FreightWagonMult(CargoID cargo);
|
||||||
|
|
||||||
|
|
|
@ -59,11 +59,6 @@ void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
ShowTrainViewWindow(v);
|
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.
|
* Get the number of pixels for the given wagon length.
|
||||||
* @param len Length measured in 1/8ths of a standard wagon.
|
* @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);
|
ShowVehicleRefitWindow(v, INVALID_VEH_ORDER_ID);
|
||||||
break;
|
break;
|
||||||
case 13:
|
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;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
|
@ -572,6 +572,8 @@ void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g);
|
||||||
CommandCost MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs);
|
CommandCost MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs);
|
||||||
bool CanBuildVehicleInfrastructure(VehicleType type);
|
bool CanBuildVehicleInfrastructure(VehicleType type);
|
||||||
|
|
||||||
|
void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
||||||
|
|
||||||
/* Flags to add to p2 for goto depot commands */
|
/* Flags to add to p2 for goto depot commands */
|
||||||
/* Note: bits 8-10 are used for VLW flags */
|
/* Note: bits 8-10 are used for VLW flags */
|
||||||
enum {
|
enum {
|
||||||
|
|
Loading…
Reference in New Issue