Fix send mail and send item commands (#95)
Server was crashing if no args or if no quotes were provided for args
This commit is contained in:
parent
39e4f51ac6
commit
860421ba9a
@ -1862,6 +1862,11 @@ bool ChatHandler::HandleSaveAllCommand(char* /*args*/)
|
||||
// Send mail by command
|
||||
bool ChatHandler::HandleSendMailCommand(char* args)
|
||||
{
|
||||
if (!*args)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// format: name "subject text" "mail text"
|
||||
Player* target;
|
||||
ObjectGuid target_guid;
|
||||
@ -1873,14 +1878,23 @@ bool ChatHandler::HandleSendMailCommand(char* args)
|
||||
|
||||
MailDraft draft;
|
||||
|
||||
// fill draft
|
||||
if (!HandleSendMailHelper(draft, args))
|
||||
// Subject and content should not be empty :
|
||||
if (!*args)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// fill draft
|
||||
if (!HandleSendMailHelper(draft, args))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// GM mail
|
||||
MailSender sender(MAIL_NORMAL, (uint32)0, MAIL_STATIONERY_GM);
|
||||
MailSender sender(MAIL_NORMAL, m_session ? m_session->GetPlayer()->GetGUIDLow() : (uint32)0, MAIL_STATIONERY_GM);
|
||||
|
||||
draft.SendMailTo(MailReceiver(target, target_guid), sender);
|
||||
|
||||
|
@ -7041,14 +7041,14 @@ bool ChatHandler::HandleAccountSetAddonCommand(char* args)
|
||||
bool ChatHandler::HandleSendMailHelper(MailDraft& draft, char* args)
|
||||
{
|
||||
// format: "subject text" "mail text"
|
||||
std::string msgSubject = ExtractQuotedArg(&args);
|
||||
if (msgSubject.empty())
|
||||
char* msgSubject = ExtractQuotedArg(&args);
|
||||
if (!msgSubject)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string msgText = ExtractQuotedArg(&args);
|
||||
if (msgText.empty())
|
||||
char* msgText = ExtractQuotedArg(&args);
|
||||
if (!msgText)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -7094,14 +7094,14 @@ bool ChatHandler::HandleSendMassMailCommand(char* args)
|
||||
bool ChatHandler::HandleSendItemsHelper(MailDraft& draft, char* args)
|
||||
{
|
||||
// format: "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12]
|
||||
std::string msgSubject = ExtractQuotedArg(&args);
|
||||
if (msgSubject.empty())
|
||||
char * msgSubject = ExtractQuotedArg(&args);
|
||||
if (!msgSubject)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string msgText = ExtractQuotedArg(&args);
|
||||
if (msgText.empty())
|
||||
char * msgText = ExtractQuotedArg(&args);
|
||||
if (!msgText)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -7195,7 +7195,7 @@ bool ChatHandler::HandleSendItemsCommand(char* args)
|
||||
return false;
|
||||
}
|
||||
|
||||
MailSender sender(MAIL_NORMAL, (uint32)0, MAIL_STATIONERY_GM);
|
||||
MailSender sender(MAIL_NORMAL, m_session ? m_session->GetPlayer()->GetGUIDLow() : (uint32)0, MAIL_STATIONERY_GM);
|
||||
|
||||
draft.SendMailTo(MailReceiver(receiver, receiver_guid), sender);
|
||||
|
||||
@ -7239,8 +7239,8 @@ bool ChatHandler::HandleSendMoneyHelper(MailDraft& draft, char* args)
|
||||
{
|
||||
/// format: "subject text" "mail text" money
|
||||
|
||||
std::string msgSubject = ExtractQuotedArg(&args);
|
||||
if (msgSubject.empty())
|
||||
char * msgSubject = ExtractQuotedArg(&args);
|
||||
if (!msgSubject)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user