Renamed shadowed variables to reduce confusion when reading source code

This commit is contained in:
hobogenized 2015-04-20 22:57:55 -04:00
parent 7a1a021974
commit 22df7df76a
5 changed files with 57 additions and 57 deletions

View File

@ -298,7 +298,7 @@ std::set<unsigned int>* BMFontConfiguration::parseConfigFile(const std::string&
int parseCount = 0;
while (next)
{
lineLength = next - base;
lineLength = ((int)(next - base));
memcpy(line, contents + parseCount, lineLength);
line[lineLength] = 0;

View File

@ -74,7 +74,7 @@ static const char* START_FRAME = "startFrame";
static const char* X = "x";
static const char* Y = "y";
static const char* ROTATION = "rotation";
static const char* ALPHA = "alpha";
static const char* ALPHA = "alpha"; //TODO: Unused variable
static const char* RED = "red";
static const char* GREEN = "green";
static const char* BLUE = "blue";

View File

@ -266,12 +266,12 @@ void _spRotateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton,
bone = skeleton->bones[self->boneIndex];
if (time >= self->frames[self->framesCount - 2]) { /* Time is after last frame. */
float amount = bone->data->rotation + self->frames[self->framesCount - 1] - bone->rotation;
while (amount > 180)
amount -= 360;
while (amount < -180)
amount += 360;
bone->rotation += amount * alpha;
float tempAmount = bone->data->rotation + self->frames[self->framesCount - 1] - bone->rotation;
while (tempAmount > 180)
tempAmount -= 360;
while (tempAmount < -180)
tempAmount += 360;
bone->rotation += tempAmount * alpha;
return;
}

View File

@ -266,7 +266,7 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
int slotIndex = spSkeletonData_findSlotIndex(skeletonData, slotMap->name);
Json* timelineArray;
for (timelineArray = slotMap->child; timelineArray; timelineArray = timelineArray->next) {
Json* frame;
Json* currFrame;
int verticesCount = 0;
float* tempVertices;
spFFDTimeline *timeline;
@ -287,8 +287,8 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
timeline->attachment = attachment;
tempVertices = MALLOC(float, verticesCount);
for (frame = timelineArray->child, i = 0; frame; frame = frame->next, ++i) {
Json* vertices = Json_getItem(frame, "vertices");
for (currFrame = timelineArray->child, i = 0; currFrame; currFrame = currFrame->next, ++i) {
Json* vertices = Json_getItem(currFrame, "vertices");
float* frameVertices;
if (!vertices) {
if (attachment->type == SP_ATTACHMENT_MESH)
@ -298,7 +298,7 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
memset(frameVertices, 0, sizeof(float) * verticesCount);
}
} else {
int v, start = Json_getInt(frame, "offset", 0);
int v, start = Json_getInt(currFrame, "offset", 0);
Json* vertex;
frameVertices = tempVertices;
memset(frameVertices, 0, sizeof(float) * start);
@ -316,8 +316,8 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
frameVertices[v] += meshVertices[v];
}
}
spFFDTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), frameVertices);
readCurve(SUPER(timeline), i, frame);
spFFDTimeline_setFrame(timeline, i, Json_getFloat(currFrame, "time", 0), frameVertices);
readCurve(SUPER(timeline), i, currFrame);
}
FREE(tempVertices);
@ -333,16 +333,16 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
spDrawOrderTimeline* timeline = spDrawOrderTimeline_create(drawOrder->size, skeletonData->slotsCount);
for (frame = drawOrder->child, i = 0; frame; frame = frame->next, ++i) {
int ii;
int* drawOrder = 0;
int* currDrawOrder = 0;
Json* offsets = Json_getItem(frame, "offsets");
if (offsets) {
Json* offsetMap;
int* unchanged = MALLOC(int, skeletonData->slotsCount - offsets->size);
int originalIndex = 0, unchangedIndex = 0;
drawOrder = MALLOC(int, skeletonData->slotsCount);
currDrawOrder = MALLOC(int, skeletonData->slotsCount);
for (ii = skeletonData->slotsCount - 1; ii >= 0; --ii)
drawOrder[ii] = -1;
currDrawOrder[ii] = -1;
for (offsetMap = offsets->child; offsetMap; offsetMap = offsetMap->next) {
int slotIndex = spSkeletonData_findSlotIndex(skeletonData, Json_getString(offsetMap, "slot", 0));
@ -355,7 +355,7 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
while (originalIndex != slotIndex)
unchanged[unchangedIndex++] = originalIndex++;
/* Set changed items. */
drawOrder[originalIndex + Json_getInt(offsetMap, "offset", 0)] = originalIndex;
currDrawOrder[originalIndex + Json_getInt(offsetMap, "offset", 0)] = originalIndex;
originalIndex++;
}
/* Collect remaining unchanged items. */
@ -363,10 +363,10 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
unchanged[unchangedIndex++] = originalIndex++;
/* Fill in unchanged items. */
for (ii = skeletonData->slotsCount - 1; ii >= 0; ii--)
if (drawOrder[ii] == -1) drawOrder[ii] = unchanged[--unchangedIndex];
if (currDrawOrder[ii] == -1) currDrawOrder[ii] = unchanged[--unchangedIndex];
FREE(unchanged);
}
spDrawOrderTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), drawOrder);
spDrawOrderTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), currDrawOrder);
FREE(drawOrder);
}
animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline);
@ -376,24 +376,24 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
/* Event timeline. */
if (events) {
Json* frame;
Json* currFrame;
spEventTimeline* timeline = spEventTimeline_create(events->size);
for (frame = events->child, i = 0; frame; frame = frame->next, ++i) {
for (currFrame = events->child, i = 0; currFrame; currFrame = currFrame->next, ++i) {
spEvent* event;
const char* stringValue;
spEventData* eventData = spSkeletonData_findEvent(skeletonData, Json_getString(frame, "name", 0));
spEventData* eventData = spSkeletonData_findEvent(skeletonData, Json_getString(currFrame, "name", 0));
if (!eventData) {
spAnimation_dispose(animation);
_spSkeletonJson_setError(self, 0, "Event not found: ", Json_getString(frame, "name", 0));
_spSkeletonJson_setError(self, 0, "Event not found: ", Json_getString(currFrame, "name", 0));
return 0;
}
event = spEvent_create(eventData);
event->intValue = Json_getInt(frame, "int", eventData->intValue);
event->floatValue = Json_getFloat(frame, "float", eventData->floatValue);
stringValue = Json_getString(frame, "string", eventData->stringValue);
event->intValue = Json_getInt(currFrame, "int", eventData->intValue);
event->floatValue = Json_getFloat(currFrame, "float", eventData->floatValue);
stringValue = Json_getString(currFrame, "string", eventData->stringValue);
if (stringValue) MALLOC_STR(event->stringValue, stringValue);
spEventTimeline_setFrame(timeline, i, Json_getFloat(frame, "time", 0), event);
spEventTimeline_setFrame(timeline, i, Json_getFloat(currFrame, "time", 0), event);
}
animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline);
duration = timeline->frames[events->size - 1];
@ -571,7 +571,7 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
const char* attachmentName = Json_getString(attachmentMap, "name", skinAttachmentName);
const char* path = Json_getString(attachmentMap, "path", attachmentName);
const char* color;
int i;
int currIndex;
Json* entry;
const char* typeString = Json_getString(attachmentMap, "type", "region");
@ -631,19 +631,19 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
entry = Json_getItem(attachmentMap, "vertices");
mesh->verticesCount = entry->size;
mesh->vertices = MALLOC(float, entry->size);
for (entry = entry->child, i = 0; entry; entry = entry->next, ++i)
mesh->vertices[i] = entry->valueFloat * self->scale;
for (entry = entry->child, currIndex = 0; entry; entry = entry->next, ++currIndex)
mesh->vertices[currIndex] = entry->valueFloat * self->scale;
entry = Json_getItem(attachmentMap, "triangles");
mesh->trianglesCount = entry->size;
mesh->triangles = MALLOC(int, entry->size);
for (entry = entry->child, i = 0; entry; entry = entry->next, ++i)
mesh->triangles[i] = entry->valueInt;
for (entry = entry->child, currIndex = 0; entry; entry = entry->next, ++currIndex)
mesh->triangles[currIndex] = entry->valueInt;
entry = Json_getItem(attachmentMap, "uvs");
mesh->regionUVs = MALLOC(float, entry->size);
for (entry = entry->child, i = 0; entry; entry = entry->next, ++i)
mesh->regionUVs[i] = entry->valueFloat;
for (entry = entry->child, currIndex = 0; entry; entry = entry->next, ++currIndex)
mesh->regionUVs[currIndex] = entry->valueFloat;
spMeshAttachment_updateUVs(mesh);
@ -661,8 +661,8 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
if (entry) {
mesh->edgesCount = entry->size;
mesh->edges = MALLOC(int, entry->size);
for (entry = entry->child, i = 0; entry; entry = entry->next, ++i)
mesh->edges[i] = entry->valueInt;
for (entry = entry->child, currIndex = 0; entry; entry = entry->next, ++currIndex)
mesh->edges[currIndex] = entry->valueInt;
}
mesh->width = Json_getFloat(attachmentMap, "width", 32) * self->scale;
@ -679,32 +679,32 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
entry = Json_getItem(attachmentMap, "uvs");
mesh->uvsCount = entry->size;
mesh->regionUVs = MALLOC(float, entry->size);
for (entry = entry->child, i = 0; entry; entry = entry->next, ++i)
mesh->regionUVs[i] = entry->valueFloat;
for (entry = entry->child, currIndex = 0; entry; entry = entry->next, ++currIndex)
mesh->regionUVs[currIndex] = entry->valueFloat;
entry = Json_getItem(attachmentMap, "vertices");
verticesCount = entry->size;
vertices = MALLOC(float, entry->size);
for (entry = entry->child, i = 0; entry; entry = entry->next, ++i)
vertices[i] = entry->valueFloat;
for (entry = entry->child, currIndex = 0; entry; entry = entry->next, ++currIndex)
vertices[currIndex] = entry->valueFloat;
for (i = 0; i < verticesCount;) {
int bonesCount = (int)vertices[i];
for (currIndex = 0; currIndex < verticesCount;) {
int bonesCount = (int)vertices[currIndex];
mesh->bonesCount += bonesCount + 1;
mesh->weightsCount += bonesCount * 3;
i += 1 + bonesCount * 4;
currIndex += 1 + bonesCount * 4;
}
mesh->bones = MALLOC(int, mesh->bonesCount);
mesh->weights = MALLOC(float, mesh->weightsCount);
for (i = 0, b = 0, w = 0; i < verticesCount;) {
int bonesCount = (int)vertices[i++];
for (currIndex = 0, b = 0, w = 0; currIndex < verticesCount;) {
int bonesCount = (int)vertices[currIndex++];
mesh->bones[b++] = bonesCount;
for (nn = i + bonesCount * 4; i < nn; i += 4, ++b, w += 3) {
mesh->bones[b] = (int)vertices[i];
mesh->weights[w] = vertices[i + 1] * self->scale;
mesh->weights[w + 1] = vertices[i + 2] * self->scale;
mesh->weights[w + 2] = vertices[i + 3];
for (nn = currIndex + bonesCount * 4; currIndex < nn; currIndex += 4, ++b, w += 3) {
mesh->bones[b] = (int)vertices[currIndex];
mesh->weights[w] = vertices[currIndex + 1] * self->scale;
mesh->weights[w + 1] = vertices[currIndex + 2] * self->scale;
mesh->weights[w + 2] = vertices[currIndex + 3];
}
}
@ -713,8 +713,8 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
entry = Json_getItem(attachmentMap, "triangles");
mesh->trianglesCount = entry->size;
mesh->triangles = MALLOC(int, entry->size);
for (entry = entry->child, i = 0; entry; entry = entry->next, ++i)
mesh->triangles[i] = entry->valueInt;
for (entry = entry->child, currIndex = 0; entry; entry = entry->next, ++currIndex)
mesh->triangles[currIndex] = entry->valueInt;
spSkinnedMeshAttachment_updateUVs(mesh);
@ -732,7 +732,7 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
if (entry) {
mesh->edgesCount = entry->size;
mesh->edges = MALLOC(int, entry->size);
for (entry = entry->child, i = 0; entry; entry = entry->next, ++i)
for (entry = entry->child, currIndex = 0; entry; entry = entry->next, ++currIndex)
mesh->edges[i] = entry->valueInt;
}
@ -745,8 +745,8 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
entry = Json_getItem(attachmentMap, "vertices");
box->verticesCount = entry->size;
box->vertices = MALLOC(float, entry->size);
for (entry = entry->child, i = 0; entry; entry = entry->next, ++i)
box->vertices[i] = entry->valueFloat * self->scale;
for (entry = entry->child, currIndex = 0; entry; entry = entry->next, ++currIndex)
box->vertices[currIndex] = entry->valueFloat * self->scale;
break;
}
}

View File

@ -48,7 +48,7 @@ void _spAtlasPage_disposeTexture (spAtlasPage* self) {
char* _spUtil_readFile (const char* path, int* length) {
Data data = FileUtils::getInstance()->getDataFromFile(
FileUtils::getInstance()->fullPathForFilename(path).c_str());
*length = data.getSize();
*length = (int) data.getSize();
char* bytes = MALLOC(char, *length);
memcpy(bytes, data.getBytes(), *length);
return bytes;