From 071796660d387884c2c54a946bb78dfd90c182ab Mon Sep 17 00:00:00 2001 From: yeah-its-gloria <32610623+yeah-its-gloria@users.noreply.github.com> Date: Sat, 18 May 2024 15:39:54 -0400 Subject: [PATCH] Fix: Implement support for secure state coding on macOS Fixes a warning when running on macOS 14 and newer about not officially supporting secure state coding. --- src/video/cocoa/cocoa_wnd.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/video/cocoa/cocoa_wnd.mm b/src/video/cocoa/cocoa_wnd.mm index a36ef78dea..068fa3cedb 100644 --- a/src/video/cocoa/cocoa_wnd.mm +++ b/src/video/cocoa/cocoa_wnd.mm @@ -261,6 +261,18 @@ static NSImage *NSImageFromSprite(SpriteID sprite_id, ZoomLevel zoom) { [ [ NSNotificationCenter defaultCenter ] removeObserver:self ]; } + +/** + * Indicates to AppKit that OpenTTD is compatible with secure state storage. + * Starting with macOS 12, macOS expects us to be better compatible with NSSecureCoding, as to prevent attacks through restorable storage. + * Starting with 14, macOS logs a warning if we don't implement this ourselves. Since OpenTTD does not (yet) make use of restorable state, we simply don't care what happens with it. + * + * Explained here: https://developer.apple.com/documentation/foundation/nssecurecoding + */ +- (BOOL)applicationSupportsSecureRestorableState:(NSApplication*) sender +{ + return YES; +} @end /**