bool HolidayManager::Hook_IsHolidayActive(int holiday) { void *pGameRules = META_IFACEPTR(void *); bool actualres = SH_MCALL(pGameRules, IsHolidayActive)(holiday); if (!m_isHolidayForward) { g_pSM->LogMessage(myself, "Invalid Forward"); RETURN_META_VALUE(MRES_IGNORED, true); } cell_t result = 0; cell_t newres = actualres ? 1 : 0; m_isHolidayForward->PushCell(holiday); m_isHolidayForward->PushCellByRef(&newres); m_isHolidayForward->Execute(&result); if (result > Pl_Continue) { RETURN_META_VALUE(MRES_SUPERCEDE, (newres == 0) ? false : true); } RETURN_META_VALUE(MRES_IGNORED, true); }
IClient *CForwardManager::OnSpectatorConnect(netadr_t & address, int nProtocol, int iChallenge, int iClientChallenge, int nAuthProtocol, const char *pchName, const char *pchPassword, const char *pCookie, int cbCookie) #endif { if (!pCookie || (size_t)cbCookie < sizeof(uint64)) RETURN_META_VALUE(MRES_IGNORED, nullptr); #if SOURCE_ENGINE == SE_CSGO // CS:GO doesn't send the player name in pchName, but only in the client info convars. // Try to extract the name from the protobuf msg. char playerName[MAX_PLAYER_NAME_LENGTH]; if (ExtractPlayerName(pSplitPlayerConnectVector, playerName, sizeof(playerName))) pchName = playerName; #endif char ipString[16]; V_snprintf(ipString, sizeof(ipString), "%u.%u.%u.%u", address.ip[0], address.ip[1], address.ip[2], address.ip[3]); V_strncpy(passwordBuffer, pchPassword, 255); // SourceTV doesn't validate steamids?! char rejectReason[255]; m_SpectatorPreConnectFwd->PushString(pchName); m_SpectatorPreConnectFwd->PushStringEx(passwordBuffer, 255, SM_PARAM_STRING_UTF8 | SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK); m_SpectatorPreConnectFwd->PushString(ipString); m_SpectatorPreConnectFwd->PushStringEx(rejectReason, 255, SM_PARAM_STRING_UTF8 | SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK); cell_t retVal = 1; m_SpectatorPreConnectFwd->Execute(&retVal); IServer *server = META_IFACEPTR(IServer); if (retVal == 0) { if (m_bHasRejectConnectionOffset) { #if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_LEFT4DEAD || SOURCE_ENGINE == SE_LEFT4DEAD2 SH_MCALL(server, CHLTVServer_RejectConnection)(address, rejectReason); #else SH_MCALL(server, CHLTVServer_RejectConnection)(address, iClientChallenge, rejectReason); #endif } RETURN_META_VALUE(MRES_SUPERCEDE, nullptr); } // Call the original function. #if SOURCE_ENGINE == SE_CSGO IClient *client = SH_MCALL(server, CHLTVServer_ConnectClient)(address, nProtocol, iChallenge, nAuthProtocol, pchName, passwordBuffer, pCookie, cbCookie, pSplitPlayerConnectVector, bUnknown, platform, pUnknown, iUnknown); #elif SOURCE_ENGINE == SE_LEFT4DEAD || SOURCE_ENGINE == SE_LEFT4DEAD2 IClient *client = SH_MCALL(server, CHLTVServer_ConnectClient)(address, nProtocol, iChallenge, nAuthProtocol, pchName, passwordBuffer, pCookie, cbCookie, pSplitPlayerConnectVector, bUnknown); #else IClient *client = SH_MCALL(server, CHLTVServer_ConnectClient)(address, nProtocol, iChallenge, iClientChallenge, nAuthProtocol, pchName, passwordBuffer, pCookie, cbCookie); #endif if (!client) RETURN_META_VALUE(MRES_SUPERCEDE, nullptr); HookClient(client); HLTVServerWrapper *wrapper = g_HLTVServers.GetWrapper(server); if (wrapper) { HLTVClientWrapper *clientWrapper = wrapper->GetClient(client->GetPlayerSlot() + 1); clientWrapper->Initialize(ipString, pchPassword, client); } m_SpectatorConnectedFwd->PushCell(client->GetPlayerSlot() + 1); m_SpectatorConnectedFwd->Execute(); // Don't call the hooked function again, just return its value. RETURN_META_VALUE(MRES_SUPERCEDE, client); }