From a7463d57a6ade33ad026cfafdc50b1b34230cf38 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 25 Jul 2009 08:02:13 +0000 Subject: [PATCH] mourning --- src/common/gamecode/creport.c | 10 +++++----- src/common/gamecode/economy.c | 6 +++--- src/common/gamecode/laws.c | 2 +- src/common/gamecode/report.c | 10 +++++++--- src/common/kernel/eressea.c | 18 ++++++++++-------- src/common/kernel/eressea.h | 4 ++-- src/common/kernel/region.c | 16 ++++++++++++++-- src/common/kernel/region.h | 2 +- src/common/kernel/xmlreader.c | 2 +- src/eressea/tolua/helpers.c | 3 ++- src/res/de/strings.xml | 4 ++++ 11 files changed, 50 insertions(+), 27 deletions(-) diff --git a/src/common/gamecode/creport.c b/src/common/gamecode/creport.c index 66aa740dd..9f8ab1e22 100644 --- a/src/common/gamecode/creport.c +++ b/src/common/gamecode/creport.c @@ -1178,15 +1178,15 @@ cr_output_region(FILE * F, report_context * ctx, seen_region * sr) fprintf(F, "%d;Unterh\n", entertainmoney(r)); } if (is_cursed(r->attribs, C_RIOT, 0)){ - fprintf(F, "0;Rekruten\n"); + fputs("0;Rekruten\n", F); } else { fprintf(F, "%d;Rekruten\n", rpeasants(r) / RECRUITFRACTION); } if (production(r)) { - if (markets_module()) { /* hack */ - fprintf(F, "%d;Lohn\n", wage(r, NULL, NULL)); - } else { - fprintf(F, "%d;Lohn\n", wage(r, f, f->race)); + int p_wage = wage(r, NULL, NULL, turn+1); + fprintf(F, "%d;Lohn\n", p_wage); + if (owner_change(r)==turn) { + fputs("1;mourning\n", F); } } if (r->land->ownership) { diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index 5961678ca..53acc3252 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -3077,7 +3077,7 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork) /* n: verbleibende Einnahmen */ /* fishes: maximale Arbeiter */ int jobs = maxwork; - int p_wage = wage(r, NULL, NULL); + int p_wage = wage(r, NULL, NULL, turn); int money = rmoney(r); request *o; @@ -3095,7 +3095,7 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork) assert(workers>=0); - u->n = workers * wage(u->region, u->faction, u->race); + u->n = workers * wage(u->region, u->faction, u->race, turn); jobs -= workers; assert(jobs>=0); @@ -3144,7 +3144,7 @@ do_work(unit * u, order * ord, request * o) if (ord) cmistake(u, ord, 69, MSG_INCOME); return -1; } - w = wage(r, u->faction, u->race); + w = wage(r, u->faction, u->race, turn); u->wants = u->number * w; o->unit = u; o->qty = u->number * w; diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 1d84684d2..f2b0e498a 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -3076,7 +3076,7 @@ void update_owners(region * r) faction * f = region_get_owner(r); unit * u = buildingowner(r, blargest); if (u==NULL) { - region_set_owner(r, NULL, turn); + if (f) region_set_owner(r, NULL, turn); } else if (u->faction!=f) { region_set_owner(r, u->faction, turn); } diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index ca06aba83..8e75c5b61 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -967,6 +967,10 @@ describe(FILE * F, const seen_region * sr, faction * f) bytes = (int)strlcpy(bufp, LOC(f->locale, n==1?"peasant":"peasant_p"), size); } if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER(); + if (owner_change(r)==turn) { + bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_mourning"), size); + if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER(); + } } if (rmoney(r) && sr->mode==see_unit) { bytes = snprintf(bufp, size, ", %d ", rmoney(r)); @@ -1190,9 +1194,9 @@ statistics(FILE * F, const region * r, const faction * f) } if (production(r) && (!fval(r->terrain, SEA_REGION) || f->race == new_race[RC_AQUARIAN])) { if (markets_module()) { /* hack */ - m = msg_message("nr_stat_salary_new", "max", wage(r, NULL, NULL)); + m = msg_message("nr_stat_salary_new", "max", wage(r, NULL, NULL, turn+1)); } else { - m = msg_message("nr_stat_salary", "max", wage(r, f, f->race)); + m = msg_message("nr_stat_salary", "max", wage(r, f, f->race, turn+1)); } nr_render(m, f->locale, buf, sizeof(buf), f); rparagraph(F, buf, 2, 2, 0); @@ -1409,7 +1413,7 @@ report_template(const char * filename, report_context * ctx, const char * charse } rps_nowrap(F, buf); rnl(F); - sprintf(buf,"; ECheck Lohn %d", wage(r, f, f->race)); + sprintf(buf,"; ECheck Lohn %d", wage(r, f, f->race, turn+1)); rps_nowrap(F, buf); rnl(F); rps_nowrap(F, ""); diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 3305addca..f5244e1db 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -2578,7 +2578,7 @@ plagues(region * r, boolean ismagic) if (!ismagic) { double mwp = MAX(maxworkingpeasants(r), 1); - double prob = pow(rpeasants(r) / (mwp * wage(r, NULL, NULL) * 0.13), 4.0) + double prob = pow(rpeasants(r) / (mwp * wage(r, NULL, NULL, turn) * 0.13), 4.0) * PLAGUE_CHANCE; if (rng_double() >= prob) return; @@ -2649,7 +2649,7 @@ int rule_auto_taxation(void) } static int -default_wage(const region *r, const faction * f, const race * rc) +default_wage(const region *r, const faction * f, const race * rc, int in_turn) { building *b = largestbuilding(r, &is_castle, false); int esize = 0; @@ -2683,7 +2683,9 @@ default_wage(const region *r, const faction * f, const race * rc) } #endif /* KARMA_MODULE */ } else { - if (fval(r->terrain, SEA_REGION)) { + if (owner_change(r) == in_turn-1) { + wage = 10; + } else if (fval(r->terrain, SEA_REGION)) { wage = 11; } else if (fval(r, RF_ORCIFIED)) { wage = wagetable[esize][1]; @@ -2721,23 +2723,23 @@ default_wage(const region *r, const faction * f, const race * rc) } static int -minimum_wage(const region *r, const faction * f, const race * rc) +minimum_wage(const region *r, const faction * f, const race * rc, int in_turn) { if (f && rc) { return rc->maintenance; } - return default_wage(r, f, rc); + return default_wage(r, f, rc, in_turn); } /* Gibt Arbeitslohn für entsprechende Rasse zurück, oder für * die Bauern wenn f == NULL. */ int -wage(const region *r, const faction * f, const race * rc) +wage(const region *r, const faction * f, const race * rc, int in_turn) { if (global.functions.wage) { - return global.functions.wage(r, f, rc); + return global.functions.wage(r, f, rc, in_turn); } - return default_wage(r, f, rc); + return default_wage(r, f, rc, in_turn); } diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index 9d45600f7..74820b9a6 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -340,7 +340,7 @@ 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 wage(const struct region *r, const struct faction *f, const struct race * rc, int in_turn); 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); extern boolean move_blocked(const struct unit * u, const struct region *src, const struct region *dest); @@ -381,7 +381,7 @@ typedef struct settings { int cookie; struct global_functions { - int (*wage)(const struct region *r, const struct faction * f, const struct race * rc); + int (*wage)(const struct region *r, const struct faction * f, const struct race * rc, int in_turn); int (*maintenance)(const struct unit * u); } functions; } settings; diff --git a/src/common/kernel/region.c b/src/common/kernel/region.c index 3dda60caa..eb0701997 100644 --- a/src/common/kernel/region.c +++ b/src/common/kernel/region.c @@ -1342,7 +1342,7 @@ terraform_region(region * r, const terrain_type * terrain) int peasants; peasants = (maxworkingpeasants(r) * (20+dice_rand("6d10")))/100; rsetpeasants(r, MAX(100, peasants)); - rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL)+1) + rng_int() % 5)); + rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL, INT_MAX)+1) + rng_int() % 5)); } } } @@ -1457,11 +1457,16 @@ region_set_owner(struct region * r, struct faction * owner, int turn) if (!r->land->ownership) { r->land->ownership = malloc(sizeof(region_owner)); region_set_morale(r, MORALE_DEFAULT, turn); + r->land->ownership->since_turn = -turn; + r->land->ownership->owner = NULL; } else if (r->land->ownership->owner) { region_set_morale(r, MORALE_TAKEOVER, turn); + r->land->ownership->since_turn = turn; + } else { + r->land->ownership->since_turn = -turn; } + assert(r->land->ownership->owner != owner); r->land->ownership->owner = owner; - r->land->ownership->since_turn = turn; } } @@ -1517,3 +1522,10 @@ void get_neighbours(const region * r, region ** list) } } +int owner_change(const region * r) +{ + if (r->land && r->land->ownership) { + return r->land->ownership->since_turn; + } + return -1; +} diff --git a/src/common/kernel/region.h b/src/common/kernel/region.h index 8c845b0a8..75edef3dc 100644 --- a/src/common/kernel/region.h +++ b/src/common/kernel/region.h @@ -274,7 +274,7 @@ const char * region_getinfo(const struct region * self); 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); - +int owner_change(const region * r); extern const struct item_type * r_luxury(struct region * r); extern void get_neighbours(const struct region * r, struct region ** list); #ifdef __cplusplus diff --git a/src/common/kernel/xmlreader.c b/src/common/kernel/xmlreader.c index 9ce155b12..fb562d463 100644 --- a/src/common/kernel/xmlreader.c +++ b/src/common/kernel/xmlreader.c @@ -922,7 +922,7 @@ parse_rules(xmlDocPtr doc) } assert(propValue!=NULL); if (strcmp((const char*)propValue, "wage")==0) { - global.functions.wage = (int (*)(const struct region*, const struct faction*, const struct race*))fun; + global.functions.wage = (int (*)(const struct region*, const struct faction*, const struct race*, int))fun; } else if (strcmp((const char*)propValue, "maintenance")==0) { global.functions.maintenance = (int (*)(const struct unit*))fun; } else { diff --git a/src/eressea/tolua/helpers.c b/src/eressea/tolua/helpers.c index 54b16672f..4c3c20a25 100644 --- a/src/eressea/tolua/helpers.c +++ b/src/eressea/tolua/helpers.c @@ -349,7 +349,7 @@ lua_canuse_item(const unit * u, const struct item_type * itype) } static int -lua_wage(const region * r, const faction * f, const race * rc) +lua_wage(const region * r, const faction * f, const race * rc, int in_turn) { lua_State * L = (lua_State *)global.vm_state; const char * fname = "wage"; @@ -361,6 +361,7 @@ lua_wage(const region * r, const faction * f, const race * rc) tolua_pushusertype(L, (void *)r, TOLUA_CAST "region"); tolua_pushusertype(L, (void *)f, TOLUA_CAST "faction"); tolua_pushstring(L, rc?rc->_name[0]:0); + tolua_pushnumber(L, (lua_Number)in_turn); if (lua_pcall(L, 3, 1, 0)!=0) { const char* error = lua_tostring(L, -1); diff --git a/src/res/de/strings.xml b/src/res/de/strings.xml index 357eea143..2966c06fd 100644 --- a/src/res/de/strings.xml +++ b/src/res/de/strings.xml @@ -306,6 +306,10 @@ beaucoup de + + (trauernd) + (in mourning) + Beschreibung: Description: