diff options
author | belugas <belugas@openttd.org> | 2007-05-31 19:13:41 +0000 |
---|---|---|
committer | belugas <belugas@openttd.org> | 2007-05-31 19:13:41 +0000 |
commit | 4c243d099cdd06454337bbea93e0d3ce84e48d14 (patch) | |
tree | 539e6a1d877b0459ab303b47d86cf1ac9c8c1e2f /src | |
parent | 4a62006c395661a7934105d9dcbcb4939c49ab43 (diff) | |
download | openttd-4c243d099cdd06454337bbea93e0d3ce84e48d14.tar.xz |
(svn r10005) -Codechange: Merge two flags (2cc and newhouses) indicating some newgrf features have been loaded, and introduce the newindustry one.
Diffstat (limited to 'src')
-rw-r--r-- | src/newgrf.cpp | 23 | ||||
-rw-r--r-- | src/newgrf.h | 11 | ||||
-rw-r--r-- | src/newgrf_house.cpp | 6 | ||||
-rw-r--r-- | src/player_gui.cpp | 6 | ||||
-rw-r--r-- | src/town_cmd.cpp | 6 |
5 files changed, 28 insertions, 24 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 8d50fef12..2e4e01eb8 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -74,12 +74,8 @@ static uint32 _ttdpatch_flags[8]; /* Used by Action 0x06 to preload a pseudo sprite and modify its content */ static byte *_preload_sprite = NULL; -/* Set if any vehicle is loaded which uses 2cc (two company colours) */ -bool _have_2cc = false; - -/* Set if there are any newhouses loaded. */ -bool _have_newhouses = false; - +/* Indicates which are the newgrf features currently loaded ingame */ +uint8 _loaded_newgrf_features; enum GrfDataType { GDT_SOUND, @@ -539,7 +535,7 @@ static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf case 0x27: // Miscellaneous flags FOR_EACH_OBJECT { ei[i].misc_flags = grf_load_byte(&buf); - if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; + if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) SETBIT(_loaded_newgrf_features, GRFLOADED_2CC); } break; @@ -661,7 +657,7 @@ static bool RoadVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf case 0x1C: // Miscellaneous flags FOR_EACH_OBJECT { ei[i].misc_flags = grf_load_byte(&buf); - if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; + if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) SETBIT(_loaded_newgrf_features, GRFLOADED_2CC); } break; @@ -772,7 +768,7 @@ static bool ShipVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf case 0x17: // Miscellaneous flags FOR_EACH_OBJECT { ei[i].misc_flags = grf_load_byte(&buf); - if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; + if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) SETBIT(_loaded_newgrf_features, GRFLOADED_2CC); } break; @@ -888,7 +884,7 @@ static bool AircraftVehicleChangeInfo(uint engine, int numinfo, int prop, byte * case 0x17: // Miscellaneous flags FOR_EACH_OBJECT { ei[i].misc_flags = grf_load_byte(&buf); - if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) _have_2cc = true; + if (HASBIT(ei[i].misc_flags, EF_USES_2CC)) SETBIT(_loaded_newgrf_features, GRFLOADED_2CC); } break; @@ -1297,7 +1293,7 @@ static bool TownHouseChangeInfo(uint hid, int numinfo, int prop, byte **bufp, in * FinaliseHouseArray() for more details. */ if (housespec[i]->min_date < 1930) housespec[i]->min_date = 1930; } - _have_newhouses = true; + SETBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES); break; case 0x09: // Building flags @@ -4459,8 +4455,9 @@ static void ResetNewGRFData() _misc_grf_features = 0; _traininfo_vehicle_pitch = 0; _traininfo_vehicle_width = 29; - _have_2cc = false; - _have_newhouses = false; + + _loaded_newgrf_features = 0; + _signal_base = 0; _coast_base = 0; diff --git a/src/newgrf.h b/src/newgrf.h index 7324e7dd9..e1c8d1a10 100644 --- a/src/newgrf.h +++ b/src/newgrf.h @@ -87,8 +87,15 @@ extern GRFFile *_first_grffile; extern SpriteID _signal_base; extern SpriteID _coast_base; -extern bool _have_2cc; -extern bool _have_newhouses; + +enum GRFLoadedFeatures { + GRFLOADED_2CC, // Set if any vehicle is loaded which uses 2cc (two company colours). + GRFLOADED_NEWHOUSES, // Set if there are any newhouses loaded. + GRFLOADED_NEWINDUSTRIES, // Set if there are any newindustries loaded. +}; + +/* Indicates which are the newgrf features currently loaded ingame */ +extern uint8 _loaded_newgrf_features; void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage); void LoadNewGRF(uint load_index, uint file_index); diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp index e6dd53df2..2883f9b2d 100644 --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -83,7 +83,7 @@ void IncreaseBuildingCount(Town *t, HouseID house_id) { HouseClassID class_id = GetHouseSpecs(house_id)->class_id; - if (!_have_newhouses) return; + if (!HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) return; /* If there are 255 buildings of this type in this town, there are also * at least that many houses of the same class in the town, and @@ -111,7 +111,7 @@ void DecreaseBuildingCount(Town *t, HouseID house_id) { HouseClassID class_id = GetHouseSpecs(house_id)->class_id; - if (!_have_newhouses) return; + if (!HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) return; if (t->building_counts.id_count[house_id] > 0) t->building_counts.id_count[house_id]--; if (_building_counts.id_count[house_id] > 0) _building_counts.id_count[house_id]--; @@ -129,7 +129,7 @@ void DecreaseBuildingCount(Town *t, HouseID house_id) */ void AfterLoadCountBuildings() { - if (!_have_newhouses) return; + if (!HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) return; for (TileIndex t = 0; t < MapSize(); t++) { if (!IsTileType(t, MP_HOUSE)) continue; diff --git a/src/player_gui.cpp b/src/player_gui.cpp index 7112a68a1..0c0eed216 100644 --- a/src/player_gui.cpp +++ b/src/player_gui.cpp @@ -324,7 +324,7 @@ static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e) switch (e->event) { case WE_CREATE: LowerWindowWidget(w, WP(w, livery_d).livery_class + 2); - if (!_have_2cc) { + if (!HASBIT(_loaded_newgrf_features, GRFLOADED_2CC)) { HideWindowWidget(w, 11); HideWindowWidget(w, 12); } @@ -366,7 +366,7 @@ static void SelectPlayerLiveryWndProc(Window *w, WindowEvent *e) DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(p->livery[scheme].colour1), 152, y); DrawString(165, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour1, sel ? 0xC : 2); - if (_have_2cc) { + if (HASBIT(_loaded_newgrf_features, GRFLOADED_2CC)) { DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(p->livery[scheme].colour2), 277, y); DrawString(290, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour2, sel ? 0xC : 2); } @@ -794,7 +794,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e) } case PCW_WIDGET_COLOR_SCHEME: { - Window *wf = AllocateWindowDescFront(_have_2cc ? &_select_player_livery_2cc_desc : &_select_player_livery_desc, w->window_number); + Window *wf = AllocateWindowDescFront(HASBIT(_loaded_newgrf_features, GRFLOADED_2CC) ? &_select_player_livery_2cc_desc : &_select_player_livery_desc, w->window_number); if (wf != NULL) { wf->caption_color = wf->window_number; WP(wf, livery_d).livery_class = LC_OTHER; diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index ce8e5dfe5..2f7b0158c 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -1668,7 +1668,7 @@ static void DoBuildTownHouse(Town *t, TileIndex tile) for (i = 0; i < HOUSE_MAX; i++) { hs = GetHouseSpecs(i); if ((~hs->building_availability & bitmask) == 0 && hs->enabled) { - if (_have_newhouses) { + if (HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) { probability_max += hs->probability; cumulative_probs[num] = probability_max; } @@ -1677,7 +1677,7 @@ static void DoBuildTownHouse(Town *t, TileIndex tile) } for (;;) { - if (_have_newhouses) { + if (HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) { uint r = RandomRange(probability_max); for (i = 0; i < num; i++) if (cumulative_probs[i] >= r) break; @@ -1688,7 +1688,7 @@ static void DoBuildTownHouse(Town *t, TileIndex tile) hs = GetHouseSpecs(house); - if (_have_newhouses) { + if (HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) { if (hs->override != 0) hs = GetHouseSpecs(hs->override); if ((hs->extra_flags & BUILDING_IS_HISTORICAL) && !_generating_world) continue; |