Unicode WIP, does not compile.

- made battle.c compile and cleaned up a lot of German text.
- fixed the create_order command to accept and respect quotes.
This commit is contained in:
Enno Rehling 2007-06-26 21:17:10 +00:00
parent 6b4ad684af
commit 8be7d65977
10 changed files with 246 additions and 239 deletions

View File

@ -70,7 +70,6 @@
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#define dbgprintf(a) fprintf a;
static FILE *bdebug; static FILE *bdebug;
#undef DELAYED_OFFENSE /* non-guarding factions cannot attack after moving */ #undef DELAYED_OFFENSE /* non-guarding factions cannot attack after moving */
@ -156,20 +155,20 @@ fleeregion(const unit * u)
} }
#endif /* SIMPLE_ESCAPE */ #endif /* SIMPLE_ESCAPE */
static char * static xmlChar *
sidename(side * s, boolean truename) sidename(side * s)
{ {
#define SIDENAMEBUFLEN 256 #define SIDENAMEBUFLEN 256
static char sidename_buf[SIDENAMEBUFLEN]; static char sidename_buf[SIDENAMEBUFLEN];
if(s->stealthfaction && truename == false) { if (s->stealthfaction) {
snprintf(sidename_buf, SIDENAMEBUFLEN, snprintf(sidename_buf, SIDENAMEBUFLEN,
"%s", factionname(s->stealthfaction)); "%s", factionname(s->stealthfaction));
} else { } else {
snprintf(sidename_buf, SIDENAMEBUFLEN, snprintf(sidename_buf, SIDENAMEBUFLEN,
"%s", factionname(s->bf->faction)); "%s", factionname(s->bf->faction));
} }
return sidename_buf; return (xmlChar *)sidename_buf;
} }
static const char * static const char *
@ -224,18 +223,6 @@ armedmen(const unit * u)
return n; return n;
} }
static void
battle_log(const char *s)
{
#if SHOW_DEBUG
puts(s);
putc('\n');
#endif
if (bdebug) {
dbgprintf((bdebug, "%s\n", s));
}
}
void void
message_all(battle * b, message * m) message_all(battle * b, message * m)
{ {
@ -255,35 +242,15 @@ message_all(battle * b, message * m)
void void
battlerecord(battle * b, const char *s) battlerecord(battle * b, const char *s)
{ {
struct message * m = msg_message("msg_battle", "string", s); struct message * m = msg_message("battle_msg", "string", s);
message_all(b, m); message_all(b, m);
msg_release(m); msg_release(m);
} }
void
battlemsg(battle * b, unit * u, const char * s)
{
bfaction * bf;
struct message * m;
plane * p = rplane(b->region);
watcher * w;
sprintf(buf, "%s %s", unitname(u), s);
m = msg_message("msg_battle", "string", buf);
for (bf=b->factions;bf;bf=bf->next) {
message_faction(b, bf->faction, m);
}
if (p) for (w=p->watchers;w;w=w->next) {
for (bf = b->factions;bf;bf=bf->next) if (bf->faction==w->faction) break;
if (bf==NULL) message_faction(b, w->faction, m);
}
msg_release(m);
}
static void static void
fbattlerecord(battle * b, faction * f, const char *s) fbattlerecord(battle * b, faction * f, const char *s)
{ {
message * m = msg_message("msg_battle", "string", s); message * m = msg_message("battle_msg", "string", s);
message_faction(b, f, m); message_faction(b, f, m);
msg_release(m); msg_release(m);
} }
@ -945,7 +912,6 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
unit *du = df->unit; unit *du = df->unit;
battle *b = df->side->battle; battle *b = df->side->battle;
int heiltrank = 0; int heiltrank = 0;
char debugbuf[512];
/* Schild */ /* Schild */
void **si; void **si;
@ -1054,9 +1020,8 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
kritchance = min(0.9, kritchance); kritchance = min(0.9, kritchance);
while (chance(kritchance)) { while (chance(kritchance)) {
if (battledebug) { if (bdebug) {
sprintf(debugbuf, "%s/%d landet einen kritischen Treffer", unitid(au), at.index); fprintf(bdebug, "%s/%d landet einen kritischen Treffer", unitid(au), at.index);
battle_log(debugbuf);
} }
da += dice_rand(damage); da += dice_rand(damage);
} }
@ -1136,11 +1101,6 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
} }
} }
if (battledebug) {
sprintf(debugbuf, "Verursacht %dTP, Rüstung %d: %d -> %d HP",
da, ar, df->person[dt.index].hp, df->person[dt.index].hp - rda);
}
#ifdef SMALL_BATTLE_MESSAGES #ifdef SMALL_BATTLE_MESSAGES
if (b->small) { if (b->small) {
if (rda > 0) { if (rda > 0) {
@ -1156,8 +1116,9 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
df->person[dt.index].hp -= rda; df->person[dt.index].hp -= rda;
if (df->person[dt.index].hp > 0) { /* Hat überlebt */ if (df->person[dt.index].hp > 0) { /* Hat überlebt */
if (battledebug) { if (bdebug) {
battle_log(debugbuf); fprintf(bdebug, "Damage %d, armor %d: %d -> %d HP\n",
da, ar, df->person[dt.index].hp, df->person[dt.index].hp - rda);
} }
if (au->race == new_race[RC_DAEMON]) { if (au->race == new_race[RC_DAEMON]) {
#ifdef TODO_RUNESWORD #ifdef TODO_RUNESWORD
@ -1226,9 +1187,9 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
return false; return false;
} }
if (battledebug) { if (bdebug) {
strcat(debugbuf, ", tot"); fprintf(bdebug, "Damage %d, armor %d: %d -> %d HP, tot.\n",
battle_log(debugbuf); da, ar, df->person[dt.index].hp, df->person[dt.index].hp - rda);
} }
#ifdef SMALL_BATTLE_MESSAGES #ifdef SMALL_BATTLE_MESSAGES
if (b->small) { if (b->small) {
@ -1519,7 +1480,6 @@ do_combatmagic(battle *b, combatmagic_t was)
double power; double power;
const spell *sp; const spell *sp;
const struct locale * lang = mage->faction->locale; const struct locale * lang = mage->faction->locale;
char cmd[128];
order * ord; order * ord;
switch(was) { switch(was) {
@ -1538,10 +1498,7 @@ do_combatmagic(battle *b, combatmagic_t was)
if (sp == NULL) if (sp == NULL)
continue; continue;
snprintf(cmd, 128, "%s \"%s\"", ord = create_order(K_CAST, lang, "'%s'", spell_name(sp, lang));
LOC(lang, keywords[K_CAST]), spell_name(sp, lang));
ord = parse_order(cmd, lang);
if (cancast(mage, sp, 1, 1, ord) == false) { if (cancast(mage, sp, 1, 1, ord) == false) {
free_order(ord); free_order(ord);
continue; continue;
@ -1616,7 +1573,6 @@ do_combatspell(troop at)
void **mg; void **mg;
order * ord; order * ord;
int sl; int sl;
char cmd[128];
const struct locale * lang = mage->faction->locale; const struct locale * lang = mage->faction->locale;
sp = get_combatspell(mage, 1); sp = get_combatspell(mage, 1);
@ -1624,9 +1580,7 @@ do_combatspell(troop at)
fi->magic = 0; /* Hat keinen Kampfzauber, kämpft nichtmagisch weiter */ fi->magic = 0; /* Hat keinen Kampfzauber, kämpft nichtmagisch weiter */
return; return;
} }
snprintf(cmd, 128, "%s \"%s\"", ord = create_order(K_CAST, lang, "'%s'", spell_name(sp, lang));
LOC(lang, keywords[K_CAST]), spell_name(sp, lang));
ord = parse_order(cmd, lang);
if (cancast(mage, sp, 1, 1, ord) == false) { if (cancast(mage, sp, 1, 1, ord) == false) {
fi->magic = 0; /* Kann nicht mehr Zaubern, kämpft nichtmagisch weiter */ fi->magic = 0; /* Kann nicht mehr Zaubern, kämpft nichtmagisch weiter */
return; return;
@ -1849,6 +1803,20 @@ attack_message(const troop at, const troop dt, const weapon * wp, int dist)
} }
#endif #endif
static void
debug_hit(troop at, const weapon * awp, troop dt, const weapon * dwp, int skdiff, int dist, boolean success)
{
fprintf(bdebug, "%.4s/%d [%6s/%d] %s %.4s/%d [%6s/%d] with %d distance %d",
unitid(at.fighter->unit), at.index,
LOC(default_locale, awp ? resourcename(awp->type->itype->rtype, 0) : "unarmed"),
weapon_effskill(at, dt, awp, true, dist>1),
success?"hits":"misses",
unitid(dt.fighter->unit), dt.index,
LOC(default_locale, dwp ? resourcename(dwp->type->itype->rtype, 0) : "unarmed"),
weapon_effskill(dt, at, dwp, false, dist>1),
skdiff, dist);
}
int int
hits(troop at, troop dt, weapon * awp) hits(troop at, troop dt, weapon * awp)
{ {
@ -1857,8 +1825,6 @@ hits(troop at, troop dt, weapon * awp)
battle * b = at.fighter->side->battle; battle * b = at.fighter->side->battle;
#endif #endif
fighter *af = at.fighter, *df = dt.fighter; fighter *af = at.fighter, *df = dt.fighter;
unit *au = af->unit, *du = df->unit;
char debugbuf[512];
const armor_type * armor, * shield; const armor_type * armor, * shield;
int skdiff = 0; int skdiff = 0;
int dist = get_unitrow(af, df->side) + get_unitrow(df, af->side) - 1; int dist = get_unitrow(af, df->side) + get_unitrow(df, af->side) - 1;
@ -1889,25 +1855,14 @@ hits(troop at, troop dt, weapon * awp)
/* Verteidiger bekommt eine Rüstung */ /* Verteidiger bekommt eine Rüstung */
armor = select_armor(dt, true); armor = select_armor(dt, true);
shield = select_armor(dt, false); shield = select_armor(dt, false);
sprintf(debugbuf, "%.4s/%d [%6s/%d] attackiert %.4s/%d [%6s/%d] mit %d dist %d",
unitid(au), at.index,
(awp != NULL) ?
locale_string(default_locale, resourcename(awp->type->itype->rtype, 0)) : "unbewaffnet",
weapon_effskill(at, dt, awp, true, dist>1),
unitid(du), dt.index,
(dwp != NULL) ?
locale_string(default_locale, resourcename(dwp->type->itype->rtype, 0)) : "unbewaffnet",
weapon_effskill(dt, at, dwp, false, dist>1),
skdiff, dist);
#ifdef SMALL_BATTLE_MESSAGES #ifdef SMALL_BATTLE_MESSAGES
if (b->small) { if (b->small) {
smallbuf = attack_message(at, dt, awp, dist); smallbuf = attack_message(at, dt, awp, dist);
} }
#endif #endif
if (contest(skdiff, armor, shield)) { if (contest(skdiff, armor, shield)) {
if (battledebug) { if (bdebug) {
strcat(debugbuf, " und trifft."); debug_hit(at, awp, dt, dwp, skdiff, dist, true);
battle_log(debugbuf);
} }
#ifdef SMALL_BATTLE_MESSAGES #ifdef SMALL_BATTLE_MESSAGES
if (b->small) { if (b->small) {
@ -1917,9 +1872,8 @@ hits(troop at, troop dt, weapon * awp)
#endif #endif
return 1; return 1;
} }
if (battledebug) { if (bdebug) {
strcat(debugbuf, "."); debug_hit(at, awp, dt, dwp, skdiff, dist, false);
battle_log(debugbuf);
} }
#ifdef SMALL_BATTLE_MESSAGES #ifdef SMALL_BATTLE_MESSAGES
if (b->small) { if (b->small) {
@ -2114,9 +2068,8 @@ attack(battle *b, troop ta, const att *a, int numattack)
} }
if (reload && wp && wp->type->reload && !getreload(ta)) { if (reload && wp && wp->type->reload && !getreload(ta)) {
int i = setreload(ta); int i = setreload(ta);
if (battledebug) { if (bdebug) {
sprintf(buf, " Nachladen gesetzt: %d", i); fprintf(bdebug, " reloading %d turns\n", i);
battle_log(buf);
} }
} }
} }
@ -2712,9 +2665,9 @@ aftermath(battle * b)
/* Beute verteilen */ /* Beute verteilen */
for (l=df->loot; l; l=l->next) { for (l=df->loot; l; l=l->next) {
const item_type * itype = l->type; const item_type * itype = l->type;
sprintf(buf, "%s erbeute%s %d %s.", unitname(du), du->number==1?"t":"n", message * m = msg_message("battle_loot", "unit amount item", du, l->number, itype->rtype);
l->number, locale_string(default_locale, resourcename(itype->rtype, l->number!=1))); message_faction(b, du->faction, m);
fbattlerecord(b, du->faction, buf); msg_release(m);
i_change(&du->items, itype, l->number); i_change(&du->items, itype, l->number);
} }
@ -2752,12 +2705,11 @@ aftermath(battle * b)
free(trollsave); free(trollsave);
#endif #endif
if (battledebug) { if (bdebug) {
sprintf(buf, "The battle lasted %d turns, %s and %s.\n", fprintf(bdebug, "The battle lasted %d turns, %s and %s.\n",
b->turn, b->turn,
b->has_tactics_turn==true?"had a tactic turn":"had no tactic turn", b->has_tactics_turn?"had a tactic turn":"had no tactic turn",
battle_was_relevant==true?"was relevant":"was not relevant."); battle_was_relevant?"was relevant":"was not relevant.");
battle_log(buf);
} }
} }
@ -2774,8 +2726,8 @@ battle_punit(unit * u, battle * b)
spunit(&S, f, u, 4, see_battle); spunit(&S, f, u, 4, see_battle);
for (x = S; x; x = x->next) { for (x = S; x; x = x->next) {
fbattlerecord(b, f, x->s); fbattlerecord(b, f, x->s);
if (battledebug && u->faction == f) { if (bdebug && u->faction == f) {
battle_log(x->s); fputs(x->s, bdebug);
} }
} }
if (S) if (S)
@ -2824,26 +2776,29 @@ static void
print_header(battle * b) print_header(battle * b)
{ {
bfaction * bf; bfaction * bf;
char zText[1024];
for (bf=b->factions;bf;bf=bf->next) { for (bf=b->factions;bf;bf=bf->next) {
message * m; message * m;
faction * f = bf->faction; faction * f = bf->faction;
const char * lastf = NULL; const xmlChar * lastf = NULL;
boolean first = false; boolean first = false;
side * s; side * s;
size_t size;
buf[0] = 0; zText[0] = 0;
size = sizeof(zText);
for (s=b->sides; s; s=s->next) { for (s=b->sides; s; s=s->next) {
fighter *df; fighter *df;
for (df=s->fighters;df;df=df->next) { for (df=s->fighters;df;df=df->next) {
if (is_attacker(df)) { if (is_attacker(df)) {
if (first) strcat(buf, ", "); if (first) size -= strlcat(zText, ", ", size);
if (lastf) { if (lastf) {
strcat(buf, lastf); size -= strlcat(zText, (const char *)lastf, size);
first = true; first = true;
} }
if (seematrix(f, s) == true) if (seematrix(f, s) == true)
lastf = sidename(s, false); lastf = sidename(s);
else else
lastf = LOC(f->locale, "unknown_faction_dative"); lastf = LOC(f->locale, "unknown_faction_dative");
break; break;
@ -2851,13 +2806,13 @@ print_header(battle * b)
} }
} }
if (first) { if (first) {
strcat(buf, " "); size -= strlcat(zText, " ", size);
strcat(buf, LOC(f->locale, "and")); size -= strlcat(zText, (const char *)LOC(f->locale, "and"), size);
strcat(buf, " "); size -= strlcat(zText, " ", size);
} }
if (lastf) strcat(buf, lastf); if (lastf) size -= strlcat(zText, (const char *)lastf, size);
m = msg_message("battle::starters", "factions", buf); m = msg_message("battle::starters", "factions", zText);
message_faction(b, f, m); message_faction(b, f, m);
msg_release(m); msg_release(m);
} }
@ -2871,23 +2826,25 @@ print_stats(battle * b)
int i = 0; int i = 0;
for (s=b->sides;s;s=s->next) { for (s=b->sides;s;s=s->next) {
bfaction *bf; bfaction *bf;
char *k;
++i; ++i;
for (bf=b->factions;bf;bf=bf->next) { for (bf=b->factions;bf;bf=bf->next) {
faction * f = bf->faction; faction * f = bf->faction;
const char * loc_army = LOC(f->locale, "battle_army"); const xmlChar * loc_army = LOC(f->locale, "battle_army");
char * bufp; char * bufp;
const xmlChar * header; const xmlChar * header;
size_t rsize, size; size_t rsize, size;
int komma; int komma;
const xmlChar * sname = seematrix(f, s) ? sidename(s) : LOC(f->locale, "unknown_faction");
message * msg;
char buf[1024];
fbattlerecord(b, f, " "); fbattlerecord(b, f, " ");
slprintf(buf, sizeof(buf), "%s %d: %s", loc_army, army_index(s), msg = msg_message("msg_army", "index name", army_index(s), sname);
seematrix(f, s) ? sidename(s, false) : LOC(f->locale, "unknown_faction")); message_faction(b, f, msg);
fbattlerecord(b, f, buf); msg_release(msg);
bufp = buf; bufp = buf;
size = sizeof(buf); size = sizeof(buf);
@ -2898,7 +2855,7 @@ print_stats(battle * b)
if (enemy(s2, s)) { if (enemy(s2, s)) {
const char * abbrev = seematrix(f, s2)?sideabkz(s2, false):"-?-"; const char * abbrev = seematrix(f, s2)?sideabkz(s2, false):"-?-";
rsize = slprintf(bufp, size, "%s %s %d(%s)", rsize = slprintf(bufp, size, "%s %s %d(%s)",
komma++ ? "," : header, loc_army, army_index(s2), abbrev); komma++ ? "," : (const char*)header, loc_army, army_index(s2), abbrev);
if (rsize>size) rsize = size-1; if (rsize>size) rsize = size-1;
size -= rsize; size -= rsize;
bufp += rsize; bufp += rsize;
@ -2915,7 +2872,7 @@ print_stats(battle * b)
if (friendly(s2, s)) { if (friendly(s2, s)) {
const char * abbrev = seematrix(f, s2)?sideabkz(s2, false):"-?-"; const char * abbrev = seematrix(f, s2)?sideabkz(s2, false):"-?-";
rsize = slprintf(bufp, size, "%s %s %d(%s)", rsize = slprintf(bufp, size, "%s %s %d(%s)",
komma++ ? "," : header, loc_army, army_index(s2), abbrev); komma++ ? "," : (const char*)header, loc_army, army_index(s2), abbrev);
if (rsize>size) rsize = size-1; if (rsize>size) rsize = size-1;
size -= rsize; size -= rsize;
bufp += rsize; bufp += rsize;
@ -2931,7 +2888,7 @@ print_stats(battle * b)
for (s2=b->sides;s2;s2=s2->next) { for (s2=b->sides;s2;s2=s2->next) {
if (s->relations[s2->index] & E_ATTACKING) { if (s->relations[s2->index] & E_ATTACKING) {
const char * abbrev = seematrix(f, s2)?sideabkz(s2, false):"-?-"; const char * abbrev = seematrix(f, s2)?sideabkz(s2, false):"-?-";
rsize = slprintf(bufp, size, "%s %s %d(%s)", komma++ ? "," : header, loc_army, rsize = slprintf(bufp, size, "%s %s %d(%s)", komma++ ? "," : (const char*)header, loc_army,
army_index(s2), abbrev); army_index(s2), abbrev);
if (rsize>size) rsize = size-1; if (rsize>size) rsize = size-1;
size -= rsize; size -= rsize;
@ -2940,17 +2897,14 @@ print_stats(battle * b)
} }
if (komma) fbattlerecord(b, f, buf); if (komma) fbattlerecord(b, f, buf);
} }
buf[77] = (char)0;
for (k = buf; *k; ++k) *k = '-'; if (bdebug && s->bf->faction) {
battlerecord(b, buf);
if (battledebug && s->bf->faction) {
if (s->bf->faction->alliance) { if (s->bf->faction->alliance) {
slprintf(buf, sizeof(buf), "##### %s (%s/%d)", s->bf->faction->name, itoa36(s->bf->faction->no), fprintf(bdebug, "##### %s (%s/%d)\n", s->bf->faction->name, itoa36(s->bf->faction->no),
s->bf->faction->alliance?s->bf->faction->alliance->id:0); s->bf->faction->alliance?s->bf->faction->alliance->id:0);
} else { } else {
slprintf(buf, sizeof(buf), "##### %s (%s)", s->bf->faction->name, itoa36(s->bf->faction->no)); fprintf(bdebug, "##### %s (%s)\n", s->bf->faction->name, itoa36(s->bf->faction->no));
} }
battle_log(buf);
} }
print_fighters(b, s); print_fighters(b, s);
} }
@ -3018,16 +2972,10 @@ make_fighter(battle * b, unit * u, side * s1, boolean attack)
const group * g = NULL; const group * g = NULL;
const attrib *a = a_find(u->attribs, &at_otherfaction); const attrib *a = a_find(u->attribs, &at_otherfaction);
const faction *stealthfaction = a?get_otherfaction(a):NULL; const faction *stealthfaction = a?get_otherfaction(a):NULL;
static const struct item_type * it_demonseye;
static boolean init = false;
unsigned int flags = 0; unsigned int flags = 0;
assert(u->number); assert(u->number);
if (fval(u, UFL_PARTEITARNUNG)!=0) flags |= SIDE_STEALTH; if (fval(u, UFL_PARTEITARNUNG)!=0) flags |= SIDE_STEALTH;
if (!init) {
it_demonseye = it_find("demonseye");
init=true;
}
if (fval(u, UFL_GROUP)) { if (fval(u, UFL_GROUP)) {
const attrib * agroup = a_find(u->attribs, &at_group); const attrib * agroup = a_find(u->attribs, &at_group);
@ -3213,17 +3161,6 @@ make_fighter(battle * b, unit * u, side * s1, boolean attack)
} }
} }
if (it_demonseye && i_get(u->items, it_demonseye)) {
char lbuf[80];
const char * s = LOC(default_locale, rc_name(u->race, 3));
char * c = lbuf;
while (*s) *c++ = (char)toupper(*s++);
*c = 0;
fig->person[0].hp = unit_max_hp(u) * 3;
slprintf(buf, sizeof(buf), "Eine Stimme ertönt über dem Schlachtfeld. 'DIESES %sKIND IST MEIN. IHR SOLLT ES NICHT HABEN.'. Eine leuchtende Aura umgibt %s", lbuf, unitname(u));
battlerecord(b, buf);
}
s1->size[statusrow(fig->status)] += u->number; s1->size[statusrow(fig->status)] += u->number;
s1->size[SUM_ROW] += u->number; s1->size[SUM_ROW] += u->number;
if (u->race->battle_flags & BF_NOBLOCK) { if (u->race->battle_flags & BF_NOBLOCK) {
@ -3379,7 +3316,7 @@ make_battle(region * r)
bdebug = fopen(zFilename, "w"); bdebug = fopen(zFilename, "w");
if (!bdebug) log_error(("battles können nicht debugged werden\n")); if (!bdebug) log_error(("battles können nicht debugged werden\n"));
else { else {
dbgprintf((bdebug, "In %s findet ein Kampf statt:\n", rname(r, NULL))); fprintf(bdebug, "In %s findet ein Kampf statt:\n", rname(r, NULL));
} }
obs_count++; obs_count++;
} }
@ -3503,8 +3440,6 @@ battle_report(battle * b)
boolean komma; boolean komma;
bfaction *bf; bfaction *bf;
buf[0] = 0;
for (s=b->sides; s; s=s->next) { for (s=b->sides; s; s=s->next) {
for(s2=b->sides; s2; s2=s2->next) { for(s2=b->sides; s2; s2=s2->next) {
if (s->alive-s->removed > 0 && s2->alive-s2->removed > 0 && enemy(s, s2)) { if (s->alive-s->removed > 0 && s2->alive-s2->removed > 0 && enemy(s, s2)) {
@ -3520,6 +3455,7 @@ battle_report(battle * b)
for (bf=b->factions;bf;bf=bf->next) { for (bf=b->factions;bf;bf=bf->next) {
faction * fac = bf->faction; faction * fac = bf->faction;
char buf[1024];
char * bufp = buf; char * bufp = buf;
size_t size = sizeof(buf), rsize; size_t size = sizeof(buf), rsize;
message * m; message * m;
@ -3537,7 +3473,7 @@ battle_report(battle * b)
int r, k = 0, * alive = get_alive(s); int r, k = 0, * alive = get_alive(s);
int l = FIGHT_ROW; int l = FIGHT_ROW;
const char * abbrev = seematrix(fac, s)?sideabkz(s, false):"-?-"; const char * abbrev = seematrix(fac, s)?sideabkz(s, false):"-?-";
const char * loc_army = LOC(fac->locale, "battle_army"); const xmlChar * loc_army = LOC(fac->locale, "battle_army");
char buffer[32]; char buffer[32];
if (komma) { if (komma) {
@ -3799,15 +3735,12 @@ init_battle(region * r, battle **bp)
if (fval(u, UFL_LONGACTION)) continue; if (fval(u, UFL_LONGACTION)) continue;
if (peace_ct && curse_active(get_curse(r->attribs, peace_ct))) { if (peace_ct && curse_active(get_curse(r->attribs, peace_ct))) {
sprintf(buf, "Hier ist es so schön friedlich, %s möchte " ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "peace_active", ""));
"hier niemanden angreifen.", unitname(u));
mistake(u, ord, buf, MSG_BATTLE);
continue; continue;
} }
if (slave_ct && curse_active(get_curse(u->attribs, slave_ct))) { if (slave_ct && curse_active(get_curse(u->attribs, slave_ct))) {
sprintf(buf, "%s kämpft nicht.", unitname(u)); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "slave_active", ""));
mistake(u, ord, buf, MSG_BATTLE);
continue; continue;
} }
@ -3848,13 +3781,7 @@ init_battle(region * r, battle **bp)
cmistake(u, ord, 47, MSG_BATTLE); cmistake(u, ord, 47, MSG_BATTLE);
continue; continue;
} }
/* xmas */ if (u2->faction->age < NewbieImmunity()) {
if (u2->no==atoi36("xmas") && u2->irace==new_race[RC_GNOME]) {
a_add(&u->attribs, a_new(&at_key))->data.i = atoi36("coal");
sprintf(buf, "%s ist böse gewesen...", unitname(u));
mistake(u, ord, buf, MSG_BATTLE);
continue;
} if (u2->faction->age < NewbieImmunity()) {
add_message(&u->faction->msgs, add_message(&u->faction->msgs,
msg_feedback(u, u->thisorder, "newbie_immunity_error", "turns", NewbieImmunity())); msg_feedback(u, u->thisorder, "newbie_immunity_error", "turns", NewbieImmunity()));
continue; continue;
@ -3901,10 +3828,9 @@ init_battle(region * r, battle **bp)
c1->side->bf->attacker = true; c1->side->bf->attacker = true;
set_enemy(c1->side, c2->side, true); set_enemy(c1->side, c2->side, true);
if (battledebug && !enemy(c1->side, c2->side)) { if (bdebug && !enemy(c1->side, c2->side)) {
sprintf(buf, "%s attackiert %s", sidename(c1->side, false), fprintf(bdebug, "%s attacks %s\n", sidename(c1->side),
sidename(c2->side, false)); sidename(c2->side));
battle_log(buf);
} }
fighting = true; fighting = true;
} }
@ -4098,10 +4024,8 @@ battle_flee(battle * b)
#endif #endif
} }
} }
if (battledebug && runners > 0) { if (bdebug && runners > 0) {
char lbuf[256]; fprintf(bdebug, "Fleeing: %d from %s\n", runners, itoa36(fig->unit->no));
sprintf(lbuf, "Flucht: %d aus %s", runners, itoa36(fig->unit->no));
battle_log(lbuf);
} }
} }
} }
@ -4172,10 +4096,8 @@ do_battle(region * r)
#endif #endif
for (;battle_report(b) && b->turn<=COMBAT_TURNS;++b->turn) { for (;battle_report(b) && b->turn<=COMBAT_TURNS;++b->turn) {
if (battledebug) { if (bdebug) {
char lbuf[256]; fprintf(bdebug, "*** Turn: %d\n", b->turn);
sprintf(lbuf, "*** Runde: %d", b->turn);
battle_log(lbuf);
} }
battle_flee(b); battle_flee(b);
battle_update(b); battle_update(b);

View File

@ -238,7 +238,6 @@ extern "C" {
extern troop select_enemy(struct fighter * af, int minrow, int maxrow, int select); extern troop select_enemy(struct fighter * af, int minrow, int maxrow, int select);
extern int count_enemies(struct battle * b, const struct fighter * af, int minrow, int maxrow, int select); extern int count_enemies(struct battle * b, const struct fighter * af, int minrow, int maxrow, int select);
extern boolean terminate(troop dt, troop at, int type, const char *damage, boolean missile); extern boolean terminate(troop dt, troop at, int type, const char *damage, boolean missile);
extern void battlemsg(battle * b, struct unit * u, const char * s);
extern void battlerecord(battle * b, const char *s); extern void battlerecord(battle * b, const char *s);
extern void message_all(battle * b, struct message * m); extern void message_all(battle * b, struct message * m);
extern void message_faction(battle * b, struct faction * f, struct message * m); extern void message_faction(battle * b, struct faction * f, struct message * m);

View File

@ -1646,13 +1646,19 @@ largestbuilding (const region * r, boolean img)
return best; return best;
} }
const char * xmlChar *
write_unitname(const unit * u, xmlChar * buffer, size_t size)
{
snprintf((char*)buffer, size, "%s (%s)", (const char*)u->name, itoa36(u->no));
buffer[size-1] = 0;
return buffer;
}
const xmlChar *
unitname(const unit * u) unitname(const unit * u)
{ {
char *ubuf = idbuf[(++nextbuf) % 8]; char *ubuf = idbuf[(++nextbuf) % 8];
snprintf(ubuf, sizeof(name), "%s (%s)", u->name, itoa36(u->no)); return write_unitname(u, (xmlChar*)ubuf, sizeof(name));
ubuf[sizeof(name)-1] = 0;
return ubuf;
} }
/* -- Erschaffung neuer Einheiten ------------------------------ */ /* -- Erschaffung neuer Einheiten ------------------------------ */
@ -2074,7 +2080,7 @@ init_locale(const struct locale * lang)
tokens = get_translations(lang, UT_TERRAINS); tokens = get_translations(lang, UT_TERRAINS);
for (terrain=terrains();terrain!=NULL;terrain=terrain->next) { for (terrain=terrains();terrain!=NULL;terrain=terrain->next) {
var.v = terrain; var.v = (void*)terrain;
addtoken(tokens, LOC(lang, terrain->_name), var); addtoken(tokens, LOC(lang, terrain->_name), var);
} }
} }

View File

@ -258,7 +258,8 @@ struct region *findunitregion(const struct unit * su);
char *estring(const char *s); char *estring(const char *s);
char *cstring(const char *s); char *cstring(const char *s);
const char *unitname(const struct unit * u); extern const xmlChar *unitname(const struct unit * u);
extern xmlChar * write_unitname(const struct unit * u, xmlChar * buffer, size_t size);
struct building *largestbuilding(const struct region * r, boolean img); struct building *largestbuilding(const struct region * r, boolean img);

View File

@ -267,6 +267,7 @@ create_order(keyword_t kwd, const struct locale * lang, const char * params, ...
va_list marker; va_list marker;
char zBuffer[DISPLAYSIZE]; char zBuffer[DISPLAYSIZE];
char * sptr = zBuffer; char * sptr = zBuffer;
char quote = 0;
va_start(marker, params); va_start(marker, params);
while (params) { while (params) {
@ -275,8 +276,18 @@ create_order(keyword_t kwd, const struct locale * lang, const char * params, ...
case ' ': case ' ':
/* ignore these, they are syntactical sugar */ /* ignore these, they are syntactical sugar */
break; break;
case '"':
case '\'':
*sptr++ = *params;
if (!quote) quote = *params;
else if (quote==*params) {
quote = 0;
*sptr++ = ' ';
}
break;
case 's': case 's':
sptr += strlcpy(sptr, va_arg(marker, const char *), sizeof(zBuffer)-(sptr-zBuffer)); sptr += strlcpy(sptr, va_arg(marker, const char *), sizeof(zBuffer)-(sptr-zBuffer));
if (!quote) *sptr++ = ' ';
break; break;
case 'd': case 'd':
sptr += strlcpy(sptr, itoa10(va_arg(marker, int)), sizeof(zBuffer)-(sptr-zBuffer)); sptr += strlcpy(sptr, itoa10(va_arg(marker, int)), sizeof(zBuffer)-(sptr-zBuffer));

View File

@ -35,6 +35,7 @@ typedef struct order {
} order; } order;
/* constructor */ /* constructor */
extern order * create_order(keyword_t kwd, const struct locale * lang, const char * params, ...);
extern order * parse_order(const xmlChar * s, const struct locale * lang); extern order * parse_order(const xmlChar * s, const struct locale * lang);
extern void replace_order(order ** dst, order * orig, const order * src); extern void replace_order(order ** dst, order * orig, const order * src);

View File

@ -267,20 +267,16 @@ sp_combatrosthauch(fighter * fi, int level, double power, spell * sp)
battle *b = fi->side->battle; battle *b = fi->side->battle;
cvector *fgs; cvector *fgs;
void **fig; void **fig;
int force; int force = lovar(power * 15);
int k = 0; int k = 0;
/* Immer aus der ersten Reihe nehmen */ /* Immer aus der ersten Reihe nehmen */
static const char * msgt[] = {
"ruft ein fürchterliches Unwetter über seine Feinde, doch es gab niemanden mehr, den dies treffen konnte.",
"ruft ein fürchterliches Unwetter über seine Feinde, doch der magische Regen zeigt keinen Effekt.",
"ruft ein fürchterliches Unwetter über seine Feinde, Der magischen Regen lässt alles Eisen rosten."
};
unused(sp); unused(sp);
force = lovar(power * 15);
if (!count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW-1, SELECT_ADVANCE|SELECT_FIND)) { if (!count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW-1, SELECT_ADVANCE|SELECT_FIND)) {
battlemsg(b, fi->unit, msgt[0]); message * msg = msg_message("rust_effect_0", "mage", fi->unit);
message_all(b, msg);
msg_release(msg);
return 0; return 0;
} }
@ -339,11 +335,15 @@ sp_combatrosthauch(fighter * fi, int level, double power, spell * sp)
if (k == 0) { if (k == 0) {
/* keine Waffen mehr da, die zerstört werden könnten */ /* keine Waffen mehr da, die zerstört werden könnten */
battlemsg(b, fi->unit, msgt[1]); message * msg = msg_message("rust_effect_1", "mage", fi->unit);
message_all(b, msg);
msg_release(msg);
fi->magic = 0; /* kämpft nichtmagisch weiter */ fi->magic = 0; /* kämpft nichtmagisch weiter */
level = 0; level = 0;
} else { } else {
battlemsg(b, fi->unit, msgt[2]); message * msg = msg_message("rust_effect_2", "mage", fi->unit);
message_all(b, msg);
msg_release(msg);
} }
return level; return level;
} }

View File

@ -25,6 +25,7 @@
#include <kernel/curse.h> #include <kernel/curse.h>
#include <util/nrmessage.h> #include <util/nrmessage.h>
#include <util/bsdstring.h>
struct curse_type; struct curse_type;
extern void ct_register(const struct curse_type * ct); extern void ct_register(const struct curse_type * ct);
@ -544,6 +545,7 @@ sp_summon_familiar(castorder *co)
direction_t d; direction_t d;
message * msg; message * msg;
xmlChar zText[NAMESIZE]; xmlChar zText[NAMESIZE];
size_t size;
if (get_familiar(mage) != NULL ) { if (get_familiar(mage) != NULL ) {
cmistake(mage, co->order, 199, MSG_MAGIC); cmistake(mage, co->order, 199, MSG_MAGIC);
@ -591,6 +593,7 @@ sp_summon_familiar(castorder *co)
if (rc->bonus[sk] > -5) dh++; if (rc->bonus[sk] > -5) dh++;
} }
zText[0] = 0; zText[0] = 0;
size = sizeof(zText);
for (sk=0;sk<MAXSKILLS;sk++) { for (sk=0;sk<MAXSKILLS;sk++) {
if (rc->bonus[sk] > -5) { if (rc->bonus[sk] > -5) {
dh--; dh--;
@ -598,12 +601,12 @@ sp_summon_familiar(castorder *co)
dh1 = 1; dh1 = 1;
} else { } else {
if (dh == 0) { if (dh == 0) {
strncat((char*)zText, (const char*)LOC(mage->faction->locale, "list_and"), sizeof(zText)); size -= strlcat((char*)zText, (const char*)LOC(mage->faction->locale, "list_and"), size);
} else { } else {
strncat((char*)zText, (const char*)", ", sizeof(zText)); size -= strlcat((char*)zText, (const char*)", ", size);
} }
} }
strncat((char*)zText, (const char*)skillname(sk, mage->faction->locale), sizeof(zText)); size -= strlcat((char*)zText, (const char*)skillname(sk, mage->faction->locale), size);
} }
} }
ADDMSG(&mage->faction->msgs, msg_message("familiar_describe", ADDMSG(&mage->faction->msgs, msg_message("familiar_describe",

View File

@ -6955,4 +6955,9 @@
<text locale="en">An alp died before it reached its target.</text> <text locale="en">An alp died before it reached its target.</text>
</string> </string>
<string name="unarmed">
<text locale="de">unbewaffnet</text>
<text locale="en">unarmed</text>
</string>
</strings> </strings>

View File

@ -1060,6 +1060,27 @@
<text locale="de">"Ein Alp hat sein Opfer gefunden und springt auf den Rücken von $unit($target)!"</text> <text locale="de">"Ein Alp hat sein Opfer gefunden und springt auf den Rücken von $unit($target)!"</text>
</message> </message>
<message name="rust_effect_0" section="events">
<type>
<arg name="mage" type="unit"/>
</type>
<text locale="de">"$unit($mage) ruft ein fürchterliches Unwetter über seine Feinde, doch es gab niemanden mehr, den dies treffen konnte."</text>
</message>
<message name="rust_effect_1" section="events">
<type>
<arg name="mage" type="unit"/>
</type>
<text locale="de">"$unit($mage) ruft ein fürchterliches Unwetter über seine Feinde, doch der magische Regen zeigt keinen Effekt."</text>
</message>
<message name="rust_effect_2" section="events">
<type>
<arg name="mage" type="unit"/>
</type>
<text locale="de">"$unit($mage) ruft ein fürchterliches Unwetter über seine Feinde, Der magischen Regen lässt alles Eisen rosten."</text>
</message>
<message name="summon_alp_effect" section="events"> <message name="summon_alp_effect" section="events">
<type> <type>
<arg name="mage" type="unit"/> <arg name="mage" type="unit"/>
@ -1272,13 +1293,21 @@
<text locale="fr">"$unit($unit) hit $int($hits) times and killed $int($kills) enemies."</text> <text locale="fr">"$unit($unit) hit $int($hits) times and killed $int($kills) enemies."</text>
<text locale="en">"$unit($unit) hit $int($hits) times and killed $int($kills) enemies."</text> <text locale="en">"$unit($unit) hit $int($hits) times and killed $int($kills) enemies."</text>
</message> </message>
<message name="msg_battle" section="battle"> <message name="battle_msg" section="battle">
<type> <type>
<arg name="string" type="string"/> <arg name="string" type="string"/>
</type> </type>
<text locale="de">"$string"</text> <text locale="de">"$string"</text>
<text locale="en">"$string"</text> <text locale="en">"$string"</text>
</message> </message>
<message name="battle_army" section="battle">
<type>
<arg name="index" type="int"/>
<arg name="name" type="int"/>
</type>
<text locale="de">"Heer $int($index): $name"</text>
<text locale="en">"Army $int($index): $name"</text>
</message>
<message name="sp_bloodsacrifice_effect" section="magic"> <message name="sp_bloodsacrifice_effect" section="magic">
<type> <type>
<arg name="unit" type="unit"/> <arg name="unit" type="unit"/>
@ -7599,4 +7628,34 @@
<text locale="en">"$unit($unit) is stricken by a strange disease."</text> <text locale="en">"$unit($unit) is stricken by a strange disease."</text>
</message> </message>
<message name="battle_loot" section="battle">
<type>
<arg name="unit" type="unit"/>
<arg name="amount" type="int"/>
<arg name="item" type="resource"/>
</type>
<text locale="de">"$unit($unit) erbeutet $int($amount) $resource($item,$amount)."</text>
<text locale="en">"$unit($unit) collects $int($amount) $resource($item,$amount)."</text>
</message>
<message name="peace_active" section="battle">
<type>
<arg name="region" type="region"/>
<arg name="unit" type="unit"/>
<arg name="command" type="order"/>
</type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Es ist so schön friedlich, man möchte hier niemanden angreifen."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - It's so quiet and peaceful, nobody wants to attack anybody right now."</text>
</message>
<message name="slave_active" section="battle">
<type>
<arg name="region" type="region"/>
<arg name="unit" type="unit"/>
<arg name="command" type="order"/>
</type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Diese Einheit kämpft nicht."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - This unit will not fight."</text>
</message>
</messages> </messages>