diff --git a/src/mapper/logging.c b/src/mapper/logging.c index c81041795..8d334d4a4 100644 --- a/src/mapper/logging.c +++ b/src/mapper/logging.c @@ -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); } @@ -97,4 +98,4 @@ log_stop(void) { fclose(log); log = NULL; -} \ No newline at end of file +} diff --git a/src/mapper/logging.h b/src/mapper/logging.h index a08f62302..4156007c3 100644 --- a/src/mapper/logging.h +++ b/src/mapper/logging.h @@ -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); diff --git a/src/mapper/mapper.c b/src/mapper/mapper.c index 323c20469..336e62ded 100644 --- a/src/mapper/mapper.c +++ b/src/mapper/mapper.c @@ -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')) {