2019-03-07 17:43:05 -08:00
|
|
|
//
|
2020-05-12 17:16:11 -07:00
|
|
|
// World subclass for the server.
|
|
|
|
// Handles blocks, entities, and clients.
|
2019-03-07 17:43:05 -08:00
|
|
|
// Created by aurailus on 05/03/19.
|
|
|
|
//
|
|
|
|
|
2019-08-24 17:39:35 -07:00
|
|
|
#pragma once
|
2019-03-07 17:43:05 -08:00
|
|
|
|
2020-08-13 00:55:18 -07:00
|
|
|
#include "world/World.h"
|
2020-03-25 18:27:05 -07:00
|
|
|
|
2020-08-13 00:55:18 -07:00
|
|
|
#include "world/dim/ServerDimension.h"
|
2019-04-08 19:18:03 -07:00
|
|
|
|
2020-07-28 14:11:11 -07:00
|
|
|
class Target;
|
|
|
|
class ItemStack;
|
2020-07-30 22:07:00 -07:00
|
|
|
class ServerPlayer;
|
2021-07-07 15:39:04 -07:00
|
|
|
class ServerClients;
|
2020-07-28 14:11:11 -07:00
|
|
|
class ServerSubgame;
|
2020-06-24 16:35:01 -07:00
|
|
|
class ServerGenStream;
|
2021-07-07 15:39:04 -07:00
|
|
|
class ServerInventoryRefs;
|
2020-07-16 19:38:25 -07:00
|
|
|
class ServerPacketStream;
|
2020-06-24 16:35:01 -07:00
|
|
|
|
2020-01-09 21:04:31 -08:00
|
|
|
class ServerWorld : public World {
|
2021-06-21 22:09:35 -07:00
|
|
|
public:
|
2020-11-08 22:57:34 -08:00
|
|
|
explicit ServerWorld(unsigned int seed, SubgamePtr game, ServerClients& clients);
|
|
|
|
|
|
|
|
void init(const std::string& worldDir);
|
|
|
|
|
|
|
|
void update(double delta) override;
|
|
|
|
|
2020-12-03 16:26:57 -08:00
|
|
|
virtual void sendMessage(const std::string& channel, const std::string& message) override;
|
|
|
|
|
2020-11-08 22:57:34 -08:00
|
|
|
virtual DimensionPtr
|
|
|
|
createDimension(const std::string& identifier, std::unordered_set<std::string>& biomes) override;
|
|
|
|
|
|
|
|
virtual DimensionPtr getDimension(unsigned int index) override;
|
|
|
|
|
|
|
|
virtual DimensionPtr getDimension(const std::string& identifier) override;
|
|
|
|
|
|
|
|
virtual InventoryRefsPtr getRefs() override;
|
|
|
|
|
|
|
|
virtual ServerClients& getClients();
|
|
|
|
|
2021-06-21 22:09:35 -07:00
|
|
|
private:
|
2020-11-08 22:57:34 -08:00
|
|
|
void changedMapBlocks(ServerPlayer& player);
|
|
|
|
|
|
|
|
bool generateMapBlock(unsigned int dim, glm::ivec3 pos);
|
|
|
|
|
|
|
|
void generateMapBlocks(ServerPlayer& player);
|
|
|
|
|
|
|
|
void sendChunksToPlayer(ServerPlayer& client);
|
|
|
|
|
|
|
|
std::shared_ptr<ServerGenStream> genStream = nullptr;
|
|
|
|
std::shared_ptr<ServerPacketStream> packetStream = nullptr;
|
|
|
|
|
2021-06-21 22:09:35 -07:00
|
|
|
u32 seed;
|
2020-11-08 22:57:34 -08:00
|
|
|
ServerClients& clients;
|
|
|
|
std::shared_ptr<ServerInventoryRefs> refs;
|
2020-07-30 22:07:00 -07:00
|
|
|
|
|
|
|
// std::string worldDir;
|
|
|
|
// std::shared_ptr<FileManipulator> fileManip;
|
2020-11-08 22:57:34 -08:00
|
|
|
|
2021-06-21 22:09:35 -07:00
|
|
|
u32 generatedMapBlocks = 0;
|
|
|
|
std::vector<ivec3> generateOrder;
|
2020-11-08 22:57:34 -08:00
|
|
|
|
2021-06-21 22:09:35 -07:00
|
|
|
const ivec2 mapBlockGenRange = { 4, 4 };
|
|
|
|
const ivec2 sendRange = { 4, 4 };
|
|
|
|
const ivec2 activeChunkRange = { 16, 16 };
|
2019-03-07 17:43:05 -08:00
|
|
|
};
|
|
|
|
|