Skip to content

Commit

Permalink
Merge MR 'Reduce RAM usage in various structures'
Browse files Browse the repository at this point in the history
As I understand in BIH_UNORDERED only children array is used, while front, back, min and max are never written. Opposite true for other node types.

On side note sizes should be explicitly added to ints.

See https://gitlab.com/xonotic/darkplaces/-/merge_requests/149

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
  • Loading branch information
bones-was-here committed Jul 20, 2024
2 parents 1f7a765 + cfe8e9b commit fd4fe9b
Show file tree
Hide file tree
Showing 3 changed files with 255 additions and 59 deletions.
20 changes: 12 additions & 8 deletions bih.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,18 @@ typedef struct bih_node_s
// TODO: move bounds data to parent node and remove it from leafs?
float mins[3];
float maxs[3];
// node indexes of children (always > this node's index)
int front;
int back;
// interval of children
float frontmin; // children[0]
float backmax; // children[1]
// BIH_UNORDERED uses this for a list of leafindex (all >= 0), -1 = end of list
int children[BIH_MAXUNORDEREDCHILDREN];
union {
struct{
// node indexes of children (always > this node's index)
int front;
int back;
// interval of children
float frontmin; // children[0]
float backmax; // children[1]
};
// BIH_UNORDERED uses this for a list of leafindex (all >= 0), -1 = end of list
int children[BIH_MAXUNORDEREDCHILDREN];
};
}
bih_node_t;

Expand Down
6 changes: 3 additions & 3 deletions com_crc16.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define CRC_INIT_VALUE 0xffff
#define CRC_XOR_VALUE 0x0000

static unsigned short crctable[256] =
static const u16 crctable[256] =
{
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
Expand Down Expand Up @@ -89,7 +89,7 @@ unsigned short CRC_Block_CaseInsensitive(const unsigned char *data, size_t size)
}

// QuakeWorld
static unsigned char chktbl[1024 + 4] =
static const u8 chktbl[1024 + 4] =
{
0x78,0xd2,0x94,0xe3,0x41,0xec,0xd6,0xd5,0xcb,0xfc,0xdb,0x8a,0x4b,0xcc,0x85,0x01,
0x23,0xd2,0xe5,0xf2,0x29,0xa7,0x45,0x94,0x4a,0x62,0xe3,0xa5,0x6f,0x3f,0xe1,0x7a,
Expand Down Expand Up @@ -131,7 +131,7 @@ static unsigned char chktbl[1024 + 4] =
// QuakeWorld
unsigned char COM_BlockSequenceCRCByteQW(unsigned char *base, int length, int sequence)
{
unsigned char *p;
const unsigned char *p;
unsigned char chkb[60 + 4];

p = chktbl + (sequence % (sizeof(chktbl) - 8));
Expand Down
Loading

0 comments on commit fd4fe9b

Please sign in to comment.