sezero / uhexen2

Hexen II: Hammer of Thyrion -- A cross-platform port of Hexen II game.
https://sourceforge.net/projects/uhexen2/
76 stars 14 forks source link

Fixed the meso2 and romeric5 maps on Amiga #54

Closed BSzili closed 2 years ago

BSzili commented 2 years ago

On Amiga there was a race condition in the order the entities get to think first when SV_SpawnServer is run. It was caused by the double to float conversion of host_frametime in SV_Physics_Pusher and later sv.time + host_frametime in SV_RunThink. Because of this some doors could be used or touched before their InitDoor function is executed causing a program error. I tried multiple ways to fix it, but it quickly became a game of whack-a-mole, so I ended up adding small constants to these checks to give them a bit of tolerance.

sezero commented 2 years ago

I wonder, wouldn't it be safe to always use those epsilons and not just for aos3.. (No, haven't yet tested myself.)

BSzili commented 2 years ago

Since it reinforces the existing behavior it probably wouldn't break other platforms, but this whole thing is quite fragile, so I wouldn't want to risk it.

sezero commented 2 years ago

SV_RunThink hexenwordl server doesn't need the same workaround?

BSzili commented 2 years ago

Oddly it didn't. There are some differences in how host_frametime is handled there, so it worked with only the SV_Physics_Pusher fix.

sezero commented 2 years ago

Asked a friend about his opinion on making the solution available to all platforms.

sezero commented 2 years ago

Asked a friend about his opinion on making the solution available to all platforms.

He says, in essence:

The second part of what he says is what I'm somewhat worried about.

BSzili commented 2 years ago

If other platforms are not affected then it's probably better to keep this Amiga-only. The second part is no problem there, as the workaround only needed for the initial SV_Physics calls in SV_SpawnServer, where host_frametime is always initialized to a known value.

sezero commented 2 years ago

OK, will probably merge this as is tomorrow. Two questions until then:

BSzili commented 2 years ago

I couldn't test with gcc2 for now, but disabling -ffast-math had no effect on it.

sezero commented 2 years ago

OK, this is in.