mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 23:42:11 +00:00
Use bitarray_t for used_spr
This commit is contained in:
parent
b3844a9ca5
commit
45d54c38f7
4 changed files with 6 additions and 6 deletions
|
@ -66,12 +66,12 @@ static inline int lib_freeslot(lua_State *L)
|
|||
|
||||
for (j = SPR_FIRSTFREESLOT; j <= SPR_LASTFREESLOT; j++)
|
||||
{
|
||||
if (used_spr[(j-SPR_FIRSTFREESLOT)/8] & (1<<(j%8)))
|
||||
if (in_bit_array(used_spr, j - SPR_FIRSTFREESLOT))
|
||||
continue; // Already allocated, next.
|
||||
// Found a free slot!
|
||||
CONS_Printf("Sprite SPR_%s allocated.\n",word);
|
||||
strcpy(sprnames[j], word);
|
||||
used_spr[(j-SPR_FIRSTFREESLOT)/8] |= 1<<(j%8); // Okay, this sprite slot has been named now.
|
||||
set_bit_array(used_spr, j - SPR_FIRSTFREESLOT); // Okay, this sprite slot has been named now.
|
||||
// Lua needs to update the value in _G if it exists
|
||||
LUA_UpdateSprName(word, j);
|
||||
lua_pushinteger(L, j);
|
||||
|
|
|
@ -445,11 +445,11 @@ void readfreeslots(MYFILE *f)
|
|||
|
||||
for (i = SPR_FIRSTFREESLOT; i <= SPR_LASTFREESLOT; i++)
|
||||
{
|
||||
if (used_spr[(i-SPR_FIRSTFREESLOT)/8] & (1<<(i%8)))
|
||||
if (in_bit_array(used_spr, i - SPR_FIRSTFREESLOT))
|
||||
continue; // Already allocated, next.
|
||||
// Found a free slot!
|
||||
strcpy(sprnames[i], word);
|
||||
used_spr[(i-SPR_FIRSTFREESLOT)/8] |= 1<<(i%8); // Okay, this sprite slot has been named now.
|
||||
set_bit_array(used_spr, i - SPR_FIRSTFREESLOT); // Okay, this sprite slot has been named now.
|
||||
// Lua needs to update the value in _G if it exists
|
||||
LUA_UpdateSprName(word, i);
|
||||
break;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
char *FREE_STATES[NUMSTATEFREESLOTS];
|
||||
char *FREE_MOBJS[NUMMOBJFREESLOTS];
|
||||
char *FREE_SKINCOLORS[NUMCOLORFREESLOTS];
|
||||
UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway.
|
||||
bitarray_t used_spr[BIT_ARRAY_SIZE(NUMSPRITEFREESLOTS)]; // Sprite freeslots in use
|
||||
|
||||
const char NIGHTSGRADE_LIST[] = {
|
||||
'F', // GRADE_F
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
extern char *FREE_STATES[NUMSTATEFREESLOTS];
|
||||
extern char *FREE_MOBJS[NUMMOBJFREESLOTS];
|
||||
extern char *FREE_SKINCOLORS[NUMCOLORFREESLOTS];
|
||||
extern UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway.
|
||||
extern bitarray_t used_spr[BIT_ARRAY_SIZE(NUMSPRITEFREESLOTS)]; // Sprite freeslots in use
|
||||
|
||||
#define initfreeslots() {\
|
||||
memset(FREE_STATES, 0, sizeof(FREE_STATES));\
|
||||
|
|
Loading…
Reference in a new issue