# HG changeset patch # User Grumpy7 # Date 1393121266 -3600 # Node ID 6ab7d7c112bb2b65c837a493f53fb7b7c03fba71 # Parent fd0b2a69741675de30045b2fe3319430e88a7dd2 adding int_get_vector_length calls where the calls were inlined diff -r fd0b2a697416 -r 6ab7d7c112bb Actor.cpp --- a/Actor.cpp Sun Feb 23 00:34:38 2014 +0100 +++ b/Actor.cpp Sun Feb 23 03:07:46 2014 +0100 @@ -3603,12 +3603,10 @@ v61 = projectileSprite->field_60_distance_related_prolly_lod; if ( projectileSprite->spell_id != SPELL_DARK_SOULDRINKER ) { - std::array distances; - distances[0] = abs(pParty->vPosition.x - projectileSprite->vPosition.x); - distances[1] = abs(pParty->vPosition.y - projectileSprite->vPosition.y); - distances[2] = abs(pParty->vPosition.z - projectileSprite->vPosition.z); - std::sort(distances.begin(), distances.end()); - v61 = ((unsigned int)(11 * distances[1]) >> 5) + (distances[0] >> 2) + distances[2]; + int d1 = abs(pParty->vPosition.x - projectileSprite->vPosition.x); + int d2 = abs(pParty->vPosition.y - projectileSprite->vPosition.y); + int d3 = abs(pParty->vPosition.z - projectileSprite->vPosition.z); + v61 = int_get_vector_length(d1, d2, d3); if ( v61 >= 5120 && !(pMonster->uAttributes & 0x400) ) return; @@ -4007,28 +4005,7 @@ for_x = abs(pActors[i].vInitialPosition.x - pParty->vPosition.x); for_y = abs(pActors[i].vInitialPosition.y - pParty->vPosition.y); for_z = abs(pActors[i].vInitialPosition.z - pParty->vPosition.z); - v3 = for_x; - v4 = for_y; - v5 = for_z; - if ( v3 < for_y ) - { - v6 = v3; - v3 = for_y; - v4 = v6; - } - if ( v3 < for_z ) - { - v7 = v3; - v3 = for_z; - v5 = v7; - } - if ( v4 < (signed int)v5 ) - { - v8 = v5; - v5 = v4; - v4 = v8; - } - if ( (signed int)(((unsigned int)(11 * v4) >> 5) + (v5 >> 2) + v3) < distance ) + if ( int_get_vector_length(for_x, for_y, for_z) < distance ) { if ( pActors[i].uAIState != Dead ) { diff -r fd0b2a697416 -r 6ab7d7c112bb CastSpellInfo.cpp --- a/CastSpellInfo.cpp Sun Feb 23 00:34:38 2014 +0100 +++ b/CastSpellInfo.cpp Sun Feb 23 03:07:46 2014 +0100 @@ -905,27 +905,7 @@ dist_X = abs(pActors[mon_id].vPosition.x - pParty->vPosition.x); dist_Y = abs(pActors[mon_id].vPosition.y - pParty->vPosition.y); dist_Z = abs(pActors[mon_id].vPosition.z - pParty->vPosition.z); - int count = dist_X; - new_dist_Y = dist_Y; - if ( dist_X < dist_Y ) - { - v116 = dist_X; - dist_X = dist_Y; - new_dist_Y = v116; - } - if ( dist_X < dist_Z ) - { - v117 = dist_X; - dist_X = dist_Z; - dist_Z = v117; - } - if ( new_dist_Y < dist_Z ) - { - v118 = dist_Z; - dist_Z = new_dist_Y; - new_dist_Y = v118; - } - count = ((unsigned int)(11 * new_dist_Y) >> 5) + (dist_Z >> 2) + dist_X; + int count = int_get_vector_length(dist_X, dist_Y, dist_Z); if ( (double)count <= 307.2 ) { v701.x = 0; diff -r fd0b2a697416 -r 6ab7d7c112bb Indoor.cpp --- a/Indoor.cpp Sun Feb 23 00:34:38 2014 +0100 +++ b/Indoor.cpp Sun Feb 23 03:07:46 2014 +0100 @@ -3662,27 +3662,7 @@ v39 = abs(pParty->vPosition.z - pActors[i].vPosition.z); v38 = abs(pParty->vPosition.y - pActors[i].vPosition.y); v1 = abs(pParty->vPosition.x - pActors[i].vPosition.x); - v2 = v38; - v3 = v39; - if ( v1 < v38 ) - { - v4 = v1; - v1 = v38; - v2 = v4; - } - if ( v1 < v39 ) - { - v5 = v1; - v1 = v39; - v3 = v5; - } - if ( v2 < (signed int)v3 ) - { - v6 = v3; - v3 = v2; - v2 = v6; - } - v7 = ((unsigned int)(11 * v2) >> 5) + (v3 >> 2) + v1; + v7 = int_get_vector_length(v39, v38, v1); v9 = v7 - pActors[i].uActorRadius; if ( v9 < 0 ) v9 = 0; diff -r fd0b2a697416 -r 6ab7d7c112bb LightmapBuilder.cpp --- a/LightmapBuilder.cpp Sun Feb 23 00:34:38 2014 +0100 +++ b/LightmapBuilder.cpp Sun Feb 23 03:07:46 2014 +0100 @@ -221,30 +221,7 @@ auto dist_x = abs(pos->x - v11->field_C08), //v31 dist_y = abs(pos->y - v11->field_C0A), //v32 arg0a dist_z = abs(pos->z - v11->field_C0C); //v33 _v64 - v31 = dist_x; - v32 = dist_y; - v33 = dist_z; - if (v31 < dist_y) - { - v34 = v31; - v31 = dist_y; - v32 = v34; - } - if (v31 < dist_z)//SHIDWORD(v64) ) - { - v35 = v31; - v31 = dist_z;//HIDWORD(v64); - v33 = v35; - } - if ( v32 < (signed int)v33 ) - { - v36 = v33; - v33 = v32; - v32 = v36; - } - v37 = v33 >> 2; - //LODWORD(a5) = ((unsigned int)(11 * v32) >> 5) + v37 + v31; - v38 = (double)(signed)(((unsigned int)(11 * v32) >> 5) + v37 + v31); + v38 = int_get_vector_length(dist_x, dist_y, dist_z); if (v38 > radius) return true; //radius = (1 / radius) * v38; @@ -841,28 +818,7 @@ //v8 = abs((int)a1.x - (signed)LODWORD(v23)); v25 = abs((signed)LODWORD(a1.y) - (signed)_v24); v8 = abs((int)a1.x - (signed)_v23); - LODWORD(a5) = v8; - v9 = v25; - v10 = v26; - if ( v8 < v25 ) - { - v11 = v8; - v8 = v25; - v9 = v11; - } - if ( v8 < v26 ) - { - v12 = v8; - v8 = v26; - v10 = v12; - } - if ( v9 < (signed int)v10 ) - { - v13 = v10; - v10 = v9; - v9 = v13; - } - v14 = (double)(signed int)(((unsigned int)(11 * v9) >> 5) + (v10 >> 2) + v8); + v14 = int_get_vector_length(v26, v25, v8); if ( v14 <= a3 ) { a5 = v14 / a3; diff -r fd0b2a697416 -r 6ab7d7c112bb Outdoor.cpp --- a/Outdoor.cpp Sun Feb 23 00:34:38 2014 +0100 +++ b/Outdoor.cpp Sun Feb 23 03:07:46 2014 +0100 @@ -3139,27 +3139,7 @@ v22 = abs(pParty->vPosition.z - actor->vPosition.z); v21 = abs(pParty->vPosition.y - actor->vPosition.y); v1 = abs(pParty->vPosition.x - actor->vPosition.x); - v2 = v21; - v3 = v22; - if ( v1 < v21 ) - { - v4 = v1; - v1 = v21; - v2 = v4; - } - if ( v1 < v22 ) - { - v5 = v1; - v1 = v22; - v3 = v5; - } - if ( v2 < (signed int)v3 ) - { - v6 = v3; - v3 = v2; - v2 = v6; - } - v7 = ((unsigned int)(11 * v2) >> 5) + (v3 >> 2) + v1; + v7 = int_get_vector_length(v22, v21, v1); //v8 = actor->uActorRadius; v9 = v7 - actor->uActorRadius; //v23 = v7 - v8; diff -r fd0b2a697416 -r 6ab7d7c112bb mm7_2.cpp --- a/mm7_2.cpp Sun Feb 23 00:34:38 2014 +0100 +++ b/mm7_2.cpp Sun Feb 23 03:07:46 2014 +0100 @@ -4511,28 +4511,7 @@ v5 = abs(pActors[i].vPosition.x - pParty->vPosition.x); v17 = abs(pActors[i].vPosition.y - pParty->vPosition.y); v18 = abs(pActors[i].vPosition.z - pParty->vPosition.z); - v6 = v5; - v7 = v17; - v8 = v18; - if ( v6 < v17 ) - { - v9 = v6; - v6 = v17; - v7 = v9; - } - if ( v6 < v18 ) - { - v10 = v6; - v6 = v18; - v8 = v10; - } - if ( v7 < (signed int)v8 ) - { - v11 = v8; - v8 = v7; - v7 = v11; - } - if ( (signed int)(((unsigned int)(11 * v7) >> 5) + (v8 >> 2) + v6) <= a3 ) + if ( int_get_vector_length(v5, v17, v18) <= a3 ) { if ( pActors[i].uAIState != Dead && pActors[i].uAIState != Dying && pActors[i].uAIState != Removed && pActors[i].uAIState != Disabled && pActors[i].uAIState != Summoned ) diff -r fd0b2a697416 -r 6ab7d7c112bb mm7_3.cpp --- a/mm7_3.cpp Sun Feb 23 00:34:38 2014 +0100 +++ b/mm7_3.cpp Sun Feb 23 03:07:46 2014 +0100 @@ -1047,28 +1047,7 @@ v12 = abs(pParty->vPosition.x - pSpriteObjects[i].vPosition.x); v18 = abs(pParty->vPosition.y - pSpriteObjects[i].vPosition.y); v19 = abs(pParty->vPosition.z - pSpriteObjects[i].vPosition.z); - v13 = v12; - v14 = v18; - v15 = v19; - if ( v12 < v18 ) - { - v13 = v18; - v14 = v12; - } - if ( v13 < v19 ) - { - v16 = v13; - v13 = v19; - v15 = v16; - } - if ( v14 < (signed int)v15 ) - { - v17 = v15; - v15 = v14; - v14 = v17; - } - v0 = (unsigned int)(11 * v14) >> 5; - if ( (signed int)(v0 + (v15 >> 2) + v13) <= 5120 ) + if ( int_get_vector_length(v12, v18, v19) <= 5120 ) continue; SpriteObject::OnInteraction(i); continue; diff -r fd0b2a697416 -r 6ab7d7c112bb mm7_4.cpp --- a/mm7_4.cpp Sun Feb 23 00:34:38 2014 +0100 +++ b/mm7_4.cpp Sun Feb 23 03:07:46 2014 +0100 @@ -2463,4 +2463,4 @@ } } return test; -} \ No newline at end of file +} diff -r fd0b2a697416 -r 6ab7d7c112bb mm7_5.cpp --- a/mm7_5.cpp Sun Feb 23 00:34:38 2014 +0100 +++ b/mm7_5.cpp Sun Feb 23 03:07:46 2014 +0100 @@ -518,28 +518,7 @@ v39 = abs(v16->vPosition.z - z); if ( v39 <= v16->uRadius ) { - v18 = v17; - v19 = v42; - v20 = v39; - if ( v18 < v42 ) - { - v21 = v18; - v18 = v42; - v19 = v21; - } - if ( v18 < v39 ) - { - v22 = v18; - v18 = v39; - v20 = v22; - } - if ( v19 < (signed int)v20 ) - { - v23 = v20; - v20 = v19; - v19 = v23; - } - v44 = ((unsigned int)(11 * v19) >> 5) + (v20 >> 2) + v18; + v44 = int_get_vector_length(v17, v42, v39); v24 = v16->uRadius; if ( (signed int)v44 < v24 ) v6 += ((unsigned __int64)(30i64 * (signed int)(v44 << 16) / v24) >> 16) - 30; @@ -562,28 +541,7 @@ v37 = abs(p->vPosition.z - z); if ( v37 <= p->uRadius) { - v27 = v26; - v28 = v40; - v29 = v37; - if ( v27 < v40 ) - { - v30 = v27; - v27 = v40; - v28 = v30; - } - if ( v27 < v37 ) - { - v31 = v27; - v27 = v37; - v29 = v31; - } - if ( v28 < (signed int)v29 ) - { - v32 = v29; - v29 = v28; - v28 = v32; - } - v45 = ((unsigned int)(11 * v28) >> 5) + (v29 >> 2) + v27; + v45 = int_get_vector_length(v26, v40, v37); v33 = p->uRadius; if ( (signed int)v45 < v33 ) v6 += ((unsigned __int64)(30i64 * (signed int)(v45 << 16) / v33) >> 16) - 30;