Fix entities with an index greater than 2047 corrupting the client's heap if sent over the network

Resolves #191
This commit is contained in:
Sam V 2023-02-04 14:29:11 +01:00
parent 0da76d96ab
commit 6ecc8f298b
3 changed files with 13 additions and 1 deletions

View file

@ -19,6 +19,7 @@
* Fixed game_player_equip crashing when given a null activator [#189](https://github.com/SamVanheer/halflife-updated/issues/189)
* Fixed Hornet gun recharging to full ammo after loading a save game [#190](https://github.com/SamVanheer/halflife-updated/issues/190)
* Fixed explosives that impact the underside of a brush dealing damage to entities on the other side of that brush (halflife issue [#3244](https://github.com/ValveSoftware/halflife/issues/3244))
* Fixed entities with an index greater than 2047 corrupting the client's heap if sent over the network [#191](https://github.com/SamVanheer/halflife-updated/issues/191)
### New features
@ -27,6 +28,7 @@
* When using `impulse 107` to get the name of a texture the texture type (as used in `materials.txt`) will also be printed
* Made `PM_FindTextureType` const correct
* Added `WRITE_FLOAT` function corresponding to the client's `READ_FLOAT` function
* Set maximum edicts to 2048 in liblist.gam [#181](https://github.com/SamVanheer/halflife-updated/issues/181)
## Changes in V1.0.0 Beta 013

View file

@ -12,7 +12,7 @@
#define STUDIO_RENDER 1
#define STUDIO_EVENTS 2
#define MAX_EDICTS 900
#define MAX_EDICTS 2048
#define MAX_MODEL_NAME 64
#define MAX_MAP_HULLS 4

View file

@ -26,6 +26,7 @@
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "com_model.h"
#include "saverestore.h"
#include "player.h"
#include "spectator.h"
@ -1084,6 +1085,15 @@ we could also use the pas/ pvs that we set in SetupVisibility, if we wanted to.
*/
int AddToFullPack(struct entity_state_s* state, int e, edict_t* ent, edict_t* host, int hostflags, int player, unsigned char* pSet)
{
// Entities with an index greater than this will corrupt the client's heap because
// the index is sent with only 11 bits of precision (2^11 == 2048).
// So we don't send them, just like having too many entities would result
// in the entity not being sent.
if (e >= MAX_EDICTS)
{
return 0;
}
int i;
auto entity = reinterpret_cast<CBaseEntity*>(GET_PRIVATE(ent));