From dea2f48477e124ec1a8b75b6a1c7e7d651aa1a73 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 28 Jun 2012 19:18:14 +0900 Subject: [PATCH] Move entity_state_t into client/entities.h Also, start working on the shared entity manager. --- include/client/entities.h | 34 +++++++++++++++++++++++++++ include/qw/protocol.h | 26 +-------------------- libs/client/cl_entities.c | 49 +++++++++++++++++++++++++++++++++++++++ nq/include/protocol.h | 19 +-------------- 4 files changed, 85 insertions(+), 43 deletions(-) diff --git a/include/client/entities.h b/include/client/entities.h index 1946b722b..3d26eb68e 100644 --- a/include/client/entities.h +++ b/include/client/entities.h @@ -33,6 +33,40 @@ #include "QF/qtypes.h" +// entity_state_t is the information conveyed from the server +// in an update message +typedef struct entity_state_s { + int number; // edict index + unsigned flags; // nolerp, etc + + vec3_t origin; + vec3_t angles; + unsigned short modelindex; + unsigned short frame; + int effects; + byte colormap; + byte skinnum; + + // QSG 2 + byte alpha; + byte scale; + byte glow_size; + byte glow_color; + byte colormod; + + struct skin_s *skin; //FIXME this should not be here, but better state + //change tracking in the client is needed for this + //to be moved +} entity_state_t; + +typedef struct { + entity_state_t * const baseline; + entity_state_t * const * const frame; +} entstates_t; + +extern entstates_t nq_entstates; +extern entstates_t qw_entstates; + extern vec3_t ent_colormod[256]; #endif//__client_entities_h diff --git a/include/qw/protocol.h b/include/qw/protocol.h index 382428d97..cfd1c22b9 100644 --- a/include/qw/protocol.h +++ b/include/qw/protocol.h @@ -300,31 +300,7 @@ // must be power of two #define UPDATE_MASK (UPDATE_BACKUP-1) -// entity_state_t is the information conveyed from the server -// in an update message -typedef struct entity_state_s { - int number; // edict index - unsigned flags; // nolerp, etc - - vec3_t origin; - vec3_t angles; - unsigned short modelindex; - unsigned short frame; - int effects; - byte colormap; - byte skinnum; - - // QSG 2 - byte alpha; - byte scale; - byte glow_size; - byte glow_color; - byte colormod; - - struct skin_s *skin; //FIXME this should not be here, but better state - //change tracking in the client is needed for this - //to be moved -} entity_state_t; +#include "client/entities.h" // for entity_state_t #define MAX_PACKET_ENTITIES 64 // doesn't count nails #define MAX_DEMO_PACKET_ENTITIES 196 // doesn't count nails diff --git a/libs/client/cl_entities.c b/libs/client/cl_entities.c index fad2f2d28..85cc7b39e 100644 --- a/libs/client/cl_entities.c +++ b/libs/client/cl_entities.c @@ -33,6 +33,55 @@ #include "client/entities.h" +/* QW has a max of 512 entities and wants 64 frames of data per entity, plus + the baseline data (512 * (64 + 1) = 33280), but NQ has a max of 32000 + entities and wants 2 frames of data per entity, plus the baseline data + (32000 * (2 + 1) = 96000) +*/ +#define NUM_ENTITY_STATES 96000 + +static entity_state_t entity_states[NUM_ENTITY_STATES]; +static entity_state_t * const nq_frames[2] = { + &entity_states[32000 * 1], + &entity_states[32000 * 2], +}; +static entity_state_t * const qw_frames[64] = { + &entity_states[512 * 1], &entity_states[512 * 2], + &entity_states[512 * 3], &entity_states[512 * 4], + &entity_states[512 * 5], &entity_states[512 * 6], + &entity_states[512 * 7], &entity_states[512 * 8], + &entity_states[512 * 9], &entity_states[512 * 10], + &entity_states[512 * 11], &entity_states[512 * 12], + &entity_states[512 * 13], &entity_states[512 * 14], + &entity_states[512 * 15], &entity_states[512 * 16], + &entity_states[512 * 17], &entity_states[512 * 18], + &entity_states[512 * 19], &entity_states[512 * 20], + &entity_states[512 * 21], &entity_states[512 * 22], + &entity_states[512 * 23], &entity_states[512 * 24], + &entity_states[512 * 25], &entity_states[512 * 26], + &entity_states[512 * 27], &entity_states[512 * 28], + &entity_states[512 * 29], &entity_states[512 * 30], + &entity_states[512 * 31], &entity_states[512 * 32], + &entity_states[512 * 33], &entity_states[512 * 34], + &entity_states[512 * 35], &entity_states[512 * 36], + &entity_states[512 * 37], &entity_states[512 * 38], + &entity_states[512 * 39], &entity_states[512 * 40], + &entity_states[512 * 41], &entity_states[512 * 42], + &entity_states[512 * 43], &entity_states[512 * 44], + &entity_states[512 * 45], &entity_states[512 * 46], + &entity_states[512 * 47], &entity_states[512 * 48], + &entity_states[512 * 49], &entity_states[512 * 50], + &entity_states[512 * 51], &entity_states[512 * 52], + &entity_states[512 * 53], &entity_states[512 * 54], + &entity_states[512 * 55], &entity_states[512 * 56], + &entity_states[512 * 57], &entity_states[512 * 58], + &entity_states[512 * 59], &entity_states[512 * 60], + &entity_states[512 * 61], &entity_states[512 * 62], + &entity_states[512 * 63], &entity_states[512 * 64], +}; +entstates_t nq_entstates = {&entity_states[0], nq_frames}; +entstates_t qw_entstates = {&entity_states[0], qw_frames}; + vec3_t ent_colormod[256] = { {0, 0, 0}, {0, 0, 0.333333}, diff --git a/nq/include/protocol.h b/nq/include/protocol.h index a6d36cd6e..2d9d6309d 100644 --- a/nq/include/protocol.h +++ b/nq/include/protocol.h @@ -223,23 +223,6 @@ #define MAX_CLIENTS 16 -// entity_state_t is the information conveyed from the server -// in an update message -typedef struct entity_state_s { - vec3_t origin; - vec3_t angles; - unsigned short modelindex; - unsigned short frame; - int effects; - byte colormap; - byte skinnum; - - // QSG 2 - byte alpha; - byte scale; - byte glow_size; - byte glow_color; - byte colormod; -} entity_state_t; +#include "client/entities.h" // for entity_state_t #endif // __protocol_h