From 4dd4b37fc081a4bed037aadc41c68d319b0dbdd8 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Thu, 3 Jul 2014 00:55:54 +1000 Subject: [PATCH] It now builds cleanly, but I cut a few code stubs --- .../combat_data.hpp | 34 +++++--- .../chunk_data.hpp => client/enemy_data.hpp | 35 ++++---- common/gameplay/character_defines.hpp | 2 + common/gameplay/combat_defines.hpp | 1 + server/combat/makefile | 2 +- server/enemies/enemy_factory_generic.cpp | 34 -------- server/enemies/enemy_factory_interface.hpp | 49 ------------ server/linit.cpp | 2 - server/makefile | 1 - server/mapgen/generator_api.cpp | 79 ------------------- server/mapgen/generator_api.hpp | 30 ------- server/mapgen/generators/base_generator.cpp | 36 --------- server/mapgen/generators/base_generator.hpp | 54 ------------- server/mapgen/generators/caves_generator.cpp | 30 ------- server/mapgen/generators/caves_generator.hpp | 36 --------- .../mapgen/generators/forests_generator.cpp | 30 ------- .../mapgen/generators/forests_generator.hpp | 36 --------- server/mapgen/generators/makefile | 37 --------- .../mapgen/generators/overworld_generator.cpp | 30 ------- .../mapgen/generators/overworld_generator.hpp | 36 --------- server/mapgen/generators/ruins_generator.cpp | 30 ------- server/mapgen/generators/ruins_generator.hpp | 36 --------- server/mapgen/generators/towers_generator.cpp | 30 ------- server/mapgen/generators/towers_generator.hpp | 36 --------- server/mapgen/makefile | 38 --------- server/mapgen/map_type.hpp | 34 -------- server/mapgen/terrain_type.hpp | 40 ---------- server/rooms/room_api.cpp | 7 -- server/rooms/room_data.hpp | 3 - server/rooms/room_manager.cpp | 29 +------ server/rooms/room_manager.hpp | 2 +- server/rooms/room_mgr_api.cpp | 12 +-- 32 files changed, 49 insertions(+), 842 deletions(-) rename server/enemies/enemy_factory_generic.hpp => client/combat_data.hpp (62%) rename server/mapgen/chunk_data.hpp => client/enemy_data.hpp (69%) delete mode 100644 server/enemies/enemy_factory_generic.cpp delete mode 100644 server/enemies/enemy_factory_interface.hpp delete mode 100644 server/mapgen/generator_api.cpp delete mode 100644 server/mapgen/generator_api.hpp delete mode 100644 server/mapgen/generators/base_generator.cpp delete mode 100644 server/mapgen/generators/base_generator.hpp delete mode 100644 server/mapgen/generators/caves_generator.cpp delete mode 100644 server/mapgen/generators/caves_generator.hpp delete mode 100644 server/mapgen/generators/forests_generator.cpp delete mode 100644 server/mapgen/generators/forests_generator.hpp delete mode 100644 server/mapgen/generators/makefile delete mode 100644 server/mapgen/generators/overworld_generator.cpp delete mode 100644 server/mapgen/generators/overworld_generator.hpp delete mode 100644 server/mapgen/generators/ruins_generator.cpp delete mode 100644 server/mapgen/generators/ruins_generator.hpp delete mode 100644 server/mapgen/generators/towers_generator.cpp delete mode 100644 server/mapgen/generators/towers_generator.hpp delete mode 100644 server/mapgen/makefile delete mode 100644 server/mapgen/map_type.hpp delete mode 100644 server/mapgen/terrain_type.hpp diff --git a/server/enemies/enemy_factory_generic.hpp b/client/combat_data.hpp similarity index 62% rename from server/enemies/enemy_factory_generic.hpp rename to client/combat_data.hpp index 5a63078..683e66f 100644 --- a/server/enemies/enemy_factory_generic.hpp +++ b/client/combat_data.hpp @@ -19,24 +19,34 @@ * 3. This notice may not be removed or altered from any source * distribution. */ -#ifndef ENEMYFACTORYGENERIC_HPP_ -#define ENEMYFACTORYGENERIC_HPP_ +#ifndef COMBATDATA_HPP_ +#define COMBATDATA_HPP_ -#include "enemy_factory_interface.hpp" +#include "vector2.hpp" +#include "combat_defines.hpp" +//gameplay members +#include "character_data.hpp" #include "enemy_data.hpp" -#include +//std namespace +#include +#include +#include -//DOCS: Not really intended for use, but rather for copying and tweaking -class EnemyFactoryGeneric : public EnemyFactoryInterface { -public: - EnemyFactoryGeneric(); - ~EnemyFactoryGeneric() noexcept override; +struct CombatData { + typedef std::chrono::steady_clock Clock; - void Generate(std::list* container) override; -private: - //TODO: hold the parameters specified by the room + std::array characterArray; + std::array enemyArray; + + //world interaction + int mapIndex = 0; + Vector2 origin = {0.0,0.0}; + Vector2 bounds = {0.0,0.0}; + + //time interval + Clock::time_point lastTick = Clock::now(); }; #endif diff --git a/server/mapgen/chunk_data.hpp b/client/enemy_data.hpp similarity index 69% rename from server/mapgen/chunk_data.hpp rename to client/enemy_data.hpp index c0c1621..ab1ef89 100644 --- a/server/mapgen/chunk_data.hpp +++ b/client/enemy_data.hpp @@ -19,26 +19,29 @@ * 3. This notice may not be removed or altered from any source * distribution. */ -#ifndef CHUNKDATA_HPP_ -#define CHUNKDATA_HPP_ +#ifndef ENEMYDATA_HPP_ +#define ENEMYDATA_HPP_ -#include "terrain_type.hpp" +#include "vector2.hpp" +#include "statistics.hpp" -#include +//std namespace +#include -struct ChunkData { - enum class Moddable { - LOCKED, //do not change - HARD, //minor changes - SOFT, //major changes - CLEAR, //untouched - }; +struct EnemyData { + //metadata + std::string handle; + std::string avatar; - TerrainType type; -// int fountainCount; - Moddable mod; + //gameplay + Statistics stats; + + //TODO: gameplay components: equipment, items, buffs, debuffs, rewards + + //active gameplay members + //NOTE: these are lost when unloaded + int tableIndex; + int atbGauge = 0; }; -static_assert(std::is_pod::value, "ChunkData is not a POD"); - #endif diff --git a/common/gameplay/character_defines.hpp b/common/gameplay/character_defines.hpp index 76d80c9..1daa1b4 100644 --- a/common/gameplay/character_defines.hpp +++ b/common/gameplay/character_defines.hpp @@ -22,6 +22,8 @@ #ifndef CHARACTERDEFINES_HPP_ #define CHARACTERDEFINES_HPP_ +#include + //the speeds that the characters move constexpr double CHARACTER_WALKING_SPEED = 140.0; constexpr double CHARACTER_WALKING_MOD = 1.0/sqrt(2.0); diff --git a/common/gameplay/combat_defines.hpp b/common/gameplay/combat_defines.hpp index 0771561..db6421c 100644 --- a/common/gameplay/combat_defines.hpp +++ b/common/gameplay/combat_defines.hpp @@ -28,6 +28,7 @@ enum class TerrainType { NONE = 0, GRASSLANDS, + //etc. }; #endif diff --git a/server/combat/makefile b/server/combat/makefile index 68368e7..4d71462 100644 --- a/server/combat/makefile +++ b/server/combat/makefile @@ -1,5 +1,5 @@ #config -INCLUDES+=. ../../common/gameplay ../../common/utilities +INCLUDES+=. ../../common/gameplay ../../common/utilities ../characters ../enemies LIBS+= CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) diff --git a/server/enemies/enemy_factory_generic.cpp b/server/enemies/enemy_factory_generic.cpp deleted file mode 100644 index e8dd647..0000000 --- a/server/enemies/enemy_factory_generic.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* 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 "enemy_factory_generic.hpp" - -EnemyFactoryGeneric::EnemyFactoryGeneric() : EnemyFactoryInterface() { - //EMPTY -} - -EnemyFactoryGeneric::~EnemyFactoryGeneric() noexcept { - //EMPTY -} - -void EnemyFactoryGeneric::Generate(std::list* container) { - //TODO: fill this out -} \ No newline at end of file diff --git a/server/enemies/enemy_factory_interface.hpp b/server/enemies/enemy_factory_interface.hpp deleted file mode 100644 index 8e97e78..0000000 --- a/server/enemies/enemy_factory_interface.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/* 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 ENEMYFACTORYINTERFACE_HPP_ -#define ENEMYFACTORYINTERFACE_HPP_ - -#include "enemy_data.hpp" -#include "map_type.hpp" - -#include - -//NOTE: Based on biome, world difficulty, etc. -class EnemyFactoryInterface { -public: - EnemyFactoryInterface() = default; - virtual ~EnemyFactoryInterface() = default; - - virtual void Generate(std::list* container) = 0; - - //control the difficulty of the room - MapType SetType(MapType t) { return type = t; } - MapType GetType() { return type; } - - int SetDifficulty(int d) { return difficulty = d; } - int GetDifficulty() { return difficulty; } -protected: - MapType type; - int difficulty = 0; -}; - -#endif diff --git a/server/linit.cpp b/server/linit.cpp index 8108a49..1d79c96 100644 --- a/server/linit.cpp +++ b/server/linit.cpp @@ -40,7 +40,6 @@ #include "region_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[] = { @@ -61,7 +60,6 @@ static const luaL_Reg loadedlibs[] = { {TORTUGA_REGION_PAGER_NAME, openRegionPagerAPI}, {TORTUGA_ROOM_NAME, openRoomAPI}, {TORTUGA_ROOM_MGR_NAME, openRoomMgrAPI}, - {TORTUGA_GENRATOR_NAME, openGeneratorAPI}, {NULL, NULL} }; diff --git a/server/makefile b/server/makefile index 642dec3..3d0de76 100644 --- a/server/makefile +++ b/server/makefile @@ -20,7 +20,6 @@ all: $(OBJ) $(OUT) $(MAKE) -C characters $(MAKE) -C combat $(MAKE) -C enemies - $(MAKE) -C mapgen $(MAKE) -C rooms $(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS) diff --git a/server/mapgen/generator_api.cpp b/server/mapgen/generator_api.cpp deleted file mode 100644 index f3cc84f..0000000 --- a/server/mapgen/generator_api.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* 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" - -#include "base_generator.hpp" - -static int getMapType(lua_State* L) { - BaseGenerator* ptr = reinterpret_cast(lua_touserdata(L, 1)); - switch(ptr->GetMapType()) { - case MapType::NONE: - lua_pushstring(L, "none"); - break; - case MapType::OVERWORLD: - lua_pushstring(L, "overworld"); - break; - case MapType::RUINS: - lua_pushstring(L, "ruins"); - break; - case MapType::TOWERS: - lua_pushstring(L, "towers"); - break; - case MapType::FORESTS: - lua_pushstring(L, "forests"); - break; - case MapType::CAVES: - lua_pushstring(L, "caves"); - break; - } - return 1; -} - -static int getChunk(lua_State* L) { - BaseGenerator* ptr = reinterpret_cast(lua_touserdata(L, 1)); - ChunkData* chunk = ptr->GetChunk(lua_tointeger(L, 2), lua_tointeger(L, 3)); - lua_pushlightuserdata(L, reinterpret_cast(chunk)); - return 1; -} - -static int getMapWidth(lua_State* L) { - lua_pushinteger(L, MAP_WIDTH); - return 1; -} - -static int getMapHeight(lua_State* L) { - lua_pushinteger(L, MAP_HEIGHT); - return 1; -} - -static const luaL_Reg generatorLib[] = { - {"GetMapType", getMapType}, - {"GetChunk", getChunk}, - {"GetMapWidth", getMapWidth}, - {"GetMapHeight", getMapHeight}, - {nullptr, nullptr} -}; - -LUAMOD_API int openGeneratorAPI(lua_State* L) { - luaL_newlib(L, generatorLib); - return 1; -} diff --git a/server/mapgen/generator_api.hpp b/server/mapgen/generator_api.hpp deleted file mode 100644 index 78c24c2..0000000 --- a/server/mapgen/generator_api.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* 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 TORTUGA_GENRATOR_NAME "Generator" -LUAMOD_API int openGeneratorAPI(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 deleted file mode 100644 index 9afab6b..0000000 --- a/server/mapgen/generators/base_generator.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* 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(MapType t) { - mapType = t; - 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/mapgen/generators/base_generator.hpp b/server/mapgen/generators/base_generator.hpp deleted file mode 100644 index 6d629cd..0000000 --- a/server/mapgen/generators/base_generator.hpp +++ /dev/null @@ -1,54 +0,0 @@ -/* 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 BASEGENERATOR_HPP_ -#define BASEGENERATOR_HPP_ - -#include "map_type.hpp" -#include "chunk_data.hpp" - -#include "lua/lua.hpp" - -constexpr int MAP_WIDTH = 256; -constexpr int MAP_HEIGHT = 256; - -class BaseGenerator { -public: - virtual ~BaseGenerator(); - - //accessors and mutators - virtual ChunkData* GetChunk(int x, int y) { return &chunks[x][y]; } - - MapType GetMapType() { return mapType; } - - lua_State* SetLuaState(lua_State* L) { return luaState = L; } - lua_State* GetLuaState() { return luaState; } - -protected: - BaseGenerator() = delete; - BaseGenerator(MapType t); - - ChunkData chunks[MAP_WIDTH][MAP_HEIGHT]; - MapType mapType = MapType::NONE; - lua_State* luaState = nullptr; -}; - -#endif diff --git a/server/mapgen/generators/caves_generator.cpp b/server/mapgen/generators/caves_generator.cpp deleted file mode 100644 index 0019bf5..0000000 --- a/server/mapgen/generators/caves_generator.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* 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() : BaseGenerator(MapType::CAVES) { - // -} - -CavesGenerator::~CavesGenerator() { - // -} \ No newline at end of file diff --git a/server/mapgen/generators/caves_generator.hpp b/server/mapgen/generators/caves_generator.hpp deleted file mode 100644 index 062a86d..0000000 --- a/server/mapgen/generators/caves_generator.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/* 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" - -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 deleted file mode 100644 index cbff079..0000000 --- a/server/mapgen/generators/forests_generator.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* 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() : BaseGenerator(MapType::FORESTS) { - // -} - -ForestsGenerator::~ForestsGenerator() { - // -} \ No newline at end of file diff --git a/server/mapgen/generators/forests_generator.hpp b/server/mapgen/generators/forests_generator.hpp deleted file mode 100644 index 459428f..0000000 --- a/server/mapgen/generators/forests_generator.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/* 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" - -class ForestsGenerator : public BaseGenerator { -public: - ForestsGenerator(); - ~ForestsGenerator(); - -private: - // -}; - -#endif diff --git a/server/mapgen/generators/makefile b/server/mapgen/generators/makefile deleted file mode 100644 index 3e4ed5b..0000000 --- a/server/mapgen/generators/makefile +++ /dev/null @@ -1,37 +0,0 @@ -#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/mapgen/generators/overworld_generator.cpp b/server/mapgen/generators/overworld_generator.cpp deleted file mode 100644 index 7bcd1c5..0000000 --- a/server/mapgen/generators/overworld_generator.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* 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 "overworld_generator.hpp" - -OverworldGenerator::OverworldGenerator() : BaseGenerator(MapType::OVERWORLD) { - // -} - -OverworldGenerator::~OverworldGenerator() { - // -} \ No newline at end of file diff --git a/server/mapgen/generators/overworld_generator.hpp b/server/mapgen/generators/overworld_generator.hpp deleted file mode 100644 index 63fd418..0000000 --- a/server/mapgen/generators/overworld_generator.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/* 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" - -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 deleted file mode 100644 index 164de89..0000000 --- a/server/mapgen/generators/ruins_generator.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* 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() : BaseGenerator(MapType::RUINS) { - // -} - -RuinsGenerator::~RuinsGenerator() { - // -} \ No newline at end of file diff --git a/server/mapgen/generators/ruins_generator.hpp b/server/mapgen/generators/ruins_generator.hpp deleted file mode 100644 index fbc0518..0000000 --- a/server/mapgen/generators/ruins_generator.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/* 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" - -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 deleted file mode 100644 index ad50a09..0000000 --- a/server/mapgen/generators/towers_generator.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* 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() : BaseGenerator(MapType::TOWERS) { - // -} - -TowersGenerator::~TowersGenerator() { - // -} \ No newline at end of file diff --git a/server/mapgen/generators/towers_generator.hpp b/server/mapgen/generators/towers_generator.hpp deleted file mode 100644 index 48a29bb..0000000 --- a/server/mapgen/generators/towers_generator.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/* 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" - -class TowersGenerator : public BaseGenerator { -public: - TowersGenerator(); - ~TowersGenerator(); - -private: - // -}; - -#endif diff --git a/server/mapgen/makefile b/server/mapgen/makefile deleted file mode 100644 index 9a44bb4..0000000 --- a/server/mapgen/makefile +++ /dev/null @@ -1,38 +0,0 @@ -#config -INCLUDES+=. generators -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 deleted file mode 100644 index e56b924..0000000 --- a/server/mapgen/map_type.hpp +++ /dev/null @@ -1,34 +0,0 @@ -/* 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 { - NONE, - OVERWORLD, - RUINS, - TOWERS, - FORESTS, - CAVES, -}; - -#endif \ No newline at end of file diff --git a/server/mapgen/terrain_type.hpp b/server/mapgen/terrain_type.hpp deleted file mode 100644 index aadfaa9..0000000 --- a/server/mapgen/terrain_type.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* 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 TERRAINTYPE_HPP_ -#define TERRAINTYPE_HPP_ - -enum class TerrainType { - //default: something's wrong - NONE = 0, - - //standard overworld - PLAINS, - GRASS, - DIRT, - SAND, - WATER, - - //not used - LAST, -}; - -#endif diff --git a/server/rooms/room_api.cpp b/server/rooms/room_api.cpp index 3f217a8..2f1d103 100644 --- a/server/rooms/room_api.cpp +++ b/server/rooms/room_api.cpp @@ -29,12 +29,6 @@ static int getPager(lua_State* L) { return 1; } -static int getGenerator(lua_State* L) { - RoomData* room = reinterpret_cast(lua_touserdata(L, 1)); - lua_pushlightuserdata(L, reinterpret_cast(room->generator)); - return 1; -} - static int onCreate(lua_State* L) { //TODO: onCreate() return 0; @@ -49,7 +43,6 @@ static int onUnload(lua_State* L) { static const luaL_Reg roomLib[] = { {"GetPager",getPager}, - {"GetGenerator",getGenerator}, {"OnCreate", onCreate}, {"OnUnload", onUnload}, {nullptr, nullptr} diff --git a/server/rooms/room_data.hpp b/server/rooms/room_data.hpp index 660e057..4f1b669 100644 --- a/server/rooms/room_data.hpp +++ b/server/rooms/room_data.hpp @@ -23,14 +23,11 @@ #define ROOMDATA_HPP_ //map system -#include "map_type.hpp" #include "region_pager_lua.hpp" -#include "base_generator.hpp" struct RoomData { //members RegionPagerLua pager; - BaseGenerator* generator = nullptr; //TODO: collision map //TODO: NPCs? diff --git a/server/rooms/room_manager.cpp b/server/rooms/room_manager.cpp index 3e4ec87..81e83a5 100644 --- a/server/rooms/room_manager.cpp +++ b/server/rooms/room_manager.cpp @@ -21,41 +21,19 @@ */ #include "room_manager.hpp" -//the generator types -#include "overworld_generator.hpp" -#include "ruins_generator.hpp" -#include "towers_generator.hpp" -#include "forests_generator.hpp" -#include "caves_generator.hpp" - #include //------------------------- //public access methods //------------------------- -RoomData* RoomManager::CreateRoom(MapType mapType) { +RoomData* RoomManager::CreateRoom() { //create the room RoomData* newRoom = new RoomData(); - //create the generator, use a lambda because I'm lazy - newRoom->generator = [mapType]() -> BaseGenerator* { - switch(mapType) { - //BUG: Not having a map type results in an overworld generator by default - case MapType::NONE: - case MapType::OVERWORLD: return new OverworldGenerator(); - case MapType::RUINS: return new RuinsGenerator(); - case MapType::TOWERS: return new TowersGenerator(); - case MapType::FORESTS: return new ForestsGenerator(); - case MapType::CAVES: return new CavesGenerator(); - } - throw(std::runtime_error("Failed to set the room's generator")); - }(); - //set the state if (luaState) { newRoom->pager.SetLuaState(luaState); - newRoom->generator->SetLuaState(luaState); } //register the room @@ -91,15 +69,12 @@ void RoomManager::UnloadRoom(int uid) { lua_pop(luaState, 1); //free the memory - delete room->generator; delete room; roomMap.erase(uid); } RoomData* RoomManager::GetRoom(int uid) { - RoomData* ptr = FindRoom(uid); - if (ptr) return ptr; - return CreateRoom(MapType::NONE); + return FindRoom(uid); } RoomData* RoomManager::FindRoom(int uid) { diff --git a/server/rooms/room_manager.hpp b/server/rooms/room_manager.hpp index 02c5b32..71c2bbf 100644 --- a/server/rooms/room_manager.hpp +++ b/server/rooms/room_manager.hpp @@ -36,7 +36,7 @@ public: ~RoomManager() = default; //public access methods - RoomData* CreateRoom(MapType); + RoomData* CreateRoom(); void UnloadRoom(int uid); RoomData* GetRoom(int uid); diff --git a/server/rooms/room_mgr_api.cpp b/server/rooms/room_mgr_api.cpp index 9907896..3c96f4e 100644 --- a/server/rooms/room_mgr_api.cpp +++ b/server/rooms/room_mgr_api.cpp @@ -46,18 +46,8 @@ static int createRoom(lua_State* L) { lua_gettable(L, LUA_REGISTRYINDEX); RoomManager* roomMgr = reinterpret_cast(lua_touserdata(L, -1)); - //determine the specified room type - MapType mapType = [L]() -> MapType { - if (std::string("overworld") == lua_tostring(L, -2)) return MapType::OVERWORLD; - if (std::string("ruins") == lua_tostring(L, -2)) return MapType::RUINS; - if (std::string("towers") == lua_tostring(L, -2)) return MapType::TOWERS; - if (std::string("forests") == lua_tostring(L, -2)) return MapType::FORESTS; - if (std::string("caves") == lua_tostring(L, -2)) return MapType::CAVES; - return MapType::NONE; - }(); - //create the room - RoomData* newRoom = roomMgr->CreateRoom(mapType); + RoomData* newRoom = roomMgr->CreateRoom(); //return the new room lua_pushlightuserdata(L, newRoom);