Skip to content

Commit cad8dde

Browse files
authored
Merge pull request #698 from energydrink02/main
Link zRumble and zEntDestructObj
2 parents f155c4f + ad51270 commit cad8dde

File tree

3 files changed

+78
-120
lines changed

3 files changed

+78
-120
lines changed

configure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ def MatchingFor(*versions):
479479
Object(Equivalent, "SB/Game/zEnt.cpp"),
480480
Object(Equivalent, "SB/Game/zEntButton.cpp"),
481481
Object(NonMatching, "SB/Game/zEntCruiseBubble.cpp"),
482-
Object(NonMatching, "SB/Game/zEntDestructObj.cpp"),
482+
Object(Matching, "SB/Game/zEntDestructObj.cpp"),
483483
Object(NonMatching, "SB/Game/zEntHangable.cpp"),
484484
Object(NonMatching, "SB/Game/zEntPickup.cpp"),
485485
Object(NonMatching, "SB/Game/zEntPlayer.cpp", extra_cflags=["-sym on"]),
@@ -511,7 +511,7 @@ def MatchingFor(*versions):
511511
Object(NonMatching, "SB/Game/zPlatform.cpp", extra_cflags=["-sym on"]),
512512
Object(Matching, "SB/Game/zPortal.cpp"),
513513
Object(Matching, "SB/Game/zRenderState.cpp"),
514-
Object(Equivalent, "SB/Game/zRumble.cpp"),
514+
Object(Matching, "SB/Game/zRumble.cpp"),
515515
Object(Equivalent, "SB/Game/zSaveLoad.cpp"),
516516
Object(NonMatching, "SB/Game/zScene.cpp"),
517517
Object(Matching, "SB/Game/zScript.cpp"),

src/SB/Game/zEntDestructObj.cpp

Lines changed: 75 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
#include <types.h>
44

55
static zParEmitter* sEmitDust;
6+
static zParEmitter* sEmitXplo;
7+
static zParEmitter* sEmitWeb;
68
static zParEmitter* sEmitFire;
79
static zParEmitter* sEmitSmoke;
8-
static zParEmitter* sEmitWeb;
9-
static zParEmitter* sEmitXplo;
1010
static zParEmitter* sShrapDefault;
1111

1212
namespace
@@ -408,168 +408,129 @@ void zEntDestructObj_DestroyFX(zEntDestructObj* ent)
408408
}
409409
}
410410

411-
S32 zEntDestructObjEventCB(xBase* from, xBase* to, U32 toEvent, const F32* toParam, xBase* baseUnk3)
411+
S32 zEntDestructObjEventCB(xBase* from, xBase* to, U32 toEvent, const F32* toParam, xBase* toParamWidget)
412412
{
413-
zEntDestructObj* toDobj = (zEntDestructObj*)to;
414-
F32 sp8;
415-
416-
// Shrapnel Asset callbacks
417-
//void (*temp_r12) (zShrapnelAsset*, xModelInstance*, xVec3*, void*);
418-
void (*temp_r12_2)(zEntDestructObj&, void*);
419-
void (*temp_r12_3)(zShrapnelAsset*, xModelInstance*, xVec3*, void (*)(zFrag*, zFragAsset*));
413+
zEntDestructObj* s = (zEntDestructObj*)to;
420414

421-
F32 temp_f1;
422-
U32 temp_r3_2;
423-
zShrapnelAsset* shrapnelDestroyAsset;
424-
xEnt* temp_r4_2;
425-
xModelInstance* temp_r4;
426-
xModelInstance* temp_r4_3;
427-
428-
switch ((en_xEventTags)toEvent)
429-
{
430-
case eEventFastVisible:
415+
switch (toEvent) {
431416
case eEventVisible:
432-
xEntShow((xEnt*)to);
433-
if ((toParam != NULL) && ((s32)(0.5f + toParam[0]) == 0x4D))
434-
{
435-
zFXPopOn(*toDobj, toParam[1], toParam[2]);
417+
case eEventFastVisible:
418+
xEntShow(s);
419+
if (toParam && (S32)(0.5f + toParam[0]) == 77) {
420+
zFXPopOn(*s, toParam[1], toParam[2]);
436421
}
437422
break;
438-
case eEventFastInvisible:
439423
case eEventInvisible:
440-
xEntHide((xEnt*)to);
441-
if ((toParam != NULL) && ((s32)(0.5f + toParam[0]) == 0x4D))
442-
{
443-
zFXPopOff(*toDobj, toParam[1], toParam[2]);
424+
case eEventFastInvisible:
425+
xEntHide(s);
426+
if (toParam && (S32)(0.5f + toParam[0]) == 77) {
427+
zFXPopOff(*s, toParam[1], toParam[2]);
444428
}
445429
break;
446430
case eEventCollisionOn:
447-
toDobj->chkby |= 0x18;
448-
toDobj->bupdate((xEnt*)to, (xVec3*)&toDobj->model->Mat->pos);
431+
s->chkby |= (XENT_COLLTYPE_PLYR | XENT_COLLTYPE_NPC);
432+
s->bupdate(s, (xVec3*)&s->model->Mat->pos);
449433
break;
450434
case eEventCollisionOff:
451-
toDobj->chkby &= 0xE7;
435+
s->chkby &= (U8)~(XENT_COLLTYPE_PLYR | XENT_COLLTYPE_NPC);
452436
break;
453437
case eEventCollision_Visible_On:
454-
toDobj->chkby |= 0x18;
455-
xEntShow((xEnt*)to);
456-
toDobj->bupdate((xEnt*)to, (xVec3*)&toDobj->model->Mat->pos);
457-
if ((toParam != NULL) && ((s32)(0.5f + toParam[0]) == 0x4D))
458-
{
459-
zFXPopOn(*toDobj, toParam[1], toParam[2]);
438+
s->chkby |= (XENT_COLLTYPE_PLYR | XENT_COLLTYPE_NPC);
439+
xEntShow(s);
440+
s->bupdate(s, (xVec3*)&s->model->Mat->pos);
441+
if (toParam && (S32)(0.5f + toParam[0]) == 77) {
442+
zFXPopOn(*s, toParam[1], toParam[2]);
460443
}
461444
break;
462445
case eEventCollision_Visible_Off:
463-
toDobj->chkby &= 0xE7;
464-
xEntHide((xEnt*)to);
465-
if ((toParam != NULL) && ((s32)(0.5f + toParam[0]) == 0x4D))
466-
{
467-
zFXPopOff(*toDobj, toParam[1], toParam[2]);
446+
s->chkby &= (U8)~(XENT_COLLTYPE_PLYR | XENT_COLLTYPE_NPC);
447+
xEntHide(s);
448+
if (toParam && (S32)(0.5f + toParam[0]) == 77) {
449+
zFXPopOff(*s, toParam[1], toParam[2]);
468450
}
469451
break;
470452
case eEventCameraCollideOn:
471-
zCollGeom_CamEnable((xEnt*)to);
453+
zCollGeom_CamEnable(s);
472454
break;
473455
case eEventCameraCollideOff:
474-
zCollGeom_CamDisable((xEnt*)to);
456+
zCollGeom_CamDisable(s);
475457
break;
476-
case eEventTeleportPlayer:
477-
temp_r4 = toDobj->destroy_model;
478-
if (temp_r4 != NULL)
479-
{
480-
SwapModel(toDobj, temp_r4);
458+
case eEventDestroy:
459+
if (s->destroy_model) {
460+
SwapModel(s, s->destroy_model);
461+
} else {
462+
s->chkby &= (U8)~(XENT_COLLTYPE_PLYR | XENT_COLLTYPE_NPC);
463+
xEntHide(s);
481464
}
482-
else
483-
{
484-
toDobj->chkby &= 0xE7;
485-
xEntHide((xEnt*)to);
465+
zEntDestructObj_DestroyFX(s);
466+
s->state = 2;
467+
if (s->shrapnel_destroy && s->shrapnel_destroy->initCB) {
468+
s->shrapnel_destroy->initCB(s->shrapnel_destroy, s->model, NULL, NULL);
486469
}
487-
zEntDestructObj_DestroyFX((zEntDestructObj*)to);
488-
toDobj->state = DOBJ_STATE_DESTROYED;
489-
shrapnelDestroyAsset = toDobj->shrapnel_destroy;
490-
if (shrapnelDestroyAsset != NULL)
491-
{
492-
//temp_r12 = shrapnelDestroyAsset->initCB;
493-
if (shrapnelDestroyAsset->initCB != NULL)
494-
{
495-
shrapnelDestroyAsset->initCB(shrapnelDestroyAsset, toDobj->model, NULL, NULL);
496-
}
497-
}
498-
temp_r12_2 = toDobj->destroy_notify;
499-
if (temp_r12_2 != NULL)
500-
{
501-
temp_r12_2(*toDobj, toDobj->notify_context);
470+
if (s->destroy_notify) {
471+
s->destroy_notify(*s, s->notify_context);
502472
}
503-
temp_r4_2 = toDobj->driver;
504-
if (temp_r4_2 != NULL)
505-
{
506-
temp_r4_2->driving_count = (u8)(temp_r4_2->driving_count - 1);
507-
toDobj->driver = NULL;
473+
if (s->driver) {
474+
s->driver->driving_count--;
475+
s->driver = NULL;
508476
}
509477
break;
510478
case eEventReset:
511-
zEntDestructObj_Reset((zEntDestructObj*)to, globals.sceneCur);
479+
zEntDestructObj_Reset(s, globals.sceneCur);
512480
break;
513-
default:
514-
zEntAnimEvent((zEnt*)to, toEvent, toParam);
481+
case eEventAnimPlay:
482+
case eEventAnimPlayLoop:
483+
case eEventAnimStop:
484+
case eEventAnimPause:
485+
case eEventAnimResume:
486+
case eEventAnimTogglePause:
487+
case eEventAnimPlayRandom:
488+
case eEventAnimPlayMaybe:
489+
zEntAnimEvent(s, toEvent, toParam);
515490
break;
516491
case eEventHit:
517-
temp_r3_2 = toDobj->healthCnt;
518-
if (temp_r3_2 != 0U)
519-
{
520-
toDobj->healthCnt = temp_r3_2 - 1;
521-
if (toDobj->healthCnt != 0U)
522-
{
523-
temp_r4_3 = toDobj->hit_model;
524-
if (temp_r4_3 != NULL)
525-
{
526-
SwapModel(toDobj, temp_r4_3);
527-
}
492+
if (s->healthCnt) {
493+
s->healthCnt--;
494+
if (s->healthCnt && s->hit_model) {
495+
SwapModel(s, s->hit_model);
528496
}
529-
if (toDobj->healthCnt == 0U)
530-
{
531-
zEntEvent(to, to, eEventDestroy);
497+
if (s->healthCnt == 0) {
498+
zEntEvent(s, s, eEventDestroy);
532499
}
533500
}
534501
break;
535502
case eEventSetUpdateDistance:
536-
if ((xUpdateCullMgr*)globals.updateMgr != NULL)
537-
{
538-
temp_f1 = toParam[0];
539-
if (temp_f1 <= 0.0f)
540-
{
541-
xUpdateCull_SetCB(globals.updateMgr, to, xUpdateCull_AlwaysTrueCB, NULL);
542-
}
543-
else
544-
{
545-
sp8 = temp_f1 * temp_f1;
546-
xUpdateCull_SetCB(globals.updateMgr, to, xUpdateCull_DistanceSquaredCB, &sp8);
503+
if (globals.updateMgr) {
504+
if (toParam[0] <= 0.0f) {
505+
xUpdateCull_SetCB(globals.updateMgr, s, xUpdateCull_AlwaysTrueCB, NULL);
506+
} else {
507+
FloatAndVoid dist;
508+
dist.f = SQR(toParam[0]);
509+
xUpdateCull_SetCB(globals.updateMgr, s, xUpdateCull_DistanceSquaredCB, dist.v);
547510
}
548511
}
549512
break;
550513
case eEventHit_BubbleBounce:
551-
zEntDestructObj_Hit((zEntDestructObj*)to, 0x2000U);
514+
zEntDestructObj_Hit(s, 0x2000);
552515
break;
553516
case eEventHit_BubbleBash:
554-
zEntDestructObj_Hit((zEntDestructObj*)to, 0x4000U);
517+
zEntDestructObj_Hit(s, 0x4000);
555518
break;
556519
case eEventHit_PatrickSlam:
557-
zEntDestructObj_Hit((zEntDestructObj*)to, 0x400U);
520+
zEntDestructObj_Hit(s, 0x400);
558521
break;
559522
case eEventHit_Throw:
560-
zEntDestructObj_Hit((zEntDestructObj*)to, 0x800U);
523+
zEntDestructObj_Hit(s, 0x800);
561524
break;
562525
case eEventLaunchShrapnel:
563-
zShrapnelAsset* shrapnelAsset = (zShrapnelAsset*)baseUnk3;
564-
if (baseUnk3 != NULL)
565-
{
566-
temp_r12_3 = shrapnelAsset->initCB;
567-
if (temp_r12_3 != NULL)
568-
{
569-
temp_r12_3(shrapnelAsset, toDobj->model, NULL, NULL);
526+
if (toParamWidget) {
527+
zShrapnelAsset* shrap = (zShrapnelAsset*)toParamWidget;
528+
if (shrap->initCB) {
529+
shrap->initCB(shrap, s->model, NULL, NULL);
570530
}
571531
}
572532
break;
573533
}
574-
return eEventEnable;
534+
535+
return 1;
575536
}

src/SB/Game/zRumble.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,10 @@ void zRumbleStartDistance(S32 pad_id, F32 real_dist, F32 max_dist, _tagRumbleTyp
108108
}
109109
}
110110

111-
// Equivalent: regalloc
112111
void zRumbleStartEntDistance(xEnt* ent, F32 dist, _tagRumbleType type, F32 maxTime)
113112
{
114-
xVec3* ent_pos = xEntGetPos(ent);
115-
xVec3* player_pos = xEntGetPos(&globals.player.ent);
116113
xVec3 ent_player_dist;
117-
xVec3Sub(&ent_player_dist, player_pos, ent_pos);
114+
xVec3Sub(&ent_player_dist, xEntGetPos(&globals.player.ent), xEntGetPos(ent));
118115

119116
zRumbleStartDistance(globals.currentActivePad, SQR(ent_player_dist.x) + SQR(ent_player_dist.z),
120117
SQR(dist), type, maxTime);

0 commit comments

Comments
 (0)