mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2026-02-05 04:10:04 +00:00
Assorted cleanups and fixes.
* Clean up spacing/indentation * Proper enum formatting * Fix nano dismissal (for real this time) * Do not copy Player struct when a pointer is right there * Stop looking after the trade partner has been found * Make sure we're shifting unsigned values (and 64-bit when they need to be) * Look for JSONs in tdata/ * Add a dbsaveinterval to the example config.ini, in the login category
This commit is contained in:
@@ -33,7 +33,7 @@ void CNShardServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
||||
void CNShardServer::keepAliveTimer(CNServer* serv, uint64_t currTime) {
|
||||
auto cachedPlayers = PlayerManager::players;
|
||||
|
||||
for (auto pair : cachedPlayers) {
|
||||
for (auto& pair : cachedPlayers) {
|
||||
if (pair.second.lastHeartbeat != 0 && currTime - pair.second.lastHeartbeat > 60000) { // if the client hadn't responded in 60 seconds, its a dead connection so throw it out
|
||||
pair.first->kill();
|
||||
continue;
|
||||
@@ -47,9 +47,10 @@ 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);
|
||||
}
|
||||
|
||||
for (auto& pair : cachedPlayers) {
|
||||
Database::updatePlayer(pair.second.plr);
|
||||
}
|
||||
}
|
||||
|
||||
void CNShardServer::newConnection(CNSocket* cns) {
|
||||
@@ -61,8 +62,8 @@ void CNShardServer::killConnection(CNSocket* cns) {
|
||||
if (PlayerManager::players.find(cns) == PlayerManager::players.end())
|
||||
return;
|
||||
|
||||
//save player to DB
|
||||
Database::updatePlayer(*PlayerManager::players[cns].plr);
|
||||
// save player to DB
|
||||
Database::updatePlayer(PlayerManager::players[cns].plr);
|
||||
|
||||
// remove from CNSharedData
|
||||
int64_t key = PlayerManager::getPlayer(cns)->SerialKey;
|
||||
|
||||
Reference in New Issue
Block a user