Fix typo in rail replacement mapping, fix several crashes

This commit is contained in:
teknomunk 2024-04-10 08:02:21 +00:00
parent 93de7d0384
commit be8697a056
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 local m2 = cart2_staticdata.mass
--print("u1="..tostring(u1)..",u2="..tostring(u2)) --print("u1="..tostring(u1)..",u2="..tostring(u2))
if u2 == 0 and u1 < 4 and train_length(cart1) < MAX_TRAIN_LENGTH then if u2 == 0 and u1 < 4 and train_length(cart1_staticdata) < MAX_TRAIN_LENGTH then
link_cart_ahead(cart1, {_staticdata=cart2_staticdata}) link_cart_ahead(cart1_staticdata, cart2_staticdata)
cart2_staticdata.dir = mcl_minecarts:get_rail_direction(cart2_staticdata.connected_at, cart1_staticdata.dir) cart2_staticdata.dir = mcl_minecarts:get_rail_direction(cart2_staticdata.connected_at, cart1_staticdata.dir)
cart2_staticdata.velocity = cart1_staticdata.velocity cart2_staticdata.velocity = cart1_staticdata.velocity
return return
@ -268,7 +268,7 @@ end
local function reverse_direction(staticdata) local function reverse_direction(staticdata)
if staticdata.behind or staticdata.ahead then if staticdata.behind or staticdata.ahead then
reverse_train(self) reverse_train(staticdata)
return return
end end

View File

@ -636,7 +636,7 @@ minetest.register_lbm({
local STRAIGHT_RAILS_MAP ={ local STRAIGHT_RAILS_MAP ={
["mcl_minecarts:golden_rail"] = "mcl_minecarts:golden_rail_v2", ["mcl_minecarts:golden_rail"] = "mcl_minecarts:golden_rail_v2",
["mcl_minecarts:golden_rail_on"] = "mcl_minecarts:golden_rail_v2_on", ["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:activator_rail_on"] = "mcl_minecarts:activator_rail_v2_on",
["mcl_minecarts:detector_rail"] = "mcl_minecarts:detector_rail_v2", ["mcl_minecarts:detector_rail"] = "mcl_minecarts:detector_rail_v2",
["mcl_minecarts:detector_rail_on"] = "mcl_minecarts:detector_rail_v2_on", ["mcl_minecarts:detector_rail_on"] = "mcl_minecarts:detector_rail_v2_on",

View File

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