Made a few tweaks to various managers

This commit is contained in:
Kayne Ruse
2014-11-05 23:43:36 +11:00
parent 8eefdd71b5
commit fc2bc06992
9 changed files with 79 additions and 48 deletions
+11 -11
View File
@@ -36,20 +36,20 @@ class ClientManager:
{ {
public: public:
//common public methods //common public methods
int Create(IPaddress); int Create(IPaddress) override;
int Load(IPaddress); int Load(IPaddress) override;
int Save(int uid); int Save(int uid) override;
void Unload(int uid); void Unload(int uid) override;
void Delete(int uid); void Delete(int uid) override;
void UnloadAll(); void UnloadAll() override;
void UnloadIf(std::function<bool(std::pair<const int, ClientData>)> fn); void UnloadIf(std::function<bool(std::pair<const int, ClientData>)> fn) override;
//accessors & mutators //accessors & mutators
ClientData* Get(int uid); ClientData* Get(int uid) override;
int GetLoadedCount(); int GetLoadedCount() override;
int GetTotalCount(); int GetTotalCount() override;
std::map<int, ClientData>* GetContainer(); std::map<int, ClientData>* GetContainer() override;
private: private:
friend Singleton<ClientManager>; friend Singleton<ClientManager>;
+12 -11
View File
@@ -36,20 +36,21 @@ class DoorManager:
{ {
public: public:
//common public methods //common public methods
int Create(std::string, Vector2); int Create(std::string, Vector2) override;
int Load(std::string, Vector2); int Load(std::string, Vector2) override;
int Save(int uid); int Save(int uid) override;
void Unload(int uid); void Unload(int uid) override;
void Delete(int uid); void Delete(int uid) override;
void UnloadAll(); void UnloadAll() override;
void UnloadIf(std::function<bool(std::pair<const int, DoorData>)> fn); void UnloadIf(std::function<bool(std::pair<const int, DoorData>)> fn) override;
//accessors & mutators //accessors & mutators
DoorData* Get(int uid); DoorData* Get(int uid) override;
int GetLoadedCount(); int GetLoadedCount() override;
int GetTotalCount(); int GetTotalCount() override;
std::map<int, DoorData>* GetContainer(); std::map<int, DoorData>* GetContainer() override;
private: private:
friend Singleton<DoorManager>; friend Singleton<DoorManager>;
+2 -2
View File
@@ -24,12 +24,12 @@ OUTDIR=../out
OUT=$(addprefix $(OUTDIR)/,server) OUT=$(addprefix $(OUTDIR)/,server)
#targets #targets
all: $(OBJ) $(OUT) all: $(OUT)
$(MAKE) -C accounts $(MAKE) -C accounts
$(MAKE) -C characters $(MAKE) -C characters
$(MAKE) -C rooms $(MAKE) -C rooms
$(MAKE) -C server_utilities $(MAKE) -C server_utilities
$(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS) # $(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS)
$(OBJ): | $(OBJDIR) $(OBJ): | $(OBJDIR)
+15 -15
View File
@@ -43,26 +43,26 @@ class MonsterManager:
{ {
public: public:
//common public methods //common public methods
int Create(std::string); int Create(std::string) override;
int Load(std::string); int Load(std::string) override;
int Save(int uid); int Save(int uid) override;
void Unload(int uid); void Unload(int uid) override;
void Delete(int uid); void Delete(int uid) override;
void UnloadAll(); void UnloadAll() override;
void UnloadIf(std::function<bool(std::pair<const int, MonsterData>)> fn); void UnloadIf(std::function<bool(std::pair<const int, MonsterData>)> fn) override;
//accessors & mutators //accessors & mutators
MonsterData* Get(int uid); MonsterData* Get(int uid) override;
int GetLoadedCount(); int GetLoadedCount() override;
int GetTotalCount(); int GetTotalCount() override;
std::map<int, MonsterData>* GetContainer(); std::map<int, MonsterData>* GetContainer() override;
//hooks //hooks
sqlite3* SetDatabase(sqlite3* db); sqlite3* SetDatabase(sqlite3* db) override;
sqlite3* GetDatabase(); sqlite3* GetDatabase() override;
lua_State* SetLuaState(lua_State* L); lua_State* SetLuaState(lua_State* L) override;
lua_State* GetLuaState(); lua_State* GetLuaState() override;
private: private:
friend Singleton<MonsterManager>; friend Singleton<MonsterManager>;
+1 -1
View File
@@ -1,5 +1,5 @@
#config #config
INCLUDES+=. ../server_utilities ../../common/map ../../common/utilities INCLUDES+=. ../entities ../server_utilities ../../common/map ../../common/utilities
LIBS+= LIBS+=
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
+23
View File
@@ -0,0 +1,23 @@
/* 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 "room_data.hpp"
+10 -3
View File
@@ -22,9 +22,12 @@
#ifndef ROOMDATA_HPP_ #ifndef ROOMDATA_HPP_
#define ROOMDATA_HPP_ #define ROOMDATA_HPP_
//map system #include "entity.hpp"
#include "region_pager_lua.hpp" #include "region_pager_lua.hpp"
#include "lua.hpp"
#include <list>
#include <string> #include <string>
class RoomData { class RoomData {
@@ -48,8 +51,12 @@ private:
RegionPagerLua pager; RegionPagerLua pager;
std::string roomName; std::string roomName;
std::string tilesetName; std::string tilesetName;
//TODO: pass the room name & tileset name to the clients std::list<Entity*> entityList;
//TODO: lua references i.e. create, unload, etc.
//lua references
int createRef = LUA_NOREF;
int loadRef = LUA_NOREF;
int unloadRef = LUA_NOREF;
}; };
#endif #endif
+2 -2
View File
@@ -29,7 +29,7 @@
//public access methods //public access methods
//------------------------- //-------------------------
int RoomManager::Create() { int RoomManager::Create(std::string roomName, std::string tilesetName) {
//create the room //create the room
RoomData* newRoom = &elementMap[counter]; //implicitly constructs the element RoomData* newRoom = &elementMap[counter]; //implicitly constructs the element
newRoom->pager.SetLuaState(lua); newRoom->pager.SetLuaState(lua);
@@ -38,7 +38,7 @@ int RoomManager::Create() {
return counter++; return counter++;
} }
int RoomManager::Load() { int RoomManager::Load(std::string roomName, std::string tilesetName) {
//TODO: RoomManager::Load() //TODO: RoomManager::Load()
return -1; return -1;
} }
+3 -3
View File
@@ -34,12 +34,12 @@
class RoomManager: class RoomManager:
public Singleton<RoomManager>, public Singleton<RoomManager>,
public ManagerInterface<RoomData> public ManagerInterface<RoomData, std::string, std::string>
{ {
public: public:
//common public methods //common public methods
int Create() override; int Create(std::string, std::string) override;
int Load() override; int Load(std::string, std::string) override;
int Save(int uid) override; int Save(int uid) override;
void Unload(int uid) override; void Unload(int uid) override;
void Delete(int uid) override; void Delete(int uid) override;