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