Split the gibs per frame limit between gibs and debris.

The gibs and debris per frame must be limited to prevent server mem
map overflows. Until now debris and gibs were handled the same, the
debris spawned by rockets and grenates could prevent the actual gibs
of the killed monster from spawning.

Before this change 20 entities were spawned at max. Now up tp 40
enties can be spawned. This needs some testings.

Fixes issue 323.
This commit is contained in:
Yamagi Burmeister 2018-10-03 18:45:23 +02:00
parent 9525dc35a8
commit ef55042cef
3 changed files with 13 additions and 18 deletions

View file

@ -405,7 +405,6 @@ ExitLevel(void)
} }
gibsthisframe = 0; gibsthisframe = 0;
lastgibframe = 0;
} }
/* /*
@ -420,6 +419,9 @@ G_RunFrame(void)
level.framenum++; level.framenum++;
level.time = level.framenum * FRAMETIME; level.time = level.framenum * FRAMETIME;
gibsthisframe = 0;
debristhisframe = 0;
/* choose a client for monsters to target this frame */ /* choose a client for monsters to target this frame */
AI_SetSightClient(); AI_SetSightClient();

View file

@ -26,8 +26,8 @@
#include "header/local.h" #include "header/local.h"
int debristhisframe;
int gibsthisframe; int gibsthisframe;
int lastgibframe;
void void
Use_Areaportal(edict_t *ent, edict_t *other /* unused */, edict_t *activator /* unused */) Use_Areaportal(edict_t *ent, edict_t *other /* unused */, edict_t *activator /* unused */)
@ -196,15 +196,9 @@ ThrowGib(edict_t *self, char *gibname, int damage, int type)
return; return;
} }
if (level.framenum > lastgibframe)
{
gibsthisframe = 0;
lastgibframe = level.framenum;
}
gibsthisframe++; gibsthisframe++;
if (gibsthisframe > 20) if (gibsthisframe > MAX_GIBS)
{ {
return; return;
} }
@ -223,6 +217,7 @@ ThrowGib(edict_t *self, char *gibname, int damage, int type)
gib->flags |= FL_NO_KNOCKBACK; gib->flags |= FL_NO_KNOCKBACK;
gib->takedamage = DAMAGE_YES; gib->takedamage = DAMAGE_YES;
gib->die = gib_die; gib->die = gib_die;
gib->health = 500;
if (type == GIB_ORGANIC) if (type == GIB_ORGANIC)
{ {
@ -378,15 +373,9 @@ ThrowDebris(edict_t *self, char *modelname, float speed, vec3_t origin)
return; return;
} }
if (level.framenum > lastgibframe) debristhisframe++;
{
gibsthisframe = 0;
lastgibframe = level.framenum;
}
gibsthisframe++; if (debristhisframe > MAX_DEBRIS)
if (gibsthisframe > 20)
{ {
return; return;
} }

View file

@ -108,6 +108,10 @@ typedef enum
AMMO_SLUGS AMMO_SLUGS
} ammo_t; } ammo_t;
/* Maximum debris / gibs per frame */
#define MAX_GIBS 20
#define MAX_DEBRIS 20
/* deadflag */ /* deadflag */
#define DEAD_NO 0 #define DEAD_NO 0
#define DEAD_DYING 1 #define DEAD_DYING 1
@ -441,8 +445,8 @@ extern spawn_temp_t st;
extern int sm_meat_index; extern int sm_meat_index;
extern int snd_fry; extern int snd_fry;
extern int debristhisframe;
extern int gibsthisframe; extern int gibsthisframe;
extern int lastgibframe;
/* means of death */ /* means of death */
#define MOD_UNKNOWN 0 #define MOD_UNKNOWN 0