forked from github/server
mourning
This commit is contained in:
parent
1ad2f4a264
commit
a7463d57a6
11 changed files with 50 additions and 27 deletions
|
@ -1178,15 +1178,15 @@ cr_output_region(FILE * F, report_context * ctx, seen_region * sr)
|
||||||
fprintf(F, "%d;Unterh\n", entertainmoney(r));
|
fprintf(F, "%d;Unterh\n", entertainmoney(r));
|
||||||
}
|
}
|
||||||
if (is_cursed(r->attribs, C_RIOT, 0)){
|
if (is_cursed(r->attribs, C_RIOT, 0)){
|
||||||
fprintf(F, "0;Rekruten\n");
|
fputs("0;Rekruten\n", F);
|
||||||
} else {
|
} else {
|
||||||
fprintf(F, "%d;Rekruten\n", rpeasants(r) / RECRUITFRACTION);
|
fprintf(F, "%d;Rekruten\n", rpeasants(r) / RECRUITFRACTION);
|
||||||
}
|
}
|
||||||
if (production(r)) {
|
if (production(r)) {
|
||||||
if (markets_module()) { /* hack */
|
int p_wage = wage(r, NULL, NULL, turn+1);
|
||||||
fprintf(F, "%d;Lohn\n", wage(r, NULL, NULL));
|
fprintf(F, "%d;Lohn\n", p_wage);
|
||||||
} else {
|
if (owner_change(r)==turn) {
|
||||||
fprintf(F, "%d;Lohn\n", wage(r, f, f->race));
|
fputs("1;mourning\n", F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (r->land->ownership) {
|
if (r->land->ownership) {
|
||||||
|
|
|
@ -3077,7 +3077,7 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork)
|
||||||
/* n: verbleibende Einnahmen */
|
/* n: verbleibende Einnahmen */
|
||||||
/* fishes: maximale Arbeiter */
|
/* fishes: maximale Arbeiter */
|
||||||
int jobs = maxwork;
|
int jobs = maxwork;
|
||||||
int p_wage = wage(r, NULL, NULL);
|
int p_wage = wage(r, NULL, NULL, turn);
|
||||||
int money = rmoney(r);
|
int money = rmoney(r);
|
||||||
request *o;
|
request *o;
|
||||||
|
|
||||||
|
@ -3095,7 +3095,7 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork)
|
||||||
|
|
||||||
assert(workers>=0);
|
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;
|
jobs -= workers;
|
||||||
assert(jobs>=0);
|
assert(jobs>=0);
|
||||||
|
@ -3144,7 +3144,7 @@ do_work(unit * u, order * ord, request * o)
|
||||||
if (ord) cmistake(u, ord, 69, MSG_INCOME);
|
if (ord) cmistake(u, ord, 69, MSG_INCOME);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
w = wage(r, u->faction, u->race);
|
w = wage(r, u->faction, u->race, turn);
|
||||||
u->wants = u->number * w;
|
u->wants = u->number * w;
|
||||||
o->unit = u;
|
o->unit = u;
|
||||||
o->qty = u->number * w;
|
o->qty = u->number * w;
|
||||||
|
|
|
@ -3076,7 +3076,7 @@ void update_owners(region * r)
|
||||||
faction * f = region_get_owner(r);
|
faction * f = region_get_owner(r);
|
||||||
unit * u = buildingowner(r, blargest);
|
unit * u = buildingowner(r, blargest);
|
||||||
if (u==NULL) {
|
if (u==NULL) {
|
||||||
region_set_owner(r, NULL, turn);
|
if (f) region_set_owner(r, NULL, turn);
|
||||||
} else if (u->faction!=f) {
|
} else if (u->faction!=f) {
|
||||||
region_set_owner(r, u->faction, turn);
|
region_set_owner(r, u->faction, turn);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, n==1?"peasant":"peasant_p"), size);
|
||||||
}
|
}
|
||||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
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) {
|
if (rmoney(r) && sr->mode==see_unit) {
|
||||||
bytes = snprintf(bufp, size, ", %d ", rmoney(r));
|
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 (production(r) && (!fval(r->terrain, SEA_REGION) || f->race == new_race[RC_AQUARIAN])) {
|
||||||
if (markets_module()) { /* hack */
|
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 {
|
} 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);
|
nr_render(m, f->locale, buf, sizeof(buf), f);
|
||||||
rparagraph(F, buf, 2, 2, 0);
|
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);
|
rps_nowrap(F, buf);
|
||||||
rnl(F);
|
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);
|
rps_nowrap(F, buf);
|
||||||
rnl(F);
|
rnl(F);
|
||||||
rps_nowrap(F, "");
|
rps_nowrap(F, "");
|
||||||
|
|
|
@ -2578,7 +2578,7 @@ plagues(region * r, boolean ismagic)
|
||||||
|
|
||||||
if (!ismagic) {
|
if (!ismagic) {
|
||||||
double mwp = MAX(maxworkingpeasants(r), 1);
|
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;
|
* PLAGUE_CHANCE;
|
||||||
|
|
||||||
if (rng_double() >= prob) return;
|
if (rng_double() >= prob) return;
|
||||||
|
@ -2649,7 +2649,7 @@ int rule_auto_taxation(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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);
|
building *b = largestbuilding(r, &is_castle, false);
|
||||||
int esize = 0;
|
int esize = 0;
|
||||||
|
@ -2683,7 +2683,9 @@ default_wage(const region *r, const faction * f, const race * rc)
|
||||||
}
|
}
|
||||||
#endif /* KARMA_MODULE */
|
#endif /* KARMA_MODULE */
|
||||||
} else {
|
} 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;
|
wage = 11;
|
||||||
} else if (fval(r, RF_ORCIFIED)) {
|
} else if (fval(r, RF_ORCIFIED)) {
|
||||||
wage = wagetable[esize][1];
|
wage = wagetable[esize][1];
|
||||||
|
@ -2721,23 +2723,23 @@ default_wage(const region *r, const faction * f, const race * rc)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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) {
|
if (f && rc) {
|
||||||
return rc->maintenance;
|
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
|
/* Gibt Arbeitslohn für entsprechende Rasse zurück, oder für
|
||||||
* die Bauern wenn f == NULL. */
|
* die Bauern wenn f == NULL. */
|
||||||
int
|
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) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -340,7 +340,7 @@ extern int besieged(const struct unit * u);
|
||||||
extern int maxworkingpeasants(const struct region * r);
|
extern int maxworkingpeasants(const struct region * r);
|
||||||
extern boolean has_horses(const struct unit * u);
|
extern boolean has_horses(const struct unit * u);
|
||||||
extern int markets_module(void);
|
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 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 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);
|
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;
|
int cookie;
|
||||||
|
|
||||||
struct global_functions {
|
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);
|
int (*maintenance)(const struct unit * u);
|
||||||
} functions;
|
} functions;
|
||||||
} settings;
|
} settings;
|
||||||
|
|
|
@ -1342,7 +1342,7 @@ terraform_region(region * r, const terrain_type * terrain)
|
||||||
int peasants;
|
int peasants;
|
||||||
peasants = (maxworkingpeasants(r) * (20+dice_rand("6d10")))/100;
|
peasants = (maxworkingpeasants(r) * (20+dice_rand("6d10")))/100;
|
||||||
rsetpeasants(r, MAX(100, peasants));
|
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) {
|
if (!r->land->ownership) {
|
||||||
r->land->ownership = malloc(sizeof(region_owner));
|
r->land->ownership = malloc(sizeof(region_owner));
|
||||||
region_set_morale(r, MORALE_DEFAULT, turn);
|
region_set_morale(r, MORALE_DEFAULT, turn);
|
||||||
|
r->land->ownership->since_turn = -turn;
|
||||||
|
r->land->ownership->owner = NULL;
|
||||||
} else if (r->land->ownership->owner) {
|
} else if (r->land->ownership->owner) {
|
||||||
region_set_morale(r, MORALE_TAKEOVER, turn);
|
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->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;
|
||||||
|
}
|
||||||
|
|
|
@ -274,7 +274,7 @@ const char * region_getinfo(const struct region * self);
|
||||||
void region_setinfo(struct region * self, const char * name);
|
void region_setinfo(struct region * self, const char * name);
|
||||||
int region_getresource(const struct region * r, const struct resource_type * rtype);
|
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);
|
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 const struct item_type * r_luxury(struct region * r);
|
||||||
extern void get_neighbours(const struct region * r, struct region ** list);
|
extern void get_neighbours(const struct region * r, struct region ** list);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -922,7 +922,7 @@ parse_rules(xmlDocPtr doc)
|
||||||
}
|
}
|
||||||
assert(propValue!=NULL);
|
assert(propValue!=NULL);
|
||||||
if (strcmp((const char*)propValue, "wage")==0) {
|
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) {
|
} else if (strcmp((const char*)propValue, "maintenance")==0) {
|
||||||
global.functions.maintenance = (int (*)(const struct unit*))fun;
|
global.functions.maintenance = (int (*)(const struct unit*))fun;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -349,7 +349,7 @@ lua_canuse_item(const unit * u, const struct item_type * itype)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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;
|
lua_State * L = (lua_State *)global.vm_state;
|
||||||
const char * fname = "wage";
|
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 *)r, TOLUA_CAST "region");
|
||||||
tolua_pushusertype(L, (void *)f, TOLUA_CAST "faction");
|
tolua_pushusertype(L, (void *)f, TOLUA_CAST "faction");
|
||||||
tolua_pushstring(L, rc?rc->_name[0]:0);
|
tolua_pushstring(L, rc?rc->_name[0]:0);
|
||||||
|
tolua_pushnumber(L, (lua_Number)in_turn);
|
||||||
|
|
||||||
if (lua_pcall(L, 3, 1, 0)!=0) {
|
if (lua_pcall(L, 3, 1, 0)!=0) {
|
||||||
const char* error = lua_tostring(L, -1);
|
const char* error = lua_tostring(L, -1);
|
||||||
|
|
|
@ -306,6 +306,10 @@
|
||||||
<text locale="fr">beaucoup de</text>
|
<text locale="fr">beaucoup de</text>
|
||||||
</string>
|
</string>
|
||||||
|
|
||||||
|
<string name="nr_mourning">
|
||||||
|
<text locale="de"> (trauernd)</text>
|
||||||
|
<text locale="en"> (in mourning)</text>
|
||||||
|
</string>
|
||||||
<string name="nr_spell_description">
|
<string name="nr_spell_description">
|
||||||
<text locale="de">Beschreibung:</text>
|
<text locale="de">Beschreibung:</text>
|
||||||
<text locale="en">Description:</text>
|
<text locale="en">Description:</text>
|
||||||
|
|
Loading…
Reference in a new issue