Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.95a is out! (03/26/21); Blog post: Skill Changes, Part 2 (07/15/21)

Pages: [1] 2

Author Topic: Items found on modded markets with zero credits as value  (Read 4315 times)

StarSchulz

  • Captain
  • ****
  • Posts: 458
    • View Profile
    • Email
Items found on modded markets with zero credits as value
« on: May 21, 2017, 05:08:24 PM »

I haven't a clue what is causing This:  
Spoiler
[close]

For some reason, i run into markets from faction mods that have random items listed as costing zero, and they zero out the entire transaction.

Spoiler
[close]

I have found more extreme versions, where multiple items are affected, such as this imperium planet with many items listed as zero. market info section also included

Spoiler
[close]
Spoiler
[close]

I haven't found any vanilla planets with this problem yet. I've heard others having this problem before, but haven't figured out what mod is doing it.
Current modlist:
Spoiler
[close]

This is somewhat difficult to reproduce, as it happens seemingly randomly. when i started out, those markets were fine. I had previously been able to purchase supplies from the DME world of Peremohy. something has happened to them along the journey from cycle 206 to 208. I don't think it could be templar crusades as neither of those systems have been crusaded against. No systems have been blockaded by the Imperium this playthrough. Anything else i can look out? i am out of ideas.


Edit:
Spoiler
[close]


View of the imperium's open market.

« Last Edit: May 23, 2017, 04:13:16 PM by StarSchulz »
Logged

arwan

  • Admiral
  • *****
  • Posts: 657
    • View Profile
    • Email
Re: Items found on modded markets with zero credits as value
« Reply #1 on: May 22, 2017, 01:18:44 PM »

i seem to recall someone mentioning that it was the Knights Templar mod messing with things. though i have not done any independent research myself to verify.
Logged
Alex
You won't be able to refit fighters and bombers at all. They're designed/balanced around having a particular set of weapons and would be very broken if you could change it. Which ones you pick for your fleet -out of quite a few that are available- is the choice here, not how they're outfitted.

Histidine

  • Admiral
  • *****
  • Posts: 3279
    • View Profile
    • Bitbucket profile
    • Email
Re: Items found on modded markets with zero credits as value
« Reply #2 on: May 23, 2017, 04:18:51 AM »

I am of the opinion that nothing a mod could do should be able to cause this, and the fact that something apparently can (reducing whole transaction cost to zero!) is a bug in itself. Is there some weird div0 somewhere in the price calculation or something?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 18934
    • View Profile
Re: Items found on modded markets with zero credits as value
« Reply #3 on: May 23, 2017, 09:00:51 AM »

Did a bit of investigating.

1) From the screenshots, this seems to only be affecting commodities and not weapons, right?
2) I don't see anything in vanilla that could do it, though that's no guarantee. The code does look "safe" and checks for the various possible divide by zeros, though.
3) If the price for a commodity ends up being a NaN, it'll get displayed as 0c.

As to how a mod could get this to happen: if either MarketAPI.getSupplyPriceMod()/getDemandPriceMod() or CommodityOnMarketAPI.getPlayerPriceMod() had any modifiers that were NaN, this would happen. I'd suspect the latter, since individual commodities seem to be affected, where if the market-wide modifier was the culprit, it'd affect every commodity on that market.
Logged

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2696
    • View Profile
    • Sc2Mafia
    • Email
Re: Items found on modded markets with zero credits as value
« Reply #4 on: May 23, 2017, 09:36:16 AM »

Interstellar Imperium does use getPlayerPriceMod using math that could potentially divide by zero if fed negative input values, but there is no code path that can actually accomplish that.

Plus, the Production Boom/Bust event isn't ongoing in your screenshot, so it couldn't be that in either case.
Logged

StarSchulz

  • Captain
  • ****
  • Posts: 458
    • View Profile
    • Email
Re: Items found on modded markets with zero credits as value
« Reply #5 on: May 23, 2017, 03:35:52 PM »

Haven't seen it on weapons, no. Would logs or my save file help, here?



I should also add that The Imperium events have not been running, no seige, no boom or bust.

I also doubt it has anything to do with my actions, as  while i had been operating mainly out of the DME system, i hadn't once visited an imperium planet this playthrough.
« Last Edit: May 23, 2017, 04:17:45 PM by StarSchulz »
Logged

StarSchulz

  • Captain
  • ****
  • Posts: 458
    • View Profile
    • Email
Re: Items found on modded markets with zero credits as value
« Reply #6 on: May 23, 2017, 04:20:40 PM »

Could it have anything to do with how Nova Capitalis doesn't import any of those things and produces its own? both markets share the Regional capital, Millitary base, and Autofactory-Heavy industrial blueprints market conditions.

The market info says that it is consuming supplies etc, but doesn't import or produce them

StarSchulz

  • Captain
  • ****
  • Posts: 458
    • View Profile
    • Email
Re: Items found on modded markets with zero credits as value
« Reply #7 on: May 23, 2017, 09:35:16 PM »

It can also appear on the intel screen:
Spoiler
[close]

It seems to have spread to Transplutonics, Heavy machinery, Supplies, and Templar Flux cores on Peremohy.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 18934
    • View Profile
Re: Items found on modded markets with zero credits as value
« Reply #8 on: May 23, 2017, 09:45:34 PM »

Hmm - if you were able to send me your mod folder (a bit of a tall order, I know - no worries if you're not up for that, just as long as there's nothing I can't download elsewhere) and the save, I could probably track down where the invalid price modifier is coming from.
Logged

StarSchulz

  • Captain
  • ****
  • Posts: 458
    • View Profile
    • Email
Re: Items found on modded markets with zero credits as value
« Reply #9 on: May 23, 2017, 10:03:48 PM »

This should be everything. Ive got a SSD and a decent internet connection, so its not too bad. If i need to upload a version non archived, i can do that too

http://www.mediafire.com/file/7ofvsf25kldn9bv/Saves.7z

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 18934
    • View Profile
Re: Items found on modded markets with zero credits as value
« Reply #10 on: May 23, 2017, 10:31:09 PM »

Thank you! Turns out the original hypothesis was incorrect - the value that ends up being NaN and messes everything up is the commodity stockpile value, not the price modifier.

The methods that modify this value are:

CommodityOnMarketAPI:
   public void setStockpile(float stockpile)
   public void addToStockpile(float quantity)
   public void removeFromStockpile(float quantity)

I took a relatively quick look through vanilla and I'm not seeing anything that seems like it could pass in a NaN value to one of those. That's of course not a guarantee...
Logged

StarSchulz

  • Captain
  • ****
  • Posts: 458
    • View Profile
    • Email
Re: Items found on modded markets with zero credits as value
« Reply #11 on: May 23, 2017, 10:40:39 PM »

The first i ever encountered this was with transplutonics after an exploration trip. i FEEL like it might have been vanilla, but i cant remember if i had already gotten mods and the save file is gone either way.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 18934
    • View Profile
Re: Items found on modded markets with zero credits as value
« Reply #12 on: May 23, 2017, 10:44:47 PM »

Hmm. It seems like if it was in vanilla, it might've gotten reported by now. Of course, it could have 1) gone under the radar or 2) be a vanilla issue that's made more likely to happen by something a particular mod does.
Logged

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2696
    • View Profile
    • Sc2Mafia
    • Email
Re: Items found on modded markets with zero credits as value
« Reply #13 on: May 24, 2017, 03:07:07 AM »

Various events in Interstellar Imperium and Templars modify stockpiles, but there is no code path that could result in divide-by-zero or even a zero-stockpile.  The only way that it could divide by zero is if somehow this code wasn't working right:

Code
        impact = typePicker.pick();
        if (impact < 0f) {
            impact = -impact;
            good = false;
        } else {
            good = true;
        }

If impact is, say, -1, then there will be tons of divide by zero errors.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 3279
    • View Profile
    • Bitbucket profile
    • Email
Re: Items found on modded markets with zero credits as value
« Reply #14 on: May 24, 2017, 04:36:40 AM »

For reference, the relevant Java classes are:
II_ProductionEvent (where the above snippet is from)
II_SiegeEvent
TEM_CrusadeEvent

It does indeed seem to me that NaNs should not be occurring.

Does it break if we pass a NaN argument to the *stockpile methods, and/or cause the stockpile to be negative? If so, do we just write wrapper methods for the stockpile setters that make sure these things never happen?
Logged
Pages: [1] 2