forked from github/server
write a log of dead factions.
This commit is contained in:
parent
5a1c6d87ca
commit
fa1e81f6ac
|
@ -4,6 +4,7 @@
|
|||
#include "kernel/calendar.h"
|
||||
#include "kernel/config.h"
|
||||
#include "kernel/curse.h"
|
||||
#include "kernel/faction.h"
|
||||
#include "kernel/building.h"
|
||||
#include "kernel/equipment.h"
|
||||
#include "kernel/item.h"
|
||||
|
@ -37,22 +38,17 @@
|
|||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* manually free() everything at exit? */
|
||||
#undef CLEANUP_CODE
|
||||
|
||||
void game_done(void)
|
||||
{
|
||||
#undef CLEANUP_CODE
|
||||
log_dead_factions();
|
||||
|
||||
#ifdef CLEANUP_CODE
|
||||
/* Diese Routine enfernt allen allokierten Speicher wieder. Das ist nur
|
||||
* zum Debugging interessant, wenn man Leak Detection hat, und nach
|
||||
* nicht freigegebenem Speicher sucht, der nicht bis zum Ende benoetigt
|
||||
* wird (temporaere Hilsstrukturen) */
|
||||
|
||||
free_game();
|
||||
|
||||
free_gamedata();
|
||||
creport_cleanup();
|
||||
#ifdef REPORT_FORMAT_NR
|
||||
report_cleanup();
|
||||
#endif
|
||||
#endif
|
||||
calendar_cleanup();
|
||||
free_functions();
|
||||
free_config();
|
||||
|
@ -60,6 +56,7 @@ void game_done(void)
|
|||
free_locales();
|
||||
kernel_done();
|
||||
dblib_close();
|
||||
#endif
|
||||
}
|
||||
|
||||
void game_init(void)
|
||||
|
|
|
@ -778,8 +778,8 @@ void free_gamedata(void)
|
|||
free(forbidden_ids);
|
||||
forbidden_ids = NULL;
|
||||
|
||||
free_donations();
|
||||
free_factions();
|
||||
free_donations();
|
||||
free_units();
|
||||
free_regions();
|
||||
free_borders();
|
||||
|
|
|
@ -738,7 +738,6 @@ void remove_empty_factions(void)
|
|||
faction *f = *fp;
|
||||
|
||||
if (!(f->_alive && f->units!=NULL) && !fval(f, FFL_NOIDLEOUT)) {
|
||||
log_debug("dead: %s", factionname(f));
|
||||
destroyfaction(fp);
|
||||
}
|
||||
else {
|
||||
|
@ -876,6 +875,27 @@ int writepasswd(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void log_dead_factions(void)
|
||||
{
|
||||
if (dead_factions) {
|
||||
const char *logname = config_get("game.deadlog");
|
||||
if (logname) {
|
||||
FILE *F;
|
||||
char path[PATH_MAX];
|
||||
|
||||
join_path(basepath(), logname, path, sizeof(path));
|
||||
F = fopen(path, "at");
|
||||
if (F) {
|
||||
faction *f;
|
||||
for (f = dead_factions; f; f = f->next) {
|
||||
fprintf(F, "%d\t%d\t%d\t%s\t%s\t%s\n", turn, f->lastorders, f->age, itoa36(f->no), f->email, f->name);
|
||||
}
|
||||
fclose(F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void free_factions(void) {
|
||||
#ifdef DMAXHASH
|
||||
int i;
|
||||
|
|
|
@ -133,6 +133,7 @@ extern "C" {
|
|||
|
||||
void renumber_faction(faction * f, int no);
|
||||
void free_factions(void);
|
||||
void log_dead_factions(void);
|
||||
void remove_empty_factions(void);
|
||||
|
||||
void update_interval(struct faction *f, struct region *r);
|
||||
|
|
|
@ -82,6 +82,7 @@ static void load_inifile(void)
|
|||
|
||||
static const char * valid_keys[] = {
|
||||
"game.id",
|
||||
"game.deadlog",
|
||||
"game.name",
|
||||
"game.start",
|
||||
"game.locale",
|
||||
|
|
Loading…
Reference in New Issue