Skip to content

Commit

Permalink
xrGame: implement timestamp on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleivg committed Nov 6, 2018
1 parent 9dae709 commit cdfd42f
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 11 deletions.
6 changes: 5 additions & 1 deletion src/xrGame/Level_network_Demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ void CLevel::PrepareToSaveDemo()
R_ASSERT(!m_DemoPlay);
string_path demo_name = "";
string_path demo_path;
#ifndef LINUX // FIXME!!!
#ifdef WINDOWS
SYSTEMTIME Time;
GetLocalTime(&Time);
xr_sprintf(demo_name, "xray_%02d-%02d-%02d_%02d-%02d-%02d.demo", Time.wMonth, Time.wDay, Time.wYear, Time.wHour,
Time.wMinute, Time.wSecond);
#else
time_t Time;
time(&Time);
xr_sprintf(demo_name, "xray_%s.demo", ctime(&Time));
#endif
Msg("Demo would be stored in - %s", demo_name);
FS.update_path(demo_path, "$logs$", demo_name);
Expand Down
8 changes: 6 additions & 2 deletions src/xrGame/game_cl_base_weapon_usage_statistic_save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ void WeaponUsageStatistic::SaveData()
return;

string64 GameType;
#ifndef LINUX // FIXME!!!
SYSTEMTIME Time;
switch (GameID())
{
case eGameIDDeathmatch: xr_sprintf(GameType, "dm"); break;
Expand All @@ -80,9 +78,15 @@ void WeaponUsageStatistic::SaveData()
case eGameIDCaptureTheArtefact: xr_sprintf(GameType, "cta"); break;
default: return; break;
};
#ifdef WINDOWS
SYSTEMTIME Time;
GetLocalTime(&Time);
xr_sprintf(mFileName, "(%s)_(%s)_%02d.%02d.%02d_%02d.%02d.%02d.wus", *(Level().name()), GameType, Time.wMonth,
Time.wDay, Time.wYear, Time.wHour, Time.wMinute, Time.wSecond);
#else
time_t Time;
time(&Time);
xr_sprintf(mFileName, "(%s)_(%s)_%s.wus", *(Level().name()), GameType, ctime(&Time));
#endif
//---------------------------------------------------------
FS.update_path(mFileName, "$logs$", mFileName);
Expand Down
14 changes: 11 additions & 3 deletions src/xrGame/game_cl_mp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1526,12 +1526,17 @@ void game_cl_mp::SendCollectedData(u8 const* buffer, u32 buffer_size, u32 uncomp
upload_memory_writer.pointer(), upload_memory_writer.size(), sending_cb, uncompressed_size);
};

#ifndef LINUX // FIXME!!!
#ifdef WINDOWS
void game_cl_mp::generate_file_name(string_path& file_name, LPCSTR file_suffix, SYSTEMTIME const& date_time)
{
xr_sprintf(file_name, "%02d%02d%02d-%02d%02d%02d_%s", date_time.wYear % 100, date_time.wMonth, date_time.wDay,
date_time.wHour, date_time.wMinute, date_time.wSecond, file_suffix);
}
#else
void game_cl_mp::generate_file_name(string_path& file_name, LPCSTR file_suffix, time_t& date_time)
{
xr_sprintf(file_name, "%s_%s", ctime(date_time), file_suffix);

This comment has been minimized.

Copy link
@Zegeri

Zegeri Nov 15, 2018

Contributor

ctime(date_time) casts implicitly a long(underlying type of time_t) to time_t* and will probably crash. The -fpermissive flag allows this cast.

}
#endif

LPCSTR game_cl_mp::make_file_name(LPCSTR session_id, string_path& dest)
Expand Down Expand Up @@ -1575,11 +1580,14 @@ void game_cl_mp::PrepareToReceiveFile(
string_path screen_shot_fn;
LPCSTR dest_file_name = NULL;
STRCONCAT(dest_file_name, make_file_name(client_session_id.c_str(), screen_shot_fn));
#ifndef LINUX // FIXME!!!
#ifdef WINDOWS // FIXME!!!
SYSTEMTIME date_time;
GetLocalTime(&date_time);
generate_file_name(screen_shot_fn, dest_file_name, date_time);
#else
time_t date_time;
time(&date_time);
#endif
generate_file_name(screen_shot_fn, dest_file_name, date_time);

fr_callback_binder* tmp_binder = get_receiver_cb_binder();
if (!tmp_binder)
Expand Down
4 changes: 3 additions & 1 deletion src/xrGame/game_cl_mp.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,10 @@ class game_cl_mp : public game_cl_GameState

void __stdcall sending_screenshot_callback(file_transfer::sending_status_t status, u32 bytes_sent, u32 data_size);
//-------------------------------------------------------------------------------------------------
#ifndef LINUX
#ifdef WINDOWS
static void generate_file_name(string_path& file_name, LPCSTR file_suffix, SYSTEMTIME const& date_time);
#else
static void generate_file_name(string_path& file_name, LPCSTR file_suffix, time_t& date_time);
#endif
static LPCSTR make_file_name(LPCSTR session_id, string_path& dest);
//-------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/screenshot_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ void screenshot_manager::process_screenshot(bool singlecore)
}
m_make_start_event = CreateEvent(NULL, FALSE, TRUE, NULL);
m_make_done_event = CreateEvent(NULL, FALSE, FALSE, NULL);
thread_spawn(&screenshot_manager::screenshot_maker_thread, "screenshot_maker", 0, this);
#endif
thread_spawn(&screenshot_manager::screenshot_maker_thread, "screenshot_maker", 0, this);
}
void __stdcall screenshot_manager::jpeg_compress_cb(long progress)
{
Expand Down
12 changes: 9 additions & 3 deletions src/xrGame/screenshot_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,14 @@ void clientdata_proxy::save_proxy_screenshot()
LPCSTR dest_file_name = NULL;
STRCONCAT(dest_file_name, clgame->make_file_name(m_cheater_name.c_str(), screenshot_fn), "_",
(m_cheater_digest.size() ? clgame->make_file_name(m_cheater_digest.c_str(), str_digest) : "nulldigest"));
#ifndef LINUX // FIXME!!!
#ifdef WINDOWS
SYSTEMTIME date_time;
GetLocalTime(&date_time);
clgame->generate_file_name(screenshot_fn, dest_file_name, date_time);
#else
time_t date_time;
time(&date_time);
#endif
clgame->generate_file_name(screenshot_fn, dest_file_name, date_time);

clgame->decompress_and_save_screenshot(
screenshot_fn, my_proxy_mem_file.pointer(), my_proxy_mem_file.size(), m_receiver->get_user_param());
Expand All @@ -160,8 +163,11 @@ void clientdata_proxy::save_proxy_config()
#ifndef LINUX // FIXME!!!
SYSTEMTIME date_time;
GetLocalTime(&date_time);
clgame->generate_file_name(dest_file_name, fn_suffix, date_time);
#else
time_t date_time;
time(&date_time);
#endif
clgame->generate_file_name(dest_file_name, fn_suffix, date_time);
IWriter* tmp_writer = FS.w_open("$screenshots$", dest_file_name);
if (!tmp_writer)
return;
Expand Down

0 comments on commit cdfd42f

Please sign in to comment.