bufunit does not write an indent, doe not need the parameter.

This commit is contained in:
Enno Rehling 2018-02-24 19:46:34 +01:00
parent 42c86d122e
commit cf46acdc6a
6 changed files with 21 additions and 21 deletions

View File

@ -55,7 +55,7 @@ static int tolua_bufunit(lua_State * L) {
if (f) { if (f) {
char buf[8192]; char buf[8192];
int mode = (int)tolua_tonumber(L, 3, (int)seen_unit); 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); tolua_pushstring(L, buf);
return 1; return 1;
} }

View File

@ -923,7 +923,7 @@ static int tolua_report_unit(lua_State * L)
char buffer[512]; char buffer[512];
unit *u = (unit *)tolua_tousertype(L, 1, 0); unit *u = (unit *)tolua_tousertype(L, 1, 0);
faction *f = (faction *)tolua_tousertype(L, 2, 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); tolua_pushstring(L, buffer);
return 1; return 1;
} }

View File

@ -695,7 +695,7 @@ nr_unit(struct stream *out, const faction * f, const unit * u, int indent, seen_
return; return;
newline(out); newline(out);
dh = bufunit(f, u, indent, mode, buf, sizeof(buf)); dh = bufunit(f, u, mode, buf, sizeof(buf));
if (u->faction == f) { if (u->faction == f) {
marker = '*'; marker = '*';

View File

@ -677,7 +677,7 @@ static size_t spskill(char *buffer, size_t size, const struct locale * lang,
} }
int 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) size_t size)
{ {
int i, dh; int i, dh;
@ -1055,7 +1055,7 @@ spunit(struct strlist **SP, const struct faction *f, const unit * u, unsigned in
seen_mode mode) seen_mode mode)
{ {
char buf[DISPLAYSIZE]; 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, lparagraph(SP, buf, indent,
(char)((u->faction == f) ? '*' : (dh ? '+' : '-'))); (char)((u->faction == f) ? '*' : (dh ? '+' : '-')));
} }

View File

@ -90,8 +90,8 @@ extern "C" {
void register_reporttype(const char *extension, report_fun write, void register_reporttype(const char *extension, report_fun write,
int flag); int flag);
int bufunit(const struct faction *f, const struct unit *u, unsigned int indent, int bufunit(const struct faction *f, const struct unit *u, seen_mode mode,
seen_mode mode, char *buf, size_t size); char *buf, size_t size);
const char *trailinto(const struct region *r, const char *trailinto(const struct region *r,
const struct locale *lang); const struct locale *lang);

View File

@ -199,56 +199,56 @@ static void test_bufunit_fstealth(CuTest *tc) {
key_set(&u->attribs, 42, 42); key_set(&u->attribs, 42, 42);
/* report to ourselves */ /* 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); CuAssertStrEquals(tc, "Hodor (1), 1 human, aggressive.", buf);
/* ... also when we are anonymous */ /* ... also when we are anonymous */
u->flags |= UFL_ANON_FACTION; 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); CuAssertStrEquals(tc, "Hodor (1), anonymous, 1 human, aggressive.", buf);
u->flags &= ~UFL_ANON_FACTION; u->flags &= ~UFL_ANON_FACTION;
/* we see that our unit is cloaked */ /* we see that our unit is cloaked */
set_factionstealth(u, f2); set_factionstealth(u, f2);
CuAssertPtrNotNull(tc, u->attribs); 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); CuAssertStrEquals(tc, "Hodor (1), TWW (2), 1 human, aggressive.", buf);
/* ... also when we are anonymous */ /* ... also when we are anonymous */
u->flags |= UFL_ANON_FACTION; 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); CuAssertStrEquals(tc, "Hodor (1), anonymous, 1 human, aggressive.", buf);
u->flags &= ~UFL_ANON_FACTION; u->flags &= ~UFL_ANON_FACTION;
/* we can see that someone is presenting as us */ /* 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); CuAssertStrEquals(tc, "Hodor (1), TWW (2), 1 human.", buf);
/* ... but not if they are anonymous */ /* ... but not if they are anonymous */
u->flags |= UFL_ANON_FACTION; 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); CuAssertStrEquals(tc, "Hodor (1), anonymous, 1 human.", buf);
u->flags &= ~UFL_ANON_FACTION; u->flags &= ~UFL_ANON_FACTION;
/* we see the same thing as them when we are an ally */ /* we see the same thing as them when we are an ally */
al = ally_add(&f1->allies, f2); al = ally_add(&f1->allies, f2);
al->status = HELP_FSTEALTH; 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); CuAssertStrEquals(tc, "Hodor (1), TWW (2) (UFO (1)), 1 human.", buf);
/* ... also when they are anonymous */ /* ... also when they are anonymous */
u->flags |= UFL_ANON_FACTION; 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); CuAssertStrEquals(tc, "Hodor (1), anonymous, 1 human.", buf);
u->flags &= ~UFL_ANON_FACTION; u->flags &= ~UFL_ANON_FACTION;
/* fstealth has no influence when we are allies, same results again */ /* fstealth has no influence when we are allies, same results again */
set_factionstealth(u, NULL); 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); CuAssertStrEquals(tc, "Hodor (1), UFO (1), 1 human.", buf);
u->flags |= UFL_ANON_FACTION; 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); CuAssertStrEquals(tc, "Hodor (1), anonymous, 1 human.", buf);
u->flags &= ~UFL_ANON_FACTION; u->flags &= ~UFL_ANON_FACTION;
@ -278,20 +278,20 @@ static void test_bufunit(CuTest *tc) {
unit_setname(u, "Hodor"); unit_setname(u, "Hodor");
unit_setid(u, 1); 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); CuAssertStrEquals(tc, "Hodor (1), 1 human, aggressiv.", buffer);
set_level(u, SK_ALCHEMY, 1); 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); CuAssertStrEquals(tc, "Hodor (1), 1 human, aggressiv, Talente: Alchemie 2.", buffer);
set_level(u, SK_SAILING, 1); 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); CuAssertStrEquals(tc, "Hodor (1), 1 human, aggressiv, Talente: Alchemie 2, Segeln 1.", buffer);
f = test_create_faction(NULL); f = test_create_faction(NULL);
f->locale = get_or_create_locale("de"); 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); CuAssertStrEquals(tc, "Hodor (1), UFO (1), 1 human.", buffer);
test_teardown(); test_teardown();