fix(Core): Crashfix. (#12643)

This commit is contained in:
UltraNix
2022-08-07 23:22:12 +02:00
committed by GitHub
parent 49eb94c93d
commit 1c6eab5856
6 changed files with 17 additions and 38 deletions

View File

@@ -14248,16 +14248,9 @@ void Player::_SaveEntryPoint(CharacterDatabaseTransaction trans)
stmt->SetData (3, m_entryPointData.joinPos.GetPositionZ());
stmt->SetData (4, m_entryPointData.joinPos.GetOrientation());
stmt->SetData(5, m_entryPointData.joinPos.GetMapId());
std::ostringstream ss("");
if (m_entryPointData.HasTaxiPath())
{
for (size_t i = 0; i < m_entryPointData.taxiPath.size(); ++i)
ss << m_entryPointData.taxiPath[i] << ' '; // xinef: segment is stored as last point
}
stmt->SetData(6, ss.str());
stmt->SetData(7, m_entryPointData.mountSpell);
stmt->SetData(6, m_entryPointData.taxiPath[0]);
stmt->SetData(7, m_entryPointData.taxiPath[1]);
stmt->SetData(8, m_entryPointData.mountSpell);
trans->Append(stmt);
}

View File

@@ -1035,11 +1035,11 @@ struct EntryPointData
}
uint32 mountSpell{0};
std::vector<uint32> taxiPath;
std::array<uint32, 2> taxiPath;
WorldLocation joinPos;
void ClearTaxiPath() { taxiPath.clear(); }
[[nodiscard]] bool HasTaxiPath() const { return !taxiPath.empty(); }
void ClearTaxiPath() { taxiPath.fill(0); }
[[nodiscard]] bool HasTaxiPath() const { return taxiPath[0] && taxiPath[1]; }
};
class Player : public Unit, public GridObject<Player>

View File

@@ -4894,21 +4894,9 @@ void Player::_LoadEntryPointData(PreparedQueryResult result)
fields[2].Get<float>(), // Z
fields[3].Get<float>()); // Orientation
std::string_view taxi = fields[5].Get<std::string_view>();
if (!taxi.empty())
{
for (auto const& itr : Acore::Tokenize(taxi, ' ', false))
{
uint32 node = Acore::StringTo<uint32>(itr).value_or(0);
m_entryPointData.taxiPath.emplace_back(node);
}
// Check integrity
if (m_entryPointData.taxiPath.size() < 3)
m_entryPointData.ClearTaxiPath();
}
m_entryPointData.mountSpell = fields[6].Get<uint32>();
m_entryPointData.taxiPath[0] = fields[5].Get<uint32>();
m_entryPointData.taxiPath[1] = fields[6].Get<uint32>();
m_entryPointData.mountSpell = fields[7].Get<uint32>();
}
bool Player::LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, ObjectGuid::LowType guid)