Server is nearly done, only server_application.cpp is failing
This commit is contained in:
@@ -36,6 +36,16 @@ static const char* DELETE_USER_ACCOUNT = "DELETE FROM Accounts WHERE uid = ?;";
|
||||
//Define the public methods
|
||||
//-------------------------
|
||||
|
||||
AccountManager::AccountManager() {
|
||||
//
|
||||
}
|
||||
|
||||
AccountManager::~AccountManager() {
|
||||
for (auto& it : accountMap) {
|
||||
SaveUserAccount(it.first);
|
||||
}
|
||||
}
|
||||
|
||||
int AccountManager::CreateUserAccount(std::string username, int clientIndex) {
|
||||
//create this user account, failing if it exists, leave this account in memory
|
||||
sqlite3_stmt* statement = nullptr;
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
|
||||
class AccountManager {
|
||||
public:
|
||||
AccountManager() = default;
|
||||
~AccountManager() = default;
|
||||
AccountManager();
|
||||
~AccountManager();
|
||||
|
||||
//public access methods
|
||||
int CreateUserAccount(std::string username, int clientIndex);
|
||||
|
||||
@@ -58,6 +58,16 @@ static const char* DELETE_CHARACTER = "DELETE FROM Characters WHERE uid = ?;";
|
||||
//Define the methods
|
||||
//-------------------------
|
||||
|
||||
CharacterManager::CharacterManager() {
|
||||
//
|
||||
}
|
||||
|
||||
CharacterManager::~CharacterManager() {
|
||||
for (auto& it : characterMap) {
|
||||
SaveCharacter(it.first);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: should statistics be stored separately?
|
||||
//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) {
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
|
||||
class CharacterManager {
|
||||
public:
|
||||
CharacterManager() = default;
|
||||
~CharacterManager() = default;
|
||||
CharacterManager();
|
||||
~CharacterManager();
|
||||
|
||||
//public access methods
|
||||
int CreateCharacter(int owner, std::string handle, std::string avatar);
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#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
|
||||
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ void ServerApplication::Init(int argc, char** argv) {
|
||||
|
||||
combatMgr.SetLuaState(luaState);
|
||||
roomMgr.SetLuaState(luaState);
|
||||
enemyMgr.SetLuaState(luaState);
|
||||
|
||||
std::cout << "Internal managers ready" << std::endl;
|
||||
|
||||
@@ -133,19 +134,6 @@ void ServerApplication::Proc() {
|
||||
void ServerApplication::Quit() {
|
||||
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
|
||||
lua_close(luaState);
|
||||
sqlite3_close_v2(database);
|
||||
|
||||
@@ -23,10 +23,11 @@
|
||||
#define SERVERAPPLICATION_HPP_
|
||||
|
||||
//server specific stuff
|
||||
#include "client_data.hpp"
|
||||
#include "account_manager.hpp"
|
||||
#include "character_manager.hpp"
|
||||
#include "client_data.hpp"
|
||||
#include "combat_manager.hpp"
|
||||
#include "enemy_manager.hpp"
|
||||
#include "room_manager.hpp"
|
||||
|
||||
//maps
|
||||
@@ -96,13 +97,14 @@ private:
|
||||
UDPNetworkUtility network;
|
||||
ConfigUtility config;
|
||||
|
||||
//server tables
|
||||
//simple tables
|
||||
std::map<int, ClientData> clientMap;
|
||||
|
||||
//managers
|
||||
AccountManager accountMgr;
|
||||
CharacterManager characterMgr;
|
||||
CombatManager combatMgr;
|
||||
EnemyManager enemyMgr;
|
||||
RoomManager roomMgr;
|
||||
|
||||
//misc
|
||||
|
||||
Reference in New Issue
Block a user