Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: #2659 - Mek Quad turret firing arc reflects turret rotation changes. #5373

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions megamek/src/megamek/client/ui/swing/TurretFacingDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,34 @@ public void actionPerformed(ActionEvent ae) {
} else {
locToChange = turret.getLocation();
}

Mounted firstMountedWeapon = null; // Take note of the first weapon mounted on this turret.
Mounted currentSelectedWeapon = null; // Take note of current selected weapon.
if (clientgui.getUnitDisplay() != null) {
currentSelectedWeapon = clientgui.getUnitDisplay().wPan.getSelectedWeapon();
}

for (Mounted weapon : mech.getWeaponList()) {
if ((weapon.getLocation() == locToChange) && weapon.isMechTurretMounted()) {
weapon.setFacing(facing);
clientgui.getClient().sendMountFacingChange(mech.getId(), mech.getEquipmentNum(weapon), facing);

// Tag the first mounted weapon as a backup option to refresh after the turret rotation.
if (firstMountedWeapon == null) {
firstMountedWeapon = weapon;
}

// If the currently selected weapon is in the turret, refresh it by default.
if (mech.getEquipmentNum(currentSelectedWeapon) == mech.getEquipmentNum(weapon)) {
firstMountedWeapon = currentSelectedWeapon;
}
}
}

// Select the mounted weapon in the unit display to refresh the firing arch.
if (clientgui.getUnitDisplay() != null) {
clientgui.getUnitDisplay().wPan.selectWeapon(mech.getEquipmentNum(firstMountedWeapon));
}
} else if (tank != null) {
tank.setDualTurretOffset(((6 - tank.getFacing()) + facing) % 6);
clientgui.getClient().sendUpdateEntity(tank);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2191,6 +2191,10 @@ private void setFieldOfFire(Mounted mounted) {
if (entity.isSecondaryArcWeapon(entity.getEquipmentNum(mounted))) {
facing = entity.getSecondaryFacing();
}
// If this is mech with turrets, check to see if the weapon is on a turret.
if ((entity instanceof Mech) && (entity.getEquipment(weaponId).isMechTurretMounted())) {
facing = mounted.getFacing();
}
// If this is a tank with dual turrets, check to see if the weapon is a second turret.
if ((entity instanceof Tank) &&
(entity.getEquipment(weaponId).getLocation() == ((Tank) entity).getLocTurret2())) {
Expand Down
Loading