Replace tabs with spaces in more files.
--HG-- branch : trunk
This commit is contained in:
+115
-115
@@ -30,179 +30,179 @@ INSTANTIATE_SINGLETON_1( TicketMgr );
|
||||
|
||||
GM_Ticket* TicketMgr::GetGMTicket(uint64 ticketGuid)
|
||||
{
|
||||
for(GmTicketList::iterator i = GM_TicketList.begin(); i != GM_TicketList.end();)
|
||||
{
|
||||
if((*i)->guid == ticketGuid)
|
||||
{
|
||||
return (*i);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return NULL;
|
||||
for(GmTicketList::iterator i = GM_TicketList.begin(); i != GM_TicketList.end();)
|
||||
{
|
||||
if((*i)->guid == ticketGuid)
|
||||
{
|
||||
return (*i);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GM_Ticket* TicketMgr::GetGMTicketByPlayer(uint64 playerGuid)
|
||||
{
|
||||
for(GmTicketList::iterator i = GM_TicketList.begin(); i != GM_TicketList.end();)
|
||||
{
|
||||
if((*i)->playerGuid == playerGuid && (*i)->closed == 0)
|
||||
{
|
||||
return (*i);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return NULL;
|
||||
for(GmTicketList::iterator i = GM_TicketList.begin(); i != GM_TicketList.end();)
|
||||
{
|
||||
if((*i)->playerGuid == playerGuid && (*i)->closed == 0)
|
||||
{
|
||||
return (*i);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GM_Ticket* TicketMgr::GetGMTicketByName(const char* name)
|
||||
{
|
||||
std::string pname = name;
|
||||
if(!normalizePlayerName(pname))
|
||||
return NULL;
|
||||
std::string pname = name;
|
||||
if(!normalizePlayerName(pname))
|
||||
return NULL;
|
||||
|
||||
Player *plr = objmgr.GetPlayer(pname.c_str());
|
||||
if(!plr)
|
||||
return NULL;
|
||||
Player *plr = objmgr.GetPlayer(pname.c_str());
|
||||
if(!plr)
|
||||
return NULL;
|
||||
|
||||
uint64 playerGuid = plr->GetGUID();
|
||||
uint64 playerGuid = plr->GetGUID();
|
||||
|
||||
for(GmTicketList::iterator i = GM_TicketList.begin(); i != GM_TicketList.end();)
|
||||
{
|
||||
if((*i)->playerGuid == playerGuid && (*i)->closed == 0)
|
||||
{
|
||||
return (*i);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return NULL;
|
||||
for(GmTicketList::iterator i = GM_TicketList.begin(); i != GM_TicketList.end();)
|
||||
{
|
||||
if((*i)->playerGuid == playerGuid && (*i)->closed == 0)
|
||||
{
|
||||
return (*i);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void TicketMgr::AddGMTicket(GM_Ticket *ticket, bool startup)
|
||||
{
|
||||
ASSERT( ticket );
|
||||
GM_TicketList.push_back(ticket);
|
||||
ASSERT( ticket );
|
||||
GM_TicketList.push_back(ticket);
|
||||
|
||||
// save
|
||||
if(!startup)
|
||||
SaveGMTicket(ticket);
|
||||
// save
|
||||
if(!startup)
|
||||
SaveGMTicket(ticket);
|
||||
}
|
||||
|
||||
void TicketMgr::DeleteGMTicketPermanently(uint64 ticketGuid)
|
||||
{
|
||||
for(GmTicketList::iterator i = GM_TicketList.begin(); i != GM_TicketList.end();)
|
||||
{
|
||||
if((*i)->guid == ticketGuid)
|
||||
{
|
||||
i = GM_TicketList.erase(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
++i;
|
||||
}
|
||||
}
|
||||
for(GmTicketList::iterator i = GM_TicketList.begin(); i != GM_TicketList.end();)
|
||||
{
|
||||
if((*i)->guid == ticketGuid)
|
||||
{
|
||||
i = GM_TicketList.erase(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
// delete database record
|
||||
CharacterDatabase.PExecute("DELETE FROM `gm_tickets` WHERE guid= '%u'", ticketGuid);
|
||||
// delete database record
|
||||
CharacterDatabase.PExecute("DELETE FROM `gm_tickets` WHERE guid= '%u'", ticketGuid);
|
||||
}
|
||||
|
||||
|
||||
void TicketMgr::LoadGMTickets()
|
||||
{
|
||||
InitTicketID();
|
||||
// Delete all out of object holder
|
||||
GM_TicketList.clear();
|
||||
QueryResult *result = CharacterDatabase.Query( "SELECT `guid`, `playerGuid`, `name`, `message`, `timestamp`, `closed`, `assignedto`, `comment` FROM `gm_tickets`" );
|
||||
GM_Ticket *ticket;
|
||||
InitTicketID();
|
||||
// Delete all out of object holder
|
||||
GM_TicketList.clear();
|
||||
QueryResult *result = CharacterDatabase.Query( "SELECT `guid`, `playerGuid`, `name`, `message`, `timestamp`, `closed`, `assignedto`, `comment` FROM `gm_tickets`" );
|
||||
GM_Ticket *ticket;
|
||||
|
||||
if(!result)
|
||||
return;
|
||||
if(!result)
|
||||
return;
|
||||
|
||||
// Assign values from SQL to the object holder
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
ticket = new GM_Ticket;
|
||||
ticket->guid = fields[0].GetUInt64();
|
||||
ticket->playerGuid = fields[1].GetUInt64();
|
||||
ticket->name = fields[2].GetString();
|
||||
ticket->message = fields[3].GetString();
|
||||
ticket->timestamp = fields[4].GetUInt32();
|
||||
ticket->closed = fields[5].GetUInt16();
|
||||
ticket->assignedToGM = fields[6].GetUInt64();
|
||||
ticket->comment = fields[7].GetString();
|
||||
// Assign values from SQL to the object holder
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
ticket = new GM_Ticket;
|
||||
ticket->guid = fields[0].GetUInt64();
|
||||
ticket->playerGuid = fields[1].GetUInt64();
|
||||
ticket->name = fields[2].GetString();
|
||||
ticket->message = fields[3].GetString();
|
||||
ticket->timestamp = fields[4].GetUInt32();
|
||||
ticket->closed = fields[5].GetUInt16();
|
||||
ticket->assignedToGM = fields[6].GetUInt64();
|
||||
ticket->comment = fields[7].GetString();
|
||||
|
||||
AddGMTicket(ticket, true);
|
||||
AddGMTicket(ticket, true);
|
||||
|
||||
} while( result->NextRow() );
|
||||
} while( result->NextRow() );
|
||||
|
||||
sWorld.SendGMText(LANG_COMMAND_TICKETRELOAD, result->GetRowCount());
|
||||
sWorld.SendGMText(LANG_COMMAND_TICKETRELOAD, result->GetRowCount());
|
||||
|
||||
delete result;
|
||||
delete result;
|
||||
}
|
||||
|
||||
void TicketMgr::RemoveGMTicket(uint64 ticketGuid, uint64 GMguid)
|
||||
{
|
||||
for(GmTicketList::iterator i = GM_TicketList.begin(); i != GM_TicketList.end();)
|
||||
{
|
||||
if((*i)->guid == ticketGuid && (*i)->closed == 0)
|
||||
{
|
||||
(*i)->closed = GMguid;
|
||||
SaveGMTicket((*i));
|
||||
}
|
||||
++i;
|
||||
}
|
||||
for(GmTicketList::iterator i = GM_TicketList.begin(); i != GM_TicketList.end();)
|
||||
{
|
||||
if((*i)->guid == ticketGuid && (*i)->closed == 0)
|
||||
{
|
||||
(*i)->closed = GMguid;
|
||||
SaveGMTicket((*i));
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TicketMgr::RemoveGMTicketByPlayer(uint64 playerGuid, uint64 GMguid)
|
||||
{
|
||||
for(GmTicketList::iterator i = GM_TicketList.begin(); i != GM_TicketList.end();)
|
||||
{
|
||||
if((*i)->playerGuid == playerGuid && (*i)->closed == 0)
|
||||
{
|
||||
(*i)->closed = GMguid;
|
||||
SaveGMTicket((*i));
|
||||
}
|
||||
++i;
|
||||
}
|
||||
for(GmTicketList::iterator i = GM_TicketList.begin(); i != GM_TicketList.end();)
|
||||
{
|
||||
if((*i)->playerGuid == playerGuid && (*i)->closed == 0)
|
||||
{
|
||||
(*i)->closed = GMguid;
|
||||
SaveGMTicket((*i));
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
void TicketMgr::SaveGMTicket(GM_Ticket* ticket)
|
||||
{
|
||||
std::string msg = ticket->message;
|
||||
std::string msg = ticket->message;
|
||||
CharacterDatabase.escape_string(msg);
|
||||
std::stringstream ss;
|
||||
ss << "REPLACE INTO `gm_tickets` (`guid`, `playerGuid`, `name`, `message`, `timestamp`, `closed`, `assignedto`, `comment`) VALUES('";
|
||||
ss << ticket->guid << "', '";
|
||||
ss << ticket->playerGuid << "', '";
|
||||
ss << ticket->name << "', '";
|
||||
ss << msg << "', '" ;
|
||||
ss << ticket->timestamp << "', '";
|
||||
ss << ticket->closed << "', '";
|
||||
ss << ticket->assignedToGM << "', '";
|
||||
ss << ticket->comment << "');";
|
||||
std::stringstream ss;
|
||||
ss << "REPLACE INTO `gm_tickets` (`guid`, `playerGuid`, `name`, `message`, `timestamp`, `closed`, `assignedto`, `comment`) VALUES('";
|
||||
ss << ticket->guid << "', '";
|
||||
ss << ticket->playerGuid << "', '";
|
||||
ss << ticket->name << "', '";
|
||||
ss << msg << "', '" ;
|
||||
ss << ticket->timestamp << "', '";
|
||||
ss << ticket->closed << "', '";
|
||||
ss << ticket->assignedToGM << "', '";
|
||||
ss << ticket->comment << "');";
|
||||
CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabase.Execute(ss.str().c_str());
|
||||
CharacterDatabase.CommitTransaction();
|
||||
CharacterDatabase.Execute(ss.str().c_str());
|
||||
CharacterDatabase.CommitTransaction();
|
||||
|
||||
}
|
||||
|
||||
void TicketMgr::UpdateGMTicket(GM_Ticket *ticket)
|
||||
{
|
||||
SaveGMTicket(ticket);
|
||||
SaveGMTicket(ticket);
|
||||
}
|
||||
|
||||
void TicketMgr::InitTicketID()
|
||||
{
|
||||
QueryResult *result = CharacterDatabase.Query("SELECT MAX(guid) FROM gm_tickets");
|
||||
if(result)
|
||||
{
|
||||
m_ticketid = result->Fetch()[0].GetUInt64();
|
||||
delete result;
|
||||
}
|
||||
QueryResult *result = CharacterDatabase.Query("SELECT MAX(guid) FROM gm_tickets");
|
||||
if(result)
|
||||
{
|
||||
m_ticketid = result->Fetch()[0].GetUInt64();
|
||||
delete result;
|
||||
}
|
||||
}
|
||||
|
||||
uint64 TicketMgr::GenerateTicketID()
|
||||
{
|
||||
return ++m_ticketid;
|
||||
return ++m_ticketid;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user