use std::srand() instead

This commit is contained in:
minggo 2016-07-11 11:17:28 +08:00
parent 6248480b3a
commit a146f3eec7
12 changed files with 27 additions and 27 deletions

View File

@ -277,7 +277,7 @@ void ShuffleTiles::startWithTarget(Node *target)
if (_seed != (unsigned int)-1)
{
srand(_seed);
std::srand(_seed);
}
_tilesCount = _gridSize.width * _gridSize.height;
@ -602,7 +602,7 @@ void TurnOffTiles::startWithTarget(Node *target)
if (_seed != (unsigned int)-1)
{
srand(_seed);
std::srand(_seed);
}
_tilesCount = _gridSize.width * _gridSize.height;

View File

@ -1221,7 +1221,7 @@ void Console::commandTouchSubCommandTap(int fd, const std::string& args)
float x = utils::atof(argv[1].c_str());
float y = utils::atof(argv[2].c_str());
srand ((unsigned)time(nullptr));
std::srand ((unsigned)time(nullptr));
_touchId = rand();
Scheduler *sched = Director::getInstance()->getScheduler();
sched->performFunctionInCocosThread( [&](){
@ -1250,7 +1250,7 @@ void Console::commandTouchSubCommandSwipe(int fd, const std::string& args)
float x2 = utils::atof(argv[3].c_str());
float y2 = utils::atof(argv[4].c_str());
srand ((unsigned)time(nullptr));
std::srand ((unsigned)time(nullptr));
_touchId = rand();
Scheduler *sched = Director::getInstance()->getScheduler();

View File

@ -33,7 +33,7 @@ public:
m_worldExtent = 15.0f;
m_proxyExtent = 0.5f;
srand(888);
std::srand(888);
for (int32 i = 0; i < e_actorCount; ++i)
{

View File

@ -37,7 +37,7 @@ bool Bug1174Layer::init()
if (BugsTestBase::init())
{
// // seed
// srand(0);
// std::srand(0);
Vec2 A,B,C,D,p1,p2,p3,p4;
float s,t;

View File

@ -111,7 +111,7 @@ std::string ConsoleCustomCommand::subtitle() const
ConsoleUploadFile::ConsoleUploadFile()
{
srand ((unsigned)time(nullptr));
std::srand ((unsigned)time(nullptr));
int _id = rand()%100000;
char buf[32];
sprintf(buf, "%d", _id);

View File

@ -991,7 +991,7 @@ bool UIS9BatchTest::init()
auto addSpriteButton = ui::Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
addSpriteButton->setPosition(Vec2(winSize.width/2 - 50,winSize.height - 100));
addSpriteButton->setTitleText("Add Normal Sprite");
srand((unsigned)time(nullptr));
std::srand((unsigned)time(nullptr));
addSpriteButton->addClickEventListener([=](Ref*){
auto spriteFrameName = spriteFrameNameArray[rand()%2];
auto sprite = Sprite::createWithSpriteFrameName(spriteFrameName);

View File

@ -289,7 +289,7 @@ void TemplateVectorTest::onEnter()
// get random object
// Set the seed by time
srand((unsigned)time(nullptr));
std::srand((unsigned)time(nullptr));
Vector<Node*> vecForRandom = createVector();
log("<--- begin ---->");
for (int i = 0; i < vecForRandom.size(); ++i)
@ -497,7 +497,7 @@ void TemplateMapTest::onEnter()
// get random object
// Set the seed by time
srand((unsigned)time(nullptr));
std::srand((unsigned)time(nullptr));
Map<std::string, Node*> mapForRandom = createMap();
log("<--- begin ---->");
for (int i = 0; i < mapForRandom.size(); ++i)

View File

@ -83,7 +83,7 @@ bool PerformceAllocScene::init()
void PerformceAllocScene::initWithQuantityOfNodes(unsigned int nNodes)
{
//srand(time());
//std::srand(time());
auto s = Director::getInstance()->getWinSize();
lastRenderedCount = 0;
@ -100,7 +100,7 @@ void PerformceAllocScene::initWithQuantityOfNodes(unsigned int nNodes)
updateQuantityOfNodes();
updateProfilerName();
CC_PROFILER_PURGE_ALL();
srand(0);
std::srand(0);
});
decrease->setColor(Color3B(0,200,20));
auto increase = MenuItemFont::create(" + ", [&](Ref *sender) {
@ -112,7 +112,7 @@ void PerformceAllocScene::initWithQuantityOfNodes(unsigned int nNodes)
updateQuantityOfNodes();
updateProfilerName();
CC_PROFILER_PURGE_ALL();
srand(0);
std::srand(0);
});
increase->setColor(Color3B(0,200,20));
@ -129,7 +129,7 @@ void PerformceAllocScene::initWithQuantityOfNodes(unsigned int nNodes)
updateQuantityLabel();
updateQuantityOfNodes();
updateProfilerName();
srand(0);
std::srand(0);
}
std::string PerformceAllocScene::title() const

View File

@ -80,7 +80,7 @@ bool PerformanceContainerScene::init()
void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes)
{
_type = 0;
//srand(time());
//std::srand(time());
auto s = Director::getInstance()->getWinSize();
lastRenderedCount = 0;
@ -97,7 +97,7 @@ void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes)
updateQuantityOfNodes();
updateProfilerName();
CC_PROFILER_PURGE_ALL();
srand(0);
std::srand(0);
});
decrease->setColor(Color3B(0,200,20));
_decrease = decrease;
@ -111,7 +111,7 @@ void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes)
updateQuantityOfNodes();
updateProfilerName();
CC_PROFILER_PURGE_ALL();
srand(0);
std::srand(0);
});
increase->setColor(Color3B(0,200,20));
_increase = increase;
@ -378,7 +378,7 @@ void TemplateVectorPerfTest::generateTestFunctions()
{ "replace", [=](){
Vector<Node*> nodeVector = createVector();
srand((unsigned)time(nullptr));
std::srand((unsigned)time(nullptr));
ssize_t index = rand() % quantityOfNodes;
CC_PROFILER_START(this->profilerName());
@ -601,7 +601,7 @@ void ArrayPerfTest::generateTestFunctions()
{ "setObject", [=](){
__Array* nodeVector = createArray();
srand((unsigned)time(nullptr));
std::srand((unsigned)time(nullptr));
ssize_t index = rand() % quantityOfNodes;
CC_PROFILER_START(this->profilerName());

View File

@ -78,7 +78,7 @@ bool PerformanceEventDispatcherScene::init()
void PerformanceEventDispatcherScene::initWithQuantityOfNodes(unsigned int nNodes)
{
_type = 0;
srand((unsigned)time(nullptr));
std::srand((unsigned)time(nullptr));
auto s = Director::getInstance()->getWinSize();
_lastRenderedCount = 0;
@ -95,7 +95,7 @@ void PerformanceEventDispatcherScene::initWithQuantityOfNodes(unsigned int nNode
updateQuantityOfNodes();
updateProfilerName();
CC_PROFILER_PURGE_ALL();
srand(0);
std::srand(0);
});
decrease->setColor(Color3B(0,200,20));
_decrease = decrease;
@ -109,7 +109,7 @@ void PerformanceEventDispatcherScene::initWithQuantityOfNodes(unsigned int nNode
updateQuantityOfNodes();
updateProfilerName();
CC_PROFILER_PURGE_ALL();
srand(0);
std::srand(0);
});
increase->setColor(Color3B(0,200,20));
_increase = increase;

View File

@ -55,7 +55,7 @@ PerformceLabelTests::PerformceLabelTests()
////////////////////////////////////////////////////////
bool LabelMainScene::init()
{
//srandom(0);
//std::srandom(0);
if (!TestCase::init())
{
return false;

View File

@ -150,7 +150,7 @@ void NodeChildrenMainScene::dumpProfilerInfo(float dt)
void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes)
{
//srand(time());
//std::srand(time());
auto s = Director::getInstance()->getWinSize();
lastRenderedCount = 0;
@ -167,7 +167,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes)
updateQuantityOfNodes();
updateProfilerName();
CC_PROFILER_PURGE_ALL();
srand(0);
std::srand(0);
});
decrease->setColor(Color3B(0,200,20));
auto increase = MenuItemFont::create(" + ", [&](Ref *sender) {
@ -179,7 +179,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes)
updateQuantityOfNodes();
updateProfilerName();
CC_PROFILER_PURGE_ALL();
srand(0);
std::srand(0);
});
increase->setColor(Color3B(0,200,20));
@ -196,7 +196,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes)
updateQuantityLabel();
updateQuantityOfNodes();
updateProfilerName();
srand(0);
std::srand(0);
}
std::string NodeChildrenMainScene::title() const