devilutionX/Source/multi.h
Gleb Mazovetskiy 076b0c0c05 Overhaul tests
1. Adds a `libdevilution_so` target when tests are enabled.
2. Each test file is now a separate binary target linked against `libdevilutionx_so` (can now run tests in parallel).
3. Tests are now defined in a separate `test/CMakeLists.txt` file.
4. Building the tests is now controlled by the standard `BUILD_TESTING` option (defined by CTest).
5. Tests are now built by default.
6. On CI, test errors are now reported.

Also:

* `.clang-format`: Enable SortIncludes in tests
* `path_test.cpp`: Fix -Wsign-compare
2021-12-16 20:26:51 +00:00

64 lines
1.8 KiB
C++

/**
* @file multi.h
*
* Interface of functions for keeping multiplayer games in sync.
*/
#pragma once
#include <cstdint>
#include "msg.h"
#include "utils/attributes.h"
namespace devilution {
// must be unsigned to generate unsigned comparisons with pnum
#define MAX_PLRS 4
struct GameData {
int32_t size;
/** Used to initialise the seed table for dungeon levels so players in multiplayer games generate the same layout */
uint32_t dwSeed;
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;
};
extern bool gbSomebodyWonGameKludge;
extern char szPlayerDescript[128];
extern uint16_t sgwPackPlrOffsetTbl[MAX_PLRS];
extern BYTE gbActivePlayers;
extern bool gbGameDestroyed;
extern GameData sgGameInitInfo;
extern bool gbSelectProvider;
extern DVL_API_FOR_TEST bool gbIsMultiplayer;
extern char szPlayerName[128];
extern bool PublicGame;
extern BYTE gbDeltaSender;
extern uint32_t player_state[MAX_PLRS];
void NetSendLoPri(int playerId, const byte *data, size_t size);
void NetSendHiPri(int playerId, const byte *data, size_t size);
void multi_send_msg_packet(uint32_t pmask, const byte *data, size_t size);
void multi_msg_countdown();
void multi_player_left(int 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(int pnum, _cmd_id bCmd, const byte *data, size_t size);
void NetClose();
bool NetInit(bool bSinglePlayer);
void recv_plrinfo(int pnum, const TCmdPlrInfoHdr &header, bool recv);
} // namespace devilution