Replaced with faluco's cleaned-up version of meta_api.cpp
This commit is contained in:
parent
afa1337e62
commit
7ce59966fc
|
@ -38,7 +38,8 @@
|
|||
#include "newmenus.h"
|
||||
#include "natives.h"
|
||||
|
||||
plugin_info_t Plugin_info = {
|
||||
plugin_info_t Plugin_info =
|
||||
{
|
||||
META_INTERFACE_VERSION, // ifvers
|
||||
"AMX Mod X", // name
|
||||
AMX_VERSION, // version
|
||||
|
@ -144,30 +145,40 @@ CFakeMeta g_FakeMeta;
|
|||
|
||||
// Precache stuff from force consistency calls
|
||||
// or check for pointed files won't be done
|
||||
int C_PrecacheModel(char *s) {
|
||||
if ( !g_forcedmodules ){
|
||||
int C_PrecacheModel(char *s)
|
||||
{
|
||||
if (!g_forcedmodules)
|
||||
{
|
||||
g_forcedmodules = true;
|
||||
for(CList<ForceObject>::iterator a = g_forcemodels.begin(); a ; ++a){
|
||||
for (CList<ForceObject>::iterator a = g_forcemodels.begin(); a; ++a)
|
||||
{
|
||||
PRECACHE_MODEL((char*)(*a).getFilename());
|
||||
ENGINE_FORCE_UNMODIFIED((*a).getForceType(), (*a).getMin(), (*a).getMax(), (*a).getFilename());
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_META_VALUE(MRES_IGNORED, 0);
|
||||
}
|
||||
|
||||
int C_PrecacheSound(char *s) {
|
||||
if ( !g_forcedsounds ) {
|
||||
int C_PrecacheSound(char *s)
|
||||
{
|
||||
if (!g_forcedsounds)
|
||||
{
|
||||
g_forcedsounds = true;
|
||||
for(CList<ForceObject>::iterator a = g_forcesounds.begin(); a ; ++a){
|
||||
for (CList<ForceObject>::iterator a = g_forcesounds.begin(); a; ++a)
|
||||
{
|
||||
PRECACHE_SOUND((char*)(*a).getFilename());
|
||||
ENGINE_FORCE_UNMODIFIED((*a).getForceType(),(*a).getMin(),(*a).getMax(),(*a).getFilename());
|
||||
}
|
||||
if (!g_bmod_cstrike){
|
||||
|
||||
if (!g_bmod_cstrike)
|
||||
{
|
||||
PRECACHE_SOUND("weapons/cbar_hitbod1.wav");
|
||||
PRECACHE_SOUND("weapons/cbar_hitbod2.wav");
|
||||
PRECACHE_SOUND("weapons/cbar_hitbod3.wav");
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_META_VALUE(MRES_IGNORED, 0);
|
||||
}
|
||||
|
||||
|
@ -183,6 +194,7 @@ int C_InconsistentFile( const edict_t *player, const char *filename, char *disco
|
|||
|
||||
if (executeForwards(FF_InconsistentFile, pPlayer->index, filename, disconnect_message) == 1)
|
||||
RETURN_META_VALUE(MRES_SUPERCEDE, FALSE);
|
||||
|
||||
RETURN_META_VALUE(MRES_SUPERCEDE, TRUE);
|
||||
}
|
||||
|
||||
|
@ -192,8 +204,10 @@ int C_InconsistentFile( const edict_t *player, const char *filename, char *disco
|
|||
const char* get_localinfo(const char* name, const char* def)
|
||||
{
|
||||
const char* b = LOCALINFO((char*)name);
|
||||
|
||||
if (b == 0 || *b == 0)
|
||||
SET_LOCALINFO((char*)name,(char*)(b = def));
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
|
@ -227,6 +241,7 @@ int C_Spawn( edict_t *pent )
|
|||
char file[256];
|
||||
g_langMngr.LoadCache(build_pathname_r(file, sizeof(file)-1, "%s/dictionary.cache", get_localinfo("amxx_datadir", "addons/amxmodx/data")));
|
||||
g_langMngr.Load(build_pathname_r(file, sizeof(file)-1, "%s/languages.dat", get_localinfo("amxmodx_datadir", "addons/amxmodx/data")));
|
||||
|
||||
// ###### Initialize commands prefixes
|
||||
g_commands.registerPrefix("amx");
|
||||
g_commands.registerPrefix("amxx");
|
||||
|
@ -254,6 +269,7 @@ int C_Spawn( edict_t *pent )
|
|||
// ###### Load Vault
|
||||
g_vault.setSource(build_pathname_r(file, sizeof(file)-1, "%s", get_localinfo("amxx_vault", "addons/amxmodx/configs/vault.ini")));
|
||||
g_vault.loadVault();
|
||||
|
||||
if (strlen(g_vault.get("server_language")) < 1)
|
||||
{
|
||||
g_vault.put("server_language", "en");
|
||||
|
@ -264,6 +280,7 @@ int C_Spawn( edict_t *pent )
|
|||
g_game_timeleft = g_bmod_dod ? 1.0f : 0.0f;
|
||||
g_task_time = gpGlobals->time + 99999.0f;
|
||||
g_auth_time = gpGlobals->time + 99999.0f;
|
||||
|
||||
#ifdef MEMORY_TEST
|
||||
g_next_memreport_time = gpGlobals->time + 99999.0f;
|
||||
#endif
|
||||
|
@ -299,7 +316,8 @@ int C_Spawn( edict_t *pent )
|
|||
executeForwards(FF_PluginPrecache);
|
||||
g_dontprecache = true;
|
||||
|
||||
for(CList<ForceObject>::iterator a = g_forcegeneric.begin(); a ; ++a){
|
||||
for (CList<ForceObject>::iterator a = g_forcegeneric.begin(); a; ++a)
|
||||
{
|
||||
PRECACHE_GENERIC((char*)(*a).getFilename());
|
||||
ENGINE_FORCE_UNMODIFIED((*a).getForceType(),
|
||||
(*a).getMin(),(*a).getMax(),(*a).getFilename());
|
||||
|
@ -308,13 +326,15 @@ int C_Spawn( edict_t *pent )
|
|||
RETURN_META_VALUE(MRES_IGNORED, 0);
|
||||
}
|
||||
|
||||
struct sUserMsg {
|
||||
struct sUserMsg
|
||||
{
|
||||
const char* name;
|
||||
int* id;
|
||||
funEventCall func;
|
||||
bool endmsg;
|
||||
bool cstrike;
|
||||
} g_user_msg[] = {
|
||||
} g_user_msg[] =
|
||||
{
|
||||
{"CurWeapon", &gmsgCurWeapon, Client_CurWeapon, false, false},
|
||||
{"Damage", &gmsgDamage, Client_DamageEnd, true, true},
|
||||
{"DeathMsg", &gmsgDeathMsg, Client_DeathMsg, false, true},
|
||||
|
@ -337,7 +357,6 @@ struct sUserMsg {
|
|||
{0, 0, 0, false, false}
|
||||
};
|
||||
|
||||
|
||||
int C_RegUserMsg_Post(const char *pszName, int iSize)
|
||||
{
|
||||
for (int i = 0; g_user_msg[i].name; ++i)
|
||||
|
@ -345,7 +364,6 @@ int C_RegUserMsg_Post(const char *pszName, int iSize)
|
|||
if (strcmp(g_user_msg[i].name, pszName) == 0)
|
||||
{
|
||||
int id = META_RESULT_ORIG_RET(int);
|
||||
|
||||
*g_user_msg[i].id = id;
|
||||
|
||||
if (!g_user_msg[i].cstrike || g_bmod_cstrike)
|
||||
|
@ -355,7 +373,6 @@ int C_RegUserMsg_Post(const char *pszName, int iSize)
|
|||
else
|
||||
modMsgs[id] = g_user_msg[i].func;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -371,10 +388,10 @@ plugin_init forward function from plugins
|
|||
void C_ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
|
||||
{
|
||||
int id;
|
||||
|
||||
for (int i = 0; g_user_msg[i].name; ++i)
|
||||
{
|
||||
if ( (*g_user_msg[ i ].id == 0) &&
|
||||
(id = GET_USER_MSG_ID(PLID, g_user_msg[ i ].name , NULL ))!=0)
|
||||
if ((*g_user_msg[i].id == 0) && (id = GET_USER_MSG_ID(PLID, g_user_msg[i].name, NULL)) != 0)
|
||||
{
|
||||
*g_user_msg[i].id = id;
|
||||
|
||||
|
@ -396,7 +413,8 @@ void C_ServerActivate_Post( edict_t *pEdictList, int edictCount, int clientMax )
|
|||
if (g_activated)
|
||||
RETURN_META(MRES_IGNORED);
|
||||
|
||||
for(int i = 1; i <= gpGlobals->maxClients; ++i) {
|
||||
for (int i= 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
|
||||
pPlayer->Init(pEdictList + i, i);
|
||||
}
|
||||
|
@ -410,7 +428,8 @@ void C_ServerActivate_Post( edict_t *pEdictList, int edictCount, int clientMax )
|
|||
g_langMngr.SaveCache(build_pathname_r(file, sizeof(file)-1, "%s/dictionary.cache", get_localinfo("amxx_datadir", "addons/amxmodx/data")));
|
||||
|
||||
// Correct time in Counter-Strike and other mods (except DOD)
|
||||
if ( !g_bmod_dod) g_game_timeleft = 0;
|
||||
if (!g_bmod_dod)
|
||||
g_game_timeleft = 0;
|
||||
|
||||
g_task_time = gpGlobals->time;
|
||||
g_auth_time = gpGlobals->time;
|
||||
|
@ -431,13 +450,15 @@ void C_ServerDeactivate()
|
|||
{
|
||||
if (!g_activated)
|
||||
RETURN_META(MRES_IGNORED);
|
||||
for(int i = 1; i <= gpGlobals->maxClients; ++i){
|
||||
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
|
||||
if (pPlayer->initialized)
|
||||
executeForwards(FF_ClientDisconnect, pPlayer->index);
|
||||
|
||||
if (pPlayer->ingame){
|
||||
|
||||
if (pPlayer->ingame)
|
||||
{
|
||||
pPlayer->Disconnect();
|
||||
--g_players_num;
|
||||
}
|
||||
|
@ -455,6 +476,7 @@ void C_ServerDeactivate_Post()
|
|||
{
|
||||
if (!g_initialized)
|
||||
RETURN_META(MRES_IGNORED);
|
||||
|
||||
detachReloadModules();
|
||||
g_auth.clear();
|
||||
g_commands.clear();
|
||||
|
@ -510,9 +532,7 @@ void C_ServerDeactivate_Post()
|
|||
// good
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// bad
|
||||
g_memreport_enabled = false;
|
||||
AMXXLOG_Log("[AMXX] Fatal error: Can't create directory for memreport files (%s)", buffer);
|
||||
|
@ -531,29 +551,29 @@ void C_ServerDeactivate_Post()
|
|||
#endif // MEMORY_TEST
|
||||
|
||||
g_initialized = false;
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
BOOL C_ClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128])
|
||||
{
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER(pEntity);
|
||||
if (!pPlayer->bot) {
|
||||
|
||||
if (!pPlayer->bot)
|
||||
{
|
||||
bool a = pPlayer->Connect(pszName, pszAddress);
|
||||
|
||||
executeForwards(FF_ClientConnect, pPlayer->index);
|
||||
|
||||
if (a)
|
||||
{
|
||||
CPlayer** aa = new CPlayer*(pPlayer);
|
||||
if ( aa ) g_auth.put( aa );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aa)
|
||||
g_auth.put(aa);
|
||||
} else {
|
||||
pPlayer->Authorize();
|
||||
executeForwards(FF_ClientAuthorized, pPlayer->index);
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_META_VALUE(MRES_IGNORED, TRUE);
|
||||
}
|
||||
|
||||
|
@ -563,32 +583,32 @@ void C_ClientDisconnect( edict_t *pEntity )
|
|||
if (pPlayer->initialized)
|
||||
executeForwards(FF_ClientDisconnect, pPlayer->index);
|
||||
|
||||
if (pPlayer->ingame) {
|
||||
if (pPlayer->ingame)
|
||||
{
|
||||
--g_players_num;
|
||||
}
|
||||
pPlayer->Disconnect();
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void C_ClientPutInServer_Post(edict_t *pEntity)
|
||||
{
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
||||
if (!pPlayer->bot) {
|
||||
if (!pPlayer->bot)
|
||||
{
|
||||
pPlayer->PutInServer();
|
||||
++g_players_num;
|
||||
|
||||
executeForwards(FF_ClientPutInServer, pPlayer->index);
|
||||
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void C_ClientUserInfoChanged_Post(edict_t *pEntity, char *infobuffer)
|
||||
{
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
||||
|
||||
executeForwards(FF_ClientInfoChanged, pPlayer->index);
|
||||
|
||||
const char* name = INFOKEY_VALUE(infobuffer,"name");
|
||||
|
||||
// Emulate bot connection and putinserver
|
||||
|
@ -605,7 +625,6 @@ void C_ClientUserInfoChanged_Post( edict_t *pEntity, char *infobuffer )
|
|||
pPlayer->Authorize();
|
||||
executeForwards(FF_ClientAuthorized, pPlayer->index);
|
||||
|
||||
|
||||
pPlayer->PutInServer();
|
||||
++g_players_num;
|
||||
|
||||
|
@ -653,7 +672,6 @@ void C_ClientCommand( edict_t *pEntity )
|
|||
if (executeForwards(FF_ClientCommand, pPlayer->index) > 0)
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
|
||||
|
||||
/* check for command and if needed also for first argument and call proper function */
|
||||
|
||||
CmdMngr::iterator aa = g_commands.clcmdprefixbegin(cmd);
|
||||
|
@ -661,14 +679,12 @@ void C_ClientCommand( edict_t *pEntity )
|
|||
|
||||
while (aa)
|
||||
{
|
||||
if ( (*aa).matchCommandLine( cmd , arg ) &&
|
||||
(*aa).getPlugin()->isExecutable( (*aa).getFunction() ) )
|
||||
if ((*aa).matchCommandLine(cmd, arg) && (*aa).getPlugin()->isExecutable((*aa).getFunction()))
|
||||
{
|
||||
ret = executeForwards((*aa).getFunction(), pPlayer->index, (*aa).getFlags(), (*aa).getId());
|
||||
if (ret & 2) result = MRES_SUPERCEDE;
|
||||
if (ret & 1) RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
|
||||
++aa;
|
||||
}
|
||||
|
||||
|
@ -681,7 +697,6 @@ void C_ClientCommand( edict_t *pEntity )
|
|||
|
||||
if (pPlayer->keys & bit_key)
|
||||
{
|
||||
|
||||
int menuid = pPlayer->menu;
|
||||
pPlayer->menu = 0;
|
||||
|
||||
|
@ -695,35 +710,41 @@ void C_ClientCommand( edict_t *pEntity )
|
|||
{
|
||||
int menu = pPlayer->newmenu;
|
||||
pPlayer->newmenu = -1;
|
||||
|
||||
if (menu >= 0 && menu < (int)g_NewMenus.size())
|
||||
{
|
||||
Menu *pMenu = g_NewMenus[menu];
|
||||
int item = pMenu->PagekeyToItem(pPlayer->page, pressed_key);
|
||||
ret = executeForwards((*a).getFunction(), pPlayer->index, menu, item);
|
||||
|
||||
if (ret & 2) result = MRES_SUPERCEDE;
|
||||
else if (ret & 1) RETURN_META(MRES_SUPERCEDE);
|
||||
else {
|
||||
else
|
||||
{
|
||||
if (item == MENU_BACK)
|
||||
{
|
||||
pMenu->Display(pPlayer->index, pPlayer->page-1);
|
||||
} else if (item == MENU_MORE) {
|
||||
} else if (item == MENU_MORE)
|
||||
{
|
||||
pMenu->Display(pPlayer->index, pPlayer->page+1);
|
||||
} else if (item == MENU_EXIT) {
|
||||
} else if (item == MENU_EXIT)
|
||||
{
|
||||
//nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ret = executeForwards((*a).getFunction(), pPlayer->index, pressed_key, 0);
|
||||
|
||||
if (ret & 2) result = MRES_SUPERCEDE;
|
||||
if (ret & 1) RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
}
|
||||
|
||||
++a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* check for PLUGIN_HANDLED_MAIN and block hl call if needed */
|
||||
RETURN_META(result);
|
||||
}
|
||||
|
@ -733,14 +754,14 @@ void C_StartFrame_Post( void )
|
|||
if (g_auth_time < gpGlobals->time)
|
||||
{
|
||||
g_auth_time = gpGlobals->time + 0.7f;
|
||||
|
||||
CList<CPlayer*>::iterator a = g_auth.begin();
|
||||
|
||||
while (a)
|
||||
{
|
||||
const char* auth = GETPLAYERAUTHID((*a)->pEdict);
|
||||
|
||||
if ( (auth == 0) || (*auth == 0) ) {
|
||||
if ((auth == 0) || (*auth == 0))
|
||||
{
|
||||
a.remove();
|
||||
continue;
|
||||
}
|
||||
|
@ -752,17 +773,15 @@ void C_StartFrame_Post( void )
|
|||
a.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
++a;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifdef MEMORY_TEST
|
||||
if (g_memreport_enabled && g_next_memreport_time <= gpGlobals->time)
|
||||
{
|
||||
g_next_memreport_time = gpGlobals->time + MEMREPORT_INTERVAL;
|
||||
|
||||
if (g_memreport_count == 0)
|
||||
{
|
||||
// make new directory
|
||||
|
@ -792,9 +811,7 @@ void C_StartFrame_Post( void )
|
|||
// good
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// bad
|
||||
g_memreport_enabled = false;
|
||||
AMXXLOG_Log("[AMXX] Fatal error: Can't create directory for memreport files (%s)", buffer);
|
||||
|
@ -819,11 +836,11 @@ void C_StartFrame_Post( void )
|
|||
|
||||
g_tasksMngr.startFrame();
|
||||
|
||||
|
||||
// Dispatch client cvar queries
|
||||
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(i);
|
||||
|
||||
if (pPlayer->pEdict && pPlayer->initialized && !pPlayer->cvarQueryQueue.empty())
|
||||
{
|
||||
if (!IS_QUERYING_CLIENT_CVAR(PLID, pPlayer->pEdict))
|
||||
|
@ -834,7 +851,6 @@ void C_StartFrame_Post( void )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
|
@ -842,7 +858,6 @@ void C_MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict
|
|||
{
|
||||
if (ed)
|
||||
{
|
||||
|
||||
if (gmsgBattery == msg_type && g_bmod_cstrike)
|
||||
{
|
||||
void* ptr = GET_PRIVATE(ed);
|
||||
|
@ -858,12 +873,11 @@ void C_MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict
|
|||
|
||||
mPlayerIndex = ENTINDEX(ed);
|
||||
mPlayer = GET_PLAYER_POINTER_I(mPlayerIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
mPlayerIndex = 0;
|
||||
mPlayer = 0;
|
||||
}
|
||||
|
||||
if (msg_type < 0 || msg_type >= MAX_REG_MSGS)
|
||||
msg_type = 0;
|
||||
|
||||
|
@ -871,72 +885,94 @@ void C_MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict
|
|||
function=modMsgs[msg_type];
|
||||
endfunction=modMsgsEnd[msg_type];
|
||||
g_events.parserInit(msg_type, &gpGlobals->time, mPlayer, mPlayerIndex);
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void C_WriteByte_Post(int iValue)
|
||||
{
|
||||
g_events.parseValue(iValue);
|
||||
if (function) (*function)((void *)&iValue);
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void C_WriteChar_Post(int iValue)
|
||||
{
|
||||
g_events.parseValue(iValue);
|
||||
if (function) (*function)((void *)&iValue);
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void C_WriteShort_Post(int iValue)
|
||||
{
|
||||
g_events.parseValue(iValue);
|
||||
if (function) (*function)((void *)&iValue);
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void C_WriteLong_Post(int iValue)
|
||||
{
|
||||
g_events.parseValue(iValue);
|
||||
if (function) (*function)((void *)&iValue);
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void C_WriteAngle_Post(float flValue)
|
||||
{
|
||||
g_events.parseValue(flValue);
|
||||
if (function) (*function)((void *)&flValue);
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void C_WriteCoord_Post(float flValue)
|
||||
{
|
||||
g_events.parseValue(flValue);
|
||||
if (function) (*function)((void *)&flValue);
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void C_WriteString_Post(const char *sz)
|
||||
{
|
||||
g_events.parseValue(sz);
|
||||
if (function) (*function)((void *)sz);
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void C_WriteEntity_Post(int iValue)
|
||||
{
|
||||
g_events.parseValue(iValue);
|
||||
if (function) (*function)((void *)&iValue);
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void C_MessageEnd_Post(void)
|
||||
{
|
||||
g_events.executeEvents();
|
||||
if (endfunction) (*endfunction)(NULL);
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void C_ChangeLevel(char* s1, char* s2)
|
||||
{
|
||||
if (FF_ChangeLevel) {
|
||||
if (FF_ChangeLevel)
|
||||
{
|
||||
int retVal = 0;
|
||||
char *map = s1;
|
||||
retVal = executeForwards(FF_ChangeLevel, map);
|
||||
|
||||
if (retVal)
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
|
@ -945,6 +981,7 @@ const char *C_Cmd_Args( void )
|
|||
// if the global "fake" flag is set, which means that engclient_cmd was used, supercede the function
|
||||
if (g_fakecmd.fake)
|
||||
RETURN_META_VALUE(MRES_SUPERCEDE, (g_fakecmd.argc > 1) ? g_fakecmd.args : g_fakecmd.argv[0]);
|
||||
|
||||
// otherwise ignore it
|
||||
RETURN_META_VALUE(MRES_IGNORED, NULL);
|
||||
}
|
||||
|
@ -954,6 +991,7 @@ const char *C_Cmd_Argv(int argc)
|
|||
// if the global "fake" flag is set, which means that engclient_cmd was used, supercede the function
|
||||
if (g_fakecmd.fake)
|
||||
RETURN_META_VALUE(MRES_SUPERCEDE, (argc < 3) ? g_fakecmd.argv[argc] : "");
|
||||
|
||||
// otherwise ignore it
|
||||
RETURN_META_VALUE(MRES_IGNORED, NULL);
|
||||
}
|
||||
|
@ -963,6 +1001,7 @@ int C_Cmd_Argc( void )
|
|||
// if the global "fake" flag is set, which means that engclient_cmd was used, supercede the function
|
||||
if (g_fakecmd.fake)
|
||||
RETURN_META_VALUE(MRES_SUPERCEDE, g_fakecmd.argc);
|
||||
|
||||
// otherwise ignore it
|
||||
RETURN_META_VALUE(MRES_IGNORED, 0);
|
||||
}
|
||||
|
@ -973,19 +1012,24 @@ void C_SetModel(edict_t *e, const char *m)
|
|||
{
|
||||
if (e->v.owner && m[7]=='w' && m[8]=='_' && m[9]=='h')
|
||||
g_grenades.put(e, 1.75, 4, GET_PLAYER_POINTER(e->v.owner));
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
// Save at what part of body a player is aiming
|
||||
void C_TraceLine_Post(const float *v1, const float *v2, int fNoMonsters, edict_t *e, TraceResult *ptr)
|
||||
{
|
||||
if ( e && ( e->v.flags & (FL_CLIENT | FL_FAKECLIENT) ) ) {
|
||||
if (e && (e->v.flags & (FL_CLIENT | FL_FAKECLIENT)))
|
||||
{
|
||||
CPlayer* pPlayer = GET_PLAYER_POINTER(e);
|
||||
|
||||
if (ptr->pHit && (ptr->pHit->v.flags & (FL_CLIENT | FL_FAKECLIENT)))
|
||||
pPlayer->aiming = ptr->iHitgroup;
|
||||
|
||||
pPlayer->lastTrace = pPlayer->thisTrace;
|
||||
pPlayer->thisTrace = ptr->vecEndPos;
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
|
@ -1011,9 +1055,12 @@ void C_AlertMessage_Post(ALERT_TYPE atype, char *szFmt, ...)
|
|||
g_logevents.setLogString(szFmt, logArgPtr);
|
||||
va_end (logArgPtr);
|
||||
g_logevents.parseLogString();
|
||||
|
||||
if (g_logevents.logEventsExist())
|
||||
g_logevents.executeLogEvents();
|
||||
|
||||
cell retVal = executeForwards(FF_PluginLog);
|
||||
|
||||
if (retVal)
|
||||
RETURN_META(MRES_HANDLED);
|
||||
}
|
||||
|
@ -1039,12 +1086,14 @@ void C_CvarValue(const edict_t *pEdict, const char *value)
|
|||
else
|
||||
executeForwards(pQuery->resultFwd, ENTINDEX(pEdict), pQuery->cvarName.c_str(), value);
|
||||
|
||||
|
||||
unregisterSPForward(pQuery->resultFwd);
|
||||
|
||||
if (pQuery->params)
|
||||
delete [] pQuery->params;
|
||||
|
||||
delete pQuery;
|
||||
pPlayer->cvarQueryQueue.pop();
|
||||
|
||||
RETURN_META(MRES_HANDLED);
|
||||
}
|
||||
|
||||
|
@ -1057,40 +1106,49 @@ C_DLLEXPORT int Meta_Query(char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_
|
|||
{
|
||||
gpMetaUtilFuncs=pMetaUtilFuncs;
|
||||
*pPlugInfo=&Plugin_info;
|
||||
|
||||
if (strcmp(ifvers, Plugin_info.ifvers))
|
||||
{
|
||||
int mmajor = 0, mminor = 0, pmajor = 0, pminor = 0;
|
||||
|
||||
LOG_MESSAGE(PLID, "WARNING: meta-interface version mismatch; requested=%s ours=%s", Plugin_info.logtag, ifvers);
|
||||
sscanf(ifvers, "%d:%d", &mmajor, &mminor);
|
||||
sscanf(META_INTERFACE_VERSION, "%d:%d", &pmajor, &pminor);
|
||||
|
||||
if (pmajor > mmajor)
|
||||
{
|
||||
LOG_ERROR(PLID, "metamod version is too old for this plugin; update metamod");
|
||||
return (FALSE);
|
||||
} else if(pmajor < mmajor) {
|
||||
} else if (pmajor < mmajor)
|
||||
{
|
||||
LOG_ERROR(PLID, "metamod version is incompatible with this plugin; please find a newer version of this plugin");
|
||||
return (FALSE);
|
||||
} else if (pmajor==mmajor) {
|
||||
} else if (pmajor == mmajor)
|
||||
{
|
||||
#ifdef FAKEMETA
|
||||
if (mminor == 10)
|
||||
{
|
||||
LOG_MESSAGE(PLID, "WARNING: metamod version is older than expected; consider finding a newer version");
|
||||
g_IsNewMM = false;
|
||||
|
||||
//hack!
|
||||
Plugin_info.ifvers = "5:10";
|
||||
#else
|
||||
if (mminor < 11)
|
||||
{
|
||||
g_NeedsP = true;
|
||||
|
||||
#endif
|
||||
} else if (mminor >= 11) {
|
||||
} else if (mminor >= 11)
|
||||
{
|
||||
g_IsNewMM = true;
|
||||
} else if (pminor > mminor) {
|
||||
} else if (pminor > mminor)
|
||||
{
|
||||
LOG_ERROR(PLID, "metamod version is incompatible with this plugin; please find a newer version of this plugin");
|
||||
return FALSE;
|
||||
} else if (pminor < mminor) {
|
||||
} else if (pminor < mminor)
|
||||
{
|
||||
LOG_MESSAGE(PLID, "WARNING: metamod version is newer than expected; consider finding a newer version of this plugin");
|
||||
|
||||
if (mminor > 11)
|
||||
g_IsNewMM = true;
|
||||
}
|
||||
|
@ -1116,7 +1174,9 @@ C_DLLEXPORT int Meta_PExtGiveFnptrs(int interfaceVersion, pextension_funcs_t *pM
|
|||
{
|
||||
return (META_PEXT_VERSION);
|
||||
}
|
||||
|
||||
gpMetaPExtFuncs = pMetaPExtFuncs;
|
||||
|
||||
return (META_PEXT_VERSION);
|
||||
}
|
||||
|
||||
|
@ -1128,17 +1188,20 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
|
|||
LOG_ERROR(PLID, "Can't load plugin right now");
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
if (g_NeedsP && !gpMetaPExtFuncs)
|
||||
{
|
||||
LOG_ERROR(PLID, "You need Metamod-P or Metamod-1.18 to use AMX Mod X 1.1!");
|
||||
LOG_ERROR(PLID, "You need Metamod-P or Metamod-1.18 to use AMX Mod X %s!", AMX_VERSION);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
gpMetaGlobals=pMGlobals;
|
||||
gMetaFunctionTable.pfnGetEntityAPI2 = GetEntityAPI2;
|
||||
gMetaFunctionTable.pfnGetEntityAPI2_Post = GetEntityAPI2_Post;
|
||||
gMetaFunctionTable.pfnGetEngineFunctions = GetEngineFunctions;
|
||||
gMetaFunctionTable.pfnGetEngineFunctions_Post = GetEngineFunctions_Post;
|
||||
gMetaFunctionTable.pfnGetNewDLLFunctions = GetNewDLLFunctions;
|
||||
|
||||
#ifdef FAKEMETA
|
||||
gMetaFunctionTable.pfnGetNewDLLFunctions_Post = GetNewDLLFunctions_Post;
|
||||
#endif
|
||||
|
@ -1158,9 +1221,11 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
|
|||
GET_GAME_DIR(gameDir);
|
||||
char *a = gameDir;
|
||||
int i = 0;
|
||||
|
||||
while (gameDir[i])
|
||||
if (gameDir[i++] == '/')
|
||||
a = &gameDir[i];
|
||||
|
||||
g_mod_name.assign(a);
|
||||
|
||||
if (g_mod_name.compare("cstrike") == 0 ||
|
||||
|
@ -1180,9 +1245,12 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
|
|||
Vault amx_config;
|
||||
amx_config.setSource(build_pathname("%s", get_localinfo("amxx_cfg", "addons/amxmodx/configs/core.ini")));
|
||||
|
||||
if ( amx_config.loadVault() ){
|
||||
if (amx_config.loadVault())
|
||||
{
|
||||
Vault::iterator a = amx_config.begin();
|
||||
while ( a != amx_config.end() ) {
|
||||
|
||||
while (a != amx_config.end())
|
||||
{
|
||||
SET_LOCALINFO((char*)a.key().c_str(), (char*)a.value().c_str());
|
||||
++a;
|
||||
}
|
||||
|
@ -1199,11 +1267,14 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
|
|||
return (TRUE);
|
||||
}
|
||||
|
||||
C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason) {
|
||||
if(now > Plugin_info.unloadable && reason != PNL_CMD_FORCED) {
|
||||
C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
|
||||
{
|
||||
if (now > Plugin_info.unloadable && reason != PNL_CMD_FORCED)
|
||||
{
|
||||
LOG_ERROR(PLID, "Can't unload plugin right now");
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
g_auth.clear();
|
||||
g_forwards.clear();
|
||||
g_commands.clear();
|
||||
|
@ -1238,8 +1309,8 @@ C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason) {
|
|||
|
||||
#ifdef __linux__
|
||||
// linux prototype
|
||||
C_DLLEXPORT void GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals ) {
|
||||
|
||||
C_DLLEXPORT void GiveFnptrsToDll(enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals)
|
||||
{
|
||||
#else
|
||||
#ifdef _MSC_VER
|
||||
// MSVC: Simulate __stdcall calling convention
|
||||
|
@ -1314,7 +1385,8 @@ C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine,
|
|||
}
|
||||
|
||||
DLL_FUNCTIONS gFunctionTable;
|
||||
C_DLLEXPORT int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion ){
|
||||
C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion)
|
||||
{
|
||||
gFunctionTable.pfnSpawn = C_Spawn;
|
||||
gFunctionTable.pfnClientCommand = C_ClientCommand;
|
||||
gFunctionTable.pfnServerDeactivate = C_ServerDeactivate;
|
||||
|
@ -1331,7 +1403,8 @@ C_DLLEXPORT int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVers
|
|||
}
|
||||
|
||||
DLL_FUNCTIONS gFunctionTable_Post;
|
||||
C_DLLEXPORT int GetEntityAPI2_Post( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion ) {
|
||||
C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion)
|
||||
{
|
||||
gFunctionTable_Post.pfnClientPutInServer = C_ClientPutInServer_Post;
|
||||
gFunctionTable_Post.pfnClientUserInfoChanged = C_ClientUserInfoChanged_Post;
|
||||
gFunctionTable_Post.pfnServerActivate = C_ServerActivate_Post;
|
||||
|
@ -1348,20 +1421,17 @@ C_DLLEXPORT int GetEntityAPI2_Post( DLL_FUNCTIONS *pFunctionTable, int *interfac
|
|||
}
|
||||
|
||||
enginefuncs_t meta_engfuncs;
|
||||
C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion ) {
|
||||
|
||||
C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion)
|
||||
{
|
||||
if (stricmp(g_mod_name.c_str(),"cstrike") == 0 || stricmp(g_mod_name.c_str(),"czero") == 0)
|
||||
{
|
||||
meta_engfuncs.pfnSetModel = C_SetModel;
|
||||
g_bmod_cstrike = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
g_bmod_cstrike = false;
|
||||
g_bmod_dod = !stricmp(g_mod_name.c_str(),"dod");
|
||||
}
|
||||
|
||||
|
||||
meta_engfuncs.pfnCmd_Argc = C_Cmd_Argc;
|
||||
meta_engfuncs.pfnCmd_Argv = C_Cmd_Argv;
|
||||
meta_engfuncs.pfnCmd_Args = C_Cmd_Args;
|
||||
|
@ -1378,7 +1448,8 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
|
|||
}
|
||||
|
||||
enginefuncs_t meta_engfuncs_post;
|
||||
C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion ) {
|
||||
C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion)
|
||||
{
|
||||
meta_engfuncs_post.pfnTraceLine = C_TraceLine_Post;
|
||||
meta_engfuncs_post.pfnMessageBegin = C_MessageBegin_Post;
|
||||
meta_engfuncs_post.pfnMessageEnd = C_MessageEnd_Post;
|
||||
|
|
Loading…
Reference in New Issue
Block a user