Mercurial > mm7
changeset 2164:f5e9ac04dd25
fixpoint_mul in ProcessPartyActions
author | Ritor1 |
---|---|
date | Thu, 16 Jan 2014 00:08:27 +0600 |
parents | 9aa0a5d90454 |
children | 47ac9e87690c |
files | Indoor.cpp Outdoor.cpp |
diffstat | 2 files changed, 101 insertions(+), 129 deletions(-) [+] |
line wrap: on
line diff
--- a/Indoor.cpp Wed Jan 15 17:35:41 2014 +0600 +++ b/Indoor.cpp Thu Jan 16 00:08:27 2014 +0600 @@ -6835,9 +6835,9 @@ } else { - v39 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16) + new_party_x; - uSectorID = new_party_y + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16); - v40 = new_party_z + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16); + v39 = new_party_x + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x); + uSectorID = new_party_y + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y); + v40 = new_party_z + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); } v42 = collide_against_floor(v39, uSectorID, v40 + 40, &stru_721530.uSectorID, &uFaceID); if ( v42 == -30000 || v42 - new_party_z > 128 ) @@ -6849,11 +6849,11 @@ new_party_z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; break; } - new_party_x += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16; - new_party_y += (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16; + new_party_x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x); + new_party_y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y); uSectorID = stru_721530.uSectorID; stru_721530.field_70 += stru_721530.field_7C; - unsigned long long v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16) + new_party_z; + unsigned long long v87 = new_party_z + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor) { if ( SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) >= 0 @@ -6865,12 +6865,12 @@ { v54 = stru_5C6E00->Atan2(new_party_x - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.x, new_party_y - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.y); - v2 = (unsigned __int64)(stru_5C6E00->Cos(v54) * (signed __int64)integer_sqrt(v2 * v2 + v1 * v1)) >> 16; - v1 = (unsigned __int64)(stru_5C6E00->Sin(v54) * (signed __int64)integer_sqrt(v2 * v2 + v1 * v1)) >> 16; + v2 = fixpoint_mul(stru_5C6E00->Cos(v54), integer_sqrt(v2 * v2 + v1 * v1)); + v1 = fixpoint_mul(stru_5C6E00->Sin(v54), integer_sqrt(v2 * v2 + v1 * v1)); } - else - { - if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) + //else + //{ + else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) { pFace = &pIndoor->pFaces[(signed int)stru_721530.uFaceID >> 3]; if ( pFace->uPolygonType == POLYGON_Floor ) @@ -6896,9 +6896,9 @@ v80 = abs(v1 * pFace->pFacePlane_old.vNormal.y + v46 + v2 * pFace->pFacePlane_old.vNormal.x) >> 16; if ((stru_721530.speed >> 3) > v80 ) v80 = stru_721530.speed >> 3; - v2 += (unsigned __int64)(v80 * (signed __int64)pFace->pFacePlane_old.vNormal.x) >> 16; - v1 += (unsigned __int64)(v80 * (signed __int64)pFace->pFacePlane_old.vNormal.y) >> 16; - pParty->uFallSpeed += (unsigned __int64)(v80 * (signed __int64)pFace->pFacePlane_old.vNormal.z) >> 16; + v2 += fixpoint_mul(v80, pFace->pFacePlane_old.vNormal.x); + v1 += fixpoint_mul(v80, pFace->pFacePlane_old.vNormal.y); + pParty->uFallSpeed += fixpoint_mul(v80, pFace->pFacePlane_old.vNormal.z); //v80 = pFace->pFacePlane_old.vNormal.y; v52 = stru_721530.prolly_normal_d - ((pFace->pFacePlane_old.dist + v87 * pFace->pFacePlane_old.vNormal.z @@ -6906,9 +6906,9 @@ + new_party_x * pFace->pFacePlane_old.vNormal.x) >> 16); if ( v52 > 0 ) { - new_party_x += v52 * pFace->pFacePlane_old.vNormal.x >> 16; - new_party_y += v52 * pFace->pFacePlane_old.vNormal.y >> 16; - v87 += v52 * pFace->pFacePlane_old.vNormal.z >> 16; + new_party_x += fixpoint_mul(v52, pFace->pFacePlane_old.vNormal.x); + new_party_y += fixpoint_mul(v52, pFace->pFacePlane_old.vNormal.y); + v87 += fixpoint_mul(v52, pFace->pFacePlane_old.vNormal.z); } if ( pParty->floor_face_pid != PID_ID(stru_721530.uFaceID) && pFace->Pressure_Plate() ) uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID; @@ -6918,9 +6918,9 @@ v80 = abs(v1 * pFace->pFacePlane_old.vNormal.y + v46 + v2 * pFace->pFacePlane_old.vNormal.x) >> 16; if ((stru_721530.speed >> 3) > v80 ) v80 = stru_721530.speed >> 3; - v2 += (unsigned __int64)(v80 * (signed __int64)pFace->pFacePlane_old.vNormal.x) >> 16; - v1 += (unsigned __int64)(v80 * (signed __int64)pFace->pFacePlane_old.vNormal.y) >> 16; - pParty->uFallSpeed += (unsigned __int64)(v80 * (signed __int64)pFace->pFacePlane_old.vNormal.z) >> 16; + v2 += fixpoint_mul(v80, pFace->pFacePlane_old.vNormal.x); + v1 += fixpoint_mul(v80, pFace->pFacePlane_old.vNormal.y); + pParty->uFallSpeed += fixpoint_mul(v80, pFace->pFacePlane_old.vNormal.z); if ( v2 * v2 + v1 * v1 >= 400 ) { if ( pParty->floor_face_pid != PID_ID(stru_721530.uFaceID) && pFace->Pressure_Plate() ) @@ -6935,11 +6935,11 @@ } } } - } - v2 = (unsigned __int64)(58500i64 * v2) >> 16; - v1 = (unsigned __int64)(58500i64 * v1) >> 16; + //} + v2 = fixpoint_mul(58500, v2); + v1 = fixpoint_mul(58500, v1); //++v83; - pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; + pParty->uFallSpeed = fixpoint_mul(58500, pParty->uFallSpeed); //if ( v83 >= 100 ) //{ //new_party_z = v87;
--- a/Outdoor.cpp Wed Jan 15 17:35:41 2014 +0600 +++ b/Outdoor.cpp Thu Jan 16 00:08:27 2014 +0600 @@ -4021,13 +4021,13 @@ } else { - v2 += (unsigned __int64)(stru_5C6E00->Cos(_angle_y) + /*v2 += (unsigned __int64)(stru_5C6E00->Cos(_angle_y) * (signed __int64)(signed int)(2 * (unsigned __int64)(signed __int64)((double)_walk_speed * fWalkSpeedMultiplier))) >> 16; v1 += (unsigned __int64)((signed int)stru_5C6E00->Sin(_angle_y) - * (signed __int64)(signed int)(2 * (unsigned __int64)(signed __int64)((double)_walk_speed * fWalkSpeedMultiplier))) >> 16; - - /*v2 += 2 * dx;//original -228, now -222 it's temporarily - v1 += 2 * dy;//original -2295, now -2292*/ + * (signed __int64)(signed int)(2 * (unsigned __int64)(signed __int64)((double)_walk_speed * fWalkSpeedMultiplier))) >> 16;*/ + + v2 += 2 * dx; + v1 += 2 * dy; v128 = v1; party_running_flag = true; @@ -4179,9 +4179,9 @@ ODM_GetTerrainNormalAt(pX, pY, &v98); v35 = fall_speed + (8 * -(pEventTimer->uTimeElapsed * GetGravityStrength())); v129 = abs(v2 * v98.x + v1 * v98.y + v35 * v98.z) >> 16; - v2 += (unsigned __int64)(v129 * (signed __int64)v98.x) >> 16; - v1 += (unsigned __int64)(v129 * (signed __int64)v98.y) >> 16; - v34 = v35 + ((unsigned __int64)(v129 * (signed __int64)v98.z) >> 16); + v2 += fixpoint_mul(v129, (int)v98.x); + v1 += fixpoint_mul(v129, (int)v98.y); + v34 = v35 + fixpoint_mul(v129, (int)v98.z); v128 = v1; fall_speed = v34; } @@ -4317,108 +4317,85 @@ pY = _angle_y; v45 = stru_721530.uFaceID; pZ = v40; + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor) { if (pParty->Invisible()) pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); - viewparams->bRedrawGameUI = true; - unsigned __int64 ps = 58500i64 * v2; - float pr = (float)v2; - v2 = ps >> 16; - pModel = (BSPModel *)58500; - v128 = (unsigned __int64)(58500i64 * v128) >> 16; - v122 = (unsigned __int64)(58500i64 * fall_speed) >> 16; - fall_speed = (unsigned __int64)(58500i64 * fall_speed) >> 16; - continue; } + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) { - //v118 = integer_sqrt(v2 * v2 + v128 * v128); v129 = stru_5C6E00->Atan2(_angle_x - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x, _angle_y - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y); - //v59 = (signed int)stru_5C6E00->Cos(v129) * (signed __int64)integer_sqrt(v2 * v2 + v128 * v128); - //v122 = ((signed int)stru_5C6E00->Cos(v129) * (signed __int64)integer_sqrt(v2 * v2 + v128 * v128)) >> 16; - v2 = ((signed int)stru_5C6E00->Cos(v129) * (signed __int64)integer_sqrt(v2 * v2 + v128 * v128)) >> 16; - //v61 = (signed int)stru_5C6E00->Sin(v129) * (signed __int64)integer_sqrt(v2 * v2 + v128 * v128); - v122 = ((signed int)stru_5C6E00->Sin(v129) * (signed __int64)integer_sqrt(v2 * v2 + v128 * v128)) >> 16; - v128 = ((signed int)stru_5C6E00->Sin(v129) * (signed __int64)integer_sqrt(v2 * v2 + v128 * v128)) >> 16; + v2 = fixpoint_mul(stru_5C6E00->Cos(v129), integer_sqrt(v2 * v2 + v128 * v128)); + v122 = fixpoint_mul(stru_5C6E00->Sin(v129), integer_sqrt(v2 * v2 + v128 * v128)); + v128 = fixpoint_mul(stru_5C6E00->Sin(v129), integer_sqrt(v2 * v2 + v128 * v128)); } - //else - //{ - if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) + + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) + { + pParty->bFlying = false; + pModel = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; + pODMFace = &pModel->pFaces[((signed int)stru_721530.uFaceID >> 3) & 0x3F]; + v48 = pODMFace->pBoundingBox.z2 - pODMFace->pBoundingBox.z1; + v129 = v48 <= 32; + v119 = pODMFace->pFacePlane.vNormal.z < 46378; + if ( bUnderwater == 1 ) + v119 = 0; + if ( pODMFace->uPolygonType == POLYGON_Floor ) { - pParty->bFlying = false; - pModel = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; - pODMFace = &pModel->pFaces[((signed int)stru_721530.uFaceID >> 3) & 0x3F]; - v48 = pODMFace->pBoundingBox.z2 - pODMFace->pBoundingBox.z1; - v129 = v48 <= 32; - v119 = pODMFace->pFacePlane.vNormal.z < 46378; - if ( bUnderwater == 1 ) - v119 = 0; - if ( pODMFace->uPolygonType == POLYGON_Floor ) + if ( fall_speed < 0 ) + fall_speed = 0; + pZ = pModel->pVertices.pVertices[pODMFace->pVertexIDs[0]].z + 1; + if ( v2 * v2 + v128 * v128 < 400 ) + { + v2 = 0; + *(float *)&v128 = 0.0; + } + if ( pParty->floor_face_pid != v45 && pODMFace->Pressure_Plate() ) { - if ( fall_speed < 0 ) - fall_speed = 0; - pZ = pModel->pVertices.pVertices[pODMFace->pVertexIDs[0]].z + 1; - if ( v2 * v2 + v128 * v128 < 400 ) - { - v2 = 0; - *(float *)&v128 = 0.0; - } - if ( pParty->floor_face_pid != v45 && pODMFace->Pressure_Plate() ) - { - pParty->floor_face_pid = v45; - trigger_id = pODMFace->sCogTriggeredID; // - } - v2 = (unsigned __int64)(58500i64 * v2) >> 16; - pModel = (BSPModel *)58500; - v128 = (unsigned __int64)(58500i64 * v128) >> 16; - v122 = (unsigned __int64)(58500i64 * fall_speed) >> 16; - fall_speed = (unsigned __int64)(58500i64 * fall_speed) >> 16; - continue; + pParty->floor_face_pid = v45; + trigger_id = pODMFace->sCogTriggeredID; } - if ( !v129 && (pODMFace->uPolygonType != POLYGON_InBetweenFloorAndWall || v119) )// упёрся в столб + } + if ( !v129 && (pODMFace->uPolygonType != POLYGON_InBetweenFloorAndWall || v119) )// упёрся в столб + { + v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + fall_speed * pODMFace->pFacePlane.vNormal.z + + v2 * pODMFace->pFacePlane.vNormal.x) >> 16; + if ((stru_721530.speed >> 3) > v118 ) + v118 = stru_721530.speed >> 3; + v2 += fixpoint_mul(v118, pODMFace->pFacePlane.vNormal.x); + v128 += fixpoint_mul(v118, pODMFace->pFacePlane.vNormal.y); + v54 = 0; + if ( !v119 ) + v54 = fixpoint_mul(v118, pODMFace->pFacePlane.vNormal.z); + pParty->uFallSpeed += v54; + v55 = stru_721530.prolly_normal_d - ((signed int)(pODMFace->pFacePlane.dist + v122 * pODMFace->pFacePlane.vNormal.z + + _angle_y * pODMFace->pFacePlane.vNormal.y + _angle_x * pODMFace->pFacePlane.vNormal.x) >> 16); + if ( v55 > 0 ) { - v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + fall_speed * pODMFace->pFacePlane.vNormal.z - + v2 * pODMFace->pFacePlane.vNormal.x) >> 16; - if ((stru_721530.speed >> 3) > v118 ) - v118 = stru_721530.speed >> 3; - v2 += (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.x) >> 16; - v128 += (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.y) >> 16; - v54 = 0; + pX = _angle_x + fixpoint_mul(pODMFace->pFacePlane.vNormal.x, v55); + pY = _angle_y + fixpoint_mul(pODMFace->pFacePlane.vNormal.y, v55); if ( !v119 ) - v54 = (unsigned __int64)(v118 * (signed __int64)(signed int)pODMFace->pFacePlane.vNormal.z) >> 16; - pParty->uFallSpeed += v54; - v55 = stru_721530.prolly_normal_d - ((signed int)(pODMFace->pFacePlane.dist + v122 * pODMFace->pFacePlane.vNormal.z - + _angle_y * pODMFace->pFacePlane.vNormal.y - + _angle_x * pODMFace->pFacePlane.vNormal.x) >> 16); - if ( v55 > 0 ) - { - pX = _angle_x + (pODMFace->pFacePlane.vNormal.x * v55 >> 16); - pY = _angle_y + (pODMFace->pFacePlane.vNormal.y * v55 >> 16); - if ( !v119 ) - pZ = v122 + (pODMFace->pFacePlane.vNormal.z * v55 >> 16); - } - if ( pParty->floor_face_pid != stru_721530.uFaceID && pODMFace->Pressure_Plate() ) - { - pParty->floor_face_pid = stru_721530.uFaceID; - trigger_id = pODMFace->sCogTriggeredID; // - } - v2 = (unsigned __int64)(58500i64 * v2) >> 16; - pModel = (BSPModel *)58500; - v128 = (unsigned __int64)(58500i64 * v128) >> 16; - v122 = (unsigned __int64)(58500i64 * fall_speed) >> 16; - fall_speed = (unsigned __int64)(58500i64 * fall_speed) >> 16; - continue; + pZ = v122 + fixpoint_mul(pODMFace->pFacePlane.vNormal.z, v55); } + if ( pParty->floor_face_pid != stru_721530.uFaceID && pODMFace->Pressure_Plate() ) + { + pParty->floor_face_pid = stru_721530.uFaceID; + trigger_id = pODMFace->sCogTriggeredID; // + } + } + if ( pODMFace->uPolygonType == POLYGON_InBetweenFloorAndWall ) + { v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + fall_speed * pODMFace->pFacePlane.vNormal.z + v2 * pODMFace->pFacePlane.vNormal.x) >> 16; if ((stru_721530.speed >> 3) > v118 ) v118 = stru_721530.speed >> 3; - v2 += (unsigned __int64)(v118 * (signed __int64)(signed int)pODMFace->pFacePlane.vNormal.x) >> 16; - v128 += (unsigned __int64)(v118 * (signed __int64)(signed int)pODMFace->pFacePlane.vNormal.y) >> 16; - fall_speed += (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.z) >> 16; + v2 += fixpoint_mul(v118, pODMFace->pFacePlane.vNormal.x); + v128 += fixpoint_mul(v118, pODMFace->pFacePlane.vNormal.y); + fall_speed += fixpoint_mul(v118, pODMFace->pFacePlane.vNormal.z); if ( v2 * v2 + v128 * v128 >= 400 ) { if ( pParty->floor_face_pid != stru_721530.uFaceID && pODMFace->Pressure_Plate() ) @@ -4426,24 +4403,19 @@ pParty->floor_face_pid = stru_721530.uFaceID; trigger_id = pODMFace->sCogTriggeredID; // } - v2 = (unsigned __int64)(58500i64 * v2) >> 16; - pModel = (BSPModel *)58500; - v128 = (unsigned __int64)(58500i64 * v128) >> 16; - v122 = (unsigned __int64)(58500i64 * fall_speed) >> 16; - //++v126; - fall_speed = (unsigned __int64)(58500i64 * fall_speed) >> 16; - continue; + } + else + { + v2 = 0; + fall_speed = 0; + *(float *)&v128 = 0.0; } - v2 = 0; - fall_speed = 0; - *(float *)&v128 = 0.0; } - //} - v2 = (unsigned __int64)(58500i64 * v2) >> 16; - pModel = (BSPModel *)58500; - v128 = (unsigned __int64)(58500i64 * v128) >> 16; - v122 = (unsigned __int64)(58500i64 * fall_speed) >> 16; - fall_speed = (unsigned __int64)(58500i64 * fall_speed) >> 16; + } + v2 = fixpoint_mul(58500, (int)v2); + v128 = fixpoint_mul(58500, (int)v128); + v122 = fixpoint_mul(58500, (int)v122); + fall_speed = fixpoint_mul(58500, (int)fall_speed); } //Воспроизведение звуков ходьбы/бега------------------------