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 #ifndef UQM_SUPERMELEE_NETPLAY_NETSTATE_H_
20 #define UQM_SUPERMELEE_NETPLAY_NETSTATE_H_
21 
22 #include "port.h"
23 
24 #if defined(__cplusplus)
25 extern "C" {
26 #endif
27 
28 typedef struct NetConnectionStateData NetConnectionStateData;
29 
30 // State of a NetConnection.
31 typedef enum {
32 	NetState_unconnected,    /* No connection initiated */
33 	NetState_connecting,     /* Connection being setup */
34 	NetState_init,           /* Initialising the connection */
35 	NetState_inSetup,        /* In the network game setup */
36 	NetState_preBattle,      /* Pre-battle initialisations */
37 	NetState_interBattle,    /* Negotiations between battles. */
38 	NetState_selectShip,     /* Selecting a ship in battle */
39 	NetState_inBattle,       /* Battle has started */
40 	NetState_endingBattle,   /* Both sides are prepared to end */
41 	NetState_endingBattle2,  /* Waiting for the final synchronisation */
42 } NetState;
43 
44 #if defined(__cplusplus)
45 }
46 #endif
47 
48 #include "types.h"
49 
50 #if defined(__cplusplus)
51 extern "C" {
52 #endif
53 
54 typedef struct {
55 	const char *name;
56 } NetStateData;
57 extern NetStateData netStateData[];
58 
59 typedef void (*NetConnectionStateData_ReleaseFunction)(
60 		NetConnectionStateData *stateData);
61 
62 #define NETCONNECTION_STATE_DATA_COMMON \
63 		NetConnectionStateData_ReleaseFunction releaseFunction;
64 
65 struct
66 NetConnectionStateData {
67 	NETCONNECTION_STATE_DATA_COMMON
68 };
69 
70 void NetConnectionStateData_release(NetConnectionStateData *stateData);
71 
72 static inline bool
NetState_battleActive(NetState state)73 NetState_battleActive(NetState state) {
74 	return state == NetState_inBattle || state == NetState_endingBattle ||
75 			state == NetState_endingBattle2;
76 }
77 
78 
79 #if defined(__cplusplus)
80 }
81 #endif
82 
83 #endif  /* UQM_SUPERMELEE_NETPLAY_NETSTATE_H_ */
84