2022-12-17 06:30:52 -05:00
|
|
|
/*
|
|
|
|
Copyright (c) 2022 ByteBit/xtreme8000
|
|
|
|
|
|
|
|
This file is part of CavEX.
|
|
|
|
|
|
|
|
CavEX is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
CavEX is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with CavEX. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2022-11-22 15:39:32 -05:00
|
|
|
#ifndef SERVER_LOCAL
|
|
|
|
#define SERVER_LOCAL
|
|
|
|
|
2023-02-04 17:47:37 -05:00
|
|
|
#include <m-lib/m-string.h>
|
2022-11-22 15:39:32 -05:00
|
|
|
#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;
|
2023-02-05 10:17:28 -05:00
|
|
|
enum world_dim dimension;
|
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-12-19 18:09:57 -05:00
|
|
|
uint64_t world_time;
|
|
|
|
ptime_t world_time_start;
|
2023-02-04 17:47:37 -05:00
|
|
|
string_t level_name;
|
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
|