consistent naming of module configurations (singular).

add module switch for volcano.
This commit is contained in:
Enno Rehling 2017-11-06 21:04:30 +01:00
parent 31d15550ed
commit eccf6bef7a
9 changed files with 57 additions and 31 deletions

View File

@ -13,10 +13,11 @@
"game.id" : 2,
"orders.default": "work",
"NewbieImmunity": 8,
"modules.markets": false,
"modules.market": false,
"modules.astralspace": true,
"modules.wormholes": true,
"modules.icebergs": true,
"modules.wormhole": true,
"modules.iceberg": true,
"modules.volcano": true,
"entertain.base": 0,
"entertain.perlevel": 20,
"taxing.perlevel": 20,

View File

@ -32,8 +32,10 @@
"database.gameid": 7,
"NewbieImmunity": 4,
"modules.astralspace": false,
"modules.wormholes": false,
"modules.markets": true,
"modules.wormhole": false,
"modules.market": true,
"modules.iceberg": false,
"modules.volcano": true,
"magic.regeneration": 0.75,
"magic.power": 0.5,
"resource.factor": 0.25,

View File

@ -37,9 +37,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stdlib.h>
#include <string.h>
#define MAXTERRAINS 14
const char *terraindata[MAXTERRAINS] = {
static const char *terrainnames[MAXTERRAINS] = {
"ocean",
"plain",
"swamp",
@ -149,10 +147,10 @@ const struct terrain_type *newterrain(terrain_t t)
assert(t < MAXTERRAINS);
result = newterrains[t];
if (!result) {
result = newterrains[t] = get_terrain(terraindata[t]);
result = newterrains[t] = get_terrain(terrainnames[t]);
}
if (!result) {
log_error("no such terrain: %s.", terraindata[t]);
log_error("no such terrain: %s.", terrainnames[t]);
}
return result;
}
@ -198,8 +196,8 @@ void init_terrains(void)
const terrain_type *newterrain = newterrains[t];
if (newterrain != NULL)
continue;
if (terraindata[t] != NULL) {
newterrain = get_terrain(terraindata[t]);
if (terrainnames[t] != NULL) {
newterrain = get_terrain(terrainnames[t]);
if (newterrain != NULL) {
newterrains[t] = newterrain;
}

View File

@ -29,6 +29,7 @@ extern "C" {
T_VOLCANO_SMOKING,
T_ICEBERG_SLEEP,
T_ICEBERG,
MAXTERRAINS,
NOTERRAIN = - 1
} terrain_t;

View File

@ -41,6 +41,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "teleport.h"
#include "calendar.h"
#include "guard.h"
#include "volcano.h"
/* attributes includes */
#include <attributes/racename.h>
@ -72,7 +73,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/spell.h>
#include <kernel/spellbook.h>
#include <kernel/terrain.h>
#include <kernel/terrainid.h> /* for volcanoes in emigration (needs a flag) */
#include <kernel/terrainid.h>
#include <kernel/unit.h>
/* util includes */
@ -246,16 +247,20 @@ static void calculate_emigration(region * r)
int maxp = region_maxworkers(r);
int rp = rpeasants(r);
int max_immigrants = MAX_IMMIGRATION(maxp - rp);
static int terrain_cache;
static const terrain_type *t_volcano;
static const terrain_type *t_smoking;
if (terrain_changed(&terrain_cache)) {
t_volcano = get_terrain("volcano");
t_smoking = get_terrain("activevolcano");
}
if (r->terrain == t_volcano || r->terrain == t_smoking) {
max_immigrants = max_immigrants / 10;
if (volcano_module()) {
static int terrain_cache;
static const terrain_type *t_volcano;
static const terrain_type *t_smoking;
if (terrain_changed(&terrain_cache)) {
t_volcano = newterrain(T_VOLCANO);
t_smoking = newterrain(T_VOLCANO_SMOKING);
}
if (r->terrain == t_volcano || r->terrain == t_smoking) {
max_immigrants = max_immigrants / 10;
}
}
for (i = 0; max_immigrants > 0 && i != MAXDIRECTIONS; i++) {
@ -4221,7 +4226,7 @@ void turn_process(void)
init_processor();
process();
if (config_get_int("modules.markets", 0)) {
if (markets_module()) {
do_markets();
}
}
@ -4233,7 +4238,7 @@ void turn_end(void)
remove_empty_units();
/* must happen AFTER age, because that would destroy them right away */
if (config_get_int("modules.wormholes", 0)) {
if (config_get_int("modules.wormhole", 0)) {
wormholes_update();
}

View File

@ -71,7 +71,7 @@ attrib_type at_market = {
bool markets_module(void)
{
return (bool)config_get_int("modules.markets", 0);
return (bool)config_get_int("modules.market", 0);
}
void do_markets(void)

View File

@ -432,7 +432,7 @@ void drown(region * r)
}
}
static void melt_iceberg(region * r)
static void melt_iceberg(region * r, const terrain_type *t_ocean)
{
attrib *a;
unit *u;
@ -456,7 +456,7 @@ static void melt_iceberg(region * r)
}
/* in Ozean wandeln */
terraform_region(r, newterrain(T_OCEAN));
terraform_region(r, t_ocean);
}
static void move_iceberg(region * r)
@ -585,14 +585,20 @@ static void move_iceberg(region * r)
static void move_icebergs(void)
{
region *r;
static int terrain_cache;
static const terrain_type *t_iceberg, *t_ocean;
if (terrain_changed(&terrain_cache)) {
t_iceberg = newterrain(T_ICEBERG);
t_ocean = newterrain(T_OCEAN);
}
for (r = regions; r; r = r->next) {
if (r->terrain == newterrain(T_ICEBERG) && !fval(r, RF_SELECT)) {
if (r->terrain == t_iceberg && !fval(r, RF_SELECT)) {
int select = rng_int() % 10;
if (select < 4) {
/* 4% chance */
fset(r, RF_SELECT);
melt_iceberg(r);
melt_iceberg(r, t_ocean);
}
else if (select < 64) {
/* 60% chance */
@ -798,7 +804,7 @@ void randomevents(void)
region *r;
faction *monsters = get_monsters();
if (config_get_int("modules.icebergs", 0)) {
if (config_get_int("modules.iceberg", 0)) {
icebergs();
}
for (r = regions; r; r = r->next) {
@ -807,7 +813,9 @@ void randomevents(void)
godcurse();
orc_growth();
demon_skillchanges();
volcano_update();
if (volcano_module) {
volcano_update();
}
/* Monumente zerfallen, Schiffe verfaulen */
for (r = regions; r; r = r->next) {

View File

@ -314,3 +314,13 @@ void volcano_update(void)
}
}
}
bool volcano_module(void)
{
static int cache;
static bool active;
if (config_changed(&cache)) {
active = config_get_int("modules.volcano", 0) != 0;
}
return active;
}

View File

@ -27,6 +27,7 @@ extern "C" {
void volcano_outbreak(struct region * r, struct region *rn);
void volcano_update(void);
bool volcano_module(void);
#ifdef __cplusplus
}