mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
Cache GM tickets on server startup.
This commit is contained in:
parent
49307f6a13
commit
843a0d7d02
11 changed files with 435 additions and 260 deletions
|
|
@ -355,189 +355,6 @@ void WorldSession::HandleLogoutCancelOpcode( WorldPacket & /*recv_data*/ )
|
|||
sLog.outDebug( "WORLD: sent SMSG_LOGOUT_CANCEL_ACK Message" );
|
||||
}
|
||||
|
||||
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); // time from ticket creation?
|
||||
data << float(0); // const
|
||||
data << float(0); // const
|
||||
data << uint8(0); // const
|
||||
data << uint8(0); // const
|
||||
}
|
||||
SendPacket( &data );
|
||||
}
|
||||
|
||||
void WorldSession::HandleGMTicketGetTicketOpcode( WorldPacket & /*recv_data*/ )
|
||||
{
|
||||
WorldPacket data( SMSG_QUERY_TIME_RESPONSE, 4+4 );
|
||||
data << (uint32)time(NULL);
|
||||
data << (uint32)0;
|
||||
SendPacket( &data );
|
||||
|
||||
uint64 guid;
|
||||
Field *fields;
|
||||
guid = GetPlayer()->GetGUID();
|
||||
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT COUNT(ticket_id) FROM character_ticket WHERE guid = '%u'", GUID_LOPART(guid));
|
||||
|
||||
if (result)
|
||||
{
|
||||
int cnt;
|
||||
fields = result->Fetch();
|
||||
cnt = fields[0].GetUInt32();
|
||||
delete result;
|
||||
|
||||
if ( cnt > 0 )
|
||||
{
|
||||
QueryResult *result2 = CharacterDatabase.PQuery("SELECT ticket_text FROM character_ticket WHERE guid = '%u'", GUID_LOPART(guid));
|
||||
if(result2)
|
||||
{
|
||||
Field *fields2 = result2->Fetch();
|
||||
SendGMTicketGetTicket(0x06,fields2[0].GetString());
|
||||
delete result2;
|
||||
}
|
||||
}
|
||||
else
|
||||
SendGMTicketGetTicket(0x0A,0);
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleGMTicketUpdateTextOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,1);
|
||||
|
||||
std::string ticketText;
|
||||
recv_data >> ticketText;
|
||||
|
||||
CharacterDatabase.escape_string(ticketText);
|
||||
CharacterDatabase.PExecute("UPDATE character_ticket SET ticket_text = '%s' WHERE guid = '%u'", ticketText.c_str(), _player->GetGUIDLow());
|
||||
}
|
||||
|
||||
void WorldSession::HandleGMTicketDeleteOpcode( WorldPacket & /*recv_data*/ )
|
||||
{
|
||||
uint32 guid = GetPlayer()->GetGUIDLow();
|
||||
|
||||
CharacterDatabase.PExecute("DELETE FROM character_ticket WHERE guid = '%u' LIMIT 1",guid);
|
||||
|
||||
WorldPacket data( SMSG_GMTICKET_DELETETICKET, 4 );
|
||||
data << uint32(9);
|
||||
SendPacket( &data );
|
||||
|
||||
SendGMTicketGetTicket(0x0A, 0);
|
||||
}
|
||||
|
||||
void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data, 4*4+1+2*4);
|
||||
|
||||
uint32 map;
|
||||
float x, y, z;
|
||||
std::string ticketText = "";
|
||||
uint32 unk1, unk2;
|
||||
|
||||
recv_data >> map >> x >> y >> z; // last check 2.4.3
|
||||
recv_data >> ticketText;
|
||||
|
||||
// recheck
|
||||
CHECK_PACKET_SIZE(recv_data,4*4+(ticketText.size()+1)+2*4);
|
||||
|
||||
recv_data >> unk1 >> unk2;
|
||||
// note: the packet might contain more data, but the exact structure of that is unknown
|
||||
|
||||
sLog.outDebug("TicketCreate: map %u, x %f, y %f, z %f, text %s, unk1 %u, unk2 %u", map, x, y, z, ticketText.c_str(), unk1, unk2);
|
||||
|
||||
CharacterDatabase.escape_string(ticketText);
|
||||
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT COUNT(*) FROM character_ticket WHERE guid = '%u'", _player->GetGUIDLow());
|
||||
|
||||
if (result)
|
||||
{
|
||||
int cnt;
|
||||
Field *fields = result->Fetch();
|
||||
cnt = fields[0].GetUInt32();
|
||||
delete result;
|
||||
|
||||
if ( cnt > 0 )
|
||||
{
|
||||
WorldPacket data( SMSG_GMTICKET_CREATE, 4 );
|
||||
data << uint32(1);
|
||||
SendPacket( &data );
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterDatabase.PExecute("INSERT INTO character_ticket (guid,ticket_text) VALUES ('%u', '%s')", _player->GetGUIDLow(), ticketText.c_str());
|
||||
|
||||
WorldPacket data( SMSG_QUERY_TIME_RESPONSE, 4+4 );
|
||||
data << (uint32)time(NULL);
|
||||
data << (uint32)0;
|
||||
SendPacket( &data );
|
||||
|
||||
data.Initialize( SMSG_GMTICKET_CREATE, 4 );
|
||||
data << uint32(2);
|
||||
SendPacket( &data );
|
||||
DEBUG_LOG("update the ticket\n");
|
||||
|
||||
//TODO: Guard player map
|
||||
HashMapHolder<Player>::MapType &m = ObjectAccessor::Instance().GetPlayers();
|
||||
for(HashMapHolder<Player>::MapType::iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if(itr->second->GetSession()->GetSecurity() >= SEC_GAMEMASTER && itr->second->isAcceptTickets())
|
||||
ChatHandler(itr->second).PSendSysMessage(LANG_COMMAND_TICKETNEW,GetPlayer()->GetName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleGMTicketSystemStatusOpcode( WorldPacket & /*recv_data*/ )
|
||||
{
|
||||
WorldPacket data( SMSG_GMTICKET_SYSTEMSTATUS,4 );
|
||||
data << uint32(1); // we can also disable ticket system by sending 0 value
|
||||
|
||||
SendPacket( &data );
|
||||
}
|
||||
|
||||
void WorldSession::HandleGMSurveySubmit( WorldPacket & recv_data)
|
||||
{
|
||||
// GM survey is shown after SMSG_GM_TICKET_STATUS_UPDATE with status = 3
|
||||
CHECK_PACKET_SIZE(recv_data,4+4);
|
||||
uint32 x;
|
||||
recv_data >> x; // answer range? (6 = 0-5?)
|
||||
sLog.outDebug("SURVEY: X = %u", x);
|
||||
|
||||
uint8 result[10];
|
||||
memset(result, 0, sizeof(result));
|
||||
for( int i = 0; i < 10; ++i)
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,recv_data.rpos()+4);
|
||||
uint32 questionID;
|
||||
recv_data >> questionID; // GMSurveyQuestions.dbc
|
||||
if (!questionID)
|
||||
break;
|
||||
|
||||
CHECK_PACKET_SIZE(recv_data,recv_data.rpos()+1+1);
|
||||
uint8 value;
|
||||
std::string unk_text;
|
||||
recv_data >> value; // answer
|
||||
recv_data >> unk_text; // always empty?
|
||||
|
||||
result[i] = value;
|
||||
sLog.outDebug("SURVEY: ID %u, value %u, text %s", questionID, value, unk_text.c_str());
|
||||
}
|
||||
|
||||
CHECK_PACKET_SIZE(recv_data,recv_data.rpos()+1);
|
||||
std::string comment;
|
||||
recv_data >> comment; // addional comment
|
||||
sLog.outDebug("SURVEY: comment %s", comment.c_str());
|
||||
|
||||
// TODO: chart this data in some way
|
||||
}
|
||||
|
||||
void WorldSession::HandleTogglePvP( WorldPacket & recv_data )
|
||||
{
|
||||
// this opcode can be used in two ways: Either set explicit new status or toggle old status
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue