From 67b6e48713ec874e585cb4cd50d6829f1df13838 Mon Sep 17 00:00:00 2001 From: sezero Date: Thu, 15 Nov 2012 17:30:43 +0000 Subject: [PATCH] pr_cmds.c, pr_exec.c, pr_edict.c, sv_main.c: Changed several Sys_Error() calls to Host_Error(). ED_PrintEdict_f(),ED_PrintEdicts() and ED_Count() require an active server to print any infos. ED_PrintEdict_f cannot work with a negative argument. git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@788 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/pr_cmds.c | 6 +++--- Quake/pr_edict.c | 47 +++++++++++++++++++++++++++-------------------- Quake/pr_exec.c | 2 +- Quake/sv_main.c | 6 +++--- 4 files changed, 34 insertions(+), 27 deletions(-) diff --git a/Quake/pr_cmds.c b/Quake/pr_cmds.c index 8b4d1fb3..6caa7688 100644 --- a/Quake/pr_cmds.c +++ b/Quake/pr_cmds.c @@ -632,13 +632,13 @@ static void PF_sound (void) attenuation = G_FLOAT(OFS_PARM4); if (volume < 0 || volume > 255) - Sys_Error ("SV_StartSound: volume = %i", volume); + Host_Error ("SV_StartSound: volume = %i", volume); if (attenuation < 0 || attenuation > 4) - Sys_Error ("SV_StartSound: attenuation = %f", attenuation); + Host_Error ("SV_StartSound: attenuation = %f", attenuation); if (channel < 0 || channel > 7) - Sys_Error ("SV_StartSound: channel = %i", channel); + Host_Error ("SV_StartSound: channel = %i", channel); SV_StartSound (entity, channel, sample, volume, attenuation); } diff --git a/Quake/pr_edict.c b/Quake/pr_edict.c index dda04a14..71866afd 100644 --- a/Quake/pr_edict.c +++ b/Quake/pr_edict.c @@ -124,7 +124,7 @@ edict_t *ED_Alloc (void) } if (i == sv.max_edicts) //johnfitz -- use sv.max_edicts instead of MAX_EDICTS - Host_Error ("ED_Alloc: no free edicts (max_edicts is %i)", sv.max_edicts); //johnfitz -- was Sys_Error + Host_Error ("ED_Alloc: no free edicts (max_edicts is %i)", sv.max_edicts); sv.num_edicts++; e = EDICT_NUM(i); @@ -576,6 +576,9 @@ void ED_PrintEdicts (void) { int i; + if (!sv.active) + return; + Con_Printf ("%i entities\n", sv.num_edicts); for (i = 0; i < sv.num_edicts; i++) ED_PrintNum (i); @@ -592,8 +595,11 @@ static void ED_PrintEdict_f (void) { int i; + if (!sv.active) + return; + i = Q_atoi (Cmd_Argv(1)); - if (i >= sv.num_edicts) + if (i < 0 || i >= sv.num_edicts) { Con_Printf("Bad edict number\n"); return; @@ -610,9 +616,11 @@ For debugging */ static void ED_Count (void) { - int i; edict_t *ent; - int active, models, solid, step; + int i, active, models, solid, step; + + if (!sv.active) + return; active = models = solid = step = 0; for (i = 0; i < sv.num_edicts; i++) @@ -694,17 +702,17 @@ void ED_ParseGlobals (const char *data) if (com_token[0] == '}') break; if (!data) - Sys_Error ("ED_ParseEntity: EOF without closing brace"); + Host_Error ("ED_ParseEntity: EOF without closing brace"); strcpy (keyname, com_token); // parse value data = COM_Parse (data); if (!data) - Sys_Error ("ED_ParseEntity: EOF without closing brace"); + Host_Error ("ED_ParseEntity: EOF without closing brace"); if (com_token[0] == '}') - Sys_Error ("ED_ParseEntity: closing brace without data"); + Host_Error ("ED_ParseEntity: closing brace without data"); key = ED_FindGlobal (keyname); if (!key) @@ -840,10 +848,9 @@ Used for initial level load and for savegames. const char *ED_ParseEdict (const char *data, edict_t *ent) { ddef_t *key; - qboolean anglehack; - qboolean init; char keyname[256]; - int n; + qboolean anglehack, init; + int n; init = false; @@ -859,7 +866,7 @@ const char *ED_ParseEdict (const char *data, edict_t *ent) if (com_token[0] == '}') break; if (!data) - Sys_Error ("ED_ParseEntity: EOF without closing brace"); + Host_Error ("ED_ParseEntity: EOF without closing brace"); // anglehack is to allow QuakeEd to write single scalar angles // and allow them to be turned into vectors. (FIXME...) @@ -888,10 +895,10 @@ const char *ED_ParseEdict (const char *data, edict_t *ent) // parse value data = COM_Parse (data); if (!data) - Sys_Error ("ED_ParseEntity: EOF without closing brace"); + Host_Error ("ED_ParseEntity: EOF without closing brace"); if (com_token[0] == '}') - Sys_Error ("ED_ParseEntity: closing brace without data"); + Host_Error ("ED_ParseEntity: closing brace without data"); init = true; @@ -963,7 +970,7 @@ void ED_LoadFromFile (const char *data) if (!data) break; if (com_token[0] != '{') - Sys_Error ("ED_LoadFromFile: found %s when expecting {",com_token); + Host_Error ("ED_LoadFromFile: found %s when expecting {",com_token); if (!ent) ent = EDICT_NUM(0); @@ -1037,7 +1044,7 @@ void PR_LoadProgs (void) progs = (dprograms_t *)COM_LoadHunkFile ("progs.dat", NULL); if (!progs) - Sys_Error ("PR_LoadProgs: couldn't load progs.dat"); + Host_Error ("PR_LoadProgs: couldn't load progs.dat"); Con_DPrintf ("Programs occupy %iK.\n", com_filesize/1024); for (i = 0; i < com_filesize; i++) @@ -1048,9 +1055,9 @@ void PR_LoadProgs (void) ((int *)progs)[i] = LittleLong ( ((int *)progs)[i] ); if (progs->version != PROG_VERSION) - Sys_Error ("progs.dat has wrong version number (%i should be %i)", progs->version, PROG_VERSION); + Host_Error ("progs.dat has wrong version number (%i should be %i)", progs->version, PROG_VERSION); if (progs->crc != PROGHEADER_CRC) - Sys_Error ("progs.dat system vars have been modified, progdefs.h is out of date"); + Host_Error ("progs.dat system vars have been modified, progdefs.h is out of date"); pr_functions = (dfunction_t *)((byte *)progs + progs->ofs_functions); pr_strings = (char *)progs + progs->ofs_strings; @@ -1105,7 +1112,7 @@ void PR_LoadProgs (void) { pr_fielddefs[i].type = LittleShort (pr_fielddefs[i].type); if (pr_fielddefs[i].type & DEF_SAVEGLOBAL) - Sys_Error ("PR_LoadProgs: pr_fielddefs[i].type & DEF_SAVEGLOBAL"); + Host_Error ("PR_LoadProgs: pr_fielddefs[i].type & DEF_SAVEGLOBAL"); pr_fielddefs[i].ofs = LittleShort (pr_fielddefs[i].ofs); pr_fielddefs[i].s_name = LittleLong (pr_fielddefs[i].s_name); @@ -1155,7 +1162,7 @@ void PR_Init (void) edict_t *EDICT_NUM(int n) { if (n < 0 || n >= sv.max_edicts) - Sys_Error ("EDICT_NUM: bad number %i", n); + Host_Error ("EDICT_NUM: bad number %i", n); return (edict_t *)((byte *)sv.edicts + (n)*pr_edict_size); } @@ -1167,7 +1174,7 @@ int NUM_FOR_EDICT(edict_t *e) b = b / pr_edict_size; if (b < 0 || b >= sv.num_edicts) - Sys_Error ("NUM_FOR_EDICT: bad pointer"); + Host_Error ("NUM_FOR_EDICT: bad pointer"); return b; } diff --git a/Quake/pr_exec.c b/Quake/pr_exec.c index 3fcedc1f..c32f5f4f 100644 --- a/Quake/pr_exec.c +++ b/Quake/pr_exec.c @@ -323,7 +323,7 @@ static int PR_LeaveFunction (void) int i, c; if (pr_depth <= 0) - Sys_Error("prog stack underflow"); + Host_Error("prog stack underflow"); // Restore locals from the stack c = pr_xfunction->locals; diff --git a/Quake/sv_main.c b/Quake/sv_main.c index 5d2b5884..0bbb06df 100644 --- a/Quake/sv_main.c +++ b/Quake/sv_main.c @@ -166,13 +166,13 @@ void SV_StartSound (edict_t *entity, int channel, const char *sample, int volume int i, field_mask; if (volume < 0 || volume > 255) - Sys_Error ("SV_StartSound: volume = %i", volume); + Host_Error ("SV_StartSound: volume = %i", volume); if (attenuation < 0 || attenuation > 4) - Sys_Error ("SV_StartSound: attenuation = %f", attenuation); + Host_Error ("SV_StartSound: attenuation = %f", attenuation); if (channel < 0 || channel > 7) - Sys_Error ("SV_StartSound: channel = %i", channel); + Host_Error ("SV_StartSound: channel = %i", channel); if (sv.datagram.cursize > MAX_DATAGRAM-16) return;