diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 8da034126..d761c9f25 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -2368,8 +2368,8 @@ origin_cmd(unit * u, struct order * ord) init_tokens(ord); skip_token(); - px = (short)atoi(getstrtoken()); - py = (short)atoi(getstrtoken()); + px = (short)getint(); + py = (short)getint(); set_ursprung(u->faction, getplaneid(u->region), px, py); return 0; @@ -2443,7 +2443,7 @@ status_cmd(unit * u, struct order * ord) } break; default: - if (strlen(param)) { + if (param[0]) { add_message(&u->faction->msgs, msg_feedback(u, ord, "unknown_status", "")); } else { @@ -2473,8 +2473,7 @@ combatspell_cmd(unit * u, struct order * ord) /* Optional: STUFE n */ if (findparam(s, u->faction->locale) == P_LEVEL) { /* Merken, setzen kommt erst später */ - s = getstrtoken(); - level = atoi(s); + level = getint(); level = max(0, level); s = getstrtoken(); } @@ -2872,7 +2871,7 @@ renumber_cmd(unit * u, order * ord) case P_FACTION: s = getstrtoken(); if (s && *s) { - int id = atoi36(s); + int id = atoi36((const char *)s); attrib * a = a_find(f->attribs, &at_number); if (!a) a = a_add(&f->attribs, a_new(&at_number)); a->data.i = id; @@ -2884,7 +2883,7 @@ renumber_cmd(unit * u, order * ord) if (s == NULL || *s == 0) { i = newunitid(); } else { - i = atoi36(s); + i = atoi36((const char *)s); if (i<=0 || i>MAX_UNIT_NR) { cmistake(u, ord, 114, MSG_EVENT); break; @@ -2923,10 +2922,10 @@ renumber_cmd(unit * u, order * ord) break; } s = getstrtoken(); - if(s == NULL || *s == 0) { + if (s == NULL || *s == 0) { i = newcontainerid(); } else { - i = atoi36(s); + i = atoi36((const char *)s); if (i<=0 || i>MAX_CONTAINER_NR) { cmistake(u,ord,114,MSG_EVENT); break; @@ -2954,7 +2953,7 @@ renumber_cmd(unit * u, order * ord) if(*s == 0) { i = newcontainerid(); } else { - i = atoi36(s); + i = atoi36((const char *)s); if (i<=0 || i>MAX_CONTAINER_NR) { cmistake(u,ord,114,MSG_EVENT); break; @@ -3195,7 +3194,7 @@ new_units (void) skip_token(); if (getparam(u->faction->locale) == P_TEMP) { const xmlChar * token; - char * name = NULL; + xmlChar * name = NULL; int alias; order ** newordersp; @@ -3223,8 +3222,8 @@ new_units (void) alias = getid(); token = getstrtoken(); - if (token && strlen(token)>0) { - name = strdup(token); + if (token && token[0]) { + name = xstrdup(token); } u2 = create_unit(r, u->faction, 0, u->faction->race, alias, name, u); if (name!=NULL) free(name); @@ -3511,11 +3510,11 @@ defaultorders (void) while (*ordp!=NULL) { order * ord = *ordp; if (get_keyword(ord)==K_DEFAULT) { - char * cmd; + const xmlChar * cmd; order * new_order; init_tokens(ord); skip_token(); /* skip the keyword */ - cmd = strdup(getstrtoken()); + cmd = getstrtoken(); new_order = parse_order(cmd, u->faction->locale); *ordp = ord->next; ord->next = NULL; @@ -3532,7 +3531,6 @@ defaultorders (void) } if (new_order) addlist(&u->old_orders, new_order); #endif - free(cmd); } else ordp = &ord->next; } @@ -3588,7 +3586,7 @@ use_cmd(unit * u, struct order * ord) skip_token(); t = getstrtoken(); - n = atoi(t); + n = atoi((const char *)t); if (n==0) { if (findparam(t, u->faction->locale) == P_ANY) { /* BENUTZE ALLES Yanxspirit */ @@ -3627,7 +3625,7 @@ claim_cmd(unit * u, struct order * ord) skip_token(); t = getstrtoken(); - n = atoi(t); + n = atoi((const char *)t); if (n==0) { n = 1; } else { @@ -3866,7 +3864,7 @@ warn_password(void) } if (pwok == false) { free(f->passw); - f->passw = strdup(itoa36(rng_int())); + f->passw = (xmlChar*)strdup(itoa36(rng_int())); ADDMSG(&f->msgs, msg_message("illegal_password", "newpass", f->passw)); } f = f->next; diff --git a/src/common/kernel/build.c b/src/common/kernel/build.c index b15e3059a..e12e5919d 100644 --- a/src/common/kernel/build.c +++ b/src/common/kernel/build.c @@ -346,7 +346,7 @@ destroy_cmd(unit * u, struct order * ord) region * r = u->region; const construction * con = NULL; int size = 0; - const char *s; + const xmlChar *s; int n = INT_MAX; if (u->number < 1) @@ -362,7 +362,7 @@ destroy_cmd(unit * u, struct order * ord) } if (s && *s) { - n = atoi(s); + n = atoi((const char *)s); if (n <= 0) { cmistake(u, ord, 288, MSG_PRODUCE); return 0; @@ -508,9 +508,7 @@ build_road(region * r, unit * u, int size, direction_t d) /* hoffentlich ist r->road <= r->terrain->max_road, n also >= 0 */ if (left <= 0) { - sprintf(buf, "In %s gibt es keine Brücken und Straßen " - "mehr zu bauen", regionname(r, u->faction)); - mistake(u, u->thisorder, buf, MSG_PRODUCE); + ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "error_roads_finished", "")); return; } @@ -818,7 +816,7 @@ build_building(unit * u, const building_type * btype, int want, order * ord) building * b = NULL; /* einmalige Korrektur */ static char buffer[8 + IDSIZE + 1 + NAMESIZE + 1]; - const char * btname; + const xmlChar * btname; order * new_order = NULL; const struct locale * lang = u->faction->locale; @@ -834,7 +832,7 @@ build_building(unit * u, const building_type * btype, int want, order * ord) * baut man an der eigenen burg weiter. */ /* Wenn die angegebene Nummer falsch ist, KEINE Burg bauen! */ - id = atoi36(getstrtoken()); + id = getid(); if (id!=0){ /* eine Nummer angegeben, keine neue Burg bauen */ b = findbuilding(id); if (!b || b->region != u->region){ /* eine Burg mit dieser Nummer gibt es hier nicht */ @@ -1013,9 +1011,8 @@ create_ship(region * r, unit * u, const struct ship_type * newtype, int want, or /* check if skill and material for 1 size is available */ if (eff_skill(u, cons->skill, r) < cons->minskill) { - sprintf(buf, "Um %s zu bauen, braucht man ein Talent von " - "mindestens %d.", newtype->name[1], cons->minskill); - mistake(u, ord, buf, MSG_PRODUCE); + ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "error_build_skill_low", "value name", + cons->minskill, newtype->name[1])); return; } @@ -1073,9 +1070,8 @@ continue_ship(region * r, unit * u, int want) return; } if (eff_skill(u, cons->skill, r) < cons->minskill) { - sprintf(buf, "Um %s zu bauen, braucht man ein Talent von " - "mindestens %d.", sh->type->name[1], cons->minskill); - mistake(u, u->thisorder, buf, MSG_PRODUCE); + ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "error_build_skill_low", "value name", + cons->minskill, sh->type->name[1])); return; } msize = maxbuild(u, cons); @@ -1132,8 +1128,7 @@ leave_cmd(unit * u, struct order * ord) } } if (!slipthru(r, u, u->building)) { - sprintf(buf, "%s wird belagert.", buildingname(u->building)); - mistake(u, ord, buf, MSG_MOVE); + ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "entrance_besieged", "building", u->building)); } else { leave(r, u); } diff --git a/src/common/kernel/building.c b/src/common/kernel/building.c index 0d39775ca..4e8018687 100644 --- a/src/common/kernel/building.c +++ b/src/common/kernel/building.c @@ -133,11 +133,7 @@ bt_find(const char* name) } } } - while (btl && strcasecmp(btl->type->_name, name)) btl = btl->next; - if (!btl) { - btl = buildingtypes; - while (btl && strncasecmp(btl->type->_name, name, strlen(name))) btl = btl->next; - } + while (btl && strcmp(btl->type->_name, name)) btl = btl->next; return btl?btl->type:NULL; } diff --git a/src/common/kernel/faction.c b/src/common/kernel/faction.c index d08ea29e3..a62f78d0d 100644 --- a/src/common/kernel/faction.c +++ b/src/common/kernel/faction.c @@ -170,15 +170,15 @@ checkpasswd(const faction * f, const xmlChar * passwd, boolean shortp) #ifdef SHORTPWDS shortpwd * slist = f->shortpwds; if (shortp) while (slist) { - if (strcasecmp(slist->pwd, passwd)==0) { + if (xstrcmp(slist->pwd, passwd)==0) { slist->used = true; return true; } slist = slist->next; } #endif - if (xmlStrcmp(f->passw, passwd)==0) return true; - if (xmlStrcmp(f->override, passwd)==0) return true; + if (xstrcmp(f->passw, passwd)==0) return true; + if (xstrcmp(f->override, passwd)==0) return true; return false; } diff --git a/src/common/kernel/group.c b/src/common/kernel/group.c index 06d44ac36..b56844556 100644 --- a/src/common/kernel/group.c +++ b/src/common/kernel/group.c @@ -140,7 +140,7 @@ join_group(unit * u, const xmlChar * name) } if (a) ((group *)(a->data.v))->members--; - if (!name || !strlen(name)) { + if (!name || !xstrlen(name)) { if (a) { a_remove(&u->attribs, a); freset(u, UFL_GROUP); @@ -189,7 +189,7 @@ read_groups(FILE * F, faction * f) fscanf(F, "%d ", &gid); if (!gid) break; rsf(F, buf, sizeof(buf)); - g = new_group(f, buf, gid); + g = new_group(f, (const xmlChar *)buf, gid); pa = &g->allies; for (;;) { ally * a; diff --git a/src/common/kernel/item.c b/src/common/kernel/item.c index e3fcbf0ed..e01bfd253 100644 --- a/src/common/kernel/item.c +++ b/src/common/kernel/item.c @@ -395,7 +395,7 @@ it_alias(const char * zname) { int i; for (i=0;it_aliases[i][0];++i) { - if (strcasecmp(it_aliases[i][0], zname)==0) return it_aliases[i][1]; + if (strcmp(it_aliases[i][0], zname)==0) return it_aliases[i][1]; } return zname; } diff --git a/src/common/kernel/movement.c b/src/common/kernel/movement.c index f6f0e6279..5bf346117 100644 --- a/src/common/kernel/movement.c +++ b/src/common/kernel/movement.c @@ -920,11 +920,10 @@ cycle_route(order * ord, unit *u, int gereist) if (get_keyword(ord) != K_ROUTE) return; tail[0] = '\0'; - xmlStrcpy(neworder, locale_string(u->faction->locale, keywords[K_ROUTE])); - init_tokens(ord); skip_token(); + neworder[0]=0; for (cm=0;;++cm) { const struct locale * lang = u->faction->locale; pause = false; @@ -966,7 +965,7 @@ cycle_route(order * ord, unit *u, int gereist) } strcat((char *)neworder, (const char *)tail); - norder = parse_order(neworder, u->faction->locale); + norder = create_order(K_ROUTE, u->faction->locale, "%s", neworder); #ifdef LASTORDER set_order(&u->lastorder, norder); #else @@ -1485,7 +1484,6 @@ travel_route(unit * u, region_list * route_begin, region_list * route_end, order /* the unit has moved at least one region */ int walkmode; region_list **rlist = &route_begin; - region * next = r; setguard(u, GUARD_NONE); cycle_route(ord, u, steps); @@ -1502,12 +1500,7 @@ travel_route(unit * u, region_list * route_begin, region_list * route_end, order /* Berichte über Durchreiseregionen */ while (*rlist!=iroute) { - if (next!=u->region && next!=current) { - MSG(("travelthru_trail", "region", next), - p, sizeof(buf) - (p-buf), u->faction->locale, u->faction); - } - next = rlist->data; - rlist = rlist->next; + rlist = &(*rlist)->next; } /* remove excess regions */ *rlist = NULL; @@ -1538,10 +1531,8 @@ ship_ready(const region * r, unit * u) return false; } if (eff_skill(u, SK_SAILING, r) < u->ship->type->cptskill) { - sprintf(buf, "Der Kapitän muß mindestens Segeln %d haben, " - "um %s zu befehligen ", u->ship->type->cptskill, - LOC(u->faction->locale, u->ship->type->name[1])); - mistake(u, u->thisorder, buf, MSG_MOVE); + ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "error_captain_skill_low", + "value ship", u->ship->type->cptskill, u->ship)); return false; } assert(u->ship->type->construction->improvement == NULL); /* sonst ist construction::size nicht ship_type::maxsize */ @@ -1855,7 +1846,6 @@ sail(unit * u, order * ord, boolean move_on_land, region_list **routep) if (sh && hafenmeister != NULL) { item * itm; unit * u2; - boolean first = true; item * trans = NULL; for (u2 = current_point->units; u2; u2 = u2->next) { @@ -1881,29 +1871,10 @@ sail(unit * u, order * ord, boolean move_on_land, region_list **routep) } } if (trans) { - sprintf(buf, "%s erhielt ", hafenmeister->name); - for (itm = trans; itm; itm=itm->next) { - if (!first) { - if (itm->next!=NULL && itm->next->next == NULL) { - scat(" und "); - } else { - scat(", "); - } - } - first = false; - icat(trans->number); - scat(" "); - if (itm->number == 1) { - scat(locale_string(default_locale, resourcename(itm->type->rtype, 0))); - } else { - scat(locale_string(default_locale, resourcename(itm->type->rtype, NMF_PLURAL))); - } - } - scat(" von der "); - scat(shipname(u->ship)); - scat("."); - addmessage(0, u->faction, buf, MSG_COMMERCE, ML_INFO); - addmessage(0, hafenmeister->faction, buf, MSG_INCOME, ML_INFO); + message * msg = msg_message("harbor_trade", "unit items ship", hafenmeister, trans, u->ship); + add_message(&u->faction->msgs, msg); + add_message(&hafenmeister->faction->msgs, msg); + msg_release(msg); while (trans) i_remove(&trans, trans); } } @@ -2144,10 +2115,10 @@ piracy_cmd(unit *u, struct order * ord) const faction * target; int value; } aff[MAXDIRECTIONS]; - int saff = 0; - int *il = NULL; - const char *s; - attrib *a; + int saff = 0; + int *il = NULL; + const xmlChar *s; + attrib *a; if (!sh) { cmistake(u, ord, 144, MSG_MOVE); @@ -2169,7 +2140,7 @@ piracy_cmd(unit *u, struct order * ord) if (s!=NULL && *s) { il = intlist_init(); while (s && *s) { - il = intlist_add(il, atoi36(s)); + il = intlist_add(il, atoi36((const char *)s)); s = getstrtoken(); } } @@ -2291,7 +2262,8 @@ hunt(unit *u, order * ord) { region *rc = u->region; int moves, id, speed; - char command[256]; + xmlChar command[256]; + size_t size = sizeof(command); direction_t dir; if (fval(u, UFL_NOTMOVING)) { @@ -2329,8 +2301,9 @@ hunt(unit *u, order * ord) return 0; } - sprintf(command, "%s %s", locale_string(u->faction->locale, keywords[K_MOVE]), + sprintf((char *)command, "%s %s", locale_string(u->faction->locale, keywords[K_MOVE]), locale_string(u->faction->locale, directions[dir])); + size -= xstrlen(command); moves = 1; speed = getuint(); @@ -2343,8 +2316,8 @@ hunt(unit *u, order * ord) rc = rconnect(rc, dir); while (moves < speed && (dir = hunted_dir(rc->attribs, id)) != NODIRECTION) { - strcat(command, " "); - strcat(command, locale_string(u->faction->locale, directions[dir])); + size -= xstrlcat(command, " ", size); + size -= xstrlcat(command, LOC(u->faction->locale, directions[dir]), size); moves++; rc = rconnect(rc, dir); } diff --git a/src/common/kernel/plane.c b/src/common/kernel/plane.c index b148846cf..e730630c7 100644 --- a/src/common/kernel/plane.c +++ b/src/common/kernel/plane.c @@ -65,7 +65,7 @@ getplanebyname(const char * name) plane *p; for (p=planes; p; p=p->next) - if (!strcasecmp(p->name, name)) + if (!strcmp(p->name, name)) return p; return NULL; } diff --git a/src/common/kernel/ship.c b/src/common/kernel/ship.c index 643b2db0b..271cd3bcb 100644 --- a/src/common/kernel/ship.c +++ b/src/common/kernel/ship.c @@ -72,7 +72,7 @@ const ship_type * st_find(const char* name) { const struct ship_typelist * stl = shiptypes; - while (stl && strcasecmp(stl->type->name[0], name)) stl = stl->next; + while (stl && strcmp(stl->type->name[0], name)) stl = stl->next; return stl?stl->type:NULL; } diff --git a/src/common/kernel/spell.c b/src/common/kernel/spell.c index d4ad9e3b7..9036355de 100644 --- a/src/common/kernel/spell.c +++ b/src/common/kernel/spell.c @@ -46,11 +46,6 @@ spell_list * spells = NULL; void register_spell(spell * sp) { -#ifndef NDEBUG - const char * name = mkname("spell", sp->sname); - assert(name!=LOC(default_locale, name)); - assert(strchr(sp->sname, ' ')==NULL); -#endif if (sp->id==0) { sp->id = hashstring(sp->sname); } @@ -102,7 +97,7 @@ init_spellnames(const struct locale * lang, magic_t mtype) for (slist=spells;slist!=NULL;slist=slist->next) { spell * sp = slist->data; if (sp->magietyp==mtype) { - const char * n = spell_name(sp, lang); + const xmlChar * n = spell_name(sp, lang); variant token; token.v = sp; addtoken(&sn->names, n, token); diff --git a/src/config.h b/src/config.h index a7f104fc6..52d8df416 100644 --- a/src/config.h +++ b/src/config.h @@ -257,9 +257,11 @@ extern char * strdup(const char *s); #define xstrlen(a) strlen((const char*)(a)) #define xstrcmp(a, b) strcmp((const char*)(a), (const char *)(b)) +#define xstrcat(a, b) (xmlChar *)strcat((char*)(a), (const char *)(b)) #define xstrncmp(a, b, s) strncmp((const char*)(a), (const char *)(b), s) #define xstrdup(a) (xmlChar *)strdup((const char*)(a)) #define xstrlcpy(a, b, s) strlcpy((char*)(a), (const char*)(b), s) +#define xstrlcat(a, b, s) strlcat((char*)(a), (const char *)(b), s) #endif diff --git a/src/res/messages.xml b/src/res/messages.xml index f78d6b52c..bf8160205 100644 --- a/src/res/messages.xml +++ b/src/res/messages.xml @@ -7702,6 +7702,38 @@ "$unit($unit) in $region($region): '$order($command)' - $unit($target) does not understand our kind of magic." + + + + + + + + + "$unit($unit) in $region($region): '$order($command)' - Der Kapitän muß ein Segeltalent von mindestens $int($value) haben, um $ship($ship) zu befehligen." + + + + + + + + + "$unit($unit) in $region($region): '$order($command)' - In dieser Region gibt es keine Brücken uns Straßen mehr zu bauen." + + + + + + + + + + + "$unit($unit) in $region($region): '$order($command)' - Um $localize($name) zu bauen, braucht man ein Talent von mindestens $int($value)." + "$unit($unit) in $region($region): '$order($command)' - To build $localize($name) requires a skill of at least $int($value)." + + @@ -7712,4 +7744,14 @@ "$unit($unit) in $region($region): '$order($command)' - This unit will not fight." + + + + + + + "$unit($unit) erhielt $resources($items) von der $ship($ship)." + "$unit($unit) received $resources($items) from the $ship($ship)." + +