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/>.
23 void nameToXY(const char *str
, int &x
, int &y
)
25 if (strchr(str
, '_') == NULL
)
27 fprintf(stderr
, "invalid zone name %s\n", str
);
35 y
= y
*10 + *(str
++)-'0';
40 x
= (toupper(str
[0])-'A')*26+(toupper(str
[1])-'A');
43 void XYToName(int x
, int y
, char *str
)
45 sprintf(str
,"%d_%c%c ", y
+1, 'A'+x
/26, 'A'+x
%26);
48 int main(int argc
, char **argv
)
52 fprintf(stderr
, "invalid usage\n");
62 nameToXY(argv
[1], x
, y
);
70 XYToName(x
+i
, y
+j
, dump
);
75 fprintf(stdout
, "%s", output
);