forked from github/server
fix travelthru reporting (passes unit test)
This commit is contained in:
parent
a2125fbb9a
commit
0753ea0174
|
@ -1951,7 +1951,7 @@ static void init_cb(cb_data *data, stream *out, char *buffer, size_t size, const
|
||||||
data->counter = 0;
|
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;
|
cb_data *data = (cb_data *)cbdata;
|
||||||
const faction *f = data->f;
|
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;
|
int maxtravel;
|
||||||
char buf[8192];
|
char buf[8192];
|
||||||
|
@ -2038,7 +2038,7 @@ report_plaintext(const char *filename, report_context * ctx,
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
char ch;
|
char ch;
|
||||||
int anyunits, no_units, no_people;
|
int anyunits, no_units, no_people;
|
||||||
const struct region *r;
|
region *r;
|
||||||
faction *f = ctx->f;
|
faction *f = ctx->f;
|
||||||
unit *u;
|
unit *u;
|
||||||
char pzTime[64];
|
char pzTime[64];
|
||||||
|
|
|
@ -27,7 +27,7 @@ extern "C" {
|
||||||
void register_nr(void);
|
void register_nr(void);
|
||||||
void report_cleanup(void);
|
void report_cleanup(void);
|
||||||
void write_spaces(struct stream *out, size_t num);
|
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_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);
|
void nr_spell(struct stream *out, struct spellbook_entry * sbe, const struct locale *lang);
|
||||||
|
|
|
@ -971,7 +971,7 @@ typedef struct address_data {
|
||||||
int stealthmod;
|
int stealthmod;
|
||||||
} address_data;
|
} 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;
|
address_data *data = (address_data *)cbdata;
|
||||||
faction *f = data->f;
|
faction *f = data->f;
|
||||||
|
|
||||||
|
@ -1292,10 +1292,11 @@ static region *firstregion(faction * f)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cb_add_seen(const region *rc, unit *u, void *cbdata) {
|
static void cb_add_seen(region *r, unit *u, void *cbdata) {
|
||||||
region *r = (region *)cbdata;
|
faction *f = (faction *)cbdata;
|
||||||
assert(rc == r);
|
if (u->faction==f) {
|
||||||
faction_add_seen(u->faction, r, seen_travel);
|
faction_add_seen(f, r, seen_travel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** set region.seen based on visibility by one faction.
|
/** 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)) {
|
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)
|
// [fast,last) interval of seen regions (with lighthouses and travel)
|
||||||
|
@ -2062,7 +2063,7 @@ typedef struct count_data {
|
||||||
const struct faction *f;
|
const struct faction *f;
|
||||||
} count_data;
|
} 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;
|
count_data *data = (count_data *)cbdata;
|
||||||
const struct faction *f = data->f;
|
const struct faction *f = data->f;
|
||||||
if (r != u->region && (!u->ship || ship_owner(u->ship) == u)) {
|
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 };
|
count_data data = { 0 };
|
||||||
data.f = f;
|
data.f = f;
|
||||||
travelthru_map(r, count_cb, &data);
|
travelthru_map(r, count_cb, &data);
|
||||||
|
|
|
@ -125,7 +125,7 @@ extern "C" {
|
||||||
|
|
||||||
int stream_printf(struct stream * out, const char *format, ...);
|
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 GR_PLURAL 0x01 /* grammar: plural */
|
||||||
#define MAX_INVENTORY 128 /* maimum number of different items in an inventory */
|
#define MAX_INVENTORY 128 /* maimum number of different items in an inventory */
|
||||||
|
|
|
@ -95,7 +95,7 @@ bool travelthru_cansee(const struct region *r, const struct faction *f, const st
|
||||||
return false;
|
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;
|
attrib *a;
|
||||||
assert(r);
|
assert(r);
|
||||||
|
|
|
@ -11,7 +11,7 @@ extern "C" {
|
||||||
struct region;
|
struct region;
|
||||||
struct faction;
|
struct faction;
|
||||||
struct unit;
|
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);
|
bool travelthru_cansee(const struct region *r, const struct faction *f, const struct unit *u);
|
||||||
void travelthru_add(struct region * r, struct unit * u);
|
void travelthru_add(struct region * r, struct unit * u);
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
struct attrib;
|
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;
|
int *n = (int *)cbdata;
|
||||||
unused_arg(r);
|
unused_arg(r);
|
||||||
*n += u->number;
|
*n += u->number;
|
||||||
|
|
Loading…
Reference in New Issue