MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / Initialize

Method Initialize

core/PlayerManager.cpp:2015–2067  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2013}
2014
2015void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity)
2016{
2017 m_IsConnected = true;
2018 m_Ip.assign(ip);
2019 m_pEdict = pEntity;
2020 m_iIndex = IndexOfEdict(pEntity);
2021 m_LangId = translator->GetServerLanguage();
2022 m_OriginalLangId = m_LangId;
2023
2024 m_Serial.bits.index = m_iIndex;
2025 m_Serial.bits.serial = g_PlayerSerialCount++;
2026
2027 SetName(name);
2028
2029 char ip2[24], *ptr;
2030 ke::SafeStrcpy(ip2, sizeof(ip2), ip);
2031 if ((ptr = strchr(ip2, ':')) != NULL)
2032 {
2033 *ptr = '\0';
2034 }
2035 m_IpNoPort.assign(ip2);
2036
2037#if SOURCE_ENGINE == SE_TF2 \
2038 || SOURCE_ENGINE == SE_CSS \
2039 || SOURCE_ENGINE == SE_DODS \
2040 || SOURCE_ENGINE == SE_HL2DM \
2041 || SOURCE_ENGINE == SE_BMS \
2042 || SOURCE_ENGINE == SE_INSURGENCY \
2043 || SOURCE_ENGINE == SE_DOI \
2044 || SOURCE_ENGINE == SE_BLADE \
2045 || SOURCE_ENGINE == SE_PVKII
2046 m_pIClient = engine->GetIServer()->GetClient(m_iIndex - 1);
2047#else
2048 #if SOURCE_ENGINE == SE_SDK2013
2049 // Source SDK 2013 mods that ship on Steam can be using older engine binaries
2050 static IVEngineServer *engine22 = (IVEngineServer *)(g_SMAPI->GetEngineFactory()("VEngineServer022", nullptr));
2051 if (engine22)
2052 {
2053 m_pIClient = engine22->GetIServer()->GetClient(m_iIndex - 1);
2054 }
2055 else
2056 #endif
2057 {
2058 INetChannel *pNetChan = static_cast<INetChannel *>(engine->GetPlayerNetInfo(m_iIndex));
2059 if (pNetChan)
2060 {
2061 m_pIClient = static_cast<IClient *>(pNetChan->GetMsgHandler());
2062 }
2063 }
2064#endif
2065
2066 UpdateAuthIds();
2067}
2068
2069void CPlayer::Connect()
2070{

Callers 1

OnClientConnectMethod · 0.45

Calls 3

IndexOfEdictFunction · 0.85
GetServerLanguageMethod · 0.80
GetIServerMethod · 0.80

Tested by

no test coverage detected