From dbe022d82b205b1e19597dab10d8112459966fe5 Mon Sep 17 00:00:00 2001 From: masakih Date: Tue, 1 Sep 2015 21:39:55 +0900 Subject: [PATCH] =?utf8?q?=E8=A4=87=E6=95=B0=E7=B5=84=E3=81=AE=E8=AD=B7?= =?utf8?q?=E8=A1=9B=E9=80=80=E9=81=BF=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- KCD/HMGuardShelterCommand.m | 27 ++++++++++++++++++++++++++- KCD/HMMapStartCommand.m | 2 ++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/KCD/HMGuardShelterCommand.m b/KCD/HMGuardShelterCommand.m index 7b42bd1a..1320b86e 100644 --- a/KCD/HMGuardShelterCommand.m +++ b/KCD/HMGuardShelterCommand.m @@ -44,6 +44,9 @@ NSString *HMGuardShelterCommandDidUpdateGuardExcapeNotification = @"HMGuardShelt [self ensureGuardShelter]; return; } + if([self.api isEqualToString:@"/kcsapi/api_req_map/next"]) { + [self removeInvalidEntry]; + } } @@ -116,7 +119,29 @@ NSString *HMGuardShelterCommandDidUpdateGuardExcapeNotification = @"HMGuardShelt [object setValue:@NO forKey:@"ensured"]; } - +- (void)removeInvalidEntry +{ + HMTemporaryDataStore *store = [HMTemporaryDataStore oneTimeEditor]; + NSError *error = nil; + NSArray *array = [store objectsWithEntityName:@"GuardEscaped" + error:&error + predicateFormat:@"ensured = FALSE"]; + if(error) { + NSLog(@"GuardEscaped is invalid. -> %@", error); + return; + } + if(!array) { + NSLog(@"GuardEscaped is invalid. -> %@", error); + return; + } + for(NSManagedObject *object in array) { + [store.managedObjectContext deleteObject:object]; + } + [store saveAction:nil]; + [NSThread sleepForTimeInterval:0.1]; + + [self notify]; +} - (void)removeAllEntry { HMTemporaryDataStore *store = [HMTemporaryDataStore oneTimeEditor]; diff --git a/KCD/HMMapStartCommand.m b/KCD/HMMapStartCommand.m index 12bbb916..15411ee7 100644 --- a/KCD/HMMapStartCommand.m +++ b/KCD/HMMapStartCommand.m @@ -9,6 +9,7 @@ #import "HMMapStartCommand.h" #import "HMCalculateDamageCommand.h" +#import "HMGuardShelterCommand.h" @implementation HMMapStartCommand + (void)load @@ -31,6 +32,7 @@ { self = [super initWithCommands: [HMCalculateDamageCommand new], + [HMGuardShelterCommand new], nil]; return self; } -- 2.11.0