DPSLOTS.H

/*========================================================================== 
*
* Copyright (C) 1997 Microsoft Corporation. All Rights Reserved.
*
* File: dpslots.h
* Content:common dpslots headers
*
***************************************************************************/

#define IDIRECTPLAY2_OR_GREATER
#include <dplay.h>
#include <dplobby.h>

// constants
#define NUMWHEELS 3// no. wheels
#define SLOTSPERWHEEL 6// no. slots per wheel
#define MAXSTRLEN200// max size of a string
#define DEFAULTDATABASE"slotsdb.txt" // default name of database file

// flags to use when creating players
#define CLIENTPLAYERFLAGS0
#define SERVERPLAYERFLAGS(DPPLAYER_SERVERPLAYER)

// flags to use when sending messages
#define NONSECURESENDFLAGS(DPSEND_GUARANTEED)
#define SECURESENDFLAGS(DPSEND_GUARANTEED |\
DPSEND_SIGNED |\
DPSEND_ENCRYPTED)
#define SENDFLAGS(bIsSecure)((bIsSecure) ? SECURESENDFLAGS : NONSECURESENDFLAGS)

// flags to use when creating sessions
#define NONSECURESESSIONFLAGS(DPSESSION_KEEPALIVE |\
DPSESSION_CLIENTSERVER)
#define SECURESESSIONFLAGS(DPSESSION_KEEPALIVE |\
DPSESSION_CLIENTSERVER |\
DPSESSION_SECURESERVER)
#define SESSIONFLAGS(bIsSecure)((bIsSecure) ? SECURESESSIONFLAGS : NONSECURESESSIONFLAGS)

// client messages
#define BALANCEREQUEST300// request for account balance
#define SPINREQUEST302// request for spin

// server messages
#define BALANCERESPONSE400// account balance reply
#define SPINRESPONSE401// spin reply

// structure used to store DirectPlay information
typedef struct {
LPDIRECTPLAY3AlpDirectPlay3A;// IDirectPlay3A interface pointer
HANDLEhPlayerEvent;// player event to use
DPIDdpidPlayer;// ID of player created
BOOLbIsHost;// TRUE if we are hosting the session
BOOLbIsSecure;// TRUE if session is secure
} DPLAYINFO, *LPDPLAYINFO;

// message structures

// used to request the results of a wager
typedef struct {
DWORD dwType;// message type
DWORD dwAmountBet;// amount to wager
} MSG_SPINREQUEST, *LPMSG_SPINREQUEST;

// response to wager request
typedef struct {
DWORD dwType;// message type
HRESULThr;// result of request
LONGdwAmountWonOrLost;// amount won or lost
DWORD dwBalance;// current balance after wager
DWORD dwIndex[NUMWHEELS];// slot settings
} MSG_SPINRESPONSE, *LPMSG_SPINRESPONSE;

// used to request current balance
typedef struct {
DWORDdwType;// message type
} MSG_BALANCEREQUEST, *LPMSG_BALANCEREQUEST;

// response to balance request
typedef struct {
DWORDdwType;// message type
HRESULThr;// result of request
DWORDdwBalance;// current balance
} MSG_BALANCERESPONSE, *LPMSG_BALANCERESPONSE;

// guid for this application
// {EC4F7AA0-E1E0-11d0-9C50-00A0C905425E}
DEFINE_GUID(DPSLOTS_GUID,
0xec4f7aa0, 0xe1e0, 0x11d0, 0x9c, 0x50, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e);

// globals
extern HINSTANCEghInstance;// instance of application
extern CHARgszDatabaseName[MAXSTRLEN];

// common prototypes
extern HRESULTConnectUsingLobby(LPDPLAYINFO lpDPInfo);
extern HRESULTConnectUsingDialog(HINSTANCE hInstance, LPDPLAYINFO lpDPInfo);
extern voidErrorBox(LPSTR lpszErrorStr, HRESULT hr);
extern voidCheckDlgItem(HWND hDlg, int nIDDlgItem, BOOL bCheck);
extern BOOLDlgItemIsChecked(HWND hDlg, int nIDDlgItem);
extern voidEnableDlgButton(HWND hDlg, int nIDDlgItem, BOOL bEnable);

// client prototypes
extern BOOL CALLBACKClientWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
extern voidClientSystemMessage(LPDPLAYINFO lpDPInfo, LPDPMSG_GENERIC lpMsg, DWORD dwMsgSize,
DPID idFrom, DPID idTo);
extern voidClientApplicationMessage(LPDPLAYINFO lpDPInfo, LPDPMSG_GENERIC lpMsg, DWORD dwMsgSize,
DPID idFrom, DPID idTo);
// server prototypes
extern BOOL CALLBACKServerWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
extern voidServerSystemMessage(LPDPLAYINFO lpDPInfo, LPDPMSG_GENERIC lpMsg, DWORD dwMsgSize,
DPID idFrom, DPID idTo);
extern voidServerApplicationMessage(LPDPLAYINFO lpDPInfo, LPDPMSG_GENERIC lpMsg, DWORD dwMsgSize,
DPID idFrom, DPID idTo);