Repository navigation
refactor: Replace _isnan and _finite with std::isnan and std::isfinite - #3686
CryoTheRenegade wants to merge 5 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. WalkthroughThe change adds a compatibility header for standard NaN and finite checks. It replaces platform-specific checks in core engine, WW3D2, Generals, and GeneralsMD code. Existing validation responses remain unchanged. ChangesMath compatibility and validation
Estimated code review effort: 2 (Simple) | ~15 minutes Change: Refactor Suggested reviewers: Merge Risk:
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The PR appears safe to merge; no actionable issues remain from this review.
|
_isnan and _finite are MSVC CRT functions from <float.h>. Use the standard functions instead. The new cmath_adapter.h gives VC6 std::isnan and std::isfinite built on _isnan and _finite, because neither VC6 nor STLport 4.5.3 has them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
de7fbee to
910c365
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…isnan wwmath.h does not call std::isnan or std::isfinite, so it should not include the adapter. The three WW3D2 files that do now include it themselves, as they do for bit_adapter.h. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The NaN checks call
_isnanand_finite, which are MSVC-only CRT functions from<float.h>. This PR replaces them with the standardstd::isnanandstd::isfinite, in the same way #3532 and #3652 added standard functions for VC6 through the adapters.<cmath>, the header it stands in for, likebit_adapter.hfor<bit>. Neither VC6 nor STLport 4.5.3 declaresisnanorisfinite. The header comment lists how the VC6 functions differ: they have onlyfloatanddoubleoverloads, and afloatis converted todoublebefore the check. That conversion keeps NaN and infinity, so the result is the same.PhysicsUpdate.cpp,Thing.cpp,AIUpdate.cpp,Object.cppandDrawable.cppin both games.GameCommon.cpp,motchan.cpp,sortingrenderer.cppandstreakRender.cppin Core._isnanis left.float, and every result is used as a condition, never as a number. The return type changing frominttobooltherefore changes nothing.<float.h>, throughPreRTS.handwwmath.h. There was no compat shim to remove.Evidence
Disassembly: ClangCL and VC6 Release objects of all changed sources, for both games, compared function by function against
main.normalizeAnglecvtss2sd+call __imp___isnanbecomes an inlineucomiss x, x; jp(43 → 35 instructions)Object::reactToTransformChangePhysicsBehavior::applyForcePhysicsBehavior::updatedtor$cleanup funclets change only their frame offsetsPhysicsBehavior::applyRandomRotation(Zero Hour)__LINE__arguments toGameLogicRandomValueRealgo up by 1, because a brace moved to its own line aboveObject::updateObjValuesFromMapProperties(Generals)ucomiss x, xsets the parity flag exactly whenxis NaN, so each check returns the same value as before. All other float arithmetic in these functions is the same asmain. The__LINE__argument ofGetGameLogicRandomValueRealis used only in itsDEBUG_LOG. Apart from the two rows above, VC6 generates identical code in every object.Claude Opus 5.5 was used to aid in implementation and disassembly
Council review
Rounds: 2