summaryrefslogtreecommitdiff
path: root/src/uqm/supermelee/netplay/netmisc.h
blob: ea1492177ad3bdb685ab2c6bce2c33d8c0b0317e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 *  Copyright 2006  Serge van den Boom <svdb@stack.nl>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef UQM_SUPERMELEE_NETPLAY_NETMISC_H_
#define UQM_SUPERMELEE_NETPLAY_NETMISC_H_

typedef struct BattleStateData BattleStateData;

#include "netconnection.h"
#include "netstate.h"
#include "types.h"

#include "../../battle.h"
		// for BattleFrameCounter, BATTLE_FRAME_RATE

#if defined(__cplusplus)
extern "C" {
#endif

struct BattleStateData {
	NETCONNECTION_STATE_DATA_COMMON

	struct melee_state *meleeState;
	struct battlestate_struct *battleState;
	struct getmelee_struct *getMeleeState;
	BattleFrameCounter endFrameCount;
};


void NetMelee_connectCallback(NetConnection *conn);
void NetMelee_closeCallback(NetConnection *conn);
void NetMelee_errorCallback(NetConnection *conn,
		const NetConnectionError *error);

void NetMelee_reenterState_inSetup(NetConnection *conn);


// Returns true iff the connection is in a state where the confirmation
// handshake is meaningful. Right now this is only when we're in the
// pre-game setup menu.
static inline bool
handshakeMeaningful(NetState state) {
	return state == NetState_inSetup;
}

static inline bool
readyFlagsMeaningful(NetState state) {
	return state == NetState_init ||
			state == NetState_preBattle ||
			state == NetState_selectShip ||
			state == NetState_interBattle ||
			state == NetState_inBattle ||
			state == NetState_endingBattle ||
			state == NetState_endingBattle2;
}


#if defined(__cplusplus)
}
#endif

#endif  /* UQM_SUPERMELEE_NETPLAY_NETMISC_H_ */