Attached Files |
-
FloatingSlopeTolerance.patch (716 bytes) 2008-06-11 22:25
Index: UnitHandler.cpp
===================================================================
--- UnitHandler.cpp (revision 6023)
+++ UnitHandler.cpp (working copy)
@@ -381,8 +381,10 @@
}
}
}
-
- if(!unitdef->floater)
+
+ float groundheight = ground->GetHeight2(pos.x,pos.z);
+
+ if(!unitdef->floater || groundheight > 0)
{
float* heightmap=readmap->GetHeightmap();
int x=(int) (pos.x/SQUARE_SIZE);
@@ -395,12 +397,12 @@
if(pos.y<orgh-hdif && pos.y<h-hdif)
return 0;
}
- float groundheight = ground->GetHeight2(pos.x,pos.z);
+
if(!unitdef->floater && groundheight<-unitdef->maxWaterDepth)
return 0;
if(groundheight>-unitdef->minWaterDepth)
return 0;
-
+
return ret;
}
-
FloatingSlopeTolerance_01.patch (2,423 bytes) 2008-06-11 23:08
Index: UnitDefHandler.cpp
===================================================================
--- UnitDefHandler.cpp (revision 5917)
+++ UnitDefHandler.cpp (working copy)
@@ -743,7 +743,7 @@
ud.smoothAnim = udTable.GetBool("smoothAnim", false);
ud.canLoopbackAttack = udTable.GetBool("canLoopbackAttack", false);
ud.canCrash = udTable.GetBool("canCrash", true);
- ud.levelGround = udTable.GetBool("levelGround", true);
+ ud.levelGround = udTable.GetBool("levelGround", !ud.floater);
ud.strafeToAttack = udTable.GetBool("strafeToAttack", false);
Index: UnitHandler.cpp
===================================================================
--- UnitHandler.cpp (revision 6023)
+++ UnitHandler.cpp (working copy)
@@ -381,8 +381,10 @@
}
}
}
-
- if(!unitdef->floater)
+
+ float groundheight = ground->GetHeight2(pos.x,pos.z);
+
+ if(!unitdef->floater || groundheight > 0)
{
float* heightmap=readmap->GetHeightmap();
int x=(int) (pos.x/SQUARE_SIZE);
@@ -395,12 +397,12 @@
if(pos.y<orgh-hdif && pos.y<h-hdif)
return 0;
}
- float groundheight = ground->GetHeight2(pos.x,pos.z);
+
if(!unitdef->floater && groundheight<-unitdef->maxWaterDepth)
return 0;
if(groundheight>-unitdef->minWaterDepth)
return 0;
-
+
return ret;
}
Index: UnitLoader.cpp
===================================================================
--- UnitLoader.cpp (revision 5917)
+++ UnitLoader.cpp (working copy)
@@ -497,7 +497,7 @@
void CUnitLoader::FlattenGround(const CUnit* unit)
{
const UnitDef* unitDef = unit->unitDef;
- if (!mapDamage->disabled && unitDef->levelGround && !unitDef->floater &&
+ if (!mapDamage->disabled && unitDef->levelGround &&
!(unitDef->canmove && (unitDef->speed > 0.0f))) {
BuildInfo bi(unitDef, unit->pos, unit->buildFacing);
bi.pos = helper->Pos2BuildPos(bi);
Index: UnitTypes/Builder.cpp
===================================================================
--- UnitTypes/Builder.cpp (revision 6024)
+++ UnitTypes/Builder.cpp (working copy)
@@ -515,7 +515,7 @@
CUnit* b = unitLoader.LoadUnit(nextBuildType, nextBuildPos, team,
true, buildInfo.buildFacing, this);
- if (mapDamage->disabled || !unitDef->levelGround || unitDef->floater ||
+ if (mapDamage->disabled || !unitDef->levelGround ||
(unitDef->canmove && (unitDef->speed > 0.0f))) {
// skip the terraforming job.
b->terraformLeft = 0;
-
FloatingSlopeTolerance_02.patch (2,552 bytes) 2008-06-11 23:30
Index: UnitHandler.cpp
===================================================================
--- UnitHandler.cpp (revision 6023)
+++ UnitHandler.cpp (working copy)
@@ -381,8 +381,10 @@
}
}
}
-
- if(!unitdef->floater)
+
+ const float groundheight = ground->GetHeight2(pos.x,pos.z);
+
+ if(!unitdef->floater || groundheight > 0)
{
float* heightmap=readmap->GetHeightmap();
int x=(int) (pos.x/SQUARE_SIZE);
@@ -395,12 +397,12 @@
if(pos.y<orgh-hdif && pos.y<h-hdif)
return 0;
}
- float groundheight = ground->GetHeight2(pos.x,pos.z);
+
if(!unitdef->floater && groundheight<-unitdef->maxWaterDepth)
return 0;
if(groundheight>-unitdef->minWaterDepth)
return 0;
-
+
return ret;
}
Index: UnitLoader.cpp
===================================================================
--- UnitLoader.cpp (revision 5917)
+++ UnitLoader.cpp (working copy)
@@ -497,7 +497,8 @@
void CUnitLoader::FlattenGround(const CUnit* unit)
{
const UnitDef* unitDef = unit->unitDef;
- if (!mapDamage->disabled && unitDef->levelGround && !unitDef->floater &&
+ const float groundheight = ground->GetHeight2(unit->pos.x,unit->pos.z);
+ if (!mapDamage->disabled && unitDef->levelGround && !(unitDef->floater && groundheight <= 0) &&
!(unitDef->canmove && (unitDef->speed > 0.0f))) {
BuildInfo bi(unitDef, unit->pos, unit->buildFacing);
bi.pos = helper->Pos2BuildPos(bi);
Index: UnitTypes/Builder.cpp
===================================================================
--- UnitTypes/Builder.cpp (revision 6024)
+++ UnitTypes/Builder.cpp (working copy)
@@ -514,8 +514,10 @@
CUnit* b = unitLoader.LoadUnit(nextBuildType, nextBuildPos, team,
true, buildInfo.buildFacing, this);
+
+ const float groundheight = ground->GetHeight2(b->pos.x,b->pos.z);
- if (mapDamage->disabled || !unitDef->levelGround || unitDef->floater ||
+ if (mapDamage->disabled || !unitDef->levelGround || (unitDef->floater && groundheight <= 0) ||
(unitDef->canmove && (unitDef->speed > 0.0f))) {
// skip the terraforming job.
b->terraformLeft = 0;
@@ -555,8 +557,8 @@
* Duplicated from CMoveType::SlowUpdate(), which
* is why we use the regular code for floating things.
*/
- curBuild->pos.y=ground->GetHeight2(curBuild->pos.x,curBuild->pos.z);
- curBuild->midPos.y=curBuild->pos.y+curBuild->relMidPos.y;
+ curBuild->pos.y=groundheight;
+ curBuild->midPos.y=groundheight+curBuild->relMidPos.y;
}
else {
float d=nextBuildPos.y-curBuild->pos.y;
|
---|