Lobby/Stage Chat Logger - 1.5 Source.
Nothing special, took me 5 min :glare:.
Lobby Logger:
Code:
MMatchServer_Channel.cpp, look for:
Code:
bool MMatchServer::ChannelChat(const MUID& uidPlayer, const MUID& uidChannel, char* pszChat)
Paste under:
Code:
pCmd->AddParameter(new MCommandParameterInt(nGrade));
This:
Code:
if( uidChannel == pObj->GetChannelUID() )
{
LOG(LOG_PROG, "[Lobby] | %s : %s ", pObj->GetName(), pszChat);
}
Stage Logger:
Code:
MMatchServer_Stage.cpp, look for:
Code:
bool MMatchServer::StageChat(const MUID& uidPlayer, const MUID& uidStage, char* pszChat)
Paste under:
Code:
pCmd->AddParameter(new MCommandParameterString(pszChat));
This:
Code:
if( uidStage == pObj->GetStageUID() )
{
LOG(LOG_PROG, "[Stage] | %s : %s ", pObj->GetName(), pszChat);
}
Note:
Code:
LOG_PROG would display in both log file and matchserver screen.
LOG_FILE would display only in log file of the matchserver.
Photo from matchserver screen:
Code from matchserver log file:
Code:
../Log
[07/04/12 00:04:43] [Lobby] | RaGEZONE : This is lobby.
[07/04/12 00:04:49] [Stage] | RaGEZONE : This is stage.
Adding custom file: (Didn't test);
Quote:
Originally Posted by
Mocro
To add Log File.
MCommandCommunicator.h :
Search for:
add:
MCommandCommunicator.cpp
search for:
Code:
void MCommandCommunicator::LOG(unsigned int nLogLevel, const char *pFormat,...)
{
add:
Code:
if (nLogLevel == LOG_FILELOBBY){
FILE * pFile;
pFile = fopen ("Logs/lobby.txt","w");
if (pFile!=NULL)
{
va_list args;
static char temp[1024];
va_start(args, pFormat);
vsprintf(temp, pFormat, args);
fputs (temp,pFile);
fclose (pFile);
}
}else
To use function:
Code:
LOG(LOG_FILELOBBY, "[Lobby] | %s : %s ", pObj->GetName(), pszChat);
Like if you gonna use it :glare:
Re: Lobby/Stage Chat Logger - 1.5 Source.
Wouldn't it be better to create separate files from the MatchServer log. This is very unorganized and is hard to read through.
Re: Lobby/Stage Chat Logger - 1.5 Source.
Don't you think the matchserver will be exploded if you will have lot's of players : < ? I rather use the Log folder only.
Re: Lobby/Stage Chat Logger - 1.5 Source.
Quote:
Originally Posted by
Mr_Troy
Wouldn't it be better to create separate files from the MatchServer log. This is very unorganized and is hard to read through.
It's very simple one, the new file would make it perfect :cool:
Quote:
Originally Posted by
CobraBite
Don't you think the matchserver will be exploded if you will have lot's of players : < ? I rather use the Log folder only.
LOG_FILE would display only in log file of the matchserver.
Re: Lobby/Stage Chat Logger - 1.5 Source.
Quote:
Originally Posted by
Mr_Troy
Wouldn't it be better to create separate files from the MatchServer log. This is very unorganized and is hard to read through.
Just make another function like the LOG_FILE and rename it to something else.
Re: Lobby/Stage Chat Logger - 1.5 Source.
You suggested me some new ideas ^_^ Thanks. <3
Re: Lobby/Stage Chat Logger - 1.5 Source.
It may be a mess, but it's actually something useful from u for once.
Re: Lobby/Stage Chat Logger - 1.5 Source.
Quote:
Originally Posted by
Joe9099
It may be a mess, but it's actually something useful from u for once.
Y U NO LOVE ME
Quote:
Originally Posted by
Ronny786
You suggested me some new ideas ^_^ Thanks. <3
Well, it's easy and usefull, anyway your welcome :cool:
Re: Lobby/Stage Chat Logger - 1.5 Source.
To add Log File.
MCommandCommunicator.h :
Search for:
add:
MCommandCommunicator.cpp
search for:
Code:
void MCommandCommunicator::LOG(unsigned int nLogLevel, const char *pFormat,...)
{
add:
Code:
if (nLogLevel == LOG_FILELOBBY){
FILE * pFile;
pFile = fopen ("Logs/lobby.txt","w");
if (pFile!=NULL)
{
va_list args;
static char temp[1024];
va_start(args, pFormat);
vsprintf(temp, pFormat, args);
fputs (temp,pFile);
fclose (pFile);
}
}else
To use function:
Code:
LOG(LOG_FILELOBBY, "[Lobby] | %s : %s ", pObj->GetName(), pszChat);
Re: Lobby/Stage Chat Logger - 1.5 Source.
Quote:
Originally Posted by
Mocro
To add Log File.
MCommandCommunicator.h :
Search for:
add:
MCommandCommunicator.cpp
search for:
Code:
void MCommandCommunicator::LOG(unsigned int nLogLevel, const char *pFormat,...)
{
add:
Code:
if (nLogLevel == LOG_FILELOBBY){
FILE * pFile;
pFile = fopen ("Logs/lobby.txt","w");
if (pFile!=NULL)
{
va_list args;
static char temp[1024];
va_start(args, pFormat);
vsprintf(temp, pFormat, args);
fputs (temp,pFile);
fclose (pFile);
}
}else
To use function:
Code:
LOG(LOG_FILELOBBY, "[Lobby] | %s : %s ", pObj->GetName(), pszChat);
Thanks for developing it, added to the main post.
Re: Lobby/Stage Chat Logger - 1.5 Source.
Code:
ofstream chatLog;
chatLog.open("ChatLogs.txt", ios::app);
sprintf(szLog, "%s From: %s To: %s: %s\n", Time(), pObj->GetName(), pszTargetName, pszMessage);
chatLog << szLog;
Code:
char* Time( )
{
time_t lTime;
struct tm* TM;
lTime = time( NULL );
TM = localtime( &lTime );
char szBuffer[25];
sprintf( szBuffer, "[%d:%d:%d]", TM->tm_mday, TM->tm_hour, TM->tm_min );
return szBuffer;
}
Re: Lobby/Stage Chat Logger - 1.5 Source.
Sigh I wish people ^ would just specify what they had changed instead of just making changes and leaving it up to the viewer to go to the top and look and the default then compare it to the latest just to see what's new.
Re: Lobby/Stage Chat Logger - 1.5 Source.
Quote:
Originally Posted by
WizCoder
Sigh I wish people ^ would just specify what they had changed instead of just making changes and leaving it up to the viewer to go to the top and look and the default then compare it to the latest just to see what's new.
Those aren't edits done to qet's source if that's what you're referring to.
Anyway, I never said I was spoonfeeding, so yeah, have fun.
Re: Lobby/Stage Chat Logger - 1.5 Source.
"%s%s"
You just made the chatroom crash even easier.
Re: Lobby/Stage Chat Logger - 1.5 Source.
Quote:
Originally Posted by
ThePhailure772
"%s%s"
You just made the chatroom crash even easier.
What Jacob is trying to say here is to use try and except handlers or make sure the chat doesn't contain % since that might result into buffer overflow (and crash your server).
try-except Statement (C++)
Putting the vsprintf in the try block would do the trick, clean your args in the except block and then return.