"Partei fehlt im Report"

Behandlung von Turmregionen. Hoffentlich richtig.
This commit is contained in:
Enno Rehling 2007-02-21 19:59:27 +00:00
parent 0cd853e38d
commit 3567e3f783
5 changed files with 49 additions and 53 deletions

View File

@ -71,6 +71,7 @@
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <math.h> #include <math.h>
#include <limits.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -1252,7 +1253,6 @@ report_computer(const char * filename, report_context * ctx)
} }
for (;sr!=NULL;sr=sr->next) { for (;sr!=NULL;sr=sr->next) {
region * r = sr->r; region * r = sr->r;
int modifier = 0;
const char * tname; const char * tname;
if (!rplane(r)) { if (!rplane(r)) {
@ -1288,6 +1288,7 @@ report_computer(const char * filename, report_context * ctx)
if (sr->mode == see_neighbour) { if (sr->mode == see_neighbour) {
cr_borders(ctx->seen, r, f, sr->mode, F); cr_borders(ctx->seen, r, f, sr->mode, F);
} else { } else {
int stealthmod = stealth_modifier(sr->mode);
#define RESOURCECOMPAT #define RESOURCECOMPAT
char cbuf[8192], *pos = cbuf; char cbuf[8192], *pos = cbuf;
#ifdef RESOURCECOMPAT #ifdef RESOURCECOMPAT
@ -1456,23 +1457,10 @@ report_computer(const char * filename, report_context * ctx)
/* visible units */ /* visible units */
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
boolean visible = true;
switch (sr->mode) { if (u->building || u->ship || (stealthmod>INT_MIN && cansee(f, r, u, stealthmod))) {
case see_unit: cr_output_unit(F, r, f, u, sr->mode);
modifier=0;
break;
case see_far:
case see_lighthouse:
modifier = -2;
break;
case see_travel:
modifier = -1;
break;
default:
visible=false;
} }
if (u->building || u->ship || (visible && cansee(f, r, u, modifier)))
cr_output_unit(F, r, f, u, sr->mode);
} }
} /* region traversal */ } /* region traversal */
} }

View File

@ -1989,29 +1989,12 @@ report_plaintext(const char * filename, report_context * ctx)
} }
for (;sr!=NULL;sr=sr->next) { for (;sr!=NULL;sr=sr->next) {
region * r = sr->r; region * r = sr->r;
boolean unit_in_region = false; int stealthmod = stealth_modifier(sr->mode);
boolean durchgezogen_in_region = false;
int turm_sieht_region = false;
switch (sr->mode) { if (sr->mode<see_lighthouse) continue;
case see_lighthouse:
turm_sieht_region = true;
break;
case see_far:
break;
case see_travel:
durchgezogen_in_region = true;
break;
case see_unit:
unit_in_region = true;
anyunits = true;
break;
default:
continue;
}
/* Beschreibung */ /* Beschreibung */
if (unit_in_region) { if (sr->mode==see_unit) {
describe(F, r, 0, f); describe(F, r, 0, f);
if (!TradeDisabled() && !fval(r->terrain, SEA_REGION) && rpeasants(r)/TRADE_FRACTION > 0) { if (!TradeDisabled() && !fval(r->terrain, SEA_REGION) && rpeasants(r)/TRADE_FRACTION > 0) {
rnl(F); rnl(F);
@ -2026,7 +2009,7 @@ report_plaintext(const char * filename, report_context * ctx)
guards(F, r, f); guards(F, r, f);
durchreisende(F, r, f); durchreisende(F, r, f);
} }
else if (turm_sieht_region) { else if (sr->mode==see_lighthouse) {
describe(F, r, 2, f); describe(F, r, 2, f);
durchreisende(F, r, f); durchreisende(F, r, f);
} else { } else {
@ -2036,12 +2019,12 @@ report_plaintext(const char * filename, report_context * ctx)
} }
/* Statistik */ /* Statistik */
if (wants_stats && unit_in_region == 1) if (wants_stats && sr->mode==see_unit)
statistics(F, r, f); statistics(F, r, f);
/* Nachrichten an REGION in der Region */ /* Nachrichten an REGION in der Region */
if (unit_in_region || durchgezogen_in_region) { if (sr->mode==see_unit || sr->mode==see_travel) {
message_list * mlist = r_getmessages(r, f); message_list * mlist = r_getmessages(r, f);
rp_messages(F, r->msgs, f, 0, true); rp_messages(F, r->msgs, f, 0, true);
if (mlist) rp_messages(F, mlist, f, 0, true); if (mlist) rp_messages(F, mlist, f, 0, true);
@ -2055,15 +2038,10 @@ report_plaintext(const char * filename, report_context * ctx)
/* Restliche Einheiten */ /* Restliche Einheiten */
if (sr->mode>=see_lighthouse) { if (stealthmod>INT_MIN) {
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
if (!u->building && !u->ship) { if (!u->building && !u->ship) {
if ((u->faction == f) || if (u->faction == f || cansee(f, r, u, stealthmod)) {
(unit_in_region && cansee(f, r, u, 0)) ||
(durchgezogen_in_region && cansee(f, r, u, -1)) ||
(sr->mode==see_far && cansee(f, r, u, -2)) ||
(turm_sieht_region && cansee(f, r, u, -2)))
{
if (dh == 0 && !(rbuildings(r) || r->ships)) { if (dh == 0 && !(rbuildings(r) || r->ships)) {
dh = 1; dh = 1;
/* rnl(F); */ /* rnl(F); */

View File

@ -47,6 +47,7 @@
/* libc includes */ /* libc includes */
#include <assert.h> #include <assert.h>
#include <limits.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
@ -824,6 +825,22 @@ add_faction(faction_list ** flist, faction * sf)
} }
} }
int
stealth_modifier(int seen_mode)
{
switch (seen_mode) {
case see_unit:
return 0;
case see_far:
case see_lighthouse:
return -2;
case see_travel:
return -1;
default:
return INT_MIN;
}
}
static void static void
get_addresses(report_context * ctx) get_addresses(report_context * ctx)
{ {
@ -840,8 +857,20 @@ get_addresses(report_context * ctx)
} }
for (;sr!=NULL;sr=sr->next) { for (;sr!=NULL;sr=sr->next) {
int stealthmod = stealth_modifier(sr->mode);
r = sr->r; r = sr->r;
if (sr->mode==see_travel) { if (sr->mode==see_lighthouse) {
unit * u = r->units;
for (;u;u=u->next) {
faction * sf = visible_faction(ctx->f, u);
if (lastf!=sf) {
if (u->building || u->ship || (stealthmod>INT_MIN && cansee(ctx->f, r, u, stealthmod))) {
add_faction(&flist, sf);
lastf = sf;
}
}
}
} if (sr->mode==see_travel) {
unit * u = r->units; unit * u = r->units;
while (u) { while (u) {
faction * sf = visible_faction(ctx->f, u); faction * sf = visible_faction(ctx->f, u);
@ -851,7 +880,7 @@ get_addresses(report_context * ctx)
while (a && a->type==&at_travelunit) { while (a && a->type==&at_travelunit) {
unit * u2 = (unit*)a->data.v; unit * u2 = (unit*)a->data.v;
if (u2->faction==ctx->f) { if (u2->faction==ctx->f) {
if (cansee_unit(u2, u, 0)) { if (cansee_unit(u2, u, stealthmod)) {
add_faction(&flist, sf); add_faction(&flist, sf);
lastf = sf; lastf = sf;
break; break;
@ -868,7 +897,7 @@ 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);
boolean ballied = sf && sf!=ctx->f && sf!=lastf boolean ballied = sf && sf!=ctx->f && sf!=lastf
&& !fval(u, UFL_PARTEITARNUNG) && cansee(ctx->f, r, u, 0); && !fval(u, UFL_PARTEITARNUNG) && cansee(ctx->f, r, u, stealthmod);
if (ballied || ALLIED(ctx->f, sf)) { if (ballied || ALLIED(ctx->f, sf)) {
add_faction(&flist, sf); add_faction(&flist, sf);
lastf = sf; lastf = sf;

View File

@ -67,6 +67,7 @@ enum {
see_unit, see_unit,
see_battle see_battle
}; };
extern int stealth_modifier(int seen_mode);
typedef struct seen_region { typedef struct seen_region {
struct seen_region * nextHash; struct seen_region * nextHash;

View File

@ -1067,10 +1067,10 @@ readunit(FILE * F)
orderp = &ord->next; orderp = &ord->next;
ord = NULL; ord = NULL;
} else if (p==MAXPERSISTENT) { } else if (p==MAXPERSISTENT) {
log_error(("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT)); log_warning(("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT));
} }
} else if (n==MAXORDERS) { } else if (n==MAXORDERS) {
log_error(("%s had %d or more orders\n", unitname(u), MAXORDERS)); log_warning(("%s had %d or more orders\n", unitname(u), MAXORDERS));
} }
if (ord!=NULL) free_order(ord); if (ord!=NULL) free_order(ord);
} }
@ -1516,7 +1516,7 @@ readfaction(FILE * F)
rds(F, &email); rds(F, &email);
if (set_email(&f->email, email)!=0) { if (set_email(&f->email, email)!=0) {
log_error(("Invalid email address for faction %s: %s\n", itoa36(f->no), email)); log_warning(("Invalid email address for faction %s: %s\n", itoa36(f->no), email));
set_email(&f->email, ""); set_email(&f->email, "");
} }
free(email); free(email);