Codechange: Move calendar date functions inside TimerGameCalendar (#10753)

This commit is contained in:
Tyler Trahan
2023-05-04 09:14:12 -04:00
committed by GitHub
parent 7669aac865
commit 6501f84b4a
43 changed files with 224 additions and 281 deletions

View File

@@ -13,7 +13,6 @@
#include "game_info.h"
#include "../../core/bitmath_func.hpp"
#include "../../company_base.h"
#include "../../date_func.h"
#include "../../timer/timer_game_calendar.h"
#include "../../debug.h"
#include "../../map_func.h"
@@ -124,7 +123,7 @@ void CheckGameCompatibility(NetworkGameInfo &ngi)
void FillStaticNetworkServerGameInfo()
{
_network_game_info.use_password = !_settings_client.network.server_password.empty();
_network_game_info.start_date = ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1);
_network_game_info.start_date = TimerGameCalendar::ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1);
_network_game_info.clients_max = _settings_client.network.max_clients;
_network_game_info.companies_max = _settings_client.network.max_companies;
_network_game_info.map_width = Map::SizeX();
@@ -256,7 +255,7 @@ void SerializeNetworkGameInfo(Packet *p, const NetworkServerGameInfo *info, bool
*/
void DeserializeNetworkGameInfo(Packet *p, NetworkGameInfo *info, const GameInfoNewGRFLookupTable *newgrf_lookup_table)
{
static const TimerGameCalendar::Date MAX_DATE = ConvertYMDToDate(MAX_YEAR, 11, 31); // December is month 11
static const TimerGameCalendar::Date MAX_DATE = TimerGameCalendar::ConvertYMDToDate(MAX_YEAR, 11, 31); // December is month 11
byte game_info_version = p->Recv_uint8();
NewGRFSerializationType newgrf_serialisation = NST_GRFID_MD5;

View File

@@ -10,7 +10,7 @@
*/
#include "../../stdafx.h"
#include "../../date_func.h"
#include "../../timer/timer_game_calendar.h"
#include "../../debug.h"
#include "tcp_coordinator.h"

View File

@@ -10,7 +10,7 @@
*/
#include "../../stdafx.h"
#include "../../date_func.h"
#include "../../timer/timer_game_calendar.h"
#include "../../debug.h"
#include "tcp_turn.h"

View File

@@ -10,7 +10,7 @@
*/
#include "../../stdafx.h"
#include "../../date_func.h"
#include "../../timer/timer_game_calendar.h"
#include "../../debug.h"
#include "game_info.h"
#include "udp.h"

View File

@@ -9,7 +9,7 @@
#include "../stdafx.h"
#include "../strings_func.h"
#include "../date_func.h"
#include "../timer/timer_game_calendar.h"
#include "../timer/timer_game_calendar.h"
#include "core/game_info.h"
#include "network_admin.h"
@@ -178,7 +178,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendWelcome()
p->Send_string(""); // Used to be map-name.
p->Send_uint32(_settings_game.game_creation.generation_seed);
p->Send_uint8 (_settings_game.game_creation.landscape);
p->Send_uint32(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1));
p->Send_uint32(TimerGameCalendar::ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1));
p->Send_uint16(Map::SizeX());
p->Send_uint16(Map::SizeY());

View File

@@ -9,7 +9,6 @@
#include "../stdafx.h"
#include "../strings_func.h"
#include "../date_func.h"
#include "../fios.h"
#include "network_client.h"
#include "network_gui.h"
@@ -38,6 +37,7 @@
#include "../company_cmd.h"
#include "../timer/timer.h"
#include "../timer/timer_window.h"
#include "../timer/timer_game_calendar.h"
#include "../widgets/network_widget.h"
@@ -432,8 +432,8 @@ protected:
if (nwi_header->IsWidgetVisible(WID_NG_DATE)) {
/* current date */
Rect date = this->GetWidget<NWidgetBase>(WID_NG_DATE)->GetCurrentRect();
YearMonthDay ymd;
ConvertDateToYMD(cur_item->info.game_date, &ymd);
TimerGameCalendar::YearMonthDay ymd;
TimerGameCalendar::ConvertDateToYMD(cur_item->info.game_date, &ymd);
SetDParam(0, ymd.year);
DrawString(date.left, date.right, y + text_y_offset, STR_JUST_INT, TC_BLACK, SA_HOR_CENTER);
}
@@ -441,9 +441,9 @@ protected:
if (nwi_header->IsWidgetVisible(WID_NG_YEARS)) {
/* number of years the game is running */
Rect years = this->GetWidget<NWidgetBase>(WID_NG_YEARS)->GetCurrentRect();
YearMonthDay ymd_cur, ymd_start;
ConvertDateToYMD(cur_item->info.game_date, &ymd_cur);
ConvertDateToYMD(cur_item->info.start_date, &ymd_start);
TimerGameCalendar::YearMonthDay ymd_cur, ymd_start;
TimerGameCalendar::ConvertDateToYMD(cur_item->info.game_date, &ymd_cur);
TimerGameCalendar::ConvertDateToYMD(cur_item->info.start_date, &ymd_start);
SetDParam(0, ymd_cur.year - ymd_start.year);
DrawString(years.left, years.right, y + text_y_offset, STR_JUST_INT, TC_BLACK, SA_HOR_CENTER);
}

View File

@@ -13,7 +13,7 @@
*/
#include "../stdafx.h"
#include "../date_func.h"
#include "../timer/timer_game_calendar.h"
#include "../map_func.h"
#include "../debug.h"
#include "core/game_info.h"