X4 Rest Server aims to provide an http/rest API for the game X4: Foundations
The project should be primarily focused on data-out, not for interacting with the game from the far, or even cheating.
All without getting "modified"
We'll see how things shake out, however...
It works by loading a shared-library (.dll/.so) into the game.
The .dll/.so loads functions from the game, which are exposed via FFI, normally used for lua-scripts managing the game UI, and calls them directly.
The results are then sent out as json via an inbuilt http-server
Due to the fact, that most code is generated, almost all endpoints use http-GET requests, even if changing values in the game. (We'll see how long that stays...)
It compiles on Windows and Linux
DataTypes, DataStructures, and Functions are listed
- in code: __generated__
- in Markdown with a bit of additional info.
See Docs
Even if not explicitly stated, feel free to take on anything on, or event outside of the TODO list.
If you have any questions, you can:
- Participate in the X4RestServer thread on Egosoft forums (preferred)
- Find me on Discord: Alia5#9959
- Find me on Steam: [oRLY]Alia5
- Open an issue
Extracts typedefs
, structs
, and function definitions
from the .lua
-scripts from an unpacked instance of X4
Written in NodeJS / TypeScript
The actual "mod".dll
Loads exposed functions, providing a basic http/Rest-Api to call them
Requirements:
- Visual Studio 2019 setup for C++, development
- Open .sln file with Visual Studio
- Build X4RestServer Project
Requirements:
- Visual Studio Code
- clang++
cd X4RestServer/
make
Requirements:
- NodeJS (14.X) (recommended: use via nvm or nvm-windows)
- An unpacked version of X4:Foundations
- Unpack X4
git clone --recursive git@github.com:Alia5/X4-rest-server.git
- Copy
X4RestServer/script/FFIRipper/config/default.js
toX4RestServer/script/FFIRipper/config/local.js
- Update
uiPath
-value inlocal.js
to point to your Unpacked X4sui
-subfolder;
Use Visual Studio to attach to X4.exe
Note: Clicking the stop button terminates the game Process. Use the Debug
menu to detach before rebuilding.
- Make sure you don't have any release build currently installed!
- Inject the X4RestServer.dll with a Dll-Injector of your choice. (i.E. Cheat Engine)
- Attach Cheat Engine to X4
- Add any address
- Browse memory region (CTRL+B)
- Tools -> Inject DLL (CTRL+I)
- Select X4RestServer.dll
curl -X GET http://localhost:3000/stop
- Cleanup / Refactor FFIRipper
- I aimed to get things done, not make them pretty... It's a mess!
- Contributors wanted (Typescript)
- Implement endpoints for which generator can't handle ('FilterComponentByText','SetMapFilterString', 'GetBlacklistInfo')
- Contributors wanted (C++)
- Implement translation from input data-structs
- Contributors wanted (C++)
- Streamline development
- Contributors wanted (C++/Typescript)
- Improve Docs
- OpenApi/Swagger Rest docs
- Contributors wanted
- Check if we can remain in our separete DLL-thread for all funcs
- If not: Add a generic hook in RenderThread that works with Steam / GoG versions
- Get out of POC stage
- Add own DLL injector for debugging.
- Improve CI
- Contributors wanted (I really don't have time to learn this shit)
- Linux support! POC is available
- Contributors wanted
MIT