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;
|
||||
pHandler = &CNShardServer::handlePacket;
|
||||
REGISTER_SHARD_TIMER(keepAliveTimer, 2000);
|
||||
REGISTER_SHARD_TIMER(periodicSaveTimer, settings::DBSAVEINTERVAL*1000);
|
||||
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) {
|
||||
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 keepAliveTimer(CNServer*, uint64_t);
|
||||
static void periodicSaveTimer(CNServer* serv, uint64_t currTime);
|
||||
|
||||
public:
|
||||
static std::map<uint32_t, PacketHandler> ShardPackets;
|
||||
|
@ -7,6 +7,7 @@ int settings::VERBOSITY = 1;
|
||||
|
||||
int settings::LOGINPORT = 8001;
|
||||
bool settings::APPROVEALLNAMES = true;
|
||||
int settings::DBSAVEINTERVAL = 240;
|
||||
|
||||
int settings::SHARDPORT = 8002;
|
||||
std::string settings::SHARDSERVERIP = "127.0.0.1";
|
||||
@ -37,10 +38,11 @@ void settings::init() {
|
||||
}
|
||||
|
||||
APPROVEALLNAMES = reader.GetBoolean("", "acceptallcustomnames", APPROVEALLNAMES);
|
||||
VERBOSITY = reader.GetInteger("", "verbosity", VERBOSITY);
|
||||
VERBOSITY = reader.GetInteger("", "verbosity", VERBOSITY);
|
||||
LOGINPORT = reader.GetInteger("login", "port", LOGINPORT);
|
||||
SHARDPORT = reader.GetInteger("shard", "port", SHARDPORT);
|
||||
SHARDSERVERIP = reader.Get("shard", "ip", "127.0.0.1");
|
||||
DBSAVEINTERVAL = reader.GetInteger("shard", "dbsaveinterval", DBSAVEINTERVAL);
|
||||
PLAYERDISTANCE = reader.GetInteger("shard", "playerdistance", PLAYERDISTANCE);
|
||||
NPCDISTANCE = reader.GetInteger("shard", "npcdistance", NPCDISTANCE);
|
||||
SPAWN_X = reader.GetInteger("shard", "spawnx", SPAWN_X);
|
||||
|
@ -3,8 +3,8 @@
|
||||
namespace settings {
|
||||
extern int VERBOSITY;
|
||||
extern int LOGINPORT;
|
||||
extern bool LOGINRANDCHARACTERS;
|
||||
extern bool APPROVEALLNAMES;
|
||||
extern int DBSAVEINTERVAL;
|
||||
extern int SHARDPORT;
|
||||
extern std::string SHARDSERVERIP;
|
||||
extern int PLAYERDISTANCE;
|
||||
|
Loading…
Reference in New Issue
Block a user