[Cleanup] Use variable for character instead of a loop (#3268)

# Notes
- Store character in a variable instead of looping a list of 1 entry.
This commit is contained in:
Alex King 2023-04-05 10:29:16 -04:00 committed by GitHub
parent 2742eca119
commit 82762c3f5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9226,12 +9226,17 @@ void Client::SetSecondaryWeaponOrnamentation(uint32 model_id)
*/
bool Client::GotoPlayer(std::string player_name)
{
auto characters = CharacterDataRepository::GetWhere(
const auto& l = CharacterDataRepository::GetWhere(
database,
fmt::format("name = '{}' AND last_login > (UNIX_TIMESTAMP() - 600) LIMIT 1", player_name)
);
for (auto &c: characters) {
if (l.empty()) {
return false;
}
const auto& c = l[0];
if (c.zone_instance > 0 && !database.CheckInstanceExists(c.zone_instance)) {
Message(Chat::Yellow, "Instance no longer exists...");
return false;
@ -9244,9 +9249,6 @@ bool Client::GotoPlayer(std::string player_name)
MovePC(c.zone_id, c.zone_instance, c.x, c.y, c.z, c.heading);
return true;
}
return false;
}
bool Client::GotoPlayerGroup(const std::string& player_name)