haekb / nolf2-modernizer

NOLF 2 Modernizer aims to unlock resolution support, restore multi-player support, and fix a few bugs here and there.
https://haekb.itch.io/nolf2-modernizer
31 stars 4 forks source link

On higher framerates, music mood doesn't build up correctly #2

Closed haekb closed 4 years ago

haekb commented 5 years ago

Noticed some weird frame timings when an npc is on alert. Could just be some debug logging, since this is in debug mode.

Good to keep an eye on though. Screenshot6

haekb commented 4 years ago

This happens on release builds :(

haekb commented 4 years ago

A week later...I cannot reproduce this. Did the latest windows 10 update fix this? image

haekb commented 4 years ago

Ahah, it's caused by music.

Thanks https://www.pcgamingwiki.com/wiki/No_One_Lives_Forever_2:_A_Spy_in_H.A.R.M.%27s_Way#Stuttering_when_guards_are_alerted

haekb commented 4 years ago

So here's the situation:

Each mood (None, Routine, Alert, Combat) individually builds up a timer that caps out at 10 seconds.

Each time a MusicMgr::DoMood function is called it increments the frametime to that timer. Each time MusicMgr::Update function is called it decrements the frametime to that timer.

If a timer reaches zero it transitions to another mood with a timer of > 0. (I haven't really looked into whether it transitions up or just picks the next timer with > 0.)

For some reason on framerates higher than 100fps it either decrements more than it increments, or vice versa, causing the timer to reach 0 for more than 1 frame causing a rapid music transitions.

This might have something to do with NOLF 1 and their server framerate being capped 100. But I need to do some more digging!