2014-06-16 03:34:39 +02:00
|
|
|
#include <platform.h>
|
|
|
|
#include <kernel/config.h>
|
|
|
|
#include "direction.h"
|
2014-09-29 21:19:07 +02:00
|
|
|
#include "vortex.h"
|
2014-06-16 03:34:39 +02:00
|
|
|
|
|
|
|
#include "util/language.h"
|
|
|
|
#include "util/umlaut.h"
|
|
|
|
|
2014-06-16 07:17:08 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
2017-12-11 16:24:06 +01:00
|
|
|
const char *shortdirections[MAXDIRECTIONS] = {
|
|
|
|
"dir_nw",
|
|
|
|
"dir_ne",
|
|
|
|
"dir_east",
|
|
|
|
"dir_se",
|
|
|
|
"dir_sw",
|
|
|
|
"dir_west"
|
|
|
|
};
|
|
|
|
|
2014-06-16 03:34:39 +02:00
|
|
|
void init_direction(const struct locale *lang, direction_t dir, const char *str) {
|
|
|
|
void **tokens = get_translations(lang, UT_DIRECTIONS);
|
|
|
|
variant token;
|
|
|
|
token.i = dir;
|
2016-09-06 20:57:07 +02:00
|
|
|
addtoken((struct tnode **)tokens, str, token);
|
2014-06-16 03:34:39 +02:00
|
|
|
}
|
|
|
|
|
2014-09-29 21:19:07 +02:00
|
|
|
void init_directions(struct locale *lang) {
|
2018-12-17 12:07:38 +01:00
|
|
|
/* mit dieser routine kann man mehrere namen fuer eine direction geben,
|
|
|
|
* das ist fuer die hexes ideal. */
|
2014-06-16 03:34:39 +02:00
|
|
|
const struct {
|
|
|
|
const char *name;
|
|
|
|
direction_t direction;
|
|
|
|
} dirs[] = {
|
|
|
|
{ "dir_ne", D_NORTHEAST },
|
2015-01-30 20:37:14 +01:00
|
|
|
{ "dir_nw", D_NORTHWEST },
|
|
|
|
{ "dir_se", D_SOUTHEAST },
|
|
|
|
{ "dir_sw", D_SOUTHWEST },
|
|
|
|
{ "dir_east", D_EAST },
|
|
|
|
{ "dir_west", D_WEST },
|
2014-06-16 03:34:39 +02:00
|
|
|
{ "northeast", D_NORTHEAST },
|
|
|
|
{ "northwest", D_NORTHWEST },
|
|
|
|
{ "southeast", D_SOUTHEAST },
|
|
|
|
{ "southwest", D_SOUTHWEST },
|
|
|
|
{ "east", D_EAST },
|
2015-01-30 20:37:14 +01:00
|
|
|
{ "west", D_WEST },
|
2014-06-16 03:34:39 +02:00
|
|
|
{ "PAUSE", D_PAUSE },
|
|
|
|
{ NULL, NODIRECTION }
|
|
|
|
};
|
|
|
|
int i;
|
|
|
|
void **tokens = get_translations(lang, UT_DIRECTIONS);
|
|
|
|
|
2014-09-29 21:19:07 +02:00
|
|
|
register_special_direction(lang, "vortex");
|
|
|
|
|
2014-06-16 03:34:39 +02:00
|
|
|
for (i = 0; dirs[i].direction != NODIRECTION; ++i) {
|
2015-01-08 20:55:29 +01:00
|
|
|
const char *str = locale_string(lang, dirs[i].name, false);
|
2014-06-16 17:01:59 +02:00
|
|
|
if (str) {
|
|
|
|
variant token;
|
|
|
|
token.i = dirs[i].direction;
|
2016-09-06 20:57:07 +02:00
|
|
|
addtoken((struct tnode **)tokens, str, token);
|
2014-06-16 17:01:59 +02:00
|
|
|
}
|
2014-06-16 03:34:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-16 07:17:08 +02:00
|
|
|
direction_t get_direction(const char *s, const struct locale *lang)
|
2014-06-16 03:34:39 +02:00
|
|
|
{
|
|
|
|
void **tokens = get_translations(lang, UT_DIRECTIONS);
|
|
|
|
variant token;
|
|
|
|
|
|
|
|
if (findtoken(*tokens, s, &token) == E_TOK_SUCCESS) {
|
|
|
|
return (direction_t)token.i;
|
|
|
|
}
|
|
|
|
return NODIRECTION;
|
|
|
|
}
|
|
|
|
|
2014-06-16 07:17:08 +02:00
|
|
|
direction_t finddirection(const char *str) {
|
|
|
|
int i;
|
2015-01-30 20:37:14 +01:00
|
|
|
for (i = 0; i != MAXDIRECTIONS + 2; ++i) {
|
|
|
|
if (directions[i] && strcmp(str, directions[i]) == 0) {
|
2014-06-16 07:17:08 +02:00
|
|
|
return (direction_t)i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NODIRECTION;
|
|
|
|
}
|
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
const char * directions[MAXDIRECTIONS + 2] = {
|
|
|
|
"northwest", "northeast", "east", "southeast", "southwest", "west", 0, "pause"
|
2014-06-16 07:17:08 +02:00
|
|
|
};
|
|
|
|
|