diff --git a/res/core/resources/iron.xml b/res/core/resources/iron.xml
index 7bc4cb428..3f8897abc 100644
--- a/res/core/resources/iron.xml
+++ b/res/core/resources/iron.xml
@@ -7,6 +7,5 @@
-
diff --git a/res/core/resources/laen.xml b/res/core/resources/laen.xml
index 571026a0a..12062bf07 100644
--- a/res/core/resources/laen.xml
+++ b/res/core/resources/laen.xml
@@ -5,6 +5,5 @@
-
diff --git a/res/core/resources/log.xml b/res/core/resources/log.xml
index 012fe9a20..e3a33ef8b 100644
--- a/res/core/resources/log.xml
+++ b/res/core/resources/log.xml
@@ -6,7 +6,6 @@
-
diff --git a/src/attributes/attributes.c b/src/attributes/attributes.c
index a82e1941d..e46988667 100644
--- a/src/attributes/attributes.c
+++ b/src/attributes/attributes.c
@@ -22,7 +22,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "laws.h"
#include "move.h"
-#include "guard.h"
/* attributes includes */
#include "follow.h"
@@ -105,7 +104,6 @@ void register_attributes(void)
at_register(&at_private);
at_register(&at_icastle);
- at_register(&at_guard);
at_register(&at_group);
at_register(&at_building_generic_type);
@@ -124,6 +122,7 @@ void register_attributes(void)
at_deprecate("xontormiaexpress", a_readint); /* required for old datafiles */
at_deprecate("lua", read_ext); /* required for old datafiles */
at_deprecate("gm", a_readint);
+ at_deprecate("guard", a_readint); /* used to contain guard-flags (v3.10.0-259-g8597e8b) */
at_register(&at_stealth);
at_register(&at_dict);
at_register(&at_unitdissolve);
diff --git a/src/economy.c b/src/economy.c
index 6ec5d9191..2aa3392ad 100644
--- a/src/economy.c
+++ b/src/economy.c
@@ -935,17 +935,6 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want)
}
}
- if (rdata->guard != 0) {
- unit *u2;
- for (u2 = r->units; u2; u2 = u2->next) {
- if (is_guard(u2, rdata->guard) != 0 && can_guard(u2, u)) {
- ADDMSG(&u->faction->msgs,
- msg_feedback(u, u->thisorder, "region_guarded", "guard", u2));
- return;
- }
- }
- }
-
/* Bergwächter können Abbau von Eisen/Laen durch Bewachen verhindern.
* Als magische Wesen 'sehen' Bergwächter alles und werden durch
* Belagerung nicht aufgehalten. (Ansonsten wie oben bei Elfen anpassen).
@@ -953,7 +942,7 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want)
if (itype->rtype && (itype->rtype == get_resourcetype(R_IRON) || itype->rtype == rt_find("laen"))) {
unit *u2;
for (u2 = r->units; u2; u2 = u2->next) {
- if (is_guard(u, GUARD_MINING)
+ if (is_guard(u, GUARD_ALL)
&& !fval(u2, UFL_ISNEW)
&& u2->number && !alliedunit(u2, u->faction, HELP_GUARD)) {
ADDMSG(&u->faction->msgs,
diff --git a/src/guard.c b/src/guard.c
index cefcdb925..eb55525e8 100644
--- a/src/guard.c
+++ b/src/guard.c
@@ -39,7 +39,7 @@ attrib_type at_guard = {
DEFAULT_INIT,
DEFAULT_FINALIZE,
DEFAULT_AGE,
- a_writeint,
+ NULL,
a_readint,
NULL,
ATF_UNIQUE
@@ -70,13 +70,6 @@ void update_guards(void)
if (can_start_guarding(u) != E_GUARD_OK) {
setguard(u, GUARD_NONE);
}
- else {
- attrib *a = a_find(u->attribs, &at_guard);
- if (a && a->data.i == (int)guard_flags(u)) {
- /* this is really rather not necessary */
- a_remove(&u->attribs, a);
- }
- }
}
}
}
@@ -97,50 +90,19 @@ unsigned int guard_flags(const unit * u)
#if GUARD_DISABLES_RECRUIT == 1
flags |= GUARD_RECRUIT;
#endif
- if (rc_changed(&rc_cache)) {
- rc_elf = get_race(RC_ELF);
- rc_ent = get_race(RC_TREEMAN);
- rc_ironkeeper = get_race(RC_IRONKEEPER);
- }
- if (rc == rc_elf) {
- if (u->faction->race == u_race(u)) {
- flags |= GUARD_TREES;
- }
- }
- else if (rc == rc_ent) {
- flags |= GUARD_TREES;
- }
- else if (rc == rc_ironkeeper) {
- flags = GUARD_MINING;
- }
return flags;
}
void setguard(unit * u, unsigned int flags)
{
- /* setzt die guard-flags der Einheit */
- attrib *a = NULL;
- assert(flags == 0 || !fval(u, UFL_MOVED));
- assert(flags == 0 || u->status < ST_FLEE);
- if (fval(u, UFL_GUARD)) {
- a = a_find(u->attribs, &at_guard);
- }
- if (flags == GUARD_NONE) {
+ bool enabled = (flags!=GUARD_NONE);
+ if (!enabled) {
+ assert(!fval(u, UFL_MOVED));
+ assert(u->status < ST_FLEE);
freset(u, UFL_GUARD);
- if (a)
- a_remove(&u->attribs, a);
- return;
- }
- fset(u, UFL_GUARD);
- fset(u->region, RF_GUARDED);
- if (flags == guard_flags(u)) {
- if (a)
- a_remove(&u->attribs, a);
- }
- else {
- if (!a)
- a = a_add(&u->attribs, a_new(&at_guard));
- a->data.i = (int)flags;
+ } else {
+ fset(u, UFL_GUARD);
+ fset(u->region, RF_GUARDED);
}
}
@@ -150,10 +112,6 @@ unsigned int getguard(const unit * u)
assert(fval(u, UFL_GUARD) || (u->building && u == building_owner(u->building))
|| !"you're doing it wrong! check is_guard first");
- a = a_find(u->attribs, &at_guard);
- if (a) {
- return (unsigned int)a->data.i;
- }
return guard_flags(u);
}
diff --git a/src/guard.h b/src/guard.h
index 5fe476e11..d88db3b49 100644
--- a/src/guard.h
+++ b/src/guard.h
@@ -14,10 +14,6 @@ extern "C" {
#define GUARD_NONE 0
#define GUARD_TAX 1
/* Verhindert Steuereintreiben */
-#define GUARD_MINING 2
- /* Verhindert Bergbau */
-#define GUARD_TREES 4
- /* Verhindert Waldarbeiten */
#define GUARD_TRAVELTHRU 8
/* Blockiert Durchreisende */
#define GUARD_LANDING 16
@@ -30,14 +26,10 @@ extern "C" {
/* Verhindert Abbau von Resourcen mit RTF_LIMITED */
#define GUARD_ALL 0xFFFF
- extern struct attrib_type at_guard;
-
guard_t can_start_guarding(const struct unit * u);
void update_guards(void);
- unsigned int guard_flags(const struct unit * u);
unsigned int getguard(const struct unit * u);
void setguard(struct unit * u, unsigned int flags);
-
void guard(struct unit * u, unsigned int mask);
struct unit *is_guarded(struct region *r, struct unit *u, unsigned int mask);
diff --git a/src/guard.test.c b/src/guard.test.c
index 61f08be05..149b3df01 100644
--- a/src/guard.test.c
+++ b/src/guard.test.c
@@ -27,16 +27,9 @@ static void test_is_guarded(CuTest *tc) {
r = test_create_region(0, 0, 0);
u1 = test_create_unit(test_create_faction(0), r);
u2 = test_create_unit(test_create_faction(rc), r);
- CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_TRAVELTHRU));
- CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_PRODUCE));
- CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_TREES));
- CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_MINING));
- guard(u2, GUARD_MINING | GUARD_PRODUCE);
- CuAssertIntEquals(tc, GUARD_CREWS | GUARD_LANDING | GUARD_TRAVELTHRU | GUARD_TAX | GUARD_PRODUCE | GUARD_RECRUIT, guard_flags(u2));
- CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_TRAVELTHRU));
- CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_TREES));
- CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_MINING));
- CuAssertPtrEquals(tc, u2, is_guarded(r, u1, GUARD_PRODUCE));
+ CuAssertPtrEquals(tc, 0, is_guarded(r, u1, GUARD_ALL));
+ guard(u2, GUARD_ALL);
+ CuAssertPtrEquals(tc, u2, is_guarded(r, u1, GUARD_ALL));
test_cleanup();
}
diff --git a/src/kernel/item.h b/src/kernel/item.h
index c3b33070e..26231fa2e 100644
--- a/src/kernel/item.h
+++ b/src/kernel/item.h
@@ -108,7 +108,6 @@ extern "C" {
typedef struct resource_limit {
rlimit_limit limit;
rlimit_produce produce;
- unsigned int guard; /* how to guard against theft */
int value;
resource_mod *modifiers;
} resource_limit;
diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c
index 38ead12ab..640a28940 100644
--- a/src/kernel/xmlreader.c
+++ b/src/kernel/xmlreader.c
@@ -1053,24 +1053,6 @@ static int parse_resources(xmlDocPtr doc)
}
xmlXPathFreeObject(result);
- result = xmlXPathEvalExpression(BAD_CAST "guard", xpath);
- if (result->nodesetval != NULL)
- for (k = 0; k != result->nodesetval->nodeNr; ++k) {
- xmlNodePtr node = result->nodesetval->nodeTab[k];
- xmlChar *propFlag = xmlGetProp(node, BAD_CAST "flag");
-
- if (propFlag != NULL) {
- if (strcmp((const char *)propFlag, "logging") == 0) {
- rdata->guard |= GUARD_TREES;
- }
- else if (strcmp((const char *)propFlag, "mining") == 0) {
- rdata->guard |= GUARD_MINING;
- }
- xmlFree(propFlag);
- }
- }
- xmlXPathFreeObject(result);
-
/* reading eressea/resources/resource/resourcelimit/function */
result = xmlXPathEvalExpression(BAD_CAST "function", xpath);
if (result->nodesetval != NULL)
diff --git a/src/spells.c b/src/spells.c
index 7d300c5e1..c48c777f0 100644
--- a/src/spells.c
+++ b/src/spells.c
@@ -2196,7 +2196,7 @@ static int sp_ironkeeper(castorder * co)
/*keeper->age = cast_level + 2; */
setstatus(keeper, ST_AVOID); /* kaempft nicht */
- guard(keeper, GUARD_MINING);
+ setguard(keeper, GUARD_ALL);
fset(keeper, UFL_ISNEW);
/* Parteitarnen, damit man nicht sofort weiß, wer dahinter steckt */
if (rule_stealth_anon()) {