From 47dfb6c52639c0a419f4e57fddfd31c6706f5a73 Mon Sep 17 00:00:00 2001 From: Luth31 Date: Sun, 14 Aug 2016 20:45:13 +0300 Subject: [PATCH] Core/Commands: Add missing message for .ticket complete (#79) Do not allow the completion of a ticket with or without response if the handler isn't the assignee Let players know when their ticket has been closed or they received a response. --- data/sql/updates/world/2016_08_13_01.sql | 3 +++ src/game/Miscellaneous/Language.h | 6 ++++- src/scripts/Commands/cs_ticket.cpp | 31 ++++++++++++++---------- 3 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 data/sql/updates/world/2016_08_13_01.sql diff --git a/data/sql/updates/world/2016_08_13_01.sql b/data/sql/updates/world/2016_08_13_01.sql new file mode 100644 index 000000000..37a5dfc4c --- /dev/null +++ b/data/sql/updates/world/2016_08_13_01.sql @@ -0,0 +1,3 @@ +INSERT INTO `trinity_string` (`entry`, `content_default`) VALUES +(1334, 'Your ticket has been closed.'), +(1335, 'You received a ticket response.'); \ No newline at end of file diff --git a/src/game/Miscellaneous/Language.h b/src/game/Miscellaneous/Language.h index 6480dcf26..bc3fca325 100644 --- a/src/game/Miscellaneous/Language.h +++ b/src/game/Miscellaneous/Language.h @@ -1045,7 +1045,11 @@ enum TrinityStrings LANG_BG_AV_H_CAPTAIN_DEAD = 1331, LANG_BG_AV_A_CAPTAIN_DEAD = 1332, LANG_BG_AV_START_TWO_MINUTES = 1333, - // FREE IDS 1334-1999 + + //Player Ticket Strings + LANG_TICKET_CLOSED = 1334, + LANG_TICKET_COMPLETED = 1335, + // FREE IDS 1336-1999 // Ticket Strings 2000-2030 LANG_COMMAND_TICKETNEW = 2000, diff --git a/src/scripts/Commands/cs_ticket.cpp b/src/scripts/Commands/cs_ticket.cpp index b107f5d06..e8ed75d6f 100644 --- a/src/scripts/Commands/cs_ticket.cpp +++ b/src/scripts/Commands/cs_ticket.cpp @@ -168,6 +168,7 @@ public: WorldPacket data(SMSG_GMTICKET_DELETETICKET, 4); data << uint32(GMTICKET_RESPONSE_TICKET_DELETED); submitter->GetSession()->SendPacket(&data); + ChatHandler(submitter->GetSession()).SendSysMessage(LANG_TICKET_CLOSED); } return true; } @@ -233,25 +234,29 @@ public: return true; } - char* response = strtok(NULL, "\n"); - if (response) + // Check if handler is not assignee in which case return + Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : NULL; + + if (player && ticket->IsAssignedNotTo(player->GetGUID())) { - // Cannot add response to ticket, assigned to someone else - //! Console excluded - Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : NULL; - if (player && ticket->IsAssignedNotTo(player->GetGUID())) - { - handler->PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->GetId()); - return true; - } - ticket->AppendResponse(response); + handler->PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->GetId()); + return true; } - if (Player* player = ticket->GetPlayer()) - ticket->SendResponse(player->GetSession()); + char* response = strtok(NULL, "\n"); + if (response) + ticket->AppendResponse(response); + if (Player* player = ticket->GetPlayer()) + { + ticket->SendResponse(player->GetSession()); + ChatHandler(player->GetSession()).SendSysMessage(LANG_TICKET_COMPLETED); + } Player* gm = handler->GetSession() ? handler->GetSession()->GetPlayer() : NULL; + std::string msg = ticket->FormatMessageString(*handler, NULL, NULL, NULL, NULL); + msg += handler->PGetParseString(LANG_COMMAND_TICKETCOMPLETED, gm ? gm->GetName().c_str() : "Console"); + handler->SendGlobalGMSysMessage(msg.c_str()); SQLTransaction trans = SQLTransaction(NULL); ticket->SetCompleted();