forked from github/server
push stream compatibility calls back to cr_output_region.
This commit is contained in:
parent
127cc41e8e
commit
e7fe3f8292
100
src/creport.c
100
src/creport.c
|
@ -101,7 +101,6 @@ struct locale *crtag_locale(void) {
|
|||
|
||||
static const char *crtag(const char *key)
|
||||
{
|
||||
/* TODO: those locale lookups are shit, but static kills testing */
|
||||
const char *result;
|
||||
result = LOC(crtag_locale(), key);
|
||||
return result;
|
||||
|
@ -621,86 +620,106 @@ static void cr_output_messages(FILE * F, message_list * msgs, faction * f)
|
|||
}
|
||||
|
||||
/* prints a building */
|
||||
static void
|
||||
cr_output_building(FILE * F, building * b, const unit * owner, int fno,
|
||||
faction * f)
|
||||
static void cr_output_building(struct stream *out, building *b,
|
||||
const unit *owner, int fno, faction *f)
|
||||
{
|
||||
const char *bname, *billusion;
|
||||
|
||||
fprintf(F, "BURG %d\n", b->no);
|
||||
stream_printf(out, "BURG %d\n", b->no);
|
||||
|
||||
report_building(b, &bname, &billusion);
|
||||
if (billusion) {
|
||||
fprintf(F, "\"%s\";Typ\n", translate(billusion, LOC(f->locale,
|
||||
stream_printf(out, "\"%s\";Typ\n", translate(billusion, LOC(f->locale,
|
||||
billusion)));
|
||||
if (owner && owner->faction == f) {
|
||||
fprintf(F, "\"%s\";wahrerTyp\n", translate(bname, LOC(f->locale,
|
||||
stream_printf(out, "\"%s\";wahrerTyp\n", translate(bname, LOC(f->locale,
|
||||
bname)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(F, "\"%s\";Typ\n", translate(bname, LOC(f->locale, bname)));
|
||||
stream_printf(out, "\"%s\";Typ\n", translate(bname, LOC(f->locale, bname)));
|
||||
}
|
||||
stream_printf(out, "\"%s\";Name\n", b->name);
|
||||
if (b->display && b->display[0]) {
|
||||
stream_printf(out, "\"%s\";Beschr\n", b->display);
|
||||
}
|
||||
if (b->size) {
|
||||
stream_printf(out, "%d;Groesse\n", b->size);
|
||||
}
|
||||
fprintf(F, "\"%s\";Name\n", b->name);
|
||||
if (b->display && b->display[0])
|
||||
fprintf(F, "\"%s\";Beschr\n", b->display);
|
||||
if (b->size)
|
||||
fprintf(F, "%d;Groesse\n", b->size);
|
||||
if (owner) {
|
||||
fprintf(F, "%d;Besitzer\n", owner->no);
|
||||
stream_printf(out, "%d;Besitzer\n", owner->no);
|
||||
}
|
||||
if (fno >= 0)
|
||||
fprintf(F, "%d;Partei\n", fno);
|
||||
if (b->besieged)
|
||||
fprintf(F, "%d;Belagerer\n", b->besieged);
|
||||
cr_output_curses_compat(F, f, b, TYP_BUILDING);
|
||||
if (fno >= 0) {
|
||||
stream_printf(out, "%d;Partei\n", fno);
|
||||
}
|
||||
if (b->besieged) {
|
||||
stream_printf(out, "%d;Belagerer\n", b->besieged);
|
||||
}
|
||||
cr_output_curses(out, f, b, TYP_BUILDING);
|
||||
}
|
||||
|
||||
static void cr_output_building_compat(FILE *F, building *b,
|
||||
const unit *owner, int fno, faction *f)
|
||||
{
|
||||
/* TODO: eliminate this function */
|
||||
stream strm;
|
||||
fstream_init(&strm, F);
|
||||
cr_output_building(&strm, b, owner, fno, f);
|
||||
}
|
||||
|
||||
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
|
||||
|
||||
/* prints a ship */
|
||||
static void
|
||||
cr_output_ship(FILE * F, const ship * sh, const unit * u, int fcaptain,
|
||||
const faction * f, const region * r)
|
||||
static void cr_output_ship(struct stream *out, const ship *sh, const unit *u,
|
||||
int fcaptain, const faction *f, const region *r)
|
||||
{
|
||||
int w = 0;
|
||||
assert(sh);
|
||||
fprintf(F, "SCHIFF %d\n", sh->no);
|
||||
fprintf(F, "\"%s\";Name\n", sh->name);
|
||||
stream_printf(out, "SCHIFF %d\n", sh->no);
|
||||
stream_printf(out, "\"%s\";Name\n", sh->name);
|
||||
if (sh->display && sh->display[0])
|
||||
fprintf(F, "\"%s\";Beschr\n", sh->display);
|
||||
fprintf(F, "\"%s\";Typ\n", translate(sh->type->_name,
|
||||
stream_printf(out, "\"%s\";Beschr\n", sh->display);
|
||||
stream_printf(out, "\"%s\";Typ\n", translate(sh->type->_name,
|
||||
LOC(f->locale, sh->type->_name)));
|
||||
fprintf(F, "%d;Groesse\n", sh->size);
|
||||
stream_printf(out, "%d;Groesse\n", sh->size);
|
||||
if (sh->damage) {
|
||||
int percent =
|
||||
(sh->damage * 100 + DAMAGE_SCALE - 1) / (sh->size * DAMAGE_SCALE);
|
||||
fprintf(F, "%d;Schaden\n", percent);
|
||||
stream_printf(out, "%d;Schaden\n", percent);
|
||||
}
|
||||
if (u) {
|
||||
fprintf(F, "%d;Kapitaen\n", u->no);
|
||||
stream_printf(out, "%d;Kapitaen\n", u->no);
|
||||
}
|
||||
if (fcaptain >= 0) {
|
||||
stream_printf(out, "%d;Partei\n", fcaptain);
|
||||
}
|
||||
if (fcaptain >= 0)
|
||||
fprintf(F, "%d;Partei\n", fcaptain);
|
||||
|
||||
/* calculate cargo */
|
||||
if (u && (u->faction == f || omniscient(f))) {
|
||||
int n = 0, p = 0;
|
||||
int mweight = shipcapacity(sh);
|
||||
getshipweight(sh, &n, &p);
|
||||
|
||||
fprintf(F, "%d;capacity\n", mweight);
|
||||
fprintf(F, "%d;cargo\n", n);
|
||||
fprintf(F, "%d;speed\n", shipspeed(sh, u));
|
||||
stream_printf(out, "%d;capacity\n", mweight);
|
||||
stream_printf(out, "%d;cargo\n", n);
|
||||
stream_printf(out, "%d;speed\n", shipspeed(sh, u));
|
||||
}
|
||||
/* shore */
|
||||
w = NODIRECTION;
|
||||
if (!fval(r->terrain, SEA_REGION))
|
||||
w = sh->coast;
|
||||
if (w != NODIRECTION)
|
||||
fprintf(F, "%d;Kueste\n", w);
|
||||
stream_printf(out, "%d;Kueste\n", w);
|
||||
|
||||
cr_output_curses_compat(F, f, sh, TYP_SHIP);
|
||||
cr_output_curses(out, f, sh, TYP_SHIP);
|
||||
}
|
||||
|
||||
static void cr_output_ship_compat(FILE *F, const ship *sh, const unit *u,
|
||||
int fcaptain, const faction *f, const region *r)
|
||||
{
|
||||
/* TODO: eliminate this function */
|
||||
stream strm;
|
||||
fstream_init(&strm, F);
|
||||
cr_output_ship(&strm, sh, u, fcaptain, f, r);
|
||||
}
|
||||
|
||||
static int stream_order(stream *out, const struct order *ord) {
|
||||
|
@ -798,7 +817,8 @@ void cr_output_unit(stream *out, const region * r, const faction * f,
|
|||
if (fother) {
|
||||
stream_printf(out, "%d;Anderepartei\n", fother->no);
|
||||
}
|
||||
} else if (!fval(u, UFL_ANON_FACTION)) {
|
||||
}
|
||||
else if (!fval(u, UFL_ANON_FACTION)) {
|
||||
/* OBS: anonymity overrides everything */
|
||||
/* we have no alliance, so we get duped */
|
||||
stream_printf(out, "%d;Partei\n", (fother ? fother : u->faction)->no);
|
||||
|
@ -1458,7 +1478,7 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
|
|||
const faction *sf = visible_faction(f, u);
|
||||
fno = sf->no;
|
||||
}
|
||||
cr_output_building(F, b, u, fno, f);
|
||||
cr_output_building_compat(F, b, u, fno, f);
|
||||
}
|
||||
|
||||
/* ships */
|
||||
|
@ -1470,7 +1490,7 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
|
|||
fno = sf->no;
|
||||
}
|
||||
|
||||
cr_output_ship(F, sh, u, fno, f, r);
|
||||
cr_output_ship_compat(F, sh, u, fno, f, r);
|
||||
}
|
||||
|
||||
/* visible units */
|
||||
|
|
Loading…
Reference in New Issue