Exporting more data for units (number, race)

This commit is contained in:
Enno Rehling 2004-02-16 23:58:47 +00:00
parent 58595fc001
commit d996889339
2 changed files with 19 additions and 3 deletions

View File

@ -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)));
}

View File

@ -5,6 +5,7 @@
#include <attributes/racename.h>
// kernel includes
#include <kernel/race.h>
#include <kernel/region.h>
#include <kernel/item.h>
#include <kernel/faction.h>
@ -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_<struct unit>("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)
];
}