"giving heros to another faction"
This commit is contained in:
Enno Rehling 2007-12-19 22:11:04 +00:00
parent 1e9081a290
commit 167651abab
2 changed files with 32 additions and 3 deletions

View file

@ -49,6 +49,7 @@
#include <util/event.h>
#include <util/goodies.h>
#include <util/lists.h>
#include <util/log.h>
#include <util/resolve.h>
#include <util/rng.h>
#include <util/variant.h>
@ -524,10 +525,11 @@ free_units(void)
}
}
void
write_unit_reference(const unit * u, FILE * F)
{
assert(u->number>0);
assert(u==NULL || u->number>0);
fprintf(F, "%s ", (u!=NULL && u->no!=0)?itoa36(u->no):"0");
}
@ -1406,10 +1408,18 @@ countheroes(const struct faction * f)
{
const unit * u = f->units;
int n = 0;
int m = 0;
while (u) {
if (fval(u, UFL_HERO)) n+= u->number;
u = u->nextF;
}
#ifndef NDEBUG
m = maxheroes(f);
if (n>m) {
log_warning(("%s has %d of %d heroes\n", factionname(f), n, m));
}
#endif
return n;
}

View file

@ -277,15 +277,27 @@ faction_setorigin_x(faction& f, short x) {
f.ursprung->x = x;
}
short
static short
faction_getorigin_y(const faction& f) {
return f.ursprung->y;
}
void
static void
faction_setorigin_y(faction& f, short y) {
f.ursprung->y = y;
}
static int
faction_countheroes(const faction& f)
{
return countheroes(&f);
}
static int
faction_maxheroes(const faction& f)
{
return maxheroes(&f);
}
void
bind_faction(lua_State * L)
@ -301,9 +313,16 @@ bind_faction(lua_State * L)
.def(self == faction())
.def("set_policy", &faction_setpolicy)
.def("get_policy", &faction_getpolicy)
// temporary variables
.def("set_variable", &faction_set_variable)
.def("get_variable", &faction_get_variable)
.def("delete_variable", &faction_delete_variable)
// heroes
.def("heroes", &faction_countheroes)
.def("max_heroes", &faction_maxheroes)
.def_readonly("name", &faction::name)
.def_readonly("score", &faction::score)
.def_readonly("id", &faction::no)