Files
TCPlayerbotCore/src/game/TicketHandler.cpp
T

155 lines
4.5 KiB
C++
Raw Normal View History

/*
2009-04-06 21:14:51 +02:00
* Copyright (C) 2005-2009 MaNGOS
*
2010-01-19 16:37:49 +01:00
* Copyright (C) 2008-2010 Trinity
*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
2009-10-17 15:51:44 -07:00
#include "Language.h"
#include "WorldPacket.h"
#include "Common.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "World.h"
2009-10-17 15:51:44 -07:00
void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data )
{
if(GM_Ticket *ticket = objmgr.GetGMTicketByPlayer(GetPlayer()->GetGUID()))
{
WorldPacket data( SMSG_GMTICKET_CREATE, 4 );
data << uint32(1); // 1 - You already have GM ticket
SendPacket( &data );
return;
}
2009-10-17 15:51:44 -07:00
2009-02-09 08:16:34 -05:00
uint32 map;
float x, y, z;
std::string ticketText, ticketText2;
2009-10-17 15:51:44 -07:00
SendQueryTimeResponse();
2009-02-09 08:16:34 -05:00
WorldPacket data(SMSG_GMTICKET_CREATE, 4);
recv_data >> map;
recv_data >> x;
recv_data >> y;
recv_data >> z;
recv_data >> ticketText;
2009-02-09 08:16:34 -05:00
recv_data >> ticketText2;
2009-10-17 15:51:44 -07:00
2009-10-17 16:20:24 -07:00
GM_Ticket *ticket = new GM_Ticket;
2009-02-09 08:16:34 -05:00
ticket->name = GetPlayer()->GetName();
ticket->guid = objmgr.GenerateGMTicketId();
2009-02-09 08:16:34 -05:00
ticket->playerGuid = GetPlayer()->GetGUID();
ticket->message = ticketText;
ticket->createtime = time(NULL);
2009-04-14 17:48:58 +02:00
ticket->map = map;
ticket->pos_x = x;
ticket->pos_y = y;
ticket->pos_z = z;
ticket->timestamp = time(NULL);
2009-02-09 08:16:34 -05:00
ticket->closed = 0;
ticket->assignedToGM = 0;
ticket->comment = "";
2009-10-17 15:51:44 -07:00
objmgr.AddOrUpdateGMTicket(*ticket, true);
2009-10-17 15:51:44 -07:00
2009-02-09 08:16:34 -05:00
data << uint32(2);
SendPacket(&data);
2009-10-17 15:51:44 -07:00
sWorld.SendGMText(LANG_COMMAND_TICKETNEW, GetPlayer()->GetName(), ticket->guid);
2009-10-17 15:51:44 -07:00
}
2009-10-17 15:51:44 -07:00
void WorldSession::HandleGMTicketUpdateOpcode( WorldPacket & recv_data)
{
2009-02-09 08:16:34 -05:00
WorldPacket data(SMSG_GMTICKET_UPDATETEXT, 4);
2009-10-17 15:51:44 -07:00
std::string message;
2009-02-09 08:16:34 -05:00
recv_data >> message;
2009-10-17 15:51:44 -07:00
GM_Ticket *ticket = objmgr.GetGMTicketByPlayer(GetPlayer()->GetGUID());
2009-02-09 08:16:34 -05:00
if(!ticket)
{
data << uint32(1);
SendPacket(&data);
return;
}
2009-10-17 15:51:44 -07:00
2009-02-09 08:16:34 -05:00
ticket->message = message;
ticket->timestamp = time(NULL);
2009-10-17 15:51:44 -07:00
objmgr.AddOrUpdateGMTicket(*ticket);
2009-10-17 15:51:44 -07:00
2009-02-09 08:16:34 -05:00
data << uint32(2);
SendPacket(&data);
2009-10-17 15:51:44 -07:00
2009-02-09 08:16:34 -05:00
sWorld.SendGMText(LANG_COMMAND_TICKETUPDATED, GetPlayer()->GetName(), ticket->guid);
2009-10-17 15:51:44 -07:00
}
2009-10-17 15:51:44 -07:00
void WorldSession::HandleGMTicketDeleteOpcode( WorldPacket & /*recv_data*/)
{
GM_Ticket* ticket = objmgr.GetGMTicketByPlayer(GetPlayer()->GetGUID());
2009-10-17 15:51:44 -07:00
2009-02-09 08:16:34 -05:00
if(ticket)
{
WorldPacket data(SMSG_GMTICKET_DELETETICKET, 4);
data << uint32(9);
SendPacket(&data);
2009-10-17 15:51:44 -07:00
2009-02-09 08:16:34 -05:00
sWorld.SendGMText(LANG_COMMAND_TICKETPLAYERABANDON, GetPlayer()->GetName(), ticket->guid );
objmgr.RemoveGMTicket(ticket, GetPlayer()->GetGUID(), false);
SendGMTicketGetTicket(0x0A, 0);
2009-02-09 08:16:34 -05:00
}
}
2009-10-17 15:51:44 -07:00
void WorldSession::HandleGMTicketGetTicketOpcode( WorldPacket & /*recv_data*/)
{
SendQueryTimeResponse();
2009-10-17 15:51:44 -07:00
GM_Ticket *ticket = objmgr.GetGMTicketByPlayer(GetPlayer()->GetGUID());
if(ticket)
2009-06-19 00:52:47 +02:00
SendGMTicketGetTicket(0x06, ticket->message.c_str());
else
SendGMTicketGetTicket(0x0A, 0);
2009-10-17 15:51:44 -07:00
}
2009-10-17 15:51:44 -07:00
void WorldSession::HandleGMTicketSystemStatusOpcode( WorldPacket & /*recv_data*/)
{
2009-02-09 08:16:34 -05:00
WorldPacket data(SMSG_GMTICKET_SYSTEMSTATUS, 4);
data << uint32(1);
SendPacket(&data);
2009-01-10 12:45:01 +01:00
}
2009-10-17 15:51:44 -07:00
void WorldSession::SendGMTicketGetTicket(uint32 status, char const* text)
{
int len = text ? strlen(text) : 0;
WorldPacket data( SMSG_GMTICKET_GETTICKET, (4+len+1+4+2+4+4) );
data << uint32(status); // standard 0x0A, 0x06 if text present
if(status == 6)
{
data << text; // ticket text
data << uint8(0x7); // ticket category
data << float(0); // tickets in queue?
data << float(0); // if > "tickets in queue" then "We are currently experiencing a high volume of petitions."
data << float(0); // 0 - "Your ticket will be serviced soon", 1 - "Wait time currently unavailable"
data << uint8(0); // if == 2 and next field == 1 then "Your ticket has been escalated"
data << uint8(0); // const
}
SendPacket( &data );
}