[aquaria] Start of a 64bit patch

Ryan C. Gordon icculus at icculus.org
Thu Jun 3 19:02:43 EDT 2010


> Attached is the start of a patch for 64bit support.  For some reason it 
> renders all black for me, however the audio works fine.  Hopefully this 
> will be some help in fixing that issue.

This probably isn't the right approach; Lua "numbers" are stored as 
doubles, so they aren't really safe for 64-bit pointers (and will break 
again if we get past 64 bits in our lifetime).

What you want to do, really, is push these as "lightuserdata" (which, 
for Lua's purposes, is a void pointer).

The problem, however, is that there are parts of the Lua code that 
compare these variables against 0 to see if they are actually NULL 
pointers in C++, and this won't work with light user data. Those things 
will need to be cleaned out. They tend to look something like this in 
the game scripts:

  while x =~ 0 do
     x = getNextEntity()
  end

I took the approach of lua_pushnumber(L, 0) when the pointer was NULL, 
and lua_pushlightuserdata(L, ptr) otherwise, which helped a lot, but 
basic things still acted wrong in the game. This was a hacky thing to do 
anyhow.

I started on this at the beginning of the Linux port. I've attached the 
patch that I did (and then reverted, because it still had bugs). It 
probably won't apply cleanly and you'll have to use patch -R because 
it's the reversion patch, but it'll give you an idea of what I'm 
thinking about.

--ryan.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: revert-64bit-attempt.diff
Type: text/x-diff
Size: 34190 bytes
Desc: not available
URL: <http://icculus.org/pipermail/aquaria/attachments/20100603/58886c89/attachment-0001.bin>


More information about the aquaria mailing list