1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
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/>.
18 #include "nel/misc/types_nl.h"
19 #include "nel/misc/file.h"
20 #include "nel/3d/quad_tree.h"
21 #include "nel/3d/zone.h"
28 using namespace NLMISC
;
33 /*******************************************************************\
35 \*******************************************************************/
36 bool getZoneCoordByName(const char * name
, uint16
& x
, uint16
& y
)
40 std::string
zoneName(name
);
43 string::size_type ind1
= zoneName
.find("_");
44 if(ind1
== string::npos
|| ind1
>=zoneName
.length())
46 nlwarning("bad file name");
49 std::string ystr
= zoneName
.substr(0,ind1
);
50 for(i
=0; i
<ystr
.length(); i
++)
54 nlwarning("y code size is not a 2 characters code");
58 NLMISC::fromString(ystr
, y
);
62 uint ind2
= (uint
)zoneName
.length();
65 nlwarning("x code size is not a 2 characters code");
68 std::string xstr
= zoneName
.substr(ind1
+1,ind2
-ind1
-1);
69 for(i
=0; i
<xstr
.length(); i
++)
74 x
+= (tolower(xstr
[i
])-'a');
85 /*******************************************************************\
87 \*******************************************************************/
88 void getLettersFromNum(uint16 num
, std::string
& code
)
92 nlwarning("zone index too high");
96 uint16 remainder
= num
%26;
98 code
+= 'A' + remainder
;
101 /*******************************************************************\
103 \*******************************************************************/
104 void getZoneNameByCoord(uint16 x
, uint16 y
, std::string
& zoneName
)
108 sprintf(stmp
,"%d",y
);
109 std::string ystrtmp
= std::string(stmp
);
113 getLettersFromNum(x
, xstrtmp
);