mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #12485 from ZehMatt/network/cleanup-1
Refactor the Network a bit, setting the stones for further refactor work
This commit is contained in:
commit
b0c67762b7
|
@ -93,6 +93,10 @@
|
|||
9346F9DB208A191900C77D91 /* GuestPathfinding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9346F9D7208A191900C77D91 /* GuestPathfinding.cpp */; };
|
||||
9346F9DC208A191900C77D91 /* GuestPathfinding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9346F9D7208A191900C77D91 /* GuestPathfinding.cpp */; };
|
||||
9346F9DD208A191900C77D91 /* GuestPathfinding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9346F9D7208A191900C77D91 /* GuestPathfinding.cpp */; };
|
||||
936F412824CE030F00E07BCF /* NetworkClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 936F412424CE030E00E07BCF /* NetworkClient.h */; };
|
||||
936F412924CE030F00E07BCF /* NetworkBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 936F412524CE030F00E07BCF /* NetworkBase.cpp */; };
|
||||
936F412A24CE030F00E07BCF /* NetworkClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 936F412624CE030F00E07BCF /* NetworkClient.cpp */; };
|
||||
936F412B24CE030F00E07BCF /* NetworkBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 936F412724CE030F00E07BCF /* NetworkBase.h */; };
|
||||
939A359A20C12FC800630B3F /* Paint.Litter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 939A359720C12FC700630B3F /* Paint.Litter.cpp */; };
|
||||
939A359B20C12FC800630B3F /* Paint.Misc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 939A359820C12FC700630B3F /* Paint.Misc.cpp */; };
|
||||
939A359C20C12FC800630B3F /* Paint.Sprite.h in Headers */ = {isa = PBXBuildFile; fileRef = 939A359920C12FC700630B3F /* Paint.Sprite.h */; };
|
||||
|
@ -482,7 +486,6 @@
|
|||
F76C85FF1EC4E88300FA49E2 /* Rain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C83AB1EC4E7CC00FA49E2 /* Rain.cpp */; };
|
||||
F76C86051EC4E88300FA49E2 /* Editor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C83B11EC4E7CC00FA49E2 /* Editor.cpp */; };
|
||||
F76C86071EC4E88300FA49E2 /* FileClassifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C83B31EC4E7CC00FA49E2 /* FileClassifier.cpp */; };
|
||||
F76C86471EC4E88300FA49E2 /* Network.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C83F81EC4E7CC00FA49E2 /* Network.cpp */; };
|
||||
F76C86491EC4E88300FA49E2 /* NetworkAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C83FA1EC4E7CC00FA49E2 /* NetworkAction.cpp */; };
|
||||
F76C864B1EC4E88300FA49E2 /* NetworkConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C83FC1EC4E7CC00FA49E2 /* NetworkConnection.cpp */; };
|
||||
F76C864D1EC4E88300FA49E2 /* NetworkGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C83FE1EC4E7CC00FA49E2 /* NetworkGroup.cpp */; };
|
||||
|
@ -1304,6 +1307,10 @@
|
|||
9350B52720B46E0900897BC5 /* ftbdf.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ftbdf.h; sourceTree = "<group>"; };
|
||||
9350B52820B46E0900897BC5 /* ftrender.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ftrender.h; sourceTree = "<group>"; };
|
||||
9350B52920B46E0900897BC5 /* ft2build.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ft2build.h; sourceTree = "<group>"; };
|
||||
936F412424CE030E00E07BCF /* NetworkClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkClient.h; sourceTree = "<group>"; };
|
||||
936F412524CE030F00E07BCF /* NetworkBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkBase.cpp; sourceTree = "<group>"; };
|
||||
936F412624CE030F00E07BCF /* NetworkClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkClient.cpp; sourceTree = "<group>"; };
|
||||
936F412724CE030F00E07BCF /* NetworkBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkBase.h; sourceTree = "<group>"; };
|
||||
9391535A22D74359008E0780 /* OpenRCT2.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OpenRCT2.entitlements; sourceTree = "<group>"; };
|
||||
939A359720C12FC700630B3F /* Paint.Litter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Paint.Litter.cpp; sourceTree = "<group>"; };
|
||||
939A359820C12FC700630B3F /* Paint.Misc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Paint.Misc.cpp; sourceTree = "<group>"; };
|
||||
|
@ -1706,7 +1713,6 @@
|
|||
F76C83B31EC4E7CC00FA49E2 /* FileClassifier.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FileClassifier.cpp; sourceTree = "<group>"; };
|
||||
F76C83B41EC4E7CC00FA49E2 /* FileClassifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FileClassifier.h; sourceTree = "<group>"; };
|
||||
F76C83BA1EC4E7CC00FA49E2 /* input.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = input.h; sourceTree = "<group>"; };
|
||||
F76C83F81EC4E7CC00FA49E2 /* Network.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Network.cpp; sourceTree = "<group>"; };
|
||||
F76C83F91EC4E7CC00FA49E2 /* network.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = network.h; sourceTree = "<group>"; };
|
||||
F76C83FA1EC4E7CC00FA49E2 /* NetworkAction.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkAction.cpp; sourceTree = "<group>"; };
|
||||
F76C83FB1EC4E7CC00FA49E2 /* NetworkAction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NetworkAction.h; sourceTree = "<group>"; };
|
||||
|
@ -2959,10 +2965,13 @@
|
|||
children = (
|
||||
2ADE2F3022441905002598AF /* DiscordService.cpp */,
|
||||
2ADE2F2F22441905002598AF /* DiscordService.h */,
|
||||
F76C83F81EC4E7CC00FA49E2 /* Network.cpp */,
|
||||
F76C83F91EC4E7CC00FA49E2 /* network.h */,
|
||||
F76C83FA1EC4E7CC00FA49E2 /* NetworkAction.cpp */,
|
||||
F76C83FB1EC4E7CC00FA49E2 /* NetworkAction.h */,
|
||||
936F412524CE030F00E07BCF /* NetworkBase.cpp */,
|
||||
936F412724CE030F00E07BCF /* NetworkBase.h */,
|
||||
936F412624CE030F00E07BCF /* NetworkClient.cpp */,
|
||||
936F412424CE030E00E07BCF /* NetworkClient.h */,
|
||||
F76C83FC1EC4E7CC00FA49E2 /* NetworkConnection.cpp */,
|
||||
F76C83FD1EC4E7CC00FA49E2 /* NetworkConnection.h */,
|
||||
F76C83FE1EC4E7CC00FA49E2 /* NetworkGroup.cpp */,
|
||||
|
@ -3673,6 +3682,7 @@
|
|||
93CBA4CC20A7504500867D56 /* ImageImporter.h in Headers */,
|
||||
2ADE2F29224418B2002598AF /* Numerics.hpp in Headers */,
|
||||
93DFD04924521C1A001FCBAF /* ScTile.hpp in Headers */,
|
||||
936F412B24CE030F00E07BCF /* NetworkBase.h in Headers */,
|
||||
93DFD04524521C1A001FCBAF /* ScObject.hpp in Headers */,
|
||||
2ADE2F382244198B002598AF /* SpriteBase.h in Headers */,
|
||||
C62D838B1FD36D6F008C04F1 /* EditorObjectSelectionSession.h in Headers */,
|
||||
|
@ -3690,6 +3700,7 @@
|
|||
93DFD04F24521C1A001FCBAF /* ScConsole.hpp in Headers */,
|
||||
9308DA05209908090079EE96 /* Surface.h in Headers */,
|
||||
93DE9753209C3C1000FB1CC8 /* GameState.h in Headers */,
|
||||
936F412824CE030F00E07BCF /* NetworkClient.h in Headers */,
|
||||
2ADE2F2A224418B2002598AF /* Meta.hpp in Headers */,
|
||||
93DFD04624521C1A001FCBAF /* HookEngine.h in Headers */,
|
||||
93FC09002418F3ED00CA3054 /* duk_config.h in Headers */,
|
||||
|
@ -4259,7 +4270,6 @@
|
|||
C6607F481FE2B97E00D3FC0D /* Input.cpp in Sources */,
|
||||
C688789F20289B200084B384 /* Language.cpp in Sources */,
|
||||
C688791620289B9B0084B384 /* MiniGolf.cpp in Sources */,
|
||||
F76C86471EC4E88300FA49E2 /* Network.cpp in Sources */,
|
||||
C688787820289A780084B384 /* Track.cpp in Sources */,
|
||||
F76C86491EC4E88300FA49E2 /* NetworkAction.cpp in Sources */,
|
||||
C688788020289ADE0084B384 /* LightFX.cpp in Sources */,
|
||||
|
@ -4378,6 +4388,7 @@
|
|||
C688791A20289B9B0084B384 /* SpaceRings.cpp in Sources */,
|
||||
C688790420289B9B0084B384 /* Steeplechase.cpp in Sources */,
|
||||
C68878E020289B9B0084B384 /* Peep.cpp in Sources */,
|
||||
936F412A24CE030F00E07BCF /* NetworkClient.cpp in Sources */,
|
||||
F76C86C51EC4E88400FA49E2 /* S6Importer.cpp in Sources */,
|
||||
C688790A20289B9B0084B384 /* WoodenRollerCoaster.cpp in Sources */,
|
||||
C688787220289A780084B384 /* MusicList.cpp in Sources */,
|
||||
|
@ -4430,6 +4441,7 @@
|
|||
93F76F0120BFF77B00D4512C /* Paint.LargeScenery.cpp in Sources */,
|
||||
C688790720289B9B0084B384 /* VerticalDropRollerCoaster.cpp in Sources */,
|
||||
93F9DA3A20B46FCA00D1BE92 /* SceneryObject.cpp in Sources */,
|
||||
936F412924CE030F00E07BCF /* NetworkBase.cpp in Sources */,
|
||||
C688787520289A780084B384 /* RideData.cpp in Sources */,
|
||||
C688789B20289B200084B384 /* Convert.cpp in Sources */,
|
||||
C688791F20289B9B0084B384 /* Enterprise.cpp in Sources */,
|
||||
|
|
|
@ -230,11 +230,14 @@
|
|||
<ClInclude Include="network\DiscordService.h" />
|
||||
<ClInclude Include="network\network.h" />
|
||||
<ClInclude Include="network\NetworkAction.h" />
|
||||
<ClInclude Include="network\NetworkBase.h" />
|
||||
<ClInclude Include="network\NetworkClient.h" />
|
||||
<ClInclude Include="network\NetworkConnection.h" />
|
||||
<ClInclude Include="network\NetworkGroup.h" />
|
||||
<ClInclude Include="network\NetworkKey.h" />
|
||||
<ClInclude Include="network\NetworkPacket.h" />
|
||||
<ClInclude Include="network\NetworkPlayer.h" />
|
||||
<ClInclude Include="network\NetworkServer.h" />
|
||||
<ClInclude Include="network\NetworkServerAdvertiser.h" />
|
||||
<ClInclude Include="network\NetworkTypes.h" />
|
||||
<ClInclude Include="network\NetworkUser.h" />
|
||||
|
@ -549,13 +552,15 @@
|
|||
<ClCompile Include="management\NewsItem.cpp" />
|
||||
<ClCompile Include="management\Research.cpp" />
|
||||
<ClCompile Include="network\DiscordService.cpp" />
|
||||
<ClCompile Include="network\Network.cpp" />
|
||||
<ClCompile Include="network\NetworkAction.cpp" />
|
||||
<ClCompile Include="network\NetworkBase.cpp" />
|
||||
<ClCompile Include="network\NetworkClient.cpp" />
|
||||
<ClCompile Include="network\NetworkConnection.cpp" />
|
||||
<ClCompile Include="network\NetworkGroup.cpp" />
|
||||
<ClCompile Include="network\NetworkKey.cpp" />
|
||||
<ClCompile Include="network\NetworkPacket.cpp" />
|
||||
<ClCompile Include="network\NetworkPlayer.cpp" />
|
||||
<ClCompile Include="network\NetworkServer.cpp" />
|
||||
<ClCompile Include="network\NetworkServerAdvertiser.cpp" />
|
||||
<ClCompile Include="network\NetworkUser.cpp" />
|
||||
<ClCompile Include="network\ServerList.cpp" />
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,235 @@
|
|||
#pragma once
|
||||
|
||||
#include "../actions/GameAction.h"
|
||||
#include "NetworkConnection.h"
|
||||
#include "NetworkGroup.h"
|
||||
#include "NetworkPlayer.h"
|
||||
#include "NetworkServerAdvertiser.h"
|
||||
#include "NetworkTypes.h"
|
||||
#include "NetworkUser.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#ifndef DISABLE_NETWORK
|
||||
|
||||
class NetworkBase
|
||||
{
|
||||
public:
|
||||
NetworkBase();
|
||||
|
||||
public: // Uncategorized
|
||||
bool BeginServer(uint16_t port, const std::string& address);
|
||||
bool BeginClient(const std::string& host, uint16_t port);
|
||||
|
||||
public: // Common
|
||||
void SetEnvironment(const std::shared_ptr<OpenRCT2::IPlatformEnvironment>& env);
|
||||
bool Init();
|
||||
void Close();
|
||||
uint32_t GetServerTick();
|
||||
void Update();
|
||||
void Flush();
|
||||
void ProcessPending();
|
||||
void ProcessPlayerList();
|
||||
std::vector<std::unique_ptr<NetworkPlayer>>::iterator GetPlayerIteratorByID(uint8_t id);
|
||||
std::vector<std::unique_ptr<NetworkGroup>>::iterator GetGroupIteratorByID(uint8_t id);
|
||||
NetworkPlayer* GetPlayerByID(uint8_t id);
|
||||
NetworkGroup* GetGroupByID(uint8_t id);
|
||||
void SetPassword(const char* password);
|
||||
uint8_t GetDefaultGroup();
|
||||
std::string BeginLog(const std::string& directory, const std::string& midName, const std::string& filenameFormat);
|
||||
void AppendLog(std::ostream& fs, const std::string& s);
|
||||
void BeginChatLog();
|
||||
void AppendChatLog(const std::string& s);
|
||||
void CloseChatLog();
|
||||
NetworkStats_t GetStats() const;
|
||||
json_t* GetServerInfoAsJson() const;
|
||||
bool ProcessConnection(NetworkConnection& connection);
|
||||
void CloseConnection();
|
||||
NetworkPlayer* AddPlayer(const std::string& name, const std::string& keyhash);
|
||||
void ProcessPacket(NetworkConnection& connection, NetworkPacket& packet);
|
||||
|
||||
public: // Server
|
||||
NetworkConnection* GetPlayerConnection(uint8_t id);
|
||||
void KickPlayer(int32_t playerId);
|
||||
NetworkGroup* AddGroup();
|
||||
void LoadGroups();
|
||||
void SetDefaultGroup(uint8_t id);
|
||||
void SaveGroups();
|
||||
void RemoveGroup(uint8_t id);
|
||||
uint8_t GetGroupIDByHash(const std::string& keyhash);
|
||||
void BeginServerLog();
|
||||
void AppendServerLog(const std::string& s);
|
||||
void CloseServerLog();
|
||||
void DecayCooldown(NetworkPlayer* player);
|
||||
void AddClient(std::unique_ptr<ITcpSocket>&& socket);
|
||||
std::string GetMasterServerUrl();
|
||||
std::string GenerateAdvertiseKey();
|
||||
void SetupDefaultGroups();
|
||||
void RemovePlayer(std::unique_ptr<NetworkConnection>& connection);
|
||||
void UpdateServer();
|
||||
void ServerClientDisconnected(std::unique_ptr<NetworkConnection>& connection);
|
||||
bool SaveMap(IStream* stream, const std::vector<const ObjectRepositoryItem*>& objects) const;
|
||||
uint8_t* save_for_network(size_t& out_size, const std::vector<const ObjectRepositoryItem*>& objects) const;
|
||||
std::string MakePlayerNameUnique(const std::string& name);
|
||||
|
||||
// Packet dispatchers.
|
||||
void Server_Send_AUTH(NetworkConnection& connection);
|
||||
void Server_Send_TOKEN(NetworkConnection& connection);
|
||||
void Server_Send_MAP(NetworkConnection* connection = nullptr);
|
||||
void Server_Send_CHAT(const char* text, const std::vector<uint8_t>& playerIds = {});
|
||||
void Server_Send_GAME_ACTION(const GameAction* action);
|
||||
void Server_Send_TICK();
|
||||
void Server_Send_PLAYERINFO(int32_t playerId);
|
||||
void Server_Send_PLAYERLIST();
|
||||
void Server_Send_PING();
|
||||
void Server_Send_PINGLIST();
|
||||
void Server_Send_SETDISCONNECTMSG(NetworkConnection& connection, const char* msg);
|
||||
void Server_Send_GAMEINFO(NetworkConnection& connection);
|
||||
void Server_Send_SHOWERROR(NetworkConnection& connection, rct_string_id title, rct_string_id message);
|
||||
void Server_Send_GROUPLIST(NetworkConnection& connection);
|
||||
void Server_Send_EVENT_PLAYER_JOINED(const char* playerName);
|
||||
void Server_Send_EVENT_PLAYER_DISCONNECTED(const char* playerName, const char* reason);
|
||||
void Server_Send_OBJECTS_LIST(NetworkConnection& connection, const std::vector<const ObjectRepositoryItem*>& objects) const;
|
||||
void Server_Send_SCRIPTS(NetworkConnection& connection) const;
|
||||
|
||||
// Handlers
|
||||
void Server_Handle_REQUEST_GAMESTATE(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Server_Handle_HEARTBEAT(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Server_Handle_AUTH(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Server_Client_Joined(const char* name, const std::string& keyhash, NetworkConnection& connection);
|
||||
void Server_Handle_CHAT(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Server_Handle_GAME_ACTION(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Server_Handle_PING(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Server_Handle_GAMEINFO(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Server_Handle_TOKEN(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Server_Handle_MAPREQUEST(NetworkConnection& connection, NetworkPacket& packet);
|
||||
|
||||
public: // Client
|
||||
void Reconnect();
|
||||
int32_t GetMode();
|
||||
int32_t GetAuthStatus();
|
||||
int32_t GetStatus();
|
||||
uint8_t GetPlayerID();
|
||||
void ProcessPlayerInfo();
|
||||
void ProcessDisconnectedClients();
|
||||
static const char* FormatChat(NetworkPlayer* fromplayer, const char* text);
|
||||
void SendPacketToClients(NetworkPacket& packet, bool front = false, bool gameCmd = false);
|
||||
bool CheckSRAND(uint32_t tick, uint32_t srand0);
|
||||
bool CheckDesynchronizaton();
|
||||
void RequestStateSnapshot();
|
||||
bool IsDesynchronised();
|
||||
NetworkServerState_t GetServerState() const;
|
||||
void ServerClientDisconnected();
|
||||
bool LoadMap(IStream* stream);
|
||||
void UpdateClient();
|
||||
|
||||
// Packet dispatchers.
|
||||
void Client_Send_RequestGameState(uint32_t tick);
|
||||
void Client_Send_TOKEN();
|
||||
void Client_Send_AUTH(
|
||||
const std::string& name, const std::string& password, const std::string& pubkey, const std::vector<uint8_t>& signature);
|
||||
void Client_Send_CHAT(const char* text);
|
||||
void Client_Send_GAME_ACTION(const GameAction* action);
|
||||
void Client_Send_PING();
|
||||
void Client_Send_GAMEINFO();
|
||||
void Client_Send_MAPREQUEST(const std::vector<std::string>& objects);
|
||||
void Client_Send_HEARTBEAT(NetworkConnection& connection) const;
|
||||
|
||||
// Handlers.
|
||||
void Client_Handle_AUTH(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Client_Handle_MAP(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Client_Handle_CHAT(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Client_Handle_GAME_ACTION(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Client_Handle_TICK(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Client_Handle_PLAYERINFO(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Client_Handle_PLAYERLIST(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Client_Handle_PING(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Client_Handle_PINGLIST(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Client_Handle_SETDISCONNECTMSG(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Client_Handle_GAMEINFO(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Client_Handle_SHOWERROR(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Client_Handle_GROUPLIST(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Client_Handle_EVENT(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Client_Handle_TOKEN(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Client_Handle_OBJECTS_LIST(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Client_Handle_SCRIPTS(NetworkConnection& connection, NetworkPacket& packet);
|
||||
void Client_Handle_GAMESTATE(NetworkConnection& connection, NetworkPacket& packet);
|
||||
|
||||
std::vector<uint8_t> _challenge;
|
||||
std::map<uint32_t, GameAction::Callback_t> _gameActionCallbacks;
|
||||
NetworkKey _key;
|
||||
NetworkUserManager _userManager;
|
||||
|
||||
public: // Public common
|
||||
std::string ServerName;
|
||||
std::string ServerDescription;
|
||||
std::string ServerGreeting;
|
||||
std::string ServerProviderName;
|
||||
std::string ServerProviderEmail;
|
||||
std::string ServerProviderWebsite;
|
||||
std::vector<std::unique_ptr<NetworkPlayer>> player_list;
|
||||
std::vector<std::unique_ptr<NetworkGroup>> group_list;
|
||||
|
||||
private: // Common Data
|
||||
using CommandHandler = void (NetworkBase::*)(NetworkConnection& connection, NetworkPacket& packet);
|
||||
|
||||
std::shared_ptr<OpenRCT2::IPlatformEnvironment> _env;
|
||||
std::vector<uint8_t> chunk_buffer;
|
||||
std::ofstream _chat_log_fs;
|
||||
uint32_t _lastUpdateTime = 0;
|
||||
uint32_t _currentDeltaTime = 0;
|
||||
int32_t mode = NETWORK_MODE_NONE;
|
||||
uint8_t default_group = 0;
|
||||
bool _closeLock = false;
|
||||
bool _requireClose = false;
|
||||
bool wsa_initialized = false;
|
||||
|
||||
private: // Server Data
|
||||
std::unordered_map<NetworkCommand, CommandHandler> server_command_handlers;
|
||||
std::unique_ptr<ITcpSocket> _listenSocket;
|
||||
std::unique_ptr<INetworkServerAdvertiser> _advertiser;
|
||||
std::list<std::unique_ptr<NetworkConnection>> client_connection_list;
|
||||
std::string _serverLogPath;
|
||||
std::string _serverLogFilenameFormat = "%Y%m%d-%H%M%S.txt";
|
||||
std::ofstream _server_log_fs;
|
||||
uint16_t listening_port = 0;
|
||||
bool _playerListInvalidated = false;
|
||||
|
||||
private: // Client Data
|
||||
struct PlayerListUpdate
|
||||
{
|
||||
std::vector<NetworkPlayer> players;
|
||||
};
|
||||
|
||||
struct ServerTickData_t
|
||||
{
|
||||
uint32_t srand0;
|
||||
uint32_t tick;
|
||||
std::string spriteHash;
|
||||
};
|
||||
|
||||
std::unordered_map<NetworkCommand, CommandHandler> client_command_handlers;
|
||||
std::unique_ptr<NetworkConnection> _serverConnection;
|
||||
std::map<uint32_t, PlayerListUpdate> _pendingPlayerLists;
|
||||
std::multimap<uint32_t, NetworkPlayer> _pendingPlayerInfo;
|
||||
std::map<uint32_t, ServerTickData_t> _serverTickData;
|
||||
std::vector<std::string> _missingObjects;
|
||||
std::string _host;
|
||||
std::string _chatLogPath;
|
||||
std::string _chatLogFilenameFormat = "%Y%m%d-%H%M%S.txt";
|
||||
std::string _password;
|
||||
MemoryStream _serverGameState;
|
||||
NetworkServerState_t _serverState;
|
||||
uint32_t _lastSentHeartbeat = 0;
|
||||
uint32_t last_ping_sent_time = 0;
|
||||
uint32_t server_connect_time = 0;
|
||||
uint32_t _actionId;
|
||||
int32_t status = NETWORK_STATUS_NONE;
|
||||
uint8_t player_id = 0;
|
||||
uint16_t _port = 0;
|
||||
SOCKET_STATUS _lastConnectStatus = SOCKET_STATUS_CLOSED;
|
||||
bool _requireReconnect = false;
|
||||
bool _clientMapLoaded = false;
|
||||
};
|
||||
|
||||
#endif // DISABLE_NETWORK
|
|
@ -0,0 +1 @@
|
|||
#include "NetworkClient.h"
|
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include "NetworkBase.h"
|
||||
|
||||
#ifndef DISABLE_NETWORK
|
||||
|
||||
class NetworkClient final : public NetworkBase
|
||||
{
|
||||
public:
|
||||
};
|
||||
|
||||
#endif // DISABLE_NETWORK
|
|
@ -0,0 +1 @@
|
|||
#include "NetworkServer.h"
|
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include "NetworkBase.h"
|
||||
|
||||
#ifndef DISABLE_NETWORK
|
||||
|
||||
class NetworkServer final : public NetworkBase
|
||||
{
|
||||
public:
|
||||
};
|
||||
|
||||
#endif // DISABLE_NETWORK
|
|
@ -13,6 +13,17 @@
|
|||
#include "../core/Endianness.h"
|
||||
#include "../ride/RideTypes.h"
|
||||
|
||||
enum
|
||||
{
|
||||
SERVER_EVENT_PLAYER_JOINED,
|
||||
SERVER_EVENT_PLAYER_DISCONNECTED,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
NETWORK_TICK_FLAG_CHECKSUMS = 1 << 0,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
NETWORK_MODE_NONE,
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include <cmath>
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
|
||||
// winsock2 must be included before windows.h
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
|
Loading…
Reference in New Issue