Update GM tickets weird char and set response text when close ticket (#139)
* Fix HandleGMTicketUpdateTextOpcode * Add response text
This commit is contained in:
parent
a5dc2b0598
commit
ff9e604e7a
@ -140,6 +140,10 @@ bool ChatHandler::HandleTicketCloseCommand(char* args)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*args) {
|
||||
ticket->SetResponseText(args);
|
||||
}
|
||||
|
||||
// Set reponse text if not existing
|
||||
if (!*ticket->GetResponse())
|
||||
{
|
||||
@ -148,7 +152,7 @@ bool ChatHandler::HandleTicketCloseCommand(char* args)
|
||||
|
||||
if (m_session)
|
||||
{
|
||||
const char* format = "[System Message] This ticket was closed by <GM>%s without any mail response, perhaps it was resolved by direct chat.";
|
||||
const char* format = "[System Message] This ticket was closed by <GM> %s without any written response, perhaps it was resolved by direct chat.";
|
||||
const char* buffer;
|
||||
snprintf(response, responseBufferSize, format, m_session->GetPlayer()->GetName());
|
||||
}
|
||||
|
@ -71,6 +71,12 @@ void WorldSession::HandleGMTicketUpdateTextOpcode(WorldPacket& recv_data)
|
||||
std::string ticketText;
|
||||
recv_data >> ticketText;
|
||||
|
||||
// When updating the ticket , the client adds a leading '\a' char ! so we need to remove it
|
||||
stripLineInvisibleChars(ticketText);
|
||||
|
||||
// Since invisible char are replaced with a ' ' if any leading space is added we remove it :
|
||||
ltrim(ticketText);
|
||||
|
||||
GMTicketResponse responce = GMTICKET_RESPONSE_UPDATE_SUCCESS;
|
||||
if (GMTicket* ticket = sTicketMgr.GetGMTicket(GetPlayer()->GetObjectGuid()))
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "../botpch.h"
|
||||
#include "playerbot.h"
|
||||
#include "Util.h"
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <cctype>
|
||||
@ -77,10 +78,6 @@ uint64 extractGuid(WorldPacket& packet)
|
||||
return guid;
|
||||
}
|
||||
|
||||
std::string <rim(std::string &s) {
|
||||
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string &rtrim(std::string &s) {
|
||||
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
|
||||
|
@ -327,6 +327,33 @@ void utf8truncate(std::string& utf8str, size_t len)
|
||||
}
|
||||
}
|
||||
|
||||
size_t utf8limit(std::string& utf8str, size_t bytes)
|
||||
{
|
||||
if (utf8str.size() > bytes)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto end = (utf8str.cbegin() + bytes);
|
||||
auto itr = utf8::find_invalid(utf8str.cbegin(), end);
|
||||
|
||||
// Fix UTF8 if it was corrupted by bytes truncated
|
||||
if (itr != end)
|
||||
bytes = std::distance(utf8str.cbegin(), itr);
|
||||
|
||||
utf8str.resize(bytes);
|
||||
utf8str.shrink_to_fit();
|
||||
|
||||
return bytes;
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
utf8str = "";
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize)
|
||||
{
|
||||
try
|
||||
|
@ -115,6 +115,13 @@ inline uint32 secsToTimeBitFields(time_t secs)
|
||||
}
|
||||
|
||||
|
||||
inline std::string ltrim(std::string& s) {
|
||||
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) {
|
||||
return !std::isspace(ch);
|
||||
}));
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return a random number in the range min..max; (max-min) must be smaller than 32768.
|
||||
*
|
||||
@ -328,6 +335,14 @@ size_t utf8length(std::string& utf8str); // set string to ""
|
||||
*/
|
||||
void utf8truncate(std::string& utf8str, size_t len);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param utf8str
|
||||
* @param bytes
|
||||
*/
|
||||
size_t utf8limit(std::string& utf8str, size_t bytes);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user