From 4cbeb03590a87cb86275c08bd69eb11fe33ec9c1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Jan 2017 18:35:54 +0100 Subject: [PATCH] clean the quipment interface for lua a little bit. --- conf/e2/config.xml | 2 +- src/bindings.c | 18 ------------------ src/kernel/faction.c | 6 ++++++ 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/conf/e2/config.xml b/conf/e2/config.xml index 5affea141..8389ba470 100644 --- a/conf/e2/config.xml +++ b/conf/e2/config.xml @@ -29,7 +29,7 @@ - + diff --git a/src/bindings.c b/src/bindings.c index fad958cd4..b6be1ccba 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -319,23 +319,6 @@ static int tolua_dice_rand(lua_State * L) return 1; } -static int tolua_addequipment(lua_State * L) -{ - const char *eqname = tolua_tostring(L, 1, 0); - const char *iname = tolua_tostring(L, 2, 0); - const char *value = tolua_tostring(L, 3, 0); - int result = -1; - if (iname != NULL) { - const struct item_type *itype = it_find(iname); - if (itype != NULL) { - equipment_setitem(get_or_create_equipment(eqname), itype, value); - result = 0; - } - } - lua_pushinteger(L, result); - return 1; -} - static int tolua_get_season(lua_State * L) { int turnno = (int)tolua_tonumber(L, 1, 0); @@ -1112,7 +1095,6 @@ int tolua_bindings_open(lua_State * L, const dictionary *inifile) tolua_function(L, TOLUA_CAST "get_season", tolua_get_season); tolua_function(L, TOLUA_CAST "equipment_setitem", tolua_equipment_setitem); tolua_function(L, TOLUA_CAST "equip_unit", tolua_equipunit); - tolua_function(L, TOLUA_CAST "add_equipment", tolua_addequipment); tolua_function(L, TOLUA_CAST "atoi36", tolua_atoi36); tolua_function(L, TOLUA_CAST "itoa36", tolua_itoa36); tolua_function(L, TOLUA_CAST "dice_roll", tolua_dice_rand); diff --git a/src/kernel/faction.c b/src/kernel/faction.c index e884a2d9b..d67619752 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -22,6 +22,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "alliance.h" #include "ally.h" #include "curse.h" +#include "equipment.h" #include "group.h" #include "item.h" #include "messages.h" @@ -286,10 +287,15 @@ faction *addfaction(const char *email, const char *password, unit *addplayer(region * r, faction * f) { unit *u; + const struct equipment* eq; assert(f->units == NULL); faction_setorigin(f, 0, r->x, r->y); u = create_unit(r, f, 1, f->race, 0, NULL, NULL); + eq = get_equipment("first_unit"); + if (eq) { + equip_items(&u->items, eq); + } u->hp = unit_max_hp(u) * u->number; fset(u, UFL_ISNEW); if (f->race == get_race(RC_DAEMON)) {