Completed check of pointers to be valid.
If a parameter (start pitbuildings, stop pitbuildings) is not defined, use pitStart or pitEnd as default replacement. Do not use undefined pointers for GfOut statements git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6387 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 624bba9d585bbb87101ae7694ab7f4b5c313b4cf Former-commit-id: d48aac1b56e0360ed9dcef54773298bfdeda4582
This commit is contained in:
parent
c9e7bb4fd0
commit
1ccf364c6f
3 changed files with 146 additions and 130 deletions
|
@ -1382,25 +1382,28 @@ ReadTrack3(tTrack *theTrack, void *TrackHandle, tRoadCam **camList, int ext)
|
|||
}
|
||||
|
||||
}
|
||||
segName = GfParmGetStr(TrackHandle, TRK_SECT_MAIN, TRK_ATT_BUILDINGS_START, NULL);
|
||||
if (segName != 0) {
|
||||
pitBuildingsStart = theTrack->seg;
|
||||
found = 0;
|
||||
for(i = 0; i < theTrack->nseg; i++) {
|
||||
if (!strcmp(segName, pitBuildingsStart->name)) {
|
||||
found = 1;
|
||||
} else if (found) {
|
||||
pitBuildingsStart = pitBuildingsStart->next;
|
||||
break;
|
||||
|
||||
if (pitStart != NULL) {
|
||||
segName = GfParmGetStr(TrackHandle, TRK_SECT_MAIN, TRK_ATT_BUILDINGS_START, NULL);
|
||||
if (segName != 0) {
|
||||
pitBuildingsStart = theTrack->seg;
|
||||
found = 0;
|
||||
for(i = 0; i < theTrack->nseg; i++) {
|
||||
if (!strcmp(segName, pitBuildingsStart->name)) {
|
||||
found = 1;
|
||||
} else if (found) {
|
||||
pitBuildingsStart = pitBuildingsStart->next;
|
||||
break;
|
||||
}
|
||||
pitBuildingsStart = pitBuildingsStart->prev;
|
||||
}
|
||||
pitBuildingsStart = pitBuildingsStart->prev;
|
||||
}
|
||||
if (!found) {
|
||||
if (!found) {
|
||||
pitBuildingsStart = pitStart;
|
||||
}
|
||||
} else {
|
||||
pitBuildingsStart = pitStart;
|
||||
}
|
||||
} else {
|
||||
pitBuildingsStart = pitStart;
|
||||
}
|
||||
}
|
||||
|
||||
segName = GfParmGetStr(TrackHandle, TRK_SECT_MAIN, TRK_ATT_PIT_END, NULL);
|
||||
if (segName != 0) {
|
||||
|
@ -1419,24 +1422,27 @@ ReadTrack3(tTrack *theTrack, void *TrackHandle, tRoadCam **camList, int ext)
|
|||
pitEnd = NULL;
|
||||
}
|
||||
|
||||
segName = GfParmGetStr(TrackHandle, TRK_SECT_MAIN, TRK_ATT_BUILDINGS_STOP, NULL);
|
||||
if (segName != 0) {
|
||||
pitBuildingsEnd = theTrack->seg;
|
||||
found = 0;
|
||||
for(i = 0; i < theTrack->nseg; i++) {
|
||||
if (!strcmp(segName, pitBuildingsEnd->name)) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
pitBuildingsEnd = pitBuildingsEnd->prev;
|
||||
}
|
||||
if (!found) {
|
||||
pitBuildingsEnd = pitEnd;
|
||||
}
|
||||
} else {
|
||||
pitBuildingsEnd = pitEnd;
|
||||
}
|
||||
if (pitEnd != NULL) {
|
||||
segName = GfParmGetStr(TrackHandle, TRK_SECT_MAIN, TRK_ATT_BUILDINGS_STOP, NULL);
|
||||
if (segName != 0) {
|
||||
pitBuildingsEnd = theTrack->seg;
|
||||
found = 0;
|
||||
for(i = 0; i < theTrack->nseg; i++) {
|
||||
if (!strcmp(segName, pitBuildingsEnd->name)) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
pitBuildingsEnd = pitBuildingsEnd->prev;
|
||||
}
|
||||
if (!found) {
|
||||
pitBuildingsEnd = pitEnd;
|
||||
}
|
||||
} else {
|
||||
pitBuildingsEnd = pitEnd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
paramVal = GfParmGetStr(TrackHandle, TRK_SECT_MAIN, TRK_ATT_PIT_SIDE, "right");
|
||||
if (strcmp(paramVal, "right") == 0) {
|
||||
pits->side = TR_RGT;
|
||||
|
|
|
@ -813,10 +813,10 @@ static bool InitPits(tTrack *theTrack, void *TrackHandle) {
|
|||
}
|
||||
pitEntrySeg = pitEntrySeg->prev;
|
||||
}// for i
|
||||
if (!found) {
|
||||
if (found)
|
||||
GfOut("PitEntry: %s\n", pitEntrySeg->name);
|
||||
else
|
||||
pitEntrySeg = NULL;
|
||||
}
|
||||
GfOut("PitEntry: %s\n", pitEntrySeg->name);
|
||||
|
||||
//Search for pit exit
|
||||
segName = GfParmGetStrNC(TrackHandle, path2, TRK_ATT_EXIT, NULL);
|
||||
|
@ -832,11 +832,11 @@ static bool InitPits(tTrack *theTrack, void *TrackHandle) {
|
|||
}
|
||||
pitExitSeg = pitExitSeg->prev;
|
||||
}
|
||||
if (!found) {
|
||||
if (found)
|
||||
GfOut("PitExit: %s\n", pitExitSeg->name);
|
||||
else
|
||||
pitExitSeg = NULL;
|
||||
}
|
||||
}
|
||||
GfOut("PitExit: %s\n", pitExitSeg->name);
|
||||
|
||||
//Search for pits start
|
||||
segName = GfParmGetStrNC(TrackHandle, path2, TRK_ATT_START, NULL);
|
||||
|
@ -856,29 +856,31 @@ static bool InitPits(tTrack *theTrack, void *TrackHandle) {
|
|||
pitStart = NULL;
|
||||
}
|
||||
}
|
||||
GfOut("PitStart: %s\n", pitStart->name);
|
||||
if (pitStart != NULL) {
|
||||
GfOut("PitStart: %s\n", pitStart->name);
|
||||
|
||||
//Search for pit buildings start
|
||||
segName = GfParmGetStrNC(TrackHandle, path2, TRK_ATT_BUILDINGS_START, NULL);
|
||||
if (segName != 0) {
|
||||
pitBuildingsStart = theTrack->seg;
|
||||
found = false;
|
||||
for(i = 0; i < theTrack->nseg; i++) {
|
||||
if (!strcmp(segName, pitBuildingsStart->name)) {
|
||||
found = true;
|
||||
} else if (found) {
|
||||
pitBuildingsStart = pitBuildingsStart->next;
|
||||
break;
|
||||
}
|
||||
pitBuildingsStart = pitBuildingsStart->prev;
|
||||
}
|
||||
if (!found) {
|
||||
pitBuildingsStart = pitStart;
|
||||
}
|
||||
} else {
|
||||
pitBuildingsStart = pitStart;
|
||||
}
|
||||
GfOut("PitBuildingStart: %s\n", pitBuildingsStart->name);
|
||||
//Search for pit buildings start
|
||||
segName = GfParmGetStrNC(TrackHandle, path2, TRK_ATT_BUILDINGS_START, NULL);
|
||||
if (segName != 0) {
|
||||
pitBuildingsStart = theTrack->seg;
|
||||
found = false;
|
||||
for(i = 0; i < theTrack->nseg; i++) {
|
||||
if (!strcmp(segName, pitBuildingsStart->name)) {
|
||||
found = true;
|
||||
} else if (found) {
|
||||
pitBuildingsStart = pitBuildingsStart->next;
|
||||
break;
|
||||
}
|
||||
pitBuildingsStart = pitBuildingsStart->prev;
|
||||
}
|
||||
if (!found) {
|
||||
pitBuildingsStart = pitStart;
|
||||
}
|
||||
} else {
|
||||
pitBuildingsStart = pitStart;
|
||||
}
|
||||
GfOut("PitBuildingStart: %s\n", pitBuildingsStart->name);
|
||||
}
|
||||
|
||||
//Search for pits end
|
||||
segName = GfParmGetStrNC(TrackHandle, path2, TRK_ATT_END, NULL);
|
||||
|
@ -897,28 +899,31 @@ static bool InitPits(tTrack *theTrack, void *TrackHandle) {
|
|||
pitEnd = NULL;
|
||||
}
|
||||
}
|
||||
GfOut("PitEnd: %s\n", pitEnd->name);
|
||||
|
||||
//Search for pit buildings end
|
||||
segName = GfParmGetStrNC(TrackHandle, path2, TRK_ATT_BUILDINGS_STOP, NULL);
|
||||
if (segName != 0) {
|
||||
/* Search backward the last segment with that name */
|
||||
pitBuildingsEnd = theTrack->seg; /* last track segment */
|
||||
found = false;
|
||||
for(i = 0; i < theTrack->nseg; i++) {
|
||||
if (!strcmp(segName, pitBuildingsEnd->name)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
pitBuildingsEnd = pitBuildingsEnd->prev;
|
||||
}
|
||||
if (!found) {
|
||||
pitBuildingsEnd = pitEnd;
|
||||
}
|
||||
} else {
|
||||
pitBuildingsEnd = pitEnd;
|
||||
}
|
||||
GfOut("PitBuildungsEnd: %s\n", pitBuildingsEnd->name);
|
||||
if (pitEnd != NULL) {
|
||||
GfOut("PitEnd: %s\n", pitEnd->name);
|
||||
|
||||
//Search for pit buildings end
|
||||
segName = GfParmGetStrNC(TrackHandle, path2, TRK_ATT_BUILDINGS_STOP, NULL);
|
||||
if (segName != 0) {
|
||||
/* Search backward the last segment with that name */
|
||||
pitBuildingsEnd = theTrack->seg; /* last track segment */
|
||||
found = false;
|
||||
for(i = 0; i < theTrack->nseg; i++) {
|
||||
if (!strcmp(segName, pitBuildingsEnd->name)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
pitBuildingsEnd = pitBuildingsEnd->prev;
|
||||
}
|
||||
if (!found) {
|
||||
pitBuildingsEnd = pitEnd;
|
||||
}
|
||||
} else {
|
||||
pitBuildingsEnd = pitEnd;
|
||||
}
|
||||
GfOut("PitBuildungsEnd: %s\n", pitBuildingsEnd->name);
|
||||
}
|
||||
|
||||
//Decide which side the pit is located
|
||||
const char *paramVal = GfParmGetStr(TrackHandle, path2, TRK_ATT_SIDE, "right");
|
||||
|
|
|
@ -837,10 +837,11 @@ static bool InitPits(tTrack *theTrack, void *TrackHandle) {
|
|||
}
|
||||
pitEntrySeg = pitEntrySeg->prev;
|
||||
}// for i
|
||||
if (!found) {
|
||||
if (found)
|
||||
GfOut("PitEntry: %s\n", pitEntrySeg->name);
|
||||
else
|
||||
pitEntrySeg = NULL;
|
||||
}
|
||||
GfOut("PitEntry: %s\n", pitEntrySeg->name);
|
||||
|
||||
|
||||
//Search for pit exit
|
||||
segName = GfParmGetStrNC(TrackHandle, path2, TRK_ATT_EXIT, NULL);
|
||||
|
@ -856,11 +857,11 @@ static bool InitPits(tTrack *theTrack, void *TrackHandle) {
|
|||
}
|
||||
pitExitSeg = pitExitSeg->prev;
|
||||
}
|
||||
if (!found) {
|
||||
if (found)
|
||||
GfOut("PitExit: %s\n", pitExitSeg->name);
|
||||
else
|
||||
pitExitSeg = NULL;
|
||||
}
|
||||
}
|
||||
GfOut("PitExit: %s\n", pitExitSeg->name);
|
||||
|
||||
//Search for pits start
|
||||
segName = GfParmGetStrNC(TrackHandle, path2, TRK_ATT_START, NULL);
|
||||
|
@ -880,29 +881,31 @@ static bool InitPits(tTrack *theTrack, void *TrackHandle) {
|
|||
pitStart = NULL;
|
||||
}
|
||||
}
|
||||
GfOut("PitStart: %s\n", pitStart->name);
|
||||
if (pitStart != NULL) {
|
||||
GfOut("PitStart: %s\n", pitStart->name);
|
||||
|
||||
//Search for pit buildings start
|
||||
segName = GfParmGetStrNC(TrackHandle, path2, TRK_ATT_BUILDINGS_START, NULL);
|
||||
if (segName != 0) {
|
||||
pitBuildingsStart = theTrack->seg;
|
||||
found = false;
|
||||
for(i = 0; i < theTrack->nseg; i++) {
|
||||
if (!strcmp(segName, pitBuildingsStart->name)) {
|
||||
found = true;
|
||||
} else if (found) {
|
||||
pitBuildingsStart = pitBuildingsStart->next;
|
||||
break;
|
||||
}
|
||||
pitBuildingsStart = pitBuildingsStart->prev;
|
||||
}
|
||||
if (!found) {
|
||||
pitBuildingsStart = pitStart;
|
||||
}
|
||||
} else {
|
||||
pitBuildingsStart = pitStart;
|
||||
}
|
||||
GfOut("PitBuildingStart: %s\n", pitBuildingsStart->name);
|
||||
//Search for pit buildings start
|
||||
segName = GfParmGetStrNC(TrackHandle, path2, TRK_ATT_BUILDINGS_START, NULL);
|
||||
if (segName != 0) {
|
||||
pitBuildingsStart = theTrack->seg;
|
||||
found = false;
|
||||
for(i = 0; i < theTrack->nseg; i++) {
|
||||
if (!strcmp(segName, pitBuildingsStart->name)) {
|
||||
found = true;
|
||||
} else if (found) {
|
||||
pitBuildingsStart = pitBuildingsStart->next;
|
||||
break;
|
||||
}
|
||||
pitBuildingsStart = pitBuildingsStart->prev;
|
||||
}
|
||||
if (!found) {
|
||||
pitBuildingsStart = pitStart;
|
||||
}
|
||||
} else {
|
||||
pitBuildingsStart = pitStart;
|
||||
}
|
||||
GfOut("PitBuildingStart: %s\n", pitBuildingsStart->name);
|
||||
}
|
||||
|
||||
//Search for pits end
|
||||
segName = GfParmGetStrNC(TrackHandle, path2, TRK_ATT_END, NULL);
|
||||
|
@ -927,28 +930,30 @@ static bool InitPits(tTrack *theTrack, void *TrackHandle) {
|
|||
pitEnd = NULL;
|
||||
}
|
||||
}
|
||||
GfOut("PitEnd: %s\n", pitEnd->name);
|
||||
if (pitEnd != NULL) {
|
||||
GfOut("PitEnd: %s\n", pitEnd->name);
|
||||
|
||||
//Search for pit buildings end
|
||||
segName = GfParmGetStrNC(TrackHandle, path2, TRK_ATT_BUILDINGS_STOP, NULL);
|
||||
if (segName != 0) {
|
||||
/* Search backward the last segment with that name */
|
||||
pitBuildingsEnd = theTrack->seg; /* last track segment */
|
||||
found = false;
|
||||
for(i = 0; i < theTrack->nseg; i++) {
|
||||
if (!strcmp(segName, pitBuildingsEnd->name)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
pitBuildingsEnd = pitBuildingsEnd->prev;
|
||||
}
|
||||
if (!found) {
|
||||
pitBuildingsEnd = pitEnd;
|
||||
}
|
||||
} else {
|
||||
pitBuildingsEnd = pitEnd;
|
||||
//Search for pit buildings end
|
||||
segName = GfParmGetStrNC(TrackHandle, path2, TRK_ATT_BUILDINGS_STOP, NULL);
|
||||
if (segName != 0) {
|
||||
/* Search backward the last segment with that name */
|
||||
pitBuildingsEnd = theTrack->seg; /* last track segment */
|
||||
found = false;
|
||||
for(i = 0; i < theTrack->nseg; i++) {
|
||||
if (!strcmp(segName, pitBuildingsEnd->name)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
pitBuildingsEnd = pitBuildingsEnd->prev;
|
||||
}
|
||||
if (!found) {
|
||||
pitBuildingsEnd = pitEnd;
|
||||
}
|
||||
} else {
|
||||
pitBuildingsEnd = pitEnd;
|
||||
}
|
||||
GfOut("PitBuildungsEnd: %s\n", pitBuildingsEnd->name);
|
||||
}
|
||||
GfOut("PitBuildungsEnd: %s\n", pitBuildingsEnd->name);
|
||||
|
||||
//Decide which side the pit is located
|
||||
const char *paramVal = GfParmGetStr(TrackHandle, path2, TRK_ATT_SIDE, "right");
|
||||
|
|
Loading…
Reference in a new issue