From 6465bd83a4275ed52fc615050079ed28a854c1ab Mon Sep 17 00:00:00 2001 From: Asher Baker Date: Wed, 11 Mar 2020 22:36:25 +0000 Subject: [PATCH] Update for latest Blade Symphony SDK --- AMBuildScript | 6 +- core/AMBuilder | 23 ++- core/HalfLife2.cpp | 15 +- core/MenuStyle_Radio.cpp | 6 +- core/PlayerManager.cpp | 2 +- core/UserMessagePBHelpers.h | 10 +- core/UserMessages.cpp | 47 ++++--- core/UserMessages.h | 6 +- core/smn_console.cpp | 4 +- core/smn_entities.cpp | 156 ++++++++++----------- core/smn_hudtext.cpp | 4 +- extensions/sdkhooks/extension.h | 8 +- extensions/sdkhooks/takedamageinfohack.cpp | 8 +- extensions/sdktools/gamerulesnatives.cpp | 4 +- extensions/sdktools/vsound.cpp | 18 +-- extensions/sdktools/vsound.h | 2 +- 16 files changed, 176 insertions(+), 143 deletions(-) diff --git a/AMBuildScript b/AMBuildScript index 96dbbd1a..9e52a273 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -52,7 +52,7 @@ PossibleSDKs = { 'eye': SDK('HL2SDK-EYE', '2.eye', '5', 'EYE', WinOnly, 'eye'), 'csgo': SDK('HL2SDKCSGO', '2.csgo', '21', 'CSGO', CSGO, 'csgo'), 'portal2': SDK('HL2SDKPORTAL2', '2.portal2', '17', 'PORTAL2', [], 'portal2'), - 'blade': SDK('HL2SDKBLADE', '2.blade', '18', 'BLADE', WinLinux, 'blade'), + 'blade': SDK('HL2SDKBLADE', '2.blade', '18', 'BLADE', WinOnly, 'blade'), 'insurgency': SDK('HL2SDKINSURGENCY', '2.insurgency', '19', 'INSURGENCY', WinLinuxMac, 'insurgency'), 'contagion': SDK('HL2SDKCONTAGION', '2.contagion', '14', 'CONTAGION', WinOnly, 'contagion'), 'bms': SDK('HL2SDKBMS', '2.bms', '10', 'BMS', WinLinux, 'bms'), @@ -538,7 +538,7 @@ class SMConfig(object): if builder.target.platform in ['linux', 'mac']: compiler.defines += ['NO_HOOK_MALLOC', 'NO_MALLOC_OVERRIDE'] - if sdk.name == 'csgo' and builder.target.platform == 'linux': + if sdk.name in ['csgo', 'blade'] and builder.target.platform == 'linux': compiler.linkflags += ['-lstdc++'] compiler.defines += ['_GLIBCXX_USE_CXX11_ABI=0'] @@ -584,7 +584,7 @@ class SMConfig(object): if builder.target.platform == 'linux': if sdk.name in ['css', 'hl2dm', 'dods', 'tf2', 'sdk2013', 'bms', 'nucleardawn', 'l4d2', 'insurgency', 'doi']: dynamic_libs = ['libtier0_srv.so', 'libvstdlib_srv.so'] - elif arch == 'x64' and sdk.name == 'csgo': + elif arch == 'x64' and sdk.name in ['csgo', 'blade']: dynamic_libs = ['libtier0_client.so', 'libvstdlib_client.so'] elif sdk.name in ['l4d', 'blade', 'insurgency', 'doi', 'csgo']: dynamic_libs = ['libtier0.so', 'libvstdlib.so'] diff --git a/core/AMBuilder b/core/AMBuilder index cc06cc1e..f77a2cbf 100644 --- a/core/AMBuilder +++ b/core/AMBuilder @@ -2,6 +2,7 @@ import os project = SM.HL2Project(builder, 'sourcemod') + project.sources += [ 'MenuStyle_Valve.cpp', 'logic_bridge.cpp', @@ -37,7 +38,6 @@ project.sources += [ 'MenuStyle_Radio.cpp', 'sm_autonatives.cpp', 'ConsoleDetours.cpp', - 'vprof_tool.cpp', 'smn_commandline.cpp', 'GameHooks.cpp', ] @@ -63,13 +63,19 @@ for sdk_name in SM.sdks: os.path.join(sdk.path, 'public', 'engine', 'protobuf'), os.path.join(sdk.path, 'public', 'game', 'shared', 'csgo', 'protobuf') ] + elif sdk.name == 'blade': + compiler.cxxincludes += [ + os.path.join(sdk.path, 'common', 'protobuf-2.5.0', 'src'), + os.path.join(sdk.path, 'public', 'engine', 'protobuf'), + os.path.join(sdk.path, 'public', 'game', 'shared', 'berimbau', 'protobuf') + ] if compiler.like('msvc'): compiler.defines += ['_ALLOW_KEYWORD_MACROS'] if builder.target.platform == 'linux': compiler.postlink += ['-lpthread', '-lrt'] - if sdk.name == 'csgo': + if sdk.name in ['csgo', 'blade']: if builder.target.platform == 'linux': if arch == 'x86': lib_path = os.path.join(sdk.path, 'lib', 'linux32', 'release', 'libprotobuf.a') @@ -95,17 +101,28 @@ for sdk_name in SM.sdks: lib_path = os.path.join(sdk.path, 'lib', 'win32', 'release', 'vs' + vs_year, 'libprotobuf.lib') compiler.linkflags.insert(0, binary.Dep(lib_path)) - if sdk.name == 'csgo': + if sdk.name in ['csgo', 'blade']: binary.sources += ['smn_protobuf.cpp'] else: binary.sources += ['smn_bitbuffer.cpp'] + if sdk.name != 'blade': + binary.sources += [ + 'vprof_tool.cpp', + ] + if sdk.name == 'csgo': binary.sources += [ os.path.join(sdk.path, 'public', 'engine', 'protobuf', 'netmessages.pb.cc'), os.path.join(sdk.path, 'public', 'game', 'shared', 'csgo', 'protobuf', 'cstrike15_usermessages.pb.cc'), os.path.join(sdk.path, 'public', 'game', 'shared', 'csgo', 'protobuf', 'cstrike15_usermessage_helpers.cpp'), ] + elif sdk.name == 'blade': + binary.sources += [ + os.path.join(sdk.path, 'public', 'engine', 'protobuf', 'netmessages.pb.cc'), + os.path.join(sdk.path, 'public', 'game', 'shared', 'berimbau', 'protobuf', 'berimbau_usermessages.pb.cc'), + os.path.join(sdk.path, 'public', 'game', 'shared', 'berimbau', 'protobuf', 'berimbau_usermessage_helpers.cpp'), + ] SM.binaries += builder.Add(project) diff --git a/core/HalfLife2.cpp b/core/HalfLife2.cpp index 27007a03..d9106d04 100644 --- a/core/HalfLife2.cpp +++ b/core/HalfLife2.cpp @@ -45,9 +45,10 @@ #if SOURCE_ENGINE == SE_CSGO #include +#elif SOURCE_ENGINE == SE_BLADE +#include #endif - typedef ICommandLine *(*FakeGetCommandLine)(); #define TIER0_NAME FORMAT_SOURCE_BIN_NAME("tier0") @@ -516,7 +517,7 @@ bool CHalfLife2::TextMsg(int client, int dest, const char *msg) char buffer[253]; ke::SafeSprintf(buffer, sizeof(buffer), "%s\1\n", msg); -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE CCSUsrMsg_SayText *pMsg; if ((pMsg = (CCSUsrMsg_SayText *)g_UserMsgs.StartProtobufMessage(m_SayTextMsg, players, 1, USERMSG_RELIABLE)) == NULL) { @@ -543,7 +544,7 @@ bool CHalfLife2::TextMsg(int client, int dest, const char *msg) } } -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE CCSUsrMsg_TextMsg *pMsg; if ((pMsg = (CCSUsrMsg_TextMsg *)g_UserMsgs.StartProtobufMessage(m_MsgTextMsg, players, 1, USERMSG_RELIABLE)) == NULL) { @@ -580,7 +581,7 @@ bool CHalfLife2::HintTextMsg(int client, const char *msg) { cell_t players[] = {client}; -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE CCSUsrMsg_HintText *pMsg; if ((pMsg = (CCSUsrMsg_HintText *)g_UserMsgs.StartProtobufMessage(m_HinTextMsg, players, 1, USERMSG_RELIABLE)) == NULL) { @@ -610,7 +611,7 @@ bool CHalfLife2::HintTextMsg(int client, const char *msg) bool CHalfLife2::HintTextMsg(cell_t *players, int count, const char *msg) { -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE CCSUsrMsg_HintText *pMsg; if ((pMsg = (CCSUsrMsg_HintText *)g_UserMsgs.StartProtobufMessage(m_HinTextMsg, players, count, USERMSG_RELIABLE)) == NULL) { @@ -645,7 +646,7 @@ bool CHalfLife2::ShowVGUIMenu(int client, const char *name, KeyValues *data, boo int count = 0; cell_t players[] = {client}; -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE CCSUsrMsg_VGUIMenu *pMsg; if ((pMsg = (CCSUsrMsg_VGUIMenu *)g_UserMsgs.StartProtobufMessage(m_VGUIMenu, players, 1, USERMSG_RELIABLE)) == NULL) { @@ -670,7 +671,7 @@ bool CHalfLife2::ShowVGUIMenu(int client, const char *name, KeyValues *data, boo SubKey = data->GetFirstSubKey(); } -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE pMsg->set_name(name); pMsg->set_show(show); diff --git a/core/MenuStyle_Radio.cpp b/core/MenuStyle_Radio.cpp index de7d8c9e..764c32f5 100644 --- a/core/MenuStyle_Radio.cpp +++ b/core/MenuStyle_Radio.cpp @@ -45,6 +45,8 @@ #if SOURCE_ENGINE == SE_CSGO #include +#elif SOURCE_ENGINE == SE_BLADE +#include #endif extern const char *g_RadioNumTable[]; @@ -174,7 +176,7 @@ void CRadioStyle::OnUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFil { int count = pFilter->GetRecipientCount(); -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE int c = ((CCSUsrMsg_ShowMenu &)msg).display_time(); #else bf_read br(bf->GetBasePointer(), 3); @@ -483,7 +485,7 @@ void CRadioMenuPlayer::Radio_Refresh() time = menuHoldTime - (unsigned int)(gpGlobals->curtime - menuStartTime); } -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE // TODO: find what happens past 240 on CS:GO CCSUsrMsg_ShowMenu *msg = (CCSUsrMsg_ShowMenu *)g_UserMsgs.StartProtobufMessage(g_ShowMenuId, players, 1, USERMSG_BLOCKHOOKS); msg->set_bits_valid_slots(display_keys); diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index 1453abf0..0ab95008 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -2463,7 +2463,7 @@ void CPlayer::Kick(const char *str) } else { -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE pClient->Disconnect(str); #else pClient->Disconnect("%s", str); diff --git a/core/UserMessagePBHelpers.h b/core/UserMessagePBHelpers.h index b76e443a..95824cae 100644 --- a/core/UserMessagePBHelpers.h +++ b/core/UserMessagePBHelpers.h @@ -816,7 +816,7 @@ public: inline bool GetColor(const char *pszFieldName, Color *out) { -#if SOURCE_ENGINE != SE_CSGO +#if SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_BLADE return false; #else GETCHECK_FIELD(); @@ -837,7 +837,7 @@ public: inline bool SetColor(const char *pszFieldName, const Color &value) { -#if SOURCE_ENGINE != SE_CSGO +#if SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_BLADE return false; #else GETCHECK_FIELD(); @@ -856,7 +856,7 @@ public: inline bool GetRepeatedColor(const char *pszFieldName, int index, Color *out) { -#if SOURCE_ENGINE != SE_CSGO +#if SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_BLADE return false; #else GETCHECK_FIELD(); @@ -878,7 +878,7 @@ public: inline bool SetRepeatedColor(const char *pszFieldName, int index, const Color &value) { -#if SOURCE_ENGINE != SE_CSGO +#if SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_BLADE return false; #else GETCHECK_FIELD(); @@ -898,7 +898,7 @@ public: inline bool AddColor(const char *pszFieldName, const Color &value) { -#if SOURCE_ENGINE != SE_CSGO +#if SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_BLADE return false; #else GETCHECK_FIELD(); diff --git a/core/UserMessages.cpp b/core/UserMessages.cpp index a8b08631..8c8d9b0d 100644 --- a/core/UserMessages.cpp +++ b/core/UserMessages.cpp @@ -35,12 +35,14 @@ #if SOURCE_ENGINE == SE_CSGO #include +#elif SOURCE_ENGINE == SE_BLADE +#include #endif #include UserMessages g_UserMsgs; -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE SH_DECL_HOOK3_void(IVEngineServer, SendUserMessage, SH_NOATTRIB, 0, IRecipientFilter &, int, const protobuf::Message &); #else #if SOURCE_ENGINE >= SE_LEFT4DEAD @@ -49,7 +51,7 @@ SH_DECL_HOOK3(IVEngineServer, UserMessageBegin, SH_NOATTRIB, 0, bf_write *, IRec SH_DECL_HOOK2(IVEngineServer, UserMessageBegin, SH_NOATTRIB, 0, bf_write *, IRecipientFilter *, int); #endif SH_DECL_HOOK0_void(IVEngineServer, MessageEnd, SH_NOATTRIB, 0); -#endif // ==SE_CSGO +#endif // ==SE_CSGO || ==SE_BLADE UserMessages::UserMessages() #ifndef USE_PROTOBUF_USERMESSAGES @@ -93,7 +95,7 @@ void UserMessages::OnSourceModAllShutdown() { if (m_HookCount) { -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Pre), false); SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Post), true); #else @@ -111,6 +113,8 @@ int UserMessages::GetMessageIndex(const char *msg) #if SOURCE_ENGINE == SE_CSGO // Can split this per engine and/or game later return g_Cstrike15UsermessageHelpers.GetIndex(msg); +#elif SOURCE_ENGINE == SE_BLADE + return g_BerimbauUsermessageHelpers.GetIndex(msg); #else int msgid; @@ -148,6 +152,8 @@ bool UserMessages::GetMessageName(int msgid, char *buffer, size_t maxlength) con #ifdef USE_PROTOBUF_USERMESSAGES #if SOURCE_ENGINE == SE_CSGO const char *pszName = g_Cstrike15UsermessageHelpers.GetName(msgid); +#elif SOURCE_ENGINE == SE_BLADE + const char *pszName = g_BerimbauUsermessageHelpers.GetName(msgid); #endif if (!pszName) return false; @@ -297,7 +303,7 @@ bool UserMessages::EndMessage() return false; } -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE if (m_CurFlags & USERMSG_BLOCKHOOKS) { ENGINE_CALL(SendUserMessage)(static_cast(m_CellRecFilter), m_CurId, *m_FakeEngineBuffer); @@ -327,7 +333,7 @@ bool UserMessages::EndMessage() } else { engine->MessageEnd(); } -#endif // SE_CSGO +#endif // SE_CSGO || SE_BLADE m_InExec = false; m_CurFlags = 0; @@ -412,7 +418,7 @@ bool UserMessages::InternalHook(int msg_id, IBitBufUserMessageListener *pListene if (!m_HookCount++) { -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE SH_ADD_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Pre), false); SH_ADD_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Post), true); #else @@ -438,6 +444,8 @@ const protobuf::Message *UserMessages::GetMessagePrototype(int msg_type) { #if SOURCE_ENGINE == SE_CSGO return g_Cstrike15UsermessageHelpers.GetPrototype(msg_type); +#elif SOURCE_ENGINE == SE_BLADE + return g_BerimbauUsermessageHelpers.GetPrototype(msg_type); #endif } #endif @@ -487,7 +495,7 @@ void UserMessages::_DecRefCounter() { if (--m_HookCount == 0) { -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Pre), false); SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Post), true); #else @@ -499,12 +507,17 @@ void UserMessages::_DecRefCounter() } } -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE void UserMessages::OnSendUserMessage_Pre(IRecipientFilter &filter, int msg_type, const protobuf::Message &msg) { #if SOURCE_ENGINE == SE_CSGO - OnStartMessage_Pre(&filter, msg_type, g_Cstrike15UsermessageHelpers.GetName(msg_type)); + const char *pszName = g_Cstrike15UsermessageHelpers.GetName(msg_type); +#elif SOURCE_ENGINE == SE_BLADE + const char *pszName = g_BerimbauUsermessageHelpers.GetName(msg_type); #endif + + OnStartMessage_Pre(&filter, msg_type, pszName); + if (m_FakeMetaRes == MRES_SUPERCEDE) { int size = msg.ByteSize(); @@ -517,9 +530,7 @@ void UserMessages::OnSendUserMessage_Pre(IRecipientFilter &filter, int msg_type, m_FakeEngineBuffer = &const_cast(msg); } -#if SOURCE_ENGINE == SE_CSGO - OnStartMessage_Post(&filter, msg_type, g_Cstrike15UsermessageHelpers.GetName(msg_type)); -#endif + OnStartMessage_Post(&filter, msg_type, pszName); OnMessageEnd_Pre(); if (m_FakeMetaRes == MRES_SUPERCEDE) @@ -551,7 +562,7 @@ void UserMessages::OnSendUserMessage_Post(IRecipientFilter &filter, int msg_type RETURN_META(res) #endif -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE protobuf::Message *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name) #elif SOURCE_ENGINE >= SE_LEFT4DEAD bf_write *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name) @@ -591,7 +602,7 @@ bf_write *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_typ UM_RETURN_META_VALUE(MRES_IGNORED, NULL); } -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE protobuf::Message *UserMessages::OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name) #elif SOURCE_ENGINE >= SE_LEFT4DEAD bf_write *UserMessages::OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name) @@ -756,7 +767,7 @@ void UserMessages::OnMessageEnd_Pre() if (!handled && intercepted) { -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE ENGINE_CALL(SendUserMessage)(static_cast(*m_CurRecFilter), m_CurId, *m_InterceptBuffer); #else bf_write *engine_bfw; @@ -768,11 +779,11 @@ void UserMessages::OnMessageEnd_Pre() m_ReadBuffer.StartReading(m_InterceptBuffer.GetBasePointer(), m_InterceptBuffer.GetNumBytesWritten()); engine_bfw->WriteBitsFromBuffer(&m_ReadBuffer, m_InterceptBuffer.GetNumBitsWritten()); ENGINE_CALL(MessageEnd)(); -#endif // SE_CSGO +#endif // SE_CSGO || SE_BLADE } { -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE int size = m_OrigBuffer->ByteSize(); uint8 *data = (uint8 *)stackalloc(size); m_OrigBuffer->SerializePartialToArray(data, size); @@ -802,7 +813,7 @@ void UserMessages::OnMessageEnd_Pre() iter++; } -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE delete pTempMsg; #endif } diff --git a/core/UserMessages.h b/core/UserMessages.h index 4e68fe8e..7c1a2a9b 100644 --- a/core/UserMessages.h +++ b/core/UserMessages.h @@ -44,7 +44,7 @@ using namespace SourceHook; using namespace SourceMod; -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE #define USE_PROTOBUF_USERMESSAGES #endif @@ -102,12 +102,12 @@ public: //IUserMessages bool intercept=false); UserMessageType GetUserMessageType() const; public: -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE void OnSendUserMessage_Pre(IRecipientFilter &filter, int msg_type, const protobuf::Message &msg); void OnSendUserMessage_Post(IRecipientFilter &filter, int msg_type, const protobuf::Message &msg); #endif -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE protobuf::Message *OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name); protobuf::Message *OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name); #elif SOURCE_ENGINE >= SE_LEFT4DEAD diff --git a/core/smn_console.cpp b/core/smn_console.cpp index 1621977a..4be81d7e 100644 --- a/core/smn_console.cpp +++ b/core/smn_console.cpp @@ -51,7 +51,7 @@ #include #include -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE #include #endif @@ -1171,7 +1171,7 @@ static cell_t SendConVarValue(IPluginContext *pContext, const cell_t *params) char data[256]; bf_write buffer(data, sizeof(data)); -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE CNETMsg_SetConVar msg; CMsg_CVars_CVar *cvar = msg.mutable_convars()->add_cvars(); diff --git a/core/smn_entities.cpp b/core/smn_entities.cpp index e9fc68c7..a8495694 100644 --- a/core/smn_entities.cpp +++ b/core/smn_entities.cpp @@ -301,31 +301,31 @@ static cell_t RemoveEntity(IPluginContext *pContext, const cell_t *params) // Some games have UTIL_Remove exposed on IServerTools, but for consistence, we'll // use this method for all. Results in DeathNotice( this ) being called on parent, // and parent being cleared (both if any parent) before UTIL_Remove is called. - static inputfunc_t fnKillEntity = nullptr; - if (!fnKillEntity) - { - // Get world, as other ents aren't guaranteed to inherit full datadesc (but kill func is same for all) - CBaseEntity *pGetterEnt = g_HL2.ReferenceToEntity(0); - if (pGetterEnt == nullptr) - { - // If we don't have a world entity yet, we'll have to rely on the given entity. Does this even make sense??? - pGetterEnt = pEntity; - } - - datamap_t *pMap = g_HL2.GetDataMap(pGetterEnt); - - sm_datatable_info_t info; - if (!g_HL2.FindDataMapInfo(pMap, "InputKill", &info)) - { - return pContext->ThrowNativeError("Failed to find Kill input!"); - } - - fnKillEntity = info.prop->inputFunc; - } - + static inputfunc_t fnKillEntity = nullptr; + if (!fnKillEntity) + { + // Get world, as other ents aren't guaranteed to inherit full datadesc (but kill func is same for all) + CBaseEntity *pGetterEnt = g_HL2.ReferenceToEntity(0); + if (pGetterEnt == nullptr) + { + // If we don't have a world entity yet, we'll have to rely on the given entity. Does this even make sense??? + pGetterEnt = pEntity; + } + + datamap_t *pMap = g_HL2.GetDataMap(pGetterEnt); + + sm_datatable_info_t info; + if (!g_HL2.FindDataMapInfo(pMap, "InputKill", &info)) + { + return pContext->ThrowNativeError("Failed to find Kill input!"); + } + + fnKillEntity = info.prop->inputFunc; + } + // Input data is ignored for this. No need to initialize - static inputdata_t data; - + static inputdata_t data; + (pEntity->*fnKillEntity)(data); return 1; @@ -1379,7 +1379,7 @@ static cell_t GetEntProp(IPluginContext *pContext, const cell_t *params) // This isn't in CS:S yet, but will be, doesn't hurt to add now, and will save us a build later #if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS \ || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 \ - || SOURCE_ENGINE == SE_CSGO + || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE if (pProp->GetFlags() & SPROP_VARINT) { bit_count = sizeof(int) * 8; @@ -1498,7 +1498,7 @@ static cell_t SetEntProp(IPluginContext *pContext, const cell_t *params) // This isn't in CS:S yet, but will be, doesn't hurt to add now, and will save us a build later #if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS \ || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2 \ - || SOURCE_ENGINE == SE_CSGO + || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE if (pProp->GetFlags() & SPROP_VARINT) { bit_count = sizeof(int) * 8; @@ -1829,22 +1829,22 @@ static cell_t SetEntPropEnt(IPluginContext *pContext, const cell_t *params) switch (td->fieldType) { - case FIELD_EHANDLE: - type = PropEnt_Handle; - break; - case FIELD_CLASSPTR: - type = PropEnt_Entity; - break; - case FIELD_EDICT: - type = PropEnt_Edict; - if (!pEdict) - return pContext->ThrowNativeError("Edict %d is invalid", params[1]); - break; - case FIELD_CUSTOM: - if ((td->flags & FTYPEDESC_OUTPUT) == FTYPEDESC_OUTPUT) - { - type = PropEnt_Variant; - } + case FIELD_EHANDLE: + type = PropEnt_Handle; + break; + case FIELD_CLASSPTR: + type = PropEnt_Entity; + break; + case FIELD_EDICT: + type = PropEnt_Edict; + if (!pEdict) + return pContext->ThrowNativeError("Edict %d is invalid", params[1]); + break; + case FIELD_CUSTOM: + if ((td->flags & FTYPEDESC_OUTPUT) == FTYPEDESC_OUTPUT) + { + type = PropEnt_Variant; + } break; } @@ -1881,9 +1881,9 @@ static cell_t SetEntPropEnt(IPluginContext *pContext, const cell_t *params) switch (type) { - case PropEnt_Handle: - case PropEnt_Variant: - { + case PropEnt_Handle: + case PropEnt_Variant: + { CBaseHandle *hndl; if (type == PropEnt_Handle) { @@ -1893,44 +1893,44 @@ static cell_t SetEntPropEnt(IPluginContext *pContext, const cell_t *params) { auto *pVariant = (variant_t *)((intptr_t)pEntity + offset); hndl = &pVariant->eVal; - } - - hndl->Set((IHandleEntity *) pOther); - - if (params[2] == Prop_Send && (pEdict != NULL)) - { - g_HL2.SetEdictStateChanged(pEdict, offset); + } + + hndl->Set((IHandleEntity *) pOther); + + if (params[2] == Prop_Send && (pEdict != NULL)) + { + g_HL2.SetEdictStateChanged(pEdict, offset); } } - break; - - case PropEnt_Entity: - { - *(CBaseEntity **) ((uint8_t *) pEntity + offset) = pOther; - break; - } - - case PropEnt_Edict: - { - edict_t *pOtherEdict = NULL; + break; + + case PropEnt_Entity: + { + *(CBaseEntity **) ((uint8_t *) pEntity + offset) = pOther; + break; + } + + case PropEnt_Edict: + { + edict_t *pOtherEdict = NULL; if (pOther) { - IServerNetworkable *pNetworkable = ((IServerUnknown *) pOther)->GetNetworkable(); - if (!pNetworkable) - { - return pContext->ThrowNativeError("Entity %d (%d) does not have a valid edict", g_HL2.ReferenceToIndex(params[4]), params[4]); - } - - pOtherEdict = pNetworkable->GetEdict(); - if (!pOtherEdict || pOtherEdict->IsFree()) - { - return pContext->ThrowNativeError("Entity %d (%d) does not have a valid edict", g_HL2.ReferenceToIndex(params[4]), params[4]); - } - } - - *(edict_t **) ((uint8_t *) pEntity + offset) = pOtherEdict; - break; + IServerNetworkable *pNetworkable = ((IServerUnknown *) pOther)->GetNetworkable(); + if (!pNetworkable) + { + return pContext->ThrowNativeError("Entity %d (%d) does not have a valid edict", g_HL2.ReferenceToIndex(params[4]), params[4]); + } + + pOtherEdict = pNetworkable->GetEdict(); + if (!pOtherEdict || pOtherEdict->IsFree()) + { + return pContext->ThrowNativeError("Entity %d (%d) does not have a valid edict", g_HL2.ReferenceToIndex(params[4]), params[4]); + } + } + + *(edict_t **) ((uint8_t *) pEntity + offset) = pOtherEdict; + break; } } diff --git a/core/smn_hudtext.cpp b/core/smn_hudtext.cpp index 0f2d01ad..90b04052 100644 --- a/core/smn_hudtext.cpp +++ b/core/smn_hudtext.cpp @@ -39,6 +39,8 @@ #if SOURCE_ENGINE == SE_CSGO #include +#elif SOURCE_ENGINE == SE_BLADE +#include #endif #define MAX_HUD_CHANNELS 6 @@ -316,7 +318,7 @@ void UTIL_SendHudText(int client, const hud_text_parms &textparms, const char *p players[0] = client; -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE CCSUsrMsg_HudMsg *msg = (CCSUsrMsg_HudMsg *)g_UserMsgs.StartProtobufMessage(g_HudMsgNum, players, 1, 0); msg->set_channel(textparms.channel & 0xFF); diff --git a/extensions/sdkhooks/extension.h b/extensions/sdkhooks/extension.h index 1bd7267b..580be1d8 100644 --- a/extensions/sdkhooks/extension.h +++ b/extensions/sdkhooks/extension.h @@ -21,7 +21,7 @@ #if SOURCE_ENGINE >= SE_CSS && SOURCE_ENGINE != SE_LEFT4DEAD #define GETMAXHEALTH_IS_VIRTUAL #endif -#if SOURCE_ENGINE != SE_HL2DM && SOURCE_ENGINE != SE_DODS && SOURCE_ENGINE != SE_CSS && SOURCE_ENGINE != SE_TF2 && SOURCE_ENGINE != SE_LEFT4DEAD2 && SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_NUCLEARDAWN +#if SOURCE_ENGINE != SE_HL2DM && SOURCE_ENGINE != SE_DODS && SOURCE_ENGINE != SE_CSS && SOURCE_ENGINE != SE_TF2 && SOURCE_ENGINE != SE_LEFT4DEAD2 && SOURCE_ENGINE != SE_CSGO && SOURCE_ENGINE != SE_NUCLEARDAWN && SOURCE_ENGINE != SE_BLADE #define GAMEDESC_CAN_CHANGE #endif @@ -78,11 +78,11 @@ enum SDKHookType SDKHook_Reload, SDKHook_ReloadPost, SDKHook_GetMaxHealth, - SDKHook_Blocked, + SDKHook_Blocked, SDKHook_BlockedPost, SDKHook_OnTakeDamage_Alive, - SDKHook_OnTakeDamage_AlivePost, - SDKHook_CanBeAutobalanced, + SDKHook_OnTakeDamage_AlivePost, + SDKHook_CanBeAutobalanced, SDKHook_MAXHOOKS }; diff --git a/extensions/sdkhooks/takedamageinfohack.cpp b/extensions/sdkhooks/takedamageinfohack.cpp index 0fdb076b..09624df5 100644 --- a/extensions/sdkhooks/takedamageinfohack.cpp +++ b/extensions/sdkhooks/takedamageinfohack.cpp @@ -88,10 +88,10 @@ CTakeDamageInfoHack::CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity * m_flRadius = 0.0f; #endif -#if SOURCE_ENGINE == SE_INSURGENCY || SOURCE_ENGINE == SE_DOI || SOURCE_ENGINE == SE_CSGO - m_iDamagedOtherPlayers = 0; - m_iObjectsPenetrated = 0; - m_uiBulletID = 0; +#if SOURCE_ENGINE == SE_INSURGENCY || SOURCE_ENGINE == SE_DOI || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE + m_iDamagedOtherPlayers = 0; + m_iObjectsPenetrated = 0; + m_uiBulletID = 0; m_uiRecoilIndex = 0; #endif } diff --git a/extensions/sdktools/gamerulesnatives.cpp b/extensions/sdktools/gamerulesnatives.cpp index 1abe4241..d44801d5 100644 --- a/extensions/sdktools/gamerulesnatives.cpp +++ b/extensions/sdktools/gamerulesnatives.cpp @@ -182,7 +182,7 @@ static cell_t GameRules_GetProp(IPluginContext *pContext, const cell_t *params) // This isn't in CS:S yet, but will be, doesn't hurt to add now, and will save us a build later #if 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_CSGO + || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE if (pProp->GetFlags() & SPROP_VARINT) { bit_count = sizeof(int) * 8; @@ -256,7 +256,7 @@ static cell_t GameRules_SetProp(IPluginContext *pContext, const cell_t *params) FIND_PROP_SEND(DPT_Int, "integer"); #if 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_CSGO + || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE if (pProp->GetFlags() & SPROP_VARINT) { bit_count = sizeof(int) * 8; diff --git a/extensions/sdktools/vsound.cpp b/extensions/sdktools/vsound.cpp index 02ddc0c6..eb58020b 100644 --- a/extensions/sdktools/vsound.cpp +++ b/extensions/sdktools/vsound.cpp @@ -34,7 +34,7 @@ SH_DECL_HOOK8_void(IVEngineServer, EmitAmbientSound, SH_NOATTRIB, 0, int, const Vector &, const char *, float, soundlevel_t, int, int, float); -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE SH_DECL_HOOK18(IEngineSound, EmitSound, SH_NOATTRIB, 0, int, IRecipientFilter &, int, int, const char *, unsigned int, const char *, float, float, int, int, int, const Vector *, const Vector *, CUtlVector *, bool, float, int, void *); SH_DECL_HOOK18(IEngineSound, EmitSound, SH_NOATTRIB, 1, int, IRecipientFilter &, int, int, const char *, unsigned int, const char *, float, soundlevel_t, int, int, int, const Vector *, const Vector *, CUtlVector *, bool, float, int, void *); #elif SOURCE_ENGINE >= SE_PORTAL2 @@ -316,7 +316,7 @@ uint32 GenerateSoundEntryHash(char const *pSoundEntry) } #endif -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE int SoundHooks::OnEmitSound(IRecipientFilter &filter, int iEntIndex, int iChannel, const char *pSoundEntry, unsigned int nSoundEntryHash, const char *pSample, float flVolume, soundlevel_t iSoundlevel, int nSeed, int iFlags, int iPitch, const Vector *pOrigin, const Vector *pDirection, CUtlVector *pUtlVecOrigins, bool bUpdatePositions, @@ -422,7 +422,7 @@ void SoundHooks::OnEmitSound(IRecipientFilter &filter, int iEntIndex, int iChann CellRecipientFilter crf; crf.Initialize(players, size); -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE RETURN_META_VALUE_NEWPARAMS( MRES_IGNORED, -1, @@ -467,7 +467,7 @@ void SoundHooks::OnEmitSound(IRecipientFilter &filter, int iEntIndex, int iChann #endif } -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE int SoundHooks::OnEmitSound2(IRecipientFilter &filter, int iEntIndex, int iChannel, const char *pSoundEntry, unsigned int nSoundEntryHash, const char *pSample, float flVolume, float flAttenuation, int nSeed, int iFlags, int iPitch, const Vector *pOrigin, const Vector *pDirection, CUtlVector *pUtlVecOrigins, bool bUpdatePositions, @@ -574,7 +574,7 @@ void SoundHooks::OnEmitSound2(IRecipientFilter &filter, int iEntIndex, int iChan CellRecipientFilter crf; crf.Initialize(players, size); -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE RETURN_META_VALUE_NEWPARAMS( MRES_IGNORED, -1, @@ -876,7 +876,7 @@ static cell_t EmitSound(IPluginContext *pContext, const cell_t *params) player[0] = cl_array[i]; crf.Reset(); crf.Initialize(player, 1); -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE if (g_InSoundHook) { SH_CALL(enginesoundPatch, @@ -1054,7 +1054,7 @@ static cell_t EmitSound(IPluginContext *pContext, const cell_t *params) #endif } } else { -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE if (g_InSoundHook) { SH_CALL(enginesoundPatch, @@ -1341,7 +1341,7 @@ static cell_t EmitSoundEntry(IPluginContext *pContext, const cell_t *params) if (g_InSoundHook) { -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE SH_CALL(enginesoundPatch, static_cast *, bool, float, int, void *)> @@ -1365,7 +1365,7 @@ SH_CALL(enginesoundPatch, else { if (g_InSoundHook) { -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE SH_CALL(enginesoundPatch, static_cast *, bool, float, int, void *)> diff --git a/extensions/sdktools/vsound.h b/extensions/sdktools/vsound.h index eff87918..6c352ddd 100644 --- a/extensions/sdktools/vsound.h +++ b/extensions/sdktools/vsound.h @@ -53,7 +53,7 @@ public: void OnEmitAmbientSound(int entindex, const Vector &pos, const char *samp, float vol, soundlevel_t soundlevel, int fFlags, int pitch, float delay); -#if SOURCE_ENGINE == SE_CSGO +#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE int OnEmitSound(IRecipientFilter& filter, int iEntIndex, int iChannel, const char *, unsigned int, const char *pSample, float flVolume, soundlevel_t iSoundlevel, int nSeed, int iFlags, int iPitch, const Vector *pOrigin, const Vector *pDirection, CUtlVector *pUtlVecOrigins, bool bUpdatePositions,