forked from github/server
Keine Anzeige von Durchreise in von Leuchtturm gesehenem Land Gleichschaltung NR und CR
This commit is contained in:
parent
9b3f5e7a55
commit
ff80cb52ba
8 changed files with 264 additions and 188 deletions
133
src/creport.c
133
src/creport.c
|
@ -4,9 +4,6 @@
|
|||
#include <kernel/config.h>
|
||||
#include <kernel/version.h>
|
||||
#include "creport.h"
|
||||
#include "market.h"
|
||||
#include "guard.h"
|
||||
#include "travelthru.h"
|
||||
|
||||
/* tweakable features */
|
||||
#define RESOURCECOMPAT
|
||||
|
@ -15,8 +12,6 @@
|
|||
/* FIXME: riesig, wegen spionage-messages :-( */
|
||||
static char g_bigbuf[BUFFERSIZE];
|
||||
|
||||
#include <spells/regioncurse.h>
|
||||
|
||||
/* modules include */
|
||||
#include <modules/score.h>
|
||||
|
||||
|
@ -29,12 +24,16 @@ static char g_bigbuf[BUFFERSIZE];
|
|||
#include <attributes/stealth.h>
|
||||
|
||||
/* gamecode includes */
|
||||
#include "laws.h"
|
||||
#include "economy.h"
|
||||
#include "move.h"
|
||||
#include "reports.h"
|
||||
#include "alchemy.h"
|
||||
#include "economy.h"
|
||||
#include "guard.h"
|
||||
#include "laws.h"
|
||||
#include "market.h"
|
||||
#include "move.h"
|
||||
#include "recruit.h"
|
||||
#include "reports.h"
|
||||
#include "teleport.h"
|
||||
#include "travelthru.h"
|
||||
|
||||
/* kernel includes */
|
||||
#include "kernel/alliance.h"
|
||||
|
@ -1170,11 +1169,11 @@ cr_borders(const region * r, const faction * f, seen_mode mode, FILE * F)
|
|||
}
|
||||
}
|
||||
|
||||
void cr_output_resources(stream *out, const faction * f, const region *r, bool see_unit)
|
||||
void cr_output_resources(stream *out, const faction * f, const region *r, seen_mode mode)
|
||||
{
|
||||
char *pos = g_bigbuf;
|
||||
resource_report result[MAX_RAWMATERIALS];
|
||||
int n, size = report_resources(r, result, MAX_RAWMATERIALS, f, see_unit);
|
||||
int n, size = report_resources(r, result, f, mode);
|
||||
|
||||
#ifdef RESOURCECOMPAT
|
||||
int trees = rtrees(r, 2);
|
||||
|
@ -1211,12 +1210,12 @@ void cr_output_resources(stream *out, const faction * f, const region *r, bool s
|
|||
}
|
||||
|
||||
static void cr_output_resources_compat(FILE *F, report_context * ctx,
|
||||
region *r, bool see_unit)
|
||||
region *r)
|
||||
{
|
||||
/* TODO: eliminate this function */
|
||||
stream strm;
|
||||
fstream_init(&strm, F);
|
||||
cr_output_resources(&strm, ctx->f, r, see_unit);
|
||||
cr_output_resources(&strm, ctx->f, r, r->seen.mode);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1331,39 +1330,20 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
|
|||
fprintf(F, "\"%s\";Terrain\n", translate(tname, LOC(f->locale, tname)));
|
||||
if (r->seen.mode != seen_unit)
|
||||
fprintf(F, "\"%s\";visibility\n", visibility[r->seen.mode]);
|
||||
if (r->seen.mode == seen_neighbour) {
|
||||
cr_borders(r, f, r->seen.mode, F);
|
||||
}
|
||||
else {
|
||||
building *b;
|
||||
ship *sh;
|
||||
unit *u;
|
||||
int stealthmod = stealth_modifier(r, f, r->seen.mode);
|
||||
|
||||
if (r->seen.mode > seen_neighbour) {
|
||||
if (r->land && r->land->display && r->land->display[0])
|
||||
fprintf(F, "\"%s\";Beschr\n", r->land->display);
|
||||
if (fval(r->terrain, LAND_REGION)) {
|
||||
assert(r->land);
|
||||
fprintf(F, "%d;Bauern\n", rpeasants(r));
|
||||
fprintf(F, "%d;Pferde\n", rhorses(r));
|
||||
|
||||
if (r->seen.mode >= seen_travel) {
|
||||
if (rule_region_owners()) {
|
||||
faction *owner = region_get_owner(r);
|
||||
if (owner) {
|
||||
fprintf(F, "%d;owner\n", owner->no);
|
||||
}
|
||||
}
|
||||
fprintf(F, "%d;Pferde\n", rhorses(r));
|
||||
fprintf(F, "%d;Silber\n", rmoney(r));
|
||||
if (skill_enabled(SK_ENTERTAINMENT)) {
|
||||
fprintf(F, "%d;Unterh\n", entertainmoney(r));
|
||||
}
|
||||
if (is_cursed(r->attribs, &ct_riotzone)) {
|
||||
fputs("0;Rekruten\n", F);
|
||||
}
|
||||
else {
|
||||
fprintf(F, "%d;Rekruten\n", rpeasants(r) / RECRUITFRACTION);
|
||||
}
|
||||
fprintf(F, "%d;Rekruten\n", max_recruits(r));
|
||||
if (max_production(r)) {
|
||||
/* Im CR steht der Bauernlohn, der bei Trauer nur 10 ist */
|
||||
bool mourn = is_mourning(r, turn);
|
||||
|
@ -1373,6 +1353,12 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
|
|||
fputs("1;mourning\n", F);
|
||||
}
|
||||
}
|
||||
if (rule_region_owners()) {
|
||||
faction *owner = region_get_owner(r);
|
||||
if (owner) {
|
||||
fprintf(F, "%d;owner\n", owner->no);
|
||||
}
|
||||
}
|
||||
if (r->land && r->land->ownership) {
|
||||
fprintf(F, "%d;morale\n", region_get_morale(r));
|
||||
}
|
||||
|
@ -1380,7 +1366,7 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
|
|||
|
||||
/* this writes both some tags (RESOURCECOMPAT) and a block.
|
||||
* must not write any blocks before it */
|
||||
cr_output_resources_compat(F, ctx, r, r->seen.mode >= seen_unit);
|
||||
cr_output_resources_compat(F, ctx, r);
|
||||
|
||||
if (r->seen.mode >= seen_unit) {
|
||||
/* trade */
|
||||
|
@ -1416,54 +1402,58 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
|
|||
}
|
||||
}
|
||||
cr_output_curses_compat(F, f, r, TYP_REGION);
|
||||
cr_borders(r, f, r->seen.mode, F);
|
||||
if (r->seen.mode >= seen_unit && is_astral(r)
|
||||
&& !is_cursed(r->attribs, &ct_astralblock))
|
||||
{
|
||||
/* Sonderbehandlung Teleport-Ebene */
|
||||
region *rl[MAX_SCHEMES];
|
||||
int num = get_astralregions(r, inhabitable, rl);
|
||||
}
|
||||
cr_borders(r, f, r->seen.mode, F);
|
||||
if (see_schemes(r)) {
|
||||
/* Sonderbehandlung Teleport-Ebene */
|
||||
region *rl[MAX_SCHEMES];
|
||||
int num = get_astralregions(r, inhabitable, rl);
|
||||
|
||||
if (num > 0) {
|
||||
int i;
|
||||
for (i = 0; i != num; ++i) {
|
||||
region *r2 = rl[i];
|
||||
plane *plx = rplane(r2);
|
||||
if (num > 0) {
|
||||
int i;
|
||||
for (i = 0; i != num; ++i) {
|
||||
region *r2 = rl[i];
|
||||
plane *plx = rplane(r2);
|
||||
|
||||
nx = r2->x;
|
||||
ny = r2->y;
|
||||
pnormalize(&nx, &ny, plx);
|
||||
adjust_coordinates(f, &nx, &ny, plx);
|
||||
fprintf(F, "SCHEMEN %d %d\n", nx, ny);
|
||||
fprintf(F, "\"%s\";Name\n", rname(r2, f->locale));
|
||||
}
|
||||
nx = r2->x;
|
||||
ny = r2->y;
|
||||
pnormalize(&nx, &ny, plx);
|
||||
adjust_coordinates(f, &nx, &ny, plx);
|
||||
fprintf(F, "SCHEMEN %d %d\n", nx, ny);
|
||||
fprintf(F, "\"%s\";Name\n", rname(r2, f->locale));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (r->seen.mode >= seen_travel) {
|
||||
message_list *mlist = r_getmessages(r, f);
|
||||
cr_output_messages(F, r->msgs, f);
|
||||
if (mlist) {
|
||||
cr_output_messages(F, mlist, f);
|
||||
}
|
||||
}
|
||||
if (r->seen.mode >= seen_lighthouse) {
|
||||
cr_output_travelthru(F, r, f);
|
||||
if (see_region_details(r)) {
|
||||
message_list *mlist = r_getmessages(r, f);
|
||||
cr_output_messages(F, r->msgs, f);
|
||||
if (mlist) {
|
||||
cr_output_messages(F, mlist, f);
|
||||
}
|
||||
}
|
||||
if (r->seen.mode >= seen_lighthouse) {
|
||||
/* buildings */
|
||||
|
||||
/* buildings */
|
||||
if (r->buildings) {
|
||||
building *b;
|
||||
for (b = rbuildings(r); b; b = b->next) {
|
||||
int fno = -1;
|
||||
u = building_owner(b);
|
||||
unit *u = building_owner(b);
|
||||
if (u && !fval(u, UFL_ANON_FACTION)) {
|
||||
const faction *sf = visible_faction(f, u);
|
||||
fno = sf->no;
|
||||
}
|
||||
cr_output_building_compat(F, b, u, fno, f);
|
||||
}
|
||||
}
|
||||
|
||||
/* ships */
|
||||
/* ships */
|
||||
if (r->ships) {
|
||||
ship *sh;
|
||||
for (sh = r->ships; sh; sh = sh->next) {
|
||||
int fno = -1;
|
||||
u = ship_owner(sh);
|
||||
unit *u = ship_owner(sh);
|
||||
if (u && !fval(u, UFL_ANON_FACTION)) {
|
||||
const faction *sf = visible_faction(f, u);
|
||||
fno = sf->no;
|
||||
|
@ -1471,7 +1461,12 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
|
|||
|
||||
cr_output_ship_compat(F, sh, u, fno, f, r);
|
||||
}
|
||||
/* visible units */
|
||||
}
|
||||
|
||||
/* visible units */
|
||||
if (r->units) {
|
||||
unit *u;
|
||||
int stealthmod = stealth_modifier(r, f, r->seen.mode);
|
||||
for (u = r->units; u; u = u->next) {
|
||||
if (visible_unit(u, f, stealthmod, r->seen.mode)) {
|
||||
cr_output_unit_compat(F, f, u, r->seen.mode);
|
||||
|
|
|
@ -20,7 +20,7 @@ extern "C" {
|
|||
void cr_output_unit(struct stream *out, const struct faction * f,
|
||||
const struct unit * u, seen_mode mode);
|
||||
void cr_output_resources(struct stream *out, const struct faction * f,
|
||||
const struct region *r, bool see_unit);
|
||||
const struct region *r, seen_mode mode);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -74,8 +74,8 @@ static void setup_resources(void) {
|
|||
locale_setstring(lang, "peasant_p", "Bauern");
|
||||
locale_setstring(lang, "stone", "Stein");
|
||||
locale_setstring(lang, "stone_p", "Steine");
|
||||
locale_setstring(lang, "tree", "Blume");
|
||||
locale_setstring(lang, "tree_p", "Blumen");
|
||||
locale_setstring(lang, "tree", "Baum");
|
||||
locale_setstring(lang, "tree_p", "Baeume");
|
||||
locale_setstring(lang, "sapling", "Schoessling");
|
||||
locale_setstring(lang, "sapling_p", "Schoesslinge");
|
||||
locale_setstring(lang, "mallornsapling", "Mallornschoessling");
|
||||
|
@ -106,7 +106,7 @@ static void test_cr_resources(CuTest *tc) {
|
|||
region_setresource(r, get_resourcetype(R_STONE), 1);
|
||||
|
||||
mstream_init(&strm);
|
||||
cr_output_resources(&strm, f, r, true);
|
||||
cr_output_resources(&strm, f, r, seen_unit);
|
||||
strm.api->rewind(strm.handle);
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "3;Baeume", line);
|
||||
|
@ -115,6 +115,20 @@ static void test_cr_resources(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "1;Steine", line);
|
||||
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "\"Bauern\";type", line);
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "200;number", line);
|
||||
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "\"Baeume\";type", line);
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "3;number", line);
|
||||
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
|
@ -122,13 +136,6 @@ static void test_cr_resources(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "2;number", line);
|
||||
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "\"Blumen\";type", line);
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "3;number", line);
|
||||
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
|
@ -136,13 +143,6 @@ static void test_cr_resources(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "300;number", line);
|
||||
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "\"Bauern\";type", line);
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "200;number", line);
|
||||
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
|
@ -159,6 +159,61 @@ static void test_cr_resources(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "1;number", line);
|
||||
|
||||
CuAssertIntEquals(tc, -1, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
|
||||
mstream_done(&strm);
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_cr_lighthouse(CuTest *tc) {
|
||||
stream strm;
|
||||
char line[1024];
|
||||
faction *f;
|
||||
region *r;
|
||||
|
||||
setup_resources();
|
||||
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
r->land->horses = 1;
|
||||
r->land->peasants = 200;
|
||||
r->land->money = 300;
|
||||
rsettrees(r, 0, 1);
|
||||
rsettrees(r, 1, 2);
|
||||
rsettrees(r, 2, 3);
|
||||
region_setresource(r, get_resourcetype(R_STONE), 1);
|
||||
|
||||
mstream_init(&strm);
|
||||
cr_output_resources(&strm, f, r, seen_lighthouse_land);
|
||||
strm.api->rewind(strm.handle);
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "3;Baeume", line);
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "2;Schoesslinge", line);
|
||||
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "\"Bauern\";type", line);
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "200;number", line);
|
||||
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "\"Baeume\";type", line);
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "3;number", line);
|
||||
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "\"Schoesslinge\";type", line);
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "2;number", line);
|
||||
|
||||
CuAssertIntEquals(tc, -1, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
|
||||
mstream_done(&strm);
|
||||
test_teardown();
|
||||
}
|
||||
|
@ -182,7 +237,7 @@ static void test_cr_mallorn(CuTest *tc) {
|
|||
rsettrees(r, 2, 3);
|
||||
|
||||
mstream_init(&strm);
|
||||
cr_output_resources(&strm, f, r, false);
|
||||
cr_output_resources(&strm, f, r, seen_travel);
|
||||
strm.api->rewind(strm.handle);
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "3;Baeume", line);
|
||||
|
@ -194,9 +249,9 @@ static void test_cr_mallorn(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "\"Mallornschoesslinge\";type", line);
|
||||
CuAssertStrEquals(tc, "\"Bauern\";type", line);
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "2;number", line);
|
||||
CuAssertStrEquals(tc, "200;number", line);
|
||||
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
|
||||
|
@ -205,6 +260,29 @@ static void test_cr_mallorn(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "3;number", line);
|
||||
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "\"Mallornschoesslinge\";type", line);
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "2;number", line);
|
||||
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "\"Silber\";type", line);
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "300;number", line);
|
||||
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "\"Pferde\";type", line);
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "1;number", line);
|
||||
|
||||
CuAssertIntEquals(tc, -1, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
|
||||
mstream_done(&strm);
|
||||
test_teardown();
|
||||
}
|
||||
|
@ -429,6 +507,7 @@ CuSuite *get_creport_suite(void)
|
|||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_cr_unit);
|
||||
SUITE_ADD_TEST(suite, test_cr_resources);
|
||||
SUITE_ADD_TEST(suite, test_cr_lighthouse);
|
||||
SUITE_ADD_TEST(suite, test_cr_mallorn);
|
||||
SUITE_ADD_TEST(suite, test_cr_hiderace);
|
||||
SUITE_ADD_TEST(suite, test_cr_factionstealth);
|
||||
|
|
|
@ -320,6 +320,14 @@ static int recruit_cost(const faction * f, const race * rc)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int max_recruits(const struct region *r)
|
||||
{
|
||||
if (is_cursed(r->attribs, &ct_riotzone)) {
|
||||
return 0;
|
||||
}
|
||||
return rpeasants(r) / RECRUITFRACTION;
|
||||
}
|
||||
|
||||
message *can_recruit(unit *u, const race *rc, order *ord, int now)
|
||||
{
|
||||
region *r = u->region;
|
||||
|
|
|
@ -13,6 +13,7 @@ extern "C" {
|
|||
struct unit;
|
||||
|
||||
struct message *can_recruit(struct unit *u, const struct race *rc, struct order *ord, int now);
|
||||
int max_recruits(const struct region *r);
|
||||
void add_recruits(struct unit* u, int number, int wanted, int ordered);
|
||||
void recruit(struct region * r);
|
||||
|
||||
|
|
84
src/report.c
84
src/report.c
|
@ -3,12 +3,6 @@
|
|||
#endif
|
||||
|
||||
#include "report.h"
|
||||
#include "reports.h"
|
||||
#include "guard.h"
|
||||
#include "laws.h"
|
||||
#include "market.h"
|
||||
#include "monsters.h"
|
||||
#include "travelthru.h"
|
||||
|
||||
#include <spells/regioncurse.h>
|
||||
#include <spells/buildingcurse.h>
|
||||
|
@ -25,10 +19,17 @@
|
|||
/* gamecode includes */
|
||||
#include "alchemy.h"
|
||||
#include "economy.h"
|
||||
#include "guard.h"
|
||||
#include "laws.h"
|
||||
#include "market.h"
|
||||
#include "monsters.h"
|
||||
#include "move.h"
|
||||
#include "recruit.h"
|
||||
#include "reports.h"
|
||||
#include "teleport.h"
|
||||
#include "travelthru.h"
|
||||
#include "upkeep.h"
|
||||
#include "vortex.h"
|
||||
#include "teleport.h"
|
||||
|
||||
/* kernel includes */
|
||||
#include "kernel/alliance.h"
|
||||
|
@ -895,7 +896,7 @@ static void report_region_description(struct stream *out, const region * r, fact
|
|||
/* iron & stone */
|
||||
if (r->seen.mode >= seen_unit) {
|
||||
resource_report result[MAX_RAWMATERIALS];
|
||||
int numresults = report_resources(r, result, MAX_RAWMATERIALS, f, true);
|
||||
int numresults = report_resources(r, result, f, r->seen.mode);
|
||||
|
||||
for (n = 0; n < numresults; ++n) {
|
||||
if (result[n].number >= 0 && result[n].level >= 0) {
|
||||
|
@ -932,9 +933,9 @@ static void report_region_description(struct stream *out, const region * r, fact
|
|||
}
|
||||
if (r->seen.mode >= seen_travel) {
|
||||
report_region_resource(&sbs, f->locale, get_resourcetype(R_SILVER), rmoney(r));
|
||||
/* Pferde */
|
||||
report_region_resource(&sbs, f->locale, get_resourcetype(R_HORSE), rhorses(r));
|
||||
}
|
||||
/* Pferde */
|
||||
report_region_resource(&sbs, f->locale, get_resourcetype(R_HORSE), rhorses(r));
|
||||
sbs_strcat(&sbs, ".");
|
||||
|
||||
if (r->land && r->land->display && r->land->display[0]) {
|
||||
|
@ -1063,38 +1064,35 @@ char *report_list(const struct locale *lang, char *buffer, size_t len, int argc,
|
|||
|
||||
static void report_region_schemes(struct stream *out, const region * r, faction * f) {
|
||||
|
||||
if (r->seen.mode >= seen_unit && is_astral(r) &&
|
||||
!is_cursed(r->attribs, &ct_astralblock)) {
|
||||
/* Sonderbehandlung Teleport-Ebene */
|
||||
region *rl[MAX_SCHEMES];
|
||||
int num = get_astralregions(r, inhabitable, rl);
|
||||
char buf[4096];
|
||||
/* Sonderbehandlung Teleport-Ebene */
|
||||
region *rl[MAX_SCHEMES];
|
||||
int num = get_astralregions(r, inhabitable, rl);
|
||||
char buf[4096];
|
||||
|
||||
if (num == 1) {
|
||||
/* single region is easy */
|
||||
region *rn = rl[0];
|
||||
f_regionid(rn, f, buf, sizeof(buf));
|
||||
}
|
||||
else if (num > 1) {
|
||||
int i;
|
||||
const char *rnames[MAX_SCHEMES];
|
||||
if (num == 1) {
|
||||
/* single region is easy */
|
||||
region *rn = rl[0];
|
||||
f_regionid(rn, f, buf, sizeof(buf));
|
||||
}
|
||||
else if (num > 1) {
|
||||
int i;
|
||||
const char *rnames[MAX_SCHEMES];
|
||||
|
||||
for (i = 0; i != num; ++i) {
|
||||
char rbuf[REPORTWIDTH];
|
||||
region *rn = rl[i];
|
||||
f_regionid(rn, f, rbuf, sizeof(rbuf));
|
||||
rnames[i] = str_strdup(rbuf);
|
||||
}
|
||||
report_list(f->locale, buf, sizeof(buf), num, rnames);
|
||||
for (i = 0; i != num; ++i) {
|
||||
free((char *)rnames[i]);
|
||||
}
|
||||
for (i = 0; i != num; ++i) {
|
||||
char rbuf[REPORTWIDTH];
|
||||
region *rn = rl[i];
|
||||
f_regionid(rn, f, rbuf, sizeof(rbuf));
|
||||
rnames[i] = str_strdup(rbuf);
|
||||
}
|
||||
if (num > 0) {
|
||||
if (format_replace(LOC(f->locale, "nr_schemes_template"), "{0}", buf, buf, sizeof(buf))) {
|
||||
newline(out);
|
||||
paragraph(out, buf, 0, 0, 0);
|
||||
}
|
||||
report_list(f->locale, buf, sizeof(buf), num, rnames);
|
||||
for (i = 0; i != num; ++i) {
|
||||
free((char *)rnames[i]);
|
||||
}
|
||||
}
|
||||
if (num > 0) {
|
||||
if (format_replace(LOC(f->locale, "nr_schemes_template"), "{0}", buf, buf, sizeof(buf))) {
|
||||
newline(out);
|
||||
paragraph(out, buf, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1151,12 +1149,10 @@ void report_region(struct stream *out, const region * r, faction * f)
|
|||
}
|
||||
|
||||
report_region_description(out, r, f, see);
|
||||
if (r->seen.mode >= seen_unit) {
|
||||
if (see_schemes(r)) {
|
||||
report_region_schemes(out, r, f);
|
||||
}
|
||||
if (r->seen.mode >= seen_lighthouse_land) {
|
||||
report_region_edges(out, r, f, edges, ne);
|
||||
}
|
||||
report_region_edges(out, r, f, edges, ne);
|
||||
}
|
||||
|
||||
static void report_statistics(struct stream *out, const region * r, const faction * f)
|
||||
|
@ -1198,7 +1194,7 @@ static void report_statistics(struct stream *out, const region * r, const factio
|
|||
}
|
||||
|
||||
if (p) {
|
||||
m = msg_message("nr_stat_recruits", "max", p / RECRUITFRACTION);
|
||||
m = msg_message("nr_stat_recruits", "max", max_recruits(r));
|
||||
nr_render(m, f->locale, buf, sizeof(buf), f);
|
||||
paragraph(out, buf, 2, 2, 0);
|
||||
msg_release(m);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "guard.h"
|
||||
#include "laws.h"
|
||||
#include "spells.h"
|
||||
#include "teleport.h"
|
||||
#include "travelthru.h"
|
||||
#include "lighthouse.h"
|
||||
#include "donations.h"
|
||||
|
@ -18,11 +19,13 @@
|
|||
#include "attributes/racename.h"
|
||||
#include "attributes/stealth.h"
|
||||
|
||||
#include "spells/regioncurse.h"
|
||||
#include "spells/unitcurse.h"
|
||||
|
||||
/* kernel includes */
|
||||
#include "kernel/config.h"
|
||||
#include "kernel/calendar.h"
|
||||
#include "kernel/curse.h"
|
||||
#include "kernel/ally.h"
|
||||
#include "kernel/alliance.h"
|
||||
#include "kernel/connection.h"
|
||||
|
@ -188,6 +191,10 @@ const char *hp_status(const unit * u)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool see_schemes(const region *r) {
|
||||
return r->seen.mode >= seen_unit && is_astral(r) && !is_cursed(r->attribs, &ct_astralblock);
|
||||
}
|
||||
|
||||
void
|
||||
report_item(const unit * owner, const item * i, const faction * viewer,
|
||||
const char **name, const char **basename, int *number, bool singular)
|
||||
|
@ -468,56 +475,47 @@ report_building(const struct building *b, const char **name,
|
|||
}
|
||||
|
||||
int
|
||||
report_resources(const region * r, resource_report * result, int size,
|
||||
const faction * viewer, bool see_unit)
|
||||
report_resources(const region * r, resource_report result[MAX_RAWMATERIALS],
|
||||
const faction * viewer, seen_mode mode)
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
if (r->land) {
|
||||
int peasants = rpeasants(r);
|
||||
int money = rmoney(r);
|
||||
int horses = rhorses(r);
|
||||
int trees = rtrees(r, 2);
|
||||
int saplings = rtrees(r, 1);
|
||||
bool mallorn = fval(r, RF_MALLORN) != 0;
|
||||
const resource_type *rtype;
|
||||
|
||||
if (saplings) {
|
||||
if (n >= size)
|
||||
return -1;
|
||||
rtype = get_resourcetype(mallorn ? R_MALLORN_SAPLING : R_SAPLING);
|
||||
report_resource(result + n, rtype, saplings, -1);
|
||||
++n;
|
||||
}
|
||||
if (trees) {
|
||||
if (n >= size)
|
||||
return -1;
|
||||
rtype = get_resourcetype(mallorn ? R_MALLORN_TREE : R_TREE);
|
||||
report_resource(result + n, rtype, trees, -1);
|
||||
++n;
|
||||
}
|
||||
if (money) {
|
||||
if (n >= size)
|
||||
return -1;
|
||||
report_resource(result + n, get_resourcetype(R_SILVER), money, -1);
|
||||
++n;
|
||||
}
|
||||
if (peasants) {
|
||||
if (n >= size)
|
||||
return -1;
|
||||
report_resource(result + n, get_resourcetype(R_PEASANT), peasants, -1);
|
||||
++n;
|
||||
}
|
||||
|
||||
if (mode >= seen_lighthouse_land) {
|
||||
const resource_type *rtype;
|
||||
int trees = rtrees(r, 2);
|
||||
int saplings = rtrees(r, 1);
|
||||
bool mallorn = fval(r, RF_MALLORN) != 0;
|
||||
if (trees) {
|
||||
rtype = get_resourcetype(mallorn ? R_MALLORN_TREE : R_TREE);
|
||||
report_resource(result + n, rtype, trees, -1);
|
||||
++n;
|
||||
}
|
||||
if (saplings) {
|
||||
rtype = get_resourcetype(mallorn ? R_MALLORN_SAPLING : R_SAPLING);
|
||||
report_resource(result + n, rtype, saplings, -1);
|
||||
++n;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mode >= seen_travel) {
|
||||
rawmaterial *res = r->resources;
|
||||
int money = rmoney(r);
|
||||
int horses = rhorses(r);
|
||||
if (money) {
|
||||
report_resource(result + n, get_resourcetype(R_SILVER), money, -1);
|
||||
++n;
|
||||
}
|
||||
if (horses) {
|
||||
if (n >= size)
|
||||
return -1;
|
||||
report_resource(result + n, get_resourcetype(R_HORSE), horses, -1);
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
if (see_unit) {
|
||||
rawmaterial *res = r->resources;
|
||||
while (res) {
|
||||
const item_type *itype = resource2item(res->rtype);
|
||||
int minskill = itype->construction->minskill;
|
||||
|
@ -543,10 +541,13 @@ report_resources(const region * r, resource_report * result, int size,
|
|||
}
|
||||
}
|
||||
if (level >= 0 && visible >= 0) {
|
||||
if (n >= size)
|
||||
return -1;
|
||||
report_resource(result + n, res->rtype, visible, level);
|
||||
n++;
|
||||
if (n >= MAX_RAWMATERIALS) {
|
||||
log_error("More than MAX_RAWMATERIALS resources in %s", regionname(r, NULL));
|
||||
}
|
||||
else {
|
||||
report_resource(result + n, res->rtype, visible, level);
|
||||
++n;
|
||||
}
|
||||
}
|
||||
res = res->next;
|
||||
}
|
||||
|
@ -2391,11 +2392,6 @@ bool visible_unit(const unit *u, const faction *f, int stealthmod, seen_mode mod
|
|||
return false;
|
||||
}
|
||||
|
||||
bool see_region_details(const region *r)
|
||||
{
|
||||
return r->seen.mode >= seen_travel;
|
||||
}
|
||||
|
||||
void register_reports(void)
|
||||
{
|
||||
/* register datatypes for the different message objects */
|
||||
|
|
|
@ -16,12 +16,18 @@ extern "C" {
|
|||
struct selist;
|
||||
struct stream;
|
||||
struct seen_region;
|
||||
struct region;
|
||||
|
||||
/* Alter, ab dem der Score angezeigt werden soll: */
|
||||
#define DISPLAYSCORE 12
|
||||
/* Breite einer Reportzeile: */
|
||||
#define REPORTWIDTH 78
|
||||
|
||||
#define GR_PLURAL 0x01 /* grammar: plural */
|
||||
#define MAX_INVENTORY 128 /* maimum number of different items in an inventory */
|
||||
#define MAX_RAWMATERIALS 12 /* maximum kinds of resources in a regions */
|
||||
|
||||
|
||||
extern const char *directions[];
|
||||
extern const char *coasts[];
|
||||
extern const char *combatstatus[];
|
||||
|
@ -33,8 +39,6 @@ extern "C" {
|
|||
|
||||
void reports_done(void);
|
||||
|
||||
struct unit *can_find(struct faction *, struct faction *);
|
||||
|
||||
bool omniscient(const struct faction *f);
|
||||
struct selist *get_regions_distance(struct region * root, int radius);
|
||||
int get_regions_distance_arr(struct region *r, int radius, struct region *result[], int size);
|
||||
|
@ -95,8 +99,8 @@ extern "C" {
|
|||
int number;
|
||||
int level;
|
||||
} resource_report;
|
||||
int report_resources(const struct region *r, struct resource_report *res,
|
||||
int size, const struct faction *viewer, bool see_unit);
|
||||
int report_resources(const struct region *r, struct resource_report res[MAX_RAWMATERIALS],
|
||||
const struct faction *viewer, seen_mode mode);
|
||||
int report_items(const struct unit *u, struct item *result, int size,
|
||||
const struct unit *owner, const struct faction *viewer);
|
||||
void report_warnings(struct faction *f, int now);
|
||||
|
@ -120,11 +124,8 @@ extern "C" {
|
|||
const char *get_mailcmd(const struct locale *loc);
|
||||
|
||||
bool visible_unit(const struct unit *u, const struct faction *f, int stealthmod, seen_mode mode);
|
||||
bool see_region_details(const struct region *r);
|
||||
|
||||
#define GR_PLURAL 0x01 /* grammar: plural */
|
||||
#define MAX_INVENTORY 128 /* maimum number of different items in an inventory */
|
||||
#define MAX_RAWMATERIALS 8 /* maximum kinds of raw materials in a regions */
|
||||
bool see_schemes(const struct region *r);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue