fix a crash in select script functions
This commit is contained in:
parent
da3703e90a
commit
4e402a7721
3 changed files with 26 additions and 0 deletions
src
|
@ -178,6 +178,13 @@ static int CclGetNumUnitsAt(lua_State *l)
|
|||
CclGetPos(l, &minPos.x, &minPos.y, 3);
|
||||
CclGetPos(l, &maxPos.x, &maxPos.y, 4);
|
||||
|
||||
if (minPos.x > maxPos.x) {
|
||||
std::swap(minPos.x, maxPos.x);
|
||||
}
|
||||
if (minPos.y > maxPos.y) {
|
||||
std::swap(minPos.y, maxPos.y);
|
||||
}
|
||||
|
||||
std::vector<CUnit *> units;
|
||||
|
||||
Select(minPos, maxPos, units);
|
||||
|
|
|
@ -361,6 +361,13 @@ static int CclChangeUnitsOwner(lua_State *l)
|
|||
Vec2i pos2;
|
||||
CclGetPos(l, &pos1.x, &pos1.y, 1);
|
||||
CclGetPos(l, &pos2.x, &pos2.y, 2);
|
||||
if (pos1.x > pos2.x) {
|
||||
std::swap(pos1.x, pos2.x);
|
||||
}
|
||||
if (pos1.y > pos2.y) {
|
||||
std::swap(pos1.y, pos2.y);
|
||||
}
|
||||
|
||||
const int oldp = LuaToNumber(l, 3);
|
||||
const int newp = LuaToNumber(l, 4);
|
||||
std::vector<CUnit *> table;
|
||||
|
@ -450,6 +457,12 @@ static int CclGiveUnitsToPlayer(lua_State *l)
|
|||
Vec2i pos2;
|
||||
CclGetPos(l, &pos1.x, &pos1.y, 3);
|
||||
CclGetPos(l, &pos2.x, &pos2.y, 4);
|
||||
if (pos1.x > pos2.x) {
|
||||
std::swap(pos1.x, pos2.x);
|
||||
}
|
||||
if (pos1.y > pos2.y) {
|
||||
std::swap(pos1.y, pos2.y);
|
||||
}
|
||||
if (any) {
|
||||
Select(pos1, pos2, table, HasSamePlayerAs(Players[oldp]));
|
||||
} else if (onlyUnits) {
|
||||
|
|
|
@ -1024,6 +1024,12 @@ static int CclKillUnitAt(lua_State *l)
|
|||
Vec2i pos2;
|
||||
CclGetPos(l, &pos1.x, &pos1.y, 4);
|
||||
CclGetPos(l, &pos2.x, &pos2.y, 5);
|
||||
if (pos1.x > pos2.x) {
|
||||
std::swap(pos1.x, pos2.x);
|
||||
}
|
||||
if (pos1.y > pos2.y) {
|
||||
std::swap(pos1.y, pos2.y);
|
||||
}
|
||||
|
||||
std::vector<CUnit *> table;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue