1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (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 Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "faction_war_manager.h"
29 using namespace NLMISC
;
36 CFactionWarManager
* CFactionWarManager::_Instance
= NULL
;
39 //----------------------------------------------------------------------------
40 void CFactionWarManager::addFactionWar(PVP_CLAN::CFactionWar fw
)
42 for( uint i
=0; i
<_FactionWarOccurs
.size(); ++i
)
44 if( _FactionWarOccurs
[i
].inPvPFaction(fw
.Clan1
, fw
.Clan2
) )
49 nldebug("<CFactionWarManager::addFactionWar> Adding faction war %s vs %s",PVP_CLAN::toString(fw
.Clan1
).c_str(),PVP_CLAN::toString(fw
.Clan2
).c_str());
50 _FactionWarOccurs
.push_back(fw
);
53 //----------------------------------------------------------------------------
54 void CFactionWarManager::stopFactionWar(PVP_CLAN::CFactionWar fw
)
56 vector
< PVP_CLAN::CFactionWar
>::iterator it
;
57 for( it
=_FactionWarOccurs
.begin(); it
!=_FactionWarOccurs
.end(); ++it
)
59 if( (*it
).inPvPFaction(fw
.Clan1
, fw
.Clan2
) )
61 nldebug("<CFactionWarManager::stopFactionWar> Stopping faction war %s vs %s",PVP_CLAN::toString(fw
.Clan1
).c_str(),PVP_CLAN::toString(fw
.Clan2
).c_str());
62 _FactionWarOccurs
.erase(it
);
68 //----------------------------------------------------------------------------
69 bool CFactionWarManager::areFactionsInWar(PVP_CLAN::TPVPClan clan1
, PVP_CLAN::TPVPClan clan2
)
71 for( uint i
=0; i
<_FactionWarOccurs
.size(); ++i
)
73 if( _FactionWarOccurs
[i
].inPvPFaction(clan1
, clan2
) )
81 //----------------------------------------------------------------------------
82 void CFactionWarManager::init()
87 _Instance
= new CFactionWarManager();
90 //----------------------------------------------------------------------------
91 CFactionWarManager
* CFactionWarManager::getInstance()
93 if(CFactionWarManager::_Instance
== 0)
95 CFactionWarManager::init();
97 return CFactionWarManager::_Instance
;
100 //----------------------------------------------------------------------------
101 void CFactionWarManager::release()
110 //----------------------------------------------------------------------------
111 CFactionWarManager::~CFactionWarManager()
113 _FactionWarOccurs
.clear();