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 <sys/types.h>
20 #include "VMapFactory.h"
21 #include "VMapManager.h"
27 extern void chompAndTrim(std::string
& str
);
29 VMapManager
*gVMapManager
= 0;
30 Table
<unsigned int , bool>* iIgnoreSpellIds
=0;
32 //===============================================
33 // result false, if no more id are found
35 bool getNextId(const std::string
& pString
, unsigned int& pStartPos
, unsigned int& pId
)
39 for(i
=pStartPos
;i
<pString
.size(); ++i
)
48 std::string idString
= pString
.substr(pStartPos
, i
-pStartPos
);
50 chompAndTrim(idString
);
51 pId
= atoi(idString
.c_str());
57 //===============================================
59 parameter: String of map ids. Delimiter = ","
62 void VMapFactory::preventSpellsFromBeingTestedForLoS(const char* pSpellIdString
)
65 iIgnoreSpellIds
= new Table
<unsigned int , bool>();
66 if(pSpellIdString
!= NULL
)
70 std::string
confString(pSpellIdString
);
71 chompAndTrim(confString
);
72 while(getNextId(confString
, pos
, id
))
74 iIgnoreSpellIds
->set(id
, true);
79 //===============================================
81 bool VMapFactory::checkSpellForLoS(unsigned int pSpellId
)
83 return(!iIgnoreSpellIds
->containsKey(pSpellId
));
86 //===============================================
87 // just return the instance
88 IVMapManager
* VMapFactory::createOrGetVMapManager()
91 gVMapManager
= new VMapManager(); // should be taken from config ... Please change if you like :-)
95 //===============================================
96 // delete all internal data structures
97 void VMapFactory::clear()
101 delete iIgnoreSpellIds
;
102 iIgnoreSpellIds
= NULL
;