Mercurial > mm7
diff mm7_3.cpp @ 1423:350959f13283
Слияние
author | Ritor1 |
---|---|
date | Tue, 30 Jul 2013 09:34:14 +0600 |
parents | 483b1b453986 |
children | 5930342f092b |
line wrap: on
line diff
--- a/mm7_3.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/mm7_3.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -42,7 +42,6 @@ #include "Time.h" #include "IconFrameTable.h" #include "TurnEngine.h" -#include "stru220.h" #include "Events2D.h" #include "stru176.h" #include "stru298.h" @@ -1817,37 +1816,38 @@ pParty->sRotationX = _view_angle; if ( bJumping ) { - pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength(); + pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength(); + if ( bJumping != v36 && pParty->uFallSpeed <= v36 ) + { + if ( pParty->uFallSpeed < -500 && !pParty->bFlying ) + { + v41 = &pPlayers[1]; + do + { + if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 + (*v41)->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0); + ++v41; + } + while ( (signed int)v41 <= (signed int)&pPlayers[4] ); + } + } + else + pParty->uFallStartY = party_z; } else { if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 32768 ) { pParty->uFallSpeed -= pEventTimer->uTimeElapsed * GetGravityStrength(); - goto LABEL_92; + pParty->uFallStartY = party_z; } - if (pParty->uFlags & PARTY_FLAGS_1_LANDING) - goto LABEL_92; - pParty->uFallSpeed = 0; - } - if ( bJumping != v36 && pParty->uFallSpeed <= v36 ) - { - if ( pParty->uFallSpeed < -500 && !pParty->bFlying ) - { - v41 = &pPlayers[1]; - do - { - if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 - (*v41)->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0); - ++v41; - } - while ( (signed int)v41 <= (signed int)&pPlayers[4] ); - } - goto LABEL_93; - } -LABEL_92: - pParty->uFallStartY = party_z; -LABEL_93: + else + { + if (! (pParty->uFlags & PARTY_FLAGS_1_LANDING) ) + pParty->uFallSpeed = 0; + pParty->uFallStartY = party_z; + } + } if ( v2 * v2 + v1 * v1 < 400 ) { v1 = 0; @@ -1924,9 +1924,8 @@ && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime)) ) pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); viewparams->bRedrawGameUI = 1; - goto LABEL_152; } - if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) + else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) { v53 = integer_sqrt(v2 * v2 + v1 * v1); v80 = v53; @@ -1956,64 +1955,69 @@ } if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; - goto LABEL_152; } - v46 = pParty->uFallSpeed * v44->pFacePlane_old.vNormal.z; - v47 = v45 == 4; - v48 = v44->pFacePlane_old.vNormal.x; - if ( !v47 ) - { - v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16; - if ( stru_721530.field_64 >> 3 > v80 ) - v80 = stru_721530.field_64 >> 3; - v50 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16; - v81 = v44->pFacePlane_old.vNormal.y; - v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16; - v82 = v44->pFacePlane_old.vNormal.z; - v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16; - v2 += v50; - pParty->uFallSpeed += v82; - v74 = v44->pFacePlane_old.vNormal.z; - v51 = v44->pFacePlane_old.vNormal.y; - v69 = v44->pFacePlane_old.vNormal.x; - v80 = v51; - v1 += v81; - v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + new_party_y * v51 + new_party_x * v69) >> 16); - if ( v52 > 0 ) - { - new_party_x += v52 * v69 >> 16; - new_party_y += v52 * v80 >> 16; - v87 += v52 * v74 >> 16; - } - v43 = stru_721530.uFaceID; - if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) - uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; - goto LABEL_152; - } - v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16; - if ( stru_721530.field_64 >> 3 > v80 ) - v80 = stru_721530.field_64 >> 3; - v49 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16; - v81 = v44->pFacePlane_old.vNormal.y; - v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16; - v82 = v44->pFacePlane_old.vNormal.z; - v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16; - v2 += v49; - v1 += v81; - pParty->uFallSpeed += v82; - if ( v2 * v2 + v1 * v1 >= 400 ) - { - v43 = stru_721530.uFaceID; - if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) - uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; - goto LABEL_152; - } - v2 = 0; - v1 = 0; - pParty->uFallSpeed = 0; + else + { + v46 = pParty->uFallSpeed * v44->pFacePlane_old.vNormal.z; + v47 = v45 == 4; + v48 = v44->pFacePlane_old.vNormal.x; + if ( !v47 ) + { + v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16; + if ( stru_721530.field_64 >> 3 > v80 ) + v80 = stru_721530.field_64 >> 3; + v50 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16; + v81 = v44->pFacePlane_old.vNormal.y; + v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16; + v82 = v44->pFacePlane_old.vNormal.z; + v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16; + v2 += v50; + pParty->uFallSpeed += v82; + v74 = v44->pFacePlane_old.vNormal.z; + v51 = v44->pFacePlane_old.vNormal.y; + v69 = v44->pFacePlane_old.vNormal.x; + v80 = v51; + v1 += v81; + v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + new_party_y * v51 + new_party_x * v69) >> 16); + if ( v52 > 0 ) + { + new_party_x += v52 * v69 >> 16; + new_party_y += v52 * v80 >> 16; + v87 += v52 * v74 >> 16; + } + v43 = stru_721530.uFaceID; + if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) + uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; + } + else + { + v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16; + if ( stru_721530.field_64 >> 3 > v80 ) + v80 = stru_721530.field_64 >> 3; + v49 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16; + v81 = v44->pFacePlane_old.vNormal.y; + v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16; + v82 = v44->pFacePlane_old.vNormal.z; + v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16; + v2 += v49; + v1 += v81; + pParty->uFallSpeed += v82; + if ( v2 * v2 + v1 * v1 >= 400 ) + { + v43 = stru_721530.uFaceID; + if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) + uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; + } + else + { + v2 = 0; + v1 = 0; + pParty->uFallSpeed = 0; + } + } + } } } -LABEL_152: v2 = (unsigned __int64)(58500i64 * v2) >> 16; v1 = (unsigned __int64)(58500i64 * v1) >> 16; ++v83; @@ -2029,8 +2033,11 @@ if ( integer_sqrt((pParty->vPosition.x - new_party_x) * (pParty->vPosition.x - new_party_x) + (pParty->vPosition.y - new_party_y) * (pParty->vPosition.y - new_party_y) + (pParty->vPosition.z - new_party_z) * (pParty->vPosition.z - new_party_z)) <= 16 ) - goto LABEL_188; - if ( v72 && (!bJumping || jumping_up) ) + { + pAudioPlayer->_4AA258(804); + pParty->walk_sound_timer = 64; + } + else if ( v72 && (!bJumping || jumping_up) ) { v66 = 0; v64 = 0; @@ -2046,13 +2053,16 @@ v57 = (SoundID)50; else v57 = (SoundID)64; - goto LABEL_175; + pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66); } - v57 = (SoundID)63; - v56 = pAudioPlayer; - goto LABEL_175; + else + { + v57 = (SoundID)63; + v56 = pAudioPlayer; + pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66); + } } - if ( v78 && (!bJumping || jumping_up) ) + else if ( v78 && (!bJumping || jumping_up) ) { v66 = 0; v64 = 0; @@ -2065,19 +2075,19 @@ { v57 = (SoundID)102; v56 = pAudioPlayer; - goto LABEL_175; } - v56 = pAudioPlayer; - if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 ) - v57 = (SoundID)89; - else - v57 = (SoundID)103; -LABEL_175: + else + { + v56 = pAudioPlayer; + if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 ) + v57 = (SoundID)89; + else + v57 = (SoundID)103; + } pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66); } else { -LABEL_188: pAudioPlayer->_4AA258(804); pParty->walk_sound_timer = 64; } @@ -2208,8 +2218,8 @@ int bFeatherFall; // [sp+28h] [bp-6Ch]@4 int v105; // [sp+2Ch] [bp-68h]@24 int bWaterWalk; // [sp+30h] [bp-64h]@1 - bool v107; // [sp+34h] [bp-60h]@30 - int v108; // [sp+38h] [bp-5Ch]@1 + //bool v107; // [sp+34h] [bp-60h]@30 + //int v108; // [sp+38h] [bp-5Ch]@1 int v109; // [sp+3Ch] [bp-58h]@28 int v110; // [sp+40h] [bp-54h]@180 int v111; // [sp+44h] [bp-50h]@14 @@ -2231,7 +2241,7 @@ BSPModel *v127; // [sp+84h] [bp-10h]@1 int v128; // [sp+88h] [bp-Ch]@1 int v129; // [sp+8Ch] [bp-8h]@92 - int v130; // [sp+90h] [bp-4h]@14 + //int v130; // [sp+90h] [bp-4h]@14 v121 = pParty->uFallSpeed; pZ = pParty->vPosition.z; @@ -2248,22 +2258,12 @@ auto partyAtHighSlope = IsTerrainSlopeTooHigh(pParty->vPosition.x, pParty->vPosition.y); v114 = 0; v124 = 0; - v108 = 0; v102 = 0; v127 = 0; bWaterWalk = 0; if (!pParty->FeatherFallActive()) - //SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) < 0 - //|| SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0 && LODWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0 ) { bFeatherFall = 0; - /*v119 = &pPlayers[1]; - while ( !(*v119)->WearsItem(536, 16) ) - { - ++v119; - if ( (signed int)v119 > (signed int)&pPlayers[4] ) - goto LABEL_9; - }*/ for (int i = 0; i < 4; ++i) if (pParty->pPlayers[i].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY)) // seems like flying boots { @@ -2286,7 +2286,11 @@ pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster - 1].sMana <= 0 ) bWaterWalk = 0; } - v3 = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &v130, &v108, bWaterWalk); + int bmodel_standing_on_pid; + int is_on_water = false; + v3 = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, bWaterWalk); + int is_not_on_bmodel = bmodel_standing_on_pid == 0; + v111 = v3; if ( bFeatherFall ) pParty->uFallStartY = v3; @@ -2317,7 +2321,7 @@ v109 = -1; if ( pParty->bFlying ) v109 = sub_46D8E3(pX, pY, pZ + pParty->uPartyHeight, (int)&v102); - v107 = v108 == 0; + //v107 = bmodel_standing_on_pid == 0; v105 = v111 + 1; if ( pZ <= v111 + 1 ) { @@ -2335,20 +2339,18 @@ pParty->walk_sound_timer -= pEventTimer->uTimeElapsed; else pParty->walk_sound_timer = 0; } - if (!bUnderwater - && SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime) <= 0 - && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime) < 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime) <= 0) ) + if (!bUnderwater && pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime <= 0) pParty->bFlying = false; if (!bJumping) { - if ( pParty->floor_face_pid != PID(OBJECT_BModel, v108) ) + if ( pParty->floor_face_pid != PID(OBJECT_BModel, bmodel_standing_on_pid) ) { - if (v108) + if (bmodel_standing_on_pid) { - if ( v108 >> 6 < pOutdoor->uNumBModels ) + if ( (bmodel_standing_on_pid >> 6) < pOutdoor->uNumBModels ) { - v7 = pOutdoor->pBModels[v108 >> 6].pFaces; - v6 = v108 & 0x3F; + v7 = pOutdoor->pBModels[bmodel_standing_on_pid >> 6].pFaces; + v6 = bmodel_standing_on_pid & 0x3F; /*if ( *(char *)(v7->pFacePlane.vNormal.x + 308 * v6 + 31) & 4 ) { pParty->field_6F4_packedid = PID(OBJECT_BModel,v108); @@ -2356,13 +2358,13 @@ }*/ if ( BYTE3(v7[v6].uAttributes) & 4 ) { - pParty->floor_face_pid = PID(OBJECT_BModel, v108); + pParty->floor_face_pid = PID(OBJECT_BModel, bmodel_standing_on_pid); v103 = v7[v6].sCogTriggeredID; } } } } - pParty->floor_face_pid = PID(OBJECT_BModel, v108); + pParty->floor_face_pid = PID(OBJECT_BModel, bmodel_standing_on_pid); } _walk_speed = pParty->uWalkSpeed; _angle_y = pParty->sRotationY; @@ -2548,7 +2550,7 @@ v128 = v1; } - else if (partyAtHighSlope && !v108) + else if (partyAtHighSlope && !bmodel_standing_on_pid) { v2 += dx; v1 += dy; @@ -2634,7 +2636,7 @@ break; case PARTY_Jump: - if ( (!partyAtHighSlope || v108) && !bJumping && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) ) + if ( (!partyAtHighSlope || bmodel_standing_on_pid) && !bJumping && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) ) { v126 = pParty->field_24 << 6; bJumping = 1; @@ -2678,7 +2680,7 @@ } else { - if ( v130 && v121 ) + if ( is_on_water && v121 ) sub_42F960_create_object(pX, pY, v111); v121 = 0; pZ = v111; @@ -2708,7 +2710,7 @@ } else if (!bJumping) { - if ( !v108 ) + if ( !bmodel_standing_on_pid ) { // rolling down the hill // how it's done: you get a little bit pushed in the air along terrain normal, getting in the air @@ -2802,18 +2804,18 @@ v40 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + pZ; } v122 = v40; - ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &v130, &v108, 0); - v129 = ODM_GetFloorLevel(_angle_x, pY, v40, pParty->uPartyHeight, &v130, &v97, 0); - auto v119 = ODM_GetFloorLevel(pX, _angle_y, v40, pParty->uPartyHeight, &v130, &v110, 0); + ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0); + v129 = ODM_GetFloorLevel(_angle_x, pY, v40, pParty->uPartyHeight, &is_on_water, &v97, 0); + auto v119 = ODM_GetFloorLevel(pX, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &v110, 0); v127 = (BSPModel *)IsTerrainSlopeTooHigh(_angle_x, pY); v42 = IsTerrainSlopeTooHigh(pX, _angle_y); - v107 = 0; + is_not_on_bmodel = false; v118 = v42; - if ( !v97 && !v110 && !v108 ) - v107 = 1; + if ( !v97 && !v110 && !bmodel_standing_on_pid ) + is_not_on_bmodel = true; v43 = 1; v44 = 1; - if ( bUnderwater || !v107 ) + if ( bUnderwater || !is_not_on_bmodel ) { pX = _angle_x; if ( v43 ) @@ -2835,7 +2837,7 @@ pY = _angle_y; else { - v127 = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &v130, &v108, 0); + v127 = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0); if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && (signed int)v127 <= pZ ) { v43 = 1; @@ -2847,7 +2849,7 @@ } if ( stru_721530.field_7C >= stru_721530.field_6C ) { - if ( !v107 ) + if ( !is_not_on_bmodel ) { pX = stru_721530.normal2.x; pY = stru_721530.normal2.y; @@ -2878,9 +2880,8 @@ { v56 = integer_sqrt(v2 * v2 + v128 * v128); v118 = v56; - v57 = 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); + v57 = 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); v129 = v57; v58 = (BSPModel *)stru_5C6E00->Cos(v57); v127 = v58; @@ -2921,7 +2922,7 @@ v2 = 0; *(float *)&v128 = 0.0; } - if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 ) + if ( pParty->floor_face_pid != v45 && (v47->uAttributes & FACE_PRESSURE_PLATE)) { pParty->floor_face_pid = v45; v103 = v47->sCogTriggeredID; @@ -3036,7 +3037,7 @@ { if ( v114 && (!bJumping || v101) ) { - if ( !v107 + if ( !is_not_on_bmodel && !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) ) { pAudioPlayer->PlaySound((SoundID)64, 804, 1, -1, 0, 0, 0, 0); @@ -3053,7 +3054,7 @@ { if ( v124 && (!bJumping || v101) ) { - if ( v107 + if ( is_not_on_bmodel || BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 ) { v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; @@ -3080,14 +3081,14 @@ v65 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; v114 = WorldPosToGridCellX(pX); v66 = WorldPosToGridCellZ(pY) - 1; - v127 = (BSPModel *)(((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1); - v122 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v114, v65) >> 1) & 1; + v127 = (BSPModel *)((~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1); + v122 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v114, v65) >> 1) & 1; v67 = pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v66); v68 = 0; - v69 = ((unsigned int)~v67 >> 1) & 1; + v69 = (~(unsigned int)v67 >> 1) & 1; if ( v114 == v126 && v66 == v65 && v122 && v69 ) v68 = 1; - if ( !v107 ) + if ( !is_not_on_bmodel ) v68 = 1; if ( v68 ) { @@ -3520,7 +3521,7 @@ v25 = 0; v16 = word_720B40_intercepts_zs[0] >= v27; if ( v15 <= 0 ) - goto LABEL_29; + return 0; do { if ( v31 >= 2 ) @@ -3555,7 +3556,6 @@ while ( v25 < v15 ); result = 1; if ( v31 != 1 ) -LABEL_29: result = 0; return result; } @@ -3658,7 +3658,7 @@ v21 = 0; v12 = word_7209A0_intercepts_ys_plus_ys[0] >= v24; if ( v11 <= 0 ) - goto LABEL_29; + return 0; do { if ( a4d >= 2 ) @@ -3693,7 +3693,6 @@ while ( v21 < v11 ); result = 1; if ( a4d != 1 ) -LABEL_29: result = 0; return result; } @@ -3892,10 +3891,37 @@ { v5 = v4 - 15; if ( *(float *)(v4 - 15) <= (double)a2 && *(float *)(v4 + 1) <= (double)a2 ) - goto LABEL_11; + { + v4 += 16; + --v34; + if ( !v34 ) + return this->uNumVertices = v38; + continue; + } if ( *(float *)v5 <= (double)a2 ) - break; - if ( *(float *)(v4 + 1) <= (double)a2 ) + { + v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); + v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4; + v36 = v6; + v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11); + v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7); + *(float *)&v37 = (double)v7 * v6; + v8 = *(float *)&v37 + 6.7553994e15; + v9 = (unsigned __int8)*v4; + *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; + v10 = *(float *)&v37 + 6.7553994e15; + v11 = (unsigned __int8)*(v4 - 2); + v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1); + v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36; + v12 = v39 + 6.7553994e15; + v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2); + v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; + v14 = v39 + 6.7553994e15; + v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8); + //this = v35; + v5 = (char *)&v30 + 4; + } + else if ( *(float *)(v4 + 1) <= (double)a2 ) { v15 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); v16 = (unsigned __int8)*v4; @@ -3928,9 +3954,8 @@ v40 += 4; *v25 = *(int *)v26; v25[1] = *(int *)(v26 + 4); - goto LABEL_9; + v5 = (char *)&v30 + 4; } -LABEL_10: v27 = v40; ++v38; *v40 = *(int *)v5; @@ -3942,36 +3967,12 @@ v40 += 4; *v27 = *(int *)v28; v27[1] = *(int *)(v28 + 4); -LABEL_11: v4 += 16; --v34; if ( !v34 ) - goto LABEL_12; + return this->uNumVertices = v38; } - v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); - v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4; - v36 = v6; - v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11); - v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7); - *(float *)&v37 = (double)v7 * v6; - v8 = *(float *)&v37 + 6.7553994e15; - v9 = (unsigned __int8)*v4; - *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; - v10 = *(float *)&v37 + 6.7553994e15; - v11 = (unsigned __int8)*(v4 - 2); - v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1); - v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36; - v12 = v39 + 6.7553994e15; - v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2); - v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; - v14 = v39 + 6.7553994e15; - v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8); -LABEL_9: - //this = v35; - v5 = (char *)&v30 + 4; - goto LABEL_10; - } -LABEL_12: + } return this->uNumVertices = v38; } @@ -4037,10 +4038,37 @@ { v5 = v4 - 15; if ( *(float *)(v4 - 15) >= (double)a2 && *(float *)(v4 + 1) >= (double)a2 ) - goto LABEL_11; + { + v4 += 16; + --v34; + if ( !v34 ) + return this->uNumVertices = v38; + continue; + } if ( *(float *)v5 >= (double)a2 ) - break; - if ( *(float *)(v4 + 1) >= (double)a2 ) + { + v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); + v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4; + v36 = v6; + v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11); + v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7); + *(float *)&v37 = (double)v7 * v6; + v8 = *(float *)&v37 + 6.7553994e15; + v9 = (unsigned __int8)*v4; + *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; + v10 = *(float *)&v37 + 6.7553994e15; + v11 = (unsigned __int8)*(v4 - 2); + v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1); + v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36; + v12 = v39 + 6.7553994e15; + v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2); + v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; + v14 = v39 + 6.7553994e15; + v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8); + //this = v35; + v5 = (char *)&v30 + 4; + } + else if ( *(float *)(v4 + 1) >= (double)a2 ) { v15 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); v16 = (unsigned __int8)*v4; @@ -4073,9 +4101,8 @@ v40 += 4; *v25 = *(int *)v26; v25[1] = *(int *)(v26 + 4); - goto LABEL_9; + v5 = (char *)&v30 + 4; } -LABEL_10: v27 = v40; ++v38; *v40 = *(int *)v5; @@ -4087,36 +4114,12 @@ v40 += 4; *v27 = *(int *)v28; v27[1] = *(int *)(v28 + 4); -LABEL_11: v4 += 16; --v34; if ( !v34 ) - goto LABEL_12; + return this->uNumVertices = v38; } - v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); - v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4; - v36 = v6; - v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11); - v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7); - *(float *)&v37 = (double)v7 * v6; - v8 = *(float *)&v37 + 6.7553994e15; - v9 = (unsigned __int8)*v4; - *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; - v10 = *(float *)&v37 + 6.7553994e15; - v11 = (unsigned __int8)*(v4 - 2); - v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1); - v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36; - v12 = v39 + 6.7553994e15; - v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2); - v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; - v14 = v39 + 6.7553994e15; - v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8); -LABEL_9: - //this = v35; - v5 = (char *)&v30 + 4; - goto LABEL_10; - } -LABEL_12: + } return this->uNumVertices = v38; } @@ -4302,7 +4305,10 @@ } v4 = a1->uNumVertices; if ( v4 <= 0 ) - goto LABEL_16; + { + memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4); + return v2->uNumVertices != 0; + } v5 = (char *)&a1->field_14[20]; v6 = v4; do @@ -4325,7 +4331,6 @@ v2->_477927(v10); return v2->uNumVertices != 0; } -LABEL_16: memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4); return v2->uNumVertices != 0; } @@ -4909,12 +4914,10 @@ { v3 = v2->pFacePlane.vNormal.x; v4 = -v2->pFacePlane.vNormal.y; -LABEL_9: v5 = 0; v11 = 65536; - goto LABEL_5; - } - if ( (v2->pFacePlane.vNormal.x || v2->pFacePlane.vNormal.y) && abs(v2->pFacePlane.vNormal.z) < 59082 ) + } + else if ( (v2->pFacePlane.vNormal.x || v2->pFacePlane.vNormal.y) && abs(v2->pFacePlane.vNormal.z) < 59082 ) { thisa.x = -v2->pFacePlane.vNormal.y; thisa.y = v2->pFacePlane.vNormal.x; @@ -4922,13 +4925,16 @@ thisa.Normalize_float(); v4 = thisa.x; v3 = thisa.y; - goto LABEL_9; - } - v3 = 0; - v4 = 65536; - v11 = 0; - v5 = -65536; -LABEL_5: + v5 = 0; + v11 = 65536; + } + else + { + v3 = 0; + v4 = 65536; + v11 = 0; + v5 = -65536; + } v6 = v11; sTextureDeltaU = v2->sTextureDeltaU; v7 = v3; @@ -5611,8 +5617,8 @@ //int v5; // eax@8 //SpawnPointMM7 *v6; // edx@14 size_t v7; // eax@19 - char *v8; // eax@19 - char *v9; // eax@21 + //char *v8; // eax@19 + //char *v9; // eax@21 char Source[120]; // [sp+Ch] [bp-84h]@19 const char *pFilename; // [sp+84h] [bp-Ch]@1 //unsigned int v12; // [sp+88h] [bp-8h]@12 @@ -5621,7 +5627,7 @@ pFilename = pLevelFilename; thisa->AllocSoftwareDrawBuffers(); pOutdoorCamera->_485F64(); - pWeather->bRenderSnow = 0; + pWeather->bRenderSnow = false; pRenderer->ClearZBuffer(0, 479); thisa = (OutdoorCamera *)1; GetAlertStatus(); @@ -5691,22 +5697,16 @@ pOutdoor->UpdateSunlightVectors(); pOutdoorCamera->int_fov_rad = (signed __int64)pIndoorCamera->flt_1C_fov; pOutdoorCamera->int_fov_rad_inv = (signed __int64)pIndoorCamera->flt_20_inv_1C; - v8 = (char *)&array_77EC08[0].ptr_38; - do - { - *(int *)v8 = (int)&stru_8019C8; - v8 += 268; - } - while ( (signed int)v8 < (signed int)&unk_801A00 ); - v9 = (char *)&array_77EC08[0].prolly_tail; - do - { - *((int *)v9 - 1) = 0; - *(int *)v9 = 0; - *((int *)v9 - 5) = 0; - v9 += 268; - } - while ( (signed int)v9 < (signed int)&unk_801A0C ); + + for (int i = 0; i < 20000; ++i) + { + array_77EC08[i].ptr_38 = &stru_8019C8; + + array_77EC08[i].prolly_head = nullptr; + array_77EC08[i].prolly_tail = nullptr; + array_77EC08[i].ptr_48 = nullptr; + } + MM7Initialization(); } @@ -5748,146 +5748,39 @@ return v1; } -//----- (0047BC6F) -------------------------------------------------------- -unsigned __int16 *__fastcall GetBillboardPalette(RenderBillboard *a1, int a2, signed int a3, int a4) -{ - int v4; // ebx@1 - int v6; // edx@4 - int v7; // ecx@5 - signed int v8; // eax@6 - signed __int64 v9; // qtt@11 - signed int v10; // eax@12 - int v11; // esi@17 - signed __int64 v12; // qtt@19 - double v13; // ST10_8@19 - int v14; // edi@25 - signed int v15; // edx@26 - signed __int64 v16; // qtt@29 - signed int v17; // eax@30 - int v18; // [sp+10h] [bp-8h]@1 - float a3a; // [sp+20h] [bp+8h]@19 - - v4 = a2; - v18 = a2; - if ( pParty->armageddon_timer ) - return PaletteManager::Get(a2); - if ( !pWeather->bNight ) - { - if (day_attrib & DAY_ATTRIB_FOG) - { - v14 = day_fogrange_1 << 16; - if ( a3 >= day_fogrange_1 << 16 ) - { - if ( a3 <= day_fogrange_2 << 16 ) - { - LODWORD(v16) = (a3 - v14) << 16; - HIDWORD(v16) = (a3 - v14) >> 16; - v15 = (unsigned __int64)(27 * v16 / ((day_fogrange_2 - day_fogrange_1) << 16)) >> 16; - } - else - { - v15 = 27; - } - } - else - { - v15 = 0; - } - v17 = _43F55F_get_billboard_light_level(a1, v15); - if ( v17 > 27 ) - v17 = 27; - if ( !a3 ) - v17 = 27; - v7 = v18; - v6 = v17; - return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1); - } - v11 = a4; - if ( a4 < 0 ) - v11 = 0; - LODWORD(v12) = a3 << 16; - HIDWORD(v12) = a3 >> 16; - a3a = (double)(signed int)(((unsigned __int64)(11 * v12 / (pOutdoorCamera->shading_dist_shade << 16)) >> 16) + 20) - * pOutdoor->fFogDensity; - v13 = a3a + 6.7553994e15; - v10 = _43F55F_get_billboard_light_level(a1, LODWORD(v13) + v11); - if ( v10 > 27 ) - v10 = 27; - if ( v10 < a4 ) - v10 = a4; - if ( v10 > pOutdoor->max_terrain_dimming_level ) - v10 = pOutdoor->max_terrain_dimming_level; - return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1); - } - v6 = 0; - if (pWeather->bNight) - { - v8 = 67108864; - if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0 ) - v8 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower << 26; - if ( a3 <= v8 ) - { - if ( a3 > 0 ) - { - LODWORD(v9) = a3 << 16; - HIDWORD(v9) = a3 >> 16; - v6 = (unsigned __int64)(27 * v9 / v8) >> 16; - } - } - else - { - v6 = 27; - } - v10 = _43F55F_get_billboard_light_level(a1, v6); - if ( v10 > 27 || !a3 ) - v10 = 27; - return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1); - } - v7 = 0; - return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1); -} //----- (0047C370) -------------------------------------------------------- -unsigned int __cdecl GetLevelFogColor() +unsigned int GetLevelFogColor() { - unsigned int result; // eax@2 signed __int64 v1; // qax@5 int v2; // eax@6 - if ( bUnderwater ) - { - result = 0xFF258F5C; - } - else - { - if (day_attrib & DAY_ATTRIB_FOG) - { + if (bUnderwater) + return 0xFF258F5C; + + if (day_attrib & DAY_ATTRIB_FOG) + { if ( pWeather->bNight ) // night-time fog { - __debugbreak(); // decompilation can be inaccurate, please send savegame to Nomad + __debugbreak(); // decompilation can be inaccurate, please send savegame to Nomad v2 = -(pWeather->bNight != 1); - result = (v2 & 0xE0E0E1) - 0xE0E0E1; + return (v2 & 0xE0E0E1) - 0xE0E0E1; } else { v1 = (signed __int64)((1.0 - pOutdoor->fFogDensity) * 200.0 + pOutdoor->fFogDensity * 31.0); - result = v1 | (((unsigned int)v1 | (((unsigned int)v1 | 0xFFFFFF00) << 8)) << 8); + return v1 | (((unsigned int)v1 | (((unsigned int)v1 | 0xFFFFFF00) << 8)) << 8); } - } - else - return 0; - } - return result; + } + + return 0; } -// 6BE030: using guessed type int day_attrib; -// 6BE3C4: using guessed type char bUnderwater; //----- (0047C3D7) -------------------------------------------------------- int __fastcall sub_47C3D7_get_fog_related_stuff(int a1, int a2, float a3) { int v3; // ecx@1 double v5; // st7@10 - signed int v6; // esi@10 signed int v7; // ecx@11 double v8; // st6@12 double v9; // st7@15 @@ -5903,44 +5796,73 @@ if ( v3 ) { v5 = (double)day_fogrange_1; - v6 = 216; if ( a3 < v5 ) - goto LABEL_11; - v8 = (double)day_fogrange_2; - if ( a3 > v8 ) - { -LABEL_13: - v7 = v6; - goto LABEL_19; - } - v7 = (signed __int64)((a3 - v5) / (v8 - v5) * 216.0); + { + v7 = 0; + if ( a3 == 0.0 ) + { + v7 = 216; + } + goto LABEL_21; + } + else + { + v8 = (double)day_fogrange_2; + if ( a3 > v8 ) + { + v7 = 216; + if ( a3 == 0.0 ) + { + v7 = 216; + } + goto LABEL_21; + } + v7 = (signed __int64)((a3 - v5) / (v8 - v5) * 216.0); + } } else { v9 = (double)day_fogrange_1; - v6 = 216; if ( a3 < v9 ) { -LABEL_11: v7 = 0; - goto LABEL_19; + if ( a3 == 0.0 ) + { + v7 = 216; + } + goto LABEL_21; } - v10 = (double)day_fogrange_2; - if ( a3 > v10 ) - goto LABEL_13; - v11 = (a3 - v9) * 216.0 / (v10 - v9); - v12 = v11 + 6.7553994e15; - v7 = LODWORD(v12); - } - if ( v7 > v6 ) - { -LABEL_20: - v7 = v6; - goto LABEL_21; - } -LABEL_19: - if ( a3 == 0.0 ) - goto LABEL_20; + else + { + v10 = (double)day_fogrange_2; + if ( a3 > v10 ) + { + v7 = 216; + if ( a3 == 0.0 ) + { + v7 = 216; + } + goto LABEL_21; + } + else + { + v11 = (a3 - v9) * 216.0 / (v10 - v9); + v12 = v11 + 6.7553994e15; + v7 = LODWORD(v12); + } + } + } + if ( v7 > 216 ) + { + v7 = 216; + } + else + { + if ( a3 == 0.0 ) + { + v7 = 216; + } + } LABEL_21: if ( a2 ) v7 = 248; @@ -6088,16 +6010,17 @@ // 6BE3C4: using guessed type char bUnderwater; //----- (0047F44B) -------------------------------------------------------- -unsigned int __stdcall WorldPosToGridCellX(signed int sWorldPosX) +unsigned int WorldPosToGridCellX(int sWorldPosX) { - return (sWorldPosX / 512) + 64; + return (sWorldPosX >> 9) + 64; // sar is in original exe, resulting -880 / 512 = -1 + // and -880 sar 9 = -2 } -// 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); //----- (0047F458) -------------------------------------------------------- -unsigned int __stdcall WorldPosToGridCellZ(signed int sWorldPosZ) +unsigned int WorldPosToGridCellZ(int sWorldPosZ) { - return 64 - (sWorldPosZ / 512); + return 64 - (sWorldPosZ >> 9); // sar is in original exe, resulting -880 / 512 = -1 + // and -880 sar 9 = -2 } //----- (0047F469) -------------------------------------------------------- @@ -6112,56 +6035,6 @@ return (64 - a1) << 9; } -//----- (0047F4D3) -------------------------------------------------------- -void __fastcall sub_47F4D3(int band1, int band2, int band3) -{ - int v3; // edi@1 - //stru220 *v4; // esi@1 - double v5; // ST2C_8@3 - double v6; // st7@3 - //double v7; // [sp+18h] [bp-28h]@3 - //double v8; // [sp+20h] [bp-20h]@2 - int v9; // [sp+34h] [bp-Ch]@1 - int v10; // [sp+38h] [bp-8h]@1 - //signed int band3a; // [sp+48h] [bp+8h]@2 - - v9 = band2 * 512; - pOutdoorCamera->outdoor_grid_band_3 = band3; - v10 = band1 * 512; - v3 = band3 * 512; - pOutdoorCamera->uPickDepth = band3 * 512; - //v4 = stru_76E5C8; // v4: 0 -> 65536 - for (uint i = 0; i < 16384; ++i) - //do - { - auto v4 = stru_76E5C8[i]; - //band3a = 256; - //v8 = (double)(signed int)((char *)v4 + 256 - (int)stru_76E5C8); - for (uint j = 0; j < 128; ++j) // band3a: 0 -> 128 - { - v5 = pow(j * 512 + 256, 2.0); - v6 = pow(i * 4 + 256, 2.0); - //*((float *)&v5 + 1) = sqrt(v6 + v5); - int v7 = floorf(sqrtf(v5 + v6) + 0.5f);//*((float *)&v5 + 1) + 6.7553994e15; - if (v7 >= v10) - { - if (v7 >= v9) - v4.field_0 = ((v7 >= v3) - 1) & 2; - else - v4.field_0 = 2; - } - else - { - v4.field_0 = 1; - } - //band3a += 512; - v4.distance = v7; - //++v4; - } - //while ( band3a < 65792 ); - } - //while ( (signed int)v4 < (signed int)arary_77E5C8 ); -} //----- (004811A3) -------------------------------------------------------- void Polygon::DrawBorderTiles() @@ -6178,24 +6051,15 @@ //----- (00481EB7) -------------------------------------------------------- -void __cdecl ResetPolygons() +void ResetPolygons() { - int v0; // ecx@1 - char *v1; // eax@2 - - v0 = pOutdoorCamera->uNumPolygons; - if ( pOutdoorCamera->uNumPolygons > 0 ) - { - v1 = (char *)&array_77EC08[0].prolly_tail; - do - { - *((int *)v1 - 1) = 0; - *(int *)v1 = 0; - *((int *)v1 - 5) = 0; - v1 += 268; - --v0; - } - while ( v0 ); + for (auto i = 0; i < pOutdoorCamera->uNumPolygons; ++i) + { + array_77EC08[i].prolly_head = nullptr; + array_77EC08[i].prolly_tail = nullptr; + + array_77EC08[i].flags = 0; + array_77EC08[i].field_32 = 0; } } @@ -6211,70 +6075,6 @@ pOutdoorCamera->field_44 = 0; } -//----- (00481EFA) -------------------------------------------------------- -bool __fastcall sub_481EFA(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, RenderVertexSoft *a4, int a5) -{ - RenderVertexSoft *v5; // esi@1 - RenderVertexSoft *v6; // edx@1 - bool v7; // edi@2 - bool v8; // ecx@5 - bool v9; // esi@8 - bool v10; // eax@11 - double v11; // st7@14 - signed int v12; // esi@15 - signed int v13; // edx@18 - signed int v14; // ecx@21 - signed int v15; // eax@24 - RenderVertexSoft *v17; // [sp+Ch] [bp-8h]@1 - - v5 = a2; - v6 = a1; - v17 = v5; - v7 = a1->vWorldViewPosition.x < 8.0; - v8 = v5->vWorldViewPosition.x < 8.0; - v9 = a3->vWorldViewPosition.x < 8.0; - v10 = a4->vWorldViewPosition.x < 8.0; - return !(v8 & v9 & v10 & v7) - && ((v11 = (double)pOutdoorCamera->shading_dist_mist, v11 > v6->vWorldViewPosition.x) ? (v12 = 0) : (v12 = 1), - v11 > v17->vWorldViewPosition.x ? (v13 = 0) : (v13 = 1), - v11 > a3->vWorldViewPosition.x ? (v14 = 0) : (v14 = 1), - v11 > a4->vWorldViewPosition.x ? (v15 = 0) : (v15 = 1), - !(v13 & v14 & v15 & v12)); -} - -//----- (00481FC9) -------------------------------------------------------- -int __fastcall sub_481FC9(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, struct Polygon *a4)//Rotate camera -{ - float arg_0, arg_4, var_4, var_8, var_c, var_10, var_14; - - if (a1->vWorldPosition.y == a2->vWorldPosition.y && a2->vWorldPosition.y == a3->vWorldPosition.y) - a4->flags |= 0x10; - var_c = a1->vWorldViewPosition.x - a2->vWorldViewPosition.x; - var_14 = a1->vWorldViewPosition.y - a2->vWorldViewPosition.y; - arg_0 = a1->vWorldViewPosition.z - a2->vWorldViewPosition.z; - var_10 = a3->vWorldViewPosition.x - a2->vWorldViewPosition.x; - var_8 = a3->vWorldViewPosition.y - a2->vWorldViewPosition.y; - var_4 = a3->vWorldViewPosition.z - a2->vWorldViewPosition.z; - arg_4 = a3->vWorldPosition.y - a2->vWorldPosition.y; - if (((a3->vWorldPosition.y - a2->vWorldPosition.y) * (a1->vWorldPosition.x - a2->vWorldPosition.x) - (a3->vWorldPosition.x - a2->vWorldPosition.x) * (a1->vWorldPosition.y - a2->vWorldPosition.y)) * (pIndoorCamera->pos.y - a2->vWorldPosition.z) + - ((a3->vWorldPosition.z - a2->vWorldPosition.z) * (a1->vWorldPosition.y - a2->vWorldPosition.y) - (a3->vWorldPosition.y - a2->vWorldPosition.y) * (a1->vWorldPosition.z - a2->vWorldPosition.z)) * (pIndoorCamera->pos.x - a2->vWorldPosition.x) + - ((a3->vWorldPosition.x - a2->vWorldPosition.x) * (a1->vWorldPosition.z - a2->vWorldPosition.z) - (a3->vWorldPosition.z - a2->vWorldPosition.z) * (a1->vWorldPosition.x - a2->vWorldPosition.x)) * (pIndoorCamera->pos.z - a2->vWorldPosition.y) < 0) - { - arg_4 = var_4 * var_14 - var_8 * arg_0; - a4->v_18.x = floorf(arg_4 + 0.5f); - arg_4 = var_10 * arg_0 - var_4 * var_c; - a4->v_18.y = floorf(arg_4 + 0.5f); - arg_4 = var_8 * var_c - var_10 * var_14; - a4->v_18.z = floorf(arg_4 + 0.5f); - a4->_486089_normalize_v_18(); - arg_4 = -(a4->v_18.x * a2->vWorldViewPosition.x) - a4->v_18.y * a2->vWorldViewPosition.y - a4->v_18.z * a2->vWorldViewPosition.z; - a4->field_24 = floorf(arg_4 + 0.5f); - return true; - } - else - return false; -} - //----- (004823F4) -------------------------------------------------------- bool IsTerrainSlopeTooHigh(int pos_x, int pos_z) { @@ -6469,50 +6269,28 @@ } //----- (00486089) -------------------------------------------------------- -void Polygon::_486089_normalize_v_18() +void Polygon::_normalize_v_18() { - //Polygon *v1; // esi@1 double v2; // st7@1 double v3; // st6@1 - float v4; // ST18_4@2 double v5; // st5@1 - float v6; // ST14_4@2 - double v7; // st7@1 - float v8; // ST24_4@2 - float v9; // ST20_4@2 - double v10; // ST0C_8@2 - float v11; // ST18_4@2 - double v12; // ST0C_8@2 - float v13; // ST14_4@2 - double v14; // ST0C_8@2 - float v15; // [sp+20h] [bp-8h]@1 //v1 = this; v2 = (double)this->v_18.x; - v15 = v2; v3 = (double)this->v_18.y; v5 = (double)this->v_18.z; - v7 = sqrt(v5 * v5 + v3 * v3 + v2 * v2); - if ( v7 == 0.0 ) - { - this->v_18.x = 0; - this->v_18.y = 0; - this->v_18.z = 65536; + float len = sqrt(v5 * v5 + v3 * v3 + v2 * v2); + if (fabsf(len) < 1e-6f) + { + v_18.x = 0; + v_18.y = 0; + v_18.z = 65536; } else { - v8 = 1.0 / v7; - v9 = v8 * v15 * 65536.0; - v10 = v9 + 6.7553994e15; - this->v_18.x = LODWORD(v10); - v4 = v3; - v11 = v8 * v4 * 65536.0; - v12 = v11 + 6.7553994e15; - this->v_18.y = LODWORD(v12); - v6 = v5; - v13 = v8 * v6 * 65536.0; - v14 = v13 + 6.7553994e15; - this->v_18.z = LODWORD(v14); + v_18.x = round(v2 / len * 65536.0); + v_18.y = round(v3 / len * 65536.0); + v_18.y = round(v5 / len * 65536.0); } } @@ -6651,58 +6429,6 @@ return result; } - -//----- (00440DF5) -------------------------------------------------------- -int stru167_wrap::Push(__int16 a2, __int16 a3, __int16 a4, int a5, __int16 bgr) -{ - int result; // eax@1 - - pElements[uNumElements].field_6_rnd_value = a2; - pElements[uNumElements].field_8_rnd_value = a3; - pElements[uNumElements].field_A_rnd_value = a4; - pElements[uNumElements].field_C_time_left = rand() % 64 + 256; - pElements[uNumElements].field_E_time_to_live = pElements[uNumElements].field_C_time_left; - result = 3 * uNumElements; - pElements[uNumElements++].bgr16 = bgr; - if (uNumElements >= 100 ) - uNumElements = 0; - return result; -} - -//----- (00440E91) -------------------------------------------------------- -void stru167_wrap::_440E91(__int16 x, int y, int z, int a5, __int16 bgr) -{ - stru167_wrap *v6; // edi@1 - int i; // esi@1 - int v8; // ST08_4@2 - int v9; // ST04_4@2 - int v10; // eax@2 - - v6 = this; - for ( i = 0; i < rand() % 6 + 5; ++i ) - { - v8 = z + rand() % 33; - v9 = rand() % 33 + y - 16; - v10 = rand(); - Push(v10 % 33 + x - 16, v9, v8, a5, bgr); - } -} - -//----- (00440F07) -------------------------------------------------------- -void stru167_wrap::_440F07() -{ - for (uint i = 0; i < 100; ++i) - { - if (pElements[i].field_C_time_left > 0) - { - pElements[i].field_A_rnd_value += rand() % 5 + 4; - pElements[i].field_6_rnd_value += rand() % 5 - 2; - pElements[i].field_8_rnd_value += rand() % 5 - 2; - pElements[i].field_C_time_left -= (short)pEventTimer->uTimeElapsed; - } - } -} - //----- (0044100D) -------------------------------------------------------- bool sub_44100D() { @@ -6835,126 +6561,126 @@ { if ( !_strnicmp(test_string, "wea", 3) ) { - p2DEvents[i].uType = BildingType_WeaponShop; + p2DEvents[i].uType = BuildingType_WeaponShop; break; } if ( !_strnicmp(test_string, "arm", 3) ) { - p2DEvents[i].uType = BildingType_ArmorShop; + p2DEvents[i].uType = BuildingType_ArmorShop; break; } if ( !_strnicmp(test_string, "mag", 3) ) { - p2DEvents[i].uType = BildingType_MagicShop; + p2DEvents[i].uType = BuildingType_MagicShop; break; } if ( !_strnicmp(test_string, "alc", 3) ) { - p2DEvents[i].uType = BildingType_AlchemistShop; + p2DEvents[i].uType = BuildingType_AlchemistShop; break; } if ( !_strnicmp(test_string, "sta", 3) ) { - p2DEvents[i].uType = BildingType_Stables; + p2DEvents[i].uType = BuildingType_Stables; break; } if ( !_strnicmp(test_string, "boa", 3) ) { - p2DEvents[i].uType = BildingType_Boats; + p2DEvents[i].uType = BuildingType_Boats; break; } if ( !_strnicmp(test_string, "tem", 3) ) { - p2DEvents[i].uType = BildingType_Temple; + p2DEvents[i].uType = BuildingType_Temple; break; } if ( !_strnicmp(test_string, "tra", 3) ) { - p2DEvents[i].uType = BildingType_Training; + p2DEvents[i].uType = BuildingType_Training; break; } if ( !_strnicmp(test_string, "tow", 3) ) { - p2DEvents[i].uType = BildingType_TownHall; + p2DEvents[i].uType = BuildingType_TownHall; break; } if ( !_strnicmp(test_string, "tav", 3) ) { - p2DEvents[i].uType = BildingType_Tavern; + p2DEvents[i].uType = BuildingType_Tavern; break; } if ( !_strnicmp(test_string, "ban", 3) ) { - p2DEvents[i].uType = BildingType_Bank; + p2DEvents[i].uType = BuildingType_Bank; break; } if ( !_strnicmp(test_string, "fir", 3) ) { - p2DEvents[i].uType = BildingType_FireGuild; + p2DEvents[i].uType = BuildingType_FireGuild; break; } if ( !_strnicmp(test_string, "air", 3) ) { - p2DEvents[i].uType = BildingType_AirGuild; + p2DEvents[i].uType = BuildingType_AirGuild; break; } if ( !_strnicmp(test_string, "wat", 3) ) { - p2DEvents[i].uType = BildingType_WaterGuild; + p2DEvents[i].uType = BuildingType_WaterGuild; break; } if ( !_strnicmp(test_string, "ear", 3) ) { - p2DEvents[i].uType = BildingType_EarthGuild; + p2DEvents[i].uType = BuildingType_EarthGuild; break; } if ( !_strnicmp(test_string, "spi", 3) ) { - p2DEvents[i].uType = BildingType_SpiritGuild; + p2DEvents[i].uType = BuildingType_SpiritGuild; break; } if ( !_strnicmp(test_string, "min", 3) ) { - p2DEvents[i].uType = BildingType_MindGuild; + p2DEvents[i].uType = BuildingType_MindGuild; break; } if ( !_strnicmp(test_string, "bod", 3) ) { - p2DEvents[i].uType = BildingType_BodyGuild; + p2DEvents[i].uType = BuildingType_BodyGuild; break; } if ( !_strnicmp(test_string, "lig", 3) ) { - p2DEvents[i].uType = BildingType_LightGuild; + p2DEvents[i].uType = BuildingType_LightGuild; break; } if ( !_strnicmp(test_string, "dar", 3) ) { - p2DEvents[i].uType = BildingType_DarkGuild; + p2DEvents[i].uType = BuildingType_DarkGuild; break; } if ( !_strnicmp(test_string, "ele", 3) ) { - p2DEvents[i].uType = BildingType_14; + p2DEvents[i].uType = BuildingType_14; break; } if ( !_strnicmp(test_string, "sel", 3) ) { - p2DEvents[i].uType = BildingType_15; + p2DEvents[i].uType = BuildingType_15; break; } if ( !_strnicmp(test_string, "mir", 3) ) { - p2DEvents[i].uType = BildingType_16; + p2DEvents[i].uType = BuildingType_16; break; } if ( !_strnicmp(test_string, "mer", 3) ) { - p2DEvents[i].uType = BildingType_TownHall; + p2DEvents[i].uType = BuildingType_TownHall; break; } - p2DEvents[i].uType = BildingType_18; + p2DEvents[i].uType = BuildingType_18; } break; @@ -7243,7 +6969,7 @@ } //----- (00444360) -------------------------------------------------------- -void __thiscall Level_LoadEvtAndStr(const char *pLevelName) +void Level_LoadEvtAndStr(const char *pLevelName) { char pContainerName[120]; // [sp+8h] [bp-98h]@1 @@ -7341,7 +7067,7 @@ } //----- (00444D80) -------------------------------------------------------- -signed int __cdecl GetTravelTime() +int GetTravelTime() { signed int v0; // esi@1