A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 214 lines 6.4 kB view raw
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 61enum 62{ 63 CMD_SEND = 1, 64 CMD_GET = 2 65}; 66typedef unsigned 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 128enum { 129 // Leave space, so low values corresponding to normal netgame setup packets can be ignored 130 nm_plcolour = 3, 131 nm_savegamename = 4, 132}; 133typedef unsigned netmisctype_t; 134 135typedef struct 136{ 137 netmisctype_t type; 138 size_t len; 139 byte value[sizeof(ticcmd_t)*BACKUPTICS - sizeof(netmisctype_t) - sizeof(size_t)]; 140} netmisc_t; 141 142typedef struct 143{ 144 // Supposed to be DOOMCOM_ID? 145 long id; 146 147 // DOOM executes an int to execute commands. 148 short intnum; 149 // Communication between DOOM and the driver. 150 // Is CMD_SEND or CMD_GET. 151 short command; 152 // Is dest for send, set by get (-1 = no packet). 153 short remotenode; 154 155 // Number of bytes in doomdata to be sent 156 short datalength; 157 158 // Info common to all nodes. 159 // Console is allways node 0. 160 short numnodes; 161 // Flag: 1 = no duplication, 2-5 = dup for slow nets. 162 short ticdup; 163 // Flag: 1 = send a backup tic in every packet. 164 short extratics; 165 // Flag: 1 = deathmatch. 166 short deathmatch; 167 // Flag: -1 = new game, 0-5 = load savegame 168 short savegame; 169 short episode; // 1-3 170 short map; // 1-9 171 short skill; // 1-5 172 173 // Info specific to this node. 174 short consoleplayer; 175 short numplayers; 176 177 // These are related to the 3-display mode, 178 // in which two drones looking left and right 179 // were used to render two additional views 180 // on two additional computers. 181 // Probably not operational anymore. 182 // 1 = left, 0 = center, -1 = right 183 short angleoffset; 184 // 1 = drone 185 short drone; 186 187 // The packet data to be sent. 188 doomdata_t data; 189 190} doomcom_t; 191 192// Create any new ticcmds and broadcast to other players. 193void NetUpdate (void); 194// Create any new ticcmds 195void D_BuildNewTiccmds (void); 196 197// Broadcasts special packets to other players 198// to notify of game exit 199void D_QuitNetGame (void); 200 201//? how many ticks to run? 202void TryRunTics (void); 203 204// CPhipps - move to header file 205void D_InitNetGame (void); // This does the setup 206void D_CheckNetGame(void); // This waits for game start 207 208// CPhipps - misc info broadcast 209void D_NetSendMisc(netmisctype_t type, size_t len, void* data); 210 211// CPhipps - ask server for a wad file we need 212boolean D_NetGetWad(const char* name); 213 214#endif