forked from github/server
consistent naming of module configurations (singular).
add module switch for volcano.
This commit is contained in:
parent
31d15550ed
commit
eccf6bef7a
|
@ -13,10 +13,11 @@
|
||||||
"game.id" : 2,
|
"game.id" : 2,
|
||||||
"orders.default": "work",
|
"orders.default": "work",
|
||||||
"NewbieImmunity": 8,
|
"NewbieImmunity": 8,
|
||||||
"modules.markets": false,
|
"modules.market": false,
|
||||||
"modules.astralspace": true,
|
"modules.astralspace": true,
|
||||||
"modules.wormholes": true,
|
"modules.wormhole": true,
|
||||||
"modules.icebergs": true,
|
"modules.iceberg": true,
|
||||||
|
"modules.volcano": true,
|
||||||
"entertain.base": 0,
|
"entertain.base": 0,
|
||||||
"entertain.perlevel": 20,
|
"entertain.perlevel": 20,
|
||||||
"taxing.perlevel": 20,
|
"taxing.perlevel": 20,
|
||||||
|
|
|
@ -32,8 +32,10 @@
|
||||||
"database.gameid": 7,
|
"database.gameid": 7,
|
||||||
"NewbieImmunity": 4,
|
"NewbieImmunity": 4,
|
||||||
"modules.astralspace": false,
|
"modules.astralspace": false,
|
||||||
"modules.wormholes": false,
|
"modules.wormhole": false,
|
||||||
"modules.markets": true,
|
"modules.market": true,
|
||||||
|
"modules.iceberg": false,
|
||||||
|
"modules.volcano": true,
|
||||||
"magic.regeneration": 0.75,
|
"magic.regeneration": 0.75,
|
||||||
"magic.power": 0.5,
|
"magic.power": 0.5,
|
||||||
"resource.factor": 0.25,
|
"resource.factor": 0.25,
|
||||||
|
|
|
@ -37,9 +37,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define MAXTERRAINS 14
|
static const char *terrainnames[MAXTERRAINS] = {
|
||||||
|
|
||||||
const char *terraindata[MAXTERRAINS] = {
|
|
||||||
"ocean",
|
"ocean",
|
||||||
"plain",
|
"plain",
|
||||||
"swamp",
|
"swamp",
|
||||||
|
@ -149,10 +147,10 @@ const struct terrain_type *newterrain(terrain_t t)
|
||||||
assert(t < MAXTERRAINS);
|
assert(t < MAXTERRAINS);
|
||||||
result = newterrains[t];
|
result = newterrains[t];
|
||||||
if (!result) {
|
if (!result) {
|
||||||
result = newterrains[t] = get_terrain(terraindata[t]);
|
result = newterrains[t] = get_terrain(terrainnames[t]);
|
||||||
}
|
}
|
||||||
if (!result) {
|
if (!result) {
|
||||||
log_error("no such terrain: %s.", terraindata[t]);
|
log_error("no such terrain: %s.", terrainnames[t]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -198,8 +196,8 @@ void init_terrains(void)
|
||||||
const terrain_type *newterrain = newterrains[t];
|
const terrain_type *newterrain = newterrains[t];
|
||||||
if (newterrain != NULL)
|
if (newterrain != NULL)
|
||||||
continue;
|
continue;
|
||||||
if (terraindata[t] != NULL) {
|
if (terrainnames[t] != NULL) {
|
||||||
newterrain = get_terrain(terraindata[t]);
|
newterrain = get_terrain(terrainnames[t]);
|
||||||
if (newterrain != NULL) {
|
if (newterrain != NULL) {
|
||||||
newterrains[t] = newterrain;
|
newterrains[t] = newterrain;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ extern "C" {
|
||||||
T_VOLCANO_SMOKING,
|
T_VOLCANO_SMOKING,
|
||||||
T_ICEBERG_SLEEP,
|
T_ICEBERG_SLEEP,
|
||||||
T_ICEBERG,
|
T_ICEBERG,
|
||||||
|
MAXTERRAINS,
|
||||||
NOTERRAIN = - 1
|
NOTERRAIN = - 1
|
||||||
} terrain_t;
|
} terrain_t;
|
||||||
|
|
||||||
|
|
29
src/laws.c
29
src/laws.c
|
@ -41,6 +41,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include "teleport.h"
|
#include "teleport.h"
|
||||||
#include "calendar.h"
|
#include "calendar.h"
|
||||||
#include "guard.h"
|
#include "guard.h"
|
||||||
|
#include "volcano.h"
|
||||||
|
|
||||||
/* attributes includes */
|
/* attributes includes */
|
||||||
#include <attributes/racename.h>
|
#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/spell.h>
|
||||||
#include <kernel/spellbook.h>
|
#include <kernel/spellbook.h>
|
||||||
#include <kernel/terrain.h>
|
#include <kernel/terrain.h>
|
||||||
#include <kernel/terrainid.h> /* for volcanoes in emigration (needs a flag) */
|
#include <kernel/terrainid.h>
|
||||||
#include <kernel/unit.h>
|
#include <kernel/unit.h>
|
||||||
|
|
||||||
/* util includes */
|
/* util includes */
|
||||||
|
@ -246,16 +247,20 @@ static void calculate_emigration(region * r)
|
||||||
int maxp = region_maxworkers(r);
|
int maxp = region_maxworkers(r);
|
||||||
int rp = rpeasants(r);
|
int rp = rpeasants(r);
|
||||||
int max_immigrants = MAX_IMMIGRATION(maxp - rp);
|
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");
|
if (volcano_module()) {
|
||||||
t_smoking = get_terrain("activevolcano");
|
static int terrain_cache;
|
||||||
}
|
static const terrain_type *t_volcano;
|
||||||
if (r->terrain == t_volcano || r->terrain == t_smoking) {
|
static const terrain_type *t_smoking;
|
||||||
max_immigrants = max_immigrants / 10;
|
|
||||||
|
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++) {
|
for (i = 0; max_immigrants > 0 && i != MAXDIRECTIONS; i++) {
|
||||||
|
@ -4221,7 +4226,7 @@ void turn_process(void)
|
||||||
init_processor();
|
init_processor();
|
||||||
process();
|
process();
|
||||||
|
|
||||||
if (config_get_int("modules.markets", 0)) {
|
if (markets_module()) {
|
||||||
do_markets();
|
do_markets();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4233,7 +4238,7 @@ void turn_end(void)
|
||||||
remove_empty_units();
|
remove_empty_units();
|
||||||
|
|
||||||
/* must happen AFTER age, because that would destroy them right away */
|
/* 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();
|
wormholes_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ attrib_type at_market = {
|
||||||
|
|
||||||
bool markets_module(void)
|
bool markets_module(void)
|
||||||
{
|
{
|
||||||
return (bool)config_get_int("modules.markets", 0);
|
return (bool)config_get_int("modules.market", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_markets(void)
|
void do_markets(void)
|
||||||
|
|
|
@ -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;
|
attrib *a;
|
||||||
unit *u;
|
unit *u;
|
||||||
|
@ -456,7 +456,7 @@ static void melt_iceberg(region * r)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* in Ozean wandeln */
|
/* in Ozean wandeln */
|
||||||
terraform_region(r, newterrain(T_OCEAN));
|
terraform_region(r, t_ocean);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void move_iceberg(region * r)
|
static void move_iceberg(region * r)
|
||||||
|
@ -585,14 +585,20 @@ static void move_iceberg(region * r)
|
||||||
static void move_icebergs(void)
|
static void move_icebergs(void)
|
||||||
{
|
{
|
||||||
region *r;
|
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) {
|
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;
|
int select = rng_int() % 10;
|
||||||
if (select < 4) {
|
if (select < 4) {
|
||||||
/* 4% chance */
|
/* 4% chance */
|
||||||
fset(r, RF_SELECT);
|
fset(r, RF_SELECT);
|
||||||
melt_iceberg(r);
|
melt_iceberg(r, t_ocean);
|
||||||
}
|
}
|
||||||
else if (select < 64) {
|
else if (select < 64) {
|
||||||
/* 60% chance */
|
/* 60% chance */
|
||||||
|
@ -798,7 +804,7 @@ void randomevents(void)
|
||||||
region *r;
|
region *r;
|
||||||
faction *monsters = get_monsters();
|
faction *monsters = get_monsters();
|
||||||
|
|
||||||
if (config_get_int("modules.icebergs", 0)) {
|
if (config_get_int("modules.iceberg", 0)) {
|
||||||
icebergs();
|
icebergs();
|
||||||
}
|
}
|
||||||
for (r = regions; r; r = r->next) {
|
for (r = regions; r; r = r->next) {
|
||||||
|
@ -807,7 +813,9 @@ void randomevents(void)
|
||||||
godcurse();
|
godcurse();
|
||||||
orc_growth();
|
orc_growth();
|
||||||
demon_skillchanges();
|
demon_skillchanges();
|
||||||
volcano_update();
|
if (volcano_module) {
|
||||||
|
volcano_update();
|
||||||
|
}
|
||||||
/* Monumente zerfallen, Schiffe verfaulen */
|
/* Monumente zerfallen, Schiffe verfaulen */
|
||||||
|
|
||||||
for (r = regions; r; r = r->next) {
|
for (r = regions; r; r = r->next) {
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ extern "C" {
|
||||||
|
|
||||||
void volcano_outbreak(struct region * r, struct region *rn);
|
void volcano_outbreak(struct region * r, struct region *rn);
|
||||||
void volcano_update(void);
|
void volcano_update(void);
|
||||||
|
bool volcano_module(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue