/* <f1e63> ../engine/sv_steam3.cpp:1054 */ uint64 Steam_StringToSteamID(const char *pStr) { CSteamID steamID; if (Steam3Server()) { CSteamID serverSteamId(Steam3Server()->GetSteamID()); steamID.SetFromSteam2String(pStr, serverSteamId.GetEUniverse()); } else { steamID.SetFromSteam2String(pStr, k_EUniversePublic); } return steamID.ConvertToUint64(); }
void CLogger::FormatMessage(wxString& string, CSteamID steamID, const char* cszMessage) { wxMutexLocker configLock(m_configLock); wxArrayString tags, replacements; tags.Add(_T("{SteamID}")); replacements.Add(wxString(steamID.SteamRender(), wxConvUTF8)); tags.Add(_T("{MySteamID}")); replacements.Add(wxString(m_pSteamUser->GetSteamID().SteamRender(), wxConvUTF8)); tags.Add(_T("{SteamID64}")); replacements.Add(wxString::Format(_T("%llu"), steamID.ConvertToUint64())); tags.Add(_T("{MySteamID64}")); replacements.Add(wxString::Format(_T("%llu"), m_pSteamUser->GetSteamID().ConvertToUint64())); tags.Add(_T("{Name}")); wxString name = wxString(m_pSteamFriends->GetFriendPersonaName(steamID), wxConvUTF8); const char* cszNickname = NULL; if(m_pClientFriends && m_pGetPlayerNickname) cszNickname = m_pGetPlayerNickname(m_pClientFriends, steamID); if(cszNickname) { name += _T(" (") + wxString(cszNickname, wxConvUTF8) + _T(")"); } replacements.Add(name); tags.Add(_T("{MyName}")); replacements.Add(wxString(m_pSteamFriends->GetPersonaName(), wxConvUTF8)); tags.Add(_T("{Date}")); replacements.Add(wxDateTime::Now().Format(m_dateFormat)); tags.Add(_T("{Time}")); replacements.Add(wxDateTime::Now().Format(m_timeFormat)); tags.Add(_T("{UnixTime}")); replacements.Add(wxString::Format(_T("%lld"), (long long)wxDateTime::GetTimeNow())); tags.Add(_T("{NewLine}")); replacements.Add(_T("\n")); tags.Add(_T("{Tab}")); replacements.Add(_T("\t")); tags.Add(_T("{Message}")); replacements.Add(wxString(cszMessage, wxConvUTF8)); string = TagsReplace(string, tags, replacements); }
static bgfx::TextureHandle* LUA_GetAvatar(lua_State* L, int friend_idx) { auto* that = getLuaSteamPlugin(L); if (!that) return nullptr; IAllocator& allocator = that->m_engine.getAllocator(); ISteamFriends* friends = SteamFriends(); if (!friends) return nullptr; CSteamID id = friends->GetFriendByIndex(friend_idx, k_EFriendFlagAll); auto iter = that->m_avatars.find(id.ConvertToUint64()); if (iter.isValid()) return &iter.value()->handle; int avatar = friends->GetMediumFriendAvatar(id); Lumix::u32 w, h; SteamUtils()->GetImageSize(avatar, &w, &h); if (w == 0 || h == 0) return nullptr; Array<Lumix::u8> data(allocator); data.resize(w * h * 4); SteamUtils()->GetImageRGBA(avatar, &data[0], w * h * 4); TextureManager* mng = static_cast<TextureManager*>(that->m_engine.getResourceManager().get(TEXTURE_TYPE)); Texture* tex = LUMIX_NEW(allocator, Texture)(Path("avatar"), *mng, allocator); tex->create(w, h, &data[0]); that->m_avatars.insert(id.ConvertToUint64(), tex); return &tex->handle; }
void Lobby2Client_Steam_Impl::OnLobbyMatchListCallback( LobbyMatchList_t *pCallback, bool bIOFailure ) { (void) bIOFailure; uint32_t i; for (i=0; i < deferredCallbacks.GetSize(); i++) { // Get any instance of Console_SearchRooms if (deferredCallbacks[i]->GetID()==L2MID_Console_SearchRooms) { Console_SearchRooms_Steam *callbackResult = (Console_SearchRooms_Steam *) deferredCallbacks[i]; // iterate the returned lobbies with GetLobbyByIndex(), from values 0 to m_nLobbiesMatching-1 // lobbies are returned in order of closeness to the user, so add them to the list in that order for ( uint32 iLobby = 0; iLobby < pCallback->m_nLobbiesMatching; iLobby++ ) { CSteamID steamId = SteamMatchmaking()->GetLobbyByIndex( iLobby ); callbackResult->roomIds.Push(steamId.ConvertToUint64(), _FILE_AND_LINE_ ); RakNet::RakString s = SteamMatchmaking()->GetLobbyData( steamId, "name" ); callbackResult->roomNames.Push(s, _FILE_AND_LINE_ ); } CallCBWithResultCode(callbackResult, L2RC_SUCCESS); msgFactory->Dealloc(callbackResult); deferredCallbacks.RemoveAtIndex(i); break; } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- uint64 CBaseMultiplayerPlayer::GetSteamIDAsUInt64( void ) { CSteamID steamIDForPlayer; if ( GetSteamID( &steamIDForPlayer ) ) return steamIDForPlayer.ConvertToUint64(); return 0; }
void GenerateUniquePlayerId(CSteamAPIContext *pSteamAPIContext) { CSHA1 sha1; // Add the steam name char szSteamId[256] = "\0"; CSteamID steamid = pSteamAPIContext->SteamUser()->GetSteamID(); V_sprintf_safe(szSteamId, "%u%u%u%u", steamid.GetEUniverse(), steamid.GetEAccountType(), steamid.GetAccountID(), steamid.GetUnAccountInstance()); sha1.Update((unsigned char *)szSteamId, strlen(szSteamId)); // Add some random numbers char randomNumbers[256] = "\0"; Q_snprintf(randomNumbers, sizeof(randomNumbers), "%i%i%i%i%i%i", RandomInt(0, 1000), RandomInt(0, 1000), RandomInt(0, 1000), RandomInt(0, 1000), RandomInt(0, 1000), RandomInt(0, 1000)); sha1.Update((unsigned char *)randomNumbers, strlen(randomNumbers)); // Generate the hash sha1.Final(); // Compile SHA1 Report char szReport[1024] = "\0"; sha1.ReportHash(szReport); // Remove the spaces and make it lowercase char playerId[1024] = "\0"; Q_StrSubst(szReport, " ", "", playerId, sizeof(playerId)); Q_strlower(playerId); DevMsg("Generated unique player ID: %s\n", playerId); ae_uniqueplayerid.SetValue(playerId); }
bool CGameServer::SendUserConnectAndAuthenticate( u32 ipClient, PConstantDataPointer authBlob, u32 authBlobSize, SteamID *steamIDUser ) { CSteamID idUser; bool results = gameServer->SendUserConnectAndAuthenticate(ipClient, authBlob, authBlobSize, &idUser); *steamIDUser = idUser.ConvertToUint64(); return results; }
s32 CFriends::GetClanChatMessage(SteamID steamIDClanChat, s32 message, PUtf8String text, s32 textSize, Enum *chatEntryType, SteamID *sender) { CSteamID senderId; s32 result = friends->GetClanChatMessage(steamIDClanChat, message, text, textSize, reinterpret_cast<EChatEntryType *>(chatEntryType), &senderId); *sender = senderId.ConvertToUint64(); return result; }
/* <ee327> ../engine/sv_steam3.cpp:578 */ bool CSteam3Server::NotifyBotConnect(client_t *client) { if (client == NULL || !m_bLoggedOn) return false; client->network_userid.idtype = AUTH_IDTYPE_LOCAL; CSteamID steamId = CRehldsPlatformHolder::get()->SteamGameServer()->CreateUnauthenticatedUserConnection(); client->network_userid.m_SteamID = steamId.ConvertToUint64(); return true; }
void Lobby2Client_Steam_Impl::GetRoomMembers(DataStructures::OrderedList<uint64_t, uint64_t> &_roomMembers) { _roomMembers.Clear(true,_FILE_AND_LINE_); int cLobbyMembers = SteamMatchmaking()->GetNumLobbyMembers( roomId ); for ( int i = 0; i < cLobbyMembers; i++ ) { CSteamID steamIDLobbyMember = SteamMatchmaking()->GetLobbyMemberByIndex( roomId, i ) ; uint64_t memberid=steamIDLobbyMember.ConvertToUint64(); _roomMembers.Insert(memberid,memberid,true,_FILE_AND_LINE_); } }
void FillPlayerInfo(da::protobuf::PlayerInfo* pbPlayerInfo, CDAPlayer* pPlayer) { FillProtoBufVector(pbPlayerInfo->mutable_position(), pPlayer->GetAbsOrigin()); pbPlayerInfo->set_health(pPlayer->GetHealth()); pbPlayerInfo->set_flags(GetFlags(pPlayer)); pbPlayerInfo->set_skill(SkillIDToAlias((SkillID)pPlayer->m_Shared.m_iStyleSkill.Get())); pbPlayerInfo->set_style(pPlayer->GetStylePoints()); pbPlayerInfo->set_total_style(pPlayer->GetTotalStyle()); pbPlayerInfo->set_kills(pPlayer->m_iKills); pbPlayerInfo->set_deaths(pPlayer->m_iDeaths); if (pPlayer->GetActiveDAWeapon()) pbPlayerInfo->set_weapon(WeaponIDToAlias(pPlayer->GetActiveDAWeapon()->GetWeaponID())); if (!pPlayer->IsBot()) { CSteamID ID; pPlayer->GetSteamID(&ID); pbPlayerInfo->set_accountid(ID.GetAccountID()); } if (DAGameRules()->GetWaypoint(0)) { pbPlayerInfo->set_waypoint(pPlayer->m_iRaceWaypoint); FillProtoBufVector(pbPlayerInfo->mutable_objective_position(), DAGameRules()->GetWaypoint(pPlayer->m_iRaceWaypoint)->GetAbsOrigin()); } if (pPlayer->HasBriefcase()) FillProtoBufVector(pbPlayerInfo->mutable_objective_position(), DAGameRules()->GetCaptureZone()->GetAbsOrigin()); if (pPlayer->m_iSlowMoType == SLOWMO_STYLESKILL) pbPlayerInfo->set_slowmo_type("super"); else if (pPlayer->m_iSlowMoType == SLOWMO_ACTIVATED) pbPlayerInfo->set_slowmo_type("active"); else if (pPlayer->m_iSlowMoType == SLOWMO_SUPERFALL) pbPlayerInfo->set_slowmo_type("superfall"); else if (pPlayer->m_iSlowMoType == SLOWMO_PASSIVE) pbPlayerInfo->set_slowmo_type("passive"); else if (pPlayer->m_iSlowMoType == SLOWMO_PASSIVE_SUPER) pbPlayerInfo->set_slowmo_type("passivesuper"); else if (pPlayer->m_iSlowMoType == SLOWMO_NONE) pbPlayerInfo->set_slowmo_type("none"); else pbPlayerInfo->set_slowmo_type("unknown"); if (pPlayer->m_flSlowMoTime) pbPlayerInfo->set_slowmo_seconds(pPlayer->m_flSlowMoTime - gpGlobals->curtime); else pbPlayerInfo->set_slowmo_seconds(pPlayer->m_flSlowMoSeconds); }
SteamAPICall_t CSteamMatchmaking007::CreateLobby( ELobbyType eLobbyType, int ) { SteamAPICall_t result = CSteamBase::RegisterCall(); LobbyCreated_t* retvals = (LobbyCreated_t*)malloc(sizeof(LobbyCreated_t)); CSteamID id = CSteamID( 1337132, 0x40000, k_EUniversePublic, k_EAccountTypeChat ); retvals->m_eResult = k_EResultOK; retvals->m_ulSteamIDLobby = id.ConvertToUint64(); CSteamBase::ReturnCall(retvals, sizeof(LobbyCreated_t), LobbyCreated_t::k_iCallback, result); JoinLobby(id); return result; }
bool SteamProxy_InitInternal() { g_steamProxy.clientFactory = loader.Load(); if (g_steamProxy.clientFactory == NULL) { return false; } g_steamProxy.steamClient = (ISteamClient008*)g_steamProxy.clientFactory(STEAMCLIENT_INTERFACE_VERSION_008, NULL); if (g_steamProxy.steamClient == NULL) { return false; } g_steamProxy.pipe = g_steamProxy.steamClient->CreateSteamPipe(); if (g_steamProxy.pipe == NULL) { return false; } g_steamProxy.user = g_steamProxy.steamClient->ConnectToGlobalUser(g_steamProxy.pipe); if (g_steamProxy.user == NULL) { return false; } ISteamUtils005* steamUtils = (ISteamUtils005*)g_steamProxy.steamClient->GetISteamUtils(g_steamProxy.pipe, STEAMUTILS_INTERFACE_VERSION_005); int appID = steamUtils->GetAppID(); if (appID == 0) { return false; } ISteamUser012* steamUser = (ISteamUser012*)g_steamProxy.steamClient->GetISteamUser(g_steamProxy.user, g_steamProxy.pipe, STEAMUSER_INTERFACE_VERSION_012); CSteamID steamID = steamUser->GetSteamID(); NP_SetExternalSteamID(steamID.ConvertToUint64()); return true; }
int CSteamUser014::InitiateGameConnection( void *pAuthBlob, int cbMaxAuthBlob, CSteamID steamIDGameServer, uint32 unIPServer, uint16 usPortServer, bool bSecure ) { if (!NP_GetUserTicket(pAuthBlob, cbMaxAuthBlob, steamIDGameServer.ConvertToUint64())) { return 0; } return sizeof(NPAuthenticateTicket); }
SteamAPICall_t CSteamMatchmaking007::JoinLobby( CSteamID steamIDLobby ) { SteamAPICall_t result = CSteamBase::RegisterCall(); LobbyEnter_t* retvals = (LobbyEnter_t*)malloc(sizeof(LobbyEnter_t)); retvals->m_bLocked = false; retvals->m_EChatRoomEnterResponse = k_EChatRoomEnterResponseSuccess; retvals->m_rgfChatPermissions = (EChatPermission)0xFFFFFFFF; retvals->m_ulSteamIDLobby = steamIDLobby.ConvertToUint64(); CSteamBase::ReturnCall(retvals, sizeof(LobbyEnter_t), LobbyEnter_t::k_iCallback, result); return result; }
da::protobuf::PlayerList* CDataManager::GetPlayerInList(CDAPlayer* pPlayer) { if (pPlayer->IsBot()) return NULL; CSteamID ID; pPlayer->GetSteamID(&ID); if (!ID.IsValid()) return NULL; if (ID.GetEUniverse() != k_EUniversePublic) return NULL; if (ID.GetEAccountType() != k_EAccountTypeIndividual) return NULL; CUtlMap<AccountID_t, class da::protobuf::PlayerList*>::IndexType_t it = d->m_apPlayerList.Find(ID.GetAccountID()); if (it == d->m_apPlayerList.InvalidIndex()) { it = d->m_apPlayerList.Insert(ID.GetAccountID(), new da::protobuf::PlayerList()); da::protobuf::PlayerList* pbPlayerInfo = d->m_apPlayerList[it]; pbPlayerInfo->set_accountid(ID.GetAccountID()); pbPlayerInfo->set_name(pPlayer->GetPlayerName()); } return d->m_apPlayerList[it]; }
int Lobby2Client_Steam_Impl::RakNetRecvFrom( char dataOut[ MAXIMUM_MTU_SIZE ], SystemAddress *senderOut, bool calledFromMainThread) { (void) calledFromMainThread; uint32 pcubMsgSize; if (SteamNetworking() && SteamNetworking()->IsP2PPacketAvailable(&pcubMsgSize)) { CSteamID psteamIDRemote; if (SteamNetworking()->ReadP2PPacket(dataOut, MAXIMUM_MTU_SIZE, &pcubMsgSize, &psteamIDRemote)) { uint64_t steamIDRemote64=psteamIDRemote.ConvertToUint64(); unsigned int i; bool objectExists; i = roomMembersById.GetIndexFromKey(steamIDRemote64, &objectExists); if (objectExists) { *senderOut=roomMembersById[i].systemAddress; } return pcubMsgSize; } } return 0; }
int CSteamUser012::InitiateGameConnection(void *pAuthBlob, int cbMaxAuthBlob, CSteamID steamIDGameServer, uint32 unIPServer, uint16 usPortServer, bool bSecure) { #ifdef USE_NP if (Legacy_IsLegacyMode()) { #endif unsigned int steamID = GetSteamID().GetAccountID(); memcpy(pAuthBlob, &steamID, 4); return 4; #ifdef USE_NP } //memset(pAuthBlob, 0xdd, cbMaxAuthBlob); if (!NP_GetUserTicket(pAuthBlob, cbMaxAuthBlob, steamIDGameServer.ConvertToUint64())) { Com_Error(2, "Could not get NP user ticket."); } return sizeof(NPAuthenticateTicket); #endif }
SteamID CFriends::GetClanOwner(SteamID steamIDClan) { CSteamID clanId(steamIDClan); CSteamID ownerId = friends->GetClanOwner(clanId); return ownerId.ConvertToUint64(); }
//==================================================================== //==================================================================== void CBaseHTML::WebThink() { if ( !cl_web_think.GetBool() ) return; float flNextThink = cl_web_think_interval.GetFloat(); // Información de la partida SetProperty( "isInGame", JSValue(engine->IsInGame()), m_pGameObject ); SetProperty( "isPaused", JSValue(engine->IsPaused()), m_pGameObject ); SetProperty( "maxClients", JSValue(engine->GetMaxClients()), m_pGameObject ); SetProperty( "isLoading", JSValue(GameUI().m_bIsLoading), m_pGameObject ); if ( InRules ) SetProperty( "gameMode", JSValue(InRules->GameMode()), m_pGameObject ); // Obtenemos al Jugador C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); // Existe, estamos en una partida if ( pPlayer ) { // Información actual del Jugador C_BaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon(); int iHealth = pPlayer->GetHealth(); int iAmmo = 0; int iAmmoTotal = 0; // Tenemos un arma if ( pWeapon ) { iAmmo = pWeapon->Clip1(); iAmmoTotal = pPlayer->GetAmmoCount( pWeapon->GetPrimaryAmmoType() ); } // Actualizamos la información básica SetProperty( "health", JSValue(iHealth), m_pPlayerObject ); SetProperty( "clip1Ammo", JSValue(iAmmo), m_pPlayerObject ); SetProperty( "clip1TotalAmmo", JSValue(iAmmoTotal), m_pPlayerObject ); } // Información de la API de Steam if ( IsPC() && steamapicontext ) { // ID de Steam if ( !m_pSteamID ) { // Intentamos obtener la ID if ( steamapicontext->SteamUser() ) { CSteamID steamID = steamapicontext->SteamUser()->GetSteamID(); uint64 mySteamID = steamID.ConvertToUint64(); m_pSteamID = VarArgs("%llu", mySteamID); } // ID cargada, se lo dejamos a JavaScript... if ( m_pSteamID ) { SetProperty( "playerID", JSValue(WSLit(m_pSteamID)), m_pSteamObject ); ExecuteJavaScript( "Helper.loadUserInfo()", "" ); } } // Utilidades e información if ( steamapicontext->SteamUtils() ) { uint32 serverTime = steamapicontext->SteamUtils()->GetServerRealTime(); const char *country = steamapicontext->SteamUtils()->GetIPCountry(); uint8 battery = steamapicontext->SteamUtils()->GetCurrentBatteryPower(); uint32 computer = steamapicontext->SteamUtils()->GetSecondsSinceComputerActive(); SetProperty( "serverTime", JSValue(WSLit(VarArgs("%llu", serverTime))), m_pSteamObject ); SetProperty( "country", JSValue(country), m_pSteamObject ); SetProperty( "batteryPower", JSValue(WSLit(VarArgs("%llu", battery))), m_pSteamObject ); SetProperty( "computerActive", JSValue(WSLit(VarArgs("%llu", computer))), m_pSteamObject ); } } // Pensamiento en JS ExecuteJavaScript( "think()", "" ); // Pensamiento nuevamente en... m_flNextThink = gpGlobals->curtime + flNextThink; }
std::string RunBotCommand(const CSteamID& id, MessageType mType, const string& message, const string& username, ChatType cType) { try { sf::TcpSocket socket; sf::Socket::Status status = socket.Connect(ipAndSuch, port); if (FAILED(status)) return "!Failed to connect to bot!"; char* utf8string = new char[2048]; sprintf(utf8string, "%s\n%s\n%s\n%s\n%s\n", (mType == Message_Interact ? "interactsteam" : "tell"), username.c_str(), id.Render(), (cType == Chat_Private ? "PM" : "GROUPCHAT"), message.c_str()); char* utf16string = 0; int utf16stringLen = 0; { CStringW temp = CStringW(CA2W(utf8string)); utf16stringLen = temp.GetLength()*2; utf16string = new char[utf16stringLen]; _swab((char*)temp.GetString(), utf16string, utf16stringLen); } delete[] utf8string; status = socket.Send(utf16string, utf16stringLen); delete[] utf16string; if (FAILED(status)) { return "!Failed to send message to bot!"; } utf16string = new char[2048]; size_t size; status = socket.Receive(utf16string, (size_t)2048, size); if (FAILED(status)) { delete[] utf16string; return "!Failed to receive response from bost!"; } std::string retString; { wchar_t* temp = new wchar_t[size]; _swab(utf16string, (char*)temp, size); CStringW asdf(temp); retString = std::string(CW2A(asdf)); delete[] temp; retString.resize(size/2); } socket.Disconnect(); return retString; } catch (const std::exception& e) { std::string error = "!Something went wrong: "; error.append(e.what()); error.append("!"); return error; } }
DECL_MEMBER_DETOUR11_void(ConnectClientDetour, void *, int, int, int, const char *, const char *, const char*, int, void *, bool, CrossPlayPlatform_t ) { CSteamID SteamID; Q_memset ( &SteamID, 0, sizeof(SteamID) ); if ( p8 >= 20 ) memcpy ( &SteamID, &p7[20], sizeof(SteamID) ); #elif defined ( GAME_ORANGE ) #define CCD_MEMBER_CALL(pw) MEMBER_CALL(ConnectClientDetour)(p1,p2,p3,p4,p5,p6,pw,p8,p9) DECL_MEMBER_DETOUR9_void(ConnectClientDetour, void *, int, int, int, int, const char *, const char *, const char*, int ) { CSteamID SteamID; Q_memset ( &SteamID, 0, sizeof(SteamID) ); if ( p9 >= 20 ) memcpy ( &SteamID, &p8[20], sizeof(SteamID) ); #else #define CCD_MEMBER_CALL(pw) MEMBER_CALL(ConnectClientDetour)(p1,p2,p3,p4,p5,pw,p7,p8,p9,pA) DECL_MEMBER_DETOUR10_void(ConnectClientDetour, void *, int, int, int, const char *, const char *, const char*, int, char const*, int ) { CSteamID SteamID; Q_memset ( &SteamID, 0, sizeof(SteamID) ); if ( pA >= 16 ) memcpy ( &SteamID, &p9[8], sizeof(SteamID) ); #endif int total_players = m_iUnaccountedPlayers + GetNumberOfActivePlayers(true); player_t player; Q_memset ( &player, 0, sizeof(player) ); strcpy ( player.steam_id, SteamID.Render() ); bool AdminAccess = gpManiClient->HasAccess(&player, ADMIN, ADMIN_BASIC_ADMIN) && ( mani_reserve_slots_include_admin.GetInt() == 1 ); if ( FillSlotMode() ) { if ( total_players == max_players ) { if(SteamID.GetEAccountType() != 1 || SteamID.GetEUniverse() != 1) #if defined ( GAME_CSGO ) return CCD_MEMBER_CALL(p6); #elif defined ( GAME_ORANGE ) return CCD_MEMBER_CALL(p7); #else return CCD_MEMBER_CALL(p6); #endif bool ReservedAccess = gpManiReservedSlot->IsPlayerInReserveList(&player); if ( AdminAccess || ReservedAccess ) { int kick_index = gpManiReservedSlot->FindPlayerToKick(); if ( kick_index < 1 ) { engine->LogPrint("MAP: Error, couldn't find anybody to kick for reserved slots!!!\n"); #if defined ( GAME_CSGO ) return CCD_MEMBER_CALL(p6); #elif defined ( GAME_ORANGE ) return CCD_MEMBER_CALL(p7); #else return CCD_MEMBER_CALL(p6); #endif } Q_memset ( &player, 0, sizeof(player) ); player.index = kick_index; FindPlayerByIndex(&player); gpManiReservedSlot->DisconnectPlayer(&player); } } } ConVar *pwd = g_pCVar->FindVar( "sv_password" ); if ( pwd && !FStrEq(pwd->GetString(),"")) { if ( AdminAccess && !war_mode && !mani_reserve_slots_enforce_password.GetBool() ) { return CCD_MEMBER_CALL(pwd->GetString()); } } #if defined ( GAME_CSGO ) return CCD_MEMBER_CALL(p6); #elif defined ( GAME_ORANGE ) return CCD_MEMBER_CALL(p7); #else return CCD_MEMBER_CALL(p6); #endif }
void StatsReport::SetPlayerNames( void ) { C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer(); if ( !pPlayer ) return; int nMarine = 0; C_ASW_Game_Resource *pGameResource = ASWGameResource(); for ( int i = 0; i < pGameResource->GetMaxMarineResources() && nMarine < ASW_STATS_REPORT_MAX_PLAYERS; i++ ) { CASW_Marine_Resource *pMR = pGameResource->GetMarineResource( i ); if ( pMR ) { C_ASW_Player *pCommander = pMR->GetCommander(); Color color = getColorPerIndex(pMR->GetCommanderIndex()); if ( pPlayer != pCommander ) { color[ 3 ] = 128; } m_pStatGraphPlayer->m_pStatGraphs[ nMarine ]->SetLineColor( color ); m_pPlayerNames[ nMarine ]->SetFgColor( color ); wchar_t wszMarineName[ 32 ]; pMR->GetDisplayName( wszMarineName, sizeof( wszMarineName ) ); m_pPlayerNames[ nMarine ]->SetText( wszMarineName ); if ( gpGlobals->maxClients == 1 ) { // Don't need these in singleplayer m_pAvatarImages[ nMarine ]->SetVisible( false ); m_pReadyCheckImages[ nMarine ]->SetVisible( false ); } else { #if !defined(NO_STEAM) CSteamID steamID; if ( pCommander ) { player_info_t pi; if ( engine->GetPlayerInfo( pCommander->entindex(), &pi ) ) { if ( pi.friendsID ) { CSteamID steamIDForPlayer( pi.friendsID, 1, steamapicontext->SteamUtils()->GetConnectedUniverse(), k_EAccountTypeIndividual ); steamID = steamIDForPlayer; } } } if ( steamID.IsValid() ) { m_pAvatarImages[ nMarine ]->SetAvatarBySteamID( &steamID ); int wide, tall; m_pAvatarImages[ nMarine ]->GetSize( wide, tall ); CAvatarImage *pImage = static_cast< CAvatarImage* >( m_pAvatarImages[ nMarine ]->GetImage() ); if ( pImage ) { pImage->SetAvatarSize( wide, tall ); pImage->SetPos( -AVATAR_INDENT_X, -AVATAR_INDENT_Y ); } } #endif } nMarine++; } } while ( nMarine < ASW_STATS_REPORT_MAX_PLAYERS ) { m_pAvatarImages[ nMarine ]->SetVisible( false ); m_pReadyCheckImages[ nMarine ]->SetVisible( false ); nMarine++; } }
SteamID CFriends::GetFriendFromSourceByIndex(SteamID steamIDSource, s32 friendIndex) { CSteamID steamId(steamIDSource); CSteamID resultId = friends->GetFriendFromSourceByIndex(steamId, friendIndex); return resultId.ConvertToUint64(); }
void CMumbleSystem::PostRender() { #ifndef NO_STEAM if ( !g_pMumbleMemory || !sv_mumble_positionalaudio.GetBool() ) return; if ( g_pMumbleMemory->uiVersion != 2 ) { V_wcscpy_safe( g_pMumbleMemory->name, L"Source engine: " ); wchar_t wcsGameDir[MAX_PATH]; Q_UTF8ToUnicode( COM_GetModDirectory(), wcsGameDir, sizeof(wcsGameDir) ); V_wcscat_safe( g_pMumbleMemory->name, wcsGameDir ); V_wcscpy_safe( g_pMumbleMemory->description, L"Links Source engine games to Mumble." ); g_pMumbleMemory->uiVersion = 2; } g_pMumbleMemory->uiTick++; Vector vecOriginPlayer, vecOriginCamera = MainViewOrigin(); QAngle anglesPlayer, anglesCamera = MainViewAngles(); C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( pPlayer ) { vecOriginPlayer = pPlayer->EyePosition(); anglesPlayer = pPlayer->GetAbsAngles(); } else { vecOriginPlayer = vecOriginCamera; anglesPlayer = anglesCamera; } anglesPlayer.x = 0; Vector vecPlayerForward, vecPlayerUp, vecCameraForward, vecCameraUp; AngleVectors( anglesPlayer, &vecPlayerForward, NULL, &vecPlayerUp ); AngleVectors( anglesCamera, &vecCameraForward, NULL, &vecCameraUp ); // 1 Source unit is about one inch // 1 mumble unit = 1 meter vecOriginPlayer *= METERS_PER_INCH; vecOriginCamera *= METERS_PER_INCH; VectorToMumbleFloatArray( vecPlayerForward, g_pMumbleMemory->fAvatarFront ); VectorToMumbleFloatArray( vecPlayerUp, g_pMumbleMemory->fAvatarTop ); VectorToMumbleFloatArray( vecOriginPlayer, g_pMumbleMemory->fAvatarPosition ); VectorToMumbleFloatArray( vecCameraForward, g_pMumbleMemory->fCameraFront ); VectorToMumbleFloatArray( vecCameraUp, g_pMumbleMemory->fCameraTop ); VectorToMumbleFloatArray( vecOriginCamera, g_pMumbleMemory->fCameraPosition ); if ( pPlayer && m_bHasSetPlayerUniqueId && m_nTeamSetInUniqueId != pPlayer->GetTeamNumber() ) { // Player changed team since we set the unique ID. Set it again. m_bHasSetPlayerUniqueId = false; } if ( !m_bHasSetPlayerUniqueId && steamapicontext && steamapicontext->SteamUser() ) { CSteamID steamid = steamapicontext->SteamUser()->GetSteamID(); if ( steamid.IsValid() ) { int unTeam = pPlayer ? pPlayer->GetTeamNumber() : 0; char szSteamId[256]; V_sprintf_safe( szSteamId, "universe:%u;account_type:%u;id:%u;instance:%u;team:%d", steamid.GetEUniverse(), steamid.GetEAccountType(), steamid.GetAccountID(), steamid.GetUnAccountInstance(), unTeam ); wchar_t wcsSteamId[256]; Q_UTF8ToUnicode( szSteamId, wcsSteamId, sizeof(wcsSteamId) ); // Identifier which uniquely identifies a certain player in a context. V_wcscpy_safe( g_pMumbleMemory->identity, wcsSteamId ); m_bHasSetPlayerUniqueId = true; m_nTeamSetInUniqueId = unTeam; } } // Context should be equal for players which should be able to hear each other positional and // differ for those who shouldn't (e.g. it could contain the server+port and team) memcpy( g_pMumbleMemory->context, &m_szSteamIDCurrentServer, m_cubSteamIDCurrentServer ); g_pMumbleMemory->context_len = m_cubSteamIDCurrentServer; #endif // NO_STEAM }
SteamID CFriends::GetClanOfficerByIndex(SteamID steamIDClan, s32 officer) { CSteamID clanId(steamIDClan); CSteamID officerId = friends->GetClanOfficerByIndex(clanId, officer); return officerId.ConvertToUint64(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- bool CTFStatPanel::ReadStats( void ) { CDmxElement *pPlayerStats; DECLARE_DMX_CONTEXT(); if ( IsX360() ) { #ifdef _X360 if ( XBX_GetStorageDeviceId() == XBX_INVALID_STORAGE_ID || XBX_GetStorageDeviceId() == XBX_STORAGE_DECLINED ) return false; #endif } char szFilename[_MAX_PATH]; if ( IsX360() ) { Q_snprintf( szFilename, sizeof( szFilename ), "cfg:/tf2_playerstats.dmx" ); } else { Q_snprintf( szFilename, sizeof( szFilename ), "tf2_playerstats.dmx" ); } MEM_ALLOC_CREDIT(); bool bOk = UnserializeDMX( szFilename, "MOD", true, &pPlayerStats ); if ( !bOk ) return false; int iVersion = pPlayerStats->GetValue< int >( "iVersion" ); if ( iVersion > PLAYERSTATS_FILE_VERSION ) { // file is beyond our comprehension return false; } int iSteamID = pPlayerStats->GetValue<int>( "SteamID" ); int iCRCFile = pPlayerStats->GetValue<int>( "iTimestamp" ); const CUtlVector< CDmxElement* > &aClassStatsList = pPlayerStats->GetArray< CDmxElement * >( "aClassStats" ); int iCount = aClassStatsList.Count(); m_aClassStats.SetCount( iCount ); for( int i = 0; i < m_aClassStats.Count(); i++ ) { CDmxElement *pClass = aClassStatsList[ i ]; ClassStats_t &stat = m_aClassStats[ i ]; pClass->UnpackIntoStructure( &stat, s_ClassStatsUnpack ); CDmxElement *pAccumulated = pClass->GetValue< CDmxElement * >( "accumulated" ); pAccumulated->UnpackIntoStructure( &stat.accumulated, s_RoundStatsUnpack ); CDmxElement *pMax = pClass->GetValue< CDmxElement * >( "max" ); pMax->UnpackIntoStructure( &stat.max, s_RoundStatsUnpack ); } CleanupDMX( pPlayerStats ); UpdateStatSummaryPanel(); // check file CRC and steam ID to see if we think this file has not been tampered with int iCRC = CalcCRC( iSteamID ); // does file CRC match CRC generated from file data, and is there a Steam ID in the file if ( ( iCRC == iCRCFile ) && ( iSteamID > 0 ) && SteamUser() ) { // does the file Steam ID match current Steam ID (so you can't hand around files) CSteamID steamID = SteamUser()->GetSteamID(); if ( steamID.GetAccountID() == (uint32) iSteamID ) { m_bLocalFileTrusted = true; } } m_bStatsChanged = false; return true; }
//----------------------------------------------------------------------------- // Purpose: Writes stat file. Used as primary storage for X360. For PC, // Steam is authoritative but we write stat file for debugging (although // we never read it). //----------------------------------------------------------------------------- void CTFStatPanel::WriteStats( void ) { if ( !m_bStatsChanged ) return; MEM_ALLOC_CREDIT(); DECLARE_DMX_CONTEXT(); CDmxElement *pPlayerStats = CreateDmxElement( "PlayerStats" ); CDmxElementModifyScope modify( pPlayerStats ); // get Steam ID. If not logged into Steam, use 0 int iSteamID = 0; if ( SteamUser() ) { CSteamID steamID = SteamUser()->GetSteamID(); iSteamID = steamID.GetAccountID(); } // Calc CRC of all data to make the local data file somewhat tamper-resistant int iCRC = CalcCRC( iSteamID ); pPlayerStats->SetValue( "iVersion", static_cast<int>( PLAYERSTATS_FILE_VERSION ) ); pPlayerStats->SetValue( "SteamID", iSteamID ); pPlayerStats->SetValue( "iTimestamp", iCRC ); // store the CRC with a non-obvious name CDmxAttribute *pClassStatsList = pPlayerStats->AddAttribute( "aClassStats" ); CUtlVector< CDmxElement* >& classStats = pClassStatsList->GetArrayForEdit<CDmxElement*>(); modify.Release(); for( int i = 0; i < m_aClassStats.Count(); i++ ) { const ClassStats_t &stat = m_aClassStats[ i ]; // strip out any garbage class data if ( ( stat.iPlayerClass > TF_LAST_NORMAL_CLASS ) || ( stat.iPlayerClass < TF_FIRST_NORMAL_CLASS ) ) continue; CDmxElement *pClass = CreateDmxElement( "ClassStats_t" ); classStats.AddToTail( pClass ); CDmxElementModifyScope modifyClass( pClass ); pClass->SetValue( "comment: classname", g_aPlayerClassNames_NonLocalized[ stat.iPlayerClass ] ); pClass->AddAttributesFromStructure( &stat, s_ClassStatsUnpack ); CDmxElement *pAccumulated = CreateDmxElement( "RoundStats_t" ); pAccumulated->AddAttributesFromStructure( &stat.accumulated, s_RoundStatsUnpack ); pClass->SetValue( "accumulated", pAccumulated ); CDmxElement *pMax = CreateDmxElement( "RoundStats_t" ); pMax->AddAttributesFromStructure( &stat.max, s_RoundStatsUnpack ); pClass->SetValue( "max", pMax ); } if ( IsX360() ) { #ifdef _X360 if ( XBX_GetStorageDeviceId() == XBX_INVALID_STORAGE_ID || XBX_GetStorageDeviceId() == XBX_STORAGE_DECLINED ) return; #endif } char szFilename[_MAX_PATH]; if ( IsX360() ) Q_snprintf( szFilename, sizeof( szFilename ), "cfg:/tf2_playerstats.dmx" ); else Q_snprintf( szFilename, sizeof( szFilename ), "tf2_playerstats.dmx" ); { MEM_ALLOC_CREDIT(); CUtlBuffer buf( 0, 0, CUtlBuffer::TEXT_BUFFER ); if ( SerializeDMX( buf, pPlayerStats, szFilename ) ) { filesystem->WriteFile( szFilename, "MOD", buf ); } } CleanupDMX( pPlayerStats ); if ( IsX360() ) { xboxsystem->FinishContainerWrites(); } m_bStatsChanged = false; }
SteamID CFriends::GetCoplayFriend(s32 coplayFriend) { CSteamID id = friends->GetCoplayFriend(coplayFriend); return id.ConvertToUint64(); }
SteamID CFriends::GetChatMemberByIndex(SteamID steamIDClan, s32 user) { CSteamID clanId(steamIDClan); CSteamID memberId = friends->GetChatMemberByIndex(clanId, user); return memberId.ConvertToUint64(); }