CavEX/source/network/server_local.h

63 lines
1.8 KiB
C
Raw Permalink Normal View History

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
#include <m-lib/m-string.h>
2022-11-22 15:39:32 -05:00
#include <stdbool.h>
#include <stddef.h>
2023-05-02 18:01:32 -04:00
#include "../item/inventory.h"
2022-11-22 15:39:32 -05:00
#include "../world.h"
#include "level_archive.h"
2023-02-07 15:51:56 -05:00
#include "server_world.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 {
2023-11-13 17:19:11 -05:00
struct random_gen rand_src;
2022-11-22 15:39:32 -05:00
struct {
double x, y, z;
float rx, ry;
2023-02-05 10:17:28 -05:00
enum world_dim dimension;
2022-12-01 16:07:08 -05:00
bool has_pos;
bool finished_loading;
2023-05-02 18:01:32 -04:00
struct inventory inventory;
struct inventory* active_inventory;
2022-11-22 15:39:32 -05:00
} player;
2023-02-07 15:51:56 -05:00
struct server_world world;
2023-10-27 17:08:52 -04:00
dict_entity_t entities;
2022-12-19 18:09:57 -05:00
uint64_t world_time;
string_t level_name;
struct level_archive level;
2022-11-22 15:39:32 -05:00
};
void server_local_create(struct server_local* s);
struct entity* server_local_spawn_item(vec3 pos, struct item_data* it,
bool throw, struct server_local* s);
2023-11-20 12:59:53 -05:00
void server_local_spawn_block_drops(struct server_local* s,
struct block_info* blk_info);
void server_local_send_inv_changes(set_inv_slot_t changes,
struct inventory* inv, uint8_t window);
2022-11-22 15:39:32 -05:00
#endif