sezero / quakespasm

QuakeSpasm -- A modern, cross-platform Quake game engine based on FitzQuake.
https://sourceforge.net/projects/quakespasm/
GNU General Public License v2.0
239 stars 95 forks source link

Intermission Camera Points in Wrong Direction During Demo Playback #18

Closed 4LT closed 2 years ago

4LT commented 2 years ago

The info_intermission camera will point in the (opposite?) direction than expected when a level is completed during the playback of a demo.

Version

Quakespasm 0.94.3

OS

Arch Linux, x86-64

Replication

  1. Record demo and launch a map, e.g. record mydemo and map e1m1
  2. Trigger the map's changelevel
  3. Stop the demo recording
  4. Play the demo back
sezero commented 2 years ago

@ericwa, @andrei-drexler?

sezero commented 2 years ago

PING @ericwa, @andrei-drexler?

andrei-drexler commented 2 years ago

I've looked into this a bit. The camera angles are not simply inverted, but rather they're the player's angles when entering the trigger.

For regular gameplay, the sequence of events is basically:

------------------
  0:svc_time
  5:svc_setangle
  9:svc_clientdata
 30:fast update (for cl.viewentity)
 43:fast update
...more updates...
142:fast update
149:END OF MESSAGE 1
------------------
  0:svc_cdtrack
  3:svc_intermission (sets cl.intermission to 1)
  3:END OF MESSAGE 2

V_RenderView
V_RenderView
...

During demo playback, however, V_RenderView also gets called several times in-between the 2 messages (they're not processed back-to-back). At that point, cl.intermission is still 0, which means that V_RenderView ends up calling V_CalcRefdef, which in turn alters the viewentity angles: https://github.com/sezero/quakespasm/blob/743c9830602da5ab8ee6c95a0ab975dbede2213e/Quake/view.c#L763-L764

An easy fix would be to restore the viewentity angles to the last value received from the server (undoing the changes in V_CalcIntermissionRefdef) when handling svc_intermission, svc_finale and svc_cutscene, which is what I've done in https://github.com/andrei-drexler/ironwail/commit/db592dfefddb2bc0112a2693a7bb969f094a3045. It might be interesting to see if there's anything fishy going on with message processing during demo playback, but that could be a deeper rabbit hole and at this point I'd rather not spend any more time on this bug.

PS Apparently Quake 1.06 shareware has the same issue. PPS 2 test demos intermission_demos.zip

ericwa commented 2 years ago

Nice debugging. I don't have much to contribute but there was this forum thread discussing the issue a few years ago: https://forums.insideqc.com/viewtopic.php?p=54375

sezero commented 2 years ago

Seems like Andrei's patch work. Don't know about Baker's solution.

sezero commented 2 years ago

Applied Andrei's patch to fix this as https://github.com/sezero/quakespasm/commit/14b7338946ddd0a497b332da518be91fc5ea0749

Closing.