Reduce size of some MapBlock members

Also adds assertions to catch refcounting errors (on a debug build).
This commit is contained in:
sfan5 2023-12-12 16:14:40 +01:00
parent 777dca7043
commit 9408a1a025
2 changed files with 8 additions and 4 deletions

View File

@ -379,15 +379,17 @@ public:
inline void refGrab()
{
assert(m_refcount < SHRT_MAX);
m_refcount++;
}
inline void refDrop()
{
assert(m_refcount > 0);
m_refcount--;
}
inline int refGet()
inline short refGet()
{
return m_refcount;
}
@ -500,7 +502,7 @@ private:
block has been modified from the one on disk.
- On the client, this is used for nothing.
*/
u32 m_modified = MOD_STATE_WRITE_NEEDED;
u16 m_modified = MOD_STATE_WRITE_NEEDED;
u32 m_modified_reason = MOD_REASON_INITIAL;
/*
@ -550,7 +552,7 @@ private:
Reference count; currently used for determining if this block is in
the list of blocks to be drawn.
*/
int m_refcount = 0;
short m_refcount = 0;
NodeTimerList m_node_timers;
};

View File

@ -19,7 +19,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#pragma once
enum ModifiedState
#include "irrlichttypes.h"
enum ModifiedState : u16
{
// Has not been modified.
MOD_STATE_CLEAN = 0,