T2: fine in 32-bit, Lua error in 64-bit

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Therem Harth
    Knight
    • Jan 2008
    • 926

    T2: fine in 32-bit, Lua error in 64-bit

    I've noticed that (in ToME 2.3.5) hitting escape in the Geomancy spell menu produces a Lua error on 64-bit Linux. The error indicates that the game attempted to index a nil variable in the function get_affect() in lib/core/s_aux.lua. It's not fatal, but it is quite unsightly.

    What's weird is that the 32-bit Linux version is perfectly okay.

    (2.3.9-ah also doesn't have this issue.)

    Anyone know why an error like this might occur only in 64-bit mode?
  • AnonymousHero
    Veteran
    • Jun 2007
    • 1393

    #2
    It may be that a function prototype/declaration in the *.pkg file differs from the declaration in the *.h file.

    Comment

    • Therem Harth
      Knight
      • Jan 2008
      • 926

      #3
      Thanks...

      Looking at the stack traceback, BTW, it looks to me like cast_school_spell() is being invoked even when you hit the escape key - and thus invoked on a spell that doesn't exist, producing the error. Not sure why; escape is supposed to produce a value of -1, which should be caught by an if statement and cause cast_school_spell not to be invoked:

      Code:
      		s = get_school_spell("cast", "is_ok_spell", 63)
      		if (s ~= -1) then
      			cast_school_spell(s, spell(s))
      		end
      Maybe there is some kind of type mismatch on 64-bit, that's preventing the value from being properly recognized?

      Comment

      • AnonymousHero
        Veteran
        • Jun 2007
        • 1393

        #4
        It's probably a declaration mismatch on the return of the function then. -1 in two-completement in 32-bit has a tendency to not stay -1 when "converted" (without sign extension, or a random adjacent garbage)

        Comment

        • Therem Harth
          Knight
          • Jan 2008
          • 926

          #5
          Looks like you're right, it's a u32b getting converted to an int. Thank you.

          Edit: wait, u32b? How are we supposed to get -1 with an unsigned integer?

          Edit 2: yes, making get_school_spell return an int instead of a u32b worked. Hurray.
          Last edited by Therem Harth; October 24, 2012, 19:05.

          Comment

          Working...
          😀
          😂
          🥰
          😘
          🤢
          😎
          😞
          😡
          👍
          👎