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