Skip to content

Commit 7b87c72

Browse files
committed
Don't use FLT_MAX for Actor::EstimateJumpHeight
Undefined sanitizer's complaint: ../Source/System/PathFinder.cpp:176:54: runtime error: 3.40282e+38 is outside the range of representable values of type 'int' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../Source/System/PathFinder.cpp:176:54 ...Also change a comment slightly lol
1 parent 8deb20f commit 7b87c72

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Source/Entities/Actor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,8 @@ float Actor::EstimateDigStrength() const {
10471047
}
10481048

10491049
float Actor::EstimateJumpHeight() const {
1050-
return FLT_MAX;
1050+
// By default, assume actors can jump as far as the scene stretches upward, twice over.
1051+
return g_SceneMan.GetSceneHeight() * c_MPP * 2;
10511052
}
10521053

10531054
void Actor::VerifyMOIDs() {

Source/System/PathFinder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ int PathFinder::CalculatePath(Vector start, Vector end, std::list<Vector>& pathR
173173
s_JumpHeight = jumpHeight;
174174

175175
// How high up we can jump from this node
176-
s_JumpHeightVertical = std::max(1, static_cast<int>(jumpHeight / (m_NodeDimension * c_MPP))); // min of 1 so automovers work a bit better
176+
s_JumpHeightVertical = std::max(1, static_cast<int>(jumpHeight / (m_NodeDimension * c_MPP))); // at least 1 so automovers work a bit better
177177
s_JumpHeightDiagonal = std::max(1, static_cast<int>((jumpHeight * 0.7F) / (m_NodeDimension * c_MPP)));
178178

179179
// Actors capable of digging can use s_DigStrength to modify the node adjacency cost.

0 commit comments

Comments
 (0)