|
27 | 27 | #include "Lib/BaseType.h" |
28 | 28 | #include "Common/MessageStream.h" |
29 | 29 |
|
30 | | -static const Int WOL_NAME_LEN = 64; |
| 30 | +static constexpr const Int WOL_NAME_LEN = 64; |
31 | 31 |
|
32 | 32 | /// Max number of commands per frame |
33 | | -static const Int MAX_COMMANDS = 256; |
| 33 | +static constexpr const Int MAX_COMMANDS = 256; |
34 | 34 |
|
35 | | -extern Int MIN_LOGIC_FRAMES; |
36 | | -extern Int MAX_FRAMES_AHEAD; |
37 | | -extern Int MIN_RUNAHEAD; |
| 35 | +// TheSuperHackers @tweak Mauller 26/08/2025 reduce the minimum runahead from 10 |
| 36 | +// This lets network games run at latencies down to 133ms when the network conditions allow |
| 37 | +static constexpr const Int MIN_LOGIC_FRAMES = 5; |
| 38 | +static constexpr const Int MAX_FRAMES_AHEAD = 128; |
| 39 | +static constexpr const Int MIN_RUNAHEAD = 4; |
38 | 40 |
|
39 | 41 | // FRAME_DATA_LENGTH needs to be MAX_FRAMES_AHEAD+1 because a player on a different |
40 | 42 | // computer can send commands for a frame that is one beyond twice the max runahead. |
41 | | -extern Int FRAME_DATA_LENGTH; |
42 | | -extern Int FRAMES_TO_KEEP; |
| 43 | +static constexpr const Int FRAME_DATA_LENGTH = (MAX_FRAMES_AHEAD + 1) * 2; |
| 44 | +static constexpr const Int FRAMES_TO_KEEP = (MAX_FRAMES_AHEAD / 2) + 1; |
43 | 45 |
|
44 | 46 | // This is the connection numbering: 1-8 are for players |
45 | 47 | enum ConnectionNumbers CPP_11(: Int) |
@@ -85,7 +87,7 @@ static constexpr const Int MAX_MESSAGES = 256; |
85 | 87 | * Command packet - contains frame #, total # of commands, and each command. This is what gets sent |
86 | 88 | * to each player every frame |
87 | 89 | */ |
88 | | -static const Int numCommandsPerCommandPacket = (MAX_NETWORK_MESSAGE_LEN - sizeof(UnsignedInt) - sizeof(UnsignedShort))/sizeof(GameMessage); |
| 90 | +static constexpr const Int numCommandsPerCommandPacket = (MAX_NETWORK_MESSAGE_LEN - sizeof(UnsignedInt) - sizeof(UnsignedShort))/sizeof(GameMessage); |
89 | 91 | #pragma pack(push, 1) |
90 | 92 | struct CommandPacket |
91 | 93 | { |
@@ -193,38 +195,38 @@ enum PlayerLeaveCode CPP_11(: Int) { |
193 | 195 | }; |
194 | 196 |
|
195 | 197 | // Magic number for identifying a Generals packet. |
196 | | -static const UnsignedShort GENERALS_MAGIC_NUMBER = 0xF00D; |
| 198 | +static constexpr const UnsignedShort GENERALS_MAGIC_NUMBER = 0xF00D; |
197 | 199 |
|
198 | 200 | // The number of fps history entries. |
199 | | -//static const Int NETWORK_FPS_HISTORY_LENGTH = 30; |
| 201 | +//static constexpr const Int NETWORK_FPS_HISTORY_LENGTH = 30; |
200 | 202 |
|
201 | 203 | // The number of ping history entries. |
202 | | -//static const Int NETWORK_LATENCY_HISTORY_LENGTH = 200; |
| 204 | +//static constexpr const Int NETWORK_LATENCY_HISTORY_LENGTH = 200; |
203 | 205 |
|
204 | 206 | // The number of miliseconds between run ahead metrics things |
205 | | -//static const Int NETWORK_RUN_AHEAD_METRICS_TIME = 5000; |
| 207 | +//static constexpr const Int NETWORK_RUN_AHEAD_METRICS_TIME = 5000; |
206 | 208 |
|
207 | 209 | // The number of cushion values to keep. |
208 | | -//static const Int NETWORK_CUSHION_HISTORY_LENGTH = 10; |
| 210 | +//static constexpr const Int NETWORK_CUSHION_HISTORY_LENGTH = 10; |
209 | 211 |
|
210 | 212 | // The amount of slack in the run ahead value. This is the percentage of the calculated run ahead that is added. |
211 | | -//static const Int NETWORK_RUN_AHEAD_SLACK = 20; |
| 213 | +//static constexpr const Int NETWORK_RUN_AHEAD_SLACK = 20; |
212 | 214 |
|
213 | 215 | // The number of seconds between when the connections to each player send a keep-alive packet. |
214 | 216 | // This should be less than 30 just to keep firewall ports open. |
215 | | -//static const Int NETWORK_KEEPALIVE_DELAY = 20; |
| 217 | +//static constexpr const Int NETWORK_KEEPALIVE_DELAY = 20; |
216 | 218 |
|
217 | 219 | // The number of milliseconds between when the game gets stuck on a frame for a network stall and |
218 | 220 | // and when the disconnect dialog comes up. |
219 | | -//static const Int NETWORK_DISCONNECT_TIME = 5000; |
| 221 | +//static constexpr const Int NETWORK_DISCONNECT_TIME = 5000; |
220 | 222 |
|
221 | 223 | // The number of miliseconds between when a player's last disconnect keep alive command |
222 | 224 | // was received and when they are considered disconnected from the game. |
223 | | -//static const Int NETWORK_PLAYER_TIMEOUT_TIME = 60000; |
| 225 | +//static constexpr const Int NETWORK_PLAYER_TIMEOUT_TIME = 60000; |
224 | 226 |
|
225 | 227 | // The base port number used for the transport socket. A players slot number is added to this |
226 | 228 | // value to get their actual port number. |
227 | | -static const Int NETWORK_BASE_PORT_NUMBER = 8088; |
| 229 | +static constexpr const Int NETWORK_BASE_PORT_NUMBER = 8088; |
228 | 230 |
|
229 | 231 | // the singleton |
230 | 232 | class NetworkInterface; |
|
0 commit comments