From d99688933918a1c847d9821b95bc0f7aed9c6da8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 16 Feb 2004 23:58:47 +0000 Subject: [PATCH] Exporting more data for units (number, race) --- src/eressea/korrektur.c | 4 +--- src/eressea/lua/unit.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/eressea/korrektur.c b/src/eressea/korrektur.c index baf2bd784..0c9c510f2 100644 --- a/src/eressea/korrektur.c +++ b/src/eressea/korrektur.c @@ -1124,12 +1124,10 @@ fix_dissolve(unit * u, int value, char mode) { attrib * a = a_find(u->attribs, &at_unitdissolve); - unused(value); - if (a!=NULL) return; a = a_add(&u->attribs, a_new(&at_unitdissolve)); a->data.ca[0] = mode; - a->data.ca[1] = 100; + a->data.ca[1] = value; log_warning(("unit %s has race %s and no dissolve-attrib\n", unitname(u), rc_name(u->race, 0))); } diff --git a/src/eressea/lua/unit.cpp b/src/eressea/lua/unit.cpp index 95f429c0b..0a34483b0 100644 --- a/src/eressea/lua/unit.cpp +++ b/src/eressea/lua/unit.cpp @@ -5,6 +5,7 @@ #include // kernel includes +#include #include #include #include @@ -100,6 +101,21 @@ unit_setskill(unit& u, const char * skname, int level) return -1; } +static const char * +unit_getrace(const unit& u) +{ + return u.race->_name[0]; +} + +static void +unit_setrace(unit& u, const char * rcname) +{ + race * rc = rc_find(rcname); + if (rc!=NULL) { + u.race = rc; + } +} + void bind_unit(lua_State * L) { @@ -109,6 +125,7 @@ bind_unit(lua_State * L) class_("unit") .def_readonly("name", &unit::name) + .def_readonly("size", &unit::number) .def_readonly("region", &unit::region) .def_readonly("faction", &unit::faction) .def_readonly("id", &unit::no) @@ -119,5 +136,6 @@ bind_unit(lua_State * L) .def("set_skill", &unit_setskill) .def("set_racename", &unit_setracename) .property("number", &unit_getnumber, &unit_setnumber) + .property("race", &unit_getrace, &unit_setrace) ]; }