diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index c24aefe9d..1c1c98060 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -2817,130 +2817,130 @@ init_reports(void) int reports(void) { - faction *f; - FILE *shfp, *BAT; - time_t ltime = time(NULL); + faction *f; + FILE *shfp, *BAT; + time_t ltime = time(NULL); const char * str; int retval = 0; nmr_warnings(); - report_donations(); - remove_empty_units(); + report_donations(); + remove_empty_units(); BAT = openbatch(); for (f = factions; f; f = f->next) { - int error = write_reports(f, ltime); - if (error) retval = error; + if (f->no != MONSTER_FACTION) { + int error = write_reports(f, ltime); + if (error) retval = error; + if (!nosh && f->email && BAT) { + sprintf(buf, "%s/%s.sh", reportpath(), factionid(f)); + shfp = fopen(buf, "w"); + fprintf(shfp,"#!/bin/sh\n\nPATH=%s\n\n",MailitPath()); + fprintf(shfp,"if [ $# -ge 1 ]; then\n"); + fprintf(shfp,"\taddr=$1\n"); + fprintf(shfp,"else\n"); + fprintf(shfp,"\taddr=%s\n", f->email); + fprintf(shfp,"fi\n\n"); + + fprintf(BAT, "\n\ndate;echo %s\n", f->email); - if (f->no > 0 && f->email && BAT) { - sprintf(buf, "%s/%s.sh", reportpath(), factionid(f)); - shfp = fopen(buf, "w"); - fprintf(shfp,"#!/bin/sh\n\nPATH=%s\n\n",MailitPath()); - fprintf(shfp,"if [ $# -ge 1 ]; then\n"); - fprintf(shfp,"\taddr=$1\n"); - fprintf(shfp,"else\n"); - fprintf(shfp,"\taddr=%s\n", f->email); - fprintf(shfp,"fi\n\n"); + if (f->options & REPORT_ZIP) { - fprintf(BAT, "\n\ndate;echo %s\n", f->email); - - if (f->no > 0 && f->options & REPORT_ZIP) { - - if(f->age == 1) { + if(f->age == 1) { #if KEEP_UNZIPPED == 1 - fprintf(BAT, "ls %d-%s.nr %d-%s.txt %d-%s.cr | zip -j -9 -@ %d-%s.zip\n", - turn, factionid(f), - turn, factionid(f), - turn, factionid(f), - turn, factionid(f)); + fprintf(BAT, "ls %d-%s.nr %d-%s.txt %d-%s.cr | zip -j -9 -@ %d-%s.zip\n", + turn, factionid(f), + turn, factionid(f), + turn, factionid(f), + turn, factionid(f)); #else - fprintf(BAT, "ls %d-%s.nr %d-%s.txt %d-%s.cr | zip -m -j -9 -@ %d-%s.zip\n", - turn, factionid(f), - turn, factionid(f), - turn, factionid(f), - turn, factionid(f)); + fprintf(BAT, "ls %d-%s.nr %d-%s.txt %d-%s.cr | zip -m -j -9 -@ %d-%s.zip\n", + turn, factionid(f), + turn, factionid(f), + turn, factionid(f), + turn, factionid(f)); #endif - fprintf(BAT, "zip -j -9 %d-%s.zip ../res/%s/%s/welcome.txt\n", - turn, factionid(f), global.welcomepath, locale_name(f->locale)); - } else { + fprintf(BAT, "zip -j -9 %d-%s.zip ../res/%s/%s/welcome.txt\n", + turn, factionid(f), global.welcomepath, locale_name(f->locale)); + } else { #if KEEP_UNZIPPED == 1 - fprintf(BAT, "ls %d-%s.nr %d-%s.txt %d-%s.cr | zip -j -9 -@ %d-%s.zip\n", - turn, factionid(f), - turn, factionid(f), - turn, factionid(f), - turn, factionid(f)); + fprintf(BAT, "ls %d-%s.nr %d-%s.txt %d-%s.cr | zip -j -9 -@ %d-%s.zip\n", + turn, factionid(f), + turn, factionid(f), + turn, factionid(f), + turn, factionid(f)); #else - fprintf(BAT, "ls %d-%s.nr %d-%s.txt %d-%s.cr | zip -m -j -9 -@ %d-%s.zip\n", - turn, factionid(f), - turn, factionid(f), - turn, factionid(f), - turn, factionid(f)); + fprintf(BAT, "ls %d-%s.nr %d-%s.txt %d-%s.cr | zip -m -j -9 -@ %d-%s.zip\n", + turn, factionid(f), + turn, factionid(f), + turn, factionid(f), + turn, factionid(f)); #endif - } - - fprintf(shfp, "eresseamail.zipped $addr \"%s %s\" \"%d-%s.zip\" " - "%d-%s.zip\n", global.gamename, gamedate_short(f->locale), - turn, factionid(f), - turn, factionid(f)); - - } else if(f->options & REPORT_BZIP2) { - - if (f->age == 1) { - fprintf(shfp, - " \\\n\t\"text/plain\" \"Willkommen\" ../res/%s/%s/welcome.txt", global.welcomepath, locale_name(f->locale)); - } - - fprintf(BAT, "bzip2 -9v `ls %d-%s.nr %d-%s.txt %d-%s.cr`\n", - turn, factionid(f), - turn, factionid(f), - turn, factionid(f)); - - fprintf(shfp, "eresseamail.bzip2 $addr \"%s %s\"", global.gamename, gamedate_short(f->locale)); - - if (!nonr && f->options & REPORT_NR) - fprintf(shfp, - " \\\n\t\"application/x-bzip2\" \"Report\" %d-%s.nr.bz2", - turn,factionid(f)); - - if (f->options & (1 << O_ZUGVORLAGE)) - fprintf(shfp, - " \\\n\t\"application/x-bzip2\" \"Zugvorlage\" %d-%s.txt.bz2", - turn,factionid(f)); - - if (!nocr && (f->options & REPORT_CR || f->age<3)) - fprintf(shfp, - " \\\n\t\"application/x-bzip2\" \"Computer-Report\" %d-%s.cr.bz2", - turn, factionid(f)); - } else { - - fprintf(shfp, MAIL " $addr \"%s %s\"", global.gamename, gamedate_short(f->locale)); - - if (f->age == 1) { - fprintf(shfp, - " \\\n\t\"text/plain\" \"Willkommen\" ../res/%s/%s/welcome.txt", global.welcomepath, locale_name(f->locale)); - } - - if (!nonr && f->options & REPORT_NR) - fprintf(shfp, - " \\\n\t\"text/plain\" \"Report\" %d-%s.nr", - turn, factionid(f)); - - if (f->options & (1 << O_ZUGVORLAGE)) - fprintf(shfp, - " \\\n\t\"text/plain\" \"Zugvorlage\" %d-%s.txt", - turn, factionid(f)); - - if (!nocr && (f->options & REPORT_CR || f->age<3)) - fprintf(shfp, - " \\\n\t\"text/x-eressea-cr\" \"Computer-Report\" %d-%s.cr", - turn, factionid(f)); - } - - fprintf(BAT, ". %s.sh %s\n", factionid(f), f->email); - fclose(shfp); - } - } - + } + + fprintf(shfp, "eresseamail.zipped $addr \"%s %s\" \"%d-%s.zip\" " + "%d-%s.zip\n", global.gamename, gamedate_short(f->locale), + turn, factionid(f), + turn, factionid(f)); + + } else if(f->options & REPORT_BZIP2) { + + if (f->age == 1) { + fprintf(shfp, + " \\\n\t\"text/plain\" \"Willkommen\" ../res/%s/%s/welcome.txt", global.welcomepath, locale_name(f->locale)); + } + + fprintf(BAT, "bzip2 -9v `ls %d-%s.nr %d-%s.txt %d-%s.cr`\n", + turn, factionid(f), + turn, factionid(f), + turn, factionid(f)); + + fprintf(shfp, "eresseamail.bzip2 $addr \"%s %s\"", global.gamename, gamedate_short(f->locale)); + + if (!nonr && f->options & REPORT_NR) + fprintf(shfp, + " \\\n\t\"application/x-bzip2\" \"Report\" %d-%s.nr.bz2", + turn,factionid(f)); + + if (f->options & (1 << O_ZUGVORLAGE)) + fprintf(shfp, + " \\\n\t\"application/x-bzip2\" \"Zugvorlage\" %d-%s.txt.bz2", + turn,factionid(f)); + + if (!nocr && (f->options & REPORT_CR || f->age<3)) + fprintf(shfp, + " \\\n\t\"application/x-bzip2\" \"Computer-Report\" %d-%s.cr.bz2", + turn, factionid(f)); + } else { + + fprintf(shfp, MAIL " $addr \"%s %s\"", global.gamename, gamedate_short(f->locale)); + + if (f->age == 1) { + fprintf(shfp, + " \\\n\t\"text/plain\" \"Willkommen\" ../res/%s/%s/welcome.txt", global.welcomepath, locale_name(f->locale)); + } + + if (!nonr && f->options & REPORT_NR) + fprintf(shfp, + " \\\n\t\"text/plain\" \"Report\" %d-%s.nr", + turn, factionid(f)); + + if (f->options & (1 << O_ZUGVORLAGE)) + fprintf(shfp, + " \\\n\t\"text/plain\" \"Zugvorlage\" %d-%s.txt", + turn, factionid(f)); + + if (!nocr && (f->options & REPORT_CR || f->age<3)) + fprintf(shfp, + " \\\n\t\"text/x-eressea-cr\" \"Computer-Report\" %d-%s.cr", + turn, factionid(f)); + } + + fprintf(BAT, ". %s.sh %s\n", factionid(f), f->email); + fclose(shfp); + } + } + } str = get_param(global.parameters, "globalreport"); if (str!=NULL) { sprintf(buf, "%s/%s.%u.cr", reportpath(), str, turn); diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index 63ccff7a5..adf274db8 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -1553,6 +1553,7 @@ readfaction(FILE * F) log_error(("Invalid email address for faction %s: %s\n", itoa36(f->no), email)); set_email(&f->email, ""); } + free(email); rds(F, &f->passw); if (global.data_version >= OVERRIDE_VERSION) { rds(F, &f->override);