diff --git a/src/cargopacket.h b/src/cargopacket.h index d4eee39b93..8118ca319a 100644 --- a/src/cargopacket.h +++ b/src/cargopacket.h @@ -582,8 +582,8 @@ public: } /** - * Are two the two CargoPackets mergeable in the context of - * a list of CargoPackets for a Vehicle? + * Are the two CargoPackets mergeable in the context of + * a list of CargoPackets for a Station? * @param cp1 First CargoPacket. * @param cp2 Second CargoPacket. * @return True if they are mergeable. diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 352ed2dd0d..7c430508d7 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -270,8 +270,6 @@ static WindowDesc _build_industry_desc( class BuildIndustryWindow : public Window { int selected_index; ///< index of the element in the matrix IndustryType selected_type; ///< industry corresponding to the above index - uint16 callback_timer; ///< timer counter for callback eventual verification - bool timer_enabled; ///< timer can be used uint16 count; ///< How many industries are loaded IndustryType index[NUM_INDUSTRYTYPES + 1]; ///< Type of industry, in the order it was loaded bool enabled[NUM_INDUSTRYTYPES + 1]; ///< availability state, coming from CBID_INDUSTRY_PROBABILITY (if ever) @@ -295,7 +293,6 @@ class BuildIndustryWindow : public Window { this->index[this->count] = INVALID_INDUSTRYTYPE; this->enabled[this->count] = true; this->count++; - this->timer_enabled = false; } /* Fill the arrays with industries. * The tests performed after the enabled allow to load the industries @@ -387,13 +384,9 @@ class BuildIndustryWindow : public Window { public: BuildIndustryWindow() : Window(&_build_industry_desc) { - this->timer_enabled = _loaded_newgrf_features.has_newindustries; - this->selected_index = -1; this->selected_type = INVALID_INDUSTRYTYPE; - this->callback_timer = DAY_TICKS; - this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_DPI_SCROLLBAR); this->FinishInitNested(0); @@ -423,10 +416,11 @@ public: } case WID_DPI_INFOPANEL: { - /* Extra line for cost outside of editor + extra lines for 'extra' information for NewGRFs. */ - int height = 2 + (_game_mode == GM_EDITOR ? 0 : 1) + (_loaded_newgrf_features.has_newindustries ? 4 : 0); + /* Extra line for cost outside of editor. */ + int height = 2 + (_game_mode == GM_EDITOR ? 0 : 1); uint extra_lines_req = 0; uint extra_lines_prd = 0; + uint extra_lines_newgrf = 0; uint max_minwidth = FONT_HEIGHT_NORMAL * MAX_MINWIDTH_LINEHEIGHTS; Dimension d = {0, 0}; for (byte i = 0; i < this->count; i++) { @@ -454,10 +448,15 @@ public: strdim.width = max_minwidth; } d = maxdim(d, strdim); + + if (indsp->grf_prop.grffile != nullptr) { + /* Reserve a few extra lines for text from an industry NewGRF. */ + extra_lines_newgrf = 4; + } } /* Set it to something more sane :) */ - height += extra_lines_prd + extra_lines_req; + height += extra_lines_prd + extra_lines_req + extra_lines_newgrf; size->height = height * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; size->width = d.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; break; @@ -673,25 +672,19 @@ public: if (success && !_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } - void OnGameTick() override + void OnHundredthTick() override { - if (!this->timer_enabled) return; - if (--this->callback_timer == 0) { - /* We have just passed another day. - * See if we need to update availability of currently selected industry */ - this->callback_timer = DAY_TICKS; // restart counter + if (_game_mode == GM_EDITOR) return; + const IndustrySpec *indsp = GetIndustrySpec(this->selected_type); - const IndustrySpec *indsp = GetIndustrySpec(this->selected_type); + if (indsp->enabled) { + bool call_back_result = GetIndustryProbabilityCallback(this->selected_type, IACT_USERCREATION, 1) > 0; - if (indsp->enabled) { - bool call_back_result = GetIndustryProbabilityCallback(this->selected_type, IACT_USERCREATION, 1) > 0; - - /* Only if result does match the previous state would it require a redraw. */ - if (call_back_result != this->enabled[this->selected_index]) { - this->enabled[this->selected_index] = call_back_result; - this->SetButtons(); - this->SetDirty(); - } + /* Only if result does match the previous state would it require a redraw. */ + if (call_back_result != this->enabled[this->selected_index]) { + this->enabled[this->selected_index] = call_back_result; + this->SetButtons(); + this->SetDirty(); } } } diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 1e03c5f6be..7d12a1917a 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -2455,8 +2455,6 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, con if (!CargoSpec::Get(housespec->accepts_cargo[2])->IsValid()) { housespec->cargo_acceptance[2] = 0; } - - _loaded_newgrf_features.has_newhouses = true; break; } @@ -9194,8 +9192,6 @@ void ResetNewGRFData() _loaded_newgrf_features.has_2CC = false; _loaded_newgrf_features.used_liveries = 1 << LS_DEFAULT; - _loaded_newgrf_features.has_newhouses = false; - _loaded_newgrf_features.has_newindustries = false; _loaded_newgrf_features.shore = SHORE_REPLACE_NONE; _loaded_newgrf_features.tram = TRAMWAY_REPLACE_DEPOT_NONE; @@ -9715,7 +9711,6 @@ static void FinaliseIndustriesArray() } _industry_mngr.SetEntitySpec(indsp); - _loaded_newgrf_features.has_newindustries = true; } } } diff --git a/src/newgrf.h b/src/newgrf.h index 24093f6564..5d2533b8c2 100644 --- a/src/newgrf.h +++ b/src/newgrf.h @@ -289,8 +289,6 @@ enum TramReplacement { struct GRFLoadedFeatures { bool has_2CC; ///< Set if any vehicle is loaded which uses 2cc (two company colours). uint64 used_liveries; ///< Bitmask of #LiveryScheme used by the defined engines. - bool has_newhouses; ///< Set if there are any newhouses loaded. - bool has_newindustries; ///< Set if there are any newindustries loaded. ShoreReplacement shore; ///< In which way shore sprites were replaced. TramReplacement tram; ///< In which way tram depots were replaced. }; diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp index 722257c91d..fc1738dfa1 100644 --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -140,8 +140,6 @@ void IncreaseBuildingCount(Town *t, HouseID house_id) { HouseClassID class_id = HouseSpec::Get(house_id)->class_id; - if (!_loaded_newgrf_features.has_newhouses) return; - t->cache.building_counts.id_count[house_id]++; _building_counts.id_count[house_id]++; @@ -161,8 +159,6 @@ void DecreaseBuildingCount(Town *t, HouseID house_id) { HouseClassID class_id = HouseSpec::Get(house_id)->class_id; - if (!_loaded_newgrf_features.has_newhouses) return; - if (t->cache.building_counts.id_count[house_id] > 0) t->cache.building_counts.id_count[house_id]--; if (_building_counts.id_count[house_id] > 0) _building_counts.id_count[house_id]--; diff --git a/src/string.cpp b/src/string.cpp index 33b36f9390..5ed6f90daf 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -32,10 +32,6 @@ #include "os/windows/string_uniscribe.h" #endif -#if defined(WITH_COCOA) -#include "os/macosx/string_osx.h" -#endif - #ifdef WITH_ICU_I18N /* Required by strnatcmp. */ #include @@ -43,6 +39,10 @@ #include "gfx_func.h" #endif /* WITH_ICU_I18N */ +#if defined(WITH_COCOA) +#include "os/macosx/string_osx.h" +#endif + /* The function vsnprintf is used internally to perform the required formatting * tasks. As such this one must be allowed, and makes sure it's terminated. */ #include "safeguards.h" diff --git a/src/table/settings.h.preamble b/src/table/settings.h.preamble index 934f257968..473ce99b44 100644 --- a/src/table/settings.h.preamble +++ b/src/table/settings.h.preamble @@ -13,7 +13,9 @@ static size_t ConvertLandscape(const char *value); /**************************** * OTTD specific INI stuff - ****************************/ + **************************** + * DO NOT edit this file. This file is automatically generated from the contents of /src/table/ + */ /** * Settings-macro usage: @@ -28,7 +30,7 @@ static size_t ConvertLandscape(const char *value); * These are for client-only variables. Here the 'var' refers to an * entry inside _settings_client. * 3. SDT_something - * Thse are for members in the struct described by the current + * These are for members in the struct described by the current * #SettingDesc list / .ini file. Here, 'base' specifies type of the * struct while 'var' points out the member of the struct (the actual * struct to store it in is implicitly defined by the #SettingDesc diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 3945031ce5..6f336e2954 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2697,8 +2697,7 @@ static CommandCost CheckCanBuildHouse(HouseID house, const Town *t) { const HouseSpec *hs = HouseSpec::Get(house); - if (_loaded_newgrf_features.has_newhouses && !_generating_world && - _game_mode != GM_EDITOR && (hs->extra_flags & BUILDING_IS_HISTORICAL) != 0) { + if (!_generating_world && _game_mode != GM_EDITOR && (hs->extra_flags & BUILDING_IS_HISTORICAL) != 0) { return CMD_ERROR; } @@ -2836,8 +2835,7 @@ static bool BuildTownHouse(Town *t, TileIndex tile) if (IsHouseTypeAllowed((HouseID)i, above_snowline, zone).Failed()) continue; if (IsAnotherHouseTypeAllowedInTown(t, (HouseID)i).Failed()) continue; - /* Without NewHouses, all houses have probability '1' */ - uint cur_prob = (_loaded_newgrf_features.has_newhouses ? HouseSpec::Get(i)->probability : 1); + uint cur_prob = HouseSpec::Get(i)->probability; probability_max += cur_prob; probs[num] = cur_prob; houses[num++] = (HouseID)i; diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp index 4a4c8086ea..774e80b2da 100644 --- a/src/video/sdl2_v.cpp +++ b/src/video/sdl2_v.cpp @@ -382,9 +382,7 @@ static void DrawSurfaceToScreen() } else { if (_sdl_surface != _sdl_realscreen) { for (int i = 0; i < n; i++) { - SDL_BlitSurface( - _sdl_surface, &_dirty_rects[i], - _sdl_realscreen, &_dirty_rects[i]); + SDL_BlitSurface(_sdl_surface, &_dirty_rects[i], _sdl_realscreen, &_dirty_rects[i]); } } diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index 682b3f8268..472a168363 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -35,7 +35,7 @@ static FVideoDriver_SDL iFVideoDriver_SDL; -static SDL_Surface *_sdl_screen; +static SDL_Surface *_sdl_surface; static SDL_Surface *_sdl_realscreen; static bool _all_modes; @@ -77,11 +77,11 @@ static void UpdatePalette(bool init = false) pal[i].unused = 0; } - SDL_SetColors(_sdl_screen, pal, _local_palette.first_dirty, _local_palette.count_dirty); + SDL_SetColors(_sdl_surface, pal, _local_palette.first_dirty, _local_palette.count_dirty); - if (_sdl_screen != _sdl_realscreen && init) { + if (_sdl_surface != _sdl_realscreen && init) { /* When using a shadow surface, also set our palette on the real screen. This lets SDL - * allocate as much colors (or approximations) as + * allocate as many colors (or approximations) as * possible, instead of using only the default SDL * palette. This allows us to get more colors exactly * right and might allow using better approximations for @@ -103,7 +103,7 @@ static void UpdatePalette(bool init = false) SDL_SetColors(_sdl_realscreen, pal, _local_palette.first_dirty, _local_palette.count_dirty); } - if (_sdl_screen != _sdl_realscreen && !init) { + if (_sdl_surface != _sdl_realscreen && !init) { /* We're not using real hardware palette, but are letting SDL * approximate the palette during shadow -> screen copy. To * change the palette, we need to recopy the entire screen. @@ -114,7 +114,7 @@ static void UpdatePalette(bool init = false) * best mapping of shadow palette colors to real palette * colors from scratch. */ - SDL_BlitSurface(_sdl_screen, nullptr, _sdl_realscreen, nullptr); + SDL_BlitSurface(_sdl_surface, nullptr, _sdl_realscreen, nullptr); SDL_UpdateRect(_sdl_realscreen, 0, 0, 0, 0); } } @@ -159,17 +159,20 @@ static void DrawSurfaceToScreen() if (n == 0) return; _num_dirty_rects = 0; + if (n > MAX_DIRTY_RECTS) { - if (_sdl_screen != _sdl_realscreen) { - SDL_BlitSurface(_sdl_screen, nullptr, _sdl_realscreen, nullptr); + if (_sdl_surface != _sdl_realscreen) { + SDL_BlitSurface(_sdl_surface, nullptr, _sdl_realscreen, nullptr); } + SDL_UpdateRect(_sdl_realscreen, 0, 0, 0, 0); } else { - if (_sdl_screen != _sdl_realscreen) { + if (_sdl_surface != _sdl_realscreen) { for (int i = 0; i < n; i++) { - SDL_BlitSurface(_sdl_screen, &_dirty_rects[i], _sdl_realscreen, &_dirty_rects[i]); + SDL_BlitSurface(_sdl_surface, &_dirty_rects[i], _sdl_realscreen, &_dirty_rects[i]); } } + SDL_UpdateRects(_sdl_realscreen, n, _dirty_rects); } } @@ -312,7 +315,7 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h) if (want_hwpalette) DEBUG(driver, 1, "SDL: requesting hardware palette"); /* Free any previously allocated shadow surface */ - if (_sdl_screen != nullptr && _sdl_screen != _sdl_realscreen) SDL_FreeSurface(_sdl_screen); + if (_sdl_surface != nullptr && _sdl_surface != _sdl_realscreen) SDL_FreeSurface(_sdl_surface); if (_sdl_realscreen != nullptr) { if (_requested_hwpalette != want_hwpalette) { @@ -379,7 +382,7 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h) _screen.height = newscreen->h; _screen.pitch = newscreen->pitch / (bpp / 8); _screen.dst_ptr = newscreen->pixels; - _sdl_screen = newscreen; + _sdl_surface = newscreen; /* When in full screen, we will always have the mouse cursor * within the window, even though SDL does not give us the @@ -614,7 +617,7 @@ const char *VideoDriver_SDL::Start(const StringList &parm) } else if (SDL_WasInit(SDL_INIT_VIDEO) == 0) { ret_code = SDL_InitSubSystem(SDL_INIT_VIDEO); } - if (ret_code == -1) return SDL_GetError(); + if (ret_code < 0) return SDL_GetError(); GetVideoModes(); if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height)) {