diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 3a64dc121..007f2a62c 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -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; diff --git a/src/common/kernel/faction.c b/src/common/kernel/faction.c index 5df5bddef..503c10a97 100644 --- a/src/common/kernel/faction.c +++ b/src/common/kernel/faction.c @@ -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) { diff --git a/src/common/kernel/faction.h b/src/common/kernel/faction.h index eb5150c3f..3ed08bc75 100644 --- a/src/common/kernel/faction.h +++ b/src/common/kernel/faction.h @@ -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 } diff --git a/src/eressea/tolua/bind_region.c b/src/eressea/tolua/bind_region.c index b614f3f5b..c334f117d 100644 --- a/src/eressea/tolua/bind_region.c +++ b/src/eressea/tolua/bind_region.c @@ -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);