Skip to content
Open
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
12 changes: 11 additions & 1 deletion code/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion code/house.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -6491,6 +6492,7 @@ void HouseClass::Serialize(SaveStreamClass & stream)
stream.Serialize(EnemyAirForcePrediction);
stream.Serialize(EnemyInfantryForcePrediction);
stream.Serialize(PowerSurplus);
stream.Serialize(TargetingSW);
}


Expand Down
5 changes: 5 additions & 0 deletions code/house.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ class HouseClass : public AbstractClass
*/
DynamicVectorClass<SuperClass *> 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
Expand Down
8 changes: 6 additions & 2 deletions code/sidebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
}
}
Expand Down