def check1(tradeItems, limitChanges, stacks, locatable, accumulators, doIds, giving): listType = type([]) possibleTypes = (type(1), type(1L), listType) for i in tradeItems: for v in i: itemType = type(v) if itemType not in possibleTypes: raise AITradeException, 'element is the wrong type' if v > 4294967295L: raise itemType != listType and AITradeException, 'element is larger than unsigned long' else: t = i[TypeIndex] if InventoryId.isLimitChange(t): a = limitChanges.setdefault(t, [t, 0]) a[1] += i[QuantityIndex] if a[1] > 65535L: raise AITradeException, 'element is larger than unsigned short' elif InventoryId.isStackable(t): a = stacks.setdefault(t, [t, 0]) a[1] += i[QuantityIndex] if a[1] > 65535L: raise AITradeException, 'element is larger than unsigned short' elif isLocatable(t): inv = simbase.air.doId2do.get(self.inventoryId) theInvItem = inv and InvItem(i) theInvItemType = theInvItem.getType() if giving: equippableInfo = inv.getItemRequirements( theInvItemType, self.giving) if equippableInfo == None or filter( lambda x: equippableInfo[x][1] == False, equippableInfo): if theInvItemType and theInvItemType not in self.unequippables: self.unequippables.append(theInvItemType) if isStackableType(theInvItem.getCat()): for currLocatable in locatable: prevInvItem = InvItem(currLocatable) if prevInvItem.compare(theInvItem, excludeLoc=True): adjustedInvItem = prevInvItem.adjustCount( theInvItem.getCount()) locatable.remove(currLocatable) i = list(adjustedInvItem) break else: raise AITradeException, 'inventory not present' locatable.append(i) elif InventoryId.isAccumulator(t): a = accumulators.setdefault(t, [t, 0]) a[1] += i[QuantityIndex] if a[1] > 4294967295L: raise AITradeException, 'element is larger than unsigned long' elif InventoryId.isDoId(t): doIds[i[DoIdIndex]] = i return
def check1(tradeItems, limitChanges, stacks, locatable, accumulators, doIds, giving): listType = type([]) possibleTypes = (type(1), type(0x1L), listType) for i in tradeItems: for v in i: itemType = type(v) if itemType not in possibleTypes: raise AITradeException, "element is the wrong type" if v > 0xFFFFFFFFL and itemType != listType: raise AITradeException, "element is larger than unsigned long" continue else: t = i[TypeIndex] if InventoryId.isLimitChange(t): a = limitChanges.setdefault(t, [t, 0]) a[1] += i[QuantityIndex] if a[1] > 0xFFFFL: raise AITradeException, "element is larger than unsigned short" if InventoryId.isStackable(t): a = stacks.setdefault(t, [t, 0]) a[1] += i[QuantityIndex] if a[1] > 0xFFFFL: raise AITradeException, "element is larger than unsigned short" a[1] > 0xFFFFL if isLocatable(t): inv = simbase.air.doId2do.get(self.inventoryId) if inv: theInvItem = InvItem(i) theInvItemType = theInvItem.getType() if giving: equippableInfo = inv.getItemRequirements(theInvItemType, self.giving) if ( ( equippableInfo == None or filter(lambda x: equippableInfo[x][1] == False, equippableInfo) ) and theInvItemType and theInvItemType not in self.unequippables ): self.unequippables.append(theInvItemType) if isStackableType(theInvItem.getCat()): for currLocatable in locatable: prevInvItem = InvItem(currLocatable) if prevInvItem.compare(theInvItem, excludeLoc=True): adjustedInvItem = prevInvItem.adjustCount(theInvItem.getCount()) locatable.remove(currLocatable) i = list(adjustedInvItem) break continue else: raise AITradeException, "inventory not present" locatable.append(i) continue if InventoryId.isAccumulator(t): a = accumulators.setdefault(t, [t, 0]) a[1] += i[QuantityIndex] if a[1] > 0xFFFFFFFFL: raise AITradeException, "element is larger than unsigned long" a[1] > 0xFFFFFFFFL if InventoryId.isDoId(t): doIds[i[DoIdIndex]] = i continue