Server is nearly done, only server_application.cpp is failing

This commit is contained in:
Kayne Ruse
2014-06-06 23:34:38 +10:00
parent 10e857ecd1
commit 170096b5db
8 changed files with 31 additions and 21 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
#config #config
INCLUDES+=. ../common/gameplay ../common/graphics ../common/map ../common/network ../common/ui ../common/utilities INCLUDES+=. ../common/gameplay ../common/graphics ../common/map ../common/network ../common/network/packet ../common/network/serial ../common/ui ../common/utilities
LIBS+=../libcommon.a -lSDL_net -lwsock32 -liphlpapi -lmingw32 -lSDLmain -lSDL -llua LIBS+=../libcommon.a -lSDL_net -lwsock32 -liphlpapi -lmingw32 -lSDLmain -lSDL -llua
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) -DGRAPHICS CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) -DGRAPHICS
+10
View File
@@ -36,6 +36,16 @@ static const char* DELETE_USER_ACCOUNT = "DELETE FROM Accounts WHERE uid = ?;";
//Define the public methods //Define the public methods
//------------------------- //-------------------------
AccountManager::AccountManager() {
//
}
AccountManager::~AccountManager() {
for (auto& it : accountMap) {
SaveUserAccount(it.first);
}
}
int AccountManager::CreateUserAccount(std::string username, int clientIndex) { int AccountManager::CreateUserAccount(std::string username, int clientIndex) {
//create this user account, failing if it exists, leave this account in memory //create this user account, failing if it exists, leave this account in memory
sqlite3_stmt* statement = nullptr; sqlite3_stmt* statement = nullptr;
+2 -2
View File
@@ -30,8 +30,8 @@
class AccountManager { class AccountManager {
public: public:
AccountManager() = default; AccountManager();
~AccountManager() = default; ~AccountManager();
//public access methods //public access methods
int CreateUserAccount(std::string username, int clientIndex); int CreateUserAccount(std::string username, int clientIndex);
+10
View File
@@ -58,6 +58,16 @@ static const char* DELETE_CHARACTER = "DELETE FROM Characters WHERE uid = ?;";
//Define the methods //Define the methods
//------------------------- //-------------------------
CharacterManager::CharacterManager() {
//
}
CharacterManager::~CharacterManager() {
for (auto& it : characterMap) {
SaveCharacter(it.first);
}
}
//TODO: should statistics be stored separately? //TODO: should statistics be stored separately?
//TODO: default stats as a parameter? This would be good for differing beggining states or multiple classes //TODO: default stats as a parameter? This would be good for differing beggining states or multiple classes
int CharacterManager::CreateCharacter(int owner, std::string handle, std::string avatar) { int CharacterManager::CreateCharacter(int owner, std::string handle, std::string avatar) {
+2 -2
View File
@@ -30,8 +30,8 @@
class CharacterManager { class CharacterManager {
public: public:
CharacterManager() = default; CharacterManager();
~CharacterManager() = default; ~CharacterManager();
//public access methods //public access methods
int CreateCharacter(int owner, std::string handle, std::string avatar); int CreateCharacter(int owner, std::string handle, std::string avatar);
+1 -1
View File
@@ -1,5 +1,5 @@
#config #config
INCLUDES+=. ../common/gameplay ../common/map ../common/network ../common/script ../common/utilities INCLUDES+=. ../common/gameplay ../common/map ../common/network ../common/network/packet ../common/network/serial ../common/script ../common/utilities
LIBS+=../libcommon.a -lSDL_net -lwsock32 -liphlpapi -lmingw32 -lSDLmain -lSDL -llua -lsqlite3 LIBS+=../libcommon.a -lSDL_net -lwsock32 -liphlpapi -lmingw32 -lSDLmain -lSDL -llua -lsqlite3
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
+1 -13
View File
@@ -80,6 +80,7 @@ void ServerApplication::Init(int argc, char** argv) {
combatMgr.SetLuaState(luaState); combatMgr.SetLuaState(luaState);
roomMgr.SetLuaState(luaState); roomMgr.SetLuaState(luaState);
enemyMgr.SetLuaState(luaState);
std::cout << "Internal managers ready" << std::endl; std::cout << "Internal managers ready" << std::endl;
@@ -133,19 +134,6 @@ void ServerApplication::Proc() {
void ServerApplication::Quit() { void ServerApplication::Quit() {
std::cout << "Shutting down" << std::endl; std::cout << "Shutting down" << std::endl;
//save the server state
for (auto& it : accountMap) {
SaveUserAccount(it.first);
}
for (auto& it : characterMap) {
SaveCharacter(it.first);
}
//empty the members
accountMap.clear();
characterMap.clear();
regionPager.UnloadAll();
//APIs //APIs
lua_close(luaState); lua_close(luaState);
sqlite3_close_v2(database); sqlite3_close_v2(database);
+4 -2
View File
@@ -23,10 +23,11 @@
#define SERVERAPPLICATION_HPP_ #define SERVERAPPLICATION_HPP_
//server specific stuff //server specific stuff
#include "client_data.hpp"
#include "account_manager.hpp" #include "account_manager.hpp"
#include "character_manager.hpp" #include "character_manager.hpp"
#include "client_data.hpp"
#include "combat_manager.hpp" #include "combat_manager.hpp"
#include "enemy_manager.hpp"
#include "room_manager.hpp" #include "room_manager.hpp"
//maps //maps
@@ -96,13 +97,14 @@ private:
UDPNetworkUtility network; UDPNetworkUtility network;
ConfigUtility config; ConfigUtility config;
//server tables //simple tables
std::map<int, ClientData> clientMap; std::map<int, ClientData> clientMap;
//managers //managers
AccountManager accountMgr; AccountManager accountMgr;
CharacterManager characterMgr; CharacterManager characterMgr;
CombatManager combatMgr; CombatManager combatMgr;
EnemyManager enemyMgr;
RoomManager roomMgr; RoomManager roomMgr;
//misc //misc