Merge pull request #1 from JGRennison/jgrpp

Synchronize with forked repository
This commit is contained in:
Andreas Schmitt
2021-06-11 23:13:01 +02:00
committed by GitHub
17 changed files with 45 additions and 31 deletions

View File

@@ -71,7 +71,7 @@ Company::Company(uint16 name_1, bool is_ai)
this->purchase_land_limit = (uint32)_settings_game.construction.purchase_land_frame_burst << 16; this->purchase_land_limit = (uint32)_settings_game.construction.purchase_land_frame_burst << 16;
this->build_object_limit = (uint32)_settings_game.construction.build_object_frame_burst << 16; this->build_object_limit = (uint32)_settings_game.construction.build_object_frame_burst << 16;
for (uint j = 0; j < 4; j++) this->share_owners[j] = COMPANY_SPECTATOR; for (uint j = 0; j < 4; j++) this->share_owners[j] = INVALID_OWNER;
InvalidateWindowData(WC_PERFORMANCE_DETAIL, 0, INVALID_COMPANY); InvalidateWindowData(WC_PERFORMANCE_DETAIL, 0, INVALID_COMPANY);
} }

View File

@@ -495,7 +495,7 @@ struct CompanyFinancesWindow : Window {
} }
} }
bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override
{ {
switch (widget) { switch (widget) {
case WID_CF_INCREASE_LOAN: { case WID_CF_INCREASE_LOAN: {

View File

@@ -60,8 +60,8 @@ DEFINE_POOL_METHOD(inline void)::ResizeFor(size_t index)
this->data = ReallocT(this->data, new_size); this->data = ReallocT(this->data, new_size);
MemSetT(this->data + this->size, 0, new_size - this->size); MemSetT(this->data + this->size, 0, new_size - this->size);
this->free_bitmap = ReallocT(this->free_bitmap, CeilDiv(new_size, 64)); this->free_bitmap = ReallocT(this->free_bitmap, CeilDivT<size_t>(new_size, 64));
MemSetT(this->free_bitmap + CeilDiv(this->size, 64), 0, CeilDiv(new_size, 64) - CeilDiv(this->size, 64)); MemSetT(this->free_bitmap + CeilDivT<size_t>(this->size, 64), 0, CeilDivT<size_t>(new_size, 64) - CeilDivT<size_t>(this->size, 64));
if (new_size % 64 != 0) { if (new_size % 64 != 0) {
this->free_bitmap[new_size / 64] |= (~((uint64) 0)) << (new_size % 64); this->free_bitmap[new_size / 64] |= (~((uint64) 0)) << (new_size % 64);
} }
@@ -75,8 +75,8 @@ DEFINE_POOL_METHOD(inline void)::ResizeFor(size_t index)
*/ */
DEFINE_POOL_METHOD(inline size_t)::FindFirstFree() DEFINE_POOL_METHOD(inline size_t)::FindFirstFree()
{ {
uint bitmap_index = this->first_free / 64; size_t bitmap_index = this->first_free / 64;
uint bitmap_end = CeilDiv(this->first_unused, 64); size_t bitmap_end = CeilDivT<size_t>(this->first_unused, 64);
for (; bitmap_index < bitmap_end; bitmap_index++) { for (; bitmap_index < bitmap_end; bitmap_index++) {
uint64 available = ~this->free_bitmap[bitmap_index]; uint64 available = ~this->free_bitmap[bitmap_index];

View File

@@ -333,10 +333,12 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
Backup<CompanyID> cur_company2(_current_company, FILE_LINE); Backup<CompanyID> cur_company2(_current_company, FILE_LINE);
const Company *c = Company::Get(old_owner); const Company *c = Company::Get(old_owner);
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (c->share_owners[i] == INVALID_OWNER) continue;
if (c->bankrupt_value == 0 && c->share_owners[i] == new_owner) { if (c->bankrupt_value == 0 && c->share_owners[i] == new_owner) {
/* You are the one buying the company; so don't sell the shares back to you. */ /* You are the one buying the company; so don't sell the shares back to you. */
Company::Get(new_owner)->share_owners[i] = COMPANY_SPECTATOR; Company::Get(new_owner)->share_owners[i] = INVALID_OWNER;
} else if (c->share_owners[i] != INVALID_OWNER) { } else {
cur_company2.Change(c->share_owners[i]); cur_company2.Change(c->share_owners[i]);
/* Sell the shares */ /* Sell the shares */
CommandCost res = DoCommand(0, old_owner, 0, DC_EXEC | DC_BANKRUPT, CMD_SELL_SHARE_IN_COMPANY); CommandCost res = DoCommand(0, old_owner, 0, DC_EXEC | DC_BANKRUPT, CMD_SELL_SHARE_IN_COMPANY);

View File

@@ -70,17 +70,17 @@ private:
public: public:
SpriteFontCache(FontSize fs); SpriteFontCache(FontSize fs);
~SpriteFontCache(); ~SpriteFontCache();
virtual SpriteID GetUnicodeGlyph(WChar key); virtual SpriteID GetUnicodeGlyph(WChar key) override;
virtual void SetUnicodeGlyph(WChar key, SpriteID sprite); virtual void SetUnicodeGlyph(WChar key, SpriteID sprite) override;
virtual void InitializeUnicodeGlyphMap() override; virtual void InitializeUnicodeGlyphMap() override;
virtual void ClearFontCache(); virtual void ClearFontCache() override;
virtual const Sprite *GetGlyph(GlyphID key); virtual const Sprite *GetGlyph(GlyphID key) override;
virtual uint GetGlyphWidth(GlyphID key); virtual uint GetGlyphWidth(GlyphID key) override;
virtual bool GetDrawGlyphShadow(); virtual bool GetDrawGlyphShadow() override;
virtual GlyphID MapCharToGlyph(WChar key) { assert(IsPrintable(key)); return SPRITE_GLYPH | key; } virtual GlyphID MapCharToGlyph(WChar key) override { assert(IsPrintable(key)); return SPRITE_GLYPH | key; }
virtual const void *GetFontTable(uint32 tag, size_t &length) { length = 0; return nullptr; } virtual const void *GetFontTable(uint32 tag, size_t &length) override { length = 0; return nullptr; }
virtual const char *GetFontName() { return "sprite"; } virtual const char *GetFontName() { return "sprite"; }
virtual bool IsBuiltInFont() { return true; } virtual bool IsBuiltInFont() override { return true; }
}; };
/** /**

View File

@@ -2185,6 +2185,8 @@ void UpdateGUIZoom()
_gui_zoom = static_cast<ZoomLevel>(_gui_zoom_cfg); _gui_zoom = static_cast<ZoomLevel>(_gui_zoom_cfg);
} }
ZoomLevel old_font_zoom = _font_zoom;
/* Determine real font zoom to use. */ /* Determine real font zoom to use. */
if (_font_zoom_cfg == ZOOM_LVL_CFG_AUTO) { if (_font_zoom_cfg == ZOOM_LVL_CFG_AUTO) {
_font_zoom = static_cast<ZoomLevel>(VideoDriver::GetInstance()->GetSuggestedUIZoom()); _font_zoom = static_cast<ZoomLevel>(VideoDriver::GetInstance()->GetSuggestedUIZoom());
@@ -2192,6 +2194,10 @@ void UpdateGUIZoom()
_font_zoom = static_cast<ZoomLevel>(_font_zoom_cfg); _font_zoom = static_cast<ZoomLevel>(_font_zoom_cfg);
} }
if (old_font_zoom != _font_zoom) {
ClearFontCache();
}
UpdateFontHeightCache(); UpdateFontHeightCache();
} }

View File

@@ -397,6 +397,7 @@ static void UpdateRouteStepSpriteSize()
_vp_route_step_subsprite.top = 0; _vp_route_step_subsprite.top = 0;
} }
#if !defined(DEDICATED)
/* multi can be density, field type, ... */ /* multi can be density, field type, ... */
static SpriteID GetSpriteIDForClearGround(const ClearGround cg, const Slope slope, const uint multi) static SpriteID GetSpriteIDForClearGround(const ClearGround cg, const Slope slope, const uint multi)
{ {
@@ -415,6 +416,7 @@ static SpriteID GetSpriteIDForClearGround(const ClearGround cg, const Slope slop
default: NOT_REACHED(); default: NOT_REACHED();
} }
} }
#endif /* !DEDICATED */
/** Once the sprites are loaded, we can determine main colours of ground/water/... */ /** Once the sprites are loaded, we can determine main colours of ground/water/... */
void GfxDetermineMainColours() void GfxDetermineMainColours()

View File

@@ -586,7 +586,7 @@ public:
void SendCommand(Packet *p, const CommandPacket *cp); void SendCommand(Packet *p, const CommandPacket *cp);
virtual std::string GetDebugInfo() const; virtual std::string GetDebugInfo() const;
virtual void LogSentPacket(const Packet &pkt); virtual void LogSentPacket(const Packet &pkt) override;
}; };
#endif /* NETWORK_CORE_TCP_GAME_H */ #endif /* NETWORK_CORE_TCP_GAME_H */

View File

@@ -200,7 +200,7 @@ struct DeterministicSpriteGroup : SpriteGroup {
void AnalyseCallbacks(AnalyseCallbackOperation &op) const override; void AnalyseCallbacks(AnalyseCallbackOperation &op) const override;
protected: protected:
const SpriteGroup *Resolve(ResolverObject &object) const; const SpriteGroup *Resolve(ResolverObject &object) const override;
}; };
enum RandomizedSpriteGroupCompareMode { enum RandomizedSpriteGroupCompareMode {
@@ -224,7 +224,7 @@ struct RandomizedSpriteGroup : SpriteGroup {
void AnalyseCallbacks(AnalyseCallbackOperation &op) const override; void AnalyseCallbacks(AnalyseCallbackOperation &op) const override;
protected: protected:
const SpriteGroup *Resolve(ResolverObject &object) const; const SpriteGroup *Resolve(ResolverObject &object) const override;
}; };
@@ -250,7 +250,7 @@ struct CallbackResultSpriteGroup : SpriteGroup {
} }
uint16 result; uint16 result;
uint16 GetCallbackResult() const { return this->result; } uint16 GetCallbackResult() const override { return this->result; }
void AnalyseCallbacks(AnalyseCallbackOperation &op) const override; void AnalyseCallbacks(AnalyseCallbackOperation &op) const override;
}; };

View File

@@ -1820,7 +1820,6 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
case OCV_COUNTER_VALUE: case OCV_COUNTER_VALUE:
case OCV_TIME_DATE: case OCV_TIME_DATE:
case OCV_TIMETABLE: case OCV_TIMETABLE:
if (data >= (1 << 16)) return CMD_ERROR;
break; break;
default: default:

View File

@@ -72,6 +72,7 @@
#include "scope_info.h" #include "scope_info.h"
#include "viewport_func.h" #include "viewport_func.h"
#include "gui.h" #include "gui.h"
#include "statusbar_gui.h"
#include "void_map.h" #include "void_map.h"
#include "station_base.h" #include "station_base.h"
@@ -1306,6 +1307,7 @@ static bool UpdateTimeSettings(int32 p1)
{ {
SetupTimeSettings(); SetupTimeSettings();
InvalidateVehTimetableWindow(p1); InvalidateVehTimetableWindow(p1);
InvalidateWindowData(WC_STATUS_BAR, 0, SBI_REINIT);
MarkWholeScreenDirty(); MarkWholeScreenDirty();
return true; return true;
} }

View File

@@ -580,7 +580,6 @@ struct GameOptionsWindow : Window {
GfxClearSpriteCache(); GfxClearSpriteCache();
_font_zoom_cfg = new_zoom; _font_zoom_cfg = new_zoom;
UpdateGUIZoom(); UpdateGUIZoom();
ClearFontCache();
LoadStringWidthTable(); LoadStringWidthTable();
UpdateAllVirtCoords(); UpdateAllVirtCoords();
ReInitAllWindows(true); ReInitAllWindows(true);
@@ -1904,7 +1903,6 @@ static SettingsContainer &GetSettingsTree()
{ {
accounting->Add(new SettingEntry("economy.inflation")); accounting->Add(new SettingEntry("economy.inflation"));
accounting->Add(new SettingEntry("economy.inflation_fixed_dates")); accounting->Add(new SettingEntry("economy.inflation_fixed_dates"));
accounting->Add(new SettingEntry("economy.day_length_factor"));
accounting->Add(new SettingEntry("difficulty.initial_interest")); accounting->Add(new SettingEntry("difficulty.initial_interest"));
accounting->Add(new SettingEntry("difficulty.max_loan")); accounting->Add(new SettingEntry("difficulty.max_loan"));
accounting->Add(new SettingEntry("difficulty.subsidy_multiplier")); accounting->Add(new SettingEntry("difficulty.subsidy_multiplier"));
@@ -2122,6 +2120,7 @@ static SettingsContainer &GetSettingsTree()
treedist->Add(new SettingEntry("construction.tree_growth_rate")); treedist->Add(new SettingEntry("construction.tree_growth_rate"));
} }
environment->Add(new SettingEntry("economy.day_length_factor"));
environment->Add(new SettingEntry("station.modified_catchment")); environment->Add(new SettingEntry("station.modified_catchment"));
environment->Add(new SettingEntry("station.catchment_increase")); environment->Add(new SettingEntry("station.catchment_increase"));
environment->Add(new SettingEntry("station.cargo_class_rating_wait_time")); environment->Add(new SettingEntry("station.cargo_class_rating_wait_time"));

View File

@@ -115,8 +115,8 @@ struct StatusBarWindow : Window {
Dimension d; Dimension d;
switch (widget) { switch (widget) {
case WID_S_LEFT: case WID_S_LEFT:
SetDParamMaxValue(0, MAX_YEAR * DAYS_IN_YEAR); SetDParam(0, (uint64)MAX_YEAR * (uint64)DAYS_IN_YEAR * (uint64)DAY_TICKS * (uint64)_settings_game.economy.day_length_factor);
d = GetStringBoundingBox(STR_WHITE_DATE_LONG); d = GetStringBoundingBox(STR_WHITE_DATE_WALLCLOCK_LONG);
break; break;
case WID_S_RIGHT: { case WID_S_RIGHT: {
@@ -210,6 +210,9 @@ struct StatusBarWindow : Window {
this->ticker_scroll = TICKER_STOP; // reset ticker ... this->ticker_scroll = TICKER_STOP; // reset ticker ...
this->reminder_timeout.SetInterval(REMINDER_STOP); // ... and reminder this->reminder_timeout.SetInterval(REMINDER_STOP); // ... and reminder
break; break;
case SBI_REINIT:
this->ReInit();
break;
} }
} }

View File

@@ -17,6 +17,7 @@ enum StatusBarInvalidate {
SBI_SHOW_TICKER, ///< start scrolling news SBI_SHOW_TICKER, ///< start scrolling news
SBI_SHOW_REMINDER, ///< show a reminder (dot on the right side of the statusbar) SBI_SHOW_REMINDER, ///< show a reminder (dot on the right side of the statusbar)
SBI_NEWS_DELETED, ///< abort current news display (active news were deleted) SBI_NEWS_DELETED, ///< abort current news display (active news were deleted)
SBI_REINIT, ///< reinit status bar
SBI_END SBI_END
}; };

View File

@@ -38,9 +38,9 @@ int CDECL seprintf(char *str, const char *last, const char *format, ...) WARN_FO
int CDECL vseprintf(char *str, const char *last, const char *format, va_list ap) WARN_FORMAT(3, 0); int CDECL vseprintf(char *str, const char *last, const char *format, va_list ap) WARN_FORMAT(3, 0);
char *CDECL str_fmt(const char *str, ...) WARN_FORMAT(1, 2); char *CDECL str_fmt(const char *str, ...) WARN_FORMAT(1, 2);
char *str_vfmt(const char *str, va_list ap); char *str_vfmt(const char *str, va_list ap) WARN_FORMAT(1, 0);
std::string CDECL stdstr_fmt(const char *str, ...) WARN_FORMAT(1, 2); std::string CDECL stdstr_fmt(const char *str, ...) WARN_FORMAT(1, 2);
std::string stdstr_vfmt(const char *str, va_list va); std::string stdstr_vfmt(const char *str, va_list va) WARN_FORMAT(1, 0);
char *str_validate(char *str, const char *last, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK); char *str_validate(char *str, const char *last, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK);
std::string str_validate(const std::string &str, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK); std::string str_validate(const std::string &str, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK);

View File

@@ -4794,7 +4794,7 @@ max = 3
str = STR_CONFIG_SETTING_DATE_WITH_TIME str = STR_CONFIG_SETTING_DATE_WITH_TIME
strval = STR_CONFIG_SETTING_DATE_WITH_TIME_NONE strval = STR_CONFIG_SETTING_DATE_WITH_TIME_NONE
strhelp = STR_CONFIG_SETTING_DATE_WITH_TIME_HELPTEXT strhelp = STR_CONFIG_SETTING_DATE_WITH_TIME_HELPTEXT
proc = RedrawScreen proc = UpdateTimeSettings
[SDTC_BOOL] [SDTC_BOOL]
var = gui.timetable_start_text_entry var = gui.timetable_start_text_entry

View File

@@ -874,8 +874,8 @@ static uint ConvertIntegerValue(TraceRestrictValueType type, uint in, bool to_di
case TRVT_SPEED: case TRVT_SPEED:
return to_display return to_display
? ConvertSpeedToDisplaySpeed(in) * 10 / 16 ? ConvertKmhishSpeedToDisplaySpeed(in)
: ConvertDisplaySpeedToSpeed(in) * 16 / 10; : ConvertDisplaySpeedToKmhishSpeed(in);
case TRVT_WEIGHT: case TRVT_WEIGHT:
return to_display return to_display