2014-06-16 03:34:39 +02:00
|
|
|
|
#include <platform.h>
|
|
|
|
|
#include <kernel/config.h>
|
|
|
|
|
#include "direction.h"
|
|
|
|
|
|
|
|
|
|
#include "util/language.h"
|
|
|
|
|
#include "util/umlaut.h"
|
|
|
|
|
|
2014-06-16 07:17:08 +02:00
|
|
|
|
#include <string.h>
|
|
|
|
|
|
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;
|
|
|
|
|
addtoken(tokens, str, token);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void init_directions(const struct locale *lang) {
|
|
|
|
|
/* mit dieser routine kann man mehrere namen f<>r eine direction geben,
|
|
|
|
|
* das ist f<EFBFBD>r die hexes ideal. */
|
|
|
|
|
const struct {
|
|
|
|
|
const char *name;
|
|
|
|
|
direction_t direction;
|
|
|
|
|
} dirs[] = {
|
|
|
|
|
{ "dir_ne", D_NORTHEAST },
|
|
|
|
|
{ "dir_nw", D_NORTHWEST },
|
|
|
|
|
{ "dir_se", D_SOUTHEAST },
|
|
|
|
|
{ "dir_sw", D_SOUTHWEST },
|
|
|
|
|
{ "dir_east", D_EAST },
|
|
|
|
|
{ "dir_west", D_WEST },
|
|
|
|
|
{ "northeast", D_NORTHEAST },
|
|
|
|
|
{ "northwest", D_NORTHWEST },
|
|
|
|
|
{ "southeast", D_SOUTHEAST },
|
|
|
|
|
{ "southwest", D_SOUTHWEST },
|
|
|
|
|
{ "east", D_EAST },
|
|
|
|
|
{ "west", D_WEST },
|
|
|
|
|
{ "PAUSE", D_PAUSE },
|
|
|
|
|
{ NULL, NODIRECTION }
|
|
|
|
|
};
|
|
|
|
|
int i;
|
|
|
|
|
void **tokens = get_translations(lang, UT_DIRECTIONS);
|
|
|
|
|
|
|
|
|
|
for (i = 0; dirs[i].direction != NODIRECTION; ++i) {
|
|
|
|
|
const char *str = locale_string(lang, dirs[i].name);
|
2014-06-16 17:01:59 +02:00
|
|
|
|
if (str) {
|
|
|
|
|
variant token;
|
|
|
|
|
token.i = dirs[i].direction;
|
|
|
|
|
addtoken(tokens, str, token);
|
|
|
|
|
}
|
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;
|
|
|
|
|
for (i=0;i!=MAXDIRECTIONS+2;++i) {
|
|
|
|
|
if (directions[i] && strcmp(str, directions[i])==0) {
|
|
|
|
|
return (direction_t)i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NODIRECTION;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char * directions[MAXDIRECTIONS+2] = {
|
|
|
|
|
"northwest", "northeast", "east", "southeast", "southwest", "west", 0, "pause"
|
|
|
|
|
};
|
|
|
|
|
|