Fixed wesnoth.is_enemy returning wrong results. (patch #1981 by FAAB)
This commit is contained in:
parent
74bf602d15
commit
ecf812f22d
2 changed files with 7 additions and 4 deletions
|
@ -1264,11 +1264,11 @@ static int intf_require(lua_State *L)
|
|||
*/
|
||||
static int intf_is_enemy(lua_State *L)
|
||||
{
|
||||
unsigned side_1 = luaL_checkint(L, 1) - 1;
|
||||
unsigned side_2 = luaL_checkint(L, 2) - 1;
|
||||
unsigned side_1 = luaL_checkint(L, 1);
|
||||
unsigned side_2 = luaL_checkint(L, 2);
|
||||
std::vector<team> &teams = *resources::teams;
|
||||
if (side_1 >= teams.size() || side_2 >= teams.size()) return 0;
|
||||
lua_pushboolean(L, teams[side_1].is_enemy(side_2));
|
||||
if (side_1 > teams.size() || side_2 > teams.size()) return 0;
|
||||
lua_pushboolean(L, teams[side_1 - 1].is_enemy(side_2));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -181,6 +181,9 @@ public:
|
|||
const t_string& objectives() const { return info_.objectives; }
|
||||
bool objectives_changed() const { return info_.objectives_changed; }
|
||||
|
||||
/**
|
||||
* arg n: a side number to compare to
|
||||
*/
|
||||
bool is_enemy(int n) const {
|
||||
const size_t index = size_t(n-1);
|
||||
if(index < enemies_.size()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue