NetworkGame.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*===========================================================================*\
  2. |
  3. | File: NetworkGame.h
  4. |
  5. | Description:
  6. | Header file for NetworkGame.cpp
  7. |
  8. |-----------------------------------------------------------------------------
  9. |
  10. | Copyright (C) 1995-1996 Microsoft Corporation. All Rights Reserved.
  11. |
  12. \*===========================================================================*/
  13. #ifndef _CGREMOTE_H
  14. #define _CGREMOTE_H
  15. //** private data **
  16. #define MAX_NAME_LENGTH 21
  17. #define MAX_PLAYERS 500
  18. DWORD WINAPI ReceiveThread(LPVOID pThreadParameter);
  19. struct PLAYERSDESC
  20. {
  21. DPID dpid;
  22. char FriendlyName[MAX_NAME_LENGTH];
  23. char FormalName[MAX_NAME_LENGTH];
  24. };
  25. class NetworkGame
  26. {
  27. private:
  28. IDirectPlayX * mpDirectPlay;
  29. HANDLE mhPlayerEvent;
  30. DPID mdpId;
  31. INT mcMessagesSent;
  32. INT mcMessagesReceived;
  33. INT mcPlayers;
  34. PLAYERSDESC mPlayers[MAX_PLAYERS];
  35. #ifdef RECEIVETHREAD
  36. HANDLE mhReceiveThread;
  37. HANDLE mhKillReceiveEvent;
  38. #endif
  39. public:
  40. FedMessaging FM;
  41. private:
  42. void ShutdownConnection();
  43. void HandleSysMsg(DPID idTo, DPID idFrom);
  44. public:
  45. NetworkGame();
  46. ~NetworkGame();
  47. HRESULT SetupConnection(const char * szFedServer,
  48. const char * szCharName,
  49. const char * szCharPW,
  50. bool fCreateNew,
  51. FILETIME * pftLastArtUpdate = NULL);
  52. HRESULT ReceiveMessages(BOOL * pfSystemMsg);
  53. HRESULT SendMessages(DPID dpidTo, bool fGuaranteed);
  54. LPSTR GetPlayerName(int i);
  55. DPID DpId();
  56. } ;
  57. class DPlayWrapper
  58. {
  59. protected:
  60. IDirectPlayX * mpDirectPlay;
  61. IDirectPlayLobbyX * mpDirectPlayLobbyA;
  62. bool CheckDPlayVersion();
  63. public:
  64. DPlayWrapper();
  65. ~DPlayWrapper();
  66. HRESULT AllocDirectPlaySession(const CHAR * szServer,
  67. IDirectPlayX ** ppDirectPlay);
  68. VOID FreeDirectPlaySession(IDirectPlayX * pDirectPlay);
  69. } ;
  70. #endif