Hey, I think I found a small logic bug in Nexerelin.
I was looking for a way to add a multiplier to the number of weapons+fighters offered in markets globally and saw Nexerelin already does this by overriding the vanilla markets. So I tried to play around with the same idea in my own mod and realized there is a logic error.
For example the Nex_OpenMarketPlugin.java
Code Snippet:
Spoiler
package exerelin.campaign.submarkets;
import com.fs.starfarer.api.impl.campaign.submarkets.OpenMarketPlugin;
import com.fs.starfarer.api.util.Misc;
@Deprecated
public class Nex_OpenMarketPlugin extends OpenMarketPlugin {
@Override
public void updateCargoPrePlayerInteraction() {
super.updateCargoPrePlayerInteraction();
if (okToUpdateShipsAndWeapons()) {
// this was already done in super method, so what we're doing is doubling weapon/fighter counts
int weapons = 2 + Math.max(0, market.getSize() - 3) + (Misc.isMilitary(market) ? 5 : 0);
int fighters = 1 + Math.max(0, (market.getSize() - 3) / 2) + (Misc.isMilitary(market) ? 2 : 0);
// just kidding, it's only 50% more
//weapons /= 2;
//fighters /= 2;
addWeapons(weapons, weapons + 1, 0, market.getFactionId());
addFighters(fighters, fighters + 1, 0, market.getFactionId());
getCargo().sort();
}
}
}
The problem is when you call super.updateCargoPrePlayerInteraction() you will cause the vanilla market to set sinceSWUpdate = 0f; which means you will always evaluate if (okToUpdateShipsAndWeapons()) to false
Since you need to accommodate the vanilla stockpile update you still need to call super before you modify the cargo (ie weapons and fighters) so I did this as an example:
Spoiler
public class RL_OpenMarketPlugin extends Nex_OpenMarketPlugin {
@Override
public void updateCargoPrePlayerInteraction() {
if (okToUpdateShipsAndWeapons()) {
super.updateCargoPrePlayerInteraction(); //must do this first or anything you add isnt real!
// this was already done in super method, so what we're doing is doubling weapon/fighter counts
int weapons = 2 + Math.max(0, market.getSize() - 3) + (Misc.isMilitary(market) ? 5 : 0);
int fighters = 1 + Math.max(0, (market.getSize() - 3) / 2) + (Misc.isMilitary(market) ? 2 : 0);
for (int x = 1; x < submarketShared.getMinWepMult(); x++){
Global.getLogger(this.getClass()).info("flapjack " + x);
addWeapons(weapons, weapons, 1, market.getFactionId());
addFighters(fighters, fighters, 1, market.getFactionId());
}
getCargo().sort();
}
else {
super.updateCargoPrePlayerInteraction(); //this makes sure the normal commodities get worked out
}
}
}
Ignore my flapjack bit - I was working on making a global multiplier that could be loaded from a config.
It also is a bit hacky for me to try to override your markets in Nexerelin because we would both be overiding the vanilla markets and it was load-order dependent on who's mod applied over who's. (I had to change my name to appear higher in the alphabet for load-order). Would you consider taking a config variable as a multiplier for weapons/fighters on a market content like this? I wanted to globally double (or triple) weapon spawns since I've been playing with so many mods I could never find the content I wanted in game with such large pools to draw from randomly.
I also saw you had marked this (and Nex_BlackMarketPlugin) as deprecated. Did you find a better way to override vanilla markets?
Let me know if I can better explain myself, I hope this is helpful! Your mod is awesome and thanks for all the incredible work you've put in over the years!