diff --git a/server/account_data.hpp b/server/accounts/account_data.hpp similarity index 100% rename from server/account_data.hpp rename to server/accounts/account_data.hpp diff --git a/server/account_manager.cpp b/server/accounts/account_manager.cpp similarity index 100% rename from server/account_manager.cpp rename to server/accounts/account_manager.cpp diff --git a/server/account_manager.hpp b/server/accounts/account_manager.hpp similarity index 100% rename from server/account_manager.hpp rename to server/accounts/account_manager.hpp diff --git a/server/accounts/makefile b/server/accounts/makefile new file mode 100644 index 0000000..8d12afe --- /dev/null +++ b/server/accounts/makefile @@ -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 diff --git a/server/character_manager.cpp b/server/characters/character_manager.cpp similarity index 100% rename from server/character_manager.cpp rename to server/characters/character_manager.cpp diff --git a/server/character_manager.hpp b/server/characters/character_manager.hpp similarity index 100% rename from server/character_manager.hpp rename to server/characters/character_manager.hpp diff --git a/server/characters/makefile b/server/characters/makefile new file mode 100644 index 0000000..68368e7 --- /dev/null +++ b/server/characters/makefile @@ -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 diff --git a/server/combat_manager.cpp b/server/combat/combat_manager.cpp similarity index 100% rename from server/combat_manager.cpp rename to server/combat/combat_manager.cpp diff --git a/server/combat_manager.hpp b/server/combat/combat_manager.hpp similarity index 100% rename from server/combat_manager.hpp rename to server/combat/combat_manager.hpp diff --git a/server/combat/makefile b/server/combat/makefile new file mode 100644 index 0000000..68368e7 --- /dev/null +++ b/server/combat/makefile @@ -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 diff --git a/server/enemy_factory_generic.cpp b/server/enemies/enemy_factory_generic.cpp similarity index 100% rename from server/enemy_factory_generic.cpp rename to server/enemies/enemy_factory_generic.cpp diff --git a/server/enemy_factory_generic.hpp b/server/enemies/enemy_factory_generic.hpp similarity index 100% rename from server/enemy_factory_generic.hpp rename to server/enemies/enemy_factory_generic.hpp diff --git a/server/enemy_factory_interface.hpp b/server/enemies/enemy_factory_interface.hpp similarity index 88% rename from server/enemy_factory_interface.hpp rename to server/enemies/enemy_factory_interface.hpp index 335814e..8e97e78 100644 --- a/server/enemy_factory_interface.hpp +++ b/server/enemies/enemy_factory_interface.hpp @@ -23,7 +23,7 @@ #define ENEMYFACTORYINTERFACE_HPP_ #include "enemy_data.hpp" -#include "room_data.hpp" +#include "map_type.hpp" #include @@ -36,13 +36,14 @@ public: virtual void Generate(std::list* container) = 0; //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; } - RoomData::RoomType GetType() { return type; } int GetDifficulty() { return difficulty; } protected: - RoomData::RoomType type; - int difficulty; + MapType type; + int difficulty = 0; }; #endif diff --git a/server/enemy_manager.cpp b/server/enemies/enemy_manager.cpp similarity index 100% rename from server/enemy_manager.cpp rename to server/enemies/enemy_manager.cpp diff --git a/server/enemy_manager.hpp b/server/enemies/enemy_manager.hpp similarity index 100% rename from server/enemy_manager.hpp rename to server/enemies/enemy_manager.hpp diff --git a/server/enemies/makefile b/server/enemies/makefile new file mode 100644 index 0000000..8c2156a --- /dev/null +++ b/server/enemies/makefile @@ -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 diff --git a/server/linit.cpp b/server/linit.cpp index 13541f2..7898184 100644 --- a/server/linit.cpp +++ b/server/linit.cpp @@ -38,6 +38,9 @@ #include "region_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 static const luaL_Reg loadedlibs[] = { @@ -56,6 +59,9 @@ static const luaL_Reg loadedlibs[] = { //custom libs {LUA_REGIONLIBNAME, luaopen_regionapi}, {LUA_PAGERLIBNAME, luaopen_pagerapi}, + {LUA_ROOMLIBNAME, luaopen_roomapi}, + {LUA_ROOMMGRLIBNAME, luaopen_roommgrapi}, + {LUA_GENERATORLIBNAME, luaopen_generatorapi}, {NULL, NULL} }; diff --git a/server/makefile b/server/makefile index 1d8df31..642dec3 100644 --- a/server/makefile +++ b/server/makefile @@ -1,6 +1,6 @@ #config -INCLUDES+=. ../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 +INCLUDES+=. accounts characters combat enemies mapgen mapgen/generators rooms ../common/gameplay ../common/map ../common/network ../common/network/packet ../common/network/serial ../common/utilities +LIBS+=server.a ../libcommon.a -lSDL_net -lwsock32 -liphlpapi -lmingw32 -lSDLmain -lSDL -llua -lsqlite3 CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) #source @@ -16,6 +16,12 @@ OUT=$(addprefix $(OUTDIR)/,server) #targets 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) $(OBJ): | $(OBJDIR) diff --git a/server/chunk_data.hpp b/server/mapgen/chunk_data.hpp similarity index 100% rename from server/chunk_data.hpp rename to server/mapgen/chunk_data.hpp diff --git a/server/mapgen/generator_api.cpp b/server/mapgen/generator_api.cpp new file mode 100644 index 0000000..2593fb5 --- /dev/null +++ b/server/mapgen/generator_api.cpp @@ -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; +} diff --git a/server/mapgen/generator_api.hpp b/server/mapgen/generator_api.hpp new file mode 100644 index 0000000..a0b9fb3 --- /dev/null +++ b/server/mapgen/generator_api.hpp @@ -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 \ No newline at end of file diff --git a/server/mapgen/generators/base_generator.cpp b/server/mapgen/generators/base_generator.cpp new file mode 100644 index 0000000..8ea5974 --- /dev/null +++ b/server/mapgen/generators/base_generator.cpp @@ -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() { + // +} \ No newline at end of file diff --git a/server/overworld_generator.hpp b/server/mapgen/generators/base_generator.hpp similarity index 71% rename from server/overworld_generator.hpp rename to server/mapgen/generators/base_generator.hpp index a3724be..ef93c38 100644 --- a/server/overworld_generator.hpp +++ b/server/mapgen/generators/base_generator.hpp @@ -19,33 +19,29 @@ * 3. This notice may not be removed or altered from any source * distribution. */ -#ifndef OVERWORLDGENERATOR_HPP_ -#define OVERWORLDGENERATOR_HPP_ +#ifndef BASEGENERATOR_HPP_ +#define BASEGENERATOR_HPP_ #include "chunk_data.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; -constexpr int OVERWORLD_HEIGHT = 256; - -//TODO: SuperGenerator API -//TODO: SuperGenerator DOCS -class OverworldGenerator { +class BaseGenerator { public: - OverworldGenerator(); - ~OverworldGenerator(); + BaseGenerator(); + virtual ~BaseGenerator(); //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* GetLuaState() { return luaState; } -private: - ChunkData chunks[OVERWORLD_WIDTH][OVERWORLD_HEIGHT]; +protected: + ChunkData chunks[MAP_WIDTH][MAP_HEIGHT]; lua_State* luaState = nullptr; }; diff --git a/server/mapgen/generators/caves_generator.cpp b/server/mapgen/generators/caves_generator.cpp new file mode 100644 index 0000000..a2cbaed --- /dev/null +++ b/server/mapgen/generators/caves_generator.cpp @@ -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() { + // +} \ No newline at end of file diff --git a/server/mapgen/generators/caves_generator.hpp b/server/mapgen/generators/caves_generator.hpp new file mode 100644 index 0000000..975ed8c --- /dev/null +++ b/server/mapgen/generators/caves_generator.hpp @@ -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 diff --git a/server/mapgen/generators/forests_generator.cpp b/server/mapgen/generators/forests_generator.cpp new file mode 100644 index 0000000..5ff8127 --- /dev/null +++ b/server/mapgen/generators/forests_generator.cpp @@ -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() { + // +} \ No newline at end of file diff --git a/server/mapgen/generators/forests_generator.hpp b/server/mapgen/generators/forests_generator.hpp new file mode 100644 index 0000000..e87d89e --- /dev/null +++ b/server/mapgen/generators/forests_generator.hpp @@ -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 diff --git a/server/mapgen/generators/makefile b/server/mapgen/generators/makefile new file mode 100644 index 0000000..3e4ed5b --- /dev/null +++ b/server/mapgen/generators/makefile @@ -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 diff --git a/server/overworld_generator.cpp b/server/mapgen/generators/overworld_generator.cpp similarity index 84% rename from server/overworld_generator.cpp rename to server/mapgen/generators/overworld_generator.cpp index 2b56bba..8119158 100644 --- a/server/overworld_generator.cpp +++ b/server/mapgen/generators/overworld_generator.cpp @@ -22,12 +22,7 @@ #include "overworld_generator.hpp" 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() { diff --git a/server/mapgen/generators/overworld_generator.hpp b/server/mapgen/generators/overworld_generator.hpp new file mode 100644 index 0000000..e47026d --- /dev/null +++ b/server/mapgen/generators/overworld_generator.hpp @@ -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 diff --git a/server/mapgen/generators/ruins_generator.cpp b/server/mapgen/generators/ruins_generator.cpp new file mode 100644 index 0000000..24a7c3e --- /dev/null +++ b/server/mapgen/generators/ruins_generator.cpp @@ -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() { + // +} \ No newline at end of file diff --git a/server/mapgen/generators/ruins_generator.hpp b/server/mapgen/generators/ruins_generator.hpp new file mode 100644 index 0000000..309bf45 --- /dev/null +++ b/server/mapgen/generators/ruins_generator.hpp @@ -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 diff --git a/server/mapgen/generators/towers_generator.cpp b/server/mapgen/generators/towers_generator.cpp new file mode 100644 index 0000000..3e8a2c6 --- /dev/null +++ b/server/mapgen/generators/towers_generator.cpp @@ -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() { + // +} \ No newline at end of file diff --git a/server/mapgen/generators/towers_generator.hpp b/server/mapgen/generators/towers_generator.hpp new file mode 100644 index 0000000..0dcb9d9 --- /dev/null +++ b/server/mapgen/generators/towers_generator.hpp @@ -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 diff --git a/server/mapgen/makefile b/server/mapgen/makefile new file mode 100644 index 0000000..d949a54 --- /dev/null +++ b/server/mapgen/makefile @@ -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 diff --git a/server/mapgen/map_type.hpp b/server/mapgen/map_type.hpp new file mode 100644 index 0000000..3127e1a --- /dev/null +++ b/server/mapgen/map_type.hpp @@ -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 \ No newline at end of file diff --git a/server/terrain_type.hpp b/server/mapgen/terrain_type.hpp similarity index 100% rename from server/terrain_type.hpp rename to server/mapgen/terrain_type.hpp diff --git a/server/rooms/makefile b/server/rooms/makefile new file mode 100644 index 0000000..f4921ea --- /dev/null +++ b/server/rooms/makefile @@ -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 diff --git a/server/room_api.cpp b/server/rooms/room_api.cpp similarity index 79% rename from server/room_api.cpp rename to server/rooms/room_api.cpp index ea7ea52..9f09f3c 100644 --- a/server/room_api.cpp +++ b/server/rooms/room_api.cpp @@ -38,22 +38,11 @@ static int getRegionPager(lua_State* L) { return 1; } -//RoomManager only -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(lua_touserdata(L, -1)); - - //push the room and return it - lua_pushlightuserdata(L, reinterpret_cast( roomMgr->GetRoom(lua_tointeger(L, -2)) )); - return 1; -} +//TODO: generators static const luaL_Reg roomlib[] = { {"gettype",getType}, {"getregionpager",getRegionPager}, - {"getroom",getRoom}, {nullptr, nullptr} }; diff --git a/server/room_api.hpp b/server/rooms/room_api.hpp similarity index 100% rename from server/room_api.hpp rename to server/rooms/room_api.hpp diff --git a/server/room_data.hpp b/server/rooms/room_data.hpp similarity index 90% rename from server/room_data.hpp rename to server/rooms/room_data.hpp index cf1b6cb..4b9e811 100644 --- a/server/room_data.hpp +++ b/server/rooms/room_data.hpp @@ -23,20 +23,15 @@ #define ROOMDATA_HPP_ //map system +#include "map_type.hpp" #include "region_pager_lua.hpp" +#include "base_generator.hpp" struct RoomData { - enum class RoomType { - OVERWORLD = 0, - RUINS = 1, - TOWERS = 2, - FORESTS = 3, - CAVE = 4, - }; - //members + MapType type; RegionPagerLua pager; - RoomType type; + BaseGenerator* generator = nullptr; //TODO: collision map //TODO: NPCs? diff --git a/server/room_manager.cpp b/server/rooms/room_manager.cpp similarity index 100% rename from server/room_manager.cpp rename to server/rooms/room_manager.cpp diff --git a/server/room_manager.hpp b/server/rooms/room_manager.hpp similarity index 100% rename from server/room_manager.hpp rename to server/rooms/room_manager.hpp diff --git a/server/rooms/room_mgr_api.cpp b/server/rooms/room_mgr_api.cpp new file mode 100644 index 0000000..44050dc --- /dev/null +++ b/server/rooms/room_mgr_api.cpp @@ -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(lua_touserdata(L, -1)); + + //push the room and return it + lua_pushlightuserdata(L, reinterpret_cast( 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; +} \ No newline at end of file diff --git a/server/rooms/room_mgr_api.hpp b/server/rooms/room_mgr_api.hpp new file mode 100644 index 0000000..1382b4d --- /dev/null +++ b/server/rooms/room_mgr_api.hpp @@ -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