diff --git a/common/gameplay/character_data.cpp b/client/character_data.cpp similarity index 97% rename from common/gameplay/character_data.cpp rename to client/character_data.cpp index 9824c79..81e4c75 100644 --- a/common/gameplay/character_data.cpp +++ b/client/character_data.cpp @@ -28,13 +28,9 @@ void CharacterData::Update(double delta) { else if (motion != 0) { origin += motion * delta; } -#ifdef GRAPHICS sprite.Update(delta); -#endif } -#ifdef GRAPHICS - void CharacterData::DrawTo(SDL_Surface* const dest, int camX, int camY) { sprite.DrawTo(dest, origin.x - camX, origin.y - camY); } @@ -63,5 +59,3 @@ void CharacterData::CorrectSprite() { sprite.SetXIndex(0); } } - -#endif \ No newline at end of file diff --git a/common/gameplay/character_data.hpp b/client/character_data.hpp similarity index 81% rename from common/gameplay/character_data.hpp rename to client/character_data.hpp index fd9f553..8756346 100644 --- a/common/gameplay/character_data.hpp +++ b/client/character_data.hpp @@ -22,36 +22,33 @@ #ifndef CHARACTERDATA_HPP_ #define CHARACTERDATA_HPP_ +//components +#include "character_defines.hpp" #include "vector2.hpp" #include "statistics.hpp" //graphics -#ifdef GRAPHICS - #include "sprite_sheet.hpp" -#endif +#include "sprite_sheet.hpp" //std namespace #include #include -//the speeds that the characters move -constexpr double CHARACTER_WALKING_SPEED = 140.0; -constexpr double CHARACTER_WALKING_MOD = 1.0/sqrt(2.0); - -//the bounding boxes for the characters -constexpr double CHARACTER_BOUNDS_WIDTH = 32.0; -constexpr double CHARACTER_BOUNDS_HEIGHT = 32.0; - +//TODO: encapsulate this and the server version struct CharacterData { //metadata int owner; std::string handle; std::string avatar; + //members + SpriteSheet sprite; + //world position int roomIndex = 0; Vector2 origin = {0.0,0.0}; Vector2 motion = {0.0,0.0}; + Vector2 bounds = {0.0,0.0}; //base statistics Statistics stats; @@ -60,17 +57,12 @@ struct CharacterData { //methods void Update(double delta); -#ifdef GRAPHICS + void DrawTo(SDL_Surface* const, int camX, int camY); void CorrectSprite(); -#endif //active gameplay members //NOTE: these are lost when unloaded -#ifdef GRAPHICS - Vector2 bounds = {0.0,0.0}; - SpriteSheet sprite; -#endif bool inCombat = false; int atbGauge = 0; //TODO: stored command diff --git a/client/client_application.cpp b/client/client_application.cpp index 06f0bc6..95f529c 100644 --- a/client/client_application.cpp +++ b/client/client_application.cpp @@ -25,6 +25,7 @@ #include #include +#include //------------------------- //Scene headers @@ -44,24 +45,71 @@ //------------------------- void ClientApplication::Init(int argc, char** argv) { + std::cout << "Beginning " << argv[0] << std::endl; + //load the prerequisites config.Load("rsc\\config.cfg"); + //------------------------- + //Initialize the APIs + //------------------------- + //initialize SDL if (SDL_Init(SDL_INIT_VIDEO)) { throw(std::runtime_error("Failed to initialize SDL")); } - int w = config.Int("client.screen.w"); - int h = config.Int("client.screen.h"); - int f = config.Bool("client.screen.f") ? SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN : SDL_HWSURFACE|SDL_DOUBLEBUF; - - BaseScene::SetScreen(w ? w : 800, h ? h : 600, 0, f); + std::cout << "Initialized SDL" << std::endl; //initialize SDL_net if (SDLNet_Init()) { throw(std::runtime_error("Failed to initialize SDL_net")); } network.Open(0); + std::cout << "Initialized SDL_net" << std::endl; + + //------------------------- + //Setup the screen + //------------------------- + + int w = config.Int("client.screen.w"); + int h = config.Int("client.screen.h"); + int f = config.Bool("client.screen.f") ? SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN : SDL_HWSURFACE|SDL_DOUBLEBUF; + + BaseScene::SetScreen(w ? w : 800, h ? h : 600, 0, f); + std::cout << "Initialized the screen" << std::endl; + + //------------------------- + //debug output + //------------------------- + + //TODO: enable/disable these with a switch +#define DEBUG_OUTPUT_VAR(x) std::cout << "\t" << #x << ": " << x << std::endl; + + std::cout << "Internal sizes:" << std::endl; + + DEBUG_OUTPUT_VAR(sizeof(Region::type_t)); + DEBUG_OUTPUT_VAR(sizeof(Region)); + DEBUG_OUTPUT_VAR(REGION_WIDTH); + DEBUG_OUTPUT_VAR(REGION_HEIGHT); + DEBUG_OUTPUT_VAR(REGION_DEPTH); + DEBUG_OUTPUT_VAR(REGION_SOLID_FOOTPRINT); + DEBUG_OUTPUT_VAR(REGION_FOOTPRINT); + DEBUG_OUTPUT_VAR(PACKET_BUFFER_SIZE); + DEBUG_OUTPUT_VAR(MAX_PACKET_SIZE); + +#undef DEBUG_OUTPUT_VAR + + //------------------------- + //finalize the startup + //------------------------- + + std::cout << "Startup completed successfully" << std::endl; + + //------------------------- + //debugging + //------------------------- + + //... } void ClientApplication::Proc() { @@ -100,9 +148,11 @@ void ClientApplication::Proc() { } void ClientApplication::Quit() { + std::cout << "Shutting down" << std::endl; network.Close(); SDLNet_Quit(); SDL_Quit(); + std::cout << "Clean exit" << std::endl; } //------------------------- diff --git a/common/gameplay/combat_data.hpp b/client/combat_data.hpp similarity index 84% rename from common/gameplay/combat_data.hpp rename to client/combat_data.hpp index b170e5f..1d6eb70 100644 --- a/common/gameplay/combat_data.hpp +++ b/client/combat_data.hpp @@ -23,31 +23,19 @@ #define COMBATDATA_HPP_ #include "vector2.hpp" +#include "combat_defines.hpp" //gameplay members #include "character_data.hpp" #include "enemy_data.hpp" -//graphics -#ifdef GRAPHICS - #include "sprite_sheet.hpp" -#endif - //std namespace #include #include #include -#define COMBAT_MAX_CHARACTERS 12 -#define COMBAT_MAX_ENEMIES 12 - +//NOTE: This is a placeholder, since it'd break to client too much to remove it struct CombatData { - enum class Terrain { - //TODO: types of combat terrains - NONE = 0, - GRASSLANDS, - }; - typedef std::chrono::steady_clock Clock; std::array characterArray; @@ -60,11 +48,6 @@ struct CombatData { //time interval Clock::time_point lastTick = Clock::now(); - - //graphics -#ifdef GRAPHICS - SpriteSheet sprite; -#endif }; #endif diff --git a/common/gameplay/enemy_data.hpp b/client/enemy_data.hpp similarity index 88% rename from common/gameplay/enemy_data.hpp rename to client/enemy_data.hpp index 533add6..6cd85f5 100644 --- a/common/gameplay/enemy_data.hpp +++ b/client/enemy_data.hpp @@ -25,14 +25,10 @@ #include "vector2.hpp" #include "statistics.hpp" -//graphics -#ifdef GRAPHICS - #include "sprite_sheet.hpp" -#endif - //std namespace #include +//NOTE: This is a placeholder, since it'd break to client too much to remove it struct EnemyData { //metadata std::string handle; @@ -45,11 +41,6 @@ struct EnemyData { //active gameplay members //NOTE: these are lost when unloaded -#ifdef GRAPHICS - SpriteSheet sprite; - Vector2 origin = {0.0,0.0}; - Vector2 bounds = {0.0,0.0}; -#endif int tableIndex; int atbGauge = 0; }; diff --git a/client/main.cpp b/client/main.cpp index 9ec652c..156adff 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -27,7 +27,6 @@ using namespace std; int main(int argc, char** argv) { - cout << "Beginning client" << endl; try { ClientApplication app; app.Init(argc, argv); @@ -38,6 +37,5 @@ int main(int argc, char** argv) { cerr << "Fatal exception thrown: " << e.what() << endl; return 1; } - cout << "Clean exit" << endl; return 0; } diff --git a/client/makefile b/client/makefile index 947b822..97d8949 100644 --- a/client/makefile +++ b/client/makefile @@ -1,7 +1,7 @@ #config -INCLUDES+=. ../common/gameplay ../common/graphics ../common/map ../common/network ../common/network/packet ../common/network/serial ../common/ui ../common/utilities -LIBS+=../libcommon.a -lSDL_net -lwsock32 -liphlpapi -lmingw32 -lSDLmain -lSDL -llua -CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) -DGRAPHICS +INCLUDES+=. scenes ../common/gameplay ../common/graphics ../common/map ../common/network ../common/network/packet ../common/network/serial ../common/ui ../common/utilities +LIBS+=client.a ../libcommon.a -lSDL_net -lwsock32 -liphlpapi -lmingw32 -lSDLmain -lSDL -llua +CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) #source CXXSRC=$(wildcard *.cpp) @@ -16,6 +16,7 @@ OUT=$(addprefix $(OUTDIR)/,client) #targets all: $(OBJ) $(OUT) + $(MAKE) -C scenes $(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS) $(OBJ): | $(OBJDIR) diff --git a/client/base_scene.cpp b/client/scenes/base_scene.cpp similarity index 100% rename from client/base_scene.cpp rename to client/scenes/base_scene.cpp diff --git a/client/base_scene.hpp b/client/scenes/base_scene.hpp similarity index 100% rename from client/base_scene.hpp rename to client/scenes/base_scene.hpp diff --git a/client/clean_up.cpp b/client/scenes/clean_up.cpp similarity index 100% rename from client/clean_up.cpp rename to client/scenes/clean_up.cpp diff --git a/client/clean_up.hpp b/client/scenes/clean_up.hpp similarity index 100% rename from client/clean_up.hpp rename to client/scenes/clean_up.hpp diff --git a/client/in_combat.cpp b/client/scenes/in_combat.cpp similarity index 100% rename from client/in_combat.cpp rename to client/scenes/in_combat.cpp diff --git a/client/in_combat.hpp b/client/scenes/in_combat.hpp similarity index 100% rename from client/in_combat.hpp rename to client/scenes/in_combat.hpp diff --git a/client/in_world.cpp b/client/scenes/in_world.cpp similarity index 100% rename from client/in_world.cpp rename to client/scenes/in_world.cpp diff --git a/client/in_world.hpp b/client/scenes/in_world.hpp similarity index 100% rename from client/in_world.hpp rename to client/scenes/in_world.hpp diff --git a/client/lobby_menu.cpp b/client/scenes/lobby_menu.cpp similarity index 100% rename from client/lobby_menu.cpp rename to client/scenes/lobby_menu.cpp diff --git a/client/lobby_menu.hpp b/client/scenes/lobby_menu.hpp similarity index 100% rename from client/lobby_menu.hpp rename to client/scenes/lobby_menu.hpp diff --git a/client/main_menu.cpp b/client/scenes/main_menu.cpp similarity index 100% rename from client/main_menu.cpp rename to client/scenes/main_menu.cpp diff --git a/client/main_menu.hpp b/client/scenes/main_menu.hpp similarity index 100% rename from client/main_menu.hpp rename to client/scenes/main_menu.hpp diff --git a/server/mapgen/makefile b/client/scenes/makefile similarity index 65% rename from server/mapgen/makefile rename to client/scenes/makefile index 9a44bb4..4e050c7 100644 --- a/server/mapgen/makefile +++ b/client/scenes/makefile @@ -1,5 +1,5 @@ #config -INCLUDES+=. generators +INCLUDES+=. .. ../../common/gameplay ../../common/graphics ../../common/map ../../common/network ../../common/network/packet ../../common/network/serial ../../common/ui ../../common/utilities LIBS+= CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) @@ -12,12 +12,11 @@ OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o)) #output OUTDIR=.. -OUT=$(addprefix $(OUTDIR)/,server.a) +OUT=$(addprefix $(OUTDIR)/,client.a) #targets all: $(OBJ) $(OUT) ar -crs $(OUT) $(OBJ) - $(MAKE) -C generators $(OBJ): | $(OBJDIR) diff --git a/client/options_menu.cpp b/client/scenes/options_menu.cpp similarity index 100% rename from client/options_menu.cpp rename to client/scenes/options_menu.cpp diff --git a/client/options_menu.hpp b/client/scenes/options_menu.hpp similarity index 100% rename from client/options_menu.hpp rename to client/scenes/options_menu.hpp diff --git a/client/splash_screen.cpp b/client/scenes/splash_screen.cpp similarity index 100% rename from client/splash_screen.cpp rename to client/scenes/splash_screen.cpp diff --git a/client/splash_screen.hpp b/client/scenes/splash_screen.hpp similarity index 100% rename from client/splash_screen.hpp rename to client/scenes/splash_screen.hpp diff --git a/server/mapgen/generators/overworld_generator.hpp b/common/gameplay/character_defines.hpp similarity index 71% rename from server/mapgen/generators/overworld_generator.hpp rename to common/gameplay/character_defines.hpp index 63fd418..1daa1b4 100644 --- a/server/mapgen/generators/overworld_generator.hpp +++ b/common/gameplay/character_defines.hpp @@ -19,18 +19,17 @@ * 3. This notice may not be removed or altered from any source * distribution. */ -#ifndef OVERWORLDGENERATOR_HPP_ -#define OVERWORLDGENERATOR_HPP_ +#ifndef CHARACTERDEFINES_HPP_ +#define CHARACTERDEFINES_HPP_ -#include "base_generator.hpp" +#include -class OverworldGenerator : public BaseGenerator { -public: - OverworldGenerator(); - ~OverworldGenerator(); +//the speeds that the characters move +constexpr double CHARACTER_WALKING_SPEED = 140.0; +constexpr double CHARACTER_WALKING_MOD = 1.0/sqrt(2.0); -private: - // -}; +//the bounding boxes for the characters +constexpr double CHARACTER_BOUNDS_WIDTH = 32.0; +constexpr double CHARACTER_BOUNDS_HEIGHT = 32.0; #endif diff --git a/server/mapgen/terrain_type.hpp b/common/gameplay/combat_defines.hpp similarity index 85% rename from server/mapgen/terrain_type.hpp rename to common/gameplay/combat_defines.hpp index aadfaa9..db6421c 100644 --- a/server/mapgen/terrain_type.hpp +++ b/common/gameplay/combat_defines.hpp @@ -19,22 +19,16 @@ * 3. This notice may not be removed or altered from any source * distribution. */ -#ifndef TERRAINTYPE_HPP_ -#define TERRAINTYPE_HPP_ +#ifndef COMBATDEFINES_HPP_ +#define COMBATDEFINES_HPP_ + +#define COMBAT_MAX_CHARACTERS 16 +#define COMBAT_MAX_ENEMIES 16 enum class TerrainType { - //default: something's wrong NONE = 0, - - //standard overworld - PLAINS, - GRASS, - DIRT, - SAND, - WATER, - - //not used - LAST, + GRASSLANDS, + //etc. }; #endif diff --git a/common/gameplay/makefile b/common/gameplay/makefile index 3be52be..9013447 100644 --- a/common/gameplay/makefile +++ b/common/gameplay/makefile @@ -1,7 +1,7 @@ #config -INCLUDES+=. ../utilities ../graphics +INCLUDES+=. LIBS+= -CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) -DGRAPHICS +CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) #source CXXSRC=$(wildcard *.cpp) diff --git a/common/network/packet/combat_packet.hpp b/common/network/packet/combat_packet.hpp index ea27e8f..6b068df 100644 --- a/common/network/packet/combat_packet.hpp +++ b/common/network/packet/combat_packet.hpp @@ -24,13 +24,13 @@ #include "serial_packet_base.hpp" -#include "combat_data.hpp" +#include "combat_defines.hpp" struct CombatPacket : SerialPacketBase { //identify the combat instance int combatIndex; int difficulty; - CombatData::Terrain terrainType; + TerrainType terrainType; //combatants int characterArray[COMBAT_MAX_CHARACTERS]; diff --git a/common/network/serial/serial_combat.cpp b/common/network/serial/serial_combat.cpp index 268d580..318779f 100644 --- a/common/network/serial/serial_combat.cpp +++ b/common/network/serial/serial_combat.cpp @@ -29,7 +29,7 @@ void serializeCombat(CombatPacket* packet, void* buffer) { //identify the combat instance SERIALIZE(buffer, &packet->combatIndex, sizeof(int)); SERIALIZE(buffer, &packet->difficulty, sizeof(int)); - SERIALIZE(buffer, &packet->terrainType, sizeof(CombatData::Terrain)); + SERIALIZE(buffer, &packet->terrainType, sizeof(TerrainType)); //combatants SERIALIZE(buffer, &packet->characterArray, sizeof(int) * COMBAT_MAX_CHARACTERS); @@ -49,7 +49,7 @@ void deserializeCombat(CombatPacket* packet, void* buffer) { //identify the combat instance DESERIALIZE(buffer, &packet->combatIndex, sizeof(int)); DESERIALIZE(buffer, &packet->difficulty, sizeof(int)); - DESERIALIZE(buffer, &packet->terrainType, sizeof(CombatData::Terrain)); + DESERIALIZE(buffer, &packet->terrainType, sizeof(TerrainType)); //combatants DESERIALIZE(buffer, &packet->characterArray, sizeof(int) * COMBAT_MAX_CHARACTERS); diff --git a/common/ui/menu_bar.hpp b/common/ui/menu_bar.hpp index fdaf45c..e4dd392 100644 --- a/common/ui/menu_bar.hpp +++ b/common/ui/menu_bar.hpp @@ -36,6 +36,7 @@ * This class needs a rewrite. */ +//TODO: This thing is fucking terrible, fix it and the button class class MenuBar { public: MenuBar() = default; diff --git a/server/characters/character_data.hpp b/server/characters/character_data.hpp new file mode 100644 index 0000000..5650e36 --- /dev/null +++ b/server/characters/character_data.hpp @@ -0,0 +1,57 @@ +/* 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 CHARACTERDATA_HPP_ +#define CHARACTERDATA_HPP_ + +//components +#include "character_defines.hpp" +#include "vector2.hpp" +#include "statistics.hpp" + +//std namespace +#include +#include + +struct CharacterData { + //metadata + int owner; + std::string handle; + std::string avatar; + + //world position + int roomIndex = 0; + Vector2 origin = {0.0,0.0}; + Vector2 motion = {0.0,0.0}; + + //base statistics + Statistics stats; + + //TODO: gameplay components: equipment, items, buffs, debuffs + + //active gameplay members + //NOTE: these are lost when unloaded + bool inCombat = false; + int atbGauge = 0; + //TODO: stored command +}; + +#endif diff --git a/server/client_data.hpp b/server/client_data.hpp index 7410b08..4a9c5bc 100644 --- a/server/client_data.hpp +++ b/server/client_data.hpp @@ -26,6 +26,7 @@ struct ClientData { IPaddress address = {0,0}; + //TODO: ping system? }; #endif diff --git a/server/enemies/enemy_factory_generic.hpp b/server/combat/combat_data.hpp similarity index 62% rename from server/enemies/enemy_factory_generic.hpp rename to server/combat/combat_data.hpp index 5a63078..683e66f 100644 --- a/server/enemies/enemy_factory_generic.hpp +++ b/server/combat/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/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/common/gameplay/sanity_check.cpp b/server/enemies/enemy_data.hpp similarity index 70% rename from common/gameplay/sanity_check.cpp rename to server/enemies/enemy_data.hpp index 8669811..ab1ef89 100644 --- a/common/gameplay/sanity_check.cpp +++ b/server/enemies/enemy_data.hpp @@ -19,13 +19,29 @@ * 3. This notice may not be removed or altered from any source * distribution. */ -#include "character_data.hpp" -#include "combat_data.hpp" -#include "enemy_data.hpp" +#ifndef ENEMYDATA_HPP_ +#define ENEMYDATA_HPP_ + +#include "vector2.hpp" #include "statistics.hpp" -/* DOCS: Sanity check, read more - * Since most/all of the files in this directory are header files, I've created - * this source file as a "sanity check", to ensure that the above header files - * are written correctly via make. -*/ \ No newline at end of file +//std namespace +#include + +struct EnemyData { + //metadata + std::string handle; + std::string avatar; + + //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; +}; + +#endif 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/main.cpp b/server/main.cpp index 288e10f..5c01971 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -21,15 +21,12 @@ */ #include "server_application.hpp" -#include "SDL/SDL.h" - #include #include using namespace std; int main(int argc, char** argv) { - cout << "Beginning server" << endl; try { ServerApplication app; app.Init(argc, argv); @@ -37,9 +34,8 @@ int main(int argc, char** argv) { app.Quit(); } catch(exception& e) { - cerr << "Fatal error: " << e.what() << endl; + cerr << "Fatal exception thrown: " << e.what() << endl; return 1; } - cout << "Clean exit" << endl; return 0; } \ No newline at end of file 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/chunk_data.hpp b/server/mapgen/chunk_data.hpp deleted file mode 100644 index c0c1621..0000000 --- a/server/mapgen/chunk_data.hpp +++ /dev/null @@ -1,44 +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 CHUNKDATA_HPP_ -#define CHUNKDATA_HPP_ - -#include "terrain_type.hpp" - -#include - -struct ChunkData { - enum class Moddable { - LOCKED, //do not change - HARD, //minor changes - SOFT, //major changes - CLEAR, //untouched - }; - - TerrainType type; -// int fountainCount; - Moddable mod; -}; - -static_assert(std::is_pod::value, "ChunkData is not a POD"); - -#endif 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/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/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/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..5560050 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,13 @@ 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); + //TODO: expand this to auto-create the room } 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); diff --git a/server/server_application.cpp b/server/server_application.cpp index 7396cda..99179c4 100644 --- a/server/server_application.cpp +++ b/server/server_application.cpp @@ -21,8 +21,11 @@ */ #include "server_application.hpp" -#include "sql_utility.hpp" +//for PACKET_BUFFER_SIZE #include "serial.hpp" + +//utility functions +#include "sql_utility.hpp" #include "utility.hpp" #include @@ -35,9 +38,9 @@ void ServerApplication::Init(int argc, char** argv) { //NOTE: I might need to rearrange the init process so that lua & SQL can interact with the map system as needed. - std::cout << "Beginning startup" << std::endl; + std::cout << "Beginning " << argv[0] << std::endl; - //initial setup + //load the prerequisites config.Load("rsc\\config.cfg"); //------------------------- @@ -80,9 +83,7 @@ void ServerApplication::Init(int argc, char** argv) { accountMgr.SetDatabase(database); characterMgr.SetDatabase(database); - combatMgr.SetLuaState(luaState); roomMgr.SetLuaState(luaState); - enemyMgr.SetLuaState(luaState); std::cout << "Internal managers set" << std::endl; @@ -113,7 +114,6 @@ void ServerApplication::Init(int argc, char** argv) { //debug output //------------------------- - //TODO: put these outputs into the client too //TODO: enable/disable these with a switch #define DEBUG_OUTPUT_VAR(x) std::cout << "\t" << #x << ": " << x << std::endl; @@ -178,7 +178,7 @@ void ServerApplication::Quit() { SDLNet_Quit(); SDL_Quit(); - std::cout << "Shutdown finished" << std::endl; + std::cout << "Clean exit" << std::endl; } //------------------------- @@ -355,12 +355,6 @@ void ServerApplication::HandleRegionRequest(RegionPacket* const argPacket) { network.SendTo(&argPacket->srcAddress, static_cast(&newPacket)); } -//------------------------- -//combat management -//------------------------- - -//TODO: combat management - //------------------------- //Character Management //------------------------- @@ -439,12 +433,6 @@ void ServerApplication::HandleCharacterUpdate(CharacterPacket* const argPacket) PumpPacket(argPacket); } -//------------------------- -//enemy management -//------------------------- - -//TODO: enemy management - //------------------------- //mismanagement //------------------------- diff --git a/server/server_application.hpp b/server/server_application.hpp index ca2129b..c5d0c1d 100644 --- a/server/server_application.hpp +++ b/server/server_application.hpp @@ -22,12 +22,10 @@ #ifndef SERVERAPPLICATION_HPP_ #define SERVERAPPLICATION_HPP_ -//server specific stuff +//server specific stuff, mostly managers +#include "client_data.hpp" #include "account_manager.hpp" #include "character_manager.hpp" -#include "client_data.hpp" -#include "combat_manager.hpp" -#include "enemy_manager.hpp" #include "room_manager.hpp" //common utilities @@ -67,17 +65,11 @@ private: //map management void HandleRegionRequest(RegionPacket* const); - //combat management - //TODO: combat management - //character management void HandleCharacterNew(CharacterPacket* const); void HandleCharacterDelete(CharacterPacket* const); void HandleCharacterUpdate(CharacterPacket* const); - //enemy management - //TODO: enemy management - //mismanagement void HandleSynchronize(ClientPacket* const); @@ -99,8 +91,6 @@ private: //managers AccountManager accountMgr; CharacterManager characterMgr; - CombatManager combatMgr; - EnemyManager enemyMgr; RoomManager roomMgr; //misc