mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 01:37:00 +00:00
Fix send mail and send item commands
Server was crashing if no args or if no quotes were provided for args
This commit is contained in:
parent
f521577336
commit
a34d10afc6
2 changed files with 27 additions and 14 deletions
|
|
@ -2022,6 +2022,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;
|
||||
|
|
@ -2033,11 +2038,19 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
// from console show nonexistent sender
|
||||
MailSender sender(MAIL_NORMAL, m_session ? m_session->GetPlayer()->GetObjectGuid().GetCounter() : 0, MAIL_STATIONERY_GM);
|
||||
|
|
|
|||
|
|
@ -7728,14 +7728,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;
|
||||
}
|
||||
|
|
@ -7767,8 +7767,8 @@ bool ChatHandler::HandleSendMassMailCommand(char* args)
|
|||
return false;
|
||||
}
|
||||
|
||||
// from console show nonexistent sender
|
||||
MailSender sender(MAIL_NORMAL, m_session ? m_session->GetPlayer()->GetObjectGuid().GetCounter() : 0, MAIL_STATIONERY_GM);
|
||||
// GM mail
|
||||
MailSender sender(MAIL_NORMAL, (uint32)0, MAIL_STATIONERY_GM);
|
||||
|
||||
sMassMailMgr.AddMassMailTask(draft, sender, raceMask);
|
||||
|
||||
|
|
@ -7781,14 +7781,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;
|
||||
}
|
||||
|
|
@ -7928,8 +7928,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…
Add table
Add a link
Reference in a new issue