OpenFusion/src/ChunkManager.hpp

48 lines
1.4 KiB
C++
Raw Normal View History

2020-09-17 22:45:43 +00:00
#pragma once
#include "CNProtocol.hpp"
#include "CNStructs.hpp"
2020-09-17 22:45:43 +00:00
#include <utility>
#include <vector>
#include <set>
#include <map>
2020-10-01 01:44:37 +00:00
#include <tuple>
2020-09-17 22:45:43 +00:00
class Chunk {
public:
std::set<CNSocket*> players;
std::set<int32_t> NPCs;
};
2020-10-01 01:44:37 +00:00
enum {
INSTANCE_OVERWORLD, // default instance every player starts in
INSTANCE_IZ, // these aren't actually used
INSTANCE_UNIQUE // these aren't actually used
2020-10-01 01:44:37 +00:00
};
2020-09-17 22:45:43 +00:00
namespace ChunkManager {
void init();
void cleanup();
2020-11-16 14:59:53 +00:00
extern std::map<ChunkPos, Chunk*> chunks;
2020-09-17 22:45:43 +00:00
2020-11-16 14:59:53 +00:00
void newChunk(ChunkPos pos);
void populateNewChunk(Chunk* chunk, ChunkPos pos);
2020-10-12 16:55:41 +00:00
void addNPC(int posX, int posY, uint64_t instanceID, int32_t id);
void addPlayer(int posX, int posY, uint64_t instanceID, CNSocket* sock);
2020-11-16 14:59:53 +00:00
bool removePlayer(ChunkPos chunkPos, CNSocket* sock);
bool removeNPC(ChunkPos chunkPos, int32_t id);
bool checkChunk(ChunkPos chunk);
void destroyChunk(ChunkPos chunkPos);
ChunkPos grabChunk(int posX, int posY, uint64_t instanceID);
std::vector<Chunk*> grabChunks(ChunkPos chunkPos);
2020-09-17 22:45:43 +00:00
std::vector<Chunk*> getDeltaChunks(std::vector<Chunk*> from, std::vector<Chunk*> to);
2020-11-16 14:59:53 +00:00
std::vector<ChunkPos> getChunksInMap(uint64_t mapNum);
2020-10-12 16:55:41 +00:00
bool inPopulatedChunks(int posX, int posY, uint64_t instanceID);
void createInstance(uint64_t);
void destroyInstance(uint64_t);
2020-10-19 02:30:12 +00:00
void destroyInstanceIfEmpty(uint64_t);
2020-09-17 22:45:43 +00:00
}