From 9b3f4dff4c77e528a8bc04b5729bd785e4c65fd3 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Tue, 31 Dec 2024 23:20:41 +0100 Subject: [PATCH] Codechange: swap `int + year` to `year + int` This way the operator+ without implicit constructor call is used --- src/network/core/network_game_info.cpp | 4 ++-- src/newgrf.cpp | 2 +- src/newgrf_text.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/network/core/network_game_info.cpp b/src/network/core/network_game_info.cpp index 8073edb247..6f22e24fd2 100644 --- a/src/network/core/network_game_info.cpp +++ b/src/network/core/network_game_info.cpp @@ -366,8 +366,8 @@ void DeserializeNetworkGameInfo(Packet &p, NetworkGameInfo &info, const GameInfo info.clients_on = p.Recv_uint8 (); info.spectators_on = p.Recv_uint8 (); if (game_info_version < 3) { // 16 bits dates got scrapped and are read earlier - info.calendar_date = p.Recv_uint16() + CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR; - info.calendar_start = p.Recv_uint16() + CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR; + info.calendar_date = CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + p.Recv_uint16(); + info.calendar_start = CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + p.Recv_uint16(); } if (game_info_version < 6) while (p.Recv_uint8() != 0) {} // Used to contain the map-name. info.map_width = p.Recv_uint16(); diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 57c861f9de..bae0c25a96 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -1018,7 +1018,7 @@ static ChangeInfoResult CommonVehicleChangeInfo(EngineInfo *ei, int prop, ByteRe { switch (prop) { case 0x00: // Introduction date - ei->base_intro = buf.ReadWord() + CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR; + ei->base_intro = CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + buf.ReadWord(); break; case 0x02: // Decay speed diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp index c62ce6fbe7..ae10192f7b 100644 --- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -905,7 +905,7 @@ char32_t RemapNewGRFStringControlCode(char32_t scc, const char **str, StringPara /* Dates from NewGRFs have 1920-01-01 as their zero point, convert it to OpenTTD's epoch. */ case SCC_NEWGRF_PRINT_WORD_DATE_LONG: - case SCC_NEWGRF_PRINT_WORD_DATE_SHORT: parameters.SetParam(0, _newgrf_textrefstack.PopUnsignedWord() + CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR); break; + case SCC_NEWGRF_PRINT_WORD_DATE_SHORT: parameters.SetParam(0, CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR + _newgrf_textrefstack.PopUnsignedWord()); break; case SCC_NEWGRF_DISCARD_WORD: _newgrf_textrefstack.PopUnsignedWord(); break;