root/trunk/src/game/OutdoorPvPMgr.cpp @ 102

Revision 102, 6.3 kB (checked in by yumileroy, 17 years ago)

[svn] Fixed copyright notices to comply with GPL.

Original author: w12x
Date: 2008-10-23 03:29:52-05:00

Line 
1/*
2 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19#include "OutdoorPvPMgr.h"
20#include "OutdoorPvPHP.h"
21#include "OutdoorPvPNA.h"
22#include "OutdoorPvPTF.h"
23#include "OutdoorPvPZM.h"
24#include "OutdoorPvPSI.h"
25#include "OutdoorPvPEP.h"
26#include "Player.h"
27#include "Policies/SingletonImp.h"
28
29INSTANTIATE_SINGLETON_1( OutdoorPvPMgr );
30
31OutdoorPvPMgr::OutdoorPvPMgr()
32{
33    //sLog.outDebug("Instantiating OutdoorPvPMgr");
34}
35
36OutdoorPvPMgr::~OutdoorPvPMgr()
37{
38    //sLog.outDebug("Deleting OutdoorPvPMgr");
39    for(OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
40    {
41        (*itr)->DeleteSpawns();
42    }
43}
44
45void OutdoorPvPMgr::InitOutdoorPvP()
46{
47    // create new opvp
48    OutdoorPvP * pOP = new OutdoorPvPHP;
49    // respawn, init variables
50    if(!pOP->SetupOutdoorPvP())
51    {
52        sLog.outDebug("OutdoorPvP : HP init failed.");
53        delete pOP;
54    }
55    else
56    {
57        m_OutdoorPvPSet.insert(pOP);
58        sLog.outDebug("OutdoorPvP : HP successfully initiated.");
59    }
60
61
62    pOP = new OutdoorPvPNA;
63    // respawn, init variables
64    if(!pOP->SetupOutdoorPvP())
65    {
66        sLog.outDebug("OutdoorPvP : NA init failed.");
67        delete pOP;
68    }
69    else
70    {
71        m_OutdoorPvPSet.insert(pOP);
72        sLog.outDebug("OutdoorPvP : NA successfully initiated.");
73    }
74
75
76    pOP = new OutdoorPvPTF;
77    // respawn, init variables
78    if(!pOP->SetupOutdoorPvP())
79    {
80        sLog.outDebug("OutdoorPvP : TF init failed.");
81        delete pOP;
82    }
83    else
84    {
85        m_OutdoorPvPSet.insert(pOP);
86        sLog.outDebug("OutdoorPvP : TF successfully initiated.");
87    }
88
89    pOP = new OutdoorPvPZM;
90    // respawn, init variables
91    if(!pOP->SetupOutdoorPvP())
92    {
93        sLog.outDebug("OutdoorPvP : ZM init failed.");
94        delete pOP;
95    }
96    else
97    {
98        m_OutdoorPvPSet.insert(pOP);
99        sLog.outDebug("OutdoorPvP : ZM successfully initiated.");
100    }
101
102    pOP = new OutdoorPvPSI;
103    // respawn, init variables
104    if(!pOP->SetupOutdoorPvP())
105    {
106        sLog.outDebug("OutdoorPvP : SI init failed.");
107        delete pOP;
108    }
109    else
110    {
111        m_OutdoorPvPSet.insert(pOP);
112        sLog.outDebug("OutdoorPvP : SI successfully initiated.");
113    }
114
115    pOP = new OutdoorPvPEP;
116    // respawn, init variables
117    if(!pOP->SetupOutdoorPvP())
118    {
119        sLog.outDebug("OutdoorPvP : EP init failed.");
120        delete pOP;
121    }
122    else
123    {
124        m_OutdoorPvPSet.insert(pOP);
125        sLog.outDebug("OutdoorPvP : EP successfully initiated.");
126    }
127}
128
129void OutdoorPvPMgr::AddZone(uint32 zoneid, OutdoorPvP *handle)
130{
131    m_OutdoorPvPMap[zoneid] = handle;
132}
133
134
135void OutdoorPvPMgr::HandlePlayerEnterZone(Player *plr, uint32 zoneid)
136{
137    OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid);
138    if(itr == m_OutdoorPvPMap.end())
139    {
140        // no handle for this zone, return
141        return;
142    }
143    // add possibly beneficial buffs to plr for zone
144    itr->second->HandlePlayerEnterZone(plr, zoneid);
145    plr->SendInitWorldStates();
146    sLog.outDebug("Player %u entered outdoorpvp id %u",plr->GetGUIDLow(), itr->second->GetTypeId());
147}
148
149void OutdoorPvPMgr::HandlePlayerLeaveZone(Player *plr, uint32 zoneid)
150{
151    OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid);
152    if(itr == m_OutdoorPvPMap.end())
153    {
154        // no handle for this zone, return
155        return;
156    }
157    // inform the OutdoorPvP class of the leaving, it should remove the player from all objectives
158    itr->second->HandlePlayerLeaveZone(plr, zoneid);
159    sLog.outDebug("Player %u left outdoorpvp id %u",plr->GetGUIDLow(), itr->second->GetTypeId());
160}
161
162OutdoorPvP * OutdoorPvPMgr::GetOutdoorPvPToZoneId(uint32 zoneid)
163{
164    OutdoorPvPMap::iterator itr = m_OutdoorPvPMap.find(zoneid);
165    if(itr == m_OutdoorPvPMap.end())
166    {
167        // no handle for this zone, return
168        return NULL;
169    }
170    return itr->second;
171}
172
173void OutdoorPvPMgr::Update(uint32 diff)
174{
175    for(OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
176    {
177        (*itr)->Update(diff);
178    }
179}
180
181bool OutdoorPvPMgr::HandleCustomSpell(Player *plr, uint32 spellId, GameObject * go)
182{
183    for(OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
184    {
185        if((*itr)->HandleCustomSpell(plr,spellId,go))
186            return true;
187    }
188    return false;
189}
190
191bool OutdoorPvPMgr::HandleOpenGo(Player *plr, uint64 guid)
192{
193    for(OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
194    {
195        if((*itr)->HandleOpenGo(plr,guid))
196            return true;
197    }
198    return false;
199}
200
201bool OutdoorPvPMgr::HandleCaptureCreaturePlayerMoveInLos(Player * plr, Creature * c)
202{
203    for(OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
204    {
205        if((*itr)->HandleCaptureCreaturePlayerMoveInLos(plr,c))
206            return true;
207    }
208    return false;
209}
210
211void OutdoorPvPMgr::HandleGossipOption(Player *plr, uint64 guid, uint32 gossipid)
212{
213    for(OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
214    {
215        if((*itr)->HandleGossipOption(plr,guid,gossipid))
216            return;
217    }
218}
219
220bool OutdoorPvPMgr::CanTalkTo(Player * plr, Creature * c, GossipOption & gso)
221{
222    for(OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
223    {
224        if((*itr)->CanTalkTo(plr,c,gso))
225            return true;
226    }
227    return false;
228}
229
230void OutdoorPvPMgr::HandleDropFlag(Player *plr, uint32 spellId)
231{
232    for(OutdoorPvPSet::iterator itr = m_OutdoorPvPSet.begin(); itr != m_OutdoorPvPSet.end(); ++itr)
233    {
234        if((*itr)->HandleDropFlag(plr,spellId))
235            return;
236    }
237}
Note: See TracBrowser for help on using the browser.