pull economy requests into header, rename the struct.

This commit is contained in:
Enno Rehling 2017-12-04 19:20:48 +01:00
parent c124702ffe
commit 05425b5101
9 changed files with 121 additions and 119 deletions

View File

@ -45,28 +45,35 @@ int tolua_shiplist_next(lua_State * L)
static int tolua_ship_get_id(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, 0);
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
lua_pushinteger(L, self->no);
return 1;
}
static int tolua_ship_get_name(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, 0);
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
tolua_pushstring(L, ship_getname(self));
return 1;
}
static int tolua_ship_get_size(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
lua_pushinteger(L, self->size);
return 1;
}
static int tolua_ship_get_display(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, 0);
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
tolua_pushstring(L, self->display);
return 1;
}
static int tolua_ship_get_region(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, 0);
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
if (self) {
tolua_pushusertype(L, self->region, TOLUA_CAST "region");
return 1;
@ -76,8 +83,8 @@ static int tolua_ship_get_region(lua_State * L)
static int tolua_ship_set_region(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, 0);
region *r = (region *)tolua_tousertype(L, 1, 0);
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
region *r = (region *)tolua_tousertype(L, 2, NULL);
if (self) {
move_ship(self, self->region, r, NULL);
}
@ -86,22 +93,29 @@ static int tolua_ship_set_region(lua_State * L)
static int tolua_ship_set_name(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, 0);
ship_setname(self, tolua_tostring(L, 2, 0));
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
ship_setname(self, tolua_tostring(L, 2, NULL));
return 0;
}
static int tolua_ship_set_size(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
self->size = lua_tointeger(L, 2);
return 0;
}
static int tolua_ship_set_display(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, 0);
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
free(self->display);
self->display = strdup(tolua_tostring(L, 2, 0));
self->display = strdup(tolua_tostring(L, 2, NULL));
return 0;
}
static int tolua_ship_get_units(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, 0);
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
unit **unit_ptr = (unit **)lua_newuserdata(L, sizeof(unit *));
unit *u = self->region->units;
@ -118,8 +132,8 @@ static int tolua_ship_get_units(lua_State * L)
static int tolua_ship_create(lua_State * L)
{
region *r = (region *)tolua_tousertype(L, 1, 0);
const char *sname = tolua_tostring(L, 2, 0);
region *r = (region *)tolua_tousertype(L, 1, NULL);
const char *sname = tolua_tostring(L, 2, NULL);
if (sname) {
const ship_type *stype = st_find(sname);
if (stype) {
@ -138,40 +152,40 @@ static int tolua_ship_create(lua_State * L)
static int
tolua_ship_tostring(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, 0);
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
lua_pushstring(L, shipname(self));
return 1;
}
static int tolua_ship_get_flags(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, 0);
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
lua_pushinteger(L, self->flags);
return 1;
}
static int tolua_ship_set_flags(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, 0);
self->flags = (int)tolua_tonumber(L, 2, 0);
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
self->flags = (int)lua_tointeger(L, 2);
return 0;
}
static int tolua_ship_set_coast(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, 0);
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
if (lua_isnil(L, 2)) {
self->coast = NODIRECTION;
}
else if (lua_isnumber(L, 2)) {
self->coast = (direction_t)tolua_tonumber(L, 2, 0);
self->coast = (direction_t)lua_tointeger(L, 2);
}
return 0;
}
static int tolua_ship_get_coast(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, 0);
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
if (self->coast) {
lua_pushinteger(L, self->coast);
return 1;
@ -181,28 +195,28 @@ static int tolua_ship_get_coast(lua_State * L)
static int tolua_ship_get_type(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, 0);
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
tolua_pushstring(L, self->type->_name);
return 1;
}
static int tolua_ship_get_damage(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, 0);
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
lua_pushinteger(L, self->damage);
return 1;
}
static int tolua_ship_set_damage(lua_State * L)
{
ship *self = (ship *)tolua_tousertype(L, 1, 0);
self->damage = (int)tolua_tonumber(L, 2, 0);
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
self->damage = (int)lua_tointeger(L, 2);
return 0;
}
static int tolua_ship_get_curse(lua_State *L) {
ship *self = (ship *)tolua_tousertype(L, 1, 0);
const char *name = tolua_tostring(L, 2, 0);
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
const char *name = tolua_tostring(L, 2, NULL);
if (self->attribs) {
curse * c = get_curse(self->attribs, ct_find(name));
if (c) {
@ -214,8 +228,8 @@ static int tolua_ship_get_curse(lua_State *L) {
}
static int tolua_ship_has_attrib(lua_State *L) {
ship *self = (ship *)tolua_tousertype(L, 1, 0);
const char *name = tolua_tostring(L, 2, 0);
ship *self = (ship *)tolua_tousertype(L, 1, NULL);
const char *name = tolua_tostring(L, 2, NULL);
attrib * a = a_find(self->attribs, at_find(name));
lua_pushboolean(L, a != NULL);
return 1;
@ -236,6 +250,8 @@ void tolua_ship_open(lua_State * L)
tolua_variable(L, TOLUA_CAST "id", tolua_ship_get_id, NULL);
tolua_variable(L, TOLUA_CAST "name", tolua_ship_get_name,
tolua_ship_set_name);
tolua_variable(L, TOLUA_CAST "size", tolua_ship_get_size,
tolua_ship_set_size);
tolua_variable(L, TOLUA_CAST "info", tolua_ship_get_display,
tolua_ship_set_display);
tolua_variable(L, TOLUA_CAST "units", tolua_ship_get_units, NULL);

View File

@ -1388,7 +1388,7 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
else {
fprintf(F, "%d;Rekruten\n", rpeasants(r) / RECRUITFRACTION);
}
if (production(r)) {
if (max_production(r)) {
int p_wage = wage(r, NULL, NULL, turn + 1);
fprintf(F, "%d;Lohn\n", p_wage);
if (is_mourning(r, turn + 1)) {

View File

@ -81,26 +81,14 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <assert.h>
#include <limits.h>
typedef struct request {
struct request *next;
struct unit *unit;
struct order *ord;
int qty;
int no;
union {
bool goblin; /* stealing */
const struct luxury_type *ltype; /* trading */
} type;
} request;
static int working;
static request entertainers[1024];
static request *nextentertainer;
static production entertainers[1024];
static production *nextentertainer;
static int entertaining;
static unsigned int norders;
static request *g_requests;
static production *g_requests;
#define RECRUIT_MERGE 1
static int rules_recruit = -1;
@ -153,12 +141,12 @@ static void scramble(void *data, unsigned int n, size_t width)
}
}
static void expandorders(region * r, request * requests)
static void expandorders(region * r, production * requests)
{
unit *u;
request *o;
production *o;
/* Alle Units ohne request haben ein -1, alle units mit orders haben ein
/* Alle Units ohne production haben ein -1, alle units mit orders haben ein
* 0 hier stehen */
for (u = r->units; u; u = u->next)
@ -174,7 +162,7 @@ static void expandorders(region * r, request * requests)
if (norders > 0) {
int i = 0;
g_requests = (request *)calloc(norders, sizeof(request));
g_requests = (production *)calloc(norders, sizeof(production));
for (o = requests; o; o = o->next) {
if (o->qty > 0) {
unsigned int j;
@ -185,13 +173,13 @@ static void expandorders(region * r, request * requests)
}
}
}
scramble(g_requests, norders, sizeof(request));
scramble(g_requests, norders, sizeof(production));
}
else {
g_requests = NULL;
}
while (requests) {
request *o = requests->next;
production *o = requests->next;
free_order(requests->ord);
free(requests);
requests = o;
@ -203,21 +191,21 @@ static void expandorders(region * r, request * requests)
typedef struct recruitment {
struct recruitment *next;
faction *f;
request *requests;
production *requests;
int total, assigned;
} recruitment;
/** Creates a list of recruitment structs, one for each faction. Adds every quantifyable request
/** Creates a list of recruitment structs, one for each faction. Adds every quantifyable production
* to the faction's struct and to total.
*/
static recruitment *select_recruitment(request ** rop,
static recruitment *select_recruitment(production ** rop,
int(*quantify) (const struct race *, int), int *total)
{
recruitment *recruits = NULL;
while (*rop) {
recruitment *rec = recruits;
request *ro = *rop;
production *ro = *rop;
unit *u = ro->unit;
const race *rc = u_race(u);
int qty = quantify(rc, ro->qty);
@ -294,7 +282,7 @@ static int do_recruiting(recruitment * recruits, int available)
int n = 0;
int rest, mintotal = INT_MAX;
/* find smallest request */
/* find smallest production */
for (rec = recruits; rec != NULL; rec = rec->next) {
int want = rec->total - rec->assigned;
if (want > 0) {
@ -310,7 +298,7 @@ static int do_recruiting(recruitment * recruits, int available)
}
rest = available - mintotal * n;
/* assign size of smallest request for everyone if possible; in the end roll dice to assign
/* assign size of smallest production for everyone if possible; in the end roll dice to assign
* small rest */
for (rec = recruits; rec != NULL; rec = rec->next) {
int want = rec->total - rec->assigned;
@ -330,7 +318,7 @@ static int do_recruiting(recruitment * recruits, int available)
/* do actual recruiting */
for (rec = recruits; rec != NULL; rec = rec->next) {
request *req;
production *req;
int get = rec->assigned;
for (req = rec->requests; req; req = req->next) {
@ -379,7 +367,7 @@ void free_recruitments(recruitment * recruits)
recruitment *rec = recruits;
recruits = rec->next;
while (rec->requests) {
request *req = rec->requests;
production *req = rec->requests;
rec->requests = req->next;
free_order(req->ord);
free(req);
@ -389,7 +377,7 @@ void free_recruitments(recruitment * recruits)
}
/* Rekrutierung */
static void expandrecruit(region * r, request * recruitorders)
static void expandrecruit(region * r, production * recruitorders)
{
recruitment *recruits = NULL;
@ -430,11 +418,11 @@ static int recruit_cost(const faction * f, const race * rc)
return -1;
}
static void recruit(unit * u, struct order *ord, request ** recruitorders)
static void recruit(unit * u, struct order *ord, production ** recruitorders)
{
region *r = u->region;
plane *pl;
request *o;
production *o;
int recruitcost = -1;
const faction *f = u->faction;
const struct race *rc = u_race(u);
@ -555,7 +543,7 @@ static void recruit(unit * u, struct order *ord, request ** recruitorders)
return;
}
o = (request *)calloc(1, sizeof(request));
o = (production *)calloc(1, sizeof(production));
o->qty = n;
o->unit = u;
o->ord = copy_order(ord);
@ -751,7 +739,7 @@ void maintain_buildings(region * r)
void economics(region * r)
{
unit *u;
request *recruitorders = NULL;
production *recruitorders = NULL;
/* Geben vor Selbstmord (doquit)! Hier alle unmittelbaren Befehle.
* Rekrutieren vor allen Einnahmequellen. Bewachen JA vor Steuern
@ -1441,7 +1429,7 @@ const attrib_type at_luxuries = {
"luxuries", NULL, free_luxuries, NULL, NULL, NULL
};
static void expandbuying(region * r, request * buyorders)
static void expandbuying(region * r, production * buyorders)
{
const resource_type *rsilver = get_resourcetype(R_SILVER);
int max_products;
@ -1554,12 +1542,12 @@ attrib_type at_trades = {
NO_READ
};
static void buy(unit * u, request ** buyorders, struct order *ord)
static void buy(unit * u, production ** buyorders, struct order *ord)
{
char token[128];
region *r = u->region;
int n, k;
request *o;
production *o;
attrib *a;
const item_type *itype = NULL;
const luxury_type *ltype = NULL;
@ -1650,7 +1638,7 @@ static void buy(unit * u, request ** buyorders, struct order *ord)
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "luxury_notsold", ""));
return;
}
o = (request *)calloc(1, sizeof(request));
o = (production *)calloc(1, sizeof(production));
o->type.ltype = ltype; /* sollte immer gleich sein */
o->unit = u;
@ -1670,7 +1658,7 @@ static void add_income(unit * u, int type, int want, int qty)
/* Steuers<72>tze in % bei Burggr<67><72>e */
static int tax_per_size[7] = { 0, 6, 12, 18, 24, 30, 36 };
static void expandselling(region * r, request * sellorders, int limit)
static void expandselling(region * r, production * sellorders, int limit)
{
int money, price, max_products;
unsigned int j;
@ -1859,7 +1847,7 @@ static void expandselling(region * r, request * sellorders, int limit)
}
}
static bool sell(unit * u, request ** sellorders, struct order *ord)
static bool sell(unit * u, production ** sellorders, struct order *ord)
{
char token[128];
bool unlimited = true;
@ -1952,7 +1940,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
}
else {
attrib *a;
request *o;
production *o;
int k, available;
if (!r_demand(r, ltype)) {
@ -1977,7 +1965,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
cmistake(u, ord, 264, MSG_COMMERCE);
return false;
}
/* Hier wird request->type verwendet, weil die obere limit durch
/* Hier wird production->type verwendet, weil die obere limit durch
* das silber gegeben wird (region->money), welches f<EFBFBD>r alle
* (!) produkte als summe gilt, als nicht wie bei der
* produktion, wo f<EFBFBD>r jedes produkt einzeln eine obere limite
@ -2000,7 +1988,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
assert(n >= 0);
/* die Menge der verkauften G<>ter merken */
a->data.i += n;
o = (request *)calloc(1, sizeof(request));
o = (production *)calloc(1, sizeof(production));
o->unit = u;
o->qty = n;
o->type.ltype = ltype;
@ -2012,7 +2000,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
/* ------------------------------------------------------------- */
static void expandstealing(region * r, request * stealorders)
static void expandstealing(region * r, production * stealorders)
{
const resource_type *rsilver = get_resourcetype(R_SILVER);
unsigned int j;
@ -2406,12 +2394,12 @@ message * check_steal(const unit * u, struct order *ord) {
return 0;
}
static void steal_cmd(unit * u, struct order *ord, request ** stealorders)
static void steal_cmd(unit * u, struct order *ord, production ** stealorders)
{
const resource_type *rring = get_resourcetype(R_RING_OF_NIMBLEFINGER);
int n, i, id, effsk;
bool goblin = false;
request *o;
production *o;
unit *u2 = NULL;
region *r = u->region;
faction *f = NULL;
@ -2508,7 +2496,7 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders)
/* wer dank unsichtbarkeitsringen klauen kann, muss nicht unbedingt ein
* guter dieb sein, schliesslich macht man immer noch sehr viel laerm */
o = (request *)calloc(1, sizeof(request));
o = (production *)calloc(1, sizeof(production));
o->unit = u;
o->qty = 1; /* Betrag steht in u->wants */
o->no = u2->no;
@ -2526,7 +2514,7 @@ static void expandentertainment(region * r)
{
unit *u;
int m = entertainmoney(r);
request *o;
production *o;
for (o = &entertainers[0]; o != nextentertainer; ++o) {
double part = m / (double)entertaining;
@ -2551,7 +2539,7 @@ void entertain_cmd(unit * u, struct order *ord)
{
region *r = u->region;
int max_e;
request *o;
production *o;
static int entertainbase = 0;
static int entertainperlevel = 0;
keyword_t kwd;
@ -2604,7 +2592,7 @@ void entertain_cmd(unit * u, struct order *ord)
* \return number of working spaces taken by players
*/
static void
expandwork(region * r, request * work_begin, request * work_end, int maxwork)
expandwork(region * r, production * work_begin, production * work_end, int maxwork)
{
int earnings;
/* n: verbleibende Einnahmen */
@ -2612,7 +2600,7 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork)
int jobs = maxwork;
int p_wage = wage(r, NULL, NULL, turn);
int money = rmoney(r);
request *o;
production *o;
for (o = work_begin; o != work_end; ++o) {
unit *u = o->unit;
@ -2655,7 +2643,7 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork)
rsetmoney(r, money + earnings);
}
static int do_work(unit * u, order * ord, request * o)
static int do_work(unit * u, order * ord, production * o)
{
if (playerrace(u_race(u))) {
region *r = u->region;
@ -2690,7 +2678,7 @@ static int do_work(unit * u, order * ord, request * o)
return -1;
}
static void expandloot(region * r, request * lootorders)
static void expandloot(region * r, production * lootorders)
{
unit *u;
unsigned int i;
@ -2727,7 +2715,7 @@ static void expandloot(region * r, request * lootorders)
}
}
void expandtax(region * r, request * taxorders)
void expandtax(region * r, production * taxorders)
{
unit *u;
unsigned int i;
@ -2751,13 +2739,13 @@ void expandtax(region * r, request * taxorders)
}
}
void tax_cmd(unit * u, struct order *ord, request ** taxorders)
void tax_cmd(unit * u, struct order *ord, production ** taxorders)
{
/* Steuern werden noch vor der Forschung eingetrieben */
region *r = u->region;
unit *u2;
int n;
request *o;
production *o;
int max;
keyword_t kwd;
static int taxperlevel = 0;
@ -2819,20 +2807,20 @@ void tax_cmd(unit * u, struct order *ord, request ** taxorders)
* fraktionen werden dann bei eintreiben unter allen eintreibenden
* einheiten aufgeteilt. */
o = (request *)calloc(1, sizeof(request));
o = (production *)calloc(1, sizeof(production));
o->qty = u->wants / TAXFRACTION;
o->unit = u;
addlist(taxorders, o);
return;
}
void loot_cmd(unit * u, struct order *ord, request ** lootorders)
void loot_cmd(unit * u, struct order *ord, production ** lootorders)
{
region *r = u->region;
unit *u2;
int n;
int max;
request *o;
production *o;
keyword_t kwd;
kwd = init_order_depr(ord);
@ -2884,7 +2872,7 @@ void loot_cmd(unit * u, struct order *ord, request ** lootorders)
u->wants = MIN(n * skbonus * 10, max);
}
o = (request *)calloc(1, sizeof(request));
o = (production *)calloc(1, sizeof(production));
o->qty = u->wants / TAXFRACTION;
o->unit = u;
addlist(lootorders, o);
@ -2895,8 +2883,8 @@ void loot_cmd(unit * u, struct order *ord, request ** lootorders)
#define MAX_WORKERS 2048
void auto_work(region * r)
{
request workers[MAX_WORKERS];
request *nextworker = workers;
production workers[MAX_WORKERS];
production *nextworker = workers;
unit *u;
for (u = r->units; u; u = u->next) {
@ -2964,11 +2952,11 @@ static bool rule_autowork(void) {
void produce(struct region *r)
{
request workers[MAX_WORKERS];
request *taxorders, *lootorders, *sellorders, *stealorders, *buyorders;
production workers[MAX_WORKERS];
production *taxorders, *lootorders, *sellorders, *stealorders, *buyorders;
unit *u;
bool limited = true;
request *nextworker = workers;
production *nextworker = workers;
static int bt_cache;
static const struct building_type *caravan_bt;
static int rc_cache;

View File

@ -45,7 +45,18 @@ extern "C" {
struct faction;
struct order;
struct message;
struct request;
typedef struct production {
struct production *next;
struct unit *unit;
struct order *ord;
int qty;
int no;
union {
bool goblin; /* stealing */
const struct luxury_type *ltype; /* trading */
} type;
} production;
int income(const struct unit *u);
int entertainmoney(const struct region *r);
@ -61,8 +72,8 @@ extern "C" {
void split_allocations(struct region *r);
int give_control_cmd(struct unit *u, struct order *ord);
void give_control(struct unit * u, struct unit * u2);
void tax_cmd(struct unit * u, struct order *ord, struct request ** taxorders);
void expandtax(struct region * r, struct request * taxorders);
void tax_cmd(struct unit * u, struct order *ord, struct production ** taxorders);
void expandtax(struct region * r, struct production * taxorders);
void add_recruits(struct unit * u, int number, int wanted);
struct message * check_steal(const struct unit * u, struct order *ord);

View File

@ -300,26 +300,13 @@ static void test_buy_cmd(CuTest *tc) {
test_cleanup();
}
typedef struct request {
struct request *next;
struct unit *unit;
struct order *ord;
int qty;
int no;
union {
bool goblin; /* stealing */
const struct luxury_type *ltype; /* trading */
} type;
} request;
static void test_tax_cmd(CuTest *tc) {
order *ord;
faction *f;
region *r;
unit *u;
item_type *sword, *silver;
request *taxorders = 0;
production *taxorders = 0;
test_setup();
init_resources();

View File

@ -139,7 +139,7 @@ const char *regionname(const region * r, const faction * f)
int region_maxworkers(const region *r)
{
int size = production(r);
int size = max_production(r);
int treespace = (rtrees(r, 2) + rtrees(r, 1) / 2) * TREESIZE;
return MAX(size - treespace, MIN(size / 10, 200));
}
@ -1244,7 +1244,7 @@ void terraform_region(region * r, const terrain_type * terrain)
* egal ob durch den spell oder anderes angelegt.
**/
#include "curse.h"
int production(const region * r)
int max_production(const region * r)
{
/* muß rterrain(r) sein, nicht rterrain() wegen rekursion */
int p = r->terrain->size;

View File

@ -240,7 +240,7 @@ extern "C" {
extern const int delta_x[MAXDIRECTIONS];
extern const int delta_y[MAXDIRECTIONS];
direction_t dir_invert(direction_t dir);
int production(const struct region *r);
int max_production(const struct region *r);
void region_set_owner(struct region *r, struct faction *owner, int turn);
struct faction *region_get_owner(const struct region *r);

View File

@ -314,7 +314,7 @@ static void peasants(region * r, int rule)
{
int peasants = rpeasants(r);
int money = rmoney(r);
int maxp = production(r);
int maxp = max_production(r);
int n, satiated;
int dead = 0;
@ -588,12 +588,12 @@ growing_trees(region * r, const int current_season, const int last_weeks_season)
return;
}
if (production(r) <= 0)
if (max_production(r) <= 0)
return;
/* Grundchance 1.0% */
/* Jeder Elf in der Region erhöht die Chance marginal */
elves = MIN(elves, production(r) / 8);
elves = MIN(elves, max_production(r) / 8);
if (elves) {
seedchance += 1.0 - pow(0.99999, elves * RESOURCE_QUANTITY);
}

View File

@ -974,7 +974,7 @@ void report_region(struct stream *out, const region * r, faction * f)
/* Trees */
trees = rtrees(r, 2);
saplings = rtrees(r, 1);
if (production(r)) {
if (max_production(r)) {
if (trees > 0 || saplings > 0) {
bytes = snprintf(bufp, size, ", %d/%d ", trees, saplings);
if (wrptr(&bufp, &size, bytes) != 0)
@ -1311,7 +1311,7 @@ static void statistics(struct stream *out, const region * r, const faction * f)
paragraph(out, buf, 2, 2, 0);
msg_release(m);
}
if (production(r) && (!fval(r->terrain, SEA_REGION)
if (max_production(r) && (!fval(r->terrain, SEA_REGION)
|| f->race == get_race(RC_AQUARIAN))) {
if (markets_module()) { /* hack */
m =