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

Keep main script to be executed before custom scripts. #235

Merged
merged 2 commits into from
Nov 30, 2024

Conversation

MiranDMC
Copy link
Collaborator

@MiranDMC MiranDMC commented Nov 23, 2024

Fix to keep scripts execution order same as in CLEO4. Changed due to fact the multiple scripts initialization behavior was fixed.
Tested with few custom scripts, main, mission and thread from main running at once.
Fixes #60

@MiranDMC MiranDMC requested a review from x87 November 23, 2024 23:13
@MiranDMC MiranDMC changed the title Keep main script in to be executed before custom scripts. Keep main script to be executed before custom scripts. Nov 26, 2024
Copy link

@x87 x87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my gut feeling is that this is going to blow up, hoping that I'm wrong

@MiranDMC
Copy link
Collaborator Author

my gut feeling is that this is going to blow up, hoping that I'm wrong

This reflects exactly how script queue looks on startup in CLEO4.
Also this is done before any script is processed yet, so queue contains just main script. No mission or script thread had chance to be spawned yet.

Hm after more thinking I'm not sure how and when scripts attached to map objects are spawned (like vending machines). This still needs to be checked.

@x87
Copy link

x87 commented Nov 27, 2024

they load when the object is spawned on the map, object handle is passed to the new script

@MiranDMC MiranDMC force-pushed the fix_main_script_processing_order branch from cad89e8 to 800d78d Compare November 28, 2024 00:29
@MiranDMC
Copy link
Collaborator Author

Ok in case of loading save game with original main scm it starts with multiple scripts already on list.
Updated code to idea I had in first place, just append custom scripts queue at end of original queue.

@MiranDMC MiranDMC requested a review from x87 November 28, 2024 00:42
@@ -941,7 +941,22 @@ namespace CLEO

GetInstance().ModuleSystem.LoadCleoModules();
LoadState(GetInstance().saveSlot);

// keep already loaded scripts at front of processing queue
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it important to execute game scripts before custom ones? what does it solve?

Copy link
Collaborator Author

@MiranDMC MiranDMC Nov 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handling save game pickup is done in main script. So any script that want to utilize 03D9
HAS_SAVE_GAME_FINISHED
needs to be executed after it.
Due to multiple reload of scripts on game start it was already like that in CLEO4. Game adds any new script at head of the queue (which is weird), and game is reset few times on each session start.

@MiranDMC MiranDMC merged commit 27e9f27 into master Nov 30, 2024
1 check passed
@MiranDMC MiranDMC deleted the fix_main_script_processing_order branch November 30, 2024 14:49
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 this pull request may close these issues.

not working with Skin Selector 2.1 (Modloader version)
2 participants