Unicode WIP:

- completed i18n for combatspells and battle
adding the filereader header (the implementation is on my PC which is still in transit to Germany)
This commit is contained in:
Enno Rehling 2007-07-20 07:28:11 +00:00
parent 7e36df93a4
commit d2094d6205
12 changed files with 199 additions and 87 deletions

View file

@ -69,7 +69,7 @@ createmonsters(void)
* no 0 muss keine orders einreichen! */
f->email = strdup("monsters@eressea.de");
set_string(&f->name, (xmlChar*)"Monster");
f->name = (xmlChar*)strdup("Monster");
f->alive = 1;
f->options = (char)(1<<O_REPORT);
addlist(&factions, f);

View file

@ -169,7 +169,6 @@ use_instantartsculpture(struct unit * u, const struct item_type * itype,
b = new_building(bt_find("artsculpture"), u->region, u->faction->locale);
b->size = 100;
set_string(&b->name, LOC(u->faction->locale, "artsculpture"));
ADDMSG(&u->region->msgs, msg_message("artsculpture_create", "unit region",
u, u->region));
@ -192,7 +191,6 @@ use_instantartacademy(struct unit * u, const struct item_type * itype,
b = new_building(bt_find("artacademy"), u->region, u->faction->locale);
b->size = 100;
set_string(&b->name, LOC(u->faction->locale, "artacademy"));
ADDMSG(&u->region->msgs, msg_message(
"artacademy_create", "unit region", u, u->region));

View file

@ -1064,7 +1064,8 @@ parse_restart(void)
continue;
}
if (fval(f, FFL_OVERRIDE)) {
set_string(&f->override, (xmlChar*)strdup(itoa36(rng_int())));
free(f->override);
f->override = (xmlChar*)strdup(itoa36(rng_int()));
freset(f, FFL_OVERRIDE);
}
if (turn!=f->lastorders) {
@ -1408,13 +1409,11 @@ display_cmd(unit * u, struct order * ord)
if (s!=NULL) {
const xmlChar * s2 = getstrtoken();
free(*s);
*s = xstrdup(s2);
if (xstrlen(s2)>=DISPLAYSIZE) {
xmlChar * s3 = xstrdup(s2);
s3[DISPLAYSIZE] = 0;
set_string(s, s3);
free(s3);
} else
set_string(s, s2);
(*s)[DISPLAYSIZE] = 0;
}
}
return 0;
@ -1677,14 +1676,11 @@ name_cmd(unit * u, struct order * ord)
/* TODO: Validate to make sure people don't have illegal characters in
* names, phishing-style? () come to mind. */
free(*s);
*s = xstrdup(s2);
if (xstrlen(s2)>=NAMESIZE) {
xmlChar * s3 = xstrdup(s2);
s3[NAMESIZE] = 0;
set_string(s, s3);
free(s3);
} else
set_string(s, s2);
(*s)[NAMESIZE] = 0;
}
}
return 0;

View file

@ -114,6 +114,7 @@ static const double TROLL_REGENERATION = 0.10;
/* Nach dem alten System: */
static int missile_range[2] = {FIGHT_ROW, BEHIND_ROW};
static int melee_range[2] = {FIGHT_ROW, FIGHT_ROW};
static message * msg_separator;
const troop no_troop = {0, 0};
@ -2832,7 +2833,7 @@ print_stats(battle * b)
message * msg;
char buf[1024];
fbattlerecord(b, f, " ");
message_faction(b, f, msg_separator);
msg = msg_message("msg_army", "index name", army_index(s), sname);
message_faction(b, f, msg);
@ -2901,7 +2902,7 @@ print_stats(battle * b)
print_fighters(b, s);
}
battlerecord(b, " ");
message_all(b, msg_separator);
/* Besten Taktiker ermitteln */
@ -3452,7 +3453,7 @@ battle_report(battle * b)
size_t size = sizeof(buf), rsize;
message * m;
fbattlerecord(b, fac, " ");
message_faction(b, fac, msg_separator);
if (cont) m = msg_message("battle::lineup", "turn", b->turn);
else m = msg_message("battle::after", "");
@ -4035,6 +4036,10 @@ do_battle(region * r)
ship * sh;
building *bu;
if (msg_separator==NULL) {
msg_separator = msg_message("battle::section", "");
}
fighting = init_battle(r, &b);
if (b==NULL) return;

View file

@ -772,6 +772,15 @@ r_demand(const region * r, const luxury_type * ltype)
return d->value;
}
void
rsetname(struct region * r, const xmlChar * name)
{
if (r->land) {
free(r->land->name);
r->land->name = strdup(name);
}
}
const xmlChar *
rname(const region * r, const struct locale * lang) {
if (r->land) {

View file

@ -213,7 +213,7 @@ extern boolean r_isforest(const struct region * r);
#define rsetterrain(r, t) ((r)->terrain = newterrain(t))
extern const xmlChar * rname(const struct region * r, const struct locale * lang);
#define rsetname(r, str) (set_string(&(r)->land->name, str))
extern void rsetname(struct region * r, const xmlChar * name);
#define rplane(r) getplane(r)

View file

@ -38,6 +38,7 @@
/* libc includes */
#include <assert.h>
#include <string.h>
#define EFFECT_HEALING_SPELL 5
@ -715,6 +716,7 @@ sp_wolfhowl(fighter * fi, int level, double power, spell * sp)
region *r = b->region;
unit *mage = fi->unit;
attrib *a;
message * msg;
int force = (int)(get_force(power, 3)/2);
unit *u = create_unit(r, mage->faction, force, new_race[RC_WOLF], 0, NULL, mage);
unused(sp);
@ -734,9 +736,10 @@ sp_wolfhowl(fighter * fi, int level, double power, spell * sp)
a_add(&u->attribs, a);
make_fighter(b, u, fi->side, is_attacker(fi));
sprintf(buf, "%s ruft %d %s zu Hilfe", unitname(mage), force,
racename(default_locale, u, u->race));
battlerecord(b, buf);
msg = msg_message("sp_wolfhowl_effect", "mage amount race", mage, u->number, u->race);
message_all(b, msg);
msg_release(msg);
return level;
}
@ -749,9 +752,11 @@ sp_shadowknights(fighter * fi, int level, double power, spell * sp)
unit *mage = fi->unit;
attrib *a;
int force = max(1, (int)get_force(power, 3));
message * msg;
unused(sp);
u = create_unit(r, mage->faction, force, new_race[RC_SHADOWKNIGHT], 0, NULL, mage);
setstatus(u, ST_FIGHT);
@ -767,8 +772,10 @@ sp_shadowknights(fighter * fi, int level, double power, spell * sp)
make_fighter(b, u, fi->side, is_attacker(fi));
sprintf(buf, "%s beschwört Trugbilder herauf", unitname(mage));
battlerecord(b, buf);
msg = msg_message("sp_shadowknights_effect", "mage", mage);
message_all(b, msg);
msg_release(msg);
return level;
}
@ -780,15 +787,13 @@ sp_strong_wall(fighter * fi, int level, double power, spell * sp)
building *burg;
variant effect;
static boolean init = false;
message * msg;
static const curse_type * strongwall_ct;
if (!init) { init = true; strongwall_ct = ct_find("strongwall"); }
unused(sp);
if (!mage->building) {
sprintf(buf, "%s zaubert nicht, denn dieser Zauber hätte hier keinen "
"Sinn.", unitname(mage));
battlerecord(b, buf);
return 0;
}
burg = mage->building;
@ -798,9 +803,10 @@ sp_strong_wall(fighter * fi, int level, double power, spell * sp)
create_curse(mage, &burg->attribs, strongwall_ct, power, 1, effect, 0);
sprintf(buf, "%s Mauern erglühen in einem unheimlichen magischen Licht.",
buildingname(burg));
battlerecord(b, buf);
msg = msg_message("sp_strongwalls_effect", "mage building", mage, mage->building);
message_all(b, msg);
msg_release(msg);
return level;
}
@ -811,26 +817,19 @@ sp_chaosrow(fighter * fi, int level, double power, spell * sp)
unit *mage = fi->unit;
cvector *fgs;
void **fig;
message * m;
const char * mtype;
int k = 0;
if (!count_enemies(b, fi, FIGHT_ROW, NUMROWS, SELECT_ADVANCE|SELECT_FIND)) {
message * m = msg_message("battle::out_of_range", "mage spell", fi->unit, sp);
m = msg_message("battle::out_of_range", "mage spell", fi->unit, sp);
message_all(b, m);
msg_release(m);
return 0;
}
switch (sp->id) {
case SPL_CHAOSROW:
sprintf(buf, "%s murmelt eine düster klingende Formel. ", unitname(mage));
power *= 40;
break;
case SPL_SONG_OF_CONFUSION:
sprintf(buf, "%s stimmt einen seltsamen Gesang an. ", unitname(mage));
power = get_force(power, 5);
break;
}
if (sp->id==SPL_CHAOSROW) power *=40;
else power = get_force(power, 5);
fgs = fighters(b, fi->side, FIGHT_ROW, NUMROWS, FS_ENEMY);
v_scramble(fgs->begin, fgs->end);
@ -880,13 +879,14 @@ sp_chaosrow(fighter * fi, int level, double power, spell * sp)
cv_kill(fgs);
free(fgs);
scat("Ein plötzlicher Tumult entsteht");
if (k > 0) {
scat(" und bringt die Kampfaufstellung durcheinander.");
if (sp->id==SPL_CHAOSROW) {
mtype = (k>0) ? "sp_chaosrow_effect_1" : "sp_chaosrow_effect_0";
} else {
scat(", der sich jedoch schnell wieder legt.");
mtype = (k>0) ? "sp_confusion_effect_1" : "sp_confusion_effect_0";
}
battlerecord(b, buf);
m = msg_message(mtype, "mage", mage);
message_all(b, m);
msg_release(m);
return level;
}
@ -902,19 +902,16 @@ sp_flee(fighter * fi, int level, double power, spell * sp)
void **fig;
int force, n;
int panik = 0;
message * msg;
switch(sp->id) {
case SPL_FLEE:
sprintf(buf, "%s zaubert %s", unitname(mage),
spell_name(sp, default_locale));
force = (int)get_force(power,4);
break;
case SPL_SONG_OF_FEAR:
sprintf(buf, "%s stimmt einen düsteren Gesang an", unitname(mage));
force = (int)get_force(power,3);
break;
case SPL_AURA_OF_FEAR:
sprintf(buf, "%s ist von dunklen Schatten umgeben", unitname(mage));
force = (int)get_force(power,5);
break;
default:
@ -922,12 +919,11 @@ sp_flee(fighter * fi, int level, double power, spell * sp)
}
if (!count_enemies(b, fi, FIGHT_ROW, AVOID_ROW, SELECT_ADVANCE|SELECT_FIND)) {
scat(", aber es gab niemanden mehr, der beeinflusst werden konnte.");
battlerecord(b, buf);
msg = msg_message("sp_flee_effect_0", "mage spell", mage, sp);
message_all(b, msg);
msg_release(msg);
return 0;
}
scat(":");
battlerecord(b, buf);
fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_ENEMY);
v_scramble(fgs->begin, fgs->end);
@ -956,9 +952,9 @@ sp_flee(fighter * fi, int level, double power, spell * sp)
cv_kill(fgs);
free(fgs);
sprintf(buf, "%d Krieger %s von Furcht gepackt.", panik,
panik == 1 ? "wurde" : "wurden");
battlerecord(b, buf);
msg = msg_message("sp_flee_effect_1", "mage spell amount", mage, sp, panik);
message_all(b, msg);
msg_release(msg);
return level;
}
@ -968,7 +964,6 @@ int
sp_hero(fighter * fi, int level, double power, spell * sp)
{
battle *b = fi->side->battle;
unit *mage = fi->unit;
int df_bonus = 0;
int force = 0;
int allies;
@ -1017,7 +1012,6 @@ int
sp_berserk(fighter * fi, int level, double power, spell * sp)
{
battle *b = fi->side->battle;
unit *mage = fi->unit;
int at_bonus = 0;
int df_malus = 0;
int force = 0;
@ -1126,7 +1120,6 @@ sp_tiredsoldiers(fighter * fi, int level, double power, spell * sp)
int n = 0;
int force = (int)(power * power * 4);
message * m;
const char * effect;
if (!count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE|SELECT_FIND)) {
message * m = msg_message("battle::out_of_range", "mage spell", fi->unit, sp);
@ -1163,7 +1156,6 @@ int
sp_windshield(fighter * fi, int level, double power, spell * sp)
{
battle *b = fi->side->battle;
unit *mage = fi->unit;
int force, at_malus;
int enemies;
message * m;
@ -1217,7 +1209,7 @@ sp_reeling_arrows(fighter * fi, int level, double power, spell * sp)
unused(power);
b->reelarrow = true;
m = msg_message("cast_tired_effect", "mage spell amount", fi->unit, sp, n);
m = msg_message("cast_spell_effect", "mage spell", fi->unit, sp);
message_all(b, m);
msg_release(m);
return level;
@ -1552,6 +1544,7 @@ sp_undeadhero(fighter * fi, int level, double power, spell * sp)
cvector *fgs;
void **fig;
int n, undead = 0;
message * msg;
int force = (int)get_force(power,0);
double c = 0.50 + 0.02 * power;
@ -1580,15 +1573,15 @@ sp_undeadhero(fighter * fi, int level, double power, spell * sp)
}
if (j > 0) {
unit * u = create_unit(r, mage->faction, 0, new_race[RC_UNDEAD], 0, NULL, mage);
unit * u = create_unit(r, mage->faction, 0, new_race[RC_UNDEAD], 0, du->name, du);
/* new units gets some stats from old unit */
set_string(&u->name, du->name);
set_string(&u->display, du->display);
free(u->display);
u->display = xstrdup(du->display);
setstatus(u, du->status);
setguard(u, GUARD_NONE);
/* inherit stealth from magician */
/* inheit stealth from magician */
if (fval(mage, UFL_PARTEITARNUNG)) {
fset(u, UFL_PARTEITARNUNG);
}
@ -1608,19 +1601,14 @@ sp_undeadhero(fighter * fi, int level, double power, spell * sp)
cv_kill(fgs);
free(fgs);
level = min(level, undead);
if (undead == 0) {
sprintf(buf, "%s kann keine Untoten rufen.", unitname(mage));
level = 0;
} else if (undead == 1) {
sprintf(buf, "%s erweckt einen Untoten.", unitname(mage));
level = 1;
msg = msg_message("summonundead_effect_0", "mage", mage);
} else {
sprintf(buf, "%s erweckt %d Untote.", unitname(mage), undead);
msg = msg_message("summonundead_effect_1", "mage", mage);
}
battlerecord(b, buf);
message_all(b, msg);
msg_release(msg);
return level;
}
/* ------------------------------------------------------------------ */

View file

@ -0,0 +1,21 @@
/* vi: set ts=2:
* +-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
* | | Enno Rehling <enno@eressea.de>
* | Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
* | (c) 1998 - 2005 |
* | | This program may not be used, modified or distributed
* +-------------------+ without prior permission by the authors of Eressea.
*
*/
#ifndef UTIL_FILEREADER_H
#define UTIL_FILEREADER_H
#ifdef __cplusplus
extern "C" {
#endif
const xmlChar * getbuf(FILE *, int encoding);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -82,25 +82,27 @@ building_addaction(building& b, const char * fname, const char * param)
static const char *
building_getinfo(const building& b)
{
return b.display;
return (const char*)b.display;
}
static void
building_setinfo(building& b, const char * info)
{
set_string(&b.display, info);
free(b.display);
b.display = (xmlChar*)strdup(info);
}
static const char *
building_getname(const building& b)
{
return b.name;
return (const char *)b.name;
}
static void
building_setname(building& b, const char * name)
{
set_string(&b.name, name);
free(b.name);
b.name = (xmlChar*)strdup(name);
}
static region *

View file

@ -90,8 +90,10 @@ region_getherbtype(const region& r) {
}
static void
region_setinfo(region& r, const char * info) {
set_string(&r.display, info);
region_setinfo(region& r, const char * info)
{
free(r.display);
r.display = xstrdup(info);
}
static const char *

View file

@ -378,7 +378,8 @@ unit_getname(const unit& u)
static void
unit_setname(unit& u, const char * name)
{
set_string(&u.name, name);
free(u.name);
u.name = xstrdup(name);
}
static const char *
@ -390,7 +391,8 @@ unit_getinfo(const unit& u)
static void
unit_setinfo(unit& u, const char * info)
{
set_string(&u.display, info);
free(u.display);
u.display = xstrdup(info);
}
static bool

View file

@ -1155,6 +1155,25 @@
<text locale="en">"$unit($mage) casts $spell($spell): $int($amount) fighters were intimidated."</text>
</message>
<message name="sp_flee_effect_0" section="magic">
<type>
<arg name="mage" type="unit"/>
<arg name="spell" type="spell"/>
</type>
<text locale="de">"$unit($mage) zaubert $spell($spell), aber es gab niemanden, der beeinflusst werden konnte."</text>
<text locale="en">"$unit($mage) casts $spell($spell), but nobody is impressed."</text>
</message>
<message name="sp_flee_effect_1" section="magic">
<type>
<arg name="mage" type="unit"/>
<arg name="spell" type="spell"/>
<arg name="amount" type="int"/>
</type>
<text locale="de">"$unit($mage) zaubert $spell($spell): $int($amount) Krieger wurden von Furcht gepackt."</text>
<text locale="en">"$unit($mage) casts $spell($spell): $int($amount) fighters were consumed by fear."</text>
</message>
<message name="cast_escape_effect" section="magic">
<type>
<arg name="mage" type="unit"/>
@ -1299,6 +1318,14 @@
<text locale="en">"A vortex of blinding light appears."</text>
</message>
<message name="summonundead_effect_0" section="magic">
<type>
<arg name="mage" type="unit"/>
</type>
<text locale="de">"$unit($mage) kann keine Unjtoten rufen."</text>
<text locale="en">"$unit($mage) cannot summon any undead."</text>
</message>
<message name="summonundead_effect_1" section="magic">
<type>
<arg name="mage" type="unit"/>
@ -7129,12 +7156,74 @@
<text locale="de">"$unit($mage) zaubert $spell($spell), aber niemand war in Reichweite."</text>
<text locale="en">"$unit($mage) casts $spell($spell), but nobody was in range."</text>
</message>
<message name="battle::after" section="battle">
<type>
</type>
<text locale="de">"Einheiten nach dem Kampf:"</text>
<text locale="en">"Units after the battle:"</text>
</message>
<message name="battle::section" section="battle">
<type>
</type>
<text locale="de">""</text>
<text locale="en">""</text>
</message>
<message name="sp_wolfhowl_effect" section="battle">
<type>
<arg name="mage" type="unit"/>
<arg name="amount" type="int"/>
<arg name="race" type="race"/>
</type>
<text locale="de">"$unit($mage) ruft $int($amount) $race($race, $amount) zu Hilfe."</text>
<text locale="en">"$unit($mage) calls for the help of $int($amount) $race($race, $amount)."</text>
</message>
<message name="sp_shadowknights_effect" section="battle">
<type>
<arg name="mage" type="unit"/>
</type>
<text locale="de">"$unit($mage) beschwört Trugbilder herauf."</text>
</message>
<message name="sp_chaosrow_effect_0" section="battle">
<type>
<arg name="mage" type="unit"/>
</type>
<text locale="de">"$unit($mage) murmelt eine düster klingende Formel. Ein plötzlicher Tumult entsteht, der sich jedoch schnell wieder legt."</text>
</message>
<message name="sp_chaosrow_effect_1" section="battle">
<type>
<arg name="mage" type="unit"/>
</type>
<text locale="de">"$unit($mage) murmelt eine düster klingende Formel. Ein plötzlicher Tumult entsteht und bringt die Kampfaufstellung durcheinander."</text>
</message>
<message name="sp_confusion_effect_0" section="battle">
<type>
<arg name="mage" type="unit"/>
</type>
<text locale="de">"$unit($mage) stimmt einen seltsamen Gesang an. Ein plötzlicher Tumult entsteht, der sich jedoch schnell wieder legt."</text>
</message>
<message name="sp_confusion_effect_1" section="battle">
<type>
<arg name="mage" type="unit"/>
</type>
<text locale="de">"$unit($mage) stimmt einen seltsamen Gesang an. Ein plötzlicher Tumult entsteht und bringt die Kampfaufstellung durcheinander."</text>
</message>
<message name="sp_strongwalls_effect" section="battle">
<type>
<arg name="mage" type="unit"/>
<arg name="building" type="building"/>
</type>
<text locale="de">"$unit($mage) läßt die Mauern von $building($building) in einem unheimlichen magischen Licht erglühen."</text>
</message>
<message name="battle::lineup" section="battle">
<type>
<arg name="turn" type="int"/>