2022-11-22 15:39:32 -05:00
|
|
|
#ifndef SERVER_LOCAL
|
|
|
|
#define SERVER_LOCAL
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
#include "../world.h"
|
2022-12-17 06:09:30 -05:00
|
|
|
#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;
|
2022-12-17 06:09:30 -05:00
|
|
|
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;
|
2022-11-30 06:07:12 -05:00
|
|
|
ptime_t last_chunk_load;
|
2022-12-17 06:09:30 -05:00
|
|
|
struct level_archive level;
|
2022-11-22 15:39:32 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
void server_local_create(struct server_local* s);
|
|
|
|
|
|
|
|
#endif
|