Header file cleanup, so we can build more stuff which is completely common!

*.pak support!
This commit is contained in:
Zephaniah E. Hull 2000-03-08 01:12:26 +00:00
parent ddfbc49092
commit 8ce43b2ec1
9 changed files with 267 additions and 226 deletions

View file

@ -34,7 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <net.h>
#include <qtypes.h>
#include <zone.h>
#include <protocol.h>
#include <common_protocol.h>
#include <vid.h>
#include <render.h>
#include <common.h>
@ -104,7 +104,6 @@ typedef struct player_info_s
} player_info_t;
//#ifdef QUAKEWORLD
typedef struct
{
// generated on client side
@ -145,9 +144,7 @@ typedef struct
float die; // stop lighting after this time
float decay; // drop this each second
float minlight; // don't add when contributing less
#ifdef QUAKE2
qboolean dark;
#endif // QUAKE2
float color[4];
} dlight_t;
@ -198,7 +195,6 @@ typedef struct
cactive_t state; // connection info
netchan_t netchan; // network stuff
//#ifdef QUAKEWORLD
char userinfo[MAX_INFO_STRING];
char servername[MAX_OSPATH];
int qport;
@ -213,13 +209,11 @@ typedef struct
int challenge;
float latency; // rolling average
//#elif UQUAKE
char mapstring[MAX_QPATH];
char spawnparms[MAX_MAPSTRING]; // to restart level
int signon;
struct qsocket_s *netcon;
//#endif // QUAKEWORLD else UQUAKE
// demos - this stuff can't go into client_state_t
int demonum;
@ -297,7 +291,6 @@ typedef struct
int gametype;
int maxclients;
//#ifdef QUAKEWORLD
// QW specific!
// all player information
player_info_t players[MAX_CLIENTS];
@ -324,7 +317,6 @@ typedef struct
//
char model_name[MAX_MODELS][MAX_QPATH];
char sound_name[MAX_SOUNDS][MAX_QPATH];
//#elif defined(UQUAKE)
// UQ specific.
int num_entities; // held in cl_entities array
float last_received_message; // (time) for net trouble icon
@ -346,7 +338,6 @@ typedef struct
vec3_t mvelocity[2]; // update by server, used for lean+bob
// (0 is newest)
vec3_t velocity; // lerped between mvelocity[0] and [1]
//#endif // QUAKEWORLD else UQUAKE
} client_state_t;
extern client_state_t cl;
@ -354,18 +345,18 @@ extern client_state_t cl;
//
// cvars
//
#ifdef UQUAKE
//#ifdef UQUAKE
extern cvar_t *cl_name;
extern cvar_t *cl_color;
extern cvar_t *cl_autofire;
extern cvar_t *cl_nolerp;
#endif // UQUAKE
//#endif // UQUAKE
extern cvar_t *cl_warncmd;
#ifdef QUAKEWORLD
//#ifdef QUAKEWORLD
extern cvar_t *name;
extern cvar_t *topcolor;
extern cvar_t *bottomcolor;
#endif // QUAKEWORLD
//#endif // QUAKEWORLD
extern cvar_t *rate;
extern cvar_t *host_speeds;
extern cvar_t *cl_maxfps;
@ -403,10 +394,10 @@ extern cvar_t *_windowed_mouse;
// FIXME, allocate dynamically
extern entity_state_t cl_baselines[MAX_EDICTS];
#ifdef UQUAKE
//#ifdef UQUAKE
entity_t cl_entities[MAX_EDICTS];
entity_t cl_temp_entities[MAX_TEMP_ENTITIES];
#endif // UQUAKE
//#endif // UQUAKE
extern efrag_t cl_efrags[MAX_EFRAGS];
extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
@ -435,20 +426,20 @@ void SetPal (int i);
void CL_RelinkEntities (void);
void CL_ReadPackets (void);
#ifdef UQUAKE
//#ifdef UQUAKE
void CL_Signon1 (void);
void CL_Signon2 (void);
void CL_Signon3 (void);
void CL_Signon4 (void);
#endif // UQUAKE
//#endif // UQUAKE
void CL_Disconnect (void);
void CL_Disconnect_f (void);
void CL_NextDemo (void);
#ifdef QUAKEWORLD
//#ifdef QUAKEWORLD
qboolean CL_DemoBehind(void);
void CL_BeginServerConnect(void);
#endif // QUAKEWORLD
//#endif // QUAKEWORLD
#define MAX_VISEDICTS 256
@ -486,9 +477,9 @@ void CL_UpdateTEnts (void);
void CL_ClearState (void);
#ifdef QUAKEWORLD
//#ifdef QUAKEWORLD
void CL_ReadPackets (void);
#endif // QUAKEWORLD
//#endif // QUAKEWORLD
int CL_ReadFromServer (void);
void CL_WriteToServer (usercmd_t *cmd);
@ -503,17 +494,17 @@ char *Key_KeynumToString (int keynum);
//
void CL_StopPlayback (void);
int CL_GetMessage (void);
#ifdef QUAKEWORLD
//#ifdef QUAKEWORLD
void CL_WriteDemoCmd (usercmd_t *pcmd);
#elif defined(UQUAKE)
//#elif defined(UQUAKE)
void CL_SignonReply (void);
#endif // QUAKEWORLD else UQUAKE
//#endif // QUAKEWORLD else UQUAKE
void CL_Stop_f (void);
void CL_Record_f (void);
#ifdef QUAKEWORLD
//#ifdef QUAKEWORLD
void CL_ReRecord_f (void);
#endif // QUAKEWORLD
//#endif // QUAKEWORLD
void CL_PlayDemo_f (void);
void CL_TimeDemo_f (void);
@ -522,7 +513,7 @@ void CL_TimeDemo_f (void);
//
void CL_ParseServerMessage (void);
void CL_NewTranslation (int slot);
#ifdef QUAKEWORLD
//#ifdef QUAKEWORLD
#define NET_TIMINGS 256
#define NET_TIMINGSMASK 255
extern int packet_latency[NET_TIMINGS];
@ -532,7 +523,7 @@ qboolean CL_IsUploading(void);
void CL_NextUpload(void);
void CL_StartUpload (byte *data, int size);
void CL_StopUpload(void);
#endif // QUAKEWORLD
//#endif // QUAKEWORLD
//
// view.c
@ -553,9 +544,9 @@ void V_CalcBlend (void);
//
void CL_InitTEnts (void);
void CL_ClearTEnts (void);
#ifdef UQUAKE
//#ifdef UQUAKE
void CL_SignonReply (void);
#endif
//#endif
//#ifdef QUAKEWORLD
//

View file

@ -24,9 +24,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef _COMMON_H
#define _COMMON_H
#ifdef QUAKEWORLD
# include <bothdefs.h>
#endif
//#ifdef QUAKEWORLD
//# include <bothdefs.h>
//#endif
#include <register_check.h>
#include <qtypes.h>
#include <cvar.h>

201
common/common_protocol.h Normal file
View file

@ -0,0 +1,201 @@
/*
protocol.h - communications protocol (quake1)
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __common_protocol_h
#define __common_protocol_h
/*
#if !(defined(QUAKEWORLD) || defined(UQUAKE))
#error This is NOT safe to include for common items.
#endif
*/
// game types sent by serverinfo
// these determine which intermission screen plays
#define GAME_COOP 0
#define GAME_DEATHMATCH 1
//==================
// note that there are some defs.qc that mirror to these numbers
// also related to svc_strings[] in cl_parse
//==================
//
// server to client
//
#define svc_bad 0
#define svc_nop 1
#define svc_disconnect 2
#define svc_updatestat 3 // [byte] [long]
#define svc_version 4 // [long] server version
#define svc_setview 5 // [short] entity number
#define svc_sound 6 // <see code>
#define svc_time 7 // [float] server time
#define svc_print 8 // [string] null terminated string
#define svc_stufftext 9 // [string] stuffed into client's console buffer
// the string should be \n terminated
#define svc_setangle 10 // [angle3] set the view angle to this absolute value
#define svc_lightstyle 12 // [byte] [string]
#define svc_updatename 13 // [byte] [string]
#define svc_updatefrags 14 // [byte] [short]
#define svc_clientdata 15 // <shortbits + data>
#define svc_stopsound 16 // <see code>
#define svc_updatecolors 17 // [byte] [byte]
#define svc_particle 18 // [vec3] <variable>
#define svc_damage 19
#define svc_spawnstatic 20
// svc_spawnbinary 21
#define svc_spawnbaseline 22
#define svc_temp_entity 23
#define svc_setpause 24 // [byte] on / off
#define svc_signonnum 25 // [byte] used for the signon sequence
#define svc_centerprint 26 // [string] to put in center of the screen
#define svc_killedmonster 27
#define svc_foundsecret 28
#define svc_spawnstaticsound 29 // [coord3] [byte] samp [byte] vol [byte] aten
#define svc_intermission 30 // [string] music
#define svc_finale 31 // [string] music [string] text
#define svc_cdtrack 32 // [byte] track [byte] looptrack
#define svc_sellscreen 33
#define svc_cutscene 34
// QUAKEWORLD
#define svc_smallkick 34 // set client punchangle to 2
#define svc_bigkick 35 // set client punchangle to 4
#define svc_updateping 36 // [byte] [short]
#define svc_updateentertime 37 // [byte] [float]
#define svc_updatestatlong 38 // [byte] [long]
#define svc_muzzleflash 39 // [short] entity
#define svc_updateuserinfo 40 // [byte] slot [long] uid
// [string] userinfo
#define svc_download 41 // [short] size [size bytes]
#define svc_playerinfo 42 // variable
#define svc_nails 43 // [byte] num [48 bits] xyzpy 12 12 12 4 8
#define svc_chokecount 44 // [byte] packets choked
#define svc_modellist 45 // [strings]
#define svc_soundlist 46 // [strings]
#define svc_packetentities 47 // [...]
#define svc_deltapacketentities 48 // [...]
#define svc_maxspeed 49 // maxspeed change, for prediction
#define svc_entgravity 50 // gravity change, for prediction
#define svc_setinfo 51 // setinfo on a client
#define svc_updatepl 53 // [byte] [byte]
//
// client to server
//
#define clc_bad 0
#define clc_nop 1
#define clc_disconnect 2
#define clc_move 3 // [usercmd_t]
#define clc_stringcmd 4 // [string] message
#define clc_delta 5 // [byte] sequence number, requests delta compression of message
#define clc_tmove 6 // teleport request, spectator only
#define clc_upload 7 // teleport request, spectator only
//==============================================
// playerinfo flags from server
// playerinfo allways sends: playernum, flags, origin[] and framenumber
#define PF_MSEC (1<<0)
#define PF_COMMAND (1<<1)
#define PF_VELOCITY1 (1<<2)
#define PF_VELOCITY2 (1<<3)
#define PF_VELOCITY3 (1<<4)
#define PF_MODEL (1<<5)
#define PF_SKINNUM (1<<6)
#define PF_EFFECTS (1<<7)
#define PF_WEAPONFRAME (1<<8) // only sent for view player
#define PF_DEAD (1<<9) // don't block movement any more
#define PF_GIB (1<<10) // offset the view height differently
#define PF_NOGRAV (1<<11) // don't apply gravity for prediction
//==============================================
// if the high bit of the client to server byte is set, the low bits are
// client move cmd bits
// ms and angle2 are allways sent, the others are optional
#define CM_ANGLE1 (1<<0)
#define CM_ANGLE3 (1<<1)
#define CM_FORWARD (1<<2)
#define CM_SIDE (1<<3)
#define CM_UP (1<<4)
#define CM_BUTTONS (1<<5)
#define CM_IMPULSE (1<<6)
#define CM_ANGLE2 (1<<7)
//
// temp entity events
//
#define TE_SPIKE 0
#define TE_SUPERSPIKE 1
#define TE_GUNSHOT 2
#define TE_EXPLOSION 3
#define TE_TAREXPLOSION 4
#define TE_LIGHTNING1 5
#define TE_LIGHTNING2 6
#define TE_WIZSPIKE 7
#define TE_KNIGHTSPIKE 8
#define TE_LIGHTNING3 9
#define TE_LAVASPLASH 10
#define TE_TELEPORT 11
#define TE_EXPLOSION2 12
// PGM 01/21/97
#define TE_BEAM 13
// PGM 01/21/97
// QUAKEWORLD
#define TE_BLOOD 12
#define TE_LIGHTNINGBLOOD 13
/*
==========================================================
ELEMENTS COMMUNICATED ACROSS THE NET
==========================================================
*/
#define MAX_CLIENTS 32
#define UPDATE_BACKUP 64 // copies of entity_state_t to keep buffered
// must be power of two
#define UPDATE_MASK (UPDATE_BACKUP-1)
#endif

View file

@ -590,7 +590,7 @@ Host_Init (quakeparms_t *parms)
Mod_Init ();
#ifdef UQUAKE
NET_Init ();
NET_Init (-1); // The port is not used, at all..
SV_Init ();
#endif

View file

@ -61,7 +61,7 @@ extern sizebuf_t net_message;
extern int net_socket;
#ifdef UQUAKE
//#ifdef UQUAKE
// This ifdef is for clarity, not compilability
#define NET_NAMELEN 64
@ -189,11 +189,11 @@ extern int messagesSent;
extern int messagesReceived;
extern int unreliableMessagesSent;
extern int unreliableMessagesReceived;
#endif // UQUAKE
//#endif // UQUAKE
#ifdef QUAKEWORLD
//#ifdef QUAKEWORLD
void NET_Init (int port);
#endif
//#endif
void NET_Shutdown (void);
qboolean NET_GetPacket (void);
void NET_SendPacket (int length, void *data, netadr_t to);
@ -256,7 +256,7 @@ typedef struct
double outgoing_time[MAX_LATENT];
} netchan_t;
#ifdef QUAKEWORLD
//#ifdef QUAKEWORLD
extern int net_drop; // packets dropped before this one
void Netchan_Init (void);
@ -268,11 +268,11 @@ void Netchan_Setup (netchan_t *chan, netadr_t adr, int qport);
qboolean Netchan_CanPacket (netchan_t *chan);
qboolean Netchan_CanReliable (netchan_t *chan);
#endif
//#endif
extern cvar_t *hostname;
#ifdef UQUAKE
//#ifdef UQUAKE
qsocket_t *NET_NewQSocket (void);
void NET_FreeQSocket(qsocket_t *);
double SetNetTime(void);
@ -305,7 +305,7 @@ extern double net_time;
extern sizebuf_t net_message;
extern int net_activeconnections;
void NET_Init (void);
//void NET_Init (void);
void NET_Shutdown (void);
struct qsocket_s *NET_CheckNewConnections (void);
@ -373,7 +373,7 @@ extern qboolean slistSilent;
extern qboolean slistLocal;
void NET_Slist_f (void);
#endif // UQUAKE
//#endif // UQUAKE
#define MAX_PACKET_ENTITIES 64 // doesn't count nails
typedef struct

View file

@ -22,6 +22,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef __protocol_h
#define __protocol_h
#include <common_protocol.h>
#if !(defined(QUAKEWORLD) || defined(UQUAKE))
#error This is NOT safe to include for common items.
#endif
#ifdef UQUAKE
#define PROTOCOL_VERSION 15
@ -143,32 +149,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#endif // QUAKEWORLD
// game types sent by serverinfo
// these determine which intermission screen plays
#define GAME_COOP 0
#define GAME_DEATHMATCH 1
//==================
// note that there are some defs.qc that mirror to these numbers
// also related to svc_strings[] in cl_parse
//==================
//
// server to client
//
#define svc_bad 0
#define svc_nop 1
#define svc_disconnect 2
#define svc_updatestat 3 // [byte] [long]
#define svc_version 4 // [long] server version
#define svc_setview 5 // [short] entity number
#define svc_sound 6 // <see code>
#define svc_time 7 // [float] server time
#define svc_print 8 // [string] null terminated string
#define svc_stufftext 9 // [string] stuffed into client's console buffer
// the string should be \n terminated
#define svc_setangle 10 // [angle3] set the view angle to this absolute value
#ifdef UQUAKE
#define svc_serverinfo 11 // [long] version
// [string] signon string
@ -177,154 +157,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#else
#define svc_serverdata 11 // [long] protocol ...
#endif
#define svc_lightstyle 12 // [byte] [string]
#define svc_updatename 13 // [byte] [string]
#define svc_updatefrags 14 // [byte] [short]
#define svc_clientdata 15 // <shortbits + data>
#define svc_stopsound 16 // <see code>
#define svc_updatecolors 17 // [byte] [byte]
#define svc_particle 18 // [vec3] <variable>
#define svc_damage 19
#define svc_spawnstatic 20
// svc_spawnbinary 21
#define svc_spawnbaseline 22
#define svc_temp_entity 23
#define svc_setpause 24 // [byte] on / off
#define svc_signonnum 25 // [byte] used for the signon sequence
#define svc_centerprint 26 // [string] to put in center of the screen
#define svc_killedmonster 27
#define svc_foundsecret 28
#define svc_spawnstaticsound 29 // [coord3] [byte] samp [byte] vol [byte] aten
#define svc_intermission 30 // [string] music
#define svc_finale 31 // [string] music [string] text
#define svc_cdtrack 32 // [byte] track [byte] looptrack
#define svc_sellscreen 33
#define svc_cutscene 34
// QUAKEWORLD
#define svc_smallkick 34 // set client punchangle to 2
#define svc_bigkick 35 // set client punchangle to 4
#define svc_updateping 36 // [byte] [short]
#define svc_updateentertime 37 // [byte] [float]
#define svc_updatestatlong 38 // [byte] [long]
#define svc_muzzleflash 39 // [short] entity
#define svc_updateuserinfo 40 // [byte] slot [long] uid
// [string] userinfo
#define svc_download 41 // [short] size [size bytes]
#define svc_playerinfo 42 // variable
#define svc_nails 43 // [byte] num [48 bits] xyzpy 12 12 12 4 8
#define svc_chokecount 44 // [byte] packets choked
#define svc_modellist 45 // [strings]
#define svc_soundlist 46 // [strings]
#define svc_packetentities 47 // [...]
#define svc_deltapacketentities 48 // [...]
#define svc_maxspeed 49 // maxspeed change, for prediction
#define svc_entgravity 50 // gravity change, for prediction
#define svc_setinfo 51 // setinfo on a client
#ifdef QUAKEWORLD
#define svc_serverinfo 52 // serverinfo
#endif
#define svc_updatepl 53 // [byte] [byte]
//
// client to server
//
#define clc_bad 0
#define clc_nop 1
#define clc_disconnect 2
#define clc_move 3 // [usercmd_t]
#define clc_stringcmd 4 // [string] message
#define clc_delta 5 // [byte] sequence number, requests delta compression of message
#define clc_tmove 6 // teleport request, spectator only
#define clc_upload 7 // teleport request, spectator only
//==============================================
// playerinfo flags from server
// playerinfo allways sends: playernum, flags, origin[] and framenumber
#define PF_MSEC (1<<0)
#define PF_COMMAND (1<<1)
#define PF_VELOCITY1 (1<<2)
#define PF_VELOCITY2 (1<<3)
#define PF_VELOCITY3 (1<<4)
#define PF_MODEL (1<<5)
#define PF_SKINNUM (1<<6)
#define PF_EFFECTS (1<<7)
#define PF_WEAPONFRAME (1<<8) // only sent for view player
#define PF_DEAD (1<<9) // don't block movement any more
#define PF_GIB (1<<10) // offset the view height differently
#define PF_NOGRAV (1<<11) // don't apply gravity for prediction
//==============================================
// if the high bit of the client to server byte is set, the low bits are
// client move cmd bits
// ms and angle2 are allways sent, the others are optional
#define CM_ANGLE1 (1<<0)
#define CM_ANGLE3 (1<<1)
#define CM_FORWARD (1<<2)
#define CM_SIDE (1<<3)
#define CM_UP (1<<4)
#define CM_BUTTONS (1<<5)
#define CM_IMPULSE (1<<6)
#define CM_ANGLE2 (1<<7)
//
// temp entity events
//
#define TE_SPIKE 0
#define TE_SUPERSPIKE 1
#define TE_GUNSHOT 2
#define TE_EXPLOSION 3
#define TE_TAREXPLOSION 4
#define TE_LIGHTNING1 5
#define TE_LIGHTNING2 6
#define TE_WIZSPIKE 7
#define TE_KNIGHTSPIKE 8
#define TE_LIGHTNING3 9
#define TE_LAVASPLASH 10
#define TE_TELEPORT 11
#define TE_EXPLOSION2 12
// PGM 01/21/97
#define TE_BEAM 13
// PGM 01/21/97
#ifdef QUAKE2
#define TE_IMPLOSION 14
#define TE_RAILTRAIL 15
#endif
// QUAKEWORLD
#define TE_BLOOD 12
#define TE_LIGHTNINGBLOOD 13
/*
==========================================================
ELEMENTS COMMUNICATED ACROSS THE NET
==========================================================
*/
#define MAX_CLIENTS 32
#define UPDATE_BACKUP 64 // copies of entity_state_t to keep buffered
// must be power of two
#define UPDATE_MASK (UPDATE_BACKUP-1)
#endif

View file

@ -36,6 +36,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <zone.h>
#include <common.h>
#include <draw.h>
#include <dirent.h>
#include <fnmatch.h>
#ifdef WIN32
#include <io.h>
#endif
@ -667,26 +669,31 @@ pack_t *COM_LoadPackZipFile (char *packfile)
void
COM_LoadGameDirectory(char *dir)
{
int i;
searchpath_t *search;
pack_t *pak;
char pakfile[MAX_OSPATH];
qboolean done = false;
DIR *dir_ptr;
struct dirent *dirent;
for ( i=0 ; !done ; i++ ) { // Load all Pak1 files
snprintf(pakfile, sizeof(pakfile), "%s/pak%i.pak", dir, i);
dir_ptr = opendir(dir);
pak = COM_LoadPackFile(pakfile);
if( !pak ) {
done = true;
} else {
search = Z_Malloc (sizeof(searchpath_t));
search->pack = pak;
search->next = com_searchpaths;
com_searchpaths = search;
while ((dirent = readdir(dir_ptr))) {
if (!fnmatch("*.pak", dirent->d_name, 0)) {
snprintf(pakfile, sizeof(pakfile), "%s/%s", dir, dirent->d_name);
pak = COM_LoadPackFile(pakfile);
if (!pak) {
Sys_Error(va("Bad pakfile %s!!", pakfile));
} else {
search = Z_Malloc (sizeof(searchpath_t));
search->pack = pak;
search->next = com_searchpaths;
com_searchpaths = search;
}
}
}
closedir(dir_ptr);
#ifdef GENERATIONS
for (done=false, i=0 ; !done ; i++ ) {

View file

@ -24,6 +24,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef _SERVER_H
#define _SERVER_H
#if !(defined(QUAKEWORLD) || defined(UQUAKE))
#error This is NOT safe to include for common items.
#endif
#ifdef _WIN32
#pragma warning( disable : 4244 4127 4201 4214 4514 4305 4115 4018)
#endif

View file

@ -816,7 +816,7 @@ NET_Init
====================
*/
void NET_Init (void)
void NET_Init (int port)
{
int i;
int controlSocket;