mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
Revert "fix: update player container on shutdown (#1704)"
This reverts commit 3ecbd1013b
.
This commit is contained in:
@@ -57,32 +57,13 @@ void PlayerContainer::InsertPlayer(Packet* packet) {
|
||||
LOG("Added user: %s (%llu), zone: %i", data.playerName.c_str(), data.playerID, data.zoneID.GetMapID());
|
||||
|
||||
Database::Get()->UpdateActivityLog(data.playerID, eActivityType::PlayerLoggedIn, data.zoneID.GetMapID());
|
||||
m_PlayersToRemove.erase(playerId);
|
||||
}
|
||||
|
||||
void PlayerContainer::ScheduleRemovePlayer(Packet* packet) {
|
||||
void PlayerContainer::RemovePlayer(Packet* packet) {
|
||||
CINSTREAM_SKIP_HEADER;
|
||||
LWOOBJID playerID{ LWOOBJID_EMPTY };
|
||||
LWOOBJID playerID;
|
||||
inStream.Read(playerID);
|
||||
constexpr float updatePlayerOnLogoutTime = 20.0f;
|
||||
if (playerID != LWOOBJID_EMPTY) m_PlayersToRemove.insert_or_assign(playerID, updatePlayerOnLogoutTime);
|
||||
}
|
||||
|
||||
void PlayerContainer::Update(const float deltaTime) {
|
||||
for (auto it = m_PlayersToRemove.begin(); it != m_PlayersToRemove.end();) {
|
||||
auto& [id, time] = *it;
|
||||
time -= deltaTime;
|
||||
|
||||
if (time <= 0.0f) {
|
||||
RemovePlayer(id);
|
||||
it = m_PlayersToRemove.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerContainer::RemovePlayer(const LWOOBJID playerID) {
|
||||
//Before they get kicked, we need to also send a message to their friends saying that they disconnected.
|
||||
const auto& player = GetPlayerData(playerID);
|
||||
|
||||
@@ -436,13 +417,3 @@ const PlayerData& PlayerContainer::GetPlayerData(const LWOOBJID& playerID) {
|
||||
const PlayerData& PlayerContainer::GetPlayerData(const std::string& playerName) {
|
||||
return GetPlayerDataMutable(playerName);
|
||||
}
|
||||
|
||||
void PlayerContainer::Shutdown() {
|
||||
m_Players.erase(LWOOBJID_EMPTY);
|
||||
while (!m_Players.empty()) {
|
||||
const auto& [id, playerData] = *m_Players.begin();
|
||||
Database::Get()->UpdateActivityLog(id, eActivityType::PlayerLoggedOut, playerData.zoneID.GetMapID());
|
||||
m_Players.erase(m_Players.begin());
|
||||
}
|
||||
for (auto* team : mTeams) if (team) delete team;
|
||||
}
|
||||
|
Reference in New Issue
Block a user