diff --git a/include/QF/darray.h b/include/QF/darray.h index 61500256a..e41cd5edb 100644 --- a/include/QF/darray.h +++ b/include/QF/darray.h @@ -69,6 +69,8 @@ ele_type *a; \ } +#define DARRAY_STATIC_INIT(g) { .grow = g } + /** Allocate a fixed-size array using the given allocator The allocated array is initilized to be ungrowable, and with both size diff --git a/include/QF/render.h b/include/QF/render.h index d6a871865..99fb105a9 100644 --- a/include/QF/render.h +++ b/include/QF/render.h @@ -124,7 +124,6 @@ typedef struct renderer_s { typedef struct entity_s { struct entity_s *next; - struct entity_s *unext; //FIXME this shouldn't be here. for qw demos struct transform_s *transform; animation_t animation; diff --git a/qw/include/client.h b/qw/include/client.h index 23d22e893..3c64c128b 100644 --- a/qw/include/client.h +++ b/qw/include/client.h @@ -28,6 +28,7 @@ #ifndef _CLIENT_H #define _CLIENT_H +#include "QF/entity.h" #include "QF/info.h" #include "QF/quakefs.h" #include "QF/vid.h" @@ -341,7 +342,7 @@ extern struct cvar_s *cl_fb_players; extern client_state_t cl; -extern entity_t *cl_static_entities; +extern entityset_t cl_static_entities; extern entity_t cl_entities[512]; extern byte cl_entity_valid[2][512]; diff --git a/qw/source/cl_demo.c b/qw/source/cl_demo.c index d063211d4..31594d51f 100644 --- a/qw/source/cl_demo.c +++ b/qw/source/cl_demo.c @@ -755,7 +755,9 @@ demo_start_recording (int track) SZ_Clear (&buf); } // spawnstatic - for (ent = cl_static_entities; ent; ent = ent->unext) { + for (size_t staticIndex = 0; staticIndex < cl_static_entities.size; + staticIndex++) { + ent = cl_static_entities.a[staticIndex]; MSG_WriteByte (&buf, svc_spawnstatic); for (j = 1; j < cl.nummodels; j++) { diff --git a/qw/source/cl_parse.c b/qw/source/cl_parse.c index 2266d1029..7366b4da0 100644 --- a/qw/source/cl_parse.c +++ b/qw/source/cl_parse.c @@ -169,8 +169,7 @@ int packet_latency[NET_TIMINGS]; extern cvar_t *hud_scoreboard_uid; -entity_t *cl_static_entities; -static entity_t **cl_static_tail; +entityset_t cl_static_entities = DARRAY_STATIC_INIT (32); static void CL_LoadSky (void) @@ -298,8 +297,7 @@ map_ent (const char *mapname) static void CL_NewMap (const char *mapname) { - cl_static_entities = 0; - cl_static_tail = &cl_static_entities; + cl_static_entities.size = 0; r_funcs->R_NewMap (cl.worldmodel, cl.model_precache, cl.nummodels); Team_NewMap (); Con_NewMap (); @@ -973,8 +971,7 @@ CL_ParseStatic (void) ent = r_funcs->R_AllocEntity (); CL_Init_Entity (ent); - *cl_static_tail = ent; - cl_static_tail = &ent->unext; + DARRAY_APPEND (&cl_static_entities, ent); // copy it to the current state ent->renderer.model = cl.model_precache[es.modelindex];