Resources can now be deposited at flying units, by land or air units. This fixes issue #100 .

This commit is contained in:
Jammyjamjamman 2018-03-30 02:42:45 +01:00
parent 50de66d6da
commit 01454a32e5
No known key found for this signature in database
GPG Key ID: A5541C132A56EAB4

View File

@ -1553,7 +1553,7 @@ bool Map::isNextTo(const Vec2i &pos, const Unit *unit) const {
return false;
}
//return if unit is next to pos
// Check if a unit is next to another particular unit.
bool Map::isNextTo(const Unit *unit1, const Unit *unit2) const {
Vec2i pos = unit1->getPosNotThreadSafe();
const UnitType *ut = unit1->getType();
@ -1561,10 +1561,11 @@ bool Map::isNextTo(const Unit *unit1, const Unit *unit2) const {
for (int x=-1; x < ut->getSize()+1; ++x) {
Vec2i cellPos = pos + Vec2i(x, y);
if(isInside(cellPos) && isInsideSurface(toSurfCoords(cellPos))) {
if(getCell(cellPos)->getUnit(fLand) == unit2) {
// Check if unit 2 is at that position, on land or air.
if(getCell(cellPos)->getUnit(fLand) == unit2 || getCell(cellPos)->getUnit(fAir) == unit2) {
return true;
}
else if(getCell(cellPos)->getUnitWithEmptyCellMap(fLand) == unit2) {
else if(getCell(cellPos)->getUnitWithEmptyCellMap(fLand) == unit2 || getCell(cellPos)->getUnitWithEmptyCellMap(fAir) == unit2) {
return true;
}
}