Skip to content

Commit

Permalink
Update 2024-02-29-creating-the-perfect-modding-language.md
Browse files Browse the repository at this point in the history
  • Loading branch information
MyNameIsTrez authored Mar 2, 2024
1 parent 02f6a3e commit c5e0f44
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion _posts/2024-02-29-creating-the-perfect-modding-language.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ No more unformatted messes when having to fix other people's code

# Hot reloading

It's the game's responsibility to scan their mod directory for the paths of mods to be loaded. The game needs to load mod DLLs one-by-one with `dlopen()`, and can then use [this code](https://stackoverflow.com/a/62205128/13279557) to iterate over all the function names in the DLL. The reason that calling `dlsym()` for every event function that the game exposes on every mod, is because the `define_human_marine` function name above needs to be callable by the game, and that function name is a custom one composed of the game's `define_human_` prefix, combined with the name `marine` that the mod came up with. TODO: If the marine and zombie were to be split into separate files, then it could just become `define_human()`, which would eradicate this complicated iteration code on the game's side.
It's the game's responsibility to scan their mod directory for the paths of mods to be loaded. The game needs to load mod DLLs one-by-one with `dlopen()`, and can then use [this code](https://stackoverflow.com/a/62205128/13279557) to iterate over all the function names in the DLL. The reason that calling `dlsym()` for every event function that the game exposes on every mod, is because the `define_human_marine` function name above needs to be callable by the game, and that function name is a custom one composed of the game's `define_human_` prefix, combined with the name `marine` that the mod came up with. TODO: If the marine and zombie were to be split into separate files, then it could just become `define_human()`, which would eradicate this complicated iteration code on the game's side. It unfortunately isn't possible to just move the `marine` and `zombie` part of the function name into the `human` struct as a string, since there'd then be two `define_human()` definitions in the same file.

There is an alternative (but in my opinion worse) approach that *does* allow all mods to be put inside of a single DLL: Let something automatically prepend the mod name/id to all of its structs and functions, before TCC compiles the object file.

Expand Down

0 comments on commit c5e0f44

Please sign in to comment.