root/trunk/src/game/GMTicketMgr.cpp @ 229

Revision 229, 2.3 kB (checked in by yumileroy, 17 years ago)

[svn] *** Source: MaNGOS ***
* Fixed build extractor at Windows Vista. Author: Vladimir
* Fixed comment text and code indentifiers spelling. Author: Vladimir & Paradox.
* Access cached member lists in guild handlers instead of querying the DB. Author: Hunuza
* Small fixes in send/received packet and simple code cleanup also. Author: Vladimir
* Not output error at loading empty character_ticket table. Author: Vladimir
* Not reset display model at shapeshift aura remove if it not set at apply. Author: Arthorius
* Applied props to few files.

Original author: visagalis
Date: 2008-11-14 16:28:45-06:00

Line 
1/*
2 * Copyright (C) 2005-2008 MaNGOS
3 *
4 * Copyright (C) 2008 Trinity
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include "Common.h"
22#include "Database/DatabaseEnv.h"
23#include "Database/SQLStorage.h"
24#include "GMTicketMgr.h"
25#include "ObjectMgr.h"
26#include "ProgressBar.h"
27#include "Policies/SingletonImp.h"
28#include "Player.h"
29#include "ObjectDefines.h"
30
31INSTANTIATE_SINGLETON_1(GMTicketMgr);
32
33void GMTicketMgr::LoadGMTickets()
34{
35    m_GMTicketMap.clear();                                  // For reload case
36
37    QueryResult *result = CharacterDatabase.Query(
38        //      0     1           2
39        "SELECT guid, ticket_text,UNIX_TIMESTAMP(ticket_lastchange) FROM character_ticket");
40
41    if( !result )
42    {
43        barGoLink bar( 1 );
44
45        bar.step();
46
47        sLog.outString();
48        sLog.outString(">> Loaded `character_ticket`, table is empty.");
49        return;
50    }
51
52    barGoLink bar( result->GetRowCount() );
53
54    uint32 count = 0;
55
56    do
57    {
58        bar.step();
59
60        Field* fields = result->Fetch();
61
62        uint32 guid = fields[0].GetUInt32();
63        m_GMTicketMap[guid] = GMTicket(guid, fields[1].GetCppString(), time_t(fields[2].GetUInt64()));
64        ++count;
65
66    } while (result->NextRow());
67    delete result;
68
69    sLog.outString();
70    sLog.outString( ">> Loaded %d GM tickets", count );
71}
72
73void GMTicketMgr::DeleteAll()
74{
75    for(GMTicketMap::iterator itr = m_GMTicketMap.begin(); itr != m_GMTicketMap.end(); ++itr)
76    {
77        if(Player* owner = objmgr.GetPlayer(MAKE_NEW_GUID(itr->first,0,HIGHGUID_PLAYER)))
78            owner->GetSession()->SendGMTicketGetTicket(0x0A,0);
79    }
80    CharacterDatabase.PExecute("DELETE FROM character_ticket");
81    m_GMTicketMap.clear();
82}
Note: See TracBrowser for help on using the browser.