Merge branch 'master' into jgrpp

# Conflicts:
#	src/town_cmd.cpp
This commit is contained in:
Jonathan G Rennison
2020-06-05 17:07:58 +01:00
10 changed files with 48 additions and 65 deletions

View File

@@ -582,8 +582,8 @@ public:
} }
/** /**
* Are two the two CargoPackets mergeable in the context of * Are the two CargoPackets mergeable in the context of
* a list of CargoPackets for a Vehicle? * a list of CargoPackets for a Station?
* @param cp1 First CargoPacket. * @param cp1 First CargoPacket.
* @param cp2 Second CargoPacket. * @param cp2 Second CargoPacket.
* @return True if they are mergeable. * @return True if they are mergeable.

View File

@@ -270,8 +270,6 @@ static WindowDesc _build_industry_desc(
class BuildIndustryWindow : public Window { class BuildIndustryWindow : public Window {
int selected_index; ///< index of the element in the matrix int selected_index; ///< index of the element in the matrix
IndustryType selected_type; ///< industry corresponding to the above index 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 uint16 count; ///< How many industries are loaded
IndustryType index[NUM_INDUSTRYTYPES + 1]; ///< Type of industry, in the order it was 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) 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->index[this->count] = INVALID_INDUSTRYTYPE;
this->enabled[this->count] = true; this->enabled[this->count] = true;
this->count++; this->count++;
this->timer_enabled = false;
} }
/* Fill the arrays with industries. /* Fill the arrays with industries.
* The tests performed after the enabled allow to load the industries * The tests performed after the enabled allow to load the industries
@@ -387,13 +384,9 @@ class BuildIndustryWindow : public Window {
public: public:
BuildIndustryWindow() : Window(&_build_industry_desc) BuildIndustryWindow() : Window(&_build_industry_desc)
{ {
this->timer_enabled = _loaded_newgrf_features.has_newindustries;
this->selected_index = -1; this->selected_index = -1;
this->selected_type = INVALID_INDUSTRYTYPE; this->selected_type = INVALID_INDUSTRYTYPE;
this->callback_timer = DAY_TICKS;
this->CreateNestedTree(); this->CreateNestedTree();
this->vscroll = this->GetScrollbar(WID_DPI_SCROLLBAR); this->vscroll = this->GetScrollbar(WID_DPI_SCROLLBAR);
this->FinishInitNested(0); this->FinishInitNested(0);
@@ -423,10 +416,11 @@ public:
} }
case WID_DPI_INFOPANEL: { case WID_DPI_INFOPANEL: {
/* Extra line for cost outside of editor + extra lines for 'extra' information for NewGRFs. */ /* Extra line for cost outside of editor. */
int height = 2 + (_game_mode == GM_EDITOR ? 0 : 1) + (_loaded_newgrf_features.has_newindustries ? 4 : 0); int height = 2 + (_game_mode == GM_EDITOR ? 0 : 1);
uint extra_lines_req = 0; uint extra_lines_req = 0;
uint extra_lines_prd = 0; uint extra_lines_prd = 0;
uint extra_lines_newgrf = 0;
uint max_minwidth = FONT_HEIGHT_NORMAL * MAX_MINWIDTH_LINEHEIGHTS; uint max_minwidth = FONT_HEIGHT_NORMAL * MAX_MINWIDTH_LINEHEIGHTS;
Dimension d = {0, 0}; Dimension d = {0, 0};
for (byte i = 0; i < this->count; i++) { for (byte i = 0; i < this->count; i++) {
@@ -454,10 +448,15 @@ public:
strdim.width = max_minwidth; strdim.width = max_minwidth;
} }
d = maxdim(d, strdim); 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 :) */ /* 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->height = height * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
size->width = d.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; size->width = d.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
break; break;
@@ -673,14 +672,9 @@ public:
if (success && !_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); if (success && !_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
} }
void OnGameTick() override void OnHundredthTick() override
{ {
if (!this->timer_enabled) return; if (_game_mode == GM_EDITOR) 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
const IndustrySpec *indsp = GetIndustrySpec(this->selected_type); const IndustrySpec *indsp = GetIndustrySpec(this->selected_type);
if (indsp->enabled) { if (indsp->enabled) {
@@ -694,7 +688,6 @@ public:
} }
} }
} }
}
void OnTimeout() override void OnTimeout() override
{ {

View File

@@ -2455,8 +2455,6 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, con
if (!CargoSpec::Get(housespec->accepts_cargo[2])->IsValid()) { if (!CargoSpec::Get(housespec->accepts_cargo[2])->IsValid()) {
housespec->cargo_acceptance[2] = 0; housespec->cargo_acceptance[2] = 0;
} }
_loaded_newgrf_features.has_newhouses = true;
break; break;
} }
@@ -9194,8 +9192,6 @@ void ResetNewGRFData()
_loaded_newgrf_features.has_2CC = false; _loaded_newgrf_features.has_2CC = false;
_loaded_newgrf_features.used_liveries = 1 << LS_DEFAULT; _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.shore = SHORE_REPLACE_NONE;
_loaded_newgrf_features.tram = TRAMWAY_REPLACE_DEPOT_NONE; _loaded_newgrf_features.tram = TRAMWAY_REPLACE_DEPOT_NONE;
@@ -9715,7 +9711,6 @@ static void FinaliseIndustriesArray()
} }
_industry_mngr.SetEntitySpec(indsp); _industry_mngr.SetEntitySpec(indsp);
_loaded_newgrf_features.has_newindustries = true;
} }
} }
} }

View File

@@ -289,8 +289,6 @@ enum TramReplacement {
struct GRFLoadedFeatures { struct GRFLoadedFeatures {
bool has_2CC; ///< Set if any vehicle is loaded which uses 2cc (two company colours). 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. 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. ShoreReplacement shore; ///< In which way shore sprites were replaced.
TramReplacement tram; ///< In which way tram depots were replaced. TramReplacement tram; ///< In which way tram depots were replaced.
}; };

View File

@@ -140,8 +140,6 @@ void IncreaseBuildingCount(Town *t, HouseID house_id)
{ {
HouseClassID class_id = HouseSpec::Get(house_id)->class_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]++; t->cache.building_counts.id_count[house_id]++;
_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; 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 (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]--; if (_building_counts.id_count[house_id] > 0) _building_counts.id_count[house_id]--;

View File

@@ -32,10 +32,6 @@
#include "os/windows/string_uniscribe.h" #include "os/windows/string_uniscribe.h"
#endif #endif
#if defined(WITH_COCOA)
#include "os/macosx/string_osx.h"
#endif
#ifdef WITH_ICU_I18N #ifdef WITH_ICU_I18N
/* Required by strnatcmp. */ /* Required by strnatcmp. */
#include <unicode/ustring.h> #include <unicode/ustring.h>
@@ -43,6 +39,10 @@
#include "gfx_func.h" #include "gfx_func.h"
#endif /* WITH_ICU_I18N */ #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 /* 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. */ * tasks. As such this one must be allowed, and makes sure it's terminated. */
#include "safeguards.h" #include "safeguards.h"

View File

@@ -13,7 +13,9 @@ static size_t ConvertLandscape(const char *value);
/**************************** /****************************
* OTTD specific INI stuff * OTTD specific INI stuff
****************************/ ****************************
* DO NOT edit this file. This file is automatically generated from the contents of /src/table/
*/
/** /**
* Settings-macro usage: * 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 * These are for client-only variables. Here the 'var' refers to an
* entry inside _settings_client. * entry inside _settings_client.
* 3. SDT_something * 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 * #SettingDesc list / .ini file. Here, 'base' specifies type of the
* struct while 'var' points out the member of the struct (the actual * struct while 'var' points out the member of the struct (the actual
* struct to store it in is implicitly defined by the #SettingDesc * struct to store it in is implicitly defined by the #SettingDesc

View File

@@ -2697,8 +2697,7 @@ static CommandCost CheckCanBuildHouse(HouseID house, const Town *t)
{ {
const HouseSpec *hs = HouseSpec::Get(house); const HouseSpec *hs = HouseSpec::Get(house);
if (_loaded_newgrf_features.has_newhouses && !_generating_world && if (!_generating_world && _game_mode != GM_EDITOR && (hs->extra_flags & BUILDING_IS_HISTORICAL) != 0) {
_game_mode != GM_EDITOR && (hs->extra_flags & BUILDING_IS_HISTORICAL) != 0) {
return CMD_ERROR; return CMD_ERROR;
} }
@@ -2836,8 +2835,7 @@ static bool BuildTownHouse(Town *t, TileIndex tile)
if (IsHouseTypeAllowed((HouseID)i, above_snowline, zone).Failed()) continue; if (IsHouseTypeAllowed((HouseID)i, above_snowline, zone).Failed()) continue;
if (IsAnotherHouseTypeAllowedInTown(t, (HouseID)i).Failed()) continue; if (IsAnotherHouseTypeAllowedInTown(t, (HouseID)i).Failed()) continue;
/* Without NewHouses, all houses have probability '1' */ uint cur_prob = HouseSpec::Get(i)->probability;
uint cur_prob = (_loaded_newgrf_features.has_newhouses ? HouseSpec::Get(i)->probability : 1);
probability_max += cur_prob; probability_max += cur_prob;
probs[num] = cur_prob; probs[num] = cur_prob;
houses[num++] = (HouseID)i; houses[num++] = (HouseID)i;

View File

@@ -382,9 +382,7 @@ static void DrawSurfaceToScreen()
} else { } else {
if (_sdl_surface != _sdl_realscreen) { if (_sdl_surface != _sdl_realscreen) {
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
SDL_BlitSurface( SDL_BlitSurface(_sdl_surface, &_dirty_rects[i], _sdl_realscreen, &_dirty_rects[i]);
_sdl_surface, &_dirty_rects[i],
_sdl_realscreen, &_dirty_rects[i]);
} }
} }

View File

@@ -35,7 +35,7 @@
static FVideoDriver_SDL iFVideoDriver_SDL; static FVideoDriver_SDL iFVideoDriver_SDL;
static SDL_Surface *_sdl_screen; static SDL_Surface *_sdl_surface;
static SDL_Surface *_sdl_realscreen; static SDL_Surface *_sdl_realscreen;
static bool _all_modes; static bool _all_modes;
@@ -77,11 +77,11 @@ static void UpdatePalette(bool init = false)
pal[i].unused = 0; 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 /* 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 * possible, instead of using only the default SDL
* palette. This allows us to get more colors exactly * palette. This allows us to get more colors exactly
* right and might allow using better approximations for * 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); 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 /* We're not using real hardware palette, but are letting SDL
* approximate the palette during shadow -> screen copy. To * approximate the palette during shadow -> screen copy. To
* change the palette, we need to recopy the entire screen. * 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 * best mapping of shadow palette colors to real palette
* colors from scratch. * 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); SDL_UpdateRect(_sdl_realscreen, 0, 0, 0, 0);
} }
} }
@@ -159,17 +159,20 @@ static void DrawSurfaceToScreen()
if (n == 0) return; if (n == 0) return;
_num_dirty_rects = 0; _num_dirty_rects = 0;
if (n > MAX_DIRTY_RECTS) { if (n > MAX_DIRTY_RECTS) {
if (_sdl_screen != _sdl_realscreen) { if (_sdl_surface != _sdl_realscreen) {
SDL_BlitSurface(_sdl_screen, nullptr, _sdl_realscreen, nullptr); SDL_BlitSurface(_sdl_surface, nullptr, _sdl_realscreen, nullptr);
} }
SDL_UpdateRect(_sdl_realscreen, 0, 0, 0, 0); SDL_UpdateRect(_sdl_realscreen, 0, 0, 0, 0);
} else { } else {
if (_sdl_screen != _sdl_realscreen) { if (_sdl_surface != _sdl_realscreen) {
for (int i = 0; i < n; i++) { 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); 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"); if (want_hwpalette) DEBUG(driver, 1, "SDL: requesting hardware palette");
/* Free any previously allocated shadow surface */ /* 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 (_sdl_realscreen != nullptr) {
if (_requested_hwpalette != want_hwpalette) { if (_requested_hwpalette != want_hwpalette) {
@@ -379,7 +382,7 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h)
_screen.height = newscreen->h; _screen.height = newscreen->h;
_screen.pitch = newscreen->pitch / (bpp / 8); _screen.pitch = newscreen->pitch / (bpp / 8);
_screen.dst_ptr = newscreen->pixels; _screen.dst_ptr = newscreen->pixels;
_sdl_screen = newscreen; _sdl_surface = newscreen;
/* When in full screen, we will always have the mouse cursor /* When in full screen, we will always have the mouse cursor
* within the window, even though SDL does not give us the * 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) { } else if (SDL_WasInit(SDL_INIT_VIDEO) == 0) {
ret_code = SDL_InitSubSystem(SDL_INIT_VIDEO); ret_code = SDL_InitSubSystem(SDL_INIT_VIDEO);
} }
if (ret_code == -1) return SDL_GetError(); if (ret_code < 0) return SDL_GetError();
GetVideoModes(); GetVideoModes();
if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height)) { if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height)) {