Skip to content
Snippets Groups Projects
  • Monster Iestyn's avatar
    75ee3193
    Write a new hack for getting sector->linecount from sector->lines in Lua, to... · 75ee3193
    Monster Iestyn authored
    Write a new hack for getting sector->linecount from sector->lines in Lua, to put my mind at rest about it at last.
    
    1) In sector_get, actually push the memory address of the lines array within sector_t, rather than push the value of "lines" itself (essentially, we we want a pointer to a double pointer, or rather a TRIPLE pointer haha)
    2) In the sectorlines_* functions, use offsetof to shift the memory address so we can obtain the value of linecount within the sector_t struct, and dereference the result to obtain the value of linecount itself
    3) ??? profit
    
    Untested and uncompiled atm, but I have some confidence this might work
    75ee3193
    History
    Write a new hack for getting sector->linecount from sector->lines in Lua, to...
    Monster Iestyn authored
    Write a new hack for getting sector->linecount from sector->lines in Lua, to put my mind at rest about it at last.
    
    1) In sector_get, actually push the memory address of the lines array within sector_t, rather than push the value of "lines" itself (essentially, we we want a pointer to a double pointer, or rather a TRIPLE pointer haha)
    2) In the sectorlines_* functions, use offsetof to shift the memory address so we can obtain the value of linecount within the sector_t struct, and dereference the result to obtain the value of linecount itself
    3) ??? profit
    
    Untested and uncompiled atm, but I have some confidence this might work