Jump to content

[Patch] Ticket response check at player login


Guest Kami-Nezumi

Recommended Posts

Hi. I've just made this patch and decided to share it. I've tested it, and it works fine.

What bug does the patch fix? What features does the patch add?

It justs add a check when a player who made a ticket and logged off wants to login again. It checks in the DB if a GM answered to his ticket (Currently, this check occures only at world initalization, never after).

I made this patch for rev 10337.

diff --git a/src/game/GMTicketHandler.cpp b/src/game/GMTicketHandler.cpp
index 5e49ec5..cfad316 100644
--- a/src/game/GMTicketHandler.cpp
+++ b/src/game/GMTicketHandler.cpp
@@ -62,13 +62,27 @@ void WorldSession::HandleGMTicketGetTicketOpcode( WorldPacket & /*recv_data*/ )
{
    SendQueryTimeResponse();

-    GMTicket* ticket = sTicketMgr.GetGMTicket(GetPlayer()->GetGUIDLow());
+    uint32 playerGUID = GetPlayer()->GetGUIDLow();
+
+    GMTicket* ticket = sTicketMgr.GetGMTicket(playerGUID);
    if(ticket)
    {
-        if(ticket->HasResponse())
-            SendGMResponse(ticket);
+        QueryResult *result;
+        result = CharacterDatabase.PQuery("SELECT response_text FROM character_ticket WHERE guid = %u", playerGUID);
+
+        Field* fields = result->Fetch();
+        std::string response_text = fields->GetCppString();
+
+        if(!response_text.empty())
+        {
+            ticket->SetResponseText(response_text.c_str());
+
+            SendGMResponse(ticket);
+        }
        else
            SendGMTicketGetTicket(0x06, ticket->GetText());
+
+        delete result;
    }
    else
        SendGMTicketGetTicket(0x0A, 0);

Link to comment
Share on other sites

see ChatHandler::HandleTicketCommand

    // ticket respond
   if (strncmp(px, "respond", 8) == 0)
   {
       std::string plName = ExtractPlayerNameFromLink(&args);
       if (plName.empty())
       {
           SendSysMessage(LANG_CMD_SYNTAX);
           SetSentErrorMessage(true);
           return false;
       }

       uint64 guid = sObjectMgr.GetPlayerGUIDByName(plName);

       if (!guid)
       {
           SendSysMessage(LANG_PLAYER_NOT_FOUND);
           SetSentErrorMessage(true);
           return false;
       }

       GMTicket* ticket = sTicketMgr.GetGMTicket(GUID_LOPART(guid));

       if (!ticket)
       {
           PSendSysMessage(LANG_COMMAND_TICKETNOTEXIST, GUID_LOPART(guid));
           SetSentErrorMessage(true);
           return false;
       }

       if (!*args)
       {
           SendSysMessage(LANG_CMD_SYNTAX);
           SetSentErrorMessage(true);
           return false;
       }

[b][color=red]        ticket->SetResponseText(args);[/color][/b]

       if (Player* pl = sObjectMgr.GetPlayer(guid))
           pl->GetSession()->SendGMResponse(ticket);

       return true;
   }

see void GMTicket::SetResponseText and HasResponseText

        void SetResponseText(const char* text)
       {
           m_responseText = text ? text : "";
           m_lastUpdate = time(NULL);

           std::string escapedString = m_responseText;
           CharacterDatabase.escape_string(escapedString);
           CharacterDatabase.PExecute("UPDATE character_ticket SET response_text = '%s' WHERE guid = '%u'", escapedString.c_str(), m_guid);
       }

       bool HasResponse() { return !m_responseText.empty(); }

So your patch is incorrect.

Link to comment
Share on other sites

LordJZ meaning: not need access to DB when all data already in memory.

I test case without reload respose show and it show as expected. in instantly and if player relogin

If you known special case when this not work, then please describe this step by step.

Ok, i find in current code redundent Db access and in another cases, so will cleanup its.

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use