[Crash] Fix crash in #movechar (#3612)

This commit is contained in:
Chris Miles 2023-10-07 14:00:27 -05:00 committed by GitHub
parent d8926cd5f3
commit cea3ad6a42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,7 +46,12 @@ void command_movechar(Client *c, const Seperator *sep)
} }
auto zone_id = ZoneID(zone_short_name); auto zone_id = ZoneID(zone_short_name);
std::string zone_long_name = ZoneLongName(zone_id); auto z = GetZone(zone_id);
if (!z) {
c->Message(Chat::Red, "Invalid zone.");
return;
}
bool is_special_zone = ( bool is_special_zone = (
zone_short_name.find("cshome") != std::string::npos || zone_short_name.find("cshome") != std::string::npos ||
@ -59,7 +64,7 @@ void command_movechar(Client *c, const Seperator *sep)
Chat::White, Chat::White,
fmt::format( fmt::format(
"{} ({}) is a special zone and you cannot move someone there.", "{} ({}) is a special zone and you cannot move someone there.",
zone_long_name, z->long_name,
zone_short_name zone_short_name
).c_str() ).c_str()
); );
@ -91,7 +96,7 @@ void command_movechar(Client *c, const Seperator *sep)
fmt::format( fmt::format(
"Character Move {} | Zone: {} ({}) ID: {}", "Character Move {} | Zone: {} ({}) ID: {}",
moved_string, moved_string,
zone_long_name, z->long_name,
zone_short_name, zone_short_name,
zone_id zone_id
).c_str() ).c_str()