mirror of https://github.com/OpenTTD/OpenTTD
(svn r5281) -Backport: r5124
-Fix: Be more strict what it means for an aircraft to be in a hangar: It's not just being stopped on a hangar tilerelease/0.4
parent
a8d2aa157a
commit
d070a97f7a
|
@ -0,0 +1,16 @@
|
|||
/* $Id$ */
|
||||
|
||||
#include "station_map.h"
|
||||
#include "vehicle.h"
|
||||
|
||||
|
||||
static inline bool IsAircraftInHangar(const Vehicle* v)
|
||||
{
|
||||
assert(v->type == VEH_Aircraft);
|
||||
return v->vehstatus & VS_HIDDEN && IsHangarTile(v->tile);
|
||||
}
|
||||
|
||||
static inline bool IsAircraftInHangarStopped(const Vehicle* v)
|
||||
{
|
||||
return IsAircraftInHangar(v) && v->vehstatus & VS_STOPPED;
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "aircraft.h"
|
||||
#include "debug.h"
|
||||
#include "functions.h"
|
||||
#include "table/strings.h"
|
||||
|
@ -312,16 +313,6 @@ bool IsAircraftHangarTile(TileIndex tile)
|
|||
(_m[tile].m5 == 32 || _m[tile].m5 == 65 || _m[tile].m5 == 86);
|
||||
}
|
||||
|
||||
bool CheckStoppedInHangar(const Vehicle* v)
|
||||
{
|
||||
if (!(v->vehstatus & VS_STOPPED) || !IsAircraftHangarTile(v->tile)) {
|
||||
_error_message = STR_A01B_AIRCRAFT_MUST_BE_STOPPED;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void DoDeleteAircraft(Vehicle *v)
|
||||
{
|
||||
|
@ -345,8 +336,8 @@ int32 CmdSellAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
|||
|
||||
v = GetVehicle(p1);
|
||||
|
||||
if (v->type != VEH_Aircraft || !CheckOwnership(v->owner) || !CheckStoppedInHangar(v))
|
||||
return CMD_ERROR;
|
||||
if (v->type != VEH_Aircraft || !CheckOwnership(v->owner)) return CMD_ERROR;
|
||||
if (!IsAircraftInHangarStopped(v)) return_cmd_error(STR_A01B_AIRCRAFT_MUST_BE_STOPPED);
|
||||
|
||||
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
|
||||
|
||||
|
@ -472,7 +463,7 @@ int32 CmdRefitAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
|||
v = GetVehicle(p1);
|
||||
|
||||
if (v->type != VEH_Aircraft || !CheckOwnership(v->owner)) return CMD_ERROR;
|
||||
if (!CheckStoppedInHangar(v)) return_cmd_error(STR_A01B_AIRCRAFT_MUST_BE_STOPPED);
|
||||
if (!IsAircraftInHangarStopped(v)) return_cmd_error(STR_A01B_AIRCRAFT_MUST_BE_STOPPED);
|
||||
|
||||
avi = AircraftVehInfo(v->engine_type);
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "aircraft.h"
|
||||
#include "debug.h"
|
||||
#include "functions.h"
|
||||
#include "table/sprites.h"
|
||||
|
@ -492,7 +493,6 @@ static const Widget _aircraft_view_widgets[] = {
|
|||
{ WIDGETS_END }
|
||||
};
|
||||
|
||||
bool CheckStoppedInHangar(const Vehicle* v); /* XXX extern function declaration in .c */
|
||||
|
||||
static void AircraftViewWndProc(Window *w, WindowEvent *e)
|
||||
{
|
||||
|
@ -502,9 +502,7 @@ static void AircraftViewWndProc(Window *w, WindowEvent *e)
|
|||
uint32 disabled = 1 << 8;
|
||||
StringID str;
|
||||
|
||||
if (v->vehstatus & VS_STOPPED && IsAircraftHangarTile(v->tile)) {
|
||||
disabled = 0;
|
||||
}
|
||||
if (IsAircraftInHangarStopped(v)) disabled = 0;
|
||||
|
||||
if (v->owner != _local_player) disabled |= 1 << 8 | 1 << 7;
|
||||
w->disabled_state = disabled;
|
||||
|
@ -597,7 +595,7 @@ static void AircraftViewWndProc(Window *w, WindowEvent *e)
|
|||
|
||||
case WE_MOUSELOOP: {
|
||||
const Vehicle* v = GetVehicle(w->window_number);
|
||||
uint32 h = CheckStoppedInHangar(v) ? (1 << 7) : (1 << 11);
|
||||
uint32 h = IsAircraftInHangarStopped(v) ? 1 << 7 : 1 << 11;
|
||||
|
||||
if (h != w->hidden_state) {
|
||||
w->hidden_state = h;
|
||||
|
@ -1033,7 +1031,7 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
|
|||
DrawVehicleProfitButton(v, x, y + 13);
|
||||
|
||||
SetDParam(0, v->unitnumber);
|
||||
if (IsAircraftHangarTile(v->tile) && (v->vehstatus & VS_HIDDEN)) {
|
||||
if (IsAircraftInHangar(v)) {
|
||||
str = STR_021F;
|
||||
} else {
|
||||
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2;
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/* $Id$ */
|
||||
|
||||
#include "tile.h"
|
||||
|
||||
#ifndef STATION_MAP_H
|
||||
#define STATION_MAP_H
|
||||
|
||||
typedef byte StationGfx;
|
||||
|
||||
|
||||
typedef enum HangarTiles {
|
||||
HANGAR_TILE_0 = 32,
|
||||
HANGAR_TILE_1 = 65,
|
||||
HANGAR_TILE_2 = 86
|
||||
} HangarTiles;
|
||||
|
||||
|
||||
static inline StationGfx GetStationGfx(TileIndex t)
|
||||
{
|
||||
assert(IsTileType(t, MP_STATION));
|
||||
return _m[t].m5;
|
||||
}
|
||||
|
||||
|
||||
static inline bool IsHangar(TileIndex t)
|
||||
{
|
||||
StationGfx gfx = GetStationGfx(t);
|
||||
return
|
||||
gfx == HANGAR_TILE_0 ||
|
||||
gfx == HANGAR_TILE_1 ||
|
||||
gfx == HANGAR_TILE_2;
|
||||
}
|
||||
|
||||
|
||||
static inline bool IsHangarTile(TileIndex t)
|
||||
{
|
||||
return IsTileType(t, MP_STATION) && IsHangar(t);
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue