forked from github/server
BUG 2366: Fix cansee for seen_spell regions.
This commit is contained in:
parent
9d48bfc36c
commit
1b53128e1a
|
@ -114,7 +114,7 @@ static attrib *make_observer(faction *f, int perception)
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_observer(region *r, faction *f) {
|
int get_observer(const region *r, const faction *f) {
|
||||||
if (fval(r, RF_OBSERVER)) {
|
if (fval(r, RF_OBSERVER)) {
|
||||||
attrib *a = a_find(r->attribs, &at_observer);
|
attrib *a = a_find(r->attribs, &at_observer);
|
||||||
while (a && a->type == &at_observer) {
|
while (a && a->type == &at_observer) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ extern "C" {
|
||||||
extern void register_attributes(void);
|
extern void register_attributes(void);
|
||||||
|
|
||||||
void set_observer(struct region *r, struct faction *f, int perception, int turns);
|
void set_observer(struct region *r, struct faction *f, int perception, int turns);
|
||||||
int get_observer(struct region *r, struct faction *f);
|
int get_observer(const struct region *r, const struct faction *f);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -3847,7 +3847,7 @@ static bool start_battle(region * r, battle ** bp)
|
||||||
|
|
||||||
/* Beginn Fehlerbehandlung */
|
/* Beginn Fehlerbehandlung */
|
||||||
/* Fehler: "Die Einheit wurde nicht gefunden" */
|
/* Fehler: "Die Einheit wurde nicht gefunden" */
|
||||||
if (!u2 || u2->number == 0 || !cansee(u->faction, u->region, u2, 0)) {
|
if (!u2 || u2->number == 0 || !cansee(u->faction, u->region, u2, 0, seen_battle)) {
|
||||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord,
|
ADDMSG(&u->faction->msgs, msg_feedback(u, ord,
|
||||||
"feedback_unit_not_found", ""));
|
"feedback_unit_not_found", ""));
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -1363,7 +1363,7 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
|
||||||
building *b;
|
building *b;
|
||||||
ship *sh;
|
ship *sh;
|
||||||
unit *u;
|
unit *u;
|
||||||
int stealthmod = stealth_modifier(r->seen.mode);
|
int stealthmod = stealth_modifier(r, f, r->seen.mode);
|
||||||
|
|
||||||
if (r->land && r->land->display && r->land->display[0])
|
if (r->land && r->land->display && r->land->display[0])
|
||||||
fprintf(F, "\"%s\";Beschr\n", r->land->display);
|
fprintf(F, "\"%s\";Beschr\n", r->land->display);
|
||||||
|
@ -1497,7 +1497,7 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
|
||||||
for (u = r->units; u; u = u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
|
|
||||||
if (u->building || u->ship || (stealthmod > INT_MIN
|
if (u->building || u->ship || (stealthmod > INT_MIN
|
||||||
&& cansee(f, r, u, stealthmod))) {
|
&& cansee(f, r, u, stealthmod, r->seen.mode))) {
|
||||||
cr_output_unit_compat(F, r, f, u, r->seen.mode);
|
cr_output_unit_compat(F, r, f, u, r->seen.mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2454,7 +2454,7 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u2 = r->units; u2; u2 = u2->next) {
|
for (u2 = r->units; u2; u2 = u2->next) {
|
||||||
if (u2->faction == f && cansee(u->faction, r, u2, 0))
|
if (u2->faction == f && cansee_depr(u->faction, r, u2, 0))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -614,7 +614,7 @@ bool can_give_to(unit *u, unit *u2) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (u2 && !alliedunit(u2, u->faction, HELP_GIVE)
|
if (u2 && !alliedunit(u2, u->faction, HELP_GIVE)
|
||||||
&& !cansee(u->faction, u->region, u2, 0) && !ucontact(u2, u)
|
&& !cansee_depr(u->faction, u->region, u2, 0) && !ucontact(u2, u)
|
||||||
&& !fval(u2, UFL_TAKEALL)) {
|
&& !fval(u2, UFL_TAKEALL)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ static bool is_guardian_u(const unit * guard, unit * u)
|
||||||
return false;
|
return false;
|
||||||
if (ucontact(guard, u))
|
if (ucontact(guard, u))
|
||||||
return false;
|
return false;
|
||||||
if (!cansee(guard->faction, u->region, u, 0))
|
if (!cansee_depr(guard->faction, u->region, u, 0))
|
||||||
return false;
|
return false;
|
||||||
if (!(u_race(guard)->flags & RCF_FLY) && u_race(u)->flags & RCF_FLY)
|
if (!(u_race(guard)->flags & RCF_FLY) && u_race(u)->flags & RCF_FLY)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -113,7 +113,7 @@ static void destroy_road(unit * u, int nmax, struct order *ord)
|
||||||
|
|
||||||
for (u2 = r->units; u2; u2 = u2->next) {
|
for (u2 = r->units; u2; u2 = u2->next) {
|
||||||
if (u2->faction != u->faction && is_guard(u2)
|
if (u2->faction != u->faction && is_guard(u2)
|
||||||
&& cansee(u2->faction, u->region, u, 0)
|
&& cansee_depr(u2->faction, u->region, u, 0)
|
||||||
&& !alliedunit(u, u2->faction, HELP_GUARD)) {
|
&& !alliedunit(u, u2->faction, HELP_GUARD)) {
|
||||||
cmistake(u, ord, 70, MSG_EVENT);
|
cmistake(u, ord, 70, MSG_EVENT);
|
||||||
return;
|
return;
|
||||||
|
|
58
src/laws.c
58
src/laws.c
|
@ -1651,7 +1651,7 @@ static bool try_rename(unit *u, building *b, order *ord) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (owner) {
|
if (owner) {
|
||||||
if (cansee(owner->faction, u->region, u, 0)) {
|
if (cansee(owner->faction, u->region, u, 0, seen_unit)) {
|
||||||
ADDMSG(&owner->faction->msgs,
|
ADDMSG(&owner->faction->msgs,
|
||||||
msg_message("renamed_building_seen",
|
msg_message("renamed_building_seen",
|
||||||
"building renamer region", b, u, u->region));
|
"building renamer region", b, u, u->region));
|
||||||
|
@ -1747,7 +1747,7 @@ int name_cmd(struct unit *u, struct order *ord)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cansee(f, r, u, 0)) {
|
if (cansee(f, r, u, 0, seen_unit)) {
|
||||||
ADDMSG(&f->msgs,
|
ADDMSG(&f->msgs,
|
||||||
msg_message("renamed_faction_seen", "unit region", u, r));
|
msg_message("renamed_faction_seen", "unit region", u, r));
|
||||||
}
|
}
|
||||||
|
@ -1794,7 +1794,7 @@ int name_cmd(struct unit *u, struct order *ord)
|
||||||
}
|
}
|
||||||
uo = ship_owner(sh);
|
uo = ship_owner(sh);
|
||||||
if (uo) {
|
if (uo) {
|
||||||
if (cansee(uo->faction, r, u, 0)) {
|
if (cansee(uo->faction, r, u, 0, seen_unit)) {
|
||||||
ADDMSG(&uo->faction->msgs,
|
ADDMSG(&uo->faction->msgs,
|
||||||
msg_message("renamed_ship_seen", "ship renamer region", sh, u, r));
|
msg_message("renamed_ship_seen", "ship renamer region", sh, u, r));
|
||||||
}
|
}
|
||||||
|
@ -1823,7 +1823,7 @@ int name_cmd(struct unit *u, struct order *ord)
|
||||||
unit *u2 = 0;
|
unit *u2 = 0;
|
||||||
|
|
||||||
getunit(r, u->faction, &u2);
|
getunit(r, u->faction, &u2);
|
||||||
if (!u2 || !cansee(u->faction, r, u2, 0)) {
|
if (!u2 || !cansee(u->faction, r, u2, 0, seen_unit)) {
|
||||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord,
|
ADDMSG(&u->faction->msgs, msg_feedback(u, ord,
|
||||||
"feedback_unit_not_found", ""));
|
"feedback_unit_not_found", ""));
|
||||||
break;
|
break;
|
||||||
|
@ -1836,7 +1836,7 @@ int name_cmd(struct unit *u, struct order *ord)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cansee(u2->faction, r, u, 0)) {
|
if (cansee(u2->faction, r, u, 0, seen_unit)) {
|
||||||
ADDMSG(&u2->faction->msgs, msg_message("renamed_seen",
|
ADDMSG(&u2->faction->msgs, msg_message("renamed_seen",
|
||||||
"renamer renamed region", u, u2, r));
|
"renamer renamed region", u, u2, r));
|
||||||
}
|
}
|
||||||
|
@ -1898,7 +1898,7 @@ int name_cmd(struct unit *u, struct order *ord)
|
||||||
void
|
void
|
||||||
deliverMail(faction * f, region * r, unit * u, const char *s, unit * receiver)
|
deliverMail(faction * f, region * r, unit * u, const char *s, unit * receiver)
|
||||||
{
|
{
|
||||||
if (!cansee(f, r, u, 0)) {
|
if (!cansee(f, r, u, 0, seen_unit)) {
|
||||||
u = NULL;
|
u = NULL;
|
||||||
}
|
}
|
||||||
if (!receiver) { /* BOTSCHAFT an PARTEI */
|
if (!receiver) { /* BOTSCHAFT an PARTEI */
|
||||||
|
@ -1917,7 +1917,7 @@ mailunit(region * r, unit * u, int n, struct order *ord, const char *s)
|
||||||
{
|
{
|
||||||
unit *u2 = findunitr(r, n);
|
unit *u2 = findunitr(r, n);
|
||||||
|
|
||||||
if (u2 && cansee(u->faction, r, u2, 0)) {
|
if (u2 && cansee(u->faction, r, u2, 0, seen_unit)) {
|
||||||
deliverMail(u2->faction, r, u, s, u2);
|
deliverMail(u2->faction, r, u, s, u2);
|
||||||
/* now done in prepare_mail_cmd */
|
/* now done in prepare_mail_cmd */
|
||||||
}
|
}
|
||||||
|
@ -1995,7 +1995,7 @@ int mail_cmd(unit * u, struct order *ord)
|
||||||
n = getid();
|
n = getid();
|
||||||
|
|
||||||
for (u2 = r->units; u2; u2 = u2->next) {
|
for (u2 = r->units; u2; u2 = u2->next) {
|
||||||
if (u2->no == n && cansee(u->faction, r, u2, 0)) {
|
if (u2->no == n && cansee(u->faction, r, u2, 0, seen_unit)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2049,7 +2049,7 @@ int mail_cmd(unit * u, struct order *ord)
|
||||||
|
|
||||||
for (u2 = r->units; u2; u2 = u2->next) {
|
for (u2 = r->units; u2; u2 = u2->next) {
|
||||||
if (u2->building == b && !fval(u2->faction, FFL_SELECT)
|
if (u2->building == b && !fval(u2->faction, FFL_SELECT)
|
||||||
&& cansee(u->faction, r, u2, 0)) {
|
&& cansee(u->faction, r, u2, 0, seen_unit)) {
|
||||||
mailunit(r, u, u2->no, ord, s);
|
mailunit(r, u, u2->no, ord, s);
|
||||||
fset(u2->faction, FFL_SELECT);
|
fset(u2->faction, FFL_SELECT);
|
||||||
}
|
}
|
||||||
|
@ -2078,7 +2078,7 @@ int mail_cmd(unit * u, struct order *ord)
|
||||||
|
|
||||||
for (u2 = r->units; u2; u2 = u2->next) {
|
for (u2 = r->units; u2; u2 = u2->next) {
|
||||||
if (u2->ship == sh && !fval(u2->faction, FFL_SELECT)
|
if (u2->ship == sh && !fval(u2->faction, FFL_SELECT)
|
||||||
&& cansee(u->faction, r, u2, 0)) {
|
&& cansee(u->faction, r, u2, 0, seen_unit)) {
|
||||||
mailunit(r, u, u2->no, ord, s);
|
mailunit(r, u, u2->no, ord, s);
|
||||||
fset(u2->faction, FFL_SELECT);
|
fset(u2->faction, FFL_SELECT);
|
||||||
}
|
}
|
||||||
|
@ -4281,10 +4281,9 @@ void update_subscriptions(void)
|
||||||
* Es muss auch niemand aus f in der region sein, wenn sie vom Turm
|
* Es muss auch niemand aus f in der region sein, wenn sie vom Turm
|
||||||
* erblickt wird */
|
* erblickt wird */
|
||||||
bool
|
bool
|
||||||
cansee(const faction * f, const region * r, const unit * u, int modifier)
|
cansee(const faction * f, const region * r, const unit * u, int modifier, seen_mode mode)
|
||||||
{
|
{
|
||||||
int stealth, rings;
|
int stealth, rings;
|
||||||
unit *u2 = r->units;
|
|
||||||
|
|
||||||
if (u->faction == f || omniscient(f)) {
|
if (u->faction == f || omniscient(f)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -4303,23 +4302,21 @@ cansee(const faction * f, const region * r, const unit * u, int modifier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leftship(u))
|
/* simple visibility, just gotta have a viewer in the region to see 'em */
|
||||||
return true;
|
if (leftship(u) || is_guard(u) || usiege(u) || u->building || u->ship) {
|
||||||
|
|
||||||
while (u2 && u2->faction != f)
|
|
||||||
u2 = u2->next;
|
|
||||||
if (u2 == NULL)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
/* simple visibility, just gotta have a unit in the region to see 'em */
|
|
||||||
if (is_guard(u) || usiege(u) || u->building || u->ship) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
rings = invisible(u, NULL);
|
rings = invisible(u, NULL);
|
||||||
stealth = eff_stealth(u, r) - modifier;
|
stealth = eff_stealth(u, r) - modifier;
|
||||||
|
|
||||||
while (u2) {
|
if (mode > seen_unit) {
|
||||||
|
return (rings <= 0 || stealth <= 0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
unit *u2;
|
||||||
|
for (u2 = r->units; u2; u2 = u2->next) {
|
||||||
|
if (u2->faction == f) {
|
||||||
if (rings < u->number || invisible(u, u2) < u->number) {
|
if (rings < u->number || invisible(u, u2) < u->number) {
|
||||||
if (skill_enabled(SK_PERCEPTION)) {
|
if (skill_enabled(SK_PERCEPTION)) {
|
||||||
int observation = effskill(u2, SK_PERCEPTION, 0);
|
int observation = effskill(u2, SK_PERCEPTION, 0);
|
||||||
|
@ -4332,15 +4329,18 @@ cansee(const faction * f, const region * r, const unit * u, int modifier)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* find next unit in our faction */
|
}
|
||||||
do {
|
|
||||||
u2 = u2->next;
|
|
||||||
} while (u2 && u2->faction != f);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
cansee_depr(const faction * f, const region * r, const unit * u, int modifier)
|
||||||
|
{
|
||||||
|
return cansee(f, r, u, modifier, seen_unit);
|
||||||
|
}
|
||||||
|
|
||||||
bool cansee_unit(const unit * u, const unit * target, int modifier)
|
bool cansee_unit(const unit * u, const unit * target, int modifier)
|
||||||
/* target->region kann != u->region sein, wenn es um durchreisen geht */
|
/* target->region kann != u->region sein, wenn es um durchreisen geht */
|
||||||
{
|
{
|
||||||
|
@ -4427,7 +4427,7 @@ bool
|
||||||
seefaction(const faction * f, const region * r, const unit * u, int modifier)
|
seefaction(const faction * f, const region * r, const unit * u, int modifier)
|
||||||
{
|
{
|
||||||
if (((f == u->faction) || !fval(u, UFL_ANON_FACTION))
|
if (((f == u->faction) || !fval(u, UFL_ANON_FACTION))
|
||||||
&& cansee(f, r, u, modifier))
|
&& cansee(f, r, u, modifier, seen_unit))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,9 @@ extern "C" {
|
||||||
|
|
||||||
void nmr_warnings(void);
|
void nmr_warnings(void);
|
||||||
|
|
||||||
bool cansee(const struct faction *f, const struct region *r,
|
bool cansee(const struct faction * f, const struct region * r,
|
||||||
|
const struct unit *u, int modifier, seen_mode mode);
|
||||||
|
bool cansee_depr(const struct faction *f, const struct region *r,
|
||||||
const struct unit *u, int modifier);
|
const struct unit *u, int modifier);
|
||||||
bool cansee_durchgezogen(const struct faction *f, const struct region *r,
|
bool cansee_durchgezogen(const struct faction *f, const struct region *r,
|
||||||
const struct unit *u, int modifier);
|
const struct unit *u, int modifier);
|
||||||
|
|
|
@ -1621,7 +1621,7 @@ order * ord)
|
||||||
if (u->region != r)
|
if (u->region != r)
|
||||||
u = NULL;
|
u = NULL;
|
||||||
else if (sp->sptyp & TESTCANSEE) {
|
else if (sp->sptyp & TESTCANSEE) {
|
||||||
if (!cansee(mage->faction, r, u, 0) && !ucontact(u, mage)) {
|
if (!cansee_depr(mage->faction, r, u, 0) && !ucontact(u, mage)) {
|
||||||
u = NULL;
|
u = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,7 @@ static order *monster_attack(unit * u, const unit * target)
|
||||||
{
|
{
|
||||||
assert(u->region == target->region);
|
assert(u->region == target->region);
|
||||||
assert(u->faction != target->faction);
|
assert(u->faction != target->faction);
|
||||||
if (!cansee(u->faction, u->region, target, 0))
|
if (!cansee_depr(u->faction, u->region, target, 0))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (monster_is_waiting(u))
|
if (monster_is_waiting(u))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -199,7 +199,7 @@ int monster_attacks(unit * monster, bool rich_only)
|
||||||
int money = 0;
|
int money = 0;
|
||||||
|
|
||||||
for (u2 = r->units; u2; u2 = u2->next) {
|
for (u2 = r->units; u2; u2 = u2->next) {
|
||||||
if (u2->faction != monster->faction && cansee(monster->faction, r, u2, 0) && !in_safe_building(u2, monster)) {
|
if (u2->faction != monster->faction && cansee_depr(monster->faction, r, u2, 0) && !in_safe_building(u2, monster)) {
|
||||||
int m = get_money(u2);
|
int m = get_money(u2);
|
||||||
if (u_race(monster) == rc_serpent) {
|
if (u_race(monster) == rc_serpent) {
|
||||||
/* attack bigger ships only */
|
/* attack bigger ships only */
|
||||||
|
|
|
@ -912,7 +912,7 @@ static void caught_target(region * r, unit * u)
|
||||||
target, u));
|
target, u));
|
||||||
}
|
}
|
||||||
else if (!alliedunit(target, u->faction, HELP_ALL)
|
else if (!alliedunit(target, u->faction, HELP_ALL)
|
||||||
&& cansee(target->faction, r, u, 0)) {
|
&& cansee_depr(target->faction, r, u, 0)) {
|
||||||
ADDMSG(&target->faction->msgs, msg_message("followdetect",
|
ADDMSG(&target->faction->msgs, msg_message("followdetect",
|
||||||
"unit follower", target, u));
|
"unit follower", target, u));
|
||||||
}
|
}
|
||||||
|
@ -1185,7 +1185,7 @@ static void init_transportation(void)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!transport(ut, u)) {
|
if (!transport(ut, u)) {
|
||||||
if (cansee(u->faction, r, ut, 0)) {
|
if (cansee_depr(u->faction, r, ut, 0)) {
|
||||||
cmistake(u, u->thisorder, 286, MSG_MOVE);
|
cmistake(u, u->thisorder, 286, MSG_MOVE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2093,7 +2093,7 @@ static const region_list *travel_i(unit * u, const region_list * route_begin,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
if (cansee(u->faction, u->region, ut, 0)) {
|
if (cansee_depr(u->faction, u->region, ut, 0)) {
|
||||||
cmistake(u, ord, 90, MSG_MOVE);
|
cmistake(u, ord, 90, MSG_MOVE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2604,7 +2604,7 @@ void follow_unit(unit * u)
|
||||||
u2 = a->data.v;
|
u2 = a->data.v;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!u2 || (!followship && (u2->region != r || !cansee(u->faction, r, u2, 0)))) {
|
if (!u2 || (!followship && (u2->region != r || !cansee_depr(u->faction, r, u2, 0)))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
src/report.c
10
src/report.c
|
@ -2269,7 +2269,7 @@ report_plaintext(const char *filename, report_context * ctx,
|
||||||
anyunits = 0;
|
anyunits = 0;
|
||||||
|
|
||||||
for (r = ctx->first; r != ctx->last; r = r->next) {
|
for (r = ctx->first; r != ctx->last; r = r->next) {
|
||||||
int stealthmod = stealth_modifier(r->seen.mode);
|
int stealthmod = stealth_modifier(r, f, r->seen.mode);
|
||||||
building *b = r->buildings;
|
building *b = r->buildings;
|
||||||
ship *sh = r->ships;
|
ship *sh = r->ships;
|
||||||
|
|
||||||
|
@ -2314,14 +2314,12 @@ report_plaintext(const char *filename, report_context * ctx,
|
||||||
newline(out);
|
newline(out);
|
||||||
report_travelthru(out, r, f);
|
report_travelthru(out, r, f);
|
||||||
}
|
}
|
||||||
/* Statistik */
|
|
||||||
|
|
||||||
if (wants_stats && r->seen.mode >= seen_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 (r->seen.mode >= seen_travel) {
|
||||||
if (r->seen.mode == seen_unit || r->seen.mode == seen_travel) {
|
|
||||||
message_list *mlist = r_getmessages(r, f);
|
message_list *mlist = r_getmessages(r, f);
|
||||||
if (mlist) {
|
if (mlist) {
|
||||||
struct mlist **split = merge_messages(mlist, r->msgs);
|
struct mlist **split = merge_messages(mlist, r->msgs);
|
||||||
|
@ -2350,8 +2348,8 @@ report_plaintext(const char *filename, report_context * ctx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (u && !u->ship) {
|
while (u && !u->ship) {
|
||||||
if (stealthmod > INT_MIN) {
|
if (stealthmod > INT_MIN && r->seen.mode >= seen_unit) {
|
||||||
if (u->faction == f || cansee(f, r, u, stealthmod)) {
|
if (u->faction == f || cansee(f, r, u, stealthmod, r->seen.mode)) {
|
||||||
nr_unit(out, f, u, 4, r->seen.mode);
|
nr_unit(out, f, u, 4, r->seen.mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -960,15 +960,16 @@ struct message *msg_curse(const struct curse *c, const void *obj, objtype_t typ,
|
||||||
const struct unit *ucansee(const struct faction *f, const struct unit *u,
|
const struct unit *ucansee(const struct faction *f, const struct unit *u,
|
||||||
const struct unit *x)
|
const struct unit *x)
|
||||||
{
|
{
|
||||||
if (cansee(f, u->region, u, 0))
|
if (cansee_depr(f, u->region, u, 0))
|
||||||
return u;
|
return u;
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
int stealth_modifier(seen_mode mode)
|
int stealth_modifier(const region *r, const faction *f, seen_mode mode)
|
||||||
{
|
{
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case seen_spell:
|
case seen_spell:
|
||||||
|
return get_observer(r, f);
|
||||||
case seen_unit:
|
case seen_unit:
|
||||||
return 0;
|
return 0;
|
||||||
case seen_lighthouse:
|
case seen_lighthouse:
|
||||||
|
@ -1061,14 +1062,14 @@ void get_addresses(report_context * ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; r != NULL; r = r->next) {
|
for (; r != NULL; r = r->next) {
|
||||||
int stealthmod = stealth_modifier(r->seen.mode);
|
int stealthmod = stealth_modifier(r, ctx->f, r->seen.mode);
|
||||||
if (r->seen.mode == seen_lighthouse) {
|
if (r->seen.mode == seen_lighthouse) {
|
||||||
unit *u = r->units;
|
unit *u = r->units;
|
||||||
for (; u; u = u->next) {
|
for (; u; u = u->next) {
|
||||||
faction *sf = visible_faction(ctx->f, u);
|
faction *sf = visible_faction(ctx->f, u);
|
||||||
if (lastf != sf) {
|
if (lastf != sf) {
|
||||||
if (u->building || u->ship || (stealthmod > INT_MIN
|
if (u->building || u->ship || (stealthmod > INT_MIN
|
||||||
&& cansee(ctx->f, r, u, stealthmod))) {
|
&& cansee_depr(ctx->f, r, u, stealthmod))) {
|
||||||
add_seen_faction_i(&flist, sf);
|
add_seen_faction_i(&flist, sf);
|
||||||
lastf = sf;
|
lastf = sf;
|
||||||
}
|
}
|
||||||
|
@ -1086,7 +1087,7 @@ void get_addresses(report_context * ctx)
|
||||||
if (u->faction != ctx->f) {
|
if (u->faction != ctx->f) {
|
||||||
faction *sf = visible_faction(ctx->f, u);
|
faction *sf = visible_faction(ctx->f, u);
|
||||||
bool ballied = sf && sf != ctx->f && sf != lastf
|
bool ballied = sf && sf != ctx->f && sf != lastf
|
||||||
&& !fval(u, UFL_ANON_FACTION) && cansee(ctx->f, r, u, stealthmod);
|
&& !fval(u, UFL_ANON_FACTION) && cansee_depr(ctx->f, r, u, stealthmod);
|
||||||
if (ballied || is_allied(ctx->f, sf)) {
|
if (ballied || is_allied(ctx->f, sf)) {
|
||||||
add_seen_faction_i(&flist, sf);
|
add_seen_faction_i(&flist, sf);
|
||||||
lastf = sf;
|
lastf = sf;
|
||||||
|
|
|
@ -70,7 +70,7 @@ extern "C" {
|
||||||
const struct unit *ucansee(const struct faction *f,
|
const struct unit *ucansee(const struct faction *f,
|
||||||
const struct unit *u, const struct unit *x);
|
const struct unit *u, const struct unit *x);
|
||||||
|
|
||||||
int stealth_modifier(seen_mode seen_mode);
|
int stealth_modifier(const struct region *r, const struct faction *f, seen_mode mode);
|
||||||
|
|
||||||
typedef struct report_context {
|
typedef struct report_context {
|
||||||
struct faction *f;
|
struct faction *f;
|
||||||
|
|
|
@ -762,6 +762,24 @@ static void test_report_far_vision(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_stealth_modifier(CuTest *tc) {
|
||||||
|
region *r;
|
||||||
|
faction *f;
|
||||||
|
|
||||||
|
test_setup();
|
||||||
|
f = test_create_faction(NULL);
|
||||||
|
r = test_create_region(0, 0, NULL);
|
||||||
|
CuAssertIntEquals(tc, 0, stealth_modifier(r, f, seen_unit));
|
||||||
|
CuAssertIntEquals(tc, -1, stealth_modifier(r, f, seen_travel));
|
||||||
|
CuAssertIntEquals(tc, -2, stealth_modifier(r, f, seen_lighthouse));
|
||||||
|
CuAssertIntEquals(tc, -1, stealth_modifier(r, f, seen_spell));
|
||||||
|
|
||||||
|
set_observer(r, f, 10, 1);
|
||||||
|
CuAssertIntEquals(tc, 10, stealth_modifier(r, f, seen_spell));
|
||||||
|
CuAssertIntEquals(tc, -1, stealth_modifier(r, NULL, seen_spell));
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
CuSuite *get_reports_suite(void)
|
CuSuite *get_reports_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
|
@ -782,6 +800,7 @@ CuSuite *get_reports_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_report_far_vision);
|
SUITE_ADD_TEST(suite, test_report_far_vision);
|
||||||
SUITE_ADD_TEST(suite, test_reorder_units);
|
SUITE_ADD_TEST(suite, test_reorder_units);
|
||||||
SUITE_ADD_TEST(suite, test_seen_faction);
|
SUITE_ADD_TEST(suite, test_seen_faction);
|
||||||
|
SUITE_ADD_TEST(suite, test_stealth_modifier);
|
||||||
SUITE_ADD_TEST(suite, test_regionid);
|
SUITE_ADD_TEST(suite, test_regionid);
|
||||||
SUITE_ADD_TEST(suite, test_sparagraph);
|
SUITE_ADD_TEST(suite, test_sparagraph);
|
||||||
SUITE_ADD_TEST(suite, test_sparagraph_long);
|
SUITE_ADD_TEST(suite, test_sparagraph_long);
|
||||||
|
|
38
src/spells.c
38
src/spells.c
|
@ -362,11 +362,11 @@ int report_action(region * r, unit * actor, message * msg, int flags)
|
||||||
if (view == ACTION_CANSEE) {
|
if (view == ACTION_CANSEE) {
|
||||||
/* Bei Fernzaubern sieht nur die eigene Partei den Magier */
|
/* Bei Fernzaubern sieht nur die eigene Partei den Magier */
|
||||||
show = show || (r == actor->region
|
show = show || (r == actor->region
|
||||||
&& cansee(u->faction, r, actor, 0));
|
&& cansee_depr(u->faction, r, actor, 0));
|
||||||
}
|
}
|
||||||
else if (view == ACTION_CANNOTSEE) {
|
else if (view == ACTION_CANNOTSEE) {
|
||||||
show = !show && !(r == actor->region
|
show = !show && !(r == actor->region
|
||||||
&& cansee(u->faction, r, actor, 0));
|
&& cansee_depr(u->faction, r, actor, 0));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* the unliely (or lazy) case */
|
/* the unliely (or lazy) case */
|
||||||
|
@ -1328,7 +1328,7 @@ static int sp_rosthauch(castorder * co)
|
||||||
"mage target amount", mage, u, ironweapon));
|
"mage target amount", mage, u, ironweapon));
|
||||||
ADDMSG(&u->faction->msgs, msg_message("rust_effect",
|
ADDMSG(&u->faction->msgs, msg_message("rust_effect",
|
||||||
"mage target amount",
|
"mage target amount",
|
||||||
cansee(u->faction, r, mage, 0) ? mage : NULL, u, ironweapon));
|
cansee_depr(u->faction, r, mage, 0) ? mage : NULL, u, ironweapon));
|
||||||
success += ironweapon;
|
success += ironweapon;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1405,7 +1405,7 @@ static int sp_kaelteschutz(castorder * co)
|
||||||
u));
|
u));
|
||||||
if (u->faction != mage->faction)
|
if (u->faction != mage->faction)
|
||||||
ADDMSG(&u->faction->msgs, msg_message("heat_effect", "mage target",
|
ADDMSG(&u->faction->msgs, msg_message("heat_effect", "mage target",
|
||||||
cansee(u->faction, r, mage, 0) ? mage : NULL, u));
|
cansee_depr(u->faction, r, mage, 0) ? mage : NULL, u));
|
||||||
i = cast_level;
|
i = cast_level;
|
||||||
}
|
}
|
||||||
/* Erstattung? */
|
/* Erstattung? */
|
||||||
|
@ -1825,7 +1825,7 @@ static int sp_treewalkenter(castorder * co)
|
||||||
m = NULL;
|
m = NULL;
|
||||||
for (u2 = r->units; u2; u2 = u2->next) {
|
for (u2 = r->units; u2; u2 = u2->next) {
|
||||||
if (!fval(u2->faction, FFL_SELECT)) {
|
if (!fval(u2->faction, FFL_SELECT)) {
|
||||||
if (cansee(u2->faction, r, u, 0)) {
|
if (cansee_depr(u2->faction, r, u, 0)) {
|
||||||
fset(u2->faction, FFL_SELECT);
|
fset(u2->faction, FFL_SELECT);
|
||||||
if (!m)
|
if (!m)
|
||||||
m = msg_message("astral_disappear", "unit", u);
|
m = msg_message("astral_disappear", "unit", u);
|
||||||
|
@ -1842,7 +1842,7 @@ static int sp_treewalkenter(castorder * co)
|
||||||
m = NULL;
|
m = NULL;
|
||||||
for (u2 = rt->units; u2; u2 = u2->next) {
|
for (u2 = rt->units; u2; u2 = u2->next) {
|
||||||
if (!fval(u2->faction, FFL_SELECT)) {
|
if (!fval(u2->faction, FFL_SELECT)) {
|
||||||
if (cansee(u2->faction, rt, u, 0)) {
|
if (cansee_depr(u2->faction, rt, u, 0)) {
|
||||||
fset(u2->faction, FFL_SELECT);
|
fset(u2->faction, FFL_SELECT);
|
||||||
if (!m)
|
if (!m)
|
||||||
m = msg_message("astral_appear", "unit", u);
|
m = msg_message("astral_appear", "unit", u);
|
||||||
|
@ -1971,7 +1971,7 @@ static int sp_treewalkexit(castorder * co)
|
||||||
m = NULL;
|
m = NULL;
|
||||||
for (u2 = r->units; u2; u2 = u2->next) {
|
for (u2 = r->units; u2; u2 = u2->next) {
|
||||||
if (!fval(u2->faction, FFL_SELECT)) {
|
if (!fval(u2->faction, FFL_SELECT)) {
|
||||||
if (cansee(u2->faction, r, u, 0)) {
|
if (cansee_depr(u2->faction, r, u, 0)) {
|
||||||
fset(u2->faction, FFL_SELECT);
|
fset(u2->faction, FFL_SELECT);
|
||||||
if (!m)
|
if (!m)
|
||||||
m = msg_message("astral_disappear", "unit", u);
|
m = msg_message("astral_disappear", "unit", u);
|
||||||
|
@ -1989,7 +1989,7 @@ static int sp_treewalkexit(castorder * co)
|
||||||
m = NULL;
|
m = NULL;
|
||||||
for (u2 = rt->units; u2; u2 = u2->next) {
|
for (u2 = rt->units; u2; u2 = u2->next) {
|
||||||
if (!fval(u2->faction, FFL_SELECT)) {
|
if (!fval(u2->faction, FFL_SELECT)) {
|
||||||
if (cansee(u2->faction, rt, u, 0)) {
|
if (cansee_depr(u2->faction, rt, u, 0)) {
|
||||||
fset(u2->faction, FFL_SELECT);
|
fset(u2->faction, FFL_SELECT);
|
||||||
if (!m)
|
if (!m)
|
||||||
m = msg_message("astral_appear", "unit", u);
|
m = msg_message("astral_appear", "unit", u);
|
||||||
|
@ -2954,7 +2954,7 @@ static int sp_deathcloud(castorder * co)
|
||||||
if (!fval(u->faction, FFL_SELECT)) {
|
if (!fval(u->faction, FFL_SELECT)) {
|
||||||
fset(u->faction, FFL_SELECT);
|
fset(u->faction, FFL_SELECT);
|
||||||
ADDMSG(&u->faction->msgs, msg_message("deathcloud_effect",
|
ADDMSG(&u->faction->msgs, msg_message("deathcloud_effect",
|
||||||
"mage region", cansee(u->faction, r, mage, 0) ? mage : NULL, r));
|
"mage region", cansee_depr(u->faction, r, mage, 0) ? mage : NULL, r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3848,7 +3848,7 @@ static int sp_song_of_peace(castorder * co)
|
||||||
if (!fval(u->faction, FFL_SELECT)) {
|
if (!fval(u->faction, FFL_SELECT)) {
|
||||||
message *m = NULL;
|
message *m = NULL;
|
||||||
fset(u->faction, FFL_SELECT);
|
fset(u->faction, FFL_SELECT);
|
||||||
if (cansee(u->faction, r, mage, 0)) {
|
if (cansee_depr(u->faction, r, mage, 0)) {
|
||||||
if (msg[0] == NULL)
|
if (msg[0] == NULL)
|
||||||
msg[0] = msg_message("song_of_peace_effect_0", "mage", mage);
|
msg[0] = msg_message("song_of_peace_effect_0", "mage", mage);
|
||||||
m = msg[0];
|
m = msg[0];
|
||||||
|
@ -3905,7 +3905,7 @@ static int sp_generous(castorder * co)
|
||||||
if (!fval(u->faction, FFL_SELECT)) {
|
if (!fval(u->faction, FFL_SELECT)) {
|
||||||
message *m = NULL;
|
message *m = NULL;
|
||||||
fset(u->faction, FFL_SELECT);
|
fset(u->faction, FFL_SELECT);
|
||||||
if (cansee(u->faction, r, mage, 0)) {
|
if (cansee_depr(u->faction, r, mage, 0)) {
|
||||||
if (msg[0] == NULL)
|
if (msg[0] == NULL)
|
||||||
msg[0] = msg_message("generous_effect_0", "mage", mage);
|
msg[0] = msg_message("generous_effect_0", "mage", mage);
|
||||||
m = msg[0];
|
m = msg[0];
|
||||||
|
@ -5040,7 +5040,7 @@ int sp_enterastral(castorder * co)
|
||||||
m = NULL;
|
m = NULL;
|
||||||
for (u2 = r->units; u2; u2 = u2->next) {
|
for (u2 = r->units; u2; u2 = u2->next) {
|
||||||
if (!fval(u2->faction, FFL_SELECT)) {
|
if (!fval(u2->faction, FFL_SELECT)) {
|
||||||
if (cansee(u2->faction, r, u, 0)) {
|
if (cansee_depr(u2->faction, r, u, 0)) {
|
||||||
fset(u2->faction, FFL_SELECT);
|
fset(u2->faction, FFL_SELECT);
|
||||||
if (!m)
|
if (!m)
|
||||||
m = msg_message("astral_disappear", "unit", u);
|
m = msg_message("astral_disappear", "unit", u);
|
||||||
|
@ -5058,7 +5058,7 @@ int sp_enterastral(castorder * co)
|
||||||
m = NULL;
|
m = NULL;
|
||||||
for (u2 = rt->units; u2; u2 = u2->next) {
|
for (u2 = rt->units; u2; u2 = u2->next) {
|
||||||
if (!fval(u2->faction, FFL_SELECT)) {
|
if (!fval(u2->faction, FFL_SELECT)) {
|
||||||
if (cansee(u2->faction, rt, u, 0)) {
|
if (cansee_depr(u2->faction, rt, u, 0)) {
|
||||||
fset(u2->faction, FFL_SELECT);
|
fset(u2->faction, FFL_SELECT);
|
||||||
if (!m)
|
if (!m)
|
||||||
m = msg_message("astral_appear", "unit", u);
|
m = msg_message("astral_appear", "unit", u);
|
||||||
|
@ -5184,7 +5184,7 @@ int sp_pullastral(castorder * co)
|
||||||
m = NULL;
|
m = NULL;
|
||||||
for (u2 = r->units; u2; u2 = u2->next) {
|
for (u2 = r->units; u2; u2 = u2->next) {
|
||||||
if (!fval(u2->faction, FFL_SELECT)) {
|
if (!fval(u2->faction, FFL_SELECT)) {
|
||||||
if (cansee(u2->faction, r, u, 0)) {
|
if (cansee_depr(u2->faction, r, u, 0)) {
|
||||||
fset(u2->faction, FFL_SELECT);
|
fset(u2->faction, FFL_SELECT);
|
||||||
if (!m)
|
if (!m)
|
||||||
m = msg_message("astral_disappear", "unit", u);
|
m = msg_message("astral_disappear", "unit", u);
|
||||||
|
@ -5202,7 +5202,7 @@ int sp_pullastral(castorder * co)
|
||||||
m = NULL;
|
m = NULL;
|
||||||
for (u2 = rt->units; u2; u2 = u2->next) {
|
for (u2 = rt->units; u2; u2 = u2->next) {
|
||||||
if (!fval(u2->faction, FFL_SELECT)) {
|
if (!fval(u2->faction, FFL_SELECT)) {
|
||||||
if (cansee(u2->faction, rt, u, 0)) {
|
if (cansee_depr(u2->faction, rt, u, 0)) {
|
||||||
fset(u2->faction, FFL_SELECT);
|
fset(u2->faction, FFL_SELECT);
|
||||||
if (!m)
|
if (!m)
|
||||||
m = msg_message("astral_appear", "unit", u);
|
m = msg_message("astral_appear", "unit", u);
|
||||||
|
@ -5315,7 +5315,7 @@ int sp_leaveastral(castorder * co)
|
||||||
m = NULL;
|
m = NULL;
|
||||||
for (u2 = r->units; u2; u2 = u2->next) {
|
for (u2 = r->units; u2; u2 = u2->next) {
|
||||||
if (!fval(u2->faction, FFL_SELECT)) {
|
if (!fval(u2->faction, FFL_SELECT)) {
|
||||||
if (cansee(u2->faction, r, u, 0)) {
|
if (cansee_depr(u2->faction, r, u, 0)) {
|
||||||
fset(u2->faction, FFL_SELECT);
|
fset(u2->faction, FFL_SELECT);
|
||||||
if (!m)
|
if (!m)
|
||||||
m = msg_message("astral_disappear", "unit", u);
|
m = msg_message("astral_disappear", "unit", u);
|
||||||
|
@ -5333,7 +5333,7 @@ int sp_leaveastral(castorder * co)
|
||||||
m = NULL;
|
m = NULL;
|
||||||
for (u2 = rt->units; u2; u2 = u2->next) {
|
for (u2 = rt->units; u2; u2 = u2->next) {
|
||||||
if (!fval(u2->faction, FFL_SELECT)) {
|
if (!fval(u2->faction, FFL_SELECT)) {
|
||||||
if (cansee(u2->faction, rt, u, 0)) {
|
if (cansee_depr(u2->faction, rt, u, 0)) {
|
||||||
fset(u2->faction, FFL_SELECT);
|
fset(u2->faction, FFL_SELECT);
|
||||||
if (!m)
|
if (!m)
|
||||||
m = msg_message("astral_appear", "unit", u);
|
m = msg_message("astral_appear", "unit", u);
|
||||||
|
@ -5443,7 +5443,7 @@ int sp_fetchastral(castorder * co)
|
||||||
m = NULL;
|
m = NULL;
|
||||||
for (u2 = ro->units; u2; u2 = u2->next) {
|
for (u2 = ro->units; u2; u2 = u2->next) {
|
||||||
if (!fval(u2->faction, FFL_SELECT)) {
|
if (!fval(u2->faction, FFL_SELECT)) {
|
||||||
if (cansee(u2->faction, ro, u, 0)) {
|
if (cansee_depr(u2->faction, ro, u, 0)) {
|
||||||
fset(u2->faction, FFL_SELECT);
|
fset(u2->faction, FFL_SELECT);
|
||||||
if (!m)
|
if (!m)
|
||||||
m = msg_message("astral_disappear", "unit", u);
|
m = msg_message("astral_disappear", "unit", u);
|
||||||
|
@ -5460,7 +5460,7 @@ int sp_fetchastral(castorder * co)
|
||||||
m = NULL;
|
m = NULL;
|
||||||
for (u2 = rt->units; u2; u2 = u2->next) {
|
for (u2 = rt->units; u2; u2 = u2->next) {
|
||||||
if (!fval(u2->faction, FFL_SELECT)) {
|
if (!fval(u2->faction, FFL_SELECT)) {
|
||||||
if (cansee(u2->faction, rt, u, 0)) {
|
if (cansee_depr(u2->faction, rt, u, 0)) {
|
||||||
fset(u2->faction, FFL_SELECT);
|
fset(u2->faction, FFL_SELECT);
|
||||||
if (!m)
|
if (!m)
|
||||||
m = msg_message("astral_appear", "unit", u);
|
m = msg_message("astral_appear", "unit", u);
|
||||||
|
|
|
@ -193,7 +193,7 @@ static bool can_set_factionstealth(const unit * u, const faction * f)
|
||||||
if (ru->number) {
|
if (ru->number) {
|
||||||
faction *fv = visible_faction(f, ru);
|
faction *fv = visible_faction(f, ru);
|
||||||
if (fv == f) {
|
if (fv == f) {
|
||||||
if (cansee(f, lastr, ru, 0))
|
if (cansee_depr(f, lastr, ru, 0))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue