diff --git a/res/core/resources/hp.xml b/res/core/resources/hp.xml
index fb1b6e32f..aa0ad4d29 100644
--- a/res/core/resources/hp.xml
+++ b/res/core/resources/hp.xml
@@ -1,5 +1,4 @@
-
diff --git a/res/core/resources/peasant.xml b/res/core/resources/peasant.xml
index 32e1e1ca1..bce23430c 100644
--- a/res/core/resources/peasant.xml
+++ b/res/core/resources/peasant.xml
@@ -1,5 +1,4 @@
-
diff --git a/res/e3a/weapons.xml b/res/e3a/weapons.xml
index 96a987b28..fdc8f1f3a 100644
--- a/res/e3a/weapons.xml
+++ b/res/e3a/weapons.xml
@@ -4,13 +4,13 @@
-
+
diff --git a/res/e3a/weapons/rep_crossbow.xml b/res/e3a/weapons/rep_crossbow.xml
new file mode 100644
index 000000000..02f0d865f
--- /dev/null
+++ b/res/e3a/weapons/rep_crossbow.xml
@@ -0,0 +1,15 @@
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/scripts/eressea/resources.lua b/scripts/eressea/resources.lua
index 588620aa4..fa6e1c4da 100644
--- a/scripts/eressea/resources.lua
+++ b/scripts/eressea/resources.lua
@@ -1,9 +1,5 @@
-- global functions used in items.xml
-function peasant_getresource(u)
- return u.region:get_resource("peasant")
-end
-
function peasant_changeresource(u, delta)
local p = u.region:get_resource("peasant")
p = p + delta
@@ -14,10 +10,6 @@ function peasant_changeresource(u, delta)
return p
end
-function hp_getresource(u)
- return u.hp
-end
-
function hp_changeresource(u, delta)
local hp = u.hp + delta
diff --git a/src/helpers.c b/src/helpers.c
index a4746461b..402ecdd48 100644
--- a/src/helpers.c
+++ b/src/helpers.c
@@ -496,13 +496,13 @@ use_item_lua(unit *u, const item_type *itype, int amount, struct order *ord)
}
return result;
}
+ lua_pop(L, 1);
if (itype->rtype->ptype) {
return use_potion(u, itype, amount, ord);
} else {
log_error("no such callout: %s", fname);
}
log_error("use(%s) calling '%s': not a function.\n", unitname(u), fname);
- lua_pop(L, 1);
return result;
}
diff --git a/src/kernel/item.h b/src/kernel/item.h
index dda0cf3e4..77fe1a9c2 100644
--- a/src/kernel/item.h
+++ b/src/kernel/item.h
@@ -68,8 +68,6 @@ extern "C" {
typedef int(*rtype_uchange) (struct unit * user,
const struct resource_type * rtype, int delta);
- typedef int(*rtype_uget) (const struct unit * user,
- const struct resource_type * rtype);
typedef char *(*rtype_name) (const struct resource_type * rtype, int flags);
typedef struct resource_type {
/* --- constants --- */
@@ -77,7 +75,6 @@ extern "C" {
unsigned int flags;
/* --- functions --- */
rtype_uchange uchange;
- rtype_uget uget;
rtype_name name;
struct rawmaterial_type *raw;
struct resource_mod *modifiers;
diff --git a/src/kernel/pool.c b/src/kernel/pool.c
index 702f86e0f..8dfd589c3 100644
--- a/src/kernel/pool.c
+++ b/src/kernel/pool.c
@@ -40,11 +40,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
int get_resource(const unit * u, const resource_type * rtype)
{
assert(rtype);
- if (rtype->uget) {
- /* this resource is probably special */
- int i = rtype->uget(u, rtype);
- if (i >= 0)
- return i;
+ if (rtype == get_resourcetype(R_PEASANT)) {
+ return u->region->land ? u->region->land->peasants : 0;
+ }
+ else if (rtype == rt_find("hp")) {
+ return u->hp;
}
else if (rtype->uchange) {
/* this resource is probably special */
@@ -176,7 +176,7 @@ int count)
}
if (rtype->flags & RTF_POOLED && mode & ~(GET_SLACK | GET_RESERVE)) {
for (v = r->units; v && use < count; v = v->next)
- if (u != v && (v->items || rtype->uget)) {
+ if (u != v) {
int mask;
if ((u_race(v)->ec_flags & ECF_KEEP_ITEM))
@@ -234,8 +234,6 @@ use_pooled(unit * u, const resource_type * rtype, unsigned int mode, int count)
int mask;
if ((u_race(v)->ec_flags & ECF_KEEP_ITEM))
continue;
- if (v->items == NULL && rtype->uget == NULL)
- continue;
if (v->faction == f) {
mask = (mode >> 3) & (GET_SLACK | GET_RESERVE);
diff --git a/src/kernel/region.c b/src/kernel/region.c
index aefffa875..e4f33db33 100644
--- a/src/kernel/region.c
+++ b/src/kernel/region.c
@@ -38,6 +38,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "unit.h"
/* util includes */
+#include
#include
#include
#include
@@ -697,6 +698,7 @@ void r_setdemand(region * r, const luxury_type * ltype, int value)
d = *dp;
if (!d) {
d = *dp = malloc(sizeof(struct demand));
+ assert_alloc(d);
d->next = NULL;
d->type = ltype;
}
@@ -768,6 +770,7 @@ region *new_region(int x, int y, struct plane *pl, int uid)
return r;
}
r = calloc(1, sizeof(region));
+ assert_alloc(r);
r->x = x;
r->y = y;
r->uid = uid;
diff --git a/src/kernel/save.c b/src/kernel/save.c
index 8316121f3..e487737f9 100644
--- a/src/kernel/save.c
+++ b/src/kernel/save.c
@@ -52,6 +52,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include
/* util includes */
+#include
#include
#include
#include
@@ -646,6 +647,7 @@ unit *read_unit(struct gamedata *data)
}
else {
u = calloc(sizeof(unit), 1);
+ assert_alloc(u);
u->no = n;
uhash(u);
}
diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c
index aabab91d6..4db528853 100644
--- a/src/kernel/xmlreader.c
+++ b/src/kernel/xmlreader.c
@@ -972,9 +972,6 @@ static int parse_resources(xmlDocPtr doc)
if (strcmp((const char *)propValue, "change") == 0) {
rtype->uchange = (rtype_uchange)fun;
}
- else if (strcmp((const char *)propValue, "get") == 0) {
- rtype->uget = (rtype_uget)fun;
- }
else if (strcmp((const char *)propValue, "name") == 0) {
rtype->name = (rtype_name)fun;
}