| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/Main/multi_client.cpp $ |
| 21 | * $Revision: 57 $ |
| 22 | * $Date: 9/20/01 1:10p $ |
| 23 | * $Author: Matt $ |
| 24 | * |
| 25 | * Multiplayer client code |
| 26 | * |
| 27 | * $Log: /DescentIII/Main/multi_client.cpp $ |
| 28 | * |
| 29 | * 57 9/20/01 1:10p Matt |
| 30 | * Fix for client not taking fusion overchage damage in a peer-to-peer |
| 31 | * game. |
| 32 | * |
| 33 | * 56 9/02/99 3:34p Jason |
| 34 | * send secondary fire reliable in a C/S game |
| 35 | * |
| 36 | * 55 5/20/99 4:10p Jason |
| 37 | * added heartbeat to multiplayer so clients wouldn't time out, also |
| 38 | * various multiplayer fixes |
| 39 | * |
| 40 | * 54 5/17/99 6:26p Jason |
| 41 | * added message for when the reliable buffer overruns |
| 42 | * |
| 43 | * 53 5/13/99 6:20p Kevin |
| 44 | * fixed bug with client who's reliable connection was broken to the |
| 45 | * server not disconnecting |
| 46 | * |
| 47 | * 52 5/10/99 10:22p Ardussi |
| 48 | * changes to compile on Mac |
| 49 | * |
| 50 | * 51 5/05/99 5:41p Jason |
| 51 | * fixed various multiplayer issues, including sequencing bugs and cheat |
| 52 | * prevention |
| 53 | * |
| 54 | * 50 4/30/99 5:06p Kevin |
| 55 | * misc dedicated server, networking and low memory enhancements |
| 56 | * |
| 57 | * 49 4/27/99 4:42a Jeff |
| 58 | * pass guidebot name on MyInfo |
| 59 | * |
| 60 | * 48 4/14/99 2:51a Jeff |
| 61 | * fixed some case mismatched #includes |
| 62 | * |
| 63 | * 47 2/16/99 3:47p Jason |
| 64 | * added marker updates to multiplayer server stream |
| 65 | * |
| 66 | * 46 2/15/99 7:49p Jeff |
| 67 | * new pilot file class and read/write system checked in...should be more |
| 68 | * robust than old |
| 69 | * |
| 70 | * 45 2/15/99 12:24p Jason |
| 71 | * set default pps setting if permissable netgame |
| 72 | * |
| 73 | * 44 2/15/99 11:21a Jason |
| 74 | * took out client side interpolation |
| 75 | * |
| 76 | * 43 2/12/99 5:58p Jason |
| 77 | * more permissable server stuff |
| 78 | * |
| 79 | * 42 2/12/99 3:38p Jason |
| 80 | * added client side interpolation |
| 81 | * |
| 82 | * 41 2/04/99 11:01a Jason |
| 83 | * added anti cheating to multiplayer |
| 84 | * |
| 85 | * 40 12/21/98 10:22a Jason |
| 86 | * added auto pps |
| 87 | * |
| 88 | * 39 12/08/98 4:52p Jeff |
| 89 | * changed the pilot pics packing to use Ushort instead of int16_t just for |
| 90 | * my conscience...removed some annoying mprintf's too |
| 91 | * |
| 92 | * 38 12/01/98 5:48p Jeff |
| 93 | * added pilot picture id to netplayer struct |
| 94 | * |
| 95 | * 37 11/18/98 10:50a Jason |
| 96 | * fixed peer to peer with new architecture |
| 97 | * |
| 98 | * 36 11/16/98 4:47p Jason |
| 99 | * changes for multiplayer (weapons load sent and deleting destroyed |
| 100 | * lightmapped objects) |
| 101 | * |
| 102 | * 35 10/28/98 11:51a Jason |
| 103 | * fixed some multiplayer problems, plus redid coop a bit to make it |
| 104 | * cleaner |
| 105 | * |
| 106 | * 34 10/27/98 10:19a Jason |
| 107 | * changes for new arch |
| 108 | * |
| 109 | * 33 10/22/98 12:28p Kevin |
| 110 | * Fixed pings in peer-peer |
| 111 | * |
| 112 | * 32 10/19/98 7:18p Matt |
| 113 | * Added system to support different types of damage to the player and |
| 114 | * have these different types make different sounds. |
| 115 | * |
| 116 | * 31 10/01/98 4:03p Jason |
| 117 | * took out sequencing bug |
| 118 | * |
| 119 | * 30 10/01/98 11:36a Kevin |
| 120 | * UI fixes and stuff |
| 121 | * |
| 122 | * 29 10/01/98 11:29a Jason |
| 123 | * changes for world states in multiplayer games |
| 124 | * |
| 125 | * 28 9/11/98 12:26p Jason |
| 126 | * got energy to shield and fusion damage working in multiplayer |
| 127 | * |
| 128 | * 27 9/04/98 3:45p Kevin |
| 129 | * Added ping_time to Netplayers struct. It's updated in peer-peer and |
| 130 | * client server |
| 131 | * |
| 132 | * 26 8/05/98 10:46a Kevin |
| 133 | * sound & bmp exchange fixes |
| 134 | * |
| 135 | */ |
| 136 | |
| 137 | #include "multi.h"cxx . . $ `<file>/Descent3/multi.h`/ |
| 138 | #include "multi_client.h"cxx . . $ `<file>/Descent3/multi_client.h`/ |
| 139 | #include "game.h"cxx . . $ `<file>/Descent3/game.h`/ |
| 140 | #include "player.h"cxx . . $ `<file>/Descent3/player.h`/ |
| 141 | #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/ |
| 142 | #include "pilot.h"cxx . . $ `<file>/Descent3/pilot.h`/ |
| 143 | #include "Mission.h"cxx . . $ `<file>/Descent3/Mission.h`/ |
| 144 | #include "stringtable.h"cxx . . $ `<file>/Descent3/stringtable.h`/ |
| 145 | #include "d3serial.h"cxx . . $ `<file>/Descent3/d3serial.h`/ |
| 146 | #include "ship.h"cxx . . $ `<file>/Descent3/ship.h`/ |
| 147 | |
| 148 | #define WEAPONS_LOAD_UPDATE_INTERVALcxx . . $ `Descent3/multi_client.cpp:148:9`! 2.0 |
| 149 | |
| 150 | float Last_weapons_load_update_timecxx . . $ Last_weapons_load_update_time. = 0; |
| 151 | |
| 152 | // Setup saved moves |
| 153 | saved_movecxx . . $ saved_move# SavedMovescxx . . $ SavedMoves.[MAX_SAVED_MOVEScxx . . $ `Descent3/multi_client.h:27:9`!]; |
| 154 | int Current_saved_movecxx . . $ Current_saved_move. = 0; |
| 155 | |
| 156 | extern int Use_file_xfercxx . . $ Use_file_xfer.; |
| 157 | |
| 158 | // Tell the server about my info, such as name, ship type, etc |
| 159 | void MultiSendMyInfocxx . . $ MultiSendMyInfo(49f6e7a06ebc5aa8).() { |
| 160 | int size; |
| 161 | uint8_tcxx . . $ uint8_t# data[MAX_GAME_DATA_SIZEcxx . . $ `Descent3/multi_external.h:134:9`!]; |
| 162 | int count = 0; |
| 163 | |
| 164 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Sending my info\n"); |
| 165 | char pshipmodel[PAGENAME_LENcxx . . $ `lib/manage_external.h:49:9`!]; |
| 166 | Current_pilotcxx . . $ Current_pilot..get_shipcxx . . $ pilot#get_ship(fda57c8427c60377).(pshipmodel); |
| 167 | |
| 168 | int ship_index = FindShipNamecxx . . $ FindShipName(5c4306d8553b3696).(pshipmodel); |
| 169 | if (ship_index < 0) |
| 170 | ship_index = 0; |
| 171 | |
| 172 | size = START_DATAcxx . . $ START_DATA(8c36ee1faa9e0a0b).(MP_MY_INFOcxx . . $ `Descent3/multi.h:529:9`!, data, &count); |
| 173 | |
| 174 | // Do callsign name |
| 175 | MultiAddBytecxx . . $ MultiAddByte(3bbe8835367eaa4e).(Player_numcxx . . $ Player_num., data, &count); |
| 176 | int len = strlen(Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].callsigncxx . . $ player#callsign.) + 1; |
| 177 | MultiAddBytecxx . . $ MultiAddByte(3bbe8835367eaa4e).(len, data, &count); |
| 178 | memcpy(&data[count], Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].callsigncxx . . $ player#callsign., len); |
| 179 | count += len; |
| 180 | |
| 181 | // Do ship name |
| 182 | len = strlen(Shipscxx . . $ Ships.[ship_index].namecxx . . $ ship#name.) + 1; |
| 183 | MultiAddBytecxx . . $ MultiAddByte(3bbe8835367eaa4e).(len, data, &count); |
| 184 | memcpy(&data[count], Shipscxx . . $ Ships.[ship_index].namecxx . . $ ship#name., len); |
| 185 | count += len; |
| 186 | |
| 187 | if (Game_is_master_tracker_gamecxx . . $ Game_is_master_tracker_game.) { |
| 188 | MultiAddUintcxx . . $ MultiAddUint(c51d06dbd74b8495).(MASTER_TRACKER_SIGcxx . . $ `Descent3/multi.h:656:9`!, data, &count); |
| 189 | strcpy(Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].tracker_idcxx . . $ player#tracker_id., Tracker_idcxx . . $ Tracker_id.); |
| 190 | len = strlen(Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].tracker_idcxx . . $ player#tracker_id.) + 1; |
| 191 | MultiAddBytecxx . . $ MultiAddByte(3bbe8835367eaa4e).(len, data, &count); |
| 192 | memcpy(&data[count], Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].tracker_idcxx . . $ player#tracker_id., len); |
| 193 | count += len; |
| 194 | } |
| 195 | int ser = 0; |
| 196 | GetInternalSerializationNumbercxx . . $ GetInternalSerializationNumber(c936d4c31c50eb30).(&ser); |
| 197 | MultiAddIntcxx . . $ MultiAddInt(49f79918a3afee3).(ser, data, &count); |
| 198 | |
| 199 | // Send packets per second |
| 200 | int pps = nw_ReccomendPPScxx . . $ nw_ReccomendPPS(b126dc7c1de90089).(); |
| 201 | if ((Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_PERMISSABLEcxx . . $ `Descent3/multi_external.h:239:9`!) && pps < 8) |
| 202 | pps = 8; // If permissable game, can't be lower than 8 |
| 203 | |
| 204 | MultiAddBytecxx . . $ MultiAddByte(3bbe8835367eaa4e).(pps, data, &count); |
| 205 | |
| 206 | // pilot picture id |
| 207 | uint16_tcxx . . $ uint16_t# ppic_id; |
| 208 | Current_pilotcxx . . $ Current_pilot..get_multiplayer_datacxx . . $ pilot#get_multiplayer_data(ea6e7aa10f4b80f5).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, &ppic_id); |
| 209 | MultiAddUshortcxx . . $ MultiAddUshort(309f537dbae2306e).(ppic_id, data, &count); |
| 210 | |
| 211 | // Copy the guidebot name out |
| 212 | char guidebot_name[32]; |
| 213 | Current_pilotcxx . . $ Current_pilot..get_guidebot_namecxx . . $ pilot#get_guidebot_name(fda57c8427c60377).(guidebot_name); |
| 214 | len = strlen(guidebot_name) + 1; |
| 215 | MultiAddBytecxx . . $ MultiAddByte(3bbe8835367eaa4e).(len, data, &count); |
| 216 | memcpy(&data[count], guidebot_name, len); |
| 217 | count += len; |
| 218 | |
| 219 | END_DATAcxx . . $ END_DATA(dde21517a502ab05).(count, data, size); |
| 220 | |
| 221 | nw_SendReliablecxx . . $ nw_SendReliable(f6b56715d3e5e15a).(NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].reliable_socketcxx . . $ netplayer#reliable_socket., data, count); |
| 222 | } |
| 223 | |
| 224 | // Ask the server to tell me about the players |
| 225 | void MultiSendRequestForPlayerscxx . . $ MultiSendRequestForPlayers(49f6e7a06ebc5aa8).() { |
| 226 | int size; |
| 227 | uint8_tcxx . . $ uint8_t# data[MAX_GAME_DATA_SIZEcxx . . $ `Descent3/multi_external.h:134:9`!]; |
| 228 | int count = 0; |
| 229 | |
| 230 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Sending request for players\n"); |
| 231 | |
| 232 | size = START_DATAcxx . . $ START_DATA(8c36ee1faa9e0a0b).(MP_REQUEST_PLAYERScxx . . $ `Descent3/multi.h:528:9`!, data, &count); |
| 233 | MultiAddBytecxx . . $ MultiAddByte(3bbe8835367eaa4e).(Player_numcxx . . $ Player_num., data, &count); |
| 234 | END_DATAcxx . . $ END_DATA(dde21517a502ab05).(count, data, size); |
| 235 | |
| 236 | nw_SendReliablecxx . . $ nw_SendReliable(f6b56715d3e5e15a).(NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].reliable_socketcxx . . $ netplayer#reliable_socket., data, count); |
| 237 | } |
| 238 | |
| 239 | // Ask the server to tell me about the buildings |
| 240 | void MultiSendRequestForBuildingscxx . . $ MultiSendRequestForBuildings(49f6e7a06ebc5aa8).() { |
| 241 | int size; |
| 242 | uint8_tcxx . . $ uint8_t# data[MAX_GAME_DATA_SIZEcxx . . $ `Descent3/multi_external.h:134:9`!]; |
| 243 | int count = 0; |
| 244 | |
| 245 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Sending request for buildings\n"); |
| 246 | |
| 247 | size = START_DATAcxx . . $ START_DATA(8c36ee1faa9e0a0b).(MP_REQUEST_BUILDINGScxx . . $ `Descent3/multi.h:540:9`!, data, &count); |
| 248 | MultiAddBytecxx . . $ MultiAddByte(3bbe8835367eaa4e).(Player_numcxx . . $ Player_num., data, &count); |
| 249 | END_DATAcxx . . $ END_DATA(dde21517a502ab05).(count, data, size); |
| 250 | |
| 251 | nw_SendReliablecxx . . $ nw_SendReliable(f6b56715d3e5e15a).(NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].reliable_socketcxx . . $ netplayer#reliable_socket., data, count); |
| 252 | } |
| 253 | |
| 254 | // Ask the server to tell me about the world |
| 255 | void MultiSendRequestForWorldStatescxx . . $ MultiSendRequestForWorldStates(49f6e7a06ebc5aa8).() { |
| 256 | int size; |
| 257 | uint8_tcxx . . $ uint8_t# data[MAX_GAME_DATA_SIZEcxx . . $ `Descent3/multi_external.h:134:9`!]; |
| 258 | int count = 0; |
| 259 | |
| 260 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Sending request for world states\n"); |
| 261 | |
| 262 | size = START_DATAcxx . . $ START_DATA(8c36ee1faa9e0a0b).(MP_REQUEST_WORLD_STATEScxx . . $ `Descent3/multi.h:609:9`!, data, &count); |
| 263 | MultiAddBytecxx . . $ MultiAddByte(3bbe8835367eaa4e).(Player_numcxx . . $ Player_num., data, &count); |
| 264 | // Send the digest (checksum) for this level + our salt + the ships |
| 265 | // Do level checksum |
| 266 | for (int i = 0; i < 16; i++) { |
| 267 | MultiAddBytecxx . . $ MultiAddByte(3bbe8835367eaa4e).(NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].digestcxx . . $ netplayer#digest.[i], data, &count); |
| 268 | } |
| 269 | |
| 270 | END_DATAcxx . . $ END_DATA(dde21517a502ab05).(count, data, size); |
| 271 | |
| 272 | nw_SendReliablecxx . . $ nw_SendReliable(f6b56715d3e5e15a).(NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].reliable_socketcxx . . $ netplayer#reliable_socket., data, count); |
| 273 | } |
| 274 | |
| 275 | // Ask the server to tell me about the objects |
| 276 | void MultiSendRequestForObjectscxx . . $ MultiSendRequestForObjects(49f6e7a06ebc5aa8).() { |
| 277 | int size; |
| 278 | uint8_tcxx . . $ uint8_t# data[MAX_GAME_DATA_SIZEcxx . . $ `Descent3/multi_external.h:134:9`!]; |
| 279 | int count = 0; |
| 280 | |
| 281 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Sending request for objects\n"); |
| 282 | |
| 283 | size = START_DATAcxx . . $ START_DATA(8c36ee1faa9e0a0b).(MP_REQUEST_OBJECTScxx . . $ `Descent3/multi.h:543:9`!, data, &count); |
| 284 | MultiAddBytecxx . . $ MultiAddByte(3bbe8835367eaa4e).(Player_numcxx . . $ Player_num., data, &count); |
| 285 | END_DATAcxx . . $ END_DATA(dde21517a502ab05).(count, data, size); |
| 286 | |
| 287 | nw_SendReliablecxx . . $ nw_SendReliable(f6b56715d3e5e15a).(NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].reliable_socketcxx . . $ netplayer#reliable_socket., data, count); |
| 288 | } |
| 289 | |
| 290 | #define SERVER_DISCONNECT_TIMEcxx . . $ `Descent3/multi_client.cpp:290:9`! 8.0 |
| 291 | |
| 292 | // Returns 1 if the server is gone! |
| 293 | int ServerTimedOutcxx . . $ ServerTimedOut(b126dc7c1de90089).() { |
| 294 | // Don't check for a non-connected player |
| 295 | if (!(NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].flagscxx . . $ netplayer#flags. & NPF_CONNECTEDcxx . . $ `Descent3/multi_external.h:165:9`!)) |
| 296 | return 0; |
| 297 | |
| 298 | if (!nw_CheckReliableSocketcxx . . $ nw_CheckReliableSocket(7864480464b09eea).(NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].reliable_socketcxx . . $ netplayer#reliable_socket.)) { |
| 299 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Reliable connection to the server was broken. Disconnecting.\n"); |
| 300 | ShowProgressScreencxx . . $ ShowProgressScreen(8d00172ec7558ddf).(TXT_RELIABLE_OVERRUNcxx . . $ `Descent3/stringtable.h:921:9`!); |
| 301 | Sleepcxx . . $ Sleep(d4f767463ce0a6b3).(1000); |
| 302 | return 1; |
| 303 | } |
| 304 | if ((timer_GetTimecxx . . $ `ddio/ddio.h:236:9`!() - Netgamecxx . . $ Netgame..last_server_timecxx . . $ netgame_info#last_server_time.) > SERVER_DISCONNECT_TIMEcxx . . $ `Descent3/multi_client.cpp:290:9`!) |
| 305 | return 1; |
| 306 | |
| 307 | return 0; |
| 308 | } |
| 309 | #define NET_CLIENT_GAMETIME_REQ_TIMEOUTcxx . . $ `Descent3/multi_client.cpp:309:9`! 10 |
| 310 | #define NET_CLIENT_GAMETIME_REQ_RETRYcxx . . $ `Descent3/multi_client.cpp:310:9`! 1 |
| 311 | float First_gametime_reqcxx . . $ First_gametime_req. = 0; |
| 312 | float Last_gametime_reqcxx . . $ Last_gametime_req. = 0; |
| 313 | |
| 314 | // Do client stuff for this frame |
| 315 | void MultiDoClientFramecxx . . $ MultiDoClientFrame(49f6e7a06ebc5aa8).() { |
| 316 | int i; |
| 317 | Multi_last_sent_timecxx . . $ Multi_last_sent_time.[Player_numcxx . . $ Player_num.][0] += Frametimecxx . . $ Frametime.; |
| 318 | |
| 319 | // Get data from the server |
| 320 | MultiProcessIncomingcxx . . $ MultiProcessIncoming(49f6e7a06ebc5aa8).(); |
| 321 | |
| 322 | if (Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_EXIT_NOWcxx . . $ `Descent3/multi_external.h:229:9`!) { |
| 323 | // DLL says we should bail! |
| 324 | Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. &= ~NF_EXIT_NOWcxx . . $ `Descent3/multi_external.h:229:9`!; |
| 325 | MultiLeaveGamecxx . . $ MultiLeaveGame(49f6e7a06ebc5aa8).(); |
| 326 | SetFunctionModecxx . . $ SetFunctionMode(63b1daf7e687142b).(MENU_MODEcxx . . $ MENU_MODE.); |
| 327 | return; |
| 328 | } |
| 329 | |
| 330 | if (NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].sequencecxx . . $ netplayer#sequence. == NETSEQ_LEVEL_STARTcxx . . $ `Descent3/multi_external.h:150:9`!) { |
| 331 | MultiSendMyInfocxx . . $ MultiSendMyInfo(49f6e7a06ebc5aa8).(); |
| 332 | NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].sequencecxx . . $ netplayer#sequence. = NETSEQ_NEED_GAMETIMEcxx . . $ `Descent3/multi_external.h:151:9`!; |
| 333 | First_gametime_reqcxx . . $ First_gametime_req. = timer_GetTimecxx . . $ `ddio/ddio.h:236:9`!(); |
| 334 | } else if (NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].sequencecxx . . $ netplayer#sequence. == NETSEQ_NEED_GAMETIMEcxx . . $ `Descent3/multi_external.h:151:9`!) { |
| 335 | // Ask for gametime |
| 336 | GetServerGameTimecxx . . $ GetServerGameTime(49f6e7a06ebc5aa8).(); |
| 337 | Last_gametime_reqcxx . . $ Last_gametime_req. = timer_GetTimecxx . . $ `ddio/ddio.h:236:9`!(); |
| 338 | NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].sequencecxx . . $ netplayer#sequence. = NETSEQ_WAIT_GAMETIMEcxx . . $ `Descent3/multi_external.h:152:9`!; |
| 339 | } else if (NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].sequencecxx . . $ netplayer#sequence. == NETSEQ_WAIT_GAMETIMEcxx . . $ `Descent3/multi_external.h:152:9`!) { |
| 340 | if (Got_new_game_timecxx . . $ Got_new_game_time.) { |
| 341 | NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].sequencecxx . . $ netplayer#sequence. = NETSEQ_REQUEST_PLAYERScxx . . $ `Descent3/multi_external.h:153:9`!; |
| 342 | } else { |
| 343 | // Wait for server response |
| 344 | if ((timer_GetTimecxx . . $ `ddio/ddio.h:236:9`!() - First_gametime_reqcxx . . $ First_gametime_req.) > NET_CLIENT_GAMETIME_REQ_TIMEOUTcxx . . $ `Descent3/multi_client.cpp:309:9`!) { |
| 345 | // Giving up, we waited too long. |
| 346 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Server disconnected while waiting for gametime!\n"); |
| 347 | MultiLeaveGamecxx . . $ MultiLeaveGame(49f6e7a06ebc5aa8).(); |
| 348 | ShowProgressScreencxx . . $ ShowProgressScreen(8d00172ec7558ddf).(TXT_MLTDISCFRMSERVcxx . . $ `Descent3/stringtable.h:182:9`!); |
| 349 | Sleepcxx . . $ Sleep(d4f767463ce0a6b3).(2000); |
| 350 | } else if ((timer_GetTimecxx . . $ `ddio/ddio.h:236:9`!() - Last_gametime_reqcxx . . $ Last_gametime_req.) > NET_CLIENT_GAMETIME_REQ_RETRYcxx . . $ `Descent3/multi_client.cpp:310:9`!) { |
| 351 | NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].sequencecxx . . $ netplayer#sequence. = NETSEQ_NEED_GAMETIMEcxx . . $ `Descent3/multi_external.h:151:9`!; |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | } else if (NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].sequencecxx . . $ netplayer#sequence. == NETSEQ_REQUEST_PLAYERScxx . . $ `Descent3/multi_external.h:153:9`!) { |
| 356 | MultiSendRequestForPlayerscxx . . $ MultiSendRequestForPlayers(49f6e7a06ebc5aa8).(); |
| 357 | NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].sequencecxx . . $ netplayer#sequence. = NETSEQ_PLAYERScxx . . $ `Descent3/multi_external.h:154:9`!; |
| 358 | } else if (NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].sequencecxx . . $ netplayer#sequence. == NETSEQ_REQUEST_BUILDINGScxx . . $ `Descent3/multi_external.h:155:9`!) { |
| 359 | MultiSendRequestForBuildingscxx . . $ MultiSendRequestForBuildings(49f6e7a06ebc5aa8).(); |
| 360 | NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].sequencecxx . . $ netplayer#sequence. = NETSEQ_BUILDINGScxx . . $ `Descent3/multi_external.h:156:9`!; |
| 361 | } else if (NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].sequencecxx . . $ netplayer#sequence. == NETSEQ_REQUEST_OBJECTScxx . . $ `Descent3/multi_external.h:157:9`!) { |
| 362 | MultiSendRequestForObjectscxx . . $ MultiSendRequestForObjects(49f6e7a06ebc5aa8).(); |
| 363 | NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].sequencecxx . . $ netplayer#sequence. = NETSEQ_OBJECTScxx . . $ `Descent3/multi_external.h:158:9`!; |
| 364 | } else if (NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].sequencecxx . . $ netplayer#sequence. == NETSEQ_REQUEST_WORLDcxx . . $ `Descent3/multi_external.h:159:9`!) { |
| 365 | MultiSendRequestForWorldStatescxx . . $ MultiSendRequestForWorldStates(49f6e7a06ebc5aa8).(); |
| 366 | NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].sequencecxx . . $ netplayer#sequence. = NETSEQ_WORLDcxx . . $ `Descent3/multi_external.h:160:9`!; |
| 367 | NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].custom_file_seqcxx . . $ netplayer#custom_file_seq. = 0; |
| 368 | } else if (NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].sequencecxx . . $ netplayer#sequence. == NETSEQ_PLAYINGcxx . . $ `Descent3/multi_external.h:161:9`!) { |
| 369 | if (NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].custom_file_seqcxx . . $ netplayer#custom_file_seq. == 0) { |
| 370 | // Tell the server about our custom data (once only) |
| 371 | if (NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].ship_logocxx . . $ netplayer#ship_logo.[0]) |
| 372 | PlayerSetCustomTexturecxx . . $ PlayerSetCustomTexture(3c8082c546dd2ea0).(Player_numcxx . . $ Player_num., NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].ship_logocxx . . $ netplayer#ship_logo.); |
| 373 | NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].custom_file_seqcxx . . $ netplayer#custom_file_seq. = 0xff; |
| 374 | |
| 375 | // Make sure we as the client actually want to send our custom data |
| 376 | if (Use_file_xfercxx . . $ Use_file_xfer.) |
| 377 | MultiSendClientCustomDatacxx . . $ MultiSendClientCustomData(3e454b8ccf442868).(Player_numcxx . . $ Player_num.); |
| 378 | } |
| 379 | |
| 380 | bool client_file_xfering = false; |
| 381 | for (i = 0; i < MAX_NET_PLAYERScxx . . $ `Descent3/multi_external.h:132:9`!; i++) { |
| 382 | if (NetPlayerscxx . . $ NetPlayers.[i].file_xfer_flagscxx . . $ netplayer#file_xfer_flags. != NETFILE_NONEcxx . . $ `Descent3/multi.h:683:9`!) |
| 383 | client_file_xfering = true; |
| 384 | } |
| 385 | // See if we have room for a transfer |
| 386 | if (!client_file_xfering) { |
| 387 | // Check to see if we need to request any files from this bozo |
| 388 | for (i = 0; i < MAX_NET_PLAYERScxx . . $ `Descent3/multi_external.h:132:9`!; i++) { |
| 389 | if (i == Player_numcxx . . $ Player_num.) |
| 390 | continue; |
| 391 | if ((NetPlayerscxx . . $ NetPlayers.[i].custom_file_seqcxx . . $ netplayer#custom_file_seq. != NETFILE_ID_NOFILEcxx . . $ `Descent3/multi.h:688:9`!) && |
| 392 | (NetPlayerscxx . . $ NetPlayers.[i].custom_file_seqcxx . . $ netplayer#custom_file_seq. != NETFILE_ID_DONEcxx . . $ `Descent3/multi.h:694:9`!)) { |
| 393 | // See if we are already sending or receiving a file from this player |
| 394 | if (NetPlayerscxx . . $ NetPlayers.[i].file_xfer_flagscxx . . $ netplayer#file_xfer_flags. == NETFILE_NONEcxx . . $ `Descent3/multi.h:683:9`!) { |
| 395 | // Check to see if we have this file in our cache |
| 396 | // Time to ask for the file specified in the sequence |
| 397 | MultiAskForFilecxx . . $ MultiAskForFile(1dc4f76fb2e63523).(NetPlayerscxx . . $ NetPlayers.[i].custom_file_seqcxx . . $ netplayer#custom_file_seq., i, 0); |
| 398 | break; |
| 399 | } |
| 400 | } |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | Last_weapons_load_update_timecxx . . $ Last_weapons_load_update_time. += Frametimecxx . . $ Frametime.; |
| 405 | if (Last_weapons_load_update_timecxx . . $ Last_weapons_load_update_time. > WEAPONS_LOAD_UPDATE_INTERVALcxx . . $ `Descent3/multi_client.cpp:148:9`!) { |
| 406 | Last_weapons_load_update_timecxx . . $ Last_weapons_load_update_time. = 0; |
| 407 | MultiSendWeaponsLoadcxx . . $ MultiSendWeaponsLoad(49f6e7a06ebc5aa8).(); |
| 408 | } |
| 409 | |
| 410 | // Figure out if we need to send our movement |
| 411 | bool send_it = false; |
| 412 | |
| 413 | if (Player_fire_packetcxx . . $ Player_fire_packet.[Player_numcxx . . $ Player_num.].fired_on_this_framecxx . . $ player_fire_packet#fired_on_this_frame. != PFP_NO_FIREDcxx . . $ `Descent3/multi.h:659:9`!) |
| 414 | send_it = true; |
| 415 | |
| 416 | if (Multi_last_sent_timecxx . . $ Multi_last_sent_time.[Player_numcxx . . $ Player_num.][0] > (1.0 / (float)NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].ppscxx . . $ netplayer#pps.)) |
| 417 | send_it = true; |
| 418 | |
| 419 | if (send_it) { |
| 420 | // Request damage if need be |
| 421 | if (Multi_requested_damage_amountcxx . . $ Multi_requested_damage_amount. != 0) { |
| 422 | if ((Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_CLIENTcxx . . $ `Descent3/multi_external.h:128:9`!) && (Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_PEER_PEERcxx . . $ `Descent3/multi_external.h:230:9`!)) { |
| 423 | MultiSendRequestPeerDamagecxx . . $ MultiSendRequestPeerDamage(429600379706fe12).(&Objectscxx . . $ Objects.[Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].objnumcxx . . $ player#objnum.], -1, Multi_requested_damage_typecxx . . $ Multi_requested_damage_type., |
| 424 | Multi_requested_damage_amountcxx . . $ Multi_requested_damage_amount.); |
| 425 | } else { |
| 426 | MultiSendRequestDamagecxx . . $ MultiSendRequestDamage(43c79ee2f1b9aefe).(Multi_requested_damage_typecxx . . $ Multi_requested_damage_type., Multi_requested_damage_amountcxx . . $ Multi_requested_damage_amount.); |
| 427 | } |
| 428 | Multi_requested_damage_amountcxx . . $ Multi_requested_damage_amount. = 0; |
| 429 | } |
| 430 | |
| 431 | // Request shields if need be |
| 432 | for (i = 0; i < MAX_SHIELD_REQUEST_TYPEScxx . . $ `Descent3/multi.h:651:9`!; i++) { |
| 433 | if (Multi_additional_shieldscxx . . $ Multi_additional_shields.[i] != 0) { |
| 434 | MultiSendRequestShieldscxx . . $ MultiSendRequestShields(43c79ee2f1b9aefe).(i, Multi_additional_shieldscxx . . $ Multi_additional_shields.[i]); |
| 435 | Multi_additional_shieldscxx . . $ Multi_additional_shields.[i] = 0; |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | uint8_tcxx . . $ uint8_t# data[MAX_GAME_DATA_SIZEcxx . . $ `Descent3/multi_external.h:134:9`!], count = 0, add_count = 0; |
| 440 | |
| 441 | count = MultiStuffPositioncxx . . $ MultiStuffPosition(b2cc8657ba51080d).(Player_numcxx . . $ Player_num., data); |
| 442 | |
| 443 | // Send firing if needed |
| 444 | if (Player_fire_packetcxx . . $ Player_fire_packet.[Player_numcxx . . $ Player_num.].fired_on_this_framecxx . . $ player_fire_packet#fired_on_this_frame. == PFP_FIREDcxx . . $ `Descent3/multi.h:660:9`!) |
| 445 | add_count = MultiStuffPlayerFirecxx . . $ MultiStuffPlayerFire(b2cc8657ba51080d).(Player_numcxx . . $ Player_num., &data[count]); |
| 446 | |
| 447 | count += add_count; |
| 448 | |
| 449 | // Add in guided stuff |
| 450 | if (Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].guided_objcxx . . $ player#guided_obj. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 451 | add_count = MultiStuffGuidedInfocxx . . $ MultiStuffGuidedInfo(b2cc8657ba51080d).(Player_numcxx . . $ Player_num., &data[count]); |
| 452 | count += add_count; |
| 453 | } |
| 454 | |
| 455 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(count < MAX_GAME_DATA_SIZEcxx . . $ `Descent3/multi_external.h:134:9`!); |
| 456 | |
| 457 | if (Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_PEER_PEERcxx . . $ `Descent3/multi_external.h:230:9`!) { |
| 458 | for (i = 0; i < MAX_NET_PLAYERScxx . . $ `Descent3/multi_external.h:132:9`!; i++) { |
| 459 | if (!(NetPlayerscxx . . $ NetPlayers.[i].flagscxx . . $ netplayer#flags. & NPF_CONNECTEDcxx . . $ `Descent3/multi_external.h:165:9`!)) |
| 460 | continue; |
| 461 | if (i == Player_numcxx . . $ Player_num.) |
| 462 | continue; |
| 463 | |
| 464 | // Now get the ping time if needed |
| 465 | if ((timer_GetTimecxx . . $ `ddio/ddio.h:236:9`!() - NetPlayerscxx . . $ NetPlayers.[i].last_ping_timecxx . . $ netplayer#last_ping_time.) > MULTI_PING_INTERVALcxx . . $ `Descent3/multi.h:520:9`!) |
| 466 | MultiSendPingcxx . . $ MultiSendPing(d4f767463ce0a6b3).(i); |
| 467 | |
| 468 | nw_Sendcxx . . $ nw_Send(102d2f582237fe86).(&NetPlayerscxx . . $ NetPlayers.[i].addrcxx . . $ netplayer#addr., data, count, 0); |
| 469 | } |
| 470 | } else |
| 471 | nw_Sendcxx . . $ nw_Send(102d2f582237fe86).(&Netgamecxx . . $ Netgame..server_addresscxx . . $ netgame_info#server_address., data, count, 0); |
| 472 | |
| 473 | // TODO: SEND RELIABLE WEAPON FIRE |
| 474 | if (Player_fire_packetcxx . . $ Player_fire_packet.[Player_numcxx . . $ Player_num.].fired_on_this_framecxx . . $ player_fire_packet#fired_on_this_frame. == PFP_FIRED_RELIABLEcxx . . $ `Descent3/multi.h:661:9`!) { |
| 475 | // mprintf(0,"I NEED TO SEND RELIABLE FIRE\n"); |
| 476 | count = MultiStuffPlayerFirecxx . . $ MultiStuffPlayerFire(b2cc8657ba51080d).(Player_numcxx . . $ Player_num., data); |
| 477 | nw_SendReliablecxx . . $ nw_SendReliable(f6b56715d3e5e15a).(NetPlayerscxx . . $ NetPlayers.[Player_numcxx . . $ Player_num.].reliable_socketcxx . . $ netplayer#reliable_socket., data, count, true); |
| 478 | } |
| 479 | |
| 480 | // Clear our data |
| 481 | Player_fire_packetcxx . . $ Player_fire_packet.[Player_numcxx . . $ Player_num.].fired_on_this_framecxx . . $ player_fire_packet#fired_on_this_frame. = PFP_NO_FIREDcxx . . $ `Descent3/multi.h:659:9`!; |
| 482 | Multi_last_sent_timecxx . . $ Multi_last_sent_time.[Player_numcxx . . $ Player_num.][0] = 0; |
| 483 | Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].flagscxx . . $ player#flags. &= ~PLAYER_FLAGS_SEND_MOVEMENTcxx . . $ `Descent3/player_external.h:98:9`!; |
| 484 | } |
| 485 | |
| 486 | if (ServerTimedOutcxx . . $ ServerTimedOut(b126dc7c1de90089).()) { |
| 487 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Server disconnected!\n"); |
| 488 | MultiLeaveGamecxx . . $ MultiLeaveGame(49f6e7a06ebc5aa8).(); |
| 489 | ShowProgressScreencxx . . $ ShowProgressScreen(8d00172ec7558ddf).(TXT_MLTDISCFRMSERVcxx . . $ `Descent3/stringtable.h:182:9`!); |
| 490 | Sleepcxx . . $ Sleep(d4f767463ce0a6b3).(2000); |
| 491 | } |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | // Initializes some fields for a network client to play |
| 496 | // Client only |
| 497 | void MultiStartClientcxx . . $ MultiStartClient(fda57c8427c60377).(char *scriptname) { |
| 498 | int i; |
| 499 | |
| 500 | for (i = 0; i < MAX_NET_PLAYERScxx . . $ `Descent3/multi_external.h:132:9`!; i++) { |
| 501 | memset(&NetPlayerscxx . . $ NetPlayers.[i], 0, sizeof(netplayercxx . . $ netplayer#)); |
| 502 | } |
| 503 | |
| 504 | for (i = 0; i < MAX_SAVED_MOVEScxx . . $ `Descent3/multi_client.h:27:9`!; i++) |
| 505 | SavedMovescxx . . $ SavedMoves.[i].timestampcxx . . $ saved_move#timestamp. = 0; |
| 506 | |
| 507 | Current_saved_movecxx . . $ Current_saved_move. = 0; |
| 508 | |
| 509 | // Temporary name fix |
| 510 | Current_pilotcxx . . $ Current_pilot..get_namecxx . . $ pilot#get_name(fda57c8427c60377).(Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].callsigncxx . . $ player#callsign.); |
| 511 | |
| 512 | Multi_send_sizecxx . . $ Multi_send_size.[Player_numcxx . . $ Player_num.] = 0; |
| 513 | Multi_last_sent_timecxx . . $ Multi_last_sent_time.[Player_numcxx . . $ Player_num.][0] = 0; |
| 514 | Last_weapons_load_update_timecxx . . $ Last_weapons_load_update_time. = 0; |
| 515 | |
| 516 | Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. = LR_CLIENTcxx . . $ `Descent3/multi_external.h:128:9`!; |
| 517 | Game_modecxx . . $ Game_mode. = GM_NETWORKcxx . . $ `Descent3/game.h:281:9`!; |
| 518 | SetGamemodeScriptcxx . . $ SetGamemodeScript(34d26762b42c433a).(scriptname); |
| 519 | } |