AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
TicketMgr Class Reference

#include "TicketMgr.h"

Public Member Functions

void LoadTickets ()
 
void LoadSurveys ()
 
GmTicketGetTicket (uint32 ticketId)
 
GmTicketGetTicketByPlayer (ObjectGuid playerGuid)
 
GmTicketGetOldestOpenTicket ()
 
void AddTicket (GmTicket *ticket)
 
void CloseTicket (uint32 ticketId, ObjectGuid source=ObjectGuid::Empty)
 
void ResolveAndCloseTicket (uint32 ticketId, ObjectGuid source)
 
void RemoveTicket (uint32 ticketId)
 
bool GetStatus () const
 
void SetStatus (bool status)
 
uint64 GetLastChange () const
 
void UpdateLastChange (GmTicket *ticket)
 
uint32 GenerateTicketId ()
 
uint32 GetOpenTicketCount () const
 
uint32 GetNextSurveyID ()
 
void Initialize ()
 
void ResetTickets ()
 
void ShowList (ChatHandler &handler, bool onlineOnly) const
 
void ShowClosedList (ChatHandler &handler) const
 
void ShowEscalatedList (ChatHandler &handler) const
 
void SendTicket (WorldSession *session, GmTicket *ticket) const
 

Static Public Member Functions

static TicketMgrinstance ()
 

Protected Member Functions

void _RemoveTicket (uint32 ticketId, int64 source=-1, bool permanently=false)
 

Protected Attributes

GmTicketList _ticketList
 
bool _status
 
uint32 _lastTicketId
 
uint32 _lastSurveyId
 
uint32 _openTicketCount
 
uint64 _lastChange
 

Private Member Functions

 TicketMgr ()
 
 ~TicketMgr ()
 

Detailed Description

Constructor & Destructor Documentation

◆ TicketMgr()

TicketMgr::TicketMgr ( )
private
bool _status
Definition TicketMgr.h:253
uint32 _lastTicketId
Definition TicketMgr.h:254
uint32 _openTicketCount
Definition TicketMgr.h:256
uint32 _lastSurveyId
Definition TicketMgr.h:255
uint64 _lastChange
Definition TicketMgr.h:257
Seconds GetGameTime()
Definition GameTime.cpp:38

◆ ~TicketMgr()

TicketMgr::~TicketMgr ( )
private
268{
269 for (GmTicketList::const_iterator itr = _ticketList.begin(); itr != _ticketList.end(); ++itr)
270 delete itr->second;
271}
GmTicketList _ticketList
Definition TicketMgr.h:251

References _ticketList.

Member Function Documentation

◆ _RemoveTicket()

void TicketMgr::_RemoveTicket ( uint32  ticketId,
int64  source = -1,
bool  permanently = false 
)
protected

◆ AddTicket()

void TicketMgr::AddTicket ( GmTicket ticket)
362{
363 _ticketList[ticket->GetId()] = ticket;
364 if (!ticket->IsClosed())
367 ticket->SaveToDB(trans);
368
369 sScriptMgr->OnTicketCreate(ticket);
370}
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition DatabaseEnvFwd.h:69
#define sScriptMgr
Definition ScriptMgr.h:727
bool IsClosed() const
Definition TicketMgr.h:94
void SaveToDB(CharacterDatabaseTransaction trans) const
Definition TicketMgr.cpp:79
uint32 GetId() const
Definition TicketMgr.h:101

References _openTicketCount, _ticketList, GmTicket::GetId(), GmTicket::IsClosed(), GmTicket::SaveToDB(), and sScriptMgr.

◆ CloseTicket()

void TicketMgr::CloseTicket ( uint32  ticketId,
ObjectGuid  source = ObjectGuid::Empty 
)
373{
374 if (GmTicket* ticket = GetTicket(ticketId))
375 {
377 ticket->SetClosedBy(source);
378 if (source)
380 ticket->SaveToDB(trans);
381
382 sScriptMgr->OnTicketClose(ticket);
383 }
384}
Definition TicketMgr.h:88
GmTicket * GetTicket(uint32 ticketId)
Definition TicketMgr.h:197

References _openTicketCount, GetTicket(), and sScriptMgr.

◆ GenerateTicketId()

uint32 TicketMgr::GenerateTicketId ( )
inline
235{ return ++_lastTicketId; }

References _lastTicketId.

◆ GetLastChange()

uint64 TicketMgr::GetLastChange ( ) const
inline
232{ return _lastChange; }

References _lastChange.

◆ GetNextSurveyID()

uint32 TicketMgr::GetNextSurveyID ( )
inline
237{ return ++_lastSurveyId; }

References _lastSurveyId.

◆ GetOldestOpenTicket()

GmTicket * TicketMgr::GetOldestOpenTicket ( )
inline
216 {
217 for (GmTicketList::const_iterator itr = _ticketList.begin(); itr != _ticketList.end(); ++itr)
218 if (itr->second && !itr->second->IsClosed() && !itr->second->IsCompleted())
219 return itr->second;
220
221 return nullptr;
222 }

References _ticketList.

◆ GetOpenTicketCount()

uint32 TicketMgr::GetOpenTicketCount ( ) const
inline
236{ return _openTicketCount; }

References _openTicketCount.

◆ GetStatus()

bool TicketMgr::GetStatus ( ) const
inline
229{ return _status; }

References _status.

◆ GetTicket()

GmTicket * TicketMgr::GetTicket ( uint32  ticketId)
inline
198 {
199 GmTicketList::iterator itr = _ticketList.find(ticketId);
200 if (itr != _ticketList.end())
201 return itr->second;
202
203 return nullptr;
204 }

References _ticketList.

Referenced by CloseTicket(), RemoveTicket(), and ResolveAndCloseTicket().

◆ GetTicketByPlayer()

GmTicket * TicketMgr::GetTicketByPlayer ( ObjectGuid  playerGuid)
inline
207 {
208 for (GmTicketList::const_iterator itr = _ticketList.begin(); itr != _ticketList.end(); ++itr)
209 if (itr->second && itr->second->IsFromPlayer(playerGuid) && !itr->second->IsClosed())
210 return itr->second;
211
212 return nullptr;
213 }

References _ticketList.

◆ Initialize()

void TicketMgr::Initialize ( )
279{ SetStatus(sWorld->getBoolConfig(CONFIG_ALLOW_TICKETS)); }
@ CONFIG_ALLOW_TICKETS
Definition IWorld.h:132
void SetStatus(bool status)
Definition TicketMgr.h:230
#define sWorld
Definition World.h:363

References CONFIG_ALLOW_TICKETS, SetStatus(), and sWorld.

◆ instance()

TicketMgr * TicketMgr::instance ( )
static
274{
275 static TicketMgr instance;
276 return &instance;
277}
Definition TicketMgr.h:186
static TicketMgr * instance()
Definition TicketMgr.cpp:273

References instance().

Referenced by instance().

◆ LoadSurveys()

void TicketMgr::LoadSurveys ( )
349{
350 // we don't actually load anything into memory here as there's no reason to
351 _lastSurveyId = 0;
352
353 uint32 oldMSTime = getMSTime();
354 if (QueryResult result = CharacterDatabase.Query("SELECT MAX(surveyId) FROM gm_survey"))
355 _lastSurveyId = (*result)[0].Get<uint32>();
356
357 LOG_INFO("server.loading", ">> Loaded GM Survey count from database in {} ms", GetMSTimeDiffToNow(oldMSTime));
358 LOG_INFO("server.loading", " ");
359}
std::shared_ptr< ResultSet > QueryResult
Definition DatabaseEnvFwd.h:27
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
std::uint32_t uint32
Definition Define.h:107
#define LOG_INFO(filterType__,...)
Definition Log.h:165
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition Timer.h:131
uint32 getMSTime()
Definition Timer.h:103

References _lastSurveyId, CharacterDatabase, getMSTime(), GetMSTimeDiffToNow(), and LOG_INFO.

◆ LoadTickets()

void TicketMgr::LoadTickets ( )
303{
304 uint32 oldMSTime = getMSTime();
305
306 for (GmTicketList::const_iterator itr = _ticketList.begin(); itr != _ticketList.end(); ++itr)
307 delete itr->second;
308 _ticketList.clear();
309
310 _lastTicketId = 0;
312
314 PreparedQueryResult result = CharacterDatabase.Query(stmt);
315 if (!result)
316 {
317 LOG_WARN("server.loading", ">> Loaded 0 GM tickets. DB table `gm_ticket` is empty!");
318
319 return;
320 }
321
322 uint32 count = 0;
323 do
324 {
325 Field* fields = result->Fetch();
326 GmTicket* ticket = new GmTicket();
327 if (!ticket->LoadFromDB(fields))
328 {
329 delete ticket;
330 continue;
331 }
332 if (!ticket->IsClosed())
334
335 // Update max ticket id if necessary
336 uint32 id = ticket->GetId();
337 if (_lastTicketId < id)
338 _lastTicketId = id;
339
340 _ticketList[id] = ticket;
341 ++count;
342 } while (result->NextRow());
343
344 LOG_INFO("server.loading", ">> Loaded {} GM tickets in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
345 LOG_INFO("server.loading", " ");
346}
@ CHAR_SEL_GM_TICKETS
Definition CharacterDatabase.h:262
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
#define LOG_WARN(filterType__,...)
Definition Log.h:161
Class used to access individual fields of database query result.
Definition Field.h:98
bool LoadFromDB(Field *fields)
Definition TicketMgr.cpp:50
Definition PreparedStatement.h:157

References _lastTicketId, _openTicketCount, _ticketList, CHAR_SEL_GM_TICKETS, CharacterDatabase, GmTicket::GetId(), getMSTime(), GetMSTimeDiffToNow(), GmTicket::IsClosed(), GmTicket::LoadFromDB(), LOG_INFO, and LOG_WARN.

◆ RemoveTicket()

void TicketMgr::RemoveTicket ( uint32  ticketId)
387{
388 if (GmTicket* ticket = GetTicket(ticketId))
389 {
390 ticket->DeleteFromDB();
391 _ticketList.erase(ticketId);
392 delete ticket;
393 }
394}

References _ticketList, and GetTicket().

◆ ResetTickets()

void TicketMgr::ResetTickets ( )
282{
283 for (GmTicketList::const_iterator itr = _ticketList.begin(); itr != _ticketList.end();)
284 {
285 if (itr->second->IsClosed())
286 {
287 uint32 ticketId = itr->second->GetId();
288 ++itr;
289 sTicketMgr->RemoveTicket(ticketId);
290 }
291 else
292 ++itr;
293 }
294
295 _lastTicketId = 0;
296
298
299 CharacterDatabase.Execute(stmt);
300}
@ CHAR_DEL_ALL_GM_TICKETS
Definition CharacterDatabase.h:265
#define sTicketMgr
Definition TicketMgr.h:260

References _lastTicketId, _ticketList, CHAR_DEL_ALL_GM_TICKETS, CharacterDatabase, and sTicketMgr.

◆ ResolveAndCloseTicket()

void TicketMgr::ResolveAndCloseTicket ( uint32  ticketId,
ObjectGuid  source 
)
397{
398 if (GmTicket* ticket = GetTicket(ticketId))
399 {
401 ticket->SetClosedBy(source);
402 ticket->SetResolvedBy(source);
403 if (source)
405 ticket->SaveToDB(trans);
406
407 sScriptMgr->OnTicketResolve(ticket);
408 }
409}

References _openTicketCount, GetTicket(), and sScriptMgr.

◆ SendTicket()

void TicketMgr::SendTicket ( WorldSession session,
GmTicket ticket 
) const
437{
438 WorldPacket data(SMSG_GMTICKET_GETTICKET, (ticket ? (4 + 4 + 1 + 4 + 4 + 4 + 1 + 1) : 4));
439
440 if (ticket)
441 ticket->WritePacket(data);
442 else
444
445 session->SendPacket(&data);
446}
@ GMTICKET_STATUS_DEFAULT
Definition TicketMgr.h:37
void WritePacket(WorldPacket &data) const
Definition TicketMgr.cpp:116
Definition WorldPacket.h:26
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition WorldSession.cpp:226
@ SMSG_GMTICKET_GETTICKET
Definition Opcodes.h:560

References GMTICKET_STATUS_DEFAULT, WorldSession::SendPacket(), SMSG_GMTICKET_GETTICKET, and GmTicket::WritePacket().

◆ SetStatus()

void TicketMgr::SetStatus ( bool  status)
inline
230{ _status = status; }

References _status.

Referenced by Initialize().

◆ ShowClosedList()

void TicketMgr::ShowClosedList ( ChatHandler handler) const
421{
423 for (GmTicketList::const_iterator itr = _ticketList.begin(); itr != _ticketList.end(); ++itr)
424 if (itr->second->IsClosed())
425 handler.SendSysMessage(itr->second->FormatMessageString(handler).c_str());
426}
@ LANG_COMMAND_TICKETSHOWCLOSEDLIST
Definition Language.h:1023
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:160

References _ticketList, LANG_COMMAND_TICKETSHOWCLOSEDLIST, and ChatHandler::SendSysMessage().

◆ ShowEscalatedList()

void TicketMgr::ShowEscalatedList ( ChatHandler handler) const
429{
431 for (GmTicketList::const_iterator itr = _ticketList.begin(); itr != _ticketList.end(); ++itr)
432 if (!itr->second->IsClosed() && itr->second->GetEscalatedStatus() == TICKET_IN_ESCALATION_QUEUE)
433 handler.SendSysMessage(itr->second->FormatMessageString(handler).c_str());
434}
@ LANG_COMMAND_TICKETSHOWESCALATEDLIST
Definition Language.h:1038
@ TICKET_IN_ESCALATION_QUEUE
Definition TicketMgr.h:59

References _ticketList, LANG_COMMAND_TICKETSHOWESCALATEDLIST, ChatHandler::SendSysMessage(), and TICKET_IN_ESCALATION_QUEUE.

◆ ShowList()

void TicketMgr::ShowList ( ChatHandler handler,
bool  onlineOnly 
) const
412{
414 for (GmTicketList::const_iterator itr = _ticketList.begin(); itr != _ticketList.end(); ++itr)
415 if (!itr->second->IsClosed() && !itr->second->IsCompleted())
416 if (!onlineOnly || itr->second->GetPlayer())
417 handler.SendSysMessage(itr->second->FormatMessageString(handler).c_str());
418}
@ LANG_COMMAND_TICKETSHOWONLINELIST
Definition Language.h:1022
@ LANG_COMMAND_TICKETSHOWLIST
Definition Language.h:1021

References _ticketList, LANG_COMMAND_TICKETSHOWLIST, LANG_COMMAND_TICKETSHOWONLINELIST, and ChatHandler::SendSysMessage().

◆ UpdateLastChange()

void TicketMgr::UpdateLastChange ( GmTicket ticket)
449{
451
452 sScriptMgr->OnTicketUpdateLastChange(ticket);
453}

References _lastChange, GameTime::GetGameTime(), and sScriptMgr.

Member Data Documentation

◆ _lastChange

uint64 TicketMgr::_lastChange
protected

Referenced by GetLastChange(), and UpdateLastChange().

◆ _lastSurveyId

uint32 TicketMgr::_lastSurveyId
protected

Referenced by GetNextSurveyID(), and LoadSurveys().

◆ _lastTicketId

uint32 TicketMgr::_lastTicketId
protected

◆ _openTicketCount

uint32 TicketMgr::_openTicketCount
protected

◆ _status

bool TicketMgr::_status
protected

Referenced by GetStatus(), and SetStatus().

◆ _ticketList


The documentation for this class was generated from the following files: