Rearange menu of mpegplayer. Add new menu with "settings" and "quit", and remove...
[kugel-rb.git] / apps / plugins / doom / d_net.h
blob6b586e3c96f31cde78e4b854a7505392fa213f7d
1 /* Emacs style mode select -*- C++ -*-
2 *-----------------------------------------------------------------------------
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
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.
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.
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.
27 * DESCRIPTION:
28 * Networking stuff.
30 *-----------------------------------------------------------------------------*/
33 #ifndef __D_NET__
34 #define __D_NET__
36 #include "d_player.h"
39 #ifdef __GNUG__
40 #pragma interface
41 #endif
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.
52 #define DOOMCOM_ID 0x12345678l
54 // Max computers/players in a game.
55 #define MAXNETNODES 8
58 // Networking and tick handling related.
59 #define BACKUPTICS 12
61 typedef enum
63 CMD_SEND = 1,
64 CMD_GET = 2
66 } command_t;
70 // Network packet data.
72 typedef struct
74 // High bit is retransmit request.
75 unsigned checksum;
76 // Only valid if NCMD_RETRANSMIT.
77 byte retransmitfrom;
79 byte starttic;
80 byte player;
81 byte numtics;
82 ticcmd_t cmds[BACKUPTICS];
84 } doomdata_t;
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
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
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.
113 #define STARTUPLEN 12
114 typedef struct
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;
128 typedef 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;
134 typedef struct
136 netmisctype_t type;
137 size_t len;
138 byte value[sizeof(ticcmd_t)*BACKUPTICS - sizeof(netmisctype_t) - sizeof(size_t)];
139 } netmisc_t;
141 typedef struct
143 // Supposed to be DOOMCOM_ID?
144 long id;
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;
154 // Number of bytes in doomdata to be sent
155 short datalength;
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
172 // Info specific to this node.
173 short consoleplayer;
174 short numplayers;
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;
186 // The packet data to be sent.
187 doomdata_t data;
189 } doomcom_t;
191 // Create any new ticcmds and broadcast to other players.
192 void NetUpdate (void);
193 // Create any new ticcmds
194 void D_BuildNewTiccmds (void);
196 // Broadcasts special packets to other players
197 // to notify of game exit
198 void D_QuitNetGame (void);
200 //? how many ticks to run?
201 void TryRunTics (void);
203 // CPhipps - move to header file
204 void D_InitNetGame (void); // This does the setup
205 void D_CheckNetGame(void); // This waits for game start
207 // CPhipps - misc info broadcast
208 void D_NetSendMisc(netmisctype_t type, size_t len, void* data);
210 // CPhipps - ask server for a wad file we need
211 boolean D_NetGetWad(const char* name);
213 #endif