From 57c6f45c213a0a65164fd6ed1f8cf82a941133d0 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Tue, 30 Dec 2014 02:19:19 +1100 Subject: [PATCH 1/3] Added API placeholder files --- rsc/scripts/map_saver.lua | 2 ++ rsc/scripts/setup_server.lua | 21 ------------- server/characters/character_api.cpp | 33 ++++++++++++++++++++ server/characters/character_api.hpp | 34 +++++++++++++++++++++ server/characters/character_manager_api.cpp | 33 ++++++++++++++++++++ server/characters/character_manager_api.hpp | 34 +++++++++++++++++++++ server/entities/entity_api.cpp | 33 ++++++++++++++++++++ server/entities/entity_api.hpp | 34 +++++++++++++++++++++ server/monsters/monster_api.cpp | 33 ++++++++++++++++++++ server/monsters/monster_api.hpp | 34 +++++++++++++++++++++ server/monsters/monster_manager_api.cpp | 33 ++++++++++++++++++++ server/monsters/monster_manager_api.hpp | 34 +++++++++++++++++++++ 12 files changed, 337 insertions(+), 21 deletions(-) create mode 100644 server/characters/character_api.cpp create mode 100644 server/characters/character_api.hpp create mode 100644 server/characters/character_manager_api.cpp create mode 100644 server/characters/character_manager_api.hpp create mode 100644 server/entities/entity_api.cpp create mode 100644 server/entities/entity_api.hpp create mode 100644 server/monsters/monster_api.cpp create mode 100644 server/monsters/monster_api.hpp create mode 100644 server/monsters/monster_manager_api.cpp create mode 100644 server/monsters/monster_manager_api.hpp diff --git a/rsc/scripts/map_saver.lua b/rsc/scripts/map_saver.lua index 0d7431f..7454081 100644 --- a/rsc/scripts/map_saver.lua +++ b/rsc/scripts/map_saver.lua @@ -1,9 +1,11 @@ local mapSaver = {} function mapSaver.Load(region) --empty + print("map_saver.lua:mapSaver.Load(region)") end function mapSaver.Save(region) --empty + print("map_saver.lua:mapSaver.Save(region)") end --TODO: create a flexible saving & loading system return mapSaver \ No newline at end of file diff --git a/rsc/scripts/setup_server.lua b/rsc/scripts/setup_server.lua index 7ac5afc..d39656f 100644 --- a/rsc/scripts/setup_server.lua +++ b/rsc/scripts/setup_server.lua @@ -4,27 +4,6 @@ mapMaker = require "map_maker" mapSaver = require "map_saver" roomSystem = require "room_system" -local function dumpTable(t) - print(t) - for k, v in pairs(t) do - print("",k, v) - end -end - ---create the overworld, set it's generator, loader & saver ---[[ -local t = { - "overworld.bmp", --tileset name - mapSaver.load, --load function - mapSaver.save, --save function - mapMaker.debugIsland, --create function - mapSaver.save --unload function -}]] - -dumpTable(roomSystem) -dumpTable(roomSystem.RoomManager) -dumpTable(roomSystem.Room) - --NOTE: room 0 is the first that the client asks for, therefore it must exist local overworld, uid = roomSystem.RoomManager.CreateRoom("overworld") roomSystem.Room.Initialize(overworld, "overworld.bmp", mapSaver.Load, mapSaver.Save, mapMaker.debugIsland, mapSaver.Save) diff --git a/server/characters/character_api.cpp b/server/characters/character_api.cpp new file mode 100644 index 0000000..bf8b6f0 --- /dev/null +++ b/server/characters/character_api.cpp @@ -0,0 +1,33 @@ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * 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 "character_api.hpp" + +#include "character_data.hpp" + +static const luaL_Reg characterLib[] = { + {nullptr, nullptr} +}; + +LUAMOD_API int openCharacterAPI(lua_State* L) { + luaL_newlib(L, characterLib); + return 1; +} \ No newline at end of file diff --git a/server/characters/character_api.hpp b/server/characters/character_api.hpp new file mode 100644 index 0000000..5ceda91 --- /dev/null +++ b/server/characters/character_api.hpp @@ -0,0 +1,34 @@ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * 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 CHARACTERAPI_HPP_ +#define CHARACTERAPI_HPP_ + +#if defined(__MINGW32__) + #include "lua/lua.hpp" +#else + #include "lua.hpp" +#endif + +#define TORTUGA_CHARACTER_API "character" +LUAMOD_API int openCharacterAPI(lua_State* L); + +#endif \ No newline at end of file diff --git a/server/characters/character_manager_api.cpp b/server/characters/character_manager_api.cpp new file mode 100644 index 0000000..b249ba9 --- /dev/null +++ b/server/characters/character_manager_api.cpp @@ -0,0 +1,33 @@ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * 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 "character_manager_api.hpp" + +#include "character_manager.hpp" + +static const luaL_Reg characterManagerLib[] = { + {nullptr, nullptr} +}; + +LUAMOD_API int openCharacterManagerAPI(lua_State* L) { + luaL_newlib(L, characterManagerLib); + return 1; +} \ No newline at end of file diff --git a/server/characters/character_manager_api.hpp b/server/characters/character_manager_api.hpp new file mode 100644 index 0000000..f4e52ed --- /dev/null +++ b/server/characters/character_manager_api.hpp @@ -0,0 +1,34 @@ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * 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 CHARACTERMANAGERAPI_HPP_ +#define CHARACTERMANAGERAPI_HPP_ + +#if defined(__MINGW32__) + #include "lua/lua.hpp" +#else + #include "lua.hpp" +#endif + +#define TORTUGA_CHARACTER_MANAGER_API "character_manager" +LUAMOD_API int openCharacterManagerAPI(lua_State* L); + +#endif \ No newline at end of file diff --git a/server/entities/entity_api.cpp b/server/entities/entity_api.cpp new file mode 100644 index 0000000..84c1a63 --- /dev/null +++ b/server/entities/entity_api.cpp @@ -0,0 +1,33 @@ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * 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 "entity_api.hpp" + +#include "entity.hpp" + +static const luaL_Reg entityLib[] = { + {nullptr, nullptr} +}; + +LUAMOD_API int openEntityAPI(lua_State* L) { + luaL_newlib(L, entityLib); + return 1; +} \ No newline at end of file diff --git a/server/entities/entity_api.hpp b/server/entities/entity_api.hpp new file mode 100644 index 0000000..1e20cff --- /dev/null +++ b/server/entities/entity_api.hpp @@ -0,0 +1,34 @@ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * 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 ENTITYAPI_HPP_ +#define ENTITYAPI_HPP_ + +#if defined(__MINGW32__) + #include "lua/lua.hpp" +#else + #include "lua.hpp" +#endif + +#define TORTUGA_ENTITY_API "entity" +LUAMOD_API int openEntityAPI(lua_State* L); + +#endif \ No newline at end of file diff --git a/server/monsters/monster_api.cpp b/server/monsters/monster_api.cpp new file mode 100644 index 0000000..3baec56 --- /dev/null +++ b/server/monsters/monster_api.cpp @@ -0,0 +1,33 @@ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * 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_api.hpp" + +#include "monster_data.hpp" + +static const luaL_Reg monsterLib[] = { + {nullptr, nullptr} +}; + +LUAMOD_API int openMonsterAPI(lua_State* L) { + luaL_newlib(L, monsterLib); + return 1; +} \ No newline at end of file diff --git a/server/monsters/monster_api.hpp b/server/monsters/monster_api.hpp new file mode 100644 index 0000000..d0c52ef --- /dev/null +++ b/server/monsters/monster_api.hpp @@ -0,0 +1,34 @@ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * 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 MONSTERAPI_HPP_ +#define MONSTERAPI_HPP_ + +#if defined(__MINGW32__) + #include "lua/lua.hpp" +#else + #include "lua.hpp" +#endif + +#define TORTUGA_MONSTER_API "monster" +LUAMOD_API int openMonsterAPI(lua_State* L); + +#endif \ No newline at end of file diff --git a/server/monsters/monster_manager_api.cpp b/server/monsters/monster_manager_api.cpp new file mode 100644 index 0000000..6fc6a81 --- /dev/null +++ b/server/monsters/monster_manager_api.cpp @@ -0,0 +1,33 @@ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * 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_api.hpp" + +#include "monster_manager.hpp" + +static const luaL_Reg monsterManagerLib[] = { + {nullptr, nullptr} +}; + +LUAMOD_API int openMonsterManagerAPI(lua_State* L) { + luaL_newlib(L, monsterManagerLib); + return 1; +} \ No newline at end of file diff --git a/server/monsters/monster_manager_api.hpp b/server/monsters/monster_manager_api.hpp new file mode 100644 index 0000000..d9eac7e --- /dev/null +++ b/server/monsters/monster_manager_api.hpp @@ -0,0 +1,34 @@ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * 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 MONSTERMANAGERAPI_HPP_ +#define MONSTERMANAGERAPI_HPP_ + +#if defined(__MINGW32__) + #include "lua/lua.hpp" +#else + #include "lua.hpp" +#endif + +#define TORTUGA_MONSTER_MANAGER_API "monster_manager" +LUAMOD_API int openMonsterManagerAPI(lua_State* L); + +#endif \ No newline at end of file From 3a9fdd511b1d3134510bc10c5d7480e66008a296 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Tue, 30 Dec 2014 02:38:25 +1100 Subject: [PATCH 2/3] Replaced door system with waypoint system --- server/main.cpp | 6 ++-- server/makefile | 4 +-- server/server_application.hpp | 4 +-- server/server_logic.cpp | 2 +- server/{doors => waypoints}/makefile | 2 +- .../waypoint_data.cpp} | 28 +------------------ .../waypoint_data.hpp} | 24 ++++++++-------- .../waypoint_manager.cpp} | 24 ++++++++-------- .../waypoint_manager.hpp} | 28 +++++++++---------- 9 files changed, 47 insertions(+), 75 deletions(-) rename server/{doors => waypoints}/makefile (87%) rename server/{doors/door_data.hpp => waypoints/waypoint_data.cpp} (67%) rename server/{doors/door_data.cpp => waypoints/waypoint_data.hpp} (75%) rename server/{doors/door_manager.cpp => waypoints/waypoint_manager.cpp} (66%) rename server/{doors/door_manager.hpp => waypoints/waypoint_manager.hpp} (71%) diff --git a/server/main.cpp b/server/main.cpp index a132c96..a86f4f0 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -26,10 +26,10 @@ #include "character_manager.hpp" #include "client_manager.hpp" #include "config_utility.hpp" -#include "door_manager.hpp" #include "monster_manager.hpp" #include "room_manager.hpp" #include "udp_network_utility.hpp" +#include "waypoint_manager.hpp" #include #include @@ -43,10 +43,10 @@ int main(int argc, char* argv[]) { CharacterManager::CreateSingleton(); ClientManager::CreateSingleton(); ConfigUtility::CreateSingleton(); - DoorManager::CreateSingleton(); MonsterManager::CreateSingleton(); RoomManager::CreateSingleton(); UDPNetworkUtility::CreateSingleton(); + WaypointManager::CreateSingleton(); //call the server's routines ServerApplication::CreateSingleton(); @@ -63,10 +63,10 @@ int main(int argc, char* argv[]) { CharacterManager::DeleteSingleton(); ClientManager::DeleteSingleton(); ConfigUtility::DeleteSingleton(); - DoorManager::DeleteSingleton(); MonsterManager::DeleteSingleton(); RoomManager::DeleteSingleton(); UDPNetworkUtility::DeleteSingleton(); + WaypointManager::DeleteSingleton(); } catch(exception& e) { cerr << "Fatal exception thrown: " << e.what() << endl; diff --git a/server/makefile b/server/makefile index b798e8b..0c8fff1 100644 --- a/server/makefile +++ b/server/makefile @@ -1,5 +1,5 @@ #include directories -INCLUDES+=. accounts characters clients doors entities monsters rooms server_utilities ../common/debugging ../common/gameplay ../common/map ../common/network ../common/network/packet_types ../common/utilities +INCLUDES+=. accounts characters clients entities monsters rooms server_utilities waypoints ../common/debugging ../common/gameplay ../common/map ../common/network ../common/network/packet_types ../common/utilities #libraries #the order of the $(LIBS) is important, at least for MinGW @@ -28,11 +28,11 @@ all: $(OBJ) $(OUT) $(MAKE) -C accounts $(MAKE) -C characters $(MAKE) -C clients - $(MAKE) -C doors $(MAKE) -C entities $(MAKE) -C monsters $(MAKE) -C rooms $(MAKE) -C server_utilities + $(MAKE) -C waypoints $(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS) $(OBJ): | $(OBJDIR) diff --git a/server/server_application.hpp b/server/server_application.hpp index 37b33bc..72d890c 100644 --- a/server/server_application.hpp +++ b/server/server_application.hpp @@ -26,9 +26,9 @@ #include "account_manager.hpp" #include "character_manager.hpp" #include "client_manager.hpp" -#include "door_manager.hpp" #include "monster_manager.hpp" #include "room_manager.hpp" +#include "waypoint_manager.hpp" //utilities #include "config_utility.hpp" @@ -123,9 +123,9 @@ private: AccountManager& accountMgr = AccountManager::GetSingleton(); CharacterManager& characterMgr = CharacterManager::GetSingleton(); ClientManager& clientMgr = ClientManager::GetSingleton(); - DoorManager& doorMgr = DoorManager::GetSingleton(); MonsterManager& monsterMgr = MonsterManager::GetSingleton(); RoomManager& roomMgr = RoomManager::GetSingleton(); + WaypointManager& waypointMgr = WaypointManager::GetSingleton(); ConfigUtility& config = ConfigUtility::GetSingleton(); UDPNetworkUtility& network = UDPNetworkUtility::GetSingleton(); diff --git a/server/server_logic.cpp b/server/server_logic.cpp index df88632..5e93167 100644 --- a/server/server_logic.cpp +++ b/server/server_logic.cpp @@ -201,9 +201,9 @@ void ServerApplication::Quit() { accountMgr.UnloadAll(); characterMgr.UnloadAll(); clientMgr.UnloadAll(); - doorMgr.UnloadAll(); monsterMgr.UnloadAll(); roomMgr.UnloadAll(); + waypointMgr.UnloadAll(); //APIs lua_close(luaState); diff --git a/server/doors/makefile b/server/waypoints/makefile similarity index 87% rename from server/doors/makefile rename to server/waypoints/makefile index 3585271..2a5c671 100644 --- a/server/doors/makefile +++ b/server/waypoints/makefile @@ -1,5 +1,5 @@ #config -INCLUDES+=. ../entities ../server_utilities ../../common/utilities +INCLUDES+=. ../server_utilities ../../common/utilities LIBS+= CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) diff --git a/server/doors/door_data.hpp b/server/waypoints/waypoint_data.cpp similarity index 67% rename from server/doors/door_data.hpp rename to server/waypoints/waypoint_data.cpp index fbd009d..229d597 100644 --- a/server/doors/door_data.hpp +++ b/server/waypoints/waypoint_data.cpp @@ -19,31 +19,5 @@ * 3. This notice may not be removed or altered from any source * distribution. */ -#ifndef DOORDATA_HPP_ -#define DOORDATA_HPP_ +#include "waypoint_data.hpp" -#include "entity.hpp" -#include "vector2.hpp" - -#include - -class DoorData: public Entity { -public: - DoorData() = default; - ~DoorData() = default; - - //accessors & mutators - std::string SetRoomName(std::string); - Vector2 SetDestPosition(Vector2); - - std::string GetRoomName(); - Vector2 GetDestPosition(); - -private: - friend class DoorManager; - - std::string roomName; - Vector2 destPosition; -}; - -#endif \ No newline at end of file diff --git a/server/doors/door_data.cpp b/server/waypoints/waypoint_data.hpp similarity index 75% rename from server/doors/door_data.cpp rename to server/waypoints/waypoint_data.hpp index c03f5a2..d1d3f77 100644 --- a/server/doors/door_data.cpp +++ b/server/waypoints/waypoint_data.hpp @@ -19,20 +19,18 @@ * 3. This notice may not be removed or altered from any source * distribution. */ -#include "door_data.hpp" +#ifndef WAYPOINTDATA_HPP_ +#define WAYPOINTDATA_HPP_ -std::string DoorData::SetRoomName(std::string s) { - return roomName = s; -} +#include -Vector2 DoorData::SetDestPosition(Vector2 v) { - return destPosition = v; -} +class WaypointData { +public: + WaypointData() = default; + ~WaypointData() = default; -std::string DoorData::GetRoomName() { - return roomName; -} +private: + friend class WaypointManager; +}; -Vector2 DoorData::GetDestPosition() { - return destPosition; -} +#endif \ No newline at end of file diff --git a/server/doors/door_manager.cpp b/server/waypoints/waypoint_manager.cpp similarity index 66% rename from server/doors/door_manager.cpp rename to server/waypoints/waypoint_manager.cpp index f2c3ebe..fe0889b 100644 --- a/server/doors/door_manager.cpp +++ b/server/waypoints/waypoint_manager.cpp @@ -19,48 +19,48 @@ * 3. This notice may not be removed or altered from any source * distribution. */ -#include "door_manager.hpp" +#include "waypoint_manager.hpp" -int DoorManager::Create(std::string, Vector2) { +int WaypointManager::Create() { //TODO } -int DoorManager::Load(std::string, Vector2) { +int WaypointManager::Load() { //TODO } -int DoorManager::Save(int uid) { +int WaypointManager::Save(int uid) { //TODO } -void DoorManager::Unload(int uid) { +void WaypointManager::Unload(int uid) { //TODO } -void DoorManager::Delete(int uid) { +void WaypointManager::Delete(int uid) { //TODO } -void DoorManager::UnloadAll() { +void WaypointManager::UnloadAll() { //TODO } -void DoorManager::UnloadIf(std::function)> fn) { +void WaypointManager::UnloadIf(std::function)> fn) { //TODO } -DoorData* DoorManager::Get(int uid) { +WaypointData* WaypointManager::Get(int uid) { //TODO } -int DoorManager::GetLoadedCount() { +int WaypointManager::GetLoadedCount() { //TODO } -int DoorManager::GetTotalCount() { +int WaypointManager::GetTotalCount() { //TODO } -std::map* DoorManager::GetContainer() { +std::map* WaypointManager::GetContainer() { //TODO } diff --git a/server/doors/door_manager.hpp b/server/waypoints/waypoint_manager.hpp similarity index 71% rename from server/doors/door_manager.hpp rename to server/waypoints/waypoint_manager.hpp index 908da7d..f4975aa 100644 --- a/server/doors/door_manager.hpp +++ b/server/waypoints/waypoint_manager.hpp @@ -19,10 +19,10 @@ * 3. This notice may not be removed or altered from any source * distribution. */ -#ifndef DOORMANAGER_HPP_ -#define DOORMANAGER_HPP_ +#ifndef WAYPOINTMANAGER_HPP_ +#define WAYPOINTMANAGER_HPP_ -#include "door_data.hpp" +#include "waypoint_data.hpp" #include "manager_interface.hpp" #include "singleton.hpp" #include "vector2.hpp" @@ -30,32 +30,32 @@ #include #include -class DoorManager: - public Singleton, - public ManagerInterface +class WaypointManager: + public Singleton, + public ManagerInterface { public: //common public methods - int Create(std::string, Vector2) override; - int Load(std::string, Vector2) override; + int Create() override; + int Load() override; int Save(int uid) override; void Unload(int uid) override; void Delete(int uid) override; void UnloadAll() override; - void UnloadIf(std::function)> fn) override; + void UnloadIf(std::function)> fn) override; //accessors & mutators - DoorData* Get(int uid) override; + WaypointData* Get(int uid) override; int GetLoadedCount() override; int GetTotalCount() override; - std::map* GetContainer() override; + std::map* GetContainer() override; private: - friend Singleton; + friend Singleton; - DoorManager() = default; - ~DoorManager() = default; + WaypointManager() = default; + ~WaypointManager() = default; }; #endif \ No newline at end of file From f3fb5017b368e5dbdee4746a2c00b184eef1bbb9 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Tue, 30 Dec 2014 02:45:35 +1100 Subject: [PATCH 3/3] Added waypoint API placeholder files --- server/waypoints/waypoint_api.cpp | 33 ++++++++++++++++++++++ server/waypoints/waypoint_api.hpp | 34 +++++++++++++++++++++++ server/waypoints/waypoint_manager_api.cpp | 33 ++++++++++++++++++++++ server/waypoints/waypoint_manager_api.hpp | 34 +++++++++++++++++++++++ 4 files changed, 134 insertions(+) create mode 100644 server/waypoints/waypoint_api.cpp create mode 100644 server/waypoints/waypoint_api.hpp create mode 100644 server/waypoints/waypoint_manager_api.cpp create mode 100644 server/waypoints/waypoint_manager_api.hpp diff --git a/server/waypoints/waypoint_api.cpp b/server/waypoints/waypoint_api.cpp new file mode 100644 index 0000000..0092d3d --- /dev/null +++ b/server/waypoints/waypoint_api.cpp @@ -0,0 +1,33 @@ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * 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 "waypoint_api.hpp" + +#include "waypoint_data.hpp" + +static const luaL_Reg waypointLib[] = { + {nullptr, nullptr} +}; + +LUAMOD_API int openWaypointAPI(lua_State* L) { + luaL_newlib(L, waypointLib); + return 1; +} \ No newline at end of file diff --git a/server/waypoints/waypoint_api.hpp b/server/waypoints/waypoint_api.hpp new file mode 100644 index 0000000..a3c49b9 --- /dev/null +++ b/server/waypoints/waypoint_api.hpp @@ -0,0 +1,34 @@ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * 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 WAYPOINTAPI_HPP_ +#define WAYPOINTAPI_HPP_ + +#if defined(__MINGW32__) + #include "lua/lua.hpp" +#else + #include "lua.hpp" +#endif + +#define TORTUGA_WAYPOINT_API "waypoint" +LUAMOD_API int openWaypointAPI(lua_State* L); + +#endif \ No newline at end of file diff --git a/server/waypoints/waypoint_manager_api.cpp b/server/waypoints/waypoint_manager_api.cpp new file mode 100644 index 0000000..c99782a --- /dev/null +++ b/server/waypoints/waypoint_manager_api.cpp @@ -0,0 +1,33 @@ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * 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 "waypoint_manager_api.hpp" + +#include "waypoint_manager.hpp" + +static const luaL_Reg waypointManagerLib[] = { + {nullptr, nullptr} +}; + +LUAMOD_API int openWaypointManagerAPI(lua_State* L) { + luaL_newlib(L, waypointManagerLib); + return 1; +} \ No newline at end of file diff --git a/server/waypoints/waypoint_manager_api.hpp b/server/waypoints/waypoint_manager_api.hpp new file mode 100644 index 0000000..f716ab4 --- /dev/null +++ b/server/waypoints/waypoint_manager_api.hpp @@ -0,0 +1,34 @@ +/* Copyright: (c) Kayne Ruse 2013-2015 + * + * 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 WAYPOINTMANAGERAPI_HPP_ +#define WAYPOINTMANAGERAPI_HPP_ + +#if defined(__MINGW32__) + #include "lua/lua.hpp" +#else + #include "lua.hpp" +#endif + +#define TORTUGA_WAYPOINT_MANAGER_API "waypoint_manager" +LUAMOD_API int openWaypointManagerAPI(lua_State* L); + +#endif \ No newline at end of file