Merge https://git.unloze.com/UNLOZE/sm-ext-CSSFixes into no-force-ct
This commit is contained in:
commit
81f488ec25
@ -76,6 +76,38 @@ bool UTIL_ContainsDataTable(SendTable *pTable, const char *name)
|
||||
return false;
|
||||
}
|
||||
|
||||
void UTIL_StringToVector( float *pVector, const char *pString )
|
||||
{
|
||||
char *pstr, *pfront, tempString[128];
|
||||
int j;
|
||||
|
||||
Q_strncpy( tempString, pString, sizeof(tempString) );
|
||||
pstr = pfront = tempString;
|
||||
|
||||
for ( j = 0; j < 3; j++ ) // lifted from pr_edict.c
|
||||
{
|
||||
pVector[j] = atof( pfront );
|
||||
|
||||
// skip any leading whitespace
|
||||
while ( *pstr && *pstr <= ' ' )
|
||||
pstr++;
|
||||
|
||||
// skip to next whitespace
|
||||
while ( *pstr && *pstr > ' ' )
|
||||
pstr++;
|
||||
|
||||
if (!*pstr)
|
||||
break;
|
||||
|
||||
pstr++;
|
||||
pfront = pstr;
|
||||
}
|
||||
for ( j++; j < 3; j++ )
|
||||
{
|
||||
pVector[j] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
class CTraceFilterSimple : public CTraceFilter
|
||||
{
|
||||
public:
|
||||
@ -223,6 +255,8 @@ CDetour *g_pDetour_SwingOrStab = NULL;
|
||||
int g_SH_SkipTwoEntitiesShouldHitEntity = 0;
|
||||
int g_SH_SimpleShouldHitEntity = 0;
|
||||
|
||||
int g_iMaxPlayers = 0;
|
||||
|
||||
uintptr_t g_CTraceFilterNoNPCsOrPlayer = 0;
|
||||
CTraceFilterSkipTwoEntities *g_CTraceFilterSkipTwoEntities = NULL;
|
||||
CTraceFilterSimple *g_CTraceFilterSimple = NULL;
|
||||
@ -274,7 +308,7 @@ DETOUR_DECL_MEMBER2(DETOUR_PassesFilterImpl, bool, CBaseEntity*, pCaller, CBaseE
|
||||
{
|
||||
datamap_t *pDataMap = gamehelpers->GetDataMap(pEntity);
|
||||
sm_datatable_info_t info;
|
||||
|
||||
|
||||
// Both are CBaseEntity members, so the offsets will always be the same across different entity classes
|
||||
gamehelpers->FindDataMapInfo(pDataMap, "m_ResponseContexts", &info);
|
||||
m_ResponseContexts_offset = info.actual_offset;
|
||||
@ -301,7 +335,7 @@ DETOUR_DECL_MEMBER2(DETOUR_PassesFilterImpl, bool, CBaseEntity*, pCaller, CBaseE
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// CBaseFilter::PassesFilterImpl just returns true so no need to call it
|
||||
return true;
|
||||
}
|
||||
@ -318,10 +352,13 @@ DETOUR_DECL_STATIC2(DETOUR_CreateEntityByName, CBaseEntity*, const char*, classN
|
||||
|
||||
DETOUR_DECL_MEMBER2(DETOUR_KeyValue, bool, const char *, szKeyName, const char *, szValue)
|
||||
{
|
||||
CBaseEntity *pEntity = (CBaseEntity *)this;
|
||||
|
||||
// Fix crash bug in engine
|
||||
if(strcasecmp(szKeyName, "angle") == 0)
|
||||
{
|
||||
szKeyName = "angles";
|
||||
|
||||
|
||||
/*
|
||||
else if(strcasecmp(szKeyName, "classname") == 0 &&
|
||||
strcasecmp(szValue, "info_player_terrorist") == 0)
|
||||
@ -331,7 +368,6 @@ DETOUR_DECL_MEMBER2(DETOUR_KeyValue, bool, const char *, szKeyName, const char *
|
||||
}
|
||||
else if(strcasecmp(szKeyName, "teamnum") == 0 || strcasecmp(szKeyName, "teamnum") == 0 )
|
||||
{
|
||||
CBaseEntity *pEntity = (CBaseEntity *)this;
|
||||
const char *pClassname = gamehelpers->GetEntityClassname(pEntity);
|
||||
|
||||
// All buyzones should be CT buyzones
|
||||
@ -339,6 +375,25 @@ DETOUR_DECL_MEMBER2(DETOUR_KeyValue, bool, const char *, szKeyName, const char *
|
||||
szValue = "3";
|
||||
}
|
||||
*/
|
||||
else if(strcasecmp(szKeyName, "absvelocity") == 0)
|
||||
{
|
||||
static int m_AbsVelocity_offset = 0;
|
||||
|
||||
if (!m_AbsVelocity_offset)
|
||||
{
|
||||
datamap_t *pDataMap = gamehelpers->GetDataMap(pEntity);
|
||||
sm_datatable_info_t info;
|
||||
|
||||
gamehelpers->FindDataMapInfo(pDataMap, "m_vecAbsVelocity", &info);
|
||||
m_AbsVelocity_offset = info.actual_offset;
|
||||
}
|
||||
|
||||
float tmp[3];
|
||||
UTIL_StringToVector(tmp, szValue);
|
||||
|
||||
Vector *vecAbsVelocity = (Vector*)((uint8_t*)pEntity + m_AbsVelocity_offset);
|
||||
vecAbsVelocity->Init(tmp[0], tmp[1], tmp[2]);
|
||||
}
|
||||
|
||||
return DETOUR_MEMBER_CALL(DETOUR_KeyValue)(szKeyName, szValue);
|
||||
}
|
||||
@ -382,7 +437,7 @@ bool ShouldHitEntity(IHandleEntity *pHandleEntity, int contentsMask)
|
||||
|
||||
int iTeam = 0;
|
||||
|
||||
if(index > SM_MAXPLAYERS && g_pPhysboxToClientMap && index < 2048)
|
||||
if(index > g_iMaxPlayers && g_pPhysboxToClientMap && index < 2048)
|
||||
{
|
||||
index = g_pPhysboxToClientMap[index];
|
||||
}
|
||||
@ -391,7 +446,7 @@ bool ShouldHitEntity(IHandleEntity *pHandleEntity, int contentsMask)
|
||||
{
|
||||
iTeam = -index;
|
||||
}
|
||||
else if(index < 1 || index > SM_MAXPLAYERS)
|
||||
else if(index < 1 || index > g_iMaxPlayers)
|
||||
{
|
||||
RETURN_META_VALUE(MRES_IGNORED, true);
|
||||
}
|
||||
@ -503,6 +558,8 @@ bool CSSFixes::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||
{
|
||||
srand((unsigned int)time(NULL));
|
||||
|
||||
g_iMaxPlayers = playerhelpers->GetMaxClients();
|
||||
|
||||
char conf_error[255] = "";
|
||||
if(!gameconfs->LoadGameConfigFile("CSSFixes", &g_pGameConf, conf_error, sizeof(conf_error)))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user