| 310 | } |
| 311 | |
| 312 | bool WeaponsInfo::Load(RString filename) |
| 313 | { |
| 314 | ParamArchiveLoad ar; |
| 315 | if (!ar.LoadBin(filename) && ar.Load(filename) != LSOK) |
| 316 | { |
| 317 | return false; |
| 318 | } |
| 319 | ar.FirstPass(); |
| 320 | if (Serialize(ar) != LSOK) |
| 321 | { |
| 322 | return false; |
| 323 | } |
| 324 | ar.SecondPass(); |
| 325 | if (Serialize(ar) != LSOK) |
| 326 | { |
| 327 | return false; |
| 328 | } |
| 329 | |
| 330 | // assign new ID to all magazines |
| 331 | for (int i = 0; i < _weapons.Size(); i++) |
| 332 | { |
| 333 | UnitWeaponsInfo& info = _weapons[i]; |
| 334 | for (int j = 0; j < MAGAZINE_SLOTS;) |
| 335 | { |
| 336 | Magazine* magazine = info.magazines[j++]; |
| 337 | if (!magazine) |
| 338 | { |
| 339 | continue; |
| 340 | } |
| 341 | int oldId = magazine->_id; |
| 342 | magazine->_id = GWorld->GetMagazineID(); |
| 343 | while (j < MAGAZINE_SLOTS) |
| 344 | { |
| 345 | Magazine* m = info.magazines[j]; |
| 346 | if (!m || m->_id != oldId) |
| 347 | { |
| 348 | break; |
| 349 | } |
| 350 | info.magazines[j++] = magazine; |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | for (int j = 0; j < _magazinesPool.Size();) |
| 356 | { |
| 357 | Magazine* magazine = _magazinesPool[j++]; |
| 358 | if (!magazine) |
| 359 | { |
| 360 | continue; |
| 361 | } |
| 362 | int oldId = magazine->_id; |
| 363 | magazine->_id = GWorld->GetMagazineID(); |
| 364 | while (j < _magazinesPool.Size()) |
| 365 | { |
| 366 | Magazine* m = _magazinesPool[j]; |
| 367 | if (!m || m->_id != oldId) |
| 368 | { |
| 369 | break; |
no test coverage detected