1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
29 #include "nel/misc/vectord.h"
31 #include "nel/georges/u_form.h"
32 #include "nel/georges/u_form_elm.h"
33 #include "nel/georges/u_form_loader.h"
42 using namespace NLMISC
;
43 using namespace NLGEORGES
;
50 const NLMISC::CVectorD
CTeleport::Unknown
= NLMISC::CVectorD(-1.0, -1.0, -1.0);
51 CTeleport::TDestinations
CTeleport::_Destinations
;
54 //-----------------------------------------------
57 //-----------------------------------------------
58 void CTeleport::load(const std::string
&/* filename */)
61 // TRAP : no more teleport list to load from georges file if you want this feature again ask me
63 // Clear old destinations.
64 _Destinations.clear();
67 CSmartPtr<UForm> form = 0;
68 NLGEORGES::UFormLoader *formLoader = UFormLoader::createLoader();
71 form = formLoader->loadForm(filename.c_str());
74 nlwarning("CTeleport::load: can't load form '%s'.", filename.c_str());
80 nlwarning("CTeleport::load: cannot create an UFormLoader *.");
85 const UFormElm& rootElmt = form->getRootNode();
89 const UFormElm *elmt = 0;
90 rootElmt.getNodeByName(&elmt, "list");
94 elmt->getArraySize(arrawSize);
95 // Get all animation for the State.
96 for(uint i = 0; i<arrawSize; ++i)
98 const UFormElm *tpElmt;
99 elmt->getArrayNode(&tpElmt, i);
104 if(tpElmt->getValueByName(destName, "name"))
108 if(tpElmt->getValueByName(pos.x, "position.X")
109 && tpElmt->getValueByName(pos.y, "position.Y")
110 && tpElmt->getValueByName(pos.z, "position.Z"))
112 // All in UPPER CASE to not be CASE SENSITIVE.
113 _Destinations.insert(make_pair(NLMISC::toLowerAscii(destName), pos));
116 nlwarning("CTeleport::load: Cannot find the one of the key 'position.X or Y or Z' for the element %d.", i);
119 nlwarning("CTeleport::load: Cannot find the key 'name' for the element %d.", i);
122 nlwarning("CTeleport::load: element (%d) should be here in 'list'.", i);
126 nlwarning("CTeleport::load: there is no element 'list'.");
128 // Release the loader.
131 UFormLoader::releaseLoader(formLoader);
137 //-----------------------------------------------
139 // Get the destination position or CTeleport::Unknown.
140 //-----------------------------------------------
141 const NLMISC::CVectorD
&CTeleport::getPos(const std::string
&/* dest */)
145 TDestinations::const_iterator it = _Destinations.find(dest);
146 if(it == _Destinations.end())