Fix typo in rail replacement mapping, fix several crashes

This commit is contained in:
teknomunk 2024-04-10 08:02:21 +00:00
parent 568529e4b4
commit 8101299ed8
3 changed files with 5 additions and 8 deletions

View File

@ -154,8 +154,8 @@ local function handle_cart_collision(cart1_staticdata, prev_pos, next_dir)
local m2 = cart2_staticdata.mass
--print("u1="..tostring(u1)..",u2="..tostring(u2))
if u2 == 0 and u1 < 4 and train_length(cart1) < MAX_TRAIN_LENGTH then
link_cart_ahead(cart1, {_staticdata=cart2_staticdata})
if u2 == 0 and u1 < 4 and train_length(cart1_staticdata) < MAX_TRAIN_LENGTH then
link_cart_ahead(cart1_staticdata, cart2_staticdata)
cart2_staticdata.dir = mcl_minecarts:get_rail_direction(cart2_staticdata.connected_at, cart1_staticdata.dir)
cart2_staticdata.velocity = cart1_staticdata.velocity
return
@ -268,7 +268,7 @@ end
local function reverse_direction(staticdata)
if staticdata.behind or staticdata.ahead then
reverse_train(self)
reverse_train(staticdata)
return
end

View File

@ -636,7 +636,7 @@ minetest.register_lbm({
local STRAIGHT_RAILS_MAP ={
["mcl_minecarts:golden_rail"] = "mcl_minecarts:golden_rail_v2",
["mcl_minecarts:golden_rail_on"] = "mcl_minecarts:golden_rail_v2_on",
["mcl_minecarts:activator_rail"] = "mcl_minecarts_activator_rail_v2",
["mcl_minecarts:activator_rail"] = "mcl_minecarts:activator_rail_v2",
["mcl_minecarts:activator_rail_on"] = "mcl_minecarts:activator_rail_v2_on",
["mcl_minecarts:detector_rail"] = "mcl_minecarts:detector_rail_v2",
["mcl_minecarts:detector_rail_on"] = "mcl_minecarts:detector_rail_v2_on",

View File

@ -139,10 +139,7 @@ function mod.update_train(staticdata)
end
end
function mod.link_cart_ahead(cart, cart_ahead)
local staticdata = cart._staticdata
local ca_staticdata = cart_ahead._staticdata
function mod.link_cart_ahead(staticdata, ca_staticdata)
minetest.log("action","Linking cart #"..staticdata.uuid.." to cart #"..ca_staticdata.uuid)
staticdata.ahead = ca_staticdata.uuid