home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / graphics / directx / dpslots / dpslots.h < prev    next >
C/C++ Source or Header  |  1997-07-14  |  4KB  |  114 lines

  1. /*==========================================================================
  2.  *
  3.  *  Copyright (C) 1997 Microsoft Corporation.  All Rights Reserved.
  4.  *
  5.  *  File:       dpslots.h
  6.  *  Content:    common dpslots headers
  7.  *
  8.  ***************************************************************************/
  9.  
  10. #define IDIRECTPLAY2_OR_GREATER
  11. #include <dplay.h>
  12. #include <dplobby.h>
  13.  
  14. // constants
  15. #define NUMWHEELS                3        // no. wheels
  16. #define SLOTSPERWHEEL            6        // no. slots per wheel
  17. #define MAXSTRLEN                200        // max size of a string
  18. #define DEFAULTDATABASE            "slotsdb.txt" // default name of database file
  19.  
  20. // flags to use when creating players
  21. #define CLIENTPLAYERFLAGS            0
  22. #define SERVERPLAYERFLAGS            (DPPLAYER_SERVERPLAYER)
  23.  
  24. // flags to use when sending messages
  25. #define NONSECURESENDFLAGS            (DPSEND_GUARANTEED)
  26. #define SECURESENDFLAGS                (DPSEND_GUARANTEED |    \
  27.                                      DPSEND_SIGNED |        \
  28.                                      DPSEND_ENCRYPTED)
  29. #define SENDFLAGS(bIsSecure)        ((bIsSecure) ? SECURESENDFLAGS : NONSECURESENDFLAGS)
  30.  
  31. // flags to use when creating sessions
  32. #define NONSECURESESSIONFLAGS        (DPSESSION_KEEPALIVE |        \
  33.                                      DPSESSION_CLIENTSERVER)
  34. #define SECURESESSIONFLAGS            (DPSESSION_KEEPALIVE |        \
  35.                                      DPSESSION_CLIENTSERVER |    \
  36.                                      DPSESSION_SECURESERVER)
  37. #define SESSIONFLAGS(bIsSecure)        ((bIsSecure) ? SECURESESSIONFLAGS : NONSECURESESSIONFLAGS)
  38.  
  39. // client messages
  40. #define BALANCEREQUEST            300        // request for account balance
  41. #define SPINREQUEST                302        // request for spin
  42.  
  43. // server messages
  44. #define BALANCERESPONSE            400        // account balance reply
  45. #define SPINRESPONSE            401        // spin reply
  46.  
  47. // structure used to store DirectPlay information
  48. typedef struct {
  49.     LPDIRECTPLAY3A    lpDirectPlay3A;        // IDirectPlay3A interface pointer
  50.     HANDLE            hPlayerEvent;        // player event to use
  51.     DPID            dpidPlayer;            // ID of player created
  52.     BOOL            bIsHost;            // TRUE if we are hosting the session
  53.     BOOL            bIsSecure;            // TRUE if session is secure
  54. } DPLAYINFO, *LPDPLAYINFO;
  55.  
  56. // message structures
  57.  
  58. // used to request the results of a wager
  59. typedef struct {
  60.     DWORD   dwType;                        // message type
  61.     DWORD   dwAmountBet;                // amount to wager
  62. } MSG_SPINREQUEST, *LPMSG_SPINREQUEST;
  63.  
  64. // response to wager request
  65. typedef struct {
  66.     DWORD   dwType;                        // message type
  67.     HRESULT    hr;                            // result of request
  68.     LONG    dwAmountWonOrLost;            // amount won or lost
  69.     DWORD   dwBalance;                    // current balance after wager
  70.     DWORD   dwIndex[NUMWHEELS];            // slot settings
  71. } MSG_SPINRESPONSE, *LPMSG_SPINRESPONSE;
  72.  
  73. // used to request current balance
  74. typedef struct {
  75.     DWORD    dwType;                        // message type
  76. } MSG_BALANCEREQUEST, *LPMSG_BALANCEREQUEST;
  77.  
  78. // response to balance request
  79. typedef struct {
  80.     DWORD    dwType;                        // message type
  81.     HRESULT    hr;                            // result of request
  82.     DWORD    dwBalance;                    // current balance
  83. } MSG_BALANCERESPONSE, *LPMSG_BALANCERESPONSE;
  84.  
  85. // guid for this application
  86. // {EC4F7AA0-E1E0-11d0-9C50-00A0C905425E}
  87. DEFINE_GUID(DPSLOTS_GUID, 
  88. 0xec4f7aa0, 0xe1e0, 0x11d0, 0x9c, 0x50, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e);
  89.  
  90. // globals
  91. extern HINSTANCE        ghInstance;        // instance of application
  92. extern CHAR                gszDatabaseName[MAXSTRLEN];
  93.  
  94. // common prototypes
  95. extern HRESULT            ConnectUsingLobby(LPDPLAYINFO lpDPInfo);
  96. extern HRESULT            ConnectUsingDialog(HINSTANCE hInstance, LPDPLAYINFO lpDPInfo);
  97. extern void                ErrorBox(LPSTR lpszErrorStr, HRESULT hr);
  98. extern void                CheckDlgItem(HWND hDlg, int nIDDlgItem, BOOL bCheck);
  99. extern BOOL                DlgItemIsChecked(HWND hDlg, int nIDDlgItem);
  100. extern void                EnableDlgButton(HWND hDlg, int nIDDlgItem, BOOL bEnable);
  101.  
  102. // client prototypes
  103. extern BOOL CALLBACK    ClientWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  104. extern void                ClientSystemMessage(LPDPLAYINFO lpDPInfo, LPDPMSG_GENERIC lpMsg, DWORD dwMsgSize,
  105.                                             DPID idFrom, DPID idTo);
  106. extern void                ClientApplicationMessage(LPDPLAYINFO lpDPInfo, LPDPMSG_GENERIC lpMsg, DWORD dwMsgSize,
  107.                                                  DPID idFrom, DPID idTo);
  108. // server prototypes
  109. extern BOOL CALLBACK    ServerWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  110. extern void                ServerSystemMessage(LPDPLAYINFO lpDPInfo, LPDPMSG_GENERIC lpMsg, DWORD dwMsgSize,
  111.                                             DPID idFrom, DPID idTo);
  112. extern void                ServerApplicationMessage(LPDPLAYINFO lpDPInfo, LPDPMSG_GENERIC lpMsg, DWORD dwMsgSize,
  113.                                                  DPID idFrom, DPID idTo);
  114.