mirror of
https://github.com/rehlds/reapi.git
synced 2025-01-16 00:28:17 +03:00
Refactored project structure
Natives optimization
This commit is contained in:
parent
e0fb129f4d
commit
73c1151962
@ -13,10 +13,14 @@
|
||||
#pragma library reapi
|
||||
#endif
|
||||
|
||||
// reapi version
|
||||
#define REAPI_VERISON_MAJOR 1
|
||||
#define REAPI_VERISON_MINOR 0
|
||||
|
||||
#include <reapi_const.inc>
|
||||
#include <reapi_engine.inc> // NOTE: only for ReHLDS
|
||||
#include <reapi_gamedll.inc> // NOTE: only for gamedll Counter-Strike (ReGameDLL_CS)
|
||||
#include <reapi_misc.inc> // NOTE: Common set of natives and forwards.
|
||||
#include <reapi_addons.inc> // NOTE: 3-rd party addons
|
||||
|
||||
// hookchain return type
|
||||
enum
|
||||
|
@ -1,31 +1,7 @@
|
||||
#if defined _reapi_misc_included
|
||||
#if defined _reapi_addons_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _reapi_misc_included
|
||||
|
||||
enum client_auth
|
||||
{
|
||||
/**
|
||||
* Description: -
|
||||
* Return type: int
|
||||
* Params: get_client_data(const index, CA_PROTOCOL)
|
||||
*/
|
||||
CA_PROTOCOL,
|
||||
|
||||
/**
|
||||
* Description: -
|
||||
* Return type: client_auth_type
|
||||
* Params: get_client_data(const index, CA_TYPE)
|
||||
*/
|
||||
CA_TYPE,
|
||||
|
||||
/**
|
||||
* Description: -
|
||||
* Return type: -
|
||||
* Params: get_client_data(const index, CA_STRING, output[], maxlength)
|
||||
*/
|
||||
CA_STRING,
|
||||
};
|
||||
#define _reapi_addons_included
|
||||
|
||||
enum client_auth_type
|
||||
{
|
||||
@ -85,9 +61,17 @@ forward VTC_OnClientStartSpeak(index);
|
||||
forward VTC_OnClientStopSpeak(index);
|
||||
|
||||
/*
|
||||
* Get out information of the client
|
||||
* Get client protocol
|
||||
*
|
||||
* @param index Client index
|
||||
* @type to look enum client_auth
|
||||
* @noreturn
|
||||
*/
|
||||
native get_client_data(const index, client_auth:type, any:...);
|
||||
native REU_GetProtocol(const index);
|
||||
|
||||
/*
|
||||
* Get client auth type
|
||||
*
|
||||
* @param index Client index
|
||||
* @noreturn
|
||||
*/
|
||||
native REU_GetAuthtype(const index);
|
@ -1,8 +0,0 @@
|
||||
#if defined _reapi_const_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _reapi_const_included
|
||||
|
||||
// reapi version
|
||||
#define REAPI_VERISON_MAJOR 1
|
||||
#define REAPI_VERISON_MINOR 0
|
@ -4,32 +4,4 @@
|
||||
|
||||
#define _reapi_engine_included
|
||||
|
||||
enum EngineFunc
|
||||
{
|
||||
/**
|
||||
* Description: -
|
||||
* Params: (const recipients, const entity, const channel, const sample[], const volume, Float:attenuation, const fFlags, const pitch)
|
||||
*/
|
||||
RH_SV_StartSound = 0,
|
||||
|
||||
/**
|
||||
* Description: -
|
||||
* Params: (const client, bool:crash, const fmt[])
|
||||
*/
|
||||
RH_SV_DropClient,
|
||||
|
||||
/**
|
||||
* Description: -
|
||||
* Params: (const runPhysics)
|
||||
*/
|
||||
RH_SV_ActivateServer,
|
||||
|
||||
/**
|
||||
* Description: -
|
||||
* Params: (pcvar, const value[])
|
||||
*/
|
||||
RH_Cvar_DirectSet,
|
||||
|
||||
// [...]
|
||||
RH_EngineFunc_End
|
||||
};
|
||||
#include <reapi_engine_const.inc>
|
||||
|
35
reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc
Normal file
35
reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc
Normal file
@ -0,0 +1,35 @@
|
||||
#if defined _reapi_engine_const_included
|
||||
#endinput
|
||||
#endif
|
||||
|
||||
#define _reapi_engine_const_included
|
||||
|
||||
enum EngineFunc
|
||||
{
|
||||
/**
|
||||
* Description: -
|
||||
* Params: (const recipients, const entity, const channel, const sample[], const volume, Float:attenuation, const fFlags, const pitch)
|
||||
*/
|
||||
RH_SV_StartSound = 0,
|
||||
|
||||
/**
|
||||
* Description: -
|
||||
* Params: (const client, bool:crash, const fmt[])
|
||||
*/
|
||||
RH_SV_DropClient,
|
||||
|
||||
/**
|
||||
* Description: -
|
||||
* Params: (const runPhysics)
|
||||
*/
|
||||
RH_SV_ActivateServer,
|
||||
|
||||
/**
|
||||
* Description: -
|
||||
* Params: (pcvar, const value[])
|
||||
*/
|
||||
RH_Cvar_DirectSet,
|
||||
|
||||
// [...]
|
||||
RH_EngineFunc_End
|
||||
};
|
@ -210,7 +210,7 @@
|
||||
<ClInclude Include="..\src\natives\natives_hookchains.h" />
|
||||
<ClInclude Include="..\src\natives\natives_members.h" />
|
||||
<ClInclude Include="..\src\natives\natives_misc.h" />
|
||||
<ClInclude Include="..\src\natives\natives_vtc.h" />
|
||||
<ClInclude Include="..\src\natives\natives_addons.h" />
|
||||
<ClInclude Include="..\src\precompiled.h" />
|
||||
<ClInclude Include="..\src\reapi_utils.h" />
|
||||
</ItemGroup>
|
||||
@ -249,7 +249,7 @@
|
||||
<ClCompile Include="..\src\natives\natives_hookchains.cpp" />
|
||||
<ClCompile Include="..\src\natives\natives_members.cpp" />
|
||||
<ClCompile Include="..\src\natives\natives_misc.cpp" />
|
||||
<ClCompile Include="..\src\natives\natives_vtc.cpp" />
|
||||
<ClCompile Include="..\src\natives\natives_addons.cpp" />
|
||||
<ClCompile Include="..\src\precompiled.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
@ -264,9 +264,10 @@
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi.inc" />
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_const.inc" />
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_engine.inc" />
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_engine_const.inc" />
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_gamedll.inc" />
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_gamedll_const.inc" />
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_misc.inc" />
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_addons.inc" />
|
||||
<None Include="..\extra\amxmodx\scripting\reapi_test.sma" />
|
||||
<None Include="..\src\reapi_const.inc" />
|
||||
<None Include="reapi.def" />
|
||||
|
@ -636,9 +636,6 @@
|
||||
<ClInclude Include="..\src\natives\natives_misc.h">
|
||||
<Filter>src\natives</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\natives\natives_vtc.h">
|
||||
<Filter>src\natives</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\vtc_api.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
@ -651,6 +648,9 @@
|
||||
<ClInclude Include="..\src\mods\mod_reunion_api.h">
|
||||
<Filter>src\mods</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\natives\natives_addons.h">
|
||||
<Filter>src\natives</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\include\cssdk\common\parsemsg.cpp">
|
||||
@ -725,12 +725,12 @@
|
||||
<ClCompile Include="..\src\natives\natives_misc.cpp">
|
||||
<Filter>src\natives</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\natives\natives_vtc.cpp">
|
||||
<Filter>src\natives</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\mods\mod_reunion_api.cpp">
|
||||
<Filter>src\mods</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\natives\natives_addons.cpp">
|
||||
<Filter>src\natives</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi.inc">
|
||||
@ -746,16 +746,19 @@
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_const.inc">
|
||||
<Filter>amxmodx\scripting\include</Filter>
|
||||
</None>
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_engine.inc">
|
||||
<Filter>amxmodx\scripting\include</Filter>
|
||||
</None>
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_gamedll.inc">
|
||||
<Filter>amxmodx\scripting\include</Filter>
|
||||
</None>
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_gamedll_const.inc">
|
||||
<Filter>amxmodx\scripting\include</Filter>
|
||||
</None>
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_misc.inc">
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_engine_const.inc">
|
||||
<Filter>amxmodx\scripting\include</Filter>
|
||||
</None>
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_engine.inc">
|
||||
<Filter>amxmodx\scripting\include</Filter>
|
||||
</None>
|
||||
<None Include="..\extra\amxmodx\scripting\include\reapi_addons.inc">
|
||||
<Filter>amxmodx\scripting\include</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
@ -164,7 +164,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
|
||||
RegisterNatives_HookChains();
|
||||
RegisterNatives_Members();
|
||||
RegisterNatives_Misc();
|
||||
RegisterNatives_Vtc();
|
||||
RegisterNatives_Addons();
|
||||
|
||||
return AMXX_OK;
|
||||
}
|
||||
|
@ -55,8 +55,50 @@ AMX_NATIVE_INFO Vtc_Natives[] =
|
||||
{ nullptr, nullptr }
|
||||
};
|
||||
|
||||
void RegisterNatives_Vtc()
|
||||
/*
|
||||
* Get client protocol
|
||||
*
|
||||
* @param index Client index
|
||||
*
|
||||
* native REU_GetProtocol(const index);
|
||||
*/
|
||||
cell AMX_NATIVE_CALL REU_GetProtocol(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_index };
|
||||
|
||||
CHECK_ISPLAYER(params[arg_index]);
|
||||
|
||||
return g_ReunionApi->GetClientProtocol(params[arg_index] - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get client auth type
|
||||
*
|
||||
* @param index Client index
|
||||
*
|
||||
* native REU_GetAuthtype(const index);
|
||||
*/
|
||||
cell AMX_NATIVE_CALL REU_GetAuthtype(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_index };
|
||||
|
||||
CHECK_ISPLAYER(params[arg_index]);
|
||||
|
||||
return g_ReunionApi->GetClientAuthtype(params[arg_index] - 1);
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO Reunion_Natives[] =
|
||||
{
|
||||
{ "REU_GetProtocol", REU_GetProtocol },
|
||||
{ "REU_GetAuthtype", REU_GetAuthtype },
|
||||
|
||||
{ nullptr, nullptr }
|
||||
};
|
||||
|
||||
void RegisterNatives_Addons()
|
||||
{
|
||||
if (api_cfg.hasVTC())
|
||||
g_amxxapi.AddNatives(Vtc_Natives);
|
||||
if (api_cfg.hasReunion())
|
||||
g_amxxapi.AddNatives(Reunion_Natives);
|
||||
}
|
3
reapi/src/natives/natives_addons.h
Normal file
3
reapi/src/natives/natives_addons.h
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
void RegisterNatives_Addons();
|
@ -310,7 +310,7 @@ cell AMX_NATIVE_CALL rg_fire_bullets3(AMX *amx, cell *params)
|
||||
args[arg_bullet_type],
|
||||
args[arg_dmg],
|
||||
args[arg_range_mod],
|
||||
pAttacker,
|
||||
pAttacker, // icc fix
|
||||
args[arg_pistol],
|
||||
args[arg_rand]
|
||||
);
|
||||
@ -428,7 +428,7 @@ cell AMX_NATIVE_CALL rg_create_entity(AMX *amx, cell *params)
|
||||
string_t iClass = g_engfuncs.pfnAllocString(getAmxString(amx, params[arg_classname]));
|
||||
edict_t *pEnt = g_ReGameFuncs->CREATE_NAMED_ENTITY2(iClass);
|
||||
|
||||
if (!FNullEnt(pEnt))
|
||||
if (pEnt != nullptr)
|
||||
{
|
||||
return ENTINDEX(pEnt);
|
||||
}
|
||||
@ -452,10 +452,9 @@ cell AMX_NATIVE_CALL rg_find_ent_by_class(AMX *amx, cell *params)
|
||||
|
||||
CBaseEntity *pStartEntity = getPrivate<CBaseEntity>(params[arg_start_index]);
|
||||
const char* value = getAmxString(amx, params[arg_classname]);
|
||||
|
||||
CBaseEntity *pEntity = g_ReGameFuncs->UTIL_FindEntityByString(pStartEntity, "classname", value);
|
||||
|
||||
if (pEntity != nullptr && !FNullEnt(pEntity->edict()))
|
||||
if (pEntity != nullptr)
|
||||
{
|
||||
return indexOfEdict(pEntity->pev);
|
||||
}
|
||||
@ -479,16 +478,14 @@ cell AMX_NATIVE_CALL rg_find_ent_by_owner(AMX *amx, cell *params)
|
||||
|
||||
CHECK_ISENTITY(params[arg_onwer]);
|
||||
|
||||
CBaseEntity *pEntity = getPrivate<CBaseEntity>(params[arg_start_index]);
|
||||
const char* value = getAmxString(amx, params[arg_classname]);
|
||||
|
||||
edict_t *pOwner = edictByIndex(params[arg_onwer]);
|
||||
while ((pEntity = g_ReGameFuncs->UTIL_FindEntityByString(pEntity, "classname", value)) != nullptr)
|
||||
edict_t *pEntity = g_pEdicts;
|
||||
|
||||
for (int i = 0; i < gpGlobals->maxEntities; i++, pEntity++)
|
||||
{
|
||||
if (pEntity != nullptr && !FNullEnt(pEntity->edict()) && pEntity->pev->owner == pOwner)
|
||||
{
|
||||
return indexOfEdict(pEntity->pev);
|
||||
}
|
||||
if (pEntity->v.owner == pOwner && !strcmp(STRING(pEntity->v.classname), value))
|
||||
return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -602,9 +599,8 @@ cell AMX_NATIVE_CALL rg_remove_item(AMX *amx, cell *params)
|
||||
}
|
||||
|
||||
const char* szItemName = getAmxString(amx, params[arg_item_name]);
|
||||
for (auto& item : pPlayer->m_rgpPlayerItems)
|
||||
for (auto pItem : pPlayer->m_rgpPlayerItems)
|
||||
{
|
||||
CBasePlayerItem *pItem = item;
|
||||
while (pItem != nullptr)
|
||||
{
|
||||
if (FClassnameIs(pItem->pev, szItemName))
|
||||
@ -655,94 +651,8 @@ AMX_NATIVE_INFO Misc_Natives_RG[] =
|
||||
{ nullptr, nullptr }
|
||||
};
|
||||
|
||||
enum client_auth
|
||||
{
|
||||
/**
|
||||
* Description: -
|
||||
* Return type: int
|
||||
* Params: get_client_data(const index, CA_PROTOCOL)
|
||||
*/
|
||||
CA_PROTOCOL,
|
||||
|
||||
/**
|
||||
* Description: -
|
||||
* Return type: client_auth_type
|
||||
* Params: get_client_data(const index, CA_TYPE)
|
||||
*/
|
||||
CA_TYPE,
|
||||
|
||||
/**
|
||||
* Description: -
|
||||
* Return type: -
|
||||
* Params: get_client_data(const index, CA_STRING, output[], maxlength)
|
||||
*/
|
||||
CA_STRING,
|
||||
};
|
||||
|
||||
/*
|
||||
* Get out information of the client
|
||||
*
|
||||
* @param index Client index
|
||||
* @type to look enum client_auth
|
||||
*
|
||||
* native get_client_data(const index, client_auth:type, any:...);
|
||||
*/
|
||||
cell AMX_NATIVE_CALL get_client_data(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_index, arg_type, arg_3, arg_4 };
|
||||
|
||||
CHECK_ISPLAYER(params[arg_index]);
|
||||
|
||||
client_auth type = static_cast<client_auth>(params[arg_type]);
|
||||
switch (type)
|
||||
{
|
||||
case CA_PROTOCOL:
|
||||
{
|
||||
// native get_client_data(id, CA_PROTOCOL);
|
||||
return g_ReunionApi->GetClientProtocol(params[arg_index] - 1);
|
||||
}
|
||||
case CA_TYPE:
|
||||
{
|
||||
// native client_auth_type:get_client_data(id, CA_TYPE);
|
||||
return g_ReunionApi->GetClientAuthtype(params[arg_index] - 1);
|
||||
}
|
||||
case CA_STRING:
|
||||
{
|
||||
if (PARAMS_COUNT != arg_4) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "get_client_data: bad parameter count, got %i, expected %i", PARAMS_COUNT, arg_4);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// native get_client_data(id, CA_STRING, output[], maxlength);
|
||||
cell* dest = getAmxAddr(amx, params[arg_3]);
|
||||
size_t length = *getAmxAddr(amx, params[arg_4]);
|
||||
|
||||
char data[128];
|
||||
g_ReunionApi->GetClientAuthdataString(params[arg_index] - 1, data, sizeof data);
|
||||
setAmxString(dest, data, length);
|
||||
|
||||
return 1;
|
||||
}
|
||||
default:
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "get_client_data: unknown type statement %i, params count %i", type, PARAMS_COUNT);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO Misc_Natives_Reunion[] =
|
||||
{
|
||||
{ "get_client_data", get_client_data },
|
||||
|
||||
{ nullptr, nullptr }
|
||||
};
|
||||
|
||||
void RegisterNatives_Misc()
|
||||
{
|
||||
if (api_cfg.hasReGameDLL())
|
||||
g_amxxapi.AddNatives(Misc_Natives_RG);
|
||||
|
||||
if (api_cfg.hasReunion())
|
||||
g_amxxapi.AddNatives(Misc_Natives_Reunion);
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
void RegisterNatives_Vtc();
|
@ -48,7 +48,7 @@
|
||||
#include "natives_hookchains.h"
|
||||
#include "natives_members.h"
|
||||
#include "natives_misc.h"
|
||||
#include "natives_vtc.h"
|
||||
#include "natives_addons.h"
|
||||
#include "natives_helper.h"
|
||||
|
||||
#undef DLLEXPORT
|
||||
|
Loading…
x
Reference in New Issue
Block a user