|
coastline 0.0.4
|
Network play over DirectPlay: the session and its players, the messages between them, and the threads that receive the messages and exchange the streams of a race. More...
#include <windows.h>#include <dplay.h>#include <dplobby.h>#include "common/assetnames.h"#include "common/ghost.h"#include "common/networkrace.h"#include "common/racephases.h"
Go to the source code of this file.
Classes | |
| struct | DirectPlayInfo |
| The DirectPlay object of the game and its local player. More... | |
| struct | ServiceProvider |
| A service provider of DirectPlay found by EnumConnections. More... | |
| struct | NetworkSessionSettings |
| The settings of a network session the game hosts. More... | |
| struct | NetworkJoinCredentials |
| The local user and optional authentication fields used when joining a session. More... | |
| struct | NetPeerSlot |
| A peer of a network game. More... | |
| struct | SessionSlot |
| A player in a slot of the session. More... | |
| struct | NetPlayerSlot |
| A network player of a race. More... | |
Macros | |
| #define | SERVICE_PROVIDER_COUNT 16 |
| The number of entries of g_aServiceProviders. | |
| #define | NET_PEER_SLOT_COUNT 16 |
| The number of entries of g_aNetPeerSlots. | |
| #define | PLAYER_SLOT_STACK_SIZE 16 |
| The number of entries of g_anDepartedPlayerSlotStack and g_anJoinedPlayerSlotStack. | |
| #define | NET_PLAYER_SLOT_COUNT 16 |
| The number of entries of g_aNetPlayerSlots. | |
| #define | SESSION_SLOT_COUNT 8 |
| The number of entries of g_aSessionSlots. | |
| #define | WM_NETWORK_NOTICE 0x501 |
| The message the main window receives with a notice of network play in locked global memory as the second parameter. | |
Functions | |
| int | GetSelectedServiceProvider (GUID **ppGuid) |
| Report the GUID of the service provider chosen. | |
| HRESULT | DirectPlaySendLocked (IDirectPlay3A *pDirectPlay, DPID dpidFrom, DPID dpidTo, DWORD dwFlags, void *pData, DWORD dwSize) |
| Send a message of DirectPlay under g_DirectPlaySendCritSec. | |
| HRESULT | SendNetworkMessage6 (DirectPlayInfo *pInfo, DPID dpidPlayer) |
| Send message 6 of the game, which names a player, from the local player to every player. | |
| HRESULT | SendNetworkMessage3 (DirectPlayInfo *pInfo) |
| Send message 3 of the game from the local player to every player, unless the sends are blocked. | |
| HRESULT | SendNetworkReadyMessage (DirectPlayInfo *pInfo, DWORD dwReady) |
| Send whether the slot of a player is ready from the local player to every player, unless sends are blocked. | |
| HRESULT | SendNetworkMessage4 (DirectPlayInfo *pInfo, DPID dpidPlayer) |
| Send message 4 of the game, which identifies a player to boot, from the local player to every player, unless sends are blocked. | |
| HRESULT | SendNetworkRaceStateMessage (DirectPlayInfo *pInfo, DWORD dwState) |
| Send a state of the race from the local player to every player, unless sends are blocked. | |
| HRESULT | SendNetworkMessage7 (DirectPlayInfo *pInfo, DPID dpidPlayer) |
| Send message 7 of the game, which names a player, from the local player to every player. | |
| void | ResetNetworkStreamWithTimestamp (NetStream *pStream) |
| Empty a stream and write the time of the worker thread of network play at its start. | |
| unsigned | GetElapsedFrameCount (void) |
| Get the frames of network play since g_dwNetClockBaseMs, at three for each tenth of a second. | |
| void | WriteTimestampToStream (NetStream *pStream) |
| Empty a stream and write the current frame of network play at its start. | |
| HRESULT | DestroyLocalDirectPlayPlayer (void) |
| Destroy the local player of DirectPlay, when there is one. | |
| void | ClampFloat (float *pValue) |
| Limit a value to the range from -1 to 1. | |
| void | ClampWorldCoordinate (float *pValue) |
| Limit a coordinate to the range from 0 to 2048. | |
| void | ClampTerrainHeightCoordinate (float *pHeight) |
| Limit a height to the range from -256 to 256. | |
| bool | InitializeDirectPlay (void) |
| Create DirectPlay, connecting through a lobby when one launched the game, and start the receive thread and the network timer. | |
| HRESULT | CreateDirectPlayReceiveThread (HINSTANCE hInstance, DirectPlayInfo *pInfo) |
| Clear a DirectPlay info, create its player event, and start the thread that receives the messages of its player. | |
| HRESULT | ShutdownDirectPlaySession (DirectPlayInfo *pInfo) |
| Stop the receive thread, destroy the local player, and close and release DirectPlay. | |
| DWORD WINAPI | DirectPlayReceiveThreadProc (void *pParameter) |
| Receive the messages of the local player until the stop event is signalled. | |
| HRESULT | ReceiveAndDispatchDirectPlayMessages (DirectPlayInfo *pInfo) |
| Receive and handle every waiting message of the local player, growing the buffer of the messages in global memory as a message needs, until the receive fails. | |
| HRESULT | ConnectFromDirectPlayLobby (DirectPlayInfo *pInfo) |
| Connect to the session of the lobby that launched the game, and create the local player in it. | |
| int | JoinNetworkSession (void) |
| Join the selected session and initialise network play after a successful connection. | |
| HRESULT | JoinDirectPlaySession (IDirectPlay3A *pDirectPlay, const GUID *instance, NetworkJoinCredentials *credentials, DirectPlayInfo *pInfo) |
| Open a session, create the local player, and load its race settings. | |
| HRESULT | CreateDirectPlaySession (IDirectPlay3A *pDirectPlay, NetworkSessionSettings *pSettings, DirectPlayInfo *pInfo) |
| Create an eight-player session and its local host player. | |
| void | HostNetworkSession (void) |
| Create a session using the selected settings and initialise host network state. | |
| HRESULT | UpdateNetworkSessionSettings (void) |
| Publish the selected track, weather, car class, and lap count to the current session. | |
| bool | InitializeNetworkMutexes (int nReason) |
| Create every mutex of network play and reset the state of the network. | |
| void | CopySessionNameToBuffer (NetworkSessionSettings *pSettings) |
| Copy g_szSessionName into the settings of a session when it is longer than one character, and clear whether the session is secure. | |
| HRESULT | EnumeratePlayerAddress (HWND hWnd, IDirectPlayLobby2A *pLobby) |
| Enumerate the parts of the address of the local player for the lobby. | |
| BOOL WINAPI | EnumAddressCallback (REFGUID guidDataType, DWORD dwDataSize, const void *pData, void *pContext) |
| Walk the strings of the modem part of an address, and skip any other part. | |
| HRESULT | CreateDirectPlayObject (IDirectPlay3A **ppDirectPlay) |
| Create the DirectPlay object. | |
| HRESULT | CreateDirectPlayLobby (IDirectPlayLobby2A **ppLobby) |
| Create the DirectPlay lobby and enumerate the address of the local player. | |
| HRESULT | RefreshNetworkSessionList (IDirectPlay3A *pDirectPlay) |
| Enumerate the sessions of the selected service provider again. | |
| HRESULT | EnumerateNetworkPlayers (GUID *instance, LPDPENUMPLAYERSCALLBACK2 callback, void *context, DWORD flags) |
| Refresh player entries, enumerate players, and broadcast the local ready flag. | |
| BOOL CALLBACK | EnumSessionsCallback_AddSessionToList (LPCDPSESSIONDESC2 description, DWORD *timeout, DWORD flags, void *context) |
| Add an available session to the menu, then enumerate its players. | |
| BOOL WINAPI | EnumConnectionsCallback_StoreServiceProvider (const GUID *pGuidServiceProvider, void *pConnection, DWORD dwConnectionSize, const DPNAME *pName, DWORD dwFlags, void *pContext) |
| Store a service provider of IPX, TCP/IP, modem, or serial in g_aServiceProviders, and skip any other. | |
| void | ShowNetworkErrorMessage (const char *pszFormat, HRESULT hResult) |
| Show an error of network play with its DirectPlay error name. | |
| const char * | GetDirectPlayErrorString (HRESULT hResult) |
| Give the name of a DirectPlay error. | |
| void | InitializeDirectPlayForDesktopWindow (void) |
| Initialise DirectPlay for the main window. | |
| bool | RequestNetworkPause (void) |
| Request a pause from the other players of a network game, when no request waits. | |
| bool | SetNetworkReadyToStartFlag (void) |
| Mark the local player ready to start a network race. | |
| void | TickNetworkPauseRequest (void) |
| Send the request to pause of a network game. | |
| void | MaybeSendAllPlayersReadyPacket (void) |
| Send the local player information once every active vehicle has a session player. | |
| int | CountActivePlayerSlots (void) |
| Count active vehicles with a driver assigned. | |
| int | SendNetworkStreamReliable (DirectPlayInfo *pInfo, NetStream *pStream) |
| Send a stream to the server, or process it locally when hosting. | |
| int | SendNetworkStreamUnreliable (DirectPlayInfo *pInfo, NetStream *pStream) |
| Send a stream to every player and process it locally when hosting. | |
| int | SendPlayerInfoPacket (DirectPlayInfo *pInfo, unsigned char bPlayer, unsigned char bCar, unsigned char bColorR, unsigned char bColorG, unsigned char bColorB, DPID dpidOwner, const char *szPlayerName, int nState, unsigned char bTag) |
| Send a player's car, colour, owner, and status in a reliable packet. | |
| LRESULT WINAPI | HandleNetworkWindowMessage (HWND hWnd, UINT nMessage, WPARAM wParam, LPARAM lParam) |
| Give a message of the main window to the network play. | |
| char * | GetSlotPlayerName (int nSlot) |
| Copy a player's name under its slot mutex into the shared name buffer. | |
| int | SendTimeSyncReply (DirectPlayInfo *pInfo, unsigned timestamp) |
| Send a reliable reply with the timestamp received from the server. | |
| void | SyncNetworkClockFromServer (unsigned serverFrame, unsigned localTime, unsigned echoedFrame, unsigned roundTrip) |
| Adjust the network clock when a sampled reply improves the round-trip measurement. | |
| void | LoadNetworkPlayerColors (void) |
| Copy the local player's assigned colour into the first vehicle. | |
| int | SendPlayerJoinPacket (DirectPlayInfo *pInfo, unsigned char player, unsigned char red, unsigned char green, unsigned char blue, const char *name, unsigned char tag) |
| Send the joining player's car, colour, and name in a reliable packet. | |
| int | GetPlayerPingMs (int nSlot) |
| Get the time of the last round trip to the player of a slot, under the mutex of the slot. | |
| DPID | GetSlotPlayerId (int nSlot) |
| The player of the session in a slot of a peer, read under the mutex of the slot. | |
| int | GetSlotStatusThreadSafe (int nSlot) |
| The status of a slot of a peer, read under the mutex of the slot. | |
| int | GetNormalizedSlotStatusFlags (int nSlot) |
| The status of a slot of a peer in its low 6 bits, less 4, under the mutex of the slot. | |
| void | SetSlotStatusThreadSafe (int nSlot, int dwStatus) |
| Set the status of a slot of a peer under the mutex of the slot. | |
| unsigned | ReadPlayerSlotColorRgb (int slotIndex, unsigned char *red, unsigned char *green, unsigned char *blue) |
| Read a peer's selected car and RGB colour under its slot mutex. | |
| void | SetGlobalStatusString (const char *pszStatus) |
| Set the line of status of network play under the mutex of the notices. | |
| void | StopNetworkWorkerThread (void) |
| Stop the thread that works for the host of a network game, wait for it, and close it and its stop event. | |
| void | PromoteReadyNetworkPlayersToStart (void) |
| Move the players of a network game that are ready to the start. | |
| void | RankNetworkPlayersByProgress (void) |
| Rank the players of a network game by their progress. | |
| void | ResetAllNetworkPlayerStreams (void) |
| Empty the streams of every player of a network game. | |
| void | BuildNetworkPlayerStatusPackets (void) |
| Write the packets of the status of the players of a network game into their streams. | |
| int | FlushNetworkPlayerStreams (DirectPlayInfo *pInfo) |
| Send the streams of the players of a network game. | |
| DWORD WINAPI | NetworkWorkerThreadProc (LPVOID pParameter) |
| Do the work of the host of a network game once a second, sleeping until each second. | |
| void | CreateNetworkPlayerSlotMutexes (void) |
| Create the mutexes of the slots of the players of a network game. | |
| void | ResetAllPlayerSlots (void) |
| Reset race and peer states, timing, and finishing positions for every network player. | |
| HRESULT | SendNetworkFinishPositionMessage (DirectPlayInfo *pInfo, DPID dpidPlayer, DWORD dwPosition) |
| Broadcast a player's finishing position with guaranteed delivery. | |
| void | StartNetworkWorkerThread (void) |
| Start the thread that works for the host of a network game. | |
| bool | InitializeNetworkThreading (void) |
| Create the mutexes of the slots of the players and start the worker thread of a network game. | |
| DWORD | GetElapsedTimeSinceStart (void) |
| Get the time since the network session started. | |
| void | HandleDirectPlaySystemMessage (DirectPlayInfo *pInfo, DPMSG_GENERIC *pMessage, DWORD dwSize, DPID dpidFrom, DPID dpidTo) |
| Handle a message of the system of DirectPlay as the host or a client. | |
| void | ClearNetworkPlayerSlotsByOwner (DPID dpidOwner) |
| Free the slots of the network players a player of the session controls. | |
| void | HandlePlayerDisconnect (DPID dpidPlayer) |
| Remove a player that departed from a race of the network. | |
| void | ProcessMultiplayerPackets (DirectPlayInfo *pInfo, void *pData, DWORD dwSize, DPID dpidFrom, DPID dpidTo) |
| Handle the packets of a secure message as the host. | |
| int | FindNetworkSlotByPlayerId (DPID dpidPlayer) |
| Find a player's active slot, or the first free slot for a new player. | |
| void | ProcessNetworkDataStream (DirectPlayInfo *pInfo, void *pData, DWORD dwSize, DPID dpidFrom, DPID dpidTo) |
| Handle the packets of a secure message as a client. | |
| void | HandleDirectPlaySystemMessageHost (DirectPlayInfo *pInfo, DPMSG_GENERIC *pMessage, DWORD dwSize, DPID dpidFrom, DPID dpidTo) |
| Handle a message of the system of DirectPlay for the host of the session. | |
| void | HandleDirectPlaySystemMessageClient (DirectPlayInfo *pInfo, DPMSG_GENERIC *pMessage, DWORD dwSize, DPID dpidFrom, DPID dpidTo) |
| Handle a message of the system of DirectPlay for a client of the session. | |
| HRESULT | GetDirectPlaySessionDesc (IDirectPlay3A *pDirectPlay, DPSESSIONDESC2 **ppDesc) |
| Get the description of the session of DirectPlay in a buffer of locked global memory. | |
| HRESULT | LoadNetworkSettings (void) |
| Read the track, the weather, the class of car, the laps, and the name of the network session from its description, and choose a car of the class that can be chosen. | |
| void | ResetSessionSlotTable (void) |
| Free every slot of the session and unblock the sends. | |
| int | GetNetworkPlayerSlotStatus (int nSlot) |
| The state of a network player of a race, under the mutex of its slot. | |
| int | GetNetworkPeerChannelStatus (int nSlot) |
| The state of a network player as its own peer reports it, under the mutex of the entry. | |
| void | DestroyNetworkGroups (void) |
| Remove entries from the menu of network sessions. | |
| void | InitializeNetworkServiceProvider (void) |
| Start the service provider of network play chosen. | |
| HRESULT | CreateServiceProviderAddress (void **ppAddress, DWORD *pdwSize) |
| Build the compound address for the selected DirectPlay service provider. | |
| bool | InitServiceProviderAndStartTimer (void) |
| Start the service provider chosen and the timer of network play of the main window, and mark the DirectPlay session open. | |
| bool | InitServiceProviderAndStartSession (void) |
| Start the service provider chosen and the timer of network play as InitServiceProviderAndStartTimer() does, then enumerate the sessions again while the list of sessions exists. | |
| HRESULT | CloseAndReleaseDirectPlay (void) |
| Destroy the groups and the local player, close and release DirectPlay, and count one DirectPlay object less. | |
| void | MarkSessionListEntrySeen (DPID dpidPlayer) |
| Mark the slot of a player of the session as found, or give the player the first free slot. | |
| BOOL CALLBACK | EnumPlayersCallback_AddPlayerToList (DPID dpidPlayer, DWORD dwPlayerType, LPCDPNAME pName, DWORD dwFlags, void *pContext) |
| Add a non-spectator player to the network player menu. | |
| void | PurgeStaleSessionListEntries (void) |
| Free each slot of the session whose player was not found since the last purge. | |
| int | GetSessionSlotFlag (DPID dpidPlayer) |
| Get the flag of the slot of a player of the session. | |
| HRESULT | SendNetworkChatMessage (HWND hWindow, DirectPlayInfo *pInfo, bool bNotice) |
| Post the local chat line to the window and broadcast its text with guaranteed delivery. | |
| void | HandleMultiplayerSessionMessage (DirectPlayInfo *pInfo, void *pMessage, DWORD dwSize, DPID dpidFrom, DPID dpidTo) |
| Handle a message another player of the session sent. | |
| HRESULT | GetDirectPlayPlayerName (IDirectPlay3A *pDirectPlay, DPID dpidPlayer, DPNAME **ppName) |
| Retrieve a player's DirectPlay name in globally allocated, locked memory. | |
| HRESULT | FormatNetworkChatLine (IDirectPlay3A *pDirectPlay, DPID dpidPlayer, const char *text, char **ppLine, bool bNotice) |
| Format a chat line with the sender's name in globally allocated, locked memory. | |
| int | ToggleSelectedSessionSlotFlag (void) |
| Toggle the local player's session slot flag. | |
| bool | ShutdownNetworkSubsystem (int nReason) |
| End the network play of a game. | |
| void | ShutdownDirectPlay (void) |
| End network play, free the connection data of the service providers, write the count of DirectPlay objects left to the debugger, and release the lobby. | |
| void | FreeServiceProviderConnectionData (void) |
| Free the connection data of every service provider. | |
| void | DisconnectNetworkSession (void) |
| Exit the session of DirectPlay. | |
Variables | |
| DirectPlayInfo | g_DirectPlayInfo |
| The DirectPlay object of the game and its local player. | |
| DirectPlayInfo * | g_pDirectPlayInfo |
| The DirectPlay info other routines read, g_DirectPlayInfo once DirectPlay starts. | |
| DPID | g_dwNetCarSetupSelectedPlayerId |
| The DirectPlay identifier of the player selected during network car setup. | |
| ServiceProvider | g_aServiceProviders [SERVICE_PROVIDER_COUNT] |
| The service providers, indexed by IPX, TCP/IP, modem, and serial in that order. | |
| int | g_dwServiceProviderIndex |
| The index in g_aServiceProviders of the service provider chosen. | |
| unsigned | g_dwNetWorkerCurrentTime |
| The time of the worker thread of network play, written at the start of a packet. | |
| unsigned | g_dwNetClockBaseMs |
| The time network play started counting frames from, in milliseconds. | |
| unsigned | g_dwNetLastKeyframeFrame |
| The frame of the last key frame written to a stream. | |
| unsigned | g_dwNetRaceStartFrame |
| The frame a network race starts on. | |
| char | g_szModemPhoneNumber [] |
| The telephone number of a modem connection. | |
| char | g_szModemDeviceName [] |
| The device of a modem connection. | |
| int | g_dwLaunchedFromLobby |
| Whether a lobby launched the game. | |
| int | g_dwLobbyIsHost |
| Whether the lobby made the game the host. | |
| int | g_dwSessionEnumPending |
| Whether an enumeration of sessions is waiting for a reply. | |
| UINT_PTR | g_dwNetworkTimerId |
| The timer of the main window that drives network play. | |
| IDirectPlayLobby2A * | g_pDirectPlayLobby |
| The DirectPlay lobby. | |
| int | g_bDirectPlayReceiveThreadStarted |
| Whether the critical section of DirectPlay sends exists. | |
| CRITICAL_SECTION | g_DirectPlaySendCritSec |
| The critical section of DirectPlay sends. | |
| HANDLE | g_hDirectPlayReceiveStopEvent |
| The event that stops the receive thread. | |
| DWORD | g_dwDirectPlayReceiveThreadId |
| The identifier of the receive thread. | |
| HANDLE | g_hDirectPlayReceiveThread |
| The thread that receives the messages of the local player. | |
| char | g_szSessionName [] |
| The name of the network session. | |
| char | g_szDirectPlayErrorBuffer [16] |
| The name of an error GetDirectPlayErrorString() does not know, written in hexadecimal. | |
| int | g_dwDirectPlaySessionActive |
| Whether a DirectPlay session is open. | |
| int | g_nNetPauseRequestTicks |
| The ticks a request of a pause of a network game has waited, 0 for no request. | |
| int | g_nNetUnpauseRequestTicks |
| The ticks a request of the end of a pause of a network game has waited, 0 for no request. | |
| int | g_bNetReadyToStart |
| Whether the local player is ready to start a network race. | |
| int | g_bNetReceiveEnabled |
| Whether the messages received are processed. | |
| int | g_dwLocalNetPlayerId |
| The slot of the local player of a network game, -1 before one is assigned. | |
| const RECT | g_rcNetCarSetupPlayerList |
| The player list rectangle on the network car setup screen, in pixels. | |
| int | g_dwNetworkCarSetupShown |
| Whether the network car setup screen has been shown. | |
| NetPeerSlot | g_aNetPeerSlots [NET_PEER_SLOT_COUNT] |
| The peers of a network game. | |
| int | g_adwNetRaceOrder [NET_PEER_SLOT_COUNT] |
| The order of the players of a network race. | |
| char | g_szNetStatusString [] |
| The line of status of network play the game shows. | |
| int | g_bNetStatusStringDirty |
| Whether g_szNetStatusString changed since it was shown. | |
| int | g_anDepartedPlayerSlotStack [PLAYER_SLOT_STACK_SIZE] |
| The slots of the players that departed, for the race to remove. | |
| int | g_nDepartedPlayerStackTop |
| The index of the top of g_anDepartedPlayerSlotStack. | |
| int | g_anJoinedPlayerSlotStack [PLAYER_SLOT_STACK_SIZE] |
| The slots of the players that joined, for the race to add. | |
| int | g_nJoinedPlayerStackTop |
| The index of the top of g_anJoinedPlayerSlotStack. | |
| HANDLE | g_hNetRaceStartMutex |
| The mutex of the start of a network race. | |
| HANDLE | g_hNetReceiveMutex |
| The mutex of the messages received. | |
| HANDLE | g_hNetPauseMutex |
| The mutex of a pause of a network game. | |
| HANDLE | g_hNetUnpauseMutex |
| The mutex of the end of a pause of a network game. | |
| HANDLE | g_hNetReadyMutex |
| The mutex of the players that are ready. | |
| HANDLE | g_hNetKeyframeMutex |
| The mutex of the key frames of a network race. | |
| HANDLE | g_hJoinedPlayerStackMutex |
| The mutex of the stack of players that joined. | |
| HANDLE | g_hDepartedPlayerStackMutex |
| The mutex of the stack of players that departed. | |
| HANDLE | g_hNetRaceOrderMutex |
| The mutex of the order of a network race. | |
| HANDLE | g_hNetNotifyMutex |
| The mutex of the notices of network play. | |
| int | g_bNetWorkerThreadRunning |
| Whether the worker thread of the host runs. | |
| HANDLE | g_hNetWorkerStopEvent |
| The event that stops the worker thread of the host. | |
| HANDLE | g_hNetWorkerThread |
| The worker thread of the host. | |
| DWORD | g_dwNetWorkerThreadId |
| The identifier of the worker thread of network play. | |
| DWORD | g_dwNetWorkerNextTickTime |
| The time of the next tick of the worker thread of network play, in milliseconds. | |
| DWORD | g_dwNetSessionStartTime |
| The time the network session started, in milliseconds. | |
| int | g_dwNetworkSendBlocked |
| Whether the sends of network play are blocked. | |
| NetPlayerSlot | g_aNetPlayerSlots [NET_PLAYER_SLOT_COUNT] |
| The network players of a race. | |
| NetPlayerSlot | g_aNetPeerSlotMatrix [NET_PLAYER_SLOT_COUNT][NET_PLAYER_SLOT_COUNT] |
| The network players of a race as each peer reports them, by peer and then by player. | |
| SessionSlot | g_aSessionSlots [SESSION_SLOT_COUNT] |
| The players in the slots of the session. | |
| char | g_szNetworkChatText [] |
| The chat line being edited or sent from the network menu. | |
| int | g_dwNetworkDataStreamActive |
| Whether the network data stream is active. | |
| int | g_dwNetworkEscapePending |
| Whether the network menu has an escape request to process. | |
| int | g_dwDirectPlayInstanceCount |
| The number of DirectPlay objects that exist. | |
Network play over DirectPlay: the session and its players, the messages between them, and the threads that receive the messages and exchange the streams of a race.
| #define SERVICE_PROVIDER_COUNT 16 |
The number of entries of g_aServiceProviders.
| #define NET_PEER_SLOT_COUNT 16 |
The number of entries of g_aNetPeerSlots.
| #define PLAYER_SLOT_STACK_SIZE 16 |
The number of entries of g_anDepartedPlayerSlotStack and g_anJoinedPlayerSlotStack.
| #define NET_PLAYER_SLOT_COUNT 16 |
The number of entries of g_aNetPlayerSlots.
| #define SESSION_SLOT_COUNT 8 |
The number of entries of g_aSessionSlots.
| #define WM_NETWORK_NOTICE 0x501 |
The message the main window receives with a notice of network play in locked global memory as the second parameter.
The window frees the notice.
| int GetSelectedServiceProvider | ( | GUID ** | ppGuid | ) |
| HRESULT DirectPlaySendLocked | ( | IDirectPlay3A * | pDirectPlay, |
| DPID | dpidFrom, | ||
| DPID | dpidTo, | ||
| DWORD | dwFlags, | ||
| void * | pData, | ||
| DWORD | dwSize ) |
Send a message of DirectPlay under g_DirectPlaySendCritSec.
| pDirectPlay | The DirectPlay object. |
| dpidFrom | The player that sends. |
| dpidTo | The player that receives, or DPID_ALLPLAYERS. |
| dwFlags | The flags of the send. |
| pData | The message. |
| dwSize | The bytes of the message. |
| HRESULT SendNetworkMessage6 | ( | DirectPlayInfo * | pInfo, |
| DPID | dpidPlayer ) |
Send message 6 of the game, which names a player, from the local player to every player.
| pInfo | The session. |
| dpidPlayer | The player the message names. |
| HRESULT SendNetworkMessage3 | ( | DirectPlayInfo * | pInfo | ) |
Send message 3 of the game from the local player to every player, unless the sends are blocked.
The second word of the message is never written.
| pInfo | The session. |
| HRESULT SendNetworkReadyMessage | ( | DirectPlayInfo * | pInfo, |
| DWORD | dwReady ) |
Send whether the slot of a player is ready from the local player to every player, unless sends are blocked.
| pInfo | The session. |
| dwReady | The flag of the slot of the local player, from GetSessionSlotFlag(). |
| HRESULT SendNetworkMessage4 | ( | DirectPlayInfo * | pInfo, |
| DPID | dpidPlayer ) |
Send message 4 of the game, which identifies a player to boot, from the local player to every player, unless sends are blocked.
| pInfo | The session. |
| dpidPlayer | The player. |
| HRESULT SendNetworkRaceStateMessage | ( | DirectPlayInfo * | pInfo, |
| DWORD | dwState ) |
Send a state of the race from the local player to every player, unless sends are blocked.
| pInfo | The session. |
| dwState | The state. |
| HRESULT SendNetworkMessage7 | ( | DirectPlayInfo * | pInfo, |
| DPID | dpidPlayer ) |
Send message 7 of the game, which names a player, from the local player to every player.
| pInfo | The session. |
| dpidPlayer | The player the message names. |
| void ResetNetworkStreamWithTimestamp | ( | NetStream * | pStream | ) |
Empty a stream and write the time of the worker thread of network play at its start.
| pStream | The stream. |
| unsigned GetElapsedFrameCount | ( | void | ) |
Get the frames of network play since g_dwNetClockBaseMs, at three for each tenth of a second.
| void WriteTimestampToStream | ( | NetStream * | pStream | ) |
Empty a stream and write the current frame of network play at its start.
| pStream | The stream. |
| HRESULT DestroyLocalDirectPlayPlayer | ( | void | ) |
Destroy the local player of DirectPlay, when there is one.
| void ClampFloat | ( | float * | pValue | ) |
Limit a value to the range from -1 to 1.
| pValue | The value. |
| void ClampWorldCoordinate | ( | float * | pValue | ) |
Limit a coordinate to the range from 0 to 2048.
| pValue | The coordinate. |
| void ClampTerrainHeightCoordinate | ( | float * | pHeight | ) |
Limit a height to the range from -256 to 256.
| pHeight | The height. |
| bool InitializeDirectPlay | ( | void | ) |
Create DirectPlay, connecting through a lobby when one launched the game, and start the receive thread and the network timer.
| HRESULT CreateDirectPlayReceiveThread | ( | HINSTANCE | hInstance, |
| DirectPlayInfo * | pInfo ) |
Clear a DirectPlay info, create its player event, and start the thread that receives the messages of its player.
| hInstance | The module of the game. |
| pInfo | The info to set up. |
| HRESULT ShutdownDirectPlaySession | ( | DirectPlayInfo * | pInfo | ) |
Stop the receive thread, destroy the local player, and close and release DirectPlay.
| pInfo | The info to shut down, or null to stop the thread alone. |
Receive the messages of the local player until the stop event is signalled.
| pParameter | The DirectPlayInfo of the player. |
| HRESULT ReceiveAndDispatchDirectPlayMessages | ( | DirectPlayInfo * | pInfo | ) |
Receive and handle every waiting message of the local player, growing the buffer of the messages in global memory as a message needs, until the receive fails.
| pInfo | The info of the player. |
| HRESULT ConnectFromDirectPlayLobby | ( | DirectPlayInfo * | pInfo | ) |
Connect to the session of the lobby that launched the game, and create the local player in it.
The name of the player and of the session are copied from the lobby.
| pInfo | The info to fill, whose player event is already created. |
| int JoinNetworkSession | ( | void | ) |
Join the selected session and initialise network play after a successful connection.
| HRESULT JoinDirectPlaySession | ( | IDirectPlay3A * | pDirectPlay, |
| const GUID * | instance, | ||
| NetworkJoinCredentials * | credentials, | ||
| DirectPlayInfo * | pInfo ) |
Open a session, create the local player, and load its race settings.
| pDirectPlay | The connected DirectPlay object. |
| instance | The selected session instance. |
| credentials | Optional authentication fields and the local user name. |
| pInfo | Receives the local player and session state after a successful join. |
| HRESULT CreateDirectPlaySession | ( | IDirectPlay3A * | pDirectPlay, |
| NetworkSessionSettings * | pSettings, | ||
| DirectPlayInfo * | pInfo ) |
Create an eight-player session and its local host player.
| pDirectPlay | The connected DirectPlay object. |
| pSettings | The session name and secure-server setting. |
| pInfo | Receives the host player and session state after creation. |
| void HostNetworkSession | ( | void | ) |
Create a session using the selected settings and initialise host network state.
| HRESULT UpdateNetworkSessionSettings | ( | void | ) |
Publish the selected track, weather, car class, and lap count to the current session.
| bool InitializeNetworkMutexes | ( | int | nReason | ) |
Create every mutex of network play and reset the state of the network.
| nReason | Not read. The callers pass 1. |
| void CopySessionNameToBuffer | ( | NetworkSessionSettings * | pSettings | ) |
Copy g_szSessionName into the settings of a session when it is longer than one character, and clear whether the session is secure.
| pSettings | The settings. |
| HRESULT EnumeratePlayerAddress | ( | HWND | hWnd, |
| IDirectPlayLobby2A * | pLobby ) |
Enumerate the parts of the address of the local player for the lobby.
| hWnd | The main window. |
| pLobby | The lobby. |
| BOOL WINAPI EnumAddressCallback | ( | REFGUID | guidDataType, |
| DWORD | dwDataSize, | ||
| const void * | pData, | ||
| void * | pContext ) |
Walk the strings of the modem part of an address, and skip any other part.
| guidDataType | The type of the part. |
| dwDataSize | Not read. |
| pData | The data of the part. |
| pContext | Not read. |
| HRESULT CreateDirectPlayObject | ( | IDirectPlay3A ** | ppDirectPlay | ) |
Create the DirectPlay object.
| ppDirectPlay | Receives the object, or null. |
| HRESULT CreateDirectPlayLobby | ( | IDirectPlayLobby2A ** | ppLobby | ) |
Create the DirectPlay lobby and enumerate the address of the local player.
| ppLobby | Receives the lobby on success. |
| HRESULT RefreshNetworkSessionList | ( | IDirectPlay3A * | pDirectPlay | ) |
Enumerate the sessions of the selected service provider again.
| pDirectPlay | The DirectPlay object. |
| HRESULT EnumerateNetworkPlayers | ( | GUID * | instance, |
| LPDPENUMPLAYERSCALLBACK2 | callback, | ||
| void * | context, | ||
| DWORD | flags ) |
Refresh player entries, enumerate players, and broadcast the local ready flag.
| instance | The session instance to enumerate. |
| callback | The callback for each player. |
| context | User data passed to the callback. |
| flags | DirectPlay enumeration flags. |
| BOOL CALLBACK EnumSessionsCallback_AddSessionToList | ( | LPCDPSESSIONDESC2 | description, |
| DWORD * | timeout, | ||
| DWORD | flags, | ||
| void * | context ) |
Add an available session to the menu, then enumerate its players.
| description | The session description. |
| timeout | Unused. |
| flags | DirectPlay callback flags. |
| context | User data passed to the player enumeration. |
| BOOL WINAPI EnumConnectionsCallback_StoreServiceProvider | ( | const GUID * | pGuidServiceProvider, |
| void * | pConnection, | ||
| DWORD | dwConnectionSize, | ||
| const DPNAME * | pName, | ||
| DWORD | dwFlags, | ||
| void * | pContext ) |
Store a service provider of IPX, TCP/IP, modem, or serial in g_aServiceProviders, and skip any other.
| pGuidServiceProvider | The GUID of the service provider. |
| pConnection | The connection data. |
| dwConnectionSize | The size of the connection data. |
| pName | The name of the connection. |
| dwFlags | Not read. |
| pContext | Not read. |
| void ShowNetworkErrorMessage | ( | const char * | pszFormat, |
| HRESULT | hResult ) |
Show an error of network play with its DirectPlay error name.
| pszFormat | A wsprintfA format of the message, with one s for the error name. |
| hResult | The error. |
| const char * GetDirectPlayErrorString | ( | HRESULT | hResult | ) |
Give the name of a DirectPlay error.
| hResult | The error. |
| void InitializeDirectPlayForDesktopWindow | ( | void | ) |
Initialise DirectPlay for the main window.
| bool RequestNetworkPause | ( | void | ) |
Request a pause from the other players of a network game, when no request waits.
| bool SetNetworkReadyToStartFlag | ( | void | ) |
Mark the local player ready to start a network race.
| void TickNetworkPauseRequest | ( | void | ) |
Send the request to pause of a network game.
| void MaybeSendAllPlayersReadyPacket | ( | void | ) |
Send the local player information once every active vehicle has a session player.
| int CountActivePlayerSlots | ( | void | ) |
Count active vehicles with a driver assigned.
| int SendNetworkStreamReliable | ( | DirectPlayInfo * | pInfo, |
| NetStream * | pStream ) |
Send a stream to the server, or process it locally when hosting.
Sending is skipped while the network data stream is active.
| pInfo | The local session. |
| pStream | The stream to send. |
| int SendNetworkStreamUnreliable | ( | DirectPlayInfo * | pInfo, |
| NetStream * | pStream ) |
Send a stream to every player and process it locally when hosting.
Sending is skipped while the network data stream is active.
| pInfo | The local session. |
| pStream | The stream to send. |
| int SendPlayerInfoPacket | ( | DirectPlayInfo * | pInfo, |
| unsigned char | bPlayer, | ||
| unsigned char | bCar, | ||
| unsigned char | bColorR, | ||
| unsigned char | bColorG, | ||
| unsigned char | bColorB, | ||
| DPID | dpidOwner, | ||
| const char * | szPlayerName, | ||
| int | nState, | ||
| unsigned char | bTag ) |
Send a player's car, colour, owner, and status in a reliable packet.
| pInfo | The local session. |
| bPlayer | The player slot. |
| bCar | The car selection. |
| bColorR | The red component of the car colour. |
| bColorG | The green component of the car colour. |
| bColorB | The blue component of the car colour. |
| dpidOwner | The DirectPlay owner of the player. |
| szPlayerName | The player name, included for status values up to two. |
| nState | The player status, including any flags outside the low six bits. |
| bTag | Flags combined with the local player identifier. |
| LRESULT WINAPI HandleNetworkWindowMessage | ( | HWND | hWnd, |
| UINT | nMessage, | ||
| WPARAM | wParam, | ||
| LPARAM | lParam ) |
Give a message of the main window to the network play.
| hWnd | The main window. |
| nMessage | The message. |
| wParam | The first parameter of the message. |
| lParam | The second parameter of the message. |
| char * GetSlotPlayerName | ( | int | nSlot | ) |
Copy a player's name under its slot mutex into the shared name buffer.
| nSlot | The peer slot index. |
| int SendTimeSyncReply | ( | DirectPlayInfo * | pInfo, |
| unsigned | timestamp ) |
Send a reliable reply with the timestamp received from the server.
| pInfo | The local session. |
| timestamp | The timestamp to return. |
| void SyncNetworkClockFromServer | ( | unsigned | serverFrame, |
| unsigned | localTime, | ||
| unsigned | echoedFrame, | ||
| unsigned | roundTrip ) |
Adjust the network clock when a sampled reply improves the round-trip measurement.
| serverFrame | The server frame in the latest sample. |
| localTime | The local timestamp associated with the latest sample. |
| echoedFrame | A prior server frame echoed by the reply. |
| roundTrip | The measured round-trip duration. |
| void LoadNetworkPlayerColors | ( | void | ) |
Copy the local player's assigned colour into the first vehicle.
| int SendPlayerJoinPacket | ( | DirectPlayInfo * | pInfo, |
| unsigned char | player, | ||
| unsigned char | red, | ||
| unsigned char | green, | ||
| unsigned char | blue, | ||
| const char * | name, | ||
| unsigned char | tag ) |
Send the joining player's car, colour, and name in a reliable packet.
| pInfo | The local session. |
| player | The joining player slot. |
| red | The red component of the car colour. |
| green | The green component of the car colour. |
| blue | The blue component of the car colour. |
| name | The player name, truncated to 24 bytes in the packet. |
| tag | Flags combined with the local player identifier. |
| int GetPlayerPingMs | ( | int | nSlot | ) |
Get the time of the last round trip to the player of a slot, under the mutex of the slot.
| nSlot | The slot. |
| DPID GetSlotPlayerId | ( | int | nSlot | ) |
The player of the session in a slot of a peer, read under the mutex of the slot.
| nSlot | The slot. |
| int GetSlotStatusThreadSafe | ( | int | nSlot | ) |
The status of a slot of a peer, read under the mutex of the slot.
| nSlot | The slot. |
| int GetNormalizedSlotStatusFlags | ( | int | nSlot | ) |
The status of a slot of a peer in its low 6 bits, less 4, under the mutex of the slot.
| nSlot | The slot. |
| void SetSlotStatusThreadSafe | ( | int | nSlot, |
| int | dwStatus ) |
Set the status of a slot of a peer under the mutex of the slot.
| nSlot | The slot. |
| dwStatus | The status. |
| unsigned ReadPlayerSlotColorRgb | ( | int | slotIndex, |
| unsigned char * | red, | ||
| unsigned char * | green, | ||
| unsigned char * | blue ) |
Read a peer's selected car and RGB colour under its slot mutex.
| slotIndex | The peer slot index. |
| red | Receives the red colour component. |
| green | Receives the green colour component. |
| blue | Receives the blue colour component. |
| void SetGlobalStatusString | ( | const char * | pszStatus | ) |
Set the line of status of network play under the mutex of the notices.
| pszStatus | The line. |
| void StopNetworkWorkerThread | ( | void | ) |
Stop the thread that works for the host of a network game, wait for it, and close it and its stop event.
| void PromoteReadyNetworkPlayersToStart | ( | void | ) |
Move the players of a network game that are ready to the start.
| void RankNetworkPlayersByProgress | ( | void | ) |
Rank the players of a network game by their progress.
| void ResetAllNetworkPlayerStreams | ( | void | ) |
Empty the streams of every player of a network game.
| void BuildNetworkPlayerStatusPackets | ( | void | ) |
Write the packets of the status of the players of a network game into their streams.
| int FlushNetworkPlayerStreams | ( | DirectPlayInfo * | pInfo | ) |
Send the streams of the players of a network game.
| pInfo | The session. |
Do the work of the host of a network game once a second, sleeping until each second.
The loop never ends: it reads no stop event, so the thread never returns.
| pParameter | Not read. |
| void CreateNetworkPlayerSlotMutexes | ( | void | ) |
Create the mutexes of the slots of the players of a network game.
| void ResetAllPlayerSlots | ( | void | ) |
Reset race and peer states, timing, and finishing positions for every network player.
| HRESULT SendNetworkFinishPositionMessage | ( | DirectPlayInfo * | pInfo, |
| DPID | dpidPlayer, | ||
| DWORD | dwPosition ) |
Broadcast a player's finishing position with guaranteed delivery.
| pInfo | The local session. |
| dpidPlayer | The finishing player. |
| dwPosition | The finishing position. |
| void StartNetworkWorkerThread | ( | void | ) |
Start the thread that works for the host of a network game.
| bool InitializeNetworkThreading | ( | void | ) |
Create the mutexes of the slots of the players and start the worker thread of a network game.
| DWORD GetElapsedTimeSinceStart | ( | void | ) |
Get the time since the network session started.
| void HandleDirectPlaySystemMessage | ( | DirectPlayInfo * | pInfo, |
| DPMSG_GENERIC * | pMessage, | ||
| DWORD | dwSize, | ||
| DPID | dpidFrom, | ||
| DPID | dpidTo ) |
Handle a message of the system of DirectPlay as the host or a client.
While the front end is up, a player that joins or departs is posted to the main window as a notice, a player that departs frees its slot of the session, and a new description of the session reloads the settings of the network.
| pInfo | The info of the local player. |
| pMessage | The message. |
| dwSize | The size of the message. |
| dpidFrom | The sender, DPID_SYSMSG. |
| dpidTo | The receiver. |
| void ClearNetworkPlayerSlotsByOwner | ( | DPID | dpidOwner | ) |
Free the slots of the network players a player of the session controls.
| dpidOwner | The player. |
| void HandlePlayerDisconnect | ( | DPID | dpidPlayer | ) |
Remove a player that departed from a race of the network.
Each slot of a peer of the player with a status is pushed on g_anDepartedPlayerSlotStack and cleared, and the line of status reports that the player left.
| dpidPlayer | The player. |
| void ProcessMultiplayerPackets | ( | DirectPlayInfo * | pInfo, |
| void * | pData, | ||
| DWORD | dwSize, | ||
| DPID | dpidFrom, | ||
| DPID | dpidTo ) |
Handle the packets of a secure message as the host.
| pInfo | The info of the local player. |
| pData | The data of the message. |
| dwSize | The size of the data. |
| dpidFrom | The sender. |
| dpidTo | The receiver. |
| int FindNetworkSlotByPlayerId | ( | DPID | dpidPlayer | ) |
Find a player's active slot, or the first free slot for a new player.
| dpidPlayer | The player identifier. |
| void ProcessNetworkDataStream | ( | DirectPlayInfo * | pInfo, |
| void * | pData, | ||
| DWORD | dwSize, | ||
| DPID | dpidFrom, | ||
| DPID | dpidTo ) |
Handle the packets of a secure message as a client.
| pInfo | The info of the local player. |
| pData | The data of the message. |
| dwSize | The size of the data. |
| dpidFrom | The sender. |
| dpidTo | The receiver. |
| void HandleDirectPlaySystemMessageHost | ( | DirectPlayInfo * | pInfo, |
| DPMSG_GENERIC * | pMessage, | ||
| DWORD | dwSize, | ||
| DPID | dpidFrom, | ||
| DPID | dpidTo ) |
Handle a message of the system of DirectPlay for the host of the session.
A player that departs while the front end is down frees its slots and exits the race, and the data of a secure message goes to ProcessMultiplayerPackets().
| pInfo | The info of the local player. |
| pMessage | The message. |
| dwSize | The size of the message. |
| dpidFrom | The sender, DPID_SYSMSG. |
| dpidTo | The receiver. |
| void HandleDirectPlaySystemMessageClient | ( | DirectPlayInfo * | pInfo, |
| DPMSG_GENERIC * | pMessage, | ||
| DWORD | dwSize, | ||
| DPID | dpidFrom, | ||
| DPID | dpidTo ) |
Handle a message of the system of DirectPlay for a client of the session.
A player that departs while the front end is down exits the race, and the data of a secure message goes to ProcessNetworkDataStream().
| pInfo | The info of the local player. |
| pMessage | The message. |
| dwSize | The size of the message. |
| dpidFrom | The sender, DPID_SYSMSG. |
| dpidTo | The receiver. |
| HRESULT GetDirectPlaySessionDesc | ( | IDirectPlay3A * | pDirectPlay, |
| DPSESSIONDESC2 ** | ppDesc ) |
Get the description of the session of DirectPlay in a buffer of locked global memory.
| pDirectPlay | The DirectPlay object. |
| ppDesc | Receives the description, for the caller to unlock and free. |
| HRESULT LoadNetworkSettings | ( | void | ) |
Read the track, the weather, the class of car, the laps, and the name of the network session from its description, and choose a car of the class that can be chosen.
| void ResetSessionSlotTable | ( | void | ) |
Free every slot of the session and unblock the sends.
| int GetNetworkPlayerSlotStatus | ( | int | nSlot | ) |
The state of a network player of a race, under the mutex of its slot.
| nSlot | The slot. |
| int GetNetworkPeerChannelStatus | ( | int | nSlot | ) |
The state of a network player as its own peer reports it, under the mutex of the entry.
| nSlot | The slot of the player and of its peer. |
| void DestroyNetworkGroups | ( | void | ) |
Remove entries from the menu of network sessions.
| void InitializeNetworkServiceProvider | ( | void | ) |
Start the service provider of network play chosen.
Build the compound address for the selected DirectPlay service provider.
| ppAddress | Receives globally allocated, locked address data on success. |
| pdwSize | Receives the address size in bytes on success. |
| bool InitServiceProviderAndStartTimer | ( | void | ) |
Start the service provider chosen and the timer of network play of the main window, and mark the DirectPlay session open.
| bool InitServiceProviderAndStartSession | ( | void | ) |
Start the service provider chosen and the timer of network play as InitServiceProviderAndStartTimer() does, then enumerate the sessions again while the list of sessions exists.
| HRESULT CloseAndReleaseDirectPlay | ( | void | ) |
Destroy the groups and the local player, close and release DirectPlay, and count one DirectPlay object less.
| void MarkSessionListEntrySeen | ( | DPID | dpidPlayer | ) |
Mark the slot of a player of the session as found, or give the player the first free slot.
The flag of a new slot is set for the host and cleared for another player. A player is dropped when no slot is free.
| dpidPlayer | The player. |
| BOOL CALLBACK EnumPlayersCallback_AddPlayerToList | ( | DPID | dpidPlayer, |
| DWORD | dwPlayerType, | ||
| LPCDPNAME | pName, | ||
| DWORD | dwFlags, | ||
| void * | pContext ) |
Add a non-spectator player to the network player menu.
| dpidPlayer | The player identifier. |
| dwPlayerType | Unused. |
| pName | The player's DirectPlay name. |
| dwFlags | Enumeration flags, including the spectator flag. |
| pContext | Unused. |
| void PurgeStaleSessionListEntries | ( | void | ) |
Free each slot of the session whose player was not found since the last purge.
| int GetSessionSlotFlag | ( | DPID | dpidPlayer | ) |
Get the flag of the slot of a player of the session.
| dpidPlayer | The player. |
| HRESULT SendNetworkChatMessage | ( | HWND | hWindow, |
| DirectPlayInfo * | pInfo, | ||
| bool | bNotice ) |
Post the local chat line to the window and broadcast its text with guaranteed delivery.
| hWindow | The window that receives the local notice. |
| pInfo | The local session. |
| bNotice | Whether to format the line as a notice rather than chat. |
| void HandleMultiplayerSessionMessage | ( | DirectPlayInfo * | pInfo, |
| void * | pMessage, | ||
| DWORD | dwSize, | ||
| DPID | dpidFrom, | ||
| DPID | dpidTo ) |
Handle a message another player of the session sent.
The return, if any, is not recovered yet.
| pInfo | The info of the local player. |
| pMessage | The message. |
| dwSize | The size of the message. |
| dpidFrom | The sender. |
| dpidTo | The receiver. |
| HRESULT GetDirectPlayPlayerName | ( | IDirectPlay3A * | pDirectPlay, |
| DPID | dpidPlayer, | ||
| DPNAME ** | ppName ) |
Retrieve a player's DirectPlay name in globally allocated, locked memory.
| pDirectPlay | The DirectPlay object. |
| dpidPlayer | The player identifier. |
| ppName | Receives the name on success; the caller must unlock and free it. |
| HRESULT FormatNetworkChatLine | ( | IDirectPlay3A * | pDirectPlay, |
| DPID | dpidPlayer, | ||
| const char * | text, | ||
| char ** | ppLine, | ||
| bool | bNotice ) |
Format a chat line with the sender's name in globally allocated, locked memory.
| pDirectPlay | The DirectPlay object. |
| dpidPlayer | The sender identifier. |
| text | The chat message. |
| ppLine | Receives the line on success; the caller must unlock and free it. |
| bNotice | Whether to omit the colon between the sender and the text. |
| int ToggleSelectedSessionSlotFlag | ( | void | ) |
Toggle the local player's session slot flag.
| bool ShutdownNetworkSubsystem | ( | int | nReason | ) |
End the network play of a game.
The host stops its worker thread, the session of DirectPlay shuts down, and every mutex of network play is closed.
| nReason | Not read. The callers pass 1. |
| void ShutdownDirectPlay | ( | void | ) |
End network play, free the connection data of the service providers, write the count of DirectPlay objects left to the debugger, and release the lobby.
| void FreeServiceProviderConnectionData | ( | void | ) |
Free the connection data of every service provider.
| void DisconnectNetworkSession | ( | void | ) |
Exit the session of DirectPlay.
|
extern |
The DirectPlay object of the game and its local player.
|
extern |
The DirectPlay info other routines read, g_DirectPlayInfo once DirectPlay starts.
|
extern |
The DirectPlay identifier of the player selected during network car setup.
|
extern |
The service providers, indexed by IPX, TCP/IP, modem, and serial in that order.
|
extern |
The index in g_aServiceProviders of the service provider chosen.
|
extern |
The time of the worker thread of network play, written at the start of a packet.
|
extern |
The time network play started counting frames from, in milliseconds.
|
extern |
The frame of the last key frame written to a stream.
|
extern |
The frame a network race starts on.
|
extern |
The telephone number of a modem connection.
|
extern |
The device of a modem connection.
|
extern |
Whether a lobby launched the game.
|
extern |
Whether the lobby made the game the host.
|
extern |
Whether an enumeration of sessions is waiting for a reply.
|
extern |
The timer of the main window that drives network play.
|
extern |
The DirectPlay lobby.
|
extern |
Whether the critical section of DirectPlay sends exists.
|
extern |
The critical section of DirectPlay sends.
|
extern |
The event that stops the receive thread.
|
extern |
The identifier of the receive thread.
|
extern |
The thread that receives the messages of the local player.
|
extern |
The name of the network session.
|
extern |
The name of an error GetDirectPlayErrorString() does not know, written in hexadecimal.
|
extern |
Whether a DirectPlay session is open.
|
extern |
The ticks a request of a pause of a network game has waited, 0 for no request.
|
extern |
The ticks a request of the end of a pause of a network game has waited, 0 for no request.
|
extern |
Whether the local player is ready to start a network race.
|
extern |
Whether the messages received are processed.
|
extern |
The slot of the local player of a network game, -1 before one is assigned.
|
extern |
The player list rectangle on the network car setup screen, in pixels.
|
extern |
Whether the network car setup screen has been shown.
|
extern |
The peers of a network game.
|
extern |
The order of the players of a network race.
|
extern |
The line of status of network play the game shows.
Its size is not recovered yet.
|
extern |
Whether g_szNetStatusString changed since it was shown.
|
extern |
The slots of the players that departed, for the race to remove.
|
extern |
The index of the top of g_anDepartedPlayerSlotStack.
|
extern |
The slots of the players that joined, for the race to add.
|
extern |
The index of the top of g_anJoinedPlayerSlotStack.
|
extern |
The mutex of the start of a network race.
|
extern |
The mutex of the messages received.
|
extern |
The mutex of a pause of a network game.
|
extern |
The mutex of the end of a pause of a network game.
|
extern |
The mutex of the players that are ready.
|
extern |
The mutex of the key frames of a network race.
|
extern |
The mutex of the stack of players that joined.
|
extern |
The mutex of the stack of players that departed.
|
extern |
The mutex of the order of a network race.
|
extern |
The mutex of the notices of network play.
|
extern |
Whether the worker thread of the host runs.
|
extern |
The event that stops the worker thread of the host.
|
extern |
The worker thread of the host.
|
extern |
The identifier of the worker thread of network play.
|
extern |
The time of the next tick of the worker thread of network play, in milliseconds.
|
extern |
The time the network session started, in milliseconds.
|
extern |
Whether the sends of network play are blocked.
|
extern |
The network players of a race.
|
extern |
The network players of a race as each peer reports them, by peer and then by player.
|
extern |
The players in the slots of the session.
|
extern |
The chat line being edited or sent from the network menu.
|
extern |
Whether the network data stream is active.
|
extern |
Whether the network menu has an escape request to process.
|
extern |
The number of DirectPlay objects that exist.