forked from github/server
eliminate duplicate call to link_seen (and report_context.seen)
This commit is contained in:
parent
84aa0beee5
commit
d64948f0fc
|
@ -1343,7 +1343,7 @@ static void cr_output_region(FILE * F, report_context * ctx, seen_region * sr)
|
||||||
if (sr->mode != see_unit)
|
if (sr->mode != see_unit)
|
||||||
fprintf(F, "\"%s\";visibility\n", visibility[sr->mode]);
|
fprintf(F, "\"%s\";visibility\n", visibility[sr->mode]);
|
||||||
if (sr->mode == see_neighbour) {
|
if (sr->mode == see_neighbour) {
|
||||||
cr_borders(ctx->seen, r, f, sr->mode, F);
|
cr_borders(ctx->f->seen, r, f, sr->mode, F);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
building *b;
|
building *b;
|
||||||
|
@ -1431,7 +1431,7 @@ static void cr_output_region(FILE * F, report_context * ctx, seen_region * sr)
|
||||||
print_items(F, r->land->items, f->locale);
|
print_items(F, r->land->items, f->locale);
|
||||||
}
|
}
|
||||||
cr_output_curses_compat(F, f, r, TYP_REGION);
|
cr_output_curses_compat(F, f, r, TYP_REGION);
|
||||||
cr_borders(ctx->seen, r, f, sr->mode, F);
|
cr_borders(ctx->f->seen, r, f, sr->mode, F);
|
||||||
if (sr->mode == see_unit && is_astral(r)
|
if (sr->mode == see_unit && is_astral(r)
|
||||||
&& !is_cursed(r->attribs, C_ASTRALBLOCK, 0)) {
|
&& !is_cursed(r->attribs, C_ASTRALBLOCK, 0)) {
|
||||||
/* Sonderbehandlung Teleport-Ebene */
|
/* Sonderbehandlung Teleport-Ebene */
|
||||||
|
@ -1686,7 +1686,7 @@ report_computer(const char *filename, report_context * ctx, const char *charset)
|
||||||
|
|
||||||
/* traverse all regions */
|
/* traverse all regions */
|
||||||
for (r = ctx->first; sr == NULL && r != ctx->last; r = r->next) {
|
for (r = ctx->first; sr == NULL && r != ctx->last; r = r->next) {
|
||||||
sr = find_seen(ctx->seen, r);
|
sr = find_seen(ctx->f->seen, r);
|
||||||
}
|
}
|
||||||
for (; sr != NULL; sr = sr->next) {
|
for (; sr != NULL; sr = sr->next) {
|
||||||
cr_output_region(F, ctx, sr);
|
cr_output_region(F, ctx, sr);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "reports.h"
|
#include "reports.h"
|
||||||
#include "jsreport.h"
|
#include "jsreport.h"
|
||||||
|
#include <kernel/faction.h>
|
||||||
#include <kernel/region.h>
|
#include <kernel/region.h>
|
||||||
#include <kernel/terrain.h>
|
#include <kernel/terrain.h>
|
||||||
#include <kernel/terrainid.h>
|
#include <kernel/terrainid.h>
|
||||||
|
@ -31,7 +32,7 @@ static int report_json(const char *filename, report_context * ctx, const char *c
|
||||||
region *r;
|
region *r;
|
||||||
/* traverse all regions */
|
/* traverse all regions */
|
||||||
for (sr = NULL, r = ctx->first; sr == NULL && r != ctx->last; r = r->next) {
|
for (sr = NULL, r = ctx->first; sr == NULL && r != ctx->last; r = r->next) {
|
||||||
sr = find_seen(ctx->seen, r);
|
sr = find_seen(ctx->f->seen, r);
|
||||||
}
|
}
|
||||||
for (; sr != NULL; sr = sr->next) {
|
for (; sr != NULL; sr = sr->next) {
|
||||||
int tx = sr->r->x;
|
int tx = sr->r->x;
|
||||||
|
@ -55,7 +56,7 @@ static int report_json(const char *filename, report_context * ctx, const char *c
|
||||||
coor_from_tiled(&tx, &ty);
|
coor_from_tiled(&tx, &ty);
|
||||||
r = findregion(tx, ty);
|
r = findregion(tx, ty);
|
||||||
if (r) {
|
if (r) {
|
||||||
sr = find_seen(ctx->seen, r);
|
sr = find_seen(ctx->f->seen, r);
|
||||||
if (sr) {
|
if (sr) {
|
||||||
terrain_t ter = oldterrain(r->terrain);
|
terrain_t ter = oldterrain(r->terrain);
|
||||||
if (ter == NOTERRAIN) {
|
if (ter == NOTERRAIN) {
|
||||||
|
|
|
@ -1412,7 +1412,7 @@ report_template(const char *filename, report_context * ctx, const char *charset)
|
||||||
newline(out);
|
newline(out);
|
||||||
|
|
||||||
for (r = ctx->first; sr == NULL && r != ctx->last; r = r->next) {
|
for (r = ctx->first; sr == NULL && r != ctx->last; r = r->next) {
|
||||||
sr = find_seen(ctx->seen, r);
|
sr = find_seen(ctx->f->seen, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; sr != NULL; sr = sr->next) {
|
for (; sr != NULL; sr = sr->next) {
|
||||||
|
@ -2306,7 +2306,7 @@ const char *charset)
|
||||||
anyunits = 0;
|
anyunits = 0;
|
||||||
|
|
||||||
for (r = ctx->first; sr == NULL && r != ctx->last; r = r->next) {
|
for (r = ctx->first; sr == NULL && r != ctx->last; r = r->next) {
|
||||||
sr = find_seen(ctx->seen, r);
|
sr = find_seen(ctx->f->seen, r);
|
||||||
}
|
}
|
||||||
for (; sr != NULL; sr = sr->next) {
|
for (; sr != NULL; sr = sr->next) {
|
||||||
region *r = sr->r;
|
region *r = sr->r;
|
||||||
|
|
|
@ -1038,7 +1038,7 @@ static void get_addresses(report_context * ctx)
|
||||||
|
|
||||||
/* find the first region that this faction can see */
|
/* find the first region that this faction can see */
|
||||||
for (r = ctx->first; sr == NULL && r != ctx->last; r = r->next) {
|
for (r = ctx->first; sr == NULL && r != ctx->last; r = r->next) {
|
||||||
sr = find_seen(ctx->seen, r);
|
sr = find_seen(ctx->f->seen, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; sr != NULL; sr = sr->next) {
|
for (; sr != NULL; sr = sr->next) {
|
||||||
|
@ -1166,9 +1166,9 @@ static void get_seen_interval(report_context * ctx)
|
||||||
* which may well be outside of [firstregion, lastregion) */
|
* which may well be outside of [firstregion, lastregion) */
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
assert(ctx->seen);
|
assert(ctx->f->seen);
|
||||||
for (i = 0; i != MAXSEEHASH; ++i) {
|
for (i = 0; i != MAXSEEHASH; ++i) {
|
||||||
seen_region *sr = ctx->seen[i];
|
seen_region *sr = ctx->f->seen[i];
|
||||||
while (sr != NULL) {
|
while (sr != NULL) {
|
||||||
if (ctx->first == NULL || sr->r->index < ctx->first->index) {
|
if (ctx->first == NULL || sr->r->index < ctx->first->index) {
|
||||||
ctx->first = sr->r;
|
ctx->first = sr->r;
|
||||||
|
@ -1179,7 +1179,7 @@ static void get_seen_interval(report_context * ctx)
|
||||||
sr = sr->nextHash;
|
sr = sr->nextHash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
link_seen(ctx->seen, ctx->first, ctx->last);
|
link_seen(ctx->f->seen, ctx->first, ctx->last);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -1624,15 +1624,19 @@ static region *firstregion(faction * f)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static seen_region **prepare_report(faction * f)
|
static void prepare_report(struct report_context *ctx, faction *f)
|
||||||
{
|
{
|
||||||
|
region *r;
|
||||||
struct seen_region *sr;
|
struct seen_region *sr;
|
||||||
region *r = firstregion(f);
|
|
||||||
region *last = lastregion(f);
|
|
||||||
|
|
||||||
link_seen(f->seen, r, last);
|
ctx->f = f;
|
||||||
|
ctx->report_time = time(NULL);
|
||||||
|
ctx->first = firstregion(f);
|
||||||
|
ctx->last = lastregion(f);
|
||||||
|
ctx->addresses = NULL;
|
||||||
|
ctx->userdata = NULL;
|
||||||
|
|
||||||
for (sr = NULL; sr == NULL && r != last; r = r->next) {
|
for (r = ctx->first, sr = NULL; sr == NULL && r != ctx->last; r = r->next) {
|
||||||
sr = find_seen(f->seen, r);
|
sr = find_seen(f->seen, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1649,7 +1653,7 @@ static seen_region **prepare_report(faction * f)
|
||||||
view(f->seen, r, f);
|
view(f->seen, r, f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return f->seen;
|
get_seen_interval(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_reports(faction * f, time_t ltime)
|
int write_reports(faction * f, time_t ltime)
|
||||||
|
@ -1663,16 +1667,7 @@ int write_reports(faction * f, time_t ltime)
|
||||||
if (noreports) {
|
if (noreports) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ctx.f = f;
|
prepare_report(&ctx, f);
|
||||||
ctx.report_time = time(NULL);
|
|
||||||
ctx.seen = prepare_report(f);
|
|
||||||
ctx.first = firstregion(f);
|
|
||||||
ctx.last = lastregion(f);
|
|
||||||
ctx.addresses = NULL;
|
|
||||||
ctx.userdata = NULL;
|
|
||||||
if (ctx.seen) {
|
|
||||||
get_seen_interval(&ctx);
|
|
||||||
}
|
|
||||||
get_addresses(&ctx);
|
get_addresses(&ctx);
|
||||||
if (_access(reportpath(), 0) < 0) {
|
if (_access(reportpath(), 0) < 0) {
|
||||||
_mkdir(reportpath());
|
_mkdir(reportpath());
|
||||||
|
@ -1714,8 +1709,8 @@ int write_reports(faction * f, time_t ltime)
|
||||||
log_warning("No report for faction %s!", factionid(f));
|
log_warning("No report for faction %s!", factionid(f));
|
||||||
}
|
}
|
||||||
ql_free(ctx.addresses);
|
ql_free(ctx.addresses);
|
||||||
if (ctx.seen) {
|
if (ctx.f->seen) {
|
||||||
seen_done(ctx.seen);
|
seen_done(ctx.f->seen);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,6 @@ extern "C" {
|
||||||
typedef struct report_context {
|
typedef struct report_context {
|
||||||
struct faction *f;
|
struct faction *f;
|
||||||
struct quicklist *addresses;
|
struct quicklist *addresses;
|
||||||
struct seen_region **seen;
|
|
||||||
struct region *first, *last;
|
struct region *first, *last;
|
||||||
void *userdata;
|
void *userdata;
|
||||||
time_t report_time;
|
time_t report_time;
|
||||||
|
|
Loading…
Reference in New Issue