forked from github/server
parent
83f170541b
commit
45862a06d0
|
@ -65,8 +65,8 @@ static void test_cr_resources(CuTest *tc) {
|
|||
locale_setstring(lang, "horse_p", "Pferde");
|
||||
locale_setstring(lang, "peasant", "Bauer");
|
||||
locale_setstring(lang, "peasant_p", "Bauern");
|
||||
locale_setstring(lang, "tree", "Baum");
|
||||
locale_setstring(lang, "tree_p", "B?ume");
|
||||
locale_setstring(lang, "tree", "Blume");
|
||||
locale_setstring(lang, "tree_p", "Blumen");
|
||||
locale_setstring(lang, "sapling", "Schoessling");
|
||||
locale_setstring(lang, "sapling_p", "Schoesslinge");
|
||||
|
||||
|
@ -118,7 +118,7 @@ static void test_cr_resources(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, "\"B?ume\";type", line);
|
||||
CuAssertStrEquals(tc, "\"Blumen\";type", line);
|
||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||
CuAssertStrEquals(tc, "3;number", line);
|
||||
|
||||
|
|
|
@ -610,12 +610,6 @@ struct order *ord)
|
|||
return -1; /* use the mechanism */
|
||||
}
|
||||
|
||||
#define R_MINOTHER R_SILVER
|
||||
#define R_MINHERB R_PLAIN_1
|
||||
#define R_MINPOTION R_FAST
|
||||
#define R_MINITEM R_IRON
|
||||
#define MAXHERBSPERPOTION 6
|
||||
|
||||
const potion_type *oldpotiontype[MAX_POTIONS + 1];
|
||||
|
||||
/*** alte items ***/
|
||||
|
@ -982,21 +976,25 @@ void init_resources(void)
|
|||
* which can be used in a construction recipe or as a spell ingredient.
|
||||
*/
|
||||
|
||||
/* special resources needed in report_region */
|
||||
rtype = rt_get_or_create(resourcenames[R_SILVER]);
|
||||
rtype->flags |= RTF_ITEM | RTF_POOLED;
|
||||
rtype->uchange = res_changeitem;
|
||||
rtype->itype = it_get_or_create(rtype);
|
||||
rtype->itype->give = give_money;
|
||||
|
||||
rtype = rt_get_or_create(resourcenames[R_HORSE]);
|
||||
rtype->flags |= RTF_ITEM | RTF_LIMITED;
|
||||
rtype->itype = it_get_or_create(rtype);
|
||||
rtype->itype->flags |= ITF_ANIMAL | ITF_BIG;
|
||||
|
||||
/* "special" spell components */
|
||||
rtype = rt_get_or_create(resourcenames[R_AURA]);
|
||||
rtype->uchange = res_changeaura;
|
||||
|
||||
rtype = rt_get_or_create(resourcenames[R_PERMAURA]);
|
||||
rtype->uchange = res_changepermaura;
|
||||
|
||||
rtype = rt_get_or_create(resourcenames[R_LIFE]);
|
||||
rtype->uchange = res_changehp;
|
||||
|
||||
rtype = rt_get_or_create(resourcenames[R_PEASANT]);
|
||||
rtype->uchange = res_changepeasants;
|
||||
|
||||
|
|
|
@ -117,14 +117,14 @@ void test_findresourcetype(CuTest * tc)
|
|||
test_setup();
|
||||
|
||||
lang = get_or_create_locale("de");
|
||||
locale_setstring(lang, "horse", "Pferd");
|
||||
locale_setstring(lang, "log", "Holz");
|
||||
locale_setstring(lang, "peasant", "Bauer");
|
||||
init_resources();
|
||||
CuAssertPtrNotNull(tc, rt_find("peasant"));
|
||||
CuAssertPtrEquals(tc, 0, rt_find("horse"));
|
||||
itype = test_create_itemtype("horse");
|
||||
CuAssertPtrEquals(tc, 0, rt_find("log"));
|
||||
itype = test_create_itemtype("log");
|
||||
|
||||
CuAssertPtrEquals(tc, (void*)itype->rtype, (void*)findresourcetype("Pferd", lang));
|
||||
CuAssertPtrEquals(tc, (void*)itype->rtype, (void*)findresourcetype("Holz", lang));
|
||||
CuAssertPtrEquals(tc, (void *)rt_find("peasant"), (void *)findresourcetype("Bauer", lang));
|
||||
test_cleanup();
|
||||
}
|
||||
|
|
20
src/report.c
20
src/report.c
|
@ -878,7 +878,7 @@ bool see_border(const connection * b, const faction * f, const region * r)
|
|||
return cs;
|
||||
}
|
||||
|
||||
static void describe(struct stream *out, const region * r, faction * f)
|
||||
void report_region(struct stream *out, const region * r, faction * f)
|
||||
{
|
||||
int n;
|
||||
bool dh;
|
||||
|
@ -1181,7 +1181,6 @@ static void describe(struct stream *out, const region * r, faction * f)
|
|||
dh = 1;
|
||||
}
|
||||
}
|
||||
newline(out);
|
||||
*bufp = 0;
|
||||
paragraph(out, buf, 0, 0, 0);
|
||||
|
||||
|
@ -1999,7 +1998,7 @@ static void cb_write_travelthru(region *r, unit *u, void *cbdata) {
|
|||
}
|
||||
}
|
||||
|
||||
void write_travelthru(struct stream *out, region *r, const faction *f)
|
||||
void report_travelthru(struct stream *out, region *r, const faction *f)
|
||||
{
|
||||
int maxtravel;
|
||||
char buf[8192];
|
||||
|
@ -2281,7 +2280,8 @@ report_plaintext(const char *filename, report_context * ctx,
|
|||
|
||||
if (r->seen.mode == seen_unit) {
|
||||
anyunits = 1;
|
||||
describe(out, r, f);
|
||||
newline(out);
|
||||
report_region(out, r, f);
|
||||
if (markets_module() && r->land) {
|
||||
const item_type *lux = r_luxury(r);
|
||||
const item_type *herb = r->land->herbtype;
|
||||
|
@ -2308,20 +2308,22 @@ report_plaintext(const char *filename, report_context * ctx,
|
|||
}
|
||||
guards(out, r, f);
|
||||
newline(out);
|
||||
write_travelthru(out, r, f);
|
||||
report_travelthru(out, r, f);
|
||||
}
|
||||
else {
|
||||
if (r->seen.mode == seen_far) {
|
||||
describe(out, r, f);
|
||||
newline(out);
|
||||
report_region(out, r, f);
|
||||
newline(out);
|
||||
guards(out, r, f);
|
||||
newline(out);
|
||||
write_travelthru(out, r, f);
|
||||
report_travelthru(out, r, f);
|
||||
}
|
||||
else {
|
||||
describe(out, r, f);
|
||||
newline(out);
|
||||
write_travelthru(out, r, f);
|
||||
report_region(out, r, f);
|
||||
newline(out);
|
||||
report_travelthru(out, r, f);
|
||||
}
|
||||
}
|
||||
/* Statistik */
|
||||
|
|
|
@ -27,7 +27,8 @@ extern "C" {
|
|||
void register_nr(void);
|
||||
void report_cleanup(void);
|
||||
void write_spaces(struct stream *out, size_t num);
|
||||
void write_travelthru(struct stream *out, struct region * r, const struct faction * f);
|
||||
void report_travelthru(struct stream *out, struct region * r, const struct faction * f);
|
||||
void report_region(struct stream *out, const struct region * r, struct faction * f);
|
||||
|
||||
void nr_spell_syntax(struct stream *out, struct spellbook_entry * sbe, const struct locale *lang);
|
||||
void nr_spell(struct stream *out, struct spellbook_entry * sbe, const struct locale *lang);
|
||||
|
|
|
@ -56,7 +56,52 @@ static void test_write_many_spaces(CuTest *tc) {
|
|||
mstream_done(&out);
|
||||
}
|
||||
|
||||
static void test_write_travelthru(CuTest *tc) {
|
||||
static void test_report_region(CuTest *tc) {
|
||||
char buf[1024];
|
||||
region *r;
|
||||
faction *f;
|
||||
stream out = { 0 };
|
||||
size_t len;
|
||||
struct locale *lang;
|
||||
|
||||
test_setup();
|
||||
init_resources();
|
||||
lang = get_or_create_locale("de"); /* CR tags are translated from this */
|
||||
locale_setstring(lang, "money", "Silber");
|
||||
locale_setstring(lang, "money_p", "Silber");
|
||||
locale_setstring(lang, "horse", "Pferd");
|
||||
locale_setstring(lang, "horse_p", "Pferde");
|
||||
locale_setstring(lang, "peasant", "Bauer");
|
||||
locale_setstring(lang, "peasant_p", "Bauern");
|
||||
locale_setstring(lang, "tree", "Blume");
|
||||
locale_setstring(lang, "tree_p", "Blumen");
|
||||
locale_setstring(lang, "stone", "Stein");
|
||||
locale_setstring(lang, "stone_p", "Steine");
|
||||
locale_setstring(lang, "sapling", "Schoessling");
|
||||
locale_setstring(lang, "sapling_p", "Schoesslinge");
|
||||
locale_setstring(lang, "plain", "Ebene");
|
||||
|
||||
mstream_init(&out);
|
||||
r = test_create_region(0, 0, 0);
|
||||
r->land->peasants = 100;
|
||||
r->land->horses = 200;
|
||||
rsettrees(r, 0, 1);
|
||||
rsettrees(r, 1, 2);
|
||||
rsettrees(r, 2, 3);
|
||||
region_setname(r, "Hodor");
|
||||
f = test_create_faction(0);
|
||||
f->locale = lang;
|
||||
|
||||
report_region(&out, r, f);
|
||||
out.api->rewind(out.handle);
|
||||
len = out.api->read(out.handle, buf, sizeof(buf));
|
||||
buf[len] = '\0';
|
||||
CuAssertStrEquals(tc, "Hodor (0,0), Ebene, 3/2 Blumen, 100 Bauern, 200 Pferde.\n", buf);
|
||||
mstream_done(&out);
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_report_travelthru(CuTest *tc) {
|
||||
stream out = { 0 };
|
||||
char buf[1024];
|
||||
size_t len;
|
||||
|
@ -65,7 +110,7 @@ static void test_write_travelthru(CuTest *tc) {
|
|||
unit *u;
|
||||
struct locale *lang;
|
||||
|
||||
test_cleanup();
|
||||
test_setup();
|
||||
lang = get_or_create_locale("de");
|
||||
locale_setstring(lang, "travelthru_header", "Durchreise: ");
|
||||
mstream_init(&out);
|
||||
|
@ -77,7 +122,7 @@ static void test_write_travelthru(CuTest *tc) {
|
|||
unit_setname(u, "Hodor");
|
||||
unit_setid(u, 1);
|
||||
|
||||
write_travelthru(&out, r, f);
|
||||
report_travelthru(&out, r, f);
|
||||
out.api->rewind(out.handle);
|
||||
len = out.api->read(out.handle, buf, sizeof(buf));
|
||||
CuAssertIntEquals_Msg(tc, "no travelers, no report", 0, (int)len);
|
||||
|
@ -85,7 +130,7 @@ static void test_write_travelthru(CuTest *tc) {
|
|||
|
||||
mstream_init(&out);
|
||||
travelthru_add(r, u);
|
||||
write_travelthru(&out, r, f);
|
||||
report_travelthru(&out, r, f);
|
||||
out.api->rewind(out.handle);
|
||||
len = out.api->read(out.handle, buf, sizeof(buf));
|
||||
buf[len] = '\0';
|
||||
|
@ -94,7 +139,7 @@ static void test_write_travelthru(CuTest *tc) {
|
|||
|
||||
mstream_init(&out);
|
||||
move_unit(u, r, 0);
|
||||
write_travelthru(&out, r, f);
|
||||
report_travelthru(&out, r, f);
|
||||
out.api->rewind(out.handle);
|
||||
len = out.api->read(out.handle, buf, sizeof(buf));
|
||||
CuAssertIntEquals_Msg(tc, "do not list units that stopped in the region", 0, (int)len);
|
||||
|
@ -234,7 +279,8 @@ CuSuite *get_report_suite(void)
|
|||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_write_spaces);
|
||||
SUITE_ADD_TEST(suite, test_write_many_spaces);
|
||||
SUITE_ADD_TEST(suite, test_write_travelthru);
|
||||
SUITE_ADD_TEST(suite, test_report_travelthru);
|
||||
SUITE_ADD_TEST(suite, test_report_region);
|
||||
SUITE_ADD_TEST(suite, test_write_spell_syntax);
|
||||
return suite;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue