forked from github/server
recalculate [first,last) after lighthouses aand trvelthru
This commit is contained in:
parent
652ead4f60
commit
71fa3600f7
6 changed files with 40 additions and 36 deletions
|
@ -96,7 +96,6 @@ set (ERESSEA_SRC
|
|||
guard.c
|
||||
prefix.c
|
||||
donations.c
|
||||
seen.c
|
||||
eressea.c
|
||||
callback.c
|
||||
direction.c
|
||||
|
@ -197,7 +196,6 @@ set(TESTS_SRC
|
|||
tests.test.c
|
||||
volcano.test.c
|
||||
reports.test.c
|
||||
seen.test.c
|
||||
summary.test.c
|
||||
travelthru.test.c
|
||||
callback.test.c
|
||||
|
|
|
@ -170,7 +170,8 @@ static int potion_luck(unit *u, region *r, attrib_type *atype, int amount) {
|
|||
}
|
||||
|
||||
static int potion_truth(unit *u) {
|
||||
fset(u, UFL_DISBELIEVES);
|
||||
// TODO: this potion does nothing!
|
||||
// fset(u, UFL_DISBELIEVES);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include "chaos.h"
|
||||
#include "move.h"
|
||||
#include "laws.h"
|
||||
#include "seen.h"
|
||||
#include "skill.h"
|
||||
#include "monster.h"
|
||||
|
||||
|
@ -2884,7 +2883,7 @@ static void battle_punit(unit * u, battle * b)
|
|||
faction *f = bf->faction;
|
||||
strlist *S = 0, *x;
|
||||
|
||||
spunit(&S, f, u, 4, see_battle);
|
||||
spunit(&S, f, u, 4, seen_battle);
|
||||
for (x = S; x; x = x->next) {
|
||||
fbattlerecord(b, f, x->s);
|
||||
if (bdebug && u->faction == f) {
|
||||
|
|
|
@ -11,7 +11,6 @@ without prior permission by the authors of Eressea.
|
|||
#include <kernel/config.h>
|
||||
#include <kernel/version.h>
|
||||
#include "creport.h"
|
||||
#include "seen.h"
|
||||
#include "travelthru.h"
|
||||
|
||||
/* tweakable features */
|
||||
|
|
|
@ -1372,6 +1372,31 @@ void reorder_units(region * r)
|
|||
}
|
||||
}
|
||||
|
||||
static region *lastregion(faction * f)
|
||||
{
|
||||
#ifdef SMART_INTERVALS
|
||||
return f->last->next;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static region *firstregion(faction * f)
|
||||
{
|
||||
#ifdef SMART_INTERVALS
|
||||
region *r = f->first;
|
||||
|
||||
if (f->units == NULL)
|
||||
return NULL;
|
||||
if (r != NULL)
|
||||
return r;
|
||||
|
||||
return f->first = regions;
|
||||
#else
|
||||
return regions;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void cb_add_seen(region *r, unit *u, void *cbdata) {
|
||||
unused_arg(cbdata);
|
||||
faction_add_seen(u->faction, r, seen_travel);
|
||||
|
@ -1391,6 +1416,9 @@ void prepare_seen(report_context *ctx)
|
|||
static bool rule_region_owners;
|
||||
const struct building_type *bt_lighthouse = bt_find("lighthouse");
|
||||
|
||||
// [fast,last) interval of regions with a unit in it
|
||||
ctx->first = firstregion(f);
|
||||
ctx->last = lastregion(f);
|
||||
if (config_changed(&config)) {
|
||||
rule_region_owners = config_token("rules.region_owner_pay_building", bt_lighthouse->_name);
|
||||
}
|
||||
|
@ -1421,7 +1449,7 @@ void prepare_seen(report_context *ctx)
|
|||
if (u_race(u) != get_race(RC_SPELL) || u->number == RS_FARVISION) {
|
||||
faction_add_seen(f, r, seen_unit);
|
||||
}
|
||||
if (fval(r, RF_LIGHTHOUSE) {
|
||||
if (fval(r, RF_LIGHTHOUSE)) {
|
||||
// TODO: is the building big enough for the unit?
|
||||
if (u->building && u->building->type == bt_lighthouse) {
|
||||
/* we are in a lighthouse. add the regions we can see from here! */
|
||||
|
@ -1435,6 +1463,11 @@ void prepare_seen(report_context *ctx)
|
|||
travelthru_map(r, cb_add_seen, ctx);
|
||||
}
|
||||
}
|
||||
// [fast,last) interval of seen regions (with lighthouses and travel)
|
||||
// TODO: what about neighbours? when are they included? do we need
|
||||
// them outside of the CR?
|
||||
ctx->first = firstregion(f);
|
||||
ctx->last = lastregion(f);
|
||||
}
|
||||
|
||||
static void cb_set_last(region *r, unit *u, void *cbdata) {
|
||||
|
@ -1444,40 +1477,13 @@ static void cb_set_last(region *r, unit *u, void *cbdata) {
|
|||
}
|
||||
}
|
||||
|
||||
static region *lastregion(faction * f)
|
||||
{
|
||||
#ifdef SMART_INTERVALS
|
||||
return f->last->next;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static region *firstregion(faction * f)
|
||||
{
|
||||
#ifdef SMART_INTERVALS
|
||||
region *r = f->first;
|
||||
|
||||
if (f->units == NULL)
|
||||
return NULL;
|
||||
if (r != NULL)
|
||||
return r;
|
||||
|
||||
return f->first = regions;
|
||||
#else
|
||||
return regions;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void prepare_report(report_context *ctx, faction *f)
|
||||
{
|
||||
ctx->f = f;
|
||||
ctx->report_time = time(NULL);
|
||||
ctx->addresses = NULL;
|
||||
ctx->userdata = NULL;
|
||||
ctx->first = firstregion(f);
|
||||
ctx->last = lastregion(f);
|
||||
prepare_seen(&ctx);
|
||||
prepare_seen(ctx);
|
||||
}
|
||||
|
||||
static void finish_reports(report_context *ctx) {
|
||||
|
|
|
@ -56,7 +56,6 @@ extern "C" {
|
|||
void spunit(struct strlist **SP, const struct faction *f,
|
||||
const struct unit *u, unsigned int indent, seen_mode mode);
|
||||
|
||||
void prepare_seen(struct faction *f);
|
||||
int reports(void);
|
||||
int write_reports(struct faction *f, time_t ltime);
|
||||
int init_reports(void);
|
||||
|
@ -75,6 +74,8 @@ extern "C" {
|
|||
time_t report_time;
|
||||
} report_context;
|
||||
|
||||
void prepare_seen(struct report_context *ctx);
|
||||
|
||||
typedef int(*report_fun) (const char *filename, report_context * ctx,
|
||||
const char *charset);
|
||||
void register_reporttype(const char *extension, report_fun write,
|
||||
|
|
Loading…
Reference in a new issue