mirror of https://github.com/axmolengine/axmol.git
commit
368647c166
|
@ -134,7 +134,7 @@ void PointArray::insertControlPoint(Point &controlPoint, int index)
|
|||
|
||||
Point PointArray::getControlPointAtIndex(int index)
|
||||
{
|
||||
index = MIN(_controlPoints->size()-1, MAX(index, 0));
|
||||
index = static_cast<int>(MIN(_controlPoints->size()-1, MAX(index, 0)));
|
||||
return *(_controlPoints->at(index));
|
||||
}
|
||||
|
||||
|
@ -291,7 +291,7 @@ CardinalSplineTo* CardinalSplineTo::clone() const
|
|||
|
||||
void CardinalSplineTo::update(float time)
|
||||
{
|
||||
ssize_t p;
|
||||
int p;
|
||||
float lt;
|
||||
|
||||
// eg.
|
||||
|
|
|
@ -102,7 +102,7 @@ void AnimationCache::parseVersion1(const ValueMap& animations)
|
|||
continue;
|
||||
}
|
||||
|
||||
Vector<AnimationFrame*> frames(frameNames.size());
|
||||
Vector<AnimationFrame*> frames(static_cast<int>(frameNames.size()));
|
||||
|
||||
for (auto& frameName : frameNames)
|
||||
{
|
||||
|
@ -155,7 +155,7 @@ void AnimationCache::parseVersion2(const ValueMap& animations)
|
|||
}
|
||||
|
||||
// Array of AnimationFrames
|
||||
Vector<AnimationFrame*> array(frameArray.size());
|
||||
Vector<AnimationFrame*> array(static_cast<int>(frameArray.size()));
|
||||
|
||||
for (auto& obj : frameArray)
|
||||
{
|
||||
|
|
|
@ -1080,7 +1080,7 @@ void EventDispatcher::removeCustomEventListeners(const std::string& customEventN
|
|||
|
||||
void EventDispatcher::removeAllEventListeners()
|
||||
{
|
||||
std::vector<int> types(_listeners.size());
|
||||
std::vector<EventListener::ListenerID> types(_listeners.size());
|
||||
|
||||
for (auto iter = _listeners.begin(); iter != _listeners.end(); ++iter)
|
||||
{
|
||||
|
|
|
@ -141,7 +141,7 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
|
|||
}
|
||||
|
||||
float scaleFactor = CC_CONTENT_SCALE_FACTOR();
|
||||
int newLetterCount = fontDefs.size();
|
||||
size_t newLetterCount = fontDefs.size();
|
||||
float glyphWidth;
|
||||
for (int i = 0; i < newLetterCount; ++i)
|
||||
{
|
||||
|
|
|
@ -149,7 +149,7 @@ FontAtlas * FontFNT::createFontAtlas()
|
|||
if (!_configuration->_fontDefDictionary)
|
||||
return nullptr;
|
||||
|
||||
int numGlyphs = _configuration->_characterSet->size();
|
||||
size_t numGlyphs = _configuration->_characterSet->size();
|
||||
if (!numGlyphs)
|
||||
return nullptr;
|
||||
|
||||
|
|
|
@ -297,7 +297,7 @@ int FontFreeType::getAdvanceForChar(unsigned short theChar) const
|
|||
return 0;
|
||||
|
||||
// get to the advance for this glyph
|
||||
return (_fontRef->glyph->advance.x >> 6);
|
||||
return (static_cast<int>(_fontRef->glyph->advance.x >> 6));
|
||||
}
|
||||
|
||||
int FontFreeType::getBearingXForChar(unsigned short theChar) const
|
||||
|
@ -316,7 +316,7 @@ int FontFreeType::getBearingXForChar(unsigned short theChar) const
|
|||
if (FT_Load_Glyph(_fontRef, glyphIndex, FT_LOAD_DEFAULT))
|
||||
return 0;
|
||||
|
||||
return (_fontRef->glyph->metrics.horiBearingX >>6);
|
||||
return (static_cast<int>(_fontRef->glyph->metrics.horiBearingX >>6));
|
||||
}
|
||||
|
||||
int FontFreeType::getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const
|
||||
|
@ -346,12 +346,12 @@ int FontFreeType::getHorizontalKerningForChars(unsigned short firstChar, unsign
|
|||
if (FT_Get_Kerning( _fontRef, glyphIndex1, glyphIndex2, FT_KERNING_DEFAULT, &kerning))
|
||||
return 0;
|
||||
|
||||
return (kerning.x >> 6);
|
||||
return (static_cast<int>(kerning.x >> 6));
|
||||
}
|
||||
|
||||
int FontFreeType::getFontMaxHeight() const
|
||||
{
|
||||
return (_fontRef->size->metrics.height >> 6);
|
||||
return (static_cast<int>(_fontRef->size->metrics.height >> 6));
|
||||
}
|
||||
|
||||
unsigned char * FontFreeType::getGlyphBitmap(unsigned short theChar, int &outWidth, int &outHeight) const
|
||||
|
|
|
@ -62,7 +62,7 @@ bool LabelAtlas::initWithString(const std::string& string, const std::string& ch
|
|||
|
||||
bool LabelAtlas::initWithString(const std::string& string, Texture2D* texture, int itemWidth, int itemHeight, int startCharMap)
|
||||
{
|
||||
if (AtlasNode::initWithTexture(texture, itemWidth, itemHeight, string.size()))
|
||||
if (AtlasNode::initWithTexture(texture, itemWidth, itemHeight, static_cast<int>(string.size())))
|
||||
{
|
||||
_mapStartChar = startCharMap;
|
||||
this->setString(string);
|
||||
|
@ -179,7 +179,7 @@ void LabelAtlas::updateAtlasValues()
|
|||
_textureAtlas->setDirty(true);
|
||||
auto totalQuads = _textureAtlas->getTotalQuads();
|
||||
if (n > totalQuads) {
|
||||
_textureAtlas->increaseTotalQuadsWith(n - totalQuads);
|
||||
_textureAtlas->increaseTotalQuadsWith(static_cast<int>(n - totalQuads));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ void LabelAtlas::setString(const std::string &label)
|
|||
auto len = label.size();
|
||||
if (len > _textureAtlas->getTotalQuads())
|
||||
{
|
||||
_textureAtlas->resizeCapacity(len);
|
||||
_textureAtlas->resizeCapacity(static_cast<int>(len));
|
||||
}
|
||||
_string.clear();
|
||||
_string = label;
|
||||
|
|
|
@ -494,7 +494,7 @@ bool LabelBMFont::initWithString(const std::string& theString, const std::string
|
|||
texture->autorelease();
|
||||
}
|
||||
|
||||
if (SpriteBatchNode::initWithTexture(texture, theString.size()))
|
||||
if (SpriteBatchNode::initWithTexture(texture, static_cast<int>(theString.size())))
|
||||
{
|
||||
_width = width;
|
||||
_alignment = alignment;
|
||||
|
@ -1085,7 +1085,7 @@ void LabelBMFont::updateLabel()
|
|||
lineNumber++;
|
||||
continue;
|
||||
}
|
||||
int index = i + line_length - 1 + lineNumber;
|
||||
int index = static_cast<int>(i + line_length - 1 + lineNumber);
|
||||
if (index < 0) continue;
|
||||
|
||||
Sprite* lastChar = static_cast<Sprite*>( getChildByTag(index) );
|
||||
|
|
|
@ -39,7 +39,7 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
|
|||
{
|
||||
// Step 1: Make multiline
|
||||
vector<unsigned short> strWhole = cc_utf16_vec_from_utf16_str(theLabel->getUTF8String());
|
||||
unsigned int stringLength = strWhole.size();
|
||||
size_t stringLength = strWhole.size();
|
||||
|
||||
vector<unsigned short> multiline_string;
|
||||
multiline_string.reserve( stringLength );
|
||||
|
@ -197,7 +197,7 @@ bool LabelTextFormatter::multilineText(LabelTextFormatProtocol *theLabel)
|
|||
|
||||
multiline_string.insert(multiline_string.end(), last_word.begin(), last_word.end());
|
||||
|
||||
int size = multiline_string.size();
|
||||
size_t size = multiline_string.size();
|
||||
unsigned short* strNew = new unsigned short[size + 1];
|
||||
|
||||
for (int j = 0; j < size; ++j)
|
||||
|
@ -231,7 +231,7 @@ bool LabelTextFormatter::alignText(LabelTextFormatProtocol *theLabel)
|
|||
if (currentChar == '\n' || currentChar == 0)
|
||||
{
|
||||
float lineWidth = 0.0f;
|
||||
unsigned int lineLength = lastLine.size();
|
||||
size_t lineLength = lastLine.size();
|
||||
|
||||
// if last line is empty we must just increase lineNumber and work with next line
|
||||
if (lineLength == 0)
|
||||
|
@ -239,7 +239,7 @@ bool LabelTextFormatter::alignText(LabelTextFormatProtocol *theLabel)
|
|||
lineNumber++;
|
||||
continue;
|
||||
}
|
||||
int index = i + lineLength - 1 + lineNumber;
|
||||
int index = static_cast<int>(i + lineLength - 1 + lineNumber);
|
||||
if (index < 0) continue;
|
||||
|
||||
if(currentChar == 0)
|
||||
|
|
|
@ -42,7 +42,7 @@ THE SOFTWARE.
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
static long _globalFontSize = kItemSize;
|
||||
static int _globalFontSize = kItemSize;
|
||||
static std::string _globalFontName = "Marker Felt";
|
||||
static bool _globalFontNameRelease = false;
|
||||
|
||||
|
|
|
@ -393,7 +393,7 @@ bool ParticleSystem::initWithDictionary(ValueMap& dictionary, const std::string&
|
|||
CCASSERT( buffer != nullptr, "CCParticleSystem: error decoding textureImageData");
|
||||
CC_BREAK_IF(!buffer);
|
||||
|
||||
int deflatedLen = ZipUtils::inflateMemory(buffer, decodeLen, &deflated);
|
||||
ssize_t deflatedLen = ZipUtils::inflateMemory(buffer, decodeLen, &deflated);
|
||||
CCASSERT( deflated != nullptr, "CCParticleSystem: error ungzipping textureImageData");
|
||||
CC_BREAK_IF(!deflated);
|
||||
|
||||
|
|
|
@ -406,9 +406,9 @@ void SpriteBatchNode::increaseAtlasCapacity(void)
|
|||
// if we're going beyond the current TextureAtlas's capacity,
|
||||
// all the previously initialized sprites will need to redo their texture coords
|
||||
// this is likely computationally expensive
|
||||
auto quantity = (_textureAtlas->getCapacity() + 1) * 4 / 3;
|
||||
int quantity = (_textureAtlas->getCapacity() + 1) * 4 / 3;
|
||||
|
||||
CCLOG("cocos2d: SpriteBatchNode: resizing TextureAtlas capacity from [%lu] to [%lu].",
|
||||
CCLOG("cocos2d: SpriteBatchNode: resizing TextureAtlas capacity from [%d] to [%d].",
|
||||
_textureAtlas->getCapacity(),
|
||||
quantity);
|
||||
|
||||
|
@ -551,7 +551,7 @@ void SpriteBatchNode::appendChild(Sprite* sprite)
|
|||
}
|
||||
|
||||
_descendants.push_back(sprite);
|
||||
auto index = _descendants.size()-1;
|
||||
int index = static_cast<int>(_descendants.size()-1);
|
||||
|
||||
sprite->setAtlasIndex(index);
|
||||
|
||||
|
|
|
@ -379,7 +379,7 @@ Sprite * TMXLayer::insertTileForGID(unsigned int gid, const Point& pos)
|
|||
setupTileSprite(tile, pos, gid);
|
||||
|
||||
// get atlas index
|
||||
unsigned int indexForZ = atlasIndexForNewZ(z);
|
||||
unsigned int indexForZ = atlasIndexForNewZ(static_cast<int>(z));
|
||||
|
||||
// Optimization: add the quad without adding a child
|
||||
this->insertQuadFromSprite(tile, indexForZ);
|
||||
|
|
|
@ -664,9 +664,9 @@ void TMXMapInfo::endElement(void *ctx, const char *name)
|
|||
unsigned char *deflated = nullptr;
|
||||
Size s = layer->_layerSize;
|
||||
// int sizeHint = s.width * s.height * sizeof(uint32_t);
|
||||
int sizeHint = (int)(s.width * s.height * sizeof(unsigned int));
|
||||
ssize_t sizeHint = s.width * s.height * sizeof(unsigned int);
|
||||
|
||||
int CC_UNUSED inflatedLen = ZipUtils::inflateMemoryWithHint(buffer, len, &deflated, sizeHint);
|
||||
ssize_t CC_UNUSED inflatedLen = ZipUtils::inflateMemoryWithHint(buffer, len, &deflated, sizeHint);
|
||||
CCASSERT(inflatedLen == sizeHint, "");
|
||||
|
||||
free(buffer);
|
||||
|
|
|
@ -164,7 +164,7 @@ void TextFieldTTF::insertText(const char * text, int len)
|
|||
std::string sInsert(text, len);
|
||||
|
||||
// insert \n means input end
|
||||
int nPos = sInsert.find('\n');
|
||||
int nPos = static_cast<int>(sInsert.find('\n'));
|
||||
if ((int)sInsert.npos != nPos)
|
||||
{
|
||||
len = nPos;
|
||||
|
@ -201,7 +201,7 @@ void TextFieldTTF::insertText(const char * text, int len)
|
|||
|
||||
void TextFieldTTF::deleteBackward()
|
||||
{
|
||||
int nStrLen = _inputText.length();
|
||||
size_t nStrLen = _inputText.length();
|
||||
if (! nStrLen)
|
||||
{
|
||||
// there is no string
|
||||
|
@ -279,7 +279,7 @@ void TextFieldTTF::setString(const std::string &text)
|
|||
{
|
||||
static char bulletString[] = {(char)0xe2, (char)0x80, (char)0xa2, (char)0x00};
|
||||
std::string displayText;
|
||||
int length;
|
||||
size_t length;
|
||||
|
||||
if (text.length()>0)
|
||||
{
|
||||
|
|
|
@ -49,7 +49,7 @@ TextPageDef::TextPageDef(int pageNum, int width, int height): _pageNum(pageNum
|
|||
|
||||
TextPageDef::~TextPageDef()
|
||||
{
|
||||
int numLines = _lines.size();
|
||||
size_t numLines = _lines.size();
|
||||
|
||||
for( int c = 0; c<numLines; ++c )
|
||||
{
|
||||
|
@ -122,8 +122,8 @@ TextFontPagesDef::TextFontPagesDef()
|
|||
|
||||
TextFontPagesDef::~TextFontPagesDef()
|
||||
{
|
||||
int numPages = _pages.size();
|
||||
for( int c = 0; c < numPages; ++c )
|
||||
size_t numPages = _pages.size();
|
||||
for( size_t c = 0; c < numPages; ++c )
|
||||
{
|
||||
if (_pages[c])
|
||||
delete _pages[c];
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
float getHeight() const { return _height; }
|
||||
|
||||
void addGlyph(GlyphDef theGlyph) { _glyphs.push_back(theGlyph); }
|
||||
int getNumGlyph() const { return _glyphs.size(); }
|
||||
int getNumGlyph() const { return static_cast<int>(_glyphs.size()); }
|
||||
const GlyphDef & getGlyphAt(int index) const { return _glyphs[index]; }
|
||||
|
||||
private:
|
||||
|
@ -115,7 +115,7 @@ public:
|
|||
~TextPageDef();
|
||||
|
||||
void addLine(TextLineDef *theLine) { _lines.push_back(theLine); }
|
||||
int getNumLines() const { return _lines.size(); }
|
||||
int getNumLines() const { return static_cast<int>(_lines.size()); }
|
||||
TextLineDef * getLineAt(int index) const { return _lines[index]; }
|
||||
int getWidth() const { return _width; }
|
||||
int getHeight() const { return _height; }
|
||||
|
@ -156,7 +156,7 @@ public:
|
|||
~TextFontPagesDef();
|
||||
|
||||
void addPage(TextPageDef *newPage) { _pages.push_back(newPage); }
|
||||
int getNumPages() const { return _pages.size(); }
|
||||
int getNumPages() const { return static_cast<int>(_pages.size()); }
|
||||
TextPageDef* getPageAt(int index) const { return _pages[index]; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -641,7 +641,7 @@ bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat
|
|||
|
||||
if (i > 0 && (width != height || ccNextPOT(width) != width ))
|
||||
{
|
||||
CCLOG("cocos2d: Texture2D. WARNING. Mipmap level %u is not squared. Texture won't render correctly. width=%ld != height=%ld", i, width, height);
|
||||
CCLOG("cocos2d: Texture2D. WARNING. Mipmap level %u is not squared. Texture won't render correctly. width=%d != height=%d", i, width, height);
|
||||
}
|
||||
|
||||
GLenum err = glGetError();
|
||||
|
|
|
@ -404,7 +404,7 @@ void UserDefault::setDataForKey(const char* pKey, const Data& value) {
|
|||
|
||||
char *encodedData = 0;
|
||||
|
||||
base64Encode(value.getBytes(), value.getSize(), &encodedData);
|
||||
base64Encode(value.getBytes(), static_cast<unsigned int>(value.getSize()), &encodedData);
|
||||
|
||||
setValueForKey(pKey, encodedData);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ bool ZipUtils::s_bEncryptionKeyIsValid = false;
|
|||
|
||||
// --------------------- ZipUtils ---------------------
|
||||
|
||||
inline void ZipUtils::decodeEncodedPvr(unsigned int *data, long len)
|
||||
inline void ZipUtils::decodeEncodedPvr(unsigned int *data, ssize_t len)
|
||||
{
|
||||
const int enclen = 1024;
|
||||
const int securelen = 512;
|
||||
|
@ -108,7 +108,7 @@ inline void ZipUtils::decodeEncodedPvr(unsigned int *data, long len)
|
|||
}
|
||||
}
|
||||
|
||||
inline unsigned int ZipUtils::checksumPvr(const unsigned int *data, long len)
|
||||
inline unsigned int ZipUtils::checksumPvr(const unsigned int *data, ssize_t len)
|
||||
{
|
||||
unsigned int cs = 0;
|
||||
const int cslen = 128;
|
||||
|
@ -127,12 +127,12 @@ inline unsigned int ZipUtils::checksumPvr(const unsigned int *data, long len)
|
|||
// Should buffer factor be 1.5 instead of 2 ?
|
||||
#define BUFFER_INC_FACTOR (2)
|
||||
|
||||
int ZipUtils::inflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long *outLength, long outLenghtHint)
|
||||
int ZipUtils::inflateMemoryWithHint(unsigned char *in, ssize_t inLength, unsigned char **out, ssize_t *outLength, ssize_t outLenghtHint)
|
||||
{
|
||||
/* ret value */
|
||||
int err = Z_OK;
|
||||
|
||||
long bufferSize = outLenghtHint;
|
||||
ssize_t bufferSize = outLenghtHint;
|
||||
*out = (unsigned char*)malloc(bufferSize);
|
||||
|
||||
z_stream d_stream; /* decompression stream */
|
||||
|
@ -141,9 +141,9 @@ int ZipUtils::inflateMemoryWithHint(unsigned char *in, long inLength, unsigned c
|
|||
d_stream.opaque = (voidpf)0;
|
||||
|
||||
d_stream.next_in = in;
|
||||
d_stream.avail_in = inLength;
|
||||
d_stream.avail_in = static_cast<unsigned int>(inLength);
|
||||
d_stream.next_out = *out;
|
||||
d_stream.avail_out = bufferSize;
|
||||
d_stream.avail_out = static_cast<unsigned int>(bufferSize);
|
||||
|
||||
/* window size to hold 256k */
|
||||
if( (err = inflateInit2(&d_stream, 15 + 32)) != Z_OK )
|
||||
|
@ -182,7 +182,7 @@ int ZipUtils::inflateMemoryWithHint(unsigned char *in, long inLength, unsigned c
|
|||
}
|
||||
|
||||
d_stream.next_out = *out + bufferSize;
|
||||
d_stream.avail_out = bufferSize;
|
||||
d_stream.avail_out = static_cast<unsigned int>(bufferSize);
|
||||
bufferSize *= BUFFER_INC_FACTOR;
|
||||
}
|
||||
}
|
||||
|
@ -192,9 +192,9 @@ int ZipUtils::inflateMemoryWithHint(unsigned char *in, long inLength, unsigned c
|
|||
return err;
|
||||
}
|
||||
|
||||
int ZipUtils::inflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long outLengthHint)
|
||||
ssize_t ZipUtils::inflateMemoryWithHint(unsigned char *in, ssize_t inLength, unsigned char **out, ssize_t outLengthHint)
|
||||
{
|
||||
long outLength = 0;
|
||||
ssize_t outLength = 0;
|
||||
int err = inflateMemoryWithHint(in, inLength, out, &outLength, outLengthHint);
|
||||
|
||||
if (err != Z_OK || *out == NULL) {
|
||||
|
@ -225,7 +225,7 @@ int ZipUtils::inflateMemoryWithHint(unsigned char *in, long inLength, unsigned c
|
|||
return outLength;
|
||||
}
|
||||
|
||||
int ZipUtils::inflateMemory(unsigned char *in, long inLength, unsigned char **out)
|
||||
ssize_t ZipUtils::inflateMemory(unsigned char *in, ssize_t inLength, unsigned char **out)
|
||||
{
|
||||
// 256k for hint
|
||||
return inflateMemoryWithHint(in, inLength, out, 256 * 1024);
|
||||
|
@ -363,7 +363,7 @@ bool ZipUtils::isGZipBuffer(const unsigned char *buffer, long len)
|
|||
}
|
||||
|
||||
|
||||
int ZipUtils::inflateCCZBuffer(const unsigned char *buffer, long bufferLen, unsigned char **out)
|
||||
int ZipUtils::inflateCCZBuffer(const unsigned char *buffer, ssize_t bufferLen, unsigned char **out)
|
||||
{
|
||||
struct CCZHeader *header = (struct CCZHeader*) buffer;
|
||||
|
||||
|
@ -407,7 +407,7 @@ int ZipUtils::inflateCCZBuffer(const unsigned char *buffer, long bufferLen, unsi
|
|||
|
||||
// decrypt
|
||||
unsigned int* ints = (unsigned int*)(buffer+12);
|
||||
int enclen = (bufferLen-12)/4;
|
||||
ssize_t enclen = (bufferLen-12)/4;
|
||||
|
||||
decodeEncodedPvr(ints, enclen);
|
||||
|
||||
|
@ -614,7 +614,7 @@ unsigned char *ZipFile::getFileData(const std::string &fileName, ssize_t *size)
|
|||
CC_BREAK_IF(UNZ_OK != nRet);
|
||||
|
||||
buffer = (unsigned char*)malloc(fileInfo.uncompressed_size);
|
||||
int CC_UNUSED nSize = unzReadCurrentFile(_data->zipFile, buffer, fileInfo.uncompressed_size);
|
||||
int CC_UNUSED nSize = unzReadCurrentFile(_data->zipFile, buffer, static_cast<unsigned int>(fileInfo.uncompressed_size));
|
||||
CCASSERT(nSize == 0 || nSize == (int)fileInfo.uncompressed_size, "the file size is wrong");
|
||||
|
||||
if (size)
|
||||
|
|
|
@ -65,8 +65,8 @@ namespace cocos2d
|
|||
*
|
||||
@since v0.8.1
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE static int ccInflateMemory(unsigned char *in, long inLength, unsigned char **out) { return inflateMemory(in, inLength, out); }
|
||||
static int inflateMemory(unsigned char *in, long inLength, unsigned char **out);
|
||||
CC_DEPRECATED_ATTRIBUTE static ssize_t ccInflateMemory(unsigned char *in, ssize_t inLength, unsigned char **out) { return inflateMemory(in, inLength, out); }
|
||||
static ssize_t inflateMemory(unsigned char *in, ssize_t inLength, unsigned char **out);
|
||||
|
||||
/**
|
||||
* Inflates either zlib or gzip deflated memory. The inflated memory is
|
||||
|
@ -78,8 +78,8 @@ namespace cocos2d
|
|||
*
|
||||
@since v1.0.0
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE static int ccInflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long outLengthHint) { return inflateMemoryWithHint(in, inLength, out, outLengthHint); }
|
||||
static int inflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long outLengthHint);
|
||||
CC_DEPRECATED_ATTRIBUTE static ssize_t ccInflateMemoryWithHint(unsigned char *in, ssize_t inLength, unsigned char **out, ssize_t outLengthHint) { return inflateMemoryWithHint(in, inLength, out, outLengthHint); }
|
||||
static ssize_t inflateMemoryWithHint(unsigned char *in, ssize_t inLength, unsigned char **out, ssize_t outLengthHint);
|
||||
|
||||
/** inflates a GZip file into memory
|
||||
*
|
||||
|
@ -105,8 +105,8 @@ namespace cocos2d
|
|||
*
|
||||
* @since v3.0
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE static bool ccIsGZipBuffer(const unsigned char *buffer, long len) { return isGZipBuffer(buffer, len); }
|
||||
static bool isGZipBuffer(const unsigned char *buffer, long len);
|
||||
CC_DEPRECATED_ATTRIBUTE static bool ccIsGZipBuffer(const unsigned char *buffer, ssize_t len) { return isGZipBuffer(buffer, len); }
|
||||
static bool isGZipBuffer(const unsigned char *buffer, ssize_t len);
|
||||
|
||||
/** inflates a CCZ file into memory
|
||||
*
|
||||
|
@ -123,8 +123,8 @@ namespace cocos2d
|
|||
*
|
||||
* @since v3.0
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE static int ccInflateCCZBuffer(const unsigned char *buffer, long len, unsigned char **out) { return inflateCCZBuffer(buffer, len, out); }
|
||||
static int inflateCCZBuffer(const unsigned char *buffer, long len, unsigned char **out);
|
||||
CC_DEPRECATED_ATTRIBUTE static int ccInflateCCZBuffer(const unsigned char *buffer, ssize_t len, unsigned char **out) { return inflateCCZBuffer(buffer, len, out); }
|
||||
static int inflateCCZBuffer(const unsigned char *buffer, ssize_t len, unsigned char **out);
|
||||
|
||||
/** test a file is a CCZ format file or not
|
||||
*
|
||||
|
@ -141,8 +141,8 @@ namespace cocos2d
|
|||
*
|
||||
* @since v3.0
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE static bool ccIsCCZBuffer(const unsigned char *buffer, long len) { return isCCZBuffer(buffer, len); }
|
||||
static bool isCCZBuffer(const unsigned char *buffer, long len);
|
||||
CC_DEPRECATED_ATTRIBUTE static bool ccIsCCZBuffer(const unsigned char *buffer, ssize_t len) { return isCCZBuffer(buffer, len); }
|
||||
static bool isCCZBuffer(const unsigned char *buffer, ssize_t len);
|
||||
|
||||
/** Sets the pvr.ccz encryption key parts separately for added
|
||||
* security.
|
||||
|
@ -199,9 +199,9 @@ namespace cocos2d
|
|||
static void setPvrEncryptionKey(unsigned int keyPart1, unsigned int keyPart2, unsigned int keyPart3, unsigned int keyPart4);
|
||||
|
||||
private:
|
||||
static int inflateMemoryWithHint(unsigned char *in, long inLength, unsigned char **out, long *outLength, long outLenghtHint);
|
||||
static inline void decodeEncodedPvr (unsigned int *data, long len);
|
||||
static inline unsigned int checksumPvr(const unsigned int *data, long len);
|
||||
static int inflateMemoryWithHint(unsigned char *in, ssize_t inLength, unsigned char **out, ssize_t *outLength, ssize_t outLenghtHint);
|
||||
static inline void decodeEncodedPvr (unsigned int *data, ssize_t len);
|
||||
static inline unsigned int checksumPvr(const unsigned int *data, ssize_t len);
|
||||
|
||||
static unsigned int s_uEncryptedPvrKeyParts[4];
|
||||
static unsigned int s_uEncryptionKey[1024];
|
||||
|
|
|
@ -129,7 +129,7 @@ static const char *const g_utf8_skip = utf8_skip_data;
|
|||
* */
|
||||
unsigned int cc_utf8_find_last_not_char(std::vector<unsigned short> str, unsigned short c)
|
||||
{
|
||||
int len = str.size();
|
||||
int len = static_cast<int>(str.size());
|
||||
|
||||
int i = len - 1;
|
||||
for (; i >= 0; --i)
|
||||
|
@ -148,7 +148,7 @@ unsigned int cc_utf8_find_last_not_char(std::vector<unsigned short> str, unsigne
|
|||
* */
|
||||
static void cc_utf8_trim_from(std::vector<unsigned short>* str, int index)
|
||||
{
|
||||
int size = str->size();
|
||||
int size = static_cast<int>(str->size());
|
||||
if (index >= size || index < 0)
|
||||
return;
|
||||
|
||||
|
@ -171,7 +171,7 @@ bool isspace_unicode(unsigned short ch)
|
|||
|
||||
void cc_utf8_trim_ws(std::vector<unsigned short>* str)
|
||||
{
|
||||
int len = str->size();
|
||||
int len = static_cast<int>(str->size());
|
||||
|
||||
if ( len <= 0 )
|
||||
return;
|
||||
|
@ -277,7 +277,7 @@ cc_utf8_get_char (const char * p)
|
|||
|
||||
unsigned short* cc_utf8_to_utf16(const char* str_old, int length/* = -1 */, int* rUtf16Size/* = NULL */)
|
||||
{
|
||||
int len = cc_utf8_strlen(str_old, length);
|
||||
unsigned short len = cc_utf8_strlen(str_old, length);
|
||||
if (rUtf16Size != NULL) {
|
||||
*rUtf16Size = len;
|
||||
}
|
||||
|
@ -335,21 +335,23 @@ cc_unichar_to_utf8 (unsigned short c,
|
|||
first = 0xc0;
|
||||
len = 2;
|
||||
}
|
||||
else if (c < 0x10000)
|
||||
{
|
||||
first = 0xe0;
|
||||
len = 3;
|
||||
}
|
||||
else if (c < 0x200000)
|
||||
{
|
||||
first = 0xf0;
|
||||
len = 4;
|
||||
}
|
||||
else if (c < 0x4000000)
|
||||
{
|
||||
first = 0xf8;
|
||||
len = 5;
|
||||
}
|
||||
// XXX FIXME
|
||||
// These conditions are alwasy true.
|
||||
// else if (c < 0x10000)
|
||||
// {
|
||||
// first = 0xe0;
|
||||
// len = 3;
|
||||
// }
|
||||
// else if (c < 0x200000)
|
||||
// {
|
||||
// first = 0xf0;
|
||||
// len = 4;
|
||||
// }
|
||||
// else if (c < 0x4000000)
|
||||
// {
|
||||
// first = 0xf8;
|
||||
// len = 5;
|
||||
// }
|
||||
else
|
||||
{
|
||||
first = 0xfc;
|
||||
|
@ -452,7 +454,7 @@ cc_utf16_to_utf8 (const unsigned short *str,
|
|||
}
|
||||
|
||||
/********** DIFFERENT for UTF8/UCS4 **********/
|
||||
n_bytes += UTF8_LENGTH (wc);
|
||||
n_bytes += UTF8_LENGTH (static_cast<unsigned int>(wc));
|
||||
|
||||
next1:
|
||||
in++;
|
||||
|
|
|
@ -280,7 +280,7 @@ void EGLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys
|
|||
else
|
||||
{
|
||||
// It is error, should return.
|
||||
CCLOG("Moving touches with id: %ld error", id);
|
||||
CCLOG("Moving touches with id: %d error", id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ void EGLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode
|
|||
}
|
||||
else
|
||||
{
|
||||
CCLOG("Ending touches with id: %ld error", id);
|
||||
CCLOG("Ending touches with id: %d error", id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -349,7 +349,7 @@ namespace
|
|||
typedef struct
|
||||
{
|
||||
const unsigned char * data;
|
||||
int size;
|
||||
ssize_t size;
|
||||
int offset;
|
||||
}tImageSource;
|
||||
|
||||
|
@ -941,7 +941,7 @@ bool Image::initWithPngData(const unsigned char * data, ssize_t dataLen)
|
|||
}
|
||||
|
||||
// read png data
|
||||
png_uint_32 rowbytes;
|
||||
png_size_t rowbytes;
|
||||
png_bytep* row_pointers = (png_bytep*)malloc( sizeof(png_bytep) * _height );
|
||||
|
||||
rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
|
@ -1418,7 +1418,7 @@ bool Image::initWithPVRv3Data(const unsigned char * data, ssize_t dataLen)
|
|||
packetLength = packetLength > dataSize ? dataSize : packetLength;
|
||||
|
||||
_mipmaps[i].address = _data + dataOffset;
|
||||
_mipmaps[i].len = packetLength;
|
||||
_mipmaps[i].len = static_cast<int>(packetLength);
|
||||
|
||||
dataOffset += packetLength;
|
||||
CCAssert(dataOffset <= _dataLen, "CCTexurePVR: Invalid lenght");
|
||||
|
|
|
@ -81,7 +81,7 @@ bool XmlSaxHander::VisitExit( const tinyxml2::XMLElement& element )
|
|||
bool XmlSaxHander::Visit( const tinyxml2::XMLText& text )
|
||||
{
|
||||
//log("Visit %s",text.Value());
|
||||
SAXParser::textHandler(_ccsaxParserImp, (const CC_XML_CHAR *)text.Value(), strlen(text.Value()));
|
||||
SAXParser::textHandler(_ccsaxParserImp, (const CC_XML_CHAR *)text.Value(), static_cast<int>(strlen(text.Value())));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ NS_CC_BEGIN
|
|||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int height;
|
||||
unsigned int width;
|
||||
int height;
|
||||
int width;
|
||||
bool hasAlpha;
|
||||
bool isPremultipliedAlpha;
|
||||
unsigned char* data;
|
||||
|
@ -138,8 +138,8 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
|||
dimensions.height = realDimensions.height;
|
||||
}
|
||||
|
||||
NSUInteger POTWide = (NSUInteger)dimensions.width;
|
||||
NSUInteger POTHigh = (NSUInteger)(MAX(dimensions.height, realDimensions.height));
|
||||
NSInteger POTWide = dimensions.width;
|
||||
NSInteger POTHigh = MAX(dimensions.height, realDimensions.height);
|
||||
unsigned char* data;
|
||||
//Alignment
|
||||
|
||||
|
@ -185,8 +185,8 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
|||
if (dataNew) {
|
||||
memcpy(dataNew, data, textureSize);
|
||||
// output params
|
||||
pInfo->width = POTWide;
|
||||
pInfo->height = POTHigh;
|
||||
pInfo->width = static_cast<int>(POTWide);
|
||||
pInfo->height = static_cast<int>(POTHigh);
|
||||
pInfo->data = dataNew;
|
||||
pInfo->hasAlpha = true;
|
||||
pInfo->isPremultipliedAlpha = true;
|
||||
|
|
|
@ -105,7 +105,7 @@ Array* Array::createWithArray(Array* otherArray)
|
|||
return otherArray->clone();
|
||||
}
|
||||
|
||||
Array* Array::createWithCapacity(size_t capacity)
|
||||
Array* Array::createWithCapacity(int capacity)
|
||||
{
|
||||
CCASSERT(capacity>=0, "Invalid capacity");
|
||||
|
||||
|
@ -182,7 +182,7 @@ bool Array::initWithObjects(Object* object, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool Array::initWithCapacity(size_t capacity)
|
||||
bool Array::initWithCapacity(int capacity)
|
||||
{
|
||||
CCASSERT(capacity>=0, "Invalid capacity");
|
||||
|
||||
|
@ -196,11 +196,11 @@ bool Array::initWithArray(Array* otherArray)
|
|||
return true;
|
||||
}
|
||||
|
||||
size_t Array::getIndexOfObject(Object* object) const
|
||||
int Array::getIndexOfObject(Object* object) const
|
||||
{
|
||||
auto it = data.begin();
|
||||
|
||||
for (size_t i = 0; it != data.end(); ++it, ++i)
|
||||
for (int i = 0; it != data.end(); ++it, ++i)
|
||||
{
|
||||
if (it->get() == object)
|
||||
{
|
||||
|
@ -238,7 +238,7 @@ bool Array::containsObject(Object* object) const
|
|||
|
||||
bool Array::isEqualToArray(Array* otherArray)
|
||||
{
|
||||
for (size_t i = 0; i < this->count(); ++i)
|
||||
for (int i = 0; i < this->count(); ++i)
|
||||
{
|
||||
if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i)))
|
||||
{
|
||||
|
@ -258,12 +258,12 @@ void Array::addObjectsFromArray(Array* otherArray)
|
|||
data.insert(data.end(), otherArray->data.begin(), otherArray->data.end());
|
||||
}
|
||||
|
||||
void Array::insertObject(Object* object, size_t index)
|
||||
void Array::insertObject(Object* object, int index)
|
||||
{
|
||||
data.insert(std::begin(data) + index, RCPtr<Object>(object));
|
||||
}
|
||||
|
||||
void Array::setObject(Object* object, size_t index)
|
||||
void Array::setObject(Object* object, int index)
|
||||
{
|
||||
data[index] = RCPtr<Object>(object);
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ void Array::removeObject(Object* object, bool releaseObj /* ignored */)
|
|||
data.erase(std::remove(data.begin(), data.end(), object));
|
||||
}
|
||||
|
||||
void Array::removeObjectAtIndex(size_t index, bool releaseObj /* ignored */)
|
||||
void Array::removeObjectAtIndex(int index, bool releaseObj /* ignored */)
|
||||
{
|
||||
auto obj = data[index];
|
||||
data.erase(data.begin() + index);
|
||||
|
@ -295,7 +295,7 @@ void Array::removeAllObjects()
|
|||
data.erase(std::begin(data), std::end(data));
|
||||
}
|
||||
|
||||
void Array::fastRemoveObjectAtIndex(size_t index)
|
||||
void Array::fastRemoveObjectAtIndex(int index)
|
||||
{
|
||||
removeObjectAtIndex(index);
|
||||
}
|
||||
|
@ -315,12 +315,12 @@ void Array::exchangeObject(Object* object1, Object* object2)
|
|||
std::swap(data[idx1], data[idx2]);
|
||||
}
|
||||
|
||||
void Array::exchangeObjectAtIndex(size_t index1, size_t index2)
|
||||
void Array::exchangeObjectAtIndex(int index1, int index2)
|
||||
{
|
||||
std::swap(data[index1], data[index2]);
|
||||
}
|
||||
|
||||
void Array::replaceObjectAtIndex(size_t index, Object* object, bool releaseObject /* ignored */)
|
||||
void Array::replaceObjectAtIndex(int index, Object* object, bool releaseObject /* ignored */)
|
||||
{
|
||||
data[index] = object;
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ Array* Array::createWithArray(Array* otherArray)
|
|||
return otherArray->clone();
|
||||
}
|
||||
|
||||
Array* Array::createWithCapacity(size_t capacity)
|
||||
Array* Array::createWithCapacity(int capacity)
|
||||
{
|
||||
CCASSERT(capacity>=0, "Invalid capacity");
|
||||
|
||||
|
@ -480,7 +480,7 @@ Array* Array::createWithContentsOfFileThreadSafe(const char* fileName)
|
|||
{
|
||||
ValueVector arr = FileUtils::getInstance()->getValueVectorFromFile(fileName);
|
||||
|
||||
Array* ret = Array::createWithCapacity(arr.size());
|
||||
Array* ret = Array::createWithCapacity(static_cast<int>(arr.size()));
|
||||
|
||||
std::for_each(arr.cbegin(), arr.cend(), [&ret](const Value& value){
|
||||
ret->addObject(String::create(value.asString()));
|
||||
|
@ -539,7 +539,7 @@ bool Array::initWithObjects(Object* object, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool Array::initWithCapacity(size_t capacity)
|
||||
bool Array::initWithCapacity(int capacity)
|
||||
{
|
||||
CCASSERT(capacity>=0 && !data, "Array cannot be re-initialized");
|
||||
|
||||
|
@ -563,7 +563,7 @@ bool Array::initWithArray(Array* otherArray)
|
|||
return ret;
|
||||
}
|
||||
|
||||
size_t Array::getIndexOfObject(Object* object) const
|
||||
int Array::getIndexOfObject(Object* object) const
|
||||
{
|
||||
return ccArrayGetIndexOfObject(data, object);
|
||||
}
|
||||
|
@ -582,7 +582,7 @@ Object* Array::getRandomObject()
|
|||
r = 0;
|
||||
}
|
||||
|
||||
return data->arr[static_cast<size_t>(data->num * r)];
|
||||
return data->arr[static_cast<int>(data->num * r)];
|
||||
}
|
||||
|
||||
bool Array::containsObject(Object* object) const
|
||||
|
@ -592,7 +592,7 @@ bool Array::containsObject(Object* object) const
|
|||
|
||||
bool Array::isEqualToArray(Array* otherArray)
|
||||
{
|
||||
for (size_t i = 0; i < this->count(); ++i)
|
||||
for (int i = 0; i < this->count(); ++i)
|
||||
{
|
||||
if (!this->getObjectAtIndex(i)->isEqual(otherArray->getObjectAtIndex(i)))
|
||||
{
|
||||
|
@ -614,13 +614,13 @@ void Array::addObjectsFromArray(Array* otherArray)
|
|||
ccArrayAppendArrayWithResize(data, otherArray->data);
|
||||
}
|
||||
|
||||
void Array::insertObject(Object* object, size_t index)
|
||||
void Array::insertObject(Object* object, int index)
|
||||
{
|
||||
CCASSERT(data, "Array not initialized");
|
||||
ccArrayInsertObjectAtIndex(data, object, index);
|
||||
}
|
||||
|
||||
void Array::setObject(Object* object, size_t index)
|
||||
void Array::setObject(Object* object, int index)
|
||||
{
|
||||
CCASSERT(index >= 0 && index < count(), "Invalid index");
|
||||
|
||||
|
@ -643,7 +643,7 @@ void Array::removeObject(Object* object, bool releaseObj/* = true*/)
|
|||
ccArrayRemoveObject(data, object, releaseObj);
|
||||
}
|
||||
|
||||
void Array::removeObjectAtIndex(size_t index, bool releaseObj)
|
||||
void Array::removeObjectAtIndex(int index, bool releaseObj)
|
||||
{
|
||||
ccArrayRemoveObjectAtIndex(data, index, releaseObj);
|
||||
}
|
||||
|
@ -658,7 +658,7 @@ void Array::removeAllObjects()
|
|||
ccArrayRemoveAllObjects(data);
|
||||
}
|
||||
|
||||
void Array::fastRemoveObjectAtIndex(size_t index)
|
||||
void Array::fastRemoveObjectAtIndex(int index)
|
||||
{
|
||||
ccArrayFastRemoveObjectAtIndex(data, index);
|
||||
}
|
||||
|
@ -685,12 +685,12 @@ void Array::exchangeObject(Object* object1, Object* object2)
|
|||
ccArraySwapObjectsAtIndexes(data, index1, index2);
|
||||
}
|
||||
|
||||
void Array::exchangeObjectAtIndex(size_t index1, size_t index2)
|
||||
void Array::exchangeObjectAtIndex(int index1, int index2)
|
||||
{
|
||||
ccArraySwapObjectsAtIndexes(data, index1, index2);
|
||||
}
|
||||
|
||||
void Array::replaceObjectAtIndex(size_t index, Object* object, bool releaseObject/* = true*/)
|
||||
void Array::replaceObjectAtIndex(int index, Object* object, bool releaseObject/* = true*/)
|
||||
{
|
||||
ccArrayInsertObjectAtIndex(data, object, index);
|
||||
ccArrayRemoveObjectAtIndex(data, index + 1);
|
||||
|
|
|
@ -250,7 +250,7 @@ public:
|
|||
/** Create an array with a default capacity
|
||||
* @js NA
|
||||
*/
|
||||
static Array* createWithCapacity(size_t capacity);
|
||||
static Array* createWithCapacity(int capacity);
|
||||
/** Create an array with from an existing array
|
||||
* @js NA
|
||||
*/
|
||||
|
@ -295,7 +295,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
bool initWithCapacity(size_t capacity);
|
||||
bool initWithCapacity(int capacity);
|
||||
/** Initializes an array with an existing array
|
||||
* @js NA
|
||||
* @lua NA
|
||||
|
@ -307,7 +307,7 @@ public:
|
|||
/** Returns element count of the array
|
||||
* @js NA
|
||||
*/
|
||||
size_t count() const
|
||||
int count() const
|
||||
{
|
||||
#if CC_USE_ARRAY_VECTOR
|
||||
return data.size();
|
||||
|
@ -318,7 +318,7 @@ public:
|
|||
/** Returns capacity of the array
|
||||
* @js NA
|
||||
*/
|
||||
size_t capacity() const
|
||||
int capacity() const
|
||||
{
|
||||
#if CC_USE_ARRAY_VECTOR
|
||||
return data.capacity();
|
||||
|
@ -330,17 +330,17 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
size_t getIndexOfObject(Object* object) const;
|
||||
int getIndexOfObject(Object* object) const;
|
||||
/**
|
||||
* @js NA
|
||||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE size_t indexOfObject(Object* object) const { return getIndexOfObject(object); }
|
||||
CC_DEPRECATED_ATTRIBUTE int indexOfObject(Object* object) const { return getIndexOfObject(object); }
|
||||
|
||||
/** Returns an element with a certain index
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Object* getObjectAtIndex(size_t index)
|
||||
Object* getObjectAtIndex(int index)
|
||||
{
|
||||
CCASSERT(index>=0 && index < count(), "index out of range in getObjectAtIndex()");
|
||||
#if CC_USE_ARRAY_VECTOR
|
||||
|
@ -349,7 +349,7 @@ public:
|
|||
return data->arr[index];
|
||||
#endif
|
||||
}
|
||||
CC_DEPRECATED_ATTRIBUTE Object* objectAtIndex(size_t index) { return getObjectAtIndex(index); }
|
||||
CC_DEPRECATED_ATTRIBUTE Object* objectAtIndex(int index) { return getObjectAtIndex(index); }
|
||||
/** Returns the last element of the array
|
||||
* @js NA
|
||||
*/
|
||||
|
@ -401,17 +401,17 @@ public:
|
|||
/** Insert a certain object at a certain index
|
||||
* @js NA
|
||||
*/
|
||||
void insertObject(Object* object, size_t index);
|
||||
void insertObject(Object* object, int index);
|
||||
/** sets a certain object at a certain index
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void setObject(Object* object, size_t index);
|
||||
void setObject(Object* object, int index);
|
||||
/** sets a certain object at a certain index without retaining. Use it with caution
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void fastSetObject(Object* object, size_t index)
|
||||
void fastSetObject(Object* object, int index)
|
||||
{
|
||||
#if CC_USE_ARRAY_VECTOR
|
||||
setObject(object, index);
|
||||
|
@ -424,7 +424,7 @@ public:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void swap( size_t indexOne, size_t indexTwo )
|
||||
void swap( int indexOne, int indexTwo )
|
||||
{
|
||||
CCASSERT(indexOne >=0 && indexOne < count() && indexTwo >= 0 && indexTwo < count(), "Invalid indices");
|
||||
#if CC_USE_ARRAY_VECTOR
|
||||
|
@ -447,7 +447,7 @@ public:
|
|||
/** Remove an element with a certain index
|
||||
* @js NA
|
||||
*/
|
||||
void removeObjectAtIndex(size_t index, bool releaseObj = true);
|
||||
void removeObjectAtIndex(int index, bool releaseObj = true);
|
||||
/** Remove all elements
|
||||
* @js NA
|
||||
*/
|
||||
|
@ -463,7 +463,7 @@ public:
|
|||
/** Fast way to remove an element with a certain index
|
||||
* @js NA
|
||||
*/
|
||||
void fastRemoveObjectAtIndex(size_t index);
|
||||
void fastRemoveObjectAtIndex(int index);
|
||||
|
||||
// Rearranging Content
|
||||
|
||||
|
@ -474,12 +474,12 @@ public:
|
|||
/** Swap two elements with certain indexes
|
||||
* @js NA
|
||||
*/
|
||||
void exchangeObjectAtIndex(size_t index1, size_t index2);
|
||||
void exchangeObjectAtIndex(int index1, int index2);
|
||||
|
||||
/** Replace object at index with another object.
|
||||
* @js NA
|
||||
*/
|
||||
void replaceObjectAtIndex(size_t index, Object* object, bool releaseObject = true);
|
||||
void replaceObjectAtIndex(int index, Object* object, bool releaseObject = true);
|
||||
|
||||
/** Revers the array
|
||||
* @js NA
|
||||
|
|
|
@ -109,7 +109,7 @@ Array* Dictionary::allKeys()
|
|||
{
|
||||
HASH_ITER(hh, _elements, pElement, tmp)
|
||||
{
|
||||
Integer* pOneKey = new Integer(pElement->_intKey);
|
||||
Integer* pOneKey = new Integer(static_cast<int>(pElement->_intKey));
|
||||
pArray->addObject(pOneKey);
|
||||
CC_SAFE_RELEASE(pOneKey);
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ Array* Dictionary::allKeysForObject(Object* object)
|
|||
{
|
||||
if (object == pElement->_object)
|
||||
{
|
||||
Integer* pOneKey = new Integer(pElement->_intKey);
|
||||
Integer* pOneKey = new Integer(static_cast<int>(pElement->_intKey));
|
||||
pArray->addObject(pOneKey);
|
||||
CC_SAFE_RELEASE(pOneKey);
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ typedef std::vector<std::string> strArray;
|
|||
// string toolkit
|
||||
static inline void split(std::string src, const char* token, strArray& vect)
|
||||
{
|
||||
int nend=0;
|
||||
int nbegin=0;
|
||||
size_t nend=0;
|
||||
size_t nbegin=0;
|
||||
while(nend != -1)
|
||||
{
|
||||
nend = src.find(token, nbegin);
|
||||
|
@ -65,8 +65,8 @@ static bool splitWithForm(const std::string& str, strArray& strs)
|
|||
std::string content = str;
|
||||
CC_BREAK_IF(content.length() == 0);
|
||||
|
||||
int nPosLeft = content.find('{');
|
||||
int nPosRight = content.find('}');
|
||||
size_t nPosLeft = content.find('{');
|
||||
size_t nPosRight = content.find('}');
|
||||
|
||||
// don't have '{' and '}'
|
||||
CC_BREAK_IF(nPosLeft == (int)std::string::npos || nPosRight == (int)std::string::npos);
|
||||
|
@ -77,8 +77,8 @@ static bool splitWithForm(const std::string& str, strArray& strs)
|
|||
// nothing between '{' and '}'
|
||||
CC_BREAK_IF(pointStr.length() == 0);
|
||||
|
||||
int nPos1 = pointStr.find('{');
|
||||
int nPos2 = pointStr.find('}');
|
||||
size_t nPos1 = pointStr.find('{');
|
||||
size_t nPos2 = pointStr.find('}');
|
||||
// contain '{' or '}'
|
||||
CC_BREAK_IF(nPos1 != (int)std::string::npos || nPos2 != (int)std::string::npos);
|
||||
|
||||
|
@ -107,8 +107,8 @@ Rect RectFromString(const std::string& str)
|
|||
std::string content = str;
|
||||
|
||||
// find the first '{' and the third '}'
|
||||
int nPosLeft = content.find('{');
|
||||
int nPosRight = content.find('}');
|
||||
size_t nPosLeft = content.find('{');
|
||||
size_t nPosRight = content.find('}');
|
||||
for (int i = 1; i < 3; ++i)
|
||||
{
|
||||
if (nPosRight == (int)std::string::npos)
|
||||
|
@ -120,7 +120,7 @@ Rect RectFromString(const std::string& str)
|
|||
CC_BREAK_IF(nPosLeft == (int)std::string::npos || nPosRight == (int)std::string::npos);
|
||||
|
||||
content = content.substr(nPosLeft + 1, nPosRight - nPosLeft - 1);
|
||||
int nPointEnd = content.find('}');
|
||||
size_t nPointEnd = content.find('}');
|
||||
CC_BREAK_IF(nPointEnd == (int)std::string::npos);
|
||||
nPointEnd = content.find(',', nPointEnd);
|
||||
CC_BREAK_IF(nPointEnd == (int)std::string::npos);
|
||||
|
|
|
@ -146,9 +146,9 @@ const char* String::getCString() const
|
|||
return _string.c_str();
|
||||
}
|
||||
|
||||
unsigned int String::length() const
|
||||
int String::length() const
|
||||
{
|
||||
return _string.length();
|
||||
return static_cast<int>(_string.length());
|
||||
}
|
||||
|
||||
int String::compare(const char * pStr) const
|
||||
|
@ -182,7 +182,7 @@ Array* String::componentsSeparatedByString(const char *delimiter)
|
|||
{
|
||||
Array* result = Array::create();
|
||||
|
||||
int cutAt;
|
||||
size_t cutAt;
|
||||
while( (cutAt = _string.find_first_of(delimiter)) != _string.npos )
|
||||
{
|
||||
if(cutAt > 0)
|
||||
|
|
|
@ -114,7 +114,7 @@ public:
|
|||
/** get the length of string
|
||||
* @js NA
|
||||
*/
|
||||
unsigned int length() const;
|
||||
int length() const;
|
||||
|
||||
/** compare to a c string
|
||||
* @js NA
|
||||
|
|
|
@ -113,7 +113,7 @@ public:
|
|||
/** Returns element count of the array */
|
||||
int size() const
|
||||
{
|
||||
return _data.size();
|
||||
return static_cast<int>(_data.size());
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
|
|
|
@ -136,7 +136,7 @@ static int readTuple (const char* end, Str tuple[]) {
|
|||
}
|
||||
|
||||
static char* mallocString (Str* str) {
|
||||
int length = str->end - str->begin;
|
||||
size_t length = str->end - str->begin;
|
||||
char* string = MALLOC(char, length + 1);
|
||||
memcpy(string, str->begin, length);
|
||||
string[length] = '\0';
|
||||
|
@ -144,7 +144,7 @@ static char* mallocString (Str* str) {
|
|||
}
|
||||
|
||||
static int indexOf (const char** array, int count, Str* str) {
|
||||
int length = str->end - str->begin;
|
||||
size_t length = str->end - str->begin;
|
||||
int i;
|
||||
for (i = count - 1; i >= 0; i--)
|
||||
if (strncmp(array[i], str->begin, length) == 0) return i;
|
||||
|
@ -156,7 +156,7 @@ static int equals (Str* str, const char* other) {
|
|||
}
|
||||
|
||||
static int toInt (Str* str) {
|
||||
return strtol(str->begin, (char**)&str->end, 10);
|
||||
return static_cast<int>(strtol(str->begin, (char**)&str->end, 10));
|
||||
}
|
||||
|
||||
static Atlas* abortAtlas (Atlas* self) {
|
||||
|
@ -171,7 +171,7 @@ static const char* textureFilterNames[] = {"Nearest", "Linear", "MipMap", "MipMa
|
|||
Atlas* Atlas_readAtlas (const char* begin, int length, const char* dir) {
|
||||
int count;
|
||||
const char* end = begin + length;
|
||||
int dirLength = strlen(dir);
|
||||
size_t dirLength = strlen(dir);
|
||||
int needsSlash = dirLength > 0 && dir[dirLength - 1] != '/' && dir[dirLength - 1] != '\\';
|
||||
|
||||
Atlas* self = NEW(Atlas);
|
||||
|
@ -295,13 +295,13 @@ Atlas* Atlas_readAtlasFile (const char* path) {
|
|||
const char* lastBackwardSlash = strrchr(path, '\\');
|
||||
const char* lastSlash = lastForwardSlash > lastBackwardSlash ? lastForwardSlash : lastBackwardSlash;
|
||||
if (lastSlash == path) lastSlash++; /* Never drop starting slash. */
|
||||
dirLength = lastSlash ? lastSlash - path : 0;
|
||||
dirLength = static_cast<int>(lastSlash ? lastSlash - path : 0);
|
||||
dir = MALLOC(char, dirLength + 1);
|
||||
memcpy(dir, path, dirLength);
|
||||
dir[dirLength] = '\0';
|
||||
|
||||
data = _Util_readFile(path, &length);
|
||||
if (data) atlas = Atlas_readAtlas(data, length, dir);
|
||||
if (data) atlas = Atlas_readAtlas(data, static_cast<int>(length), dir);
|
||||
|
||||
FREE(data);
|
||||
FREE(dir);
|
||||
|
|
|
@ -105,7 +105,7 @@ bool UICCTextField::onTextFieldDetachWithIME(cocos2d::TextFieldTTF *pSender)
|
|||
void UICCTextField::insertText(const char * text, int len)
|
||||
{
|
||||
std::string str_text = text;
|
||||
int str_len = cocos2d::TextFieldTTF::getString().size();
|
||||
size_t str_len = cocos2d::TextFieldTTF::getString().size();
|
||||
|
||||
if (strcmp(text, "\n") != 0)
|
||||
{
|
||||
|
|
|
@ -182,24 +182,24 @@ void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response
|
|||
|
||||
std::string res = s.str();
|
||||
std::string sid;
|
||||
int pos = 0;
|
||||
size_t pos = 0;
|
||||
int heartbeat = 0, timeout = 0;
|
||||
|
||||
pos = res.find(":");
|
||||
if(pos >= 0)
|
||||
if(pos != std::string::npos)
|
||||
{
|
||||
sid = res.substr(0, pos);
|
||||
res.erase(0, pos+1);
|
||||
}
|
||||
|
||||
pos = res.find(":");
|
||||
if(pos >= 0)
|
||||
if(pos != std::string::npos)
|
||||
{
|
||||
heartbeat = atoi(res.substr(pos+1, res.size()).c_str());
|
||||
}
|
||||
|
||||
pos = res.find(":");
|
||||
if(pos >= 0)
|
||||
if(pos != std::string::npos)
|
||||
{
|
||||
timeout = atoi(res.substr(pos+1, res.size()).c_str());
|
||||
}
|
||||
|
@ -381,21 +381,21 @@ void SIOClientImpl::onMessage(WebSocket* ws, const WebSocket::Data& data)
|
|||
std::string payload, msgid, endpoint, s_data, eventname;
|
||||
payload = data.bytes;
|
||||
|
||||
int pos, pos2;
|
||||
size_t pos, pos2;
|
||||
|
||||
pos = payload.find(":");
|
||||
if(pos >=0 ) {
|
||||
if(pos != std::string::npos ) {
|
||||
payload.erase(0, pos+1);
|
||||
}
|
||||
|
||||
pos = payload.find(":");
|
||||
if(pos > 0 ) {
|
||||
if(pos != std::string::npos ) {
|
||||
msgid = atoi(payload.substr(0, pos+1).c_str());
|
||||
}
|
||||
payload.erase(0, pos+1);
|
||||
|
||||
pos = payload.find(":");
|
||||
if(pos >= 0)
|
||||
if(pos != std::string::npos)
|
||||
{
|
||||
endpoint = payload.substr(0, pos);
|
||||
payload.erase(0, pos+1);
|
||||
|
@ -617,33 +617,33 @@ SIOClient* SocketIO::connect(SocketIO::SIODelegate& delegate, const std::string&
|
|||
{
|
||||
std::string host = uri;
|
||||
int port = 0;
|
||||
int pos = 0;
|
||||
size_t pos = 0;
|
||||
|
||||
pos = host.find("//");
|
||||
if (pos >= 0)
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
host.erase(0, pos+2);
|
||||
}
|
||||
|
||||
pos = host.find(":");
|
||||
if (pos >= 0)
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
port = atoi(host.substr(pos+1, host.size()).c_str());
|
||||
}
|
||||
|
||||
pos = host.find("/", 0);
|
||||
std::string path = "/";
|
||||
if (pos >= 0)
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
path += host.substr(pos + 1, host.size());
|
||||
}
|
||||
|
||||
pos = host.find(":");
|
||||
if (pos >= 0)
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
host.erase(pos, host.size());
|
||||
}
|
||||
else if ((pos = host.find("/"))>=0)
|
||||
else if ((pos = host.find("/")) != std::string::npos)
|
||||
{
|
||||
host.erase(pos, host.size());
|
||||
}
|
||||
|
|
|
@ -243,7 +243,7 @@ bool WebSocket::init(const Delegate& delegate,
|
|||
bool ret = false;
|
||||
bool useSSL = false;
|
||||
std::string host = url;
|
||||
int pos = 0;
|
||||
size_t pos = 0;
|
||||
int port = 80;
|
||||
|
||||
_delegate = const_cast<Delegate*>(&delegate);
|
||||
|
@ -260,16 +260,16 @@ bool WebSocket::init(const Delegate& delegate,
|
|||
}
|
||||
|
||||
pos = host.find(":");
|
||||
if (pos >= 0) port = atoi(host.substr(pos+1, host.size()).c_str());
|
||||
if (pos != std::string::npos) port = atoi(host.substr(pos+1, host.size()).c_str());
|
||||
|
||||
pos = host.find("/", 0);
|
||||
std::string path = "/";
|
||||
if (pos >= 0) path += host.substr(pos + 1, host.size());
|
||||
if (pos != std::string::npos) path += host.substr(pos + 1, host.size());
|
||||
|
||||
pos = host.find(":");
|
||||
if(pos >= 0){
|
||||
if(pos != std::string::npos){
|
||||
host.erase(pos, host.size());
|
||||
}else if((pos = host.find("/"))>=0) {
|
||||
}else if((pos = host.find("/")) != std::string::npos) {
|
||||
host.erase(pos, host.size());
|
||||
}
|
||||
|
||||
|
@ -280,7 +280,7 @@ bool WebSocket::init(const Delegate& delegate,
|
|||
|
||||
CCLOG("[WebSocket::init] _host: %s, _port: %d, _path: %s", _host.c_str(), _port, _path.c_str());
|
||||
|
||||
int protocolCount = 0;
|
||||
size_t protocolCount = 0;
|
||||
if (protocols && protocols->size() > 0)
|
||||
{
|
||||
protocolCount = protocols->size();
|
||||
|
@ -329,7 +329,7 @@ void WebSocket::send(const std::string& message)
|
|||
Data* data = new Data();
|
||||
data->bytes = new char[message.length()+1];
|
||||
strcpy(data->bytes, message.c_str());
|
||||
data->len = message.length();
|
||||
data->len = static_cast<ssize_t>(message.length());
|
||||
msg->obj = data;
|
||||
_wsHelper->sendMessageToSubThread(msg);
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ void WebSocket::onSubThreadEnded()
|
|||
int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
|
||||
struct libwebsocket *wsi,
|
||||
int reason,
|
||||
void *user, void *in, size_t len)
|
||||
void *user, void *in, ssize_t len)
|
||||
{
|
||||
//CCLOG("socket callback for %d reason", reason);
|
||||
CCASSERT(_wsContext == nullptr || ctx == _wsContext, "Invalid context.");
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
{
|
||||
Data():bytes(NULL), len(0), isBinary(false){}
|
||||
char* bytes;
|
||||
int len;
|
||||
ssize_t len;
|
||||
bool isBinary;
|
||||
};
|
||||
|
||||
|
@ -143,7 +143,7 @@ private:
|
|||
int onSocketCallback(struct libwebsocket_context *ctx,
|
||||
struct libwebsocket *wsi,
|
||||
int reason,
|
||||
void *user, void *in, size_t len);
|
||||
void *user, void *in, ssize_t len);
|
||||
|
||||
private:
|
||||
State _readyState;
|
||||
|
|
|
@ -714,7 +714,7 @@ Point PhysicsShapeEdgePolygon::getCenter()
|
|||
|
||||
int PhysicsShapeEdgePolygon::getPointsCount() const
|
||||
{
|
||||
return _info->getShapes().size() + 1;
|
||||
return static_cast<int>(_info->getShapes().size() + 1);
|
||||
}
|
||||
|
||||
// PhysicsShapeEdgeChain
|
||||
|
@ -775,7 +775,7 @@ Point PhysicsShapeEdgeChain::getCenter()
|
|||
|
||||
int PhysicsShapeEdgeChain::getPointsCount() const
|
||||
{
|
||||
return _info->getShapes().size() + 1;
|
||||
return static_cast<int>(_info->getShapes().size() + 1);
|
||||
}
|
||||
|
||||
void PhysicsShape::setGroup(int group)
|
||||
|
|
|
@ -321,7 +321,7 @@ void IterateSpriteSheetCArray::update(float dt)
|
|||
{
|
||||
// iterate using fast enumeration protocol
|
||||
auto children = batchNode->getChildren();
|
||||
Object* object = NULL;
|
||||
// Object* object = NULL;
|
||||
|
||||
CC_PROFILER_START(this->profilerName());
|
||||
|
||||
|
|
Loading…
Reference in New Issue