1346 {
1347 int muzzleIndex = wpn.GetCurrentMuzzle();
1348 Magazine old_mag = Magazine.Cast(wpn.GetMagazine(muzzleIndex));
1349 InventoryLocation temp = new InventoryLocation();
1350
1351 if (old_mag)
1352 {
1353 bool result = GameInventory.CanSwapEntitiesEx(new_mag, old_mag);
1354 if ( result )
1355 {
1356 new_mag.GetInventory().GetCurrentInventoryLocation(new_il);
1357 new_il.SetItem(old_mag);
1358 }
1359 else
1360 {
1361 result = GameInventory.CanForceSwapEntitiesEx(new_mag, null, old_mag, new_il);
1362 if ( !result )
1363 {
1364 vector rotationMatrix[3];
1365 float dir[4];
1366 Math3D.YawPitchRollMatrix(
m_player.GetOrientation(), rotationMatrix);
1367 Math3D.MatrixToQuat(rotationMatrix, dir);
1368 new_il.SetGroundEx( old_mag,
m_player.GetPosition(), dir);
1369 }
1370 }
1371 }
1372 return true;
1373 }