/* <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(); }
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; } } }
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); }
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; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- uint64 CBaseMultiplayerPlayer::GetSteamIDAsUInt64( void ) { CSteamID steamIDForPlayer; if ( GetSteamID( &steamIDForPlayer ) ) return steamIDForPlayer.ConvertToUint64(); return 0; }
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; }
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); }
/* <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_); } }
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; }
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 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 }
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; }
void CLogger::FormatFilename(wxString& string, CSteamID steamID) { 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}")); if(steamID.BIndividualAccount()) { replacements.Add(wxString(m_pSteamFriends->GetFriendPersonaName(steamID), wxConvUTF8)); } else { const char* cszChatRoomName = NULL; if(m_pClientFriends && m_pGetChatRoomName) cszChatRoomName = m_pGetChatRoomName(m_pClientFriends, steamID); if(*cszChatRoomName) { replacements.Add(wxString(cszChatRoomName, wxConvUTF8)); } else { wxString name; for(int i = 0; i < m_pSteamFriends->GetFriendCountFromSource(steamID); i++) { name += wxString(m_pSteamFriends->GetFriendPersonaName(m_pSteamFriends->GetFriendFromSourceByIndex(steamID, i)), wxConvUTF8) + _T(" + "); } name.RemoveLast(3); replacements.Add(name); } } tags.Add(_T("{Nickname}")); if(steamID.BIndividualAccount()) { const char* cszNickname = NULL; if(m_pClientFriends && m_pGetPlayerNickname) cszNickname = m_pGetPlayerNickname(m_pClientFriends, steamID); if(cszNickname) { replacements.Add(wxString(cszNickname, wxConvUTF8)); } else { replacements.Add(wxString(m_pSteamFriends->GetFriendPersonaName(steamID), wxConvUTF8)); } } else { replacements.Add(replacements.Last()); } 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())); string = TagsReplace(string, tags, replacements); static const wxChar* invalidChars[] = {_T("\\"), _T("/"), _T(":"), _T("*"), _T("?"), _T("\""), _T("<"), _T(">"), _T("|")}; for(int i = 0; i < sizeof(invalidChars) / sizeof(*invalidChars); i++) { string.Replace(invalidChars[i], m_replacementChar); } }
//==================================================================== //==================================================================== 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; }
SteamID CFriends::GetChatMemberByIndex(SteamID steamIDClan, s32 user) { CSteamID clanId(steamIDClan); CSteamID memberId = friends->GetChatMemberByIndex(clanId, user); return memberId.ConvertToUint64(); }
SteamID CFriends::GetCoplayFriend(s32 coplayFriend) { CSteamID id = friends->GetCoplayFriend(coplayFriend); return id.ConvertToUint64(); }
SteamID CFriends::GetClanOfficerByIndex(SteamID steamIDClan, s32 officer) { CSteamID clanId(steamIDClan); CSteamID officerId = friends->GetClanOfficerByIndex(clanId, officer); return officerId.ConvertToUint64(); }
SteamID CFriends::GetClanOwner(SteamID steamIDClan) { CSteamID clanId(steamIDClan); CSteamID ownerId = friends->GetClanOwner(clanId); return ownerId.ConvertToUint64(); }
SteamID CFriends::GetFriendFromSourceByIndex(SteamID steamIDSource, s32 friendIndex) { CSteamID steamId(steamIDSource); CSteamID resultId = friends->GetFriendFromSourceByIndex(steamId, friendIndex); return resultId.ConvertToUint64(); }
int HandleConnectionLessPacket(char*ip, short port, int connection_less, bf_read& recvdata) { recvdata.ReadLong(); int header = 0; int id = 0; int total = 0; int number = 0; short splitsize = 0; if (connection_less == 1) { header = recvdata.ReadByte(); } else { id = recvdata.ReadLong(); total = recvdata.ReadByte(); number = recvdata.ReadByte(); splitsize = recvdata.ReadByte(); } switch (header) { case '9': { recvdata.ReadLong(); char error[1024]; recvdata.ReadString(error, 1024); printf("Connection refused! [%s]\n", error); NET_Reconnect(); return 0; } case 'A': // A2A_GETCHALLENGE { bconnectstep = 2; long magicnumber = recvdata.ReadLong(); serverchallenge = recvdata.ReadLong(); ourchallenge = recvdata.ReadLong(); authprotocol = recvdata.ReadLong(); steamkey_encryptionsize = recvdata.ReadShort(); // gotta be 0 recvdata.ReadBytes(steamkey_encryptionkey, steamkey_encryptionsize); recvdata.ReadBytes(serversteamid, sizeof(serversteamid)); vacsecured = recvdata.ReadByte(); printf("Challenge: %lu__%lu|Auth: %x|SKey: %lu|VAC: %x\n", serverchallenge, ourchallenge, authprotocol, steamkey_encryptionsize, vacsecured); char connectpkg[700]; memset(connectpkg, 0, sizeof(connectpkg)); bf_write writeconnect(connectpkg, sizeof(connectpkg)); bf_read readsteamid(connectpkg, sizeof(connectpkg)); writeconnect.WriteLong(-1); writeconnect.WriteByte('k');//C2S_CONNECT writeconnect.WriteLong(0x18);//protocol ver writeconnect.WriteLong(0x03);//auth protocol 0x03 = PROTOCOL_STEAM, 0x02 = PROTOCOL_HASHEDCDKEY, 0x01=PROTOCOL_AUTHCERTIFICATE writeconnect.WriteLong(serverchallenge); writeconnect.WriteLong(ourchallenge); writeconnect.WriteUBitLong(2729496039, 32); writeconnect.WriteString(nickname); //nick writeconnect.WriteString(password); // pass writeconnect.WriteString("2000"); // game version unsigned char steamkey[STEAM_KEYSIZE]; unsigned int keysize = 0; steamuser->GetAuthSessionTicket(steamkey, STEAM_KEYSIZE, &keysize); CSteamID localsid = steamuser->GetSteamID(); writeconnect.WriteShort(242); unsigned long long steamid64 = localsid.ConvertToUint64(); writeconnect.WriteLongLong(steamid64); if (keysize) writeconnect.WriteBytes(steamkey, keysize); net.SendTo(ip, port, connectpkg, writeconnect.GetNumBytesWritten()); return 0; } case 'B': // S2C_CONNECTION { if (bconnectstep == 2) { bconnectstep = 3; printf("Connected successfully\n"); netchan->Initialize(); senddata.WriteUBitLong(6, 6); senddata.WriteByte(2); senddata.WriteLong(-1); senddata.WriteUBitLong(4, 6); senddata.WriteString("VModEnable 1"); senddata.WriteUBitLong(4, 6); senddata.WriteString("vban 0 0 0 0"); /* senddata.WriteByte(31); for (int i = 0; i < 31; i++) { senddata.WriteString("gm_snapangles"); senddata.WriteString("45"); }s */ NET_SendDatagram(); Sleep(3000); } return 0; } case 'I': { return 0; } default: { printf("Unknown message received from: %s, header: %i ( %c )\n", ip, header, header); break; } } return 0; }