beyond-all-reason / beyond-all-reason/RecoilEngine

Round integers (frames etc) instead of truncating

Open
#2,018 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
679
Forks
290
Avg merge
3d 1h
Merged PRs (30d)
38

Description

The engine sometimes converts floats received from Lua into integers, most commonly to convert time into frames.
For example:
https://github.com/beyond-all-reason/RecoilEngine/blob/5e4cf02f7afc796aac72be0c5a10338230bc4378/rts/Sim/Weapons/WeaponLoader.cpp#L149
https://github.com/beyond-all-reason/RecoilEngine/blob/5e4cf02f7afc796aac72be0c5a10338230bc4378/rts/Lua/LuaSyncedCtrl.cpp#L2254-L2255

The issue with this is that calculations can sometimes produce a value epsilon less than desired due to float precision limits, and then this shifts the resulting value a whole step downwards. The better interface would be to round instead.

Contributor guide

Open the contributing guide

Research direction

Start at the cited conversions in rts/Sim/Weapons/WeaponLoader.cpp around line 149 and rts/Lua/LuaSyncedCtrl.cpp around lines 2254-2255. Inspect how Lua-provided floats become integer frame values and look for similar conversions in the engine. Done means the affected conversions round values instead of truncating them, avoiding epsilon-related downward shifts.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.