[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / src / game / BattleGroundAV.cpp
blobc444bcbb246a8256ecc0e59039508dc99ed5130f
1 /*
2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
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.
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.
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
19 #include "Object.h"
20 #include "Player.h"
21 #include "BattleGround.h"
22 #include "BattleGroundAV.h"
23 #include "Creature.h"
24 #include "MapManager.h"
25 #include "Language.h"
27 BattleGroundAV::BattleGroundAV()
32 BattleGroundAV::~BattleGroundAV()
37 void BattleGroundAV::Update(uint32 diff)
39 BattleGround::Update(diff);
42 void BattleGroundAV::AddPlayer(Player *plr)
44 BattleGround::AddPlayer(plr);
45 //create score and add it to map, default values are set in constructor
46 BattleGroundAVScore* sc = new BattleGroundAVScore;
48 m_PlayerScores[plr->GetGUID()] = sc;
51 void BattleGroundAV::RemovePlayer(Player* /*plr*/,uint64 /*guid*/)
56 void BattleGroundAV::HandleAreaTrigger(Player *Source, uint32 Trigger)
58 // this is wrong way to implement these things. On official it done by gameobject spell cast.
59 if(GetStatus() != STATUS_IN_PROGRESS)
60 return;
62 uint32 SpellId = 0;
63 switch(Trigger)
65 case 95:
66 case 2606:
67 case 2608:
68 case 3326:
69 case 3327:
70 case 3328:
71 case 3329:
72 case 3330:
73 case 3331:
74 break;
75 default:
76 sLog.outError("WARNING: Unhandled AreaTrigger in Battleground: %u", Trigger);
77 Source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger);
78 break;
81 if(SpellId)
82 Source->CastSpell(Source, SpellId, true);
85 void BattleGroundAV::UpdatePlayerScore(Player* Source, uint32 type, uint32 value)
88 std::map<uint64, BattleGroundScore*>::iterator itr = m_PlayerScores.find(Source->GetGUID());
90 if(itr == m_PlayerScores.end()) // player not found...
91 return;
93 switch(type)
95 case SCORE_GRAVEYARDS_ASSAULTED:
96 ((BattleGroundAVScore*)itr->second)->GraveyardsAssaulted += value;
97 break;
98 case SCORE_GRAVEYARDS_DEFENDED:
99 ((BattleGroundAVScore*)itr->second)->GraveyardsDefended += value;
100 break;
101 case SCORE_TOWERS_ASSAULTED:
102 ((BattleGroundAVScore*)itr->second)->TowersAssaulted += value;
103 break;
104 case SCORE_TOWERS_DEFENDED:
105 ((BattleGroundAVScore*)itr->second)->TowersDefended += value;
106 break;
107 case SCORE_MINES_CAPTURED:
108 ((BattleGroundAVScore*)itr->second)->MinesCaptured += value;
109 break;
110 case SCORE_LEADERS_KILLED:
111 ((BattleGroundAVScore*)itr->second)->LeadersKilled += value;
112 break;
113 case SCORE_SECONDARY_OBJECTIVES:
114 ((BattleGroundAVScore*)itr->second)->SecondaryObjectives += value;
115 break;
116 default:
117 BattleGround::UpdatePlayerScore(Source,type,value);
118 break;