Skip to content
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

Packet suppression should happen automatically via source generated interceptors #2198

Open
Measurity opened this issue Nov 18, 2024 · 0 comments
Labels
Area: dev Related to development environment or dev QoL
Milestone

Comments

@Measurity
Copy link
Collaborator

Measurity commented Nov 18, 2024

Issue

The way Nitrox uses the game code is for both functionality and to know when the game does something (to then signal the interesting parts of data to the server). This however becomes a problem when Nitrox causes game APIs to be called instead of the original game flow, leading to wrong/redundant signalling to the server.

To fix the problem PacketSuppressor<TPacket> API was created. This blocks the client from sending a packet type by wrapping (patched) game APIs in a using block. But packet suppression is easy to do wrong, so an automated way would be a good Quality of Life feature for development.

Implementation steps

  1. Generate a call hierarchy of the game functions via an MSBuild task using cecil or dnlib.
  2. Find patched game function symbols from Nitrox code.
  3. Group results of step 1 and 2 so that for every call to game code we know which packet types are being send.
  4. Generate interceptors on the calls to (patched) game code to be replaced with a wrapped packet suppression block of every packet type that could be called based on context.

Tools to use for each step

  1. MSBuild task to generate a file with the entire game call hierarchy. Only needs to be generated once if game DLL isn't changing.
  2. Source generator to inspect our code for patches and which game function they patch. But only if they are sending packets. The generated file from the MSBuild task should be included in this source generator as "additional text files"
  3. Within the same source generator, group the results so we know which packets are being send in the entire call hierarchy of the game.
  4. Within the same source generator, generate interceptors on calls made on patched game functions. The interceptor should redirect it to a wrapped call using a PacketSuppressor which will suppress the appropriate packets. Note that only the Nitrox Client project should have packet suppression.

Resources to help with implementation

@Measurity Measurity added the Area: dev Related to development environment or dev QoL label Nov 18, 2024
@Measurity Measurity added this to the Future milestone Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: dev Related to development environment or dev QoL
Projects
None yet
Development

No branches or pull requests

1 participant