Skip to content

Commit e313ac5

Browse files
committed
Merge pull request #4 from cocos2d/develop
sync original repo
2 parents 23af93a + 01669b7 commit e313ac5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+612
-390
lines changed

AUTHORS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,9 @@ Developers:
678678
seobyeongky
679679
Updates spine runtime.
680680

681+
luocker
682+
Fix a bug that string itself is also modified in `String::componentsSeparatedByString`.
683+
681684
Retired Core Developers:
682685
WenSheng Yang
683686
Author of windows port, CCTextField,

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ cocos2d-x-3.0beta0 ?? 2013
1515
[FIX] LabelBMFont string can't be shown integrally.
1616
[FIX] Deprecates FileUtils::getFileData, adds FileUtils::getStringFromFile/getDataFromFile.
1717
[FIX] GUI refactoring: Removes UI prefix, Widget is inherited from Node, uses new containers(Vector<T>, Map<K,V>).
18+
[FIX] String itself is also modified in `String::componentsSeparatedByString`.
1819
[Android]
1920
[NEW] build/android-build.sh: add supporting to generate .apk file
2021
[FIX] XMLHttpRequest receives wrong binary array.

cocos/2d/CCDirector.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,8 @@ void DisplayLinkDirector::startAnimation()
10761076
}
10771077

10781078
_invalid = false;
1079+
1080+
Application::getInstance()->setAnimationInterval(_animationInterval);
10791081
}
10801082

10811083
void DisplayLinkDirector::mainLoop()

cocos/2d/CCShaderCache.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ void ShaderCache::reloadDefaultShaders()
185185
p->reset();
186186
loadDefaultShader(p, kShaderType_PositionTextureColor);
187187

188+
// Position Texture Color without MVP shader
189+
p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP);
190+
p->reset();
191+
loadDefaultShader(p, kShaderType_PositionTextureColor_noMVP);
192+
188193
// Position Texture Color alpha test
189194
p = getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST);
190195
p->reset();

cocos/2d/CCTMXTiledMap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class CC_DLL TMXTiledMap : public Node
204204
ValueMap _properties;
205205

206206
//! tile properties
207-
IntValueMap _tileProperties;
207+
ValueMapIntKey _tileProperties;
208208

209209
private:
210210
CC_DISALLOW_COPY_AND_ASSIGN(TMXTiledMap);

cocos/2d/CCTMXXMLParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ void TMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
536536
}
537537
else if ( tmxMapInfo->getParentElement() == TMXPropertyTile )
538538
{
539-
IntValueMap& dict = tmxMapInfo->getTileProperties().at(tmxMapInfo->getParentGID()).asIntKeyMap();
539+
ValueMapIntKey& dict = tmxMapInfo->getTileProperties().at(tmxMapInfo->getParentGID()).asIntKeyMap();
540540

541541
int propertyName = attributeDict["name"].asInt();
542542
dict[propertyName] = attributeDict["value"];

cocos/2d/CCTMXXMLParser.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ class CC_DLL TMXMapInfo : public Object, public SAXDelegator
195195
/* initializes parsing of an XML string, either a tmx (Map) string or tsx (Tileset) string */
196196
bool parseXMLString(const std::string& xmlString);
197197

198-
IntValueMap& getTileProperties() { return _tileProperties; };
199-
void setTileProperties(const IntValueMap& tileProperties) {
198+
ValueMapIntKey& getTileProperties() { return _tileProperties; };
199+
void setTileProperties(const ValueMapIntKey& tileProperties) {
200200
_tileProperties = tileProperties;
201201
};
202202

@@ -311,7 +311,7 @@ class CC_DLL TMXMapInfo : public Object, public SAXDelegator
311311
//! current string
312312
std::string _currentString;
313313
//! tile properties
314-
IntValueMap _tileProperties;
314+
ValueMapIntKey _tileProperties;
315315
unsigned int _currentFirstGID;
316316
};
317317

cocos/2d/renderer/CCRenderer.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,14 @@ Renderer::~Renderer()
6565
glDeleteVertexArrays(1, &_quadVAO);
6666
GL::bindVAO(0);
6767
}
68+
#if CC_ENABLE_CACHE_TEXTURE_DATA
69+
NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND);
70+
#endif
6871
}
6972

7073
void Renderer::initGLView()
7174
{
72-
#if 0//CC_ENABLE_CACHE_TEXTURE_DATA
75+
#if CC_ENABLE_CACHE_TEXTURE_DATA
7376
// listen the event when app go to background
7477
NotificationCenter::getInstance()->addObserver(this,
7578
callfuncO_selector(Renderer::onBackToForeground),

cocos/base/CCMap.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#define __CCMAP_H__
2727

2828
#include "ccMacros.h"
29-
29+
#include "CCObject.h"
3030
#include <vector>
3131
#include <unordered_map>
3232

@@ -62,20 +62,23 @@ class CC_DLL Map
6262
Map<K, V>()
6363
: _data()
6464
{
65+
static_assert(std::is_convertible<V, Object*>::value, "Invalid Type for cocos2d::Map<K, V>!");
6566
CCLOGINFO("In the default constructor of Map!");
6667
}
6768

6869
/** Contructor with capacity */
6970
explicit Map<K, V>(ssize_t capacity)
7071
: _data()
7172
{
73+
static_assert(std::is_convertible<V, Object*>::value, "Invalid Type for cocos2d::Map<K, V>!");
7274
CCLOGINFO("In the constructor with capacity of Map!");
7375
_data.reserve(capacity);
7476
}
7577

7678
/** Copy constructor */
7779
Map<K, V>(const Map<K, V>& other)
7880
{
81+
static_assert(std::is_convertible<V, Object*>::value, "Invalid Type for cocos2d::Map<K, V>!");
7982
CCLOGINFO("In the copy constructor of Map!");
8083
_data = other._data;
8184
addRefForAllObjects();
@@ -84,6 +87,7 @@ class CC_DLL Map
8487
/** Move constructor */
8588
Map<K, V>(Map<K, V>&& other)
8689
{
90+
static_assert(std::is_convertible<V, Object*>::value, "Invalid Type for cocos2d::Map<K, V>!");
8791
CCLOGINFO("In the move constructor of Map!");
8892
_data = std::move(other._data);
8993
}

cocos/base/CCString.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,20 +181,20 @@ void __String::appendWithFormat(const char* format, ...)
181181
__Array* __String::componentsSeparatedByString(const char *delimiter)
182182
{
183183
__Array* result = __Array::create();
184-
184+
std::string strTmp = _string;
185185
size_t cutAt;
186-
while( (cutAt = _string.find_first_of(delimiter)) != _string.npos )
186+
while( (cutAt = strTmp.find_first_of(delimiter)) != strTmp.npos )
187187
{
188188
if(cutAt > 0)
189189
{
190-
result->addObject(__String::create(_string.substr(0, cutAt)));
190+
result->addObject(__String::create(strTmp.substr(0, cutAt)));
191191
}
192-
_string = _string.substr(cutAt + 1);
192+
strTmp = strTmp.substr(cutAt + 1);
193193
}
194194

195-
if(_string.length() > 0)
195+
if(strTmp.length() > 0)
196196
{
197-
result->addObject(__String::create(_string));
197+
result->addObject(__String::create(strTmp));
198198
}
199199

200200
return result;

0 commit comments

Comments
 (0)