mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-22 01:01:45 +00:00
Merge branch 'fix-sector-lines' into 'next'
Fix sector.lines in Lua See merge request STJr/SRB2!542
This commit is contained in:
commit
4f33476fc0
1 changed files with 2 additions and 2 deletions
|
@ -445,7 +445,7 @@ static int sectorlines_get(lua_State *L)
|
||||||
// get the "linecount" by shifting our retrieved memory address of "lines" to where "linecount" is in the sector_t, then dereferencing the result
|
// get the "linecount" by shifting our retrieved memory address of "lines" to where "linecount" is in the sector_t, then dereferencing the result
|
||||||
// we need this to determine the array's actual size, and therefore also the maximum value allowed as an index
|
// we need this to determine the array's actual size, and therefore also the maximum value allowed as an index
|
||||||
// this only works if seclines is actually a pointer to a sector's lines member in memory, oh boy
|
// this only works if seclines is actually a pointer to a sector's lines member in memory, oh boy
|
||||||
numoflines = (size_t)(*(seclines - (offsetof(sector_t, lines) - offsetof(sector_t, linecount))));
|
numoflines = (size_t)(*(size_t *)(((size_t)seclines) - (offsetof(sector_t, lines) - offsetof(sector_t, linecount))));
|
||||||
|
|
||||||
/* OLD HACK
|
/* OLD HACK
|
||||||
// check first linedef to figure which of its sectors owns this sector->lines pointer
|
// check first linedef to figure which of its sectors owns this sector->lines pointer
|
||||||
|
@ -479,7 +479,7 @@ static int sectorlines_num(lua_State *L)
|
||||||
return luaL_error(L, "accessed sector_t.lines doesn't exist anymore.");
|
return luaL_error(L, "accessed sector_t.lines doesn't exist anymore.");
|
||||||
|
|
||||||
// see comments in the _get function above
|
// see comments in the _get function above
|
||||||
numoflines = (size_t)(*(seclines - (offsetof(sector_t, lines) - offsetof(sector_t, linecount))));
|
numoflines = (size_t)(*(size_t *)(((size_t)seclines) - (offsetof(sector_t, lines) - offsetof(sector_t, linecount))));
|
||||||
lua_pushinteger(L, numoflines);
|
lua_pushinteger(L, numoflines);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue