Added spawnCrystalItem
[ryzomcore.git] / ryzom / client / src / r2 / dmc / palette.cpp
blob2ef0eb6300b4069216506c990577fdd2bf00721e
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
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.
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 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/>.
17 #include "stdpch.h"
19 #include "palette.h"
20 #include "game_share/object.h"
22 #include <assert.h>
24 #ifdef DEBUG_NEW
25 #define new DEBUG_NEW
26 #endif
28 using namespace R2;
30 namespace R2
33 CObject* CPalette::getPaletteElement(const std::string& key) const
35 //H_AUTO(R2_CPalette_getPaletteElement)
36 TMap::const_iterator find(_Map.find(key));
37 if (find != _Map.end())
39 return find->second;
41 return 0;
44 void CPalette::addPaletteElement(const std::string& key, CObject* paletteElement)
46 //H_AUTO(R2_CPalette_addPaletteElement)
47 std::pair< TMap::iterator, bool> result;
48 result = _Map.insert( std::pair<std::string, CObject*>(key, paletteElement));
51 if (!result.second)
53 nlwarning("Palette element added twice : %s", key.c_str());
54 delete paletteElement;
58 bool CPalette::isInPalette(const std::string &key) const
60 //H_AUTO(R2_CPalette_isInPalette)
61 TMap::const_iterator found(_Map.find(key));
62 if (found != _Map.end())
63 return true;
64 return false;
67 CPalette::~CPalette()
69 TMap::iterator first(_Map.begin()), last(_Map.end());
70 for (; first != last; ++first)
72 delete(first->second);
74 _Map.clear();
77 } // R2