forked from github/server
Leerzeichen aus Beschreibungen trimmen.
This commit is contained in:
parent
7298968921
commit
75dfed8082
|
@ -314,7 +314,7 @@
|
|||
<resource name="aura" amount="10" cost="fixed"/>
|
||||
</spell>
|
||||
<spell name="analyse_object" rank="5" parameters="kc+" ship="true" variable="true" regiontarget="true" unittarget="false" buildingtarget="true" shiptarget="true">
|
||||
<resource name="aura" amount="3" cost="level"/>
|
||||
<resource name="aura" amount="3" cost="level"/>
|
||||
</spell>
|
||||
<spell name="destroy_magic" rank="2" parameters="kc+" los="true" ship="true" far="true" variable="true">
|
||||
<resource name="aura" amount="4" cost="level"/>
|
||||
|
|
16
src/laws.c
16
src/laws.c
|
@ -1488,7 +1488,7 @@ int display_cmd(unit * u, struct order *ord)
|
|||
{
|
||||
char token[128];
|
||||
char **s = NULL;
|
||||
const char *str;
|
||||
char *str;
|
||||
region *r = u->region;
|
||||
|
||||
init_order_depr(ord);
|
||||
|
@ -1525,11 +1525,19 @@ int display_cmd(unit * u, struct order *ord)
|
|||
break;
|
||||
|
||||
case P_UNIT:
|
||||
unit_setinfo(u, getstrtoken());
|
||||
str = getstrtoken();
|
||||
if (str) {
|
||||
unicode_utf8_trim(str);
|
||||
}
|
||||
unit_setinfo(u, str);
|
||||
break;
|
||||
|
||||
case P_PRIVAT:
|
||||
usetprivate(u, getstrtoken());
|
||||
str = getstrtoken();
|
||||
if (str) {
|
||||
unicode_utf8_trim(str);
|
||||
}
|
||||
usetprivate(u, str);
|
||||
break;
|
||||
|
||||
case P_REGION:
|
||||
|
@ -1664,7 +1672,7 @@ int name_cmd(struct unit *u, struct order *ord)
|
|||
bool foreign = false;
|
||||
const char *str;
|
||||
|
||||
init_order_depr(ord);
|
||||
init_order(ord, u->faction->locale);
|
||||
str = gettoken(token, sizeof(token));
|
||||
p = findparam_ex(str, u->faction->locale);
|
||||
|
||||
|
|
|
@ -221,6 +221,21 @@ static void test_display_cmd(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "Hodor", unit_getinfo(u));
|
||||
free_order(ord);
|
||||
|
||||
ord = create_order(K_DISPLAY, f->locale, "%s ' Klabautermann '", LOC(f->locale, parameters[P_UNIT]));
|
||||
CuAssertIntEquals(tc, 0, display_cmd(u, ord));
|
||||
CuAssertStrEquals(tc, "Klabautermann", unit_getinfo(u));
|
||||
free_order(ord);
|
||||
|
||||
ord = create_order(K_DISPLAY, f->locale, "%s Hodor", LOC(f->locale, parameters[P_PRIVAT]));
|
||||
CuAssertIntEquals(tc, 0, display_cmd(u, ord));
|
||||
CuAssertStrEquals(tc, "Hodor", uprivate(u));
|
||||
free_order(ord);
|
||||
|
||||
ord = create_order(K_DISPLAY, f->locale, "%s ' Klabautermann '", LOC(f->locale, parameters[P_PRIVAT]));
|
||||
CuAssertIntEquals(tc, 0, display_cmd(u, ord));
|
||||
CuAssertStrEquals(tc, "Klabautermann", uprivate(u));
|
||||
free_order(ord);
|
||||
|
||||
ord = create_order(K_DISPLAY, f->locale, LOC(f->locale, parameters[P_UNIT]));
|
||||
CuAssertIntEquals(tc, 0, display_cmd(u, ord));
|
||||
CuAssertPtrEquals(tc, NULL, (void *)unit_getinfo(u));
|
||||
|
@ -940,6 +955,12 @@ static void test_name_unit(CuTest *tc) {
|
|||
|
||||
u = setup_name_cmd();
|
||||
f = u->faction;
|
||||
|
||||
ord = create_order(K_NAME, f->locale, "%s ' Klabauterfrau '", LOC(f->locale, parameters[P_UNIT]));
|
||||
name_cmd(u, ord);
|
||||
CuAssertStrEquals(tc, "Klabauterfrau", u->_name);
|
||||
free_order(ord);
|
||||
|
||||
ord = create_order(K_NAME, f->locale, "%s Hodor", LOC(f->locale, parameters[P_UNIT]));
|
||||
name_cmd(u, ord);
|
||||
CuAssertStrEquals(tc, "Hodor", u->_name);
|
||||
|
@ -960,10 +981,15 @@ static void test_name_region(CuTest *tc) {
|
|||
order *ord;
|
||||
|
||||
u = setup_name_cmd();
|
||||
u_set_building(u, test_create_building(u->region, NULL));
|
||||
f = u->faction;
|
||||
|
||||
ord = create_order(K_NAME, f->locale, "%s ' Hodor Hodor '", LOC(f->locale, parameters[P_REGION]));
|
||||
name_cmd(u, ord);
|
||||
CuAssertStrEquals(tc, "Hodor Hodor", u->region->land->name);
|
||||
free_order(ord);
|
||||
|
||||
ord = create_order(K_NAME, f->locale, "%s Hodor", LOC(f->locale, parameters[P_REGION]));
|
||||
u_set_building(u, test_create_building(u->region, NULL));
|
||||
name_cmd(u, ord);
|
||||
CuAssertStrEquals(tc, "Hodor", u->region->land->name);
|
||||
free_order(ord);
|
||||
|
@ -980,6 +1006,7 @@ static void test_name_region(CuTest *tc) {
|
|||
static void test_name_building(CuTest *tc) {
|
||||
unit *uo, *u, *ux;
|
||||
faction *f;
|
||||
order *ord;
|
||||
|
||||
u = setup_name_cmd();
|
||||
u->building = test_create_building(u->region, NULL);
|
||||
|
@ -989,29 +1016,33 @@ static void test_name_building(CuTest *tc) {
|
|||
ux = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
u_set_building(ux, u->building);
|
||||
|
||||
u->thisorder = create_order(K_NAME, f->locale, "%s Hodor", LOC(f->locale, parameters[P_BUILDING]));
|
||||
|
||||
ord = create_order(K_NAME, f->locale, "%s ' Hodor Hodor '", LOC(f->locale, parameters[P_BUILDING]));
|
||||
building_set_owner(uo);
|
||||
name_cmd(u, u->thisorder);
|
||||
name_cmd(u, ord);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error148"));
|
||||
test_clear_messages(f);
|
||||
|
||||
building_set_owner(u);
|
||||
name_cmd(u, u->thisorder);
|
||||
name_cmd(u, ord);
|
||||
CuAssertStrEquals(tc, "Hodor Hodor", u->building->name);
|
||||
free_order(ord);
|
||||
|
||||
ord = create_order(K_NAME, f->locale, "%s Hodor", LOC(f->locale, parameters[P_BUILDING]));
|
||||
name_cmd(u, ord);
|
||||
CuAssertStrEquals(tc, "Hodor", u->building->name);
|
||||
|
||||
building_setname(u->building, "Home");
|
||||
building_set_owner(ux);
|
||||
name_cmd(u, u->thisorder);
|
||||
name_cmd(u, ord);
|
||||
CuAssertPtrEquals(tc, NULL, test_find_messagetype(f->msgs, "error148"));
|
||||
CuAssertStrEquals(tc, "Hodor", u->building->name);
|
||||
|
||||
test_clear_messages(f);
|
||||
free_order(u->thisorder);
|
||||
u->thisorder = create_order(K_NAME, f->locale, LOC(f->locale, parameters[P_BUILDING]));
|
||||
name_cmd(u, u->thisorder);
|
||||
free_order(ord);
|
||||
|
||||
ord = create_order(K_NAME, f->locale, LOC(f->locale, parameters[P_BUILDING]));
|
||||
name_cmd(u, ord);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error84"));
|
||||
CuAssertStrEquals(tc, "Hodor", u->building->name);
|
||||
free_order(ord);
|
||||
|
||||
/* TODO: test BTF_NAMECHANGE:
|
||||
btype->flags |= BTF_NAMECHANGE;
|
||||
|
|
|
@ -233,12 +233,12 @@ const char *parse_token_depr(const char **str)
|
|||
return parse_token(str, pbuf, MAXTOKENSIZE);
|
||||
}
|
||||
|
||||
const char *getstrtoken(void)
|
||||
char *getstrtoken(void)
|
||||
{
|
||||
return parse_token((const char **)&states->current_token, pbuf, MAXTOKENSIZE);
|
||||
}
|
||||
|
||||
const char *gettoken(char *lbuf, size_t bufsize)
|
||||
char *gettoken(char *lbuf, size_t bufsize)
|
||||
{
|
||||
return parse_token((const char **)&states->current_token, lbuf, bufsize);
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ extern "C" {
|
|||
void parser_pushstate(void);
|
||||
void parser_popstate(void);
|
||||
bool parser_end(void);
|
||||
const char *getstrtoken(void);
|
||||
const char *gettoken(char *lbuf, size_t bufsize);
|
||||
char *getstrtoken(void);
|
||||
char *gettoken(char *lbuf, size_t bufsize);
|
||||
int getuint(void);
|
||||
int getint(void);
|
||||
int getid(void);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <platform.h>
|
||||
#include "unicode.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <wctype.h>
|
||||
|
@ -36,6 +37,7 @@ int unicode_utf8_trim(utf8_t *buf)
|
|||
{
|
||||
int result = 0, ts = 0;
|
||||
utf8_t *op = buf, *ip = buf, *lc = buf;
|
||||
assert(buf);
|
||||
while (*ip) {
|
||||
size_t size = 1;
|
||||
wint_t wc = *ip;
|
||||
|
|
Loading…
Reference in New Issue