Merge pull request #684 from ennorehling/develop

Ponnuki and Farsi
This commit is contained in:
Enno Rehling 2017-04-15 20:30:26 +02:00 committed by GitHub
commit b82bc0bb9c
4 changed files with 32 additions and 10 deletions

View File

@ -14,9 +14,11 @@ local function ponnuki_brain(u)
u:add_notice("Eine Botschaft von " .. tostring(u) .. ": " ..jokes[i]) u:add_notice("Eine Botschaft von " .. tostring(u) .. ": " ..jokes[i])
local d = math.random(6) local d = math.random(6)
local r = u.region:next(d-1) local r = u.region:next(d-1)
if r.terrain == 'glacier' then
u:clear_orders() u:clear_orders()
u:add_order("NACH " .. directions[d]) u:add_order("NACH " .. directions[d])
end end
end
function ponnuki.init() function ponnuki.init()
-- initialize other scripts -- initialize other scripts
@ -26,11 +28,18 @@ function ponnuki.init()
local home = get_region(-67, -5) local home = get_region(-67, -5)
local f = get_faction(666) local f = get_faction(666)
if home and f then if home and f then
u = unit.create(f, home, 1, "illusion") if home.terrain~="glacier" then
home.terrain="glacier"
home.name = 'Magrathea'
end
u = unit.create(f, home, 1, "template")
if u then
u.id = atoi36("ponn") u.id = atoi36("ponn")
u.name = "Ponnuki" u.name = "Ponnuki"
u.info = "Go, Ponnuki, Go!" u.info = "Go, Ponnuki, Go!"
u:set_racename("Ritter von Go") u.race_name = "Ritter von Go"
print(u:show())
end
else else
eressea.log.error("Ponnuki cannot find Magrathea") eressea.log.error("Ponnuki cannot find Magrathea")
end end

View File

@ -121,7 +121,7 @@ const char *parameters[MAXPARAMS] = {
"TEMP", "TEMP",
"FLIEHE", "FLIEHE",
"GEBAEUDE", "GEBAEUDE",
"GIB", /* F<EFBFBD>r HELFE */ "GIB", /* HELFE GIB */
"KAEMPFE", "KAEMPFE",
"DURCHREISE", "DURCHREISE",
"BEWACHE", "BEWACHE",

View File

@ -57,7 +57,7 @@ int unicode_utf8_trim(utf8_t *buf)
if (op == buf && iswspace(wc)) { if (op == buf && iswspace(wc)) {
++result; ++result;
} }
else if (iswprint(wc)) { else if (wc>255 || !iscntrl(wc)) {
if (op != ip) { if (op != ip) {
memmove(op, ip, size); memmove(op, ip, size);
} }
@ -67,7 +67,8 @@ int unicode_utf8_trim(utf8_t *buf)
lc = op; lc = op;
ts = 0; ts = 0;
} }
} else { }
else {
++result; ++result;
} }
ip += size; ip += size;

View File

@ -123,6 +123,17 @@ static void test_unicode_compare(CuTest *tc)
CuAssertIntEquals(tc, 1, unicode_utf8_strcasecmp("bacdefg123", "ABCDEFG123")); CuAssertIntEquals(tc, 1, unicode_utf8_strcasecmp("bacdefg123", "ABCDEFG123"));
} }
static void test_unicode_farsi_nzwj(CuTest *tc) {
const char str[] = { 0xe2, 0x80, 0x8c, 0xd8, 0xa7, 0xd9, 0x84, 0xd8, 0xaf,
0xdb, 0x8c, 0xd9, 0x86, 0x20, 0xd9, 0x85, 0xd8, 0xad, 0xd9, 0x85, 0xd8,
0xaf, 0x20, 0xd8, 0xb1, 0xd9, 0x88, 0xd9, 0x85, 0xdb, 0x8c, 0xe2, 0x80,
0x8e, 0xe2, 0x80, 0x8e, 0x00 };
char name[64];
strcpy(name, str);
CuAssertIntEquals(tc, 0, unicode_utf8_trim(name));
CuAssertStrEquals(tc, str, name);
}
CuSuite *get_unicode_suite(void) CuSuite *get_unicode_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); CuSuite *suite = CuSuiteNew();
@ -132,5 +143,6 @@ CuSuite *get_unicode_suite(void)
SUITE_ADD_TEST(suite, test_unicode_utf8_to_other); SUITE_ADD_TEST(suite, test_unicode_utf8_to_other);
SUITE_ADD_TEST(suite, test_unicode_utf8_to_ucs); SUITE_ADD_TEST(suite, test_unicode_utf8_to_ucs);
SUITE_ADD_TEST(suite, test_unicode_compare); SUITE_ADD_TEST(suite, test_unicode_compare);
SUITE_ADD_TEST(suite, test_unicode_farsi_nzwj);
return suite; return suite;
} }