- displaying markets in the report.

This commit is contained in:
Enno Rehling 2009-06-02 12:22:20 +00:00
parent 4b5882b450
commit 93e34d979d
9 changed files with 73 additions and 14 deletions

View File

@ -1157,7 +1157,21 @@ cr_output_region(FILE * F, report_context * ctx, seen_region * sr)
if (sr->mode>=see_unit) {
/* trade */
if (rpeasants(r)/TRADE_FRACTION > 0) {
if (markets_module() && r->land) {
const item_type * lux = r_luxury(r);
const item_type * herb = r->land->herbtype;
if (lux || herb) {
fputs("PREISE\n", F);
if (lux) {
const char * ch = resourcename(lux->rtype, 0);
fprintf(F, "%d;%s\n", 1, add_translation(ch, locale_string(f->locale, ch)));
}
if (herb) {
const char * ch = resourcename(herb->rtype, 0);
fprintf(F, "%d;%s\n", 1, add_translation(ch, locale_string(f->locale, ch)));
}
}
} else if (rpeasants(r)/TRADE_FRACTION > 0) {
struct demand * dmd = r->land->demands;
fputs("PREISE\n", F);
while (dmd) {

View File

@ -59,15 +59,6 @@ free_market(attrib * a)
a->data.v = 0;
}
const item_type * r_luxury(region * r)
{
struct demand * dmd;
for (dmd=r->land->demands;dmd;dmd=dmd->next) {
if (dmd->value==0) return dmd->type->itype;
}
return NULL;
}
attrib_type at_market = {
"script",
NULL, free_market, NULL,

View File

@ -1882,6 +1882,19 @@ nr_building(FILE *F, const seen_region * sr, const building * b, const faction *
nr_curses(F, f, b, TYP_BUILDING, 4);
}
static void nr_paragraph(FILE * F, message * m, faction * f)
{
int bytes;
char buf[4096], * bufp = buf;
size_t size = sizeof(buf) - 1;
bytes = (int)nr_render(m, f->locale, bufp, size, f);
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
msg_release(m);
rparagraph(F, buf, 0, 0, 0);
}
int
report_plaintext(const char * filename, report_context * ctx, const char * charset)
{
@ -2169,9 +2182,20 @@ report_plaintext(const char * filename, report_context * ctx, const char * chars
if (sr->mode==see_unit) {
anyunits = 1;
describe(F, sr, f);
if (!fval(r->terrain, SEA_REGION) && rpeasants(r)/TRADE_FRACTION > 0) {
if (markets_module() && r->land) {
const item_type * lux = r_luxury(r);
const item_type * herb = r->land->herbtype;
message * m = msg_message("nr_market_info", "product herb",
lux->rtype, herb?herb->rtype:0);
rnl(F);
prices(F, r, f);
nr_paragraph(F, m, f);
//
} else {
if (!fval(r->terrain, SEA_REGION) && rpeasants(r)/TRADE_FRACTION > 0) {
rnl(F);
prices(F, r, f);
}
}
guards(F, r, f);
durchreisende(F, r, f);

View File

@ -822,7 +822,8 @@ select_armor(troop t, boolean shield)
return a->atype;
}
}
} return NULL;
}
return NULL;
}

View File

@ -3052,6 +3052,15 @@ int rule_give(void)
return value;
}
int markets_module(void)
{
static int value = -1;
if (value<0) {
value = get_param_int(global.parameters, "modules.markets", 0);
}
return value;
}
/** releases all memory associated with the game state.
* call this function before calling read_game() to load a new game
* if you have a previously loaded state in memory.

View File

@ -336,7 +336,7 @@ extern int lifestyle(const struct unit*);
extern int besieged(const struct unit * u);
extern int maxworkingpeasants(const struct region * r);
extern boolean has_horses(const struct unit * u);
extern int markets_module(void);
extern int wage(const struct region *r, const struct faction *f, const struct race * rc);
extern int maintenance_cost(const struct unit * u);
extern struct message * movement_error(struct unit * u, const char * token, struct order * ord, int error_code);

View File

@ -791,6 +791,16 @@ r_setdemand(region * r, const luxury_type * ltype, int value)
d->value = value;
}
const item_type *
r_luxury(region * r)
{
struct demand * dmd;
for (dmd=r->land->demands;dmd;dmd=dmd->next) {
if (dmd->value==0) return dmd->type->itype;
}
return NULL;
}
int
r_demand(const region * r, const luxury_type * ltype)
{

View File

@ -265,6 +265,8 @@ void region_setinfo(struct region * self, const char * name);
int region_getresource(const struct region * r, const struct resource_type * rtype);
void region_setresource(struct region * r, const struct resource_type * rtype, int value);
extern const struct item_type * r_luxury(struct region * r);
#ifdef __cplusplus
}
#endif

View File

@ -862,6 +862,14 @@
<text locale="fr">"Le marché local offre la $resource($product,0) au prix de $int($price) écus."</text>
<text locale="en">"The local market offers $resource($product,0) at a price of $int($price) silver."</text>
</message>
<message name="nr_market_info" section="nr">
<type>
<arg name="product" type="resource"/>
<arg name="herb" type="resource"/>
</type>
<text locale="de">"Auf dem Markt werden $resource($product,0) und $resource($herb,0) feilgeboten."</text>
<text locale="de">"The local market offers $resource($product,0) and $resource($herb,0)."</text>
</message>
<message name="newbie_password" section="events">
<type>
<arg name="password" type="string"/>