[Cleanup] Use variable for c->GetTarget() instead of calling multiple times in bot_command.cpp (#3254)

# Notes
- Calling multiple times is less performant than using a variable.
This commit is contained in:
Alex King 2023-04-05 10:09:19 -04:00 committed by GitHub
parent 4a0725e278
commit 2a094e8792
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2526,9 +2526,17 @@ void bot_command_apply_poison(Client *c, const Seperator *sep)
}
Bot *my_rogue_bot = nullptr;
if (c->GetTarget() && c->GetTarget()->IsBot() && c->GetTarget()->CastToBot()->GetBotOwnerCharacterID() == c->CharacterID() && c->GetTarget()->CastToBot()->GetClass() == ROGUE) {
my_rogue_bot = c->GetTarget()->CastToBot();
auto t = c->GetTarget();
if (
t &&
t->IsBot() &&
t->CastToBot()->GetBotOwnerCharacterID() == c->CharacterID() &&
t->GetClass() == ROGUE
) {
my_rogue_bot = t->CastToBot();
}
if (!my_rogue_bot) {
c->Message(Chat::White, "You must target a rogue bot that you own to use this command!");
@ -6402,13 +6410,14 @@ void bot_subcommand_bot_report(Client *c, const Seperator *sep)
std::string ab_type_arg = sep->arg[1];
if (ab_type_arg.empty()) {
if (c->GetTarget()) {
if (c->GetTarget()->IsClient() && c->GetTarget()->CastToClient() == c)
auto t = c->GetTarget();
if (t && t->IsClient()) {
if (t->CastToClient() == c) {
ab_type_arg = "ownergroup";
else if (c->GetTarget()->IsClient() && c->GetTarget()->CastToClient() != c)
} else {
ab_type_arg = "targetgroup";
}
else {
}
} else {
ab_type_arg = "spawned";
}
}