diff --git a/server/monsters/makefile b/server/monsters/makefile new file mode 100644 index 0000000..7e666d5 --- /dev/null +++ b/server/monsters/makefile @@ -0,0 +1,37 @@ +#config +INCLUDES+=. ../entities ../server_utilities ../../common/gameplay ../../common/utilities +LIBS+= +CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) + +#source +CXXSRC=$(wildcard *.cpp) + +#objects +OBJDIR=obj +OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o)) + +#output +OUTDIR=.. +OUT=$(addprefix $(OUTDIR)/,server.a) + +#targets +all: $(OBJ) $(OUT) + ar -crs $(OUT) $(OBJ) + +$(OBJ): | $(OBJDIR) + +$(OUT): | $(OUTDIR) + +$(OBJDIR): + mkdir $(OBJDIR) + +$(OUTDIR): + mkdir $(OUTDIR) + +$(OBJDIR)/%.o: %.cpp + $(CXX) $(CXXFLAGS) -c -o $@ $< + +clean: + $(RM) *.o *.a *.exe + +rebuild: clean all diff --git a/server/monsters/monster_data.cpp b/server/monsters/monster_data.cpp new file mode 100644 index 0000000..2298c06 --- /dev/null +++ b/server/monsters/monster_data.cpp @@ -0,0 +1,42 @@ +/* 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 "monster_data.hpp" + +Statistics* MonsterData::GetBaseStats() { + return &baseStats; +} + +std::string MonsterData::SetAvatar(std::string s) { + return avatar = s; +} + +int MonsterData::SetScriptReference(int i) { + return scriptRef = i; +} + +std::string MonsterData::GetAvatar() { + return avatar; +} + +int MonsterData::GetScriptReference() { + return scriptRef; +} \ No newline at end of file diff --git a/server/monsters/monster_data.hpp b/server/monsters/monster_data.hpp new file mode 100644 index 0000000..1e1fcb2 --- /dev/null +++ b/server/monsters/monster_data.hpp @@ -0,0 +1,51 @@ +/* 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 MONSTERDATA_HPP_ +#define MONSTERDATA_HPP_ + +#include "entity.hpp" +#include "statistics.hpp" + +#include + +class MonsterData: Entity { +public: + MonsterData() = default; + ~MonsterData() = default; + + Statistics* GetBaseStats(); + + std::string SetAvatar(std::string); + int SetScriptReference(int); + + std::string GetAvatar(); + int GetScriptReference(); + +private: + friend class MonsterManager; + + Statistics baseStats; + std::string avatar; + int scriptRef; +}; + +#endif \ No newline at end of file diff --git a/server/monsters/monster_manager.cpp b/server/monsters/monster_manager.cpp new file mode 100644 index 0000000..2df1f5e --- /dev/null +++ b/server/monsters/monster_manager.cpp @@ -0,0 +1,84 @@ +/* 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 "monster_manager.hpp" + +//TODO: monster_manager.cpp + +int MonsterManager::Create(std::string) { + // +} + +int MonsterManager::Load(std::string) { + // +} + +int MonsterManager::Save(int uid) { + // +} + +void MonsterManager::Unload(int uid) { + // +} + +void MonsterManager::Delete(int uid) { + // +} + +void MonsterManager::UnloadAll() { + // +} + +void MonsterManager::UnloadIf(std::function)> fn) { + // +} + +MonsterData* MonsterManager::Get(int uid) { + // +} + +int MonsterManager::GetLoadedCount() { + // +} + +int MonsterManager::GetTotalCount() { + // +} + +std::map* MonsterManager::GetContainer() { + // +} + +sqlite3* MonsterManager::SetDatabase(sqlite3* db) { + // +} + +sqlite3* MonsterManager::GetDatabase() { + // +} + +lua_State* MonsterManager::SetLuaState(lua_State* L) { + // +} + +lua_State* MonsterManager::GetLuaState() { + // +} diff --git a/server/monsters/monster_manager.hpp b/server/monsters/monster_manager.hpp new file mode 100644 index 0000000..9b05db8 --- /dev/null +++ b/server/monsters/monster_manager.hpp @@ -0,0 +1,77 @@ +/* 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 MONSTERMANAGER_HPP_ +#define MONSTERMANAGER_HPP_ + +#include "manager_interface.hpp" +#include "monster_data.hpp" +#include "singleton.hpp" + +#ifdef __unix__ + #include "lua.hpp" + #include "sqlite3.h" +#else + #include "lua/lua.hpp" + #include "sqlite3/sqlite3.h" +#endif + +#include +#include + +class MonsterManager: + Singleton, + ManagerInterface +{ +public: + //common public methods + int Create(std::string); + int Load(std::string); + int Save(int uid); + void Unload(int uid); + void Delete(int uid); + + void UnloadAll(); + void UnloadIf(std::function)> fn); + + //accessors & mutators + MonsterData* Get(int uid); + int GetLoadedCount(); + int GetTotalCount(); + std::map* GetContainer(); + + //hooks + sqlite3* SetDatabase(sqlite3* db); + sqlite3* GetDatabase(); + lua_State* SetLuaState(lua_State* L); + lua_State* GetLuaState(); + +private: + friend Singleton; + + MonsterManager() = default; + ~MonsterManager() = default; + + sqlite3* database = nullptr; + lua_State* lua = nullptr; +}; + +#endif \ No newline at end of file diff --git a/todo.txt b/todo.txt index f2f38ec..ab0e4a9 100644 --- a/todo.txt +++ b/todo.txt @@ -1,4 +1,5 @@ TODO: Get the rooms working, even if only via hotkeys +TODO: I need a better way to handle the statistics TODO: SerialPacketType::CHARACTER_LOCATION, CHARACTER_MOVE, CHARACTER_TELEPORT, ROOM_CHANGE, etc. TODO: Fix shoddy movement TODO: Handle statistics server-side