Choumiko / FARL

51 stars 21 forks source link

[4.0.4] nil index in reset_rail_types #109

Open 0ptera opened 4 years ago

0ptera commented 4 years ago

Hi, looks like you forgot a nil check when rewriting the rail initialization.

1805.505 Script @__FARL__/control.lua:251: FARL version changed from 4.0.2 to 4.0.4
1806.232 Error AppManagerStates.cpp:1453: The mod Fully Automated Rail Layer (4.0.4) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event FARL::on_configuration_changed
__FARL__/control.lua:238: attempt to index a nil value
stack traceback:
    __FARL__/control.lua:238: in function 'reset_rail_types'
    __FARL__/control.lua:494: in function <__FARL__/control.lua:244>
Choumiko commented 4 years ago

Now that's a strange line to error on: https://github.com/Choumiko/FARL/blob/dcc834e8e3d76e22283a6bf8ab321f63592bee3a/control.lua#L237-L238

I registered on_pre_player_removed and clean up global.players. Looks like you removed a player before i added that hook?

Edit: git blame says that would have been 2 years ago.. Seems strange, i'll have to double check what's going on in the morning

0ptera commented 4 years ago

Even stranger, it's a single player map. Unless your global.players actually contains characters I don't see how a change to that could have happen.

Edit: Here's the serpent from my global.players

/c __FARL__ log(serpent.block(global.players)):
{
  {
    YARM_old_expando = false,
    activeBP = {
      diagonal = {
        boundingBox = {
          br = {
            x = 2.5,
            y = 4
          },
          tl = {
            x = -1,
            y = 0
          }
        },
        clearance_points = {},
        direction = 7,
        lanes = {},
        pole = {
          name = "big-electric-pole",
          position = {
            x = 2.5,
            y = 2.5
          }
        },
        poleEntities = {
          {
            name = "small-lamp",
            position = {
              x = -1.5,
              y = 1.5
            }
          }
        },
        railEntities = {},
        rails = {},
        signals = {}
      },
      straight = {
        boundingBox = {
          br = {
            x = 3,
            y = 0.5
          },
          tl = {
            x = -0.5,
            y = -1
          }
        },
        clearance_points = {},
        direction = 0,
        lanes = {},
        pole = {
          name = "big-electric-pole",
          position = {
            x = 3,
            y = -1
          }
        },
        poleEntities = {
          {
            name = "small-lamp",
            position = {
              x = -0.5,
              y = 1.5
            }
          }
        },
        railEntities = {},
        rails = {},
        signals = {}
      }
    },
    bp = 0,
    bridge = true,
    bulldozer = false,
    ccNet = true,
    ccWires = 3,
    collectWood = true,
    concrete = false,
    cruiseSpeed = 0.4,
    curvedWeight = 4,
    dropWood = true,
    flipPoles = false,
    maintenance = true,
    minPoles = true,
    mirrorConcrete = true,
    parallelTracks = true,
    place_ghosts = false,
    poleEntities = true,
    poles = true,
    rail = {
      curved = "curved-rail",
      index = 1,
      item = "rail",
      straight = "straight-rail"
    },
    railEntities = false,
    railType = 1,
    remove_cliffs = true,
    signalDistance = 13,
    signalEveryPole = false,
    signals = false
  },
  {
    activeBP = {
      diagonal = {
        boundingBox = {
          br = {
            x = 2.5,
            y = 4
          },
          tl = {
            x = -1,
            y = 0
          }
        },
        clearance_points = {},
        direction = 7,
        lanes = {},
        pole = {
          name = "big-electric-pole",
          position = {
            x = 2.5,
            y = 2.5
          }
        },
        poleEntities = {
          {
            name = "small-lamp",
            position = {
              x = -1.5,
              y = 1.5
            }
          }
        },
        railEntities = {},
        rails = {},
        signals = {}
      },
      straight = {
        boundingBox = {
          br = {
            x = 3,
            y = 0.5
          },
          tl = {
            x = -0.5,
            y = -1
          }
        },
        clearance_points = {},
        direction = 0,
        lanes = {},
        pole = {
          name = "big-electric-pole",
          position = {
            x = 3,
            y = -1
          }
        },
        poleEntities = {
          {
            name = "small-lamp",
            position = {
              x = -0.5,
              y = 1.5
            }
          }
        },
        railEntities = {},
        rails = {},
        signals = {}
      }
    },
    bp = 0,
    bridge = false,
    bulldozer = false,
    ccNet = false,
    ccWires = 1,
    collectWood = true,
    concrete = true,
    cruiseSpeed = 0.4,
    curvedWeight = 4,
    dropWood = true,
    flipPoles = false,
    maintenance = false,
    minPoles = true,
    mirrorConcrete = true,
    parallelTracks = true,
    place_ghosts = true,
    poleEntities = true,
    poles = true,
    rail = 0,
    railEntities = true,
    railType = 1,
    remove_cliffs = true,
    signalDistance = 15,
    signalEveryPole = false,
    signals = true
  }
}