From 929fb9f2c0e7e790b3601be664e9b52ccf27b304 Mon Sep 17 00:00:00 2001 From: Nikos Barkas Date: Mon, 6 Sep 2010 18:20:39 +0000 Subject: [PATCH] Added the playerWillSaveGame script event handler, taking as parameter the type of savegame, which can be standardSave, autoSave or quickSave, as per request in http://www.aegidian.org/bb/viewtopic.php?p=117800#117800. git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@3746 127b21dd-08f5-0310-b4b7-95ae10353056 --- src/Core/Entities/PlayerEntityLoadSave.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Core/Entities/PlayerEntityLoadSave.m b/src/Core/Entities/PlayerEntityLoadSave.m index d8e1eb6c..7e619dda 100644 --- a/src/Core/Entities/PlayerEntityLoadSave.m +++ b/src/Core/Entities/PlayerEntityLoadSave.m @@ -142,6 +142,8 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict); tmp_name = player_name; tmp_path = save_path; + [self doScriptEvent:@"playerWillSaveGame" withArgument:@"autoSave"]; + NSString *saveName = player_name; if (![player_name hasSuffix:DESC(@"autosave-commander-suffix")]) saveName = [player_name stringByAppendingString:DESC(@"autosave-commander-suffix")]; @@ -180,6 +182,8 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict); format:@"ERROR no file name returned by [[gameView gameController] playerFileToLoad]"]; } + [self doScriptEvent:@"playerWillSaveGame" withArgument:@"quickSave"]; + [self writePlayerToPath:path]; [[UNIVERSE gameView] supressKeysUntilKeyUp]; [self setGuiToStatusScreen]; @@ -577,6 +581,8 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict); NSArray* path_components = [[sp filename] pathComponents]; NSString* new_name = [[path_components objectAtIndex:[path_components count]-1] stringByDeletingPathExtension]; + [self doScriptEvent:@"playerWillSaveGame" withArgument:@"standardSave"]; + [player_name release]; player_name = [new_name copy]; @@ -628,9 +634,10 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict); - (void)nativeSavePlayer:(NSString *)cdrName { NSString* dir = [[UNIVERSE gameController] playerFileDirectory]; - NSString *savePath = [dir stringByAppendingPathComponent:[cdrName stringByAppendingPathExtension:@"oolite-save"]]; + [self doScriptEvent:@"playerWillSaveGame" withArgument:@"standardSave"]; + [player_name release]; player_name = [cdrName copy];