mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
Changed to support rewritten amxxlog
This commit is contained in:
parent
8973af479c
commit
9656eac079
@ -56,7 +56,9 @@
|
||||
#include "CMenu.h"
|
||||
#include "CEvent.h"
|
||||
#include "fakemeta.h"
|
||||
#include "amxxlog.h"
|
||||
|
||||
#define AMXXLOG_Log g_log.Log
|
||||
#define AMX_VERSION "0.2"
|
||||
|
||||
extern AMX_NATIVE_INFO core_Natives[];
|
||||
@ -106,10 +108,6 @@ void UTIL_IntToString(int value, char *output);
|
||||
void UTIL_ShowMOTD( edict_t *client , char *motd, int mlen, const char *name);
|
||||
void UTIL_ShowMenu( edict_t* pEntity, int slots, int time, char *menu, int mlen );
|
||||
|
||||
// Logging
|
||||
void AMXXLOG_Init();
|
||||
void AMXXLOG_MapChange();
|
||||
void AMXXLOG_Log(const char *fmt, ...);
|
||||
|
||||
#define GET_PLAYER_POINTER(e) (&g_players[ENTINDEX(e)])
|
||||
//#define GET_PLAYER_POINTER(e) (&g_players[(((int)e-g_edict_point)/sizeof(edict_t ))])
|
||||
@ -129,7 +127,7 @@ struct fakecmd_t {
|
||||
bool fake;
|
||||
};
|
||||
|
||||
|
||||
extern CLog g_log;
|
||||
extern CPluginMngr g_plugins;
|
||||
extern CTaskMngr g_tasksMngr;
|
||||
extern CPlayer g_players[33];
|
||||
|
@ -56,6 +56,7 @@ funEventCall modMsgs[MAX_REG_MSGS];
|
||||
void (*function)(void*);
|
||||
void (*endfunction)(void*);
|
||||
|
||||
CLog g_log;
|
||||
CForwardMngr g_forwards;
|
||||
CList<CPlayer*> g_auth;
|
||||
CList<CCVar> g_cvars;
|
||||
@ -208,13 +209,8 @@ int C_Spawn( edict_t *pent ) {
|
||||
hostname = CVAR_GET_POINTER("hostname");
|
||||
mp_timelimit = CVAR_GET_POINTER("mp_timelimit");
|
||||
|
||||
// we need to initialize logging in Meta_Attach, but we have to create a new logfile each map,
|
||||
// so we clear g_log_dir in ServerDeactivate_Post to know we should create one...
|
||||
if (g_log_dir.empty())
|
||||
{
|
||||
g_log_dir.set(get_localinfo("amxx_logs", "addons/amxx/logs"));
|
||||
AMXXLOG_MapChange();
|
||||
}
|
||||
|
||||
g_log.MapChange();
|
||||
|
||||
// ###### Initialize task manager
|
||||
g_tasksMngr.registerTimers( &gpGlobals->time, &mp_timelimit->value, &g_game_timeleft );
|
||||
@ -503,9 +499,6 @@ void C_ServerDeactivate_Post() {
|
||||
}
|
||||
#endif // MEMORY_TEST
|
||||
|
||||
g_log_dir.clear();
|
||||
AMXXLOG_Log("Log file closed.");
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
@ -1076,9 +1069,7 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS *pFunctionTable, m
|
||||
}
|
||||
|
||||
// ###### Initialize logging here
|
||||
AMXXLOG_Init();
|
||||
g_log_dir.set(get_localinfo("amxx_logs", "addons/amxx/logs"));
|
||||
AMXXLOG_MapChange();
|
||||
|
||||
// ###### Now attach metamod modules
|
||||
// This will also call modules Meta_Query and Meta_Attach functions
|
||||
@ -1114,6 +1105,8 @@ C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason) {
|
||||
g_FakeMeta.Meta_Detach(now, reason);
|
||||
g_FakeMeta.ReleasePlugins();
|
||||
|
||||
g_log.CloseFile();
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
@ -1269,6 +1262,28 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
|
||||
meta_engfuncs_post.pfnRegUserMsg = C_RegUserMsg_Post;
|
||||
|
||||
|
||||
CList<int, int> list;
|
||||
list.put(new int (8));
|
||||
list.put_back(new int(10));
|
||||
list.put_front(new int(6));
|
||||
list.put(new int (12));
|
||||
CList<int,int>::iterator iter;
|
||||
iter = list.begin();
|
||||
while (iter)
|
||||
{
|
||||
if (*iter == 10)
|
||||
iter.remove();
|
||||
else if (*iter == 8)
|
||||
iter.put(new int (9));
|
||||
else
|
||||
++iter;
|
||||
}
|
||||
iter = list.begin();
|
||||
while (iter)
|
||||
{
|
||||
AMXXLOG_Log("%d", *iter);
|
||||
++iter;
|
||||
}
|
||||
return g_FakeMeta.GetEngineFunctions_Post(pengfuncsFromEngine, interfaceVersion, &meta_engfuncs_post);
|
||||
/*
|
||||
if(*interfaceVersion!=ENGINE_INTERFACE_VERSION) {
|
||||
|
@ -814,6 +814,16 @@ REAL MNF_CellToReal(cell x)
|
||||
return *(REAL*)&x;
|
||||
}
|
||||
|
||||
void MNF_Log(const char *fmt, ...)
|
||||
{
|
||||
// :TODO: Overflow possible here
|
||||
char msg[3072];
|
||||
va_list arglst;
|
||||
va_start(arglst, fmt);
|
||||
vsprintf(msg, fmt, arglst);
|
||||
va_end(arglst);
|
||||
AMXXLOG_Log("%s", msg);
|
||||
}
|
||||
// Fnptr Request function for the new interface
|
||||
const char *g_LastRequestedFunc = NULL;
|
||||
#define REGISTER_FUNC(name, func) { name, (void*)func },
|
||||
@ -830,7 +840,7 @@ void *Module_ReqFnptr(const char *funcName)
|
||||
REGISTER_FUNC("BuildPathname", build_pathname)
|
||||
REGISTER_FUNC("PrintSrvConsole", print_srvconsole)
|
||||
REGISTER_FUNC("GetModname", MNF_GetModname)
|
||||
REGISTER_FUNC("Log", AMXXLOG_Log)
|
||||
REGISTER_FUNC("Log", MNF_Log)
|
||||
|
||||
// Amx scripts loading / unloading / managing
|
||||
REGISTER_FUNC("GetAmxScript", MNF_GetAmxScript)
|
||||
|
Loading…
Reference in New Issue
Block a user