Alright thought I release another simple part :)
It creates a console window and print the errors out in the console.
If you want you can add some printf("Sumlog %s",someshit); like when someone logs in you be able to see that.
In worldserver open versionCommon.h
add
Open worldserver.cpp and look for
// float point ¿¡·¯°¡ exceptionÀ» ³»°Ô ÇÑ´Ù.
void EnableFloatException()
{
int cw = _controlfp( 0, 0 );
cw &= ~(EM_OVERFLOW|EM_UNDERFLOW|EM_ZERODIVIDE|EM_DENORMAL);
_controlfp( cw, MCW_EM );
}
Add this under it
#ifdef __QUGET_CONSOLE
//Picked up from a proxy hack source code(Not infiltration) and used some google
HANDLE CreateConsole()
{
int hConHandle = 0;
HANDLE lStdHandle = 0;
FILE *fp = 0;
// Allocate a console
AllocConsole();
WNDCLASSEX wc = { 0 };
//Quget test
wc.cbSize = sizeof( WNDCLASSEX ) ;
wc.cbClsExtra = 0; // ignore for now
wc.cbWndExtra = 0; // ignore for now
wc.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
wc.hCursor = LoadCursor( NULL, IDC_ARROW );
//wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
wc.lpfnWndProc = WndProc;
wc.lpszClassName = TEXT("Console");
wc.lpszMenuName = 0;
wc.style = CS_HREDRAW | CS_VREDRAW; // Redraw the window
RegisterClassEx( &wc );
//End test
// redirect unbuffered STDOUT to the console
lStdHandle = GetStdHandle(STD_OUTPUT_HANDLE);
hConHandle = _open_osfhandle(PtrToUlong(lStdHandle), 0x4000);//_O_TEXT);
fp = _fdopen(hConHandle, "w");
*stdout = *fp;
setvbuf(stdout, NULL, _IONBF, 0);
return lStdHandle;
}
#endif // __QUGET_CONSOLE
Alles anzeigen
In the same file look for
And add this under it
#ifdef __QUGET_CONSOLE
CreateConsole();
SetProcessWorkingSetSize(hInstance, -1, -1);
printf("Quget Server Console.\n");
#endif // __QUGET_CONSOLE
Open xUtil.cpp
Look for
LPCTSTR Error( LPCTSTR strFormat, ... )
{
char szBuff[8192];
va_list args;
va_start(args, strFormat);
int n = _vsntprintf( szBuff, 8191, strFormat, args );
va_end(args);
if( n > 0 )
{
#if defined(_DEBUG) && defined(__XUZHU)
if( g_bShowMsgBox && MessageBox( NULL, szBuff, "¿À·ù", MB_OKCANCEL) == IDCANCEL )
g_bShowMsgBox = FALSE;
#endif
char szStr[8192];
SYSTEMTIME time;
GetLocalTime( &time );
sprintf( szStr, "%d/%2d/%2d %02d:%02d:%02d %s\n",
time.wYear, time.wMonth, time.wDay,
time.wHour, time.wMinute, time.wSecond,
szBuff );
DEBUGOUT2( szStr );
Alles anzeigen
And add this under it
Now the console will print all errors :)
An example too add extra logs(Some extra features!)
For showing who logged in and out
Look for
void CDPDatabaseClient::SendLogConnect( CUser* pUser )
{
BEFORESENDDUAL( ar, PACKETTYPE_LOG_PLAY_CONNECT, DPID_UNKNOWN, DPID_UNKNOWN );
ar << pUser->GetWorld()->GetID(); // world id
ar.Write( &pUser->m_playAccount.m_stLogin, sizeof(SYSTEMTIME) );
ar.WriteString( pUser->m_playAccount.lpAddr ); // ip
DWORD dwSeed = pUser->GetGold() + pUser->m_dwGoldBank[pUser->m_nSlot];
ar << dwSeed; // seed
ar << pUser->m_idPlayer;
ar.WriteString( pUser->m_playAccount.lpszAccount );
ar << pUser->GetLevel();
ar << pUser->GetJob();
#if __VER >= 14 // __PCBANG
ar << CPCBang::GetInstance()->GetPCBangClass( pUser->m_idPlayer );
#endif // __PCBANG
Alles anzeigen
And add this under it
#ifdef __QUGET_CONSOLE
printf("Logged out:[%s],Gold:[%d],JobId:[%d],Level:[%d],Autht:[%d] \n",pUser->GetName(),pUser->GetGold(),pUser->GetJob(),pUser->GetLevel(),pUser->m_dwAuthorization);
#endif //__QUGET_CONSOLE
Now for the log in Look for
#if __VER >= 15 // __GUILD_HOUSE
pUser->AddGuildHouseAllInfo( GuildHouseMng->GetGuildHouse( pUser->m_idGuild ) );
GuildHouseMng->SetApplyDST( pUser );
if( pWorld && GuildHouseMng->IsGuildHouse( pWorld->GetID() ) && pUser->GetLayer() == pUser->m_idGuild ) // Á¢¼ÓÁö°¡ ±æµåÇϿ콺 À̸é..
pUser->SetIncRestPoint( tLogOut / REST_POINT_TICK * REST_POINT_LOGOUT_INC ); // ·Î±×¾Æ¿ô ÈÞ½Ä Æ÷ÀÎÆ®¸¦ Áõ°¡ ½ÃÄÑÁØ´Ù.
#endif // __GUILD_HOUSE
#if __VER >= 15 // __CAMPUS
u_long idCampus = pUser->GetCampusId();
if( idCampus )
{
CCampus* pCampus = CCampusHelper::GetInstance()->GetCampus( idCampus );
if( pCampus && pCampus->IsMember( pUser->m_idPlayer ) )
pUser->AddUpdateCampus( pCampus );
else
pUser->SetCampusId( 0 );
}
#endif // __CAMPUS
Alles anzeigen
And add this under it
#ifdef __QUGET_CONSOLE
printf("Character logged in:[%s] Gold:[%d] JobId:[%d] level:[%d] Auth:[%d] \n",pUser->GetName(),pUser->GetGold(),pUser->GetJob(),pUser->GetLevel(),pUser->m_dwAuthorization);
#endif //__QUGET_CONSOLE
Now you are all done having a wolrdserver with a console window printing everything that goes in error%%%.txt and showing who logged in and off :)
Credits:
70% Quget aka Misterkid
30% Google and some hack source code for giving me the idea.