forked from github/server
fix curse-vigour calculation math.
also fix a ton of small other niggles from pvs-studio.
This commit is contained in:
parent
a8f3cad143
commit
ec4060cb9a
|
@ -765,7 +765,7 @@ bool missile)
|
||||||
skill += CavalryBonus(tu, enemy, BONUS_SKILL);
|
skill += CavalryBonus(tu, enemy, BONUS_SKILL);
|
||||||
if (wtype)
|
if (wtype)
|
||||||
skill =
|
skill =
|
||||||
skillmod(urace(tu)->attribs, tu, tu->region, wtype->skill, skill,
|
skillmod(u_race(tu)->attribs, tu, tu->region, wtype->skill, skill,
|
||||||
SMF_RIDING);
|
SMF_RIDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ static request *nextentertainer;
|
||||||
static int entertaining;
|
static int entertaining;
|
||||||
|
|
||||||
static unsigned int norders;
|
static unsigned int norders;
|
||||||
static request *oa;
|
static request *g_requests;
|
||||||
|
|
||||||
#define RECRUIT_MERGE 1
|
#define RECRUIT_MERGE 1
|
||||||
static int rules_recruit = -1;
|
static int rules_recruit = -1;
|
||||||
|
@ -154,21 +154,21 @@ static void expandorders(region * r, request * requests)
|
||||||
|
|
||||||
if (norders > 0) {
|
if (norders > 0) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
oa = (request *)calloc(norders, sizeof(request));
|
g_requests = (request *)calloc(norders, sizeof(request));
|
||||||
for (o = requests; o; o = o->next) {
|
for (o = requests; o; o = o->next) {
|
||||||
if (o->qty > 0) {
|
if (o->qty > 0) {
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
for (j = o->qty; j; j--) {
|
for (j = o->qty; j; j--) {
|
||||||
oa[i] = *o;
|
g_requests[i] = *o;
|
||||||
oa[i].unit->n = 0;
|
g_requests[i].unit->n = 0;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scramble(oa, norders, sizeof(request));
|
scramble(g_requests, norders, sizeof(request));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
oa = NULL;
|
g_requests = NULL;
|
||||||
}
|
}
|
||||||
while (requests) {
|
while (requests) {
|
||||||
request *o = requests->next;
|
request *o = requests->next;
|
||||||
|
@ -1458,16 +1458,16 @@ static void expandbuying(region * r, request * buyorders)
|
||||||
|
|
||||||
for (j = 0; j != norders; j++) {
|
for (j = 0; j != norders; j++) {
|
||||||
int price, multi;
|
int price, multi;
|
||||||
ltype = oa[j].type.ltype;
|
ltype = g_requests[j].type.ltype;
|
||||||
trade = trades;
|
trade = trades;
|
||||||
while (trade->type != ltype)
|
while (trade->type != ltype)
|
||||||
++trade;
|
++trade;
|
||||||
multi = trade->multi;
|
multi = trade->multi;
|
||||||
price = ltype->price * multi;
|
price = ltype->price * multi;
|
||||||
|
|
||||||
if (get_pooled(oa[j].unit, rsilver, GET_DEFAULT,
|
if (get_pooled(g_requests[j].unit, rsilver, GET_DEFAULT,
|
||||||
price) >= price) {
|
price) >= price) {
|
||||||
unit *u = oa[j].unit;
|
unit *u = g_requests[j].unit;
|
||||||
item *items;
|
item *items;
|
||||||
|
|
||||||
/* litems zählt die Güter, die verkauft wurden, u->n das Geld, das
|
/* litems zählt die Güter, die verkauft wurden, u->n das Geld, das
|
||||||
|
@ -1481,7 +1481,7 @@ static void expandbuying(region * r, request * buyorders)
|
||||||
items = a->data.v;
|
items = a->data.v;
|
||||||
i_change(&items, ltype->itype, 1);
|
i_change(&items, ltype->itype, 1);
|
||||||
a->data.v = items;
|
a->data.v = items;
|
||||||
i_change(&oa[j].unit->items, ltype->itype, 1);
|
i_change(&g_requests[j].unit->items, ltype->itype, 1);
|
||||||
use_pooled(u, rsilver, GET_DEFAULT, price);
|
use_pooled(u, rsilver, GET_DEFAULT, price);
|
||||||
if (u->n < 0)
|
if (u->n < 0)
|
||||||
u->n = 0;
|
u->n = 0;
|
||||||
|
@ -1499,7 +1499,7 @@ static void expandbuying(region * r, request * buyorders)
|
||||||
fset(u, UFL_LONGACTION | UFL_NOTMOVING);
|
fset(u, UFL_LONGACTION | UFL_NOTMOVING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(oa);
|
free(g_requests);
|
||||||
|
|
||||||
/* Ausgabe an Einheiten */
|
/* Ausgabe an Einheiten */
|
||||||
|
|
||||||
|
@ -1736,7 +1736,7 @@ static void expandselling(region * r, request * sellorders, int limit)
|
||||||
|
|
||||||
for (j = 0; j != norders; j++) {
|
for (j = 0; j != norders; j++) {
|
||||||
const luxury_type *search = NULL;
|
const luxury_type *search = NULL;
|
||||||
const luxury_type *ltype = oa[j].type.ltype;
|
const luxury_type *ltype = g_requests[j].type.ltype;
|
||||||
int multi = r_demand(r, ltype);
|
int multi = r_demand(r, ltype);
|
||||||
int i;
|
int i;
|
||||||
int use = 0;
|
int use = 0;
|
||||||
|
@ -1753,7 +1753,7 @@ static void expandselling(region * r, request * sellorders, int limit)
|
||||||
if (money >= price) {
|
if (money >= price) {
|
||||||
int abgezogenhafen = 0;
|
int abgezogenhafen = 0;
|
||||||
int abgezogensteuer = 0;
|
int abgezogensteuer = 0;
|
||||||
unit *u = oa[j].unit;
|
unit *u = g_requests[j].unit;
|
||||||
item *itm;
|
item *itm;
|
||||||
attrib *a = a_find(u->attribs, &at_luxuries);
|
attrib *a = a_find(u->attribs, &at_luxuries);
|
||||||
if (a == NULL)
|
if (a == NULL)
|
||||||
|
@ -1801,10 +1801,10 @@ static void expandselling(region * r, request * sellorders, int limit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (use > 0) {
|
if (use > 0) {
|
||||||
use_pooled(oa[j].unit, ltype->itype->rtype, GET_DEFAULT, use);
|
use_pooled(g_requests[j].unit, ltype->itype->rtype, GET_DEFAULT, use);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(oa);
|
free(g_requests);
|
||||||
|
|
||||||
/* Steuern. Hier werden die Steuern dem Besitzer der größten Burg gegeben. */
|
/* Steuern. Hier werden die Steuern dem Besitzer der größten Burg gegeben. */
|
||||||
if (maxowner) {
|
if (maxowner) {
|
||||||
|
@ -1928,7 +1928,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
|
||||||
s = gettoken(token, sizeof(token));
|
s = gettoken(token, sizeof(token));
|
||||||
itype = s ? finditemtype(s, u->faction->locale) : 0;
|
itype = s ? finditemtype(s, u->faction->locale) : 0;
|
||||||
ltype = itype ? resource2luxury(itype->rtype) : 0;
|
ltype = itype ? resource2luxury(itype->rtype) : 0;
|
||||||
if (ltype == NULL) {
|
if (ltype == NULL || itype == NULL) {
|
||||||
cmistake(u, ord, 126, MSG_COMMERCE);
|
cmistake(u, ord, 126, MSG_COMMERCE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2010,8 +2010,8 @@ static void expandstealing(region * r, request * stealorders)
|
||||||
* u ist die beklaute unit. oa.unit ist die klauende unit.
|
* u ist die beklaute unit. oa.unit ist die klauende unit.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (j = 0; j != norders && oa[j].unit->n <= oa[j].unit->wants; j++) {
|
for (j = 0; j != norders && g_requests[j].unit->n <= g_requests[j].unit->wants; j++) {
|
||||||
unit *u = findunitg(oa[j].no, r);
|
unit *u = findunitg(g_requests[j].no, r);
|
||||||
int n = 0;
|
int n = 0;
|
||||||
if (u && u->region == r) {
|
if (u && u->region == r) {
|
||||||
n = get_pooled(u, rsilver, GET_ALL, INT_MAX);
|
n = get_pooled(u, rsilver, GET_ALL, INT_MAX);
|
||||||
|
@ -2035,17 +2035,17 @@ static void expandstealing(region * r, request * stealorders)
|
||||||
n = 10;
|
n = 10;
|
||||||
}
|
}
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
n = _min(n, oa[j].unit->wants);
|
n = _min(n, g_requests[j].unit->wants);
|
||||||
use_pooled(u, rsilver, GET_ALL, n);
|
use_pooled(u, rsilver, GET_ALL, n);
|
||||||
oa[j].unit->n = n;
|
g_requests[j].unit->n = n;
|
||||||
change_money(oa[j].unit, n);
|
change_money(g_requests[j].unit, n);
|
||||||
ADDMSG(&u->faction->msgs, msg_message("stealeffect", "unit region amount",
|
ADDMSG(&u->faction->msgs, msg_message("stealeffect", "unit region amount",
|
||||||
u, u->region, n));
|
u, u->region, n));
|
||||||
}
|
}
|
||||||
add_income(oa[j].unit, IC_STEAL, oa[j].unit->wants, oa[j].unit->n);
|
add_income(g_requests[j].unit, IC_STEAL, g_requests[j].unit->wants, g_requests[j].unit->n);
|
||||||
fset(oa[j].unit, UFL_LONGACTION | UFL_NOTMOVING);
|
fset(g_requests[j].unit, UFL_LONGACTION | UFL_NOTMOVING);
|
||||||
}
|
}
|
||||||
free(oa);
|
free(g_requests);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
@ -2060,14 +2060,14 @@ static void plant(unit * u, int raw)
|
||||||
if (!fval(r->terrain, LAND_REGION)) {
|
if (!fval(r->terrain, LAND_REGION)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (rherbtype(r) == NULL) {
|
itype = rherbtype(r);
|
||||||
|
if (itype == NULL) {
|
||||||
cmistake(u, u->thisorder, 108, MSG_PRODUCE);
|
cmistake(u, u->thisorder, 108, MSG_PRODUCE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Skill prüfen */
|
/* Skill prüfen */
|
||||||
skill = effskill(u, SK_HERBALISM, 0);
|
skill = effskill(u, SK_HERBALISM, 0);
|
||||||
itype = rherbtype(r);
|
|
||||||
if (skill < 6) {
|
if (skill < 6) {
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_feedback(u, u->thisorder, "plant_skills",
|
msg_feedback(u, u->thisorder, "plant_skills",
|
||||||
|
@ -2702,13 +2702,13 @@ static void expandloot(region * r, request * lootorders)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i != norders && startmoney > looted + TAXFRACTION * 2; i++) {
|
for (i = 0; i != norders && startmoney > looted + TAXFRACTION * 2; i++) {
|
||||||
change_money(oa[i].unit, TAXFRACTION);
|
change_money(g_requests[i].unit, TAXFRACTION);
|
||||||
oa[i].unit->n += TAXFRACTION;
|
g_requests[i].unit->n += TAXFRACTION;
|
||||||
/*Looting destroys double the money*/
|
/*Looting destroys double the money*/
|
||||||
looted += TAXFRACTION * 2;
|
looted += TAXFRACTION * 2;
|
||||||
}
|
}
|
||||||
rsetmoney(r, startmoney - looted);
|
rsetmoney(r, startmoney - looted);
|
||||||
free(oa);
|
free(g_requests);
|
||||||
|
|
||||||
/* Lowering morale by 1 depending on the looted money (+20%) */
|
/* Lowering morale by 1 depending on the looted money (+20%) */
|
||||||
if (rng_int() % 100 < 20 + (looted * 80) / startmoney) {
|
if (rng_int() % 100 < 20 + (looted * 80) / startmoney) {
|
||||||
|
@ -2737,11 +2737,11 @@ void expandtax(region * r, request * taxorders)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i != norders && rmoney(r) > TAXFRACTION; i++) {
|
for (i = 0; i != norders && rmoney(r) > TAXFRACTION; i++) {
|
||||||
change_money(oa[i].unit, TAXFRACTION);
|
change_money(g_requests[i].unit, TAXFRACTION);
|
||||||
oa[i].unit->n += TAXFRACTION;
|
g_requests[i].unit->n += TAXFRACTION;
|
||||||
rsetmoney(r, rmoney(r) - TAXFRACTION);
|
rsetmoney(r, rmoney(r) - TAXFRACTION);
|
||||||
}
|
}
|
||||||
free(oa);
|
free(g_requests);
|
||||||
|
|
||||||
for (u = r->units; u; u = u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
if (u->n >= 0) {
|
if (u->n >= 0) {
|
||||||
|
@ -2939,9 +2939,10 @@ static void peasant_taxes(region * r)
|
||||||
maxsize = buildingeffsize(b, false);
|
maxsize = buildingeffsize(b, false);
|
||||||
if (maxsize > 0) {
|
if (maxsize > 0) {
|
||||||
double taxfactor = money * b->type->taxes(b, maxsize);
|
double taxfactor = money * b->type->taxes(b, maxsize);
|
||||||
double morale = money * region_get_morale(r) * MORALE_TAX_FACTOR;
|
double morale = MORALE_TAX_FACTOR * money * region_get_morale(r);
|
||||||
if (taxfactor > morale)
|
if (taxfactor > morale) {
|
||||||
taxfactor = morale;
|
taxfactor = morale;
|
||||||
|
}
|
||||||
if (taxfactor > 0) {
|
if (taxfactor > 0) {
|
||||||
int taxmoney = (int)taxfactor;
|
int taxmoney = (int)taxfactor;
|
||||||
change_money(u, taxmoney);
|
change_money(u, taxmoney);
|
||||||
|
|
|
@ -137,7 +137,7 @@ int give_quota(const unit * src, const unit * dst, const item_type * type,
|
||||||
}
|
}
|
||||||
if (dst && src && src->faction != dst->faction) {
|
if (dst && src && src->faction != dst->faction) {
|
||||||
divisor = config_get_flt("rules.items.give_divisor", 1);
|
divisor = config_get_flt("rules.items.give_divisor", 1);
|
||||||
assert(divisor == 0 || divisor >= 1);
|
assert(divisor <= 0 || divisor >= 1);
|
||||||
if (divisor >= 1) {
|
if (divisor >= 1) {
|
||||||
/* predictable > correct: */
|
/* predictable > correct: */
|
||||||
int x = (int)(n / divisor);
|
int x = (int)(n / divisor);
|
||||||
|
@ -781,7 +781,7 @@ void give_cmd(unit * u, order * ord)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (u2 != NULL) {
|
if (u2 != NULL) {
|
||||||
if ((u_race(u)->ec_flags & ECF_KEEP_ITEM) && u2 != NULL) {
|
if ((u_race(u)->ec_flags & ECF_KEEP_ITEM)) {
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
|
msg_feedback(u, ord, "race_nogive", "race", u_race(u)));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -114,10 +114,9 @@ struct order *ord)
|
||||||
const resource_type *rt_crystal = NULL;
|
const resource_type *rt_crystal = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (rt_crystal == NULL) {
|
|
||||||
rt_crystal = rt_find("antimagic");
|
rt_crystal = rt_find("antimagic");
|
||||||
assert(rt_crystal != NULL);
|
assert(rt_crystal != NULL);
|
||||||
}
|
|
||||||
for (i = 0; i != amount; ++i) {
|
for (i = 0; i != amount; ++i) {
|
||||||
int effect, duration = 2;
|
int effect, duration = 2;
|
||||||
double force;
|
double force;
|
||||||
|
|
|
@ -405,8 +405,8 @@ static void test_buildingtype_exists(CuTest * tc)
|
||||||
|
|
||||||
r = findregion(-1, 0);
|
r = findregion(-1, 0);
|
||||||
b = new_building(btype, r, default_locale);
|
b = new_building(btype, r, default_locale);
|
||||||
b->size = 10;
|
|
||||||
CuAssertPtrNotNull(tc, b);
|
CuAssertPtrNotNull(tc, b);
|
||||||
|
b->size = 10;
|
||||||
|
|
||||||
CuAssertTrue(tc, !buildingtype_exists(r, NULL, false));
|
CuAssertTrue(tc, !buildingtype_exists(r, NULL, false));
|
||||||
CuAssertTrue(tc, !buildingtype_exists(r, btype2, false));
|
CuAssertTrue(tc, !buildingtype_exists(r, btype2, false));
|
||||||
|
|
|
@ -741,10 +741,15 @@ int cmp_current_owner(const building * b, const building * a)
|
||||||
int oldsize = buildingeffsize(a, false);
|
int oldsize = buildingeffsize(a, false);
|
||||||
double oldtaxes = a->type->taxes(a, oldsize);
|
double oldtaxes = a->type->taxes(a, oldsize);
|
||||||
|
|
||||||
if (newtaxes != oldtaxes)
|
if (newtaxes > oldtaxes) {
|
||||||
return (newtaxes > oldtaxes) ? 1 : -1;
|
return 1;
|
||||||
if (newsize != oldsize)
|
}
|
||||||
|
if (newtaxes < oldtaxes) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (newsize != oldsize) {
|
||||||
return newsize - oldsize;
|
return newsize - oldsize;
|
||||||
|
}
|
||||||
return (b->size - a->size);
|
return (b->size - a->size);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -944,7 +949,7 @@ int entertainmoney(const region * r)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = rmoney(r) / ENTERTAINFRACTION;
|
n = rmoney(r) / (double)ENTERTAINFRACTION;
|
||||||
|
|
||||||
if (is_cursed(r->attribs, C_GENEROUS, 0)) {
|
if (is_cursed(r->attribs, C_GENEROUS, 0)) {
|
||||||
n *= get_curseeffect(r->attribs, C_GENEROUS, 0);
|
n *= get_curseeffect(r->attribs, C_GENEROUS, 0);
|
||||||
|
|
|
@ -825,7 +825,7 @@ double destr_curse(curse * c, int cast_level, double force)
|
||||||
c->type->change_vigour(c, -(cast_level + 1) / 2);
|
c->type->change_vigour(c, -(cast_level + 1) / 2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
c->vigour -= cast_level + 1 / 2;
|
c->vigour -= (cast_level + 1) / 2.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -827,7 +827,7 @@ int writepasswd(void)
|
||||||
log_info("writing passwords...");
|
log_info("writing passwords...");
|
||||||
|
|
||||||
for (f = factions; f; f = f->next) {
|
for (f = factions; f; f = f->next) {
|
||||||
fprintf(F, "%s:%s:%s:%u\n",
|
fprintf(F, "%s:%s:%s:%d\n",
|
||||||
itoa36(f->no), f->email, f->_password, f->subscription);
|
itoa36(f->no), f->email, f->_password, f->subscription);
|
||||||
}
|
}
|
||||||
fclose(F);
|
fclose(F);
|
||||||
|
|
|
@ -973,7 +973,7 @@ void init_resources(void)
|
||||||
{
|
{
|
||||||
resource_type *rtype;
|
resource_type *rtype;
|
||||||
|
|
||||||
rtype = rt_get_or_create(resourcenames[R_PERSON]); // lousy hack
|
rt_get_or_create(resourcenames[R_PERSON]); // lousy hack
|
||||||
|
|
||||||
rtype = rt_get_or_create(resourcenames[R_PEASANT]);
|
rtype = rt_get_or_create(resourcenames[R_PEASANT]);
|
||||||
rtype->uchange = res_changepeasants;
|
rtype->uchange = res_changepeasants;
|
||||||
|
@ -1204,7 +1204,7 @@ void read_items(struct storage *store, item ** ilist)
|
||||||
itype = it_find(ibuf);
|
itype = it_find(ibuf);
|
||||||
READ_INT(store, &i);
|
READ_INT(store, &i);
|
||||||
if (i <= 0) {
|
if (i <= 0) {
|
||||||
log_error("data contains an entry with %d %s", i, resourcename(itype->rtype, NMF_PLURAL));
|
log_error("data contains an entry with %d %s", i, ibuf);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (itype && itype->rtype) {
|
if (itype && itype->rtype) {
|
||||||
|
|
|
@ -179,7 +179,7 @@ int count)
|
||||||
if (u != v && (v->items || rtype->uget)) {
|
if (u != v && (v->items || rtype->uget)) {
|
||||||
int mask;
|
int mask;
|
||||||
|
|
||||||
if ((urace(v)->ec_flags & ECF_KEEP_ITEM))
|
if ((u_race(v)->ec_flags & ECF_KEEP_ITEM))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (v->faction == f) {
|
if (v->faction == f) {
|
||||||
|
@ -232,7 +232,7 @@ use_pooled(unit * u, const resource_type * rtype, unsigned int mode, int count)
|
||||||
for (v = r->units; use > 0 && v != NULL; v = v->next) {
|
for (v = r->units; use > 0 && v != NULL; v = v->next) {
|
||||||
if (u != v) {
|
if (u != v) {
|
||||||
int mask;
|
int mask;
|
||||||
if ((urace(v)->ec_flags & ECF_KEEP_ITEM))
|
if ((u_race(v)->ec_flags & ECF_KEEP_ITEM))
|
||||||
continue;
|
continue;
|
||||||
if (v->items == NULL && rtype->uget == NULL)
|
if (v->items == NULL && rtype->uget == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -46,7 +46,7 @@ extern int dice_rand(const char *s);
|
||||||
|
|
||||||
static void update_resource(struct rawmaterial *res, double modifier)
|
static void update_resource(struct rawmaterial *res, double modifier)
|
||||||
{
|
{
|
||||||
double amount = 1 + (res->level - res->startlevel) * res->divisor / 100.0;
|
double amount = (res->level - res->startlevel) / 100.0 * res->divisor + 1;
|
||||||
amount = ResourceFactor() * res->base * amount * modifier;
|
amount = ResourceFactor() * res->base * amount * modifier;
|
||||||
if (amount < 1.0)
|
if (amount < 1.0)
|
||||||
res->amount = 1;
|
res->amount = 1;
|
||||||
|
|
|
@ -917,11 +917,6 @@ bool leave(unit * u, bool force)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct race *urace(const struct unit *u)
|
|
||||||
{
|
|
||||||
return u->_race;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool can_survive(const unit * u, const region * r)
|
bool can_survive(const unit * u, const region * r)
|
||||||
{
|
{
|
||||||
if ((fval(r->terrain, WALK_INTO) && (u_race(u)->flags & RCF_WALK))
|
if ((fval(r->terrain, WALK_INTO) && (u_race(u)->flags & RCF_WALK))
|
||||||
|
|
|
@ -141,8 +141,6 @@ extern "C" {
|
||||||
struct unit *utarget(const struct unit *u);
|
struct unit *utarget(const struct unit *u);
|
||||||
void usettarget(struct unit *u, const struct unit *b);
|
void usettarget(struct unit *u, const struct unit *b);
|
||||||
|
|
||||||
extern const struct race *urace(const struct unit *u);
|
|
||||||
|
|
||||||
const char *uprivate(const struct unit *u);
|
const char *uprivate(const struct unit *u);
|
||||||
void usetprivate(struct unit *u, const char *c);
|
void usetprivate(struct unit *u, const char *c);
|
||||||
|
|
||||||
|
|
|
@ -648,7 +648,7 @@ growing_trees(region * r, const int current_season, const int last_weeks_season)
|
||||||
* verfügbaren Fläche ab. In Gletschern gibt es weniger
|
* verfügbaren Fläche ab. In Gletschern gibt es weniger
|
||||||
* Möglichkeiten als in Ebenen. */
|
* Möglichkeiten als in Ebenen. */
|
||||||
sprout = 0;
|
sprout = 0;
|
||||||
seedchance = (1000 * region_maxworkers(r2)) / r2->terrain->size;
|
seedchance = (1000 * region_maxworkers(r2)) / (double)r2->terrain->size;
|
||||||
for (i = 0; i < seeds / MAXDIRECTIONS; i++) {
|
for (i = 0; i < seeds / MAXDIRECTIONS; i++) {
|
||||||
if (rng_int() % 10000 < seedchance)
|
if (rng_int() % 10000 < seedchance)
|
||||||
sprout++;
|
sprout++;
|
||||||
|
@ -3636,7 +3636,7 @@ int pay_cmd(unit * u, struct order *ord)
|
||||||
static int reserve_i(unit * u, struct order *ord, int flags)
|
static int reserve_i(unit * u, struct order *ord, int flags)
|
||||||
{
|
{
|
||||||
char token[128];
|
char token[128];
|
||||||
if (u->number > 0 && (urace(u)->ec_flags & GETITEM)) {
|
if (u->number > 0 && (u_race(u)->ec_flags & GETITEM)) {
|
||||||
int use, count, para;
|
int use, count, para;
|
||||||
const item_type *itype;
|
const item_type *itype;
|
||||||
const char *s;
|
const char *s;
|
||||||
|
@ -3945,7 +3945,7 @@ int armedmen(const unit * u, bool siege_weapons)
|
||||||
{
|
{
|
||||||
item *itm;
|
item *itm;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
if (!(urace(u)->flags & RCF_NOWEAPONS)) {
|
if (!(u_race(u)->flags & RCF_NOWEAPONS)) {
|
||||||
if (effskill(u, SK_WEAPONLESS, 0) >= 1) {
|
if (effskill(u, SK_WEAPONLESS, 0) >= 1) {
|
||||||
/* kann ohne waffen bewachen: fuer drachen */
|
/* kann ohne waffen bewachen: fuer drachen */
|
||||||
n = u->number;
|
n = u->number;
|
||||||
|
|
|
@ -76,17 +76,13 @@ bool monster_is_waiting(const unit * u)
|
||||||
static void eaten_by_monster(unit * u)
|
static void eaten_by_monster(unit * u)
|
||||||
{
|
{
|
||||||
/* adjustment for smaller worlds */
|
/* adjustment for smaller worlds */
|
||||||
static double multi = 0.0;
|
double multi = RESOURCE_QUANTITY * newterrain(T_PLAIN)->size / 10000.0;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int horse = -1;
|
int horse = -1;
|
||||||
const resource_type *rhorse = get_resourcetype(R_HORSE);
|
const resource_type *rhorse = get_resourcetype(R_HORSE);
|
||||||
const race *rc = u_race(u);
|
const race *rc = u_race(u);
|
||||||
attrib *a;
|
attrib *a;
|
||||||
|
|
||||||
if (multi == 0.0) {
|
|
||||||
multi = RESOURCE_QUANTITY * newterrain(T_PLAIN)->size / 10000.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
a = a_find(rc->attribs, &at_scare);
|
a = a_find(rc->attribs, &at_scare);
|
||||||
if (a) {
|
if (a) {
|
||||||
n = rng_int() & a->data.i * u->number;
|
n = rng_int() & a->data.i * u->number;
|
||||||
|
|
|
@ -695,7 +695,7 @@ static order *plan_dragon(unit * u)
|
||||||
int attempts = 0;
|
int attempts = 0;
|
||||||
skill_t sk = SK_PERCEPTION;
|
skill_t sk = SK_PERCEPTION;
|
||||||
/* study perception (or a random useful skill) */
|
/* study perception (or a random useful skill) */
|
||||||
while ((!skill_enabled(sk) || (attempts < MAXSKILLS && u_race(u)->bonus[sk] < (++attempts < 10?1:-5 )))) {
|
while (!skill_enabled(sk) || (attempts < MAXSKILLS && u_race(u)->bonus[sk] < (++attempts < 10?1:-5 ))) {
|
||||||
sk = (skill_t)(rng_int() % MAXSKILLS);
|
sk = (skill_t)(rng_int() % MAXSKILLS);
|
||||||
}
|
}
|
||||||
long_order = create_order(K_STUDY, u->faction->locale, "'%s'",
|
long_order = create_order(K_STUDY, u->faction->locale, "'%s'",
|
||||||
|
|
|
@ -1730,7 +1730,7 @@ static void rpline(struct stream *out)
|
||||||
memset(line, '-', sizeof(line));
|
memset(line, '-', sizeof(line));
|
||||||
line[REPORTWIDTH] = '\n';
|
line[REPORTWIDTH] = '\n';
|
||||||
}
|
}
|
||||||
swrite(line, sizeof(char), sizeof(line), out);
|
swrite(line, sizeof(line), 1, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void list_address(struct stream *out, const faction * uf, quicklist * seenfactions)
|
static void list_address(struct stream *out, const faction * uf, quicklist * seenfactions)
|
||||||
|
|
|
@ -220,7 +220,7 @@ void report_summary(summary * s, summary * o, bool full)
|
||||||
fprintf(F, " Helden: %s\n", pcomp(s->heroes, o->heroes));
|
fprintf(F, " Helden: %s\n", pcomp(s->heroes, o->heroes));
|
||||||
|
|
||||||
if (full) {
|
if (full) {
|
||||||
fprintf(F, "Regionen: %d\n", listlen(regions));
|
fprintf(F, "Regionen: %d\n", (int)listlen(regions));
|
||||||
fprintf(F, "Bewohnte Regionen: %d\n", s->inhabitedregions);
|
fprintf(F, "Bewohnte Regionen: %d\n", s->inhabitedregions);
|
||||||
fprintf(F, "Landregionen: %d\n", s->landregionen);
|
fprintf(F, "Landregionen: %d\n", s->landregionen);
|
||||||
fprintf(F, "Spielerregionen: %d\n", s->regionen_mit_spielern);
|
fprintf(F, "Spielerregionen: %d\n", s->regionen_mit_spielern);
|
||||||
|
|
|
@ -29,7 +29,7 @@ static void test_unicode_trim(CuTest * tc)
|
||||||
CuAssertIntEquals(tc, 3, unicode_utf8_trim(buffer));
|
CuAssertIntEquals(tc, 3, unicode_utf8_trim(buffer));
|
||||||
CuAssertStrEquals(tc, "Hello Word", buffer);
|
CuAssertStrEquals(tc, "Hello Word", buffer);
|
||||||
|
|
||||||
buffer[9] = (char)0xc3;
|
buffer[9] = -61;
|
||||||
CuAssertIntEquals(tc, 1, unicode_utf8_trim(buffer));
|
CuAssertIntEquals(tc, 1, unicode_utf8_trim(buffer));
|
||||||
CuAssertStrEquals(tc, "Hello Wor?", buffer);
|
CuAssertStrEquals(tc, "Hello Wor?", buffer);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue