From a2d5ac6a236ff69a6e462f8853a626ef05336737 Mon Sep 17 00:00:00 2001 From: Jaghaimo <1764586+jaghaimo@users.noreply.github.com> Date: Sun, 23 Apr 2023 09:44:27 +0100 Subject: [PATCH] Bugfix release 2.6.2 (#97) - Fix self nuking by making another call while within a call. - Fix visual bug by showing a contact while within a call. - Fix neutral faction crest using flag instead (upstream bug). - Fix excluder filtering (incorrect id in csv file). - Reduce minimum quantity for profit calculation. - Treat contact calls while docked at contact's location as vanilla calls. - Reset cache on game load and dev reload (avoids memory leak with Nexerelin enabled). --- .vscode/extensions.json | 7 ++--- .../stelnet/exclude/market_by_faction.csv | 2 +- assets/data/stelnet/exclude/market_by_id.csv | 2 +- .../data/stelnet/exclude/market_by_system.csv | 2 +- assets/data/stelnet/exclude/market_by_tag.csv | 2 +- assets/data/world/factions/neutral.faction | 4 +++ assets/mod_info.json | 2 +- assets/stelnet.version | 4 +-- src/stelnet/StelnetMod.java | 9 ++++++ .../board/commodity/table/ProfitTableRow.java | 2 +- src/stelnet/board/contact/CallContact.java | 5 +++- src/stelnet/board/contact/ContactDialog.java | 29 ++++++++++++++++--- src/stelnet/board/contact/ContactsBoard.java | 13 +++++++++ .../board/contact/ShowContactButton.java | 1 + .../board/query/provider/SkillProvider.java | 6 +++- src/stelnet/util/Configurator.java | 15 ++++++++++ src/stelnet/util/ModConstants.java | 5 ++++ 17 files changed, 92 insertions(+), 18 deletions(-) create mode 100644 assets/data/world/factions/neutral.faction diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 01fd479f4..360b3f2c9 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,15 +1,14 @@ { // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp - // List of extensions which should be recommended for users of this workspace. "recommendations": [ "esbenp.prettier-vscode", - "gabrielbb.vscode-lombok", "naco-siren.gradle-language", "vscjava.vscode-gradle", - "vscjava.vscode-java-pack" + "vscjava.vscode-java-pack", + "vscjava.vscode-lombok" ], // List of extensions recommended by VS Code that should not be recommended for users of this workspace. "unwantedRecommendations": [] -} +} \ No newline at end of file diff --git a/assets/data/stelnet/exclude/market_by_faction.csv b/assets/data/stelnet/exclude/market_by_faction.csv index 0f4f76ad1..05a536691 100644 --- a/assets/data/stelnet/exclude/market_by_faction.csv +++ b/assets/data/stelnet/exclude/market_by_faction.csv @@ -1 +1 @@ -faction id +id \ No newline at end of file diff --git a/assets/data/stelnet/exclude/market_by_id.csv b/assets/data/stelnet/exclude/market_by_id.csv index c836235aa..074d1eeb4 100644 --- a/assets/data/stelnet/exclude/market_by_id.csv +++ b/assets/data/stelnet/exclude/market_by_id.csv @@ -1 +1 @@ -market id +id diff --git a/assets/data/stelnet/exclude/market_by_system.csv b/assets/data/stelnet/exclude/market_by_system.csv index f1ea03a1c..074d1eeb4 100644 --- a/assets/data/stelnet/exclude/market_by_system.csv +++ b/assets/data/stelnet/exclude/market_by_system.csv @@ -1 +1 @@ -system id +id diff --git a/assets/data/stelnet/exclude/market_by_tag.csv b/assets/data/stelnet/exclude/market_by_tag.csv index 42c7c82cc..074d1eeb4 100644 --- a/assets/data/stelnet/exclude/market_by_tag.csv +++ b/assets/data/stelnet/exclude/market_by_tag.csv @@ -1 +1 @@ -tag +id diff --git a/assets/data/world/factions/neutral.faction b/assets/data/world/factions/neutral.faction new file mode 100644 index 000000000..8b267d28b --- /dev/null +++ b/assets/data/world/factions/neutral.faction @@ -0,0 +1,4 @@ +{ + "id": "neutral", + "crest": "graphics/factions/crest_neutral.png" +} \ No newline at end of file diff --git a/assets/mod_info.json b/assets/mod_info.json index 661df04cb..29ff88feb 100644 --- a/assets/mod_info.json +++ b/assets/mod_info.json @@ -3,7 +3,7 @@ "name": "Stellar Networks", "author": "Jaghaimo", "utility": true, - "version": "2.6.1", + "version": "2.6.2", "description": "A collection of intel boards for Starsector", "gameVersion": "0.95.1a-RC6", "modPlugin": "stelnet.StelnetMod", diff --git a/assets/stelnet.version b/assets/stelnet.version index efca6fc58..8cbe59fa2 100644 --- a/assets/stelnet.version +++ b/assets/stelnet.version @@ -5,7 +5,7 @@ "modVersion": { "major": 2, "minor": 6, - "patch": 1 + "patch": 2 }, - "directDownloadURL": "https://github.com/jaghaimo/stelnet/releases/download/2.6.1/stelnet-2.6.1.zip" + "directDownloadURL": "https://github.com/jaghaimo/stelnet/releases/download/2.6.2/stelnet-2.6.2.zip" } \ No newline at end of file diff --git a/src/stelnet/StelnetMod.java b/src/stelnet/StelnetMod.java index fad5b6feb..e50c7d0ab 100644 --- a/src/stelnet/StelnetMod.java +++ b/src/stelnet/StelnetMod.java @@ -21,6 +21,7 @@ public void afterGameSave() { @Override public void beforeGameSave() { + Configurator.resetCache(); if (ConfigConstants.UNINSTALL_MOD) { Configurator.deactivate(false); } @@ -34,10 +35,18 @@ public void onApplicationLoad() throws Exception { @Override public void onGameLoad(boolean newGame) { + Configurator.resetCache(); if (TutorialMissionIntel.isTutorialInProgress()) { Configurator.deactivate(true); return; } Configurator.activate(); } + + @Override + public void onDevModeF8Reload() { + Configurator.deactivate(false); + Configurator.resetCache(); + Configurator.activate(); + } } diff --git a/src/stelnet/board/commodity/table/ProfitTableRow.java b/src/stelnet/board/commodity/table/ProfitTableRow.java index 9cd069054..0e52043f8 100644 --- a/src/stelnet/board/commodity/table/ProfitTableRow.java +++ b/src/stelnet/board/commodity/table/ProfitTableRow.java @@ -19,7 +19,7 @@ @RequiredArgsConstructor public class ProfitTableRow implements Comparable, TableContentRow { - private static final int MINIMUM_QUANTITY = 1000; + private static final int MINIMUM_QUANTITY = 100; private final List elements = new LinkedList<>(); private final MarketAPI buyMarket; diff --git a/src/stelnet/board/contact/CallContact.java b/src/stelnet/board/contact/CallContact.java index cd4a153dd..6ce083aa0 100644 --- a/src/stelnet/board/contact/CallContact.java +++ b/src/stelnet/board/contact/CallContact.java @@ -13,13 +13,16 @@ public class CallContact extends Button { public CallContact(String label, Size size, final MarketAPI market, final PersonAPI person) { super(size, label, true, person.getFaction().getBrightUIColor(), person.getFaction().getDarkUIColor()); - setEnabled(market.hasSubmarket(Submarkets.SUBMARKET_STORAGE)); + boolean hasSubmarket = market.hasSubmarket(Submarkets.SUBMARKET_STORAGE); + boolean isCalling = ContactsBoard.isCalling(); + setEnabled(hasSubmarket && !isCalling); setCutStyle(CutStyle.C2_MENU); setPadding(0); setHandler( new EventHandler() { @Override public void onConfirm(IntelUIAPI ui) { + ContactsBoard.registerCall(); ui.showDialog( market.getPrimaryEntity(), new ContactDialog(ui, person, market.getSubmarket(Submarkets.SUBMARKET_STORAGE)) diff --git a/src/stelnet/board/contact/ContactDialog.java b/src/stelnet/board/contact/ContactDialog.java index 32c548442..874099694 100644 --- a/src/stelnet/board/contact/ContactDialog.java +++ b/src/stelnet/board/contact/ContactDialog.java @@ -24,8 +24,10 @@ public ContactDialog(IntelUIAPI ui, PersonAPI person, SubmarketAPI storage) { this.market = storage.getMarket(); this.ui = ui; playerData = new CargoFleetData(Global.getSector().getPlayerFleet()); - playerData.clear(); storageData = new CargoFleetData(storage); + if (this.isRemoteCall()) { + playerData.clear(); + } } @Override @@ -52,11 +54,30 @@ public void optionSelected(String text, Object optionData) { super.optionSelected(text, optionData); } + private boolean isRemoteCall() { + SectorEntityToken playerFocus = Global.getSector().getPlayerFleet().getOrbitFocus(); + if (playerFocus == null) { + return true; + } + if (playerFocus.equals(this.market.getPrimaryEntity())) { + return false; + } + for (SectorEntityToken connectedEntity : this.market.getConnectedEntities()) { + if (playerFocus.equals(connectedEntity)) { + return false; + } + } + return true; + } + private void dismiss() { + ContactsBoard.unregisterCall(); ContactsBoard board = ContactsBoard.getInstance(ContactsBoard.class); - board.getRenderableState().addTrackingData(market, storageData, playerData); - storageData.add(playerData); - playerData.restore(); + if (this.isRemoteCall()) { + board.getRenderableState().addTrackingData(market, storageData, playerData); + storageData.add(playerData); + playerData.restore(); + } dialog.dismiss(); ui.recreateIntelUI(); ui.updateUIForItem(board); diff --git a/src/stelnet/board/contact/ContactsBoard.java b/src/stelnet/board/contact/ContactsBoard.java index aa18f0346..715c8c5f6 100644 --- a/src/stelnet/board/contact/ContactsBoard.java +++ b/src/stelnet/board/contact/ContactsBoard.java @@ -1,5 +1,6 @@ package stelnet.board.contact; +import com.fs.starfarer.api.Global; import lombok.Getter; import stelnet.board.BoardBasePlugin; import stelnet.board.BoardRenderableInfo; @@ -27,4 +28,16 @@ protected RenderableIntelInfo getIntelInfo() { public boolean isHidden() { return renderableState.getContactNumber() == 0; } + + public static boolean isCalling() { + return Global.getSector().getMemoryWithoutUpdate().getBoolean(ModConstants.MEMORY_IS_CALLING); + } + + public static void registerCall() { + Global.getSector().getMemoryWithoutUpdate().set(ModConstants.MEMORY_IS_CALLING, true, 0); + } + + public static void unregisterCall() { + Global.getSector().getMemoryWithoutUpdate().unset(ModConstants.MEMORY_IS_CALLING); + } } diff --git a/src/stelnet/board/contact/ShowContactButton.java b/src/stelnet/board/contact/ShowContactButton.java index 4d38cc9c0..54e969dd6 100644 --- a/src/stelnet/board/contact/ShowContactButton.java +++ b/src/stelnet/board/contact/ShowContactButton.java @@ -14,6 +14,7 @@ public class ShowContactButton extends Button { public ShowContactButton(String label, Size size, final ContactIntel intel, FactionAPI faction) { super(size, label, true, faction.getBrightUIColor(), faction.getDarkUIColor()); + setEnabled(!ContactsBoard.isCalling()); setCutStyle(CutStyle.C2_MENU); setPadding(0); setHandler( diff --git a/src/stelnet/board/query/provider/SkillProvider.java b/src/stelnet/board/query/provider/SkillProvider.java index a0420bd9e..f2121e91d 100644 --- a/src/stelnet/board/query/provider/SkillProvider.java +++ b/src/stelnet/board/query/provider/SkillProvider.java @@ -10,7 +10,11 @@ public class SkillProvider { - private transient List allSkills; + private static transient List allSkills; + + public static void reset() { + allSkills = null; + } public List getMatching(List filter) { if (allSkills == null) { diff --git a/src/stelnet/util/Configurator.java b/src/stelnet/util/Configurator.java index 5f18777f7..dcbda8c82 100644 --- a/src/stelnet/util/Configurator.java +++ b/src/stelnet/util/Configurator.java @@ -13,6 +13,12 @@ import stelnet.board.query.MarketUpdater; import stelnet.board.query.QueryBoard; import stelnet.board.query.ResultIntel; +import stelnet.board.query.provider.DmodProvider; +import stelnet.board.query.provider.FactionProvider; +import stelnet.board.query.provider.ItemProvider; +import stelnet.board.query.provider.MarketProvider; +import stelnet.board.query.provider.ShipProvider; +import stelnet.board.query.provider.SkillProvider; import stelnet.board.storage.StorageBoard; import stelnet.board.storage.StorageIntel; import stelnet.board.storage.StorageListener; @@ -44,6 +50,15 @@ public static void deactivate(boolean skipUiReset) { log.info("Stelnet deactivated"); } + public static void resetCache() { + DmodProvider.reset(); + FactionProvider.reset(); + ItemProvider.reset(); + MarketProvider.reset(); + ShipProvider.reset(); + SkillProvider.reset(); + } + private static void purgeIntel(Class... classNames) { for (Class className : classNames) { log.debug("Removing intel " + className); diff --git a/src/stelnet/util/ModConstants.java b/src/stelnet/util/ModConstants.java index b6fe29975..7f8d7d86e 100644 --- a/src/stelnet/util/ModConstants.java +++ b/src/stelnet/util/ModConstants.java @@ -15,4 +15,9 @@ public class ModConstants { public static final String TAG_QUERY = TAG_MARKET; public static final String TAG_STORAGE = "stelnetStorage"; public static final String TAG_VIEWER = TAG_MARKET; + + /** + * Memory flags used. + */ + public static final String MEMORY_IS_CALLING = "$stelnetIsCalling"; }