lua write_reports() kann jetzt theoretisch einen Fehler zurückliefern, aber tut das (noch) nicht, weil ich dafür Fehlerchecks in den Report-Routinen brauche. Hier ist aber definitiv die nächste Baustelle, auch das gezielte Schreiben einzelner Reports ist wirklich an der Zeit.

This commit is contained in:
Enno Rehling 2005-04-24 21:49:51 +00:00
parent 1e17981a1f
commit 0bcac1de15
6 changed files with 48 additions and 42 deletions

View file

@ -1083,7 +1083,7 @@ get_seen_interval(region ** first, region ** last)
} }
/* main function of the creport. creates the header and traverses all regions */ /* main function of the creport. creates the header and traverses all regions */
void int
report_computer(FILE * F, faction * f, const faction_list * addresses, report_computer(FILE * F, faction * f, const faction_list * addresses,
const time_t report_time) const time_t report_time)
{ {
@ -1525,4 +1525,5 @@ report_computer(FILE * F, faction * f, const faction_list * addresses,
report_crtypes(F, f->locale); report_crtypes(F, f->locale);
write_translations(F); write_translations(F);
reset_translations(); reset_translations();
return 0;
} }

View file

@ -20,7 +20,7 @@ extern "C" {
struct faction_list; struct faction_list;
struct seen_region; struct seen_region;
struct faction; struct faction;
extern void report_computer(FILE * F, struct faction * f, extern int report_computer(FILE * F, struct faction * f,
const struct faction_list * addresses, const time_t report_time); const struct faction_list * addresses, const time_t report_time);
extern void creport_cleanup(void); extern void creport_cleanup(void);
extern void creport_init(void); extern void creport_init(void);

View file

@ -1575,7 +1575,7 @@ buildingmaintenance(const building * b, const resource_type * rtype)
return cost; return cost;
} }
static void static int
order_template(FILE * F, faction * f) order_template(FILE * F, faction * f)
{ {
region *r; region *r;
@ -1690,6 +1690,7 @@ order_template(FILE * F, faction * f)
sprintf(buf, LOC(f->locale, parameters[P_NEXT])); sprintf(buf, LOC(f->locale, parameters[P_NEXT]));
rps_nowrap(F, buf); rps_nowrap(F, buf);
rnl(F); rnl(F);
return 0;
} }
static void static void
@ -1978,7 +1979,7 @@ report_building(FILE *F, const region * r, const building * b, const faction * f
rpunit(F, f, u, 6, mode); rpunit(F, f, u, 6, mode);
} }
static void static int
report(FILE *F, faction * f, const faction_list * addresses, report(FILE *F, faction * f, const faction_list * addresses,
const char * pzTime) const char * pzTime)
{ {
@ -2408,6 +2409,7 @@ report(FILE *F, faction * f, const faction_list * addresses,
list_address(F, f, addresses); list_address(F, f, addresses);
} }
} }
return 0;
} }
FILE * FILE *
@ -2685,7 +2687,7 @@ struct fsee {
} * see; } * see;
} * fsee[FMAXHASH]; } * fsee[FMAXHASH];
void int
reports(void) reports(void)
{ {
faction *f; faction *f;
@ -2741,9 +2743,10 @@ reports(void)
sprintf(buf, "%s/%d-%s.nr", reportpath(), turn, factionid(f)); sprintf(buf, "%s/%d-%s.nr", reportpath(), turn, factionid(f));
F = cfopen(buf, "wt"); F = cfopen(buf, "wt");
if (F) { if (F) {
report(F, f, addresses, pzTime); int status = report(F, f, addresses, pzTime);
fclose(F); fclose(F);
gotit = true; gotit = true;
if (status!=0) return status; /* catch errors */
} }
} }
/* CR schreiben: */ /* CR schreiben: */
@ -2751,9 +2754,10 @@ reports(void)
sprintf(buf, "%s/%d-%s.cr", reportpath(), turn, factionid(f)); sprintf(buf, "%s/%d-%s.cr", reportpath(), turn, factionid(f));
F = cfopen(buf, "wt"); F = cfopen(buf, "wt");
if (F) { if (F) {
report_computer(F, f, addresses, ltime); int status = report_computer(F, f, addresses, ltime);
fclose(F); fclose(F);
gotit = true; gotit = true;
if (status!=0) return status; /* catch errors */
} }
} }
/* ZV schreiben: */ /* ZV schreiben: */
@ -2761,8 +2765,9 @@ reports(void)
sprintf(buf, "%s/%d-%s.txt", reportpath(), turn, factionid(f)); sprintf(buf, "%s/%d-%s.txt", reportpath(), turn, factionid(f));
F = cfopen(buf, "wt"); F = cfopen(buf, "wt");
if (F) { if (F) {
order_template(F, f); int status = order_template(F, f);
fclose(F); fclose(F);
if (status!=0) return status; /* catch errors */
} }
} }
if (f->no > 0 && f->email && BAT) { if (f->no > 0 && f->email && BAT) {
@ -2895,6 +2900,7 @@ reports(void)
closebatch(BAT); closebatch(BAT);
current_faction = NULL; current_faction = NULL;
seen_done(); seen_done();
return 0;
} }
void void
@ -3024,7 +3030,7 @@ typedef struct summary {
} summary; } summary;
summary * summary *
make_summary(boolean count_new) make_summary(void)
{ {
faction *f; faction *f;
region *r; region *r;
@ -3045,7 +3051,13 @@ make_summary(boolean count_new)
f->nregions = 0; f->nregions = 0;
f->num_total = 0; f->num_total = 0;
f->money = 0; f->money = 0;
if (f->alive && (count_new || f->age > 0)) s->factions++; if (f->alive && f->units) {
s->factions++;
/* Problem mit Monsterpartei ... */
if (f->no!=MONSTER_FACTION) {
s->factionrace[old_race(f->race)]++;
}
}
} }
/* Alles zählen */ /* Alles zählen */
@ -3142,13 +3154,6 @@ make_summary(boolean count_new)
} }
} }
/* jetzt noch parteienweise zählen */
/* Problem mit Monsterpartei ... */
for (f = factions; f; f = f->next) if (f->no!=MONSTER_FACTION) {
if (f->alive && (count_new || f->age > 0)) {
s->factionrace[old_race(f->race)]++;
}
}
return s; return s;
} }

View file

@ -46,13 +46,13 @@ const char *hp_status(const struct unit * u);
extern void spskill(const struct locale * lang, const struct unit * u, skill_t sk, int *dh, int days); /* mapper */ extern void spskill(const struct locale * lang, const struct unit * u, skill_t sk, int *dh, int days); /* mapper */
extern void spunit(struct strlist ** SP, const struct faction * f, const struct unit * u, int indent, int mode); extern void spunit(struct strlist ** SP, const struct faction * f, const struct unit * u, int indent, int mode);
void reports(void); int reports(void);
extern const struct unit *ucansee(const struct faction *f, const struct unit *u, const struct unit *x); extern const struct unit *ucansee(const struct faction *f, const struct unit *u, const struct unit *x);
struct summary; struct summary;
extern void report_summary(struct summary * n, struct summary * o, boolean full); extern void report_summary(struct summary * n, struct summary * o, boolean full);
extern struct summary * make_summary(boolean count_new); extern struct summary * make_summary();
int hat_in_region(item_t itm, struct region * r, struct faction * f); int hat_in_region(item_t itm, struct region * r, struct faction * f);

View file

@ -285,7 +285,7 @@ processturn(char *filename)
#ifdef SHORTPWDS #ifdef SHORTPWDS
readshortpwds("passwords"); readshortpwds("passwords");
#endif #endif
begin = make_summary(false); begin = make_summary();
printf(" - Korrekturen Runde %d\n", turn); printf(" - Korrekturen Runde %d\n", turn);
korrektur(); korrektur();
turn++; turn++;
@ -310,7 +310,7 @@ processturn(char *filename)
free_units(); free_units();
puts(" - Beseitige leere Parteien"); puts(" - Beseitige leere Parteien");
remove_empty_factions(true); remove_empty_factions(true);
end = make_summary(true); end = make_summary();
report_summary(end, begin, false); report_summary(end, begin, false);
report_summary(end, begin, true); report_summary(end, begin, true);
free(end); free(end);

View file

@ -1,24 +1,24 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<buildings> <buildings>
<building name="illusioncastle" capacity="0" maxcapacity="0" maxsize="0" nobuild="yes" auraregen="1.00"/> <building name="illusioncastle" capacity="0" maxcapacity="0" maxsize="0" nobuild="yes"/>
<building name="xmas_exit" maxsize="10" maxcapacity="2" nobuild="yes" nodestroy="yes" unique="yes" auraregen="1.00"/> <building name="xmas_exit" maxsize="10" maxcapacity="2" nobuild="yes" nodestroy="yes" unique="yes"/>
<building name="caldera" capacity="1" nodestroy="yes" nobuild="yes" auraregen="1.00"/> <building name="caldera" capacity="1" nodestroy="yes" nobuild="yes"/>
<building name="genericbuilding" maxsize="1" nobuild="yes" auraregen="1.00"/> <building name="genericbuilding" maxsize="1" nobuild="yes"/>
<building name="artacademy" maxsize="100" nobuild="yes" nodestroy="yes" unique="yes" auraregen="1.00"/> <building name="artacademy" maxsize="100" nobuild="yes" nodestroy="yes" unique="yes"/>
<building name="artsculpture" maxsize="100" nobuild="yes" nodestroy="yes" unique="yes" auraregen="1.00"/> <building name="artsculpture" maxsize="100" nobuild="yes" nodestroy="yes" unique="yes"/>
<building name="blessedstonecircle" maxcapacity="3" maxsize="100" nobuild="yes" magic="yes" magres="60" magresbonus="30" auraregen="1.50"> <building name="blessedstonecircle" maxcapacity="3" maxsize="100" nobuild="yes" magic="yes" magres="60" magresbonus="30" auraregen="1.50">
<construction skill="sk_building" minskill="2" reqsize="100" maxsize="100"> <construction skill="sk_building" minskill="2" reqsize="100" maxsize="100">
<requirement type="log" recycle="0.5" quantity="500"/> <requirement type="log" recycle="0.5" quantity="500"/>
<requirement type="stone" recycle="0.5" quantity="500"/> <requirement type="stone" recycle="0.5" quantity="500"/>
</construction> </construction>
</building> </building>
<building name="stonecircle" maxsize="100" auraregen="1.00"> <building name="stonecircle" maxsize="100">
<construction skill="sk_building" minskill="2" reqsize="100" maxsize="100"> <construction skill="sk_building" minskill="2" reqsize="100" maxsize="100">
<requirement type="log" recycle="0.5" quantity="500"/> <requirement type="log" recycle="0.5" quantity="500"/>
<requirement type="stone" recycle="0.5" quantity="500"/> <requirement type="stone" recycle="0.5" quantity="500"/>
</construction> </construction>
</building> </building>
<building name="inn" capacity="1" auraregen="1.00"> <building name="inn" capacity="1">
<maintenance type="money" amount="5" variable="yes" vital="yes"/> <maintenance type="money" amount="5" variable="yes" vital="yes"/>
<construction skill="sk_building" minskill="2" reqsize="10"> <construction skill="sk_building" minskill="2" reqsize="10">
<requirement type="iron" recycle="0.5" quantity="10"/> <requirement type="iron" recycle="0.5" quantity="10"/>
@ -27,7 +27,7 @@
<requirement type="money" quantity="2000"/> <requirement type="money" quantity="2000"/>
</construction> </construction>
</building> </building>
<building name="tunnel" capacity="1" maxsize="100" auraregen="1.00"> <building name="tunnel" capacity="1" maxsize="100">
<maintenance type="stone" recycle="0.5" amount="2"/> <maintenance type="stone" recycle="0.5" amount="2"/>
<maintenance type="money" amount="100" vital="yes"/> <maintenance type="money" amount="100" vital="yes"/>
<construction skill="sk_building" minskill="6" reqsize="100" maxsize="100"> <construction skill="sk_building" minskill="6" reqsize="100" maxsize="100">
@ -37,7 +37,7 @@
<requirement type="money" quantity="30000"/> <requirement type="money" quantity="30000"/>
</construction> </construction>
</building> </building>
<building name="caravan" capacity="1" maxsize="10" auraregen="1.00"> <building name="caravan" capacity="1" maxsize="10">
<maintenance type="horse" amount="2"/> <maintenance type="horse" amount="2"/>
<maintenance type="money" amount="3000" vital="yes"/> <maintenance type="money" amount="3000" vital="yes"/>
<construction skill="sk_building" minskill="2" reqsize="10" maxsize="10"> <construction skill="sk_building" minskill="2" reqsize="10" maxsize="10">
@ -47,7 +47,7 @@
<requirement type="money" quantity="5000"/> <requirement type="money" quantity="5000"/>
</construction> </construction>
</building> </building>
<building name="dam" capacity="1" maxsize="50" auraregen="1.00"> <building name="dam" capacity="1" maxsize="50">
<maintenance type="log" recycle="0.5" amount="3"/> <maintenance type="log" recycle="0.5" amount="3"/>
<maintenance type="money" amount="1000" vital="yes"/> <maintenance type="money" amount="1000" vital="yes"/>
<construction skill="sk_building" minskill="4" reqsize="50" maxsize="50"> <construction skill="sk_building" minskill="4" reqsize="50" maxsize="50">
@ -57,7 +57,7 @@
<requirement type="money" quantity="25000"/> <requirement type="money" quantity="25000"/>
</construction> </construction>
</building> </building>
<building name="monument" capacity="1" auraregen="1.00"> <building name="monument" capacity="1">
<construction skill="sk_building" minskill="4" reqsize="1"> <construction skill="sk_building" minskill="4" reqsize="1">
<requirement type="log" recycle="0.5" quantity="1"/> <requirement type="log" recycle="0.5" quantity="1"/>
<requirement type="stone" recycle="0.5" quantity="1"/> <requirement type="stone" recycle="0.5" quantity="1"/>
@ -65,7 +65,7 @@
<requirement type="money" quantity="400"/> <requirement type="money" quantity="400"/>
</construction> </construction>
</building> </building>
<building name="stables" capacity="1" auraregen="1.00"> <building name="stables" capacity="1">
<maintenance type="money" amount="150" vital="yes"/> <maintenance type="money" amount="150" vital="yes"/>
<construction skill="sk_building" minskill="2" reqsize="1"> <construction skill="sk_building" minskill="2" reqsize="1">
<requirement type="log" recycle="0.5" quantity="4"/> <requirement type="log" recycle="0.5" quantity="4"/>
@ -74,7 +74,7 @@
<requirement type="money" quantity="100"/> <requirement type="money" quantity="100"/>
</construction> </construction>
</building> </building>
<building name="sawmill" capacity="1" auraregen="1.00"> <building name="sawmill" capacity="1">
<maintenance type="money" amount="250" vital="yes"/> <maintenance type="money" amount="250" vital="yes"/>
<construction skill="sk_building" minskill="3" reqsize="1"> <construction skill="sk_building" minskill="3" reqsize="1">
<requirement type="log" recycle="0.5" quantity="5"/> <requirement type="log" recycle="0.5" quantity="5"/>
@ -83,7 +83,7 @@
<requirement type="money" quantity="200"/> <requirement type="money" quantity="200"/>
</construction> </construction>
</building> </building>
<building name="smithy" capacity="1" auraregen="1.00"> <building name="smithy" capacity="1">
<function name="init" value="init_smithy"/> <function name="init" value="init_smithy"/>
<maintenance type="money" amount="300" vital="yes"/> <maintenance type="money" amount="300" vital="yes"/>
<maintenance type="log" recycle="0.5" amount="1"/> <maintenance type="log" recycle="0.5" amount="1"/>
@ -105,7 +105,7 @@
<requirement type="money" quantity="25000"/> <requirement type="money" quantity="25000"/>
</construction> </construction>
</building> </building>
<building name="academy" maxcapacity="25" maxsize="25" auraregen="1.00"> <building name="academy" maxcapacity="25" maxsize="25">
<maintenance type="money" amount="1000" vital="yes"/> <maintenance type="money" amount="1000" vital="yes"/>
<construction skill="sk_building" minskill="3" reqsize="25" maxsize="25"> <construction skill="sk_building" minskill="3" reqsize="25" maxsize="25">
<requirement type="log" recycle="0.5" quantity="125"/> <requirement type="log" recycle="0.5" quantity="125"/>
@ -114,7 +114,7 @@
<requirement type="money" quantity="12500"/> <requirement type="money" quantity="12500"/>
</construction> </construction>
</building> </building>
<building name="harbour" capacity="1" maxcapacity="25" maxsize="25" auraregen="1.00"> <building name="harbour" capacity="1" maxcapacity="25" maxsize="25">
<maintenance type="money" amount="250" vital="yes"/> <maintenance type="money" amount="250" vital="yes"/>
<construction skill="sk_building" minskill="3" reqsize="25" maxsize="25"> <construction skill="sk_building" minskill="3" reqsize="25" maxsize="25">
<requirement type="log" recycle="0.5" quantity="125"/> <requirement type="log" recycle="0.5" quantity="125"/>
@ -122,7 +122,7 @@
<requirement type="money" quantity="6250"/> <requirement type="money" quantity="6250"/>
</construction> </construction>
</building> </building>
<building name="quarry" capacity="1" auraregen="1.00"> <building name="quarry" capacity="1">
<maintenance type="money" amount="250" vital="yes"/> <maintenance type="money" amount="250" vital="yes"/>
<construction skill="sk_building" minskill="2" reqsize="1"> <construction skill="sk_building" minskill="2" reqsize="1">
<requirement type="iron" recycle="0.5" quantity="1"/> <requirement type="iron" recycle="0.5" quantity="1"/>
@ -131,7 +131,7 @@
<requirement type="money" quantity="250"/> <requirement type="money" quantity="250"/>
</construction> </construction>
</building> </building>
<building name="mine" capacity="1" auraregen="1.00"> <building name="mine" capacity="1">
<maintenance type="money" amount="500" vital="yes"/> <maintenance type="money" amount="500" vital="yes"/>
<construction skill="sk_building" minskill="4" reqsize="1"> <construction skill="sk_building" minskill="4" reqsize="1">
<requirement type="iron" recycle="0.5" quantity="1"/> <requirement type="iron" recycle="0.5" quantity="1"/>
@ -140,7 +140,7 @@
<requirement type="money" quantity="250"/> <requirement type="money" quantity="250"/>
</construction> </construction>
</building> </building>
<building name="lighthouse" capacity="1" maxcapacity="4" auraregen="1.00"> <building name="lighthouse" capacity="1" maxcapacity="4">
<maintenance type="money" amount="100" vital="yes"/> <maintenance type="money" amount="100" vital="yes"/>
<construction skill="sk_building" minskill="3" reqsize="1"> <construction skill="sk_building" minskill="3" reqsize="1">
<requirement type="iron" recycle="0.5" quantity="1"/> <requirement type="iron" recycle="0.5" quantity="1"/>