• entries
557
1237
• views
423619

# Untitled

133 views

EPIC FAIL:
// Get number of bytes read so faru32 getNumBytes() const{	if(m_nOffset&8)		return m_nOffset/8 + 1;	return m_nOffset/8;}

I spent 3 hours tracking down this sodding save CRC bug. The problem is that the CRC was right all along, it was just saving one byte too few (The CRC is at the end of the data), so the last few bits of the CRC were chopped off.

See if you can spot the bug, it's reasonably obvious (m_nOffset is in bits).

m_nOffset%8 or m_nOffset&7, I guess? Glad you got it fixed. [grin]

Quote:
 Original post by benryves m_nOffset%8 or m_nOffset&7, I guess? Glad you got it fixed. [grin]

[smile]

I thought the following was the standard way to do this?
// Get number of bytes read so far
u32 getNumBytes() const
{
return (m_nOffset+7)/8;
}



Quote:
 Original post by rick_appleton I thought the following was the standard way to do this? *** Source Snippet Removed ***
Yup, that's what I've changed it to [smile]

## Create an account

Register a new account