diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index e2fe94daf..35f0101bd 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -42,6 +42,7 @@ function setup() write_game("free.dat") settings.set("nmr.removenewbie", "0") settings.set("nmr.timeout", "0") + settings.set("NewbieImmunity", "0") settings.set("rules.economy.food", "4") end @@ -67,6 +68,7 @@ function test_fleeing_units_can_be_transported() u1:add_order("ATTACKIEREN " .. itoa36(u2.id)) u2.number = 100 u2:add_order("FAHREN " .. itoa36(u3.id)) + u2:add_order("KAEMPFE FLIEHE") u3.number = 100 u3:add_order("KAEMPFE FLIEHE") u3:add_order("TRANSPORT " .. itoa36(u2.id)) @@ -1043,7 +1045,7 @@ function test_building_unique() assert_equal(h1, bs.name) end assert_equal(1, string.find(bs.name, "Hafen")) - if bs.size >= 25 then + if bs.size >= config.get_building(utype).maxsize then bcount = bcount + 1 end end diff --git a/src/kernel/building.c b/src/kernel/building.c index 45d6f84fe..f26e153bf 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -126,6 +126,7 @@ typedef struct building_typelist { quicklist *buildingtypes = NULL; +/* Returns a building type for the (internal) name */ building_type *bt_find(const char *name) { quicklist *ql; @@ -169,6 +170,9 @@ attrib_type at_building_generic_type = { ATF_UNIQUE }; +/* Returns the (internal) name for a building of given size and type. Especially, returns the correct + * name if it depends on the size (as for Eressea castles). + */ const char *buildingtype(const building_type * btype, const building * b, int bsize) { @@ -350,6 +354,8 @@ int wdw_pyramid_level(const struct building *b) static local_names *bnames; +/* Find the building type for a given localized name (as seen by the user). Useful for parsing + * orders. The inverse of locale_string(lang, btype->_name), sort of. */ const building_type *findbuildingtype(const char *name, const struct locale *lang) { @@ -391,10 +397,17 @@ static int eressea_building_protection(building * b, unit * u) return beff; } +static int meropis_building_protection(building * b, unit * u) +{ + return 2; +} + void register_buildings(void) { register_function((pf_generic) & eressea_building_protection, "eressea_building_protection"); + register_function((pf_generic) & meropis_building_protection, + "meropis_building_protection"); register_function((pf_generic) & init_smithy, "init_smithy"); register_function((pf_generic) & castle_name, "castle_name"); register_function((pf_generic) & castle_name_2, "castle_name_2");