Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cutscenes failing to play correctly #1150

Closed
lawadr opened this issue May 18, 2023 · 2 comments · Fixed by #1153
Closed

Cutscenes failing to play correctly #1150

lawadr opened this issue May 18, 2023 · 2 comments · Fixed by #1153

Comments

@lawadr
Copy link
Contributor

lawadr commented May 18, 2023

I'm experiencing an issue in Jedi Academy on the cutscene where Luke is addressing the students after the first level. The game does not crash but nothing happens. No animation, no camera movement, no speech. You have to skip the cutscene to progress. This happens in both vanilla Jedi Academy and with the latest OpenJK.

I've found a number of reports of the same issue online:
https://www.gog.com/forum/star_wars_jedi_knight_jedi_academy/first_jedi_temple_cutscene_stuck
https://www.gog.com/forum/star_wars_jedi_knight_jedi_academy/game_freezing
https://steamcommunity.com/app/6020/discussions/0/3276942370878082914/
https://steamcommunity.com/app/6020/discussions/0/3201493200082464233/
https://steamcommunity.com/app/6020/discussions/0/1696048426810765937/
https://www.reddit.com/r/jediknight/comments/ek9mkq/jedi_academy_yavin_iv_cutscene_glitch/

Debugging this issue was a pain because debug builds of OpenJK played the cutscene just fine, but I got there in the end. It turns out that the issue occurs when the level loads too fast.

The game server spawns entities behind the scenes while the loading bar is moving. When the loading bar reaches the end, the client connects to the server and the player is placed in the world. If this occurs before all the entities are loaded then any script that references any of the missing entities will fail to load fully, leaving the chain of sequencer tasks broken.

When the server starts (at the beginning of the loading screen), the server time is set to 1000 milliseconds:

sv.time = 1000;

It then runs frames at 1000, 1100, 1200 and 1300 milliseconds to "warm up" the sever:

// run a few frames to allow everything to settle

Meanwhile, the entity spawner's nextthink time is set to 1350 and its e_ThinkFunc is set to thinkF_NPC_Spawn_Go:

OpenJK/code/game/NPC_spawn.cpp

Lines 2048 to 2049 in 90e8005

self->e_ThinkFunc = thinkF_NPC_Spawn_Go;
self->nextthink = level.time + START_TIME_REMOVE_ENTS + 50;

The first non-warmup frame occurs at 1400+(1/sv_fps) milliseconds, which with the default settings is at 1450. This triggers the think function, which finally bumps the nextthink time along by 100 milliseconds to 1550 and sets e_ThinkFunc to thinkF_NPC_Begin:

OpenJK/code/game/NPC_spawn.cpp

Lines 1758 to 1759 in 90e8005

newent->e_ThinkFunc = thinkF_NPC_Begin;
newent->nextthink = level.time + FRAMETIME;

If this next time is reached before the client connects to the server (the loading bar reaches the end) then everything runs smoothly. The NPC_Begin function has been run on each entity and so they can all be looked up correctly by name, specifically here:

entname = (char*) block->GetMemberData( 0 );
ent = game->GetByName( entname );

On my laptop, and in a release build, the client connects to the server at 1400 milliseconds. With RelWithDebugInfo I get around 1550 to 1600 on the first load of the cutscene, meaning it works, and then 1450 to 1500 on reloads (probably because some assets are still in memory?), meaning it fails.

I'm unsure what the best way to fix this bug is. The easiest way would probably be to increase the number of warm up frames or hardcode a delay to the client connection until after 1550 milliseconds. Alternatively, the Icarus code could be changed to postpone the lookup of entities until the task is processed, but I wouldn't know where to start with that.

@Graham1225
Copy link

I am having the same issue with Jedi Outcast (via OpenJO) on a 2020 M1 Macbook Air with loading cutscenes at the start of new levels—which, in my case, are the start of Artus Mine and the cutscene following the first fight with Desaan. I am completely ignorant of coding, so I can't comment on your work, but you seem to experiencing the same problem: models load in and music starts, but the in-engine cutscene does not continue and thus soft-locking the game. The only command actions I can apparently do is open the console or quick-load. Has anyone figured out a workaround?

@lawadr
Copy link
Contributor Author

lawadr commented Jun 25, 2023

I am having the same issue with Jedi Outcast (via OpenJO) on a 2020 M1 Macbook Air with loading cutscenes at the start of new levels—which, in my case, are the start of Artus Mine and the cutscene following the first fight with Desaan. I am completely ignorant of coding, so I can't comment on your work, but you seem to experiencing the same problem: models load in and music starts, but the in-engine cutscene does not continue and thus soft-locking the game. The only command actions I can apparently do is open the console or quick-load. Has anyone figured out a workaround?

I've just submitted a PR to fix this issue. With it, I finished Jedi Academy twice with no cutscene problems whatsoever. If you can build it, give it a shot and see if it fixes your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants