mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-17 21:25:40 +00:00
(svn r14884) -Codechange: simplify code responsible for opening vehicle view windows
This commit is contained in:
parent
828675bf0e
commit
1ada1a4ff2
@ -1994,30 +1994,6 @@ static bool CheckClickOnLandscape(const ViewPort *vp, int x, int y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void SafeShowTrainViewWindow(const Vehicle* v)
|
|
||||||
{
|
|
||||||
if (!IsFrontEngine(v)) v = v->First();
|
|
||||||
ShowVehicleViewWindow(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SafeShowRoadVehViewWindow(const Vehicle *v)
|
|
||||||
{
|
|
||||||
if (!IsRoadVehFront(v)) v = v->First();
|
|
||||||
ShowVehicleViewWindow(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void Nop(const Vehicle *v) {}
|
|
||||||
|
|
||||||
typedef void OnVehicleClickProc(const Vehicle *v);
|
|
||||||
static OnVehicleClickProc* const _on_vehicle_click_proc[] = {
|
|
||||||
SafeShowTrainViewWindow,
|
|
||||||
SafeShowRoadVehViewWindow,
|
|
||||||
ShowVehicleViewWindow,
|
|
||||||
ShowVehicleViewWindow,
|
|
||||||
Nop, // Special vehicles
|
|
||||||
Nop // Disaster vehicles
|
|
||||||
};
|
|
||||||
|
|
||||||
bool HandleViewportClicked(const ViewPort *vp, int x, int y)
|
bool HandleViewportClicked(const ViewPort *vp, int x, int y)
|
||||||
{
|
{
|
||||||
const Vehicle *v;
|
const Vehicle *v;
|
||||||
@ -2031,7 +2007,7 @@ bool HandleViewportClicked(const ViewPort *vp, int x, int y)
|
|||||||
v = CheckClickOnVehicle(vp, x, y);
|
v = CheckClickOnVehicle(vp, x, y);
|
||||||
if (v != NULL) {
|
if (v != NULL) {
|
||||||
DEBUG(misc, 2, "Vehicle %d (index %d) at %p", v->unitnumber, v->index, v);
|
DEBUG(misc, 2, "Vehicle %d (index %d) at %p", v->unitnumber, v->index, v);
|
||||||
_on_vehicle_click_proc[v->type](v);
|
if (IsCompanyBuildableVehicleType(v)) ShowVehicleViewWindow(v->First());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return CheckClickOnLandscape(vp, x, y);
|
return CheckClickOnLandscape(vp, x, y);
|
||||||
|
Loading…
Reference in New Issue
Block a user