forked from github/server
replace bsdstring in bufunit
This commit is contained in:
parent
6c5597b054
commit
3e54d307df
15 changed files with 249 additions and 234 deletions
|
@ -62,7 +62,7 @@ static int tolua_bufunit(lua_State * L) {
|
|||
if (f) {
|
||||
char buf[8192];
|
||||
int mode = (int)tolua_tonumber(L, 3, (int)seen_unit);
|
||||
bufunit(f, u, mode, buf, sizeof(buf));
|
||||
bufunit_depr(f, u, mode, buf, sizeof(buf));
|
||||
tolua_pushstring(L, buf);
|
||||
return 1;
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ static int tolua_unit_set_id(lua_State * L)
|
|||
static int tolua_unit_get_auramax(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
lua_pushinteger(L, max_spellpoints(self->region, self));
|
||||
lua_pushinteger(L, max_spellpoints_depr(self->region, self));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -817,7 +817,7 @@ static int tolua_report_unit(lua_State * L)
|
|||
char buffer[512];
|
||||
unit *u = (unit *)tolua_tousertype(L, 1, 0);
|
||||
faction *f = (faction *)tolua_tousertype(L, 2, 0);
|
||||
bufunit(f, u, seen_unit, buffer, sizeof(buffer));
|
||||
bufunit_depr(f, u, seen_unit, buffer, sizeof(buffer));
|
||||
tolua_pushstring(L, buffer);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -917,7 +917,7 @@ void cr_output_unit(stream *out, const faction * f,
|
|||
}
|
||||
if (is_mage(u)) {
|
||||
stream_printf(out, "%d;Aura\n", get_spellpoints(u));
|
||||
stream_printf(out, "%d;Auramax\n", max_spellpoints(u->region, u));
|
||||
stream_printf(out, "%d;Auramax\n", max_spellpoints_depr(u->region, u));
|
||||
}
|
||||
/* default commands */
|
||||
stream_printf(out, "COMMANDS\n");
|
||||
|
|
|
@ -74,7 +74,7 @@ use_manacrystal(struct unit *u, const struct item_type *itype, int amount,
|
|||
return -1;
|
||||
}
|
||||
|
||||
msp = max_spellpoints(u->region, u) / 2;
|
||||
msp = max_spellpoints_depr(u->region, u) / 2;
|
||||
for (i = 0; i != amount; ++i) {
|
||||
sp += MAX(25, msp);
|
||||
change_spellpoints(u, sp);
|
||||
|
|
|
@ -62,7 +62,7 @@ int get_resource(const unit * u, const resource_type * rtype)
|
|||
return get_spellpoints(u);
|
||||
}
|
||||
if (rtype == get_resourcetype(R_PERMAURA)) {
|
||||
return max_spellpoints(u->region, u);
|
||||
return max_spellpoints_depr(u->region, u);
|
||||
}
|
||||
log_error("trying to get unknown resource '%s'.\n", rtype->_name);
|
||||
return 0;
|
||||
|
|
19
src/magic.c
19
src/magic.c
|
@ -646,7 +646,7 @@ static int use_item_aura(const region * r, const unit * u)
|
|||
return n;
|
||||
}
|
||||
|
||||
int max_spellpoints(const region * r, const unit * u)
|
||||
int max_spellpoints(const struct unit *u, const region * r)
|
||||
{
|
||||
int sk;
|
||||
double n, msp = 0;
|
||||
|
@ -654,6 +654,9 @@ int max_spellpoints(const region * r, const unit * u)
|
|||
double divisor = 1.2;
|
||||
const struct resource_type *rtype;
|
||||
|
||||
assert(u);
|
||||
if (!r) r = u->region;
|
||||
|
||||
sk = effskill(u, SK_MAGIC, r);
|
||||
msp = rc_maxaura(u_race(u)) * (pow(sk, potenz) / divisor + 1) + get_spchange(u);
|
||||
|
||||
|
@ -668,6 +671,11 @@ int max_spellpoints(const region * r, const unit * u)
|
|||
return (msp > 0) ? (int)msp : 0;
|
||||
}
|
||||
|
||||
int max_spellpoints_depr(const struct region *r, const struct unit *u)
|
||||
{
|
||||
return max_spellpoints(u, r);
|
||||
}
|
||||
|
||||
int change_maxspellpoints(unit * u, int csp)
|
||||
{
|
||||
sc_mage *m = get_mage(u);
|
||||
|
@ -675,7 +683,7 @@ int change_maxspellpoints(unit * u, int csp)
|
|||
return 0;
|
||||
}
|
||||
m->spchange += csp;
|
||||
return max_spellpoints(u->region, u);
|
||||
return max_spellpoints_depr(u->region, u);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
@ -1456,7 +1464,7 @@ void regenerate_aura(void)
|
|||
for (u = r->units; u; u = u->next) {
|
||||
if (u->number && is_mage(u)) {
|
||||
aura = get_spellpoints(u);
|
||||
auramax = max_spellpoints(r, u);
|
||||
auramax = max_spellpoints_depr(r, u);
|
||||
if (aura < auramax) {
|
||||
struct building *b = inside_building(u);
|
||||
const struct building_type *btype = building_is_active(b) ? b->type : NULL;
|
||||
|
@ -2979,6 +2987,11 @@ int cast_spell(struct castorder *co)
|
|||
return fun(co);
|
||||
}
|
||||
|
||||
const char *magic_name(magic_t mtype, const struct locale *lang)
|
||||
{
|
||||
return LOC(lang, mkname("school", magic_school[mtype]));
|
||||
}
|
||||
|
||||
static critbit_tree cb_spellbooks;
|
||||
|
||||
#define SBNAMELEN 16
|
||||
|
|
|
@ -252,7 +252,8 @@ extern "C" {
|
|||
/* setzt die Magiepunkte auf sp */
|
||||
int change_spellpoints(struct unit *u, int mp);
|
||||
/* verändert die Anzahl der Magiepunkte der Einheit um +mp */
|
||||
int max_spellpoints(const struct region *r, const struct unit *u);
|
||||
int max_spellpoints_depr(const struct region *r, const struct unit *u);
|
||||
int max_spellpoints(const struct unit *u, const struct region *r);
|
||||
/* gibt die aktuell maximal möglichen Magiepunkte der Einheit zurück */
|
||||
int change_maxspellpoints(struct unit *u, int csp);
|
||||
/* verändert die maximalen Magiepunkte einer Einheit */
|
||||
|
@ -316,6 +317,7 @@ extern "C" {
|
|||
* widersteht */
|
||||
extern struct spell * unit_getspell(struct unit *u, const char *s,
|
||||
const struct locale *lang);
|
||||
const char *magic_name(magic_t mtype, const struct locale *lang);
|
||||
|
||||
/* Sprüche in der struct region */
|
||||
/* (sind in curse) */
|
||||
|
|
|
@ -446,19 +446,19 @@ static void test_max_spellpoints(CuTest *tc) {
|
|||
test_setup();
|
||||
rc = test_create_race("human");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, 1, max_spellpoints(u->region, u));
|
||||
CuAssertIntEquals(tc, 1, max_spellpoints_depr(u->region, u));
|
||||
rc->maxaura = 100;
|
||||
CuAssertIntEquals(tc, 1, max_spellpoints(u->region, u));
|
||||
CuAssertIntEquals(tc, 1, max_spellpoints_depr(u->region, u));
|
||||
rc->maxaura = 200;
|
||||
CuAssertIntEquals(tc, 2, max_spellpoints(u->region, u));
|
||||
CuAssertIntEquals(tc, 2, max_spellpoints_depr(u->region, u));
|
||||
create_mage(u, M_GWYRRD);
|
||||
set_level(u, SK_MAGIC, 1);
|
||||
CuAssertIntEquals(tc, 3, max_spellpoints(u->region, u));
|
||||
CuAssertIntEquals(tc, 3, max_spellpoints_depr(u->region, u));
|
||||
set_level(u, SK_MAGIC, 2);
|
||||
CuAssertIntEquals(tc, 9, max_spellpoints(u->region, u));
|
||||
CuAssertIntEquals(tc, 9, max_spellpoints_depr(u->region, u));
|
||||
/* permanent aura loss: */
|
||||
CuAssertIntEquals(tc, 7, change_maxspellpoints(u, -2));
|
||||
CuAssertIntEquals(tc, 7, max_spellpoints(u->region, u));
|
||||
CuAssertIntEquals(tc, 7, max_spellpoints_depr(u->region, u));
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
|
|
|
@ -676,7 +676,7 @@ nr_unit(struct stream *out, const faction * f, const unit * u, int indent, seen_
|
|||
return;
|
||||
|
||||
newline(out);
|
||||
dh = bufunit(f, u, mode, buf, sizeof(buf));
|
||||
dh = bufunit_depr(f, u, mode, buf, sizeof(buf));
|
||||
|
||||
if (u->faction == f) {
|
||||
marker = '*';
|
||||
|
@ -2026,7 +2026,7 @@ report_plaintext(const char *filename, report_context * ctx,
|
|||
newline(out);
|
||||
sprintf(buf, "%s, %s/%s (%s)", factionname(f),
|
||||
LOC(f->locale, rc_name_s(f->race, NAME_PLURAL)),
|
||||
LOC(f->locale, mkname("school", magic_school[f->magiegebiet])), faction_getemail(f));
|
||||
magic_name(f->magiegebiet, f->locale), faction_getemail(f));
|
||||
centre(out, buf, true);
|
||||
if (f_get_alliance(f)) {
|
||||
centre(out, alliancename(f->alliance), true);
|
||||
|
|
391
src/reports.c
391
src/reports.c
|
@ -162,29 +162,37 @@ const char *combatstatus[] = {
|
|||
"status_avoid", "status_flee"
|
||||
};
|
||||
|
||||
size_t report_status(const unit * u, const struct locale *lang, char *fsbuf, size_t buflen)
|
||||
void report_status(const unit * u, const struct locale *lang, struct sbstring *sbp)
|
||||
{
|
||||
const char * status = LOC(lang, combatstatus[u->status]);
|
||||
size_t len = 0;
|
||||
|
||||
if (!status) {
|
||||
const char *lname = locale_name(lang);
|
||||
struct locale *wloc = get_locale(lname);
|
||||
|
||||
log_warning("no translation for combat status %s in %s", combatstatus[u->status], lname);
|
||||
locale_setstring(wloc, combatstatus[u->status], combatstatus[u->status] + 7);
|
||||
len = str_strlcpy(fsbuf, combatstatus[u->status] + 7, buflen);
|
||||
sbs_strcat(sbp, combatstatus[u->status] + 7);
|
||||
}
|
||||
else {
|
||||
len = str_strlcpy(fsbuf, status, buflen);
|
||||
sbs_strcat(sbp, status);
|
||||
}
|
||||
if (fval(u, UFL_NOAID)) {
|
||||
len += str_strlcat(fsbuf + len, ", ", buflen - len);
|
||||
len += str_strlcat(fsbuf + len, LOC(lang, "status_noaid"), buflen - len);
|
||||
sbs_strcat(sbp, ", ");
|
||||
sbs_strcat(sbp, LOC(lang, "status_noaid"));
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
size_t report_status_depr(const unit * u, const struct locale *lang, char *fsbuf, size_t buflen)
|
||||
{
|
||||
sbstring sbs;
|
||||
|
||||
sbs_init(&sbs, fsbuf, buflen);
|
||||
report_status(u, lang, &sbs);
|
||||
return sbs_length(&sbs);
|
||||
}
|
||||
|
||||
|
||||
const char *hp_status(const unit * u)
|
||||
{
|
||||
double p;
|
||||
|
@ -274,19 +282,19 @@ report_item(const unit * owner, const item * i, const faction * viewer,
|
|||
}
|
||||
|
||||
#define ORDERS_IN_NR 1
|
||||
static void buforder(sbstring *sbs, const order * ord, const struct locale *lang, int mode)
|
||||
static void buforder(sbstring *sbp, const order * ord, const struct locale *lang, int mode)
|
||||
{
|
||||
sbs_strcpy(sbs, ", \"");
|
||||
sbs_strcat(sbp, ", \"");
|
||||
if (mode < ORDERS_IN_NR) {
|
||||
char cmd[ORDERSIZE];
|
||||
get_command(ord, lang, cmd, sizeof(cmd));
|
||||
sbs_strcat(sbs, cmd);
|
||||
sbs_strcat(sbp, cmd);
|
||||
}
|
||||
else {
|
||||
sbs_strcat(sbs, "...");
|
||||
sbs_strcat(sbp, "...");
|
||||
}
|
||||
|
||||
sbs_strcat(sbs, "\"");
|
||||
sbs_strcat(sbp, "\"");
|
||||
}
|
||||
|
||||
static size_t buforder_depr(char *buffer, size_t size, const order * ord, const struct locale *lang, int mode) {
|
||||
|
@ -362,24 +370,24 @@ static void report_resource(resource_report * result, const resource_type *rtype
|
|||
result->level = level;
|
||||
}
|
||||
|
||||
static void bufattack(struct sbstring *sbs, const struct locale *lang, const char *name, const char *dmg) {
|
||||
sbs_strcat(sbs, LOC(lang, name));
|
||||
static void bufattack(struct sbstring *sbp, const struct locale *lang, const char *name, const char *dmg) {
|
||||
sbs_strcat(sbp, LOC(lang, name));
|
||||
if (dmg) {
|
||||
sbs_strcat(sbs, " (");
|
||||
sbs_strcat(sbs, dmg);
|
||||
sbs_strcat(sbs, ")");
|
||||
sbs_strcat(sbp, " (");
|
||||
sbs_strcat(sbp, dmg);
|
||||
sbs_strcat(sbp, ")");
|
||||
}
|
||||
}
|
||||
|
||||
void report_raceinfo(const struct race *rc, const struct locale *lang, struct sbstring *sbs)
|
||||
void report_raceinfo(const struct race *rc, const struct locale *lang, struct sbstring *sbp)
|
||||
{
|
||||
const char *info;
|
||||
int a, at_count;
|
||||
const char *name, *key;
|
||||
|
||||
name = rc_name_s(rc, NAME_SINGULAR);
|
||||
sbs_strcpy(sbs, LOC(lang, name));
|
||||
sbs_strcat(sbs, ": ");
|
||||
sbs_strcat(sbp, LOC(lang, name));
|
||||
sbs_strcat(sbp, ": ");
|
||||
|
||||
key = mkname("raceinfo", rc->_name);
|
||||
info = locale_getstring(lang, key);
|
||||
|
@ -388,36 +396,36 @@ void report_raceinfo(const struct race *rc, const struct locale *lang, struct sb
|
|||
}
|
||||
|
||||
if (info) {
|
||||
sbs_strcat(sbs, info);
|
||||
sbs_strcat(sbp, info);
|
||||
}
|
||||
|
||||
/* hp_p : Trefferpunkte */
|
||||
sbs_strcat(sbs, " ");
|
||||
sbs_strcat(sbs, str_itoa(rc->hitpoints));
|
||||
sbs_strcat(sbs, " ");
|
||||
sbs_strcat(sbs, LOC(lang, "stat_hitpoints"));
|
||||
sbs_strcat(sbp, " ");
|
||||
sbs_strcat(sbp, str_itoa(rc->hitpoints));
|
||||
sbs_strcat(sbp, " ");
|
||||
sbs_strcat(sbp, LOC(lang, "stat_hitpoints"));
|
||||
|
||||
/* b_attacke : Angriff */
|
||||
sbs_strcat(sbs, ", ");
|
||||
sbs_strcat(sbs, LOC(lang, "stat_attack"));
|
||||
sbs_strcat(sbs, ": ");
|
||||
sbs_strcat(sbs, str_itoa(rc->at_default + rc->at_bonus));
|
||||
sbs_strcat(sbp, ", ");
|
||||
sbs_strcat(sbp, LOC(lang, "stat_attack"));
|
||||
sbs_strcat(sbp, ": ");
|
||||
sbs_strcat(sbp, str_itoa(rc->at_default + rc->at_bonus));
|
||||
|
||||
/* b_defense : Verteidigung */
|
||||
sbs_strcat(sbs, ", ");
|
||||
sbs_strcat(sbs, LOC(lang, "stat_defense"));
|
||||
sbs_strcat(sbs, ": ");
|
||||
sbs_strcat(sbs, str_itoa(rc->df_default + rc->df_bonus));
|
||||
sbs_strcat(sbp, ", ");
|
||||
sbs_strcat(sbp, LOC(lang, "stat_defense"));
|
||||
sbs_strcat(sbp, ": ");
|
||||
sbs_strcat(sbp, str_itoa(rc->df_default + rc->df_bonus));
|
||||
|
||||
/* b_armor : Rüstung */
|
||||
if (rc->armor > 0) {
|
||||
sbs_strcat(sbs, ", ");
|
||||
sbs_strcat(sbs, LOC(lang, "stat_armor"));
|
||||
sbs_strcat(sbs, ": ");
|
||||
sbs_strcat(sbs, str_itoa(rc->armor));
|
||||
sbs_strcat(sbp, ", ");
|
||||
sbs_strcat(sbp, LOC(lang, "stat_armor"));
|
||||
sbs_strcat(sbp, ": ");
|
||||
sbs_strcat(sbp, str_itoa(rc->armor));
|
||||
}
|
||||
|
||||
sbs_strcat(sbs, ".");
|
||||
sbs_strcat(sbp, ".");
|
||||
|
||||
/* b_damage : Schaden */
|
||||
at_count = 0;
|
||||
|
@ -427,53 +435,53 @@ void report_raceinfo(const struct race *rc, const struct locale *lang, struct sb
|
|||
}
|
||||
}
|
||||
if (rc->battle_flags & BF_EQUIPMENT) {
|
||||
sbs_strcat(sbs, " ");
|
||||
sbs_strcat(sbs, LOC(lang, "stat_equipment"));
|
||||
sbs_strcat(sbp, " ");
|
||||
sbs_strcat(sbp, LOC(lang, "stat_equipment"));
|
||||
}
|
||||
if (rc->battle_flags & BF_RES_PIERCE) {
|
||||
sbs_strcat(sbs, " ");
|
||||
sbs_strcat(sbs, LOC(lang, "stat_pierce"));
|
||||
sbs_strcat(sbp, " ");
|
||||
sbs_strcat(sbp, LOC(lang, "stat_pierce"));
|
||||
}
|
||||
if (rc->battle_flags & BF_RES_CUT) {
|
||||
sbs_strcat(sbs, " ");
|
||||
sbs_strcat(sbs, LOC(lang, "stat_cut"));
|
||||
sbs_strcat(sbp, " ");
|
||||
sbs_strcat(sbp, LOC(lang, "stat_cut"));
|
||||
}
|
||||
if (rc->battle_flags & BF_RES_BASH) {
|
||||
sbs_strcat(sbs, " ");
|
||||
sbs_strcat(sbs, LOC(lang, "stat_bash"));
|
||||
sbs_strcat(sbp, " ");
|
||||
sbs_strcat(sbp, LOC(lang, "stat_bash"));
|
||||
}
|
||||
|
||||
sbs_strcat(sbs, " ");
|
||||
sbs_strcat(sbs, str_itoa(at_count));
|
||||
sbs_strcat(sbs, " ");
|
||||
sbs_strcat(sbs, LOC(lang, (at_count == 1) ? "stat_attack" : "stat_attacks"));
|
||||
sbs_strcat(sbp, " ");
|
||||
sbs_strcat(sbp, str_itoa(at_count));
|
||||
sbs_strcat(sbp, " ");
|
||||
sbs_strcat(sbp, LOC(lang, (at_count == 1) ? "stat_attack" : "stat_attacks"));
|
||||
|
||||
for (a = 0; a < RACE_ATTACKS; a++) {
|
||||
if (rc->attack[a].type != AT_NONE) {
|
||||
sbs_strcat(sbs, (a == 0) ? ": " : ", ");
|
||||
sbs_strcat(sbp, (a == 0) ? ": " : ", ");
|
||||
|
||||
switch (rc->attack[a].type) {
|
||||
case AT_STANDARD:
|
||||
bufattack(sbs, lang, "attack_standard", rc->def_damage);
|
||||
bufattack(sbp, lang, "attack_standard", rc->def_damage);
|
||||
break;
|
||||
case AT_NATURAL:
|
||||
bufattack(sbs, lang, "attack_natural", rc->attack[a].data.dice);
|
||||
bufattack(sbp, lang, "attack_natural", rc->attack[a].data.dice);
|
||||
break;
|
||||
case AT_SPELL:
|
||||
case AT_COMBATSPELL:
|
||||
case AT_DRAIN_ST:
|
||||
case AT_DRAIN_EXP:
|
||||
case AT_DAZZLE:
|
||||
bufattack(sbs, lang, "attack_magical", NULL);
|
||||
bufattack(sbp, lang, "attack_magical", NULL);
|
||||
break;
|
||||
case AT_STRUCTURAL:
|
||||
bufattack(sbs, lang, "attack_structural", rc->attack[a].data.dice);
|
||||
bufattack(sbp, lang, "attack_structural", rc->attack[a].data.dice);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sbs_strcat(sbs, ".");
|
||||
sbs_strcat(sbp, ".");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -582,50 +590,47 @@ report_resources(const region * r, resource_report * result, int size,
|
|||
return n;
|
||||
}
|
||||
|
||||
static size_t spskill(char *buffer, size_t size, const struct locale * lang,
|
||||
static void spskill(sbstring *sbp, const struct locale * lang,
|
||||
const struct unit * u, struct skill * sv, int *dh)
|
||||
{
|
||||
char *bufp = buffer;
|
||||
int effsk;
|
||||
|
||||
if (!u->number)
|
||||
return 0;
|
||||
if (!u->number) {
|
||||
return;
|
||||
}
|
||||
if (sv->level <= 0) {
|
||||
if (sv->old <= 0 || (u->faction->options & WANT_OPTION(O_SHOWSKCHANGE)) == 0) {
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bufp = STRLCPY(bufp, ", ", size);
|
||||
sbs_strcat(sbp, ", ");
|
||||
|
||||
if (!*dh) {
|
||||
bufp = STRLCPY(bufp, LOC(lang, "nr_skills"), size);
|
||||
bufp = STRLCPY(bufp, ": ", size);
|
||||
sbs_strcat(sbp, LOC(lang, "nr_skills"));
|
||||
sbs_strcat(sbp, ": ");
|
||||
*dh = 1;
|
||||
}
|
||||
bufp = STRLCPY(bufp, skillname(sv->id, lang), size);
|
||||
bufp = STRLCPY(bufp, " ", size);
|
||||
sbs_strcat(sbp, skillname(sv->id, lang));
|
||||
sbs_strcat(sbp, " ");
|
||||
|
||||
if (sv->id == SK_MAGIC) {
|
||||
magic_t mtype = unit_get_magic(u);
|
||||
if (mtype != M_GRAY) {
|
||||
bufp = STRLCPY(bufp,
|
||||
LOC(lang, mkname("school", magic_school[mtype])), size);
|
||||
bufp = STRLCPY(bufp, " ", size);
|
||||
sbs_strcat(sbp, magic_name(mtype, lang));
|
||||
sbs_strcat(sbp, " ");
|
||||
}
|
||||
}
|
||||
|
||||
if (sv->id == SK_STEALTH && fval(u, UFL_STEALTH)) {
|
||||
int i = u_geteffstealth(u);
|
||||
if (i >= 0) {
|
||||
if (wrptr(&bufp, &size, snprintf(bufp, size, "%d/", i)) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
sbs_strcat(sbp, str_itoa(i));
|
||||
sbs_strcat(sbp, "/");
|
||||
}
|
||||
}
|
||||
|
||||
effsk = eff_skill(u, sv, 0);
|
||||
if (wrptr(&bufp, &size, snprintf(bufp, size, "%d", effsk)) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
sbs_strcat(sbp, str_itoa(effsk));
|
||||
|
||||
if (u->faction->options & WANT_OPTION(O_SHOWSKCHANGE)) {
|
||||
int oldeff = 0;
|
||||
|
@ -639,150 +644,146 @@ static size_t spskill(char *buffer, size_t size, const struct locale * lang,
|
|||
diff = effsk - oldeff;
|
||||
|
||||
if (diff != 0) {
|
||||
if (wrptr(&bufp, &size, snprintf(bufp, size, " (%s%d)", (diff > 0) ? "+" : "", diff)) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
sbs_strcat(sbp, " (");
|
||||
sbs_strcat(sbp, (diff > 0) ? "+" : "");
|
||||
sbs_strcat(sbp, str_itoa(diff));
|
||||
sbs_strcat(sbp, ")");
|
||||
}
|
||||
}
|
||||
return bufp - buffer;
|
||||
}
|
||||
|
||||
int
|
||||
bufunit(const faction * f, const unit * u, seen_mode mode, char *buf,
|
||||
size_t size)
|
||||
static size_t spskill_depr(char *buffer, size_t size, const struct locale * lang,
|
||||
const struct unit * u, struct skill * sv, int *dh)
|
||||
{
|
||||
sbstring sbs;
|
||||
sbs_init(&sbs, buffer, size);
|
||||
spskill(&sbs, lang, u, sv, dh);
|
||||
return sbs_length(&sbs);
|
||||
}
|
||||
|
||||
void bufunit(const faction * f, const unit * u, const faction *fv,
|
||||
seen_mode mode, int getarnt, struct sbstring *sbp)
|
||||
{
|
||||
int i, dh;
|
||||
int getarnt = fval(u, UFL_ANON_FACTION);
|
||||
const char *pzTmp, *str;
|
||||
bool isbattle = (mode == seen_battle);
|
||||
item *itm, *show = NULL;
|
||||
faction *fv;
|
||||
char *bufp = buf;
|
||||
int result = 0;
|
||||
item results[MAX_INVENTORY];
|
||||
const struct locale *lang = f->locale;
|
||||
|
||||
if (!fv) {
|
||||
fv = visible_faction(f, u);
|
||||
}
|
||||
assert(f);
|
||||
bufp = STRLCPY(bufp, unitname(u), size);
|
||||
fv = visible_faction(f, u);
|
||||
sbs_strcat(sbp, unitname(u));
|
||||
if (!isbattle) {
|
||||
if (u->faction == f) {
|
||||
if (fval(u, UFL_GROUP)) {
|
||||
group *g = get_group(u);
|
||||
if (g) {
|
||||
bufp = STRLCPY(bufp, ", ", size);
|
||||
bufp = STRLCPY(bufp, groupid(g, f), size);
|
||||
sbs_strcat(sbp, ", ");
|
||||
sbs_strcat(sbp, groupid(g, f));
|
||||
}
|
||||
}
|
||||
if (getarnt) {
|
||||
bufp = STRLCPY(bufp, ", ", size);
|
||||
bufp = STRLCPY(bufp, LOC(lang, "anonymous"), size);
|
||||
sbs_strcat(sbp, ", ");
|
||||
sbs_strcat(sbp, LOC(lang, "anonymous"));
|
||||
}
|
||||
else if (u->attribs) {
|
||||
faction *otherf = get_otherfaction(u);
|
||||
if (otherf) {
|
||||
bufp = STRLCPY(bufp, ", ", size);
|
||||
bufp = STRLCPY(bufp, factionname(otherf), size);
|
||||
sbs_strcat(sbp, ", ");
|
||||
sbs_strcat(sbp, factionname(otherf));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (getarnt) {
|
||||
bufp = STRLCPY(bufp, ", ", size);
|
||||
bufp = STRLCPY(bufp, LOC(lang, "anonymous"), size);
|
||||
sbs_strcat(sbp, ", ");
|
||||
sbs_strcat(sbp, LOC(lang, "anonymous"));
|
||||
}
|
||||
else {
|
||||
if (u->attribs && alliedunit(u, f, HELP_FSTEALTH)) {
|
||||
faction *otherf = get_otherfaction(u);
|
||||
if (otherf) {
|
||||
int n = snprintf(bufp, size, ", %s (%s)",
|
||||
factionname(otherf), factionname(u->faction));
|
||||
if (wrptr(&bufp, &size, n) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
sbs_strcat(sbp, ", ");
|
||||
sbs_strcat(sbp, factionname(otherf));
|
||||
sbs_strcat(sbp, " (");
|
||||
sbs_strcat(sbp, factionname(u->faction));
|
||||
sbs_strcat(sbp, ")");
|
||||
}
|
||||
else {
|
||||
bufp = STRLCPY(bufp, ", ", size);
|
||||
bufp = STRLCPY(bufp, factionname(fv), size);
|
||||
sbs_strcat(sbp, ", ");
|
||||
sbs_strcat(sbp, factionname(fv));
|
||||
}
|
||||
}
|
||||
else {
|
||||
bufp = STRLCPY(bufp, ", ", size);
|
||||
bufp = STRLCPY(bufp, factionname(fv), size);
|
||||
sbs_strcat(sbp, ", ");
|
||||
sbs_strcat(sbp, factionname(fv));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bufp = STRLCPY(bufp, ", ", size);
|
||||
|
||||
if (wrptr(&bufp, &size, snprintf(bufp, size, "%d ", u->number)))
|
||||
WARN_STATIC_BUFFER();
|
||||
sbs_strcat(sbp, ", ");
|
||||
sbs_strcat(sbp, str_itoa(u->number));
|
||||
sbs_strcat(sbp, " ");
|
||||
|
||||
pzTmp = get_racename(u->attribs);
|
||||
if (pzTmp) {
|
||||
bufp = STRLCPY(bufp, pzTmp, size);
|
||||
sbs_strcat(sbp, pzTmp);
|
||||
if (u->faction == f && fval(u_race(u), RCF_SHAPESHIFTANY)) {
|
||||
bufp = STRLCPY(bufp, " (", size);
|
||||
bufp = STRLCPY(bufp, racename(lang, u, u_race(u)), size);
|
||||
if (size > 1) {
|
||||
strcpy(bufp++, ")");
|
||||
--size;
|
||||
}
|
||||
sbs_strcat(sbp, " (");
|
||||
sbs_strcat(sbp, racename(lang, u, u_race(u)));
|
||||
sbs_strcat(sbp, ")");
|
||||
}
|
||||
}
|
||||
else {
|
||||
const race *irace = u_irace(u);
|
||||
bufp = STRLCPY(bufp, racename(lang, u, irace), size);
|
||||
if (u->faction == f && irace != u_race(u)) {
|
||||
bufp = STRLCPY(bufp, " (", size);
|
||||
bufp = STRLCPY(bufp, racename(lang, u, u_race(u)), size);
|
||||
if (size > 1) {
|
||||
strcpy(bufp++, ")");
|
||||
--size;
|
||||
}
|
||||
const race *urace = u_race(u);
|
||||
sbs_strcat(sbp, racename(lang, u, irace));
|
||||
if (u->faction == f && irace != urace) {
|
||||
sbs_strcat(sbp, " (");
|
||||
sbs_strcat(sbp, racename(lang, u, urace));
|
||||
sbs_strcat(sbp, ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (fval(u, UFL_HERO) && (u->faction == f || omniscient(f))) {
|
||||
bufp = STRLCPY(bufp, ", ", size);
|
||||
bufp = STRLCPY(bufp, LOC(lang, "hero"), size);
|
||||
sbs_strcat(sbp, ", ");
|
||||
sbs_strcat(sbp, LOC(lang, "hero"));
|
||||
}
|
||||
/* status */
|
||||
|
||||
if (u->number && (u->faction == f || isbattle)) {
|
||||
const char *c = hp_status(u);
|
||||
c = c ? LOC(lang, c) : 0;
|
||||
bufp = STRLCPY(bufp, ", ", size);
|
||||
bufp += report_status(u, lang, bufp, size);
|
||||
sbs_strcat(sbp, ", ");
|
||||
report_status(u, lang, sbp);
|
||||
if (c || fval(u, UFL_HUNGER)) {
|
||||
bufp = STRLCPY(bufp, " (", size);
|
||||
sbs_strcat(sbp, " (");
|
||||
if (c) {
|
||||
bufp = STRLCPY(bufp, c, size);
|
||||
sbs_strcat(sbp, c);
|
||||
}
|
||||
if (fval(u, UFL_HUNGER)) {
|
||||
if (c) {
|
||||
bufp = STRLCPY(bufp, ", ", size);
|
||||
sbs_strcat(sbp, ", ");
|
||||
}
|
||||
bufp = STRLCPY(bufp, LOC(lang, "unit_hungers"), size);
|
||||
}
|
||||
if (size > 1) {
|
||||
strcpy(bufp++, ")");
|
||||
--size;
|
||||
sbs_strcat(sbp, LOC(lang, "unit_hungers"));
|
||||
}
|
||||
sbs_strcat(sbp, ")");
|
||||
}
|
||||
}
|
||||
if (is_guard(u)) {
|
||||
bufp = STRLCPY(bufp, ", ", size);
|
||||
bufp = STRLCPY(bufp, LOC(lang, "unit_guards"), size);
|
||||
sbs_strcat(sbp, ", ");
|
||||
sbs_strcat(sbp, LOC(lang, "unit_guards"));
|
||||
}
|
||||
|
||||
dh = 0;
|
||||
if (u->faction == f) {
|
||||
skill *sv;
|
||||
for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) {
|
||||
size_t bytes = spskill(bufp, size, lang, u, sv, &dh);
|
||||
assert(bytes <= INT_MAX);
|
||||
if (wrptr(&bufp, &size, (int)bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
spskill(sbp, lang, u, sv, &dh);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -801,22 +802,23 @@ bufunit(const faction * f, const unit * u, seen_mode mode, char *buf,
|
|||
const char *ic;
|
||||
int in;
|
||||
report_item(u, itm, f, &ic, NULL, &in, false);
|
||||
if (in == 0 || ic == NULL)
|
||||
if (in == 0 || ic == NULL) {
|
||||
continue;
|
||||
bufp = STRLCPY(bufp, ", ", size);
|
||||
}
|
||||
sbs_strcat(sbp, ", ");
|
||||
|
||||
if (!dh) {
|
||||
result = snprintf(bufp, size, "%s: ", LOC(lang, "nr_inventory"));
|
||||
if (wrptr(&bufp, &size, result) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
sbs_strcat(sbp, LOC(lang, "nr_inventory"));
|
||||
sbs_strcat(sbp, ": ");
|
||||
dh = 1;
|
||||
}
|
||||
if (in == 1) {
|
||||
bufp = STRLCPY(bufp, ic, size);
|
||||
sbs_strcat(sbp, ic);
|
||||
}
|
||||
else {
|
||||
if (wrptr(&bufp, &size, snprintf(bufp, size, "%d %s", in, ic)))
|
||||
WARN_STATIC_BUFFER();
|
||||
sbs_strcat(sbp, str_itoa(in));
|
||||
sbs_strcat(sbp, " ");
|
||||
sbs_strcat(sbp, ic);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -826,27 +828,26 @@ bufunit(const faction * f, const unit * u, seen_mode mode, char *buf,
|
|||
if (book) {
|
||||
selist *ql = book->spells;
|
||||
int qi, header, maxlevel = effskill(u, SK_MAGIC, 0);
|
||||
int n = snprintf(bufp, size, ". Aura %d/%d", get_spellpoints(u), max_spellpoints(u->region, u));
|
||||
if (wrptr(&bufp, &size, n) != 0) {
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
sbs_strcat(sbp, ". Aura ");
|
||||
sbs_strcat(sbp, str_itoa(get_spellpoints(u)));
|
||||
sbs_strcat(sbp, "/");
|
||||
sbs_strcat(sbp, str_itoa(max_spellpoints(u, NULL)));
|
||||
|
||||
for (header = 0, qi = 0; ql; selist_advance(&ql, &qi, 1)) {
|
||||
spellbook_entry * sbe = (spellbook_entry *)selist_get(ql, qi);
|
||||
const spell *sp = spellref_get(&sbe->spref);
|
||||
if (sbe->level <= maxlevel) {
|
||||
if (!header) {
|
||||
n = snprintf(bufp, size, ", %s: ", LOC(lang, "nr_spells"));
|
||||
sbs_strcat(sbp, ", ");
|
||||
sbs_strcat(sbp, LOC(lang, "nr_spells"));
|
||||
sbs_strcat(sbp, ": ");
|
||||
header = 1;
|
||||
}
|
||||
else {
|
||||
n = (int)str_strlcpy(bufp, ", ", size);
|
||||
}
|
||||
if (wrptr(&bufp, &size, n) != 0) {
|
||||
WARN_STATIC_BUFFER();
|
||||
sbs_strcat(sbp, ", ");
|
||||
}
|
||||
/* TODO: no need to deref the spellref here (spref->name is good) */
|
||||
bufp = STRLCPY(bufp, spell_name(sp, lang), size);
|
||||
sbs_strcat(sbp, spell_name(sp, lang));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -855,10 +856,9 @@ bufunit(const faction * f, const unit * u, seen_mode mode, char *buf,
|
|||
break;
|
||||
}
|
||||
if (i != MAXCOMBATSPELLS) {
|
||||
n = snprintf(bufp, size, ", %s: ", LOC(lang, "nr_combatspells"));
|
||||
if (wrptr(&bufp, &size, n) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
|
||||
sbs_strcat(sbp, ", ");
|
||||
sbs_strcat(sbp, LOC(lang, "nr_combatspells"));
|
||||
sbs_strcat(sbp, ": ");
|
||||
dh = 0;
|
||||
for (i = 0; i < MAXCOMBATSPELLS; i++) {
|
||||
const spell *sp;
|
||||
|
@ -866,20 +866,20 @@ bufunit(const faction * f, const unit * u, seen_mode mode, char *buf,
|
|||
dh = 1;
|
||||
}
|
||||
else {
|
||||
bufp = STRLCPY(bufp, ", ", size);
|
||||
sbs_strcat(sbp, ", ");
|
||||
}
|
||||
sp = get_combatspell(u, i);
|
||||
if (sp) {
|
||||
int sl = get_combatspelllevel(u, i);
|
||||
bufp = STRLCPY(bufp, spell_name(sp, lang), size);
|
||||
sbs_strcat(sbp, spell_name(sp, lang));
|
||||
if (sl > 0) {
|
||||
n = snprintf(bufp, size, " (%d)", sl);
|
||||
if (wrptr(&bufp, &size, n) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
sbs_strcat(sbp, "( ");
|
||||
sbs_strcat(sbp, str_itoa(sl));
|
||||
sbs_strcat(sbp, ")");
|
||||
}
|
||||
}
|
||||
else {
|
||||
bufp = STRLCPY(bufp, LOC(lang, "nr_nospells"), size);
|
||||
sbs_strcat(sbp, LOC(lang, "nr_nospells"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -890,62 +890,59 @@ bufunit(const faction * f, const unit * u, seen_mode mode, char *buf,
|
|||
for (ord = u->old_orders; ord; ord = ord->next) {
|
||||
keyword_t kwd = getkeyword(ord);
|
||||
if (is_repeated(kwd)) {
|
||||
if (printed < ORDERS_IN_NR) {
|
||||
int n = (int)buforder_depr(bufp, size, ord, u->faction->locale, printed++);
|
||||
if (wrptr(&bufp, &size, n) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
else
|
||||
if (printed >= ORDERS_IN_NR) {
|
||||
break;
|
||||
}
|
||||
buforder(sbp, ord, u->faction->locale, printed++);
|
||||
}
|
||||
}
|
||||
if (printed < ORDERS_IN_NR)
|
||||
if (printed < ORDERS_IN_NR) {
|
||||
for (ord = u->orders; ord; ord = ord->next) {
|
||||
keyword_t kwd = getkeyword(ord);
|
||||
if (is_repeated(kwd)) {
|
||||
if (printed < ORDERS_IN_NR) {
|
||||
int n = (int)buforder_depr(bufp, size, ord, lang, printed++);
|
||||
if (wrptr(&bufp, &size, n) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
else {
|
||||
if (printed >= ORDERS_IN_NR) {
|
||||
break;
|
||||
}
|
||||
buforder(sbp, ord, lang, printed++);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
i = 0;
|
||||
|
||||
str = u_description(u, lang);
|
||||
if (str) {
|
||||
bufp = STRLCPY(bufp, "; ", size);
|
||||
bufp = STRLCPY(bufp, str, size);
|
||||
sbs_strcat(sbp, "; ");
|
||||
sbs_strcat(sbp, str);
|
||||
i = str[strlen(str) - 1];
|
||||
}
|
||||
if (i != '!' && i != '?' && i != '.') {
|
||||
if (size > 1) {
|
||||
strcpy(bufp++, ".");
|
||||
--size;
|
||||
}
|
||||
sbs_strcat(sbp, ".");
|
||||
}
|
||||
pzTmp = uprivate(u);
|
||||
if (u->faction == f && pzTmp) {
|
||||
bufp = STRLCPY(bufp, " (Bem: ", size);
|
||||
bufp = STRLCPY(bufp, pzTmp, size);
|
||||
bufp = STRLCPY(bufp, ")", size);
|
||||
sbs_strcat(sbp, " (Bem: ");
|
||||
sbs_strcat(sbp, pzTmp);
|
||||
sbs_strcat(sbp, ")");
|
||||
}
|
||||
}
|
||||
|
||||
dh = 0;
|
||||
int bufunit_depr(const faction * f, const unit * u, seen_mode mode,
|
||||
char *buf, size_t size)
|
||||
{
|
||||
int getarnt = fval(u, UFL_ANON_FACTION);
|
||||
const faction * fv = visible_faction(f, u);
|
||||
sbstring sbs;
|
||||
|
||||
sbs_init(&sbs, buf, size);
|
||||
bufunit(f, u, fv, mode, getarnt, &sbs);
|
||||
if (!getarnt) {
|
||||
if (alliedfaction(f, fv, HELP_ALL)) {
|
||||
dh = 1;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (size <= 1) {
|
||||
log_warning("bufunit ran out of space after writing %u bytes.\n", (bufp - buf));
|
||||
}
|
||||
return dh;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void split_paragraph(strlist ** SP, const char *s, unsigned int indent, unsigned int width, char mark)
|
||||
|
@ -1019,7 +1016,7 @@ spunit(struct strlist **SP, const struct faction *f, const unit * u, unsigned in
|
|||
seen_mode mode)
|
||||
{
|
||||
char buf[DISPLAYSIZE];
|
||||
int dh = bufunit(f, u, mode, buf, sizeof(buf));
|
||||
int dh = bufunit_depr(f, u, mode, buf, sizeof(buf));
|
||||
lparagraph(SP, buf, indent,
|
||||
(char)((u->faction == f) ? '*' : (dh ? '+' : '-')));
|
||||
}
|
||||
|
|
|
@ -88,12 +88,15 @@ extern "C" {
|
|||
void register_reporttype(const char *extension, report_fun write,
|
||||
int flag);
|
||||
|
||||
int bufunit(const struct faction *f, const struct unit *u, seen_mode mode,
|
||||
int bufunit_depr(const struct faction *f, const struct unit *u, seen_mode mode,
|
||||
char *buf, size_t size);
|
||||
void bufunit(const struct faction * f, const struct unit * u,
|
||||
const struct faction *fv, seen_mode mode, int getarnt,
|
||||
struct sbstring *sbp);
|
||||
|
||||
const char *trailinto(const struct region *r,
|
||||
const struct locale *lang);
|
||||
size_t report_status(const struct unit *u,
|
||||
size_t report_status_depr(const struct unit *u,
|
||||
const struct locale *lang, char *buf, size_t siz);
|
||||
void report_battle_start(struct battle * b);
|
||||
|
||||
|
|
|
@ -199,55 +199,55 @@ static void test_bufunit_fstealth(CuTest *tc) {
|
|||
key_set(&u->attribs, 42, 42);
|
||||
|
||||
/* report to ourselves */
|
||||
bufunit(f1, u, seen_unit, buf, sizeof(buf));
|
||||
bufunit_depr(f1, u, seen_unit, buf, sizeof(buf));
|
||||
CuAssertStrEquals(tc, "Hodor (1), 1 human, aggressive.", buf);
|
||||
|
||||
/* ... also when we are anonymous */
|
||||
u->flags |= UFL_ANON_FACTION;
|
||||
bufunit(f1, u, seen_unit, buf, sizeof(buf));
|
||||
bufunit_depr(f1, u, seen_unit, buf, sizeof(buf));
|
||||
CuAssertStrEquals(tc, "Hodor (1), anonymous, 1 human, aggressive.", buf);
|
||||
u->flags &= ~UFL_ANON_FACTION;
|
||||
|
||||
/* we see that our unit is cloaked */
|
||||
set_factionstealth(u, f2);
|
||||
CuAssertPtrNotNull(tc, u->attribs);
|
||||
bufunit(f1, u, seen_unit, buf, sizeof(buf));
|
||||
bufunit_depr(f1, u, seen_unit, buf, sizeof(buf));
|
||||
CuAssertStrEquals(tc, "Hodor (1), TWW (2), 1 human, aggressive.", buf);
|
||||
|
||||
/* ... also when we are anonymous */
|
||||
u->flags |= UFL_ANON_FACTION;
|
||||
bufunit(f1, u, seen_unit, buf, sizeof(buf));
|
||||
bufunit_depr(f1, u, seen_unit, buf, sizeof(buf));
|
||||
CuAssertStrEquals(tc, "Hodor (1), anonymous, 1 human, aggressive.", buf);
|
||||
u->flags &= ~UFL_ANON_FACTION;
|
||||
|
||||
/* we can see that someone is presenting as us */
|
||||
bufunit(f2, u, seen_unit, buf, sizeof(buf));
|
||||
bufunit_depr(f2, u, seen_unit, buf, sizeof(buf));
|
||||
CuAssertStrEquals(tc, "Hodor (1), TWW (2), 1 human.", buf);
|
||||
|
||||
/* ... but not if they are anonymous */
|
||||
u->flags |= UFL_ANON_FACTION;
|
||||
bufunit(f2, u, seen_unit, buf, sizeof(buf));
|
||||
bufunit_depr(f2, u, seen_unit, buf, sizeof(buf));
|
||||
CuAssertStrEquals(tc, "Hodor (1), anonymous, 1 human.", buf);
|
||||
u->flags &= ~UFL_ANON_FACTION;
|
||||
|
||||
/* we see the same thing as them when we are an ally */
|
||||
ally_set(&f1->allies, f2, HELP_FSTEALTH);
|
||||
bufunit(f2, u, seen_unit, buf, sizeof(buf));
|
||||
bufunit_depr(f2, u, seen_unit, buf, sizeof(buf));
|
||||
CuAssertStrEquals(tc, "Hodor (1), TWW (2) (UFO (1)), 1 human.", buf);
|
||||
|
||||
/* ... also when they are anonymous */
|
||||
u->flags |= UFL_ANON_FACTION;
|
||||
bufunit(f2, u, seen_unit, buf, sizeof(buf));
|
||||
bufunit_depr(f2, u, seen_unit, buf, sizeof(buf));
|
||||
CuAssertStrEquals(tc, "Hodor (1), anonymous, 1 human.", buf);
|
||||
u->flags &= ~UFL_ANON_FACTION;
|
||||
|
||||
/* fstealth has no influence when we are allies, same results again */
|
||||
set_factionstealth(u, NULL);
|
||||
bufunit(f2, u, seen_unit, buf, sizeof(buf));
|
||||
bufunit_depr(f2, u, seen_unit, buf, sizeof(buf));
|
||||
CuAssertStrEquals(tc, "Hodor (1), UFO (1), 1 human.", buf);
|
||||
|
||||
u->flags |= UFL_ANON_FACTION;
|
||||
bufunit(f2, u, seen_unit, buf, sizeof(buf));
|
||||
bufunit_depr(f2, u, seen_unit, buf, sizeof(buf));
|
||||
CuAssertStrEquals(tc, "Hodor (1), anonymous, 1 human.", buf);
|
||||
u->flags &= ~UFL_ANON_FACTION;
|
||||
|
||||
|
@ -277,20 +277,20 @@ static void test_bufunit(CuTest *tc) {
|
|||
unit_setname(u, "Hodor");
|
||||
unit_setid(u, 1);
|
||||
|
||||
bufunit(u->faction, u, 0, buffer, sizeof(buffer));
|
||||
bufunit_depr(u->faction, u, 0, buffer, sizeof(buffer));
|
||||
CuAssertStrEquals(tc, "Hodor (1), 1 human, aggressiv.", buffer);
|
||||
|
||||
set_level(u, SK_ALCHEMY, 1);
|
||||
bufunit(u->faction, u, 0, buffer, sizeof(buffer));
|
||||
bufunit_depr(u->faction, u, 0, buffer, sizeof(buffer));
|
||||
CuAssertStrEquals(tc, "Hodor (1), 1 human, aggressiv, Talente: Alchemie 2.", buffer);
|
||||
|
||||
set_level(u, SK_SAILING, 1);
|
||||
bufunit(u->faction, u, 0, buffer, sizeof(buffer));
|
||||
bufunit_depr(u->faction, u, 0, buffer, sizeof(buffer));
|
||||
CuAssertStrEquals(tc, "Hodor (1), 1 human, aggressiv, Talente: Alchemie 2, Segeln 1.", buffer);
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f->locale = get_or_create_locale("de");
|
||||
bufunit(f, u, 0, buffer, sizeof(buffer));
|
||||
bufunit_depr(f, u, 0, buffer, sizeof(buffer));
|
||||
CuAssertStrEquals(tc, "Hodor (1), UFO (1), 1 human.", buffer);
|
||||
|
||||
test_teardown();
|
||||
|
|
|
@ -3790,7 +3790,7 @@ static int sp_migranten(castorder * co)
|
|||
return 0;
|
||||
}
|
||||
/* maximal Stufe Personen */
|
||||
if (target->number > cast_level || target->number > max_spellpoints(r, mage)) {
|
||||
if (target->number > cast_level || target->number > max_spellpoints_depr(r, mage)) {
|
||||
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order,
|
||||
"spellfail_toomanytargets", ""));
|
||||
return 0;
|
||||
|
|
|
@ -67,7 +67,7 @@ void spy_message(int spy, const unit * u, const unit * target)
|
|||
{
|
||||
char status[32];
|
||||
|
||||
report_status(target, u->faction->locale, status, sizeof(status));
|
||||
report_status_depr(target, u->faction->locale, status, sizeof(status));
|
||||
|
||||
ADDMSG(&u->faction->msgs, msg_message("spyreport", "spy target status", u,
|
||||
target, status));
|
||||
|
|
|
@ -67,7 +67,7 @@ static void do_shock(unit * u, const char *reason)
|
|||
|
||||
/* Aura - Verlust */
|
||||
if (is_mage(u)) {
|
||||
int aura = max_spellpoints(u->region, u) / 10;
|
||||
int aura = max_spellpoints_depr(u->region, u) / 10;
|
||||
int now = get_spellpoints(u);
|
||||
if (now > aura) {
|
||||
set_spellpoints(u, aura);
|
||||
|
|
Loading…
Reference in a new issue