1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-24 15:09:10 +00:00

Codechange: make TimerGameCalendar Date and Year types strongly typed (#10761)

This commit is contained in:
Patric Stout
2023-08-12 20:14:21 +02:00
committed by GitHub
parent 0238a2b567
commit 299570b2c1
55 changed files with 390 additions and 203 deletions

View File

@@ -227,8 +227,8 @@ void SerializeNetworkGameInfo(Packet *p, const NetworkServerGameInfo *info, bool
}
/* NETWORK_GAME_INFO_VERSION = 3 */
p->Send_uint32(info->game_date);
p->Send_uint32(info->start_date);
p->Send_uint32(static_cast<int32_t>(info->game_date));
p->Send_uint32(static_cast<int32_t>(info->start_date));
/* NETWORK_GAME_INFO_VERSION = 2 */
p->Send_uint8 (info->companies_max);
@@ -323,8 +323,8 @@ void DeserializeNetworkGameInfo(Packet *p, NetworkGameInfo *info, const GameInfo
}
case 3:
info->game_date = Clamp(p->Recv_uint32(), 0, MAX_DATE);
info->start_date = Clamp(p->Recv_uint32(), 0, MAX_DATE);
info->game_date = Clamp(p->Recv_uint32(), 0, static_cast<int32_t>(MAX_DATE));
info->start_date = Clamp(p->Recv_uint32(), 0, static_cast<int32_t>(MAX_DATE));
FALLTHROUGH;
case 2:

View File

@@ -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(TimerGameCalendar::ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1));
p->Send_uint32(static_cast<int32_t>(TimerGameCalendar::ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1)));
p->Send_uint16(Map::SizeX());
p->Send_uint16(Map::SizeY());
@@ -208,7 +208,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendDate()
{
Packet *p = new Packet(ADMIN_PACKET_SERVER_DATE);
p->Send_uint32(TimerGameCalendar::date);
p->Send_uint32(static_cast<int32_t>(TimerGameCalendar::date));
this->SendPacket(p);
return NETWORK_RECV_STATUS_OKAY;
@@ -244,7 +244,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendClientInfo(const NetworkC
p->Send_string(cs == nullptr ? "" : const_cast<NetworkAddress &>(cs->client_address).GetHostname());
p->Send_string(ci->client_name);
p->Send_uint8 (0); // Used to be language
p->Send_uint32(ci->join_date);
p->Send_uint32(static_cast<int32_t>(ci->join_date));
p->Send_uint8 (ci->client_playas);
this->SendPacket(p);
@@ -329,7 +329,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyInfo(const Company
p->Send_string(GetString(STR_PRESIDENT_NAME));
p->Send_uint8 (c->colour);
p->Send_bool (NetworkCompanyIsPassworded(c->index));
p->Send_uint32(c->inaugurated_year);
p->Send_uint32(static_cast<int32_t>(c->inaugurated_year));
p->Send_bool (c->is_ai);
p->Send_uint8 (CeilDiv(c->months_of_bankruptcy, 3)); // send as quarters_of_bankruptcy