diff --git a/scripts/tests/laws.lua b/scripts/tests/laws.lua index f0fef15a9..6f41fc54b 100644 --- a/scripts/tests/laws.lua +++ b/scripts/tests/laws.lua @@ -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 diff --git a/src/bind_config.c b/src/bind_config.c index 929e4cca0..faf543f47 100644 --- a/src/bind_config.c +++ b/src/bind_config.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -20,7 +21,9 @@ void config_reset(void) { default_locale = 0; + free_config(); free_locales(); + free_nrmesssages(); free_spells(); free_buildingtypes(); free_shiptypes(); diff --git a/src/bindings.c b/src/bindings.c index 0986ffb37..7bf30202a 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -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 */ diff --git a/src/laws.c b/src/laws.c index d6e005ff8..74e572a78 100644 --- a/src/laws.c +++ b/src/laws.c @@ -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) diff --git a/src/util/nrmessage.c b/src/util/nrmessage.c index 8156b9784..717c4dc1f 100644 --- a/src/util/nrmessage.c +++ b/src/util/nrmessage.c @@ -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); + } + } +} diff --git a/src/util/nrmessage.h b/src/util/nrmessage.h index 122b1f1a8..6cc02bfe2 100644 --- a/src/util/nrmessage.h +++ b/src/util/nrmessage.h @@ -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. diff --git a/src/util/nrmessage_struct.h b/src/util/nrmessage_struct.h index 6a3a1d9b0..57f8e644d 100644 --- a/src/util/nrmessage_struct.h +++ b/src/util/nrmessage_struct.h @@ -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;