mirror of https://github.com/OpenTTD/OpenTTD
(svn r18779) -Codechange: merge the command callbacks of the primary vehicles; they are identical
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
|
/** 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
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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);
|
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: {
|
case BUILD_VEHICLE_WIDGET_BUILD: {
|
||||||
EngineID sel_eng = this->sel_engine;
|
EngineID sel_eng = this->sel_engine;
|
||||||
if (sel_eng != INVALID_ENGINE) {
|
if (sel_eng != INVALID_ENGINE) {
|
||||||
CommandCallback *callback;
|
CommandCallback *callback = (this->vehicle_type == VEH_TRAIN && RailVehInfo(sel_eng)->railveh_type == RAILVEH_WAGON) ? CcBuildWagon : CcBuildPrimaryVehicle;
|
||||||
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;
|
|
||||||
}
|
|
||||||
DoCommandP(this->window_number, sel_eng, 0, GetCmdBuildVeh(this->vehicle_type), callback);
|
DoCommandP(this->window_number, sel_eng, 0, GetCmdBuildVeh(this->vehicle_type), callback);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
* see below for the full list!
|
* see below for the full list!
|
||||||
* If you don't do it, it won't work across the network!! */
|
* If you don't do it, it won't work across the network!! */
|
||||||
|
|
||||||
/* aircraft_gui.cpp */
|
/* ai/ai_core.cpp */
|
||||||
CommandCallback CcBuildAircraft;
|
CommandCallback CcAI;
|
||||||
|
|
||||||
/* airport_gui.cpp */
|
/* airport_gui.cpp */
|
||||||
CommandCallback CcBuildAirport;
|
CommandCallback CcBuildAirport;
|
||||||
|
@ -33,6 +33,9 @@ CommandCallback CcBuildCanal;
|
||||||
/* depot_gui.cpp */
|
/* depot_gui.cpp */
|
||||||
CommandCallback CcCloneVehicle;
|
CommandCallback CcCloneVehicle;
|
||||||
|
|
||||||
|
/* group_gui.cpp */
|
||||||
|
CommandCallback CcCreateGroup;
|
||||||
|
|
||||||
/* main_gui.cpp */
|
/* main_gui.cpp */
|
||||||
CommandCallback CcPlaySound10;
|
CommandCallback CcPlaySound10;
|
||||||
CommandCallback CcPlaceSign;
|
CommandCallback CcPlaceSign;
|
||||||
|
@ -50,53 +53,40 @@ CommandCallback CcPlaySound1D;
|
||||||
CommandCallback CcBuildRoadTunnel;
|
CommandCallback CcBuildRoadTunnel;
|
||||||
CommandCallback CcRoadDepot;
|
CommandCallback CcRoadDepot;
|
||||||
|
|
||||||
/* roadveh_gui.cpp */
|
|
||||||
CommandCallback CcBuildRoadVeh;
|
|
||||||
|
|
||||||
/* ship_gui.cpp */
|
|
||||||
CommandCallback CcBuildShip;
|
|
||||||
|
|
||||||
/* train_gui.cpp */
|
/* train_gui.cpp */
|
||||||
CommandCallback CcBuildWagon;
|
CommandCallback CcBuildWagon;
|
||||||
CommandCallback CcBuildLoco;
|
|
||||||
|
|
||||||
/* town_gui.cpp */
|
/* town_gui.cpp */
|
||||||
CommandCallback CcFoundTown;
|
CommandCallback CcFoundTown;
|
||||||
CommandCallback CcFoundRandomTown;
|
CommandCallback CcFoundRandomTown;
|
||||||
|
|
||||||
/* group_gui.cpp */
|
/* vehicle_gui.cpp */
|
||||||
CommandCallback CcCreateGroup;
|
CommandCallback CcBuildPrimaryVehicle;
|
||||||
|
|
||||||
/* ai/ai_core.cpp */
|
|
||||||
CommandCallback CcAI;
|
|
||||||
|
|
||||||
CommandCallback * const _callback_table[] = {
|
CommandCallback * const _callback_table[] = {
|
||||||
/* 0x00 */ NULL,
|
/* 0x00 */ NULL,
|
||||||
/* 0x01 */ CcBuildAircraft,
|
/* 0x01 */ CcBuildPrimaryVehicle,
|
||||||
/* 0x02 */ CcBuildAirport,
|
/* 0x02 */ CcBuildAirport,
|
||||||
/* 0x03 */ CcBuildBridge,
|
/* 0x03 */ CcBuildBridge,
|
||||||
/* 0x04 */ CcBuildCanal,
|
/* 0x04 */ CcBuildCanal,
|
||||||
/* 0x05 */ CcBuildDocks,
|
/* 0x05 */ CcBuildDocks,
|
||||||
/* 0x06 */ CcBuildLoco,
|
/* 0x06 */ CcFoundTown,
|
||||||
/* 0x07 */ CcBuildRoadVeh,
|
/* 0x07 */ CcBuildRoadTunnel,
|
||||||
/* 0x08 */ CcBuildShip,
|
/* 0x08 */ CcBuildRailTunnel,
|
||||||
/* 0x09 */ CcFoundTown,
|
/* 0x09 */ CcBuildWagon,
|
||||||
/* 0x0A */ CcBuildRoadTunnel,
|
/* 0x0A */ CcRoadDepot,
|
||||||
/* 0x0B */ CcBuildRailTunnel,
|
/* 0x0B */ CcRailDepot,
|
||||||
/* 0x0C */ CcBuildWagon,
|
/* 0x0C */ CcPlaceSign,
|
||||||
/* 0x0D */ CcRoadDepot,
|
/* 0x0D */ CcPlaySound10,
|
||||||
/* 0x0E */ CcRailDepot,
|
/* 0x0E */ CcPlaySound1D,
|
||||||
/* 0x0F */ CcPlaceSign,
|
/* 0x0F */ CcPlaySound1E,
|
||||||
/* 0x10 */ CcPlaySound10,
|
/* 0x10 */ CcStation,
|
||||||
/* 0x11 */ CcPlaySound1D,
|
/* 0x11 */ CcTerraform,
|
||||||
/* 0x12 */ CcPlaySound1E,
|
/* 0x12 */ CcAI,
|
||||||
/* 0x13 */ CcStation,
|
/* 0x13 */ CcCloneVehicle,
|
||||||
/* 0x14 */ CcTerraform,
|
/* 0x14 */ CcGiveMoney,
|
||||||
/* 0x15 */ CcAI,
|
/* 0x15 */ CcCreateGroup,
|
||||||
/* 0x16 */ CcCloneVehicle,
|
/* 0x16 */ CcFoundRandomTown,
|
||||||
/* 0x17 */ CcGiveMoney,
|
|
||||||
/* 0x18 */ CcCreateGroup,
|
|
||||||
/* 0x19 */ CcFoundRandomTown,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const int _callback_table_count = lengthof(_callback_table);
|
const int _callback_table_count = lengthof(_callback_table);
|
||||||
|
|
|
@ -107,4 +107,6 @@ static inline DoCommandFlag CommandFlagsToDCFlags(uint cmd_flags)
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CommandCallback CcBuildPrimaryVehicle;
|
||||||
|
|
||||||
#endif /* COMMAND_FUNC_H */
|
#endif /* COMMAND_FUNC_H */
|
||||||
|
|
|
@ -79,8 +79,6 @@ enum RoadVehicleSubType {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
|
||||||
|
|
||||||
void RoadVehUpdateCache(RoadVehicle *v);
|
void RoadVehUpdateCache(RoadVehicle *v);
|
||||||
|
|
||||||
/** Cached oftenly queried (NewGRF) values */
|
/** 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);
|
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 "engine_base.h"
|
||||||
#include "economy_func.h"
|
#include "economy_func.h"
|
||||||
|
|
||||||
void CcBuildShip(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);
|
||||||
|
|
||||||
|
|
|
@ -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
|
* Draw the details for the given vehicle at the given position
|
||||||
*
|
*
|
||||||
|
|
|
@ -44,7 +44,6 @@ enum VehicleRailFlags {
|
||||||
VRF_TRAIN_STUCK = 8,
|
VRF_TRAIN_STUCK = 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
byte FreightWagonMult(CargoID cargo);
|
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
|
* Draws an image of a whole train
|
||||||
* @param v Front vehicle
|
* @param v Front vehicle
|
||||||
|
|
|
@ -2141,3 +2141,23 @@ void StopGlobalFollowVehicle(const Vehicle *v)
|
||||||
w->viewport->follow_vehicle = INVALID_VEHICLE;
|
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