Mercurial > mm7
changeset 1897:436553b0603c
_46DF1A_collide_against_actor cleaned up, moved to Actor.h
author | Grumpy7 |
---|---|
date | Sun, 20 Oct 2013 22:58:27 -0700 |
parents | b6a7410ff0ef |
children | dd9d4b7c1199 |
files | Actor.cpp Actor.h Indoor.cpp SpriteObject.cpp mm7_3.cpp mm7_data.h |
diffstat | 6 files changed, 41 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Sun Oct 20 02:52:48 2013 -0700 +++ b/Actor.cpp Sun Oct 20 22:58:27 2013 -0700 @@ -2787,71 +2787,58 @@ } // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int); //----- (0046DF1A) -------------------------------------------------------- -signed int __fastcall _46DF1A_collide_against_actor(int a1, int a2) +bool Actor::_46DF1A_collide_against_actor( int a1, int a2 ) { Actor *v2; // edi@1 unsigned __int16 v3; // ax@1 int v4; // esi@6 - int v5; // ecx@8 - int v6; // eax@10 - int v7; // edx@12 int v8; // ecx@14 int v9; // eax@14 int v10; // ebx@14 int v11; // esi@14 int v12; // ebx@15 int v13; // ebx@17 - unsigned int v14; // eax@20 - signed int result; // eax@21 - int v16; // [sp+Ch] [bp-10h]@1 - int v17; // [sp+10h] [bp-Ch]@14 - int v18; // [sp+14h] [bp-8h]@14 - int v19; // [sp+18h] [bp-4h]@14 - v16 = a1; v2 = &pActors[a1]; v3 = v2->uAIState; - if ( v3 == 11 || v3 == 4 || v3 == 19 || v3 == 5 || v3 == 17 ) - goto LABEL_25; + if ( v3 == Removed || v3 == Dying || v3 == Disabled || v3 == Dead || v3 == Summoned ) + return 0; v4 = v2->uActorRadius; if ( a2 ) v4 = a2; - v5 = v2->vPosition.x; - if ( stru_721530.sMaxX > v5 + v4 - || stru_721530.sMinX < v5 - v4 - || (v6 = v2->vPosition.y, stru_721530.sMaxY > v6 + v4) - || stru_721530.sMinY < v6 - v4 - || (v7 = v2->vPosition.z, stru_721530.sMaxZ > v7 + v2->uActorHeight) - || stru_721530.sMinZ < v7 - || (v8 = v5 - stru_721530.normal.x, - v9 = v6 - stru_721530.normal.y, - v10 = stru_721530.prolly_normal_d + v4, - v17 = stru_721530.prolly_normal_d + v4, - v11 = (v8 * stru_721530.direction.y - v9 * stru_721530.direction.x) >> 16, - v18 = v8, - v19 = v9, - abs((v8 * stru_721530.direction.y - v9 * stru_721530.direction.x) >> 16) > v10) - || (v12 = (v18 * stru_721530.direction.x + v19 * stru_721530.direction.y) >> 16, v12 <= 0) - || (signed int)(((unsigned __int64)(stru_721530.direction.z * (signed __int64)v12) >> 16) + stru_721530.normal.z) < v2->vPosition.z ) + + if (stru_721530.sMaxX > v2->vPosition.x + v4 || + stru_721530.sMinX < v2->vPosition.x - v4 || + stru_721530.sMaxY > v2->vPosition.y + v4 || + stru_721530.sMinY < v2->vPosition.y - v4 || + stru_721530.sMaxZ > v2->vPosition.z + v2->uActorHeight || + stru_721530.sMinZ < v2->vPosition.z) + { + return false; + } + v8 = v2->vPosition.x - stru_721530.normal.x; + v9 = v2->vPosition.y - stru_721530.normal.y; + v10 = stru_721530.prolly_normal_d + v4; + v11 = (v8 * stru_721530.direction.y - v9 * stru_721530.direction.x) >> 16; + v12 = (v8 * stru_721530.direction.x + v9 * stru_721530.direction.y) >> 16; + if ( abs(v11) > v10 || v12 <= 0) { -LABEL_25: - result = 0; + return false; } - else + if (((stru_721530.direction.z * (signed __int64)v12) >> 16) + stru_721530.normal.z < v2->vPosition.z) { - v13 = v12 - integer_sqrt(v17 * v17 - v11 * v11); - if ( v13 < 0 ) - v13 = 0; - if ( v13 < stru_721530.field_7C ) - { - stru_721530.field_7C = v13; - v14 = 8 * v16; - LOBYTE(v14) = PID(OBJECT_Actor,v16); - stru_721530.uFaceID = v14; - } - result = 1; + return false; } - return result; + + v13 = v12 - integer_sqrt(v10 * v10 - v11 * v11); + if ( v13 < 0 ) + v13 = 0; + if ( v13 < stru_721530.field_7C ) + { + stru_721530.field_7C = v13; + stru_721530.uFaceID = PID(OBJECT_Actor,a1); + } + return true; } //----- (00401A91) -------------------------------------------------------- void UpdateActorAI()
--- a/Actor.h Sun Oct 20 02:52:48 2013 -0700 +++ b/Actor.h Sun Oct 20 22:58:27 2013 -0700 @@ -245,6 +245,7 @@ int _43B3E0_CalcDamage(signed int dmgSource); static void AddBloodsplatOnDamageOverlay(unsigned int uActorID, int a2, signed int a3); + static bool _46DF1A_collide_against_actor(int a1, int a2); char pActorName[32]; signed __int16 sNPC_ID;
--- a/Indoor.cpp Sun Oct 20 02:52:48 2013 -0700 +++ b/Indoor.cpp Sun Oct 20 22:58:27 2013 -0700 @@ -3424,7 +3424,7 @@ v28 = abs(pActors[v26].vPosition.y - v0->vPosition.y); v29 = abs(pActors[v26].vPosition.x - v0->vPosition.x); if ( int_get_vector_length(v29, v28, v27) >= v0->uActorRadius + (signed int)pActors[v26].uActorRadius - && _46DF1A_collide_against_actor(v54, 40) ) + && Actor::_46DF1A_collide_against_actor(v54, 40) ) ++v58; v22 = 0; }
--- a/SpriteObject.cpp Sun Oct 20 02:52:48 2013 -0700 +++ b/SpriteObject.cpp Sun Oct 20 22:58:27 2013 -0700 @@ -430,7 +430,7 @@ for (v56 =0; v56 < uNumActors; ++v56) { if ( v20->GetActorsRelation(&pActors[v56]) ) - _46DF1A_collide_against_actor(v56, 0); + Actor::_46DF1A_collide_against_actor(v56, 0); } } @@ -438,7 +438,7 @@ else { for ( i = 0; i < (signed int)uNumActors; ++i ) - _46DF1A_collide_against_actor(i, 0); + Actor::_46DF1A_collide_against_actor(i, 0); } v26 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; v27 = ODM_GetFloorLevel( @@ -712,7 +712,7 @@ //if ( v14 != (unsigned int)(signed __int64)((double)v41 * 0.3333333333333333) ) if( pActors[pSpriteObject->spell_caster_pid >> 3].pMonsterInfo.uID != v39b->pMonsterInfo.uID ) //not sure: pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius - _46DF1A_collide_against_actor(v42, pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius); + Actor::_46DF1A_collide_against_actor(v42, pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius); ++v42; ++v39b;// += 836; } @@ -727,7 +727,7 @@ v39b = pActors.data();//[0].word_000086_some_monster_id; do { - _46DF1A_collide_against_actor(v42++, pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius); + Actor::_46DF1A_collide_against_actor(v42++, pMonsterList->pMonsters[v39b->word_000086_some_monster_id-1].uToHitRadius); ++v39b; } while ( v42 < (signed int)uNumActors );
--- a/mm7_3.cpp Sun Oct 20 02:52:48 2013 -0700 +++ b/mm7_3.cpp Sun Oct 20 22:58:27 2013 -0700 @@ -1093,7 +1093,7 @@ for ( i = 0; v31 < ai_arrays_size; ++v31 ) { v33 = ai_near_actors_ids[v31]; - if ( v33 != v75 && _46DF1A_collide_against_actor(v33, 40) ) + if ( v33 != v75 && Actor::_46DF1A_collide_against_actor(v33, 40) ) ++i; } v71 = i > 1; @@ -1833,7 +1833,7 @@ _46E44E_collide_against_faces_and_portals(1u); _46E0B2_collide_against_decorations(); for ( v80 = 0; v80 < (signed int)uNumActors; ++v80 ) - _46DF1A_collide_against_actor(v80, 0); + Actor::_46DF1A_collide_against_actor(v80, 0); if ( _46F04E_collide_against_portals() ) break; ++v73; @@ -2685,7 +2685,7 @@ _46E26D_collide_against_sprites(v38, v37); _46ED8A_collide_against_sprite_objects(4u); for ( i = 0; i < (signed int)uNumActors; ++i ) - _46DF1A_collide_against_actor(i, 0); + Actor::_46DF1A_collide_against_actor(i, 0); if ( stru_721530.field_7C >= stru_721530.field_6C ) { _angle_x = stru_721530.normal2.x;
--- a/mm7_data.h Sun Oct 20 02:52:48 2013 -0700 +++ b/mm7_data.h Sun Oct 20 22:58:27 2013 -0700 @@ -1282,7 +1282,6 @@ int __fastcall sub_46D8E3(int a1, signed int a2, int a3, int a4); void ODM_GetTerrainNormalAt(int pos_x, int pos_z, Vec3_int_ *out); unsigned int __fastcall sub_46DEF2(signed int a2, unsigned int uLayingItemID); -int __fastcall _46DF1A_collide_against_actor(int, int); // weak void _46E0B2_collide_against_decorations(); void __fastcall _46E26D_collide_against_sprites(signed int a1, signed int a2); int _46E44E_collide_against_faces_and_portals(unsigned int b1); // idb