8000 feat: implement validation for native script definitions by jac3km4 · Pull Request #37 · wopss/RED4ext · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: implement validation for native script definitions #37

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

Merged
merged 15 commits into from
Dec 17, 2023

Conversation

jac3km4
Copy link
Contributor
@jac3km4 jac3km4 commented Dec 13, 2023

depends on wopss/RED4ext.SDK#102

my c++ isn't very good, feel free to make commits here if you don't like something

the overview is:

  • red4ext now pulls redscript as a dependency (for a single C header)
  • redscript now ships with a scc_shared.dll file which can be used to interact with the compiler
  • red4ext ExecuteProcess has been updated to dynamically load this dll when it's present, use it to compile scripts and then finally retrieve information necessary to map all native definitions to source files (which we use later)
  • I've added a basic SourceRefRepository class for management of source references, it uses a string interner to store strings as an optimiation, because paths and class names are going to repeat a lot
  • I've added a new ValidateScripts hook, which invokes existing script validation that's already implemented in the game, parses the validation errors into a simple structure, and then finally converts that into a nice error message notifying the user about the problematic scripts

image

@jac3km4
Copy link
Contributor Author
jac3km4 commented Dec 14, 2023

I've cleaned up the code and updated some things @wopss.

The popup now looks like this:
image

It's meant to be readable for regular users. The logs contain detailed information with source file references and line numbers:

[2023-12-14 11:09:34.661] [RED4ext] [info] scc invoked successfully, 49 source refs were returned
[2023-12-14 11:09:34.905] [RED4ext] [error] Script validation error: Missing native function 'ChangeResource' in native class 'IComponent' at C:\Games\Cyberpunk 2077\r6\scripts\Test.reds:173
[2023-12-14 11:09:34.905] [RED4ext] [error] Script validation error: Missing native class 'Dupa' at C:\Games\Cyberpunk 2077\r6\scripts\Test.reds:168
[2023-12-14 11:09:34.905] [RED4ext] [error] Script validation error: Missing base class 'Dupa' of native class 'BraindanceDissolveComponent' at C:\Games\Cyberpunk 2077\r6\scripts\Test.reds:176
[2023-12-14 11:09:34.905] [RED4ext] [error] Script validation error: Native class 'BraindanceDissolveComponent' has declared base class 'Dupa' that is different than current one 'entIComponent' at C:\Games\Cyberpunk 2077\r6\scripts\Test.reds:176
[2023-12-14 11:09:34.905] [RED4ext] [error] Script validation error: Imported property 'BraindanceDissolveComponent.dissolveRadius' type 'Int32' does not match with the native one 'Float'. at C:\Games\Cyberpunk 2077\r6\scripts\Test.reds:177
[2023-12-14 11:09:34.905] [RED4ext] [error] Script validation error: Missing native property 'event2' in native class 'audioAudEventStruct' at C:\Games\Cyberpunk 2077\r6\scripts\Test.reds:181
[2023-12-14 11:09:34.905] [RED4ext] [error] Script validation error: Missing native global function 'Ahgjadshgkjdas' at C:\Games\Cyberpunk 2077\r6\scripts\Test.reds:171

Copy link
Owner
@wopss wopss left a comment

Choose a reason for hiding this comment

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

Poggies!

Thanks! I have a few minor remarks.

@jac3km4 jac3km4 requested a review from wopss December 16, 2023 18:38
@jac3km4
Copy link
Contributor Author
jac3km4 commented Dec 16, 2023

@wopss addressed all your comments

@wopss
Copy link
Owner
wopss commented Dec 17, 2023

Thanks!

@wopss wopss merged commit 5d7d30b into wopss:master Dec 17, 2023
@jac3km4 jac3km4 deleted the feat/script-validation branch December 17, 2023 12:39
@WSSDude
Copy link
Contributor
WSSDude commented Dec 18, 2023

RIP, I think this may crash or cause other issues if path contains unicode chars as mentioned in comment...

@WSSDude
Copy link
Contributor
WSSDude commented Dec 18, 2023

Probably not an issue for regular installs, but if someone put their legit copy in some weird path this is an issue... And you can do that with Steam and GOG at least, dunno about EGS... Probably not for majority though... Should still be patched.

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.

3 participants
0