CavEX/source/network/server_local.h

36 lines
807 B
C
Raw Normal View History

2022-11-22 15:39:32 -05:00
#ifndef SERVER_LOCAL
#define SERVER_LOCAL
#include <stdbool.h>
#include <stddef.h>
#include "../world.h"
#include "level_archive.h"
2022-12-01 16:07:08 -05:00
#include "region_archive.h"
2022-11-22 15:39:32 -05:00
2022-12-01 16:07:08 -05:00
#define MAX_REGIONS 4
#define MAX_VIEW_DISTANCE 5 // in chunks
2022-11-22 15:39:32 -05:00
#define MAX_CHUNKS ((MAX_VIEW_DISTANCE * 2 + 2) * (MAX_VIEW_DISTANCE * 2 + 2))
struct server_local {
struct {
double x, y, z;
2022-12-01 16:07:08 -05:00
bool has_pos;
bool finished_loading;
2022-11-22 15:39:32 -05:00
} player;
struct loaded_chunk {
w_coord_t x, z; // not!!! stored in multiples of CHUNK_SIZE
bool modified;
} loaded_chunks[MAX_CHUNKS];
size_t loaded_chunks_length;
2022-12-01 16:07:08 -05:00
struct region_archive loaded_regions[MAX_REGIONS];
2022-12-07 16:53:08 -05:00
ilist_regions_t loaded_regions_lru;
2022-12-01 16:07:08 -05:00
size_t loaded_regions_length;
ptime_t last_chunk_load;
struct level_archive level;
2022-11-22 15:39:32 -05:00
};
void server_local_create(struct server_local* s);
#endif