Merge branch 'mapgen' into develop
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
#config
|
||||||
|
INCLUDES+=.
|
||||||
|
LIBS+=
|
||||||
|
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||||
|
|
||||||
|
#source
|
||||||
|
CXXSRC=$(wildcard *.cpp)
|
||||||
|
|
||||||
|
#objects
|
||||||
|
OBJDIR=obj
|
||||||
|
OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o))
|
||||||
|
|
||||||
|
#output
|
||||||
|
OUTDIR=..
|
||||||
|
OUT=$(addprefix $(OUTDIR)/,server.a)
|
||||||
|
|
||||||
|
#targets
|
||||||
|
all: $(OBJ) $(OUT)
|
||||||
|
ar -crs $(OUT) $(OBJ)
|
||||||
|
|
||||||
|
$(OBJ): | $(OBJDIR)
|
||||||
|
|
||||||
|
$(OUT): | $(OUTDIR)
|
||||||
|
|
||||||
|
$(OBJDIR):
|
||||||
|
mkdir $(OBJDIR)
|
||||||
|
|
||||||
|
$(OUTDIR):
|
||||||
|
mkdir $(OUTDIR)
|
||||||
|
|
||||||
|
$(OBJDIR)/%.o: %.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#config
|
||||||
|
INCLUDES+=. ../../common/gameplay ../../common/utilities
|
||||||
|
LIBS+=
|
||||||
|
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||||
|
|
||||||
|
#source
|
||||||
|
CXXSRC=$(wildcard *.cpp)
|
||||||
|
|
||||||
|
#objects
|
||||||
|
OBJDIR=obj
|
||||||
|
OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o))
|
||||||
|
|
||||||
|
#output
|
||||||
|
OUTDIR=..
|
||||||
|
OUT=$(addprefix $(OUTDIR)/,server.a)
|
||||||
|
|
||||||
|
#targets
|
||||||
|
all: $(OBJ) $(OUT)
|
||||||
|
ar -crs $(OUT) $(OBJ)
|
||||||
|
|
||||||
|
$(OBJ): | $(OBJDIR)
|
||||||
|
|
||||||
|
$(OUT): | $(OUTDIR)
|
||||||
|
|
||||||
|
$(OBJDIR):
|
||||||
|
mkdir $(OBJDIR)
|
||||||
|
|
||||||
|
$(OUTDIR):
|
||||||
|
mkdir $(OUTDIR)
|
||||||
|
|
||||||
|
$(OBJDIR)/%.o: %.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#config
|
||||||
|
INCLUDES+=. ../../common/gameplay ../../common/utilities
|
||||||
|
LIBS+=
|
||||||
|
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||||
|
|
||||||
|
#source
|
||||||
|
CXXSRC=$(wildcard *.cpp)
|
||||||
|
|
||||||
|
#objects
|
||||||
|
OBJDIR=obj
|
||||||
|
OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o))
|
||||||
|
|
||||||
|
#output
|
||||||
|
OUTDIR=..
|
||||||
|
OUT=$(addprefix $(OUTDIR)/,server.a)
|
||||||
|
|
||||||
|
#targets
|
||||||
|
all: $(OBJ) $(OUT)
|
||||||
|
ar -crs $(OUT) $(OBJ)
|
||||||
|
|
||||||
|
$(OBJ): | $(OBJDIR)
|
||||||
|
|
||||||
|
$(OUT): | $(OUTDIR)
|
||||||
|
|
||||||
|
$(OBJDIR):
|
||||||
|
mkdir $(OBJDIR)
|
||||||
|
|
||||||
|
$(OUTDIR):
|
||||||
|
mkdir $(OUTDIR)
|
||||||
|
|
||||||
|
$(OBJDIR)/%.o: %.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
#define ENEMYFACTORYINTERFACE_HPP_
|
#define ENEMYFACTORYINTERFACE_HPP_
|
||||||
|
|
||||||
#include "enemy_data.hpp"
|
#include "enemy_data.hpp"
|
||||||
#include "room_data.hpp"
|
#include "map_type.hpp"
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
@@ -36,13 +36,14 @@ public:
|
|||||||
virtual void Generate(std::list<EnemyData>* container) = 0;
|
virtual void Generate(std::list<EnemyData>* container) = 0;
|
||||||
|
|
||||||
//control the difficulty of the room
|
//control the difficulty of the room
|
||||||
RoomData::RoomType SetType(RoomData::RoomType t) { return type = t; }
|
MapType SetType(MapType t) { return type = t; }
|
||||||
|
MapType GetType() { return type; }
|
||||||
|
|
||||||
int SetDifficulty(int d) { return difficulty = d; }
|
int SetDifficulty(int d) { return difficulty = d; }
|
||||||
RoomData::RoomType GetType() { return type; }
|
|
||||||
int GetDifficulty() { return difficulty; }
|
int GetDifficulty() { return difficulty; }
|
||||||
protected:
|
protected:
|
||||||
RoomData::RoomType type;
|
MapType type;
|
||||||
int difficulty;
|
int difficulty = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#config
|
||||||
|
INCLUDES+=. ../mapgen ../../common/gameplay ../../common/map ../../common/utilities
|
||||||
|
LIBS+=
|
||||||
|
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||||
|
|
||||||
|
#source
|
||||||
|
CXXSRC=$(wildcard *.cpp)
|
||||||
|
|
||||||
|
#objects
|
||||||
|
OBJDIR=obj
|
||||||
|
OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o))
|
||||||
|
|
||||||
|
#output
|
||||||
|
OUTDIR=..
|
||||||
|
OUT=$(addprefix $(OUTDIR)/,server.a)
|
||||||
|
|
||||||
|
#targets
|
||||||
|
all: $(OBJ) $(OUT)
|
||||||
|
ar -crs $(OUT) $(OBJ)
|
||||||
|
|
||||||
|
$(OBJ): | $(OBJDIR)
|
||||||
|
|
||||||
|
$(OUT): | $(OUTDIR)
|
||||||
|
|
||||||
|
$(OBJDIR):
|
||||||
|
mkdir $(OBJDIR)
|
||||||
|
|
||||||
|
$(OUTDIR):
|
||||||
|
mkdir $(OUTDIR)
|
||||||
|
|
||||||
|
$(OBJDIR)/%.o: %.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
@@ -38,6 +38,9 @@
|
|||||||
|
|
||||||
#include "region_api.hpp"
|
#include "region_api.hpp"
|
||||||
#include "pager_api.hpp"
|
#include "pager_api.hpp"
|
||||||
|
#include "room_api.hpp"
|
||||||
|
#include "room_mgr_api.hpp"
|
||||||
|
#include "generator_api.hpp"
|
||||||
|
|
||||||
//these libs are loaded by lua.c and are readily available to any Lua program
|
//these libs are loaded by lua.c and are readily available to any Lua program
|
||||||
static const luaL_Reg loadedlibs[] = {
|
static const luaL_Reg loadedlibs[] = {
|
||||||
@@ -56,6 +59,9 @@ static const luaL_Reg loadedlibs[] = {
|
|||||||
//custom libs
|
//custom libs
|
||||||
{LUA_REGIONLIBNAME, luaopen_regionapi},
|
{LUA_REGIONLIBNAME, luaopen_regionapi},
|
||||||
{LUA_PAGERLIBNAME, luaopen_pagerapi},
|
{LUA_PAGERLIBNAME, luaopen_pagerapi},
|
||||||
|
{LUA_ROOMLIBNAME, luaopen_roomapi},
|
||||||
|
{LUA_ROOMMGRLIBNAME, luaopen_roommgrapi},
|
||||||
|
{LUA_GENERATORLIBNAME, luaopen_generatorapi},
|
||||||
|
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|||||||
+8
-2
@@ -1,6 +1,6 @@
|
|||||||
#config
|
#config
|
||||||
INCLUDES+=. ../common/gameplay ../common/map ../common/network ../common/network/packet ../common/network/serial ../common/utilities
|
INCLUDES+=. accounts characters combat enemies mapgen mapgen/generators rooms ../common/gameplay ../common/map ../common/network ../common/network/packet ../common/network/serial ../common/utilities
|
||||||
LIBS+=../libcommon.a -lSDL_net -lwsock32 -liphlpapi -lmingw32 -lSDLmain -lSDL -llua -lsqlite3
|
LIBS+=server.a ../libcommon.a -lSDL_net -lwsock32 -liphlpapi -lmingw32 -lSDLmain -lSDL -llua -lsqlite3
|
||||||
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||||
|
|
||||||
#source
|
#source
|
||||||
@@ -16,6 +16,12 @@ OUT=$(addprefix $(OUTDIR)/,server)
|
|||||||
|
|
||||||
#targets
|
#targets
|
||||||
all: $(OBJ) $(OUT)
|
all: $(OBJ) $(OUT)
|
||||||
|
$(MAKE) -C accounts
|
||||||
|
$(MAKE) -C characters
|
||||||
|
$(MAKE) -C combat
|
||||||
|
$(MAKE) -C enemies
|
||||||
|
$(MAKE) -C mapgen
|
||||||
|
$(MAKE) -C rooms
|
||||||
$(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS)
|
$(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS)
|
||||||
|
|
||||||
$(OBJ): | $(OBJDIR)
|
$(OBJ): | $(OBJDIR)
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#include "generator_api.hpp"
|
||||||
|
|
||||||
|
static int getGenerator(lua_State* L) {
|
||||||
|
//TODO: return a generator based on the given parameter
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const luaL_Reg generatorlib[] = {
|
||||||
|
{"getgenerator", getGenerator},
|
||||||
|
{nullptr, nullptr}
|
||||||
|
};
|
||||||
|
|
||||||
|
LUAMOD_API int luaopen_generatorapi(lua_State* L) {
|
||||||
|
luaL_newlib(L, generatorlib);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#ifndef GENERATORAPI_HPP_
|
||||||
|
#define GENERATORAPI_HPP_
|
||||||
|
|
||||||
|
#include "lua/lua.hpp"
|
||||||
|
|
||||||
|
#define LUA_GENERATORLIBNAME "generator"
|
||||||
|
LUAMOD_API int luaopen_generatorapi(lua_State* L);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#include "base_generator.hpp"
|
||||||
|
|
||||||
|
BaseGenerator::BaseGenerator() {
|
||||||
|
for (int i = 0; i < MAP_WIDTH; i++) {
|
||||||
|
for (int j = 0; j < MAP_HEIGHT; j++) {
|
||||||
|
chunks[i][j].type = TerrainType::NONE;
|
||||||
|
chunks[i][j].mod = ChunkData::Moddable::CLEAR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseGenerator::~BaseGenerator() {
|
||||||
|
//
|
||||||
|
}
|
||||||
@@ -19,33 +19,29 @@
|
|||||||
* 3. This notice may not be removed or altered from any source
|
* 3. This notice may not be removed or altered from any source
|
||||||
* distribution.
|
* distribution.
|
||||||
*/
|
*/
|
||||||
#ifndef OVERWORLDGENERATOR_HPP_
|
#ifndef BASEGENERATOR_HPP_
|
||||||
#define OVERWORLDGENERATOR_HPP_
|
#define BASEGENERATOR_HPP_
|
||||||
|
|
||||||
#include "chunk_data.hpp"
|
#include "chunk_data.hpp"
|
||||||
|
|
||||||
#include "lua/lua.hpp"
|
#include "lua/lua.hpp"
|
||||||
|
|
||||||
#define OVERWORLD_GENERATOR_PSEUDOINDEX "OverworldGenerator"
|
constexpr int MAP_WIDTH = 256;
|
||||||
|
constexpr int MAP_HEIGHT = 256;
|
||||||
|
|
||||||
constexpr int OVERWORLD_WIDTH = 256;
|
class BaseGenerator {
|
||||||
constexpr int OVERWORLD_HEIGHT = 256;
|
|
||||||
|
|
||||||
//TODO: SuperGenerator API
|
|
||||||
//TODO: SuperGenerator DOCS
|
|
||||||
class OverworldGenerator {
|
|
||||||
public:
|
public:
|
||||||
OverworldGenerator();
|
BaseGenerator();
|
||||||
~OverworldGenerator();
|
virtual ~BaseGenerator();
|
||||||
|
|
||||||
//accessors and mutators
|
//accessors and mutators
|
||||||
ChunkData* GetChunk(int x, int y) { return &chunks[x][y]; }
|
virtual ChunkData* GetChunk(int x, int y) { return &chunks[x][y]; }
|
||||||
|
|
||||||
lua_State* SetLuaState(lua_State* L) { return luaState = L; }
|
lua_State* SetLuaState(lua_State* L) { return luaState = L; }
|
||||||
lua_State* GetLuaState() { return luaState; }
|
lua_State* GetLuaState() { return luaState; }
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
ChunkData chunks[OVERWORLD_WIDTH][OVERWORLD_HEIGHT];
|
ChunkData chunks[MAP_WIDTH][MAP_HEIGHT];
|
||||||
lua_State* luaState = nullptr;
|
lua_State* luaState = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#include "caves_generator.hpp"
|
||||||
|
|
||||||
|
CavesGenerator::CavesGenerator() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
CavesGenerator::~CavesGenerator() {
|
||||||
|
//
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#ifndef CAVESGENERATOR_HPP_
|
||||||
|
#define CAVESGENERATOR_HPP_
|
||||||
|
|
||||||
|
#include "base_generator.hpp"
|
||||||
|
|
||||||
|
#define CAVES_GENERATOR_PSEUDOINDEX "CavesGenerator"
|
||||||
|
|
||||||
|
class CavesGenerator : public BaseGenerator {
|
||||||
|
public:
|
||||||
|
CavesGenerator();
|
||||||
|
~CavesGenerator();
|
||||||
|
|
||||||
|
private:
|
||||||
|
//
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#include "forests_generator.hpp"
|
||||||
|
|
||||||
|
ForestsGenerator::ForestsGenerator() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
ForestsGenerator::~ForestsGenerator() {
|
||||||
|
//
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#ifndef FORESTSGENERATOR_HPP_
|
||||||
|
#define FORESTSGENERATOR_HPP_
|
||||||
|
|
||||||
|
#include "base_generator.hpp"
|
||||||
|
|
||||||
|
#define FORESTS_GENERATOR_PSEUDOINDEX "ForestsGenerator"
|
||||||
|
|
||||||
|
class ForestsGenerator : public BaseGenerator {
|
||||||
|
public:
|
||||||
|
ForestsGenerator();
|
||||||
|
~ForestsGenerator();
|
||||||
|
|
||||||
|
private:
|
||||||
|
//
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#config
|
||||||
|
INCLUDES+=. ..
|
||||||
|
LIBS+=
|
||||||
|
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||||
|
|
||||||
|
#source
|
||||||
|
CXXSRC=$(wildcard *.cpp)
|
||||||
|
|
||||||
|
#objects
|
||||||
|
OBJDIR=obj
|
||||||
|
OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o))
|
||||||
|
|
||||||
|
#output
|
||||||
|
OUTDIR=../..
|
||||||
|
OUT=$(addprefix $(OUTDIR)/,server.a)
|
||||||
|
|
||||||
|
#targets
|
||||||
|
all: $(OBJ) $(OUT)
|
||||||
|
ar -crs $(OUT) $(OBJ)
|
||||||
|
|
||||||
|
$(OBJ): | $(OBJDIR)
|
||||||
|
|
||||||
|
$(OUT): | $(OUTDIR)
|
||||||
|
|
||||||
|
$(OBJDIR):
|
||||||
|
mkdir $(OBJDIR)
|
||||||
|
|
||||||
|
$(OUTDIR):
|
||||||
|
mkdir $(OUTDIR)
|
||||||
|
|
||||||
|
$(OBJDIR)/%.o: %.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
@@ -22,12 +22,7 @@
|
|||||||
#include "overworld_generator.hpp"
|
#include "overworld_generator.hpp"
|
||||||
|
|
||||||
OverworldGenerator::OverworldGenerator() {
|
OverworldGenerator::OverworldGenerator() {
|
||||||
for (int i = 0; i < OVERWORLD_WIDTH; i++) {
|
//
|
||||||
for (int j = 0; j < OVERWORLD_HEIGHT; j++) {
|
|
||||||
chunks[i][j].type = TerrainType::NONE;
|
|
||||||
chunks[i][j].mod = ChunkData::Moddable::CLEAR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OverworldGenerator::~OverworldGenerator() {
|
OverworldGenerator::~OverworldGenerator() {
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#ifndef OVERWORLDGENERATOR_HPP_
|
||||||
|
#define OVERWORLDGENERATOR_HPP_
|
||||||
|
|
||||||
|
#include "base_generator.hpp"
|
||||||
|
|
||||||
|
#define OVERWORLD_GENERATOR_PSEUDOINDEX "OverworldGenerator"
|
||||||
|
|
||||||
|
class OverworldGenerator : public BaseGenerator {
|
||||||
|
public:
|
||||||
|
OverworldGenerator();
|
||||||
|
~OverworldGenerator();
|
||||||
|
|
||||||
|
private:
|
||||||
|
//
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#include "ruins_generator.hpp"
|
||||||
|
|
||||||
|
RuinsGenerator::RuinsGenerator() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
RuinsGenerator::~RuinsGenerator() {
|
||||||
|
//
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#ifndef RUINSGENERATOR_HPP_
|
||||||
|
#define RUINSGENERATOR_HPP_
|
||||||
|
|
||||||
|
#include "base_generator.hpp"
|
||||||
|
|
||||||
|
#define RUINS_GENERATOR_PSEUDOINDEX "RuinsGenerator"
|
||||||
|
|
||||||
|
class RuinsGenerator : public BaseGenerator {
|
||||||
|
public:
|
||||||
|
RuinsGenerator();
|
||||||
|
~RuinsGenerator();
|
||||||
|
|
||||||
|
private:
|
||||||
|
//
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#include "towers_generator.hpp"
|
||||||
|
|
||||||
|
TowersGenerator::TowersGenerator() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
TowersGenerator::~TowersGenerator() {
|
||||||
|
//
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#ifndef TOWERSGENERATOR_HPP_
|
||||||
|
#define TOWERSGENERATOR_HPP_
|
||||||
|
|
||||||
|
#include "base_generator.hpp"
|
||||||
|
|
||||||
|
#define TOWERS_GENERATOR_PSEUDOINDEX "TowersGenerator"
|
||||||
|
|
||||||
|
class TowersGenerator : public BaseGenerator {
|
||||||
|
public:
|
||||||
|
TowersGenerator();
|
||||||
|
~TowersGenerator();
|
||||||
|
|
||||||
|
private:
|
||||||
|
//
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#config
|
||||||
|
INCLUDES+=.
|
||||||
|
LIBS+=
|
||||||
|
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||||
|
|
||||||
|
#source
|
||||||
|
CXXSRC=$(wildcard *.cpp)
|
||||||
|
|
||||||
|
#objects
|
||||||
|
OBJDIR=obj
|
||||||
|
OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o))
|
||||||
|
|
||||||
|
#output
|
||||||
|
OUTDIR=..
|
||||||
|
OUT=$(addprefix $(OUTDIR)/,server.a)
|
||||||
|
|
||||||
|
#targets
|
||||||
|
all: $(OBJ) $(OUT)
|
||||||
|
ar -crs $(OUT) $(OBJ)
|
||||||
|
$(MAKE) -C generators
|
||||||
|
|
||||||
|
$(OBJ): | $(OBJDIR)
|
||||||
|
|
||||||
|
$(OUT): | $(OUTDIR)
|
||||||
|
|
||||||
|
$(OBJDIR):
|
||||||
|
mkdir $(OBJDIR)
|
||||||
|
|
||||||
|
$(OUTDIR):
|
||||||
|
mkdir $(OUTDIR)
|
||||||
|
|
||||||
|
$(OBJDIR)/%.o: %.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#ifndef MAPTYPE_HPP_
|
||||||
|
#define MAPTYPE_HPP_
|
||||||
|
|
||||||
|
enum class MapType {
|
||||||
|
OVERWORLD = 0,
|
||||||
|
RUINS = 1,
|
||||||
|
TOWERS = 2,
|
||||||
|
FORESTS = 3,
|
||||||
|
CAVES = 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#config
|
||||||
|
INCLUDES+=. ../mapgen ../mapgen/generators ../../common/map
|
||||||
|
LIBS+=
|
||||||
|
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||||
|
|
||||||
|
#source
|
||||||
|
CXXSRC=$(wildcard *.cpp)
|
||||||
|
|
||||||
|
#objects
|
||||||
|
OBJDIR=obj
|
||||||
|
OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o))
|
||||||
|
|
||||||
|
#output
|
||||||
|
OUTDIR=..
|
||||||
|
OUT=$(addprefix $(OUTDIR)/,server.a)
|
||||||
|
|
||||||
|
#targets
|
||||||
|
all: $(OBJ) $(OUT)
|
||||||
|
ar -crs $(OUT) $(OBJ)
|
||||||
|
|
||||||
|
$(OBJ): | $(OBJDIR)
|
||||||
|
|
||||||
|
$(OUT): | $(OUTDIR)
|
||||||
|
|
||||||
|
$(OBJDIR):
|
||||||
|
mkdir $(OBJDIR)
|
||||||
|
|
||||||
|
$(OUTDIR):
|
||||||
|
mkdir $(OUTDIR)
|
||||||
|
|
||||||
|
$(OBJDIR)/%.o: %.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
@@ -38,22 +38,11 @@ static int getRegionPager(lua_State* L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//RoomManager only
|
//TODO: generators
|
||||||
static int getRoom(lua_State* L) {
|
|
||||||
//get the room manager
|
|
||||||
lua_pushstring(L, ROOM_MANAGER_PSEUDOINDEX);
|
|
||||||
lua_gettable(L, LUA_REGISTRYINDEX);
|
|
||||||
RoomManager* roomMgr = reinterpret_cast<RoomManager*>(lua_touserdata(L, -1));
|
|
||||||
|
|
||||||
//push the room and return it
|
|
||||||
lua_pushlightuserdata(L, reinterpret_cast<void*>( roomMgr->GetRoom(lua_tointeger(L, -2)) ));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const luaL_Reg roomlib[] = {
|
static const luaL_Reg roomlib[] = {
|
||||||
{"gettype",getType},
|
{"gettype",getType},
|
||||||
{"getregionpager",getRegionPager},
|
{"getregionpager",getRegionPager},
|
||||||
{"getroom",getRoom},
|
|
||||||
{nullptr, nullptr}
|
{nullptr, nullptr}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -23,20 +23,15 @@
|
|||||||
#define ROOMDATA_HPP_
|
#define ROOMDATA_HPP_
|
||||||
|
|
||||||
//map system
|
//map system
|
||||||
|
#include "map_type.hpp"
|
||||||
#include "region_pager_lua.hpp"
|
#include "region_pager_lua.hpp"
|
||||||
|
#include "base_generator.hpp"
|
||||||
|
|
||||||
struct RoomData {
|
struct RoomData {
|
||||||
enum class RoomType {
|
|
||||||
OVERWORLD = 0,
|
|
||||||
RUINS = 1,
|
|
||||||
TOWERS = 2,
|
|
||||||
FORESTS = 3,
|
|
||||||
CAVE = 4,
|
|
||||||
};
|
|
||||||
|
|
||||||
//members
|
//members
|
||||||
|
MapType type;
|
||||||
RegionPagerLua pager;
|
RegionPagerLua pager;
|
||||||
RoomType type;
|
BaseGenerator* generator = nullptr;
|
||||||
|
|
||||||
//TODO: collision map
|
//TODO: collision map
|
||||||
//TODO: NPCs?
|
//TODO: NPCs?
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#include "room_mgr_api.hpp"
|
||||||
|
|
||||||
|
#include "room_manager.hpp"
|
||||||
|
#include "room_data.hpp"
|
||||||
|
|
||||||
|
static int getRoom(lua_State* L) {
|
||||||
|
//get the room manager
|
||||||
|
lua_pushstring(L, ROOM_MANAGER_PSEUDOINDEX);
|
||||||
|
lua_gettable(L, LUA_REGISTRYINDEX);
|
||||||
|
RoomManager* roomMgr = reinterpret_cast<RoomManager*>(lua_touserdata(L, -1));
|
||||||
|
|
||||||
|
//push the room and return it
|
||||||
|
lua_pushlightuserdata(L, reinterpret_cast<void*>( roomMgr->GetRoom(lua_tointeger(L, -2)) ));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const luaL_Reg roommgrlib[] = {
|
||||||
|
{"getroom",getRoom},
|
||||||
|
{nullptr, nullptr}
|
||||||
|
};
|
||||||
|
|
||||||
|
LUAMOD_API int luaopen_roommgrapi(lua_State* L) {
|
||||||
|
luaL_newlib(L, roommgrlib);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#ifndef ROOMMGRAPI_HPP_
|
||||||
|
#define ROOMMGRAPI_HPP_
|
||||||
|
|
||||||
|
#include "lua/lua.hpp"
|
||||||
|
|
||||||
|
#define LUA_ROOMMGRLIBNAME "roommgr"
|
||||||
|
LUAMOD_API int luaopen_roommgrapi(lua_State* L);
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user