forked from github/server
remove at_chaoscount, update storage module.
This commit is contained in:
parent
38cb6297bb
commit
5018308170
2
clibs
2
clibs
|
@ -1 +1 @@
|
|||
Subproject commit f9842e07a442c5453c270badf25ab72633b4edf5
|
||||
Subproject commit bd70ef20babbe9949e5ad5acd5317e7d39ad1e72
|
|
@ -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 */
|
||||
|
|
|
@ -20,7 +20,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <kernel/config.h>
|
||||
#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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "bind_ship.h"
|
||||
#include "bind_building.h"
|
||||
|
||||
#include "chaos.h"
|
||||
#include "teleport.h"
|
||||
|
||||
#include <kernel/calendar.h>
|
||||
|
@ -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) {
|
||||
|
|
61
src/chaos.c
61
src/chaos.c
|
@ -39,57 +39,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
/*********************/
|
||||
/* 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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
#include <util/unicode.h>
|
||||
|
||||
#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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
@ -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.
|
||||
|
|
2
storage
2
storage
|
@ -1 +1 @@
|
|||
Subproject commit 5623ee6527e97af20c7d8efc03800b6fe1579744
|
||||
Subproject commit 4d33d5081f593272c25baa64d6210635c1c7e828
|
Loading…
Reference in New Issue