2010-10-07 15:35:36 +02:00
|
|
|
/*
|
2012-01-01 00:32:13 +01:00
|
|
|
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
|
2010-10-07 15:35:36 +02:00
|
|
|
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
* option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
|
* more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-12-31 15:07:29 +01:00
|
|
|
*/
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-12-31 15:07:29 +01:00
|
|
|
#include "Language.h"
|
|
|
|
|
#include "WorldPacket.h"
|
|
|
|
|
#include "Common.h"
|
2009-06-15 23:58:29 +02:00
|
|
|
#include "ObjectMgr.h"
|
2010-08-29 20:28:14 -07:00
|
|
|
#include "TicketMgr.h"
|
2008-12-31 15:07:29 +01:00
|
|
|
#include "Player.h"
|
|
|
|
|
#include "World.h"
|
2010-08-29 20:28:14 -07:00
|
|
|
#include "WorldSession.h"
|
|
|
|
|
#include "Util.h"
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-04-07 22:59:46 +02:00
|
|
|
void WorldSession::HandleGMTicketCreateOpcode(WorldPacket & recv_data)
|
2008-12-31 15:07:29 +01:00
|
|
|
{
|
2010-11-14 00:29:34 +01:00
|
|
|
// Don't accept tickets if the ticket queue is disabled. (Ticket UI is greyed out but not fully dependable)
|
2010-12-22 21:25:23 +01:00
|
|
|
if (sTicketMgr->GetStatus() == GMTICKET_QUEUE_STATUS_DISABLED)
|
2010-11-14 00:29:34 +01:00
|
|
|
return;
|
|
|
|
|
|
2010-12-23 23:25:44 +01:00
|
|
|
if (GetPlayer()->getLevel() < sWorld->getIntConfig(CONFIG_TICKET_LEVEL_REQ))
|
2010-03-09 12:58:48 +01:00
|
|
|
{
|
2010-12-23 23:25:44 +01:00
|
|
|
SendNotification(GetTrinityString(LANG_TICKET_REQ), sWorld->getIntConfig(CONFIG_TICKET_LEVEL_REQ));
|
2010-03-09 12:58:48 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-28 03:59:03 +02:00
|
|
|
GMTicketResponse response = GMTICKET_RESPONSE_CREATE_ERROR;
|
2011-04-19 14:04:18 +06:00
|
|
|
// Player must not have ticket
|
|
|
|
|
if (!sTicketMgr->GetTicketByPlayer(GetPlayer()->GetGUID()))
|
2009-06-19 00:25:12 +02:00
|
|
|
{
|
2011-04-19 14:04:18 +06:00
|
|
|
GmTicket* ticket = new GmTicket(GetPlayer(), recv_data);
|
|
|
|
|
sTicketMgr->AddTicket(ticket);
|
|
|
|
|
sTicketMgr->UpdateLastChange();
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-04-19 14:04:18 +06:00
|
|
|
sWorld->SendGMText(LANG_COMMAND_TICKETNEW, GetPlayer()->GetName(), ticket->GetId());
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2012-03-28 03:59:03 +02:00
|
|
|
response = GMTICKET_RESPONSE_CREATE_SUCCESS;
|
2011-04-19 14:04:18 +06:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-08-29 20:28:14 -07:00
|
|
|
WorldPacket data(SMSG_GMTICKET_CREATE, 4);
|
2011-04-19 14:04:18 +06:00
|
|
|
data << uint32(response);
|
2009-02-09 08:16:34 -05:00
|
|
|
SendPacket(&data);
|
2008-12-31 15:07:29 +01:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-04-07 22:59:46 +02:00
|
|
|
void WorldSession::HandleGMTicketUpdateOpcode(WorldPacket & recv_data)
|
2008-12-31 15:07:29 +01:00
|
|
|
{
|
2009-06-15 23:58:29 +02:00
|
|
|
std::string message;
|
2009-02-09 08:16:34 -05:00
|
|
|
recv_data >> message;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2012-03-28 03:59:03 +02:00
|
|
|
GMTicketResponse response = GMTICKET_RESPONSE_UPDATE_ERROR;
|
|
|
|
|
if (GmTicket* ticket = sTicketMgr->GetTicketByPlayer(GetPlayer()->GetGUID()))
|
2009-02-09 08:16:34 -05:00
|
|
|
{
|
2011-04-19 14:04:18 +06:00
|
|
|
SQLTransaction trans = SQLTransaction(NULL);
|
|
|
|
|
ticket->SetMessage(message);
|
|
|
|
|
ticket->SaveToDB(trans);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-04-19 14:04:18 +06:00
|
|
|
sWorld->SendGMText(LANG_COMMAND_TICKETUPDATED, GetPlayer()->GetName(), ticket->GetId());
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2012-03-28 03:59:03 +02:00
|
|
|
response = GMTICKET_RESPONSE_UPDATE_SUCCESS;
|
2011-04-19 14:04:18 +06:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-08-29 20:28:14 -07:00
|
|
|
WorldPacket data(SMSG_GMTICKET_UPDATETEXT, 4);
|
2011-04-19 14:04:18 +06:00
|
|
|
data << uint32(response);
|
2009-02-09 08:16:34 -05:00
|
|
|
SendPacket(&data);
|
2008-12-31 15:07:29 +01:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-04-07 22:59:46 +02:00
|
|
|
void WorldSession::HandleGMTicketDeleteOpcode(WorldPacket & /*recv_data*/)
|
2008-12-31 15:07:29 +01:00
|
|
|
{
|
2011-04-19 14:04:18 +06:00
|
|
|
if (GmTicket* ticket = sTicketMgr->GetTicketByPlayer(GetPlayer()->GetGUID()))
|
2009-02-09 08:16:34 -05:00
|
|
|
{
|
|
|
|
|
WorldPacket data(SMSG_GMTICKET_DELETETICKET, 4);
|
2010-08-29 20:28:14 -07:00
|
|
|
data << uint32(GMTICKET_RESPONSE_TICKET_DELETED);
|
2009-02-09 08:16:34 -05:00
|
|
|
SendPacket(&data);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-04-19 14:04:18 +06:00
|
|
|
sWorld->SendGMText(LANG_COMMAND_TICKETPLAYERABANDON, GetPlayer()->GetName(), ticket->GetId());
|
|
|
|
|
|
|
|
|
|
sTicketMgr->CloseTicket(ticket->GetId(), GetPlayer()->GetGUID());
|
|
|
|
|
sTicketMgr->SendTicket(this, NULL);
|
2009-02-09 08:16:34 -05:00
|
|
|
}
|
2008-12-31 15:07:29 +01:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-04-07 22:59:46 +02:00
|
|
|
void WorldSession::HandleGMTicketGetTicketOpcode(WorldPacket & /*recv_data*/)
|
2008-12-31 15:07:29 +01:00
|
|
|
{
|
2010-01-29 22:24:18 +01:00
|
|
|
SendQueryTimeResponse();
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-04-19 14:04:18 +06:00
|
|
|
if (GmTicket* ticket = sTicketMgr->GetTicketByPlayer(GetPlayer()->GetGUID()))
|
2010-08-29 20:28:14 -07:00
|
|
|
{
|
2011-04-19 14:04:18 +06:00
|
|
|
if (ticket->IsCompleted())
|
|
|
|
|
ticket->SendResponse(this);
|
2010-08-29 20:28:14 -07:00
|
|
|
else
|
2011-04-19 14:04:18 +06:00
|
|
|
sTicketMgr->SendTicket(this, ticket);
|
2010-08-29 20:28:14 -07:00
|
|
|
}
|
2009-06-19 00:25:12 +02:00
|
|
|
else
|
2011-04-19 14:04:18 +06:00
|
|
|
sTicketMgr->SendTicket(this, NULL);
|
2008-12-31 15:07:29 +01:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-04-07 22:59:46 +02:00
|
|
|
void WorldSession::HandleGMTicketSystemStatusOpcode(WorldPacket & /*recv_data*/)
|
2008-12-31 15:07:29 +01:00
|
|
|
{
|
2010-11-14 00:29:34 +01:00
|
|
|
// Note: This only disables the ticket UI at client side and is not fully reliable
|
2010-08-29 20:28:14 -07:00
|
|
|
// are we sure this is a uint32? Should ask Zor
|
2011-04-19 14:04:18 +06:00
|
|
|
WorldPacket data(SMSG_GMTICKET_SYSTEMSTATUS, 4);
|
2010-12-22 21:25:23 +01:00
|
|
|
data << uint32(sTicketMgr->GetStatus() ? GMTICKET_QUEUE_STATUS_ENABLED : GMTICKET_QUEUE_STATUS_DISABLED);
|
2009-02-09 08:16:34 -05:00
|
|
|
SendPacket(&data);
|
2009-01-10 12:45:01 +01:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-08-29 20:28:14 -07:00
|
|
|
void WorldSession::HandleGMSurveySubmit(WorldPacket& recv_data)
|
|
|
|
|
{
|
2011-04-19 14:04:18 +06:00
|
|
|
uint32 nextSurveyID = sTicketMgr->GetNextSurveyID();
|
2010-08-29 20:28:14 -07:00
|
|
|
// just put the survey into the database
|
|
|
|
|
uint32 mainSurvey; // GMSurveyCurrentSurvey.dbc, column 1 (all 9) ref to GMSurveySurveys.dbc
|
|
|
|
|
recv_data >> mainSurvey;
|
|
|
|
|
|
2010-09-12 01:40:27 +02:00
|
|
|
// sub_survey1, r1, comment1, sub_survey2, r2, comment2, sub_survey3, r3, comment3, sub_survey4, r4, comment4, sub_survey5, r5, comment5, sub_survey6, r6, comment6, sub_survey7, r7, comment7, sub_survey8, r8, comment8, sub_survey9, r9, comment9, sub_survey10, r10, comment10,
|
2010-08-29 20:28:14 -07:00
|
|
|
for (uint8 i = 0; i < 10; i++)
|
|
|
|
|
{
|
|
|
|
|
uint32 subSurveyId; // ref to i'th GMSurveySurveys.dbc field (all fields in that dbc point to fields in GMSurveyQuestions.dbc)
|
|
|
|
|
recv_data >> subSurveyId;
|
2011-04-19 14:04:18 +06:00
|
|
|
if (!subSurveyId)
|
2010-08-29 20:28:14 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
uint8 rank; // probably some sort of ref to GMSurveyAnswers.dbc
|
|
|
|
|
recv_data >> rank;
|
2011-04-19 14:04:18 +06:00
|
|
|
std::string comment; // comment ("Usage: GMSurveyAnswerSubmit(question, rank, comment)")
|
2010-08-29 20:28:14 -07:00
|
|
|
recv_data >> comment;
|
|
|
|
|
|
2012-01-01 01:09:38 +01:00
|
|
|
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GM_SUBSURVEY);
|
2011-04-19 14:04:18 +06:00
|
|
|
stmt->setUInt32(0, nextSurveyID);
|
|
|
|
|
stmt->setUInt32(1, subSurveyId);
|
|
|
|
|
stmt->setUInt32(2, rank);
|
|
|
|
|
stmt->setString(3, comment);
|
|
|
|
|
CharacterDatabase.Execute(stmt);
|
2010-08-29 20:28:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string comment; // just a guess
|
|
|
|
|
recv_data >> comment;
|
|
|
|
|
|
2012-01-01 01:09:38 +01:00
|
|
|
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GM_SURVEY);
|
2011-04-19 14:04:18 +06:00
|
|
|
stmt->setUInt32(0, GUID_LOPART(GetPlayer()->GetGUID()));
|
|
|
|
|
stmt->setUInt32(1, nextSurveyID);
|
|
|
|
|
stmt->setUInt32(2, mainSurvey);
|
|
|
|
|
stmt->setString(3, comment);
|
|
|
|
|
|
|
|
|
|
CharacterDatabase.Execute(stmt);
|
2010-08-29 20:28:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WorldSession::HandleReportLag(WorldPacket& recv_data)
|
|
|
|
|
{
|
|
|
|
|
// just put the lag report into the database...
|
|
|
|
|
// can't think of anything else to do with it
|
|
|
|
|
uint32 lagType, mapId;
|
|
|
|
|
recv_data >> lagType;
|
|
|
|
|
recv_data >> mapId;
|
2011-04-19 14:04:18 +06:00
|
|
|
float x, y, z;
|
2010-08-29 20:28:14 -07:00
|
|
|
recv_data >> x;
|
|
|
|
|
recv_data >> y;
|
|
|
|
|
recv_data >> z;
|
|
|
|
|
|
2012-01-01 01:09:38 +01:00
|
|
|
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_LAG_REPORT);
|
2011-04-19 14:04:18 +06:00
|
|
|
stmt->setUInt32(0, GUID_LOPART(GetPlayer()->GetGUID()));
|
|
|
|
|
stmt->setUInt8 (1, lagType);
|
|
|
|
|
stmt->setUInt16(2, mapId);
|
|
|
|
|
stmt->setFloat (3, x);
|
|
|
|
|
stmt->setFloat (4, y);
|
|
|
|
|
stmt->setFloat (5, z);
|
2012-04-07 19:12:14 +01:00
|
|
|
stmt->setUInt32(6, GetLatency());
|
|
|
|
|
stmt->setUInt32(7, time(NULL));
|
2011-04-19 14:04:18 +06:00
|
|
|
CharacterDatabase.Execute(stmt);
|
2010-08-29 20:28:14 -07:00
|
|
|
}
|
|
|
|
|
|
2010-08-30 15:25:15 +02:00
|
|
|
void WorldSession::HandleGMResponseResolve(WorldPacket& /*recvPacket*/)
|
2010-08-29 20:28:14 -07:00
|
|
|
{
|
|
|
|
|
// empty packet
|
2011-04-19 14:04:18 +06:00
|
|
|
if (GmTicket* ticket = sTicketMgr->GetTicketByPlayer(GetPlayer()->GetGUID()))
|
2010-08-29 20:28:14 -07:00
|
|
|
{
|
|
|
|
|
uint8 getSurvey = 0;
|
2011-04-19 14:04:18 +06:00
|
|
|
if (float(rand_chance()) < sWorld->getFloatConfig(CONFIG_CHANCE_OF_GM_SURVEY))
|
2010-08-29 20:28:14 -07:00
|
|
|
getSurvey = 1;
|
|
|
|
|
|
|
|
|
|
WorldPacket data(SMSG_GMRESPONSE_STATUS_UPDATE, 4);
|
|
|
|
|
data << uint8(getSurvey);
|
|
|
|
|
SendPacket(&data);
|
|
|
|
|
|
|
|
|
|
WorldPacket data2(SMSG_GMTICKET_DELETETICKET, 4);
|
|
|
|
|
data2 << uint32(GMTICKET_RESPONSE_TICKET_DELETED);
|
|
|
|
|
SendPacket(&data2);
|
2011-04-19 14:04:18 +06:00
|
|
|
|
|
|
|
|
sTicketMgr->CloseTicket(ticket->GetId(), GetPlayer()->GetGUID());
|
|
|
|
|
sTicketMgr->SendTicket(this, NULL);
|
2010-08-29 20:28:14 -07:00
|
|
|
}
|
|
|
|
|
}
|