Merge pull request #638 from ennorehling/develop

disable config.lua auto-laod
This commit is contained in:
Enno Rehling 2017-01-23 21:40:57 +01:00 committed by GitHub
commit 9cea70afe8
9 changed files with 44 additions and 13 deletions

View File

@ -95,6 +95,7 @@ function test_force_leave_postcombat()
u1.building = b1
u2.building = b1
eressea.settings.set("rules.owners.force_leave", "1")
eressea.settings.set("NewbieImmunity", "0")
u1:clear_orders()
u1:add_order("ATTACKIERE " .. itoa36(u2.id))
u2:clear_orders()
@ -109,6 +110,7 @@ function test_force_leave_postcombat()
end
end
assert_not_equal(nil, u3)
assert_equal(nil, u2.building)
assert_equal(nil, u3.building)
assert_equal(1, u3.number)
end

View File

@ -8,6 +8,8 @@ function setup()
eressea.settings.set("rules.grow.formula", "0")
eressea.settings.set("rules.peasants.growth.factor", "0")
eressea.settings.set("volcano.active.percent", "0")
eressea.settings.set("volcano.outbreak.percent", "0")
eressea.settings.set("volcano.stop.percent", "0")
end
function test_snowglobe_fail()

View File

@ -4,6 +4,7 @@
#include <kernel/config.h>
#include <kernel/jsonconf.h>
#include <util/bsdstring.h>
#include <util/nrmessage.h>
#include <util/log.h>
#include <util/language.h>
#include <cJSON.h>
@ -20,7 +21,9 @@
void config_reset(void) {
default_locale = 0;
free_config();
free_locales();
free_nrmesssages();
free_spells();
free_buildingtypes();
free_shiptypes();

View File

@ -1190,7 +1190,7 @@ int eressea_run(lua_State *L, const char *luafile)
lua_remove(L, -2);
/* try to run configuration scripts: */
err = run_script(L, "config.lua");
// err = run_script(L, "config.lua");
err = run_script(L, "custom.lua");
/* run the main script */

View File

@ -119,7 +119,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
int NewbieImmunity(void)
{
return config_get_int("NewbieImmunity", 0);
int result = config_get_int("NewbieImmunity", 0);
return result;
}
bool IsImmune(const faction * f)

View File

@ -178,3 +178,16 @@ const char *nrt_section(const nrmessage_type * nrt)
{
return nrt ? nrt->section : NULL;
}
void free_nrmesssages(void) {
int i;
for (i = 0; i != NRT_MAXHASH; ++i) {
while (nrtypes[i]) {
nrmessage_type *nr = nrtypes[i];
nrtypes[i] = nr->next;
free(nr->string);
free(nr->vars);
free(nr);
}
}
}

View File

@ -31,18 +31,20 @@ extern "C" {
extern nrsection *sections;
extern void nrt_register(const struct message_type *mtype,
void free_nrmesssages(void);
void nrt_register(const struct message_type *mtype,
const struct locale *lang, const char *script,
int level, const char *section);
extern struct nrmessage_type *nrt_find(const struct locale *,
struct nrmessage_type *nrt_find(const struct locale *,
const struct message_type *);
extern const char *nrt_string(const struct nrmessage_type *type);
extern const char *nrt_section(const struct nrmessage_type *mt);
const char *nrt_string(const struct nrmessage_type *type);
const char *nrt_section(const struct nrmessage_type *mt);
extern size_t nr_render(const struct message *msg, const struct locale *lang,
size_t nr_render(const struct message *msg, const struct locale *lang,
char *buffer, size_t size, const void *userdata);
extern int nr_level(const struct message *msg);
extern const char *nr_section(const struct message *msg);
int nr_level(const struct message *msg);
const char *nr_section(const struct message *msg);
/* before:
* fogblock;movement:0;de;{unit} konnte von {region} nicht nach {$dir direction} ausreisen, der Nebel war zu dicht.

View File

@ -8,8 +8,8 @@
typedef struct nrmessage_type {
const struct message_type *mtype;
const struct locale *lang;
const char *string;
const char *vars;
char *string;
char *vars;
struct nrmessage_type *next;
int level;
const char *section;

View File

@ -256,11 +256,19 @@ void volcano_outbreak(region * r, region *rn)
}
static bool stop_smoke_chance(void) {
return rng_int() % 100 < 12;
static int cache, percent = 0;
if (config_changed(&cache)) {
percent = config_get_int("volcano.stop.percent", 12);
}
return percent!=0 && (rng_int() % 100) < percent;
}
static bool outbreak_chance(void) {
return rng_int() % 100 < 8;
static int cache, percent = 0;
if (config_changed(&cache)) {
percent = config_get_int("volcano.outbreak.percent", 8);
}
return percent!=0 && (rng_int() % 100) < percent;
}
void volcano_update(void)