Commit 8a802087 authored by Artem Golubikhin's avatar Artem Golubikhin Committed by Ecklory

Added `rg_remove_entity` native function

(cherry picked from commit 06547e6c009ea505e5a2010275e0f0e2da10ff91)

# Conflicts:
#	gradle.properties
#	reapi/include/cssdk/dlls/regamedll_api.h
parent 8647cd08
majorVersion=5
minorVersion=15
minorVersion=16
maintenanceVersion=0
......@@ -378,6 +378,16 @@ native rg_update_teamscores(const iCtsWins = 0, const iTsWins = 0, const bool:bA
*/
native rg_create_entity(const classname[], const bool:useHashTable = false);
/**
* Removes an entity just like `remove_entity(entity)` or `engfunc(EngFunc_RemoveEntity, entity)`,
* but in a more safe manner. Internally calls an `UTIL_Remove` function.
*
* @param entity Entity index
*
* @noreturn
*/
native rg_remove_entity(const entity);
/*
* Finds an entity in the world using Counter-Strike's custom FindEntityByString wrapper.
*
......
......@@ -39,7 +39,7 @@
#include <API/CSInterfaces.h>
#define REGAMEDLL_API_VERSION_MAJOR 5
#define REGAMEDLL_API_VERSION_MINOR 18
#define REGAMEDLL_API_VERSION_MINOR 19
// CBasePlayer::Spawn hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_Spawn;
......@@ -625,6 +625,7 @@ struct ReGameFuncs_t {
void (*RemoveEntityHashValue)(entvars_t *pev, const char *value, hash_types_e fieldType);
int (*Cmd_Argc)();
const char *(*Cmd_Argv)(int i);
void (*UTIL_Remove)(class CBaseEntity *pEntity);
};
class IReGameApi {
......
......@@ -526,6 +526,26 @@ cell AMX_NATIVE_CALL rg_create_entity(AMX *amx, cell *params)
return 0;
}
/**
* Removes an entity just like `remove_entity(entity)` or `engfunc(EngFunc_RemoveEntity, entity)`,
* but in a more safe manner. Internally calls an `UTIL_Remove` function.
*
* @param entity Entity index
*
* @noreturn
*
* native rg_remove_entity(const entity);
*/
cell AMX_NATIVE_CALL rg_remove_entity(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_entity };
auto pEntity = getPrivate<CBaseEntity>(params[arg_entity]);
g_ReGameFuncs->UTIL_Remove(pEntity);
return 0;
}
/*
* Finds an entity in the world using Counter-Strike's custom FindEntityByString wrapper.
*
......@@ -2315,6 +2335,7 @@ AMX_NATIVE_INFO Misc_Natives_RG[] =
{ "rg_update_teamscores", rg_update_teamscores },
{ "rg_create_entity", rg_create_entity },
{ "rg_remove_entity", rg_remove_entity },
{ "rg_find_ent_by_class", rg_find_ent_by_class },
{ "rg_find_ent_by_owner", rg_find_ent_by_owner },
{ "rg_find_weapon_bpack_by_name", rg_find_weapon_bpack_by_name },
......
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