Began working on the lua API for the map

The basic framework is done.
This commit is contained in:
Kayne Ruse
2014-03-28 03:24:14 +11:00
parent 47684380a9
commit 38b603fc8f
15 changed files with 263 additions and 14 deletions
+19 -2
View File
@@ -21,10 +21,27 @@
*/
#include "map_file_format.hpp"
void MapFileFormat::Load(Region** const ptr, int x, int y) {
void DummyFormat::Load(Region** const ptr, int x, int y) {
//TODO
}
void MapFileFormat::Save(Region* const ptr) {
void DummyFormat::Save(Region* const ptr) {
//TODO
}
/*
void VerboseFormat::Load(Region** const ptr, int x, int y) {
//TODO
}
void VerboseFormat::Save(Region* const ptr) {
//TODO
}
void CompactFormat::Load(Region** const ptr, int x, int y) {
//TODO
}
void CompactFormat::Save(Region* const ptr) {
//TODO
}
*/
+17 -1
View File
@@ -24,7 +24,15 @@
#include "region.hpp"
class MapFileFormat {
class DummyFormat {
public:
void Load(Region** const, int x, int y);
void Save(Region* const);
private:
//
};
/*
class VerboseFormat {
public:
void Load(Region** const, int x, int y);
void Save(Region* const);
@@ -32,4 +40,12 @@ private:
//
};
class CompactFormat {
public:
void Load(Region** const, int x, int y);
void Save(Region* const);
private:
//
};
*/
#endif
+23 -2
View File
@@ -21,10 +21,31 @@
*/
#include "map_generator.hpp"
void MapGenerator::Create(Region** const ptr, int width, int height, int depth, int x, int y) {
void BlankGenerator::Create(Region** const ptr, int width, int height, int depth, int x, int y) {
(*ptr) = new Region(width, height, depth, x, y);
}
void MapGenerator::Unload(Region* const ptr) {
void BlankGenerator::Unload(Region* const ptr) {
delete ptr;
}
/*
void PerlinGenerator::Create(Region** const ptr, int width, int height, int depth, int x, int y) {
(*ptr) = new Region(width, height, depth, x, y);
}
void PerlinGenerator::Unload(Region* const ptr) {
delete ptr;
}
*/
void LuaGenerator::Create(Region** const ptr, int width, int height, int depth, int x, int y) {
(*ptr) = new Region(width, height, depth, x, y);
//generate the lua-driven maps
lua_getglobal(state, "CreateRegion");
lua_pushlightuserdata(state, ptr);
lua_pcall(state, 1, 0, 0);
}
void LuaGenerator::Unload(Region* const ptr) {
delete ptr;
}
+22 -1
View File
@@ -24,12 +24,33 @@
#include "region.hpp"
class MapGenerator {
#include "lua/lua.hpp"
class BlankGenerator {
public:
void Create(Region** const, int width, int height, int depth, int x, int y);
void Unload(Region* const);
private:
//
};
/*
class PerlinGenerator {
public:
void Create(Region** const, int width, int height, int depth, int x, int y);
void Unload(Region* const);
private:
//
};
*/
class LuaGenerator {
public:
void Create(Region** const, int width, int height, int depth, int x, int y);
void Unload(Region* const);
lua_State* SetLuaState(lua_State* L) { return state = L; }
lua_State* GetLuaState() { return state; }
private:
lua_State* state = nullptr;
};
#endif