1.1, Add new natives, entity types

This commit is contained in:
Kyle
2021-03-31 11:42:50 +08:00
parent 0fa5a52caf
commit 1b95cb6fb5
5 changed files with 92 additions and 31 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ jobs:
before_deploy:
- git config --local user.name "Kxnrl"
- git config --local user.email "[email protected]"
- export TRAVIS_TAG=release-$TRAVIS_BUILD_NUMBER
- export TRAVIS_TAG=release-$TRAVIS_OS_NAME-$TRAVIS_BUILD_NUMBER
- git tag $TRAVIS_TAG
deploy:
provider: releases
+4 -1
View File
@@ -6,11 +6,13 @@
native void TransmitManager_AddEntityHooks(int entity);
native bool TransmitManager_SetEntityOwner(int entity, int target);
native bool TransmitManager_SetEntityState(int entity, int client, bool can);
native bool TransmitManager_GetEntityState(int entity, int client);
native bool TransmitManager_IsEntityHooked(int entity);
/**
* _________________Do not edit below this line!_______________________
*/
public Extension __ext_movement =
public Extension __ext_transmit =
{
name = "TransmitManager",
file = "TransmitManager.ext",
@@ -25,3 +27,4 @@ public Extension __ext_movement =
required = 0,
#endif
};
+67 -9
View File
@@ -23,14 +23,35 @@ struct HookingEntity
iEntityIndex = gamehelpers->EntityToBCompatRef(pEntity);
SourceHookId = SH_ADD_MANUALHOOK(SetTransmit, pEntity, SH_MEMBER(&g_Transmit, &TransmitManager::Hook_SetTransmit), false);
for (auto i = 1; i < SM_MAXPLAYERS; i++)
// for css, gotv is 65
for (auto i = 1; i <= SM_MAXPLAYERS; i++)
{
// can see by default
bCanTransmit[i] = true;
}
auto* pName = gamehelpers->GetEntityClassname(pEntity);
if (pName != nullptr && (V_strcmp(pName, "info_particle_system") == 0 || V_strcmp(pName, "light_dynamic") == 0))
if (pName != nullptr && (
V_strcasecmp(pName, "info_particle_system") == 0 ||
V_strcasecmp(pName, "light_dynamic") == 0 ||
V_strcasecmp(pName, "env_cascade_light") == 0 ||
V_strcasecmp(pName, "env_projectedtexture") == 0 ||
V_strcasecmp(pName, "env_screenoverlay") == 0 ||
V_strcasecmp(pName, "env_fog_controller") == 0 ||
V_strcasecmp(pName, "env_lightglow") == 0 ||
V_strcasecmp(pName, "env_particlesmokegrenade") == 0 ||
V_strcasecmp(pName, "env_global_light") == 0 ||
V_strcasecmp(pName, "env_sun") == 0 ||
V_strcasecmp(pName, "env_sprite") == 0 ||
V_strcasecmp(pName, "point_camera") == 0 ||
V_strcasecmp(pName, "point_viewproxy") == 0 ||
V_strcasecmp(pName, "inferno") == 0 ||
V_strcasecmp(pName, "sunshine_shadow_control") == 0 ||
V_strcasecmp(pName, "cfe_player_decal") == 0 ||
V_strncasecmp(pName, "point_viewcontrol", 17) == 0 ||
V_strncasecmp(pName, "env_fire", 8) == 0 ||
V_strncasecmp(pName, "color_correction", 16) == 0))
{
bRemoveFlags = true;
@@ -54,7 +75,8 @@ struct HookingEntity
bool CanSee(int client)
{
if (iEntityIndex == client || iOwnerEntity == client)
// remove self bypass
if (iEntityIndex == client) /*|| iOwnerEntity == client*/
{
// self or children
return true;
@@ -86,7 +108,7 @@ struct HookingEntity
private:
int SourceHookId;
int iEntityIndex;
bool bCanTransmit[SM_MAXPLAYERS];
bool bCanTransmit[SM_MAXPLAYERS + 1];
int iOwnerEntity;
bool bRemoveFlags;
};
@@ -297,7 +319,7 @@ void TransmitManager::UnhookEntity(int index)
static cell_t Native_SetEntityOwner(IPluginContext* pContext, const cell_t* params)
{
if (!(params[1] >= 1 && params[1] < MAX_EDICTS))
if (!IsEntityIndexInRange(params[1]))
{
// out-of-range
return pContext->ThrowNativeError("Entity %d is out-of-range.", params[1]);
@@ -309,7 +331,7 @@ static cell_t Native_SetEntityOwner(IPluginContext* pContext, const cell_t* para
return true;
}
if (params[1] >= 1 && params[1] < SM_MAXPLAYERS)
if (params[1] >= 1 && params[1] < playerhelpers->GetMaxClients())
{
smutils->LogError(myself, "Entity %d is not being hook.", params[1]);
return false;
@@ -320,7 +342,7 @@ static cell_t Native_SetEntityOwner(IPluginContext* pContext, const cell_t* para
static cell_t Native_SetEntityState(IPluginContext* pContext, const cell_t* params)
{
if (!(params[1] >= 1 && params[1] < MAX_EDICTS))
if (!IsEntityIndexInRange(params[1]))
{
// out-of-range
return pContext->ThrowNativeError("Entity %d is out-of-range.", params[1]);
@@ -338,7 +360,7 @@ static cell_t Native_SetEntityState(IPluginContext* pContext, const cell_t* para
return true;
}
if (params[1] >= 1 && params[1] < SM_MAXPLAYERS)
if (params[1] >= 1 && params[1] < playerhelpers->GetMaxClients())
{
smutils->LogError(myself, "Entity %d is not being hook.", params[1]);
return false;
@@ -349,7 +371,7 @@ static cell_t Native_SetEntityState(IPluginContext* pContext, const cell_t* para
static cell_t Native_AddEntityHooks(IPluginContext* pContext, const cell_t* params)
{
if (!(params[1] >= 1 && params[1] < MAX_EDICTS))
if (!IsEntityIndexInRange(params[1]))
{
// out-of-range
return pContext->ThrowNativeError("Entity %d is out-of-range.", params[1]);
@@ -367,10 +389,46 @@ static cell_t Native_AddEntityHooks(IPluginContext* pContext, const cell_t* para
return 0;
}
static cell_t Native_GetEntityState(IPluginContext* pContext, const cell_t* params)
{
if (!IsEntityIndexInRange(params[1]))
{
// out-of-range
return pContext->ThrowNativeError("Entity %d is out-of-range.", params[1]);
}
auto* pPlayer = playerhelpers->GetGamePlayer(params[2]);
if (!pPlayer || !pPlayer->IsInGame())
{
return pContext->ThrowNativeError("Client %d is invalid.", params[2]);
}
if (g_Hooked[params[1]] == nullptr)
{
// can see
return true;
}
return g_Hooked[params[1]]->CanSee(params[2]);
}
static cell_t Native_IsEntityHooked(IPluginContext* pContext, const cell_t* params)
{
if (!IsEntityIndexInRange(params[1]))
{
// out-of-range
return pContext->ThrowNativeError("Entity %d is out-of-range.", params[1]);
}
return g_Hooked[params[1]] != nullptr;
}
sp_nativeinfo_t g_Natives[] =
{
{"TransmitManager_AddEntityHooks", Native_AddEntityHooks},
{"TransmitManager_SetEntityOwner", Native_SetEntityOwner},
{"TransmitManager_SetEntityState", Native_SetEntityState},
{"TransmitManager_GetEntityState", Native_GetEntityState},
{"TransmitManager_IsEntityHooked", Native_IsEntityHooked},
{nullptr, nullptr},
};
+1 -1
View File
@@ -27,6 +27,6 @@ private:
void UnhookEntity(int index);
};
inline bool IsEntityIndexInRange(int i) { return i >= 1 && i < 2048; }
inline bool IsEntityIndexInRange(int i) { return i >= 1 && i < MAX_EDICTS; }
#endif
+1 -1
View File
@@ -3,7 +3,7 @@
#define SMEXT_CONF_NAME "Transmit Manager"
#define SMEXT_CONF_DESCRIPTION ""
#define SMEXT_CONF_VERSION "1.0.1"
#define SMEXT_CONF_VERSION "1.1"
#define SMEXT_CONF_AUTHOR "Kyle \"Kxnrl\" Frankiss"
#define SMEXT_CONF_URL "https://www.kxnrl.com"
#define SMEXT_CONF_LOGTAG "TransmitManager"