forked from github/server
commit
bce2afac12
6 changed files with 69 additions and 31 deletions
|
@ -214,6 +214,27 @@ param_t findparam(const char *s, const struct locale * lang)
|
|||
return result;
|
||||
}
|
||||
|
||||
param_t findparam_block(const char *s, const struct locale *lang, bool any_locale)
|
||||
{
|
||||
param_t p;
|
||||
if (!s || s[0] == '@') {
|
||||
return NOPARAM;
|
||||
}
|
||||
p = findparam(s, lang);
|
||||
if (any_locale && p==NOPARAM) {
|
||||
const struct locale *loc;
|
||||
for (loc=locales;loc;loc=nextlocale(loc)) {
|
||||
if (loc!=lang) {
|
||||
p = findparam(s, loc);
|
||||
if (p==P_FACTION || p==P_GAMENAME) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
param_t findparam_ex(const char *s, const struct locale * lang)
|
||||
{
|
||||
param_t result = findparam(s, lang);
|
||||
|
|
|
@ -45,6 +45,7 @@ extern "C" {
|
|||
int findoption(const char *s, const struct locale *lang);
|
||||
|
||||
param_t findparam(const char *s, const struct locale *lang);
|
||||
param_t findparam_block(const char *s, const struct locale *lang, bool any_locale);
|
||||
param_t findparam_ex(const char *s, const struct locale * lang);
|
||||
bool isparam(const char *s, const struct locale * lang, param_t param);
|
||||
param_t getparam(const struct locale *lang);
|
||||
|
|
|
@ -251,9 +251,33 @@ static void test_config_inifile(CuTest *tc) {
|
|||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_findparam(CuTest *tc) {
|
||||
struct locale *en, *de;
|
||||
test_setup();
|
||||
en = get_or_create_locale("en");
|
||||
locale_setstring(en, parameters[P_FACTION], "FACTION");
|
||||
CuAssertIntEquals(tc, NOPARAM, findparam("FACTION", en));
|
||||
init_parameters(en);
|
||||
CuAssertIntEquals(tc, P_FACTION, findparam("FACTION", en));
|
||||
de = get_or_create_locale("de");
|
||||
locale_setstring(de, parameters[P_FACTION], "PARTEI");
|
||||
CuAssertIntEquals(tc, NOPARAM, findparam("PARTEI", de));
|
||||
init_parameters(de);
|
||||
CuAssertIntEquals(tc, P_FACTION, findparam("PARTEI", de));
|
||||
CuAssertIntEquals(tc, NOPARAM, findparam("HODOR", de));
|
||||
|
||||
CuAssertIntEquals(tc, NOPARAM, findparam("PARTEI", en));
|
||||
CuAssertIntEquals(tc, NOPARAM, findparam_block("HODOR", de, false));
|
||||
CuAssertIntEquals(tc, P_FACTION, findparam_block("PARTEI", de, true));
|
||||
CuAssertIntEquals(tc, NOPARAM, findparam_block("PARTEI", en, false));
|
||||
CuAssertIntEquals(tc, P_FACTION, findparam_block("PARTEI", en, true));
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
CuSuite *get_config_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_findparam);
|
||||
SUITE_ADD_TEST(suite, test_config_inifile);
|
||||
SUITE_ADD_TEST(suite, test_config_cache);
|
||||
SUITE_ADD_TEST(suite, test_get_set_param);
|
||||
|
|
|
@ -252,26 +252,6 @@ static faction *factionorders(void)
|
|||
return f;
|
||||
}
|
||||
|
||||
static param_t next_param(const char *s, const struct locale *lang) {
|
||||
param_t p;
|
||||
if (!s || s[0] == '@') {
|
||||
return NOPARAM;
|
||||
}
|
||||
p = findparam(s, lang);
|
||||
if (p==NOPARAM) {
|
||||
const struct locale *loc;
|
||||
for (loc=locales;loc;loc=nextlocale(loc)) {
|
||||
if (loc!=lang) {
|
||||
p = findparam(s, lang);
|
||||
if (p==P_FACTION || p==P_GAMENAME) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
int readorders(const char *filename)
|
||||
{
|
||||
FILE *F = NULL;
|
||||
|
@ -299,7 +279,7 @@ int readorders(const char *filename)
|
|||
const char *s;
|
||||
init_tokens_str(b);
|
||||
s = gettoken(token, sizeof(token));
|
||||
p = next_param(s, lang);
|
||||
p = findparam_block(s, lang, true);
|
||||
switch (p) {
|
||||
case P_GAMENAME:
|
||||
case P_FACTION:
|
||||
|
|
|
@ -295,10 +295,11 @@ void init_translations(const struct locale *lang, int ut, const char * (*string_
|
|||
// TODO: swap the name of s and key
|
||||
const char * s = string_cb(i);
|
||||
if (s) {
|
||||
struct critbit_tree ** cb = (struct critbit_tree **)tokens;
|
||||
const char * key = locale_string(lang, s, false);
|
||||
if (!key) key = s;
|
||||
add_translation(cb, key, i);
|
||||
if (key) {
|
||||
struct critbit_tree ** cb = (struct critbit_tree **)tokens;
|
||||
add_translation(cb, key, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ static int nb_armor(const unit * u, int index)
|
|||
if (!(u_race(u)->battle_flags & BF_EQUIPMENT))
|
||||
return 0;
|
||||
|
||||
/* Normale Rüstung */
|
||||
/* Normale R<EFBFBD>stung */
|
||||
|
||||
for (itm = u->items; itm; itm = itm->next) {
|
||||
const armor_type *atype = itm->type->rtype->atype;
|
||||
|
@ -169,11 +169,11 @@ static region *rrandneighbour(region * r)
|
|||
for (i = 0; i != MAXDIRECTIONS; i++) {
|
||||
c++;
|
||||
}
|
||||
/* Zufällig eine auswählen */
|
||||
/* Zuf<EFBFBD>llig eine ausw<73>hlen */
|
||||
|
||||
rr = rng_int() % c;
|
||||
|
||||
/* Durchzählen */
|
||||
/* Durchz<EFBFBD>hlen */
|
||||
|
||||
c = -1;
|
||||
for (i = 0; i != MAXDIRECTIONS; i++) {
|
||||
|
@ -204,7 +204,7 @@ volcano_destruction(region * volcano, region * r, const char *damage)
|
|||
else {
|
||||
/* Produktion vierteln ... */
|
||||
a->data.sa[0] = (short)percent;
|
||||
/* Für 6-17 Runden */
|
||||
/* F<EFBFBD>r 6-17 Runden */
|
||||
a->data.sa[1] = (short)(a->data.sa[1] + time);
|
||||
}
|
||||
|
||||
|
@ -255,6 +255,14 @@ void volcano_outbreak(region * r, region *rn)
|
|||
}
|
||||
}
|
||||
|
||||
static bool stop_smoke_chance(void) {
|
||||
return rng_int() % 100 < 12;
|
||||
}
|
||||
|
||||
static bool outbreak_chance(void) {
|
||||
return rng_int() % 100 < 8;
|
||||
}
|
||||
|
||||
void volcano_update(void)
|
||||
{
|
||||
region *r;
|
||||
|
@ -270,13 +278,16 @@ void volcano_update(void)
|
|||
r->terrain = t_volcano;
|
||||
}
|
||||
else {
|
||||
if (rng_int() % 100 < 12) {
|
||||
if (stop_smoke_chance()) {
|
||||
ADDMSG(&r->msgs, msg_message("volcanostopsmoke", "region", r));
|
||||
r->terrain = t_volcano;
|
||||
}
|
||||
else if (r->uid == 1246051340 || (r->age > 20 && rng_int() % 100 < 8)) {
|
||||
else if (r->uid == 1246051340 || outbreak_chance()) {
|
||||
// HACK: a fixed E4-only region-uid in Code.
|
||||
// FIXME: In E4 gibt es eine Ebene #1246051340, die Smalland heisst.
|
||||
// da das kein aktiver Vulkan ist, ist dieser Test da nicht idiotisch?
|
||||
// das sollte bestimmt rn betreffen?
|
||||
region *rn;
|
||||
/* Zufällige Nachbarregion verwüsten */
|
||||
rn = rrandneighbour(r);
|
||||
volcano_outbreak(r, rn);
|
||||
r->terrain = t_volcano;
|
||||
|
|
Loading…
Reference in a new issue