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; int parseCount = 0;
while (next) while (next)
{ {
lineLength = next - base; lineLength = ((int)(next - base));
memcpy(line, contents + parseCount, lineLength); memcpy(line, contents + parseCount, lineLength);
line[lineLength] = 0; line[lineLength] = 0;

View File

@ -74,7 +74,7 @@ static const char* START_FRAME = "startFrame";
static const char* X = "x"; static const char* X = "x";
static const char* Y = "y"; static const char* Y = "y";
static const char* ROTATION = "rotation"; 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* RED = "red";
static const char* GREEN = "green"; static const char* GREEN = "green";
static const char* BLUE = "blue"; static const char* BLUE = "blue";

View File

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

View File

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

View File

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