forked from github/server
make migrants.formula a flag.
lookup in race.parameters was slow. there is only one formula, anyhow.
This commit is contained in:
parent
3b3e39a319
commit
bdb50eab75
|
@ -565,7 +565,7 @@ bool valid_race(const struct faction *f, const struct race *rc)
|
||||||
else {
|
else {
|
||||||
const char *str = get_param(f->race->parameters, "other_race");
|
const char *str = get_param(f->race->parameters, "other_race");
|
||||||
if (str)
|
if (str)
|
||||||
return (bool)(rc_find(str) == rc);
|
return rc_find(str) == rc;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,7 @@ static void test_max_migrants(CuTest *tc) {
|
||||||
f = test_create_faction(rc);
|
f = test_create_faction(rc);
|
||||||
u = test_create_unit(f, test_create_region(0, 0, 0));
|
u = test_create_unit(f, test_create_region(0, 0, 0));
|
||||||
CuAssertIntEquals(tc, 0, count_maxmigrants(f));
|
CuAssertIntEquals(tc, 0, count_maxmigrants(f));
|
||||||
set_param(&rc->parameters, "migrants.formula", "1");
|
rc->flags |= RCF_MIGRANTS;
|
||||||
CuAssertIntEquals(tc, 0, count_maxmigrants(f));
|
CuAssertIntEquals(tc, 0, count_maxmigrants(f));
|
||||||
scale_number(u, 250);
|
scale_number(u, 250);
|
||||||
CuAssertIntEquals(tc, 13, count_maxmigrants(f));
|
CuAssertIntEquals(tc, 13, count_maxmigrants(f));
|
||||||
|
|
|
@ -296,7 +296,7 @@ int rc_armor_bonus(const race *rc) {
|
||||||
|
|
||||||
int rc_migrants_formula(const race *rc)
|
int rc_migrants_formula(const race *rc)
|
||||||
{
|
{
|
||||||
return rc->parameters ? get_param_int(rc->parameters, "migrants.formula", MIGRANTS_NONE) : MIGRANTS_NONE;
|
return (rc->flags&RCF_MIGRANTS) ? MIGRANTS_LOG10 : MIGRANTS_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* rc_name(const race * rc, name_t n, char *name, size_t size) {
|
const char* rc_name(const race * rc, name_t n, char *name, size_t size) {
|
||||||
|
|
|
@ -223,6 +223,7 @@ extern "C" {
|
||||||
#define RCF_STONEGOLEM (1<<27) /* race gets stonegolem properties */
|
#define RCF_STONEGOLEM (1<<27) /* race gets stonegolem properties */
|
||||||
#define RCF_IRONGOLEM (1<<28) /* race gets irongolem properties */
|
#define RCF_IRONGOLEM (1<<28) /* race gets irongolem properties */
|
||||||
#define RCF_ATTACK_MOVED (1<<29) /* may attack if it has moved */
|
#define RCF_ATTACK_MOVED (1<<29) /* may attack if it has moved */
|
||||||
|
#define RCF_MIGRANTS (1<<30) /* may have migrant units (human bonus) */
|
||||||
|
|
||||||
/* Economic flags */
|
/* Economic flags */
|
||||||
#define ECF_KEEP_ITEM (1<<1) /* gibt Gegenst<73>nde weg */
|
#define ECF_KEEP_ITEM (1<<1) /* gibt Gegenst<73>nde weg */
|
||||||
|
|
|
@ -1737,6 +1737,11 @@ static int parse_races(xmlDocPtr doc)
|
||||||
if (strcmp((const char *)propName, "recruit_multi")==0) {
|
if (strcmp((const char *)propName, "recruit_multi")==0) {
|
||||||
rc->recruit_multi = atof((const char *)propValue);
|
rc->recruit_multi = atof((const char *)propValue);
|
||||||
}
|
}
|
||||||
|
else if (strcmp((const char *)propName, "migrants.formula") == 0) {
|
||||||
|
if (propValue[0] == '1') {
|
||||||
|
rc->flags |= RCF_MIGRANTS;
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
set_param(&rc->parameters, (const char *)propName, (const char *)propValue);
|
set_param(&rc->parameters, (const char *)propName, (const char *)propValue);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue