Skip to content

Commit

Permalink
fix warnings (cocos2d#17971)
Browse files Browse the repository at this point in the history
  • Loading branch information
minggo authored Jun 23, 2017
1 parent 61839e7 commit 3208120
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion cocos/editor-support/spine/Animation.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ void _spAttachmentTimeline_apply (const spTimeline* timeline, spSkeleton* skelet
spSlot* slot = skeleton->slots[self->slotIndex];

if (mixingOut && setupPose) {
const char* attachmentName = slot->data->attachmentName;
attachmentName = slot->data->attachmentName;
spSlot_setAttachment(slot, attachmentName ? spSkeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName) : 0);
return;
}
Expand Down
4 changes: 3 additions & 1 deletion cocos/editor-support/spine/IkConstraint.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ void spIkConstraint_apply2 (spBone* parent, spBone* child, float targetX, float
float d = c1 * c1 - 4 * c2 * c0;
float minAngle = 0, minDist = FLT_MAX, minX = 0, minY = 0;
float maxAngle = 0, maxDist = 0, maxX = 0, maxY = 0;
float x = l1 + a, dist = x * x, angle, y;
float dist, angle;
x = l1 + a;
dist = x * x;
if (d >= 0) {
float q = SQRT(d), r0, r1;
if (c1 < 0) q = -q;
Expand Down
2 changes: 0 additions & 2 deletions cocos/editor-support/spine/SkeletonAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ void SkeletonAnimation::initialize () {
_state = spAnimationState_create(spAnimationStateData_create(_skeleton->data));
_state->rendererObject = this;
_state->listener = animationCallback;

_spAnimationState* stateInternal = (_spAnimationState*)_state;
}

SkeletonAnimation::SkeletonAnimation ()
Expand Down
22 changes: 11 additions & 11 deletions cocos/editor-support/spine/SkeletonBinary.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,9 @@ static spAnimation* _spSkeletonBinary_readAnimation (spSkeletonBinary* self, con
break;
}
default: {
int i;
for (i = 0; i < kv_size(timelines); ++i)
spTimeline_dispose(kv_A(timelines, i));
int j;
for (j = 0; j < kv_size(timelines); ++j)
spTimeline_dispose(kv_A(timelines, j));
kv_destroy(timelines);
_spSkeletonBinary_setError(self, "Invalid timeline type for a slot: ", skeletonData->slots[slotIndex]->name);
return 0;
Expand Down Expand Up @@ -353,9 +353,9 @@ static spAnimation* _spSkeletonBinary_readAnimation (spSkeletonBinary* self, con
break;
}
default: {
int i;
for (i = 0; i < kv_size(timelines); ++i)
spTimeline_dispose(kv_A(timelines, i));
int j;
for (j = 0; j < kv_size(timelines); ++j)
spTimeline_dispose(kv_A(timelines, j));
kv_destroy(timelines);
_spSkeletonBinary_setError(self, "Invalid timeline type for a bone: ", skeletonData->bones[boneIndex]->name);
return 0;
Expand Down Expand Up @@ -465,8 +465,8 @@ static spAnimation* _spSkeletonBinary_readAnimation (spSkeletonBinary* self, con
spVertexAttachment* attachment = SUB_CAST(spVertexAttachment,
spSkin_getAttachment(skin, slotIndex, attachmentName));
if (!attachment) {
int i;
for (i = 0; i < kv_size(timelines); ++i)
int j;
for (j = 0; j < kv_size(timelines); ++j)
spTimeline_dispose(kv_A(timelines, i));
kv_destroy(timelines);
_spSkeletonBinary_setError(self, "Attachment not found: ", attachmentName);
Expand Down Expand Up @@ -583,7 +583,7 @@ static spAnimation* _spSkeletonBinary_readAnimation (spSkeletonBinary* self, con

animation = spAnimation_create(name, 0);
animation->duration = duration;
animation->timelinesCount = kv_size(timelines);
animation->timelinesCount = (int)kv_size(timelines);
animation->timelines = kv_array(timelines);
return animation;
}
Expand Down Expand Up @@ -647,11 +647,11 @@ static void _readVertices(spSkeletonBinary* self, _dataInput* input, spVertexAtt
}

kv_trim(float, weights);
attachment->verticesCount = kv_size(weights);
attachment->verticesCount = (int)kv_size(weights);
attachment->vertices = kv_array(weights);

kv_trim(int, bones);
attachment->bonesCount = kv_size(bones);
attachment->bonesCount = (int)kv_size(bones);
attachment->bones = kv_array(bones);
}

Expand Down
54 changes: 27 additions & 27 deletions cocos/editor-support/spine/SkeletonJson.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
Json* ik = Json_getItem(root, "ik");
Json* transform = Json_getItem(root, "transform");
Json* paths = Json_getItem(root, "paths");
Json* deform = Json_getItem(root, "deform");
Json* drawOrder = Json_getItem(root, "drawOrder");
Json* deformObj = Json_getItem(root, "deform");
Json* drawOrderObj = Json_getItem(root, "drawOrder");
Json* events = Json_getItem(root, "events");
Json *boneMap, *slotMap, *constraintMap;
if (!drawOrder) drawOrder = Json_getItem(root, "draworder");
if (!drawOrderObj) drawOrderObj = Json_getItem(root, "draworder");

for (boneMap = bones ? bones->child : 0; boneMap; boneMap = boneMap->next)
timelinesCount += boneMap->size;
Expand All @@ -167,10 +167,10 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
timelinesCount += transform ? transform->size : 0;
for (constraintMap = paths ? paths->child : 0; constraintMap; constraintMap = constraintMap->next)
timelinesCount += constraintMap->size;
for (constraintMap = deform ? deform->child : 0; constraintMap; constraintMap = constraintMap->next)
for (constraintMap = deformObj ? deformObj->child : 0; constraintMap; constraintMap = constraintMap->next)
for (slotMap = constraintMap->child; slotMap; slotMap = slotMap->next)
timelinesCount += slotMap->size;
if (drawOrder) ++timelinesCount;
if (drawOrderObj) ++timelinesCount;
if (events) ++timelinesCount;

animation = spAnimation_create(root->name, timelinesCount);
Expand Down Expand Up @@ -363,7 +363,7 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
}

/* Deform timelines. */
for (constraintMap = deform ? deform->child : 0; constraintMap; constraintMap = constraintMap->next) {
for (constraintMap = deformObj ? deformObj->child : 0; constraintMap; constraintMap = constraintMap->next) {
spSkin* skin = spSkeletonData_findSkin(skeletonData, constraintMap->name);
for (slotMap = constraintMap->child; slotMap; slotMap = slotMap->next) {
int slotIndex = spSkeletonData_findSlotIndex(skeletonData, slotMap->name);
Expand All @@ -388,9 +388,9 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
timeline->attachment = SUPER(attachment);

for (valueMap = timelineMap->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) {
Json* vertices = Json_getItem(valueMap, "vertices");
Json* verticesObj = Json_getItem(valueMap, "vertices");
float* deform;
if (!vertices) {
if (!verticesObj) {
if (weighted) {
deform = tempDeform;
memset(deform, 0, sizeof(float) * deformLength);
Expand All @@ -402,10 +402,10 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
deform = tempDeform;
memset(deform, 0, sizeof(float) * start);
if (self->scale == 1) {
for (vertex = vertices->child, v = start; vertex; vertex = vertex->next, ++v)
for (vertex = verticesObj->child, v = start; vertex; vertex = vertex->next, ++v)
deform[v] = vertex->valueFloat;
} else {
for (vertex = vertices->child, v = start; vertex; vertex = vertex->next, ++v)
for (vertex = verticesObj->child, v = start; vertex; vertex = vertex->next, ++v)
deform[v] = vertex->valueFloat * self->scale;
}
memset(deform + v, 0, sizeof(float) * (deformLength - v));
Expand All @@ -427,9 +427,9 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
}

/* Draw order timeline. */
if (drawOrder) {
spDrawOrderTimeline* timeline = spDrawOrderTimeline_create(drawOrder->size, skeletonData->slotsCount);
for (valueMap = drawOrder->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) {
if (drawOrderObj) {
spDrawOrderTimeline* timeline = spDrawOrderTimeline_create(drawOrderObj->size, skeletonData->slotsCount);
for (valueMap = drawOrderObj->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) {
int ii;
int* drawOrder = 0;
Json* offsets = Json_getItem(valueMap, "offsets");
Expand Down Expand Up @@ -468,7 +468,7 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
FREE(drawOrder);
}
animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline);
animation->duration = MAX(animation->duration, timeline->frames[drawOrder->size - 1]);
animation->duration = MAX(animation->duration, timeline->frames[drawOrderObj->size - 1]);
}

/* Event timeline. */
Expand Down Expand Up @@ -564,7 +564,7 @@ spSkeletonData* spSkeletonJson_readSkeletonDataFile (spSkeletonJson* self, const
spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const char* json) {
int i, ii;
spSkeletonData* skeletonData;
Json *root, *skeleton, *bones, *boneMap, *ik, *transform, *path, *slots, *skins, *animations, *events;
Json *root, *skeleton, *bones, *boneMap, *ik, *transform, *pathObj, *slots, *skins, *animations, *events;
char* oldLocale;
_spSkeletonJson* internal = SUB_CAST(_spSkeletonJson, self);

Expand Down Expand Up @@ -777,12 +777,12 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
}

/* Path constraints */
path = Json_getItem(root, "path");
if (path) {
pathObj = Json_getItem(root, "path");
if (pathObj) {
Json *constraintMap;
skeletonData->pathConstraintsCount = path->size;
skeletonData->pathConstraints = MALLOC(spPathConstraintData*, path->size);
for (constraintMap = path->child, i = 0; constraintMap; constraintMap = constraintMap->next, ++i) {
skeletonData->pathConstraintsCount = pathObj->size;
skeletonData->pathConstraints = MALLOC(spPathConstraintData*, pathObj->size);
for (constraintMap = pathObj->child, i = 0; constraintMap; constraintMap = constraintMap->next, ++i) {
const char* name;
const char* item;

Expand Down Expand Up @@ -976,19 +976,19 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
break;
}
case SP_ATTACHMENT_PATH: {
spPathAttachment* path = SUB_CAST(spPathAttachment, attachment);
spPathAttachment* pathAttachment = SUB_CAST(spPathAttachment, attachment);
int vertexCount = 0;
path->closed = Json_getInt(attachmentMap, "closed", 0);
path->constantSpeed = Json_getInt(attachmentMap, "constantSpeed", 1);
pathAttachment->closed = Json_getInt(attachmentMap, "closed", 0);
pathAttachment->constantSpeed = Json_getInt(attachmentMap, "constantSpeed", 1);
vertexCount = Json_getInt(attachmentMap, "vertexCount", 0);
_readVertices(self, attachmentMap, SUPER(path), vertexCount << 1);
_readVertices(self, attachmentMap, SUPER(pathAttachment), vertexCount << 1);

path->lengthsLength = vertexCount / 3;
path->lengths = MALLOC(float, path->lengthsLength);
pathAttachment->lengthsLength = vertexCount / 3;
pathAttachment->lengths = MALLOC(float, pathAttachment->lengthsLength);

curves = Json_getItem(attachmentMap, "lengths");
for (curves = curves->child, ii = 0; curves; curves = curves->next, ++ii) {
path->lengths[ii] = curves->valueFloat * self->scale;
pathAttachment->lengths[ii] = curves->valueFloat * self->scale;
}
break;
}
Expand Down

0 comments on commit 3208120

Please sign in to comment.