diff --git a/src/Engine/sithCollision.c b/src/Engine/sithCollision.c index c0f6c6766..d4dcfac70 100644 --- a/src/Engine/sithCollision.c +++ b/src/Engine/sithCollision.c @@ -225,8 +225,6 @@ float sithCollision_UpdateSectorThingCollision(sithSector *a1, sithThing *sender sithThing *v8; // ebp int v9; // ebx int v10; // eax - int v11; // eax - int v12; // edx sithThing *v13; // ecx sithThing *v14; // eax sithThing *v15; // ecx @@ -263,17 +261,15 @@ float sithCollision_UpdateSectorThingCollision(sithSector *a1, sithThing *sender goto LABEL_41; if ( v8 != v7 ) { - v11 = v8->type; - v12 = v7->type; - if ( sithCollision_collisionHandlers[12 * v11 + v12].handler ) + if ( sithCollision_collisionHandlers[12 * v8->type + v7->type].handler ) { if ( (v8->thingflags & SITH_TF_DEAD) == 0 && (v7->thingflags & SITH_TF_DEAD) == 0 - && (v11 != SITH_THING_WEAPON + && (v8->type != SITH_THING_WEAPON || (v8->actorParams.typeflags & THING_TYPEFLAGS_1) == 0 || ((v13 = v8->prev_thing) == 0 || (v14 = v7->prev_thing) == 0 || v13 != v14 || v8->child_signature != v7->child_signature) && (v13 != v7 || v8->child_signature != v7->signature)) - && (v12 != SITH_THING_WEAPON + && (v7->type != SITH_THING_WEAPON || (v7->actorParams.typeflags & THING_TYPEFLAGS_1) == 0 || ((v15 = v7->prev_thing) == 0 || (v16 = v8->prev_thing) == 0 || v15 != v16 || v7->child_signature != v8->child_signature) && (v15 != v8 || v7->child_signature != v8->signature)) ) @@ -656,16 +652,12 @@ float sithCollision_UpdateThingCollision(sithThing *a3, rdVector3 *a2, float a6, int v35; // eax int v36; // eax sithSurface *v37; // eax - int (__cdecl *v38)(sithThing *, sithSurface *, sithCollisionSearchEntry *); // eax double v44; // st7 //char v46; // c3 //char v49; // c0 //char v52; // c0 sithThing *i; // esi - sithSector *v58; // eax - sithSector *v59; // ecx int v61; // eax - float amounta; // [esp+0h] [ebp-54h] sithSurface *amount; // [esp+0h] [ebp-54h] float v64; // [esp+18h] [ebp-3Ch] float v65; // [esp+1Ch] [ebp-38h] @@ -715,8 +707,7 @@ float sithCollision_UpdateThingCollision(sithThing *a3, rdVector3 *a2, float a6, LABEL_20: if ( (v5->thingflags & SITH_TF_NOIMPACTDAMAGE) == 0 ) { - amounta = (a6 - v11) * 100.0; - sithThing_Damage(v10, v5, amounta, 1); + sithThing_Damage(v10, v5, (a6 - v11) * 100.0, 1); } a6 = v11; } @@ -796,7 +787,7 @@ float sithCollision_UpdateThingCollision(sithThing *a3, rdVector3 *a2, float a6, rdVector_Scale3(&v5->field_268, &direction, v25); if ( v5->moveType == SITH_MT_PHYSICS && (v5->physicsParams.physflags & 0x20) != 0 - && (v5->physicsParams.addedVelocity.x != 0.0 || v5->physicsParams.addedVelocity.y != 0.0 || v5->physicsParams.addedVelocity.z != 0.0) ) + && (!rdVector_IsZero3(&v5->physicsParams.addedVelocity)) ) { v30 = 1.0 - v19->distance / a6; v65 = v30; @@ -828,9 +819,8 @@ float sithCollision_UpdateThingCollision(sithThing *a3, rdVector3 *a2, float a6, else { amount = v19->surface; - v38 = (int (__cdecl *)(sithThing *, sithSurface *, sithCollisionSearchEntry *))sithCollision_funcList[v5->type]; - if ( v38 ) - v36 = v38(v5, amount, v19); + if ( sithCollision_funcList[v5->type] ) + v36 = sithCollision_funcList[v5->type](v5, amount, v19); else v36 = sithCollision_DefaultHitHandler(v5, amount, v19); } @@ -888,11 +878,9 @@ float sithCollision_UpdateThingCollision(sithThing *a3, rdVector3 *a2, float a6, if ( (i->attach_flags & ATTACHFLAGS_THING_RELATIVE) != 0 ) { rdMatrix_TransformVector34(&i->position, &i->field_4C, &v5->lookOrientation); - v58 = v5->sector; - v59 = i->sector; rdVector_Add3Acc(&i->position, &v5->position); - if ( v59 != v58 ) - sithThing_MoveToSector(i, v58, 0); + if ( i->sector != v5->sector ) + sithThing_MoveToSector(i, v5->sector, 0); } } if ( v5->moveType == SITH_MT_PHYSICS ) diff --git a/src/Engine/sithIntersect.c b/src/Engine/sithIntersect.c index 5328571e6..7e5e313e3 100644 --- a/src/Engine/sithIntersect.c +++ b/src/Engine/sithIntersect.c @@ -561,14 +561,13 @@ int sithIntersect_sub_508990(rdVector3 *a1, float a2, rdFace *a3, rdVector3 *a4, int v11; // eax rdVector3 *v14; // esi rdVector3 *v15; // edi - long double v16; // st7 + double v16; // st7 //char v18; // c0 int v19; // ecx double v20; // st6 double v21; // st5 double v22; // st7 - long double v24; // st6 - float v26; // [esp+0h] [ebp-30h] + double v24; // st6 float v27; // [esp+4h] [ebp-2Ch] int i; // [esp+8h] [ebp-28h] rdVector3 v29; // [esp+Ch] [ebp-24h] @@ -592,13 +591,12 @@ int sithIntersect_sub_508990(rdVector3 *a1, float a2, rdFace *a3, rdVector3 *a4, rdVector_Sub3(&a1a, v15, v14); v16 = rdVector_Normalize3Acc(&a1a); v34 = a1a.x * (a1->x - a4[v10[v8]].x) + a1a.y * (a1->y - a4[v10[v8]].y) + a1a.z * (a1->z - a4[v10[v8]].z); - v26 = v16; - if ( v34 > a2 && v34 - a2 <= v26 ) + if ( -a2 <= v34 && v34 - a2 <= v16 ) { v19 = 16; if ( v34 >= 0.0 ) { - if ( v34 <= (double)v26 ) + if ( v34 <= (double)v16 ) { v29.x = v34 * a1a.x + v14->x; v29.y = v34 * a1a.y + v14->y; diff --git a/src/types.h b/src/types.h index 6728532e4..cf8a990e7 100644 --- a/src/types.h +++ b/src/types.h @@ -486,6 +486,7 @@ typedef int (*sithMultiHandler_t)(); typedef int (*stdPalEffectSetPaletteFunc_t)(uint8_t*); typedef int (*sithAICommandFunc_t)(sithActor *actor, sithAIClassEntry *a8, sithActorInstinct *a3, int b, intptr_t a4); typedef int (*sithControlEnumFunc_t)(int inputFuncIdx, const char *pInputFuncStr, uint32_t a3, int dxKeyNum, uint32_t a5, int a6, stdControlKeyInfoEntry* pControlEntry, Darray* pDarr); +typedef int (*sithCollisionHitHandler_t)(sithThing *, sithSurface *, sithCollisionSearchEntry *); // Define some maximums here #define SITHBIN_NUMBINS (200) diff --git a/symbols.syms b/symbols.syms index a62fe8ac6..e3a018fdd 100644 --- a/symbols.syms +++ b/symbols.syms @@ -695,7 +695,7 @@ jkPlayer_tipMat 0x00860580 char[32] sithCollision_stackIdk 0x847F28 int[4] sithCollision_collisionHandlers 0x00847F38 sithCollisionEntry[144] -sithCollision_funcList 0x8485F8 void*[12] +sithCollision_funcList 0x8485F8 sithCollisionHitHandler_t[12] sithCollision_searchStack 0x00848628 sithCollisionSearchResult[4] sithCollision_searchNumResults 0x84DA28 int[4] sithCollision_searchStackIdx 0x0054BA90 int = -1