fix travelthru reporting (passes unit test)

This commit is contained in:
Enno Rehling 2016-09-17 08:28:33 +02:00
parent a2125fbb9a
commit 0753ea0174
7 changed files with 17 additions and 16 deletions

View File

@ -1951,7 +1951,7 @@ static void init_cb(cb_data *data, stream *out, char *buffer, size_t size, const
data->counter = 0;
}
static void cb_write_travelthru(const region *r, unit *u, void *cbdata) {
static void cb_write_travelthru(region *r, unit *u, void *cbdata) {
cb_data *data = (cb_data *)cbdata;
const faction *f = data->f;
@ -2006,7 +2006,7 @@ static void cb_write_travelthru(const region *r, unit *u, void *cbdata) {
}
}
void write_travelthru(stream *out, const region *r, const faction *f)
void write_travelthru(stream *out, region *r, const faction *f)
{
int maxtravel;
char buf[8192];
@ -2038,7 +2038,7 @@ report_plaintext(const char *filename, report_context * ctx,
int flag = 0;
char ch;
int anyunits, no_units, no_people;
const struct region *r;
region *r;
faction *f = ctx->f;
unit *u;
char pzTime[64];

View File

@ -27,7 +27,7 @@ extern "C" {
void register_nr(void);
void report_cleanup(void);
void write_spaces(struct stream *out, size_t num);
void write_travelthru(struct stream *out, const struct region * r, const struct faction * f);
void write_travelthru(struct stream *out, struct region * r, const struct faction * f);
void nr_spell_syntax(struct stream *out, struct spellbook_entry * sbe, const struct locale *lang);
void nr_spell(struct stream *out, struct spellbook_entry * sbe, const struct locale *lang);

View File

@ -971,7 +971,7 @@ typedef struct address_data {
int stealthmod;
} address_data;
static void cb_add_address(const region *r, unit *ut, void *cbdata) {
static void cb_add_address(region *r, unit *ut, void *cbdata) {
address_data *data = (address_data *)cbdata;
faction *f = data->f;
@ -1292,10 +1292,11 @@ static region *firstregion(faction * f)
#endif
}
static void cb_add_seen(const region *rc, unit *u, void *cbdata) {
region *r = (region *)cbdata;
assert(rc == r);
faction_add_seen(u->faction, r, seen_travel);
static void cb_add_seen(region *r, unit *u, void *cbdata) {
faction *f = (faction *)cbdata;
if (u->faction==f) {
faction_add_seen(f, r, seen_travel);
}
}
/** set region.seen based on visibility by one faction.
@ -1359,7 +1360,7 @@ void prepare_report(report_context *ctx, faction *f)
}
if (fval(r, RF_TRAVELUNIT)) {
travelthru_map(r, cb_add_seen, r);
travelthru_map(r, cb_add_seen, f);
}
}
// [fast,last) interval of seen regions (with lighthouses and travel)
@ -2062,7 +2063,7 @@ typedef struct count_data {
const struct faction *f;
} count_data;
static void count_cb(const region *r, unit *u, void *cbdata) {
static void count_cb(region *r, unit *u, void *cbdata) {
count_data *data = (count_data *)cbdata;
const struct faction *f = data->f;
if (r != u->region && (!u->ship || ship_owner(u->ship) == u)) {
@ -2072,7 +2073,7 @@ static void count_cb(const region *r, unit *u, void *cbdata) {
}
}
int count_travelthru(const struct region *r, const struct faction *f) {
int count_travelthru(struct region *r, const struct faction *f) {
count_data data = { 0 };
data.f = f;
travelthru_map(r, count_cb, &data);

View File

@ -125,7 +125,7 @@ extern "C" {
int stream_printf(struct stream * out, const char *format, ...);
int count_travelthru(const struct region *r, const struct faction *f);
int count_travelthru(struct region *r, const struct faction *f);
#define GR_PLURAL 0x01 /* grammar: plural */
#define MAX_INVENTORY 128 /* maimum number of different items in an inventory */

View File

@ -95,7 +95,7 @@ bool travelthru_cansee(const struct region *r, const struct faction *f, const st
return false;
}
void travelthru_map(const region * r, void(*cb)(const region *, struct unit *, void *), void *cbdata)
void travelthru_map(region * r, void(*cb)(region *, struct unit *, void *), void *cbdata)
{
attrib *a;
assert(r);

View File

@ -11,7 +11,7 @@ extern "C" {
struct region;
struct faction;
struct unit;
void travelthru_map(const struct region * r, void(*cb)(const struct region *r, struct unit *, void *), void *cbdata);
void travelthru_map(struct region * r, void(*cb)(struct region *r, struct unit *, void *), void *cbdata);
bool travelthru_cansee(const struct region *r, const struct faction *f, const struct unit *u);
void travelthru_add(struct region * r, struct unit * u);

View File

@ -13,7 +13,7 @@
struct attrib;
static void count_travelers(const region *r, unit *u, void *cbdata) {
static void count_travelers(region *r, unit *u, void *cbdata) {
int *n = (int *)cbdata;
unused_arg(r);
*n += u->number;