forked from github/server
Lua-Zugriff auf den item-pool
This commit is contained in:
parent
d7cb8c517e
commit
1b62f53285
|
@ -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;
|
||||
|
|
|
@ -188,6 +188,10 @@ faction_setrace(faction& f, const char * rcname)
|
|||
}
|
||||
}
|
||||
|
||||
static eressea::list<std::string, item *, eressea::bind_items>
|
||||
faction_items(const faction& f) {
|
||||
return eressea::list<std::string, item *, eressea::bind_items>(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)
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#ifndef LUA_LIST_H
|
||||
#define LUA_LIST_H
|
||||
|
||||
#include <string>
|
||||
#include <kernel/item.h>
|
||||
|
||||
namespace eressea {
|
||||
|
||||
template<class T, class N = T>
|
||||
|
@ -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
|
||||
|
|
|
@ -80,17 +80,9 @@ unit_orders(const unit& u) {
|
|||
return eressea::list<std::string, order *, bind_orders>(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<std::string, item *, bind_items>
|
||||
static eressea::list<std::string, item *, eressea::bind_items>
|
||||
unit_items(const unit& u) {
|
||||
return eressea::list<std::string, item *, bind_items>(u.items);
|
||||
return eressea::list<std::string, item *, eressea::bind_items>(u.items);
|
||||
}
|
||||
|
||||
static unit *
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue