diff options
Diffstat (limited to 'src/d_net.h')
-rw-r--r-- | src/d_net.h | 214 |
1 files changed, 214 insertions, 0 deletions
diff --git a/src/d_net.h b/src/d_net.h new file mode 100644 index 0000000..fcdeb6c --- /dev/null +++ b/src/d_net.h | |||
@@ -0,0 +1,214 @@ | |||
1 | /* Emacs style mode select -*- C++ -*- | ||
2 | *----------------------------------------------------------------------------- | ||
3 | * | ||
4 | * | ||
5 | * PrBoom: a Doom port merged with LxDoom and LSDLDoom | ||
6 | * based on BOOM, a modified and improved DOOM engine | ||
7 | * Copyright (C) 1999 by | ||
8 | * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman | ||
9 | * Copyright (C) 1999-2000 by | ||
10 | * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze | ||
11 | * Copyright 2005, 2006 by | ||
12 | * Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License | ||
16 | * as published by the Free Software Foundation; either version 2 | ||
17 | * of the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, | ||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
22 | * GNU General Public License for more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the Free Software | ||
26 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
27 | * 02111-1307, USA. | ||
28 | * | ||
29 | * DESCRIPTION: | ||
30 | * Networking stuff. | ||
31 | * | ||
32 | *-----------------------------------------------------------------------------*/ | ||
33 | |||
34 | |||
35 | #ifndef __D_NET__ | ||
36 | #define __D_NET__ | ||
37 | |||
38 | #include "d_player.h" | ||
39 | |||
40 | |||
41 | #ifdef __GNUG__ | ||
42 | #pragma interface | ||
43 | #endif | ||
44 | |||
45 | |||
46 | // | ||
47 | // Network play related stuff. | ||
48 | // There is a data struct that stores network | ||
49 | // communication related stuff, and another | ||
50 | // one that defines the actual packets to | ||
51 | // be transmitted. | ||
52 | // | ||
53 | |||
54 | #define DOOMCOM_ID 0x12345678l | ||
55 | |||
56 | // Max computers/players in a game. | ||
57 | #define MAXNETNODES 8 | ||
58 | |||
59 | |||
60 | typedef enum | ||
61 | { | ||
62 | CMD_SEND = 1, | ||
63 | CMD_GET = 2 | ||
64 | |||
65 | } command_t; | ||
66 | |||
67 | |||
68 | // | ||
69 | // Network packet data. | ||
70 | // | ||
71 | typedef struct | ||
72 | { | ||
73 | // High bit is retransmit request. | ||
74 | unsigned checksum; | ||
75 | // Only valid if NCMD_RETRANSMIT. | ||
76 | byte retransmitfrom; | ||
77 | |||
78 | byte starttic; | ||
79 | byte player; | ||
80 | byte numtics; | ||
81 | ticcmd_t cmds[BACKUPTICS]; | ||
82 | |||
83 | } doomdata_t; | ||
84 | |||
85 | // | ||
86 | // Startup packet difference | ||
87 | // SG: 4/12/98 | ||
88 | // Added so we can send more startup data to synch things like | ||
89 | // bobbing, recoil, etc. | ||
90 | // this is just mapped over the ticcmd_t array when setup packet is sent | ||
91 | // | ||
92 | // Note: the original code takes care of startskill, deathmatch, nomonsters | ||
93 | // respawn, startepisode, startmap | ||
94 | // Note: for phase 1 we need to add monsters_remember, variable_friction, | ||
95 | // weapon_recoil, allow_pushers, over_under, player_bobbing, | ||
96 | // fastparm, demo_insurance, and the rngseed | ||
97 | //Stick all options into bytes so we don't need to mess with bitfields | ||
98 | //WARNING: make sure this doesn't exceed the size of the ticcmds area! | ||
99 | //sizeof(ticcmd_t)*BACKUPTICS | ||
100 | //This is the current length of our extra stuff | ||
101 | // | ||
102 | //killough 5/2/98: this should all be replaced by calls to G_WriteOptions() | ||
103 | //and G_ReadOptions(), which were specifically designed to set up packets. | ||
104 | //By creating a separate struct and functions to read/write the options, | ||
105 | //you now have two functions and data to maintain instead of just one. | ||
106 | //If the array in g_game.c which G_WriteOptions()/G_ReadOptions() operates | ||
107 | //on, is too large (more than sizeof(ticcmd_t)*BACKUPTICS), it can | ||
108 | //either be shortened, or the net code needs to divide it up | ||
109 | //automatically into packets. The STARTUPLEN below is non-portable. | ||
110 | //There's a portable way to do it without having to know the sizes. | ||
111 | |||
112 | #define STARTUPLEN 12 | ||
113 | typedef struct | ||
114 | { | ||
115 | byte monsters_remember; | ||
116 | byte variable_friction; | ||
117 | byte weapon_recoil; | ||
118 | byte allow_pushers; | ||
119 | byte over_under; | ||
120 | byte player_bobbing; | ||
121 | byte fastparm; | ||
122 | byte demo_insurance; | ||
123 | unsigned long rngseed; | ||
124 | char filler[sizeof(ticcmd_t)*BACKUPTICS-STARTUPLEN]; | ||
125 | } startup_t; | ||
126 | |||
127 | typedef enum { | ||
128 | // Leave space, so low values corresponding to normal netgame setup packets can be ignored | ||
129 | nm_plcolour = 3, | ||
130 | nm_savegamename = 4, | ||
131 | } netmisctype_t; | ||
132 | |||
133 | typedef struct | ||
134 | { | ||
135 | netmisctype_t type; | ||
136 | size_t len; | ||
137 | byte value[sizeof(ticcmd_t)*BACKUPTICS - sizeof(netmisctype_t) - sizeof(size_t)]; | ||
138 | } netmisc_t; | ||
139 | |||
140 | typedef struct | ||
141 | { | ||
142 | // Supposed to be DOOMCOM_ID? | ||
143 | long id; | ||
144 | |||
145 | // DOOM executes an int to execute commands. | ||
146 | short intnum; | ||
147 | // Communication between DOOM and the driver. | ||
148 | // Is CMD_SEND or CMD_GET. | ||
149 | short command; | ||
150 | // Is dest for send, set by get (-1 = no packet). | ||
151 | short remotenode; | ||
152 | |||
153 | // Number of bytes in doomdata to be sent | ||
154 | short datalength; | ||
155 | |||
156 | // Info common to all nodes. | ||
157 | // Console is allways node 0. | ||
158 | short numnodes; | ||
159 | // Flag: 1 = no duplication, 2-5 = dup for slow nets. | ||
160 | short ticdup; | ||
161 | // Flag: 1 = send a backup tic in every packet. | ||
162 | short extratics; | ||
163 | // Flag: 1 = deathmatch. | ||
164 | short deathmatch; | ||
165 | // Flag: -1 = new game, 0-5 = load savegame | ||
166 | short savegame; | ||
167 | short episode; // 1-3 | ||
168 | short map; // 1-9 | ||
169 | short skill; // 1-5 | ||
170 | |||
171 | // Info specific to this node. | ||
172 | short consoleplayer; | ||
173 | short numplayers; | ||
174 | |||
175 | // These are related to the 3-display mode, | ||
176 | // in which two drones looking left and right | ||
177 | // were used to render two additional views | ||
178 | // on two additional computers. | ||
179 | // Probably not operational anymore. | ||
180 | // 1 = left, 0 = center, -1 = right | ||
181 | short angleoffset; | ||
182 | // 1 = drone | ||
183 | short drone; | ||
184 | |||
185 | // The packet data to be sent. | ||
186 | doomdata_t data; | ||
187 | |||
188 | } doomcom_t; | ||
189 | |||
190 | // Create any new ticcmds and broadcast to other players. | ||
191 | #ifdef HAVE_NET | ||
192 | void NetUpdate (void); | ||
193 | #else | ||
194 | void D_BuildNewTiccmds(void); | ||
195 | #endif | ||
196 | |||
197 | //? how many ticks to run? | ||
198 | void TryRunTics (void); | ||
199 | |||
200 | // CPhipps - move to header file | ||
201 | void D_InitNetGame (void); // This does the setup | ||
202 | void D_CheckNetGame(void); // This waits for game start | ||
203 | |||
204 | // CPhipps - misc info broadcast | ||
205 | void D_NetSendMisc(netmisctype_t type, size_t len, void* data); | ||
206 | |||
207 | // CPhipps - ask server for a wad file we need | ||
208 | boolean D_NetGetWad(const char* name); | ||
209 | |||
210 | // Netgame stuff (buffers and pointers, i.e. indices). | ||
211 | extern doomcom_t *doomcom; | ||
212 | extern doomdata_t *netbuffer; // This points inside doomcom. | ||
213 | |||
214 | #endif | ||