diff --git a/code/display.cpp b/code/display.cpp index 373ac53..a3943d2 100644 --- a/code/display.cpp +++ b/code/display.cpp @@ -136,6 +136,7 @@ #include "smudtype.h" #include "sidebar.h" #include "suprtype.h" +#include "super.h" #include "surface.h" #include "tactical.h" #include "tag.h" @@ -1831,6 +1832,7 @@ void DisplayClass::Mouse_Right_Release(Point2D const & point) } else { if (IsTargettingMode != SUPER_NONE) { IsTargettingMode = SUPER_NONE; + PlayerPtr->TargetingSW = NULL; } else { if (IsWaypointMode) { Waypoint_Mode_Control(0); @@ -2427,10 +2429,18 @@ void DisplayClass::Mouse_Left_Release(Coord const & coord, Cell const & cell, Ob } } - SuperWeaponTypeClass *stype = SuperWeaponTypeClass::From_Action(action); + SuperWeaponTypeClass *stype; + if (PlayerPtr->TargetingSW != NULL) { + stype = PlayerPtr->TargetingSW->Class; + } else { + stype = SuperWeaponTypeClass::From_Action(action); + } + if (stype != NULL) { OutList.push_back(EventClass(PlayerPtr->HeapID, EventClass::SPECIAL_PLACE, stype->HeapID, cell)); } + + PlayerPtr->TargetingSW = NULL; } IsTentative = false; diff --git a/code/house.cpp b/code/house.cpp index 9f25998..aff4be9 100644 --- a/code/house.cpp +++ b/code/house.cpp @@ -355,7 +355,8 @@ HouseClass::HouseClass(HouseTypeClass const * type) : EnemyArmorForcePrediction(0.33f), EnemyAirForcePrediction(0.33f), EnemyInfantryForcePrediction(0.34f), - PowerSurplus(0) + PowerSurplus(0), + TargetingSW(NULL) { int index; @@ -6491,6 +6492,7 @@ void HouseClass::Serialize(SaveStreamClass & stream) stream.Serialize(EnemyAirForcePrediction); stream.Serialize(EnemyInfantryForcePrediction); stream.Serialize(PowerSurplus); + stream.Serialize(TargetingSW); } diff --git a/code/house.h b/code/house.h index 604f5f2..8e78e31 100644 --- a/code/house.h +++ b/code/house.h @@ -416,6 +416,11 @@ class HouseClass : public AbstractClass */ DynamicVectorClass SuperWeapon; + /* + ** Superweapon class currently in targeting mode for house. + */ + SuperClass * TargetingSW; + /* ** This is a record of the last building that was built. For buildings that ** were built as a part of scenario creation, it will be the last one diff --git a/code/sidebar.cpp b/code/sidebar.cpp index 4ca1411..2eaaaf9 100644 --- a/code/sidebar.cpp +++ b/code/sidebar.cpp @@ -2146,6 +2146,7 @@ int SidebarClass::StripClass::SelectClass::Action(unsigned flags, KeyNumType & k */ if (flags & RIGHTPRESS) { Map.IsTargettingMode = SUPER_NONE; + PlayerPtr->TargetingSW = NULL; } /* ** A left mouse press signal "activate". If our weapon type is @@ -2154,16 +2155,19 @@ int SidebarClass::StripClass::SelectClass::Action(unsigned flags, KeyNumType & k if (flags & LEFTPRESS) { if ((unsigned)spc < (unsigned)PlayerPtr->SuperWeapon.Count()) { - if (PlayerPtr->SuperWeapon[spc]->Can_Place()) { - if (PlayerPtr->SuperWeapon[spc]->Class->Action == ACTION_NONE) { + SuperClass* curr_sw = PlayerPtr->SuperWeapon[spc]; + if (curr_sw->Can_Place()) { + if (curr_sw->Class->Action == ACTION_NONE) { OutList.push_back(EventClass(PlayerPtr->HeapID, EventClass::SPECIAL_PLACE, PlayerPtr->SuperWeapon[spc]->Class->HeapID, Cell(0, 0))); } else { + PlayerPtr->TargetingSW = curr_sw; Map.IsTargettingMode = spc; Unselect_All(); Speak(VOX_SELECT_TARGET); } } else { PlayerPtr->SuperWeapon[spc]->Impatient_Click(); + PlayerPtr->TargetingSW = NULL; } } }