eco2d/code/apps/server/source/world/blocks.c

50 lines
930 B
C
Raw Normal View History

2021-01-11 14:27:32 +00:00
#include "zpl.h"
#include "world/blocks.h"
2021-01-11 13:47:14 +00:00
// todo: csv parsing + utils
2021-01-11 14:27:32 +00:00
2021-01-11 16:20:12 +00:00
#define BLOCKS_COUNT (sizeof(blocks)/sizeof(block))
2021-01-11 14:27:32 +00:00
typedef struct {
2021-01-11 16:20:12 +00:00
uint8_t tex_id;
2021-01-14 16:37:20 +00:00
char *name;
2021-01-11 14:27:32 +00:00
uint32_t flags;
2021-01-11 16:20:12 +00:00
uint32_t kind;
uint32_t biome;
char symbol;
2021-01-11 14:27:32 +00:00
} block;
2021-01-11 16:20:12 +00:00
#include "blocks_list.c"
2021-01-11 14:27:32 +00:00
2021-01-11 16:20:12 +00:00
uint8_t blocks_find(uint32_t biome, uint32_t kind) {
for (int i=0; i<BLOCKS_COUNT; i++) {
if (blocks[i].biome == biome && blocks[i].kind == kind)
return i;
}
return BLOCK_INVALID;
2021-01-11 14:27:32 +00:00
}
2021-01-11 16:20:12 +00:00
char *blocks_get_name(uint8_t id) {
return blocks[id].name;
2021-01-11 14:27:32 +00:00
}
2021-01-11 16:20:12 +00:00
uint8_t blocks_get_tex_id(uint8_t id) {
return blocks[id].tex_id;
2021-01-11 14:27:32 +00:00
}
2021-01-11 16:20:12 +00:00
char blocks_get_symbol(uint8_t id) {
return blocks[id].symbol;
2021-01-11 14:27:32 +00:00
}
2021-01-11 14:42:36 +00:00
uint32_t blocks_get_flags(uint8_t id) {
2021-01-11 16:20:12 +00:00
return blocks[id].flags;
2021-01-11 14:27:32 +00:00
}
2021-01-11 17:15:11 +00:00
uint32_t blocks_get_biome(uint8_t id) {
return blocks[id].biome;
}
uint32_t blocks_get_kind(uint8_t id) {
return blocks[id].kind;
}