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
7 changes: 6 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 Expand Up @@ -8726,6 +8728,7 @@ void HouseClass::Update_Present_Super_Weapons(void)
if (PlayerPtr != NULL && Fetch_ID() == PlayerPtr->Fetch_ID()) {
if (Map.IsTargettingMode == s) {
Map.IsTargettingMode = SUPER_NONE;
PlayerPtr->TargetingSW = NULL;
}
Map.Column[1].Flag_To_Redraw();
}
Expand All @@ -8736,6 +8739,7 @@ void HouseClass::Update_Present_Super_Weapons(void)
if (PlayerPtr != NULL && Fetch_ID() == PlayerPtr->Fetch_ID()) {
if (s == Map.IsTargettingMode) {
Map.IsTargettingMode = SUPER_NONE;
PlayerPtr->TargetingSW = NULL;
}
Map.Column[1].Flag_To_Redraw();
}
Expand All @@ -8746,6 +8750,7 @@ void HouseClass::Update_Present_Super_Weapons(void)
if (Fetch_ID() == PlayerPtr->Fetch_ID()) {
if (Map.IsTargettingMode == s) {
Map.IsTargettingMode = SUPER_NONE;
PlayerPtr->TargetingSW = NULL;
}
Map.Column[1].Flag_To_Redraw();
}
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
1 change: 1 addition & 0 deletions code/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4927,6 +4927,7 @@ class ManualPlaceCommandClass : public CommandClass

// Drop any superweapon cursor, so that placing the building does not return to it.
Map.IsTargettingMode = SUPER_NONE;
PlayerPtr->TargetingSW = NULL;

PlayerPtr->Manual_Place(builder, (BuildingClass *)pending);
}
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
5 changes: 5 additions & 0 deletions code/super.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ void SuperClass::Place(Cell const & cell, bool player)
Drop_Pods(cell);
if (player) {
Map.IsTargettingMode = SUPER_NONE;
PlayerPtr->TargetingSW = NULL;
}
House->IsRecalcNeeded = true;
break;
Expand All @@ -619,6 +620,7 @@ void SuperClass::Place(Cell const & cell, bool player)
if (coord != COORD_NONE) {
if (player) {
Map.IsTargettingMode = SUPER_NONE;
PlayerPtr->TargetingSW = NULL;
}
House->IsRecalcNeeded = true;
new IonBlastClass(coord);
Expand Down Expand Up @@ -656,6 +658,7 @@ void SuperClass::Place(Cell const & cell, bool player)
}
if (player) {
Map.IsTargettingMode = SUPER_NONE;
PlayerPtr->TargetingSW = NULL;
}
House->IsRecalcNeeded = true;
}
Expand Down Expand Up @@ -698,6 +701,7 @@ void SuperClass::Place(Cell const & cell, bool player)
}
if (player) {
Map.IsTargettingMode = SUPER_NONE;
PlayerPtr->TargetingSW = NULL;
}
House->IsRecalcNeeded = true;
} else {
Expand Down Expand Up @@ -726,6 +730,7 @@ void SuperClass::Place(Cell const & cell, bool player)
}
if (player) {
Map.IsTargettingMode = SUPER_NONE;
PlayerPtr->TargetingSW = NULL;
}
House->IsRecalcNeeded = true;
}
Expand Down
20 changes: 20 additions & 0 deletions manual/changes/fix-sw-shadowing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: Keep superweapons that share an Action from replacing each other
category: fix
release: 0.2.0
targets:
- type: system
id: superweapons
effect: changed
credit: [Templarfreak]
---

Placing a superweapon on the map now fires the one that was actually armed, even when
another superweapon defines the same Action. Clicking a target cell previously resolved
back to whichever superweapon type first matched that Action, so two superweapons sharing
one Action value could not be fired independently: placing either one always discharged
the same type and left the other's charge untouched.

The game now remembers the specific superweapon that was armed from the sidebar and fires
that one directly, falling back to the old Action lookup only when nothing was armed
through the sidebar.