the progs engine and the server are now completely independent paving the way

for CSQC.
This commit is contained in:
Bill Currie 2001-01-03 05:54:35 +00:00
parent 6a52b0460c
commit 0192ed40c3
7 changed files with 57 additions and 34 deletions

View file

@ -153,6 +153,10 @@ eval_t *GetEdictFieldValue(struct progs_s *pr, edict_t *ed, char *field);
char *PR_GetString(struct progs_s *pr, int num);
int PR_SetString(struct progs_s *pr, char *s);
// externaly supplied functions
int ED_Parse_Extra_Fields (struct progs_s *pr, char *key, char *value);
//============================================================================
#define MAX_STACK_DEPTH 32
@ -195,6 +199,8 @@ typedef struct progs_s {
int *num_edicts;
double *time;
int null_bad;
int crc;
} progs_t;
#endif // _PROGS_H

View file

@ -380,6 +380,8 @@ extern cvar_t *deathmatch;
extern cvar_t *fraglimit;
extern cvar_t *timelimit;
extern cvar_t *r_skyname;
extern server_static_t svs; // persistant server info
extern server_t sv; // local server

View file

@ -67,10 +67,10 @@ if ASM_ARCH
world_ASM= worlda.S
endif
server_SOURCES= pr_cmds.c pr_edict.c pr_exec.c pr_offs.c sv_ccmds.c sv_cvar.c \
server_SOURCES= pr_edict.c pr_exec.c pr_offs.c sv_ccmds.c sv_cvar.c \
sv_ents.c sv_init.c sv_main.c sv_misc.c sv_model.c \
sv_move.c sv_nchan.c sv_phys.c sv_progs.c sv_send.c sv_user.c \
ver_check.c world.c $(world_ASM)
sv_move.c sv_nchan.c sv_phys.c sv_pr_cmds.c sv_progs.c sv_send.c \
sv_user.c ver_check.c world.c $(world_ASM)
qf_server_SOURCES= $(common_SOURCES) $(server_SOURCES)
qf_server_LDADD= -L. -lqfsys_sv $(NET_LIBS) $(Z_LIBS) $(DL_LIBS)

View file

@ -810,35 +810,24 @@ ED_ParseEdict (progs_t *pr, char *data, edict_t *ent)
if (keyname[0] == '_')
continue;
// If skyname is set, we want to allow skyboxes and set what
// the skybox name should be. "qlsky" is supported since
// at least one other map uses it already. --KB
if (stricmp (keyname, "sky") == 0 || // LordHavoc: added "sky" key
// (Quake2 and DarkPlaces use
// this)
stricmp (keyname, "skyname") == 0 ||
stricmp (keyname, "qlsky") == 0) {
Info_SetValueForKey (svs.info, "skybox",
"1", MAX_SERVERINFO_STRING);
Cvar_Set (r_skyname, com_token);
continue;
}
key = ED_FindField (pr, keyname);
if (!key) {
Con_Printf ("%s is not a field\n", keyname);
continue;
if (!ED_Parse_Extra_Fields (pr, keyname, com_token)) {
Con_Printf ("%s is not a field\n", keyname);
continue;
}
} else {
if (anglehack) {
char temp[32];
strncpy (temp, com_token, sizeof (temp));
temp[sizeof (temp) - 1] = 0;
snprintf (com_token, sizeof (com_token), "0 %s 0", temp);
}
if (!ED_ParseEpair (pr, (void *) &ent->v, key, com_token))
SV_Error ("ED_ParseEdict: parse error");
}
if (anglehack) {
char temp[32];
strcpy (temp, com_token);
snprintf (com_token, sizeof (com_token), "0 %s 0", temp);
}
if (!ED_ParseEpair (pr, (void *) &ent->v, key, com_token))
SV_Error ("ED_ParseEdict: parse error");
}
if (!init)
@ -927,7 +916,6 @@ void
PR_LoadProgs (progs_t *pr)
{
int i;
char num[32];
dstatement_t *st;
// flush the non-C variable lookup cache
@ -942,10 +930,8 @@ PR_LoadProgs (progs_t *pr)
Con_DPrintf ("Programs occupy %iK.\n", com_filesize / 1024);
// add prog crc to the serverinfo
snprintf (num, sizeof (num), "%i",
CRC_Block ((byte *) pr->progs, com_filesize));
Info_SetValueForStarKey (svs.info, "*progs", num, MAX_SERVERINFO_STRING);
// store prog crc
pr->crc = CRC_Block ((byte *) pr->progs, com_filesize);
// byte swap the header
for (i = 0; i < sizeof (*pr->progs) / 4; i++)

View file

@ -42,6 +42,7 @@
#include "quakefs.h"
#include "server.h"
#include "world.h"
#include "va.h"
server_t sv; // local server
@ -346,6 +347,8 @@ SV_SpawnServer (char *server)
// load progs to get entity field count
// which determines how big each edict is
PR_LoadProgs (&sv_progs);
Info_SetValueForStarKey (svs.info, "*progs", va ("%i", sv_progs.crc),
MAX_SERVERINFO_STRING);
// allocate edicts
sv.edicts = Hunk_AllocName (MAX_EDICTS * sv_progs.pr_edict_size, "edicts");

View file

@ -30,6 +30,13 @@
# include "config.h"
#endif
#ifdef HAVE_STRING_H
#include "string.h"
#endif
#ifdef HAVE_STRINGS_H
#include "strings.h"
#endif
#include "cmd.h"
#include "progs.h"
#include "server.h"
@ -111,3 +118,22 @@ PR_Profile_f (void)
{
PR_Profile (&sv_progs);
}
int
ED_Parse_Extra_Fields (progs_t *pr, char *key, char *value)
{
// If skyname is set, we want to allow skyboxes and set what
// the skybox name should be. "qlsky" is supported since
// at least one other map uses it already. --KB
if (stricmp (key, "sky") == 0 || // LordHavoc: added "sky" key
// (Quake2 and DarkPlaces use
// this)
stricmp (key, "skyname") == 0 ||
stricmp (key, "qlsky") == 0) {
Info_SetValueForKey (svs.info, "skybox",
"1", MAX_SERVERINFO_STRING);
Cvar_Set (r_skyname, value);
return 1;
}
return 0;
}