| 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 | |
| 19 | #ifndef MULTI_SERVER_H |
| 20 | |
| 21 | #include "pstypes.h" |
| 22 | #include "multi.h" |
| 23 | #include "game2dll.h" |
| 24 | // #include "gametrack.h" |
| 25 | |
| 26 | extern int Join_response_strings[]; |
| 27 | |
| 28 | // extern d3_net_game_data D3_tracker_info; |
| 29 | |
| 30 | #define MAX_CHANGED_OBJECTS 700 |
| 31 | |
| 32 | extern int Changed_anim[MAX_CHANGED_OBJECTS][MAX_NET_PLAYERS]; |
| 33 | extern uint16_t Num_changed_anim[MAX_NET_PLAYERS]; |
| 34 | |
| 35 | extern int Changed_wb_anim[MAX_CHANGED_OBJECTS][MAX_NET_PLAYERS]; |
| 36 | extern uint16_t Num_changed_wb_anim[MAX_NET_PLAYERS]; |
| 37 | |
| 38 | extern int Changed_turret[MAX_CHANGED_OBJECTS][MAX_NET_PLAYERS]; |
| 39 | extern uint16_t Num_changed_turret[MAX_NET_PLAYERS]; |
| 40 | |
| 41 | extern uint32_t Secret_net_id; |
| 42 | #define JOIN_ANSWER_OK 0 |
| 43 | #define JOIN_ANSWER_NOT_SERVER 1 |
| 44 | #define JOIN_ANSWER_REJECTED 2 |
| 45 | #define JOIN_ANSWER_NO_ROOM 3 |
| 46 | #define JOIN_ANSWER_FULL 4 |
| 47 | |
| 48 | // Does whatever the server needs to do for this frame |
| 49 | void MultiDoServerFrame(); |
| 50 | |
| 51 | // Set the local machine as a server |
| 52 | void MultiStartServer(int playing, char *scriptname, int dedicated_server_num_teams = -1); |
| 53 | |
| 54 | // Disconnects all players that haven't been heard from in a while |
| 55 | // Server only |
| 56 | void MultiDisconnectDeadPlayers(); |
| 57 | |
| 58 | // Disconnect a player for whatever reason |
| 59 | // Server only |
| 60 | void MultiDisconnectPlayer(int slot); |
| 61 | |
| 62 | // Sends existing players to a joining player |
| 63 | // Server only |
| 64 | void MultiSendPlayer(int slot, int which); |
| 65 | |
| 66 | // Sends this reliable packet to everyone except the server and the named slot |
| 67 | void MultiSendReliablyToAllExcept(int except, uint8_t *data, int size, int seq_threshold = 0, bool urgent = 1); |
| 68 | |
| 69 | // Tells clients to execute dlls on their machines |
| 70 | void MultiSendClientExecuteDLL(int eventnum, int me_objnum, int it_objnum, int to, dllinfo *info = NULL); |
| 71 | |
| 72 | // Resets the settings that a server uses |
| 73 | void MultiResetSettings(); |
| 74 | |
| 75 | // Given a killer and killed player, calculates their new rankings |
| 76 | void GetNewRankings(object *killed, object *killer); |
| 77 | |
| 78 | // Returns a ranking index based on the player rating |
| 79 | // If rankbuf is non-null, fills in the string corresponding to that rank |
| 80 | // Returns -1 if not a pxo game (ie no rankings in this game) |
| 81 | int GetRankIndex(int pnum, char *rankbuf = NULL); |
| 82 | |
| 83 | #endif |