- new island creation lua exports

- bugfix recruit heroes
This commit is contained in:
Enno Rehling 2009-07-13 22:08:58 +00:00
parent e129125a90
commit 3b2e28402b
4 changed files with 30 additions and 1 deletions

View File

@ -2313,7 +2313,7 @@ promotion_cmd(unit * u, struct order * ord)
maxheroes(u->faction), countheroes(u->faction)));
return 0;
}
if (u->race!=u->faction->race) {
if (valid_race(u->faction, u->race)) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "heroes_race", "race",
u->race));
return 0;

View File

@ -461,6 +461,15 @@ faction_setpassword(faction * f, const char * passw)
else f->passw = strdup(itoa36(rng_int()));
}
boolean valid_race(const struct faction * f, const struct race * rc)
{
if (f->race==rc) return true;
else {
const char * str = get_param(f->race->parameters, "other_race");
return (str?rc_find(str)==rc:false);
}
}
const char *
faction_getpassword(const faction * f)
{

View File

@ -144,6 +144,7 @@ void faction_setemail(struct faction * self, const char * email);
const char * faction_getpassword(const struct faction * self);
void faction_setpassword(struct faction * self, const char * password);
boolean valid_race(const struct faction * f, const struct race * rc);
#ifdef __cplusplus
}

View File

@ -76,6 +76,14 @@ tolua_region_get_y(lua_State* L)
return 1;
}
static int
tolua_region_get_plane(lua_State* L)
{
region * r = (region *)tolua_tousertype(L, 1, 0);
tolua_pushusertype(L, rplane(r), TOLUA_CAST "plane");
return 1;
}
static int
tolua_region_get_terrain(lua_State* L)
{
@ -462,6 +470,15 @@ tolua_plane_tostring(lua_State *L)
return 1;
}
static int
tolua_plane_get_size(lua_State *L)
{
plane * pl = (plane *)tolua_tousertype(L, 1, 0);
lua_pushnumber(L, plane_width(pl));
lua_pushnumber(L, plane_height(pl));
return 2;
}
static int
tolua_distance(lua_State *L)
{
@ -502,6 +519,7 @@ tolua_region_open(lua_State* L)
tolua_variable(L, TOLUA_CAST "id", tolua_region_get_id, NULL);
tolua_variable(L, TOLUA_CAST "x", tolua_region_get_x, NULL);
tolua_variable(L, TOLUA_CAST "y", tolua_region_get_y, NULL);
tolua_variable(L, TOLUA_CAST "plane", tolua_region_get_plane, NULL);
tolua_variable(L, TOLUA_CAST "name", tolua_region_get_name, tolua_region_set_name);
tolua_variable(L, TOLUA_CAST "info", tolua_region_get_info, tolua_region_set_info);
tolua_variable(L, TOLUA_CAST "units", tolua_region_get_units, NULL);
@ -544,6 +562,7 @@ tolua_region_open(lua_State* L)
tolua_function(L, TOLUA_CAST "get", tolua_plane_get);
tolua_function(L, TOLUA_CAST "__tostring", tolua_plane_tostring);
tolua_function(L, TOLUA_CAST "size", tolua_plane_get_size);
tolua_variable(L, TOLUA_CAST "id", tolua_plane_get_id, NULL);
tolua_function(L, TOLUA_CAST "normalize", tolua_plane_normalize);
tolua_variable(L, TOLUA_CAST "name", tolua_plane_get_name, tolua_plane_set_name);