summaryrefslogtreecommitdiff
path: root/aircraft_gui.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-07-22 14:43:53 +0000
committertron <tron@openttd.org>2006-07-22 14:43:53 +0000
commitfadc3a564c910d3b56c157a164e4e6770de2494e (patch)
treea4937442361134139cfc02c49524349fe016f776 /aircraft_gui.c
parent81846cca24f76652d2d11bcc7d4e2566d4f61d03 (diff)
downloadopenttd-fadc3a564c910d3b56c157a164e4e6770de2494e.tar.xz
(svn r5594) Be more strict what's allowed to be built in a hangar: if the airport can't handle planes/helicopters don't present and disallow building planes/helicopters - the latter case wasn't covered yet.
Also remove an error message about building aircraft which can't be triggered by a normal client
Diffstat (limited to 'aircraft_gui.c')
-rw-r--r--aircraft_gui.c59
1 files changed, 35 insertions, 24 deletions
diff --git a/aircraft_gui.c b/aircraft_gui.c
index a4ead2d52..4be5bb59a 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -112,47 +112,58 @@ static void NewAircraftWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
case WE_PAINT: {
- if (w->window_number == 0) SETBIT(w->disabled_state, 5);
+ TileIndex tile = w->window_number;
+ const AirportFTAClass* ap;
+
+ if (tile == 0) SETBIT(w->disabled_state, 5);
+
+ ap = GetAirport(GetStationByTile(tile)->airport_type);
{
int count = 0;
- int num = NUM_AIRCRAFT_ENGINES;
- const Engine* e = GetEngine(AIRCRAFT_ENGINES_INDEX);
- EngineID engine_id = AIRCRAFT_ENGINES_INDEX;
+ EngineID eid;
- do {
- if (HASBIT(e->player_avail, _local_player) &&
- !( (GetAirport(GetStationByTile(w->window_number)->airport_type)->acc_planes == HELICOPTERS_ONLY) &&
- (AircraftVehInfo(engine_id)->subtype & AIR_CTOL) ) ) count++;
- } while (++engine_id, ++e,--num);
+ for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) {
+ const AircraftVehicleInfo* avi;
+
+ if (!HASBIT(GetEngine(eid)->player_avail, _local_player)) continue;
+
+ avi = AircraftVehInfo(eid);
+ if ((avi->subtype & AIR_CTOL ? HELICOPTERS_ONLY : AIRCRAFT_ONLY) == ap->acc_planes) continue;
+
+ count++;
+ }
SetVScrollCount(w, count);
}
DrawWindowWidgets(w);
{
- int num = NUM_AIRCRAFT_ENGINES;
- const Engine* e = GetEngine(AIRCRAFT_ENGINES_INDEX);
int x = 2;
int y = 15;
int sel = WP(w,buildtrain_d).sel_index;
int pos = w->vscroll.pos;
- EngineID engine_id = AIRCRAFT_ENGINES_INDEX;
EngineID selected_id = INVALID_ENGINE;
+ EngineID eid;
- do {
- if (HASBIT(e->player_avail, _local_player) &&
- !( (GetAirport(GetStationByTile(w->window_number)->airport_type)->acc_planes == HELICOPTERS_ONLY) &&
- (AircraftVehInfo(engine_id)->subtype & AIR_CTOL) ) ) {
- if (sel==0) selected_id = engine_id;
- if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) {
- DrawString(x+62, y+7, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10);
- DrawAircraftEngine(x+29, y+10, engine_id, GetEnginePalette(engine_id, _local_player));
- y += 24;
- }
- sel--;
+ for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) {
+ const AircraftVehicleInfo* avi;
+
+ if (!HASBIT(GetEngine(eid)->player_avail, _local_player)) continue;
+
+ avi = AircraftVehInfo(eid);
+ if ((avi->subtype & AIR_CTOL ? HELICOPTERS_ONLY : AIRCRAFT_ONLY) == ap->acc_planes) continue;
+
+ if (sel == 0) selected_id = eid;
+
+ if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) {
+ DrawString(x + 62, y + 7, GetCustomEngineName(eid), sel == 0 ? 0xC : 0x10);
+ DrawAircraftEngine(x + 29, y + 10, eid, GetEnginePalette(eid, _local_player));
+ y += 24;
}
- } while (++engine_id, ++e,--num);
+
+ sel--;
+ }
WP(w,buildtrain_d).sel_engine = selected_id;