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