mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2025-12-23 12:20:05 +00:00
On login, load Player from DB in shard thread, not in login thread
This avoids some needless data shuffling and fixes a rare desync.
This commit is contained in:
@@ -224,18 +224,22 @@ static void enterPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
return;
|
||||
}
|
||||
|
||||
// for convenience
|
||||
Player& plr = lm->plr;
|
||||
|
||||
plr.groupCnt = 1;
|
||||
plr.iIDGroup = plr.groupIDs[0] = plr.iID;
|
||||
Player plr = {};
|
||||
Database::getPlayer(&plr, lm->playerId);
|
||||
|
||||
// check if account is already in use
|
||||
if (isAccountInUse(plr.accountId)) {
|
||||
// kick the other player
|
||||
exitDuplicate(plr.accountId);
|
||||
|
||||
// re-read the player from disk, in case it was just flushed
|
||||
plr = {};
|
||||
Database::getPlayer(&plr, lm->playerId);
|
||||
}
|
||||
|
||||
plr.groupCnt = 1;
|
||||
plr.iIDGroup = plr.groupIDs[0] = plr.iID;
|
||||
|
||||
response.iID = plr.iID;
|
||||
response.uiSvrTime = getTime();
|
||||
response.PCLoadData2CL.iUserLevel = plr.accountLevel;
|
||||
@@ -345,7 +349,7 @@ static void enterPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
if (pair.second->notify)
|
||||
Chat::sendServerMessage(pair.first, "[ADMIN]" + getPlayerName(&plr) + " has joined.");
|
||||
|
||||
// deallocate lm (and therefore the plr object)
|
||||
// deallocate lm
|
||||
delete lm;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user