mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
added periodic DB saves, fixed some settings
This commit is contained in:
parent
1d9a7139a8
commit
3d83f93167
@ -17,6 +17,7 @@ CNShardServer::CNShardServer(uint16_t p) {
|
|||||||
port = p;
|
port = p;
|
||||||
pHandler = &CNShardServer::handlePacket;
|
pHandler = &CNShardServer::handlePacket;
|
||||||
REGISTER_SHARD_TIMER(keepAliveTimer, 2000);
|
REGISTER_SHARD_TIMER(keepAliveTimer, 2000);
|
||||||
|
REGISTER_SHARD_TIMER(periodicSaveTimer, settings::DBSAVEINTERVAL*1000);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,6 +45,13 @@ void CNShardServer::keepAliveTimer(CNServer* serv, uint64_t currTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CNShardServer::periodicSaveTimer(CNServer* serv, uint64_t currTime) {
|
||||||
|
auto cachedPlayers = PlayerManager::players;
|
||||||
|
for (auto pair : cachedPlayers) {
|
||||||
|
Database::updatePlayer(*pair.second.plr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CNShardServer::newConnection(CNSocket* cns) {
|
void CNShardServer::newConnection(CNSocket* cns) {
|
||||||
cns->setActiveKey(SOCKETKEY_E); // by default they accept keys encrypted with the default key
|
cns->setActiveKey(SOCKETKEY_E); // by default they accept keys encrypted with the default key
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ private:
|
|||||||
static void handlePacket(CNSocket* sock, CNPacketData* data);
|
static void handlePacket(CNSocket* sock, CNPacketData* data);
|
||||||
|
|
||||||
static void keepAliveTimer(CNServer*, uint64_t);
|
static void keepAliveTimer(CNServer*, uint64_t);
|
||||||
|
static void periodicSaveTimer(CNServer* serv, uint64_t currTime);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static std::map<uint32_t, PacketHandler> ShardPackets;
|
static std::map<uint32_t, PacketHandler> ShardPackets;
|
||||||
|
@ -7,6 +7,7 @@ int settings::VERBOSITY = 1;
|
|||||||
|
|
||||||
int settings::LOGINPORT = 8001;
|
int settings::LOGINPORT = 8001;
|
||||||
bool settings::APPROVEALLNAMES = true;
|
bool settings::APPROVEALLNAMES = true;
|
||||||
|
int settings::DBSAVEINTERVAL = 240;
|
||||||
|
|
||||||
int settings::SHARDPORT = 8002;
|
int settings::SHARDPORT = 8002;
|
||||||
std::string settings::SHARDSERVERIP = "127.0.0.1";
|
std::string settings::SHARDSERVERIP = "127.0.0.1";
|
||||||
@ -41,6 +42,7 @@ void settings::init() {
|
|||||||
LOGINPORT = reader.GetInteger("login", "port", LOGINPORT);
|
LOGINPORT = reader.GetInteger("login", "port", LOGINPORT);
|
||||||
SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT);
|
SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT);
|
||||||
SHARDSERVERIP = reader.Get("shard", "ip", "127.0.0.1");
|
SHARDSERVERIP = reader.Get("shard", "ip", "127.0.0.1");
|
||||||
|
DBSAVEINTERVAL = reader.GetInteger("shard", "dbsaveinterval", DBSAVEINTERVAL);
|
||||||
PLAYERDISTANCE = reader.GetInteger("shard", "playerdistance", PLAYERDISTANCE);
|
PLAYERDISTANCE = reader.GetInteger("shard", "playerdistance", PLAYERDISTANCE);
|
||||||
NPCDISTANCE = reader.GetInteger("shard", "npcdistance", NPCDISTANCE);
|
NPCDISTANCE = reader.GetInteger("shard", "npcdistance", NPCDISTANCE);
|
||||||
SPAWN_X = reader.GetInteger("shard", "spawnx", SPAWN_X);
|
SPAWN_X = reader.GetInteger("shard", "spawnx", SPAWN_X);
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
namespace settings {
|
namespace settings {
|
||||||
extern int VERBOSITY;
|
extern int VERBOSITY;
|
||||||
extern int LOGINPORT;
|
extern int LOGINPORT;
|
||||||
extern bool LOGINRANDCHARACTERS;
|
|
||||||
extern bool APPROVEALLNAMES;
|
extern bool APPROVEALLNAMES;
|
||||||
|
extern int DBSAVEINTERVAL;
|
||||||
extern int SHARDPORT;
|
extern int SHARDPORT;
|
||||||
extern std::string SHARDSERVERIP;
|
extern std::string SHARDSERVERIP;
|
||||||
extern int PLAYERDISTANCE;
|
extern int PLAYERDISTANCE;
|
||||||
|
Loading…
Reference in New Issue
Block a user