forked from github/server
morale is ony [0-10], so unsigned short is more than fine.
This commit is contained in:
parent
a51d3edee7
commit
8106cf15a1
|
@ -626,6 +626,7 @@ void rsetpeasants(region * r, int value)
|
||||||
assert(value >= 0);
|
assert(value >= 0);
|
||||||
if (r->land) {
|
if (r->land) {
|
||||||
if (value > USHRT_MAX) {
|
if (value > USHRT_MAX) {
|
||||||
|
log_warning("region %s cannot have %d peasants.", regionname(r, NULL), value);
|
||||||
value = USHRT_MAX;
|
value = USHRT_MAX;
|
||||||
}
|
}
|
||||||
r->land->peasants = (unsigned short)value;
|
r->land->peasants = (unsigned short)value;
|
||||||
|
@ -662,15 +663,18 @@ void rsetmoney(region * r, int value)
|
||||||
|
|
||||||
int rherbs(const region *r)
|
int rherbs(const region *r)
|
||||||
{
|
{
|
||||||
return r->land?r->land->herbs:0;
|
return r->land ? r->land->herbs : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rsetherbs(region *r, int value)
|
void rsetherbs(region *r, int value)
|
||||||
{
|
{
|
||||||
assert(r->land || value==0);
|
assert(r->land || value==0);
|
||||||
assert(value >= 0 && value<=SHRT_MAX);
|
|
||||||
if (r->land) {
|
if (r->land) {
|
||||||
r->land->herbs = value;
|
if (value > USHRT_MAX) {
|
||||||
|
log_warning("region %s cannot have %d herbs.", regionname(r, NULL), value);
|
||||||
|
value = USHRT_MAX;
|
||||||
|
}
|
||||||
|
r->land->herbs = (unsigned short)value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1481,7 +1485,7 @@ const char *region_getname(const region * r)
|
||||||
int region_get_morale(const region * r)
|
int region_get_morale(const region * r)
|
||||||
{
|
{
|
||||||
if (r->land) {
|
if (r->land) {
|
||||||
assert(r->land->morale >= 0 && r->land->morale <= MORALE_MAX);
|
assert(r->land->morale <= MORALE_MAX);
|
||||||
return r->land->morale;
|
return r->land->morale;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1490,11 +1494,11 @@ int region_get_morale(const region * r)
|
||||||
void region_set_morale(region * r, int morale, int turn)
|
void region_set_morale(region * r, int morale, int turn)
|
||||||
{
|
{
|
||||||
if (r->land) {
|
if (r->land) {
|
||||||
r->land->morale = morale;
|
r->land->morale = (unsigned short)morale;
|
||||||
if (turn >= 0 && r->land->ownership) {
|
if (turn >= 0 && r->land->ownership) {
|
||||||
r->land->ownership->morale_turn = turn;
|
r->land->ownership->morale_turn = turn;
|
||||||
}
|
}
|
||||||
assert(r->land->morale >= 0 && r->land->morale <= MORALE_MAX);
|
assert(r->land->morale <= MORALE_MAX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,10 +97,10 @@ extern "C" {
|
||||||
char *display;
|
char *display;
|
||||||
demand *demands;
|
demand *demands;
|
||||||
const struct item_type *herbtype;
|
const struct item_type *herbtype;
|
||||||
|
unsigned short herbs;
|
||||||
unsigned short peasants;
|
unsigned short peasants;
|
||||||
|
unsigned short morale;
|
||||||
short newpeasants;
|
short newpeasants;
|
||||||
int herbs;
|
|
||||||
int morale;
|
|
||||||
int trees[3]; /* 0 -> seeds, 1 -> shoots, 2 -> trees */
|
int trees[3]; /* 0 -> seeds, 1 -> shoots, 2 -> trees */
|
||||||
int horses;
|
int horses;
|
||||||
int money;
|
int money;
|
||||||
|
|
Loading…
Reference in New Issue