trackgen: use C++ style casts

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@8525 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 223cafca121c8f55cb5f2f30823c617ee4483d0c
Former-commit-id: da5d5f98002fd6218f0b1cd4adaa5989c5fd3f15
This commit is contained in:
iobyte 2022-09-19 17:46:57 +00:00
parent 4c86572ed1
commit e8d7725eb5

View file

@ -67,7 +67,7 @@ hookNode(char *s)
{ {
tLine *line; tLine *line;
line = (tLine*)calloc(1, sizeof(tLine)); line = reinterpret_cast<tLine*>(calloc(1, sizeof(tLine)));
line->branch = new ssgBranch(); line->branch = new ssgBranch();
if (strncmp(s, "interior", 8) == 0) { if (strncmp(s, "interior", 8) == 0) {
@ -104,18 +104,21 @@ LoadRelief(tTrack *track, void *TrackHandle, const char *reliefFile)
static void static void
countRec(ssgEntity *e, int *nb_vert, int *nb_seg) countRec(ssgEntity *e, int *nb_vert, int *nb_seg)
{ {
if (e->isAKindOf(_SSG_TYPE_BRANCH)) { if (e->isAKindOf(_SSG_TYPE_BRANCH))
ssgBranch *br = (ssgBranch *)e; {
ssgBranch* br = dynamic_cast<ssgBranch*>(e);
for (int i = 0; i < br->getNumKids(); i++) { for (int i = 0; i < br->getNumKids(); i++)
countRec(br->getKid(i), nb_vert, nb_seg); {
} countRec(br->getKid(i), nb_vert, nb_seg);
} else { }
if (e->isAKindOf(_SSG_TYPE_VTXTABLE)) { }
ssgVtxTable *vt = (ssgVtxTable *)e; else if (e->isAKindOf(_SSG_TYPE_VTXTABLE))
*nb_vert += vt->getNumVertices(); {
*nb_seg += vt->getNumLines(); ssgVtxTable* vt = dynamic_cast<ssgVtxTable*>(e);
}
*nb_vert += vt->getNumVertices();
*nb_seg += vt->getNumLines();
} }
} }
@ -146,7 +149,7 @@ CountRelief(bool interior, int *nb_vert, int *nb_seg)
ssgFlatten(br); ssgFlatten(br);
curLine->branch = br2; curLine->branch = br2;
countRec((ssgEntity *)curLine->branch, nb_vert, nb_seg); countRec(dynamic_cast<ssgEntity *>(curLine->branch), nb_vert, nb_seg);
curLine = GF_TAILQ_NEXT(curLine, link); curLine = GF_TAILQ_NEXT(curLine, link);
} }
@ -157,36 +160,34 @@ genRec(ssgEntity *e)
{ {
if (e->isAKindOf(_SSG_TYPE_BRANCH)) if (e->isAKindOf(_SSG_TYPE_BRANCH))
{ {
ssgBranch* br = (ssgBranch*)e; ssgBranch* br = dynamic_cast<ssgBranch*>(e);
for (int i = 0; i < br->getNumKids(); i++) for (int i = 0; i < br->getNumKids(); i++)
{ {
genRec(br->getKid(i)); genRec(br->getKid(i));
} }
} }
else else if (e->isAKindOf(_SSG_TYPE_VTXTABLE))
{ {
if (e->isAKindOf(_SSG_TYPE_VTXTABLE)) ssgVtxTable* vt = dynamic_cast<ssgVtxTable*>(e);
int nv = vt->getNumVertices();
int nl = vt->getNumLines();
int sv = getPointCount();
for (int i = 0; i < nv; i++)
{ {
ssgVtxTable* vt = (ssgVtxTable*)e; float* vtx = vt->getVertex(i);
int nv = vt->getNumVertices();
int nl = vt->getNumLines();
int sv = getPointCount();
for (int i = 0; i < nv; i++) addPoint(vtx[0], vtx[1], vtx[2], GridStep, 100000);
{ }
float* vtx = vt->getVertex(i);
addPoint(vtx[0], vtx[1], vtx[2], GridStep, 100000); for (int i = 0; i < nl; i++)
} {
short vv0, vv1;
for (int i = 0; i < nl; i++) vt->getLine(i, &vv0, &vv1);
{ addSegment(vv0 + sv, vv1 + sv, 100000);
short vv0, vv1;
vt->getLine(i, &vv0, &vv1);
addSegment(vv0 + sv, vv1 + sv, 100000);
}
} }
} }
} }
@ -212,7 +213,7 @@ GenRelief(bool interior)
curLine = GF_TAILQ_FIRST(curHead); curLine = GF_TAILQ_FIRST(curHead);
while (curLine != nullptr) { while (curLine != nullptr) {
genRec((ssgEntity *)curLine->branch); genRec(dynamic_cast<ssgEntity *>(curLine->branch));
curLine = GF_TAILQ_NEXT(curLine, link); curLine = GF_TAILQ_NEXT(curLine, link);
} }