Merge pull request #567 from ennorehling/develop

Bug 2235: new players getting NMR warnings
This commit is contained in:
Enno Rehling 2016-09-11 16:48:47 +02:00 committed by GitHub
commit 03a8e0449a
15 changed files with 51 additions and 102 deletions

View File

@ -57,7 +57,7 @@
<text locale="de">eressea-server@eressea.de</text>
<text locale="en">eressea-server@eressea.de</text>
</string>
<string name="newbie_info_1">
<string name="newbie_info_game">
<text locale="de">Bitte denke daran, deine Befehle mit dem Betreff
ERESSEA 2 BEFEHLE an eressea-server@eressea.de zu senden.</text>
<text locale="en">Remember to send your orders to

View File

@ -49,7 +49,7 @@
<text locale="de">eressea-server@eressea.de</text>
<text locale="en">eressea-server@eressea.de</text>
</string>
<string name="newbie_info_1">
<string name="newbie_info_game">
<text locale="de">Bitte denke daran, deine Befehle mit dem Betreff
ERESSEA 3 BEFEHLE an eressea-server@eressea.de zu senden.</text>
<text locale="en">Remember to send your orders to

View File

@ -50,7 +50,7 @@
<text locale="de">eressea-server@eressea.de</text>
<text locale="en">eressea-server@eressea.de</text>
</string>
<string name="newbie_info_1">
<string name="newbie_info_game">
<text locale="de">Bitte denke daran, deine Befehle mit dem Betreff
ERESSEA 4 BEFEHLE an eressea-server@eressea.de zu senden.</text>
<text locale="en">Remember to send your orders to

View File

@ -268,13 +268,7 @@
<text locale="de">Muscheln</text>
<text locale="en">seashells</text>
</string>
<string name="newbie_info_2">
<text locale="de">Die ersten beiden Züge mußt du abgeben, sonst wird deine
Partei sofort wieder gelöscht, um Karteileichen zu vermeiden.</text>
<text locale="en">If you fail to send in orders for one of the first two turns, your faction will be erased from the game to reduce the number of inactive players in Eressea.</text>
</string>
<string name="newbie_info_3">
<string name="newbie_info_cr">
<text locale="de">Mit der ersten Auswertung bekommst du einen
Computerreport, den du mit vielen Tools wie z.B. Magellan benutzen kannst. Wenn du ihn
weiterhin bekommen willst, gib einer deiner Einheiten den Befehl OPTION

View File

@ -17,7 +17,7 @@ function setup()
end
function test_faction_flags()
assert_equal(0, f.flags)
assert_equal(2, f.flags) -- FFL_ISNEW
f.flags = 42
assert_equal(42, f.flags)
end

View File

@ -88,7 +88,6 @@ static FILE *bdebug;
#define TDIFF_CHANGE 5 /* 5% höher pro Stufe */
#define DAMAGE_QUOTIENT 2 /* damage += skilldiff/DAMAGE_QUOTIENT */
#undef DEBUG_FAST /* should be disabled when b->fast and b->rowcache works */
#define DEBUG_SELECT /* should be disabled if select_enemy works */
typedef enum combatmagic {
@ -205,12 +204,7 @@ static const char *sideabkz(side * s, bool truename)
const faction *f = (s->stealthfaction
&& !truename) ? s->stealthfaction : s->faction;
#undef SIDE_ABKZ
#ifdef SIDE_ABKZ
abkz(f->name, sideabkz_buf, sizeof(sideabkz_buf), 3);
#else
strlcpy(sideabkz_buf, itoa36(f->no), sizeof(sideabkz_buf));
#endif
return sideabkz_buf;
}
@ -471,13 +465,7 @@ static int get_unitrow(const fighter * af, const side * vs)
b->rowcache.result = get_row(af->side, row, vs);
return b->rowcache.result;
}
#ifdef DEBUG_FAST /* validation code */
{
int i = get_row(af->side, row, vs);
assert(i == b->rowcache.result);
}
#endif
return b->rowcache.result;
return b->rowcache.result;
}
}
@ -1445,18 +1433,10 @@ int select)
if (b->alive == b->fast.alive && as == b->fast.side && sr == b->fast.status
&& minrow == b->fast.minrow && maxrow == b->fast.maxrow) {
if (b->fast.enemies[select] >= 0) {
#ifdef DEBUG_FAST
int i = count_enemies_i(b, af, minrow, maxrow, select);
assert(i == b->fast.enemies[select]);
#endif
return b->fast.enemies[select];
}
else if (select & SELECT_FIND) {
if (b->fast.enemies[select - SELECT_FIND] >= 0) {
#ifdef DEBUG_FAST
int i = count_enemies_i(b, af, minrow, maxrow, select);
assert((i > 0) == (b->fast.enemies[select - SELECT_FIND] > 0));
#endif
return b->fast.enemies[select - SELECT_FIND];
}
}

View File

@ -233,15 +233,7 @@ void tolua_ship_open(lua_State * L)
tolua_variable(L, TOLUA_CAST "type", tolua_ship_get_type, 0);
tolua_variable(L, TOLUA_CAST "damage", tolua_ship_get_damage,
tolua_ship_set_damage);
#ifdef TODO
.property("weight", &ship_getweight)
.property("capacity", &ship_getcapacity)
.property("maxsize", &ship_maxsize)
.def_readwrite("damage", &ship::damage)
.def_readwrite("size", &ship::size)
#endif
tolua_variable(L, TOLUA_CAST "objects", tolua_ship_get_objects, 0);
tolua_variable(L, TOLUA_CAST "objects", tolua_ship_get_objects, 0);
tolua_function(L, TOLUA_CAST "create", tolua_ship_create);
}

View File

@ -767,25 +767,6 @@ static int tolua_unit_get_spells(lua_State * L)
return tolua_quicklist_push(L, "spellbook", "spell_entry", slist);
}
#ifdef TODO /* spellbooks */
static void unit_removespell(unit * u, spell * sp)
{
quicklist **isptr;
isptr = get_spelllist(get_mage(u), u->faction);
ql_set_remove(isptr, sp);
}
static int tolua_unit_removespell(lua_State * L)
{
unit *self = (unit *) tolua_tousertype(L, 1, 0);
spell *sp = (spell *) tolua_tousertype(L, 2, 0);
unit_removespell(self, sp);
return 0;
}
#endif
static int tolua_unit_get_orders(lua_State * L)
{
unit *self = (unit *)tolua_tousertype(L, 1, 0);
@ -1019,9 +1000,6 @@ void tolua_unit_open(lua_State * L)
tolua_variable(L, TOLUA_CAST "race_name", &tolua_unit_get_racename,
&tolua_unit_set_racename);
tolua_function(L, TOLUA_CAST "add_spell", &tolua_unit_addspell);
#ifdef TODO /* spellbooks */
tolua_function(L, TOLUA_CAST "remove_spell", &tolua_unit_removespell);
#endif
tolua_variable(L, TOLUA_CAST "spells", &tolua_unit_get_spells, 0);
tolua_function(L, TOLUA_CAST "cast_spell", &tolua_unit_castspell);

View File

@ -867,21 +867,29 @@ bool rule_stealth_other(void)
bool rule_stealth_anon(void)
{
int rule = config_get_int("stealth.faction.anon", 1);
static int rule, config;
if (config_changed(&config)) {
rule = config_get_int("stealth.faction.anon", 1);
}
return rule != 0;
}
bool rule_region_owners(void)
{
int rule = config_get_int("rules.region_owners", 0);
static int rule, config;
if (config_changed(&config)) {
rule = config_get_int("rules.region_owners", 0);
}
return rule != 0;
}
int rule_blessed_harvest(void)
{
int rule = config_get_int("rules.blessed_harvest.flags",
HARVEST_WORK);
assert(rule >= 0);
static int rule, config;
if (config_changed(&config)) {
rule = config_get_int("rules.blessed_harvest.flags", HARVEST_WORK);
assert(rule >= 0);
}
return rule;
}
@ -1053,7 +1061,12 @@ int entertainmoney(const region * r)
int rule_give(void)
{
return config_get_int("rules.give.flags", GIVE_DEFAULT);
static int config;
static int rule;
if (config_changed(&config)) {
rule = config_get_int("rules.give.flags", GIVE_DEFAULT);
}
return rule;
}
bool markets_module(void)

View File

@ -204,6 +204,26 @@ static void test_config_cache(CuTest *tc) {
}
static void test_rules(CuTest *tc) {
CuAssertIntEquals(tc, HARVEST_WORK, rule_blessed_harvest());
config_set("rules.blessed_harvest.flags", "15");
CuAssertIntEquals(tc, 15, rule_blessed_harvest());
CuAssertTrue(tc, !rule_region_owners());
config_set("rules.region_owners", "1");
CuAssertTrue(tc, rule_region_owners());
CuAssertTrue(tc, rule_stealth_anon());
config_set("stealth.faction.anon", "0");
CuAssertTrue(tc, !rule_stealth_anon());
CuAssertTrue(tc, rule_stealth_other());
config_set("stealth.faction.other", "0");
CuAssertTrue(tc, !rule_stealth_other());
CuAssertIntEquals(tc, GIVE_DEFAULT, rule_give());
config_set("rules.give.flags", "15");
CuAssertIntEquals(tc, 15, rule_give());
CuAssertIntEquals(tc, 0, rule_alliance_limit());
config_set("rules.limit.alliance", "1");
CuAssertIntEquals(tc, 1, rule_alliance_limit());

View File

@ -261,6 +261,7 @@ faction *addfaction(const char *email, const char *password,
f->magiegebiet = 0;
f->locale = loc;
f->subscription = subscription;
f->flags = FFL_ISNEW;
f->options =
want(O_REPORT) | want(O_ZUGVORLAGE) | want(O_COMPUTER) | want(O_COMPRESS) |

View File

@ -40,7 +40,6 @@ extern "C" {
/* faction flags */
#define FFL_NEWID (1<<0) /* Die Partei hat bereits einmal ihre no gewechselt */
#define FFL_ISNEW (1<<1)
#define FFL_RESTART (1<<2)
#define FFL_QUIT (1<<3)
#define FFL_CURSED (1<<4) /* you're going to have a bad time */
#define FFL_DEFENDER (1<<10)
@ -52,8 +51,7 @@ extern "C" {
* FL_MARK hinterher löschen) */
#define FFL_NOIDLEOUT (1<<24) /* Partei stirbt nicht an NMRs */
#define FFL_NPC (1<<25) /* eine Partei mit Monstern */
#define FFL_DBENTRY (1<<28) /* Partei ist in Datenbank eingetragen */
#define FFL_SAVEMASK (FFL_DEFENDER|FFL_NEWID|FFL_NPC|FFL_DBENTRY|FFL_NOIDLEOUT|FFL_CURSED)
#define FFL_SAVEMASK (FFL_DEFENDER|FFL_NEWID|FFL_NPC|FFL_NOIDLEOUT|FFL_CURSED)
typedef struct faction {
struct faction *next;

View File

@ -117,7 +117,7 @@ static void test_addfaction(CuTest *tc) {
CuAssertTrue(tc, checkpasswd(f, "hurrdurr"));
CuAssertPtrEquals(tc, (void *)lang, (void *)f->locale);
CuAssertIntEquals(tc, 1234, f->subscription);
CuAssertIntEquals(tc, 0, f->flags);
CuAssertIntEquals(tc, FFL_ISNEW, f->flags);
CuAssertIntEquals(tc, 0, f->age);
CuAssertTrue(tc, faction_alive(f));
CuAssertIntEquals(tc, M_GRAY, f->magiegebiet);

View File

@ -322,10 +322,6 @@ int main(int argc, char **argv)
log_error("script %s failed with code %d\n", luafile, err);
return err;
}
#ifdef MSPACES
malloc_stats();
#endif
game_done();
lua_done(L);
log_close();

View File

@ -2106,19 +2106,14 @@ const char *charset)
if (f->age <= 2) {
const char *s;
s = locale_getstring(f->locale, "newbie_info_1");
if (s) {
newline(out);
centre(out, s, true);
}
s = locale_getstring(f->locale, "newbie_info_2");
s = locale_getstring(f->locale, "newbie_info_game");
if (s) {
newline(out);
centre(out, s, true);
}
if ((f->options & want(O_COMPUTER)) == 0) {
f->options |= want(O_COMPUTER);
s = locale_getstring(f->locale, "newbie_info_3");
s = locale_getstring(f->locale, "newbie_info_cr");
if (s) {
newline(out);
centre(out, s, true);
@ -2133,23 +2128,6 @@ const char *charset)
RENDER(f, buf, sizeof(buf), ("nr_score", "score average", score, avg));
centre(out, buf, true);
}
#ifdef COUNT_AGAIN
no_units = 0;
no_people = 0;
for (u = f->units; u; u = u->nextF) {
if (playerrace(u_race(u))) {
++no_people;
no_units += u->number;
assert(f == u->faction);
}
}
if (no_units != f->no_units) {
f->no_units = no_units;
}
if (no_people != f->num_people) {
f->num_people = no_people;
}
#else
no_units = count_units(f);
no_people = count_all(f);
if (f->flags & FFL_NPC) {
@ -2158,7 +2136,6 @@ const char *charset)
else {
no_people = f->num_people;
}
#endif
m = msg_message("nr_population", "population units limit", no_people, no_units, rule_faction_limit());
nr_render(m, f->locale, buf, sizeof(buf), f);
msg_release(m);