Mercurial > mm7
diff mm7_3.cpp @ 139:7eeea515f5ff
Refactored strafe
author | Nomad |
---|---|
date | Tue, 12 Feb 2013 00:58:00 +0200 |
parents | a8ec7e1e18b6 |
children | f4d7a9a8c363 2b0c652cc165 |
line wrap: on
line diff
--- a/mm7_3.cpp Tue Feb 12 00:22:30 2013 +0200 +++ b/mm7_3.cpp Tue Feb 12 00:58:00 2013 +0200 @@ -3003,14 +3003,14 @@ int v6; // esi@45 ODMFace *v7; // ecx@45 //unsigned int v8; // eax@71 - double v9; // st7@72 + //double v9; // st7@72 //signed __int64 v10; // qax@74 - double v11; // st7@75 - int v12; // ecx@77 - int v13; // eax@84 - double v14; // st7@84 - int v15; // eax@87 - double v16; // st7@87 + //double v11; // st7@75 + //int v12; // ecx@77 + //int v13; // eax@84 + //double v14; // st7@84 + //int v15; // eax@87 + //double v16; // st7@87 int v17; // eax@88 double v18; // st7@88 int v19; // eax@89 @@ -3311,7 +3311,7 @@ break; case PARTY_FlyDown: - if ( (signed __int64)pParty->pPartyBuffs[7].uExpireTime > 0 || bUnderwater == 1 ) + if (pParty->FlyActive() || bUnderwater) { pParty->bFlying = 0; if ( bUnderwater @@ -3331,85 +3331,86 @@ } } } - goto LABEL_118; + break; + case PARTY_TurnLeft: - //v8 = uTurnSpeed; - if ( uTurnSpeed ) - { - v12 = uTurnSpeed + _angle_y; - _angle_y = stru_5C6E00->uDoublePiMask & v12; - } - else - { - v9 = (double)dturn * fTurnSpeedMultiplier; - _angle_y = stru_5C6E00->uDoublePiMask & (_angle_y + (unsigned __int64)(signed __int64)v9); - } - break; + if (uTurnSpeed) + _angle_y += uTurnSpeed; //descrete turn + else + _angle_y += dturn * fTurnSpeedMultiplier; // time-based smooth turn + + _angle_y &= stru_5C6E00->uDoublePiMask; + break; case PARTY_TurnRight: - //LODWORD(v10) = uTurnSpeed; - if ( uTurnSpeed ) - { - v12 = _angle_y - uTurnSpeed; - _angle_y = stru_5C6E00->uDoublePiMask & v12; - } - else - { - v11 = (double)dturn * fTurnSpeedMultiplier; - v12 = _angle_y - (signed __int64)v11; - _angle_y = stru_5C6E00->uDoublePiMask & v12; - } - break; + if (uTurnSpeed) + _angle_y -= uTurnSpeed; + else + _angle_y -= dturn * fTurnSpeedMultiplier; + + _angle_y &= stru_5C6E00->uDoublePiMask; + break; case PARTY_FastTurnLeft: - if ( uTurnSpeed ) - { - v12 = uTurnSpeed + _angle_y; - _angle_y = stru_5C6E00->uDoublePiMask & v12; - } - else - { - v9 = (fTurnSpeedMultiplier + fTurnSpeedMultiplier) * (double)dturn; - _angle_y = stru_5C6E00->uDoublePiMask & (_angle_y + (unsigned __int64)(signed __int64)v9); - } - break; + if (uTurnSpeed) + _angle_y += uTurnSpeed; + else + _angle_y += 2.0f * fTurnSpeedMultiplier * (double)dturn; + + _angle_y &= stru_5C6E00->uDoublePiMask; + break; case PARTY_FastTurnRight: - if ( !uTurnSpeed ) - { - v11 = (fTurnSpeedMultiplier + fTurnSpeedMultiplier) * (double)dturn; - v12 = _angle_y - (signed __int64)v11; - _angle_y = stru_5C6E00->uDoublePiMask & v12; - } - else - { - v12 = _angle_y - uTurnSpeed; - _angle_y = stru_5C6E00->uDoublePiMask & v12; - } - break; + if (!uTurnSpeed) + _angle_y -= 2.0f * fTurnSpeedMultiplier * (double)dturn; + else + _angle_y -= uTurnSpeed; + + _angle_y &= stru_5C6E00->uDoublePiMask; + break; case PARTY_StrafeLeft: - v13 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi); - v14 = (double)_walk_speed; - v126 = v13; - *(float *)&v128 = v14; - v124 = (unsigned __int64)(v13 * (signed __int64)((signed int)(signed __int64)(v14 * fWalkSpeedMultiplier) >> 1)) >> 16; - v2 -= v124; - v126 = stru_5C6E00->SinCos(_angle_y); - v124 = (unsigned __int64)(v126 - * (signed __int64)((signed int)(signed __int64)(*(float *)&v128 * fWalkSpeedMultiplier) >> 1)) >> 16; - goto LABEL_85; + { + //v13 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi); + //v14 = (double)_walk_speed; + *(float *)&v128 = pParty->uWalkSpeed; + + float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0); + int dx = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; + v2 -= 3 * dx / 4; + + float cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0); + int dy = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; + v1 += 3 * dy / 4; + + v128 = v1; + v124 = 1; + } + break; + case PARTY_StrafeRight: - v15 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi); - v16 = (double)_walk_speed; - v126 = v15; - *(float *)&v128 = v16; - v124 = (unsigned __int64)(v15 * (signed __int64)((signed int)(signed __int64)(v16 * fWalkSpeedMultiplier) >> 1)) >> 16; + { + //v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi); + *(float *)&v128 = pParty->uWalkSpeed; + /*v124 = (unsigned __int64)(v126 * (signed __int64)((signed int)(signed __int64)(pParty->uWalkSpeed * fWalkSpeedMultiplier) >> 1)) >> 16; v2 += v124; v126 = stru_5C6E00->SinCos(_angle_y); v124 = (unsigned __int64)(v126 * (signed __int64)((signed int)(signed __int64)(*(float *)&v128 * fWalkSpeedMultiplier) >> 1)) >> 16; - goto LABEL_90; + v1 -= v124;*/ + float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0); + int dx = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; + v2 += 3 * dx / 4; + + float cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0); + int dy = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; + v1 -= 3 * dy / 4; + + v128 = v1; + v124 = 1; + } + break; + case PARTY_WalkForward: v17 = stru_5C6E00->SinCos(_angle_y); v18 = (double)_walk_speed; @@ -3420,9 +3421,11 @@ v126 = stru_5C6E00->SinCos(_angle_y - stru_5C6E00->uIntegerHalfPi); v124 = (unsigned __int64)(v126 * (signed __int64)(signed int)(signed __int64)(*(float *)&v128 * fWalkSpeedMultiplier)) >> 16; -LABEL_85: v1 += v124; - goto LABEL_86; + v128 = v1; + v124 = 1; + break; + case PARTY_WalkBackward: v19 = stru_5C6E00->SinCos(_angle_y); v20 = (double)_walk_speed; @@ -3435,9 +3438,11 @@ v124 = (unsigned __int64)(v126 * (signed __int64)(signed int)(signed __int64)(*(float *)&v128 * fBackwardWalkSpeedMultiplier)) >> 16; -LABEL_90: v1 -= v124; - goto LABEL_86; + v128 = v1; + v124 = 1; + break; + case PARTY_RunForward: if ( pParty->bFlying ) { @@ -3470,7 +3475,9 @@ v129 = (unsigned __int64)(v126 * (signed __int64)(signed int)(signed __int64)(*(float *)&v128 * fWalkSpeedMultiplier)) >> 16; v1 += v129; - goto LABEL_86; + v128 = v1; + v124 = 1; + break; } v25 = stru_5C6E00->SinCos(_angle_y); v26 = (double)_walk_speed; @@ -3490,6 +3497,7 @@ v114 = 1; v128 = v1; break; + case PARTY_RunBackward: v27 = stru_5C6E00->SinCos(_angle_y); v28 = (double)_walk_speed; @@ -3518,7 +3526,7 @@ * (signed __int64)(signed int)(signed __int64)(*(float *)&v128 * fBackwardWalkSpeedMultiplier)) >> 16; v1 -= v129; -LABEL_86: +//LABEL_86: v128 = v1; v124 = 1; }