Skip to content

Commit cdfd42f

Browse files
committed
xrGame: implement timestamp on linux
1 parent 9dae709 commit cdfd42f

File tree

6 files changed

+35
-11
lines changed

6 files changed

+35
-11
lines changed

src/xrGame/Level_network_Demo.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ void CLevel::PrepareToSaveDemo()
1818
R_ASSERT(!m_DemoPlay);
1919
string_path demo_name = "";
2020
string_path demo_path;
21-
#ifndef LINUX // FIXME!!!
21+
#ifdef WINDOWS
2222
SYSTEMTIME Time;
2323
GetLocalTime(&Time);
2424
xr_sprintf(demo_name, "xray_%02d-%02d-%02d_%02d-%02d-%02d.demo", Time.wMonth, Time.wDay, Time.wYear, Time.wHour,
2525
Time.wMinute, Time.wSecond);
26+
#else
27+
time_t Time;
28+
time(&Time);
29+
xr_sprintf(demo_name, "xray_%s.demo", ctime(&Time));
2630
#endif
2731
Msg("Demo would be stored in - %s", demo_name);
2832
FS.update_path(demo_path, "$logs$", demo_name);

src/xrGame/game_cl_base_weapon_usage_statistic_save.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ void WeaponUsageStatistic::SaveData()
7070
return;
7171

7272
string64 GameType;
73-
#ifndef LINUX // FIXME!!!
74-
SYSTEMTIME Time;
7573
switch (GameID())
7674
{
7775
case eGameIDDeathmatch: xr_sprintf(GameType, "dm"); break;
@@ -80,9 +78,15 @@ void WeaponUsageStatistic::SaveData()
8078
case eGameIDCaptureTheArtefact: xr_sprintf(GameType, "cta"); break;
8179
default: return; break;
8280
};
81+
#ifdef WINDOWS
82+
SYSTEMTIME Time;
8383
GetLocalTime(&Time);
8484
xr_sprintf(mFileName, "(%s)_(%s)_%02d.%02d.%02d_%02d.%02d.%02d.wus", *(Level().name()), GameType, Time.wMonth,
8585
Time.wDay, Time.wYear, Time.wHour, Time.wMinute, Time.wSecond);
86+
#else
87+
time_t Time;
88+
time(&Time);
89+
xr_sprintf(mFileName, "(%s)_(%s)_%s.wus", *(Level().name()), GameType, ctime(&Time));
8690
#endif
8791
//---------------------------------------------------------
8892
FS.update_path(mFileName, "$logs$", mFileName);

src/xrGame/game_cl_mp.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,12 +1526,17 @@ void game_cl_mp::SendCollectedData(u8 const* buffer, u32 buffer_size, u32 uncomp
15261526
upload_memory_writer.pointer(), upload_memory_writer.size(), sending_cb, uncompressed_size);
15271527
};
15281528

1529-
#ifndef LINUX // FIXME!!!
1529+
#ifdef WINDOWS
15301530
void game_cl_mp::generate_file_name(string_path& file_name, LPCSTR file_suffix, SYSTEMTIME const& date_time)
15311531
{
15321532
xr_sprintf(file_name, "%02d%02d%02d-%02d%02d%02d_%s", date_time.wYear % 100, date_time.wMonth, date_time.wDay,
15331533
date_time.wHour, date_time.wMinute, date_time.wSecond, file_suffix);
15341534
}
1535+
#else
1536+
void game_cl_mp::generate_file_name(string_path& file_name, LPCSTR file_suffix, time_t& date_time)
1537+
{
1538+
xr_sprintf(file_name, "%s_%s", ctime(date_time), file_suffix);
1539+
}
15351540
#endif
15361541

15371542
LPCSTR game_cl_mp::make_file_name(LPCSTR session_id, string_path& dest)
@@ -1575,11 +1580,14 @@ void game_cl_mp::PrepareToReceiveFile(
15751580
string_path screen_shot_fn;
15761581
LPCSTR dest_file_name = NULL;
15771582
STRCONCAT(dest_file_name, make_file_name(client_session_id.c_str(), screen_shot_fn));
1578-
#ifndef LINUX // FIXME!!!
1583+
#ifdef WINDOWS // FIXME!!!
15791584
SYSTEMTIME date_time;
15801585
GetLocalTime(&date_time);
1581-
generate_file_name(screen_shot_fn, dest_file_name, date_time);
1586+
#else
1587+
time_t date_time;
1588+
time(&date_time);
15821589
#endif
1590+
generate_file_name(screen_shot_fn, dest_file_name, date_time);
15831591

15841592
fr_callback_binder* tmp_binder = get_receiver_cb_binder();
15851593
if (!tmp_binder)

src/xrGame/game_cl_mp.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,10 @@ class game_cl_mp : public game_cl_GameState
328328

329329
void __stdcall sending_screenshot_callback(file_transfer::sending_status_t status, u32 bytes_sent, u32 data_size);
330330
//-------------------------------------------------------------------------------------------------
331-
#ifndef LINUX
331+
#ifdef WINDOWS
332332
static void generate_file_name(string_path& file_name, LPCSTR file_suffix, SYSTEMTIME const& date_time);
333+
#else
334+
static void generate_file_name(string_path& file_name, LPCSTR file_suffix, time_t& date_time);
333335
#endif
334336
static LPCSTR make_file_name(LPCSTR session_id, string_path& dest);
335337
//-------------------------------------------------------------------------------------------------

src/xrGame/screenshot_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ void screenshot_manager::process_screenshot(bool singlecore)
264264
}
265265
m_make_start_event = CreateEvent(NULL, FALSE, TRUE, NULL);
266266
m_make_done_event = CreateEvent(NULL, FALSE, FALSE, NULL);
267-
thread_spawn(&screenshot_manager::screenshot_maker_thread, "screenshot_maker", 0, this);
268267
#endif
268+
thread_spawn(&screenshot_manager::screenshot_maker_thread, "screenshot_maker", 0, this);
269269
}
270270
void __stdcall screenshot_manager::jpeg_compress_cb(long progress)
271271
{

src/xrGame/screenshot_server.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,14 @@ void clientdata_proxy::save_proxy_screenshot()
136136
LPCSTR dest_file_name = NULL;
137137
STRCONCAT(dest_file_name, clgame->make_file_name(m_cheater_name.c_str(), screenshot_fn), "_",
138138
(m_cheater_digest.size() ? clgame->make_file_name(m_cheater_digest.c_str(), str_digest) : "nulldigest"));
139-
#ifndef LINUX // FIXME!!!
139+
#ifdef WINDOWS
140140
SYSTEMTIME date_time;
141141
GetLocalTime(&date_time);
142-
clgame->generate_file_name(screenshot_fn, dest_file_name, date_time);
142+
#else
143+
time_t date_time;
144+
time(&date_time);
143145
#endif
146+
clgame->generate_file_name(screenshot_fn, dest_file_name, date_time);
144147

145148
clgame->decompress_and_save_screenshot(
146149
screenshot_fn, my_proxy_mem_file.pointer(), my_proxy_mem_file.size(), m_receiver->get_user_param());
@@ -160,8 +163,11 @@ void clientdata_proxy::save_proxy_config()
160163
#ifndef LINUX // FIXME!!!
161164
SYSTEMTIME date_time;
162165
GetLocalTime(&date_time);
163-
clgame->generate_file_name(dest_file_name, fn_suffix, date_time);
166+
#else
167+
time_t date_time;
168+
time(&date_time);
164169
#endif
170+
clgame->generate_file_name(dest_file_name, fn_suffix, date_time);
165171
IWriter* tmp_writer = FS.w_open("$screenshots$", dest_file_name);
166172
if (!tmp_writer)
167173
return;

0 commit comments

Comments
 (0)