diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index f90224277..e41b49478 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -448,14 +448,7 @@ recruit(unit * u, struct order * ord, request ** recruitorders) if (f->no==MONSTER_FACTION) { /* Monster dürfen REKRUTIERE 15 dracoid machen */ const xmlChar * str = getstrtoken(); - if (str!=NULL && *str) { - for (rc = races;rc;rc=rc->next) { - if (xmlStrncasecmp(LOC(f->locale, rc->_name[0]), str, xstrlen(str))==0) - break; - if (xmlStrncasecmp(LOC(f->locale, rc->_name[1]), str, xstrlen(str))==0) - break; - } - } + rc = findrace(str, f->locale); if (rc==NULL) rc = f->race; } @@ -2992,21 +2985,10 @@ expandwork(region * r) /* Der Rest wird von den Bauern verdient. n ist das uebriggebliebene * Geld. */ -#ifdef AFFECT_SALARY - { - attrib * a = a_find(r->attribs, &at_salary); - if (a) verdienst = a->data.i; - } -#endif - + earnings = min(n, rpeasants(r) * p_wage) + verdienst; /* Mehr oder weniger durch Trank "Riesengrass" oder "Faulobstschnaps" */ - if (verdienst) { - sprintf(buf, "%d Bauern verdienen ein Silber %s durch %s.", - abs(verdienst), (verdienst > 0) ? "mehr" : "weniger", - (verdienst > 0) ? "Riesengras" : "Faulobstschnaps"); - } rsetmoney(r, rmoney(r) + earnings); } diff --git a/src/common/gamecode/items.c b/src/common/gamecode/items.c index 1ec0a902c..7ced515c8 100644 --- a/src/common/gamecode/items.c +++ b/src/common/gamecode/items.c @@ -169,8 +169,7 @@ use_instantartsculpture(struct unit * u, const struct item_type * itype, b = new_building(bt_find("artsculpture"), u->region, u->faction->locale); b->size = 100; - sprintf(buf, "%s", LOC(u->faction->locale, "artsculpture")); - set_string(&b->name, buf); + set_string(&b->name, LOC(u->faction->locale, "artsculpture")); ADDMSG(&u->region->msgs, msg_message("artsculpture_create", "unit region", u, u->region)); @@ -193,8 +192,7 @@ use_instantartacademy(struct unit * u, const struct item_type * itype, b = new_building(bt_find("artacademy"), u->region, u->faction->locale); b->size = 100; - sprintf(buf, "%s", LOC(u->faction->locale, "artacademy")); - set_string(&b->name, buf); + set_string(&b->name, LOC(u->faction->locale, "artacademy")); ADDMSG(&u->region->msgs, msg_message( "artacademy_create", "unit region", u, u->region)); diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index d761c9f25..82a10a0ca 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -2147,35 +2147,36 @@ display_race(faction *f, unit *u, const race * rc) bufp += rsize; /* hp_p : Trefferpunkte */ - sprintf(buf2, " %d Trefferpunkte", rc->hitpoints); + sprintf(buf2, " %d %s", rc->hitpoints, LOC(f->locale, "stat_hitpoints")); rsize = strlcpy(bufp, buf2, size); if (rsize>size) rsize = size-1; size -= rsize; bufp += rsize; - /* b_armor : Rüstung */ - if (rc->armor > 0){ - sprintf(buf2, ", Rüstung: %d", rc->armor); - rsize = strlcpy(bufp, buf2, size); - if (rsize>size) rsize = size-1; - size -= rsize; - bufp += rsize; - } /* b_attacke : Angriff */ - sprintf(buf2, ", Angriff: %d", (rc->at_default+rc->at_bonus)); + sprintf(buf2, ", %s: %d", LOC(f->locale, "stat_attack"), (rc->at_default+rc->at_bonus)); rsize = strlcpy(bufp, buf2, size); if (rsize>size) rsize = size-1; size -= rsize; bufp += rsize; /* b_defense : Verteidigung */ - sprintf(buf2, ", Verteidigung: %d", (rc->df_default+rc->df_bonus)); + sprintf(buf2, ", %s: %d", LOC(f->locale, "stat_defense"), (rc->df_default+rc->df_bonus)); rsize = strlcpy(bufp, buf2, size); if (rsize>size) rsize = size-1; size -= rsize; bufp += rsize; + /* b_armor : Rüstung */ + if (rc->armor > 0) { + sprintf(buf2, ", %s: %d", LOC(f->locale, "stat_armor"), rc->armor); + rsize = strlcpy(bufp, buf2, size); + if (rsize>size) rsize = size-1; + size -= rsize; + bufp += rsize; + } + if (size>1) { strcpy(bufp++, "."); --size; @@ -2189,31 +2190,31 @@ display_race(faction *f, unit *u, const race * rc) } } if (rc->battle_flags & BF_EQUIPMENT) { - rsize = strlcpy(bufp, " Kann Waffen benutzen.", size); + rsize = snprintf(bufp, size, " %s", LOC(f->locale, "stat_equipment")); if (rsize>size) rsize = size-1; size -= rsize; bufp += rsize; } if (rc->battle_flags & BF_RES_PIERCE) { - rsize = strlcpy(bufp, " Ist durch Stichwaffen, Bögen und Armbrüste schwer zu verwunden.", size); + rsize = snprintf(bufp, size, " %s", LOC(f->locale, "stat_pierce")); if (rsize>size) rsize = size-1; size -= rsize; bufp += rsize; } if (rc->battle_flags & BF_RES_CUT) { - rsize = strlcpy(bufp, " Ist durch Hiebwaffen schwer zu verwunden.", size); + rsize = snprintf(bufp, size, " %s", LOC(f->locale, "stat_cut")); if (rsize>size) rsize = size-1; size -= rsize; bufp += rsize; } if (rc->battle_flags & BF_RES_BASH) { - rsize = strlcpy(bufp, " Ist durch Schlagwaffen und Katapulte schwer zu verwunden.", size); + rsize = snprintf(bufp, size, " %s", LOC(f->locale, "stat_bash")); if (rsize>size) rsize = size-1; size -= rsize; bufp += rsize; } - sprintf(buf2, " Hat %d Angriff%s", at_count, (at_count>1)?"e":""); + sprintf(buf2, " %d %s", at_count, LOC(f->locale, (at_count==1)?"stat_attack":"stat_attacks")); rsize = strlcpy(bufp, buf2, size); if (rsize>size) rsize = size-1; size -= rsize; @@ -2229,19 +2230,19 @@ display_race(faction *f, unit *u, const race * rc) } switch(rc->attack[a].type) { case AT_STANDARD: - sprintf(buf2, "ein Angriff mit der Waffe oder macht unbewaffnet %s Schaden", rc->def_damage); + sprintf(buf2, "%s (%s)", LOC(f->locale, "attack_standard"), rc->def_damage); break; case AT_NATURAL: - sprintf(buf2, "ein Angriff mit Krallen, Zähnen oder Klauen, der %s Schaden macht", rc->attack[a].data.dice); + sprintf(buf2, "%s (%s)", LOC(f->locale, "attack_natural"), rc->attack[a].data.dice); break; case AT_SPELL: case AT_COMBATSPELL: case AT_DRAIN_ST: case AT_DAZZLE: - sprintf(buf2, "ein magischer Angriff"); + sprintf(buf2, "%s", LOC(f->locale, "attack_natural")); break; case AT_STRUCTURAL: - sprintf(buf2, "ein Angriff, der %s Gebäudeschaden verursacht", rc->attack[a].data.dice); + sprintf(buf2, "%s (%s)", LOC(f->locale, "attack_structural"), rc->attack[a].data.dice); } rsize = strlcpy(bufp, buf2, size); if (rsize>size) rsize = size-1; @@ -2255,7 +2256,7 @@ display_race(faction *f, unit *u, const race * rc) --size; } - addmessage(0, f, buf, MSG_EVENT, ML_IMPORTANT); + addmessage(0, f, (const xmlChar *)buf, MSG_EVENT, ML_IMPORTANT); return true; } diff --git a/src/common/gamecode/xmlreport.c b/src/common/gamecode/xmlreport.c index 9953d37b9..112116dc0 100644 --- a/src/common/gamecode/xmlreport.c +++ b/src/common/gamecode/xmlreport.c @@ -138,7 +138,7 @@ report_region(report_context * ctx, seen_region * sr) xmlNewProp(node, BAD_CAST "plane", xml_s(r->planep->name)); } if (r->land!=NULL) { - xmlNewProp(node, BAD_CAST "name", xml_s(r->land->name)); + xmlNewProp(node, BAD_CAST "name", r->land->name); } return node; } diff --git a/src/common/kernel/building.h b/src/common/kernel/building.h index 3b8c29f2b..a3ba7656d 100644 --- a/src/common/kernel/building.h +++ b/src/common/kernel/building.h @@ -109,7 +109,8 @@ extern void add_buildinglist(building_list **bl, struct building *b); extern struct attrib_type at_building_generic_type; extern const char * buildingtype(const building_type * btype, const struct building * b, int bsize); -extern const char * buildingname(const struct building * b); +extern const xmlChar * buildingname(const struct building * b); +extern const xmlChar * write_buildingname(const building * b, xmlChar * ibuf, size_t size); extern int buildingcapacity(const struct building * b); extern struct building *new_building(const struct building_type * typ, struct region * r, const struct locale * lang); void build_building(struct unit * u, const struct building_type * typ, int size, struct order * ord); diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index e1b1f744e..c0a35c070 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -1556,52 +1556,67 @@ typedef char name[OBJECTIDSIZE+1]; static name idbuf[8]; static int nextbuf = 0; +char * +estring_i(char *ibuf) +{ + char *p = ibuf; + + while (*p) { + if (isspace(*(unsigned*)p) == ' ') { + *p = '~'; + } + ++p; + } + return ibuf; +} + char * estring(const char *s) { char *ibuf = idbuf[(++nextbuf) % 8]; - char *r; strlcpy(ibuf, s, sizeof(name)); - r = ibuf; + return estring_i(ibuf); +} - while (*ibuf) { - if(*ibuf == ' ') { - *ibuf = '~'; +char * +cstring_i(char *ibuf) +{ + char *p = ibuf; + + while (*p) { + if (*p == '~') { + *p = ' '; } - ibuf++; + ++p; } - return r; + return ibuf; } char * cstring(const char *s) { char *ibuf = idbuf[(++nextbuf) % 8]; - char *r; strlcpy(ibuf,s, sizeof(name)); - r = ibuf; - - while (*ibuf) { - if (*ibuf == '~') { - *ibuf = ' '; - } - ibuf++; - } - return r; + return cstring_i(ibuf); } -const char * -buildingname (const building * b) +const xmlChar * +write_buildingname(const building * b, xmlChar * ibuf, size_t size) { - char *ibuf = idbuf[(++nextbuf) % 8]; - - snprintf(ibuf, sizeof(name), "%s (%s)", b->name, itoa36(b->no)); + snprintf((char*)ibuf, sizeof(name), "%s (%s)", b->name, itoa36(b->no)); ibuf[sizeof(name)-1] = 0; return ibuf; } +const xmlChar * +buildingname(const building * b) +{ + char *ibuf = idbuf[(++nextbuf) % 8]; + return write_buildingname(b, (xmlChar*)ibuf, sizeof(name)); +} + building * largestbuilding (const region * r, boolean img) { diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index b00bfaa6b..4a23ed7e5 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -43,7 +43,6 @@ extern "C" { #define INSECT_POTION /* Spezialtrank für Insekten */ #define ORCIFICATION /* gioving snotlings to the peasants gets counted */ #undef TROLLSAVE /* saving throw for dead trolls */ -#undef AFFECT_SALARY /* gibt es ein attribut at_salary (ist noch nicht fertig!) */ #include @@ -256,8 +255,10 @@ struct unit *findunit(int n); struct unit *findunitr(const struct region * r, int n); struct region *findunitregion(const struct unit * su); -char *estring(const char *s); -char *cstring(const char *s); +extern char *estring(const char *s); +extern char *estring_i(char *s); +extern char *cstring(const char *s); +extern char *cstring_i(char *s); extern const xmlChar *unitname(const struct unit * u); extern xmlChar * write_unitname(const struct unit * u, xmlChar * buffer, size_t size); diff --git a/src/common/kernel/kernel.vcproj b/src/common/kernel/kernel.vcproj index 9a0f0058d..d6a5c5440 100644 --- a/src/common/kernel/kernel.vcproj +++ b/src/common/kernel/kernel.vcproj @@ -409,6 +409,9 @@ + + diff --git a/src/common/kernel/region.c b/src/common/kernel/region.c index 183e31d8c..0890009a0 100644 --- a/src/common/kernel/region.c +++ b/src/common/kernel/region.c @@ -38,6 +38,7 @@ #include "terrain.h" #include "terrainid.h" #include "unit.h" +#include "version.h" /* util includes */ #include @@ -102,29 +103,30 @@ dir_invert(direction_t dir) } const xmlChar * -regionname(const region * r, const faction * f) +write_regionname(const region * r, const faction * f, xmlChar * buffer, size_t size) { - static char buf[65]; + char * buf = (char *)buffer; const struct locale * lang = f ? f->locale : 0; if (r==NULL) { strcpy(buf, "(null)"); } else { plane *pl = r->planep; if (pl && fval(pl, PFL_NOCOORDS)) { - strncpy(buf, rname(r, lang), 65); + strncpy(buf, (const char *)rname(r, lang), size); } else { -#ifdef HAVE_SNPRINTF - snprintf(buf, 65, "%s (%d,%d)", rname(r, lang), + snprintf(buf, size, "%s (%d,%d)", rname(r, lang), region_x(r, f), region_y(r, f)); -#else - strncpy(buf, rname(r, lang), 50); - buf[50]=0; - sprintf(buf+strlen(buf), " (%d,%d)", region_x(r, f), region_y(r, f)); -#endif } } buf[64] = 0; - return buf; + return buffer; +} + +const xmlChar * +regionname(const region * r, const faction * f) +{ + static xmlChar buf[65]; + return write_regionname(r, f, buf, sizeof(buf)); } int @@ -207,9 +209,15 @@ a_readdirection(attrib *a, FILE *f) spec_direction *d = (spec_direction *)(a->data.v); fscanf(f, "%hd %hd %d", &d->x, &d->y, &d->duration); fscanf(f, "%15s ", lbuf); - d->desc = strdup(cstring(lbuf)); + d->desc = strdup(lbuf); fscanf(f, "%15s ", lbuf); - d->keyword = strdup(cstring(lbuf)); + d->keyword = strdup(lbuf); + if (global.data_versiondesc); + cstring_i(d->keyword); + /* TODO: reverse lookup of desc and keyword or something? */ + assert(!"not implemented"); + } d->active = true; return AT_READ_OK; } @@ -220,7 +228,7 @@ a_writedirection(const attrib *a, FILE *f) spec_direction *d = (spec_direction *)(a->data.v); fprintf(f, "%d %d %d %s %s ", d->x, d->y, d->duration, - estring(d->desc), estring(d->keyword)); + (const char *)d->desc, (const char *)d->keyword); } attrib_type at_direction = { @@ -686,11 +694,12 @@ r_demand(const region * r, const luxury_type * ltype) return d->value; } -const char * +const xmlChar * rname(const region * r, const struct locale * lang) { - if (r->land) + if (r->land) { return r->land->name; - return locale_string(lang, terrain_name(r)); + } + return LOC(lang, terrain_name(r)); } int @@ -789,7 +798,10 @@ free_region(region * r) free(r); } -static char * +/** creates a name for a region + * TODO: Make this XML-configurable and allow non-ascii characters again. + */ +static xmlChar * makename(void) { int s, v, k, e, p = 0, x = 0; @@ -797,12 +809,16 @@ makename(void) static char name[16]; const char *kons = "bcdfghklmnprstvwz", *end = "nlrdst", - *vokal = "aaaaaaaaaāâeeeeeeeeeéčęiiiiiiiiiíîoooooooooķōôuuuuuuuuuúyy", +#if 0 + *vowels = "aaaaaaaaaāâeeeeeeeeeéčęiiiiiiiiiíîoooooooooķōôuuuuuuuuuúyy", +#else + *vowels = "aaaaaaaaaaaeeeeeeeeeeeeiiiiiiiiiiioooooooooooouuuuuuuuuuyy", +#endif *start = "bcdgtskpvfr"; nk = strlen(kons); ne = strlen(end); - nv = strlen(vokal); + nv = strlen(vowels); ns = strlen(start); for (s = rng_int() % 3 + 2; s > 0; s--) { @@ -816,7 +832,7 @@ makename(void) p++; } v = rng_int() % (int)nv; - name[p] = vokal[v]; + name[p] = vowels[v]; p++; if (rng_int() % 3 == 2 || s == 1) { e = rng_int() % (int)ne; @@ -828,7 +844,7 @@ makename(void) } name[p] = '\0'; name[0] = (char) toupper(name[0]); - return name; + return (xmlChar*)name; } void diff --git a/src/common/kernel/region.h b/src/common/kernel/region.h index c8ceae1e6..199e565c1 100644 --- a/src/common/kernel/region.h +++ b/src/common/kernel/region.h @@ -131,8 +131,8 @@ typedef struct spec_direction { short x, y; int duration; boolean active; - xmlChar *desc; - xmlChar *keyword; + char *desc; + char *keyword; } spec_direction; typedef struct { @@ -209,7 +209,7 @@ extern boolean r_isforest(const struct region * r); #define rterrain(r) (oldterrain((r)->terrain)) #define rsetterrain(r, t) ((r)->terrain = newterrain(t)) -extern const char * rname(const struct region * r, const struct locale * lang); +extern const xmlChar * rname(const struct region * r, const struct locale * lang); #define rsetname(r, str) (set_string(&(r)->land->name, str)) #define rplane(r) getplane(r) @@ -218,6 +218,8 @@ extern void r_setdemand(struct region * r, const struct luxury_type * ltype, int extern int r_demand(const struct region * r, const struct luxury_type * ltype); extern const xmlChar * regionname(const struct region * r, const struct faction * f); +extern const xmlChar * write_regionname(const struct region * r, const struct faction * f, xmlChar * buffer, size_t size); + extern void * resolve_region(variant data); extern struct region * new_region(short x, short y); extern void terraform(struct region * r, terrain_t terrain); diff --git a/src/common/kernel/version.h b/src/common/kernel/version.h index b7f5883f9..c8a879aeb 100644 --- a/src/common/kernel/version.h +++ b/src/common/kernel/version.h @@ -64,6 +64,7 @@ #define REGIONITEMS_VERSION 323 /* regions have items */ #define ATTRIBREAD_VERSION 324 /* remove a_readint */ #define CURSEFLAGS_VERSION 325 /* remove a_readint */ +#define UNICODE_VERSION 326 /* everything is stored as UTF8 */ #define MIN_VERSION CURSETYPE_VERSION #define REGIONOWNERS_VERSION 400 diff --git a/src/common/kernel/xmlreader.c b/src/common/kernel/xmlreader.c index 1474b6c35..f9e47eabf 100644 --- a/src/common/kernel/xmlreader.c +++ b/src/common/kernel/xmlreader.c @@ -103,12 +103,12 @@ xml_cleanup_string(xmlChar * str) while (*read) { /* eat leading whitespace */ - if (*read && isspace(*read)) { - while (*read && isspace(*read)) { - ++read; - } - *write++ = ' '; - } + if (*read && isspace(*read)) { + while (*read && isspace(*read)) { + ++read; + } + *write++ = ' '; + } while (*read) { if (*read== '\n') break; if (*read== '\r') break; @@ -1625,7 +1625,7 @@ parse_terrains(xmlDocPtr doc) xpath = xmlXPathNewContext(doc); - /* reading eressea/strings/string */ + /* reading eressea/terrains/terrain */ terrains = xmlXPathEvalExpression(BAD_CAST "/eressea/terrains/terrain", xpath); nodes = terrains->nodesetval; for (i=0;i!=nodes->nodeNr;++i) { @@ -1740,7 +1740,7 @@ parse_messages(xmlDocPtr doc) xpath = xmlXPathNewContext(doc); - /* reading eressea/strings/string */ + /* reading eressea/messages/message */ messages = xmlXPathEvalExpression(BAD_CAST "/eressea/messages/message", xpath); nodes = messages->nodesetval; for (i=0;i!=nodes->nodeNr;++i) { @@ -1806,7 +1806,7 @@ parse_messages(xmlDocPtr doc) xml_readtext(node, &lang, &text); xml_cleanup_string(text); - nrt_register(mtype, lang, xml_to_locale(text), 0, (const char*)section); + nrt_register(mtype, lang, (const char *)text, 0, (const char*)section); xmlFree(text); } diff --git a/src/common/spells/combatspells.c b/src/common/spells/combatspells.c index 24e49363b..5dede6c77 100644 --- a/src/common/spells/combatspells.c +++ b/src/common/spells/combatspells.c @@ -164,7 +164,7 @@ sp_kampfzauber(fighter * fi, int level, double power, spell * sp) /* Versteinern */ int -sp_versteinern(fighter * fi, int level, double power, spell * sp) +sp_petrify(fighter * fi, int level, double power, spell * sp) { battle *b = fi->side->battle; unit *mage = fi->unit; @@ -194,9 +194,7 @@ sp_versteinern(fighter * fi, int level, double power, spell * sp) --force; } - sprintf(buf, "%d Personen %s versteinert", - stoned, stoned == 1 ? "wurde" : "wurden"); - m = msg_message("cast_spell_effect", "mage spell effect", mage, sp, buf); + m = msg_message("cast_petrify_effect", "mage spell amount", fi->unit, sp, stoned); message_all(b, m); msg_release(m); return level; @@ -247,9 +245,7 @@ sp_stun(fighter * fi, int level, double power, spell * sp) } } - sprintf(buf, "%d Krieger %s für einen Moment benommen", - stunned, stunned == 1 ? "ist" : "sind"); - m = msg_message("cast_spell_effect", "mage spell effect", mage, sp, buf); + m = msg_message("cast_stun_effect", "mage spell amount", fi->unit, sp, stunned); message_all(b, m); msg_release(m); return level; @@ -381,9 +377,7 @@ sp_sleep(fighter * fi, int level, double power, spell * sp) --force; } - sprintf(buf, "%d Krieger %s in Schlaf versetzt", - k, k == 1 ? "wurde" : "wurden"); - m = msg_message("cast_spell_effect", "mage spell effect", mage, sp, buf); + m = msg_message("cast_sleep_effect", "mage spell amount", fi->unit, sp, k); message_all(b, m); msg_release(m); return level; @@ -455,9 +449,7 @@ sp_speed(fighter * fi, int level, double power, spell * sp) } } - sprintf(buf, "%d Krieger %s magisch beschleunigt", - targets, targets == 1 ? "wurde" : "wurden"); - m = msg_message("cast_spell_effect", "mage spell effect", fi->unit, sp, buf); + m = msg_message("cast_speed_effect", "mage spell amount", fi->unit, sp, targets); message_all(b, m); msg_release(m); return 1; @@ -687,10 +679,7 @@ sp_drainodem(fighter * fi, int level, double power, spell * sp) --force; } - sprintf(buf, "%d Person%s wurde ihre Lebenskraft entzogen", - drained, drained == 1 ? " wurde" : "en wurden"); - - m = msg_message("cast_spell_effect", "mage spell effect", fi->unit, sp, buf); + m = msg_message("cast_drainlife_effect", "mage spell amount", fi->unit, sp, drained); message_all(b, m); msg_release(m); return level; @@ -1030,9 +1019,7 @@ sp_hero(fighter * fi, int level, double power, spell * sp) } } - sprintf(buf, "%d Krieger %s moralisch gestärkt", - targets, targets == 1 ? "wurde" : "wurden"); - m = msg_message("cast_spell_effect", "mage spell effect", mage, sp, buf); + m = msg_message("cast_hero_effect", "mage spell amount", fi->unit, sp, targets); message_all(b, m); msg_release(m); @@ -1086,9 +1073,7 @@ sp_berserk(fighter * fi, int level, double power, spell * sp) } } - sprintf(buf, "%d Krieger %s in Blutrausch versetzt", - targets, targets == 1 ? "wurde" : "wurden"); - m = msg_message("cast_spell_effect", "mage spell effect", mage, sp, buf); + m = msg_message("cast_berserk_effect", "mage spell amount", fi->unit, sp, targets); message_all(b, m); msg_release(m); return level; @@ -1139,9 +1124,7 @@ sp_frighten(fighter * fi, int level, double power, spell * sp) --force; } - sprintf(buf, "%d Krieger %s eingeschüchtert", - targets, targets == 1 ? "wurde" : "wurden"); - m = msg_message("cast_spell_effect", "mage spell effect", fi->unit, sp, buf); + m = msg_message("cast_frighten_effect", "mage spell amount", fi->unit, sp, targets); message_all(b, m); msg_release(m); return level; @@ -1183,15 +1166,7 @@ sp_tiredsoldiers(fighter * fi, int level, double power, spell * sp) --force; } - if (n == 0) { - effect = "Der Zauber konnte keinen Krieger ermüden"; - } else if (n == 1) { - effect = "Ein Krieger schleppt sich müde in den Kampf"; - } else { - sprintf(buf, "%d Krieger schleppen sich müde in den Kampf", n); - effect = buf; - } - m = msg_message("cast_spell_effect", "mage spell effect", fi->unit, sp, effect); + m = msg_message("cast_tired_effect", "mage spell amount", fi->unit, sp, n); message_all(b, m); msg_release(m); return level; @@ -1240,8 +1215,7 @@ sp_windshield(fighter * fi, int level, double power, spell * sp) } } - m = msg_message("cast_spell_effect", "mage spell effect", mage, sp, - "Ein Sturm kommt auf und die Schützen können kaum noch zielen"); + m = msg_message("cast_storm_effect", "mage spell", fi->unit, sp); message_all(b, m); msg_release(m); return level; @@ -1256,8 +1230,7 @@ sp_reeling_arrows(fighter * fi, int level, double power, spell * sp) unused(power); b->reelarrow = true; - m = msg_message("cast_spell_effect", "mage spell effect", fi->unit, sp, - "Ein Sturm kommt auf und die Schützen können kaum noch zielen"); + m = msg_message("cast_tired_effect", "mage spell amount", fi->unit, sp, n); message_all(b, m); msg_release(m); return level; @@ -1310,8 +1283,7 @@ sp_denyattack(fighter * fi, int level, double power, spell * sp) /* fighter leeren */ rmfighter(fi, mage->number); - m = msg_message("cast_spell_effect", "mage spell effect", fi->unit, sp, - "Das Kampfgetümmel erstirbt und er kann unbehelligt seines Weges ziehen"); + m = msg_message("cast_escape_effect", "mage spell", fi->unit, sp); message_all(b, m); msg_release(m); diff --git a/src/common/spells/combatspells.h b/src/common/spells/combatspells.h index 4e72d3636..1061e01c4 100644 --- a/src/common/spells/combatspells.h +++ b/src/common/spells/combatspells.h @@ -36,7 +36,7 @@ extern "C" { extern int sp_sleep(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_windshield(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_strong_wall(struct fighter * fi, int level, double power, struct spell * sp); - extern int sp_versteinern(struct fighter * fi, int level, double power, struct spell * sp); + extern int sp_petrify(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_hero(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_frighten(struct fighter * fi, int level, double power, struct spell * sp); extern int sp_mindblast(struct fighter * fi, int level, double power, struct spell * sp); diff --git a/src/common/spells/spells.c b/src/common/spells/spells.c index 9046e1efa..ede3a5997 100644 --- a/src/common/spells/spells.c +++ b/src/common/spells/spells.c @@ -580,7 +580,7 @@ sp_summon_familiar(castorder *co) } msg = msg_message("familiar_name", "unit", mage); - nr_render(msg, mage->faction->locale, zText, sizeof(zText), mage->faction); + nr_render(msg, mage->faction->locale, (char *)zText, sizeof(zText), mage->faction); msg_release(msg); familiar = create_unit(target_region, mage->faction, 1, rc, 0, zText, mage); setstatus(familiar, ST_FLEE); @@ -635,7 +635,7 @@ sp_destroy_magic(castorder *co) double force = co->force; spellparameter *pa = co->par; curse * c = NULL; - char ts[80]; + xmlChar ts[80]; attrib **ap; int obj; int succ; @@ -653,7 +653,7 @@ sp_destroy_magic(castorder *co) /* region *tr = pa->param[0]->data.r; -- farcasting! */ region *tr = co->rt; ap = &tr->attribs; - strcpy(ts, regionname(tr, mage->faction)); + write_regionname(tr, mage->faction, ts, sizeof(ts)); break; } case SPP_TEMP: @@ -662,7 +662,7 @@ sp_destroy_magic(castorder *co) unit *u; u = pa->param[0]->data.u; ap = &u->attribs; - strcpy(ts, unitname(u)); + write_unitname(u, ts, sizeof(ts)); break; } case SPP_BUILDING: @@ -4450,9 +4450,7 @@ sp_pump(castorder *co) target = pa->param[0]->data.u; /* Zieleinheit */ if (fval(target->race, RCF_UNDEAD)) { - sprintf(buf, "%s kann nicht auf Untote gezaubert werden.", - spell_name(sp, mage->faction->locale)); - addmessage(0, mage->faction, buf, MSG_EVENT, ML_WARN); + ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order, "error_not_on_undead", "")); return 0; } if (is_magic_resistant(mage, target, 0) || target->faction->no == MONSTER_FACTION) { @@ -7357,7 +7355,7 @@ static spelldata spelldaten[] = { 0, 0, 0 }, { 0, 0, 0 } }, - (spell_f)sp_versteinern, NULL + (spell_f)sp_petrify, NULL }, { SPL_STRONG_WALL, "strongwall", NULL, NULL, NULL, diff --git a/src/common/spells/unitcurse.c b/src/common/spells/unitcurse.c index d709c18f7..3553886b6 100644 --- a/src/common/spells/unitcurse.c +++ b/src/common/spells/unitcurse.c @@ -45,20 +45,16 @@ static message * cinfo_auraboost(const void * obj, typ_t typ, const curse *c, int self) { - struct unit *u; + struct unit *u = (struct unit *)obj; unused(typ); assert(typ == TYP_UNIT); - u = (struct unit *)obj; if (self != 0){ if (curse_geteffect(c) > 100){ - sprintf(buf, "%s fühlt sich von starken magischen Energien " - "durchströmt", u->name); + return msg_message("curseinfo::auraboost_0", "unit id", u, c->no); } else { - sprintf(buf, "%s hat Schwierigkeiten seine magischen Energien " - "zu sammeln", u->name); + return msg_message("curseinfo::auraboost_1", "unit id", u, c->no); } - return msg_message("curseinfo::info_str", "text id", buf, c->no); } return NULL; } diff --git a/src/common/util/nrmessage.c b/src/common/util/nrmessage.c index 47097b368..28410e18b 100644 --- a/src/common/util/nrmessage.c +++ b/src/common/util/nrmessage.c @@ -119,8 +119,8 @@ nrt_register(const struct message_type * mtype, const struct locale * lang, cons else nrt->section = NULL; messagetypes[hash] = nrt; assert(string && *string); - nrt->string = strdup(string); - *c = '\0'; + nrt->string = xstrdup(string); + *c = '\0'; for (i=0;i!=mtype->nparameters;++i) { if (i!=0) *c++ = ' '; c+= strlen(strcpy(c, mtype->pnames[i])); @@ -131,7 +131,7 @@ nrt_register(const struct message_type * mtype, const struct locale * lang, cons } size_t -nr_render(const struct message * msg, const struct locale * lang, xmlChar * buffer, size_t size, const void * userdata) +nr_render(const struct message * msg, const struct locale * lang, char * buffer, size_t size, const void * userdata) { struct nrmessage_type * nrt = nrt_find(lang, msg->type); diff --git a/src/common/util/nrmessage.h b/src/common/util/nrmessage.h index 89668998e..d9a931570 100644 --- a/src/common/util/nrmessage.h +++ b/src/common/util/nrmessage.h @@ -37,7 +37,7 @@ extern const char * nrt_string(const struct nrmessage_type *type); extern const char * nrt_section(const struct nrmessage_type * mt); extern size_t nr_render(const struct message * msg, const struct locale * lang, - xmlChar * buffer, size_t size, const void * userdata); + char * buffer, size_t size, const void * userdata); extern int nr_level(const struct message *msg); extern const char * nr_section(const struct message *msg);