diff options
Diffstat (limited to 'serialize.h')
-rw-r--r-- | serialize.h | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/serialize.h b/serialize.h index 792b9096db..2eb525b978 100644 --- a/serialize.h +++ b/serialize.h @@ -22,8 +22,8 @@ class CDataStream; class CAutoFile; static const unsigned int MAX_SIZE = 0x02000000; -static const int VERSION = 312; -static const char* pszSubVer = ".8"; +static const int VERSION = 31300; +static const char* pszSubVer = ""; @@ -85,13 +85,6 @@ enum #define READWRITE(obj) (nSerSize += ::SerReadWrite(s, (obj), nType, nVersion, ser_action)) -#define READWRITEVER(obj) \ - do { \ - READWRITE((obj)); \ - if ((obj) == 10300) \ - (obj) = 300; \ - } while (false) - @@ -163,7 +156,7 @@ template<typename Stream> inline void Unserialize(Stream& s, bool& a, int, int=0 // inline unsigned int GetSizeOfCompactSize(uint64 nSize) { - if (nSize < UCHAR_MAX-2) return sizeof(unsigned char); + if (nSize < 253) return sizeof(unsigned char); else if (nSize <= USHRT_MAX) return sizeof(unsigned char) + sizeof(unsigned short); else if (nSize <= UINT_MAX) return sizeof(unsigned char) + sizeof(unsigned int); else return sizeof(unsigned char) + sizeof(uint64); @@ -172,30 +165,31 @@ inline unsigned int GetSizeOfCompactSize(uint64 nSize) template<typename Stream> void WriteCompactSize(Stream& os, uint64 nSize) { - if (nSize < UCHAR_MAX-2) + if (nSize < 253) { unsigned char chSize = nSize; WRITEDATA(os, chSize); } else if (nSize <= USHRT_MAX) { - unsigned char chSize = UCHAR_MAX-2; + unsigned char chSize = 253; unsigned short xSize = nSize; WRITEDATA(os, chSize); WRITEDATA(os, xSize); } else if (nSize <= UINT_MAX) { - unsigned char chSize = UCHAR_MAX-1; + unsigned char chSize = 254; unsigned int xSize = nSize; WRITEDATA(os, chSize); WRITEDATA(os, xSize); } else { - unsigned char chSize = UCHAR_MAX; + unsigned char chSize = 255; + uint64 xSize = nSize; WRITEDATA(os, chSize); - WRITEDATA(os, nSize); + WRITEDATA(os, xSize); } return; } @@ -206,27 +200,27 @@ uint64 ReadCompactSize(Stream& is) unsigned char chSize; READDATA(is, chSize); uint64 nSizeRet = 0; - if (chSize < UCHAR_MAX-2) + if (chSize < 253) { nSizeRet = chSize; } - else if (chSize == UCHAR_MAX-2) + else if (chSize == 253) { - unsigned short nSize; - READDATA(is, nSize); - nSizeRet = nSize; + unsigned short xSize; + READDATA(is, xSize); + nSizeRet = xSize; } - else if (chSize == UCHAR_MAX-1) + else if (chSize == 254) { - unsigned int nSize; - READDATA(is, nSize); - nSizeRet = nSize; + unsigned int xSize; + READDATA(is, xSize); + nSizeRet = xSize; } else { - uint64 nSize; - READDATA(is, nSize); - nSizeRet = nSize; + uint64 xSize; + READDATA(is, xSize); + nSizeRet = xSize; } if (nSizeRet > (uint64)MAX_SIZE) throw std::ios_base::failure("ReadCompactSize() : size too large"); |