Worldserver with console :)

    Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

    • Worldserver with console :)

      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

      Quellcode

      1. #define __QUGET_CONSOLE

      Open worldserver.cpp and look for

      Quellcode

      1. // float point ¿¡·¯°¡ exceptionÀ» ³»°Ô ÇÑ´Ù.
      2. void EnableFloatException()
      3. {
      4. int cw = _controlfp( 0, 0 );
      5. cw &= ~(EM_OVERFLOW|EM_UNDERFLOW|EM_ZERODIVIDE|EM_DENORMAL);
      6. _controlfp( cw, MCW_EM );
      7. }

      Add this under it

      Quellcode

      1. #ifdef __QUGET_CONSOLE
      2. //Picked up from a proxy hack source code(Not infiltration) and used some google
      3. HANDLE CreateConsole()
      4. {
      5. int hConHandle = 0;
      6. HANDLE lStdHandle = 0;
      7. FILE *fp = 0;
      8. // Allocate a console
      9. AllocConsole();
      10. WNDCLASSEX wc = { 0 };
      11. //Quget test
      12. wc.cbSize = sizeof( WNDCLASSEX ) ;
      13. wc.cbClsExtra = 0; // ignore for now
      14. wc.cbWndExtra = 0; // ignore for now
      15. wc.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
      16. wc.hCursor = LoadCursor( NULL, IDC_ARROW );
      17. //wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
      18. wc.lpfnWndProc = WndProc;
      19. wc.lpszClassName = TEXT("Console");
      20. wc.lpszMenuName = 0;
      21. wc.style = CS_HREDRAW | CS_VREDRAW; // Redraw the window
      22. RegisterClassEx( &wc );
      23. //End test
      24. // redirect unbuffered STDOUT to the console
      25. lStdHandle = GetStdHandle(STD_OUTPUT_HANDLE);
      26. hConHandle = _open_osfhandle(PtrToUlong(lStdHandle), 0x4000);//_O_TEXT);
      27. fp = _fdopen(hConHandle, "w");
      28. *stdout = *fp;
      29. setvbuf(stdout, NULL, _IONBF, 0);
      30. return lStdHandle;
      31. }
      32. #endif // __QUGET_CONSOLE
      Alles anzeigen



      In the same file look for


      Quellcode

      1. BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
      2. {



      And add this under it

      Quellcode

      1. #ifdef __QUGET_CONSOLE
      2. CreateConsole();
      3. SetProcessWorkingSetSize(hInstance, -1, -1);
      4. printf("Quget Server Console.\n");
      5. #endif // __QUGET_CONSOLE



      Open xUtil.cpp


      Look for


      Quellcode

      1. LPCTSTR Error( LPCTSTR strFormat, ... )
      2. {
      3. char szBuff[8192];
      4. va_list args;
      5. va_start(args, strFormat);
      6. int n = _vsntprintf( szBuff, 8191, strFormat, args );
      7. va_end(args);
      8. if( n > 0 )
      9. {
      10. #if defined(_DEBUG) && defined(__XUZHU)
      11. if( g_bShowMsgBox && MessageBox( NULL, szBuff, "¿À·ù", MB_OKCANCEL) == IDCANCEL )
      12. g_bShowMsgBox = FALSE;
      13. #endif
      14. char szStr[8192];
      15. SYSTEMTIME time;
      16. GetLocalTime( &time );
      17. sprintf( szStr, "%d/%2d/%2d %02d:%02d:%02d %s\n",
      18. time.wYear, time.wMonth, time.wDay,
      19. time.wHour, time.wMinute, time.wSecond,
      20. szBuff );
      21. DEBUGOUT2( szStr );
      Alles anzeigen

      And add this under it


      Quellcode

      1. #ifdef __QUGET_CONSOLE
      2. printf(szStr);
      3. #endif



      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


      Quellcode

      1. void CDPDatabaseClient::SendLogConnect( CUser* pUser )
      2. {
      3. BEFORESENDDUAL( ar, PACKETTYPE_LOG_PLAY_CONNECT, DPID_UNKNOWN, DPID_UNKNOWN );
      4. ar << pUser->GetWorld()->GetID(); // world id
      5. ar.Write( &pUser->m_playAccount.m_stLogin, sizeof(SYSTEMTIME) );
      6. ar.WriteString( pUser->m_playAccount.lpAddr ); // ip
      7. DWORD dwSeed = pUser->GetGold() + pUser->m_dwGoldBank[pUser->m_nSlot];
      8. ar << dwSeed; // seed
      9. ar << pUser->m_idPlayer;
      10. ar.WriteString( pUser->m_playAccount.lpszAccount );
      11. ar << pUser->GetLevel();
      12. ar << pUser->GetJob();
      13. #if __VER >= 14 // __PCBANG
      14. ar << CPCBang::GetInstance()->GetPCBangClass( pUser->m_idPlayer );
      15. #endif // __PCBANG
      Alles anzeigen



      And add this under it


      Quellcode

      1. #ifdef __QUGET_CONSOLE
      2. printf("Logged out:[%s],Gold:[%d],JobId:[%d],Level:[%d],Autht:[%d] \n",pUser->GetName(),pUser->GetGold(),pUser->GetJob(),pUser->GetLevel(),pUser->m_dwAuthorization);
      3. #endif //__QUGET_CONSOLE



      Now for the log in Look for


      Quellcode

      1. #if __VER >= 15 // __GUILD_HOUSE
      2. pUser->AddGuildHouseAllInfo( GuildHouseMng->GetGuildHouse( pUser->m_idGuild ) );
      3. GuildHouseMng->SetApplyDST( pUser );
      4. if( pWorld && GuildHouseMng->IsGuildHouse( pWorld->GetID() ) && pUser->GetLayer() == pUser->m_idGuild ) // Á¢¼ÓÁö°¡ ±æµåÇϿ콺 À̸é..
      5. pUser->SetIncRestPoint( tLogOut / REST_POINT_TICK * REST_POINT_LOGOUT_INC ); // ·Î±×¾Æ¿ô ÈÞ½Ä Æ÷ÀÎÆ®¸¦ Áõ°¡ ½ÃÄÑÁØ´Ù.
      6. #endif // __GUILD_HOUSE
      7. #if __VER >= 15 // __CAMPUS
      8. u_long idCampus = pUser->GetCampusId();
      9. if( idCampus )
      10. {
      11. CCampus* pCampus = CCampusHelper::GetInstance()->GetCampus( idCampus );
      12. if( pCampus && pCampus->IsMember( pUser->m_idPlayer ) )
      13. pUser->AddUpdateCampus( pCampus );
      14. else
      15. pUser->SetCampusId( 0 );
      16. }
      17. #endif // __CAMPUS
      Alles anzeigen



      And add this under it


      Quellcode

      1. #ifdef __QUGET_CONSOLE
      2. 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);
      3. #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.
    • Werbung zur Unterstützung des Forums ( Bitte AddBlocker deaktivieren )