mirror of https://github.com/axmolengine/axmol.git
Merge pull request #47 from lvlonggame/v3
modify bundle3d version and bundleReader
This commit is contained in:
commit
5666033faf
|
@ -447,8 +447,7 @@ bool Bundle3D::loadBinary(const std::string& path)
|
|||
return false;
|
||||
}
|
||||
|
||||
// Create bundle reader
|
||||
//CC_SAFE_DELETE(_bundleReader);
|
||||
// Initialise bundle reader
|
||||
_binaryReader.init( (char*)_binaryBuffer->getBytes(), _binaryBuffer->getSize() );
|
||||
|
||||
// Read identifier info
|
||||
|
@ -463,8 +462,11 @@ bool Bundle3D::loadBinary(const std::string& path)
|
|||
|
||||
// Read version
|
||||
unsigned char ver[2];
|
||||
if (_binaryReader.read(ver, 1, 2) == 2)
|
||||
{
|
||||
if (_binaryReader.read(ver, 1, 2)!= 2){
|
||||
CCLOG("Failed to read version:");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ver[0] != 0) {
|
||||
clear();
|
||||
CCLOGINFO(false, "Unsupported version: (%d, %d)", ver[0], ver[1]);
|
||||
|
@ -476,7 +478,7 @@ bool Bundle3D::loadBinary(const std::string& path)
|
|||
CCLOGINFO(false, "Unsupported version: (%d, %d)", ver[0], ver[1]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Read ref table size
|
||||
if (_binaryReader.read(&_referenceCount, 4, 1) != 1)
|
||||
|
|
|
@ -65,7 +65,7 @@ char* BundleReader::readLine(int num,char* line)
|
|||
char* p = line;
|
||||
char c;
|
||||
ssize_t readNum = 0;
|
||||
while((c=*buffer) != 10 && readNum < (ssize_t)num && m_position<(long int)m_length)
|
||||
while((c=*buffer) != 10 && readNum < (ssize_t)num && m_position < m_length)
|
||||
{
|
||||
*p = c;
|
||||
p++;
|
||||
|
@ -91,7 +91,7 @@ ssize_t BundleReader::length()
|
|||
return m_length;
|
||||
}
|
||||
|
||||
long int BundleReader::tell()
|
||||
ssize_t BundleReader::tell()
|
||||
{
|
||||
if (!m_buffer)
|
||||
return -1;
|
||||
|
|
|
@ -112,7 +112,7 @@ public:
|
|||
bool readMatrix(float* m);
|
||||
|
||||
private:
|
||||
long int m_position;
|
||||
ssize_t m_position;
|
||||
ssize_t m_length;
|
||||
char* m_buffer;
|
||||
};
|
||||
|
@ -136,6 +136,7 @@ inline bool BundleReader::readArray(unsigned int *length, std::vector<T> *values
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*length > 0 && values)
|
||||
{
|
||||
values->resize(*length);
|
||||
|
|
Loading…
Reference in New Issue