Skip to content

Commit

Permalink
[c][cpp] Fix compilation errors. See commit dc9a6eb, see EsotericSoft…
Browse files Browse the repository at this point in the history
  • Loading branch information
badlogic committed Sep 13, 2021
1 parent 8770e31 commit 31c2f4a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
29 changes: 14 additions & 15 deletions spine-c/spine-c/src/spine/SkeletonJson.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,44 +218,44 @@ static void cleanUpTimelines(spTimelineArray *timelines) {
spTimelineArray_dispose(timelines);
}

static int findSlotIndex(const spSkeletonData *skeletonData, const char *slotName, spTimelineArray *timelines) {
static int findSlotIndex(spSkeletonJson *json, const spSkeletonData *skeletonData, const char *slotName, spTimelineArray *timelines) {
spSlotData *slot = spSkeletonData_findSlot(skeletonData, slotName);
if (slot) return slot->index;
cleanUpTimelines(timelines);
_spSkeletonJson_setError(skeletonData, NULL, "Slot not found: ", slotName);
_spSkeletonJson_setError(json, NULL, "Slot not found: ", slotName);
return -1;
}

int findIkConstraintIndex(const spSkeletonData *skeletonData, const spIkConstraintData *constraint, spTimelineArray *timelines) {
int findIkConstraintIndex(spSkeletonJson *json, const spSkeletonData *skeletonData, const spIkConstraintData *constraint, spTimelineArray *timelines) {
if (constraint) {
int i;
for (i = 0; i < skeletonData->ikConstraintsCount; ++i)
if (skeletonData->ikConstraints[i] == constraint) return i;
}
cleanUpTimelines(timelines);
_spSkeletonJson_setError(skeletonData, NULL, "IK constraint not found: ", constraint->name);
_spSkeletonJson_setError(json, NULL, "IK constraint not found: ", constraint->name);
return -1;
}

int findTransformConstraintIndex(const spSkeletonData *skeletonData, const spTransformConstraintData *constraint, spTimelineArray *timelines) {
int findTransformConstraintIndex(spSkeletonJson *json, const spSkeletonData *skeletonData, const spTransformConstraintData *constraint, spTimelineArray *timelines) {
if (constraint) {
int i;
for (i = 0; i < skeletonData->transformConstraintsCount; ++i)
if (skeletonData->transformConstraints[i] == constraint) return i;
}
cleanUpTimelines(timelines);
_spSkeletonJson_setError(skeletonData, NULL, "Transform constraint not found: ", constraint->name);
_spSkeletonJson_setError(json, NULL, "Transform constraint not found: ", constraint->name);
return -1;
}

int findPathConstraintIndex(const spSkeletonData *skeletonData, const spPathConstraintData *constraint, spTimelineArray *timelines) {
int findPathConstraintIndex(spSkeletonJson *json, const spSkeletonData *skeletonData, const spPathConstraintData *constraint, spTimelineArray *timelines) {
if (constraint) {
int i;
for (i = 0; i < skeletonData->pathConstraintsCount; ++i)
if (skeletonData->pathConstraints[i] == constraint) return i;
}
cleanUpTimelines(timelines);
_spSkeletonJson_setError(skeletonData, NULL, "Path constraint not found: ", constraint->name);
_spSkeletonJson_setError(json, NULL, "Path constraint not found: ", constraint->name);
return -1;
}

Expand All @@ -277,7 +277,7 @@ static spAnimation *_spSkeletonJson_readAnimation(spSkeletonJson *self, Json *ro

/* Slot timelines. */
for (slotMap = slots ? slots->child : 0; slotMap; slotMap = slotMap->next) {
int slotIndex = findSlotIndex(skeletonData, slotMap->name, timelines);
int slotIndex = findSlotIndex(self, skeletonData, slotMap->name, timelines);
if (slotIndex == -1) return NULL;

for (timelineMap = slotMap->child; timelineMap; timelineMap = timelineMap->next) {
Expand Down Expand Up @@ -454,7 +454,6 @@ static spAnimation *_spSkeletonJson_readAnimation(spSkeletonJson *self, Json *ro
/* Bone timelines. */
for (boneMap = bones ? bones->child : 0; boneMap; boneMap = boneMap->next) {
int boneIndex = -1;
int i;
for (i = 0; i < skeletonData->bonesCount; ++i) {
if (strcmp(skeletonData->bones[i]->name, boneMap->name) == 0) {
boneIndex = i;
Expand Down Expand Up @@ -527,7 +526,7 @@ static spAnimation *_spSkeletonJson_readAnimation(spSkeletonJson *self, Json *ro
if (keyMap == NULL) continue;

constraint = spSkeletonData_findIkConstraint(skeletonData, constraintMap->name);
constraintIndex = findIkConstraintIndex(skeletonData, constraint, timelines);
constraintIndex = findIkConstraintIndex(self, skeletonData, constraint, timelines);
if (constraintIndex == -1) return NULL;
timeline = spIkConstraintTimeline_create(constraintMap->size, constraintMap->size << 1, constraintIndex);

Expand Down Expand Up @@ -575,7 +574,7 @@ static spAnimation *_spSkeletonJson_readAnimation(spSkeletonJson *self, Json *ro
if (keyMap == NULL) continue;

constraint = spSkeletonData_findTransformConstraint(skeletonData, constraintMap->name);
constraintIndex = findTransformConstraintIndex(skeletonData, constraint, timelines);
constraintIndex = findTransformConstraintIndex(self, skeletonData, constraint, timelines);
if (constraintIndex == -1) return NULL;
timeline = spTransformConstraintTimeline_create(constraintMap->size, constraintMap->size * 6, constraintIndex);

Expand Down Expand Up @@ -630,7 +629,7 @@ static spAnimation *_spSkeletonJson_readAnimation(spSkeletonJson *self, Json *ro
/** Path constraint timelines. */
for (constraintMap = paths ? paths->child : 0; constraintMap; constraintMap = constraintMap->next) {
spPathConstraintData *constraint = spSkeletonData_findPathConstraint(skeletonData, constraintMap->name);
int constraintIndex = findPathConstraintIndex(skeletonData, constraint->name);
int constraintIndex = findPathConstraintIndex(self, skeletonData, constraint, timelines);
if (constraintIndex == -1) return NULL;
for (timelineMap = constraintMap->child; timelineMap; timelineMap = timelineMap->next) {
const char *timelineName;
Expand Down Expand Up @@ -696,7 +695,7 @@ static spAnimation *_spSkeletonJson_readAnimation(spSkeletonJson *self, Json *ro
for (constraintMap = deformJson ? deformJson->child : 0; constraintMap; constraintMap = constraintMap->next) {
spSkin *skin = spSkeletonData_findSkin(skeletonData, constraintMap->name);
for (slotMap = constraintMap->child; slotMap; slotMap = slotMap->next) {
int slotIndex = findSlotIndex(skeletonData, slotMap->name, timelines);
int slotIndex = findSlotIndex(self, skeletonData, slotMap->name, timelines);
if (slotIndex == -1) return NULL;

for (timelineMap = slotMap->child; timelineMap; timelineMap = timelineMap->next) {
Expand Down Expand Up @@ -789,7 +788,7 @@ static spAnimation *_spSkeletonJson_readAnimation(spSkeletonJson *self, Json *ro
drawOrder[ii] = -1;

for (offsetMap = offsets->child; offsetMap; offsetMap = offsetMap->next) {
int slotIndex = findSlotIndex(skeletonData, Json_getString(offsetMap, "slot", 0), timelines);
int slotIndex = findSlotIndex(self, skeletonData, Json_getString(offsetMap, "slot", 0), timelines);
if (slotIndex == -1) return NULL;

/* Collect unchanged items. */
Expand Down
2 changes: 2 additions & 0 deletions spine-cpp/spine-cpp/include/spine/SkeletonJson.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ namespace spine {
void readVertices(Json *attachmentMap, VertexAttachment *attachment, size_t verticesLength);

void setError(Json *root, const String &value1, const String &value2);

int findSlotIndex(SkeletonData *skeletonData, const String &slotName, Vector<Timeline *> timelines);
};
}

Expand Down
4 changes: 2 additions & 2 deletions spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,8 +849,8 @@ Timeline *SkeletonJson::readTimeline(Json *keyMap, CurveTimeline2 *timeline, con
return timeline;
}

int SkeletonJson::findSlotIndex(const SkeletonData *skeletonData, const String &slotName, Vector<Timeline *> timelines) {
int slotIndex = ContainerUtil::findIndexWithName(skeletonData->_slots, slotName);
int SkeletonJson::findSlotIndex(SkeletonData *skeletonData, const String &slotName, Vector<Timeline *> timelines) {
int slotIndex = ContainerUtil::findIndexWithName(skeletonData->getSlots(), slotName);
if (slotIndex == -1) {
ContainerUtil::cleanUpVectorOfPointers(timelines);
setError(NULL, "Slot not found: ", slotName);
Expand Down

0 comments on commit 31c2f4a

Please sign in to comment.