Commit e6036d66 authored by Mikleo's avatar Mikleo
Browse files

Destroy engineer buildings safely.

parent 0a0a0883
Pipeline #13484 passed with stages
in 16 seconds
......@@ -10,7 +10,7 @@
#include <SteamWorks>
#define PluginVersion "1.46"
#define PluginVersion "1.47"
float pVersion;
// note linearmap field is unstable
......@@ -597,6 +597,16 @@ EnableCloseResourcePoint(float position[3])
}
}
bool IsEngineerBuildable(int entity, char[] className)
{
if(StrEqual(className,"emp_building_mgturret",true) || StrEqual(className,"emp_building_imp_mgturret",true) || StrEqual(className,"emp_building_nf_mgturret",true) || StrEqual(className,"emp_building_mlturret",true) || StrEqual(className,"emp_building_imp_mlturret",true) || StrEqual(className,"emp_building_nf_mlturret",true) || StrEqual(className,"emp_eng_walls",true) )
{
if(GetEntProp(entity,Prop_Send,"m_iOwner") != 0)
return true;
}
return false;
}
ExecuteRemoveEntity(int entity)
{
char className[64];
......@@ -674,6 +684,11 @@ ExecuteRemoveEntity(int entity)
float cornerPosition[3] = {-16000.0,-16000.0,-16000.0};
TeleportEntity(entity,cornerPosition, NULL_VECTOR, NULL_VECTOR);
}
else if(IsEngineerBuildable(entity,className))
{
// entity needs to be "destroyed" for proper cleanup or it will cause a crash.
SDKHooks_TakeDamage(entity, 0, 0, 100000.0, 0, 0);
}
if(StrEqual(className,"emp_vehicle",true))
{
......@@ -2420,18 +2435,9 @@ bool ShouldSave(int entity,char[] classname,any[] classInfo)
if(parent > 0 && IsBuilding(parent))
return false;
}
else if( StrEqual(classname,"emp_building_imp_mgturret",true) || StrEqual(classname,"emp_building_nf_mgturret",true) ||StrEqual(classname,"emp_building_imp_mlturret",true) || StrEqual(classname,"emp_building_nf_mlturret",true) )
{
// do not save turrets with a player owner
if(GetEntProp(entity,Prop_Send,"m_iOwner") != 0)
return false;
}
else if( StrEqual(classname,"emp_eng_walls",true))
else if(IsEngineerBuildable(entity,classname))
{
// do not save walls with a player owner.
if(GetEntProp(entity,Prop_Send,"m_iOwner") != 0)
return false;
return false;
}
else if(StrEqual(classname,"emp_info_player_nf",false) || StrEqual(classname,"emp_info_player_imp",false))
{
......
......@@ -498,7 +498,6 @@ int Create_Brush(char[] name, char[] className,int client,float position[3], flo
PrintToChatAll("Test success");
return entindex;
}
......@@ -2064,6 +2063,7 @@ public Action:Hook_Grab(grabbingClient,client)
{
if (IsValidEntity(entity))
{
float eyeAngles[3];
float ActiveEyeAngles[3];
float eyeDir[3];
......@@ -2076,6 +2076,8 @@ public Action:Hook_Grab(grabbingClient,client)
float pos[3];
GetClientEyePosition(client, pos);
float distance = grabDistance[client];
pos[0]+=eyeDir[0]*distance;
......@@ -2084,8 +2086,8 @@ public Action:Hook_Grab(grabbingClient,client)
float entityPos[3];
GetEntPropVector(grabbedEntity[client], Prop_Send, "m_vecOrigin", entityPos);
if(lockgrabaxis[client][0])
{
pos[0] = entityPos[0];
......@@ -2099,7 +2101,7 @@ public Action:Hook_Grab(grabbingClient,client)
pos[2] = entityPos[2];
}
decl Float:propAng[3];
......@@ -2124,8 +2126,10 @@ public Action:Hook_Grab(grabbingClient,client)
AddVectors(positionDiff,grabStartPos[client],pos);
if(lockgrabrotation[client])
{
......
......@@ -4,7 +4,7 @@
{
"Version"
{
"Latest" "1.46"
"Latest" "1.47"
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment