mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-14 07:21:48 +00:00
[Commands] Resolve issue with #giveitem crash with no target. (#1425)
This commit is contained in:
parent
249cbb7bc7
commit
27cf5a4068
140
zone/command.cpp
140
zone/command.cpp
@ -8137,74 +8137,82 @@ 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 (link_open != link_close && (cmd_msg.length() - link_open) > EQ::constants::SAY_LINK_BODY_SIZE) {
|
if (c->GetTarget()) {
|
||||||
EQ::SayLinkBody_Struct link_body;
|
if (!c->GetTarget()->IsClient()) {
|
||||||
EQ::saylink::DegenerateLinkBody(link_body, cmd_msg.substr(link_open + 1, EQ::constants::SAY_LINK_BODY_SIZE));
|
c->Message(Chat::Red, "You can only give items to players with this command.");
|
||||||
item_id = link_body.item_id;
|
return;
|
||||||
augment_one = link_body.augment_1;
|
}
|
||||||
augment_two = link_body.augment_2;
|
|
||||||
augment_three = link_body.augment_3;
|
if (link_open != link_close && (cmd_msg.length() - link_open) > EQ::constants::SAY_LINK_BODY_SIZE) {
|
||||||
augment_four = link_body.augment_4;
|
EQ::SayLinkBody_Struct link_body;
|
||||||
augment_five = link_body.augment_5;
|
EQ::saylink::DegenerateLinkBody(link_body, cmd_msg.substr(link_open + 1, EQ::constants::SAY_LINK_BODY_SIZE));
|
||||||
augment_six = link_body.augment_6;
|
item_id = link_body.item_id;
|
||||||
} else if (sep->IsNumber(1)) {
|
augment_one = link_body.augment_1;
|
||||||
item_id = atoi(sep->arg[1]);
|
augment_two = link_body.augment_2;
|
||||||
} else if (!sep->IsNumber(1)) {
|
augment_three = link_body.augment_3;
|
||||||
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.)");
|
augment_four = link_body.augment_4;
|
||||||
} else if (!c->GetTarget()) {
|
augment_five = link_body.augment_5;
|
||||||
|
augment_six = link_body.augment_6;
|
||||||
|
} else if (sep->IsNumber(1)) {
|
||||||
|
item_id = atoi(sep->arg[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.)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Client *client_target = c->GetTarget()->CastToClient();
|
||||||
|
uint8 item_status = 0;
|
||||||
|
uint8 current_status = c->Admin();
|
||||||
|
const EQ::ItemData* item = database.GetItem(item_id);
|
||||||
|
if (item) {
|
||||||
|
item_status = item->MinStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item_status > current_status) {
|
||||||
|
c->Message(
|
||||||
|
Chat::White,
|
||||||
|
fmt::format(
|
||||||
|
"Insufficient status to summon this item, current status is {}, required status is {}.",
|
||||||
|
current_status,
|
||||||
|
item_status
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arguments >= 2 && sep->IsNumber(2)) {
|
||||||
|
charges = atoi(sep->arg[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arguments >= 3 && sep->IsNumber(3)) {
|
||||||
|
augment_one = atoi(sep->arg[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arguments >= 4 && sep->IsNumber(4)) {
|
||||||
|
augment_two = atoi(sep->arg[4]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arguments >= 5 && sep->IsNumber(5)) {
|
||||||
|
augment_three = atoi(sep->arg[5]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arguments >= 6 && sep->IsNumber(6)) {
|
||||||
|
augment_four = atoi(sep->arg[6]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arguments >= 7 && sep->IsNumber(7)) {
|
||||||
|
augment_five = atoi(sep->arg[7]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arguments == 8 && sep->IsNumber(8)) {
|
||||||
|
augment_six = atoi(sep->arg[8]);
|
||||||
|
}
|
||||||
|
|
||||||
|
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.");
|
c->Message(Chat::Red, "You must target a client to give the item to.");
|
||||||
} else if (!c->GetTarget()->IsClient()) {
|
return;
|
||||||
c->Message(Chat::Red, "You can only give items to players with this command.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *client_target = c->GetTarget()->CastToClient();
|
|
||||||
uint8 item_status = 0;
|
|
||||||
uint8 current_status = c->Admin();
|
|
||||||
const EQ::ItemData* item = database.GetItem(item_id);
|
|
||||||
if (item) {
|
|
||||||
item_status = item->MinStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item_status > current_status) {
|
|
||||||
c->Message(
|
|
||||||
Chat::White,
|
|
||||||
fmt::format(
|
|
||||||
"Insufficient status to summon this item, current status is {}, required status is {}.",
|
|
||||||
current_status,
|
|
||||||
item_status
|
|
||||||
).c_str()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arguments >= 2 && sep->IsNumber(2)) {
|
|
||||||
charges = atoi(sep->arg[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arguments >= 3 && sep->IsNumber(3)) {
|
|
||||||
augment_one = atoi(sep->arg[3]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arguments >= 4 && sep->IsNumber(4)) {
|
|
||||||
augment_two = atoi(sep->arg[4]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arguments >= 5 && sep->IsNumber(5)) {
|
|
||||||
augment_three = atoi(sep->arg[5]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arguments >= 6 && sep->IsNumber(6)) {
|
|
||||||
augment_four = atoi(sep->arg[6]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arguments >= 7 && sep->IsNumber(7)) {
|
|
||||||
augment_five = atoi(sep->arg[7]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arguments == 8 && sep->IsNumber(8)) {
|
|
||||||
augment_six = atoi(sep->arg[8]);
|
|
||||||
}
|
|
||||||
|
|
||||||
client_target->SummonItem(item_id, charges, augment_one, augment_two, augment_three, augment_four, augment_five, augment_six);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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