added UTIL_GetModulesNum function

This commit is contained in:
Pavol Marko 2004-03-24 18:33:41 +00:00
parent e40daf1315
commit cfb45c1302
2 changed files with 39 additions and 0 deletions

View File

@ -103,6 +103,12 @@ void UTIL_ShowMenu( edict_t* pEntity, int slots, int time, char *menu, int mlen
void UTIL_MakeNewLogFile();
void UTIL_Log(const char *fmt, ...);
#define UTIL_MODULES_RUNNING 0
#define UTIL_MODULES_ALL 1
#define UTIL_MODULES_STOPPED 2
int UTIL_GetModulesNum(int mode);
#define GET_PLAYER_POINTER(e) (&g_players[ENTINDEX(e)])
//#define GET_PLAYER_POINTER(e) (&g_players[(((int)e-g_edict_point)/sizeof(edict_t ))])
#define GET_PLAYER_POINTER_I(i) (&g_players[i])

View File

@ -330,3 +330,36 @@ void UTIL_Log(const char *fmt, ...)
fclose(pF);
print_srvconsole("L %s: %s\n", date, msg);
}
// Get the number of running modules
int UTIL_GetModulesNum(int mode)
{
CList<CModule>::iterator iter;
int num;
switch (mode)
{
case UTIL_MODULES_ALL:
return g_modules.size();
case UTIL_MODULES_RUNNING:
iter = g_modules.begin();
num = 0;
while (iter)
{
if ((*iter).getStatusValue() == MODULE_LOADED)
++num;
++iter;
}
return num;
case UTIL_MODULES_STOPPED:
iter = g_modules.begin();
num = 0;
while (iter)
{
if ((*iter).getStatusValue() != MODULE_LOADED)
++num;
++iter;
}
return num;
}
return 0;
}