forked from github/server
bufunit does not write an indent, doe not need the parameter.
This commit is contained in:
parent
42c86d122e
commit
cf46acdc6a
6 changed files with 21 additions and 21 deletions
|
@ -55,7 +55,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, 0, mode, buf, sizeof(buf));
|
||||
bufunit(f, u, mode, buf, sizeof(buf));
|
||||
tolua_pushstring(L, buf);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -923,7 +923,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, 0, seen_unit, buffer, sizeof(buffer));
|
||||
bufunit(f, u, seen_unit, buffer, sizeof(buffer));
|
||||
tolua_pushstring(L, buffer);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -695,7 +695,7 @@ nr_unit(struct stream *out, const faction * f, const unit * u, int indent, seen_
|
|||
return;
|
||||
|
||||
newline(out);
|
||||
dh = bufunit(f, u, indent, mode, buf, sizeof(buf));
|
||||
dh = bufunit(f, u, mode, buf, sizeof(buf));
|
||||
|
||||
if (u->faction == f) {
|
||||
marker = '*';
|
||||
|
|
|
@ -677,7 +677,7 @@ static size_t spskill(char *buffer, size_t size, const struct locale * lang,
|
|||
}
|
||||
|
||||
int
|
||||
bufunit(const faction * f, const unit * u, unsigned int indent, seen_mode mode, char *buf,
|
||||
bufunit(const faction * f, const unit * u, seen_mode mode, char *buf,
|
||||
size_t size)
|
||||
{
|
||||
int i, dh;
|
||||
|
@ -1055,7 +1055,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, indent, mode, buf, sizeof(buf));
|
||||
int dh = bufunit(f, u, mode, buf, sizeof(buf));
|
||||
lparagraph(SP, buf, indent,
|
||||
(char)((u->faction == f) ? '*' : (dh ? '+' : '-')));
|
||||
}
|
||||
|
|
|
@ -90,8 +90,8 @@ extern "C" {
|
|||
void register_reporttype(const char *extension, report_fun write,
|
||||
int flag);
|
||||
|
||||
int bufunit(const struct faction *f, const struct unit *u, unsigned int indent,
|
||||
seen_mode mode, char *buf, size_t size);
|
||||
int bufunit(const struct faction *f, const struct unit *u, seen_mode mode,
|
||||
char *buf, size_t size);
|
||||
|
||||
const char *trailinto(const struct region *r,
|
||||
const struct locale *lang);
|
||||
|
|
|
@ -199,56 +199,56 @@ static void test_bufunit_fstealth(CuTest *tc) {
|
|||
key_set(&u->attribs, 42, 42);
|
||||
|
||||
/* report to ourselves */
|
||||
bufunit(f1, u, 0, seen_unit, buf, sizeof(buf));
|
||||
bufunit(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, 0, seen_unit, buf, sizeof(buf));
|
||||
bufunit(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, 0, seen_unit, buf, sizeof(buf));
|
||||
bufunit(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, 0, seen_unit, buf, sizeof(buf));
|
||||
bufunit(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, 0, seen_unit, buf, sizeof(buf));
|
||||
bufunit(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, 0, seen_unit, buf, sizeof(buf));
|
||||
bufunit(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 */
|
||||
al = ally_add(&f1->allies, f2);
|
||||
al->status = HELP_FSTEALTH;
|
||||
bufunit(f2, u, 0, seen_unit, buf, sizeof(buf));
|
||||
bufunit(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, 0, seen_unit, buf, sizeof(buf));
|
||||
bufunit(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, 0, seen_unit, buf, sizeof(buf));
|
||||
bufunit(f2, u, seen_unit, buf, sizeof(buf));
|
||||
CuAssertStrEquals(tc, "Hodor (1), UFO (1), 1 human.", buf);
|
||||
|
||||
u->flags |= UFL_ANON_FACTION;
|
||||
bufunit(f2, u, 0, seen_unit, buf, sizeof(buf));
|
||||
bufunit(f2, u, seen_unit, buf, sizeof(buf));
|
||||
CuAssertStrEquals(tc, "Hodor (1), anonymous, 1 human.", buf);
|
||||
u->flags &= ~UFL_ANON_FACTION;
|
||||
|
||||
|
@ -278,20 +278,20 @@ static void test_bufunit(CuTest *tc) {
|
|||
unit_setname(u, "Hodor");
|
||||
unit_setid(u, 1);
|
||||
|
||||
bufunit(u->faction, u, 0, 0, buffer, sizeof(buffer));
|
||||
bufunit(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, 0, buffer, sizeof(buffer));
|
||||
bufunit(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, 0, buffer, sizeof(buffer));
|
||||
bufunit(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, 0, buffer, sizeof(buffer));
|
||||
bufunit(f, u, 0, buffer, sizeof(buffer));
|
||||
CuAssertStrEquals(tc, "Hodor (1), UFO (1), 1 human.", buffer);
|
||||
|
||||
test_teardown();
|
||||
|
|
Loading…
Reference in a new issue