43 lines
1.2 KiB
C
43 lines
1.2 KiB
C
#ifndef WORLD_H
|
|
#define WORLD_H
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <jansson.h>
|
|
|
|
#include "error.h"
|
|
#include "entity/registry.h"
|
|
#include "entity/entity.h"
|
|
|
|
#define MAX_ENTITIES 256
|
|
|
|
struct world_t {
|
|
struct entity_t entities[MAX_ENTITIES];
|
|
struct entity_registry_t registered_entities;
|
|
|
|
size_t height;
|
|
size_t width;
|
|
};
|
|
|
|
enum error_t world_init(struct world_t *, size_t, size_t);
|
|
void world_free(struct world_t *);
|
|
|
|
// json_t doesn't store the json data itself; the value of the pointer is
|
|
// apparently needed for jansson to use the data, so I need a double pointer
|
|
//
|
|
// TODO
|
|
// Right now, to serialise and deserialise again you have to call:
|
|
// 1. world_serialise() | world_t -> json_t
|
|
// 2. json_dumpX() | json_t -> char *
|
|
// 3. json_loadX() | char * -> json_t
|
|
// 4. world_deserialise() | json_t -> world_t
|
|
//
|
|
// Perhaps these two functions should go directly between world_t and char *
|
|
enum error_t world_serialise(struct world_t *, struct json_t **);
|
|
enum error_t world_deserialise(struct world_t *, struct json_t *);
|
|
|
|
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
|