forked from TheSuperHackers/GeneralsGameCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetworkInterface.h
More file actions
131 lines (101 loc) · 5.2 KB
/
NetworkInterface.h
File metadata and controls
131 lines (101 loc) · 5.2 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
** Command & Conquer Generals Zero Hour(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// NetworkInterface.h ///////////////////////////////////////////////////////////////
// Network singleton class - defines interface to Network methods
// Author: Matthew D. Campbell, July 2001
#pragma once
#include "Common/MessageStream.h"
#include "GameNetwork/ConnectionManager.h"
#include "GameNetwork/User.h"
#include "GameNetwork/NetworkDefs.h"
// forward declarations
struct CommandPacket;
class GameMessage;
class GameInfo;
void ClearCommandPacket(UnsignedInt frame); ///< ClearCommandPacket clears the command packet at the start of the frame.
CommandPacket *GetCommandPacket(); ///< TheNetwork calls GetCommandPacket to get commands to send.
/**
* Interface definition for the Network.
*/
class NetworkInterface : public SubsystemInterface
{
protected:
public:
virtual ~NetworkInterface() override { };
static NetworkInterface * createNetwork();
virtual void liteupdate() = 0; ///< does a lightweight update for passing messages around.
virtual void setLocalAddress(UnsignedInt ip, UnsignedInt port) = 0; ///< Tell the network what local ip and port to bind to.
virtual Bool isFrameDataReady() = 0; ///< Are the commands for the next frame available?
virtual Bool isStalling() = 0;
virtual void parseUserList( const GameInfo *game ) = 0; ///< Parse a userlist, creating connections
virtual void startGame() = 0; ///< Sets the network game frame counter to -1
virtual UnsignedInt getRunAhead() = 0; ///< Get the current RunAhead value
virtual UnsignedInt getFrameRate() = 0; ///< Get the current allowed frame rate.
virtual UnsignedInt getPacketArrivalCushion() = 0; ///< Get the smallest packet arrival cushion since this was last called.
// Chat functions
virtual void sendChat(UnicodeString text, Int playerMask) = 0; ///< Send a chat line using the normal system.
virtual void sendDisconnectChat(UnicodeString text) = 0; ///< Send a chat line using the disconnect manager.
virtual void sendFile(AsciiString path, UnsignedByte playerMask, UnsignedShort commandID) = 0;
virtual UnsignedShort sendFileAnnounce(AsciiString path, UnsignedByte playerMask) = 0;
virtual Int getFileTransferProgress(Int playerID, AsciiString path) = 0;
virtual Bool areAllQueuesEmpty() = 0;
virtual void quitGame() = 0; ///< Quit the game right now.
virtual void selfDestructPlayer(Int index) = 0;
virtual void voteForPlayerDisconnect(Int slot) = 0; ///< register a vote towards this player's disconnect.
virtual Bool isPacketRouter() = 0;
// Bandwidth metrics
virtual Real getIncomingBytesPerSecond() = 0;
virtual Real getIncomingPacketsPerSecond() = 0;
virtual Real getOutgoingBytesPerSecond() = 0;
virtual Real getOutgoingPacketsPerSecond() = 0;
virtual Real getUnknownBytesPerSecond() = 0;
virtual Real getUnknownPacketsPerSecond() = 0;
virtual void updateLoadProgress( Int percent ) = 0;
virtual void loadProgressComplete() = 0;
virtual void sendTimeOutGameStart() = 0;
virtual UnsignedInt getLocalPlayerID()= 0;
virtual UnicodeString getPlayerName(Int playerNum)= 0;
virtual Int getNumPlayers() = 0;
virtual Int getAverageFPS() = 0;
virtual Int getSlotAverageFPS(Int slot) = 0;
virtual void attachTransport(Transport *transport) = 0;
virtual void initTransport() = 0;
virtual Bool sawCRCMismatch() = 0;
virtual void setSawCRCMismatch() = 0;
virtual Bool isPlayerConnected(Int playerID) = 0;
virtual void notifyOthersOfCurrentFrame() = 0; ///< Tells all the other players what frame we are on.
virtual void notifyOthersOfNewFrame(UnsignedInt frame) = 0; ///< Tells all the other players that we are on a new frame.
virtual Int getExecutionFrame() = 0; ///< Returns the next valid frame for simultaneous command execution.
#if defined(RTS_DEBUG)
virtual void toggleNetworkOn() = 0; ///< toggle whether or not to send network traffic.
#endif
// For disconnect blame assignment
virtual UnsignedInt getPingFrame() = 0;
virtual Int getPingsSent() = 0;
virtual Int getPingsReceived() = 0;
};
/**
* ResolveIP turns a string ("games2.westwood.com", or "192.168.0.1") into
* a 32-bit unsigned integer.
*/
UnsignedInt ResolveIP(AsciiString host);