Skip to content

Commit

Permalink
Allow demolishing departed ally structures
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Nov 3, 2023
1 parent d5b7444 commit 52c563f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1736,7 +1736,12 @@ void actionUpdateDroid(DROID *psDroid)
}
else if (order->type == DORDER_DEMOLISH && structureAtPos->player != psDroid->player)
{
cantDoRepairLikeAction = true;
bool ObjAllied = (aiCheckAlliances(psDroid->player, structureAtPos->player));
bool ObjDepartedAlly = (bMultiPlayer && NetPlay.players[structureAtPos->player].difficulty == AIDifficulty::HUMAN && !NetPlay.players[structureAtPos->player].allocated);
if (!ObjAllied || !ObjDepartedAlly)
{
cantDoRepairLikeAction = true;
}
}

if (cantDoRepairLikeAction)
Expand Down
6 changes: 4 additions & 2 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,7 @@ void processMouseClickInput()

ASSERT(selectedPlayer < MAX_PLAYERS, "selectedPlayer is too high: %" PRIu32 "", selectedPlayer);
ObjAllied = (ObjUnderMouse && selectedPlayer != ObjUnderMouse->player && aiCheckAlliances(selectedPlayer, ObjUnderMouse->player));
bool ObjDepartedAlly = (ObjUnderMouse && bMultiPlayer && NetPlay.players[ObjUnderMouse->player].difficulty == AIDifficulty::HUMAN && !NetPlay.players[ObjUnderMouse->player].allocated);

if (item != MT_NOTARGET)
{
Expand Down Expand Up @@ -820,7 +821,7 @@ void processMouseClickInput()
else if (selection == SC_DROID_DEMOLISH)
{
// Can't demolish allied objects, or something that isn't built yet
if (ObjAllied || (ObjUnderMouse && (ObjUnderMouse->type != OBJ_STRUCTURE || (((STRUCTURE *)ObjUnderMouse)->status == SS_BLUEPRINT_PLANNED))))
if ((ObjAllied && !ObjDepartedAlly) || (ObjUnderMouse && (ObjUnderMouse->type != OBJ_STRUCTURE || (((STRUCTURE *)ObjUnderMouse)->status == SS_BLUEPRINT_PLANNED))))
{
item = MT_BLOCKING;
}
Expand Down Expand Up @@ -920,7 +921,8 @@ void processMouseClickInput()
arnMPointers[item][selection] == CURSOR_EMBARK ||
arnMPointers[item][selection] == CURSOR_ATTACH ||
arnMPointers[item][selection] == CURSOR_LOCKON ||
arnMPointers[item][selection] == CURSOR_DEST) && ObjAllied)
arnMPointers[item][selection] == CURSOR_DEST) && ObjAllied
&& (selection != SC_DROID_DEMOLISH || !ObjDepartedAlly))
{
// If you want to do these things, just gift your unit to your ally.
item = MT_BLOCKING;
Expand Down
4 changes: 3 additions & 1 deletion src/order.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2724,7 +2724,9 @@ DroidOrder chooseOrderObj(DROID *psDroid, BASE_OBJECT *psObj, bool altOrder)
int moduleIndex = nextModuleToBuild(psStruct, ctrlShiftDown() ? highestQueuedModule(psDroid, psStruct) : -1);

//Re-written to allow demolish order to be added to the queuing system
if (intDemolishSelectMode() && psObj->player == psDroid->player)
bool ObjDepartedAlly = (bMultiPlayer && NetPlay.players[psObj->player].difficulty == AIDifficulty::HUMAN && !NetPlay.players[psObj->player].allocated);
if (intDemolishSelectMode()
&& (psObj->player == psDroid->player || ObjDepartedAlly))
{
//check to see if anything is currently trying to build the structure
//can't build and demolish at the same time!
Expand Down

0 comments on commit 52c563f

Please sign in to comment.