2 * Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "WorldPacket.h"
23 #include "GMTicketMgr.h"
24 #include "ObjectAccessor.h"
28 void WorldSession::SendGMTicketGetTicket(uint32 status
, char const* text
)
30 int len
= text
? strlen(text
) : 0;
31 WorldPacket
data( SMSG_GMTICKET_GETTICKET
, (4+len
+1+4+2+4+4) );
32 data
<< uint32(status
); // standard 0x0A, 0x06 if text present
35 data
<< uint32(123); // unk
36 data
<< text
; // ticket text
37 data
<< uint8(0x7); // ticket category
38 data
<< float(0); // tickets in queue?
39 data
<< float(0); // if > "tickets in queue" then "We are currently experiencing a high volume of petitions."
40 data
<< float(0); // 0 - "Your ticket will be serviced soon", 1 - "Wait time currently unavailable"
41 data
<< uint8(0); // if == 2 and next field == 1 then "Your ticket has been escalated"
42 data
<< uint8(0); // const
47 void WorldSession::SendGMResponse(GMTicket
*ticket
)
49 int len
= strlen(ticket
->GetText())+1+strlen(ticket
->GetResponse())+1;
50 WorldPacket
data(SMSG_GMRESPONSE_RECEIVED
, 4+4+len
+1+1+1);
53 data
<< ticket
->GetText(); // issue text
54 data
<< ticket
->GetResponse(); // response text 1
55 data
<< uint8(0); // response text 2
56 data
<< uint8(0); // response text 3
57 data
<< uint8(0); // response text 4
61 void WorldSession::HandleGMTicketGetTicketOpcode( WorldPacket
& /*recv_data*/ )
63 SendQueryTimeResponse();
65 GMTicket
* ticket
= sTicketMgr
.GetGMTicket(GetPlayer()->GetGUIDLow());
68 if(ticket
->HasResponse())
69 SendGMResponse(ticket
);
71 SendGMTicketGetTicket(0x06, ticket
->GetText());
74 SendGMTicketGetTicket(0x0A, 0);
77 void WorldSession::HandleGMTicketUpdateTextOpcode( WorldPacket
& recv_data
)
79 std::string ticketText
;
80 recv_data
>> ticketText
;
82 if(GMTicket
* ticket
= sTicketMgr
.GetGMTicket(GetPlayer()->GetGUIDLow()))
83 ticket
->SetText(ticketText
.c_str());
85 sLog
.outError("Ticket update: Player %s (GUID: %u) doesn't have active ticket", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
88 void WorldSession::HandleGMTicketDeleteTicketOpcode( WorldPacket
& /*recv_data*/ )
90 sTicketMgr
.Delete(GetPlayer()->GetGUIDLow());
92 WorldPacket
data( SMSG_GMTICKET_DELETETICKET
, 4 );
96 SendGMTicketGetTicket(0x0A, 0);
99 void WorldSession::HandleGMTicketCreateOpcode( WorldPacket
& recv_data
)
103 std::string ticketText
= "";
106 recv_data
>> map
>> x
>> y
>> z
; // last check 2.4.3
107 recv_data
>> ticketText
;
109 recv_data
.read_skip
<uint32
>(); // unk1, 11 - talk to gm, 1 - report problem
110 recv_data
>> isFollowup
; // unk2, 1 - followup ticket
111 recv_data
.read_skip
<uint32
>(); // unk3, 0
112 recv_data
.read_skip
<uint32
>(); // unk4, 0
114 sLog
.outDebug("TicketCreate: map %u, x %f, y %f, z %f, text %s", map
, x
, y
, z
, ticketText
.c_str());
116 if(sTicketMgr
.GetGMTicket(GetPlayer()->GetGUIDLow()) && !isFollowup
)
118 WorldPacket
data( SMSG_GMTICKET_CREATE
, 4 );
119 data
<< uint32(1); // 1 - You already have GM ticket
125 sTicketMgr
.Delete(_player
->GetGUIDLow());
127 sTicketMgr
.Create(_player
->GetGUIDLow(), ticketText
.c_str());
129 SendQueryTimeResponse();
131 WorldPacket
data( SMSG_GMTICKET_CREATE
, 4 );
132 data
<< uint32(2); // 2 - nothing appears (3-error creating, 5-error updating)
135 //TODO: Guard player map
136 HashMapHolder
<Player
>::MapType
&m
= sObjectAccessor
.GetPlayers();
137 for(HashMapHolder
<Player
>::MapType::const_iterator itr
= m
.begin(); itr
!= m
.end(); ++itr
)
139 if(itr
->second
->GetSession()->GetSecurity() >= SEC_GAMEMASTER
&& itr
->second
->isAcceptTickets())
140 ChatHandler(itr
->second
).PSendSysMessage(LANG_COMMAND_TICKETNEW
,GetPlayer()->GetName());
144 void WorldSession::HandleGMTicketSystemStatusOpcode( WorldPacket
& /*recv_data*/ )
146 WorldPacket
data( SMSG_GMTICKET_SYSTEMSTATUS
, 4 );
147 data
<< uint32(1); // we can also disable ticket system by sending 0 value
152 void WorldSession::HandleGMSurveySubmit( WorldPacket
& recv_data
)
154 // GM survey is shown after SMSG_GM_TICKET_STATUS_UPDATE with status = 3
156 recv_data
>> x
; // answer range? (6 = 0-5?)
157 sLog
.outDebug("SURVEY: X = %u", x
);
160 memset(result
, 0, sizeof(result
));
161 for( int i
= 0; i
< 10; ++i
)
164 recv_data
>> questionID
; // GMSurveyQuestions.dbc
169 std::string unk_text
;
170 recv_data
>> value
; // answer
171 recv_data
>> unk_text
; // always empty?
174 sLog
.outDebug("SURVEY: ID %u, value %u, text %s", questionID
, value
, unk_text
.c_str());
178 recv_data
>> comment
; // addional comment
179 sLog
.outDebug("SURVEY: comment %s", comment
.c_str());
181 // TODO: chart this data in some way
184 void WorldSession::HandleGMResponseResolve(WorldPacket
& recv_data
)
187 sLog
.outDebug("WORLD: %s", LookupOpcodeName(recv_data
.GetOpcode()));
189 sTicketMgr
.Delete(GetPlayer()->GetGUIDLow());
191 WorldPacket
data(SMSG_GMRESPONSE_STATUS_UPDATE
, 1);
192 data
<< uint8(0); // ask to fill out gm survey = 1