Fixed CPlayer init, it was called too early.

nothing important on the logger

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40273
This commit is contained in:
Borja Ferrer 2007-01-05 00:42:22 +00:00
parent 35896b6eb3
commit d899b7a32a
4 changed files with 21 additions and 7 deletions

View File

@ -39,7 +39,11 @@ void CLogger::_NewMapFile()
char date[32];
strftime(date, sizeof(date), "%m/%d/%Y - %H:%M:%S", curtime);
fprintf(fp, "L %s: SourceMod log file started (file \"L%02d%02d%03d.log\") (Version \"%s\")\n", date, curtime->tm_mon + 1, curtime->tm_mday, i, SOURCEMOD_VERSION);
fprintf(fp, "L %s: Info (map \"%s\")\n", date, m_CurMapName.c_str());
if (m_PrntMapname)
{
fprintf(fp, "L %s: Info (map \"%s\")\n", date, m_CurMapName.c_str());
m_PrntMapname = false;
}
fclose(fp);
}
}
@ -249,6 +253,7 @@ void CLogger::LogMessageEx(LogType type, const char *vafmt, ...)
void CLogger::MapChange(const char *mapname)
{
m_CurMapName.assign(mapname);
m_PrntMapname = true;
switch (m_mode)
{

View File

@ -25,7 +25,7 @@ enum LoggingMode
class CLogger
{
public:
CLogger() : m_ErrMapStart(false), m_Active(false), m_DelayedStart(false), m_DailyPrintHdr(false) {}
CLogger() : m_PrntMapname(false), m_ErrMapStart(false), m_Active(false), m_DelayedStart(false), m_DailyPrintHdr(false) {}
public:
void InitLogger(LoggingMode mode, bool startlogging);
void CloseLogger();
@ -46,6 +46,7 @@ private:
String m_CurMapName;
LoggingMode m_mode;
int m_CurDay;
bool m_PrntMapname;
bool m_ErrMapStart;
bool m_Active;
bool m_DelayedStart;

View File

@ -8,6 +8,7 @@ SH_DECL_HOOK2_void(IServerGameClients, ClientPutInServer, SH_NOATTRIB, 0, edict_
SH_DECL_HOOK1_void(IServerGameClients, ClientDisconnect, SH_NOATTRIB, 0, edict_t *);
SH_DECL_HOOK1_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *);
SH_DECL_HOOK1_void(IServerGameClients, ClientSettingsChanged, SH_NOATTRIB, 0, edict_t *);
SH_DECL_HOOK3_void(IServerGameDLL, ServerActivate, SH_NOATTRIB, 0, edict_t *, int, int);
void CPlayerManager::OnSourceModAllInitialized()
{
@ -17,6 +18,7 @@ void CPlayerManager::OnSourceModAllInitialized()
SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientDisconnect, serverClients, this, &CPlayerManager::OnClientDisconnect_Post, true);
SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientCommand, serverClients, this, &CPlayerManager::OnClientCommand, false);
SH_ADD_HOOK_MEMFUNC(IServerGameClients, ClientSettingsChanged, serverClients, this, &CPlayerManager::OnClientSettingsChanged, true);
SH_ADD_HOOK_MEMFUNC(IServerGameDLL, ServerActivate, gamedll, this, &CPlayerManager::OnServerActivate, true);
/* Register OnClientConnect */
ParamType p1[] = {Param_Cell, Param_String, Param_Cell};
@ -40,11 +42,6 @@ void CPlayerManager::OnSourceModAllInitialized()
/* Register OnClientAuthorized */
//:TODO:
/* Initialize all players */
m_maxClients = g_SMAPI->pGlobals()->maxClients;
m_PlayerCount = 0;
m_Players = new CPlayer[m_maxClients];
}
void CPlayerManager::OnSourceModShutdown()
@ -55,6 +52,7 @@ void CPlayerManager::OnSourceModShutdown()
SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientDisconnect, serverClients, this, &CPlayerManager::OnClientDisconnect_Post, true);
SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientCommand, serverClients, this, &CPlayerManager::OnClientCommand, false);
SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, ClientSettingsChanged, serverClients, this, &CPlayerManager::OnClientSettingsChanged, true);
SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, ServerActivate, gamedll, this, &CPlayerManager::OnServerActivate, true);
/* Release forwards */
g_Forwards.ReleaseForward(m_clconnect);
@ -67,6 +65,14 @@ void CPlayerManager::OnSourceModShutdown()
delete [] m_Players;
}
void CPlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
{
/* Initialize all players */
m_maxClients = clientMax;
m_PlayerCount = 0;
m_Players = new CPlayer[m_maxClients + 1];
}
bool CPlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
{
cell_t res = 1;

View File

@ -26,6 +26,8 @@ public:
void OnClientAuthorized(); //:TODO: any args needed?
void OnClientCommand(edict_t *pEntity);
void OnClientSettingsChanged(edict_t *pEntity);
private:
void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
private:
IForward *m_clconnect;
IForward *m_cldisconnect;