Skip to content

Conversation

@ate47
Copy link
Contributor

@ate47 ate47 commented Aug 4, 2023

Like I told you by message for #8, if we call one of the function about the game stack or the VM_OP we have a game crash (unlike using the project-bo4 dll), but I added some other options.

I made the same tests as the ones in #8 so to avoid a duplicated PR I don't mention them there.

I didn't took the time to look at it so I've put a config to enable these options instead.

The new options with their default values are:

dll=false
dll.lazylink=false
dll.detours=false
dll.builtins=false

We can put them in the gsc.conf or using the option -Ckey=value when calling the compiler.

The dll and dll.lazylink options aren't crashing the game and can be used with the base game, but maybe it's better to not inject a dll by default.

Event functions

It seems that your assertion that the 2nd namespace in the export is a namespace was false (at least from this code), it seems to be the event name for the event functions. (I added some events in my find.txt file)

You can see the the event linking in Scr_GscObjLink, which is calling ScrEvent_AddCallbackEventHandler

Scr_GscObjLink	.text	0000000002748E70
ScrEvent_AddCallbackEventHandler	.text	0000000002744E80

To keep the syntax simple I used something like with the detours. The prefix event_ can be used to use hashed event name.

event<eventname> func_name(eventstruct) {
   // ...
}

To test, I've used this example, which was working and was printing my username.

event<player_connect> codecallback_player_co(eventstruct) {
    am_log("player connect " + self.name);
}

Advanced builtins

I wanted to quickly dump some script information so I added 2 builtins:

// Print text in a file
// <file>: File to open
// <mode>: File open mode, w(write) or a(append)
// <message>: Text to write
compiler::GScr_fnprint(file, mode, message);

// Print a line in a file
// <file>: File to open
// <mode>: File open mode, w(write) or a(append)
// <message>: Text to write
compiler::GScr_fnprintln(file, mode, message);

Due to the obvious hazard that can be created using these functions, I added the symbol T8CINTERNAL_ADVANCED to avoid them during compilation. (The config Release_Advanced adds this symbol)

GCSC

The CSC files added, I think it's better to have a way to write common CSC/GSC files, I used the extension .gcsc which is compiled on both the csc and gsc sides.

Symbols

To have a better compilation, I added a symbol for each feature

_INJECT_CLIENT : client=true
_INJECT_SERVER : server=true
_SUPPORTS_BUILTINS : dll.builtins = true
_SUPPORTS_DETOURS : dll.detours = true
_SUPPORTS_LAZYLINK : dll.lazylink = true
_SUPPORTS_EVENTFUNC : true if game = T8
_SUPPORTS_GCSC : true by default (avoid old compilers)
_CSC : compiling a client script (useful for .gcsc files)
_GSC : compiling a server script (useful for .gcsc files)

I hope I didn't make it too long, sorry.

@shiversoftdev
Copy link
Owner

Hello, sorry its taking so long to review, it is a big pull request and I am very busy. I did roughly look over things and will make a more detailed pass at a later date. I need to review the grammar changes, build setting changes, and some of the config changes made because they can have rippling effects down the line. I may suggest some changes before pulling to the main project.

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.

2 participants