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

Support future game versions #14

Open
mwl4 opened this issue Oct 13, 2023 · 1 comment
Open

Support future game versions #14

mwl4 opened this issue Oct 13, 2023 · 1 comment

Comments

@mwl4
Copy link

mwl4 commented Oct 13, 2023

Hello,

I can see that it is challenging to predict future game versions and in the same time keep plugin working for the largest number of game binary versions.

To do it effectively, you could first verify what you need, if it fails, then inform user that different plugin version is needed, if it succeeds let it load.
To make it happen, you could use __try and __except keywords.
https://stackoverflow.com/a/7049836

int FilterException(int code, PEXCEPTION_POINTERS ex) {
    return EXCEPTION_EXECUTE_HANDLER;
}

void SomeCheckingOfNeededGameStuff()
{
  // check if game_ctrl_u object is really game_ctrl
  // check if game_actor_u object is really game_actor
  // etc
  // if anything goes bad and throws exception, it will be catched in __except block.
}

bool ShouldPluginBeRunning()
{
    __try {
        SomeCheckingOfNeededGameStuff();
        return true; // all went fine
    }
    __except(FilterException(GetExceptionCode(), GetExceptionInformation())) {
        return false;
    }
}

Real code might be different, and I am not sure if you can return false just like that from __except block. But I think it should be all possible.

Thank you for understanding.

@dariowouters
Copy link
Owner

Hey,

Thank you, I don't know much about c++ so I did not know __try/__catch even existed, I think I tried the std try/catch at some point but that was only able to catch std exceptions.

The version checker I added last plugin version only checks 1.xx, I didn't really expect SCS to do a .5 update.
And I indeed don't really want to constantly have to update this for every smaller binary change. So it wasn't able to catch the .5 update unfortunately.

I will look into it and hopefully stop the crashes once and for all, thanks again.
And sorry for any issues/extra work the plugin crashes have caused for you and the TruckersMP team.

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

No branches or pull requests

2 participants