mirror of https://github.com/axmolengine/axmol.git
issue #1056: Added CCArray::copyWithZone implementation. CCDictElement bound check.
This commit is contained in:
parent
15e03f8b14
commit
7c0af610ff
|
@ -130,7 +130,7 @@ void CCAtlasNode::updateAtlasValues()
|
||||||
}
|
}
|
||||||
|
|
||||||
// CCAtlasNode - draw
|
// CCAtlasNode - draw
|
||||||
void CCAtlasNode::draw()
|
void CCAtlasNode::draw(void)
|
||||||
{
|
{
|
||||||
CC_NODE_DRAW_SETUP();
|
CC_NODE_DRAW_SETUP();
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ public:
|
||||||
void replaceObjectAtIndex(unsigned int uIndex, CCObject* pObject, bool bReleaseObject = true);
|
void replaceObjectAtIndex(unsigned int uIndex, CCObject* pObject, bool bReleaseObject = true);
|
||||||
|
|
||||||
/** TODO: deep copy array. */
|
/** TODO: deep copy array. */
|
||||||
virtual CCObject* copyWithZone(CCZone* pZone) {CCAssert(false, "");return NULL;}
|
virtual CCObject* copyWithZone(CCZone* pZone);
|
||||||
public:
|
public:
|
||||||
ccArray* data;
|
ccArray* data;
|
||||||
CCArray() : data(NULL) {};
|
CCArray() : data(NULL) {};
|
||||||
|
|
|
@ -87,7 +87,7 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void updateAtlasValues();
|
virtual void updateAtlasValues();
|
||||||
|
|
||||||
virtual void draw();
|
virtual void draw(void);
|
||||||
|
|
||||||
// CC Texture protocol
|
// CC Texture protocol
|
||||||
|
|
||||||
|
|
|
@ -52,11 +52,13 @@ public:
|
||||||
|
|
||||||
inline const char* getStrKey() const
|
inline const char* getStrKey() const
|
||||||
{
|
{
|
||||||
|
CCAssert(m_szKey[0] != '\0', "Should not call this function for integer dictionary");
|
||||||
return m_szKey;
|
return m_szKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int getIntKey() const
|
inline int getIntKey() const
|
||||||
{
|
{
|
||||||
|
CCAssert(m_szKey[0] == '\0', "Should not call this function for string dictionary");
|
||||||
return m_iKey;
|
return m_iKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,9 +77,9 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char m_szKey[256]; /* hash key of string type*/
|
char m_szKey[256]; /** hash key of string type*/
|
||||||
int m_iKey; /* hash key of integer type */
|
int m_iKey; /** hash key of integer type */
|
||||||
CCObject* m_pObject;/* hash value */
|
CCObject* m_pObject;/** hash value */
|
||||||
public:
|
public:
|
||||||
UT_hash_handle hh; /* makes this class hashable */
|
UT_hash_handle hh; /* makes this class hashable */
|
||||||
friend class CCDictionary;
|
friend class CCDictionary;
|
||||||
|
|
|
@ -61,17 +61,8 @@ CCArray* CCArray::arrayWithCapacity(unsigned int capacity)
|
||||||
|
|
||||||
CCArray* CCArray::arrayWithArray(CCArray* otherArray)
|
CCArray* CCArray::arrayWithArray(CCArray* otherArray)
|
||||||
{
|
{
|
||||||
CCArray* pArray = new CCArray();
|
CCArray* pArray = (CCArray*)otherArray->copyWithZone(NULL);
|
||||||
|
pArray->autorelease();
|
||||||
if (pArray && pArray->initWithArray(otherArray))
|
|
||||||
{
|
|
||||||
pArray->autorelease();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CC_SAFE_DELETE(pArray);
|
|
||||||
}
|
|
||||||
|
|
||||||
return pArray;
|
return pArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,4 +248,15 @@ void CCArray::replaceObjectAtIndex(unsigned int uIndex, CCObject* pObject, bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CCObject* CCArray::copyWithZone(CCZone* pZone)
|
||||||
|
{
|
||||||
|
CCArray* pArray = new CCArray();
|
||||||
|
|
||||||
|
if (!(pArray && pArray->initWithArray(this)))
|
||||||
|
{
|
||||||
|
CC_SAFE_DELETE(pArray);
|
||||||
|
}
|
||||||
|
return pArray;
|
||||||
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -523,6 +523,7 @@ void CCTextureAtlas::drawNumberOfQuads(unsigned int n)
|
||||||
|
|
||||||
void CCTextureAtlas::drawNumberOfQuads(unsigned int n, unsigned int start)
|
void CCTextureAtlas::drawNumberOfQuads(unsigned int n, unsigned int start)
|
||||||
{
|
{
|
||||||
|
if (0 == n) return;
|
||||||
ccGLBindTexture2D( m_pTexture->getName() );
|
ccGLBindTexture2D( m_pTexture->getName() );
|
||||||
|
|
||||||
// XXX: update is done in draw... perhaps it should be done in a timer
|
// XXX: update is done in draw... perhaps it should be done in a timer
|
||||||
|
|
Loading…
Reference in New Issue