Skip to content

Second attempt of porting HeXen: Edge Of Chaos#45

Draft
DanielGibson wants to merge 18 commits intoupdatefrom
eoc
Draft

Second attempt of porting HeXen: Edge Of Chaos#45
DanielGibson wants to merge 18 commits intoupdatefrom
eoc

Conversation

@DanielGibson
Copy link
Member

@DanielGibson DanielGibson commented Jan 7, 2026

Based on @LegendaryGuard's #32 but fixes several issues and has a more concise commit history.

This PR is kind of fake: the branch already is at its final place (has its final name and is in this repo), but I figured that it would be easier to discuss it here we code changes can be easily commented on.

@DanielGibson
Copy link
Member Author

based on their patch for the original SDK
(without their changes to d3xp/, because their game DLL is built from
 game/)

Doesn't work yet, I only fixed merge conflicts.
There were some bigger changes (and conflicts) in Player_local.h,
I hope I didn't break anything.. if some variable is missing after all,
check out the original code (for the Doom3 SDK)
did small adjustments to formatting in the README
it caused an assertion (`assert(data)`) when starting a level because
it wasn't linked. when linking it it causes
> ERROR: Missing 'AI_ATTACK2_HELD' field in script object 'player'
which indicates that the scripts don't support it, so I just commented
it out completely
so they have deterministic values.
fixes NaN-related trouble in the first level
the old code would read out of bounds and then most probably do nothing,
or if surprisingly rocks[i] == NULL it would dereference that pointer

.. which would've blown up, but not as intended, höhö
script variables must be linked before they're used.
like I just did in main dhewm3, it triggered when loading the swamp
@LegendaryGuard
Copy link

LegendaryGuard commented Jan 7, 2026

Nice work! Thanks, I couldn't find out what's wrong all that time!

Please apply to fix the crash for the item pickups:
e790cb9

LegendaryGuard and others added 2 commits January 7, 2026 18:59
`assert( idStr::Icmpn( soundName, "snd_", 4 ) == 0 );`

happens when trying to use god cheat..
nothing critical, warning suffices
@DanielGibson
Copy link
Member Author

done, thanks!

klaussilveira and others added 2 commits January 10, 2026 09:02
and turn the prints into warnings

moved the commented out assertions to where they were before
commit c22965bf580f0a718b7117a92da83205fccc32ec
so the code is a bit closer to the original (and the SDK)
@LegendaryGuard
Copy link

LegendaryGuard commented Jan 11, 2026

Found compiler warnings of unused variables, PR: #46

The "Recalculate gameLocal.msec each frame so 60 frames add up to 1000ms"
commit, that makes gameLocal.msec take either 16 or 17ms so on average
it's 16.666ms, caused problems with the "sys.waitFrame()" script
function, that calls idThread::WaitFrame() which sets
`waitingUntil = gameLocal.time + gameLocal.msec;`.
When we're in a 17ms frame and this is set, and the next frame is a 16ms
frame, then in the next frame this timeout won't have passed yet,
because it's just 16ms later, not 17ms later, so it will effectively
wait for two frames instead of one in every third frame.
This caused the (script-driven) MD3 animation in #727 to run too slowly.

Other similar calculations where gameLocal.msec is used to calculate
a (usually future) time relative to gameLocal.time will have similar
problems.

Mitigate this by introducing gameLocal.msecPrecise: It's always 16.666ms
(except in d3xp when slowmo is active) so when added to an integer it's
rounded down to 16ms (which will always trigger in the next frame), and
when multiplied to get the time of several frames it will also be way
more exact, off by < 1ms (instead of up to n*2/3 ms for n frames)
basically the same as in the previous commit, but more complicated
due to d3xp's slowmo feature.
slowmoMsec was always a float, now its value is based on the precise
frametime (16.666ms, added USERCMD_MSEC_PRECISE for that) instead of
USERCMD_MSEC = 16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants