From c269aada29deee6b6f77f9af5bc608a885e59e69 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 31 Dec 2021 01:40:13 -0600 Subject: [PATCH 1/3] Enforce max transports as intended. The number of transports sent is only capped for logging purposes, not actual functional effect. --- src/rotp/model/colony/Colony.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rotp/model/colony/Colony.java b/src/rotp/model/colony/Colony.java index 08a4dd338..ad8994186 100644 --- a/src/rotp/model/colony/Colony.java +++ b/src/rotp/model/colony/Colony.java @@ -947,7 +947,7 @@ public void scheduleTransportsToSystem(StarSystem dest, int pop) { if ((dest == starSystem()) || (xPop == 0)) clearTransport(); else { - transport().size(pop); + transport().size(xPop); transport().setDest(dest); transport().setDefaultTravelSpeed(); } From a8f52312521f241135a04ac629d29c71252696b6 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 3 Jan 2022 23:33:41 -0600 Subject: [PATCH 2/3] Improved fix for enforcement of max transports. Also documented exploit made possible by current implementation of abandonment, for future work. --- src/rotp/model/colony/Colony.java | 13 ++++++++----- src/rotp/ui/main/TransportDeploymentPanel.java | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/rotp/model/colony/Colony.java b/src/rotp/model/colony/Colony.java index 3da57c9fa..cde3674b4 100644 --- a/src/rotp/model/colony/Colony.java +++ b/src/rotp/model/colony/Colony.java @@ -39,6 +39,7 @@ import rotp.model.tech.TechMissileWeapon; import rotp.model.tech.TechTree; import rotp.ui.RotPUI; +import rotp.ui.main.TransportDeploymentPanel; import rotp.ui.notifications.GNNNotification; import rotp.ui.notifications.InvadersKilledAlert; import rotp.ui.notifications.TransportsKilledAlert; @@ -946,13 +947,15 @@ public void scheduleTransportsToSystem(StarSystem dest, int pop, float travelTim } } public void scheduleTransportsToSystem(StarSystem dest, int pop) { - // adjust pop to max allowed - - int xPop = min(pop, maxTransportsAllowed()); - log("Scheduling " + xPop + " transports from: " + starSystem().name() + " to: " + dest.name()); + // If pop is the entire current population then accept it if abandonment is + // permitted, otherwise adjust it to the max allowed. + if (pop < population() || !TransportDeploymentPanel.enableAbandon) { + pop = min(pop, maxTransportsAllowed()); + } + log("Scheduling " + pop + " transports from: " + starSystem().name() + " to: " + dest.name()); // if zero or to this system, then clear - if ((dest == starSystem()) || (xPop == 0)) + if ((dest == starSystem()) || (pop == 0)) clearTransport(); else { transport().size(xPop); diff --git a/src/rotp/ui/main/TransportDeploymentPanel.java b/src/rotp/ui/main/TransportDeploymentPanel.java index 1ef302a92..b4a5aff57 100644 --- a/src/rotp/ui/main/TransportDeploymentPanel.java +++ b/src/rotp/ui/main/TransportDeploymentPanel.java @@ -46,6 +46,22 @@ public class TransportDeploymentPanel extends SystemPanel { private static final long serialVersionUID = 1L; + // NOTE: This use of a public static variable needs rework because it permits an in-game exploit: + // - Pick a system and abandon it to any valid target (own) system. + // - Select the same source system and click "Send Transports". + // - Choose any valid target system (which can include an enemy system). + // - Adjust the population to any value greater than half of but below the current full colony size. + // - Click the green "Send Transports" button to confirm. + // - Next turn the game ships the specified number of transports without abandoning the colony. + // This can be used to muster force against an enemy in excess of what should be possible, but + // it can also be used defensively or economically to rapidly populate one's own system(s) from + // back-line colonies. + // The essential nature of the issue is that committing the abandon action sets this global flag + // indefinitely until the regular transport action is invoked on some system. The most effective + // solution is to make the abandonment (intent) flag transient to the UI action and capture it + // elsewhere, perhaps in the transport object itself or in the colony object (latter would require + // differentiation from the "abandoned" flag that gets set when the population actually + // gets shipped). public static boolean enableAbandon = false; protected BasePanel topPane; protected BasePanel detailPane; From 0e21c9e53f52bc62c2c9d5c5e6591cb14547712e Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 3 Jan 2022 23:38:54 -0600 Subject: [PATCH 3/3] Reconcile rebase. --- src/rotp/model/colony/Colony.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rotp/model/colony/Colony.java b/src/rotp/model/colony/Colony.java index cde3674b4..9455170a0 100644 --- a/src/rotp/model/colony/Colony.java +++ b/src/rotp/model/colony/Colony.java @@ -958,7 +958,7 @@ public void scheduleTransportsToSystem(StarSystem dest, int pop) { if ((dest == starSystem()) || (pop == 0)) clearTransport(); else { - transport().size(xPop); + transport().size(pop); transport().setDest(dest); transport().setDefaultTravelSpeed(); }