-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
29c8e3a
commit 06bcc07
Showing
14 changed files
with
947 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: | ||
import os, sys | ||
|
||
projectName = 'survivor_bot_blockers_fix' | ||
|
||
# smsdk_ext.cpp will be automatically added later | ||
sourceFiles = [ | ||
'extension.cpp', | ||
] | ||
|
||
############### | ||
# Make sure to edit PackageScript, which copies your files to their appropriate locations | ||
# Simple extensions do not need to modify past this point. | ||
|
||
project = Extension.HL2Project(builder, projectName + '.ext') | ||
|
||
if os.path.isfile(os.path.join(builder.currentSourcePath, 'sdk', 'smsdk_ext.cpp')): | ||
# Use the copy included in the project | ||
project.sources += [os.path.join('sdk', 'smsdk_ext.cpp')] | ||
else: | ||
# Use the copy included with SM 1.6 and newer | ||
project.sources += [os.path.join(Extension.sm_root, 'public', 'smsdk_ext.cpp')] | ||
|
||
project.sources += sourceFiles | ||
|
||
for sdk_name in Extension.sdks: | ||
sdk = Extension.sdks[sdk_name] | ||
|
||
binary = Extension.HL2Config(project, projectName + '.ext.' + sdk.ext, sdk) | ||
|
||
Extension.extensions = builder.Add(project) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# vim: set ts=8 sts=2 sw=2 tw=99 et ft=python: | ||
import os | ||
|
||
# This is where the files will be output to | ||
# package is the default | ||
builder.SetBuildFolder('package') | ||
|
||
# Add any folders you need to this list | ||
folder_list = [ | ||
'addons/sourcemod/extensions', | ||
'addons/sourcemod/scripting/include', | ||
'addons/sourcemod/gamedata', | ||
# 'addons/sourcemod/configs', | ||
] | ||
|
||
# Create the distribution folder hierarchy. | ||
folder_map = {} | ||
for folder in folder_list: | ||
norm_folder = os.path.normpath(folder) | ||
folder_map[folder] = builder.AddFolder(norm_folder) | ||
|
||
# Do all straight-up file copies from the source tree. | ||
def CopyFiles(src, dest, files): | ||
if not dest: | ||
dest = src | ||
dest_entry = folder_map[dest] | ||
for source_file in files: | ||
source_path = os.path.join(builder.sourcePath, src, source_file) | ||
builder.AddCopy(source_path, dest_entry) | ||
|
||
# Include files | ||
CopyFiles('scripting/include', 'addons/sourcemod/scripting/include', | ||
[ 'survivor_bot_blockers_fix.inc', ] | ||
) | ||
|
||
# GameData files | ||
CopyFiles('gamedata', 'addons/sourcemod/gamedata', | ||
[ 'survivor_bot_blockers_fix.txt', | ||
'survivor_bot_blockers_fix.autoload' | ||
] | ||
) | ||
|
||
# Config Files | ||
#CopyFiles('configs', 'addons/sourcemod/configs', | ||
# [ 'configfile.cfg', | ||
# 'otherconfig.cfg, | ||
# ] | ||
#) | ||
|
||
# Copy binaries. | ||
for cxx_task in Extension.extensions: | ||
builder.AddCopy(cxx_task.binary, folder_map['addons/sourcemod/extensions']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# vim: set sts=2 ts=8 sw=2 tw=99 et: | ||
import sys | ||
from ambuild2 import run | ||
|
||
# Simple extensions do not need to modify this file. | ||
|
||
builder = run.PrepareBuild(sourcePath = sys.path[0]) | ||
|
||
builder.options.add_option('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None, | ||
help='Root search folder for HL2SDKs') | ||
builder.options.add_option('--mms-path', type=str, dest='mms_path', default=None, | ||
help='Path to Metamod:Source') | ||
builder.options.add_option('--sm-path', type=str, dest='sm_path', default=None, | ||
help='Path to SourceMod') | ||
builder.options.add_option('--enable-debug', action='store_const', const='1', dest='debug', | ||
help='Enable debugging symbols') | ||
builder.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt', | ||
help='Enable optimization') | ||
builder.options.add_option('-s', '--sdks', default='all', dest='sdks', | ||
help='Build against specified SDKs; valid args are "all", "present", or ' | ||
'comma-delimited list of engine names (default: %default)') | ||
|
||
builder.Configure() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
|
||
#include <IEngineTrace.h> | ||
|
||
typedef bool (*ShouldHitFunc_t)( IHandleEntity *pHandleEntity, int contentsMask ); | ||
|
||
struct CTraceFilterSimple : public CTraceFilter | ||
{ | ||
const IHandleEntity *m_pPassEnt; | ||
int m_collisionGroup; | ||
ShouldHitFunc_t m_pExtraShouldHitCheckFunction; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
#include "extension.h" | ||
#include "nextbot.h" | ||
#include "nextbotutil.h" | ||
#include <IStaticPropMgr.h> | ||
|
||
CSurvivorBotBlockersFix g_SurvivorBotBlockersFix; | ||
|
||
SMEXT_LINK(&g_SurvivorBotBlockersFix); | ||
|
||
SH_DECL_MANUALHOOK2(MHook_NextBotTraversableTraceFilter_ShouldHitEntity, 0, 0, 0, bool, IHandleEntity *, int); | ||
|
||
int INextBot::m_iVtbl_MySurvivorBotPointer = -1; | ||
|
||
ICallWrapper *INextBot::m_pCallWrap_MySurvivorBotPointer = nullptr; | ||
|
||
IStaticPropMgrServer *staticpropmgr = nullptr; | ||
|
||
static CBaseEntity *EntityFromEntityHandle( IHandleEntity *pHandleEntity ) | ||
{ | ||
#ifdef CLIENT_DLL | ||
IClientUnknown *pUnk = (IClientUnknown*)pHandleEntity; | ||
return pUnk->GetBaseEntity(); | ||
#else | ||
#ifndef _X360 | ||
if ( staticpropmgr->IsStaticProp( pHandleEntity ) ) | ||
return NULL; | ||
#else | ||
if ( !pHandleEntity || pHandleEntity->m_bIsStaticProp ) | ||
return NULL; | ||
#endif | ||
|
||
IServerUnknown *pUnk = (IServerUnknown*)pHandleEntity; | ||
Assert( !pUnk || pUnk->GetBaseEntity() ); | ||
return pUnk->GetBaseEntity(); | ||
#endif | ||
} | ||
|
||
bool CSurvivorBotBlockersFix::SDK_OnLoad(char *error, size_t maxlen, bool late) | ||
{ | ||
IGameConfig *pGameConfig; | ||
|
||
if (!gameconfs->LoadGameConfigFile(SMEXT_CONF_GAMEDATA_FILE, &pGameConfig, error, sizeof(error))) | ||
{ | ||
ke::SafeStrcpy(error, maxlen, "Unable to load gamedata file \"" SMEXT_CONF_GAMEDATA_FILE ".txt\""); | ||
|
||
return false; | ||
} | ||
|
||
if (!pGameConfig->GetOffset("INextBot::MySurvivorBotPointer", &INextBot::m_iVtbl_MySurvivorBotPointer)) | ||
{ | ||
ke::SafeStrcpy(error, maxlen, "Unable to find gamedata offset entry for \"INextBot::MySurvivorBotPointer\""); | ||
|
||
gameconfs->CloseGameConfigFile(pGameConfig); | ||
|
||
return false; | ||
} | ||
|
||
if (!pGameConfig->GetAddress("NextBotTraversableTraceFilter vtable", &m_pfn_NextBotTraversableTraceFilter_vtable)) | ||
{ | ||
ke::SafeStrcpy(error, maxlen, "Unable to find gamedata address entry for \"NextBotTraversableTraceFilter vtable\""); | ||
|
||
gameconfs->CloseGameConfigFile(pGameConfig); | ||
|
||
return false; | ||
} | ||
|
||
if (m_pfn_NextBotTraversableTraceFilter_vtable == nullptr) | ||
{ | ||
ke::SafeStrcpy(error, maxlen, "Unable to find signature in binary for gamedata entry \"NextBotTraversableTraceFilter vtable\""); | ||
|
||
gameconfs->CloseGameConfigFile(pGameConfig); | ||
|
||
return false; | ||
} | ||
|
||
gameconfs->CloseGameConfigFile(pGameConfig); | ||
|
||
m_nSHookID = SH_ADD_MANUALDVPHOOK(MHook_NextBotTraversableTraceFilter_ShouldHitEntity, m_pfn_NextBotTraversableTraceFilter_vtable, | ||
SH_MEMBER(this, &CSurvivorBotBlockersFix::Hook_NextBotTraversableTraceFilter_ShouldHitEntity), false); | ||
|
||
sharesys->AddDependency(myself, "bintools.ext", true, true); | ||
|
||
return true; | ||
} | ||
|
||
void CSurvivorBotBlockersFix::SDK_OnAllLoaded() | ||
{ | ||
SM_GET_LATE_IFACE(BINTOOLS, m_pBinTools); | ||
|
||
#if SMINTERFACE_BINTOOLS_VERSION == 4 | ||
PassInfo piReturn(PassType_Basic, PASSFLAG_BYVAL, sizeof(void *), nullptr, 0); | ||
#else | ||
PassInfo piReturn; | ||
piReturn.type = PassType_Basic; | ||
piReturn.flags = PASSFLAG_BYVAL; | ||
piReturn.size = sizeof(void *); | ||
#endif | ||
|
||
INextBot::m_pCallWrap_MySurvivorBotPointer = m_pBinTools->CreateVCall(INextBot::m_iVtbl_MySurvivorBotPointer, 0, 0, &piReturn, nullptr, 0); | ||
|
||
if (INextBot::m_pCallWrap_MySurvivorBotPointer == nullptr) | ||
{ | ||
smutils->LogError(myself, "Unable to create vcall wrapper for \"INextBot::MySurvivorBotPointer\""); | ||
} | ||
} | ||
|
||
void CSurvivorBotBlockersFix::SDK_OnUnload() | ||
{ | ||
SH_REMOVE_HOOK_ID(m_nSHookID); | ||
} | ||
|
||
bool CSurvivorBotBlockersFix::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late) | ||
{ | ||
GET_V_IFACE_CURRENT(GetEngineFactory, staticpropmgr, IStaticPropMgrServer, INTERFACEVERSION_STATICPROPMGR_SERVER); | ||
|
||
return true; | ||
} | ||
|
||
bool CSurvivorBotBlockersFix::Hook_NextBotTraversableTraceFilter_ShouldHitEntity(IHandleEntity *pServerEntity, int fContentsMask) | ||
{ | ||
INextBot *pNextBot = META_IFACEPTR(NextBotTraversableTraceFilter)->m_bot; | ||
|
||
if (pNextBot->MySurvivorBotPointer()) | ||
{ | ||
CBaseEntity *pEntity = EntityFromEntityHandle(pServerEntity); | ||
|
||
if (pEntity && (fContentsMask & CONTENTS_TEAM1)) | ||
{ | ||
const char *pszClassname = gamehelpers->GetEntityClassname(pEntity); | ||
|
||
if (!V_strcmp(pszClassname, "env_physics_blocker")) | ||
{ | ||
RETURN_META_VALUE(MRES_SUPERCEDE, true); | ||
} | ||
|
||
if (!V_strcmp(pszClassname, "env_player_blocker")) | ||
{ | ||
RETURN_META_VALUE(MRES_SUPERCEDE, true); | ||
} | ||
} | ||
} | ||
|
||
RETURN_META_VALUE(MRES_IGNORED, false); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#pragma once | ||
|
||
#include "smsdk_ext.h" | ||
#include <IBinTools.h> | ||
|
||
class IHandleEntity; | ||
|
||
class CSurvivorBotBlockersFix : public SDKExtension | ||
{ | ||
public: | ||
/** | ||
* @brief This is called after the initial loading sequence has been processed. | ||
* | ||
* @param error Error message buffer. | ||
* @param maxlen Size of error message buffer. | ||
* @param late Whether or not the module was loaded after map load. | ||
* @return True to succeed loading, false to fail. | ||
*/ | ||
virtual bool SDK_OnLoad(char *error, size_t maxlen, bool late) override; | ||
|
||
/** | ||
* @brief This is called once all known extensions have been loaded. | ||
* Note: It is is a good idea to add natives here, if any are provided. | ||
*/ | ||
virtual void SDK_OnAllLoaded() override; | ||
|
||
/** | ||
* @brief This is called right before the extension is unloaded. | ||
*/ | ||
virtual void SDK_OnUnload() override; | ||
#ifdef SMEXT_CONF_METAMOD | ||
/** | ||
* @brief Called when Metamod is attached, before the extension version is called. | ||
* | ||
* @param error Error buffer. | ||
* @param maxlen Maximum size of error buffer. | ||
* @param late Whether or not Metamod considers this a late load. | ||
* @return True to succeed, false to fail. | ||
*/ | ||
virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late) override; | ||
#endif | ||
private: | ||
void *m_pfn_NextBotTraversableTraceFilter_vtable; | ||
|
||
int m_nSHookID; | ||
|
||
bool Hook_NextBotTraversableTraceFilter_ShouldHitEntity(IHandleEntity *pServerEntity, int fContentsMask); | ||
|
||
IBinTools *m_pBinTools; | ||
}; |
Empty file.
Oops, something went wrong.