amxmodx/dlls/hamsandwich/amxx_api.cpp
Steve Dudenhoeffer b1a086ee93 Added {get,set}_pdata_cbase{_safe} - compliments Fakemeta's get_pdata functions, but this will set/get an offset that is a CBaseEntity.
Split constants from hamsandwich.inc into ham_const.inc.

Finished commenting native calls, need to finish the constant comments.
2007-05-13 13:59:54 +00:00

85 lines
1.7 KiB
C++

#include <extdll.h>
#include "sdk/amxxmodule.h"
#include "NEW_Util.h"
#include "CVector.h"
#include "forward.h"
#include "hook.h"
#include "ham_const.h"
#include "hooklist.h"
#include "offsets.h"
#include <assert.h>
edict_t *NEW_FirstEdict;
bool NEW_Initialized;
extern CVector<Hook*> hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL];
extern AMX_NATIVE_INFO RegisterNatives[];
extern AMX_NATIVE_INFO ReturnNatives[];
extern AMX_NATIVE_INFO pdata_natives[];
extern AMX_NATIVE_INFO pdata_natives_safe[];
extern hook_t hooklist[];
int ReadConfig(void);
void OnAmxxAttach(void)
{
// Assert that the enum is aligned properly with the table
assert(strcmp(hooklist[Ham_NS_UpdateOnRemove].name, "ns_updateonremove")==0);
MF_AddNatives(pdata_natives_safe);
if (ReadConfig() > 0)
{
if (Offsets.IsValid())
{
MF_AddNatives(RegisterNatives);
MF_AddNatives(ReturnNatives);
MF_AddNatives(pdata_natives);
}
else
{
#ifdef _WIN32
MF_Log("Error: pev and base not set for section \"%s windows\", cannot register natives.", MF_GetModname());
#elif defined __linux__
MF_Log("Error: pev and base not set for section \"%s linux\", cannot register natives.", MF_GetModname());
#endif
}
}
else
{
MF_Log("Error: Cannot read config file, natives not registered!");
}
}
void HamCommand(void);
void OnPluginsUnloaded(void)
{
CVector <Hook *>::iterator end;
for (int i = 0; i < HAM_LAST_ENTRY_DONT_USE_ME_LOL; i++)
{
end=hooks[i].end();
for (CVector<Hook*>::iterator j=hooks[i].begin();
j!=end;
++j)
{
delete (*j);
}
hooks[i].clear();
}
}
void OnPluginsLoaded(void)
{
NEW_Initialize(INDEXENT(0));
}
void OnMetaAttach(void)
{
REG_SVR_COMMAND("ham", HamCommand);
}