Began refactoring the server (read more)

* deleted the enemy and combat stubs
* encapsulated the character and account stubs

TODO:

* The remaining managers should be singletons
This commit is contained in:
Kayne Ruse
2014-08-13 09:45:54 +10:00
parent b6c70cbc0d
commit 6d98bab000
11 changed files with 80 additions and 429 deletions
-52
View File
@@ -1,52 +0,0 @@
/* 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.
*/
#ifndef COMBATDATA_HPP_
#define COMBATDATA_HPP_
#include "vector2.hpp"
#include "combat_defines.hpp"
//gameplay members
#include "character_data.hpp"
#include "enemy_data.hpp"
//std namespace
#include <chrono>
#include <array>
#include <utility>
struct CombatData {
typedef std::chrono::steady_clock Clock;
std::array<CharacterData, COMBAT_MAX_CHARACTERS> characterArray;
std::array<EnemyData, COMBAT_MAX_ENEMIES> enemyArray;
//world interaction
int mapIndex = 0;
Vector2 origin = {0.0,0.0};
Vector2 bounds = {0.0,0.0};
//time interval
Clock::time_point lastTick = Clock::now();
};
#endif
-54
View File
@@ -1,54 +0,0 @@
/* 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 "combat_manager.hpp"
//-------------------------
//public access methods
//-------------------------
//TODO
//-------------------------
//accessors and mutators
//-------------------------
CombatData* CombatManager::GetCombat(int uid) {
std::map<int, CombatData>::iterator it = combatMap.find(uid);
if (it == combatMap.end()) {
return nullptr;
}
return &it->second;
}
std::map<int, CombatData>* CombatManager::GetContainer() {
return &combatMap;
}
lua_State* CombatManager::SetLuaState(lua_State* L) {
return luaState = L;
}
lua_State* CombatManager::GetLuaState() {
return luaState;
}
-51
View File
@@ -1,51 +0,0 @@
/* 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.
*/
#ifndef COMBATMANAGER_HPP_
#define COMBATMANAGER_HPP_
#include "combat_data.hpp"
#include "lua/lua.hpp"
#include <map>
class CombatManager {
public:
CombatManager() = default;
~CombatManager() = default;
//public access methods
//TODO
//accessors and mutators
CombatData* GetCombat(int uid);
std::map<int, CombatData>* GetContainer();
lua_State* SetLuaState(lua_State*);
lua_State* GetLuaState();
private:
std::map<int, CombatData> combatMap;
lua_State* luaState = nullptr;
};
#endif
-37
View File
@@ -1,37 +0,0 @@
#config
INCLUDES+=. ../../common/gameplay ../../common/utilities ../characters ../enemies
LIBS+=
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
#source
CXXSRC=$(wildcard *.cpp)
#objects
OBJDIR=obj
OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o))
#output
OUTDIR=..
OUT=$(addprefix $(OUTDIR)/,server.a)
#targets
all: $(OBJ) $(OUT)
ar -crs $(OUT) $(OBJ)
$(OBJ): | $(OBJDIR)
$(OUT): | $(OUTDIR)
$(OBJDIR):
mkdir $(OBJDIR)
$(OUTDIR):
mkdir $(OUTDIR)
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all