From d32dfc712a04fdb22f8279dc181eeb1b56535472 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sat, 18 Feb 2017 09:42:55 +0100 Subject: [PATCH] [Steam] Adapt steam structures to our style --- src/Components/Modules/Auth.cpp | 6 +++--- src/Components/Modules/Bans.cpp | 14 ++++++------- src/Components/Modules/Dedicated.cpp | 8 ++++---- src/Components/Modules/Friends.cpp | 24 +++++++++++------------ src/Components/Modules/Party.cpp | 20 +++++++++---------- src/Steam/Interfaces/SteamMatchmaking.cpp | 8 ++++---- src/Steam/Interfaces/SteamUser.cpp | 2 +- src/Steam/Proxy.cpp | 6 +++--- src/Steam/Steam.hpp | 16 +++++++-------- 9 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/Components/Modules/Auth.cpp b/src/Components/Modules/Auth.cpp index 63e1cb50..69438768 100644 --- a/src/Components/Modules/Auth.cpp +++ b/src/Components/Modules/Auth.cpp @@ -88,7 +88,7 @@ namespace Components if (!Components::Flags::HasFlag("nosteam") && !Dvar::Var("cl_anonymous").get() && Steam::Proxy::SteamUser_) { - infostr.set("realsteamId", Utils::String::VA("%llX", Steam::Proxy::SteamUser_->GetSteamID().Bits)); + infostr.set("realsteamId", Utils::String::VA("%llX", Steam::Proxy::SteamUser_->GetSteamID().bits)); } // Build new connect string @@ -179,7 +179,7 @@ namespace Components unsigned __int64 xuid = strtoull(steamId.data(), nullptr, 16); SteamID guid; - guid.Bits = xuid; + guid.bits = xuid; if (Bans::IsBanned({ guid, address.getIP() })) { @@ -424,7 +424,7 @@ namespace Components // Guid command Command::Add("guid", [] (Command::Params*) { - Logger::Print("Your guid: %llX\n", Steam::SteamUser()->GetSteamID().Bits); + Logger::Print("Your guid: %llX\n", Steam::SteamUser()->GetSteamID().bits); }); if (!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled()) diff --git a/src/Components/Modules/Bans.cpp b/src/Components/Modules/Bans.cpp index b564e154..63a78f07 100644 --- a/src/Components/Modules/Bans.cpp +++ b/src/Components/Modules/Bans.cpp @@ -9,11 +9,11 @@ namespace Components Bans::BanList list; Bans::LoadBans(&list); - if (entry.first.Bits) + if (entry.first.bits) { for (auto& idEntry : list.idList) { - if (idEntry.Bits == entry.first.Bits) + if (idEntry.bits == entry.first.bits) { return true; } @@ -41,12 +41,12 @@ namespace Components std::lock_guard _(Bans::AccessMutex); - if (entry.first.Bits) + if (entry.first.bits) { bool found = false; for (auto& idEntry : list.idList) { - if (idEntry.Bits == entry.first.Bits) + if (idEntry.bits == entry.first.bits) { found = true; break; @@ -82,7 +82,7 @@ namespace Components for (auto& idEntry : list.idList) { - idVector.push_back(Utils::String::VA("%llX", idEntry.Bits)); + idVector.push_back(Utils::String::VA("%llX", idEntry.bits)); } for (auto& ipEntry : list.ipList) @@ -138,7 +138,7 @@ namespace Components if (idEntry.is_string()) { SteamID id; - id.Bits = strtoull(idEntry.string_value().data(), nullptr, 16); + id.bits = strtoull(idEntry.string_value().data(), nullptr, 16); list->idList.push_back(id); } @@ -178,7 +178,7 @@ namespace Components Game::client_t* client = &Game::svs_clients[num]; SteamID guid; - guid.Bits = client->steamid; + guid.bits = client->steamid; Bans::InsertBan({ guid, client->addr.ip }); diff --git a/src/Components/Modules/Dedicated.cpp b/src/Components/Modules/Dedicated.cpp index b5c802cc..9ef93cc0 100644 --- a/src/Components/Modules/Dedicated.cpp +++ b/src/Components/Modules/Dedicated.cpp @@ -220,8 +220,8 @@ namespace Components { for (int client = 0; client < 18; client++) { - Dedicated::PlayerGuids[client][0].Bits = strtoull(params.get(2 * client + 1), nullptr, 16); - Dedicated::PlayerGuids[client][1].Bits = strtoull(params.get(2 * client + 2), nullptr, 16); + Dedicated::PlayerGuids[client][0].bits = strtoull(params.get(2 * client + 1), nullptr, 16); + Dedicated::PlayerGuids[client][1].bits = strtoull(params.get(2 * client + 2), nullptr, 16); if(Steam::Proxy::SteamFriends) { @@ -557,8 +557,8 @@ namespace Components { for(int i = 0; i < ARRAYSIZE(Dedicated::PlayerGuids); ++i) { - Dedicated::PlayerGuids[i][0].Bits = 0; - Dedicated::PlayerGuids[i][1].Bits = 0; + Dedicated::PlayerGuids[i][0].bits = 0; + Dedicated::PlayerGuids[i][1].bits = 0; } // Intercept server commands diff --git a/src/Components/Modules/Friends.cpp b/src/Components/Modules/Friends.cpp index d7c5e882..545b48db 100644 --- a/src/Components/Modules/Friends.cpp +++ b/src/Components/Modules/Friends.cpp @@ -66,7 +66,7 @@ namespace Components auto entry = std::find_if(Friends::FriendsList.begin(), Friends::FriendsList.end(), [user](Friends::Friend entry) { - return (entry.userId.Bits == user.Bits); + return (entry.userId.bits == user.bits); }); if (entry == Friends::FriendsList.end() || !Steam::Proxy::SteamFriends) return; @@ -80,7 +80,7 @@ namespace Components std::string experience = Friends::GetPresence(user, "iw4x_experience"); std::string prestige = Friends::GetPresence(user, "iw4x_prestige"); - if (!guid.empty()) entry->guid.Bits = strtoull(guid.data(), nullptr, 16); + if (!guid.empty()) entry->guid.bits = strtoull(guid.data(), nullptr, 16); if (!name.empty()) entry->playerName = name; if (!experience.empty()) entry->experience = atoi(experience.data()); if (!prestige.empty()) entry->prestige = atoi(prestige.data()); @@ -215,7 +215,7 @@ namespace Components for (auto entry : Friends::FriendsList) { - if (entry.guid.Bits == guid.Bits && Friends::IsOnline(entry.lastTime) && entry.online) + if (entry.guid.bits == guid.bits && Friends::IsOnline(entry.lastTime) && entry.online) { return true; } @@ -262,7 +262,7 @@ namespace Components Friends::Friend entry; entry.userId = id; - entry.guid.Bits = 0; + entry.guid.bits = 0; entry.online = false; entry.lastTime = 0; entry.prestige = 0; @@ -271,19 +271,19 @@ namespace Components for(auto storedFriend : list.friends()) { - if(entry.userId.Bits == strtoull(storedFriend.steamid().data(), nullptr, 16)) + if(entry.userId.bits == strtoull(storedFriend.steamid().data(), nullptr, 16)) { entry.playerName = storedFriend.name(); entry.experience = storedFriend.experience(); entry.prestige = storedFriend.prestige(); - entry.guid.Bits = strtoull(storedFriend.guid().data(), nullptr, 16); + entry.guid.bits = strtoull(storedFriend.guid().data(), nullptr, 16); break; } } auto oldEntry = std::find_if(Friends::FriendsList.begin(), Friends::FriendsList.end(), [id](Friends::Friend entry) { - return (entry.userId.Bits == id.Bits); + return (entry.userId.bits == id.bits); }); if (oldEntry != Friends::FriendsList.end()) entry = *oldEntry; @@ -298,7 +298,7 @@ namespace Components auto oldEntry = std::find_if(steamFriends.begin(), steamFriends.end(), [id](Friends::Friend entry) { - return (entry.userId.Bits == id.Bits); + return (entry.userId.bits == id.bits); }); if(oldEntry == steamFriends.end()) @@ -422,7 +422,7 @@ namespace Components void Friends::UpdateTimeStamp() { Friends::SetPresence("iw4x_playing", Utils::String::VA("%d", Steam::SteamUtils()->GetServerRealTime())); - Friends::SetPresence("iw4x_guid", Utils::String::VA("%llX", Steam::SteamUser()->GetSteamID().Bits)); + Friends::SetPresence("iw4x_guid", Utils::String::VA("%llX", Steam::SteamUser()->GetSteamID().bits)); } bool Friends::IsOnline(unsigned __int64 timeStamp) @@ -442,8 +442,8 @@ namespace Components { Proto::Friends::Friend* friendEntry = list.add_friends(); - friendEntry->set_steamid(Utils::String::VA("%llX", entry.userId.Bits)); - friendEntry->set_guid(Utils::String::VA("%llX", entry.guid.Bits)); + friendEntry->set_steamid(Utils::String::VA("%llX", entry.userId.bits)); + friendEntry->set_guid(Utils::String::VA("%llX", entry.guid.bits)); friendEntry->set_name(entry.playerName); friendEntry->set_experience(entry.experience); friendEntry->set_prestige(entry.prestige); @@ -462,7 +462,7 @@ namespace Components { if (params->length() <= 1) return; SteamID id; - id.Bits = atoll(params->get(1)); + id.bits = atoll(params->get(1)); Friends::AddFriend(id); }); diff --git a/src/Components/Modules/Party.cpp b/src/Components/Modules/Party.cpp index bd412925..5597dd34 100644 --- a/src/Components/Modules/Party.cpp +++ b/src/Components/Modules/Party.cpp @@ -9,10 +9,10 @@ namespace Components { SteamID id; - id.AccountID = Game::Sys_Milliseconds(); - id.Universe = 1; - id.AccountType = 8; - id.AccountInstance = 0x40000; + id.accountID = Game::Sys_Milliseconds(); + id.universe = 1; + id.accountType = 8; + id.accountInstance = 0x40000; return id; } @@ -39,9 +39,9 @@ namespace Components const char* Party::GetLobbyInfo(SteamID lobby, std::string key) { - if (Party::LobbyMap.find(lobby.Bits) != Party::LobbyMap.end()) + if (Party::LobbyMap.find(lobby.bits) != Party::LobbyMap.end()) { - Network::Address address = Party::LobbyMap[lobby.Bits]; + Network::Address address = Party::LobbyMap[lobby.bits]; if (key == "addr") { @@ -58,9 +58,9 @@ namespace Components void Party::RemoveLobby(SteamID lobby) { - if (Party::LobbyMap.find(lobby.Bits) != Party::LobbyMap.end()) + if (Party::LobbyMap.find(lobby.bits) != Party::LobbyMap.end()) { - Party::LobbyMap.erase(Party::LobbyMap.find(lobby.Bits)); + Party::LobbyMap.erase(Party::LobbyMap.find(lobby.bits)); } } @@ -115,7 +115,7 @@ namespace Components } } - Party::LobbyMap[id.Bits] = Party::Container.target; + Party::LobbyMap[id.bits] = Party::Container.target; Game::Steam_JoinLobby(id, 0); } @@ -313,7 +313,7 @@ namespace Components info.set("hostname", Dvar::Var("sv_hostname").get()); info.set("gametype", Dvar::Var("g_gametype").get()); info.set("fs_game", Dvar::Var("fs_game").get()); - info.set("xuid", Utils::String::VA("%llX", Steam::SteamUser()->GetSteamID().Bits)); + info.set("xuid", Utils::String::VA("%llX", Steam::SteamUser()->GetSteamID().bits)); info.set("clients", Utils::String::VA("%i", clientCount)); info.set("sv_maxclients", Utils::String::VA("%i", maxclientCount)); info.set("protocol", Utils::String::VA("%i", PROTOCOL)); diff --git a/src/Steam/Interfaces/SteamMatchmaking.cpp b/src/Steam/Interfaces/SteamMatchmaking.cpp index 4d22f630..af228ce2 100644 --- a/src/Steam/Interfaces/SteamMatchmaking.cpp +++ b/src/Steam/Interfaces/SteamMatchmaking.cpp @@ -56,10 +56,10 @@ namespace Steam LobbyCreated* retvals = ::Utils::Memory::Allocate(); SteamID id; - id.AccountID = 1337132; - id.Universe = 1; - id.AccountType = 8; - id.AccountInstance = 0x40000; + id.accountID = 1337132; + id.universe = 1; + id.accountType = 8; + id.accountInstance = 0x40000; retvals->m_eResult = 1; retvals->m_ulSteamIDLobby = id; diff --git a/src/Steam/Interfaces/SteamUser.cpp b/src/Steam/Interfaces/SteamUser.cpp index 5c01d94b..457383ec 100644 --- a/src/Steam/Interfaces/SteamUser.cpp +++ b/src/Steam/Interfaces/SteamUser.cpp @@ -36,7 +36,7 @@ namespace Steam } } - id.Bits = idBits; + id.bits = idBits; return id; } diff --git a/src/Steam/Proxy.cpp b/src/Steam/Proxy.cpp index c44cc1c0..b56cf9de 100644 --- a/src/Steam/Proxy.cpp +++ b/src/Steam/Proxy.cpp @@ -93,9 +93,9 @@ namespace Steam if (!Proxy::ClientUser || Components::Flags::HasFlag("nosteam") || Components::Dedicated::IsEnabled()) return; GameID_t gameID; - gameID.m_nType = 1; // k_EGameIDTypeGameMod - gameID.m_nAppID = Proxy::AppId & 0xFFFFFF; - gameID.m_nModID = 0xBAADF00D; + gameID.type = 1; // k_EGameIDTypeGameMod + gameID.appID = Proxy::AppId & 0xFFFFFF; + gameID.modID = 0xBAADF00D; Interface clientApps(Proxy::ClientEngine->GetIClientApps(Proxy::SteamUser, Proxy::SteamPipe, "CLIENTAPPS_INTERFACE_VERSION001")); Interface clientShortcuts(Proxy::ClientEngine->GetIClientShortcuts(Proxy::SteamUser, Proxy::SteamPipe, "CLIENTSHORTCUTS_INTERFACE_VERSION001")); diff --git a/src/Steam/Steam.hpp b/src/Steam/Steam.hpp index 082a5d9e..b4a1481b 100644 --- a/src/Steam/Steam.hpp +++ b/src/Steam/Steam.hpp @@ -11,13 +11,13 @@ typedef union { struct { - unsigned int AccountID : 32; - unsigned int AccountInstance : 20; - unsigned int AccountType : 4; - int Universe : 8; + unsigned int accountID : 32; + unsigned int accountInstance : 20; + unsigned int accountType : 4; + int universe : 8; }; - unsigned long long Bits; + unsigned long long bits; } SteamID; @@ -26,9 +26,9 @@ typedef union { struct { - unsigned int m_nAppID : 24; - unsigned int m_nType : 8; - unsigned int m_nModID : 32; + unsigned int appID : 24; + unsigned int type : 8; + unsigned int modID : 32; }; unsigned long long bits;