mapper mit logging-kram

This commit is contained in:
Enno Rehling 2002-03-03 15:43:53 +00:00
parent 1e88605982
commit 036257d208
3 changed files with 41 additions and 6 deletions

View File

@ -29,8 +29,9 @@
static FILE * log;
void
readlog(FILE * log)
log_read(const char * filename)
{
FILE * log = fopen(filename, "r");
faction **fp = &factions;
char buf[64];
@ -67,14 +68,14 @@ readlog(FILE * log)
void
log_faction(const struct faction * f)
{
fprintf(log, "FACTION %s", factionid(f));
fprintf(log, "FACTION %s\n", factionid(f));
writefaction(log, f);
}
void
log_unit(const struct unit * u)
{
fprintf(log, "UNIT %s %d %d", unitid(u), u->region->x, u->region->y);
fprintf(log, "UNIT %s %d %d\n", unitid(u), u->region->x, u->region->y);
writeunit(log, u);
}

View File

@ -13,7 +13,7 @@
without prior permission by the authors of Eressea.
*/
extern void readlog(FILE * log);
extern void log_read(const char * logname);
extern void log_region(const struct region * r);
extern void log_unit(const struct unit * r);
extern void log_faction(const struct faction * f);

View File

@ -1396,12 +1396,33 @@ makemonsters(void)
return f;
}
#include "logging.h"
static void
log_newstuff(void)
{
faction * f;
region * r;
for (f=factions;f;f=f->next) {
if (f->age==0) log_faction(f);
}
for (r=regions;r;r=r->next) {
unit * u;
if (r->age==0) log_region(r);
for (u=r->units;u;u=u->next) {
if (u->age==0) log_unit(u);
}
}
}
int
main(int argc, char *argv[])
{
int x = 0, y = 0, i;
char *s;
boolean backup = true;
boolean logging = false;
boolean readlog = false;
setlocale(LC_ALL, "");
@ -1430,6 +1451,12 @@ main(int argc, char *argv[])
maxregions = (maxregions*81+80) / 81;
break;
case 'q': quiet = true; break;
case 'l':
logging = true;
break;
case 'R':
readlog = true;
break;
case 'n':
switch (argv[i][2]) {
case 'b' : backup = false; break;
@ -1499,7 +1526,13 @@ main(int argc, char *argv[])
if (findfaction(MONSTER_FACTION)==NULL) {
makemonsters();
}
if (readlog) {
log_read("mapper.log");
}
if (logging) {
log_start("mapper.log");
log_newstuff();
}
#ifdef OLD_ITEMS
make_xref();
#endif
@ -1515,6 +1548,7 @@ main(int argc, char *argv[])
Tagged=NULL;
movearound(x, y);
if (logging) log_stop();
if (modified) {
beep();
if (yes_no(0, "Daten wurden modifiziert! Abspeichern?", 'j')) {