Skip to content

Commit

Permalink
Use NSURLErrorKey for NSError user infos.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddTheSane committed May 1, 2023
1 parent 8f9b725 commit 5854125
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions Classes/PCSX2GameCore.mm
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@
alignas(16) static SysMtgsThread s_mtgs_thread;
PCSX2GameCore *_current;

@interface PCSX2GameCore ()

@end

@implementation PCSX2GameCore {
@package
bool hasInitialized;
Expand Down Expand Up @@ -151,7 +147,7 @@ - (BOOL)loadFileAtURL:(NSURL *)url error:(NSError **)error

if (_allCueSheetFiles.count <= 0) {
if (error) {
*error = [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreCouldNotLoadROMError userInfo:@{NSFilePathErrorKey: url.path}];
*error = [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreCouldNotLoadROMError userInfo:@{NSURLErrorKey: url}];
}

return false;
Expand Down Expand Up @@ -312,21 +308,22 @@ - (void)startEmulation
wi.surface_height = screenRect.size.height ;
g_host_display->CreateDevice(wi, VsyncMode::Adaptive);

VMManager::Internal::InitializeGlobals() ;
VMManager::Internal::InitializeGlobals();


if(VMManager::Initialize(params)){
if (VMManager::Initialize(params)) {
hasInitialized = true;
VMManager::SetState(VMState::Running);
if ([stateToLoad.path length] > 0)
if ([stateToLoad.path length] > 0) {
VMManager::LoadState(stateToLoad.fileSystemRepresentation);
}

[NSThread detachNewThreadSelector:@selector(runVMThread) toTarget:self withObject:nil];
[NSThread detachNewThreadSelector:@selector(runVMThread:) toTarget:self withObject:nil];
}
}
}

- (void)runVMThread
- (void)runVMThread:(id)unused
{
OESetThreadRealtime(1. / 50, .007, .03); // guessed from bsnes

Expand Down Expand Up @@ -377,6 +374,7 @@ - (void)executeFrame
#pragma mark Video
- (OEIntSize)aspectSize
{
//TODO: change based off of app/user availability.
return (OEIntSize){ 4, 3 };
}

Expand Down Expand Up @@ -478,7 +476,7 @@ - (void)loadStateFromFileAtURL:(NSURL *)fileURL completionHandler:(void (^)(BOOL
bool success = VMManager::LoadState(fileURL.fileSystemRepresentation);
WaitRequested = false;

block(success, success ? nil : [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreCouldNotLoadStateError userInfo:@{NSLocalizedDescriptionKey: @"PCSX2 Could not load the current state.", NSFilePathErrorKey: fileURL.path}]);
block(success, success ? nil : [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreCouldNotLoadStateError userInfo:@{NSLocalizedDescriptionKey: @"PCSX2 Could not load the current state.", NSURLErrorKey: fileURL}]);
}

- (void)saveStateToFileAtURL:(NSURL *)fileURL completionHandler:(void (^)(BOOL, NSError *))block
Expand All @@ -487,7 +485,7 @@ - (void)saveStateToFileAtURL:(NSURL *)fileURL completionHandler:(void (^)(BOOL,
return;
bool success = VMManager::SaveState(fileURL.fileSystemRepresentation, false, false);

block(success, success ? nil : [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreCouldNotSaveStateError userInfo:@{NSLocalizedDescriptionKey: @"PCSX2 Could not save the current state.", NSFilePathErrorKey: fileURL.path}]);
block(success, success ? nil : [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreCouldNotSaveStateError userInfo:@{NSLocalizedDescriptionKey: @"PCSX2 Could not save the current state.", NSURLErrorKey: fileURL}]);

}

Expand Down Expand Up @@ -801,7 +799,7 @@ - (void)changeDisplayWithMode:(NSString *)displayMode
void Host::ReleaseHostDisplay(bool clear_state)
{
GET_CURRENT_OR_RETURN();
if(g_host_display.get()){
if (g_host_display.get()) {
g_host_display.reset();
}
}
Expand Down

0 comments on commit 5854125

Please sign in to comment.