diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 57102f049..da798dfd1 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -1192,10 +1192,10 @@ count_all(const faction * f) if (f->num_people != n) { log_error(("Anzahl Personen für (%s) ist != num_people: %d statt %d.\n", factionid(f), f->num_migrants, n)); - f->num_people = n; + return n; } #endif - return n; + return f->num_people; } int @@ -1216,7 +1216,7 @@ count_migrants (const faction * f) if (f->num_migrants != n) { log_error(("Anzahl Migranten für (%s) ist != num_migrants: %d statt %d.\n", factionid(f), f->num_migrants, n)); - f->num_migrants = n; + return n; } #endif return f->num_migrants; diff --git a/src/eressea/lua/faction.cpp b/src/eressea/lua/faction.cpp index 3a78b1298..f105a5a90 100644 --- a/src/eressea/lua/faction.cpp +++ b/src/eressea/lua/faction.cpp @@ -188,6 +188,10 @@ faction_setrace(faction& f, const char * rcname) } } +static eressea::list +faction_items(const faction& f) { + return eressea::list(f.items); +} void bind_faction(lua_State * L) @@ -213,7 +217,10 @@ bind_faction(lua_State * L) .def_readwrite("age", &faction::age) .def_readwrite("subscription", &faction::subscription) .def_readwrite("lastturn", &faction::lastorders) + .def("add_item", &faction_additem) + .property("items", &faction_items, return_stl_iterator) + .def("add_notice", &faction_addnotice) .property("locale", &faction_getlocale, &faction_setlocale) .property("units", &faction_units, return_stl_iterator) diff --git a/src/eressea/lua/list.h b/src/eressea/lua/list.h index 1951d8330..7e68f2096 100644 --- a/src/eressea/lua/list.h +++ b/src/eressea/lua/list.h @@ -1,6 +1,9 @@ #ifndef LUA_LIST_H #define LUA_LIST_H +#include +#include + namespace eressea { template @@ -36,6 +39,14 @@ namespace eressea { N m_clist; }; + class bind_items { + public: + static item * next(item * node) { return node->next; } + static std::string value(item * node) { + return std::string(node->type->rtype->_name[0]); + } + }; + }; #endif diff --git a/src/eressea/lua/unit.cpp b/src/eressea/lua/unit.cpp index a0d1ce3a6..c55e1c8e1 100644 --- a/src/eressea/lua/unit.cpp +++ b/src/eressea/lua/unit.cpp @@ -80,17 +80,9 @@ unit_orders(const unit& u) { return eressea::list(u.orders); } -class bind_items { -public: - static item * next(item * node) { return node->next; } - static std::string value(item * node) { - return std::string(node->type->rtype->_name[0]); - } -}; - -static eressea::list +static eressea::list unit_items(const unit& u) { - return eressea::list(u.items); + return eressea::list(u.items); } static unit * diff --git a/src/mapper/map_modify.c b/src/mapper/map_modify.c index 5c50a4e60..0f9f0282e 100644 --- a/src/mapper/map_modify.c +++ b/src/mapper/map_modify.c @@ -441,7 +441,7 @@ create_region_menu(menulist ** menu, region * r) f->num_people = f->no_units = 0; for (u = r->units; u; u = u->next) { u->faction->no_units++; - u->faction->num_people += u->number; + u->faction->num_people += u->number; } addmenulist(menu, buf, 0); diff --git a/src/mapper/map_partei.c b/src/mapper/map_partei.c index 7a5f06cbd..e74218558 100644 --- a/src/mapper/map_partei.c +++ b/src/mapper/map_partei.c @@ -602,7 +602,7 @@ ParteiListe(void) u->faction->nregions++; } u->faction->nunits++; - u->faction->num_people += u->number; + u->faction->num_people += u->number; u->faction->money += get_money(u); } }