Prevent player from being destroyed by plugins (#4584)
* Prevent player from being destroyed by plugins Add manual binding, bails out with error message if attempted entity to destroy is player. * Improve warnings and documentation, remove automatic binding * Remove old and unnecessary deprecated function
This commit is contained in:
parent
b4060be3a4
commit
9210501af5
|
@ -3138,12 +3138,12 @@ local Hash = cCryptoHash.sha1HexString("DataToHash")
|
||||||
Params =
|
Params =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Name = "ShouldBroadcast",
|
Name = "ShouldBroadcast <b>(DEPRECATED)</b>",
|
||||||
Type = "boolean",
|
Type = "boolean",
|
||||||
IsOptional = true,
|
IsOptional = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Notes = "Schedules the entity to be destroyed; if ShouldBroadcast is not present or set to true, broadcasts the DestroyEntity packet",
|
Notes = "Schedules the entity to be destroyed; broadcasts the DestroyEntity packet",
|
||||||
},
|
},
|
||||||
DoesPreventBlockPlacement =
|
DoesPreventBlockPlacement =
|
||||||
{
|
{
|
||||||
|
|
|
@ -4081,6 +4081,37 @@ static int tolua_cCuboid_Move(lua_State * tolua_S)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int tolua_cEntity_Destroy(lua_State * tolua_S)
|
||||||
|
{
|
||||||
|
// Check the params:
|
||||||
|
cLuaState L(tolua_S);
|
||||||
|
if (!L.CheckParamSelf("cEntity"))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the params:
|
||||||
|
cEntity * self = nullptr;
|
||||||
|
L.GetStackValue(1, self);
|
||||||
|
|
||||||
|
if (lua_gettop(L) == 2)
|
||||||
|
{
|
||||||
|
LOGWARNING("cEntity:Destroy(bool) is deprecated, use cEntity:Destroy() instead.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self->IsPlayer())
|
||||||
|
{
|
||||||
|
return L.ApiParamError("Cannot call cEntity:Destroy() on a cPlayer, use cClientHandle:Kick() instead.");
|
||||||
|
}
|
||||||
|
|
||||||
|
self->Destroy();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int tolua_cEntity_IsSubmerged(lua_State * tolua_S)
|
static int tolua_cEntity_IsSubmerged(lua_State * tolua_S)
|
||||||
{
|
{
|
||||||
// Check the params:
|
// Check the params:
|
||||||
|
@ -4256,6 +4287,7 @@ void cManualBindings::Bind(lua_State * tolua_S)
|
||||||
|
|
||||||
tolua_beginmodule(tolua_S, "cEntity");
|
tolua_beginmodule(tolua_S, "cEntity");
|
||||||
tolua_constant(tolua_S, "INVALID_ID", cEntity::INVALID_ID);
|
tolua_constant(tolua_S, "INVALID_ID", cEntity::INVALID_ID);
|
||||||
|
tolua_function(tolua_S, "Destroy", tolua_cEntity_Destroy);
|
||||||
tolua_function(tolua_S, "IsSubmerged", tolua_cEntity_IsSubmerged);
|
tolua_function(tolua_S, "IsSubmerged", tolua_cEntity_IsSubmerged);
|
||||||
tolua_function(tolua_S, "IsSwimming", tolua_cEntity_IsSwimming);
|
tolua_function(tolua_S, "IsSwimming", tolua_cEntity_IsSwimming);
|
||||||
tolua_function(tolua_S, "GetPosition", tolua_cEntity_GetPosition);
|
tolua_function(tolua_S, "GetPosition", tolua_cEntity_GetPosition);
|
||||||
|
|
|
@ -289,14 +289,10 @@ public:
|
||||||
If this returns false, you must stop using the cEntity pointer you have. */
|
If this returns false, you must stop using the cEntity pointer you have. */
|
||||||
bool IsTicking(void) const;
|
bool IsTicking(void) const;
|
||||||
|
|
||||||
|
// tolua_end
|
||||||
/** Destroys the entity, schedules it for memory freeing and broadcasts the DestroyEntity packet */
|
/** Destroys the entity, schedules it for memory freeing and broadcasts the DestroyEntity packet */
|
||||||
virtual void Destroy();
|
virtual void Destroy();
|
||||||
|
// tolua_begin
|
||||||
OBSOLETE void Destroy(bool a_ShouldBroadcast)
|
|
||||||
{
|
|
||||||
LOGWARNING("cEntity:Destory(bool) is deprecated, use cEntity:Destroy() instead.");
|
|
||||||
Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Makes this pawn take damage from an attack by a_Attacker. Damage values are calculated automatically and DoTakeDamage() called */
|
/** Makes this pawn take damage from an attack by a_Attacker. Damage values are calculated automatically and DoTakeDamage() called */
|
||||||
void TakeDamage(cEntity & a_Attacker);
|
void TakeDamage(cEntity & a_Attacker);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user