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

Clean up and extend ArkApiUtils. #18

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

SubstituteR
Copy link
Contributor

@SubstituteR SubstituteR commented Oct 11, 2024

  1. Add literals for FVector and FRotator.
  2. Create versions of functions that take references to avoid extra null-checks (only the root should require null checking.)
  3. Clean up code / logic for various utility functions.
  4. Add experimental code / logic for padding structs and ensuring sizes match at construction time (fixes pointer arithmetic and automatic stack storage.)

Needs rigorous testing before merging

Copy link

@MolluskARK MolluskARK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IApiUtils is an exported class. It looks like you've mostly avoided falling victim to AsaApi's DLL Export Hell by adding new versions of functions. But there are a couple problem spots.

/**
* \brief Converts FVector into coords that are displayed when you view the ingame map
*/
FORCEINLINE MapCoords FVectorToCoords(FVector actor_position)
FORCEINLINE MapCoords FVectorToCoords(const FVector& position) const

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before:

?FVectorToCoords@IApiUtils@AsaApi@@QEAA?AUMapCoords@2@U?$TVector@N@Math@UE@@@Z

After:

?FVectorToCoords@IApiUtils@AsaApi@@QEBA?AUMapCoords@2@AEBU?$TVector@N@Math@UE@@@Z

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a purposeful breaking change to avoid copies and better reflect the intent of the function.

Recompiling plugins against the new api version would resolve the issue -- we can also force export this with the old name with a linker comment.

@@ -783,14 +915,24 @@ namespace AsaApi
* \param _this Player controller
* \param Command Command to run
*/
void RunHiddenCommand(AShooterPlayerController* _this, FString* Command)
void RunHiddenCommand(AShooterPlayerController* _this, const FString* Command) const

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before:

?RunHiddenCommand@IApiUtils@AsaApi@@QEAAXPEAUAShooterPlayerController@@PEAVFString@@@Z

After:

?RunHiddenCommand@IApiUtils@AsaApi@@QEBAXPEAUAShooterPlayerController@@PEBVFString@@@Z

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a purposeful breaking change to better reflect the intent of the function.

Recompiling plugins against the new api version would resolve the issue -- we can also force export this with the old name with a linker comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't bother me :) I don't know if many plugins are even using RunHiddenCommand(). And I imagine FVectorToCoords() is mostly getting inlined anyways.

Personally, there's a lot of exports I wouldn't mind seeing broken (a whole lot of FString exports that could have just been defined in headers with NativeCall, among other things). Maybe if the dev team doesn't mind potentially breaking existing plugins, then there's hope for cleaning up some other exports as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I am also not a fan of a singleton for ApiUtils.

This is just the first of a larger set of changes -- realistically we wouldn't push a new API version officially until most things are cleaned up and developers have time to recompile plugins.

With that said, we should also be using Git tags to help version the API so that people can download the latest stable source more easily, even if there are changes to master.

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