Compare commits

..

No commits in common. "19015c097c41a59107c62487a11273047fccb219" and "44305a0068df6a97cb3db352652f24430f4f27aa" have entirely different histories.

8 changed files with 43 additions and 68 deletions

View File

@ -136,7 +136,7 @@ Steam_Client *get_steam_clientserver_old()
static bool steamclient_has_ipv6_functions_flag; static bool steamclient_has_ipv6_functions_flag;
bool steamclient_has_ipv6_functions() bool steamclient_has_ipv6_functions()
{ {
return steamclient_has_ipv6_functions_flag || get_steam_client()->gameserver_has_ipv6_functions; return steamclient_has_ipv6_functions_flag;
} }
static void *create_client_interface(const char *ver) static void *create_client_interface(const char *ver)

View File

@ -5843,14 +5843,13 @@ STEAMAPI_API SteamAPICall_t SteamAPI_ISteamGameServer_GetServerReputation( IStea
return self->GetServerReputation(); return self->GetServerReputation();
} }
STEAMAPI_API void *SteamAPI_ISteamGameServer_GetPublicIP( intptr_t instancePtr, void *instancePtr_possible ) STEAMAPI_API uint32 SteamAPI_ISteamGameServer_GetPublicIP( intptr_t instancePtr, void *instancePtr_possible )
{ {
//abuse call convention rules to get this working. //TODO: check if this actually works (ret value changed from uint32 to struct)
if (steamclient_has_ipv6_functions()) { if (steamclient_has_ipv6_functions()) {
get_steam_client()->steam_gameserver->GetPublicIP_fix((SteamIPAddress_t *)instancePtr); return ((ISteamGameServer012 *)instancePtr_possible)->GetPublicIP_old();
return (void *)instancePtr;
} else { } else {
return (void *)((ISteamGameServer012 *)instancePtr)->GetPublicIP_old(); return ((ISteamGameServer012 *)instancePtr)->GetPublicIP_old();
} }
} }

View File

@ -109,8 +109,6 @@ Steam_Client::Steam_Client()
steam_gameserver_game_coordinator = new Steam_Game_Coordinator(settings_server, network, callback_results_server, callbacks_server, run_every_runcb); steam_gameserver_game_coordinator = new Steam_Game_Coordinator(settings_server, network, callback_results_server, callbacks_server, run_every_runcb);
steam_masterserver_updater = new Steam_Masterserver_Updater(settings_server, network, callback_results_server, callbacks_server, run_every_runcb); steam_masterserver_updater = new Steam_Masterserver_Updater(settings_server, network, callback_results_server, callbacks_server, run_every_runcb);
gameserver_has_ipv6_functions = false;
last_cb_run = 0; last_cb_run = 0;
PRINT_DEBUG("client init end\n"); PRINT_DEBUG("client init end\n");
} }
@ -305,10 +303,8 @@ ISteamGameServer *Steam_Client::GetISteamGameServer( HSteamUser hSteamUser, HSte
} else if (strcmp(pchVersion, "SteamGameServer012") == 0) { } else if (strcmp(pchVersion, "SteamGameServer012") == 0) {
return (ISteamGameServer *)(void *)(ISteamGameServer012 *)steam_gameserver; return (ISteamGameServer *)(void *)(ISteamGameServer012 *)steam_gameserver;
} else if (strcmp(pchVersion, STEAMGAMESERVER_INTERFACE_VERSION) == 0) { } else if (strcmp(pchVersion, STEAMGAMESERVER_INTERFACE_VERSION) == 0) {
gameserver_has_ipv6_functions = true;
return (ISteamGameServer *)(void *)(ISteamGameServer *)steam_gameserver; return (ISteamGameServer *)(void *)(ISteamGameServer *)steam_gameserver;
} else { } else {
gameserver_has_ipv6_functions = true;
return (ISteamGameServer *)(void *)(ISteamGameServer *)steam_gameserver; return (ISteamGameServer *)(void *)(ISteamGameServer *)steam_gameserver;
} }

View File

@ -139,8 +139,6 @@ public:
unsigned steam_pipe_counter = 1; unsigned steam_pipe_counter = 1;
std::map<HSteamPipe, enum Steam_Pipe> steam_pipes; std::map<HSteamPipe, enum Steam_Pipe> steam_pipes;
bool gameserver_has_ipv6_functions;
Steam_Client(); Steam_Client();
~Steam_Client(); ~Steam_Client();
// Creates a communication pipe to the Steam client. // Creates a communication pipe to the Steam client.

View File

@ -559,12 +559,6 @@ SteamIPAddress_t Steam_GameServer::GetPublicIP()
return ip; return ip;
} }
void Steam_GameServer::GetPublicIP_fix(SteamIPAddress_t *out)
{
PRINT_DEBUG("GetPublicIP_fix\n");
if (out) *out = GetPublicIP();
}
// These are in GameSocketShare mode, where instead of ISteamGameServer creating its own // These are in GameSocketShare mode, where instead of ISteamGameServer creating its own
// socket to talk to the master server on, it lets the game use its socket to forward messages // socket to talk to the master server on, it lets the game use its socket to forward messages
// back and forth. This prevents us from requiring server ops to open up yet another port // back and forth. This prevents us from requiring server ops to open up yet another port

View File

@ -278,7 +278,6 @@ public:
// connect to // connect to
uint32 GetPublicIP_old(); uint32 GetPublicIP_old();
SteamIPAddress_t GetPublicIP(); SteamIPAddress_t GetPublicIP();
void GetPublicIP_fix(SteamIPAddress_t *out);
// These are in GameSocketShare mode, where instead of ISteamGameServer creating its own // These are in GameSocketShare mode, where instead of ISteamGameServer creating its own
// socket to talk to the master server on, it lets the game use its socket to forward messages // socket to talk to the master server on, it lets the game use its socket to forward messages

View File

@ -66,17 +66,6 @@ unsigned int find_leaderboard(std::string name)
return 0; return 0;
} }
nlohmann::detail::iter_impl<nlohmann::json> defined_achievements_find(std::string key)
{
return std::find_if(defined_achievements.begin(), defined_achievements.end(), [key](nlohmann::json& item) {
std::string name = static_cast<std::string const&>(item["name"]);
return key.size() == name.size() && std::equal(name.begin(), name.end(), key.begin(),
[](char a, char b) {
return tolower(a) == tolower(b);
});
});
}
void load_achievements_db() void load_achievements_db()
{ {
std::string file_path = Local_Storage::get_game_settings_path() + achievements_user_file; std::string file_path = Local_Storage::get_game_settings_path() + achievements_user_file;
@ -238,11 +227,10 @@ bool GetAchievement( const char *pchName, bool *pbAchieved )
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
try { try {
auto it = defined_achievements_find(pchName); auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName]( nlohmann::json &item ) {
if (it == defined_achievements.end()) return false; return item["name"].get<std::string>() == pchName;
std::string pch_name = it->value("name", std::string()); });
auto ach = user_achievements.find(pchName);
auto ach = user_achievements.find(pch_name);
if (it != defined_achievements.end() && ach != user_achievements.end()) { if (it != defined_achievements.end() && ach != user_achievements.end()) {
if(pbAchieved != nullptr) *pbAchieved = (*ach)["earned"]; if(pbAchieved != nullptr) *pbAchieved = (*ach)["earned"];
return true; return true;
@ -261,14 +249,13 @@ bool SetAchievement( const char *pchName )
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
try { try {
auto it = defined_achievements_find(pchName); auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
if (it == defined_achievements.end()) return false; return item["name"].get<std::string>() == pchName;
std::string pch_name = it->value("name", std::string()); });
if (it != defined_achievements.end()) { if (it != defined_achievements.end()) {
if (user_achievements.find(pch_name) == user_achievements.end() || user_achievements[pch_name].value("earned", false) == false) { if (user_achievements.find(pchName) == user_achievements.end() || user_achievements[pchName].value("earned", false) == false) {
user_achievements[pch_name]["earned"] = true; user_achievements[pchName]["earned"] = true;
user_achievements[pch_name]["earned_time"] = std::chrono::duration_cast<std::chrono::duration<uint32>>(std::chrono::system_clock::now().time_since_epoch()).count(); user_achievements[pchName]["earned_time"] = std::chrono::duration_cast<std::chrono::duration<uint32>>(std::chrono::system_clock::now().time_since_epoch()).count();
#ifdef EMU_OVERLAY #ifdef EMU_OVERLAY
overlay->AddAchievementNotification(it.value()); overlay->AddAchievementNotification(it.value());
#endif #endif
@ -289,13 +276,12 @@ bool ClearAchievement( const char *pchName )
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
try { try {
auto it = defined_achievements_find(pchName); auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
if (it == defined_achievements.end()) return false; return static_cast<std::string const&>(item["name"]) == pchName;
std::string pch_name = it->value("name", std::string()); });
if (it != defined_achievements.end()) { if (it != defined_achievements.end()) {
user_achievements[pch_name]["earned"] = false; user_achievements[pchName]["earned"] = false;
user_achievements[pch_name]["earned_time"] = static_cast<uint32>(0); user_achievements[pchName]["earned_time"] = static_cast<uint32>(0);
save_achievements(); save_achievements();
return true; return true;
} }
@ -315,11 +301,10 @@ bool GetAchievementAndUnlockTime( const char *pchName, bool *pbAchieved, uint32
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
try { try {
auto it = defined_achievements_find(pchName); auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
if (it == defined_achievements.end()) return false; return static_cast<std::string const&>(item["name"]) == pchName;
std::string pch_name = it->value("name", std::string()); });
auto ach = user_achievements.find(pchName);
auto ach = user_achievements.find(pch_name);
if (it != defined_achievements.end() && ach != user_achievements.end()) { if (it != defined_achievements.end() && ach != user_achievements.end()) {
if(pbAchieved != nullptr) *pbAchieved = (*ach)["earned"]; if(pbAchieved != nullptr) *pbAchieved = (*ach)["earned"];
if(punUnlockTime != nullptr) *punUnlockTime = (*ach)["earned_time"]; if(punUnlockTime != nullptr) *punUnlockTime = (*ach)["earned_time"];
@ -382,7 +367,9 @@ const char * GetAchievementDisplayAttribute( const char *pchName, const char *pc
if (strcmp (pchKey, "name") == 0) { if (strcmp (pchKey, "name") == 0) {
try { try {
auto it = defined_achievements_find(pchName); auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
return static_cast<std::string const&>(item["name"]) == pchName;
});
if (it != defined_achievements.end()) { if (it != defined_achievements.end()) {
return it.value()["displayName"].get_ptr<std::string*>()->c_str(); return it.value()["displayName"].get_ptr<std::string*>()->c_str();
} }
@ -391,7 +378,9 @@ const char * GetAchievementDisplayAttribute( const char *pchName, const char *pc
if (strcmp (pchKey, "desc") == 0) { if (strcmp (pchKey, "desc") == 0) {
try { try {
auto it = defined_achievements_find(pchName); auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
return static_cast<std::string const&>(item["name"]) == pchName;
});
if (it != defined_achievements.end()) { if (it != defined_achievements.end()) {
return it.value()["description"].get_ptr<std::string*>()->c_str(); return it.value()["description"].get_ptr<std::string*>()->c_str();
} }
@ -400,7 +389,9 @@ const char * GetAchievementDisplayAttribute( const char *pchName, const char *pc
if (strcmp (pchKey, "hidden") == 0) { if (strcmp (pchKey, "hidden") == 0) {
try { try {
auto it = defined_achievements_find(pchName); auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
return static_cast<std::string const&>(item["name"]) == pchName;
});
if (it != defined_achievements.end()) { if (it != defined_achievements.end()) {
return it.value()["hidden"].get_ptr<std::string*>()->c_str(); return it.value()["hidden"].get_ptr<std::string*>()->c_str();
} }
@ -415,17 +406,15 @@ const char * GetAchievementDisplayAttribute( const char *pchName, const char *pc
// Calling this w/ N out of N progress will NOT set the achievement, the game must still do that. // Calling this w/ N out of N progress will NOT set the achievement, the game must still do that.
bool IndicateAchievementProgress( const char *pchName, uint32 nCurProgress, uint32 nMaxProgress ) bool IndicateAchievementProgress( const char *pchName, uint32 nCurProgress, uint32 nMaxProgress )
{ {
PRINT_DEBUG("IndicateAchievementProgress %s\n", pchName); PRINT_DEBUG("IndicateAchievementProgress\n");
if (pchName == nullptr) return false; if (pchName == nullptr) return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
try { try {
auto it = defined_achievements_find(pchName); auto it = std::find_if(defined_achievements.begin(), defined_achievements.end(), [pchName](nlohmann::json& item) {
if (it == defined_achievements.end()) return false; return static_cast<std::string const&>(item["name"]) == pchName;
});
std::string pch_name = it->value("name", std::string()); auto ach = user_achievements.find(pchName);
auto ach = user_achievements.find(pch_name);
if (it != defined_achievements.end()) { if (it != defined_achievements.end()) {
bool achieved = false; bool achieved = false;
if ( ach != user_achievements.end()) { if ( ach != user_achievements.end()) {
@ -435,14 +424,14 @@ bool IndicateAchievementProgress( const char *pchName, uint32 nCurProgress, uint
UserAchievementStored_t data = {}; UserAchievementStored_t data = {};
data.m_nGameID = settings->get_local_game_id().ToUint64(); data.m_nGameID = settings->get_local_game_id().ToUint64();
data.m_bGroupAchievement = false; data.m_bGroupAchievement = false;
strncpy(data.m_rgchAchievementName, pch_name.c_str(), k_cchStatNameMax); strncpy(data.m_rgchAchievementName, pchName, k_cchStatNameMax);
if (achieved) { if (achieved) {
data.m_nCurProgress = 0; data.m_nCurProgress = 0;
data.m_nMaxProgress = 0; data.m_nMaxProgress = 0;
} else { } else {
user_achievements[pch_name]["progress"] = nCurProgress; user_achievements[pchName]["progress"] = nCurProgress;
user_achievements[pch_name]["max_progress"] = nMaxProgress; user_achievements[pchName]["max_progress"] = nMaxProgress;
data.m_nCurProgress = nCurProgress; data.m_nCurProgress = nCurProgress;
data.m_nMaxProgress = nMaxProgress; data.m_nMaxProgress = nMaxProgress;
} }

View File

@ -698,7 +698,7 @@ void Steam_Overlay::Callback(Common_Message *msg)
{ {
Steam_Messages const& steam_message = msg->steam_messages(); Steam_Messages const& steam_message = msg->steam_messages();
// Change color to cyan for friend // Change color to cyan for friend
friend_info->second.chat_history.append(steam_message.message()).append("\n", 1); friend_info->second.chat_history.append("\x1""00FFFFFF", 9).append(steam_message.message()).append("\n", 1);
if (!(friend_info->second.window_state & window_state_show)) if (!(friend_info->second.window_state & window_state_show))
{ {
friend_info->second.window_state |= window_state_need_attention; friend_info->second.window_state |= window_state_need_attention;
@ -758,7 +758,7 @@ void Steam_Overlay::RunCallbacks()
msg.set_dest_id(friend_id); msg.set_dest_id(friend_id);
network->sendTo(&msg, true); network->sendTo(&msg, true);
friend_info->second.chat_history.append(input).append("\n", 1); friend_info->second.chat_history.append("\x1""00FF00FF", 9).append(input).append("\n", 1);
} }
*input = 0; // Reset the input field *input = 0; // Reset the input field
friend_info->second.window_state &= ~window_state_send_message; friend_info->second.window_state &= ~window_state_send_message;