CClient(void);
Constructor
void Initialize(char* playername, HWND hWnd, HINSTANCE
hInst, GUID& appGUID, GUID& instGUID, DPIUserInterfaceResources&
resIDs);
Does many things to intialize the client
1) Sets up direct play
2) Lets user select network connection type
3) Lets user choose to join a game/session
4) Awaits messages from server which passes any initial information
back to the client after joining
This information includes playerID, direct play ID of the server,
any server assigned
characteristics such as starting location. This function will not
return until all this information is received.
void SendNewObjectCreation(CNetworkableObject* pObject);
Call this function when a new object is created on the client due
to user input. For example when a player fires an arrow
void Tick();
Call this function once every game tick.
This function processes all updates form the server
It also sends to the server an update of the player object which
will reflect any user input
The rest of this page details some of the internal implementation
VARIABLES:
DWORD serverID;
Stores the direct play ID of the server which is needed so that
messages can be sent to the server
PLAYER_INFO playerInfo;
local copy of player information relating to ID numbers and player
name
CDirectPlayInterface m_DPI;
Used to send and receive messages through direct play
DYNAMIC_CLIENT_MAP objectState;
Data structure storing any information about the game state that
the client knows form the server
PRIVATE FUNCTIONS:
void HandleSystemMessage(DPMSG_GENERIC& message)
Handles any messages sent by direct play automatically such as joins,
leaves or chats
void HandleObjectUpdate(CDataMessage& message);
Updates objects in game state individually upon receiving
this message from a server
This function also handles creation of object if it does not already
exist in the game state
void SendPlayerObjectUpdate(void);
This function is called every tick to update the server about the
current state of the player object. This is how user input is propagated
to the server
void ReceiveMessages();
Processes any relevant messages in the message queue
This function is called once every tick