Index: C:/Games/glest-src/meglest-src/source/glest_game/world/unit_updater.cpp
===================================================================
--- C:/Games/glest-src/meglest-src/source/glest_game/world/unit_updater.cpp (revision 1614)
+++ C:/Games/glest-src/meglest-src/source/glest_game/world/unit_updater.cpp (working copy)
@@ -1494,8 +1494,8 @@
const MorphCommandType *mct= static_cast<const MorphCommandType*>(command->getCommandType());
if(unit->getCurrSkill()->getClass()!=scMorph){
- //if not morphing, check space
- if(map->isFreeCellsOrHasUnit(unit->getPos(), mct->getMorphUnit()->getSize(), unit->getCurrField(), unit)){
+ //if not morphing
+ if(map->isFreeCellsOrHasUnit(unit->getPos(), mct->getMorphUnit()->getSize(), unit->getCurrField(), unit, mct->getMorphUnit())){
unit->setCurrSkill(mct->getMorphSkillType());
}
else{
Index: C:/Games/glest-src/meglest-src/source/glest_game/world/map.h
===================================================================
--- C:/Games/glest-src/meglest-src/source/glest_game/world/map.h (revision 1614)
+++ C:/Games/glest-src/meglest-src/source/glest_game/world/map.h (working copy)
@@ -212,7 +212,7 @@
bool isFreeCellOrHasUnit(const Vec2i &pos, Field field, const Unit *unit) const;
bool isAproxFreeCell(const Vec2i &pos, Field field, int teamIndex) const;
bool isFreeCells(const Vec2i &pos, int size, Field field) const;
- bool isFreeCellsOrHasUnit(const Vec2i &pos, int size, Field field, const Unit *unit) const;
+ bool isFreeCellsOrHasUnit(const Vec2i &pos, int size, Field field, const Unit *unit, const UnitType *munit) const;
bool isAproxFreeCells(const Vec2i &pos, int size, Field field, int teamIndex) const;
bool canOccupy(const Vec2i &pos, Field field, const UnitType *ut, CardinalDir facing);
Index: C:/Games/glest-src/meglest-src/source/glest_game/world/map.cpp
===================================================================
--- C:/Games/glest-src/meglest-src/source/glest_game/world/map.cpp (revision 1614)
+++ C:/Games/glest-src/meglest-src/source/glest_game/world/map.cpp (working copy)
@@ -430,18 +430,29 @@
}
return true;
}
-
-bool Map::isFreeCellsOrHasUnit(const Vec2i &pos, int size, Field field, const Unit *unit) const {
- for(int i=pos.x; i<pos.x+size; ++i) {
- for(int j=pos.y; j<pos.y+size; ++j) {
- if(isFreeCellOrHasUnit(Vec2i(i,j), field, unit) == false) {
+bool Map::isFreeCellsOrHasUnit(const Vec2i &pos, int size, Field field, const Unit *unit, const UnitType *munit) const {
+for(int i=1; i <= munit->getSize(); ++i){
+ for(int j = 1; j <= munit->getSize(); ++j) {
+ if(munit->hasCellMap() == true){
+ if(munit->getCellMapCell(i-1,j-1,unit->getModelFacing())== true){
+ if(isFreeCellOrHasUnit(Vec2i(pos.x + i -1,pos.y + j -1), field, unit) == false) {
+ return false;
+ }
+ else{
+ }
+ }else{
+ }
+ }else{
+ //for(int i=pos.x; i<pos.x+size; ++i) {
+ //for(int j=pos.y; j<pos.y+size; ++j) {
+ if(isFreeCellOrHasUnit(Vec2i(pos.x + i -1,pos.y + j -1), field, unit) == false) {
return false;
}
}
}
+}
return true;
}
-
bool Map::isAproxFreeCells(const Vec2i &pos, int size, Field field, int teamIndex) const {
for(int i=pos.x; i<pos.x+size; ++i) {
for(int j=pos.y; j<pos.y+size; ++j) {
Index: C:/Games/glest-src/meglest-src/source/glest_game/type_instances/unit.cpp
===================================================================
--- C:/Games/glest-src/meglest-src/source/glest_game/type_instances/unit.cpp (revision 1614)
+++ C:/Games/glest-src/meglest-src/source/glest_game/type_instances/unit.cpp (working copy)
@@ -1401,7 +1401,7 @@
Field morphUnitField=fLand;
if(morphUnitType->getField(fAir)) morphUnitField=fAir;
if(morphUnitType->getField(fLand)) morphUnitField=fLand;
- if(map->isFreeCellsOrHasUnit(pos, morphUnitType->getSize(), morphUnitField, this)){
+ if(map->isFreeCellsOrHasUnit(pos, morphUnitType->getSize(), morphUnitField, this,morphUnitType)){
map->clearUnitCells(this, pos);
faction->deApplyStaticCosts(type);