mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 23:01:30 +00:00
[Commands] Resolve issue with #giveitem crash with no target. (#1425)
This commit is contained in:
parent
249cbb7bc7
commit
27cf5a4068
@ -8137,6 +8137,12 @@ void command_giveitem(Client *c, const Seperator *sep)
|
|||||||
std::string cmd_msg = sep->msg;
|
std::string cmd_msg = sep->msg;
|
||||||
size_t link_open = cmd_msg.find('\x12');
|
size_t link_open = cmd_msg.find('\x12');
|
||||||
size_t link_close = cmd_msg.find_last_of('\x12');
|
size_t link_close = cmd_msg.find_last_of('\x12');
|
||||||
|
if (c->GetTarget()) {
|
||||||
|
if (!c->GetTarget()->IsClient()) {
|
||||||
|
c->Message(Chat::Red, "You can only give items to players with this command.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (link_open != link_close && (cmd_msg.length() - link_open) > EQ::constants::SAY_LINK_BODY_SIZE) {
|
if (link_open != link_close && (cmd_msg.length() - link_open) > EQ::constants::SAY_LINK_BODY_SIZE) {
|
||||||
EQ::SayLinkBody_Struct link_body;
|
EQ::SayLinkBody_Struct link_body;
|
||||||
EQ::saylink::DegenerateLinkBody(link_body, cmd_msg.substr(link_open + 1, EQ::constants::SAY_LINK_BODY_SIZE));
|
EQ::saylink::DegenerateLinkBody(link_body, cmd_msg.substr(link_open + 1, EQ::constants::SAY_LINK_BODY_SIZE));
|
||||||
@ -8151,10 +8157,7 @@ void command_giveitem(Client *c, const Seperator *sep)
|
|||||||
item_id = atoi(sep->arg[1]);
|
item_id = atoi(sep->arg[1]);
|
||||||
} else if (!sep->IsNumber(1)) {
|
} else if (!sep->IsNumber(1)) {
|
||||||
c->Message(Chat::Red, "Usage: #giveitem [item id | link] [charges] [augment_one_id] [augment_two_id] [augment_three_id] [augment_four_id] [augment_five_id] [augment_six_id] (Charges are optional.)");
|
c->Message(Chat::Red, "Usage: #giveitem [item id | link] [charges] [augment_one_id] [augment_two_id] [augment_three_id] [augment_four_id] [augment_five_id] [augment_six_id] (Charges are optional.)");
|
||||||
} else if (!c->GetTarget()) {
|
return;
|
||||||
c->Message(Chat::Red, "You must target a client to give the item to.");
|
|
||||||
} else if (!c->GetTarget()->IsClient()) {
|
|
||||||
c->Message(Chat::Red, "You can only give items to players with this command.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *client_target = c->GetTarget()->CastToClient();
|
Client *client_target = c->GetTarget()->CastToClient();
|
||||||
@ -8174,6 +8177,7 @@ void command_giveitem(Client *c, const Seperator *sep)
|
|||||||
item_status
|
item_status
|
||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arguments >= 2 && sep->IsNumber(2)) {
|
if (arguments >= 2 && sep->IsNumber(2)) {
|
||||||
@ -8205,6 +8209,10 @@ void command_giveitem(Client *c, const Seperator *sep)
|
|||||||
}
|
}
|
||||||
|
|
||||||
client_target->SummonItem(item_id, charges, augment_one, augment_two, augment_three, augment_four, augment_five, augment_six);
|
client_target->SummonItem(item_id, charges, augment_one, augment_two, augment_three, augment_four, augment_five, augment_six);
|
||||||
|
} else {
|
||||||
|
c->Message(Chat::Red, "You must target a client to give the item to.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void command_givemoney(Client *c, const Seperator *sep)
|
void command_givemoney(Client *c, const Seperator *sep)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user