coastline 0.0.4
Loading...
Searching...
No Matches
directplay.h
Go to the documentation of this file.
1#pragma once
2
8
9#include <windows.h>
10// The headers below need the types of windows.h.
11#include <dplay.h>
12#include <dplobby.h>
13
14#include "common/assetnames.h"
15#include "common/ghost.h"
16#include "common/networkrace.h"
17#include "common/racephases.h"
18
27
35
37#define SERVICE_PROVIDER_COUNT 16
38
46
54
62
70
78
79#ifdef __cplusplus
80extern "C" {
81#endif
82
92
99extern unsigned g_dwNetWorkerCurrentTime;
100
115 DPID dpidFrom,
116 DPID dpidTo,
117 DWORD dwFlags,
118 void *pData,
119 DWORD dwSize);
120
131
142
154
166
177
188
189#ifdef __cplusplus
190}
191#endif
192
193class NetStream;
194
195#ifdef __cplusplus
196extern "C" {
197#endif
198
207
214extern unsigned g_dwNetClockBaseMs;
215
223unsigned GetElapsedFrameCount(void);
224
231extern unsigned g_dwNetLastKeyframeFrame;
232
241
248extern unsigned g_dwNetRaceStartFrame;
249
258
266void ClampFloat(float *pValue);
267
275void ClampWorldCoordinate(float *pValue);
276
284void ClampTerrainHeightCoordinate(float *pHeight);
285
292extern char g_szModemPhoneNumber[];
293
300extern char g_szModemDeviceName[];
301
308extern int g_dwLaunchedFromLobby;
309
316extern int g_dwLobbyIsHost;
317
324extern int g_dwSessionEnumPending;
325
333
341
349
357
365
373
381
391
403
413
423
434
445
452extern char g_szSessionName[];
453
459
462 char localUserName[200];
463 char userName[200];
464 char password[200];
465 char domain[200];
466};
467
476
489 const GUID *instance,
490 NetworkJoinCredentials *credentials,
491 DirectPlayInfo *pInfo);
492
504 NetworkSessionSettings *pSettings,
505 DirectPlayInfo *pInfo);
506
514
523
532bool InitializeNetworkMutexes(int nReason);
533
543
554
567 DWORD dwDataSize,
568 const void *pData,
569 void *pContext);
570
580
590
600
613 LPDPENUMPLAYERSCALLBACK2 callback,
614 void *context,
615 DWORD flags);
616
629 DWORD *timeout,
630 DWORD flags,
631 void *context);
632
648 void *pConnection,
649 DWORD dwConnectionSize,
650 const DPNAME *pName,
651 DWORD dwFlags,
652 void *pContext);
653
662void ShowNetworkErrorMessage(const char *pszFormat, HRESULT hResult);
663
670extern char g_szDirectPlayErrorBuffer[16];
671
682
690
698
705extern int g_nNetPauseRequestTicks;
706
715
723
730extern int g_bNetReadyToStart;
731
740
747extern int g_bNetReceiveEnabled;
748
755extern int g_dwLocalNetPlayerId;
756
764
772
781
793
805
824 unsigned char bPlayer,
825 unsigned char bCar,
826 unsigned char bColorR,
827 unsigned char bColorG,
828 unsigned char bColorB,
829 DPID dpidOwner,
830 const char *szPlayerName,
831 int nState,
832 unsigned char bTag);
833
839extern unsigned g_dwNetRaceStartTimeMs;
841
853
861
868extern int g_dwNetworkCarSetupShown;
869
891
894struct NetClockSample {
895 unsigned dwServerFrame;
896 unsigned dwLocalTime;
897};
898
903extern NetClockSample g_aNetClockSamples[8];
904
909extern int g_nNetClockSampleIndex;
910
915extern unsigned g_dwNetBestClockRoundTrip;
916
921extern char g_szSlotPlayerNameBuffer[0x400];
922
927extern int g_nPendingNetSoundEffect;
929
938char *GetSlotPlayerName(int nSlot);
939
949int SendTimeSyncReply(DirectPlayInfo *pInfo, unsigned timestamp);
950
961void SyncNetworkClockFromServer(unsigned serverFrame,
962 unsigned localTime,
963 unsigned echoedFrame,
964 unsigned roundTrip);
965
973
989 unsigned char player,
990 unsigned char red,
991 unsigned char green,
992 unsigned char blue,
993 const char *name,
994 unsigned char tag);
995
997#define NET_PEER_SLOT_COUNT 16
998
1006
1015int GetPlayerPingMs(int nSlot);
1016
1024
1034
1044
1054
1063void SetSlotStatusThreadSafe(int nSlot, int dwStatus);
1064
1071extern char g_szNetStatusString[];
1072
1079extern int g_bNetStatusStringDirty;
1080
1092unsigned ReadPlayerSlotColorRgb(int slotIndex,
1093 unsigned char *red,
1094 unsigned char *green,
1095 unsigned char *blue);
1096
1104void SetGlobalStatusString(const char *pszStatus);
1105
1107#define PLAYER_SLOT_STACK_SIZE 16
1108
1116
1123extern int g_nDepartedPlayerStackTop;
1124
1132
1139extern int g_nJoinedPlayerStackTop;
1140
1148
1156
1164
1172
1180
1188
1196
1204
1212
1220
1227extern int g_bNetWorkerThreadRunning;
1228
1236
1244
1253
1261
1269
1277
1285
1293
1301
1310
1321
1329
1337
1343extern DWORD g_dwNetSlotResetTime;
1344
1349extern unsigned g_dwNetNextFinishPosition;
1351
1363
1371
1380
1388
1397
1413 DirectPlayInfo *pInfo, DPMSG_GENERIC *pMessage, DWORD dwSize, DPID dpidFrom, DPID dpidTo);
1414
1423
1434
1447 DirectPlayInfo *pInfo, void *pData, DWORD dwSize, DPID dpidFrom, DPID dpidTo);
1448
1458
1471 DirectPlayInfo *pInfo, void *pData, DWORD dwSize, DPID dpidFrom, DPID dpidTo);
1472
1487 DirectPlayInfo *pInfo, DPMSG_GENERIC *pMessage, DWORD dwSize, DPID dpidFrom, DPID dpidTo);
1488
1503 DirectPlayInfo *pInfo, DPMSG_GENERIC *pMessage, DWORD dwSize, DPID dpidFrom, DPID dpidTo);
1504
1515
1526
1534
1541extern int g_dwNetworkSendBlocked;
1542
1550
1571
1573#define NET_PLAYER_SLOT_COUNT 16
1574
1582
1590
1596extern int g_bNetRaceStarted;
1598
1608
1618
1626
1634
1644HRESULT CreateServiceProviderAddress(void **ppAddress, DWORD *pdwSize);
1645
1655
1666
1676
1678#define SESSION_SLOT_COUNT 8
1679
1687
1711 DPID dpidPlayer, DWORD dwPlayerType, LPCDPNAME pName, DWORD dwFlags, void *pContext);
1712
1720
1729int GetSessionSlotFlag(DPID dpidPlayer);
1730
1735#define WM_NETWORK_NOTICE 0x501
1736
1743extern char g_szNetworkChatText[];
1744
1755HRESULT SendNetworkChatMessage(HWND hWindow, DirectPlayInfo *pInfo, bool bNotice);
1756
1769 DirectPlayInfo *pInfo, void *pMessage, DWORD dwSize, DPID dpidFrom, DPID dpidTo);
1770
1781HRESULT GetDirectPlayPlayerName(IDirectPlay3A *pDirectPlay, DPID dpidPlayer, DPNAME **ppName);
1782
1796 IDirectPlay3A *pDirectPlay, DPID dpidPlayer, const char *text, char **ppLine, bool bNotice);
1797
1810extern int g_dwNetworkEscapePending;
1819
1825extern const char *g_apszPlaceNames[8];
1827
1838
1847
1855
1863
1871#ifdef __cplusplus
1872}
1873#endif
A stream of the bytes and bits of a packet, read and written from the most significant bit.
Definition netstream.h:16
void CreateNetworkPlayerSlotMutexes(void)
Create the mutexes of the slots of the players of a network game.
DirectPlayInfo g_DirectPlayInfo
The DirectPlay object of the game and its local player.
int g_dwNetworkEscapePending
Whether the network menu has an escape request to process.
void ShutdownDirectPlay(void)
End network play, free the connection data of the service providers, write the count of DirectPlay ob...
DPID g_dwNetCarSetupSelectedPlayerId
The DirectPlay identifier of the player selected during network car setup.
UINT_PTR g_dwNetworkTimerId
The timer of the main window that drives network play.
int g_bNetReceiveEnabled
Whether the messages received are processed.
DWORD WINAPI DirectPlayReceiveThreadProc(void *pParameter)
Receive the messages of the local player until the stop event is signalled.
HANDLE g_hNetUnpauseMutex
The mutex of the end of a pause of a network game.
HRESULT SendNetworkChatMessage(HWND hWindow, DirectPlayInfo *pInfo, bool bNotice)
Post the local chat line to the window and broadcast its text with guaranteed delivery.
#define SERVICE_PROVIDER_COUNT
The number of entries of g_aServiceProviders.
Definition directplay.h:37
ServiceProvider g_aServiceProviders[SERVICE_PROVIDER_COUNT]
The service providers, indexed by IPX, TCP/IP, modem, and serial in that order.
IDirectPlayLobby2A * g_pDirectPlayLobby
The DirectPlay lobby.
NetPlayerSlot g_aNetPlayerSlots[NET_PLAYER_SLOT_COUNT]
The network players of a race.
HRESULT CloseAndReleaseDirectPlay(void)
Destroy the groups and the local player, close and release DirectPlay, and count one DirectPlay objec...
bool InitializeDirectPlay(void)
Create DirectPlay, connecting through a lobby when one launched the game, and start the receive threa...
void LoadNetworkPlayerColors(void)
Copy the local player's assigned colour into the first vehicle.
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.
int g_dwLocalNetPlayerId
The slot of the local player of a network game, -1 before one is assigned.
void MaybeSendAllPlayersReadyPacket(void)
Send the local player information once every active vehicle has a session player.
int SendTimeSyncReply(DirectPlayInfo *pInfo, unsigned timestamp)
Send a reliable reply with the timestamp received from the server.
HRESULT UpdateNetworkSessionSettings(void)
Publish the selected track, weather, car class, and lap count to the current session.
void ResetNetworkStreamWithTimestamp(NetStream *pStream)
Empty a stream and write the time of the worker thread of network play at its start.
HRESULT ReceiveAndDispatchDirectPlayMessages(DirectPlayInfo *pInfo)
Receive and handle every waiting message of the local player, growing the buffer of the messages in g...
SessionSlot g_aSessionSlots[SESSION_SLOT_COUNT]
The players in the slots of the session.
DWORD g_dwNetWorkerThreadId
The identifier of the worker thread of network play.
int ToggleSelectedSessionSlotFlag(void)
Toggle the local player's session slot flag.
void ClearNetworkPlayerSlotsByOwner(DPID dpidOwner)
Free the slots of the network players a player of the session controls.
HRESULT JoinDirectPlaySession(IDirectPlay3A *pDirectPlay, const GUID *instance, NetworkJoinCredentials *credentials, DirectPlayInfo *pInfo)
Open a session, create the local player, and load its race settings.
unsigned g_dwNetClockBaseMs
The time network play started counting frames from, in milliseconds.
HANDLE g_hNetKeyframeMutex
The mutex of the key frames of a network race.
HRESULT SendNetworkMessage6(DirectPlayInfo *pInfo, DPID dpidPlayer)
Send message 6 of the game, which names a player, from the local player to every player.
HANDLE g_hDirectPlayReceiveStopEvent
The event that stops the receive thread.
void SetSlotStatusThreadSafe(int nSlot, int dwStatus)
Set the status of a slot of a peer under the mutex of the slot.
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 HandleMultiplayerSessionMessage(DirectPlayInfo *pInfo, void *pMessage, DWORD dwSize, DPID dpidFrom, DPID dpidTo)
Handle a message another player of the session sent.
HANDLE g_hNetPauseMutex
The mutex of a pause of a network game.
HRESULT SendNetworkMessage3(DirectPlayInfo *pInfo)
Send message 3 of the game from the local player to every player, unless the sends are blocked.
int GetNetworkPlayerSlotStatus(int nSlot)
The state of a network player of a race, under the mutex of its slot.
DWORD g_dwDirectPlayReceiveThreadId
The identifier of the receive thread.
HANDLE g_hNetWorkerThread
The worker thread of the host.
HRESULT GetDirectPlayPlayerName(IDirectPlay3A *pDirectPlay, DPID dpidPlayer, DPNAME **ppName)
Retrieve a player's DirectPlay name in globally allocated, locked memory.
void ShowNetworkErrorMessage(const char *pszFormat, HRESULT hResult)
Show an error of network play with its DirectPlay error name.
int CountActivePlayerSlots(void)
Count active vehicles with a driver assigned.
HRESULT CreateDirectPlayReceiveThread(HINSTANCE hInstance, DirectPlayInfo *pInfo)
Clear a DirectPlay info, create its player event, and start the thread that receives the messages of ...
HRESULT DirectPlaySendLocked(IDirectPlay3A *pDirectPlay, DPID dpidFrom, DPID dpidTo, DWORD dwFlags, void *pData, DWORD dwSize)
Send a message of DirectPlay under g_DirectPlaySendCritSec.
HRESULT GetDirectPlaySessionDesc(IDirectPlay3A *pDirectPlay, DPSESSIONDESC2 **ppDesc)
Get the description of the session of DirectPlay in a buffer of locked global memory.
HRESULT CreateDirectPlaySession(IDirectPlay3A *pDirectPlay, NetworkSessionSettings *pSettings, DirectPlayInfo *pInfo)
Create an eight-player session and its local host player.
void HandlePlayerDisconnect(DPID dpidPlayer)
Remove a player that departed from a race of the network.
void InitializeNetworkServiceProvider(void)
Start the service provider of network play chosen.
bool InitializeNetworkMutexes(int nReason)
Create every mutex of network play and reset the state of the network.
int GetSlotStatusThreadSafe(int nSlot)
The status of a slot of a peer, read under the mutex of the slot.
HRESULT LoadNetworkSettings(void)
Read the track, the weather, the class of car, the laps, and the name of the network session from its...
HRESULT EnumeratePlayerAddress(HWND hWnd, IDirectPlayLobby2A *pLobby)
Enumerate the parts of the address of the local player for the lobby.
NetPeerSlot g_aNetPeerSlots[NET_PEER_SLOT_COUNT]
The peers of a network game.
int g_dwDirectPlaySessionActive
Whether a DirectPlay session is open.
void ProcessMultiplayerPackets(DirectPlayInfo *pInfo, void *pData, DWORD dwSize, DPID dpidFrom, DPID dpidTo)
Handle the packets of a secure message as the host.
HRESULT ConnectFromDirectPlayLobby(DirectPlayInfo *pInfo)
Connect to the session of the lobby that launched the game, and create the local player in it.
char * GetSlotPlayerName(int nSlot)
Copy a player's name under its slot mutex into the shared name buffer.
void DisconnectNetworkSession(void)
Exit the session of DirectPlay.
unsigned GetElapsedFrameCount(void)
Get the frames of network play since g_dwNetClockBaseMs, at three for each tenth of a second.
void PromoteReadyNetworkPlayersToStart(void)
Move the players of a network game that are ready to the start.
HANDLE g_hNetNotifyMutex
The mutex of the notices of network play.
void FreeServiceProviderConnectionData(void)
Free the connection data of every service provider.
void ResetSessionSlotTable(void)
Free every slot of the session and unblock the sends.
bool RequestNetworkPause(void)
Request a pause from the other players of a network game, when no request waits.
int g_dwLaunchedFromLobby
Whether a lobby launched the game.
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.
void DestroyNetworkGroups(void)
Remove entries from the menu of network sessions.
HRESULT CreateDirectPlayLobby(IDirectPlayLobby2A **ppLobby)
Create the DirectPlay lobby and enumerate the address of the local player.
void ResetAllNetworkPlayerStreams(void)
Empty the streams of every player of a network game.
int g_bNetReadyToStart
Whether the local player is ready to start a network race.
HRESULT ShutdownDirectPlaySession(DirectPlayInfo *pInfo)
Stop the receive thread, destroy the local player, and close and release DirectPlay.
int g_adwNetRaceOrder[NET_PEER_SLOT_COUNT]
The order of the players of a network race.
int g_dwDirectPlayInstanceCount
The number of DirectPlay objects that exist.
HRESULT RefreshNetworkSessionList(IDirectPlay3A *pDirectPlay)
Enumerate the sessions of the selected service provider again.
char g_szModemDeviceName[]
The device of a modem connection.
unsigned g_dwNetRaceStartFrame
The frame a network race starts on.
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.
int GetSelectedServiceProvider(GUID **ppGuid)
Report the GUID of the service provider chosen.
LRESULT WINAPI HandleNetworkWindowMessage(HWND hWnd, UINT nMessage, WPARAM wParam, LPARAM lParam)
Give a message of the main window to the network play.
int g_bNetWorkerThreadRunning
Whether the worker thread of the host runs.
void StartNetworkWorkerThread(void)
Start the thread that works for the host of a network game.
char g_szModemPhoneNumber[]
The telephone number of a modem connection.
bool InitializeNetworkThreading(void)
Create the mutexes of the slots of the players and start the worker thread of a network game.
void RankNetworkPlayersByProgress(void)
Rank the players of a network game by their progress.
char g_szNetStatusString[]
The line of status of network play the game shows.
void BuildNetworkPlayerStatusPackets(void)
Write the packets of the status of the players of a network game into their streams.
int g_dwNetworkSendBlocked
Whether the sends of network play are blocked.
char g_szDirectPlayErrorBuffer[16]
The name of an error GetDirectPlayErrorString() does not know, written in hexadecimal.
HRESULT EnumerateNetworkPlayers(GUID *instance, LPDPENUMPLAYERSCALLBACK2 callback, void *context, DWORD flags)
Refresh player entries, enumerate players, and broadcast the local ready flag.
HANDLE g_hNetRaceOrderMutex
The mutex of the order of a network race.
int g_nDepartedPlayerStackTop
The index of the top of g_anDepartedPlayerSlotStack.
unsigned g_dwNetWorkerCurrentTime
The time of the worker thread of network play, written at the start of a packet.
const char * GetDirectPlayErrorString(HRESULT hResult)
Give the name of a DirectPlay error.
DPID GetSlotPlayerId(int nSlot)
The player of the session in a slot of a peer, read under the mutex of the slot.
int GetSessionSlotFlag(DPID dpidPlayer)
Get the flag of the slot of a player of the session.
void TickNetworkPauseRequest(void)
Send the request to pause of a network game.
int g_nNetUnpauseRequestTicks
The ticks a request of the end of a pause of a network game has waited, 0 for no request.
void MarkSessionListEntrySeen(DPID dpidPlayer)
Mark the slot of a player of the session as found, or give the player the first free slot.
void InitializeDirectPlayForDesktopWindow(void)
Initialise DirectPlay for the main window.
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.
void SyncNetworkClockFromServer(unsigned serverFrame, unsigned localTime, unsigned echoedFrame, unsigned roundTrip)
Adjust the network clock when a sampled reply improves the round-trip measurement.
int g_nNetPauseRequestTicks
The ticks a request of a pause of a network game has waited, 0 for no request.
BOOL CALLBACK EnumSessionsCallback_AddSessionToList(LPCDPSESSIONDESC2 description, DWORD *timeout, DWORD flags, void *context)
Add an available session to the menu, then enumerate its players.
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 g_anDepartedPlayerSlotStack[PLAYER_SLOT_STACK_SIZE]
The slots of the players that departed, for the race to remove.
void WriteTimestampToStream(NetStream *pStream)
Empty a stream and write the current frame of network play at its start.
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.
DWORD g_dwNetWorkerNextTickTime
The time of the next tick of the worker thread of network play, in milliseconds.
char g_szSessionName[]
The name of the network session.
HANDLE g_hDepartedPlayerStackMutex
The mutex of the stack of players that departed.
void ClampWorldCoordinate(float *pValue)
Limit a coordinate to the range from 0 to 2048.
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.
void HostNetworkSession(void)
Create a session using the selected settings and initialise host network state.
HANDLE g_hNetWorkerStopEvent
The event that stops the worker thread of the host.
HRESULT DestroyLocalDirectPlayPlayer(void)
Destroy the local player of DirectPlay, when there is one.
HANDLE g_hNetRaceStartMutex
The mutex of the start of a network race.
#define NET_PEER_SLOT_COUNT
The number of entries of g_aNetPeerSlots.
Definition directplay.h:997
HANDLE g_hNetReadyMutex
The mutex of the players that are ready.
int g_bNetStatusStringDirty
Whether g_szNetStatusString changed since it was shown.
HRESULT SendNetworkFinishPositionMessage(DirectPlayInfo *pInfo, DPID dpidPlayer, DWORD dwPosition)
Broadcast a player's finishing position with guaranteed delivery.
int FlushNetworkPlayerStreams(DirectPlayInfo *pInfo)
Send the streams of the players of a network game.
CRITICAL_SECTION g_DirectPlaySendCritSec
The critical section of DirectPlay sends.
DirectPlayInfo * g_pDirectPlayInfo
The DirectPlay info other routines read, g_DirectPlayInfo once DirectPlay starts.
void SetGlobalStatusString(const char *pszStatus)
Set the line of status of network play under the mutex of the notices.
bool InitServiceProviderAndStartSession(void)
Start the service provider chosen and the timer of network play as InitServiceProviderAndStartTimer()...
#define SESSION_SLOT_COUNT
The number of entries of g_aSessionSlots.
Definition directplay.h:1678
void StopNetworkWorkerThread(void)
Stop the thread that works for the host of a network game, wait for it, and close it and its stop eve...
void CopySessionNameToBuffer(NetworkSessionSettings *pSettings)
Copy g_szSessionName into the settings of a session when it is longer than one character,...
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,...
int g_dwServiceProviderIndex
The index in g_aServiceProviders of the service provider chosen.
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.
unsigned g_dwNetLastKeyframeFrame
The frame of the last key frame written to a stream.
int GetPlayerPingMs(int nSlot)
Get the time of the last round trip to the player of a slot, under the mutex of the slot.
HRESULT CreateServiceProviderAddress(void **ppAddress, DWORD *pdwSize)
Build the compound address for the selected DirectPlay service provider.
void ClampFloat(float *pValue)
Limit a value to the range from -1 to 1.
#define PLAYER_SLOT_STACK_SIZE
The number of entries of g_anDepartedPlayerSlotStack and g_anJoinedPlayerSlotStack.
Definition directplay.h:1107
int g_dwNetworkDataStreamActive
Whether the network data stream is active.
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 bl...
int g_nJoinedPlayerStackTop
The index of the top of g_anJoinedPlayerSlotStack.
int SendNetworkStreamReliable(DirectPlayInfo *pInfo, NetStream *pStream)
Send a stream to the server, or process it locally when hosting.
DWORD WINAPI NetworkWorkerThreadProc(LPVOID pParameter)
Do the work of the host of a network game once a second, sleeping until each second.
int FindNetworkSlotByPlayerId(DPID dpidPlayer)
Find a player's active slot, or the first free slot for a new player.
void ClampTerrainHeightCoordinate(float *pHeight)
Limit a height to the range from -256 to 256.
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.
HANDLE g_hJoinedPlayerStackMutex
The mutex of the stack of players that joined.
int g_dwNetworkCarSetupShown
Whether the network car setup screen has been shown.
bool ShutdownNetworkSubsystem(int nReason)
End the network play of a game.
int g_anJoinedPlayerSlotStack[PLAYER_SLOT_STACK_SIZE]
The slots of the players that joined, for the race to add.
int SendNetworkStreamUnreliable(DirectPlayInfo *pInfo, NetStream *pStream)
Send a stream to every player and process it locally when hosting.
int JoinNetworkSession(void)
Join the selected session and initialise network play after a successful connection.
BOOL CALLBACK EnumPlayersCallback_AddPlayerToList(DPID dpidPlayer, DWORD dwPlayerType, LPCDPNAME pName, DWORD dwFlags, void *pContext)
Add a non-spectator player to the network player menu.
#define NET_PLAYER_SLOT_COUNT
The number of entries of g_aNetPlayerSlots.
Definition directplay.h:1573
HANDLE g_hDirectPlayReceiveThread
The thread that receives the messages of the local player.
DWORD GetElapsedTimeSinceStart(void)
Get the time since the network session started.
int g_dwSessionEnumPending
Whether an enumeration of sessions is waiting for a reply.
void ProcessNetworkDataStream(DirectPlayInfo *pInfo, void *pData, DWORD dwSize, DPID dpidFrom, DPID dpidTo)
Handle the packets of a secure message as a client.
int GetNetworkPeerChannelStatus(int nSlot)
The state of a network player as its own peer reports it, under the mutex of the entry.
const RECT g_rcNetCarSetupPlayerList
The player list rectangle on the network car setup screen, in pixels.
void PurgeStaleSessionListEntries(void)
Free each slot of the session whose player was not found since the last purge.
char g_szNetworkChatText[]
The chat line being edited or sent from the network menu.
HRESULT CreateDirectPlayObject(IDirectPlay3A **ppDirectPlay)
Create the DirectPlay object.
HRESULT SendNetworkRaceStateMessage(DirectPlayInfo *pInfo, DWORD dwState)
Send a state of the race from the local player to every player, unless sends are blocked.
bool InitServiceProviderAndStartTimer(void)
Start the service provider chosen and the timer of network play of the main window,...
int g_bDirectPlayReceiveThreadStarted
Whether the critical section of DirectPlay sends exists.
int g_dwLobbyIsHost
Whether the lobby made the game the host.
bool SetNetworkReadyToStartFlag(void)
Mark the local player ready to start a network race.
void ResetAllPlayerSlots(void)
Reset race and peer states, timing, and finishing positions for every network player.
HANDLE g_hNetReceiveMutex
The mutex of the messages received.
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.
HRESULT SendNetworkMessage7(DirectPlayInfo *pInfo, DPID dpidPlayer)
Send message 7 of the game, which names a player, from the local player to every player.
DWORD g_dwNetSessionStartTime
The time the network session started, in milliseconds.
typedef DPID
The ghost cars of the PC port: the frames of their recordings.
typedef CRITICAL_SECTION
const char * g_apszPlaceNames[]
The names of the places in a race: "1st" and on.
The DirectPlay object of the game and its local player.
Definition directplay.h:20
IDirectPlay3A * pDirectPlay
Definition directplay.h:21
BOOL bIsHost
Definition directplay.h:24
HANDLE hPlayerEvent
Definition directplay.h:22
DPID dpidPlayer
Definition directplay.h:23
BOOL bIgnoreMessages
Definition directplay.h:25
Vehicle pose and interpolated controls before compact frame encoding.
Definition ghost.h:29
A peer of a network game.
Definition directplay.h:871
int nCar
Definition directplay.h:877
HANDLE hMutex
Definition directplay.h:872
unsigned dwRaceTime
Definition directplay.h:888
unsigned adwSnapshotTypes[8]
Definition directplay.h:879
unsigned nSnapshotCount
Definition directplay.h:881
int nLateSnapshotFrames
Definition directplay.h:886
unsigned adwSnapshotTimes[8]
Definition directplay.h:875
int dwPingMs
Definition directplay.h:889
int dwStatus
Definition directplay.h:876
int nAppliedSnapshot
Definition directplay.h:883
char szName[0x400]
Definition directplay.h:887
unsigned char color[3]
Definition directplay.h:878
DPID dpidPlayer
Definition directplay.h:873
int nRepeatedSnapshotFrames
Definition directplay.h:885
int nCurrentSnapshot
Definition directplay.h:882
unsigned dwLastUpdateTime
Definition directplay.h:874
unsigned dwPredictionFrame
Definition directplay.h:884
KeyframeState aSnapshots[8]
Definition directplay.h:880
A network player of a race.
Definition directplay.h:1552
int nCurrentSnapshot
Definition directplay.h:1564
unsigned dwLastTimeSync
Definition directplay.h:1566
unsigned char bStatusOptionC
Definition directplay.h:1561
unsigned char bStatusOptionB
Definition directplay.h:1560
int nStatusValue
Definition directplay.h:1558
HANDLE hMutex
Definition directplay.h:1553
unsigned dwTimeSyncValue
Definition directplay.h:1568
unsigned dwRaceTime
Definition directplay.h:1567
DWORD dwLastUpdateTime
Definition directplay.h:1555
unsigned adwSnapshotTimes[8]
Definition directplay.h:1556
unsigned adwSnapshotTypes[8]
Definition directplay.h:1562
int dwState
Definition directplay.h:1557
DPID dpidOwner
Definition directplay.h:1554
unsigned char bStatusOptionA
Definition directplay.h:1559
unsigned dwFinishTime
Definition directplay.h:1569
KeyframeState aSnapshots[8]
Definition directplay.h:1563
char szPlayerName[0x400]
Definition directplay.h:1565
The local user and optional authentication fields used when joining a session.
Definition directplay.h:461
char localUserName[200]
Definition directplay.h:462
char userName[200]
Definition directplay.h:463
char domain[200]
Definition directplay.h:465
char password[200]
Definition directplay.h:464
The settings of a network session the game hosts.
Definition directplay.h:455
BOOL bSecureServer
Definition directplay.h:457
char szSessionName[200]
Definition directplay.h:456
A service provider of DirectPlay found by EnumConnections.
Definition directplay.h:29
char szName[200]
Definition directplay.h:30
DWORD dwConnectionSize
Definition directplay.h:32
GUID guid
Definition directplay.h:31
void * pConnectionData
Definition directplay.h:33
A player in a slot of the session.
Definition directplay.h:1528
int nFlag
Definition directplay.h:1530
int nSeen
Definition directplay.h:1532
DPID dpidPlayer
Definition directplay.h:1529
typedef BOOL
typedef CALLBACK
typedef DWORD
typedef HANDLE
typedef HINSTANCE
typedef HRESULT
typedef HWND
typedef LPARAM
typedef LPVOID
typedef LRESULT
typedef UINT
typedef UINT_PTR
typedef WINAPI
typedef WPARAM