MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / PoolSetWeapons

Function PoolSetWeapons

engine/Poseidon/UI/OptionsUI.cpp:1376–1432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1374 if (!weapon)
1375 {
1376 continue;
1377 }
1378 veh->AddWeaponCargo(weapon, mh.weapons[i].count);
1379 }
1380
1381 for (int i = 0; i < mh.magazines.Size(); i++)
1382 {
1383 RString name = mh.magazines[i].name;
1384 Ref<MagazineType> magazine = MagazineTypes.New(name);
1385 if (!magazine)
1386 {
1387 continue;
1388 }
1389 veh->AddMagazineCargo(magazine, mh.magazines[i].count);
1390 }
1391
1392 mh.weapons.Clear();
1393 mh.magazines.Clear();
1394
1395 return GameValue();
1396}
1397
1398GameValue PoolSetWeapons(const GameState* state, GameValuePar oper1)
1399{
1400 Object* obj = ::GetObject(oper1);
1401 if (!obj)
1402 {
1403 return GameValue();
1404 }
1405
1406 VehicleSupply* veh = dyn_cast<VehicleSupply>(obj);
1407 if (!veh)
1408 {
1409 return GameValue();
1410 }
1411
1412 int i = GetGCampaignHistory().battles.Size() - 1;
1413 if (i < 0)
1414 {
1415 return GameValue();
1416 }
1417 BattleHistory& bh = GetGCampaignHistory().battles[i];
1418 i = bh.missions.Size() - 1;
1419 if (i < 0)
1420 {
1421 return GameValue();
1422 }
1423 MissionHistory& mh = bh.missions[i];
1424
1425 // mh.weapons.Clear();
1426 // mh.magazines.Clear();
1427
1428 for (int i = 0; i < veh->GetWeaponCargoSize(); i++)
1429 {
1430 const WeaponType* weapon = veh->GetWeaponCargo(i);
1431 if (!weapon)
1432 {
1433 continue;

Callers

nothing calls this directly

Calls 12

GetWeaponCargoSizeMethod · 0.80
GetWeaponCargoMethod · 0.80
AddWeaponsMethod · 0.80
GetMagazineCargoSizeMethod · 0.80
GetMagazineCargoMethod · 0.80
AddMagazinesMethod · 0.80
ClearWeaponCargoMethod · 0.80
ClearMagazineCargoMethod · 0.80
GetObjectFunction · 0.50
GameValueClass · 0.50
SizeMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected