diff --git a/src/common/gamecode/creport.c b/src/common/gamecode/creport.c index e3845af6a..ae08a34d3 100644 --- a/src/common/gamecode/creport.c +++ b/src/common/gamecode/creport.c @@ -1073,48 +1073,27 @@ cr_borders(seen_region ** seen, const region * r, const faction * f, int seemode } } -void -get_seen_interval(struct seen_region ** seen, region ** first, region ** last) -{ -/* #ifdef ENUM_REGIONS : can speed stuff up */ - - region * r = regions; - while (r!=NULL) { - if (find_seen(seen, r)!=NULL) { - *first = r; - break; - } - r = r->next; - } - while (r!=NULL) { - if (find_seen(seen, r)!=NULL) { - *last = r->next; - } - r = r->next; - } -} - /* main function of the creport. creates the header and traverses all regions */ int report_computer(FILE * F, faction * f, struct seen_region ** seen, const faction_list * addresses, const time_t report_time) { - int i; + int i; item * itm; const char * prefix; region * r; - building *b; - ship *sh; - unit *u; + building *b; + ship *sh; + unit *u; int score = 0, avgscore = 0; - const char * mailto = locale_string(f->locale, "mailto"); - region * first = NULL, * last = NULL; - const attrib * a; + const char * mailto = locale_string(f->locale, "mailto"); + region * first = firstregion(f), * last = lastregion(f); + const attrib * a; + /* must call this to get all the neighbour regions */ get_seen_interval(seen, &first, &last); - - /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ - /* initialisations, header and lists */ + /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ + /* initialisations, header and lists */ fprintf(F, "VERSION %d\n", C_REPORT_VERSION); fprintf(F, "\"%s\";locale\n", locale_name(f->locale)); @@ -1255,12 +1234,12 @@ report_computer(FILE * F, faction * f, struct seen_region ** seen, const faction } } - /* traverse all regions */ - for (r=first;r!=last;r=r->next) { - int modifier = 0; - const char * tname; + /* traverse all regions */ + for (r=first;r!=last;r=r->next) { + int modifier = 0; + const char * tname; const seen_region * sd = find_seen(seen, r); - + if (sd==NULL) continue; if (!rplane(r)) { diff --git a/src/common/kernel/reports.c b/src/common/kernel/reports.c index b5c2d72b5..fd285c434 100644 --- a/src/common/kernel/reports.c +++ b/src/common/kernel/reports.c @@ -966,8 +966,46 @@ find_seen(struct seen_region * seehash[], const region * r) return NULL; } +void +get_seen_interval(struct seen_region ** seen, region ** first, region ** last) +{ + /* this is required to find the neighbour regions of the ones we are in, + * which may well be outside of [firstregion, lastregion) */ +#ifdef ENUM_REGIONS + int i; + for (i=0;i!=MAXSEEHASH;++i) { + seen_region * sr = seen[i]; + while (sr!=NULL) { + if (*first==NULL || sr->r->index<(*first)->index) { + *first = sr->r; + } + if (*last!=NULL && sr->r->index>=(*last)->index) { + *last = sr->r->next; + } + sr = sr->nextHash; + } + } +#else + region * r = regions; + while (r!=first) { + if (find_seen(seen, r)!=NULL) { + *first = r; + break; + } + r = r->next; + } + r = *last; + while (r!=NULL) { + if (find_seen(seen, r)!=NULL) { + *last = r->next; + } + r = r->next; + } +#endif +} + boolean -add_seen(struct seen_region * seehash[], const struct region * r, unsigned char mode, boolean dis) +add_seen(struct seen_region * seehash[], struct region * r, unsigned char mode, boolean dis) { seen_region * find = find_seen(seehash, r); if (find==NULL) { diff --git a/src/common/kernel/reports.h b/src/common/kernel/reports.h index ed75f29e0..2d3219b9c 100644 --- a/src/common/kernel/reports.h +++ b/src/common/kernel/reports.h @@ -74,17 +74,18 @@ enum { }; typedef struct seen_region { - struct seen_region * nextHash; - const struct region *r; - unsigned char mode; - boolean disbelieves; + struct seen_region * nextHash; + struct region *r; + unsigned char mode; + boolean disbelieves; } seen_region; extern struct seen_region * find_seen(struct seen_region * seehash[], const struct region * r); -extern boolean add_seen(struct seen_region * seehash[], const struct region * r, unsigned char mode, boolean dis); +extern boolean add_seen(struct seen_region * seehash[], struct region * r, unsigned char mode, boolean dis); extern struct seen_region ** seen_init(void); extern void seen_done(struct seen_region * seehash[]); extern void free_seen(void); +extern void get_seen_interval(struct seen_region ** seen, struct region ** first, struct region ** last); extern const char* resname(resource_t res, int i); diff --git a/src/eressea/server.cpp b/src/eressea/server.cpp index 737a2ee99..d8288490b 100644 --- a/src/eressea/server.cpp +++ b/src/eressea/server.cpp @@ -164,6 +164,7 @@ report_segfault(int signo, siginfo_t * sinf, void * arg) size_t size; int fd = fileno(stderr); + fflush(stdout); fputs("\n\nProgram received SIGSEGV, backtrace follows.\n", stderr); size = backtrace(btrace, 50); backtrace_symbols_fd(btrace, size, fd);