mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r18779) -Codechange: merge the command callbacks of the primary vehicles; they are identical
This commit is contained in:
parent
de878fad31
commit
833c6f36f3
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -107,4 +107,6 @@ static inline DoCommandFlag CommandFlagsToDCFlags(uint cmd_flags)
|
|||
return flags;
|
||||
}
|
||||
|
||||
CommandCallback CcBuildPrimaryVehicle;
|
||||
|
||||
#endif /* COMMAND_FUNC_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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue