From 9f7e1f864ea2f915be982488285db9e128022303 Mon Sep 17 00:00:00 2001 From: Adam Olsen Date: Tue, 9 Oct 2001 22:47:14 +0000 Subject: [PATCH] - add a pr_double_remove cvar, that either ignores (0), warns about (1), or causes a fatal error (2) when the progs remove an already removed entity. default is 1. - fix a segfault in FFnickFF parsing that causes a segfault --- qw/source/sv_main.c | 7 +++++++ qw/source/sv_pr_cmds.c | 9 +++++++++ qw/source/sv_send.c | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/qw/source/sv_main.c b/qw/source/sv_main.c index 6246d72ce..788844875 100644 --- a/qw/source/sv_main.c +++ b/qw/source/sv_main.c @@ -1897,6 +1897,7 @@ SV_InitLocal (void) extern cvar_t *sv_wateraccelerate; extern cvar_t *sv_friction; extern cvar_t *sv_waterfriction; + extern cvar_t *pr_double_remove; SV_UserInit (); @@ -2056,6 +2057,12 @@ SV_InitLocal (void) pr_gc_interval = Cvar_Get ("pr_gc_interval", "50", CVAR_NONE, NULL, "Number of frames to wait before running " "string garbage collector."); + pr_double_remove = Cvar_Get ("pr_double_remove", "1", CVAR_NONE, NULL, + "Handling of double entity remove. " + "0 is silently ignore, 1 prints a " + "traceback, and 2 gives an error.\n" + "Only works if debugging is available " + "and enabled"); // DoS protection Cmd_AddCommand ("netdosexpire", SV_netDoSexpire_f, "FIXME: part of DoS " "protection obviously, but I don't know what it does. No " diff --git a/qw/source/sv_pr_cmds.c b/qw/source/sv_pr_cmds.c index b5c623ff9..4497f8270 100644 --- a/qw/source/sv_pr_cmds.c +++ b/qw/source/sv_pr_cmds.c @@ -641,12 +641,21 @@ PF_Spawn (progs_t *pr) RETURN_EDICT (pr, ed); } +cvar_t *pr_double_remove; + void PF_Remove (progs_t *pr) { edict_t *ed; ed = G_EDICT (pr, OFS_PARM0); + if (ed->free && pr_double_remove->int_val) { + if (pr_double_remove->int_val == 1) { + PR_DumpState (pr); + SV_Printf ("Double entity remove\n"); + } else // == 2 + PR_RunError (pr, "Double entity remove\n"); + } ED_Free (pr, ed); } diff --git a/qw/source/sv_send.c b/qw/source/sv_send.c index fe4092462..8726565aa 100644 --- a/qw/source/sv_send.c +++ b/qw/source/sv_send.c @@ -148,7 +148,7 @@ SV_Print (const char *fmt, va_list args) int len; int i; - if (!*end) + if (!end) end = in + strlen (in); *end = '\0'; for (i = 0; i < MAX_CLIENTS; i++) {