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.
This commit is contained in:
@@ -540,9 +540,9 @@ void InWorld::UpdateMap() {
|
|||||||
//entity management
|
//entity management
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
//NOTE: preexisting characters will result in query responses
|
//DOCS: preexisting characters will result in query responses
|
||||||
//NOTE: new characters will result in create messages
|
//DOCS: new characters will result in create messages
|
||||||
//NOTE: this client's character will exist in both (skipped)
|
//DOCS: this client's character will exist in both (skipped)
|
||||||
|
|
||||||
void InWorld::HandleCharacterCreate(CharacterPacket* const argPacket) {
|
void InWorld::HandleCharacterCreate(CharacterPacket* const argPacket) {
|
||||||
//prevent double message
|
//prevent double message
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
//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
|
//NOTE: don't confuse SerialPacketBase with UDPpacket
|
||||||
|
|
||||||
void UDPNetworkUtility::Open(int port) {
|
void UDPNetworkUtility::Open(int port) {
|
||||||
|
|||||||
@@ -219,7 +219,6 @@ void AccountManager::UnloadIf(std::function<bool(std::pair<const int, AccountDat
|
|||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
AccountData* AccountManager::Get(int uid) {
|
AccountData* AccountManager::Get(int uid) {
|
||||||
//TODO: could this load an account first?
|
|
||||||
std::map<int, AccountData>::iterator it = elementMap.find(uid);
|
std::map<int, AccountData>::iterator it = elementMap.find(uid);
|
||||||
|
|
||||||
if (it == elementMap.end()) {
|
if (it == elementMap.end()) {
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ void ClientManager::UnloadIf(std::function<bool(std::pair<const int, ClientData>
|
|||||||
while (it != elementMap.end()) {
|
while (it != elementMap.end()) {
|
||||||
if (fn(*it)) {
|
if (fn(*it)) {
|
||||||
it = elementMap.erase(it);
|
it = elementMap.erase(it);
|
||||||
//TODO: ? disconnect, unload characters, notify other clients
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
++it;
|
++it;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
Entity() = default;
|
Entity() = default;
|
||||||
~Entity() = default;
|
virtual ~Entity() = default;
|
||||||
|
|
||||||
int roomIndex = -1;
|
int roomIndex = -1;
|
||||||
Vector2 origin;
|
Vector2 origin;
|
||||||
|
|||||||
@@ -191,7 +191,6 @@ void ServerApplication::HandleCharacterSetRoom(CharacterPacket* const argPacket)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//set the character's room, zero it's origin, zero it's motion
|
//set the character's room, zero it's origin, zero it's motion
|
||||||
//TODO: Set the origin here
|
|
||||||
characterData->SetRoomIndex(argPacket->roomIndex);
|
characterData->SetRoomIndex(argPacket->roomIndex);
|
||||||
characterData->SetOrigin({0, 0});
|
characterData->SetOrigin({0, 0});
|
||||||
characterData->SetMotion({0, 0});
|
characterData->SetMotion({0, 0});
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ void ServerApplication::Init(int argc, char* argv[]) {
|
|||||||
characterMgr.SetDatabase(database);
|
characterMgr.SetDatabase(database);
|
||||||
|
|
||||||
roomMgr.SetLuaState(luaState);
|
roomMgr.SetLuaState(luaState);
|
||||||
|
waypointMgr.SetLuaState(luaState);
|
||||||
|
|
||||||
std::cout << "Internal managers initialized" << std::endl;
|
std::cout << "Internal managers initialized" << std::endl;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#config
|
#config
|
||||||
INCLUDES+=. ../server_utilities ../../common/utilities
|
INCLUDES+=. ../entities ../server_utilities ../../common/utilities
|
||||||
LIBS+=
|
LIBS+=
|
||||||
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "waypoint_data.hpp"
|
#include "waypoint_data.hpp"
|
||||||
|
|
||||||
|
//TODO: Can I alias the entity API for this?
|
||||||
static const luaL_Reg waypointLib[] = {
|
static const luaL_Reg waypointLib[] = {
|
||||||
{nullptr, nullptr}
|
{nullptr, nullptr}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,3 +21,10 @@
|
|||||||
*/
|
*/
|
||||||
#include "waypoint_data.hpp"
|
#include "waypoint_data.hpp"
|
||||||
|
|
||||||
|
int WaypointData::SetTriggerReference(int i) {
|
||||||
|
return triggerRef = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WaypointData::GetTriggerReference() {
|
||||||
|
return triggerRef;
|
||||||
|
}
|
||||||
@@ -22,15 +22,28 @@
|
|||||||
#ifndef WAYPOINTDATA_HPP_
|
#ifndef WAYPOINTDATA_HPP_
|
||||||
#define WAYPOINTDATA_HPP_
|
#define WAYPOINTDATA_HPP_
|
||||||
|
|
||||||
|
#include "entity.hpp"
|
||||||
|
|
||||||
|
#if defined(__MINGW32__)
|
||||||
|
#include "lua/lua.hpp"
|
||||||
|
#else
|
||||||
|
#include "lua.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class WaypointData {
|
class WaypointData: public Entity {
|
||||||
public:
|
public:
|
||||||
WaypointData() = default;
|
WaypointData() = default;
|
||||||
~WaypointData() = default;
|
~WaypointData() = default;
|
||||||
|
|
||||||
|
int SetTriggerReference(int i);
|
||||||
|
int GetTriggerReference();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class WaypointManager;
|
friend class WaypointManager;
|
||||||
|
|
||||||
|
int triggerRef = LUA_NOREF;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -26,10 +26,17 @@
|
|||||||
#include "singleton.hpp"
|
#include "singleton.hpp"
|
||||||
#include "vector2.hpp"
|
#include "vector2.hpp"
|
||||||
|
|
||||||
|
#if defined(__MINGW32__)
|
||||||
|
#include "lua/lua.hpp"
|
||||||
|
#else
|
||||||
|
#include "lua.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
//TODO: should waypoints be managed on a per-room basis?
|
||||||
class WaypointManager: public Singleton<WaypointManager> {
|
class WaypointManager: public Singleton<WaypointManager> {
|
||||||
public:
|
public:
|
||||||
//common public methods
|
//common public methods
|
||||||
@@ -48,6 +55,10 @@ public:
|
|||||||
int GetTotalCount();
|
int GetTotalCount();
|
||||||
std::map<int, WaypointData>* GetContainer();
|
std::map<int, WaypointData>* GetContainer();
|
||||||
|
|
||||||
|
//hooks
|
||||||
|
lua_State* SetLuaState(lua_State* L) { return lua = L; }
|
||||||
|
lua_State* GetLuaState() { return lua; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend Singleton<WaypointManager>;
|
friend Singleton<WaypointManager>;
|
||||||
|
|
||||||
@@ -56,6 +67,8 @@ private:
|
|||||||
|
|
||||||
//members
|
//members
|
||||||
std::map<int, WaypointData> elementMap;
|
std::map<int, WaypointData> elementMap;
|
||||||
|
lua_State* lua = nullptr;
|
||||||
|
int counter = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user