more standard const qualifiers
This commit is contained in:
parent
764a5a09fc
commit
51a7412af3
@ -9,13 +9,13 @@
|
||||
|
||||
enum error_t entity_registrant_init(
|
||||
struct entity_registrant_t *self,
|
||||
const char *name, char tile
|
||||
char const *name, char tile
|
||||
) {
|
||||
assert(self != NULL);
|
||||
|
||||
if (name == NULL || strlen(name) > MAX_NAME_LENGTH) return ERR_INPUT;
|
||||
|
||||
const char *dup = strndup(name, MAX_NAME_LENGTH);
|
||||
char const *dup = strndup(name, MAX_NAME_LENGTH);
|
||||
if (dup == NULL) return ERR_ALLOC;
|
||||
|
||||
self->name = dup;
|
||||
@ -57,7 +57,7 @@ void entity_registry_free(struct entity_registry_t *self) {
|
||||
|
||||
enum error_t entity_registry_append(
|
||||
struct entity_registry_t *self,
|
||||
struct entity_registrant_t *registrant
|
||||
struct entity_registrant_t const *registrant
|
||||
) {
|
||||
assert(self != NULL && registrant != NULL);
|
||||
|
||||
|
@ -6,13 +6,13 @@
|
||||
#include "../error.h"
|
||||
|
||||
struct entity_registrant_t {
|
||||
const char *name;
|
||||
char const *name;
|
||||
char tile;
|
||||
};
|
||||
|
||||
enum error_t entity_registrant_init(
|
||||
struct entity_registrant_t *,
|
||||
const char *, char
|
||||
char const *, char
|
||||
);
|
||||
|
||||
void entity_registrant_free(struct entity_registrant_t *);
|
||||
@ -28,7 +28,7 @@ void entity_registry_free(struct entity_registry_t *);
|
||||
|
||||
enum error_t entity_registry_append(
|
||||
struct entity_registry_t *,
|
||||
struct entity_registrant_t *
|
||||
struct entity_registrant_t const *
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "error.h"
|
||||
|
||||
const char *const ERROR_STRS[] = {
|
||||
char const *const ERROR_STRS[] = {
|
||||
"SUCCESS",
|
||||
"BAD INPUT",
|
||||
"ALLOCATION",
|
||||
|
@ -9,6 +9,6 @@ enum error_t {
|
||||
__ERR_COUNT,
|
||||
};
|
||||
|
||||
extern const char *const ERROR_STRS[];
|
||||
extern char const *const ERROR_STRS[];
|
||||
|
||||
#endif
|
||||
|
@ -4,10 +4,10 @@
|
||||
|
||||
#include "render.h"
|
||||
|
||||
void render_world(struct world_t *world) {
|
||||
void render_world(struct world_t const *world) {
|
||||
for (size_t i = 0; i < MAX_ENTITIES; i++) {
|
||||
struct entity_t *entity = &world->entities[i];
|
||||
struct entity_registrant_t *registrant =
|
||||
struct entity_t const *const entity = &world->entities[i];
|
||||
struct entity_registrant_t const *const registrant =
|
||||
&world->registered_entities.entities[entity->id];
|
||||
|
||||
if (entity->id == 0) continue;
|
||||
|
@ -3,6 +3,6 @@
|
||||
|
||||
#include "../world.h"
|
||||
|
||||
void render_world(struct world_t *);
|
||||
void render_world(struct world_t const *);
|
||||
|
||||
#endif
|
||||
|
@ -38,7 +38,7 @@ void world_free(struct world_t *self) {
|
||||
|
||||
enum error_t world_register_entity(
|
||||
struct world_t *self,
|
||||
const char *name, char tile
|
||||
char const *name, char tile
|
||||
) {
|
||||
enum error_t err;
|
||||
struct entity_registry_t *registry = &self->registered_entities;
|
||||
@ -53,7 +53,7 @@ enum error_t world_register_entity(
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
static size_t world_find_empty_entity(struct world_t *self) {
|
||||
static size_t world_find_empty_entity(struct world_t const *self) {
|
||||
for (size_t i = 0; i < MAX_ENTITIES; i++)
|
||||
if (self->entities[i].id == 0) return i;
|
||||
|
||||
|
@ -20,7 +20,7 @@ struct world_t {
|
||||
enum error_t world_init(struct world_t *, size_t, size_t);
|
||||
void world_free(struct world_t *);
|
||||
|
||||
enum error_t world_register_entity(struct world_t *, const char *, char);
|
||||
enum error_t world_register_entity(struct world_t *, char const *, char);
|
||||
enum error_t world_place_entity(struct world_t *, size_t, size_t, size_t);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user