From f9c19a630d3af9bde798aaada78bddff44d2d616 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Wed, 31 Dec 2014 03:34:06 +1100 Subject: [PATCH] Added trigger reference to WaypointData, unused WaypointData also inherits from Entity now, so I could alias Entity's API for it too. I've also made a number of comment tweaks. --- client/scenes/in_world.cpp | 6 +++--- common/network/udp_network_utility.cpp | 2 +- server/accounts/account_manager.cpp | 1 - server/clients/client_manager.cpp | 1 - server/entities/entity.hpp | 2 +- server/server_character_methods.cpp | 1 - server/server_logic.cpp | 1 + server/waypoints/makefile | 2 +- server/waypoints/waypoint_api.cpp | 1 + server/waypoints/waypoint_data.cpp | 7 +++++++ server/waypoints/waypoint_data.hpp | 15 ++++++++++++++- server/waypoints/waypoint_manager.hpp | 13 +++++++++++++ 12 files changed, 42 insertions(+), 10 deletions(-) diff --git a/client/scenes/in_world.cpp b/client/scenes/in_world.cpp index 7dff310..9547f01 100644 --- a/client/scenes/in_world.cpp +++ b/client/scenes/in_world.cpp @@ -540,9 +540,9 @@ void InWorld::UpdateMap() { //entity management //------------------------- -//NOTE: preexisting characters will result in query responses -//NOTE: new characters will result in create messages -//NOTE: this client's character will exist in both (skipped) +//DOCS: preexisting characters will result in query responses +//DOCS: new characters will result in create messages +//DOCS: this client's character will exist in both (skipped) void InWorld::HandleCharacterCreate(CharacterPacket* const argPacket) { //prevent double message diff --git a/common/network/udp_network_utility.cpp b/common/network/udp_network_utility.cpp index c069b27..4dfb044 100644 --- a/common/network/udp_network_utility.cpp +++ b/common/network/udp_network_utility.cpp @@ -26,7 +26,7 @@ #include -//NOTE: memset() is used before sending a packet to remove old data; you don't want to send sensitive data over the network +//DOCS: memset() is used before sending a packet to remove old data; you don't want to send sensitive data over the network //NOTE: don't confuse SerialPacketBase with UDPpacket void UDPNetworkUtility::Open(int port) { diff --git a/server/accounts/account_manager.cpp b/server/accounts/account_manager.cpp index 84e7d06..22538bb 100644 --- a/server/accounts/account_manager.cpp +++ b/server/accounts/account_manager.cpp @@ -219,7 +219,6 @@ void AccountManager::UnloadIf(std::function::iterator it = elementMap.find(uid); if (it == elementMap.end()) { diff --git a/server/clients/client_manager.cpp b/server/clients/client_manager.cpp index 87604f6..a1c1808 100644 --- a/server/clients/client_manager.cpp +++ b/server/clients/client_manager.cpp @@ -78,7 +78,6 @@ void ClientManager::UnloadIf(std::function while (it != elementMap.end()) { if (fn(*it)) { it = elementMap.erase(it); - //TODO: ? disconnect, unload characters, notify other clients } else { ++it; diff --git a/server/entities/entity.hpp b/server/entities/entity.hpp index e110e80..f71fbf9 100644 --- a/server/entities/entity.hpp +++ b/server/entities/entity.hpp @@ -38,7 +38,7 @@ public: protected: Entity() = default; - ~Entity() = default; + virtual ~Entity() = default; int roomIndex = -1; Vector2 origin; diff --git a/server/server_character_methods.cpp b/server/server_character_methods.cpp index 018db97..8bc1393 100644 --- a/server/server_character_methods.cpp +++ b/server/server_character_methods.cpp @@ -191,7 +191,6 @@ void ServerApplication::HandleCharacterSetRoom(CharacterPacket* const argPacket) } //set the character's room, zero it's origin, zero it's motion - //TODO: Set the origin here characterData->SetRoomIndex(argPacket->roomIndex); characterData->SetOrigin({0, 0}); characterData->SetMotion({0, 0}); diff --git a/server/server_logic.cpp b/server/server_logic.cpp index 5e93167..ad78485 100644 --- a/server/server_logic.cpp +++ b/server/server_logic.cpp @@ -105,6 +105,7 @@ void ServerApplication::Init(int argc, char* argv[]) { characterMgr.SetDatabase(database); roomMgr.SetLuaState(luaState); + waypointMgr.SetLuaState(luaState); std::cout << "Internal managers initialized" << std::endl; diff --git a/server/waypoints/makefile b/server/waypoints/makefile index 2a5c671..3585271 100644 --- a/server/waypoints/makefile +++ b/server/waypoints/makefile @@ -1,5 +1,5 @@ #config -INCLUDES+=. ../server_utilities ../../common/utilities +INCLUDES+=. ../entities ../server_utilities ../../common/utilities LIBS+= CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) diff --git a/server/waypoints/waypoint_api.cpp b/server/waypoints/waypoint_api.cpp index 0092d3d..6059f69 100644 --- a/server/waypoints/waypoint_api.cpp +++ b/server/waypoints/waypoint_api.cpp @@ -23,6 +23,7 @@ #include "waypoint_data.hpp" +//TODO: Can I alias the entity API for this? static const luaL_Reg waypointLib[] = { {nullptr, nullptr} }; diff --git a/server/waypoints/waypoint_data.cpp b/server/waypoints/waypoint_data.cpp index 229d597..b720e1d 100644 --- a/server/waypoints/waypoint_data.cpp +++ b/server/waypoints/waypoint_data.cpp @@ -21,3 +21,10 @@ */ #include "waypoint_data.hpp" +int WaypointData::SetTriggerReference(int i) { + return triggerRef = i; +} + +int WaypointData::GetTriggerReference() { + return triggerRef; +} \ No newline at end of file diff --git a/server/waypoints/waypoint_data.hpp b/server/waypoints/waypoint_data.hpp index d1d3f77..32aa7d0 100644 --- a/server/waypoints/waypoint_data.hpp +++ b/server/waypoints/waypoint_data.hpp @@ -22,15 +22,28 @@ #ifndef WAYPOINTDATA_HPP_ #define WAYPOINTDATA_HPP_ +#include "entity.hpp" + +#if defined(__MINGW32__) + #include "lua/lua.hpp" +#else + #include "lua.hpp" +#endif + #include -class WaypointData { +class WaypointData: public Entity { public: WaypointData() = default; ~WaypointData() = default; + int SetTriggerReference(int i); + int GetTriggerReference(); + private: friend class WaypointManager; + + int triggerRef = LUA_NOREF; }; #endif \ No newline at end of file diff --git a/server/waypoints/waypoint_manager.hpp b/server/waypoints/waypoint_manager.hpp index 7139363..0e51d3a 100644 --- a/server/waypoints/waypoint_manager.hpp +++ b/server/waypoints/waypoint_manager.hpp @@ -26,10 +26,17 @@ #include "singleton.hpp" #include "vector2.hpp" +#if defined(__MINGW32__) + #include "lua/lua.hpp" +#else + #include "lua.hpp" +#endif + #include #include #include +//TODO: should waypoints be managed on a per-room basis? class WaypointManager: public Singleton { public: //common public methods @@ -48,6 +55,10 @@ public: int GetTotalCount(); std::map* GetContainer(); + //hooks + lua_State* SetLuaState(lua_State* L) { return lua = L; } + lua_State* GetLuaState() { return lua; } + private: friend Singleton; @@ -56,6 +67,8 @@ private: //members std::map elementMap; + lua_State* lua = nullptr; + int counter = 0; }; #endif \ No newline at end of file