| 398 | } |
| 399 | |
| 400 | bool WeaponsInfo::Import(const ParamEntry& superclass) |
| 401 | { |
| 402 | const ParamEntry* cls = superclass.FindEntry("Weapons"); |
| 403 | if (cls) |
| 404 | { |
| 405 | int mask = MaskSlotPrimary | MaskSlotSecondary | MaskSlotBinocular | MaskSlotHandGun; |
| 406 | for (int i = 0; i < cls->GetEntryCount(); i++) |
| 407 | { |
| 408 | const ParamEntry& entry = cls->GetEntry(i); |
| 409 | Ref<WeaponType> weapon = WeaponTypes.New(entry.GetName()); |
| 410 | if (!weapon) |
| 411 | { |
| 412 | continue; |
| 413 | } |
| 414 | if (weapon->_scope < 2) |
| 415 | { |
| 416 | continue; |
| 417 | } |
| 418 | if ((weapon->_weaponType & mask) == 0) |
| 419 | { |
| 420 | continue; |
| 421 | } |
| 422 | int count = entry >> "count"; |
| 423 | for (int j = 0; j < count; j++) |
| 424 | { |
| 425 | _weaponsPool.Add(weapon); |
| 426 | } |
| 427 | } |
| 428 | } |
| 429 | cls = superclass.FindEntry("Magazines"); |
| 430 | if (cls) |
| 431 | { |
| 432 | int mask = MaskSlotItem | MaskSlotHandGunItem; |
| 433 | for (int i = 0; i < cls->GetEntryCount(); i++) |
| 434 | { |
| 435 | const ParamEntry& entry = cls->GetEntry(i); |
| 436 | Ref<MagazineType> type = MagazineTypes.New(entry.GetName()); |
| 437 | if (!type) |
| 438 | { |
| 439 | continue; |
| 440 | } |
| 441 | if (type->_scope < 2) |
| 442 | { |
| 443 | continue; |
| 444 | } |
| 445 | if ((type->_magazineType & mask) == 0) |
| 446 | { |
| 447 | continue; |
| 448 | } |
| 449 | int count = entry >> "count"; |
| 450 | for (int j = 0; j < count; j++) |
| 451 | { |
| 452 | Ref<Magazine> magazine = new Magazine(type); |
| 453 | magazine->_ammo = type->_maxAmmo; |
| 454 | magazine->_reloadMagazine = 0; |
| 455 | magazine->_reload = 0; |
| 456 | if (type->_modes.Size() > 0) |
| 457 | { |
no test coverage detected