just updating plugins to 64bit support
This commit is contained in:
@@ -12,41 +12,29 @@ public Plugin myinfo =
|
||||
name = "FixVPhysicsCrush",
|
||||
author = "BotoX",
|
||||
description = "",
|
||||
version = "0.0",
|
||||
version = "0.1",
|
||||
url = ""
|
||||
};
|
||||
|
||||
Handle g_hAcceptInput;
|
||||
Handle g_hSetGameFlags;
|
||||
Handle g_hGetGameFlags;
|
||||
int g_hPhysicsObject;
|
||||
|
||||
int g_iPhysicsObjectOffset;
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
Handle hGameData = LoadGameConfigFile("sdktools.games");
|
||||
if(!hGameData)
|
||||
SetFailState("Couldn't load sdktools gamedata.");
|
||||
|
||||
// CBaseEntity::AcceptInput( const char *szInputName, CBaseEntity *pActivator, CBaseEntity *pCaller, variant_t Value, int outputID )
|
||||
int Offset = GameConfGetOffset(hGameData, "AcceptInput");
|
||||
if(Offset == -1)
|
||||
SetFailState("Failed to find AcceptInput offset.");
|
||||
|
||||
g_hAcceptInput = DHookCreate(Offset, HookType_Entity, ReturnType_Bool, ThisPointer_CBaseEntity, OnAcceptInput);
|
||||
if(g_hAcceptInput == INVALID_HANDLE)
|
||||
SetFailState("Failed to DHook AcceptInput.");
|
||||
|
||||
DHookAddParam(g_hAcceptInput, HookParamType_CharPtr);
|
||||
DHookAddParam(g_hAcceptInput, HookParamType_CBaseEntity);
|
||||
DHookAddParam(g_hAcceptInput, HookParamType_CBaseEntity);
|
||||
DHookAddParam(g_hAcceptInput, HookParamType_Object, 20, DHookPass_ByVal|DHookPass_ODTOR|DHookPass_OCTOR|DHookPass_OASSIGNOP); //varaint_t is a union of 12 (float[3]) plus two int type params 12 + 8 = 20
|
||||
DHookAddParam(g_hAcceptInput, HookParamType_Int);
|
||||
|
||||
hGameData = LoadGameConfigFile("FixVPhysicsCrush.games");
|
||||
Handle hGameData = LoadGameConfigFile("FixVPhysicsCrush.games");
|
||||
if(!hGameData)
|
||||
SetFailState("Couldn't load FixVPhysicsCrush gamedata.");
|
||||
|
||||
int iPointerSize = GameConfGetOffset(hGameData, "PointerSize");
|
||||
int iVariantSize = GameConfGetOffset(hGameData, "variant_t_size");
|
||||
if(iPointerSize == -1 || iVariantSize == -1)
|
||||
{
|
||||
delete hGameData;
|
||||
SetFailState("Missing PointerSize / variant_t_size in FixVPhysicsCrush gamedata.");
|
||||
}
|
||||
|
||||
// CPhysicsObject::SetGameFlags(unsigned short)
|
||||
StartPrepSDKCall(SDKCall_Raw);
|
||||
if(!PrepSDKCall_SetFromConf(hGameData, SDKConf_Virtual, "SetGameFlags"))
|
||||
@@ -66,14 +54,36 @@ public void OnPluginStart()
|
||||
}
|
||||
PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
|
||||
g_hGetGameFlags = EndPrepSDKCall();
|
||||
delete hGameData;
|
||||
|
||||
hGameData = LoadGameConfigFile("sdktools.games");
|
||||
if(!hGameData)
|
||||
SetFailState("Couldn't load sdktools gamedata.");
|
||||
|
||||
// CBaseEntity::AcceptInput( const char *szInputName, CBaseEntity *pActivator, CBaseEntity *pCaller, variant_t Value, int outputID )
|
||||
int Offset = GameConfGetOffset(hGameData, "AcceptInput");
|
||||
delete hGameData;
|
||||
if(Offset == -1)
|
||||
SetFailState("Failed to find AcceptInput offset.");
|
||||
|
||||
g_hAcceptInput = DHookCreate(Offset, HookType_Entity, ReturnType_Bool, ThisPointer_CBaseEntity, OnAcceptInput);
|
||||
if(g_hAcceptInput == INVALID_HANDLE)
|
||||
SetFailState("Failed to DHook AcceptInput.");
|
||||
|
||||
DHookAddParam(g_hAcceptInput, HookParamType_CharPtr);
|
||||
DHookAddParam(g_hAcceptInput, HookParamType_CBaseEntity);
|
||||
DHookAddParam(g_hAcceptInput, HookParamType_CBaseEntity);
|
||||
DHookAddParam(g_hAcceptInput, HookParamType_Object, iVariantSize, DHookPass_ByVal|DHookPass_ODTOR|DHookPass_OCTOR|DHookPass_OASSIGNOP); // variant_t: 20 bytes on x86, 24 bytes on x64
|
||||
DHookAddParam(g_hAcceptInput, HookParamType_Int);
|
||||
|
||||
int hCollisionGroup = FindSendPropInfo("CBaseEntity", "m_CollisionGroup");
|
||||
if (hCollisionGroup == -1)
|
||||
SetFailState("Couldn't find CBaseEntity::m_CollisionGroup");
|
||||
|
||||
// CNetworkVar( int, m_CollisionGroup );
|
||||
// IPhysicsObject *m_pPhysicsObject;
|
||||
g_hPhysicsObject = hCollisionGroup + 4;
|
||||
// IPhysicsObject *m_pPhysicsObject; <- pointer, aligned to pointer size (4 on x86, 8 on x64)
|
||||
g_iPhysicsObjectOffset = hCollisionGroup + 4;
|
||||
g_iPhysicsObjectOffset = (g_iPhysicsObjectOffset + iPointerSize - 1) & ~(iPointerSize - 1);
|
||||
|
||||
// Late load.
|
||||
int entity = INVALID_ENT_REFERENCE;
|
||||
@@ -94,7 +104,7 @@ public void OnEntityCreated(int entity, const char[] classname)
|
||||
public MRESReturn OnAcceptInput(int entity, Handle hReturn, Handle hParams)
|
||||
{
|
||||
if(!IsValidEntity(entity))
|
||||
return;
|
||||
return MRES_Ignored;
|
||||
|
||||
char sCommand[128];
|
||||
DHookGetParamString(hParams, 1, sCommand, sizeof(sCommand));
|
||||
@@ -104,8 +114,8 @@ public MRESReturn OnAcceptInput(int entity, Handle hReturn, Handle hParams)
|
||||
int attachedObject = GetEntPropEnt(entity, Prop_Data, "m_attachedObject");
|
||||
if(attachedObject != INVALID_ENT_REFERENCE)
|
||||
{
|
||||
int vphysObj = GetVPhysicsObject(attachedObject);
|
||||
if(vphysObj)
|
||||
Address vphysObj = GetVPhysicsObject(attachedObject);
|
||||
if(vphysObj != Address_Null)
|
||||
{
|
||||
int flags = VPhysicsGetGameFlags(vphysObj);
|
||||
flags |= FVPHYSICS_NO_IMPACT_DMG;
|
||||
@@ -113,19 +123,22 @@ public MRESReturn OnAcceptInput(int entity, Handle hReturn, Handle hParams)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return MRES_Ignored;
|
||||
}
|
||||
|
||||
int VPhysicsGetGameFlags(int vphysicsObj)
|
||||
int VPhysicsGetGameFlags(Address vphysicsObj)
|
||||
{
|
||||
return SDKCall(g_hGetGameFlags, vphysicsObj);
|
||||
return SDKCall(g_hGetGameFlags, vphysicsObj) & 0xFFFF; // returns unsigned short
|
||||
}
|
||||
|
||||
void VPhysicsSetGameFlags(int vphysicsObj, int flags)
|
||||
void VPhysicsSetGameFlags(Address vphysicsObj, int flags)
|
||||
{
|
||||
SDKCall(g_hSetGameFlags, vphysicsObj, flags);
|
||||
}
|
||||
|
||||
int GetVPhysicsObject(int entity)
|
||||
Address GetVPhysicsObject(int entity)
|
||||
{
|
||||
return GetEntData(entity, g_hPhysicsObject, 4);
|
||||
// Read the full IPhysicsObject* (4 bytes on x86, 8 bytes on x64)
|
||||
return LoadAddressFromAddress(GetEntityAddress(entity) + view_as<Address>(g_iPhysicsObjectOffset));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user