Rename entity_t and obj_t to dynentity_t and objentity_t

This commit is contained in:
Camden Dixie O'Brien 2025-01-04 04:51:27 +00:00
parent 77725a5ce4
commit 6bd85d9ebf

View File

@ -86,7 +86,7 @@ typedef struct {
ivec_t animstep, svarstep, ext; ivec_t animstep, svarstep, ext;
dbox_t fbox; dbox_t fbox;
SDL_Texture *tex; SDL_Texture *tex;
} entity_t; } dynentity_t;
typedef struct { typedef struct {
unsigned animframes; unsigned animframes;
@ -97,11 +97,11 @@ typedef struct {
typedef struct { typedef struct {
unsigned type; unsigned type;
ivec_t pos; ivec_t pos;
} obj_t; } objentity_t;
typedef struct { typedef struct {
size_t n, cap; size_t n, cap;
obj_t *buf; objentity_t *buf;
} objcol_t; } objcol_t;
typedef unsigned map_t[MAPNLAYERS][MAPWIDTH][MAPHEIGHT]; typedef unsigned map_t[MAPNLAYERS][MAPWIDTH][MAPHEIGHT];
@ -114,7 +114,7 @@ typedef struct {
dvec_t vpos; dvec_t vpos;
objtype_t objtypes[MAXOBJTYPES]; objtype_t objtypes[MAXOBJTYPES];
objcol_t objcol; objcol_t objcol;
entity_t p; dynentity_t p;
} gamestate_t; } gamestate_t;
const engineconf_t game_conf = { const engineconf_t game_conf = {
@ -298,7 +298,7 @@ maploadobjects(gamestate_t *state, xmlNodePtr node, SDL_Renderer *renderer)
{ {
state->objcol.n = 0; state->objcol.n = 0;
state->objcol.cap = INITOBJCOLCAP; state->objcol.cap = INITOBJCOLCAP;
state->objcol.buf = malloc(sizeof(obj_t) * state->objcol.cap); state->objcol.buf = malloc(sizeof(objentity_t) * state->objcol.cap);
assert(state->objcol.buf); assert(state->objcol.buf);
node = node->xmlChildrenNode; node = node->xmlChildrenNode;
@ -311,10 +311,10 @@ maploadobjects(gamestate_t *state, xmlNodePtr node, SDL_Renderer *renderer)
if (state->objcol.n == state->objcol.cap) { if (state->objcol.n == state->objcol.cap) {
state->objcol.cap *= 2; state->objcol.cap *= 2;
state->objcol.buf = realloc( state->objcol.buf = realloc(
state->objcol.buf, sizeof(obj_t) * state->objcol.cap); state->objcol.buf, sizeof(objentity_t) * state->objcol.cap);
assert(state->objcol.buf); assert(state->objcol.buf);
} }
obj_t *o = &state->objcol.buf[state->objcol.n++]; objentity_t *o = &state->objcol.buf[state->objcol.n++];
// Load object type // Load object type
xmlChar *templ = xmlGetProp(node, (const xmlChar *)"template"); xmlChar *templ = xmlGetProp(node, (const xmlChar *)"template");
@ -377,7 +377,7 @@ static void mapdraw(const gamestate_t *state, SDL_Renderer *renderer)
} }
} }
static void entityupdate(gamestate_t *state, entity_t *e, double dt) static void entityupdate(gamestate_t *state, dynentity_t *e, double dt)
{ {
if (0 == e->speed) { if (0 == e->speed) {
// Round position to nearest integer to align with pixel grid. // Round position to nearest integer to align with pixel grid.
@ -424,7 +424,7 @@ static void entityupdate(gamestate_t *state, entity_t *e, double dt)
} }
static void entitydraw( static void entitydraw(
const gamestate_t *state, SDL_Renderer *renderer, const entity_t *e, const gamestate_t *state, SDL_Renderer *renderer, const dynentity_t *e,
uint64_t t) uint64_t t)
{ {
const unsigned frame = (t / BASEANIMPERIOD) % e->animlen; const unsigned frame = (t / BASEANIMPERIOD) % e->animlen;
@ -447,7 +447,7 @@ static void
objsdraw(const gamestate_t *state, SDL_Renderer *renderer, uint64_t t) objsdraw(const gamestate_t *state, SDL_Renderer *renderer, uint64_t t)
{ {
for (unsigned i = 0; i < state->objcol.n; ++i) { for (unsigned i = 0; i < state->objcol.n; ++i) {
const obj_t *obj = &state->objcol.buf[i]; const objentity_t *obj = &state->objcol.buf[i];
assert(obj->type < MAXOBJTYPES); assert(obj->type < MAXOBJTYPES);
const objtype_t *type = &state->objtypes[obj->type]; const objtype_t *type = &state->objtypes[obj->type];
assert(NULL != type->tex); assert(NULL != type->tex);