diff --git a/src/attributes/attributes.c b/src/attributes/attributes.c index 605616ef1..afe899b0f 100644 --- a/src/attributes/attributes.c +++ b/src/attributes/attributes.c @@ -20,12 +20,17 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "attributes.h" +#include "laws.h" +#include "move.h" +#include "guard.h" + /* attributes includes */ #include "follow.h" #include "hate.h" #include "iceberg.h" #include "key.h" #include "stealth.h" +#include "magic.h" #include "moved.h" #include "movement.h" #include "dict.h" @@ -38,8 +43,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "targetregion.h" /* kernel includes */ +#include +#include +#include #include #include +#include #include #include #include @@ -47,13 +56,67 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* util includes */ #include +#include + +#include attrib_type at_unitdissolve = { "unitdissolve", NULL, NULL, NULL, a_writechars, a_readchars }; +static int read_ext(attrib * a, void *owner, struct storage *store) +{ + int len; + + READ_INT(store, &len); + store->api->r_bin(store->handle, NULL, (size_t)len); + return AT_READ_OK; +} + void register_attributes(void) { + /* Alle speicherbaren Attribute müssen hier registriert werden */ + at_register(&at_shiptrail); + at_register(&at_familiar); + at_register(&at_familiarmage); + at_register(&at_clone); + at_register(&at_clonemage); + at_register(&at_eventhandler); + at_register(&at_mage); + at_register(&at_countdown); + at_register(&at_curse); + + at_register(&at_seenspell); + + /* neue REGION-Attribute */ + at_register(&at_moveblock); + at_register(&at_deathcount); + at_register(&at_woodcount); + + /* neue UNIT-Attribute */ + at_register(&at_siege); + at_register(&at_effect); + at_register(&at_private); + + at_register(&at_icastle); + at_register(&at_guard); + at_register(&at_group); + + at_register(&at_building_generic_type); + at_register(&at_maxmagicians); + at_register(&at_npcfaction); + + /* connection-typen */ + register_bordertype(&bt_noway); + register_bordertype(&bt_fogwall); + register_bordertype(&bt_wall); + register_bordertype(&bt_illusionwall); + register_bordertype(&bt_road); + + at_register(&at_germs); + + at_deprecate("xontormiaexpress", a_readint); /* required for old datafiles */ + at_deprecate("lua", read_ext); /* required for old datafiles */ at_deprecate("gm", a_readint); at_register(&at_stealth); at_register(&at_dict); diff --git a/src/kernel/config.c b/src/kernel/config.c index ed6393349..fb316c086 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -44,7 +44,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "race.h" #include "reports.h" #include "region.h" -#include "save.h" #include "ship.h" #include "skill.h" #include "terrain.h" @@ -85,7 +84,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #endif /* external libraries */ -#include #include #include @@ -267,34 +265,6 @@ const char *options[MAXOPTIONS] = { "SHOWSKCHANGE" }; -static void init_maxmagicians(struct attrib *a) -{ - a->data.i = MAXMAGICIANS; -} - -static attrib_type at_maxmagicians = { - "maxmagicians", - init_maxmagicians, - NULL, - NULL, - a_writeint, - a_readint, - ATF_UNIQUE -}; - -int max_magicians(const faction * f) -{ - int m = config_get_int("rules.maxskills.magic", MAXMAGICIANS); - attrib *a; - - if ((a = a_find(f->attribs, &at_maxmagicians)) != NULL) { - m = a->data.i; - } - if (f->race == get_race(RC_ELF)) - ++m; - return m; -} - FILE *debug; /* ----------------------------------------------------------------------- */ @@ -786,16 +756,6 @@ void kernel_done(void) free_attribs(); } -attrib_type at_germs = { - "germs", - DEFAULT_INIT, - DEFAULT_FINALIZE, - DEFAULT_AGE, - a_writeshorts, - a_readshorts, - ATF_UNIQUE -}; - void setstatus(struct unit *u, int status) { assert(status >= ST_AGGRO && status <= ST_FLEE); @@ -1099,70 +1059,12 @@ bool has_limited_skills(const struct unit * u) } } -static int read_ext(attrib * a, void *owner, struct storage *store) -{ - int len; - - READ_INT(store, &len); - store->api->r_bin(store->handle, NULL, (size_t)len); - return AT_READ_OK; -} - - -void attrib_init(void) -{ - /* Alle speicherbaren Attribute müssen hier registriert werden */ - at_register(&at_shiptrail); - at_register(&at_familiar); - at_register(&at_familiarmage); - at_register(&at_clone); - at_register(&at_clonemage); - at_register(&at_eventhandler); - at_register(&at_mage); - at_register(&at_countdown); - at_register(&at_curse); - - at_register(&at_seenspell); - - /* neue REGION-Attribute */ - at_register(&at_moveblock); - at_register(&at_deathcount); - at_register(&at_woodcount); - - /* neue UNIT-Attribute */ - at_register(&at_siege); - at_register(&at_effect); - at_register(&at_private); - - at_register(&at_icastle); - at_register(&at_guard); - at_register(&at_group); - - at_register(&at_building_generic_type); - at_register(&at_maxmagicians); - at_register(&at_npcfaction); - - /* connection-typen */ - register_bordertype(&bt_noway); - register_bordertype(&bt_fogwall); - register_bordertype(&bt_wall); - register_bordertype(&bt_illusionwall); - register_bordertype(&bt_road); - - register_function((pf_generic)minimum_wage, "minimum_wage"); - - at_register(&at_germs); - - at_deprecate("xontormiaexpress", a_readint); /* required for old datafiles */ - at_deprecate("lua", read_ext); /* required for old datafiles */ -} - void kernel_init(void) { register_reports(); mt_clear(); - attrib_init(); translation_init(); + register_function((pf_generic)minimum_wage, "minimum_wage"); } static order * defaults[MAXLOCALES]; diff --git a/src/kernel/config.h b/src/kernel/config.h index 2296f0d99..3c1b90528 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -27,11 +27,6 @@ extern "C" { #include "types.h" struct param; - /* getunit results: */ -#define GET_UNIT 0 -#define GET_NOTFOUND 1 -#define GET_PEASANTS 2 - #define DISPLAYSIZE 8192 /* max. Länge einer Beschreibung, incl trailing 0 */ #define ORDERSIZE (DISPLAYSIZE*2) /* max. length of an order */ #define NAMESIZE 128 /* max. Länge eines Namens, incl trailing 0 */ @@ -50,7 +45,6 @@ struct param; #define fset(u, i) ((u)->flags |= (i)) #define freset(u, i) ((u)->flags &= ~(i)) - int max_magicians(const struct faction * f); int findoption(const char *s, const struct locale *lang); param_t findparam(const char *s, const struct locale *lang); diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 288c54569..324c4b180 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -30,6 +30,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "plane.h" #include "race.h" #include "region.h" +#include "save.h" #include "spellbook.h" #include "terrain.h" #include "unit.h" @@ -773,3 +774,32 @@ int count_maxmigrants(const faction * f) } return 0; } + +static void init_maxmagicians(struct attrib *a) +{ + a->data.i = MAXMAGICIANS; +} + +attrib_type at_maxmagicians = { + "maxmagicians", + init_maxmagicians, + NULL, + NULL, + a_writeint, + a_readint, + ATF_UNIQUE +}; + +int max_magicians(const faction * f) +{ + int m = config_get_int("rules.maxskills.magic", MAXMAGICIANS); + attrib *a; + + if ((a = a_find(f->attribs, &at_maxmagicians)) != NULL) { + m = a->data.i; + } + if (f->race == get_race(RC_ELF)) + ++m; + return m; +} + diff --git a/src/kernel/faction.h b/src/kernel/faction.h index afeef37d3..4f47daaab 100644 --- a/src/kernel/faction.h +++ b/src/kernel/faction.h @@ -29,7 +29,9 @@ extern "C" { struct alliance; struct item; struct seen_region; + struct attrib_type; + extern struct attrib_type at_maxmagicians; /* SMART_INTERVALS: define to speed up finding the interval of regions that a faction is in. defining this speeds up the turn by 30-40% */ #define SMART_INTERVALS @@ -173,7 +175,7 @@ extern "C" { int count_maxmigrants(const struct faction * f); int count_all(const struct faction * f); int count_units(const struct faction * f); - + int max_magicians(const struct faction * f); #ifdef __cplusplus } diff --git a/src/kernel/unit.h b/src/kernel/unit.h index ee9d8ecfd..2fd394ccb 100644 --- a/src/kernel/unit.h +++ b/src/kernel/unit.h @@ -256,8 +256,13 @@ extern "C" { bool unit_name_equals_race(const struct unit *u); bool unit_can_study(const struct unit *u); - int newunitid(void); + /* getunit results: */ +#define GET_UNIT 0 +#define GET_NOTFOUND 1 +#define GET_PEASANTS 2 + int getunit(const struct region * r, const struct faction * f, struct unit **uresult); + int newunitid(void); int read_unitid(const struct faction *f, const struct region *r); #ifdef __cplusplus diff --git a/src/laws.c b/src/laws.c index f69af5649..9615706a5 100755 --- a/src/laws.c +++ b/src/laws.c @@ -478,7 +478,16 @@ static int count_race(const region * r, const race * rc) return c; } -extern struct attrib_type at_germs; +attrib_type at_germs = { + "germs", + DEFAULT_INIT, + DEFAULT_FINALIZE, + DEFAULT_AGE, + a_writeshorts, + a_readshorts, + ATF_UNIQUE +}; + static void growing_trees_e3(region * r, const int current_season, diff --git a/src/laws.h b/src/laws.h index bc9afc106..e245f3c01 100755 --- a/src/laws.h +++ b/src/laws.h @@ -34,6 +34,7 @@ extern "C" { struct attrib_type; extern struct attrib_type at_germs; + extern int dropouts[2]; extern int *age;