+ midend_restart_game(me);
+}
+- (void)saveGame:(id)sender
+{
+ NSSavePanel *sp = [NSSavePanel savePanel];
+
+ if ([sp runModal] == NSFileHandlingPanelOKButton) {
+ const char *name = [[sp filename] UTF8String];
+
+ FILE *fp = fopen(name, "w");
+
+ if (!fp) {
+ [self showError:"Unable to open save file"];
+ return;
+ }
+
+ midend_serialise(me, savefile_write, fp);
+
+ fclose(fp);
+ }
+}
+- (void)loadSavedGame:(id)sender
+{
+ NSOpenPanel *op = [NSOpenPanel openPanel];
+
+ [op setAllowsMultipleSelection:NO];
+
+ if ([op runModalForTypes:nil] == NSOKButton) {
+ /*
+ * This used to be
+ *
+ * [[[op filenames] objectAtIndex:0] cString]
+ *
+ * but the plain cString method became deprecated and Xcode 7
+ * started complaining about it. Since OS X 10.9 we can
+ * apparently use the more modern API
+ *
+ * [[[op URLs] objectAtIndex:0] fileSystemRepresentation]
+ *
+ * but the alternative below still compiles with Xcode 7 and
+ * is a bit more backwards compatible, so I'll try it for the
+ * moment.
+ */
+ const char *name = [[[op filenames] objectAtIndex:0]
+ cStringUsingEncoding:
+ [NSString defaultCStringEncoding]];
+ char *err;
+
+ FILE *fp = fopen(name, "r");
+
+ if (!fp) {
+ [self showError:"Unable to open saved game file"];
+ return;
+ }
+
+ err = midend_deserialise(me, savefile_read, fp);
+
+ fclose(fp);
+
+ if (err) {
+ [self showError:err];
+ return;
+ }
+
+ [self resizeForNewGameParams];
+ [self updateTypeMenuTick];
+ }