Skip to content

Commit

Permalink
release 1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jobmail committed Aug 9, 2024
1 parent a28de1d commit 3e5bb41
Show file tree
Hide file tree
Showing 22 changed files with 1,253 additions and 1,149 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ INCLUDE = -I. -I$(CSSDK)/common -I$(CSSDK)/dlls -I$(CSSDK)/engine \
BIN_DIR = Release
CFLAGS = $(OPT_FLAGS) -Wno-unused-result

CFLAGS += -m32 -fvisibility=hidden -std=c++17 -D_GLIBCXX_USE_CXX11_ABI=0
CFLAGS += -m32 -fvisibility=hidden -std=c++17 -D_GLIBCXX_USE_CXX11_ABI=0 -DWITHOUT_SQL
#-Wl,--as-needed
#-D_GLIBCXX_USE_CXX11_ABI=0
#-Wl,--as-needed
Expand Down
Binary file modified Release/refsapi_amxx_i386.so
Binary file not shown.
211 changes: 94 additions & 117 deletions amxxmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,121 +16,118 @@

// Module info
static amxx_module_info_s g_ModuleInfo =
{
Plugin_info.name,
Plugin_info.author,
Plugin_info.version,
FALSE,
Plugin_info.logtag,
"refsapi",
"refsapi"
};
{
Plugin_info.name,
Plugin_info.author,
Plugin_info.version,
FALSE,
Plugin_info.logtag,
"refsapi",
"refsapi"};

// Storage for the requested functions
amxxapi_t g_amxxapi;

static struct funcreq_t
{
const char * name;
const char *name;
size_t offset;
} g_funcrequests[] =
{
DECLARE_REQ(AddNatives),
//DECLARE_REQ(AddNewNatives),
//DECLARE_REQ(BuildPathname),
//DECLARE_REQ(BuildPathnameR),
DECLARE_REQ(GetAmxAddr),
//DECLARE_REQ(GetAmxVectorNull), // AMXX 1.8.3-dev
//DECLARE_REQ(PrintSrvConsole),
DECLARE_REQ(GetModname),
DECLARE_REQ(GetAmxScriptName),
//DECLARE_REQ(GetAmxScript),
DECLARE_REQ(FindAmxScriptByAmx),
//DECLARE_REQ(FindAmxScriptByName),
DECLARE_REQ(SetAmxString),
DECLARE_REQ(SetAmxStringUTF8Char), // AMXX 1.8.3-dev
DECLARE_REQ(SetAmxStringUTF8Cell), // AMXX 1.8.3-dev
DECLARE_REQ(GetAmxString),
//DECLARE_REQ(GetAmxStringNull), // AMXX 1.8.3-dev
//DECLARE_REQ(GetAmxStringLen),
DECLARE_REQ(FormatAmxString),
//DECLARE_REQ(CopyAmxMemory),
DECLARE_REQ(Log),
DECLARE_REQ(LogError),
//DECLARE_REQ(RaiseAmxError),
DECLARE_REQ(RegisterForward),
DECLARE_REQ(ExecuteForward),
DECLARE_REQ(PrepareCellArray),
DECLARE_REQ(PrepareCharArray),
DECLARE_REQ(PrepareCellArrayA),
DECLARE_REQ(PrepareCharArrayA),
//DECLARE_REQ(IsPlayerValid),
//DECLARE_REQ(GetPlayerName),
//DECLARE_REQ(GetPlayerIP),
//DECLARE_REQ(IsPlayerInGame),
//DECLARE_REQ(IsPlayerBot),
//DECLARE_REQ(IsPlayerAuthorized),
//DECLARE_REQ(GetPlayerTime),
//DECLARE_REQ(GetPlayerPlayTime),
//DECLARE_REQ(GetPlayerCurweapon),
//DECLARE_REQ(GetPlayerTeam),
//DECLARE_REQ(GetPlayerTeamID),
//DECLARE_REQ(GetPlayerDeaths),
//DECLARE_REQ(GetPlayerMenu),
//DECLARE_REQ(GetPlayerKeys),
//DECLARE_REQ(IsPlayerAlive),
//DECLARE_REQ(GetPlayerFrags),
//DECLARE_REQ(IsPlayerConnecting),
//DECLARE_REQ(IsPlayerHLTV),
//DECLARE_REQ(GetPlayerArmor),
//DECLARE_REQ(GetPlayerHealth),
//DECLARE_REQ(amx_Exec),
//DECLARE_REQ(amx_Execv),
//DECLARE_REQ(amx_Allot),
DECLARE_REQ(amx_FindPublic),
//DECLARE_REQ(LoadAmxScript),
//DECLARE_REQ(UnloadAmxScript),
//DECLARE_REQ(RealToCell),
//DECLARE_REQ(CellToReal),
DECLARE_REQ(RegisterSPForward),
DECLARE_REQ(RegisterSPForwardByName),
DECLARE_REQ(UnregisterSPForward),
//DECLARE_REQ(MergeDefinitionFile),
//DECLARE_REQ(amx_FindNative),
//DECLARE_REQ(GetPlayerFlags),
//DECLARE_REQ(GetPlayerEdict),
//DECLARE_REQ(Format),
//DECLARE_REQ(RegisterFunction),
//DECLARE_REQ(RequestFunction),
//DECLARE_REQ(amx_Push),
DECLARE_REQ(SetPlayerTeamInfo),
//DECLARE_REQ(PlayerPropAddr),
//DECLARE_REQ(RegAuthFunc),
//DECLARE_REQ(UnregAuthFunc),
//DECLARE_REQ(FindLibrary),
//DECLARE_REQ(AddLibraries),
//DECLARE_REQ(RemoveLibraries),
//DECLARE_REQ(OverrideNatives),
//DECLARE_REQ(GetLocalInfo),
//DECLARE_REQ(AmxReregister),
//DECLARE_REQ(RegisterFunctionEx),
//DECLARE_REQ(MessageBlock),
{
DECLARE_REQ(AddNatives),
// DECLARE_REQ(AddNewNatives),
// DECLARE_REQ(BuildPathname),
// DECLARE_REQ(BuildPathnameR),
DECLARE_REQ(GetAmxAddr),
// DECLARE_REQ(GetAmxVectorNull), // AMXX 1.8.3-dev
// DECLARE_REQ(PrintSrvConsole),
DECLARE_REQ(GetModname),
DECLARE_REQ(GetAmxScriptName),
// DECLARE_REQ(GetAmxScript),
DECLARE_REQ(FindAmxScriptByAmx),
// DECLARE_REQ(FindAmxScriptByName),
DECLARE_REQ(SetAmxString),
DECLARE_REQ(SetAmxStringUTF8Char), // AMXX 1.8.3-dev
DECLARE_REQ(SetAmxStringUTF8Cell), // AMXX 1.8.3-dev
DECLARE_REQ(GetAmxString),
// DECLARE_REQ(GetAmxStringNull), // AMXX 1.8.3-dev
// DECLARE_REQ(GetAmxStringLen),
DECLARE_REQ(FormatAmxString),
// DECLARE_REQ(CopyAmxMemory),
DECLARE_REQ(Log),
DECLARE_REQ(LogError),
// DECLARE_REQ(RaiseAmxError),
DECLARE_REQ(RegisterForward),
DECLARE_REQ(ExecuteForward),
DECLARE_REQ(PrepareCellArray),
DECLARE_REQ(PrepareCharArray),
DECLARE_REQ(PrepareCellArrayA),
DECLARE_REQ(PrepareCharArrayA),
// DECLARE_REQ(IsPlayerValid),
// DECLARE_REQ(GetPlayerName),
// DECLARE_REQ(GetPlayerIP),
// DECLARE_REQ(IsPlayerInGame),
// DECLARE_REQ(IsPlayerBot),
// DECLARE_REQ(IsPlayerAuthorized),
// DECLARE_REQ(GetPlayerTime),
// DECLARE_REQ(GetPlayerPlayTime),
// DECLARE_REQ(GetPlayerCurweapon),
// DECLARE_REQ(GetPlayerTeam),
// DECLARE_REQ(GetPlayerTeamID),
// DECLARE_REQ(GetPlayerDeaths),
// DECLARE_REQ(GetPlayerMenu),
// DECLARE_REQ(GetPlayerKeys),
// DECLARE_REQ(IsPlayerAlive),
// DECLARE_REQ(GetPlayerFrags),
// DECLARE_REQ(IsPlayerConnecting),
// DECLARE_REQ(IsPlayerHLTV),
// DECLARE_REQ(GetPlayerArmor),
// DECLARE_REQ(GetPlayerHealth),
// DECLARE_REQ(amx_Exec),
// DECLARE_REQ(amx_Execv),
// DECLARE_REQ(amx_Allot),
DECLARE_REQ(amx_FindPublic),
// DECLARE_REQ(LoadAmxScript),
// DECLARE_REQ(UnloadAmxScript),
// DECLARE_REQ(RealToCell),
// DECLARE_REQ(CellToReal),
DECLARE_REQ(RegisterSPForward),
DECLARE_REQ(RegisterSPForwardByName),
DECLARE_REQ(UnregisterSPForward),
// DECLARE_REQ(MergeDefinitionFile),
// DECLARE_REQ(amx_FindNative),
// DECLARE_REQ(GetPlayerFlags),
// DECLARE_REQ(GetPlayerEdict),
// DECLARE_REQ(Format),
// DECLARE_REQ(RegisterFunction),
// DECLARE_REQ(RequestFunction),
// DECLARE_REQ(amx_Push),
DECLARE_REQ(SetPlayerTeamInfo),
// DECLARE_REQ(PlayerPropAddr),
// DECLARE_REQ(RegAuthFunc),
// DECLARE_REQ(UnregAuthFunc),
// DECLARE_REQ(FindLibrary),
// DECLARE_REQ(AddLibraries),
// DECLARE_REQ(RemoveLibraries),
// DECLARE_REQ(OverrideNatives),
// DECLARE_REQ(GetLocalInfo),
// DECLARE_REQ(AmxReregister),
// DECLARE_REQ(RegisterFunctionEx),
// DECLARE_REQ(MessageBlock),
};

C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
{
// check parameters
if (!interfaceVersion || !moduleInfo)
return AMXX_PARAM;

// check interface version
if (*interfaceVersion != AMXX_INTERFACE_VERSION)
{
// Tell amxx core our interface version
*interfaceVersion = AMXX_INTERFACE_VERSION;
return AMXX_IFVERS;
}

// copy module info
memcpy(moduleInfo, &g_ModuleInfo, sizeof(amxx_module_info_s));
return AMXX_OK;
Expand All @@ -146,26 +143,17 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
// Check pointer
if (!reqFnptrFunc)
return AMXX_PARAM;

for (size_t i = 0; i < ARRAYSIZE(g_funcrequests); i++)
{
void* fptr = reqFnptrFunc(g_funcrequests[i].name);
void *fptr = reqFnptrFunc(g_funcrequests[i].name);
if (fptr == NULL)
{
return AMXX_FUNC_NOT_PRESENT;
}
*(void **)((unsigned long)&g_amxxapi + g_funcrequests[i].offset) = fptr;
}

OnAmxxAttach();

RegisterNatives_Misc();

//RegisterNatives_HookChains();
//RegisterNatives_Members();
//RegisterNatives_Misc();
//RegisterNatives_Common();

return AMXX_OK;
}

Expand All @@ -176,11 +164,6 @@ C_DLLEXPORT int AMXX_Detach()

C_DLLEXPORT int AMXX_PluginsLoaded()
{
//int iFwd = g_amxxapi.RegisterForward("__reapi_version_check", ET_IGNORE, FP_CELL, FP_CELL, FP_DONE);
//g_amxxapi.ExecuteForward(iFwd, REAPI_VERSION_MAJOR, REAPI_VERSION_MINOR);

//g_amxxapi.OverrideNatives();

return AMXX_OK;
}

Expand All @@ -199,7 +182,6 @@ NOINLINE void AMXX_Log(const char *fmt, ...)
va_start(arglst, fmt);
vsnprintf(msg, sizeof msg, fmt, arglst);
va_end(arglst);

g_amxxapi.Log("[%s] %s", g_ModuleInfo.logtag, msg);
}

Expand All @@ -210,28 +192,23 @@ NOINLINE void AMXX_LogError(AMX *amx, int err, const char *fmt, ...)
va_start(arglst, fmt);
vsnprintf(msg, sizeof msg, fmt, arglst);
va_end(arglst);

g_amxxapi.LogError(amx, err, "[%s] %s", g_ModuleInfo.logtag, msg);
}

char* getAmxString(cell* src, char* dest, size_t max, size_t* len)
char *getAmxString(cell *src, char *dest, size_t max, size_t *len)
{
char* start = dest;

char *start = dest;
while (*src && --max)
*dest++ = (char)*src++;
*dest = '\0';

if (len)
*len = dest - start;

return start;
}

void setAmxString(cell* dest, const char* string, size_t max)
void setAmxString(cell *dest, const char *string, size_t max)
{
while (*string && max--)
*dest++ = (cell)*string++;

*dest = 0;
}
25 changes: 16 additions & 9 deletions api_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,32 @@

CAPI_Config api_cfg;

CAPI_Config::CAPI_Config() : m_api_rehlds(false), m_api_regame(false) {
CAPI_Config::CAPI_Config() : m_api_rehlds(false), m_api_regame(false)
{
}

void CAPI_Config::FailedReGameDllAPI() {
void CAPI_Config::FailedReGameDllAPI()
{
m_api_regame = false;
}

void CAPI_Config::Init() {
void CAPI_Config::Init()
{
m_api_rehlds = RehldsApi_Init();
m_api_regame = RegamedllApi_Init();
if (m_api_rehlds) {
if (m_api_rehlds)
{
g_engfuncs.pfnServerPrint("[REFSAPI] ReHLDS API successfully initialized.\n");
g_RehldsHookchains->Cvar_DirectSet()->registerHook(Cvar_DirectSet_RH);
}
if (m_api_regame) {
}
if (m_api_regame)
{
g_engfuncs.pfnServerPrint("[REFSAPI] ReGAME API successfully initialized.\n");
g_ReGameHookchains->InstallGameRules()->registerHook(&InstallGameRules);
}
cvar_t* pCvar = CVAR_GET_POINTER(REFSAPI_CVAR);
if (pCvar == nullptr) {
cvar_t *pCvar = CVAR_GET_POINTER(REFSAPI_CVAR);
if (pCvar == nullptr)
{
cvar_t cvar;
cvar.name = REFSAPI_CVAR;
cvar.flags = (FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED);
Expand All @@ -33,7 +39,8 @@ void CAPI_Config::Init() {
}
}

void CAPI_Config::ServerDeactivate() const {
void CAPI_Config::ServerDeactivate() const
{
if (m_api_regame)
g_pGameRules = nullptr;
}
Loading

0 comments on commit 3e5bb41

Please sign in to comment.