[9033] Fixed percent mana regneration from spell 53228 and ranks buff.
[getmangos.git] / src / game / GMTicketHandler.cpp
bloba2868ad62dafded19a58666345f896323d7ac10e
1 /*
2 * Copyright (C) 2005-2009 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
19 #include "Common.h"
20 #include "Language.h"
21 #include "WorldPacket.h"
22 #include "Log.h"
23 #include "GMTicketMgr.h"
24 #include "ObjectAccessor.h"
25 #include "Player.h"
26 #include "Chat.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
33 if(status == 6)
35 data << text; // ticket text
36 data << uint8(0x7); // ticket category
37 data << float(0); // tickets in queue?
38 data << float(0); // if > "tickets in queue" then "We are currently experiencing a high volume of petitions."
39 data << float(0); // 0 - "Your ticket will be serviced soon", 1 - "Wait time currently unavailable"
40 data << uint8(0); // if == 2 and next field == 1 then "Your ticket has been escalated"
41 data << uint8(0); // const
43 SendPacket( &data );
46 void WorldSession::HandleGMTicketGetTicketOpcode( WorldPacket & /*recv_data*/ )
48 WorldPacket data( SMSG_QUERY_TIME_RESPONSE, 4+4 );
49 data << (uint32)time(NULL);
50 data << (uint32)0;
51 SendPacket( &data );
53 GMTicket* ticket = sTicketMgr.GetGMTicket(GetPlayer()->GetGUIDLow());
54 if(ticket)
55 SendGMTicketGetTicket(0x06,ticket->GetText());
56 else
57 SendGMTicketGetTicket(0x0A,0);
60 void WorldSession::HandleGMTicketUpdateTextOpcode( WorldPacket & recv_data )
62 std::string ticketText;
63 recv_data >> ticketText;
65 if(GMTicket* ticket = sTicketMgr.GetGMTicket(GetPlayer()->GetGUIDLow()))
66 ticket->SetText(ticketText.c_str());
67 else
68 sLog.outError("Ticket update: Player %s (GUID: %u) doesn't have active ticket", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
71 void WorldSession::HandleGMTicketDeleteTicketOpcode( WorldPacket & /*recv_data*/ )
73 sTicketMgr.Delete(GetPlayer()->GetGUIDLow());
75 WorldPacket data( SMSG_GMTICKET_DELETETICKET, 4 );
76 data << uint32(9);
77 SendPacket( &data );
79 SendGMTicketGetTicket(0x0A, 0);
82 void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data )
84 uint32 map;
85 float x, y, z;
86 std::string ticketText = "";
88 recv_data >> map >> x >> y >> z; // last check 2.4.3
89 recv_data >> ticketText;
91 recv_data.read_skip<uint32>(); // unk1, 0
92 recv_data.read_skip<uint8>(); // unk2, 1
93 recv_data.read_skip<uint32>(); // unk3, 0
94 recv_data.read_skip<uint32>(); // unk4, 0
96 sLog.outDebug("TicketCreate: map %u, x %f, y %f, z %f, text %s", map, x, y, z, ticketText.c_str());
98 if(sTicketMgr.GetGMTicket(GetPlayer()->GetGUIDLow()))
100 WorldPacket data( SMSG_GMTICKET_CREATE, 4 );
101 data << uint32(1); // 1 - You already have GM ticket
102 SendPacket( &data );
103 return;
106 sTicketMgr.Create(_player->GetGUIDLow(), ticketText.c_str());
108 WorldPacket data( SMSG_QUERY_TIME_RESPONSE, 4+4 );
109 data << (uint32)time(NULL);
110 data << (uint32)0;
111 SendPacket( &data );
113 data.Initialize( SMSG_GMTICKET_CREATE, 4 );
114 data << uint32(2); // 2 - nothing appears (3-error creating, 5-error updating)
115 SendPacket( &data );
116 DEBUG_LOG("update the ticket");
118 //TODO: Guard player map
119 HashMapHolder<Player>::MapType &m = sObjectAccessor.GetPlayers();
120 for(HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
122 if(itr->second->GetSession()->GetSecurity() >= SEC_GAMEMASTER && itr->second->isAcceptTickets())
123 ChatHandler(itr->second).PSendSysMessage(LANG_COMMAND_TICKETNEW,GetPlayer()->GetName());
127 void WorldSession::HandleGMTicketSystemStatusOpcode( WorldPacket & /*recv_data*/ )
129 WorldPacket data( SMSG_GMTICKET_SYSTEMSTATUS, 4 );
130 data << uint32(1); // we can also disable ticket system by sending 0 value
132 SendPacket( &data );
135 void WorldSession::HandleGMSurveySubmit( WorldPacket & recv_data)
137 // GM survey is shown after SMSG_GM_TICKET_STATUS_UPDATE with status = 3
138 uint32 x;
139 recv_data >> x; // answer range? (6 = 0-5?)
140 sLog.outDebug("SURVEY: X = %u", x);
142 uint8 result[10];
143 memset(result, 0, sizeof(result));
144 for( int i = 0; i < 10; ++i)
146 uint32 questionID;
147 recv_data >> questionID; // GMSurveyQuestions.dbc
148 if (!questionID)
149 break;
151 uint8 value;
152 std::string unk_text;
153 recv_data >> value; // answer
154 recv_data >> unk_text; // always empty?
156 result[i] = value;
157 sLog.outDebug("SURVEY: ID %u, value %u, text %s", questionID, value, unk_text.c_str());
160 std::string comment;
161 recv_data >> comment; // addional comment
162 sLog.outDebug("SURVEY: comment %s", comment.c_str());
164 // TODO: chart this data in some way