JanWichelmann / AoETechTree

A new modding-friendly tech tree implementation for Age of Empires II, replacing the old ingame tech tree.
MIT License
11 stars 2 forks source link

Cross-compiler compatibility + add some names #8

Closed goto-bus-stop closed 4 years ago

goto-bus-stop commented 4 years ago

This PR makes AoETechTree compile on GCC / MinGW, so linux users like me can compile it. It uses a CMake build script. GCC has a different __asm syntax and slightly different macro processing than MSVC, so it turned out to be difficult to rework CREATE_STATIC_WRAPPER to work across compilers. Instead I manually typed out the static wrapper signatures, which is less nice, but imo not that bad, and it's portable :) Linux filesystems are typically case sensitive, and MinGW ships with a lowercase windows.h file, so i changed the #includes to use the lowercase version. GCC also rejected some temporaries being passed to &-reference parameters, so this changes those signatures to copy the values. It's just a few ints anyway.

It adds some function exports for aoc-mmmod to the TechTree.dll, so the custom tech tree can be loaded by mmmod. mmmod is a mod loader that works by replacing the language_x1_p1.dll file, allowing UserPatch mods to ship with DLL mods without requiring any exe changes or a custom launcher. The old Init() export is maintained for projects that do not want to use aoc-mmmod.

Finally, I renamed some of the things using data from my RE database.

I compiled this locally with MinGW on linux, and confirmed it worked. I added a Github Actions workflow to confirm that it also compiles on MSVC. The workflow has all the yaml for cross-compilation on Ubuntu as well, but I didn't manage to get it to install a recent enough CMake version, so it's commented out for now.

JanWichelmann commented 4 years ago

Thank you very much for your effort and this pull request! Your changes are very appreciated. I'll take a look within the next days, verify that everything works as desired and then merge :)