[BUG] [v1.15] In depth exploration of the buggy traders. Also: energy cell trade bug

Ask here if you experience technical problems with X Rebirth.

Moderator: Moderators for English X Forum

lasmori
Posts: 26
Joined: Sun, 30. Sep 12, 04:40
x3tc

[BUG] [v1.15] In depth exploration of the buggy traders. Also: energy cell trade bug

Post by lasmori »

NOTE: Please scroll down to my *second* update for the most up to date and accurate information.

I can confirm that this is still an issue in the v1.14 build of the client. I started with an entirely brand new game to see if this was still present.

Steps to reproduce

Buying the Cells:
1. I have my Rahanas in my Squad
2. I select the option that "Price isn't everything"
3. I activate the trade dialog on the mission marked Energy Cell seller.
4. Trade window says: Planned Trips: 1
5. Captain on ship says: Follow Albion Skunk
6. I performed the next step of the quest which involved taking on a new mission and leaving the zone.
7. After finishing the above mission, I move to the ship and sit in it's gravity waiting for something to happen. Nothing happens after an extended period of time.
--- Hack to get the quest moving forward ---
8. I have my Rahanas leave my squad
9. I save and quit
10. I remove the contents of the <shopping> tag in my quicksave.
11. Launch Game.
12. Repeat from step 1. Rahanas now moves around and eventually buys the energy cells.


Selling the Cells:
1. I have my Rahanas in my Squad
2. I activate the trade dialog on the mission marked Energy Cell buyer.
3. Trade window says: Planned Trips: 1
4. Captain on ship says: Follow Albion Skunk
5. I move to the ship and sit in it's gravity waiting for something to happen. Nothing happens after an extended period of time.
--- Hack to get the quest moving forward ---
6. I have my Rahanas leave my squad
7. I save and quit
8. I remove the contents of the <shopping> tag in my quicksave.
9. Launch Game.
10. Repeat from step 1. Rahanas now moves around and eventually sells the energy cells.


This was repeatable from a fresh game start.

EDIT #1: New Information

I've tried to reproduce the issue from a save made *during* the mission and have found some interesting results. My earlier play through, I loaded up the client. Clicked new game... and played straight through until my ship got stuck. I did make some saves along the way but that was in. The single option I had on the station was for a sell offer of just 100 units of Energy Cell for a discounted price. This is is where my Rahanas stopped functioning.

On successive attempts to reproduce I have seen some weird issues with the actual quest itself. It seems that the quest has a hard coded sell offer for 100 units at a discounted price that it's supposed to provide to the player. There is an identical buy order on the other end of the quest. Getting *only* this specific sell order as the *only* option when activating the Energy Cell sell offer icon seems to lead to the Rahanas getting stuck. It seems that this 100 unit sell offer isn't very consistent. Some times I didn't get the option for it *at all*. When I saved just after the dialog sequence with my pilot and choosing the "Price isn't everything" option... then *loaded* my game, I ended up with *two* offers. The normal station Energy Cell offer, along with the 100 unit offer. Selecting the 100 unit offer at this point seems to have a correlation to the Rahanas having to wait behind a large queue of transport ships before it can take it's turn at the station. Maybe they are all seeing it for some reason rather than just the player? It could also easily be coincidence.

So in summary:
1. Playing through from the start of the game without loading a save led to me having *only* a 100 unit sell offer (even though the station *had* cells...). My Rahanas got stuck and I had to modify the save file to clear it's shopping list.
2. Saving immediately after clicking "price isn't everything" gave me TWO options when I clicked. One for the standard station sell offer, and another for just 100 units. (When I say two, I mean literally from the menu after clicking the icon *and* inside the trade window.) My Rahanas sat inactive for a good 15 minutes but eventually started to move in on the station once the others had cleared away.)
3. I suspect there is a resource leak when loading saves successively without restarting the client. I'll make another bug report for that.
4. There seems to be a starvation issue with the traders. When my trader refuses to move again, there are generally an over abundance of traders trying to access the same port. Unsure what the deal is. Given the oddness above with the special 100 unit trade offer, perhaps the NPC traders are getting access to this and piling up on the station to get it?

I'll update with additional testing when I get the chance.

Debugging process
During my first play through I made a save while on the "The Trade Run" mission just before I started traveling to the sell order. My successive attempts have been resumed specifically from this point. Additionally, I've enabled the debug output from the "trade.performplayertraderun.xml" script in order to monitor the progress of my trade session. In the following work logs, items starting with an asterisk are actions that I have personally performed. Items starting with a minus sign are debug messages produced by the trade script.

My save game files can be found here: http://xrebirth.nexusmods.com/mods/124/

Code: Select all

--------
* Fly to nearest top offer on station
* Selected option "Price isn't everything"
* Save
* Load
* Click offer icon on station. *two* "Buy Energy Cells" options are present both in the menu and the trade window.
* Submit purchase specifically for the 100 unit sell order via open trade window.
* I do the "while we wait" mission offer
- Rahanas has 1 entries on shopping list
- 1: buy 100 Energy Cells from AES Energy Array III for 40000Cr (This debug message is likely wrong :P)
- 2783.97 moving to park at AES Energy Array III
- find sell offer on 0x286473 for ware Energy Cells
- found 0x8CDB
* I came back from the side mission. Rahanas is stationary. I sit in it's gravity waiting for it to do something.
* At least 4 other Energy Freighter seem to be lined up under my Freighter. Are they all in line 
*    for the 100Cr trade with the lower price? They each move off one at a time.
* My ship waits for other freighters to finish their business. 
* My ship finally starts moving after a long wait period. 
- 3716.68 now parked at AES Energy Array III
- Rahanas wants to buy 100 Energy Cells from AES Energy Array III for 400Cr
- trade info: 100x Energy Cells for 400Cr total
* drones pick up cells*
* "Deal Closed", mission moves up to next step.

--------

* Game performing really bad. Have loaded from saves quite a few times at this point.	
* Fly to nearest top offer on station
* Selected option "Price isn't everything"
* Click offer on station to bring up trade, one "Buy Energy Cells" option is present. This time 
*    it's the normal 168,454 count one and no 100 count option.
* Click next... window freezes. Can't get out of window.
* Opened menu and exited from the game to menu, restarted game.

--------

* Fly to nearest top offer on station
* I target the offer before completing the "Price isn't everything" dialog.
* One option, normal 168454 amount. 
* I select 100 units of that total via open trade window.
* I Submit purchase order via open trade window.
* I do the "while we wait" mission offer
- Rahanas has 1 entities on shopping list
- 1: buy 100 Energy Cells from AES Energy Array III for 46500Cr
- 2503.31 moving to park at AES Energy Array III
- find sell offer on 0x85F8 for ware Energy Cells
- found 0x6FC
* Come back from side mission. Rahanas is moving so I follow it.
* Still says Following Albion Skunk under the Captain's action.
* Ship instantly went in for the purchase rather than sit behind a large queue of transport ships.
- 3551.11 now parked at AES Energy Array III
- Rahanas wants to buy 100 Energy Cells from AES Energy Array III for 465Cr
- trade info: 100x Energy Cells for 465Cr total
* drones pick up cells*
* "Deal Closed", mission moves up to next step.
EDIT: Additional Insight
I've had the opportunity to dig into the scripts involved in actually getting the ship to it's docking point and I've come to some conclusions on the cause of the problem. While the trade quest itself is certainly buggy, it doesn't seem to have anything to do with the the issues trade ships are having getting to their dock points.

Trade ships start off by placing themselves out of the way when not currently executing an action. This seems to involve stacking up in various areas some distance from the station. This is done with the "move.unpark" script which gets used in both trade.performplayertraderun.xml and trade.performtraderun.xml.

When a trade ship has a buy or sell order, it locates the offer by using <find_sell_offer /> and <find_buy_offer />. It then uses the "move.park" script to actually relocate (move into the zone and then park itself next to the offer itself.) Once this is done, it makes sure the offer is still there (checking back with the user if something has happened) and then uses <execute_custom_trade> to exchange the cargo.

At this point, the ship goes back into "waitfororders" mode, which means that it ends up "move.unpark"ing itself again.

"move.park.xml" looks to loop over the available parking slots for 20 mins, sleeping 1-2 mins per loop. This means that if the parking spots are being starved, the ship should sit stationary for up to 20 minutes before giving up entirely. If it finds a free slot before then, it breaks out of the loop and then calls <connect_to_trade_location> to consume the free spot before traveling to it.

Once the ship has it's spot reserved, it gets the position and rotation for the spot. It then does a small series of <move_to> and <move_strafe> calls to eventually reach it's destination. During this process, it also makes several checks to see if the slot is still operational, restarting the entire procedure if that turns out to not be the case.

From what I can see, no FIFO system seems to be used... so there may likely a race condition between each ship trying to get at the available free spots. (I am not sure how this stuff gets threaded. What happens if something else calls <connect_to_trade_location> on the free slot between the <find_tradeoffer_parking_slot> and the <connect_to_trade_location>? Ignoring race conditions, there is also a possibility for starvation. (Free slots come up, but get taken before the script repeats it's loop).

There seems to be two real pain points right now with this code:

1) The ship has been "unparked" and is currently sitting away from the station. A trade request comes in and... nothing seems to happen. The ship either never moves, or only decides to move after a very prolonged period of time. The ship likely just never has a chance to actually get a free slot.
2) The ship transitions out of "unparked" and into "parked" and attempts to land at a station. Something breaks just before the ship lands and the whole parking process gets repeated. (I've seen my trade ship re-approach the station for over half an hour...) Perhaps a race contention between two threads and it loses it's slot? The first <move_to> call seems to do the majority of the travel before the the script starts checking "$freeslot.component.isoperational" again... so this would certainly explain the behavior I've seen. If it loses the slot at this point, it starts over again from scratch.)
Last edited by lasmori on Thu, 21. Nov 13, 06:03, edited 15 times in total.
Raynierf
Posts: 23
Joined: Sun, 17. Nov 13, 18:53

Post by Raynierf »

Great i did what you said and the trader moved, i was stuck on selling with 3 order on queue, the rahana was on same zone as my ship the zone for selling the energy cells, i would like to add: one you find your save file, highlight all and use find to get the <shopping> area, i delete all between <shopping> ....and ...<shopping> if you read it is a description of the selling orders on queue. i restart the game load the saved game went back to station and give the trader a new order to sell the 100 energy cells and it worked :roll:
lasmori
Posts: 26
Joined: Sun, 30. Sep 12, 04:40
x3tc

Post by lasmori »

Update with *a lot* of new information.
Husteln
Posts: 15
Joined: Sun, 17. Nov 13, 12:48

Post by Husteln »

Indeed. its quite interesting. Being stuck with food rations I was struck with the same idea (using another offer at the same location). So, after deleting previous orders I told freighter to sell 146 rations (the normal offer) and after that (before he completed first one) queued second one for 300 units.

Both have completed themselves by now, but mission says that I STILL have to bring 6 more food rations (146+300, even though I've checked cargo of only first freighter drone). Trying to finish it ATM.

add: according to cargo that drone simply didn't bring enough food rations, thats why I have 6 of them left to deliver. Even though freighter told me that the deal is closed (and he sent over some goods, but their number MATCHED the one from previous order) it still appears in order queue.


add: and it failed again. Strange thing is, that in the moment of an update (Freighter starts strafing away) new order with 124 units of food rations came up.

final update: after another savefile sweep for unfinished orders I accepted previously mentionted 124 food rations offer and, for experimet, used highway so freigher becomes OOS. In the end I had to go back because freighter stopped moving not far away from docking port. I opened trade menu once again and accepted "true" mission offer for 300 damned units of FR and it completed itself. I hope that building URV forge will take less than a week :)

~the end~

After leaving the location freighter told me that the deal is closed. Info-menu told me that I've just recieved payment. Funny thing is that it perfectly matched my number of credits, thus making me think that it just got doubled (it didn't, :D)

p.s. bug (or feature?) with freighter teleporting 11km from station after recieving trade order (teleporting occurc while being close to docking port, in my case) is rather annoying.
Sam Redstone
Posts: 189
Joined: Mon, 22. Dec 08, 16:13
xr

Post by Sam Redstone »

I tried the mission first, buying 100 cells and attempting to sell them. When I got to the system where I was meant to sell them, the mission guidance changed to send me back to buy 100 cells!

So I went back, and this time I bought them all. (30,000 or so?)

I went BACK to the sell system, told my Rahanas to sell them, and it proceeded to turn around and accelerate to impossible speeds AWAY from the system. I actually was ripped out of its gravity well (was trying to follow it) and watched it disappear into the night.

It was not in a 'highway'... it just accelerated to highway speed by itself and disappeared.

Dude.

Back to an earlier save and try again.

P.S. Thanks for these instructions, but how do we edit savegame files and where are they?
"Will you please get me a couple of things?" ~ Mahi Ma

Every Boron dies. Squiddy McSquid truly lived.
malolotja
Posts: 141
Joined: Thu, 7. Nov 13, 13:11

Post by malolotja »

You savefiles are located in

[User]\Documents\Egosoft\X Rebirth\[steamid]\saves

Here is a good collection of things you can edit:

http://forum.egosoft.com/viewtopic.php?t=350404

The changes can also help you in progressing further.
Pimpace
Posts: 268
Joined: Tue, 1. Jan 13, 15:48
x4

Re: [BUG] [v1.14] [Plot] The Trade Run - 100 energy cell trade bug

Post by Pimpace »

lasmori wrote:It seems that the quest has a hard coded sell offer for 100 units at a discounted price that it's supposed to provide to the player.
...
Selecting the 100 unit offer at this point seems to cause the Rahanas to wait behind a large queue of transport ships before it can take it's turn at the station.

I believe that it's likely somehow all of the other trade ships are queueing up for the discounted 100 unit offer and then timing out one at a time because they can't actually *use* it. This stalls your own trade ship from accessing the station.
Oh man... how lame! I'm not a programmer but I have some minimalist knowledge about programming in few language. If I were they, I would set some "flag-setting" in buy/sell offers in queue as AI can identify from an offer IT IS PLOT RELATED or something... (something like -> plot quest, player quest, free play, campaign, etc. flags for all type of trade offer)
In this case the AI (of another NPC trade ships) can ignore that offer and make theirs for basic infrastructure and when they finished their own job, player Rahanas could get the plot related offer while quest "pickup" (when we get this quest) set that player Rahanas AI this ship has priority to get the PLOT RELATED OFFER.

I know this is easy as it's write, but they should programming something like that. I hope you get my point.
lasmori
Posts: 26
Joined: Sun, 30. Sep 12, 04:40
x3tc

Post by lasmori »

I've had a chance to audit the trade ship travel code. I've added another update to my post with my conclusions.
nalim27
Posts: 363
Joined: Tue, 24. Jan 06, 20:04
x4

Post by nalim27 »

Bump because this is really important for developers.
Mine rig - X4 ready :-) Windows 10 64b
CPU: AMD Ryzen 2700X (stock clocks 3.7GHz + 4.3GHz boost), 32GB DDR4 3200MHz CL14 RAM,
GPU: AMD Vega64 8 GB HBM, played on 2569x1440, Freesync2
SSD: Samsung 970 EVO 1TB M.2 PCI-ex

CPU before 1.7.2018: Intel Xeon E5450@3.6GHz, 8GB DDR2 800MHz RAM,
Pimpace
Posts: 268
Joined: Tue, 1. Jan 13, 15:48
x4

Post by Pimpace »

nalim27 wrote:Bump because this is really important for developers.
Ye. But why do a user make such a reverse engineering to reveal such a critical bug????????????????? :evil:
nalim27
Posts: 363
Joined: Tue, 24. Jan 06, 20:04
x4

Post by nalim27 »

Pimpace wrote:
nalim27 wrote:Bump because this is really important for developers.
Ye. But why do a user make such a reverse engineering to reveal such a critical bug????????????????? :evil:
Yes, that is not clear for me too. There must exists some logical explanation for this but if Egosoft will not tell us we can guests only. Probably team is too small to develop all from scratch or (not offence) they do not have skills enough for this and there doing everything slowly.
If one developer works on great new pathfinder, another on AI, designer designing great UI ... 7 years they must create almost perfect and working code.
And off course 3D pathfinding is very hard taks but .... there exists known algorithms for this, many years - many talented sciences (mathematics) were working on that problem years and brings some ways how to do it.
And offsourse there are complete libraries for that problem (but expensive).
Mine rig - X4 ready :-) Windows 10 64b
CPU: AMD Ryzen 2700X (stock clocks 3.7GHz + 4.3GHz boost), 32GB DDR4 3200MHz CL14 RAM,
GPU: AMD Vega64 8 GB HBM, played on 2569x1440, Freesync2
SSD: Samsung 970 EVO 1TB M.2 PCI-ex

CPU before 1.7.2018: Intel Xeon E5450@3.6GHz, 8GB DDR2 800MHz RAM,
Talash
Posts: 2
Joined: Thu, 21. Nov 13, 01:44
x4

Post by Talash »

Thank you for taking the time to look into this lasmori. While the trading system does have some bugs, from what you've described in how the trade scripts work, it's just plain coded poorly. Hopefully we'll see some improvements in the days/weeks to come.
lasmori
Posts: 26
Joined: Sun, 30. Sep 12, 04:40
x3tc

Post by lasmori »

Talash wrote:Thank you for taking the time to look into this lasmori. While the trading system does have some bugs, from what you've described in how the trade scripts work, it's just plain coded poorly. Hopefully we'll see some improvements in the days/weeks to come.
Thanks!

I might start looking into trying to improve these scripts if Egosoft doesn't do something (or respond to the thread) soon.

I'm a bit disgruntled that they don't seem to use these forums... but I'm too much of a fan of the X series and the *idea* of X-Rebirth to just let it go. :)
bbeach
Posts: 100
Joined: Tue, 24. Feb 09, 03:47
x4

Post by bbeach »

Here's an unofficial patch for the problem for 1.1.5

http://forum.egosoft.com/viewtopic.php?t=352589

There are 2 versions 1 that lets the trader loop and loop and loop if there is a problem (voice comm each time). The other will cancel the trade if it fails.

Both will work on existing saves that have the "stuck freighter" problem.
marcellius
Posts: 37
Joined: Sat, 13. Aug 05, 11:43
x4

Post by marcellius »

It might be me, but I can't find the shopping entry in de xml save file anymore. There are a lot of entries, and the one I need is simply not pressent. Rahanas is stuck in space.

Return to “X Rebirth - Technical Support”