sm-plugin-LagCompensation/LagCompensation/scripting/LagCompensation.sp

578 lines
14 KiB
SourcePawn
Raw Normal View History

2019-10-01 21:45:39 +02:00
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <CSSFixes>
#include <dhooks>
#pragma semicolon 1
#pragma newdecls required
public Plugin myinfo =
{
name = "LagCompensation",
author = "BotoX",
description = "",
version = "0.0",
url = ""
};
bool g_bLateLoad = false;
2019-10-02 18:54:19 +02:00
#define MAX_RECORDS 32
2019-10-02 23:28:20 +02:00
#define MAX_ENTITIES 32
//#define DEBUG
2019-10-01 21:45:39 +02:00
enum struct LagRecord
{
float vecOrigin[3];
float vecAngles[3];
}
enum struct EntityLagData
{
int iEntity;
int iRecordIndex;
int iNumRecords;
2019-10-02 23:28:20 +02:00
int iRecordsValid;
int iDeleted;
2019-10-01 21:45:39 +02:00
bool bRestore;
2019-10-02 18:54:19 +02:00
bool bMoving;
2019-10-01 21:45:39 +02:00
LagRecord RestoreData;
}
LagRecord g_aaLagRecords[MAX_ENTITIES][MAX_RECORDS];
EntityLagData g_aEntityLagData[MAX_ENTITIES];
int g_iNumEntities = 0;
2019-10-02 23:28:20 +02:00
Handle g_hGetAbsOrigin;
2019-10-02 18:54:19 +02:00
Handle g_hSetAbsOrigin;
2019-10-02 23:28:20 +02:00
Handle g_hGetAbsAngles;
2019-10-02 18:54:19 +02:00
Handle g_hSetAbsAngles;
2019-10-01 21:45:39 +02:00
2019-10-02 23:28:20 +02:00
bool g_bBlockPhysics = false;
bool g_bNoPhysics[2048];
Handle g_hPhysicsTouchTriggers;
bool g_bRoundEnded = false;
Handle g_hUTIL_Remove;
2019-10-01 21:45:39 +02:00
public void OnPluginStart()
{
Handle hGameData = LoadGameConfigFile("LagCompensation.games");
if(!hGameData)
SetFailState("Failed to load LagCompensation gamedata.");
2019-10-02 23:28:20 +02:00
// CBaseEntity::GetAbsOrigin
StartPrepSDKCall(SDKCall_Entity);
if(!PrepSDKCall_SetFromConf(hGameData, SDKConf_Signature, "GetAbsOrigin"))
{
delete hGameData;
SetFailState("PrepSDKCall_SetFromConf(hGameData, SDKConf_Signature, \"GetAbsOrigin\") failed!");
}
PrepSDKCall_SetReturnInfo(SDKType_Vector, SDKPass_ByRef);
g_hGetAbsOrigin = EndPrepSDKCall();
2019-10-02 18:54:19 +02:00
// CBaseEntity::SetAbsOrigin
2019-10-01 21:45:39 +02:00
StartPrepSDKCall(SDKCall_Entity);
2019-10-02 18:54:19 +02:00
if(!PrepSDKCall_SetFromConf(hGameData, SDKConf_Signature, "SetAbsOrigin"))
2019-10-01 21:45:39 +02:00
{
delete hGameData;
2019-10-02 18:54:19 +02:00
SetFailState("PrepSDKCall_SetFromConf(hGameData, SDKConf_Signature, \"SetAbsOrigin\") failed!");
2019-10-01 21:45:39 +02:00
}
PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
2019-10-02 18:54:19 +02:00
g_hSetAbsOrigin = EndPrepSDKCall();
2019-10-01 21:45:39 +02:00
2019-10-02 23:28:20 +02:00
// CBaseEntity::GetAbsAngles
StartPrepSDKCall(SDKCall_Entity);
if(!PrepSDKCall_SetFromConf(hGameData, SDKConf_Signature, "GetAbsAngles"))
{
delete hGameData;
SetFailState("PrepSDKCall_SetFromConf(hGameData, SDKConf_Signature, \"GetAbsAngles\") failed!");
}
PrepSDKCall_AddParameter(SDKType_QAngle, SDKPass_ByRef);
g_hGetAbsAngles = EndPrepSDKCall();
2019-10-02 18:54:19 +02:00
// CBaseEntity::SetAbsAngles
2019-10-01 21:45:39 +02:00
StartPrepSDKCall(SDKCall_Entity);
2019-10-02 18:54:19 +02:00
if(!PrepSDKCall_SetFromConf(hGameData, SDKConf_Signature, "SetAbsAngles"))
2019-10-01 21:45:39 +02:00
{
delete hGameData;
2019-10-02 18:54:19 +02:00
SetFailState("PrepSDKCall_SetFromConf(hGameData, SDKConf_Signature, \"SetAbsAngles\") failed!");
2019-10-01 21:45:39 +02:00
}
PrepSDKCall_AddParameter(SDKType_QAngle, SDKPass_ByRef);
2019-10-02 18:54:19 +02:00
g_hSetAbsAngles = EndPrepSDKCall();
2019-10-01 21:45:39 +02:00
2019-10-02 23:28:20 +02:00
// CBaseEntity::PhysicsTouchTriggers
2019-10-01 21:45:39 +02:00
g_hPhysicsTouchTriggers = DHookCreateFromConf(hGameData, "CBaseEntity__PhysicsTouchTriggers");
if(!g_hPhysicsTouchTriggers)
2019-10-02 23:28:20 +02:00
{
delete hGameData;
2019-10-01 21:45:39 +02:00
SetFailState("Failed to setup detour for CBaseEntity__PhysicsTouchTriggers");
2019-10-02 23:28:20 +02:00
}
2019-10-01 21:45:39 +02:00
if(!DHookEnableDetour(g_hPhysicsTouchTriggers, false, Detour_OnPhysicsTouchTriggers))
2019-10-02 23:28:20 +02:00
{
delete hGameData;
2019-10-01 21:45:39 +02:00
SetFailState("Failed to detour CBaseEntity__PhysicsTouchTriggers.");
2019-10-02 23:28:20 +02:00
}
// UTIL_Remove
g_hUTIL_Remove = DHookCreateFromConf(hGameData, "UTIL_Remove");
if(!g_hUTIL_Remove)
{
delete hGameData;
SetFailState("Failed to setup detour for UTIL_Remove");
}
delete hGameData;
if(!DHookEnableDetour(g_hUTIL_Remove, false, Detour_OnUTIL_Remove))
SetFailState("Failed to detour UTIL_Remove.");
HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
}
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
g_bLateLoad = late;
return APLRes_Success;
}
public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
{
g_bRoundEnded = true;
2019-10-03 10:39:27 +02:00
for(int i = 0, j = g_iNumEntities; i < MAX_ENTITIES, j; i++)
2019-10-02 23:28:20 +02:00
{
2019-10-03 10:39:27 +02:00
if(!g_aEntityLagData[i].iEntity)
continue;
j--;
g_aEntityLagData[i].iEntity = 0;
g_iNumEntities--;
LogMessage("[%d] round_end deleted: %d / %d", GetGameTickCount(), i, g_aEntityLagData[i].iEntity);
return;
2019-10-02 23:28:20 +02:00
}
}
public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
g_bRoundEnded = false;
2019-10-01 21:45:39 +02:00
}
public MRESReturn Detour_OnPhysicsTouchTriggers(int entity, Handle hReturn, Handle hParams)
{
2019-10-02 12:22:35 +02:00
if(!g_bBlockPhysics)
return MRES_Ignored;
2019-10-01 21:45:39 +02:00
if(entity < 0 || entity > sizeof(g_bNoPhysics))
return MRES_Ignored;
if(g_bNoPhysics[entity])
{
2019-10-02 14:19:09 +02:00
//LogMessage("blocked physics on %d", entity);
2019-10-01 21:45:39 +02:00
return MRES_Supercede;
}
return MRES_Ignored;
}
2019-10-02 23:28:20 +02:00
public MRESReturn Detour_OnUTIL_Remove(Handle hParams)
2019-10-01 21:45:39 +02:00
{
2019-10-02 23:28:20 +02:00
if(g_bRoundEnded)
return MRES_Ignored;
int entity = DHookGetParam(hParams, 1);
if(entity < 0 || entity > sizeof(g_bNoPhysics))
return MRES_Ignored;
2019-10-03 10:39:27 +02:00
for(int i = 0, j = g_iNumEntities; i < MAX_ENTITIES, j; i++)
2019-10-02 23:28:20 +02:00
{
2019-10-03 10:39:27 +02:00
if(!g_aEntityLagData[i].iEntity)
continue;
j--;
2019-10-02 23:28:20 +02:00
if(g_aEntityLagData[i].iEntity != entity)
continue;
SetEntPropEnt(entity, Prop_Data, "m_pParent", 0);
if(!g_aEntityLagData[i].iDeleted)
g_aEntityLagData[i].iDeleted = GetGameTickCount();
LogMessage("[%d] !!!!!!!!!!! Detour_OnUTIL_Remove: %d / ent: %d", GetGameTickCount(), i, entity);
return MRES_Supercede;
}
return MRES_Ignored;
2019-10-01 21:45:39 +02:00
}
public void OnMapStart()
{
bool bLate = g_bLateLoad;
g_bLateLoad = false;
/* Late Load */
if(bLate)
{
for(int client = 1; client <= MaxClients; client++)
{
if(IsClientInGame(client))
OnClientPutInServer(client);
}
int entity = INVALID_ENT_REFERENCE;
while((entity = FindEntityByClassname(entity, "*")) != INVALID_ENT_REFERENCE)
{
char sClassname[64];
if(GetEntityClassname(entity, sClassname, sizeof(sClassname)))
OnEntitySpawned(entity, sClassname);
}
}
}
public void OnClientPutInServer(int client)
{
}
public void OnRunThinkFunctions(bool simulating)
{
2019-10-03 10:39:27 +02:00
for(int i = 0, j = g_iNumEntities; i < MAX_ENTITIES, j; i++)
2019-10-01 21:45:39 +02:00
{
2019-10-03 10:39:27 +02:00
if(!g_aEntityLagData[i].iEntity)
continue;
j--;
if(!g_aEntityLagData[i].bMoving)
2019-10-01 21:45:39 +02:00
continue;
if(!IsValidEntity(g_aEntityLagData[i].iEntity))
{
LogMessage("!!!!!!!!!!! OnRunThinkFunctions SHIT deleted: %d", g_aEntityLagData[i].iEntity);
g_aEntityLagData[i].iEntity = 0;
g_iNumEntities--;
continue;
}
2019-10-02 23:28:20 +02:00
if(g_aEntityLagData[i].iDeleted)
{
if(g_aEntityLagData[i].iDeleted + MAX_RECORDS < GetGameTickCount())
{
LogMessage("[%d] !!!!!!!!!!! RemoveEdict: %d / ent: %d", GetGameTickCount(), i, g_aEntityLagData[i].iEntity);
RemoveEdict(g_aEntityLagData[i].iEntity);
}
continue;
}
2019-10-01 21:45:39 +02:00
RecordDataIntoRecord(g_aEntityLagData[i].iEntity, g_aEntityLagData[i].RestoreData);
2019-10-03 10:39:27 +02:00
2019-10-02 14:19:09 +02:00
#if defined DEBUG
2019-10-02 18:54:19 +02:00
LogMessage("1 [%d] [%d] index %d, RECORD entity %d", GetGameTickCount(), i, simulating, g_aEntityLagData[i].iEntity, g_aEntityLagData[i].iRecordIndex);
2019-10-02 14:19:09 +02:00
LogMessage("%f %f %f",
g_aEntityLagData[i].RestoreData.vecOrigin[0],
g_aEntityLagData[i].RestoreData.vecOrigin[1],
g_aEntityLagData[i].RestoreData.vecOrigin[2]
);
#endif
2019-10-01 21:45:39 +02:00
}
}
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int mouse[2])
{
2019-10-02 12:22:35 +02:00
if(!IsPlayerAlive(client))
return Plugin_Continue;
2019-10-01 21:45:39 +02:00
int delta = GetGameTickCount() - tickcount;
if(delta < 0)
delta = 0;
2019-10-03 10:39:27 +02:00
for(int i = 0, j = g_iNumEntities; i < MAX_ENTITIES, j; i++)
2019-10-01 21:45:39 +02:00
{
2019-10-03 10:39:27 +02:00
if(!g_aEntityLagData[i].iEntity)
continue;
j--;
if(!g_aEntityLagData[i].bMoving)
2019-10-01 21:45:39 +02:00
continue;
if(delta >= g_aEntityLagData[i].iNumRecords)
delta = g_aEntityLagData[i].iNumRecords - 1;
2019-10-02 23:28:20 +02:00
if(g_aEntityLagData[i].iDeleted)
{
int simtick = GetGameTickCount() - delta;
if(simtick > g_aEntityLagData[i].iDeleted)
{
// TODO: completly block player from touching trigger
continue;
}
}
2019-10-01 21:45:39 +02:00
int iRecordIndex = g_aEntityLagData[i].iRecordIndex - delta;
if(iRecordIndex < 0)
iRecordIndex += MAX_RECORDS;
2019-10-02 12:22:35 +02:00
RestoreEntityFromRecord(g_aEntityLagData[i].iEntity, client, g_aaLagRecords[i][iRecordIndex]);
2019-10-02 23:28:20 +02:00
g_aEntityLagData[i].bRestore = !g_aEntityLagData[i].iDeleted;
2019-10-01 21:45:39 +02:00
#if defined DEBUG
2019-10-02 18:54:19 +02:00
LogMessage("2 [%d] index %d, Entity %d -> delta = %d | Record = %d", GetGameTickCount(), i, g_aEntityLagData[i].iEntity, delta, iRecordIndex);
2019-10-01 21:45:39 +02:00
LogMessage("%f %f %f",
g_aaLagRecords[i][iRecordIndex].vecOrigin[0],
g_aaLagRecords[i][iRecordIndex].vecOrigin[1],
g_aaLagRecords[i][iRecordIndex].vecOrigin[2]
);
#endif
}
return Plugin_Continue;
}
2019-10-02 18:54:19 +02:00
public void OnPostPlayerThinkFunctions()
2019-10-01 21:45:39 +02:00
{
2019-10-03 10:39:27 +02:00
for(int i = 0, j = g_iNumEntities; i < MAX_ENTITIES, j; i++)
2019-10-01 21:45:39 +02:00
{
2019-10-03 10:39:27 +02:00
if(!g_aEntityLagData[i].iEntity)
continue;
j--;
if(!g_aEntityLagData[i].bRestore)
2019-10-01 21:45:39 +02:00
continue;
2019-10-02 12:22:35 +02:00
RestoreEntityFromRecord(g_aEntityLagData[i].iEntity, 0, g_aEntityLagData[i].RestoreData);
2019-10-01 21:45:39 +02:00
g_aEntityLagData[i].bRestore = false;
#if defined DEBUG
2019-10-02 18:54:19 +02:00
LogMessage("3 [%d] index %d, RESTORE entity %d", GetGameTickCount(), i, g_aEntityLagData[i].iEntity, g_aEntityLagData[i].iRecordIndex);
2019-10-01 21:45:39 +02:00
LogMessage("%f %f %f",
g_aEntityLagData[i].RestoreData.vecOrigin[0],
g_aEntityLagData[i].RestoreData.vecOrigin[1],
g_aEntityLagData[i].RestoreData.vecOrigin[2]
);
#endif
}
2019-10-02 14:19:09 +02:00
g_bBlockPhysics = true;
2019-10-01 21:45:39 +02:00
}
public void OnRunThinkFunctionsPost(bool simulating)
{
2019-10-03 10:39:27 +02:00
for(int i = 0, j = g_iNumEntities; i < MAX_ENTITIES, j; i++)
2019-10-01 21:45:39 +02:00
{
2019-10-03 10:39:27 +02:00
if(!g_aEntityLagData[i].iEntity)
2019-10-01 21:45:39 +02:00
continue;
2019-10-03 10:39:27 +02:00
j--;
2019-10-01 21:45:39 +02:00
2019-10-02 23:28:20 +02:00
if(g_aEntityLagData[i].iDeleted)
2019-10-01 21:45:39 +02:00
{
2019-10-02 23:28:20 +02:00
if(g_aEntityLagData[i].iRecordsValid)
{
g_aEntityLagData[i].iRecordIndex++;
if(g_aEntityLagData[i].iRecordIndex >= MAX_RECORDS)
g_aEntityLagData[i].iRecordIndex = 0;
g_aEntityLagData[i].iRecordsValid--;
}
2019-10-01 21:45:39 +02:00
continue;
}
2019-10-02 18:54:19 +02:00
if(g_aEntityLagData[i].iNumRecords)
{
if(!g_aEntityLagData[i].bMoving)
{
float vecOldOrigin[3];
vecOldOrigin[0] = g_aaLagRecords[i][0].vecOrigin[0];
vecOldOrigin[1] = g_aaLagRecords[i][0].vecOrigin[1];
vecOldOrigin[2] = g_aaLagRecords[i][0].vecOrigin[2];
float vecOrigin[3];
GetEntPropVector(g_aEntityLagData[i].iEntity, Prop_Data, "m_vecAbsOrigin", vecOrigin);
if(vecOldOrigin[0] == vecOrigin[0] && vecOldOrigin[1] == vecOrigin[1] && vecOldOrigin[2] == vecOrigin[2])
continue;
}
g_aEntityLagData[i].bMoving = true;
}
2019-10-01 21:45:39 +02:00
g_aEntityLagData[i].iRecordIndex++;
if(g_aEntityLagData[i].iRecordIndex >= MAX_RECORDS)
g_aEntityLagData[i].iRecordIndex = 0;
if(g_aEntityLagData[i].iNumRecords < MAX_RECORDS)
2019-10-02 23:28:20 +02:00
g_aEntityLagData[i].iRecordsValid = ++g_aEntityLagData[i].iNumRecords;
2019-10-01 21:45:39 +02:00
RecordDataIntoRecord(g_aEntityLagData[i].iEntity, g_aaLagRecords[i][g_aEntityLagData[i].iRecordIndex]);
#if defined DEBUG
2019-10-02 18:54:19 +02:00
LogMessage("4 [%d] index %d, RECORD entity %d into %d", GetGameTickCount(), i, g_aEntityLagData[i].iEntity, g_aEntityLagData[i].iRecordIndex);
2019-10-01 21:45:39 +02:00
LogMessage("%f %f %f",
g_aaLagRecords[i][g_aEntityLagData[i].iRecordIndex].vecOrigin[0],
g_aaLagRecords[i][g_aEntityLagData[i].iRecordIndex].vecOrigin[1],
g_aaLagRecords[i][g_aEntityLagData[i].iRecordIndex].vecOrigin[2]
);
#endif
}
2019-10-02 14:19:09 +02:00
g_bBlockPhysics = false;
2019-10-01 21:45:39 +02:00
}
void RecordDataIntoRecord(int iEntity, LagRecord Record)
{
2019-10-02 23:28:20 +02:00
SDKCall(g_hGetAbsOrigin, iEntity, Record.vecOrigin);
SDKCall(g_hGetAbsAngles, iEntity, Record.vecAngles);
2019-10-01 21:45:39 +02:00
}
2019-10-02 12:22:35 +02:00
void RestoreEntityFromRecord(int iEntity, int iFilter, LagRecord Record)
2019-10-01 21:45:39 +02:00
{
2019-10-02 12:22:35 +02:00
FilterTriggerMoved(iFilter);
2019-10-02 14:19:09 +02:00
2019-10-02 18:54:19 +02:00
SDKCall(g_hSetAbsAngles, iEntity, Record.vecAngles);
SDKCall(g_hSetAbsOrigin, iEntity, Record.vecOrigin);
2019-10-02 14:19:09 +02:00
2019-10-02 12:22:35 +02:00
FilterTriggerMoved(-1);
2019-10-01 21:45:39 +02:00
}
bool AddEntityForLagCompensation(int iEntity)
{
2019-10-03 10:39:27 +02:00
if(g_iNumEntities == MAX_ENTITIES)
return false;
for(int i = 0, j = g_iNumEntities; i < MAX_ENTITIES, j; i++)
2019-10-01 21:45:39 +02:00
{
2019-10-03 10:39:27 +02:00
if(!g_aEntityLagData[i].iEntity)
continue;
j--;
2019-10-01 21:45:39 +02:00
if(g_aEntityLagData[i].iEntity == iEntity)
return true;
}
for(int i = 0; i < MAX_ENTITIES; i++)
{
2019-10-03 10:39:27 +02:00
if(g_aEntityLagData[i].iEntity)
2019-10-01 21:45:39 +02:00
continue;
g_iNumEntities++;
g_aEntityLagData[i].iEntity = iEntity;
g_aEntityLagData[i].iRecordIndex = -1;
g_aEntityLagData[i].iNumRecords = 0;
2019-10-02 23:28:20 +02:00
g_aEntityLagData[i].iRecordsValid = 0;
g_aEntityLagData[i].iDeleted = 0;
g_aEntityLagData[i].bRestore = false;
2019-10-02 18:54:19 +02:00
g_aEntityLagData[i].bMoving = false;
2019-10-01 21:45:39 +02:00
2019-10-02 23:28:20 +02:00
{
char sClassname[64];
GetEntityClassname(g_aEntityLagData[i].iEntity, sClassname, sizeof(sClassname));
char sTargetname[64];
GetEntPropString(g_aEntityLagData[i].iEntity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname));
int iHammerID = GetEntProp(g_aEntityLagData[i].iEntity, Prop_Data, "m_iHammerID");
LogMessage("[%d] added entity %d (%s)\"%s\"(#%d) under index %d", GetGameTickCount(), iEntity, sClassname, sTargetname, iHammerID, i);
2019-10-03 10:39:27 +02:00
float vecOrigin[3];
GetEntPropVector(iEntity, Prop_Data, "m_vecAbsOrigin", vecOrigin);
LogMessage("%f %f %f",
vecOrigin[0],
vecOrigin[1],
vecOrigin[2]
);
2019-10-02 23:28:20 +02:00
}
2019-10-01 21:45:39 +02:00
return true;
}
2019-10-03 10:39:27 +02:00
2019-10-01 21:45:39 +02:00
return false;
}
public void OnEntitySpawned(int entity, const char[] classname)
{
if(entity < 0 || entity > sizeof(g_bNoPhysics))
return;
2019-10-03 10:39:27 +02:00
if(!strncmp(classname, "func_physbox", 12))
2019-10-02 23:28:20 +02:00
{
AddEntityForLagCompensation(entity);
return;
}
2019-10-01 21:45:39 +02:00
if(!StrEqual(classname, "trigger_hurt"))
return;
2019-10-02 18:54:19 +02:00
int iParent = entity;
2019-10-01 21:45:39 +02:00
char sParentClassname[64];
2019-10-02 18:54:19 +02:00
bool bGoodParents = false;
for(;;)
{
iParent = GetEntPropEnt(iParent, Prop_Data, "m_pParent");
if(iParent == -1)
break;
2019-10-01 21:45:39 +02:00
2019-10-02 18:54:19 +02:00
GetEntityClassname(iParent, sParentClassname, sizeof(sParentClassname));
2019-10-03 10:39:27 +02:00
if(strncmp(sParentClassname, "func_", 5))
continue;
if(StrEqual(sParentClassname[5], "movelinear") ||
StrEqual(sParentClassname[5], "door") ||
StrEqual(sParentClassname[5], "tracktrain") ||
!strncmp(sParentClassname[5], "physbox", 7))
2019-10-02 18:54:19 +02:00
{
bGoodParents = true;
break;
}
}
if(iParent == -1)
return;
2019-10-01 21:45:39 +02:00
char sTargetname[64];
GetEntPropString(entity, Prop_Data, "m_iName", sTargetname, sizeof(sTargetname));
char sParentTargetname[64];
GetEntPropString(iParent, Prop_Data, "m_iName", sParentTargetname, sizeof(sParentTargetname));
2019-10-02 18:54:19 +02:00
LogMessage("test: %s %s | parent: %s %s", classname, sTargetname, sParentClassname, sParentTargetname);
if(!bGoodParents)
2019-10-01 21:45:39 +02:00
return;
2019-10-02 18:54:19 +02:00
if(!AddEntityForLagCompensation(entity))
2019-10-01 21:45:39 +02:00
return;
g_bNoPhysics[entity] = true;
LogMessage("added %s %s | parent: %s %s", classname, sTargetname, sParentClassname, sParentTargetname);
}
public void OnEntityDestroyed(int entity)
{
if(entity < 0 || entity > sizeof(g_bNoPhysics))
return;
g_bNoPhysics[entity] = false;
2019-10-03 10:39:27 +02:00
for(int i = 0, j = g_iNumEntities; i < MAX_ENTITIES, j; i++)
2019-10-01 21:45:39 +02:00
{
2019-10-03 10:39:27 +02:00
if(!g_aEntityLagData[i].iEntity)
continue;
j--;
if(g_aEntityLagData[i].iEntity != entity)
continue;
g_aEntityLagData[i].iEntity = 0;
g_iNumEntities--;
LogMessage("[%d] normal deleted: %d / %d", GetGameTickCount(), i, entity);
return;
2019-10-01 21:45:39 +02:00
}
}