issue #114, CCTMXTiledMap debug

This commit is contained in:
Walzer 2010-09-02 07:31:37 +00:00
parent 8b0bc69484
commit 43a4664534
5 changed files with 21 additions and 14 deletions

View File

@ -257,10 +257,15 @@ namespace cocos2d {
bRet = true; bRet = true;
} }
} while (0); } while (0);
CCX_SAFE_FREE(buffer); if (buffer)
{
delete [] buffer;
buffer = NULL;
}
if(deflated) if(deflated)
{ {
delete [] deflated; delete [] deflated;
deflated = NULL;
} }
CCX_SAFE_DELETE(image); CCX_SAFE_DELETE(image);
return bRet; return bRet;

View File

@ -93,14 +93,14 @@ int base64Decode(unsigned char *in, unsigned int inLength, unsigned char **out)
unsigned int outLength = 0; unsigned int outLength = 0;
//should be enough to store 6-bit buffers in 8-bit buffers //should be enough to store 6-bit buffers in 8-bit buffers
*out = (unsigned char *)malloc( (size_t)(inLength * 3.0f / 4.0f + 1)); *out = new unsigned char[(size_t)(inLength * 3.0f / 4.0f + 1)];
if( *out ) { if( *out ) {
int ret = _base64Decode(in, inLength, *out, &outLength); int ret = _base64Decode(in, inLength, *out, &outLength);
if (ret > 0 ) if (ret > 0 )
{ {
std::printf("Base64Utils: error decoding"); std::printf("Base64Utils: error decoding");
free(*out); delete [] *out;
*out = NULL; *out = NULL;
outLength = 0; outLength = 0;
} }

View File

@ -64,12 +64,13 @@ namespace cocos2d {
m_uMinGID = layerInfo->m_uMinGID; m_uMinGID = layerInfo->m_uMinGID;
m_uMaxGID = layerInfo->m_uMaxGID; m_uMaxGID = layerInfo->m_uMaxGID;
m_cOpacity = layerInfo->m_cOpacity; m_cOpacity = layerInfo->m_cOpacity;
if (!layerInfo->m_pProperties && layerInfo->m_pProperties->size()>0) m_pProperties = new StringToStringDictionary();
if (layerInfo->m_pProperties && layerInfo->m_pProperties->size()>0)
{ {
StringToStringDictionary::iterator it; StringToStringDictionary::iterator it;
for (it = layerInfo->m_pProperties->begin(); it != layerInfo->m_pProperties->end(); ++it) for (it = layerInfo->m_pProperties->begin(); it != layerInfo->m_pProperties->end(); ++it)
{ {
m_pProperties->insert(*it); m_pProperties->insert(StringToStringPair(it->first, it->second));
} }
} }

View File

@ -60,11 +60,11 @@ namespace cocos2d{
int idx = 0; int idx = 0;
if (mapInfo->getLayers() && mapInfo->getLayers()->count()>0) NSMutableArray<CCTMXLayerInfo*>* layers = mapInfo->getLayers();
if (layers && layers->count()>0)
{ {
CCTMXLayerInfo *layerInfo = NULL; CCTMXLayerInfo *layerInfo = NULL;
NSMutableArray<CCTMXLayerInfo*>::NSMutableArrayIterator it; NSMutableArray<CCTMXLayerInfo*>::NSMutableArrayIterator it;
NSMutableArray<CCTMXLayerInfo*>* layers = mapInfo->getLayers();
for (it = layers->begin(); it != layers->end(); ++it) for (it = layers->begin(); it != layers->end(); ++it)
{ {
layerInfo = *it; layerInfo = *it;
@ -128,12 +128,12 @@ namespace cocos2d{
//CFByteOrder o = CFByteOrderGetCurrent(); //CFByteOrder o = CFByteOrderGetCurrent();
CGSize size = layerInfo->m_tLayerSize; CGSize size = layerInfo->m_tLayerSize;
NSMutableArray<CCTMXTilesetInfo*>* tilesets = mapInfo->getTilesets();
if (mapInfo->getTilesets() && mapInfo->getTilesets()->count()>0) if (tilesets && tilesets->count()>0)
{ {
CCTMXTilesetInfo *tileset = NULL; CCTMXTilesetInfo *tileset = NULL;
NSMutableArray<CCTMXTilesetInfo*>::NSMutableArrayRevIterator rit; NSMutableArray<CCTMXTilesetInfo*>::NSMutableArrayRevIterator rit;
for (rit = mapInfo->getTilesets()->rbegin(); rit != mapInfo->getTilesets()->rend(); ++rit) for (rit = tilesets->rbegin(); rit != tilesets->rend(); ++rit)
{ {
tileset = *rit; tileset = *rit;
if (tileset) if (tileset)
@ -195,11 +195,11 @@ namespace cocos2d{
CCTMXObjectGroup * CCTMXTiledMap::objectGroupNamed(const char *groupName) CCTMXObjectGroup * CCTMXTiledMap::objectGroupNamed(const char *groupName)
{ {
std::string sGroupName = groupName; std::string sGroupName = groupName;
if (m_pChildren && m_pChildren->count()>0) if (m_pObjectGroups && m_pObjectGroups->count()>0)
{ {
CCTMXObjectGroup *objectGroup; CCTMXObjectGroup *objectGroup;
NSMutableArray<CCNode*>::NSMutableArrayIterator it; NSMutableArray<CCTMXObjectGroup*>::NSMutableArrayIterator it;
for (it = m_pChildren->begin(); it != m_pChildren->end(); ++it) for (it = m_pObjectGroups->begin(); it != m_pObjectGroups->end(); ++it)
{ {
objectGroup = (CCTMXObjectGroup*)(*it); objectGroup = (CCTMXObjectGroup*)(*it);
if (objectGroup && objectGroup->getGroupName() == sGroupName) if (objectGroup && objectGroup->getGroupName() == sGroupName)

View File

@ -470,7 +470,8 @@ namespace cocos2d {
{ {
unsigned char *deflated; unsigned char *deflated;
ZipUtils::inflateMemory(buffer, len, &deflated); ZipUtils::inflateMemory(buffer, len, &deflated);
free( buffer ); delete [] buffer;
buffer = NULL;
if( ! deflated ) if( ! deflated )
{ {