Add string codes for upstream wallclock mode, add upstream language changes

This commit is contained in:
Jonathan G Rennison
2024-02-13 23:26:24 +00:00
parent fc40f485ff
commit b13b2781bd
97 changed files with 11196 additions and 8939 deletions

View File

@@ -131,7 +131,7 @@ void CheckGameCompatibility(NetworkGameInfo &ngi, bool extended)
void FillStaticNetworkServerGameInfo()
{
_network_game_info.use_password = !_settings_client.network.server_password.empty();
_network_game_info.start_date = CalTime::ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1);
_network_game_info.calendar_start = CalTime::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 = MapSizeX();
@@ -157,7 +157,7 @@ const NetworkServerGameInfo *GetCurrentNetworkServerGameInfo()
*/
_network_game_info.companies_on = (byte)Company::GetNumItems();
_network_game_info.spectators_on = NetworkSpectatorCount();
_network_game_info.game_date = CalTime::CurDate();
_network_game_info.calendar_date = CalTime::CurDate();
_network_game_info.ticks_playing = _scaled_tick_counter;
return &_network_game_info;
}
@@ -239,8 +239,8 @@ void SerializeNetworkGameInfo(Packet *p, const NetworkServerGameInfo *info, bool
}
/* NETWORK_GAME_INFO_VERSION = 3 */
p->Send_uint32(info->game_date.base());
p->Send_uint32(info->start_date.base());
p->Send_uint32(info->calendar_date.base());
p->Send_uint32(info->calendar_start.base());
/* NETWORK_GAME_INFO_VERSION = 2 */
p->Send_uint8 (info->companies_max);
@@ -279,8 +279,8 @@ void SerializeNetworkGameInfoExtended(Packet *p, const NetworkServerGameInfo *in
p->Send_uint8(version); // version num
p->Send_uint32(info->game_date.base());
p->Send_uint32(info->start_date.base());
p->Send_uint32(info->calendar_date.base());
p->Send_uint32(info->calendar_start.base());
p->Send_uint8 (info->companies_max);
p->Send_uint8 (info->companies_on);
p->Send_uint8 (info->clients_max); // Used to be max-spectators
@@ -408,8 +408,8 @@ void DeserializeNetworkGameInfo(Packet *p, NetworkGameInfo *info, const GameInfo
}
case 3:
info->game_date = Clamp(p->Recv_uint32(), 0, MAX_DATE.base());
info->start_date = Clamp(p->Recv_uint32(), 0, MAX_DATE.base());
info->calendar_date = Clamp(p->Recv_uint32(), 0, MAX_DATE.base());
info->calendar_start = Clamp(p->Recv_uint32(), 0, MAX_DATE.base());
FALLTHROUGH;
case 2:
@@ -427,8 +427,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->game_date = p->Recv_uint16() + CalTime::DAYS_TILL_ORIGINAL_BASE_YEAR;
info->start_date = p->Recv_uint16() + CalTime::DAYS_TILL_ORIGINAL_BASE_YEAR;
info->calendar_date = p->Recv_uint16() + CalTime::DAYS_TILL_ORIGINAL_BASE_YEAR;
info->calendar_start = p->Recv_uint16() + CalTime::DAYS_TILL_ORIGINAL_BASE_YEAR;
}
if (game_info_version < 6) while (p->Recv_uint8() != 0) {} // Used to contain the map-name.
@@ -463,8 +463,8 @@ void DeserializeNetworkGameInfoExtended(Packet *p, NetworkGameInfo *info)
NewGRFSerializationType newgrf_serialisation = NST_GRFID_MD5;
info->game_date = Clamp(p->Recv_uint32(), 0, MAX_DATE.base());
info->start_date = Clamp(p->Recv_uint32(), 0, MAX_DATE.base());
info->calendar_date = Clamp(p->Recv_uint32(), 0, MAX_DATE.base());
info->calendar_start = Clamp(p->Recv_uint32(), 0, MAX_DATE.base());
info->companies_max = p->Recv_uint8 ();
info->companies_on = p->Recv_uint8 ();
p->Recv_uint8(); // Used to contain max-spectators.

View File

@@ -56,8 +56,8 @@
* - 4 byte lookup table index.
* For v6+ in case of type 2.
*
* 3+ 4 current game date in days since 1-1-0 (DMY)
* 3+ 4 game introduction date in days since 1-1-0 (DMY)
* 3+ 4 current calendar date in days since 1-1-0 (DMY)
* 3+ 4 calendar start date in days since 1-1-0 (DMY)
*
* 2+ 1 maximum number of companies allowed on the server
* 2+ 1 number of companies on the server
@@ -94,8 +94,8 @@ enum NewGRFSerializationType {
*/
struct NetworkServerGameInfo {
GRFConfig *grfconfig; ///< List of NewGRF files used
CalTime::Date start_date; ///< When the game started
CalTime::Date game_date; ///< Current date
CalTime::Date calendar_start;///< When the game started.
CalTime::Date calendar_date; ///< Current calendar date.
uint64_t ticks_playing; ///< Amount of ticks the game has been running unpaused.
uint32_t map_width; ///< Map width
uint32_t map_height; ///< Map height

View File

@@ -40,6 +40,7 @@
#include "../sprite.h"
#include "../settings_internal.h"
#include "../textfile_gui.h"
#include "../timer/timer_game_tick.h"
#include "../widgets/network_widget.h"
@@ -101,7 +102,7 @@ public:
this->Add(std::make_unique<NWidgetLeaf>(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_CLIENTS, STR_NETWORK_SERVER_LIST_CLIENTS_CAPTION, STR_NETWORK_SERVER_LIST_CLIENTS_CAPTION_TOOLTIP));
this->Add(std::make_unique<NWidgetLeaf>(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_MAPSIZE, STR_NETWORK_SERVER_LIST_MAP_SIZE_CAPTION, STR_NETWORK_SERVER_LIST_MAP_SIZE_CAPTION_TOOLTIP));
this->Add(std::make_unique<NWidgetLeaf>(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_DATE, STR_NETWORK_SERVER_LIST_DATE_CAPTION, STR_NETWORK_SERVER_LIST_DATE_CAPTION_TOOLTIP));
this->Add(std::make_unique<NWidgetLeaf>(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_YEARS, STR_NETWORK_SERVER_LIST_YEARS_CAPTION, STR_NETWORK_SERVER_LIST_YEARS_CAPTION_TOOLTIP));
this->Add(std::make_unique<NWidgetLeaf>(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_YEARS, STR_NETWORK_SERVER_LIST_PLAY_TIME_CAPTION, STR_NETWORK_SERVER_LIST_PLAY_TIME_CAPTION_TOOLTIP));
leaf = std::make_unique<NWidgetLeaf>(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_INFO, STR_EMPTY, STR_NETWORK_SERVER_LIST_INFO_ICONS_TOOLTIP);
leaf->SetMinimalSize(14 + GetSpriteSize(SPR_LOCK, nullptr, ZOOM_LVL_OUT_4X).width
@@ -288,18 +289,20 @@ protected:
return (r != 0) ? r < 0 : NGameClientSorter(a, b);
}
/** Sort servers by current date */
static bool NGameDateSorter(NetworkGameList * const &a, NetworkGameList * const &b)
/** Sort servers by calendar date. */
static bool NGameCalendarDateSorter(NetworkGameList * const &a, NetworkGameList * const &b)
{
auto r = a->info.game_date - b->info.game_date;
auto r = a->info.calendar_date - b->info.calendar_date;
return (r != 0) ? r < 0 : NGameClientSorter(a, b);
}
/** Sort servers by the number of days the game is running */
static bool NGameYearsSorter(NetworkGameList * const &a, NetworkGameList * const &b)
/** Sort servers by the number of ticks the game is running. */
static bool NGameTicksPlayingSorter(NetworkGameList * const &a, NetworkGameList * const &b)
{
auto r = a->info.game_date.base() - a->info.start_date.base() - b->info.game_date.base() + b->info.start_date.base();
return (r != 0) ? r < 0: NGameDateSorter(a, b);
if (a->info.ticks_playing == b->info.ticks_playing) {
return NGameClientSorter(a, b);
}
return a->info.ticks_playing < b->info.ticks_playing;
}
/**
@@ -397,18 +400,18 @@ protected:
if (const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(WID_NG_DATE); nwid->current_x != 0) {
/* current date */
Rect date = nwid->GetCurrentRect();
CalTime::YearMonthDay ymd = CalTime::ConvertDateToYMD(cur_item->info.game_date);
CalTime::YearMonthDay ymd = CalTime::ConvertDateToYMD(cur_item->info.calendar_date);
SetDParam(0, ymd.year);
DrawString(date.left, date.right, y + text_y_offset, STR_JUST_INT, TC_BLACK, SA_HOR_CENTER);
}
if (const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(WID_NG_YEARS); nwid->current_x != 0) {
/* number of years the game is running */
/* play time */
Rect years = nwid->GetCurrentRect();
CalTime::YearMonthDay ymd_cur = CalTime::ConvertDateToYMD(cur_item->info.game_date);
CalTime::YearMonthDay ymd_start = CalTime::ConvertDateToYMD(cur_item->info.start_date);
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);
const auto play_time = cur_item->info.ticks_playing / TICKS_PER_SECOND;
SetDParam(0, play_time / 60 / 60);
SetDParam(1, (play_time / 60) % 60);
DrawString(years.left, years.right, y + text_y_offset, STR_NETWORK_SERVER_LIST_PLAY_TIME_SHORT, TC_BLACK, SA_HOR_CENTER);
}
/* draw a lock if the server is password protected */
@@ -660,12 +663,17 @@ public:
StringID invite_or_address = sel->connection_string.starts_with("+") ? STR_NETWORK_SERVER_LIST_INVITE_CODE : STR_NETWORK_SERVER_LIST_SERVER_ADDRESS;
tr.top = DrawStringMultiLine(tr, invite_or_address); // server address / invite code
SetDParam(0, sel->info.start_date);
SetDParam(0, sel->info.calendar_start);
tr.top = DrawStringMultiLine(tr, STR_NETWORK_SERVER_LIST_START_DATE); // start date
SetDParam(0, sel->info.game_date);
SetDParam(0, sel->info.calendar_date);
tr.top = DrawStringMultiLine(tr, STR_NETWORK_SERVER_LIST_CURRENT_DATE); // current date
const auto play_time = sel->info.ticks_playing / TICKS_PER_SECOND;
SetDParam(0, play_time / 60 / 60);
SetDParam(1, (play_time / 60) % 60);
tr.top = DrawStringMultiLine(tr, STR_NETWORK_SERVER_LIST_PLAY_TIME); // play time
if (sel->info.gamescript_version != -1) {
SetDParamStr(0, sel->info.gamescript_name);
SetDParam(1, sel->info.gamescript_version);
@@ -867,8 +875,8 @@ GUIGameServerList::SortFunction * const NetworkGameWindow::sorter_funcs[] = {
&NGameNameSorter,
&NGameClientSorter,
&NGameMapSizeSorter,
&NGameDateSorter,
&NGameYearsSorter,
&NGameCalendarDateSorter,
&NGameTicksPlayingSorter,
&NGameAllowedSorter
};