Skip to content

Commit 5619f82

Browse files
author
Boris Spektor
committed
Merge pull request #55 from vedi/dev
Weekly PR
2 parents cc50bf9 + bca6bbd commit 5619f82

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

SoomlaiOSStore/data/StoreInfo.m

+29-3
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,38 @@ - (void)privInitializeWithIStoreAssets:(id)storeAssets {
216216
[self save];
217217
}
218218

219+
-(BOOL)checkAssetsArrayForMarketIdDuplicates:(NSArray *)assetsArray {
220+
NSMutableSet *marketItemIds = [NSMutableSet new];
221+
for (PurchasableVirtualItem *pvi in assetsArray) {
222+
if ([pvi.purchaseType isKindOfClass:[PurchaseWithMarket class]]) {
223+
NSString *currentMarketId = ((PurchaseWithMarket *)pvi.purchaseType).marketItem.productId;
224+
if ([marketItemIds containsObject:currentMarketId]) {
225+
return NO;
226+
}
227+
[marketItemIds addObject:currentMarketId];
228+
}
229+
}
230+
return YES;
231+
}
232+
233+
-(BOOL)validateStoreAssets:(id<IStoreAssets>)storeAssets {
234+
if (storeAssets == nil) {
235+
LogError(TAG, @"The given store assets can't be null!");
236+
return NO;
237+
}
238+
if (![self checkAssetsArrayForMarketIdDuplicates:storeAssets.virtualGoods]
239+
|| ![self checkAssetsArrayForMarketIdDuplicates:storeAssets.virtualCurrencyPacks]) {
240+
LogError(TAG, @"The given store assets has duplicates at marketItem productId!");
241+
return NO;
242+
}
243+
return YES;
244+
}
245+
219246
- (void)setStoreAssets:(id <IStoreAssets>)storeAssets{
220-
if(storeAssets == NULL){
221-
LogError(TAG, @"The given store assets can't be null !");
247+
if (![self validateStoreAssets:storeAssets]) {
222248
return;
223249
}
224-
250+
225251
currentAssetsVersion = [storeAssets getVersion];
226252

227253
// we prefer initialization from the database (storeAssets are only set on the first time the game is loaded)!

0 commit comments

Comments
 (0)