CTD asking DistanceTo in LUA #3913

mike-f1 opened this Issue Jan 25, 2017 · 5 comments


None yet

2 participants

mike-f1 commented Jan 25, 2017


Observed behaviour

Results are documented in attached picture

Expected behaviour

Trade ships ask DistanceTo nearest starport and then
decide if hyperspace or reach starport

Steps to reproduce

try to kill a trade ship: you could use attached save game

Pioneer version: January 2017, on Linux/Ubuntu x86_64


@mike-f1 This will solve the problem.

--- /old/TradeShips.lua
+++ /new/TradeShips.lua
@@ -786,7 +786,7 @@
 	if trader.no_jump ~= true then
 		if #starports == 0 then
 			trader['no_jump'] = true -- it already tried in onEnterSystem
-		elseif Engine.rand:Number(1) < trader.chance then
+		elseif trader.starport and Engine.rand:Number(1) < trader.chance then
 			local distance = ship:DistanceTo(trader.starport)
 			if distance > 149598000 * (2 - trader.chance) then -- 149,598,000km = 1AU
 				if getSystemAndJump(ship) then
mike-f1 commented Jan 26, 2017

@walterar It work! :) ...this needs to be pushed in master I think

mike-f1 commented Feb 1, 2017

@walterar , do you want me to open a new PR for this?

walterar commented Feb 1, 2017

@mike-f1 Yes, do it yourself, I do not get along with github, excuse me.

mike-f1 commented Feb 21, 2017

Ok, this needs to remains open because we don't know exactly what it happens...

Needs further investigations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment