Changeset - r14218:a6f34e5b981d
[Not reviewed]
master
0 12 0
rubidium - 15 years ago 2010-01-11 18:34:02
rubidium@openttd.org
(svn r18779) -Codechange: merge the command callbacks of the primary vehicles; they are identical
12 files changed with 48 insertions and 115 deletions:
0 comments (0 inline, 0 general)
src/aircraft.h
Show inline comments
 
@@ -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
 
 */
src/aircraft_gui.cpp
Show inline comments
 
@@ -102,23 +102,3 @@ void DrawAircraftImage(const Vehicle *v,
 
		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);
 
	}
 
}
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -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;
src/callback_table.cpp
Show inline comments
 
@@ -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);
src/command_func.h
Show inline comments
 
@@ -107,4 +107,6 @@ static inline DoCommandFlag CommandFlags
 
	return flags;
 
}
 

	
 
CommandCallback CcBuildPrimaryVehicle;
 

	
 
#endif /* COMMAND_FUNC_H */
src/roadveh.h
Show inline comments
 
@@ -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 */
src/roadveh_gui.cpp
Show inline comments
 
@@ -154,17 +154,3 @@ void DrawRoadVehImage(const Vehicle *v, 
 
		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);
 
}
src/ship.h
Show inline comments
 
@@ -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);
 

	
src/ship_gui.cpp
Show inline comments
 
@@ -46,19 +46,6 @@ void DrawShipImage(const Vehicle *v, int
 
	}
 
}
 

	
 
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
 
 *
src/train.h
Show inline comments
 
@@ -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);
src/train_gui.cpp
Show inline comments
 
@@ -47,18 +47,6 @@ void CcBuildWagon(bool success, TileInde
 
	}
 
}
 

	
 
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
src/vehicle_gui.cpp
Show inline comments
 
@@ -2141,3 +2141,23 @@ void StopGlobalFollowVehicle(const Vehic
 
		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);
 
}
0 comments (0 inline, 0 general)