From 2bcbd86a61ee3f5876338d2f87cf7e88f1ac32a8 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sat, 20 Feb 2016 18:20:20 +0100 Subject: [PATCH] A few fixes from q2dos --- src/g_phys.c | 6 ++++-- src/shared/shared.c | 21 +++++++++++++++++++-- src/zaero/weapon.c | 4 +++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/g_phys.c b/src/g_phys.c index 17b09f2..137ca1f 100644 --- a/src/g_phys.c +++ b/src/g_phys.c @@ -684,8 +684,10 @@ void SV_Physics_Pusher (edict_t *ent) break; // move was blocked } } - if (pushed_p > &pushed[MAX_EDICTS]) - gi.error (ERR_FATAL, "pushed_p > &pushed[MAX_EDICTS], memory corrupted"); + if (pushed_p > &pushed[MAX_EDICTS-1]) + { + gi.error (ERR_FATAL, "pushed_p > &pushed[MAX_EDICTS-1], memory corrupted"); + } if (part) { diff --git a/src/shared/shared.c b/src/shared/shared.c index bc5ae5c..9a6dadb 100644 --- a/src/shared/shared.c +++ b/src/shared/shared.c @@ -310,10 +310,10 @@ vec3_t corners[2]; int BoxOnPlaneSide2(vec3_t emins, vec3_t emaxs, struct cplane_s *p) { - int i; + //int i; // DG: I think it's supposed to write to the global! float dist1, dist2; int sides; - vec3_t corners[2]; + //vec3_t corners[2]; // DG: ditto for (i = 0; i < 3; i++) { @@ -680,6 +680,12 @@ COM_FileBase(char *in, char *out) { char *s, *s2; + if(!in[0]) + { + out[0] = '\0'; + return; + } + s = in + strlen(in) - 1; while (s != in && *s != '.') @@ -711,6 +717,12 @@ COM_FilePath(const char *in, char *out) { const char *s; + if(!in[0]) + { + out[0] = '\0'; + return; + } + s = in + strlen(in) - 1; while (s != in && *s != '/') @@ -727,6 +739,11 @@ COM_DefaultExtension(char *path, const char *extension) { char *src; + if(!path[0]) + { + return; + } + /* */ /* if path doesn't have a .EXT, append extension */ /* (extension should include the .) */ diff --git a/src/zaero/weapon.c b/src/zaero/weapon.c index 88c4794..0fe6cb8 100644 --- a/src/zaero/weapon.c +++ b/src/zaero/weapon.c @@ -171,6 +171,7 @@ void tripbomb_laser_think (edict_t *self) // randomly phase out or EMPNuke is in effect if (EMPNukeCheck(self, self->s.origin) || random() < 0.1) { + self->svflags |= SVF_NOCLIENT; return; } @@ -1045,9 +1046,10 @@ void fire_sniper_bullet (edict_t *self, vec3_t start, vec3_t aimdir, int damage, vec3_t end; vec3_t s; edict_t *ignore = self; + int i = 0; VectorMA (start, 8192, aimdir, end); VectorCopy(start, s); - while(1) + for(i=0;i<256;++i) // DG: prevent infinite loop (adapted from q2dos) { tr = gi.trace (s, NULL, NULL, end, ignore, MASK_SHOT_NO_WINDOW); if (tr.fraction >= 1.0)