[Zoning] Fix zone race condition (#2479)

* Testing

* Separate auto shutdown fix

* Revert for PR

* Invalidate lock in places where zoning is cancelled
This commit is contained in:
Chris Miles 2022-10-11 21:23:27 -04:00 committed by GitHub
parent 18bfee5616
commit bc72641eef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 6 deletions

View File

@ -232,8 +232,9 @@ Client::Client(EQStreamInterface* ieqs)
linkdead_timer.Disable();
zonesummon_id = 0;
zonesummon_ignorerestrictions = 0;
bZoning = false;
zone_mode = ZoneUnsolicited;
bZoning = false;
m_lock_save_position = false;
zone_mode = ZoneUnsolicited;
casting_spell_id = 0;
npcflag = false;
npclevel = 0;
@ -634,11 +635,14 @@ bool Client::Save(uint8 iCommitNow) {
return false;
/* Wrote current basics to PP for saves */
m_pp.x = m_Position.x;
m_pp.y = m_Position.y;
m_pp.z = m_Position.z;
if (!m_lock_save_position) {
m_pp.x = m_Position.x;
m_pp.y = m_Position.y;
m_pp.z = m_Position.z;
m_pp.heading = m_Position.w;
}
m_pp.guildrank = guildrank;
m_pp.heading = m_Position.w;
/* Mana and HP */
if (GetHP() <= 0) {
@ -11827,3 +11831,13 @@ bool Client::HasRecipeLearned(uint32 recipe_id)
return false;
}
bool Client::IsLockSavePosition() const
{
return m_lock_save_position;
}
void Client::SetLockSavePosition(bool lock_save_position)
{
Client::m_lock_save_position = lock_save_position;
}

View File

@ -1801,6 +1801,13 @@ private:
int32 max_end;
int32 current_endurance;
// https://github.com/EQEmu/Server/pull/2479
bool m_lock_save_position = false;
public:
bool IsLockSavePosition() const;
void SetLockSavePosition(bool lock_save_position);
private:
PlayerProfile_Struct m_pp;
ExtendedProfile_Struct m_epp;
EQ::InventoryProfile m_inv;

View File

@ -365,6 +365,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
zc2->success = ZONE_ERROR_NOTREADY;
entity->CastToMob()->SetZone(ztz->current_zone_id, ztz->current_instance_id);
entity->CastToClient()->SetZoning(false);
entity->CastToClient()->SetLockSavePosition(false);
}
else {
entity->CastToClient()->UpdateWho(1);

View File

@ -394,6 +394,8 @@ void Client::SendZoneCancel(ZoneChange_Struct *zc) {
zone_mode = ZoneUnsolicited;
// reset since we're not zoning anymore
bZoning = false;
// remove save position lock
m_lock_save_position = false;
}
void Client::SendZoneError(ZoneChange_Struct *zc, int8 err)
@ -413,6 +415,8 @@ void Client::SendZoneError(ZoneChange_Struct *zc, int8 err)
zone_mode = ZoneUnsolicited;
// reset since we're not zoning anymore
bZoning = false;
// remove save position lock
m_lock_save_position = false;
}
void Client::DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instance_id, float dest_x, float dest_y, float dest_z, float dest_h, int8 ignore_r) {
@ -467,6 +471,8 @@ void Client::DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instanc
//Force a save so its waiting for them when they zone
Save(2);
m_lock_save_position = true;
if (zone_id == zone->GetZoneID() && instance_id == zone->GetInstanceID()) {
// No need to ask worldserver if we're zoning to ourselves (most
// likely to a bind point), also fixes a bug since the default response was failure