File tree 1 file changed +29
-3
lines changed
1 file changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -216,12 +216,38 @@ - (void)privInitializeWithIStoreAssets:(id)storeAssets {
216
216
[self save ];
217
217
}
218
218
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
+
219
246
- (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]) {
222
248
return ;
223
249
}
224
-
250
+
225
251
currentAssetsVersion = [storeAssets getVersion ];
226
252
227
253
// we prefer initialization from the database (storeAssets are only set on the first time the game is loaded)!
You can’t perform that action at this time.
0 commit comments