300{
303 OOScript *marketScript = [PLAYER commodityScriptNamed:marketScriptName];
304 if (marketDefinition ==
nil && marketScript ==
nil)
305 {
307 return market;
308 }
309
313
314 NSString *commodity =
nil;
315 NSDictionary *good =
nil;
317 {
318 good = [_commodityLists oo_dictionaryForKey:commodity];
319 OOCargoQuantity baseCapacity = [good oo_unsignedIntForKey:kOOCommodityCapacity defaultValue:MAIN_SYSTEM_MARKET_LIMIT];
320
321
323
326
327 if (marketScript ==
nil)
328 {
329 NSDictionary *modifier = [self firstModifierForGood:commodity inClasses:[good oo_arrayForKey:kOOCommodityClasses] fromList:marketDefinition];
330 good = [self updateInfoFor:good byRule:modifier maxCapacity:capacity];
331 p = [self adjustPrice:p byRule:modifier];
332
333
334 OOCargoQuantity localCapacity = [good oo_unsignedIntForKey:kOOCommodityCapacity];
335 if (localCapacity > capacity)
336 {
337 localCapacity = capacity;
338 }
339 q = (q * localCapacity) / baseCapacity;
340 q = [self adjustQuantity:q byRule:modifier];
341 if (q > localCapacity)
342 {
343 q = localCapacity;
344 }
345 }
346 else
347 {
348
349 q = (q * capacity) / baseCapacity;
350 }
351
352 good = [self createDefinitionFrom:good price:p andQuantity:q forKey:commodity atStation:station inSystem:[UNIVERSE currentSystemID]];
353 if (marketScript !=
nil)
354 {
355 good = [self modifyGood:good withScript:marketScript atStation:station inSystem:[UNIVERSE currentSystemID] localMode:YES];
356 }
357
359 }
360 return [market autorelease];
361}
#define MAIN_SYSTEM_MARKET_LIMIT
OOCargoQuantity quantityForGood:(OOCommodityType good)
OOCreditsQuantity priceForGood:(OOCommodityType good)
OOCargoQuantity marketCapacity
NSArray * marketDefinition
NSString * marketScriptName