PlayerManager.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:3k
源码类别:

模拟服务器

开发平台:

C/C++

  1. /********************************************************************
  2. created: 2003/04/08
  3. file base: PlayerManager
  4. file ext: h
  5. author: liupeng
  6. purpose:
  7. *********************************************************************/
  8. #ifndef __INCLUDE_PLAYERMANAGER_H__
  9. #define __INCLUDE_PLAYERMANAGER_H__
  10. #include "IPlayer.h"
  11. #include "GamePlayer.h"
  12. #include "Thread.h"
  13. #include "Environment.h"
  14. #include "IClient.h"
  15. #include "RainbowInterface.h"
  16. #include "IServer.h"
  17. #include "HeavenInterface.h"
  18. #include "Library.h"
  19. #pragma warning(disable : 4786)  // identifier was truncated to '255' characters 
  20.                                  // in the debug information
  21. #include <map>
  22. #include <stack>
  23. #include <list>
  24. class CPlayerManager : protected OnlineGameLib::Win32::CThread
  25. {
  26. public:
  27. explicit CPlayerManager( ENVIRONMENT &theEnviroment );
  28. virtual ~CPlayerManager();
  29. bool Create();
  30. void Destroy();
  31. virtual int Run();
  32. static void __stdcall AccountEventNotify( LPVOID lpParam, 
  33. const unsigned long &ulnEventType );
  34. static void __stdcall DBRoleEventNotify( LPVOID lpParam, 
  35. const unsigned long &ulnEventType );
  36. static void __stdcall PlayerEventNotify( LPVOID lpParam,
  37. const unsigned long &ulnID,
  38. const unsigned long &ulnEventType );
  39. static void __stdcall GameSvrEventNotify( LPVOID lpParam,
  40. const unsigned long &ulnID,
  41. const unsigned long &ulnEventType );
  42. protected:
  43. bool StartupNetwork();
  44. void CleanNetwork();
  45. typedef HRESULT ( __stdcall * pfnCreateServerInterface )( REFIID riid, void **ppv );
  46. typedef HRESULT ( __stdcall * pfnCreateClientInterface )( REFIID riid, void **ppv );
  47. static OnlineGameLib::Win32::CLibrary m_sHeavenLib;
  48. static OnlineGameLib::Win32::CLibrary m_sRainbowLib;
  49. /*
  50.  * Network
  51.  */
  52. IClient *m_pDBRoleClient;
  53. IServer *m_pPlayerServer;
  54. void _PlayerEventNotify( const unsigned long &ulnID,
  55. const unsigned long &ulnEventType );
  56. /*
  57.  * Listen and accept data from network
  58.  */
  59. HANDLE m_hHelperThread;
  60. static unsigned int __stdcall HelperThreadFunction( void *pV );
  61. int Helper();
  62. bool AnalyzePlayerRequire( size_t index, const void *pData, size_t datalength );
  63. private:
  64. HANDLE m_hQuitEvent;
  65. ENVIRONMENT &m_theEnviroment;
  66. OnlineGameLib::Win32::CCriticalSection m_csSystemAction;
  67. typedef std::map< size_t, IPlayer * > PLAYER_MAP;
  68. PLAYER_MAP m_thePlayers;
  69. typedef std::stack< size_t > STACK;
  70. typedef std::list< size_t > LIST;
  71. STACK m_freeClientNode;
  72. LIST m_usedClientNode;
  73. OnlineGameLib::Win32::CCriticalSection m_csUsedClientList;
  74. };
  75. #endif // __INCLUDE_PLAYERMANAGER_H__