Skip to content

Commit 6de088a

Browse files
Mee-guminggo
authored andcommitted
fix C4244 warning (#20162)
* fix C4244 warning * fix warning C4244 * fix compile error
1 parent 70bd4e9 commit 6de088a

File tree

10 files changed

+92
-78
lines changed

10 files changed

+92
-78
lines changed

cocos/2d/CCActionCatmullRom.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ void CardinalSplineTo::update(float time)
269269
}
270270
else
271271
{
272-
p = time / _deltaT;
273-
lt = (time - _deltaT * (float)p) / _deltaT;
272+
p = (ssize_t)(time / _deltaT);
273+
lt = (time - _deltaT * p) / _deltaT;
274274
}
275275

276276
// Interpolate

cocos/2d/CCActionGrid3D.cpp

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ void Waves3D::update(float time)
7171
{
7272
for (j = 0; j < _gridSize.height + 1; ++j)
7373
{
74-
Vec3 v = getOriginalVertex(Vec2(i ,j));
74+
Vec2 pos((float)i, (float)j);
75+
Vec3 v = getOriginalVertex(pos);
7576
v.z += (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * 0.01f) * _amplitude * _amplitudeRate);
7677
//CCLOG("v.z offset is %f\n", (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * .01f) * _amplitude * _amplitudeRate));
77-
setVertex(Vec2(i, j), v);
78+
setVertex(pos, v);
7879
}
7980
}
8081
}
@@ -347,7 +348,8 @@ void Lens3D::update(float /*time*/)
347348
{
348349
for (j = 0; j < _gridSize.height + 1; ++j)
349350
{
350-
Vec3 v = getOriginalVertex(Vec2(i, j));
351+
Vec2 pos((float)i, (float)j);
352+
Vec3 v = getOriginalVertex(pos);
351353
Vec2 vect = _position - Vec2(v.x, v.y);
352354
float r = vect.getLength();
353355

@@ -371,7 +373,7 @@ void Lens3D::update(float /*time*/)
371373
}
372374
}
373375

374-
setVertex(Vec2(i, j), v);
376+
setVertex(pos, v);
375377
}
376378
}
377379

@@ -439,7 +441,8 @@ void Ripple3D::update(float time)
439441
{
440442
for (j = 0; j < (_gridSize.height+1); ++j)
441443
{
442-
Vec3 v = getOriginalVertex(Vec2(i, j));
444+
Vec2 pos((float)i, (float)j);
445+
Vec3 v = getOriginalVertex(pos);
443446
Vec2 vect = _position - Vec2(v.x,v.y);
444447
float r = vect.getLength();
445448

@@ -450,7 +453,7 @@ void Ripple3D::update(float time)
450453
v.z += (sinf( time*(float)M_PI * _waves * 2 + r * 0.1f) * _amplitude * _amplitudeRate * rate);
451454
}
452455

453-
setVertex(Vec2(i, j), v);
456+
setVertex(pos, v);
454457
}
455458
}
456459
}
@@ -506,15 +509,16 @@ void Shaky3D::update(float /*time*/)
506509
{
507510
for (j = 0; j < (_gridSize.height+1); ++j)
508511
{
509-
Vec3 v = getOriginalVertex(Vec2(i ,j));
512+
Vec2 pos((float)i, (float)j);
513+
Vec3 v = getOriginalVertex(pos);
510514
v.x += (rand() % (_randrange*2)) - _randrange;
511515
v.y += (rand() % (_randrange*2)) - _randrange;
512516
if (_shakeZ)
513517
{
514518
v.z += (rand() % (_randrange*2)) - _randrange;
515519
}
516520

517-
setVertex(Vec2(i, j), v);
521+
setVertex(pos, v);
518522
}
519523
}
520524
}
@@ -571,10 +575,11 @@ void Liquid::update(float time)
571575
{
572576
for (j = 1; j < _gridSize.height; ++j)
573577
{
574-
Vec3 v = getOriginalVertex(Vec2(i, j));
578+
Vec2 pos((float)i, (float)j);
579+
Vec3 v = getOriginalVertex(pos);
575580
v.x = (v.x + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate));
576581
v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.y * .01f) * _amplitude * _amplitudeRate));
577-
setVertex(Vec2(i, j), v);
582+
setVertex(pos, v);
578583
}
579584
}
580585
}
@@ -633,7 +638,8 @@ void Waves::update(float time)
633638
{
634639
for (j = 0; j < _gridSize.height + 1; ++j)
635640
{
636-
Vec3 v = getOriginalVertex(Vec2(i, j));
641+
Vec2 pos((float)i, (float)j);
642+
Vec3 v = getOriginalVertex(pos);
637643

638644
if (_vertical)
639645
{
@@ -645,7 +651,7 @@ void Waves::update(float time)
645651
v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate));
646652
}
647653

648-
setVertex(Vec2(i, j), v);
654+
setVertex(pos, v);
649655
}
650656
}
651657
}
@@ -709,7 +715,8 @@ void Twirl::update(float time)
709715
{
710716
for (j = 0; j < (_gridSize.height+1); ++j)
711717
{
712-
Vec3 v = getOriginalVertex(Vec2(i ,j));
718+
Vec2 pos((float)i, (float)j);
719+
Vec3 v = getOriginalVertex(pos);
713720

714721
Vec2 avg(i-(_gridSize.width/2.0f), j-(_gridSize.height/2.0f));
715722
float r = avg.getLength();
@@ -724,7 +731,7 @@ void Twirl::update(float time)
724731
v.x = c.x + d.x;
725732
v.y = c.y + d.y;
726733

727-
setVertex(Vec2(i ,j), v);
734+
setVertex(pos, v);
728735
}
729736
}
730737
}

cocos/2d/CCActionInterval.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,7 @@ Blink* Blink::reverse() const
20952095
FadeIn* FadeIn::create(float d)
20962096
{
20972097
FadeIn* action = new (std::nothrow) FadeIn();
2098-
if (action && action->initWithDuration(d,255.0f))
2098+
if (action && action->initWithDuration(d,255))
20992099
{
21002100
action->autorelease();
21012101
return action;
@@ -2132,7 +2132,7 @@ void FadeIn::startWithTarget(cocos2d::Node *target)
21322132
if (nullptr != _reverseAction)
21332133
this->_toOpacity = this->_reverseAction->_fromOpacity;
21342134
else
2135-
_toOpacity = 255.0f;
2135+
_toOpacity = 255;
21362136

21372137
if (target)
21382138
_fromOpacity = target->getOpacity();
@@ -2145,7 +2145,7 @@ void FadeIn::startWithTarget(cocos2d::Node *target)
21452145
FadeOut* FadeOut::create(float d)
21462146
{
21472147
FadeOut* action = new (std::nothrow) FadeOut();
2148-
if (action && action->initWithDuration(d,0.0f))
2148+
if (action && action->initWithDuration(d,0))
21492149
{
21502150
action->autorelease();
21512151
return action;
@@ -2168,7 +2168,7 @@ void FadeOut::startWithTarget(cocos2d::Node *target)
21682168
if (nullptr != _reverseAction)
21692169
_toOpacity = _reverseAction->_fromOpacity;
21702170
else
2171-
_toOpacity = 0.0f;
2171+
_toOpacity = 0;
21722172

21732173
if (target)
21742174
_fromOpacity = target->getOpacity();

cocos/2d/CCActionPageTurn3D.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void PageTurn3D::update(float time)
7474
float deltaTheta = sqrtf(time);
7575
float theta = deltaTheta > 0.5f ? (float)M_PI_2*deltaTheta : (float)M_PI_2*(1-deltaTheta);
7676

77-
float rotateByYAxis = (2-time)* M_PI;
77+
float rotateByYAxis = (2-time)* (float)M_PI;
7878

7979
float sinTheta = sinf(theta);
8080
float cosTheta = cosf(theta);
@@ -83,8 +83,9 @@ void PageTurn3D::update(float time)
8383
{
8484
for (int j = 0; j <= _gridSize.height; ++j)
8585
{
86+
Vec2 pos((float)i, (float)j);
8687
// Get original vertex
87-
Vec3 p = getOriginalVertex(Vec2(i ,j));
88+
Vec3 p = getOriginalVertex(pos);
8889

8990
p.x -= getGridRect().origin.x;
9091
float R = sqrtf((p.x * p.x) + ((p.y - ay) * (p.y - ay)));
@@ -124,7 +125,7 @@ void PageTurn3D::update(float time)
124125

125126
// Set new coords
126127
p.x += getGridRect().origin.x;
127-
setVertex(Vec2(i, j), p);
128+
setVertex(pos, p);
128129

129130
}
130131
}

0 commit comments

Comments
 (0)