-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDPInstance.h
71 lines (61 loc) · 2.59 KB
/
DPInstance.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*!
@file DPInstance.h
@brief DirectPlay reimplementation instance
@author Arves100
@date 05/02/2022
*/
#pragma once
#include "DPPlayer.h"
#include "DPMsg.h"
using QueueMsg = std::vector<std::shared_ptr<DPMsg>>;
class DPInstance final
{
public:
DPInstance(void);
~DPInstance(void);
HRESULT AddPlayerToGroup(DPID idGroup, DPID idPlayer);
HRESULT EnumSessions(LPDPSESSIONDESC2 lpsd, DWORD dwTimeout, LPDPENUMSESSIONSCALLBACK2 lpEnumSessionsCallback2, LPVOID lpContext, DWORD dwFlags);
HRESULT GetCaps(LPDPCAPS lpDPCaps, DWORD dwFlags);
HRESULT SendEx(DPID idFrom, DPID idTo, DWORD dwFlags, LPVOID lpData, DWORD dwDataSize, DWORD dwPriority, DWORD dwTimeout, LPVOID lpContext, LPDWORD lpdwMsgID);
HRESULT SendChatMessage(DPID idFrom, DPID idTo, DWORD dwFlags, LPDPCHAT lpChatMessage);
HRESULT SetSessionDesc(LPDPSESSIONDESC2 lpSessDesc, DWORD dwFlags);
HRESULT Send(DPID idFrom, DPID idTo, DWORD dwFlags, LPVOID lpData, DWORD dwDataSize);
HRESULT CreateGroup(LPDPID lpidGroup, LPDPNAME lpGroupName, LPVOID lpData, DWORD dwDataSize, DWORD dwFlags);
HRESULT Receive(LPDPID lpidFrom, LPDPID lpidTo, DWORD dwFlags, LPVOID lpData, LPDWORD lpdwDataSize);
HRESULT DestroyPlayer(DPID idPlayer);
HRESULT CreatePlayer(LPDPID lpidPlayer, LPDPNAME lpPlayerName, HANDLE hEvent, LPVOID lpData, DWORD dwDataSize, DWORD dwFlags);
HRESULT SetPlayerData(DPID idPlayer, LPVOID lpData, DWORD dwDataSize, DWORD dwFlags);
HRESULT Open(LPDPSESSIONDESC2 lpsd, DWORD dwFlags);
HRESULT Close(void);
HRESULT InitializeConnection(LPVOID lpConnection, DWORD dwFlags);
HRESULT EnumConnections(LPCGUID lpguidApplication, LPDPENUMCONNECTIONSCALLBACK lpEnumCallback, LPVOID lpContext, DWORD dwFlags);
HRESULT GetSessionDesc(LPVOID lpData, LPDWORD lpdwDataSize);
HRESULT GetPlayerData(DPID idPlayer, LPVOID lpData, LPDWORD lpdwDataSize, DWORD dwFlags);
private:
bool GetAddressFromDPAddress(LPVOID lpConnection, ENetAddress* addr);
void Service(uint32_t time);
void SetupThreadedService(bool infinite);
HRESULT EnumSessionOut(LPDPENUMSESSIONSCALLBACK2 cb, LPVOID ctx);
ENetHost* m_pHost;
// Shared
std::string m_szGameName;
std::unordered_map<DPID, std::shared_ptr<DPPlayer>> m_vPlayers;
bool m_bHost;
GUID m_gSession;
QueueMsg m_vMessages; // we need a queue due to how DPlay works...
DWORD m_adwUser[4];
// Server
DWORD m_dwMaxPlayers;
DWORD m_dwFlags;
// Client
bool m_bConnected;
ENetPeer* m_pClientPeer;
std::unordered_map<GUID, ENetAddress, GUIDHasher> m_vEnumAddr;
ENetAddress m_eConnectAddr;
GUID m_guidFF;
// ENet Thread
std::thread m_thread;
bool m_bService;
ULONGLONG m_ullServiceTimeout;
ULONGLONG m_ullStartService;
};