jpcsupplies / Economy_mod

Basic Economy System for Space Engineers
13 stars 12 forks source link

[bug] stable steam version - intermittent items refuse to sell #144

Open jpcsupplies opened 8 years ago

jpcsupplies commented 8 years ago

Black Talon server reports that items are intermittently refusing to sell in an npc market

I am on atm and it refuses to buy motors, but sells ok, previously gold ingots.. doesnt appear to be a spelling or "spacing error"

jpcsupplies commented 7 years ago

More players now reporting it - DrOwNiNg_Space_Weasel.jpg 1 hour ago
What I am having trouble with is selling items such as Silver and Silicon Ingots, along with stone or gravel. For example, when I type in " /sell 10000 "silver ingot" " it does not even bring up an error message. " /sell 1000 "silicon ingot" " brings up an error, but fails nonetheless. What is happening? I am selling both from my personal inventory to a trading station.

Not sure of cause.. @midspace any ideas? Seems totally random.

midspace commented 7 years ago

There is no such thing as "Silicon Ingot" it is "Silicon Wafer"

jpcsupplies commented 7 years ago

Ya, ignoring that one, as the poster said it threw an error - but the silver ingot shouldn't be giving no reply at all. The point was that one or more random items for some reason seem to be completely ignored when you try to trade them. I've seen it on two different servers myself now. I think callacus noticed it once on ramblers server, and same thing happened on black talon server too that Dampiir pointed out. On ramblers it only ever seemed to effect one item.

If it is always one item, it may be we have a 1 instead of a 0 processing in a split or array somewhere that shouldn't be; and we just lose the first or last item in our database, or perhaps an issue with custom objects in our database that no longer have a mod associated with them.. but that is just a wild guess there. I've not had a moment to hop on one of my pcs setup for dev to rummage around to check all our loops and search code to see if we are dropping one off the front or end.

midspace commented 7 years ago

I've never been able to reproduce it, so if anything I'll need two things.

  1. A copy of the server's Economy log.
  2. Access to a server that is showing the issue (consistently). By access, I mean able to join. Some of these servers are group restricted.
midspace commented 7 years ago

Processing wise, the player should always be receiving a message. We have a fallthrough catch at the end just in case.

            // this is a fall through from the above conditions not yet complete.
            MessageClientTextMessage.SendMessage(SenderSteamId, "SELL", "Not yet complete.");

The only spot where it may be not returning, is the OfferToMarket, as we aren't writing any message to the user or the log file. This might be the spot, but player would have to be issuing an explicit sell command to another player at a set price.

if (OfferToMarket)
                        {
                            // TODO: Here we post offer to appropriate zone market
                            return;
                        }

We could just slip in the following into line 400? MessageClientTextMessage.SendMessage(SenderSteamId, "SELL", "Offer to market is not yet complete.");

Otherwise I'm not sure. The message between the player and server could be getting lost. :frowning:

I'm linking the code here for reference. https://github.com/jpcsupplies/Economy_mod/blob/master/Economy/Data/Scripts/Economy.scripts/Messages/MessageSell.cs

midspace commented 7 years ago

Server indicated to be having the issue is "The Journey: Spokane Survivalists".

midspace commented 7 years ago

I cannot find this server running. I think we'll need an IP address and port number.

jpcsupplies commented 7 years ago

162.248.94.205:27065

at least it was when they added themself to the economy servers list think i jumped on there once, looked pretty well setup from memory

midspace commented 7 years ago

Nothing at that address.

Their facebook indicates they may be removing Economy. https://www.facebook.com/SpokaneSurvivalist/

Group page: http://steamcommunity.com/groups/SpokaneSurvivalists

Says the server is at: steam://connect/162.248.94.205:27017

midspace commented 7 years ago

Omar posed an issue on the Steam thread:

Omar 5 hours ago Delete hello is anyone ever had problem selling ingot before ? , i cant seem to be able to sell silver on my server

Their contact details are: http://steamcommunity.com/id/ExDream

Their server address is "InterStellar Journey": sese.skyspace.nl:27016

Their Trading zone is located at:

GPS:Trading Zone:90068.88:33518.32:55289.59:

The issue is with selling silver ingot, and magnesium powder.

I have tested their server by jumping online, and the issue is present. I still cannot reproduce the issue locally. At this stage to debug further we need a list of their mods, or a copy of their world.

I have to wonder, is this an SESE caused issue? It should not be.

jpcsupplies commented 7 years ago

mods list you can get off the space engineers client log on connect, just pull the file up in notepad, and halfway down should give a plain text list of mods..

I was going to pop on their anyway ill grab a list maybe.

Edit: List below. They run essentials too so they run SESE as well.

jpcsupplies commented 7 years ago
2016-08-28` 16:52:30.275 - Thread:   1 ->  Obtained details: Id=578116736; Result=OK; ugcHandle=581326799412172106; title='(DX11) Tiered JumpDrives'; tags='mod,Block'
2016-08-28 16:52:30.276 - Thread:   1 ->  Obtained details: Id=504250615; Result=OK; ugcHandle=432697227721580639; title='S - Cratos thruster - DX11'; tags='mod,Block'
2016-08-28 16:52:30.276 - Thread:   1 ->  Obtained details: Id=559202083; Result=OK; ugcHandle=494654861413101186; title='NewEssentials'; tags='mod,script'
2016-08-28 16:52:30.276 - Thread:   1 ->  Obtained details: Id=534512234; Result=OK; ugcHandle=392169271236498099; title='LCD Sci-fi interface pack'; tags='Other,mod'
2016-08-28 16:52:30.276 - Thread:   1 ->  Obtained details: Id=614609071; Result=OK; ugcHandle=276228215782723354; title='Improves SimSpeed For DS'; tags='mod,Block'
2016-08-28 16:52:30.276 - Thread:   1 ->  Obtained details: Id=544032930; Result=OK; ugcHandle=393297235563058675; title='Clean Camera'; tags='Other,mod'
2016-08-28 16:52:30.277 - Thread:   1 ->  Obtained details: Id=449392448; Result=OK; ugcHandle=486766424836559509; title='MWI - Weapon Collection (DX11)'; tags='mod,Block,modpack'
2016-08-28 16:52:30.277 - Thread:   1 ->  Obtained details: Id=489964772; Result=OK; ugcHandle=1617175662575869466; title='Small Ship Jump Drive'; tags='mod,Block'
2016-08-28 16:52:30.277 - Thread:   1 ->  Obtained details: Id=294621451; Result=OK; ugcHandle=383161437188813702; title='(DX11)Big Gate'; tags='mod,Block'
2016-08-28 16:52:30.277 - Thread:   1 ->  Obtained details: Id=350106127; Result=OK; ugcHandle=393301941913574189; title='CSD Battlecannon'; tags='mod,Block'
2016-08-28 16:52:30.277 - Thread:   1 ->  Obtained details: Id=728920721; Result=OK; ugcHandle=492400140720978575; title='Ravenbolt Compact Conveyor System'; tags='mod,Block,modpack,Other'
2016-08-28 16:52:30.277 - Thread:   1 ->  Obtained details: Id=484504816; Result=OK; ugcHandle=264971280406871773; title='Energy Shields (stable/dev)'; tags='mod,Block,Other'
2016-08-28 16:52:30.277 - Thread:   1 ->  Obtained details: Id=301830183; Result=OK; ugcHandle=269475444203008915; title='Arc Reactor Pack [DX-11 Ready]'; tags='mod,Block,modpack'
2016-08-28 16:52:30.305 - Thread:   1 ->  Obtained details: Id=655922051; Result=OK; ugcHandle=261593580287448493; title='Nanite Control Factory - Automated Construction'; tags='mod,Block,script'
2016-08-28 16:52:30.305 - Thread:   1 ->  Obtained details: Id=298550266; Result=OK; ugcHandle=442826522903546906; title='(DX11)Letters Mod'; tags='mod,Block'
2016-08-28 16:52:30.305 - Thread:   1 ->  Obtained details: Id=441722178; Result=OK; ugcHandle=396672236072162582; title='(DX11) Blast Door'; tags='mod,Block'
2016-08-28 16:52:30.305 - Thread:   1 ->  Obtained details: Id=609020322; Result=OK; ugcHandle=358402208194028007; title='(DX11) Tiered Armor Atmospheric Engines'; tags='Other,mod,Block'
2016-08-28 16:52:30.306 - Thread:   1 ->  Obtained details: Id=670717906; Result=OK; ugcHandle=263834439540358153; title='Milky Way Skybox'; tags='mod,Skybox'
2016-08-28 16:52:30.306 - Thread:   1 ->  Obtained details: Id=328494103; Result=OK; ugcHandle=608349439292568011; title='Armor Ramps [By UncleSte]'; tags='mod,Block'
2016-08-28 16:52:30.306 - Thread:   1 ->  Obtained details: Id=340933439; Result=OK; ugcHandle=425944999616654150; title='Encased Gyroscope for DirectX 11'; tags='mod,Block'
2016-08-28 16:52:30.306 - Thread:   1 ->  Obtained details: Id=630310371; Result=OK; ugcHandle=448484014592309611; title='Heavily Tinted Glass'; tags='mod,Block,modpack'
2016-08-28 16:52:30.306 - Thread:   1 ->  Obtained details: Id=472832143; Result=OK; ugcHandle=271726679843083045; title='Azimuth Complete Mega Mod Pack~(DX-11 Ready)'; tags='mod,Block,Production,modpack'
2016-08-28 16:52:30.306 - Thread:   1 ->  Obtained details: Id=598364318; Result=OK; ugcHandle=364030656447293592; title='IOM Stone Crusher'; tags='mod,Block'
2016-08-28 16:52:30.306 - Thread:   1 ->  Obtained details: Id=475375953; Result=OK; ugcHandle=693902202130441658; title='[Mexpex] Heavy Mining Drill'; tags='mod,Block'
2016-08-28 16:52:30.306 - Thread:   1 ->  Obtained details: Id=483210585; Result=OK; ugcHandle=446205490038836672; title='LCD Underwater landscapes texture pack'; tags='Other,mod,modpack'
2016-08-28 16:52:30.306 - Thread:   1 ->  Obtained details: Id=625608508; Result=OK; ugcHandle=495780761305027175; title='Safe Zone Block (Territory)'; tags='mod,Block,script'
2016-08-28 16:52:30.307 - Thread:   1 ->  Obtained details: Id=299485512; Result=OK; ugcHandle=642123563611278336; title='Gyroscope +250%'; tags='mod,Block'
2016-08-28 16:52:30.339 - Thread:   1 ->  Obtained details: Id=316190120; Result=OK; ugcHandle=259341629969149527; title='Midspace's Admin helper commands'; tags='mod,script'
2016-08-28 16:52:30.339 - Thread:   1 ->  Obtained details: Id=340095691; Result=OK; ugcHandle=389921984484917692; title='Dedicated Essentials Client Side Mod'; tags='mod,script'
2016-08-28 16:52:30.339 - Thread:   1 ->  Obtained details: Id=570765975; Result=OK; ugcHandle=351645757466803544; title='Midspace's Small Ship Speed 250 mod'; tags='Other,mod,script'
2016-08-28 16:52:30.339 - Thread:   1 ->  Obtained details: Id=386647996; Result=OK; ugcHandle=1467398677407737942; title='S - Thruster - DX11'; tags='mod,Block'
2016-08-28 16:52:30.339 - Thread:   1 ->  Obtained details: Id=405182053; Result=OK; ugcHandle=269463939074207577; title='(DX11) Tiered Armor Thrusters'; tags='mod,Block,Other'
2016-08-28 16:52:30.339 - Thread:   1 ->  Obtained details: Id=436025957; Result=OK; ugcHandle=277347560839017746; title='(DX11) Kolt - Command Console Pack'; tags='mod,Block,Animation'
2016-08-28 16:52:30.339 - Thread:   1 ->  Obtained details: Id=483644339; Result=OK; ugcHandle=446205090394686918; title='LCD Animated waterfall'; tags='Other,mod,modpack'
2016-08-28 16:52:30.339 - Thread:   1 ->  Obtained details: Id=402341075; Result=OK; ugcHandle=395549035377116234; title='(DX11) Tiered Thruster Pack'; tags='mod,Block'
2016-08-28 16:52:30.340 - Thread:   1 ->  Obtained details: Id=418515207; Result=OK; ugcHandle=285224644444773510; title='(DX11) Larger Airtight Hangar Door(s)'; tags='mod,Block'
2016-08-28 16:52:30.340 - Thread:   1 ->  Obtained details: Id=479457855; Result=OK; ugcHandle=446204855953275623; title='LCD Forest landscapes texture pack'; tags='Other,mod,modpack'
2016-08-28 16:52:30.340 - Thread:   1 ->  Obtained details: Id=412134393; Result=OK; ugcHandle=396672236072279052; title='(DX11) Small Medical Station'; tags='mod,Block'
2016-08-28 16:52:30.340 - Thread:   1 ->  Obtained details: Id=677790017; Result=OK; ugcHandle=277346667219064317; title='Cargo Container with Fill Level Bars'; tags='mod,Block,script'
2016-08-28 16:52:30.340 - Thread:   1 ->  Obtained details: Id=336484411; Result=OK; ugcHandle=368534884769524137; title='Worn Series #1 by Tartaross (DX9/DX11)'; tags='mod,Character,modpack'
2016-08-28 16:52:30.340 - Thread:   1 ->  Obtained details: Id=520712849; Result=OK; ugcHandle=259336546335467704; title='Oki edited (DX11)'; tags='mod,Block'
2016-08-28 16:52:30.340 - Thread:   1 ->  Obtained details: Id=570767017; Result=OK; ugcHandle=351645757466838358; title='Midspace's Large Ship Speed 250 mod'; tags='Other,mod,script'
2016-08-28 16:52:30.340 - Thread:   1 ->  Obtained details: Id=657749341; Result=OK; ugcHandle=446241729575153878; title='Automatic Ore Pickup'; tags='mod,script'
2016-08-28 16:52:30.340 - Thread:   1 ->  Obtained details: Id=412986157; Result=OK; ugcHandle=383161437188818589; title='(DX11)Interior Door'; tags='mod,Block'
2016-08-28 16:52:30.340 - Thread:   1 ->  Obtained details: Id=487835945; Result=OK; ugcHandle=396672236072167088; title='(DX11) Boarding Ramp'; tags='mod,Block'
2016-08-28 16:52:30.340 - Thread:   1 ->  Obtained details: Id=504209260; Result=OK; ugcHandle=266093216370691450; title='Frontier Economy (Adds money and Trade)'; tags='mod,modpack,script,Other'
2016-08-28 16:52:30.340 - Thread:   1 ->  Obtained details: Id=388580965; Result=OK; ugcHandle=268337494152648246; title='(DX11)Minotaur Cannon'; tags='mod,Block'
2016-08-28 16:52:30.341 - Thread:   1 ->  Obtained details: Id=444642373; Result=OK; ugcHandle=514882136076461589; title='S - CryoPod - DX11'; tags='mod,Block'
2016-08-28 16:52:30.341 - Thread:   1 ->  Obtained details: Id=563181662; Result=OK; ugcHandle=388796084569866861; title='LCD Building Signs (DX11)'; tags='Other,mod,modpack'
Omar001 commented 7 years ago

Hello @midspace :D

mod list : https://docs.google.com/spreadsheets/d/1GScs6dGr3VQE7LTbPrAZo82pliwQLTSaY8BU3g1cn3Q/edit#gid=0

World map : https://www.dropbox.com/s/1qs42j45loqqde4/InterStellar%20Journey%20Map.zip?dl=0

as midspace said , cant sell silver ingot or magnesium powder but can buy them with no problem

midspace commented 7 years ago

Currently I'm getting an issue with Mod 449392448. Every time I start a copy of the local server, it tries to download that mod again. At 169 Mb, it's a pain in the ass. So I've dropped it from my copy.

midspace commented 7 years ago

I've just finished testing with SESE, and still cannot reproduce the issue.

@Omar001 What I forgot to ask before, is a copy of the Economy config from the Dedicated Server's Storage path. Can we get a copy of that?

Omar001 commented 7 years ago

@midspace

Here the link to the file

https://www.dropbox.com/sh/esgqtglq5e20e61/AABL_Y9nZHSV4FxCZ07Klzdxa?dl=0

midspace commented 7 years ago

@Omar001 Well, the config files have narrowed down the issue. Both the Silver ingots and Magnesium Powder have negative stock values.

        <MarketItem>
          <TypeId>MyObjectBuilder_Ingot</TypeId>
          <SubtypeName>Magnesium</SubtypeName>
          <Quantity>-2201</Quantity>
          <SellPrice>77</SellPrice>
          <BuyPrice>70</BuyPrice>
          <IsBlacklisted>false</IsBlacklisted>
        </MarketItem>
        <MarketItem>
          <TypeId>MyObjectBuilder_Ingot</TypeId>
          <SubtypeName>Silicon</SubtypeName>
          <Quantity>546599.996928</Quantity>
          <SellPrice>0.66</SellPrice>
          <BuyPrice>0.6</BuyPrice>
          <IsBlacklisted>false</IsBlacklisted>
        </MarketItem>
        <MarketItem>
          <TypeId>MyObjectBuilder_Ingot</TypeId>
          <SubtypeName>Silver</SubtypeName>
          <Quantity>-42005</Quantity>
          <SellPrice>5.5</SellPrice>
          <BuyPrice>5</BuyPrice>
          <IsBlacklisted>false</IsBlacklisted>
        </MarketItem>

This does result in an exception that is caught and logged in the Economy server log file.

2016-09-02 19:15:03.847 - System.OverflowException: Value was either too large or too small for a Decimal.
   at System.Decimal.FCallAddSub(Decimal& d1, Decimal& d2, Byte bSign)
   at System.Decimal.op_Subtraction(Decimal d1, Decimal d2)
   at Economy.scripts.Messages.MessageSell.ProcessServer()
   at Economy.scripts.Messages.MessageBase.InvokeServerProcessing()

I'm not sure how exactly we ended up with a negative value at the moment. It needs some investigation. The quickest fix, is to reset the stock amounts with the following commands. Whether you want more than 1 in stock is up to you. /set 1 "silver ingot" /set 1 "magnesium powder"

midspace commented 7 years ago

It looks like the negative comes about because LimitedSupply is off. Obviously this allows for negative values. <LimitedSupply>false</LimitedSupply>

So obviously the /sell command doesn't work right with LimitedSupply off.

midspace commented 7 years ago

@jpcsupplies this fix will have to be published. It will allow players to correctly trade in a market without a limited supply. We may want to do something with negative stock quantities however, as it doesn't make logical sense.

Perhaps fix them at their default value rather than deducting what was bought. But, it doesn't make the market appear alive. Which returns us to topping up the stock amounts randomly.

Omar001 commented 7 years ago

@midspace

that make sense indeed , i'll try the commands thanx for the help will be waiting for the hot fix :D

jpcsupplies commented 7 years ago

Limited supply set false originally allowed the NPC to have an unlimited supply.. (but not players of course) there is a remote chance we missed something there since the test server always ran with limited supply on after the initial launch month. Perhaps in the section that deducts stock toss in a check for limited supply. If it comes up as false, roll the stock qty to zero (or lock it to the default starting amount eg 1000) if the transaction would send stock negative. That should restore designed behavior of that setting. Probably what your commit did anyway.. i've not looked it over yet.. oops :)

jpcsupplies commented 7 years ago

PS - ill have to re-insert a false in the demo mission system to disable it again too, at the moment it would allow players to get free money every time they joined as I don't have a persistent current mission number or missions in chain completed count value yet. I'll have to push that before I send out the hotfix. Should only take a few minutes (slow pc here)

jpcsupplies commented 7 years ago

Ok it is pushed out.. (took longer than expected due to having to change branches to publish on this antique) @Omar001 you able to try some buy/sells on those acting up products after your next server reboot.. thanks :)

midspace commented 7 years ago

PS - ill have to re-insert a false in the demo mission system to disable it again too, at the moment it would allow players to get free money every time they joined

This is why I defined MissionId of -1 (no current mission) to be set after completing a mission. https://github.com/jpcsupplies/Economy_mod/blob/master/Economy/Data/Scripts/Economy.scripts/EconConfig/HudManager.cs#L535

you did overwrite it with this change: https://github.com/jpcsupplies/Economy_mod/commit/a0ff1765d2be5baaa2f31dd3014954935c881379

jpcsupplies commented 7 years ago

I probably did that to enable it, i've been messing with making a tutorial mission chain. But it is hard coded, would prefer it to run as the default contents of the mission script file to make everything nice and consistent for admins to build their own mission chains. I've disabled it at here https://github.com/jpcsupplies/Economy_mod/commit/6f7ed8706d1999a2b9bde86809eb5fe0451a4116 I probably should be discussing it in the mission system thread ;)

jpcsupplies commented 7 years ago

OP: had no more reports of intermittent no-sells/buys we may have nailed it. Should be safe to close issue?

midspace commented 7 years ago

Should still rebalance the stock quantity, perhaps even fix it at the default level in case admins change it from unlimited to limited. We should retest to make sure player markets still work as limited.

jpcsupplies commented 7 years ago

I've still had no more reports of this glitch.. so im downgrading it from priority.
So far the last reports have been: 1: they are spelling it wrong or failing to use "quotes" 2: somehow stock has a negative qty and the game has been set to limited 3: item was black listed