RSDKModding / RSDKv3-Decompilation

A Full Decompilation of Sonic CD (2011) & Retro Engine (v3)
Other
591 stars 120 forks source link

MacOS helper getResourcePath() returns empty string, causing crash on launch #221

Closed ScrelliCopter closed 2 days ago

ScrelliCopter commented 1 year ago

Expected Behavior

Should return something like "/Users/me/Library/Application Support" and allow the application to launch correctly

Actual Behavior

libc++abi: terminating due to uncaught exception of type std::__1::__fs::filesystem::filesystem_error: filesystem error: in directory_iterator::directory_iterator(...): No such file or directory ["/RSDKv3"] thrown in ResolvePath

Steps to Reproduce

  1. Follow the instructions linked in the Readme to setup the Xcode project.
  2. Build with Xcode 14.3.1 and Run
  3. Have strings like modsPath set to "/RSDKv3" and crash

Screenshots

No response

Log File

No response

Decompilation Version

master (01babfc)

Game Version

Blit Release (Steam/XBOX 360/PS3)

Game Revision

No response

Script Platform Type

Standard

Renderer Type

Software Renderer

Platform

MacOS Ventura 13.4.1

Additional Comments

https://github.com/Rubberduckycooly/Sonic-CD-11-Decompilation/blob/01babfce7e9fc58960960012f03ad7a0aad6499c/dependencies/mac/cocoaHelpers.mm#L13

The documentation for NSString remarks that the string pointed at by UTF8String is unreliable past NSString's lifetime, on my machine the returned string gets clobbered to '\0' immediately hence the above behaviour. The C string should really be copied to a buffer before being returned.

I modified the function to return std::string instead and it works correctly but I'm holding off making a PR in case the project would prefer a different approach.

KirbyKid256 commented 2 days ago

I got the same bug so I fixed it using Sappharad's code. It's merged in 609387c92c37bf96d6fc9116a502eed07b7b59b4