- fixed sd-trackgen by Simon
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@5916 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 30e2929eb097966d3c9c4e9ec3db900cb2538a09 Former-commit-id: c26aa1e81edf86ea8bd68278213e209a4d255301
This commit is contained in:
parent
3325db1621
commit
22dd84ac35
1 changed files with 29 additions and 14 deletions
|
@ -106,7 +106,8 @@ static void initPits(tTrack *theTrack, void *TrackHandle, tTrackPitInfo *pits) {
|
||||||
// In TR_PIT_NO_BUILDING, the pit positions are located exactly the same,
|
// In TR_PIT_NO_BUILDING, the pit positions are located exactly the same,
|
||||||
// as in the TR_PIT_ON_TRACK_SIDE. It differs only later, showing/not showing
|
// as in the TR_PIT_ON_TRACK_SIDE. It differs only later, showing/not showing
|
||||||
// the buildings.
|
// the buildings.
|
||||||
switch (pits->type) {
|
switch (pits->type)
|
||||||
|
{
|
||||||
case TR_PIT_ON_TRACK_SIDE:
|
case TR_PIT_ON_TRACK_SIDE:
|
||||||
case TR_PIT_NO_BUILDING:
|
case TR_PIT_NO_BUILDING:
|
||||||
pits->driversPits = (tTrackOwnPit*)calloc(pits->nPitSeg, sizeof(tTrackOwnPit));
|
pits->driversPits = (tTrackOwnPit*)calloc(pits->nPitSeg, sizeof(tTrackOwnPit));
|
||||||
|
@ -118,17 +119,21 @@ static void initPits(tTrack *theTrack, void *TrackHandle, tTrackPitInfo *pits) {
|
||||||
if (segName != 0) {
|
if (segName != 0) {
|
||||||
pitBuildingsStart = theTrack->seg;
|
pitBuildingsStart = theTrack->seg;
|
||||||
found = false;
|
found = false;
|
||||||
for(i = 0; i < theTrack->nseg; i++) {
|
for(i = 0; i < theTrack->nseg; i++)
|
||||||
if (!strcmp(segName, pitBuildingsStart->name)) {
|
{
|
||||||
|
if (!strcmp(segName, pitBuildingsStart->name))
|
||||||
|
{
|
||||||
found = true;
|
found = true;
|
||||||
} else if (found) {
|
} else if (found)
|
||||||
|
{
|
||||||
pitBuildingsStart = pitBuildingsStart->next;
|
pitBuildingsStart = pitBuildingsStart->next;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pitBuildingsStart = pitBuildingsStart->prev;
|
pitBuildingsStart = pitBuildingsStart->prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found)
|
||||||
|
{
|
||||||
pitBuildingsStart = NULL;
|
pitBuildingsStart = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,16 +147,20 @@ static void initPits(tTrack *theTrack, void *TrackHandle, tTrackPitInfo *pits) {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
toStart = 0;
|
toStart = 0;
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < pits->nPitSeg) {
|
while (i < pits->nPitSeg)
|
||||||
if (changeSeg) {
|
{
|
||||||
|
if (changeSeg)
|
||||||
|
{
|
||||||
changeSeg = false;
|
changeSeg = false;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
curMainSeg = curMainSeg->next;
|
curMainSeg = curMainSeg->next;
|
||||||
|
|
||||||
switch (pits->side) {
|
switch (pits->side)
|
||||||
|
{
|
||||||
case TR_RGT:
|
case TR_RGT:
|
||||||
curPitSeg = curMainSeg->rside;
|
curPitSeg = curMainSeg->rside;
|
||||||
if (curPitSeg->rside) {
|
if (curPitSeg->rside)
|
||||||
|
{
|
||||||
offset = curPitSeg->width;
|
offset = curPitSeg->width;
|
||||||
curPitSeg = curPitSeg->rside;
|
curPitSeg = curPitSeg->rside;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +168,8 @@ static void initPits(tTrack *theTrack, void *TrackHandle, tTrackPitInfo *pits) {
|
||||||
|
|
||||||
case TR_LFT:
|
case TR_LFT:
|
||||||
curPitSeg = curMainSeg->lside;
|
curPitSeg = curMainSeg->lside;
|
||||||
if (curPitSeg->lside) {
|
if (curPitSeg->lside)
|
||||||
|
{
|
||||||
offset = curPitSeg->width;
|
offset = curPitSeg->width;
|
||||||
curPitSeg = curPitSeg->lside;
|
curPitSeg = curPitSeg->lside;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +177,8 @@ static void initPits(tTrack *theTrack, void *TrackHandle, tTrackPitInfo *pits) {
|
||||||
}
|
}
|
||||||
|
|
||||||
curPos.seg = curMainSeg;
|
curPos.seg = curMainSeg;
|
||||||
if (toStart >= curMainSeg->length) {
|
if (toStart >= curMainSeg->length)
|
||||||
|
{
|
||||||
toStart -= curMainSeg->length;
|
toStart -= curMainSeg->length;
|
||||||
changeSeg = true;
|
changeSeg = true;
|
||||||
continue;
|
continue;
|
||||||
|
@ -197,11 +208,12 @@ static void initPits(tTrack *theTrack, void *TrackHandle, tTrackPitInfo *pits) {
|
||||||
//TODO(kilo) get rid of following line when above feature is ready
|
//TODO(kilo) get rid of following line when above feature is ready
|
||||||
curPos.toStart = toStart;
|
curPos.toStart = toStart;
|
||||||
|
|
||||||
switch (pits->side) {
|
switch (pits->side)
|
||||||
|
{
|
||||||
case TR_RGT:
|
case TR_RGT:
|
||||||
curPos.toRight = -offset - RtTrackGetWidth(curPitSeg, toStart);
|
curPos.toRight = -offset - RtTrackGetWidth(curPitSeg, toStart);
|
||||||
curPos.toLeft = curMainSeg->width - curPos.toRight;
|
curPos.toLeft = curMainSeg->width - curPos.toRight;
|
||||||
curPos.toMiddle = curMainSeg->width / 2.0 - curPos.toRight;
|
curPos.toMiddle = - curMainSeg->width / 2.0 + curPos.toRight;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TR_LFT:
|
case TR_LFT:
|
||||||
|
@ -213,11 +225,14 @@ static void initPits(tTrack *theTrack, void *TrackHandle, tTrackPitInfo *pits) {
|
||||||
|
|
||||||
memcpy(&(pits->driversPits[i].pos), &curPos, sizeof(curPos));
|
memcpy(&(pits->driversPits[i].pos), &curPos, sizeof(curPos));
|
||||||
toStart += pits->len;
|
toStart += pits->len;
|
||||||
if (toStart >= curMainSeg->length) {
|
if (toStart >= curMainSeg->length)
|
||||||
|
{
|
||||||
toStart -= curMainSeg->length;
|
toStart -= curMainSeg->length;
|
||||||
changeSeg = true;
|
changeSeg = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
}//while i
|
}//while i
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue