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, "horse_p", "Pferde");
|
||||||
locale_setstring(lang, "peasant", "Bauer");
|
locale_setstring(lang, "peasant", "Bauer");
|
||||||
locale_setstring(lang, "peasant_p", "Bauern");
|
locale_setstring(lang, "peasant_p", "Bauern");
|
||||||
locale_setstring(lang, "tree", "Baum");
|
locale_setstring(lang, "tree", "Blume");
|
||||||
locale_setstring(lang, "tree_p", "B?ume");
|
locale_setstring(lang, "tree_p", "Blumen");
|
||||||
locale_setstring(lang, "sapling", "Schoessling");
|
locale_setstring(lang, "sapling", "Schoessling");
|
||||||
locale_setstring(lang, "sapling_p", "Schoesslinge");
|
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, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||||
CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
|
CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
|
||||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
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)));
|
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||||
CuAssertStrEquals(tc, "3;number", line);
|
CuAssertStrEquals(tc, "3;number", line);
|
||||||
|
|
||||||
|
|
|
@ -610,12 +610,6 @@ struct order *ord)
|
||||||
return -1; /* use the mechanism */
|
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];
|
const potion_type *oldpotiontype[MAX_POTIONS + 1];
|
||||||
|
|
||||||
/*** alte items ***/
|
/*** alte items ***/
|
||||||
|
@ -982,21 +976,25 @@ void init_resources(void)
|
||||||
* which can be used in a construction recipe or as a spell ingredient.
|
* 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 = rt_get_or_create(resourcenames[R_SILVER]);
|
||||||
rtype->flags |= RTF_ITEM | RTF_POOLED;
|
rtype->flags |= RTF_ITEM | RTF_POOLED;
|
||||||
rtype->uchange = res_changeitem;
|
rtype->uchange = res_changeitem;
|
||||||
rtype->itype = it_get_or_create(rtype);
|
rtype->itype = it_get_or_create(rtype);
|
||||||
rtype->itype->give = give_money;
|
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 = rt_get_or_create(resourcenames[R_AURA]);
|
||||||
rtype->uchange = res_changeaura;
|
rtype->uchange = res_changeaura;
|
||||||
|
|
||||||
rtype = rt_get_or_create(resourcenames[R_PERMAURA]);
|
rtype = rt_get_or_create(resourcenames[R_PERMAURA]);
|
||||||
rtype->uchange = res_changepermaura;
|
rtype->uchange = res_changepermaura;
|
||||||
|
|
||||||
rtype = rt_get_or_create(resourcenames[R_LIFE]);
|
rtype = rt_get_or_create(resourcenames[R_LIFE]);
|
||||||
rtype->uchange = res_changehp;
|
rtype->uchange = res_changehp;
|
||||||
|
|
||||||
rtype = rt_get_or_create(resourcenames[R_PEASANT]);
|
rtype = rt_get_or_create(resourcenames[R_PEASANT]);
|
||||||
rtype->uchange = res_changepeasants;
|
rtype->uchange = res_changepeasants;
|
||||||
|
|
||||||
|
|
|
@ -117,14 +117,14 @@ void test_findresourcetype(CuTest * tc)
|
||||||
test_setup();
|
test_setup();
|
||||||
|
|
||||||
lang = get_or_create_locale("de");
|
lang = get_or_create_locale("de");
|
||||||
locale_setstring(lang, "horse", "Pferd");
|
locale_setstring(lang, "log", "Holz");
|
||||||
locale_setstring(lang, "peasant", "Bauer");
|
locale_setstring(lang, "peasant", "Bauer");
|
||||||
init_resources();
|
init_resources();
|
||||||
CuAssertPtrNotNull(tc, rt_find("peasant"));
|
CuAssertPtrNotNull(tc, rt_find("peasant"));
|
||||||
CuAssertPtrEquals(tc, 0, rt_find("horse"));
|
CuAssertPtrEquals(tc, 0, rt_find("log"));
|
||||||
itype = test_create_itemtype("horse");
|
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));
|
CuAssertPtrEquals(tc, (void *)rt_find("peasant"), (void *)findresourcetype("Bauer", lang));
|
||||||
test_cleanup();
|
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;
|
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;
|
int n;
|
||||||
bool dh;
|
bool dh;
|
||||||
|
@ -1181,7 +1181,6 @@ static void describe(struct stream *out, const region * r, faction * f)
|
||||||
dh = 1;
|
dh = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newline(out);
|
|
||||||
*bufp = 0;
|
*bufp = 0;
|
||||||
paragraph(out, buf, 0, 0, 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;
|
int maxtravel;
|
||||||
char buf[8192];
|
char buf[8192];
|
||||||
|
@ -2281,7 +2280,8 @@ report_plaintext(const char *filename, report_context * ctx,
|
||||||
|
|
||||||
if (r->seen.mode == seen_unit) {
|
if (r->seen.mode == seen_unit) {
|
||||||
anyunits = 1;
|
anyunits = 1;
|
||||||
describe(out, r, f);
|
newline(out);
|
||||||
|
report_region(out, r, f);
|
||||||
if (markets_module() && r->land) {
|
if (markets_module() && r->land) {
|
||||||
const item_type *lux = r_luxury(r);
|
const item_type *lux = r_luxury(r);
|
||||||
const item_type *herb = r->land->herbtype;
|
const item_type *herb = r->land->herbtype;
|
||||||
|
@ -2308,20 +2308,22 @@ report_plaintext(const char *filename, report_context * ctx,
|
||||||
}
|
}
|
||||||
guards(out, r, f);
|
guards(out, r, f);
|
||||||
newline(out);
|
newline(out);
|
||||||
write_travelthru(out, r, f);
|
report_travelthru(out, r, f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (r->seen.mode == seen_far) {
|
if (r->seen.mode == seen_far) {
|
||||||
describe(out, r, f);
|
newline(out);
|
||||||
|
report_region(out, r, f);
|
||||||
newline(out);
|
newline(out);
|
||||||
guards(out, r, f);
|
guards(out, r, f);
|
||||||
newline(out);
|
newline(out);
|
||||||
write_travelthru(out, r, f);
|
report_travelthru(out, r, f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
describe(out, r, f);
|
|
||||||
newline(out);
|
newline(out);
|
||||||
write_travelthru(out, r, f);
|
report_region(out, r, f);
|
||||||
|
newline(out);
|
||||||
|
report_travelthru(out, r, f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Statistik */
|
/* Statistik */
|
||||||
|
|
|
@ -27,7 +27,8 @@ extern "C" {
|
||||||
void register_nr(void);
|
void register_nr(void);
|
||||||
void report_cleanup(void);
|
void report_cleanup(void);
|
||||||
void write_spaces(struct stream *out, size_t num);
|
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_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);
|
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);
|
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 };
|
stream out = { 0 };
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
size_t len;
|
size_t len;
|
||||||
|
@ -65,7 +110,7 @@ static void test_write_travelthru(CuTest *tc) {
|
||||||
unit *u;
|
unit *u;
|
||||||
struct locale *lang;
|
struct locale *lang;
|
||||||
|
|
||||||
test_cleanup();
|
test_setup();
|
||||||
lang = get_or_create_locale("de");
|
lang = get_or_create_locale("de");
|
||||||
locale_setstring(lang, "travelthru_header", "Durchreise: ");
|
locale_setstring(lang, "travelthru_header", "Durchreise: ");
|
||||||
mstream_init(&out);
|
mstream_init(&out);
|
||||||
|
@ -77,7 +122,7 @@ static void test_write_travelthru(CuTest *tc) {
|
||||||
unit_setname(u, "Hodor");
|
unit_setname(u, "Hodor");
|
||||||
unit_setid(u, 1);
|
unit_setid(u, 1);
|
||||||
|
|
||||||
write_travelthru(&out, r, f);
|
report_travelthru(&out, r, f);
|
||||||
out.api->rewind(out.handle);
|
out.api->rewind(out.handle);
|
||||||
len = out.api->read(out.handle, buf, sizeof(buf));
|
len = out.api->read(out.handle, buf, sizeof(buf));
|
||||||
CuAssertIntEquals_Msg(tc, "no travelers, no report", 0, (int)len);
|
CuAssertIntEquals_Msg(tc, "no travelers, no report", 0, (int)len);
|
||||||
|
@ -85,7 +130,7 @@ static void test_write_travelthru(CuTest *tc) {
|
||||||
|
|
||||||
mstream_init(&out);
|
mstream_init(&out);
|
||||||
travelthru_add(r, u);
|
travelthru_add(r, u);
|
||||||
write_travelthru(&out, r, f);
|
report_travelthru(&out, r, f);
|
||||||
out.api->rewind(out.handle);
|
out.api->rewind(out.handle);
|
||||||
len = out.api->read(out.handle, buf, sizeof(buf));
|
len = out.api->read(out.handle, buf, sizeof(buf));
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
@ -94,7 +139,7 @@ static void test_write_travelthru(CuTest *tc) {
|
||||||
|
|
||||||
mstream_init(&out);
|
mstream_init(&out);
|
||||||
move_unit(u, r, 0);
|
move_unit(u, r, 0);
|
||||||
write_travelthru(&out, r, f);
|
report_travelthru(&out, r, f);
|
||||||
out.api->rewind(out.handle);
|
out.api->rewind(out.handle);
|
||||||
len = out.api->read(out.handle, buf, sizeof(buf));
|
len = out.api->read(out.handle, buf, sizeof(buf));
|
||||||
CuAssertIntEquals_Msg(tc, "do not list units that stopped in the region", 0, (int)len);
|
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();
|
CuSuite *suite = CuSuiteNew();
|
||||||
SUITE_ADD_TEST(suite, test_write_spaces);
|
SUITE_ADD_TEST(suite, test_write_spaces);
|
||||||
SUITE_ADD_TEST(suite, test_write_many_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);
|
SUITE_ADD_TEST(suite, test_write_spell_syntax);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue