Debian Codegraph @

src/network.h

raw symbols SCIP
1 /*
2 * OpenTyrian: A modern cross-platform port of Tyrian
3 * Copyright (C) 2007-2009 The OpenTyrian Development Team
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (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, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19 #ifndef NETWORK_H
20 #define NETWORK_H
21
22 #include "opentyr.h"
23
24 #include "SDL.h"
25 #ifdef WITH_NETWORK
26 # include "SDL_net.h"
27 #endif
28
29 #define PACKET_ACKNOWLEDGE 0x00 //
30 #define PACKET_KEEP_ALIVE 0x01 //
31
32 #define PACKET_CONNECT 0x10 // version, delay, episodes, player_number, name
33 #define PACKET_DETAILS 0x11 // episode, difficulty
34
35 #define PACKET_QUIT 0x20 //
36 #define PACKET_WAITING 0x21 //
37 #define PACKET_BUSY 0x22 //
38
39 #define PACKET_GAME_QUIT 0x30 //
40 #define PACKET_GAME_PAUSE 0x31 //
41 #define PACKET_GAME_MENU 0x32 //
42
43 #define PACKET_STATE_RESEND 0x40 // state_id
44 #define PACKET_STATE 0x41 // <state> (not acknowledged)
45 #define PACKET_STATE_XOR 0x42 // <xor state> (not acknowledged)
46
47 extern bool isNetworkGame;
48 extern int network_delay;
49
50 extern char *network_opponent_host;
51 extern Uint16 network_player_port, network_opponent_port;
52 extern char *network_player_name, *network_opponent_name;
53
54 #ifdef WITH_NETWORK
55 extern UDPpacket *packet_out_temp;
56 extern UDPpacket *packet_in[], *packet_out[],
57 *packet_state_in[], *packet_state_out[];
58 #endif
59
60 extern uint thisPlayerNum;
61 extern JE_boolean haltGame;
62 extern JE_boolean moveOk;
63 extern JE_boolean pauseRequest, skipLevelRequest, helpRequest, nortShipRequest;
64 extern JE_boolean yourInGameMenuRequest, inGameMenuRequest;
65
66 #ifdef WITH_NETWORK
67 void network_prepare(Uint16 type);
68 bool network_send(int len);
69
70 int network_check(void);
71 bool network_update(void);
72
73 bool network_is_sync(void);
74
75 void network_state_prepare(void);
76 int network_state_send(void);
77 bool network_state_update(void);
78 bool network_state_is_reset(void);
79 void network_state_reset(void);
80
81 int network_connect(void);
82 void network_tyrian_halt(unsigned int err, bool attempt_sync);
83
84 int network_init(void);
85
86 void JE_clearSpecialRequests(void);
87
88 #define NETWORK_KEEP_ALIVE() \
89 if (isNetworkGame) \
90 network_check();
91 #else
92 #define NETWORK_KEEP_ALIVE()
93 #endif
94
95 #endif /* NETWORK_H */