Changeset - r2662:0bfdca18c20e
[Not reviewed]
master
0 6 0
tron - 19 years ago 2005-11-16 12:52:01
tron@openttd.org
(svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection
6 files changed with 19 insertions and 36 deletions:
0 comments (0 inline, 0 general)
aircraft_cmd.c
Show inline comments
 
@@ -538,10 +538,6 @@ int32 CmdRefitAircraft(int x, int y, uin
 
	return cost;
 
}
 

	
 
void HandleClickOnAircraft(Vehicle *v)
 
{
 
	ShowAircraftViewWindow(v);
 
}
 

	
 
static void CheckIfAircraftNeedsService(Vehicle *v)
 
{
disaster_cmd.c
Show inline comments
 
@@ -690,10 +690,6 @@ void DisasterVehicle_Tick(Vehicle *v)
 
	_disastervehicle_tick_procs[v->subtype](v);
 
}
 

	
 
void HandleClickOnDisasterVeh(Vehicle *v)
 
{
 
	// not used
 
}
 

	
 
void OnNewDay_DisasterVehicle(Vehicle *v)
 
{
roadveh_cmd.c
Show inline comments
 
@@ -1733,10 +1733,6 @@ void OnNewDay_RoadVeh(Vehicle *v)
 
	InvalidateWindowClasses(WC_ROADVEH_LIST);
 
}
 

	
 
void HandleClickOnRoadVeh(Vehicle *v)
 
{
 
	ShowRoadVehViewWindow(v);
 
}
 

	
 
void RoadVehiclesYearlyLoop(void)
 
{
ship_cmd.c
Show inline comments
 
@@ -801,10 +801,6 @@ void Ship_Tick(Vehicle *v)
 
	ShipController(v);
 
}
 

	
 
void HandleClickOnShip(Vehicle *v)
 
{
 
	ShowShipViewWindow(v);
 
}
 

	
 
void ShipsYearlyLoop(void)
 
{
train_cmd.c
Show inline comments
 
@@ -3630,11 +3630,6 @@ void TrainsYearlyLoop(void)
 
	}
 
}
 

	
 
void HandleClickOnTrain(Vehicle *v)
 
{
 
	if (v->subtype != TS_Front_Engine) v = GetFirstVehicleInChain(v);
 
	ShowTrainViewWindow(v);
 
}
 

	
 
void InitializeTrains(void)
 
{
viewport.c
Show inline comments
 
@@ -4,6 +4,7 @@
 
#include "openttd.h"
 
#include "debug.h"
 
#include "functions.h"
 
#include "gui.h"
 
#include "spritecache.h"
 
#include "strings.h"
 
#include "table/sprites.h"
 
@@ -1696,25 +1697,28 @@ static void CheckClickOnLandscape(const 
 
	if (pt.x != -1) ClickTile(TileVirtXY(pt.x, pt.y));
 
}
 

	
 
void HandleClickOnTrain(Vehicle *v);
 
void HandleClickOnRoadVeh(Vehicle *v);
 
void HandleClickOnAircraft(Vehicle *v);
 
void HandleClickOnShip(Vehicle *v);
 
static void HandleClickOnSpecialVeh(Vehicle *v) {}
 
void HandleClickOnDisasterVeh(Vehicle *v);
 
typedef void OnVehicleClickProc(Vehicle *v);
 
static OnVehicleClickProc * const _on_vehicle_click_proc[6] = {
 
	HandleClickOnTrain,
 
	HandleClickOnRoadVeh,
 
	HandleClickOnShip,
 
	HandleClickOnAircraft,
 
	HandleClickOnSpecialVeh,
 
	HandleClickOnDisasterVeh,
 

	
 
static void SafeShowTrainViewWindow(const Vehicle* v)
 
{
 
  if (v->subtype != TS_Front_Engine) v = GetFirstVehicleInChain(v);
 
  ShowTrainViewWindow(v);
 
}
 

	
 
static void Nop(const Vehicle* v) {}
 

	
 
typedef void OnVehicleClickProc(const Vehicle* v);
 
static OnVehicleClickProc* const _on_vehicle_click_proc[] = {
 
	SafeShowTrainViewWindow,
 
	ShowRoadVehViewWindow,
 
	ShowShipViewWindow,
 
	ShowAircraftViewWindow,
 
	Nop, // Special vehicles
 
	Nop  // Disaster vehicles
 
};
 

	
 
void HandleViewportClicked(const ViewPort *vp, int x, int y)
 
{
 
	Vehicle* v;
 
	const Vehicle* v;
 

	
 
	if (CheckClickOnTown(vp, x, y)) return;
 
	if (CheckClickOnStation(vp, x, y)) return;
0 comments (0 inline, 0 general)