Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpRangeManager.cpp
Show First 20 Lines • Show All 1,253 Lines • ▼ Show 20 Lines | else | ||||
continue; | continue; | ||||
r.push_back(it->first); | r.push_back(it->first); | ||||
} | } | ||||
std::sort(r.begin(), r.end()); | std::sort(r.begin(), r.end()); | ||||
} | } | ||||
} | } | ||||
virtual entity_pos_t GetEffectiveParabolicRange(entity_id_t source, entity_id_t target, entity_pos_t range, entity_pos_t elevationBonus) const | |||||
{ | |||||
CmpPtr<ICmpPosition> cmpSourcePosition(GetSimContext(), source); | |||||
if (!cmpSourcePosition || !cmpSourcePosition->IsInWorld()) | |||||
return entity_pos_t::FromInt(-1); | |||||
vladislavbelov: Constant for `entity_pos_t::FromInt(-1)`. | |||||
CmpPtr<ICmpPosition> cmpTargetPosition(GetSimContext(), target); | |||||
if (!cmpTargetPosition || !cmpTargetPosition->IsInWorld()) | |||||
return entity_pos_t::FromInt(-1); | |||||
entity_pos_t h = cmpSourcePosition->GetHeightOffset() - cmpTargetPosition->GetHeightOffset() + elevationBonus; | |||||
Done Inline Actionsconst entity_pos_t h = ..., what does the h mean? vladislavbelov: `const entity_pos_t h = ...`, what does the `h` mean? | |||||
if (h < -range / 2) | |||||
return entity_pos_t::FromInt(-1); | |||||
return (range.Square() + range.Multiply(h).Multiply(entity_pos_t::FromInt(2))).Sqrt(); | |||||
Done Inline ActionsThis can overflow, do we need to care? bb: This can overflow, do we need to care? | |||||
Not Done Inline ActionsI would say yes. The maximal value a fixed can hold is 65536, which is rather low when squaring stuff. A range of 260 will fail, and that doesn't seem outside the range we should support. wraitii: I would say yes. The maximal value a fixed can hold is 65536, which is rather low when squaring… | |||||
Done Inline ActionsWhat does the r mean? vladislavbelov: What does the `r` mean? | |||||
} | |||||
Not Done Inline Actionswhat will be result of isqrt64 from negative number? Silier: what will be result of isqrt64 from negative number? | |||||
Done Inline ActionsAs it seems an infinite loop, and hence blatant crash, noone has a clue about why it happened. If we want to fix this, it should be fixed generically in the isqrt64 function (any instance of the function might have this problem). Feel free to create a ticket. In this case, negative values are protected by the check above. bb: As it seems an infinite loop, and hence blatant crash, noone has a clue about why it happened. | |||||
virtual entity_pos_t GetElevationAdaptedRange(const CFixedVector3D& pos1, const CFixedVector3D& rot, entity_pos_t range, entity_pos_t elevationBonus, entity_pos_t angle) const | virtual entity_pos_t GetElevationAdaptedRange(const CFixedVector3D& pos1, const CFixedVector3D& rot, entity_pos_t range, entity_pos_t elevationBonus, entity_pos_t angle) const | ||||
{ | { | ||||
entity_pos_t r = entity_pos_t::Zero(); | entity_pos_t r = entity_pos_t::Zero(); | ||||
CFixedVector3D pos(pos1); | CFixedVector3D pos(pos1); | ||||
pos.Y += elevationBonus; | pos.Y += elevationBonus; | ||||
entity_pos_t orientation = rot.Y; | entity_pos_t orientation = rot.Y; | ||||
▲ Show 20 Lines • Show All 1,213 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Constant for entity_pos_t::FromInt(-1).