From 501830817051c581665ee5714bde5156d3c34712 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 28 Jun 2018 22:48:57 +0200 Subject: [PATCH] remove at_chaoscount, update storage module. --- clibs | 2 +- src/attributes/attributes.c | 1 + src/battle.c | 2 -- src/bind_region.c | 9 +----- src/chaos.c | 61 ------------------------------------- src/chaos.h | 7 ----- src/eressea.c | 2 -- src/gmtool.c | 2 -- src/kernel/order.test.c | 1 + src/monsters.c | 20 +++++------- storage | 2 +- 11 files changed, 13 insertions(+), 96 deletions(-) diff --git a/clibs b/clibs index f9842e07a..bd70ef20b 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit f9842e07a442c5453c270badf25ab72633b4edf5 +Subproject commit bd70ef20babbe9949e5ad5acd5317e7d39ad1e72 diff --git a/src/attributes/attributes.c b/src/attributes/attributes.c index 907478aaa..fa6f15d73 100644 --- a/src/attributes/attributes.c +++ b/src/attributes/attributes.c @@ -209,6 +209,7 @@ void register_attributes(void) at_deprecate("maxmagicians", a_readint); /* factions with differnt magician limits, probably unused */ at_deprecate("hurting", a_readint); /* an old arena attribute */ + at_deprecate("chaoscount", a_readint); /* used to increase the chance of monster spawns */ at_deprecate("xontormiaexpress", a_readint); /* required for old datafiles */ at_deprecate("orcification", a_readint); /* required for old datafiles */ at_deprecate("lua", read_ext); /* required for old datafiles */ diff --git a/src/battle.c b/src/battle.c index 9092718a2..be950af7f 100644 --- a/src/battle.c +++ b/src/battle.c @@ -20,7 +20,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "battle.h" #include "alchemy.h" -#include "chaos.h" #include "guard.h" #include "laws.h" #include "monsters.h" @@ -2531,7 +2530,6 @@ static void battle_effects(battle * b, int dead_players) } if (dead_peasants) { deathcounts(r, dead_peasants + dead_players); - add_chaoscount(r, dead_peasants / 2); rsetpeasants(r, rp - dead_peasants); } } diff --git a/src/bind_region.c b/src/bind_region.c index e041fba77..b49ceb078 100644 --- a/src/bind_region.c +++ b/src/bind_region.c @@ -7,7 +7,6 @@ #include "bind_ship.h" #include "bind_building.h" -#include "chaos.h" #include "teleport.h" #include @@ -356,7 +355,7 @@ static int tolua_region_get_resourcelevel(lua_State * L) #define LUA_ASSERT(c, s) if (!(c)) { log_error("%s(%d): %s\n", __FILE__, __LINE__, (s)); return 0; } static int special_resource(const char *type) { - const char * special[] = { "seed", "sapling", "tree", "grave", "chaos", 0 }; + const char * special[] = { "seed", "sapling", "tree", "grave", NULL }; int i; for (i = 0; special[i]; ++i) { @@ -389,9 +388,6 @@ static int tolua_region_get_resource(lua_State * L) case 3: result = deathcount(r); break; - case 4: - result = get_chaoscount(r); - break; default: rtype = rt_find(type); if (rtype) { @@ -423,9 +419,6 @@ static int tolua_region_set_resource(lua_State * L) case 3: deathcounts(r, value - deathcount(r)); break; - case 4: - add_chaoscount(r, value - get_chaoscount(r)); - break; default: rtype = rt_find(type); if (rtype != NULL) { diff --git a/src/chaos.c b/src/chaos.c index 67cdb356d..21a5a8624 100644 --- a/src/chaos.c +++ b/src/chaos.c @@ -39,57 +39,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -/*********************/ -/* at_chaoscount */ -/*********************/ -attrib_type at_chaoscount = { - "chaoscount", - DEFAULT_INIT, - DEFAULT_FINALIZE, - DEFAULT_AGE, - a_writeint, - a_readint, - NULL, - ATF_UNIQUE -}; - -void set_chaoscount(struct region *r, int deaths) -{ - if (deaths==0) { - a_removeall(&r->attribs, &at_chaoscount); - } else { - attrib *a = a_find(r->attribs, &at_chaoscount); - if (!a) { - a = a_add(&r->attribs, a_new(&at_chaoscount)); - } - a->data.i = deaths; - } -} - -int get_chaoscount(const region * r) -{ - attrib *a = a_find(r->attribs, &at_chaoscount); - if (!a) - return 0; - return a->data.i; -} - -void add_chaoscount(region * r, int fallen) -{ - attrib *a; - - if (fallen == 0) - return; - - a = a_find(r->attribs, &at_chaoscount); - if (!a) - a = a_add(&r->attribs, a_new(&at_chaoscount)); - a->data.i += fallen; - - if (a->data.i <= 0) - a_remove(&r->attribs, a); -} - static const terrain_type *chaosterrain(void) { static const terrain_type **types; @@ -248,18 +197,8 @@ void chaos_update(void) { region *r; /* Chaos */ for (r = regions; r; r = r->next) { - int i; - if ((r->flags & RF_CHAOTIC)) { chaos(r); } - i = get_chaoscount(r); - if (i) { - add_chaoscount(r, -(int)(i * ((double)(rng_int() % 10)) / 100.0)); - } } } - -void chaos_register(void) { - at_register(&at_chaoscount); -} diff --git a/src/chaos.h b/src/chaos.h index 0c2667083..550aa3efb 100644 --- a/src/chaos.h +++ b/src/chaos.h @@ -24,15 +24,8 @@ extern "C" { struct region; - extern struct attrib_type at_chaoscount; - - void chaos_register(void); void chaos_update(void); - void set_chaoscount(struct region *r, int deaths); - int get_chaoscount(const struct region * r); - void add_chaoscount(struct region * r, int deaths); - #ifdef __cplusplus } #endif diff --git a/src/eressea.c b/src/eressea.c index 982dfe6ee..0bf1454ee 100644 --- a/src/eressea.c +++ b/src/eressea.c @@ -24,7 +24,6 @@ #include "attributes/attributes.h" #include "races/races.h" -#include "chaos.h" #include "items.h" #include "creport.h" #include "report.h" @@ -82,5 +81,4 @@ void game_init(void) register_attributes(); register_gmcmd(); - chaos_register(); } diff --git a/src/gmtool.c b/src/gmtool.c index e13701f6f..d3858d09f 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -50,7 +50,6 @@ #include #include "gmtool_structs.h" -#include "chaos.h" #include "console.h" #include "listbox.h" #include "wormhole.h" @@ -531,7 +530,6 @@ static void statusline(WINDOW * win, const char *str) } static void reset_region(region *r) { - set_chaoscount(r, 0); r->flags = 0; a_removeall(&r->attribs, NULL); while (r->units) { diff --git a/src/kernel/order.test.c b/src/kernel/order.test.c index 37f88ae5a..3a2f44c56 100644 --- a/src/kernel/order.test.c +++ b/src/kernel/order.test.c @@ -512,6 +512,7 @@ static void test_create_order_long(CuTest *tc) { stream_order(&out, ord, lang, true); out.api->rewind(out.handle); out.api->readln(out.handle, buffer, sizeof(buffer)); + CuAssertIntEquals(tc, 1026, strlen(buffer)); mstream_done(&out); free_order(ord); test_teardown(); diff --git a/src/monsters.c b/src/monsters.c index be4ec7525..181615a40 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -24,7 +24,6 @@ #include "monsters.h" #include "economy.h" -#include "chaos.h" #include "give.h" #include "guard.h" #include "laws.h" @@ -843,18 +842,14 @@ void plan_monsters(faction * f) pathfinder_cleanup(); } -static double chaosfactor(region * r) -{ - return fval(r, RF_CHAOTIC) ? ((double)(1 + get_chaoscount(r)) / 1000.0) : 0.0; -} - static int nrand(int handle_start, int sub) { int res = 0; do { - if (rng_int() % 100 < handle_start) + if (rng_int() % 100 < handle_start) { res++; + } handle_start -= sub; } while (handle_start > 0); @@ -876,7 +871,7 @@ void spawn_dragons(void) region *r; faction *monsters = get_or_create_monsters(); int minage = config_get_int("monsters.spawn.min_age", 100); - int spawn_chance = 100 * config_get_int("monsters.spawn.chance", 100); + int spawn_chance = config_get_int("monsters.spawn.chance", 100); if (spawn_chance <= 0) { /* monster spawning disabled */ @@ -895,7 +890,8 @@ void spawn_dragons(void) else if ((r->terrain == newterrain(T_GLACIER) || r->terrain == newterrain(T_SWAMP) || r->terrain == newterrain(T_DESERT)) - && rng_int() % spawn_chance < (5 + 100 * chaosfactor(r))) { + && rng_int() % spawn_chance < 6) + { if (chance(0.80)) { u = create_unit(r, monsters, nrand(60, 20) + 1, get_race(RC_FIREDRAGON), 0, NULL, NULL); } @@ -907,7 +903,7 @@ void spawn_dragons(void) log_debug("spawning %d %s in %s.\n", u->number, LOC(default_locale, - rc_name_s(u_race(u), (u->number == 1) ? NAME_SINGULAR : NAME_PLURAL)), regionname(r, NULL)); + rc_name_s(u_race(u), (u->number == 1) ? NAME_SINGULAR : NAME_PLURAL)), regionname(r, NULL)); name_unit(u); @@ -932,9 +928,9 @@ void spawn_undead(void) continue; } } - /* Chance 0.1% * chaosfactor */ + if (r->land && unburied > rpeasants(r) / 20 - && rng_int() % 10000 < (100 + 100 * chaosfactor(r))) { + && rng_int() % 10000 < 200) { message *msg; unit *u; /* es ist sinnfrei, wenn irgendwo im Wald 3er-Einheiten Untote entstehen. diff --git a/storage b/storage index 5623ee652..4d33d5081 160000 --- a/storage +++ b/storage @@ -1 +1 @@ -Subproject commit 5623ee6527e97af20c7d8efc03800b6fe1579744 +Subproject commit 4d33d5081f593272c25baa64d6210635c1c7e828