Skip to content

Commit 798ff87

Browse files
committed
Some touch-ups
1 parent c8457cb commit 798ff87

File tree

1 file changed

+57
-43
lines changed

1 file changed

+57
-43
lines changed

src/SB/Core/x/xEntBoulder.cpp

Lines changed: 57 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,12 @@ void xEntBoulder_Render(xEnt* ent)
6262
shadVec.x = model->Mat->pos.x;
6363
shadVec.y = model->Mat->pos.y - 10.0f;
6464
shadVec.z = model->Mat->pos.z;
65+
6566
if (iModelCullPlusShadow(model->Data, model->Mat, &shadVec, &shadowResult) == 0)
6667
{
6768
xModelRender(model);
6869
}
70+
6971
if (shadowResult == 0)
7072
{
7173
if (ent->flags & 0x10)
@@ -415,18 +417,20 @@ void xEntBoulder_Update(xEntBoulder* ent, xScene* sc, F32 dt)
415417
}
416418
}
417419

418-
if (boul->baseType == eBaseTypeButton)
420+
_zEntButton* butt = (_zEntButton*)boul;
421+
if (butt->baseType == eBaseTypeButton)
419422
{
420-
zEntButton_Press((_zEntButton*)boul, 8);
421-
zEntButton_Hold((_zEntButton*)boul, 0x1000);
423+
zEntButton_Press(butt, 8);
424+
zEntButton_Hold(butt, 0x1000);
422425
}
423426

427+
zPlatform* plat = ((zPlatform*)(boul));
424428
if
425429
(
426430
(ent == globals.player.bubblebowl) &&
427-
(boul->moreFlags & 0x10) &&
428-
(boul->baseType == eBaseTypePlatform) &&
429-
(boul->subType == 0x0C && (((zPlatform*)(boul))->passet->paddle.paddleFlags & 0x10))
431+
(plat->moreFlags & 0x10) &&
432+
(plat->baseType == eBaseTypePlatform) &&
433+
(plat->subType == ZPLATFORM_SUBTYPE_PADDLE && (plat->passet->paddle.paddleFlags & 0x10))
430434
)
431435
{
432436
zPlatform_PaddleCollide(&ent->collis->colls[i], (xVec3 *)(&ent->model->Mat->pos), &ent->vel, 1);
@@ -572,7 +576,9 @@ void xEntBoulder_Update(xEntBoulder* ent, xScene* sc, F32 dt)
572576
xVec3AddScaled(&sphDist, &scaleVel, -ent->basset->friction * dt);
573577
}
574578
}
579+
575580
xVec3Copy(&ent->vel, &sphDist);
581+
576582
if (numDepens != 0)
577583
{
578584
if (xVec3Length2(&depen) < 0.001f)
@@ -702,8 +708,8 @@ S32 xEntBoulder_KilledBySurface(xEntBoulder* ent, xScene* sc, F32 dt)
702708

703709
if ((ent->basset->flags & 0x40) && (coll->optr != NULL) && (zGooIs((xEnt*)coll->optr, temp, 0)))
704710
{
705-
xVec3AddScaled(&ent->vel, &coll->norm, (-(ent->basset->bounce + 1.0f) * xVec3Dot(&ent->vel, &coll->norm)));
706-
zEntEvent((xBase *)ent, 0x25);
711+
xVec3AddScaled(&ent->vel, &coll->norm, -(ent->basset->bounce + 1.0f) * xVec3Dot(&ent->vel, &coll->norm));
712+
zEntEvent(ent, eEventKill);
707713
return 1;
708714
}
709715

@@ -734,7 +740,7 @@ S32 xEntBoulder_KilledBySurface(xEntBoulder* ent, xScene* sc, F32 dt)
734740
if (ent->hitpoints <= 0)
735741
{
736742
xVec3AddScaled(&ent->vel, &coll->norm, -(ent->basset->bounce + 1.0f) * xVec3Dot(&ent->vel, &coll->norm));
737-
zEntEvent((xBase *)ent, eEventKill);
743+
zEntEvent(ent, eEventKill);
738744
return 1;
739745
}
740746
break;
@@ -871,16 +877,21 @@ void xEntBoulder_Reset(xEntBoulder* boul, xScene* sc)
871877
boul->penby = 0x10;
872878
boul->collis_chk = 0x2e;
873879
boul->collis_pen = 0;
880+
874881
xEntReset(boul);
882+
875883
if ((boul->id == 0x5f2e37b4) || (boul->id + 0xa0d1c84b <= 1) || (boul->id == 0x5f2e37b7))
876884
{
877885
boul->flags |= 0x10;
878886
}
887+
879888
xVec3Init(&boul->force, 0.0f, 0.0f, 0.0f);
880889
xVec3Init(&boul->instForce, 0.0f, 0.0f, 0.0f);
881890
xVec3Init(&boul->vel, 0.0f, 0.0f, 0.0f);
882891
xVec3Init(&boul->rotVec, 1.0f, 0.0f, 0.0f);
892+
883893
boul->angVel = 0.0f;
894+
884895
if (boul->basset->flags & 0x200)
885896
{
886897
boul->timeToLive = boul->basset->killtimer;
@@ -889,8 +900,10 @@ void xEntBoulder_Reset(xEntBoulder* boul, xScene* sc)
889900
{
890901
boul->timeToLive = -1.0f;
891902
}
903+
892904
boul->hitpoints = boul->basset->hitpoints;
893905
xEntBoulder_RealBUpdate(boul, (xVec3 *)&boul->model->Mat->pos);
906+
894907
if ((globals.sceneCur->sceneID == 'BC04') && (boul->id == xStrHash("BALL_BOULDER")))
895908
{
896909
boul->collis_chk &= 0xf7;
@@ -944,9 +957,9 @@ void xBoulderGenerator_Init(xBoulderGenerator* bg, xBoulderGeneratorAsset* asset
944957
bg->lengthOfInitVel = xVec3Length(&bg->bgasset->initvel);
945958
if (bg->lengthOfInitVel > 1e-05f)
946959
{
947-
(bg->perp1).x = (bg->bgasset->initvel).z - (bg->bgasset->initvel).y;
948-
(bg->perp1).y = (bg->bgasset->initvel).x - (bg->bgasset->initvel).z;
949-
(bg->perp1).z = (bg->bgasset->initvel).y - (bg->bgasset->initvel).x;
960+
bg->perp1.x = bg->bgasset->initvel.z - bg->bgasset->initvel.y;
961+
bg->perp1.y = bg->bgasset->initvel.x - bg->bgasset->initvel.z;
962+
bg->perp1.z = bg->bgasset->initvel.y - bg->bgasset->initvel.x;
950963
xVec3Normalize(&bg->perp1, &bg->perp1);
951964
xVec3Cross(&bg->perp2, &bg->bgasset->initvel, &bg->perp1);
952965
xVec3SMulBy(&bg->perp1, bg->lengthOfInitVel);
@@ -975,70 +988,70 @@ static void BoulderGen_GiveBirth(xBoulderGenerator* gen, S32 param)
975988

976989
static S32 GetBoulderForGenerating(xBoulderGenerator* bg)
977990
{
978-
// TODO: Variable names.
979-
S32 r31;
980-
S32 r30;
981-
S32 r29;
982-
S32 r28 = -1;
983-
S32 blah = bg->numBoulders >> 1;
984-
985-
for (r29 = 0, r31 = bg->numBoulders; r29 < r31; r29++)
991+
S32 numList;
992+
S32 j;
993+
S32 i;
994+
S32 oldestCulled = -1;
995+
S32 minAge = bg->numBoulders >> 1;
996+
997+
for (i = 0, numList = bg->numBoulders; i < numList; i++)
986998
{
987-
r30 = r29 + bg->nextBoulder;
988-
if (r30 >= r31)
999+
j = i + bg->nextBoulder;
1000+
1001+
if (j >= numList)
9891002
{
990-
r30 -= r31;
1003+
j -= numList;
9911004
}
9921005

993-
if (!xEntIsVisible(bg->boulderList[r30]))
1006+
if (!xEntIsVisible(bg->boulderList[j]))
9941007
{
9951008
break;
9961009
}
9971010

998-
if (bg->boulderAges[r30] < blah)
1011+
if (bg->boulderAges[j] < minAge)
9991012
{
1000-
1013+
// :^)
10011014
}
1002-
else if (r28 < 0)
1015+
else if (oldestCulled < 0)
10031016
{
1004-
r28 = r30;
1017+
oldestCulled = j;
10051018
}
1006-
else if (bg->boulderList[r28]->isCulled)
1019+
else if (bg->boulderList[oldestCulled]->isCulled)
10071020
{
1008-
if (bg->boulderList[r30]->isCulled && (bg->boulderAges[r28] < bg->boulderAges[r30]))
1021+
if (bg->boulderList[j]->isCulled && (bg->boulderAges[oldestCulled] < bg->boulderAges[j]))
10091022
{
1010-
r28 = r30;
1023+
oldestCulled = j;
10111024
}
10121025
}
1013-
else if (bg->boulderList[r30]->isCulled || (bg->boulderAges[r28] < bg->boulderAges[r30]))
1026+
else if (bg->boulderList[j]->isCulled || (bg->boulderAges[oldestCulled] < bg->boulderAges[j]))
10141027
{
1015-
r28 = r30;
1028+
oldestCulled = j;
10161029
}
10171030
}
10181031

1019-
if (r29 == r31)
1032+
if (i == numList)
10201033
{
1021-
if (r28 < 0)
1034+
if (oldestCulled < 0)
10221035
{
1023-
r30 = (r31 - 1) * xurand();
1024-
if (r30 >= r31)
1036+
j = (numList - 1) * xurand();
1037+
if (j >= numList)
10251038
{
1026-
r30 = r31 - 1;
1039+
j = numList - 1;
10271040
}
10281041
}
10291042
else
10301043
{
1031-
r30 = r28;
1044+
j = oldestCulled;
10321045
}
10331046
}
10341047

1035-
bg->nextBoulder = r30 + 1;
1036-
if (bg->nextBoulder >= r31)
1048+
bg->nextBoulder = j + 1;
1049+
if (bg->nextBoulder >= numList)
10371050
{
10381051
bg->nextBoulder = 0;
10391052
}
10401053

1041-
return r30;
1054+
return j;
10421055
}
10431056

10441057
void xBoulderGenerator_Launch(xBoulderGenerator* bg, xVec3* pnt, F32 t)
@@ -1050,7 +1063,7 @@ void xBoulderGenerator_Launch(xBoulderGenerator* bg, xVec3* pnt, F32 t)
10501063
if ((b != (xEntBoulder*)bg->objectPtr) || (!xEntIsVisible(b)))
10511064
{
10521065
xEntBoulder_Reset(b, globals.sceneCur);
1053-
zEntEvent((xBase *)b, 0x218);
1066+
zEntEvent(b, eEventBorn);
10541067
b->update = (void(*)(xEnt*, xScene*, F32))xEntBoulder_Update;
10551068
if (bg->isMarker)
10561069
{
@@ -1064,6 +1077,7 @@ void xBoulderGenerator_Launch(xBoulderGenerator* bg, xVec3* pnt, F32 t)
10641077
xVec3Copy(&b->rotVec, &bg->bgasset->initaxis);
10651078
b->angVel = bg->bgasset->angvel;
10661079
}
1080+
10671081
invTime = (1.0f / t);
10681082
b->vel.x = invTime * (pnt[0].x - b->model->Mat->pos.x);
10691083
b->vel.z = invTime * (pnt[0].z - b->model->Mat->pos.z);

0 commit comments

Comments
 (0)