Add files via upload
This commit is contained in:
parent
cfacf6f1eb
commit
549b392871
@ -7,7 +7,6 @@ struct voxel;
|
||||
class Content;
|
||||
|
||||
class WorldGenerator {
|
||||
protected:
|
||||
blockid_t const idStone;
|
||||
blockid_t const idDirt;
|
||||
blockid_t const idGrassBlock;
|
||||
@ -20,7 +19,7 @@ protected:
|
||||
blockid_t const idBazalt;
|
||||
public:
|
||||
WorldGenerator(const Content* content);
|
||||
virtual void generate(voxel* voxels, int x, int z, int seed);
|
||||
void generate(voxel* voxels, int x, int z, int seed);
|
||||
};
|
||||
|
||||
#endif /* VOXELS_WORLDGENERATOR_H_ */
|
||||
#endif /* VOXELS_WORLDGENERATOR_H_ */
|
||||
|
||||
@ -318,6 +318,10 @@ const char* Window::getClipboardText() {
|
||||
return glfwGetClipboardString(window);
|
||||
}
|
||||
|
||||
void Window::setClipboardText(const char* text) {
|
||||
glfwSetClipboardString(window, text);
|
||||
}
|
||||
|
||||
bool Window::tryToMaximize(GLFWwindow* window, GLFWmonitor* monitor) {
|
||||
glm::ivec4 windowFrame(0);
|
||||
glm::ivec4 workArea(0);
|
||||
|
||||
@ -55,6 +55,7 @@ public:
|
||||
static void setBgColor(glm::vec4 color);
|
||||
static double time();
|
||||
static const char* getClipboardText();
|
||||
static void setClipboardText(const char* text);
|
||||
static DisplaySettings* getSettings();
|
||||
|
||||
static void setBlendMode(blendmode mode);
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
|
||||
#include "Level.h"
|
||||
#include "../files/WorldFiles.h"
|
||||
#include "../world/WorldTypes.h"
|
||||
#include "../content/Content.h"
|
||||
#include "../content/ContentLUT.h"
|
||||
#include "../voxels/Chunk.h"
|
||||
@ -35,23 +34,6 @@ World::World(
|
||||
wfile = new WorldFiles(directory, settings.debug);
|
||||
}
|
||||
|
||||
World::World(
|
||||
std::string name,
|
||||
std::string type,
|
||||
fs::path directory,
|
||||
uint64_t seed,
|
||||
EngineSettings& settings,
|
||||
const Content* content,
|
||||
const std::vector<ContentPack> packs)
|
||||
: name(name),
|
||||
type(type),
|
||||
seed(seed),
|
||||
settings(settings),
|
||||
content(content),
|
||||
packs(packs) {
|
||||
wfile = new WorldFiles(directory, settings.debug);
|
||||
}
|
||||
|
||||
World::~World(){
|
||||
delete wfile;
|
||||
}
|
||||
@ -83,13 +65,12 @@ void World::write(Level* level) {
|
||||
}
|
||||
|
||||
Level* World::create(std::string name,
|
||||
std::string type,
|
||||
fs::path directory,
|
||||
uint64_t seed,
|
||||
EngineSettings& settings,
|
||||
const Content* content,
|
||||
const std::vector<ContentPack>& packs) {
|
||||
auto world = new World(name, type, directory, seed, settings, content, packs);
|
||||
auto world = new World(name, directory, seed, settings, content, packs);
|
||||
auto level = new Level(world, content, settings);
|
||||
auto inventory = level->player->getInventory();
|
||||
inventory->setId(world->getNextInventoryId());
|
||||
@ -150,57 +131,47 @@ uint64_t World::getSeed() const {
|
||||
return seed;
|
||||
}
|
||||
|
||||
std::string World::getType() const {
|
||||
return type;
|
||||
}
|
||||
|
||||
const std::vector<ContentPack>& World::getPacks() const {
|
||||
return packs;
|
||||
}
|
||||
|
||||
void World::deserialize(dynamic::Map* root) {
|
||||
name = root->getStr("name", name);
|
||||
type = root->getStr("type", type);
|
||||
seed = root->getInt("seed", seed);
|
||||
|
||||
if(type == "") {
|
||||
type = WorldTypes::getDefaultWorldType();
|
||||
}
|
||||
auto verobj = root->map("version");
|
||||
if (verobj) {
|
||||
int major=0, minor=-1;
|
||||
verobj->num("major", major);
|
||||
verobj->num("minor", minor);
|
||||
std::cout << "world version: " << major << "." << minor << std::endl;
|
||||
}
|
||||
|
||||
auto verobj = root->map("version");
|
||||
if (verobj) {
|
||||
int major=0, minor=-1;
|
||||
verobj->num("major", major);
|
||||
verobj->num("minor", minor);
|
||||
std::cout << "world version: " << major << "." << minor << std::endl;
|
||||
}
|
||||
|
||||
auto timeobj = root->map("time");
|
||||
if (timeobj) {
|
||||
timeobj->num("day-time", daytime);
|
||||
timeobj->num("day-time-speed", daytimeSpeed);
|
||||
auto timeobj = root->map("time");
|
||||
if (timeobj) {
|
||||
timeobj->num("day-time", daytime);
|
||||
timeobj->num("day-time-speed", daytimeSpeed);
|
||||
timeobj->num("total-time", totalTime);
|
||||
}
|
||||
}
|
||||
|
||||
nextInventoryId = root->getNum("next-inventory-id", 2);
|
||||
}
|
||||
|
||||
std::unique_ptr<dynamic::Map> World::serialize() const {
|
||||
auto root = std::make_unique<dynamic::Map>();
|
||||
auto root = std::make_unique<dynamic::Map>();
|
||||
|
||||
auto& versionobj = root->putMap("version");
|
||||
versionobj.put("major", ENGINE_VERSION_MAJOR);
|
||||
versionobj.put("minor", ENGINE_VERSION_MINOR);
|
||||
auto& versionobj = root->putMap("version");
|
||||
versionobj.put("major", ENGINE_VERSION_MAJOR);
|
||||
versionobj.put("minor", ENGINE_VERSION_MINOR);
|
||||
|
||||
root->put("name", name);
|
||||
root->put("type", type);
|
||||
root->put("seed", seed);
|
||||
|
||||
root->put("name", name);
|
||||
root->put("seed", seed);
|
||||
|
||||
auto& timeobj = root->putMap("time");
|
||||
timeobj.put("day-time", daytime);
|
||||
timeobj.put("day-time-speed", daytimeSpeed);
|
||||
timeobj.put("day-time", daytime);
|
||||
timeobj.put("day-time-speed", daytimeSpeed);
|
||||
timeobj.put("total-time", totalTime);
|
||||
|
||||
root->put("next-inventory-id", nextInventoryId);
|
||||
return root;
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,7 +28,6 @@ public:
|
||||
|
||||
class World : public Serializable {
|
||||
std::string name;
|
||||
std::string type;
|
||||
uint64_t seed;
|
||||
EngineSettings& settings;
|
||||
const Content* const content;
|
||||
@ -53,15 +52,6 @@ public:
|
||||
EngineSettings& settings,
|
||||
const Content* content,
|
||||
std::vector<ContentPack> packs);
|
||||
|
||||
World(std::string name,
|
||||
std::string type,
|
||||
fs::path directory,
|
||||
uint64_t seed,
|
||||
EngineSettings& settings,
|
||||
const Content* content,
|
||||
std::vector<ContentPack> packs);
|
||||
|
||||
~World();
|
||||
|
||||
/**
|
||||
@ -87,7 +77,6 @@ public:
|
||||
* Create new world
|
||||
* @param name internal world name
|
||||
* @param directory root world directory
|
||||
* @param type of the world
|
||||
* @param seed world generation seed
|
||||
* @param settings current engine settings
|
||||
* @param content current engine Content instance
|
||||
@ -96,7 +85,6 @@ public:
|
||||
* @return Level instance containing World instance
|
||||
*/
|
||||
static Level* create(std::string name,
|
||||
std::string type,
|
||||
fs::path directory,
|
||||
uint64_t seed,
|
||||
EngineSettings& settings,
|
||||
@ -136,8 +124,6 @@ public:
|
||||
/** Get world generation seed */
|
||||
uint64_t getSeed() const;
|
||||
|
||||
/** Get world type */
|
||||
std::string getType() const;
|
||||
/**
|
||||
* Get vector of all content-packs installed in world
|
||||
*/
|
||||
@ -162,4 +148,4 @@ public:
|
||||
void deserialize(dynamic::Map *src) override;
|
||||
};
|
||||
|
||||
#endif /* WORLD_WORLD_H_ */
|
||||
#endif /* WORLD_WORLD_H_ */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user