forked from diasurgical/DevilutionX
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmulti.h
More file actions
83 lines (71 loc) · 2.29 KB
/
multi.h
File metadata and controls
83 lines (71 loc) · 2.29 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
/**
* @file multi.h
*
* Interface of functions for keeping multiplayer games in sync.
*/
#pragma once
#include <cstdint>
#include <string>
#include <vector>
#include "msg.h"
#include "utils/attributes.h"
namespace devilution {
// Defined in player.h, forward declared here to allow for functions which operate in the context of a player.
struct Player;
// must be unsigned to generate unsigned comparisons with pnum
#define MAX_PLRS 4
struct GameData {
int32_t size;
uint8_t reserved[4];
uint32_t programid;
uint8_t versionMajor;
uint8_t versionMinor;
uint8_t versionPatch;
_difficulty nDifficulty;
uint8_t nTickRate;
uint8_t bRunInTown;
uint8_t bTheoQuest;
uint8_t bCowQuest;
uint8_t bFriendlyFire;
uint8_t fullQuests;
uint8_t bDisableSearch;
/** Used to initialise the seed table for dungeon levels so players in multiplayer games generate the same layout */
uint32_t gameSeed[4];
void swapLE();
};
/* @brief Contains info of running public game (for game list browsing) */
struct GameInfo {
std::string name;
GameData gameData;
std::vector<std::string> players;
};
extern bool gbSomebodyWonGameKludge;
extern uint16_t sgwPackPlrOffsetTbl[MAX_PLRS];
extern uint8_t gbActivePlayers;
extern bool gbGameDestroyed;
extern DVL_API_FOR_TEST GameData sgGameInitInfo;
extern bool gbSelectProvider;
extern DVL_API_FOR_TEST bool gbIsMultiplayer;
extern std::string GameName;
extern std::string GamePassword;
extern bool PublicGame;
extern uint8_t gbDeltaSender;
extern uint32_t player_state[MAX_PLRS];
extern bool IsLoopback;
void InitGameInfo();
void NetSendLoPri(uint8_t playerId, const std::byte *data, size_t size);
void NetSendHiPri(uint8_t playerId, const std::byte *data, size_t size);
void multi_send_msg_packet(uint32_t pmask, const std::byte *data, size_t size);
void multi_msg_countdown();
void multi_player_left(uint8_t pnum, int reason);
void multi_net_ping();
/**
* @return Always true for singleplayer
*/
bool multi_handle_delta();
void multi_process_network_packets();
void multi_send_zero_packet(uint8_t pnum, _cmd_id bCmd, const std::byte *data, size_t size);
void NetClose();
bool NetInit(bool bSinglePlayer);
void recv_plrinfo(Player &player, const TCmdPlrInfoHdr &header, bool recv);
} // namespace devilution