diff --git a/src/creport.c b/src/creport.c index c2d10d1c0..d2f50e816 100644 --- a/src/creport.c +++ b/src/creport.c @@ -763,12 +763,9 @@ void cr_output_unit(stream *out, const region * r, const faction * f, stream_printf(out, "\"%s\";Beschr\n", str); } /* print faction information */ - sf = visible_faction(f, u); + sf = visible_faction(NULL, u); prefix = raceprefix(u); if (u->faction == f || omniscient(f)) { - const attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction); - const faction *otherfaction = - a_otherfaction ? get_otherfaction(a_otherfaction) : NULL; /* my own faction, full info */ const attrib *a = NULL; unit *mage; @@ -780,12 +777,12 @@ void cr_output_unit(stream *out, const region * r, const faction * f, stream_printf(out, "%d;gruppe\n", g->gid); } stream_printf(out, "%d;Partei\n", u->faction->no); - if (sf != u->faction) + if (sf && sf != u->faction) { stream_printf(out, "%d;Verkleidung\n", sf->no); - if (fval(u, UFL_ANON_FACTION)) - stream_printf(out, "%d;Parteitarnung\n", (u->flags & UFL_ANON_FACTION)!=0); - if (otherfaction && otherfaction != u->faction) { - stream_printf(out, "%d;Anderepartei\n", otherfaction->no); + stream_printf(out, "%d;Anderepartei\n", sf->no); + } + if (fval(u, UFL_ANON_FACTION)) { + stream_printf(out, "%d;Parteitarnung\n", (u->flags & UFL_ANON_FACTION) != 0); } mage = get_familiar_mage(u); if (mage) { @@ -798,17 +795,14 @@ void cr_output_unit(stream *out, const region * r, const faction * f, stream_printf(out, "%d;Parteitarnung\n", (u->flags & UFL_ANON_FACTION) != 0); } else { - const attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction); - const faction *otherfaction = - a_otherfaction ? get_otherfaction(a_otherfaction) : NULL; /* other unit. show visible faction, not u->faction */ - stream_printf(out, "%d;Partei\n", sf->no); + stream_printf(out, "%d;Partei\n", sf ? sf->no : f->no); if (sf == f) { stream_printf(out, "1;Verraeter\n"); } - if (otherfaction && otherfaction != u->faction) { + if (sf && sf != u->faction) { if (alliedunit(u, f, HELP_FSTEALTH)) { - stream_printf(out, "%d;Anderepartei\n", otherfaction->no); + stream_printf(out, "%d;Anderepartei\n", sf->no); } } } diff --git a/src/creport.test.c b/src/creport.test.c index 11701b62e..14f40268c 100644 --- a/src/creport.test.c +++ b/src/creport.test.c @@ -5,6 +5,7 @@ #include "travelthru.h" #include "keyword.h" +#include #include #include #include @@ -67,6 +68,7 @@ static void test_cr_factionstealth(CuTest *tc) { faction *f1, *f2; region *r; unit *u; + ally *al; test_setup(); mstream_init(&strm); @@ -93,6 +95,14 @@ static void test_cr_factionstealth(CuTest *tc) { CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); CuAssertIntEquals(tc, 1, cr_get_int(&strm, ";Verraeter", -1)); + al = ally_add(&f1->allies, f2); + al->status = HELP_FSTEALTH; + + cr_output_unit(&strm, u->region, f2, u, seen_unit); + CuAssertIntEquals(tc, f1->no, cr_get_int(&strm, ";Partei", -1)); + CuAssertIntEquals(tc, f2->no, cr_get_int(&strm, ";Anderepartei", -1)); + CuAssertIntEquals(tc, 1, cr_get_int(&strm, ";Verraeter", -1)); + mstream_done(&strm); test_cleanup(); }