re-enable report writing, fix report.c to work without seen_region

This commit is contained in:
Enno Rehling 2016-09-16 18:03:28 +02:00
parent 007f4d8b0d
commit d449ce4a8c
10 changed files with 70 additions and 85 deletions

View File

@ -105,7 +105,7 @@ set (ERESSEA_SRC
skill.c skill.c
json.c json.c
# creport.c # creport.c
# report.c report.c
economy.c economy.c
give.c give.c
items.c items.c
@ -200,7 +200,7 @@ set(TESTS_SRC
volcano.test.c volcano.test.c
reports.test.c reports.test.c
# creport.test.c # creport.test.c
# report.test.c report.test.c
summary.test.c summary.test.c
travelthru.test.c travelthru.test.c
callback.test.c callback.test.c

View File

@ -30,7 +30,7 @@
#include "chaos.h" #include "chaos.h"
#include "items.h" #include "items.h"
//#include "creport.h" //#include "creport.h"
//#include "report.h" #include "report.h"
#include "names.h" #include "names.h"
#include "reports.h" #include "reports.h"
#include "spells.h" #include "spells.h"
@ -64,7 +64,7 @@ void game_init(void)
register_triggers(); register_triggers();
register_xmas(); register_xmas();
// register_nr(); register_nr();
// register_cr(); // register_cr();
register_races(); register_races();

View File

@ -697,13 +697,11 @@ void r_setdemand(region * r, const luxury_type * ltype, int value)
d->value = value; d->value = value;
} }
const item_type *r_luxury(region * r) const item_type *r_luxury(const region * r)
{ {
struct demand *dmd; struct demand *dmd;
if (r->land) { if (r->land) {
if (!r->land->demands) { assert(r->land->demands || !"need to call fix_demands on a region");
fix_demand(r);
}
for (dmd = r->land->demands; dmd; dmd = dmd->next) { for (dmd = r->land->demands; dmd; dmd = dmd->next) {
if (dmd->value == 0) if (dmd->value == 0)
return dmd->type->itype; return dmd->type->itype;

View File

@ -274,7 +274,7 @@ extern "C" {
int value); int value);
int owner_change(const region * r); int owner_change(const region * r);
bool is_mourning(const region * r, int in_turn); bool is_mourning(const region * r, int in_turn);
const struct item_type *r_luxury(struct region *r); const struct item_type *r_luxury(const struct region *r);
void get_neighbours(const struct region *r, struct region **list); void get_neighbours(const struct region *r, struct region **list);
struct faction *update_owners(struct region *r); struct faction *update_owners(struct region *r);

View File

@ -21,6 +21,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <platform.h> #include <platform.h>
#include <kernel/config.h> #include <kernel/config.h>
#include "report.h"
#include "reports.h" #include "reports.h"
#include "laws.h" #include "laws.h"
#include "travelthru.h" #include "travelthru.h"
@ -169,7 +170,7 @@ static void centre(stream *out, const char *s, bool breaking)
static void static void
paragraph(stream *out, const char *str, ptrdiff_t indent, int hanging_indent, paragraph(stream *out, const char *str, ptrdiff_t indent, int hanging_indent,
char marker) char marker)
{ {
size_t length = REPORTWIDTH; size_t length = REPORTWIDTH;
const char *end, *begin, *mark = 0; const char *end, *begin, *mark = 0;
@ -716,7 +717,7 @@ nr_unit(stream *out, const faction * f, const unit * u, int indent, seen_mode mo
static void static void
rp_messages(stream *out, message_list * msgs, faction * viewer, int indent, rp_messages(stream *out, message_list * msgs, faction * viewer, int indent,
bool categorized) bool categorized)
{ {
nrsection *section; nrsection *section;
@ -809,7 +810,7 @@ static void prices(stream *out, const region * r, const faction * f)
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
for (dmd = r->land->demands; dmd; dmd = dmd->next){ for (dmd = r->land->demands; dmd; dmd = dmd->next) {
if (dmd->value > 0) { if (dmd->value > 0) {
m = msg_message("nr_market_price", "product price", m = msg_message("nr_market_price", "product price",
dmd->type->itype->rtype, dmd->value * dmd->type->price); dmd->type->itype->rtype, dmd->value * dmd->type->price);
@ -937,14 +938,14 @@ static void describe(stream *out, const region * r, faction * f)
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
if (sr->mode == see_travel) { if (r->seen.mode == seen_travel) {
bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_travel")); bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "seen_travel"));
} }
else if (sr->mode == see_neighbour) { else if (r->seen.mode == seen_neighbour) {
bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_neighbour")); bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_neighbour"));
} }
else if (sr->mode == see_lighthouse) { else if (r->seen.mode == seen_lighthouse) {
bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_lighthouse")); bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "seen_lighthouse"));
} }
else { else {
bytes = 0; bytes = 0;
@ -991,9 +992,9 @@ static void describe(stream *out, const region * r, faction * f)
} }
/* iron & stone */ /* iron & stone */
if (sr->mode == see_unit) { if (r->seen.mode == seen_unit) {
resource_report result[MAX_RAWMATERIALS]; resource_report result[MAX_RAWMATERIALS];
int n, numresults = report_resources(sr, result, MAX_RAWMATERIALS, f); int n, numresults = report_resources(r, result, MAX_RAWMATERIALS, f, true);
for (n = 0; n < numresults; ++n) { for (n = 0; n < numresults; ++n) {
if (result[n].number >= 0 && result[n].level >= 0) { if (result[n].number >= 0 && result[n].level >= 0) {
@ -1026,7 +1027,7 @@ static void describe(stream *out, const region * r, faction * f)
bytes = bytes =
(int)strlcpy(bufp, LOC(f->locale, n == 1 ? "rc_orc" : "rc_orc_p"), (int)strlcpy(bufp, LOC(f->locale, n == 1 ? "rc_orc" : "rc_orc_p"),
size); size);
} }
else { else {
bytes = (int)strlcpy(bufp, " ", size); bytes = (int)strlcpy(bufp, " ", size);
@ -1034,7 +1035,7 @@ static void describe(stream *out, const region * r, faction * f)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
bytes = bytes =
(int)strlcpy(bufp, LOC(f->locale, n == 1 ? "peasant" : "peasant_p"), (int)strlcpy(bufp, LOC(f->locale, n == 1 ? "peasant" : "peasant_p"),
size); size);
} }
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
@ -1044,13 +1045,13 @@ static void describe(stream *out, const region * r, faction * f)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
} }
} }
if (rmoney(r) && sr->mode >= see_travel) { if (rmoney(r) && r->seen.mode >= seen_travel) {
bytes = _snprintf(bufp, size, ", %d ", rmoney(r)); bytes = _snprintf(bufp, size, ", %d ", rmoney(r));
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
bytes = bytes =
(int)strlcpy(bufp, LOC(f->locale, resourcename(get_resourcetype(R_SILVER), (int)strlcpy(bufp, LOC(f->locale, resourcename(get_resourcetype(R_SILVER),
rmoney(r) != 1)), size); rmoney(r) != 1)), size);
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
} }
@ -1189,7 +1190,7 @@ static void describe(stream *out, const region * r, faction * f)
*bufp = 0; *bufp = 0;
paragraph(out, buf, 0, 0, 0); paragraph(out, buf, 0, 0, 0);
if (sr->mode == see_unit && is_astral(r) && if (r->seen.mode == seen_unit && is_astral(r) &&
!is_cursed(r->attribs, C_ASTRALBLOCK, 0)) { !is_cursed(r->attribs, C_ASTRALBLOCK, 0)) {
/* Sonderbehandlung Teleport-Ebene */ /* Sonderbehandlung Teleport-Ebene */
region_list *rl = astralregions(r, inhabitable); region_list *rl = astralregions(r, inhabitable);
@ -1392,7 +1393,6 @@ report_template(const char *filename, report_context * ctx, const char *charset)
region *r; region *r;
FILE *F = fopen(filename, "w"); FILE *F = fopen(filename, "w");
stream strm = { 0 }, *out = &strm; stream strm = { 0 }, *out = &strm;
seen_region *sr = NULL;
char buf[8192], *bufp; char buf[8192], *bufp;
size_t size; size_t size;
int bytes; int bytes;
@ -1424,16 +1424,11 @@ report_template(const char *filename, report_context * ctx, const char *charset)
rps_nowrap(out, buf); rps_nowrap(out, buf);
newline(out); newline(out);
for (r = ctx->first; sr == NULL && r != ctx->last; r = r->next) { for (r = ctx->first; r != ctx->last; r = r->next) {
sr = find_seen(ctx->f->seen, r);
}
for (; sr != NULL; sr = sr->next) {
region *r = sr->r;
unit *u; unit *u;
int dh = 0; int dh = 0;
if (sr->mode < see_unit) if (r->seen.mode < seen_unit)
continue; continue;
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
@ -1778,10 +1773,9 @@ static void list_address(stream *out, const faction * uf, quicklist * seenfactio
} }
static void static void
nr_ship(stream *out, const seen_region * sr, const ship * sh, const faction * f, nr_ship(stream *out, const region *r, const ship * sh, const faction * f,
const unit * captain) const unit * captain)
{ {
const region *r = sr->r;
char buffer[8192], *bufp = buffer; char buffer[8192], *bufp = buffer;
size_t size = sizeof(buffer) - 1; size_t size = sizeof(buffer) - 1;
int bytes; int bytes;
@ -1800,7 +1794,7 @@ const unit * captain)
else { else {
bytes = bytes =
_snprintf(bufp, size, "%s, %s", shipname(sh), LOC(f->locale, _snprintf(bufp, size, "%s, %s", shipname(sh), LOC(f->locale,
sh->type->_name)); sh->type->_name));
} }
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
@ -1852,8 +1846,7 @@ const unit * captain)
} }
static void static void
nr_building(stream *out, const seen_region * sr, const building * b, nr_building(stream *out, const region *r, const building *b, const faction *f)
const faction * f)
{ {
int i, bytes; int i, bytes;
const char *name, *bname, *billusion = NULL; const char *name, *bname, *billusion = NULL;
@ -1867,7 +1860,7 @@ const faction * f)
newline(out); newline(out);
bytes = bytes =
_snprintf(bufp, size, "%s, %s %d, ", buildingname(b), LOC(lang, _snprintf(bufp, size, "%s, %s %d, ", buildingname(b), LOC(lang,
"nr_size"), b->size); "nr_size"), b->size);
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
@ -1893,7 +1886,7 @@ const faction * f)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
} }
if (b->besieged > 0 && sr->mode >= see_lighthouse) { if (b->besieged > 0 && r->seen.mode >= seen_lighthouse) {
msg = msg_message("nr_building_besieged", "soldiers diff", b->besieged, msg = msg_message("nr_building_besieged", "soldiers diff", b->besieged,
b->besieged - b->size * SIEGEFACTOR); b->besieged - b->size * SIEGEFACTOR);
bytes = (int)nr_render(msg, lang, bufp, size, f); bytes = (int)nr_render(msg, lang, bufp, size, f);
@ -1920,11 +1913,9 @@ const faction * f)
*bufp = 0; *bufp = 0;
paragraph(out, buffer, 2, 0, 0); paragraph(out, buffer, 2, 0, 0);
if (sr->mode < see_lighthouse) if (r->seen.mode >= seen_lighthouse) {
return; nr_curses(out, 4, f, TYP_BUILDING, b);
}
i = 0;
nr_curses(out, 4, f, TYP_BUILDING, b);
} }
static void nr_paragraph(stream *out, message * m, faction * f) static void nr_paragraph(stream *out, message * m, faction * f)
@ -1960,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(region *r, unit *u, void *cbdata) { static void cb_write_travelthru(const 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;
@ -2015,7 +2006,7 @@ static void cb_write_travelthru(region *r, unit *u, void *cbdata) {
} }
} }
void write_travelthru(stream *out, region * r, const faction * f) void write_travelthru(stream *out, const region *r, const faction *f)
{ {
int maxtravel; int maxtravel;
char buf[8192]; char buf[8192];
@ -2033,7 +2024,7 @@ void write_travelthru(stream *out, region * r, const faction * f)
init_cb(&cbdata, out, buf, sizeof(buf), f); init_cb(&cbdata, out, buf, sizeof(buf), f);
cbdata.maxtravel = maxtravel; cbdata.maxtravel = maxtravel;
cbdata.writep += cbdata.writep +=
strlcpy(buf, LOC(f->locale, "travelthru_header"), sizeof(buf)); strlcpy(buf, LOC(f->locale, "travelthru_header"), sizeof(buf));
travelthru_map(r, cb_write_travelthru, &cbdata); travelthru_map(r, cb_write_travelthru, &cbdata);
return; return;
@ -2042,7 +2033,7 @@ void write_travelthru(stream *out, region * r, const faction * f)
int int
report_plaintext(const char *filename, report_context * ctx, report_plaintext(const char *filename, report_context * ctx,
const char *charset) const char *charset)
{ {
int flag = 0; int flag = 0;
char ch; char ch;
@ -2058,7 +2049,6 @@ const char *charset)
int wants_stats = (f->options & ix); int wants_stats = (f->options & ix);
FILE *F = fopen(filename, "w"); FILE *F = fopen(filename, "w");
stream strm = { 0 }, *out = &strm; stream strm = { 0 }, *out = &strm;
seen_region *sr = NULL;
char buf[8192]; char buf[8192];
char *bufp; char *bufp;
bool utf8 = _strcmpl(charset, "utf8") == 0 || _strcmpl(charset, "utf-8") == 0; bool utf8 = _strcmpl(charset, "utf8") == 0 || _strcmpl(charset, "utf-8") == 0;
@ -2066,7 +2056,7 @@ const char *charset)
int thisseason; int thisseason;
int nextseason; int nextseason;
gamedate date; gamedate date;
get_gamedate(turn + 1, &date); get_gamedate(turn + 1, &date);
thisseason = date.season; thisseason = date.season;
get_gamedate(turn + 2, &date); get_gamedate(turn + 2, &date);
@ -2148,8 +2138,8 @@ const char *charset)
if (f_get_alliance(f)) { if (f_get_alliance(f)) {
m = m =
msg_message("nr_alliance", "leader name id age", msg_message("nr_alliance", "leader name id age",
alliance_get_leader(f->alliance), f->alliance->name, f->alliance->id, alliance_get_leader(f->alliance), f->alliance->name, f->alliance->id,
turn - f->alliance_joindate); turn - f->alliance_joindate);
nr_render(m, f->locale, buf, sizeof(buf), f); nr_render(m, f->locale, buf, sizeof(buf), f);
msg_release(m); msg_release(m);
centre(out, buf, true); centre(out, buf, true);
@ -2286,22 +2276,18 @@ const char *charset)
CHECK_ERRNO(); CHECK_ERRNO();
anyunits = 0; anyunits = 0;
for (r = ctx->first; sr == NULL && r != ctx->last; r = r->next) { for (r = ctx->first; r != ctx->last; r = r->next) {
sr = find_seen(ctx->f->seen, r); int stealthmod = stealth_modifier(r->seen.mode);
}
for (; sr != NULL; sr = sr->next) {
region *r = sr->r;
int stealthmod = stealth_modifier(sr->mode);
building *b = r->buildings; building *b = r->buildings;
ship *sh = r->ships; ship *sh = r->ships;
if (sr->mode < see_lighthouse) if (r->seen.mode < seen_lighthouse)
continue; continue;
/* Beschreibung */ /* Beschreibung */
if (sr->mode == see_unit) { if (r->seen.mode == seen_unit) {
anyunits = 1; anyunits = 1;
describe(out, sr, f); describe(out, r, f);
if (markets_module() && r->land) { if (markets_module() && r->land) {
const item_type *lux = r_luxury(r); const item_type *lux = r_luxury(r);
const item_type *herb = r->land->herbtype; const item_type *herb = r->land->herbtype;
@ -2331,27 +2317,27 @@ const char *charset)
write_travelthru(out, r, f); write_travelthru(out, r, f);
} }
else { else {
if (sr->mode == see_far) { if (r->seen.mode == seen_far) {
describe(out, sr, f); describe(out, r, f);
newline(out); newline(out);
guards(out, r, f); guards(out, r, f);
newline(out); newline(out);
write_travelthru(out, r, f); write_travelthru(out, r, f);
} }
else { else {
describe(out, sr, f); describe(out, r, f);
newline(out); newline(out);
write_travelthru(out, r, f); write_travelthru(out, r, f);
} }
} }
/* Statistik */ /* Statistik */
if (wants_stats && sr->mode == see_unit) if (wants_stats && r->seen.mode == seen_unit)
statistics(out, r, f); statistics(out, r, f);
/* Nachrichten an REGION in der Region */ /* Nachrichten an REGION in der Region */
if (sr->mode == see_unit || sr->mode == see_travel) { if (r->seen.mode == seen_unit || r->seen.mode == seen_travel) {
// TODO: Bug 2073 // TODO: Bug 2073
message_list *mlist = r_getmessages(r, f); message_list *mlist = r_getmessages(r, f);
if (mlist) { if (mlist) {
@ -2368,13 +2354,13 @@ const char *charset)
u = r->units; u = r->units;
while (b) { while (b) {
while (b && (!u || u->building != b)) { while (b && (!u || u->building != b)) {
nr_building(out, sr, b, f); nr_building(out, r, b, f);
b = b->next; b = b->next;
} }
if (b) { if (b) {
nr_building(out, sr, b, f); nr_building(out, r, b, f);
while (u && u->building == b) { while (u && u->building == b) {
nr_unit(out, f, u, 6, sr->mode); nr_unit(out, f, u, 6, r->seen.mode);
u = u->next; u = u->next;
} }
b = b->next; b = b->next;
@ -2383,7 +2369,7 @@ const char *charset)
while (u && !u->ship) { while (u && !u->ship) {
if (stealthmod > INT_MIN) { if (stealthmod > INT_MIN) {
if (u->faction == f || cansee(f, r, u, stealthmod)) { if (u->faction == f || cansee(f, r, u, stealthmod)) {
nr_unit(out, f, u, 4, sr->mode); nr_unit(out, f, u, 4, r->seen.mode);
} }
} }
assert(!u->building); assert(!u->building);
@ -2391,13 +2377,13 @@ const char *charset)
} }
while (sh) { while (sh) {
while (sh && (!u || u->ship != sh)) { while (sh && (!u || u->ship != sh)) {
nr_ship(out, sr, sh, f, NULL); nr_ship(out, r, sh, f, NULL);
sh = sh->next; sh = sh->next;
} }
if (sh) { if (sh) {
nr_ship(out, sr, sh, f, u); nr_ship(out, r, sh, f, u);
while (u && u->ship == sh) { while (u && u->ship == sh) {
nr_unit(out, f, u, 6, sr->mode); nr_unit(out, f, u, 6, r->seen.mode);
u = u->next; u = u->next;
} }
sh = sh->next; sh = sh->next;
@ -2459,7 +2445,7 @@ unit *can_find(faction * f, faction * f2)
if (ss) { if (ss) {
/* bei TARNE PARTEI yxz muss die Partei von unit proof nicht /* bei TARNE PARTEI yxz muss die Partei von unit proof nicht
* wirklich Partei f2 sein! */ * wirklich Partei f2 sein! */
/* assert(ss->proof->faction==f2); */ /* assert(ss->proof->faction==f2); */
return ss->proof; return ss->proof;
} }
return NULL; return NULL;

View File

@ -971,7 +971,7 @@ typedef struct address_data {
int stealthmod; int stealthmod;
} address_data; } address_data;
static void cb_add_address(region *r, unit *ut, void *cbdata) { static void cb_add_address(const 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;
@ -1378,8 +1378,9 @@ static region *firstregion(faction * f)
#endif #endif
} }
static void cb_add_seen(region *r, unit *u, void *cbdata) { static void cb_add_seen(const region *rc, unit *u, void *cbdata) {
unused_arg(cbdata); region *r = (region *)cbdata;
assert(rc == r);
faction_add_seen(u->faction, r, seen_travel); faction_add_seen(u->faction, r, seen_travel);
} }
@ -1444,7 +1445,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, ctx); travelthru_map(r, cb_add_seen, r);
} }
} }
// [fast,last) interval of seen regions (with lighthouses and travel) // [fast,last) interval of seen regions (with lighthouses and travel)
@ -2147,7 +2148,7 @@ typedef struct count_data {
const struct faction *f; const struct faction *f;
} count_data; } count_data;
static void count_cb(region *r, unit *u, void *cbdata) { static void count_cb(const 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)) {
@ -2157,7 +2158,7 @@ static void count_cb(region *r, unit *u, void *cbdata) {
} }
} }
int count_travelthru(struct region *r, const struct faction *f) { int count_travelthru(const 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);

View File

@ -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(struct region *r, const struct faction *f); int count_travelthru(const 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 */

View File

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

View File

@ -11,7 +11,7 @@ extern "C" {
struct region; struct region;
struct faction; struct faction;
struct unit; struct unit;
void travelthru_map(struct region * r, void(*cb)(struct region *r, struct unit *, void *), void *cbdata); void travelthru_map(const struct region * r, void(*cb)(const 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);

View File

@ -13,7 +13,7 @@
struct attrib; struct attrib;
static void count_travelers(region *r, unit *u, void *cbdata) { static void count_travelers(const 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;