Merge branch 'master' into k/build_static_libs

This commit is contained in:
Nicholas Hastings 2025-11-08 11:46:34 -05:00
commit df52ac7b43
12 changed files with 216 additions and 183 deletions

View File

@ -31,9 +31,9 @@ jobs:
# Setup Python for AMBuild
- uses: actions/setup-python@v6
name: Setup Python 3.8
name: Setup Python 3.12
with:
python-version: 3.8
python-version: 3.12
- name: Install AMBuild
run: |
python -m pip install --upgrade pip setuptools wheel
@ -67,7 +67,7 @@ jobs:
echo "SM_VERSION=$(cat ../product.version)" >> $GITHUB_ENV
- name: Archive tooling
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
with:
name: sourcemod-tooling-${{ env.SM_VERSION }}-${{ matrix.os_short }}
path: build/package

View File

@ -58,6 +58,7 @@ public:
virtual bool IsDirectory(const char *pFileName, const char *pathID = 0) = 0;
virtual void CreateDirHierarchy(const char *path, const char *pathID = 0) = 0;
virtual int GetSearchPath(const char* pathID, bool bGetPackFiles, char* pPath, int nMaxLen) = 0;
virtual const char * GetGameBinArchSubdirectory() = 0;
};
} // namespace SourceMod

View File

@ -1094,13 +1094,18 @@ void GameBinPathManager::Init()
std::istringstream iss(search_path);
for (std::string path; std::getline(iss, path, ';');)
{
if (path.length() > 0
&& path.find(addons_folder) == std::string::npos
&& m_lookup.find(path) == m_lookup.cend()
)
if (path.length() > 0)
{
m_lookup.insert(path);
m_ordered.push_back(path);
const char* arch_subdir = bridge->filesystem->GetGameBinArchSubdirectory();
std::string full_path = path + arch_subdir;
if (full_path.find(addons_folder) == std::string::npos
&& m_lookup.find(full_path) == m_lookup.cend()
)
{
m_lookup.insert(full_path);
m_ordered.push_back(full_path);
}
}
}

View File

@ -188,6 +188,15 @@ bool AddString(char **buf_p, size_t &maxlen, const char *string, int width, int
width -= size;
if (!(flags & LADJUST))
{
while ((width-- > 0) && maxlen)
{
*buf++ = ' ';
maxlen--;
}
}
if (g_FormatEscapeDatabase && (flags & NOESCAPE) == 0)
{
char *tempBuffer = NULL;
@ -226,10 +235,13 @@ bool AddString(char **buf_p, size_t &maxlen, const char *string, int width, int
}
}
while ((width-- > 0) && maxlen)
if (flags & LADJUST)
{
*buf++ = ' ';
maxlen--;
while ((width-- > 0) && maxlen)
{
*buf++ = ' ';
maxlen--;
}
}
*buf_p = buf;
@ -254,6 +266,12 @@ void AddFloat(char **buf_p, size_t &maxlen, double fval, int width, int prec, in
return;
}
if (ke::IsInfinite(static_cast<float>(fval)))
{
AddString(buf_p, maxlen, "Inf", width, prec, flags | NOESCAPE);
return;
}
// default precision
if (prec < 0)
{
@ -485,13 +503,15 @@ void AddInt(char **buf_p, size_t &maxlen, int val, int width, int flags)
unsignedVal /= 10;
} while (unsignedVal);
if (signedVal < 0)
{
text[digits++] = '-';
}
buf = *buf_p;
// minus sign BEFORE left padding if padding with zeros
if (signedVal < 0 && maxlen && (flags & ZEROPAD))
{
*buf++ = '-';
maxlen--;
}
if (!(flags & LADJUST))
{
while ((digits < width) && maxlen)
@ -502,6 +522,13 @@ void AddInt(char **buf_p, size_t &maxlen, int val, int width, int flags)
}
}
// minus sign AFTER left padding if padding with spaces
if (signedVal < 0 && maxlen && !(flags & ZEROPAD))
{
*buf++ = '-';
maxlen--;
}
while (digits-- && maxlen)
{
*buf++ = text[digits];

View File

@ -194,6 +194,25 @@ public:
{
return filesystem->GetSearchPath(pathID, bGetPackFiles, pPath, nMaxLen);
}
const char* GetGameBinArchSubdirectory() override
{
#if defined( KE_ARCH_X64 ) && SOURCE_ENGINE >= SE_BLADE
#if defined( PLATFORM_WINDOWS )
#if SOURCE_ENGINE == SE_MCV
return "win64" PLATFORM_SEP;
#else
return "x64" PLATFORM_SEP;
#endif // SOURCE_ENGINE == SE_MCV
#elif defined( PLATFORM_LINUX )
return "linux64" PLATFORM_SEP;
#else
#error "Unsupported platform"
#endif // PLATFORM
#else
// Already included in the GameBin path(s), if required
return "";
#endif // defined( KE_ARCH_X64 ) && SOURCE_ENGINE >= SE_BLADE
}
} fs_wrapper;
class VPlayerInfo_Logic : public IPlayerInfoBridge

View File

@ -532,6 +532,7 @@ CDynamicHooksSourcePawn::CDynamicHooksSourcePawn(HookSetup *setup, CHook *pDetou
this->hookType = setup->hookType;
this->m_pDetour = pDetour;
this->callConv = setup->callConv;
this->thisFuncCallConv = setup->callConv;
}
HookReturnStruct *CDynamicHooksSourcePawn::GetReturnStruct()

View File

@ -42,6 +42,8 @@ enum SDKFuncConfSource
SDKConf_Address
};
using ParamVector = SourceHook::CVector<ParamInfo>;
bool GetHandleIfValidOrError(HandleType_t type, void **object, IPluginContext *pContext, cell_t param)
{
if(param == BAD_HANDLE)
@ -81,6 +83,56 @@ bool GetCallbackArgHandleIfValidOrError(HandleType_t type, HandleType_t otherTyp
return true;
}
bool GetObjectAddrOrThis(IPluginContext *pContext, const cell_t *params, void *&retAddr)
{
HookParamsStruct *paramStruct = NULL;
retAddr = NULL;
if(!GetCallbackArgHandleIfValidOrError(g_HookParamsHandle, g_HookReturnHandle, (void **)&paramStruct, pContext, params[1]))
{
return false;
}
if(params[2] != 0)
{
const ParamVector &paramsVec = paramStruct->dg->params;
if(params[2] < 0 || params[2] > static_cast<int>(paramsVec.size()))
{
return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramsVec.size());
}
int index = params[2] - 1;
const ParamInfo &param = paramsVec.at(index);
if(param.type != HookParamType_ObjectPtr && param.type != HookParamType_Object)
{
return pContext->ThrowNativeError("Invalid object value type %i", param.type);
}
size_t offset = GetParamOffset(paramStruct, index);
retAddr = GetObjectAddr(param.type, param.flags, paramStruct->orgParams, offset);
return true;
}
const DHooksInfo* dgInfo = paramStruct->dg;
if(dgInfo->thisFuncCallConv != CallConv_THISCALL)
{
return pContext->ThrowNativeError("Parameter 'this' is only available in member functions");
}
if(dgInfo->thisType != ThisPointer_Address
&& dgInfo->thisType != ThisPointer_CBaseEntity
&& dgInfo->hookType != HookType_GameRules)
{
return pContext->ThrowNativeError("Parameter 'this' is not specified as an address, it is not available");
}
retAddr = g_SHPtr->GetIfacePtr();
return true;
}
IPluginFunction *GetCallback(IPluginContext *pContext, HookSetup * setup, const cell_t *params, cell_t callback_index)
{
IPluginFunction *ret = NULL;
@ -1089,28 +1141,12 @@ cell_t Native_RemoveEntityListener(IPluginContext *pContext, const cell_t *param
//native any:DHookGetParamObjectPtrVar(Handle:hParams, num, offset, ObjectValueType:type);
cell_t Native_GetParamObjectPtrVar(IPluginContext *pContext, const cell_t *params)
{
HookParamsStruct *paramStruct;
if(!GetCallbackArgHandleIfValidOrError(g_HookParamsHandle, g_HookReturnHandle, (void **)&paramStruct, pContext, params[1]))
void *addr = NULL;
if(!GetObjectAddrOrThis(pContext, params, addr))
{
return 0;
}
if(params[2] <= 0 || params[2] > (int)paramStruct->dg->params.size())
{
return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.size());
}
int index = params[2] - 1;
if(paramStruct->dg->params.at(index).type != HookParamType_ObjectPtr && paramStruct->dg->params.at(index).type != HookParamType_Object)
{
return pContext->ThrowNativeError("Invalid object value type %i", paramStruct->dg->params.at(index).type);
}
size_t offset = GetParamOffset(paramStruct, index);
void *addr = GetObjectAddr(paramStruct->dg->params.at(index).type, paramStruct->dg->params.at(index).flags, paramStruct->orgParams, offset);
switch((ObjectValueType)params[4])
{
case ObjectValueType_Int:
@ -1160,28 +1196,12 @@ cell_t Native_GetParamObjectPtrVar(IPluginContext *pContext, const cell_t *param
//native DHookSetParamObjectPtrVar(Handle:hParams, num, offset, ObjectValueType:type, value)
cell_t Native_SetParamObjectPtrVar(IPluginContext *pContext, const cell_t *params)
{
HookParamsStruct *paramStruct;
if(!GetCallbackArgHandleIfValidOrError(g_HookParamsHandle, g_HookReturnHandle, (void **)&paramStruct, pContext, params[1]))
void *addr = NULL;
if(!GetObjectAddrOrThis(pContext, params, addr))
{
return 0;
}
if(params[2] <= 0 || params[2] > (int)paramStruct->dg->params.size())
{
return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.size());
}
int index = params[2] - 1;
if(paramStruct->dg->params.at(index).type != HookParamType_ObjectPtr && paramStruct->dg->params.at(index).type != HookParamType_Object)
{
return pContext->ThrowNativeError("Invalid object value type %i", paramStruct->dg->params.at(index).type);
}
size_t offset = GetParamOffset(paramStruct, index);
void *addr = GetObjectAddr(paramStruct->dg->params.at(index).type, paramStruct->dg->params.at(index).flags, paramStruct->orgParams, offset);
switch((ObjectValueType)params[4])
{
case ObjectValueType_Int:
@ -1245,28 +1265,12 @@ cell_t Native_SetParamObjectPtrVar(IPluginContext *pContext, const cell_t *param
//native DHookGetParamObjectPtrVarVector(Handle:hParams, num, offset, ObjectValueType:type, Float:buffer[3]);
cell_t Native_GetParamObjectPtrVarVector(IPluginContext *pContext, const cell_t *params)
{
HookParamsStruct *paramStruct;
if(!GetCallbackArgHandleIfValidOrError(g_HookParamsHandle, g_HookReturnHandle, (void **)&paramStruct, pContext, params[1]))
void *addr = NULL;
if(!GetObjectAddrOrThis(pContext, params, addr))
{
return 0;
}
if(params[2] <= 0 || params[2] > (int)paramStruct->dg->params.size())
{
return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.size());
}
int index = params[2] - 1;
if(paramStruct->dg->params.at(index).type != HookParamType_ObjectPtr && paramStruct->dg->params.at(index).type != HookParamType_Object)
{
return pContext->ThrowNativeError("Invalid object value type %i", paramStruct->dg->params.at(index).type);
}
size_t offset = GetParamOffset(paramStruct, index);
void *addr = GetObjectAddr(paramStruct->dg->params.at(index).type, paramStruct->dg->params.at(index).flags, paramStruct->orgParams, offset);
cell_t *buffer;
pContext->LocalToPhysAddr(params[5], &buffer);
@ -1299,28 +1303,12 @@ cell_t Native_GetParamObjectPtrVarVector(IPluginContext *pContext, const cell_t
//native DHookSetParamObjectPtrVarVector(Handle:hParams, num, offset, ObjectValueType:type, Float:value[3]);
cell_t Native_SetParamObjectPtrVarVector(IPluginContext *pContext, const cell_t *params)
{
HookParamsStruct *paramStruct;
if(!GetCallbackArgHandleIfValidOrError(g_HookParamsHandle, g_HookReturnHandle, (void **)&paramStruct, pContext, params[1]))
void *addr = NULL;
if(!GetObjectAddrOrThis(pContext, params, addr))
{
return 0;
}
if(params[2] <= 0 || params[2] > (int)paramStruct->dg->params.size())
{
return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.size());
}
int index = params[2] - 1;
if(paramStruct->dg->params.at(index).type != HookParamType_ObjectPtr && paramStruct->dg->params.at(index).type != HookParamType_Object)
{
return pContext->ThrowNativeError("Invalid object value type %i", paramStruct->dg->params.at(index).type);
}
size_t offset = GetParamOffset(paramStruct, index);
void *addr = GetObjectAddr(paramStruct->dg->params.at(index).type, paramStruct->dg->params.at(index).flags, paramStruct->orgParams, offset);
cell_t *buffer;
pContext->LocalToPhysAddr(params[5], &buffer);
@ -1352,28 +1340,12 @@ cell_t Native_SetParamObjectPtrVarVector(IPluginContext *pContext, const cell_t
//native DHookGetParamObjectPtrString(Handle:hParams, num, offset, ObjectValueType:type, String:buffer[], size)
cell_t Native_GetParamObjectPtrString(IPluginContext *pContext, const cell_t *params)
{
HookParamsStruct *paramStruct;
if(!GetCallbackArgHandleIfValidOrError(g_HookParamsHandle, g_HookReturnHandle, (void **)&paramStruct, pContext, params[1]))
void *addr = NULL;
if (!GetObjectAddrOrThis(pContext, params, addr))
{
return 0;
}
if(params[2] <= 0 || params[2] > (int)paramStruct->dg->params.size())
{
return pContext->ThrowNativeError("Invalid param number %i max params is %i", params[2], paramStruct->dg->params.size());
}
int index = params[2] - 1;
if(paramStruct->dg->params.at(index).type != HookParamType_ObjectPtr && paramStruct->dg->params.at(index).type != HookParamType_Object)
{
return pContext->ThrowNativeError("Invalid object value type %i", paramStruct->dg->params.at(index).type);
}
size_t offset = GetParamOffset(paramStruct, index);
void *addr = GetObjectAddr(paramStruct->dg->params.at(index).type, paramStruct->dg->params.at(index).flags, paramStruct->orgParams, offset);
switch((ObjectValueType)params[4])
{
case ObjectValueType_CharPtr:

View File

@ -162,6 +162,7 @@ public:
int entity;
ThisPointerType thisType;
HookType hookType;
CallingConvention thisFuncCallConv;
};
class DHooksCallback : public SourceHook::ISHDelegate, public DHooksInfo

View File

@ -4,26 +4,32 @@
{
"Offsets"
{
"CanBeAutobalanced"
{
"windows" "465"
"linux" "466"
}
"GroundEntChanged"
{
"windows" "188"
"linux" "190"
"windows" "178"
"linux" "180"
}
"OnTakeDamage_Alive"
{
"windows" "287"
"linux" "288"
"windows" "283"
"linux" "284"
}
"GetMaxHealth"
{
"windows" "126"
"linux" "127"
"windows" "118"
"linux" "119"
}
"Blocked"
{
"windows" "109"
"linux" "110"
"windows" "101"
"linux" "102"
}
/* CBaseCombatWeapon::Reload */
"Reload"
{
"windows" "287"
@ -31,18 +37,19 @@
}
"EndTouch"
{
"windows" "107"
"linux" "108"
"windows" "99"
"linux" "100"
}
/* CBaseEntity::FireBullets(FireBulletsInfo_t const&) */
"FireBullets"
{
"windows" "121"
"linux" "121"
"windows" "113"
"linux" "113"
}
"OnTakeDamage"
{
"windows" "69"
"linux" "70"
"windows" "61"
"linux" "62"
}
"PreThink"
{
@ -56,8 +63,8 @@
}
"SetTransmit"
{
"windows" "28"
"linux" "29"
"windows" "20"
"linux" "21"
}
"ShouldCollide"
{
@ -66,64 +73,64 @@
}
"Spawn"
{
"windows" "30"
"linux" "31"
"windows" "22"
"linux" "23"
}
"StartTouch"
{
"windows" "105"
"linux" "106"
"windows" "97"
"linux" "98"
}
"Think"
{
"windows" "57"
"linux" "58"
"windows" "49"
"linux" "50"
}
"Touch"
{
"windows" "106"
"linux" "107"
"windows" "98"
"linux" "99"
}
"TraceAttack"
{
"windows" "67"
"linux" "68"
"windows" "59"
"linux" "60"
}
"Use"
{
"windows" "104"
"linux" "105"
"windows" "96"
"linux" "97"
}
"VPhysicsUpdate"
{
"windows" "168"
"linux" "169"
"windows" "158"
"linux" "159"
}
"Weapon_CanSwitchTo"
{
"windows" "278"
"linux" "279"
"windows" "277"
"linux" "278"
}
"Weapon_CanUse"
{
"windows" "271"
"linux" "272"
}
"Weapon_Drop"
{
"windows" "274"
"linux" "275"
}
"Weapon_Equip"
{
"windows" "272"
"linux" "273"
}
"Weapon_Drop"
"Weapon_Switch"
{
"windows" "275"
"linux" "276"
}
"Weapon_Equip"
{
"windows" "273"
"linux" "274"
}
"Weapon_Switch"
{
"windows" "276"
"linux" "277"
}
}
}
}

View File

@ -23,13 +23,13 @@
}
"RemovePlayerItem"
{
"windows" "285"
"linux" "286"
"windows" "281"
"linux" "282"
}
"Weapon_GetSlot"
{
"windows" "280"
"linux" "281"
"windows" "279"
"linux" "280"
}
"Ignite"
{
@ -43,8 +43,8 @@
}
"Teleport"
{
"windows" "115"
"linux" "116"
"windows" "107"
"linux" "108"
}
"CommitSuicide"
{
@ -53,33 +53,33 @@
}
"GetVelocity"
{
"windows" "151"
"linux" "152"
"windows" "141"
"linux" "142"
}
"EyeAngles"
{
"windows" "142"
"linux" "143"
"windows" "132"
"linux" "133"
}
"AcceptInput"
{
"windows" "44"
"linux" "45"
"windows" "36"
"linux" "37"
}
"SetEntityModel"
{
"windows" "32"
"linux" "33"
"windows" "24"
"linux" "25"
}
"WeaponEquip"
{
"windows" "273"
"linux" "274"
"windows" "272"
"linux" "273"
}
"Activate"
{
"windows" "41"
"linux" "42"
"windows" "33"
"linux" "34"
}
"PlayerRunCmd"
{
@ -93,13 +93,13 @@
}
"SetOwnerEntity"
{
"windows" "25"
"linux" "26"
"windows" "17"
"linux" "18"
}
"GiveAmmo"
{
"windows" "264"
"linux" "265"
"windows" "263"
"linux" "264"
}
}
"Signatures"

@ -1 +1 @@
Subproject commit 41cb9169cb613c8455d0c8958e675ed88bd02c5b
Subproject commit c018a994478d6c31f70ded7adec7aa9e2c40bb1a

View File

@ -310,7 +310,7 @@ methodmap DHookParam < Handle
// Gets an object's variable value.
//
// @param num Parameter number to get, starting at 1.
// @param num Parameter number to get, 0 for param "this", other parameters start from 1
// @param offset Byte offset within the object to the var to get.
// @param type Type of var it is.
//
@ -320,7 +320,7 @@ methodmap DHookParam < Handle
// Gets an object's vector variable value.
//
// @param num Parameter number to get, starting at 1.
// @param num Parameter number to get, 0 for param "this", other parameters start from 1.
// @param offset Byte offset within the object to the var to get.
// @param type Type of var it is.
// @param vec Buffer to store the result vector.
@ -330,7 +330,7 @@ methodmap DHookParam < Handle
// Gets an object's string variable value.
//
// @param num Parameter number to get, starting at 1.
// @param num Parameter number to get, 0 for param "this", other parameters start from 1.
// @param offset Byte offset within the object to the var to get.
// @param type Type of var it is.
// @param buffer Buffer to store the result string.
@ -344,7 +344,7 @@ methodmap DHookParam < Handle
// The changes are only applied when MRES_ChangedHandled or MRES_ChangedOverride
// is returned in the callback.
//
// @param num Parameter number to set, starting at 1.
// @param num Parameter number to set, 0 for param "this", other parameters start from 1.
// @param offset Byte offset within the object to the var to set.
// @param type Type of var it is.
// @param value The value to set the var to.
@ -357,7 +357,7 @@ methodmap DHookParam < Handle
// The changes are only applied when MRES_ChangedHandled or MRES_ChangedOverride
// is returned in the callback.
//
// @param num Parameter number to set, starting at 1.
// @param num Parameter number to set, 0 for param "this", other parameters start from 1.
// @param offset Byte offset within the object to the var to set.
// @param type Type of var it is.
// @param vec The value to set the vector var to.
@ -928,7 +928,7 @@ native void DHookSetReturnString(Handle hReturn, char[] value);
* Gets an objects variable value
*
* @param hParams Handle to params structure
* @param num Param number to get.
* @param num Param number to get, 0 for param "this".
* @param offset Offset within the object to the var to get.
* @param type Type of var it is
*
@ -941,7 +941,7 @@ native any DHookGetParamObjectPtrVar(Handle hParams, int num, int offset, Object
* Sets an objects variable value
*
* @param hParams Handle to params structure
* @param num Param number to set.
* @param num Param number to set, 0 for param "this".
* @param offset Offset within the object to the var to set.
* @param type Type of var it is
* @param value The value to set the var to.
@ -954,7 +954,7 @@ native void DHookSetParamObjectPtrVar(Handle hParams, int num, int offset, Objec
* Gets an objects vector variable value
*
* @param hParams Handle to params structure
* @param num Param number to get.
* @param num Param number to get, 0 for param "this".
* @param offset Offset within the object to the var to get.
* @param type Type of var it is
* @param buffer Buffer to store the result vector
@ -967,7 +967,7 @@ native void DHookGetParamObjectPtrVarVector(Handle hParams, int num, int offset,
* Sets an objects vector variable value
*
* @param hParams Handle to params structure
* @param num Param number to set.
* @param num Param number to set, 0 for param "this".
* @param offset Offset within the object to the var to set.
* @param type Type of var it is
* @param value The value to set the vector var to.
@ -980,7 +980,7 @@ native void DHookSetParamObjectPtrVarVector(Handle hParams, int num, int offset,
* Gets an objects string variable value
*
* @param hParams Handle to params structure
* @param num Param number to get.
* @param num Param number to get, 0 for param "this".
* @param offset Offset within the object to the var to get.
* @param type Type of var it is
* @param buffer Buffer to store the result vector