Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dll/dll/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ class Settings {
private:
CSteamID steam_id{}; // user id
CGameID game_id{};

std::chrono::system_clock::time_point purchase_date{};

std::string name{};
std::string language{}; // default "english"
CSteamID lobby_id = k_steamIDNil;
Expand Down Expand Up @@ -378,6 +381,9 @@ class Settings {

void set_game_id(CGameID game_id);

std::chrono::system_clock::time_point get_purchase_date();
void set_purchase_date(std::chrono::system_clock::time_point purchase_date);

void set_lobby(CSteamID lobby_id);
CSteamID get_lobby();

Expand Down
10 changes: 10 additions & 0 deletions dll/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ const std::string& Settings::get_supported_languages() const
return this->supported_languages;
}

std::chrono::system_clock::time_point Settings::get_purchase_date()
{
return purchase_date;
}

void Settings::set_purchase_date(std::chrono::system_clock::time_point purchase_date)
{
this->purchase_date = purchase_date;
}

void Settings::set_game_id(CGameID game_id)
{
this->game_id = game_id;
Expand Down
25 changes: 25 additions & 0 deletions dll/settings_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,29 @@ static std::set<std::string> parse_supported_languages(class Local_Storage *loca
return supported_languages;
}

static void parse_purchase_date(class Settings* settings_client, Settings* settings_server)
{
const char* raw_purchase_date = ini.GetValue("app::general", "purchase_date", "");

std::chrono::system_clock::time_point purchase_date;

std::tm time{};
std::istringstream is{ raw_purchase_date };
is.imbue(std::locale("")); // Default to system locale
is >> std::get_time(&time, "%Y/%m/%d %H:%M:%S");

// if date is formatted incorrectly
if (is.fail()) {
Copy link

Copilot AI Jun 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a log warning here when parsing fails, to help with diagnosing misconfigured purchase dates.

Copilot uses AI. Check for mistakes.
// default to 4 days ago
purchase_date = startup_time - std::chrono::hours(24 * 4);
} else {
purchase_date = std::chrono::system_clock::from_time_t(std::mktime(&time));
}

settings_client->set_purchase_date(purchase_date);
settings_server->set_purchase_date(purchase_date);
}

// app::dlcs
static void parse_dlc(class Settings *settings_client, class Settings *settings_server)
{
Expand Down Expand Up @@ -1789,6 +1812,8 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
settings_client->set_supported_languages(supported_languages);
settings_server->set_supported_languages(supported_languages);

parse_purchase_date(settings_client, settings_server);

parse_simple_features(settings_client, settings_server);
parse_stats_features(settings_client, settings_server);

Expand Down
7 changes: 2 additions & 5 deletions dll/steam_apps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,8 @@ uint32 Steam_Apps::GetEarliestPurchaseUnixTime( AppId_t nAppID )
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (nAppID == 0) return 0; // steam returns 0
if (nAppID == UINT32_MAX) return 0; // steam returns 0
auto t =
// 4 days ago
startup_time
- std::chrono::hours(24 * 4);
auto duration = std::chrono::duration_cast<std::chrono::seconds>(t.time_since_epoch());

auto duration = std::chrono::duration_cast<std::chrono::seconds>(settings->get_purchase_date().time_since_epoch());
if (nAppID == settings->get_local_game_id().AppID() || settings->hasDLC(nAppID)) {
return (uint32)duration.count();
}
Expand Down
5 changes: 5 additions & 0 deletions post_build/steam_settings.EXAMPLE/configs.app.EXAMPLE.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ is_beta_branch=0
# otherwise will be ignored by the emu and the default 'public' branch will be used
# default=public
branch_name=public
# the date of purchase, some games use this date to provide preorder stuff
# by default the emu will report a date of purchase that is 4 days ago of game startup
# Date format: YYYY/mm/dd HH:MM:SS
# default=
purchase_date=

[app::dlcs]
# 1=report all DLCs as unlocked
Expand Down