1 /* 2 * Copyright 2006 Serge van den Boom <svdb@stack.nl> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 */ 18 19 #if !defined(UQM_SUPERMELEE_NETPLAY_NETMELEE_H_) && defined(NETPLAY) 20 #define UQM_SUPERMELEE_NETPLAY_NETMELEE_H_ 21 22 #include "netplay.h" 23 #include "netinput.h" 24 #include "netconnection.h" 25 #include "packetsenders.h" 26 27 #include "../../battlecontrols.h" 28 // for NetworkInputContext 29 #include "../../controls.h" 30 // for BATTLE_INPUT_STATE 31 #include "../../races.h" 32 // for STARSHIP 33 34 #if defined(__cplusplus) 35 extern "C" { 36 #endif 37 38 extern struct NetConnection *netConnections[]; 39 40 41 void addNetConnection(NetConnection *conn, int playerNr); 42 void removeNetConnection(int playerNr); 43 void closeAllConnections(void); 44 void closeDisconnectedConnections(void); 45 size_t getNumNetConnections(void); 46 typedef bool(*ForEachConnectionCallback)(NetConnection *conn, void *arg); 47 bool forEachConnectedPlayer(ForEachConnectionCallback callback, void *arg); 48 49 struct melee_state *NetMelee_getMeleeState(NetConnection *conn); 50 struct battlestate_struct *NetMelee_getBattleState(NetConnection *conn); 51 52 void netInput(void); 53 void netInputBlocking(uint32 timeoutMs); 54 void flushPacketQueues(void); 55 56 void confirmConnections(void); 57 void cancelConfirmations(void); 58 void connectionsLocalReady(NetConnection_ReadyCallback callback, void *arg); 59 60 bool allConnected(void); 61 62 void initBattleStateDataConnections(void); 63 void setBattleStateConnections(struct battlestate_struct *bs); 64 65 BATTLE_INPUT_STATE networkBattleInput(NetworkInputContext *context, 66 STARSHIP *StarShipPtr); 67 68 NetConnection *openPlayerNetworkConnection(COUNT player, void *extra); 69 void closePlayerNetworkConnection(COUNT player); 70 71 bool setupInputDelay(size_t localInputDelay); 72 bool setStateConnections(NetState state); 73 bool sendAbortConnections(NetplayAbortReason reason); 74 bool resetConnections(NetplayResetReason reason); 75 bool localReadyConnections(NetConnection_ReadyCallback readyCallback, 76 void *arg, bool notifyRemote); 77 78 bool negotiateReady(NetConnection *conn, bool notifyRemote, 79 NetState nextState); 80 bool negotiateReadyConnections(bool notifyRemote, NetState nextState); 81 bool waitReady(NetConnection *conn); 82 83 bool waitReset(NetConnection *conn, NetState nextState); 84 bool waitResetConnections(NetState nextState); 85 86 #if defined(__cplusplus) 87 } 88 #endif 89 90 #endif /* UQM_SUPERMELEE_NETPLAY_NETMELEE_H_ */ 91