From 68c88574102a4a27f7a11c42e9ce8f2f18b52e3f Mon Sep 17 00:00:00 2001 From: Nick Hastings Date: Wed, 22 Sep 2021 21:03:21 -0400 Subject: [PATCH] Enable more CS:GO engine logic for Blade Symphony. --- core/GameHooks.cpp | 2 +- core/PlayerManager.cpp | 12 ++++++----- core/PlayerManager.h | 4 ++-- core/concmd_cleaner.cpp | 4 ++-- core/pb_proxy.cpp | 4 ++++ extensions/sdktools/extension.cpp | 6 ++++-- extensions/sdktools/vnatives.cpp | 34 ++++++++++++++++++++++++++++++- 7 files changed, 53 insertions(+), 13 deletions(-) diff --git a/core/GameHooks.cpp b/core/GameHooks.cpp index db50b03d..e8d18c4f 100644 --- a/core/GameHooks.cpp +++ b/core/GameHooks.cpp @@ -115,7 +115,7 @@ void GameHooks::OnQueryCvarValueFinished(QueryCvarCookie_t cookie, edict_t *pPla const char *cvarName, const char *cvarValue){ int client = IndexOfEdict(pPlayer); -# if SOURCE_ENGINE == SE_CSGO +# if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE if (g_Players.HandleConVarQuery(cookie, client, result, cvarName, cvarValue)) return; # endif diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index b3bec201..e2550058 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -512,7 +512,7 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const /* Get the client's language */ if (m_QueryLang) { -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE pPlayer->m_LangId = translator->GetServerLanguage(); #else const char *name; @@ -666,6 +666,8 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername && (m_SourceTVUserId == userId #if SOURCE_ENGINE == SE_CSGO || strcmp(playername, "GOTV") == 0 +#elif SOURCE_ENGINE == SE_BLADE + || strcmp(playername, "BBTV") == 0 #elif (SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_SDK2013 \ || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_NUCLEARDAWN || SOURCE_ENGINE == SE_LEFT4DEAD2) || (tv_name && strcmp(playername, tv_name->GetString()) == 0) || (tv_name && tv_name->GetString()[0] == 0 && strcmp(playername, "unnamed") == 0) @@ -721,7 +723,7 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername } pPlayer->Authorize_Post(); } -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE else if(m_QueryLang) { // Not a bot @@ -781,7 +783,7 @@ void PlayerManager::OnServerHibernationUpdate(bool bHibernating) CPlayer *pPlayer = &m_Players[i]; if (pPlayer->IsConnected() && pPlayer->IsFakeClient()) { -#if SOURCE_ENGINE < SE_LEFT4DEAD || SOURCE_ENGINE >= SE_CSGO || SOURCE_ENGINE == SE_NUCLEARDAWN +#if SOURCE_ENGINE < SE_LEFT4DEAD || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_NUCLEARDAWN // These games have the bug fixed where hltv/replay was getting kicked on hibernation if (pPlayer->IsSourceTV() || pPlayer->IsReplay()) continue; @@ -2008,7 +2010,7 @@ void CmdMaxplayersCallback() g_Players.MaxPlayersChanged(); } -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE bool PlayerManager::HandleConVarQuery(QueryCvarCookie_t cookie, int client, EQueryCvarValueStatus result, const char *cvarName, const char *cvarValue) { for (int i = 1; i <= m_maxClients; i++) @@ -2240,7 +2242,7 @@ void CPlayer::Disconnect() m_bIsSourceTV = false; m_bIsReplay = false; m_Serial.value = -1; -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE m_LanguageCookie = InvalidQueryCvarCookie; #endif ClearNetchannelQueue(); diff --git a/core/PlayerManager.h b/core/PlayerManager.h index d0cfda28..44a6df98 100644 --- a/core/PlayerManager.h +++ b/core/PlayerManager.h @@ -151,7 +151,7 @@ private: bool m_bIsReplay = false; serial_t m_Serial; CSteamID m_SteamId; -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE QueryCvarCookie_t m_LanguageCookie = InvalidQueryCvarCookie; #endif std::deque m_PrintfBuffer; @@ -235,7 +235,7 @@ public: { return m_bInCCKVHook; } -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE bool HandleConVarQuery(QueryCvarCookie_t cookie, int client, EQueryCvarValueStatus result, const char *cvarName, const char *cvarValue); #endif private: diff --git a/core/concmd_cleaner.cpp b/core/concmd_cleaner.cpp index f95103fc..83734054 100644 --- a/core/concmd_cleaner.cpp +++ b/core/concmd_cleaner.cpp @@ -36,7 +36,7 @@ #if SOURCE_ENGINE >= SE_ORANGEBOX SH_DECL_HOOK1_void(ICvar, UnregisterConCommand, SH_NOATTRIB, 0, ConCommandBase *); -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE SH_DECL_HOOK2_void(ICvar, RegisterConCommand, SH_NOATTRIB, 0, ConCommandBase *, bool); #else SH_DECL_HOOK1_void(ICvar, RegisterConCommand, SH_NOATTRIB, 0, ConCommandBase *); @@ -82,7 +82,7 @@ public: #endif } -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE void LinkConCommandBase(ConCommandBase *pBase, bool unknown) #else void LinkConCommandBase(ConCommandBase *pBase) diff --git a/core/pb_proxy.cpp b/core/pb_proxy.cpp index 886cafa4..9d005777 100644 --- a/core/pb_proxy.cpp +++ b/core/pb_proxy.cpp @@ -35,6 +35,8 @@ #if SOURCE_ENGINE == SE_CSGO # include +#elif SOURCE_ENGINE == SE_BLADE +# include #else # error "No source engine compatibility" #endif @@ -88,6 +90,8 @@ ProtobufProxy::NewPrototype(int msg_type) { #if SOURCE_ENGINE == SE_CSGO return g_Cstrike15UsermessageHelpers.GetPrototype(msg_type)->New(); +#else SOURCE_ENGINE == SE_BLADE + return g_BerimbauUsermessageHelpers.GetPrototype(msg_type)->New(); #else # error "No source engine compatibility." #endif diff --git a/extensions/sdktools/extension.cpp b/extensions/sdktools/extension.cpp index ef35c7ba..889fe0c4 100644 --- a/extensions/sdktools/extension.cpp +++ b/extensions/sdktools/extension.cpp @@ -107,7 +107,7 @@ extern sp_nativeinfo_t g_ClientNatives[]; static void InitSDKToolsAPI(); -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE CDetour *g_WriteBaselinesDetour = NULL; DETOUR_DECL_MEMBER3(CNetworkStringTableContainer__WriteBaselines, void, char const *, mapName, void *, buffer, int, currentTick) @@ -205,7 +205,9 @@ bool SDKTools::SDK_OnLoad(char *error, size_t maxlength, bool late) m_CSGOBadList.init(); m_CSGOBadList.add("m_bIsValveDS"); m_CSGOBadList.add("m_bIsQuestEligible"); +#endif +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE g_WriteBaselinesDetour = DETOUR_CREATE_MEMBER(CNetworkStringTableContainer__WriteBaselines, "WriteBaselines"); if (g_WriteBaselinesDetour) { g_WriteBaselinesDetour->EnableDetour(); @@ -243,7 +245,7 @@ void SDKTools::SDK_OnUnload() g_RegCalls.clear(); ShutdownHelpers(); -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE if (g_WriteBaselinesDetour) { g_WriteBaselinesDetour->DisableDetour(); g_WriteBaselinesDetour = NULL; diff --git a/extensions/sdktools/vnatives.cpp b/extensions/sdktools/vnatives.cpp index aa742131..18597ad6 100644 --- a/extensions/sdktools/vnatives.cpp +++ b/extensions/sdktools/vnatives.cpp @@ -197,6 +197,38 @@ static cell_t GiveNamedItem(IPluginContext *pContext, const cell_t *params) return gamehelpers->EntityToBCompatRef(pEntity); } +#elif SOURCE_ENGINE == SE_BLADE +class CEconItemView; +static cell_t GiveNamedItem(IPluginContext *pContext, const cell_t *params) +{ + static ValveCall *pCall = NULL; + if (!pCall) + { + ValvePassInfo pass[5]; + InitPass(pass[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL); + InitPass(pass[1], Valve_POD, PassType_Basic, PASSFLAG_BYVAL); + InitPass(pass[2], Valve_POD, PassType_Basic, PASSFLAG_BYVAL); + InitPass(pass[3], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL); + InitPass(pass[4], Valve_CBaseEntity, PassType_Basic, PASSFLAG_BYVAL); + if (!CreateBaseCall("GiveNamedItem", ValveCall_Player, &pass[4], pass, 4, &pCall)) + { + return pContext->ThrowNativeError("\"GiveNamedItem\" not supported by this mod"); + } else if (!pCall) { + return pContext->ThrowNativeError("\"GiveNamedItem\" wrapper failed to initialize"); + } + } + + CBaseEntity *pEntity = NULL; + START_CALL(); + DECODE_VALVE_PARAM(1, thisinfo, 0); + DECODE_VALVE_PARAM(2, vparams, 0); + DECODE_VALVE_PARAM(3, vparams, 1); + *(CEconItemView **)(vptr + 12) = NULL; + *(bool *)(vptr + 16) = false; + FINISH_CALL_SIMPLE(&pEntity); + + return gamehelpers->EntityToBCompatRef(pEntity); +} #elif SOURCE_ENGINE == SE_BMS // CBaseEntity *GiveNamedItem( const char *szName, int iSubType = 0, int iPrimaryAmmo = -1, int iSecondaryAmmo = -1 ) static cell_t GiveNamedItem(IPluginContext *pContext, const cell_t *params) @@ -972,7 +1004,7 @@ static cell_t CreateEntityByName(IPluginContext *pContext, const cell_t *params) char *classname; pContext->LocalToString(params[1], &classname); -#if SOURCE_ENGINE != SE_CSGO +#if SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_BLADE CBaseEntity *pEntity = (CBaseEntity *)servertools->CreateEntityByName(classname); #else CBaseEntity *pEntity = (CBaseEntity *)servertools->CreateItemEntityByName(classname);