forked from github/server
mourning, better.
This commit is contained in:
parent
a7463d57a6
commit
d173ba6218
|
@ -1185,7 +1185,7 @@ cr_output_region(FILE * F, report_context * ctx, seen_region * sr)
|
|||
if (production(r)) {
|
||||
int p_wage = wage(r, NULL, NULL, turn+1);
|
||||
fprintf(F, "%d;Lohn\n", p_wage);
|
||||
if (owner_change(r)==turn) {
|
||||
if (is_mourning(r, turn+1)) {
|
||||
fputs("1;mourning\n", F);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -967,7 +967,7 @@ 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) {
|
||||
if (is_mourning(r, turn+1)) {
|
||||
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_mourning"), size);
|
||||
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
|
||||
}
|
||||
|
|
|
@ -2683,7 +2683,7 @@ default_wage(const region *r, const faction * f, const race * rc, int in_turn)
|
|||
}
|
||||
#endif /* KARMA_MODULE */
|
||||
} else {
|
||||
if (owner_change(r) == in_turn-1) {
|
||||
if (is_mourning(r, in_turn)) {
|
||||
wage = 10;
|
||||
} else if (fval(r->terrain, SEA_REGION)) {
|
||||
wage = 11;
|
||||
|
|
|
@ -1457,14 +1457,15 @@ 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;
|
||||
r->land->ownership->flags = 0;
|
||||
} else if (r->land->ownership->owner) {
|
||||
region_set_morale(r, MORALE_TAKEOVER, turn);
|
||||
r->land->ownership->since_turn = turn;
|
||||
r->land->ownership->flags |= OWNER_MOURNING;
|
||||
} else {
|
||||
r->land->ownership->since_turn = -turn;
|
||||
r->land->ownership->flags &= ~OWNER_MOURNING;
|
||||
}
|
||||
r->land->ownership->since_turn = turn;
|
||||
assert(r->land->ownership->owner != owner);
|
||||
r->land->ownership->owner = owner;
|
||||
}
|
||||
|
@ -1529,3 +1530,9 @@ int owner_change(const region * r)
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
boolean is_mourning(const region * r, int in_turn)
|
||||
{
|
||||
int change = owner_change(r);
|
||||
return (change==in_turn-1 && (r->land->ownership->flags&OWNER_MOURNING));
|
||||
}
|
||||
|
|
|
@ -67,10 +67,12 @@ struct item;
|
|||
#define MORALE_TAKEOVER 0 /* Morale of peasants after they lose their lord */
|
||||
#define MORALE_COOLDOWN 2 /* minimum cooldown before a morale change occurs */
|
||||
|
||||
#define OWNER_MOURNING 0x01
|
||||
typedef struct region_owner {
|
||||
struct faction * owner;
|
||||
int since_turn; /* turn the region changed owners */
|
||||
int morale_turn; /* turn when morale has changed most recently */
|
||||
unsigned int flags;
|
||||
} region_owner;
|
||||
|
||||
typedef struct demand {
|
||||
|
@ -275,6 +277,7 @@ 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);
|
||||
boolean is_mourning(const region * r, int in_turn);
|
||||
extern const struct item_type * r_luxury(struct region * r);
|
||||
extern void get_neighbours(const struct region * r, struct region ** list);
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -602,6 +602,7 @@ write_owner(struct storage * store, region_owner *owner)
|
|||
if (owner) {
|
||||
store->w_int(store, owner->since_turn);
|
||||
store->w_int(store, owner->morale_turn);
|
||||
store->w_int(store, owner->flags);
|
||||
write_faction_reference(owner->owner, store);
|
||||
} else {
|
||||
store->w_int(store, -1);
|
||||
|
@ -616,6 +617,11 @@ read_owner(struct storage * store, region_owner **powner)
|
|||
region_owner * owner = malloc(sizeof(region_owner));
|
||||
owner->since_turn = since_turn;
|
||||
owner->morale_turn = store->r_int(store);
|
||||
if (store->version>=MOURNING_VERSION) {
|
||||
owner->flags = store->r_int(store);
|
||||
} else {
|
||||
owner->flags = 0;
|
||||
}
|
||||
read_reference(&owner->owner, store, read_faction_reference, resolve_faction);
|
||||
*powner = owner;
|
||||
} else {
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#define REGIONOWNER_VERSION 333 /* regions have owners and morale */
|
||||
#define ALLIANCELEADER_VERSION 333 /* alliances have a leader */
|
||||
#define CURSEFLOAT_VERSION 334 /* all curse-effects are float */
|
||||
#define MOURNING_VERSION 335 /* mourning peasants */
|
||||
|
||||
#define MIN_VERSION CURSETYPE_VERSION /* minimal datafile we support */
|
||||
#define RELEASE_VERSION CURSEFLOAT_VERSION /* current datafile */
|
||||
|
|
Loading…
Reference in New Issue