Mercurial > mm7
changeset 869:715064ae1792
Слияние
author | Ritor1 |
---|---|
date | Mon, 01 Apr 2013 09:05:51 +0600 |
parents | 6759478c2f14 (current diff) 54f191fc5e1e (diff) |
children | a0ae8d36c2d6 |
files | GameUIs.cpp mm7_3.cpp |
diffstat | 29 files changed, 1513 insertions(+), 1706 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/Actor.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -377,7 +377,7 @@ } //----- (00404AC7) -------------------------------------------------------- -void __fastcall Actor::_404AC7(unsigned int uActorID, AIDirection *pDir, int spellnum, int a4, unsigned int uSkillLevel) +void __fastcall Actor::SpellAttack(unsigned int uActorID, AIDirection *pDir, int spellnum, int a4, unsigned int uSkillLevel) { Actor *v5; // esi@1 unsigned int v6; // edi@1 @@ -781,7 +781,7 @@ v24 = (double)v118; v118 = v23; v112 = v24; - v116 = 8 * LODWORD(v120) | 3; + v116 = PID(OBJECT_Actor,LODWORD(v120)); do { v26 = rand(); @@ -915,7 +915,7 @@ v102 = 0; v40 = 8 * LODWORD(v120); v101 = -1; - LOBYTE(v40) = 8 * LOBYTE(v120) | 3; + LOBYTE(v40) = PID(OBJECT_Actor,LOBYTE(v120)); v100 = 0; v99 = v40; v98 = (SoundID)10040; @@ -968,7 +968,7 @@ v102 = 0; v43 = 8 * LODWORD(v120); v101 = -1; - LOBYTE(v43) = 8 * LOBYTE(v120) | 3; + LOBYTE(v43) = PID(OBJECT_Actor,LOBYTE(v120)); v100 = 0; v99 = v43; v98 = (SoundID)14010; @@ -1007,7 +1007,7 @@ v102 = 0; v46 = 8 * LODWORD(v120); v101 = -1; - LOBYTE(v46) = 8 * LOBYTE(v120) | 3; + LOBYTE(v46) = PID(OBJECT_Actor,LOBYTE(v120)); v100 = 0; v99 = v46; v98 = (SoundID)13040; @@ -1050,7 +1050,7 @@ v50 = 8 * LODWORD(v120); v102 = v47; v101 = -1; - LOBYTE(v50) = 8 * LOBYTE(v120) | 3; + LOBYTE(v50) = PID(OBJECT_Actor,LOBYTE(v120)); v100 = v47; v99 = v50; v98 = (SoundID)14020; @@ -1102,7 +1102,7 @@ v65 = 8 * LODWORD(v120); v102 = 0; v101 = -1; - LOBYTE(v65) = 8 * LOBYTE(v120) | 3; + LOBYTE(v65) = PID(OBJECT_Actor,LOBYTE(v120)); v100 = 0; v99 = v65; v22 = (SoundID)word_4EE088_sound_ids[80]; @@ -1131,7 +1131,7 @@ v102 = 0; v52 = 8 * LODWORD(v120); v101 = -1; - LOBYTE(v52) = 8 * LOBYTE(v120) | 3; + LOBYTE(v52) = PID(OBJECT_Actor,LOBYTE(v120)); v100 = 0; v99 = v52; v98 = (SoundID)16060; @@ -1185,7 +1185,7 @@ v102 = 0; v55 = 8 * LODWORD(v120); v101 = -1; - LOBYTE(v55) = 8 * LOBYTE(v120) | 3; + LOBYTE(v55) = PID(OBJECT_Actor,LOBYTE(v120)); v100 = 0; v99 = v55; v98 = (SoundID)14060; @@ -1228,7 +1228,7 @@ v102 = 0; v97 = 8 * LODWORD(v120); v101 = -1; - LOBYTE(v97) = 8 * LOBYTE(v120) | 3; + LOBYTE(v97) = PID(OBJECT_Actor,LOBYTE(v120)); v100 = 0; v99 = v97; v98 = (SoundID)17070; @@ -1272,7 +1272,7 @@ v102 = 0; v95 = 8 * LODWORD(v120); v101 = -1; - LOBYTE(v95) = 8 * LOBYTE(v120) | 3; + LOBYTE(v95) = PID(OBJECT_Actor,LOBYTE(v120)); v100 = 0; v99 = v95; v98 = (SoundID)17080; @@ -1319,7 +1319,7 @@ v102 = 0; v69 = 8 * LODWORD(v120); v101 = -1; - LOBYTE(v69) = 8 * LOBYTE(v120) | 3; + LOBYTE(v69) = PID(OBJECT_Actor,LOBYTE(v120)); v100 = 0; v99 = v69; v98 = (SoundID)18060; @@ -1482,7 +1482,7 @@ } //----- (00404874) -------------------------------------------------------- -char __fastcall Actor::_404874(unsigned int uActorID, AIDirection *a2, int a3, char a4) +char __fastcall Actor::RangedAttack(unsigned int uActorID, AIDirection *a2, int a3, char a4) { AIDirection *v4; // edi@1 Actor *v5; // esi@1 @@ -1757,174 +1757,189 @@ int outx; // [sp+48h] [bp-4h]@6 float a4a; // [sp+58h] [bp+Ch]@45 - v4 = (signed int)uObj1ID >> 3; - v5 = (uObj1ID & 7) - 2; + v4 = PID_ID(uObj1ID); + v5 = PID_TYPE(uObj1ID); v6 = uObj2ID; - if ( !v5 ) - { - v19 = v4; - outx = pSpriteObjects[v19].vPosition.x; - v13 = pSpriteObjects[v19].vPosition.y; - v14 = pSpriteObjects[v19].vPosition.z; - goto LABEL_26; - } - v7 = v5 - 1; - if ( !v7 ) - { - outx = pActors[v4].vPosition.x; - outy = pActors[v4].vPosition.y; - LODWORD(v42) = pActors[v4].uActorHeight; - v11 = pActors[v4].vPosition.z - (unsigned int)(signed __int64)((double)SLODWORD(v42) * -0.75); - goto LABEL_24; - } - v8 = v7 - 1; - if ( !v8 ) + switch(v5) { - if ( !v4 ) - { - outx = pParty->vPosition.x; - outy = pParty->vPosition.y; - v14 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; -LABEL_27: - outz = v14; - goto LABEL_28; - } - v15 = v4 - 1; - if ( v15 ) - { - v16 = v15 - 1; - if ( v16 ) - { - v17 = v16 - 1; - if ( v17 ) - { - if ( v17 != 1 ) - goto LABEL_28; - v40 = &outz; - v39 = &outy; - v38 = &outx; - v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi; - v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - goto LABEL_20; - } - v40 = &outz; - v39 = &outy; - v38 = &outx; - v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi; - v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - } - else - { - v40 = &outz; - v39 = &outy; - v38 = &outx; - v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY; - } - *(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x; - v36 = 0; - v35 = 8; -LABEL_21: - Vec3_int_::Rotate(v35, v18, v36, v37, v38, v39, v40); - goto LABEL_28; - } - v40 = &outz; - v39 = &outy; - v38 = &outx; - v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY; -LABEL_20: - *(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x; - v36 = 0; - v35 = 24; - goto LABEL_21; + case OBJECT_Item: + { + v19 = v4; + outx = pSpriteObjects[v19].vPosition.x; + v13 = pSpriteObjects[v19].vPosition.y; + v14 = pSpriteObjects[v19].vPosition.z; + outy = v13; + outz = v14; + break; + } + case OBJECT_Actor: + { + outx = pActors[v4].vPosition.x; + outy = pActors[v4].vPosition.y; + LODWORD(v42) = pActors[v4].uActorHeight; + v11 = pActors[v4].vPosition.z - (unsigned int)(signed __int64)((double)SLODWORD(v42) * -0.75); + outz = v11; + break; + } + case OBJECT_Player: + { + if ( !v4 ) + { + outx = pParty->vPosition.x; + outy = pParty->vPosition.y; + v14 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + outz = v14; + break;; + } + if ( v4 == 4 ) + { + v40 = &outz; + v39 = &outy; + v38 = &outx; + v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi; + v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + *(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x; + v36 = 0; + v35 = 24; + Vec3_int_::Rotate(v35, v18, v36, v37, v38, v39, v40); + break; + } + if ( v4 == 3 ) + { + v40 = &outz; + v39 = &outy; + v38 = &outx; + v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi; + v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + *(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x; + v36 = 0; + v35 = 8; + Vec3_int_::Rotate(v35, v18, v36, v37, v38, v39, v40); + break; + } + if ( v4 == 2 ) + { + v40 = &outz; + v39 = &outy; + v38 = &outx; + v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY; + *(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x; + v36 = 0; + v35 = 8; + Vec3_int_::Rotate(v35, v18, v36, v37, v38, v39, v40); + break; + } + if ( v4 == 1 ) + { + v40 = &outz; + v39 = &outy; + v38 = &outx; + v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY; + *(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x; + v36 = 0; + v35 = 24; + Vec3_int_::Rotate(v35, v18, v36, v37, v38, v39, v40); + break; + } + } + case OBJECT_Decoration: + { + v12 = v4; + outx = pLevelDecorations[v12].vPosition.x; + v13 = pLevelDecorations[v12].vPosition.y; + v14 = pLevelDecorations[v12].vPosition.z; + outy = v13; + outz = v14; + break; + } + default: + { + outz = 0; + outy = 0; + outx = 0; + break; + } + case OBJECT_BModel: + { + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + { + v10 = &pIndoor->pFaces[v4]; + outx = (v10->pBounding.x1 + v10->pBounding.x2) >> 1; + outy = (v10->pBounding.y1 + v10->pBounding.y2) >> 1; + v11 = (v10->pBounding.z1 + v10->pBounding.z2) >> 1; + outz = v11; + } + break; + } } - v9 = v8 - 1; - if ( !v9 ) - { - v12 = v4; - outx = pLevelDecorations[v12].vPosition.x; - v13 = pLevelDecorations[v12].vPosition.y; - v14 = pLevelDecorations[v12].vPosition.z; -LABEL_26: - outy = v13; - goto LABEL_27; - } - if ( v9 != 1 ) - { - outz = 0; - outy = 0; - outx = 0; - goto LABEL_28; - } - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - { - v10 = &pIndoor->pFaces[v4]; - outx = (v10->pBounding.x1 + v10->pBounding.x2) >> 1; - outy = (v10->pBounding.y1 + v10->pBounding.y2) >> 1; - v11 = (v10->pBounding.z1 + v10->pBounding.z2) >> 1; -LABEL_24: - outz = v11; - } -LABEL_28: v20 = v6; - v21 = v6 & 7; - v22 = v20 >> 3; - if ( v21 == 2 ) - { - v30 = v22; - LODWORD(v45) = pSpriteObjects[v30].vPosition.x; - v27 = pSpriteObjects[v30].vPosition.y; - v28 = pSpriteObjects[v30].vPosition.z; - goto LABEL_43; - } - if ( v21 == 3 ) + v21 = PID_TYPE(v6); + v22 = PID_ID(v20); + switch(v6) { - LODWORD(v45) = pActors[v22].vPosition.x; - LODWORD(v44) = pActors[v22].vPosition.y; - v25 = pActors[v22].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v22].uActorHeight * -0.75); - goto LABEL_41; - } - if ( v21 == 4 ) - { - LODWORD(v45) = pParty->vPosition.x; - LODWORD(v44) = pParty->vPosition.y; - v29 = a4; - if ( !a4 ) - v29 = pParty->sEyelevel; - v28 = pParty->vPosition.z + v29; - goto LABEL_44; + case OBJECT_Item: + { + v30 = v22; + LODWORD(v45) = pSpriteObjects[v30].vPosition.x; + v27 = pSpriteObjects[v30].vPosition.y; + v28 = pSpriteObjects[v30].vPosition.z; + LODWORD(v44) = v27; + a4 = v28; + break; + } + case OBJECT_Actor: + { + LODWORD(v45) = pActors[v22].vPosition.x; + LODWORD(v44) = pActors[v22].vPosition.y; + v25 = pActors[v22].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v22].uActorHeight * -0.75); + a4 = v25; + break; + } + case OBJECT_Player: + { + LODWORD(v45) = pParty->vPosition.x; + LODWORD(v44) = pParty->vPosition.y; + v29 = a4; + if ( !a4 ) + v29 = pParty->sEyelevel; + v28 = pParty->vPosition.z + v29; + a4 = v28; + break; + } + case OBJECT_Decoration: + { + v26 = v22; + LODWORD(v45) = pLevelDecorations[v26].vPosition.x; + v27 = pLevelDecorations[v26].vPosition.y; + v28 = pLevelDecorations[v26].vPosition.z; + LODWORD(v44) = v27; + a4 = v28; + break; + } + default: + { + a4 = 0; + v44 = 0.0; + v45 = 0.0; + break; + } + case OBJECT_BModel: + { + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + { + v23 = &pIndoor->pFaces[v22]; + v24 = v23->pBounding.y1; + LODWORD(v45) = (v23->pBounding.x1 + v23->pBounding.x2) >> 1; + LODWORD(v44) = (v24 + v23->pBounding.y2) >> 1; + v25 = (v23->pBounding.z1 + v23->pBounding.z2) >> 1; + a4 = v25; + } + break; + } } - if ( v21 == 5 ) - { - v26 = v22; - LODWORD(v45) = pLevelDecorations[v26].vPosition.x; - v27 = pLevelDecorations[v26].vPosition.y; - v28 = pLevelDecorations[v26].vPosition.z; -LABEL_43: - LODWORD(v44) = v27; -LABEL_44: - a4 = v28; - goto LABEL_45; - } - if ( v21 != 6 ) - { - a4 = 0; - v44 = 0.0; - v45 = 0.0; - goto LABEL_45; - } - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - { - v23 = &pIndoor->pFaces[v22]; - v24 = v23->pBounding.y1; - LODWORD(v45) = (v23->pBounding.x1 + v23->pBounding.x2) >> 1; - LODWORD(v44) = (v24 + v23->pBounding.y2) >> 1; - v25 = (v23->pBounding.z1 + v23->pBounding.z2) >> 1; -LABEL_41: - a4 = v25; - } -LABEL_45: + v31 = (double)SLODWORD(v45) - (double)outx; v42 = v31; v32 = (double)SLODWORD(v44) - (double)outy; @@ -2050,7 +2065,7 @@ } //----- (00403C6C) -------------------------------------------------------- -void Actor::_403C6C(unsigned int uActorID, signed int edx0, struct AIDirection *arg0) +void Actor::MeleeAttack(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0) { Actor *v3; // ebx@1 char v4; // zf@1 @@ -2071,85 +2086,82 @@ AIDirection a3; // [sp+Ch] [bp-48h]@12 AIDirection v20; // [sp+28h] [bp-2Ch]@12 unsigned int v21; // [sp+44h] [bp-10h]@9 - signed int a2; // [sp+48h] [bp-Ch]@1 + //signed int a2; // [sp+48h] [bp-Ch]@1 int v23; // [sp+4Ch] [bp-8h]@6 unsigned int v24; // [sp+50h] [bp-4h]@1 unsigned int v25; // [sp+5Ch] [bp+8h]@13 v3 = &pActors[uActorID]; - a2 = edx0; + //a2 = edx0; v4 = v3->pMonsterInfo.uMovementType == 5; v24 = uActorID; if ( v4 && v3->pMonsterInfo.uAIType == 1 ) { - Actor::AI_Stand(uActorID, edx0, 0, arg0); + Actor::AI_Stand(uActorID, sTargetPid, 0, arg0); return; } - if ( (edx0 & 7) == OBJECT_Actor) - { - v8 = edx0 >> 3; - v6 = (AIDirection *)pActors[v8].vPosition.x; - v7 = (AIDirection *)pActors[v8].vPosition.y; - v23 = (signed __int64)((double)pActors[v8].uActorHeight * 0.75 + (double)pActors[v8].vPosition.z); - } - else + if ( PID_TYPE(sTargetPid) == OBJECT_Actor) + { + v8 = PID_ID(sTargetPid); + v6 = (AIDirection *)pActors[v8].vPosition.x; + v7 = (AIDirection *)pActors[v8].vPosition.y; + v23 = (signed __int64)((double)pActors[v8].uActorHeight * 0.75 + (double)pActors[v8].vPosition.z); + } + else if ( PID_TYPE(sTargetPid) == OBJECT_Player) + { + v6 = (AIDirection *)pParty->vPosition.x; + v7 = (AIDirection *)pParty->vPosition.y; + v23 = pParty->vPosition.z + pParty->sEyelevel; + } + else + { + v6 = arg0; + v7 = arg0; + } + v21 = v3->uActorHeight; + v9 = (double)(signed int)v21 * 0.75; + v21 = v3->vPosition.z; + v10.z = (signed __int64)(v9 + (double)(signed int)v21); + v10.y = v3->vPosition.y; + v10.x = v3->vPosition.x; + if ( sub_407A1C((int)v6, (int)v7, v23, v10) ) + { + v12 = arg0; + v13 = 0; + if ( !arg0 ) { - if ( (edx0 & 7) == OBJECT_Player) - { - v6 = (AIDirection *)pParty->vPosition.x; - v7 = (AIDirection *)pParty->vPosition.y; - v23 = pParty->vPosition.z + pParty->sEyelevel; - } - else - { - v6 = arg0; - v7 = arg0; - } - } - v21 = v3->uActorHeight; - v9 = (double)(signed int)v21 * 0.75; - v21 = v3->vPosition.z; - v10.z = (signed __int64)(v9 + (double)(signed int)v21); - v10.y = v3->vPosition.y; - v10.x = v3->vPosition.x; - if ( sub_407A1C((int)v6, (int)v7, v23, v10) ) - { - v12 = arg0; - v13 = 0; - if ( !arg0 ) - { - v14 = Actor::GetDirectionInfo(PID(OBJECT_Actor, v24), a2, &a3, 0); + v14 = Actor::GetDirectionInfo(PID(OBJECT_Actor, v24), sTargetPid, &a3, 0); v12 = &v20; memcpy(&v20, v14, sizeof(v20)); v13 = 0; - } - v15 = pSpriteFrameTable->pSpriteSFrames; - v3->uYawAngle = LOWORD(v12->uYawAngle); - v16 = v15[v3->pSpriteIDs[ANIM_AtkMelee]].uAnimLength; - v17 = v24; - v3->uCurrentActionLength = 8 * v16; - v3->uCurrentActionTime = v13; - v3->uAIState = AttackingMelee; - Actor::PlaySound(v17, 0); - LODWORD(v18) = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; - v25 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; - if ( SHIDWORD(v3->pActorBuffs[7].uExpireTime) >= (signed int)v13 - && (SHIDWORD(v3->pActorBuffs[7].uExpireTime) > (signed int)v13 || LODWORD(v3->pActorBuffs[7].uExpireTime) > v13) ) - { - LODWORD(v18) = 2 * v18; + } + v15 = pSpriteFrameTable->pSpriteSFrames; + v3->uYawAngle = LOWORD(v12->uYawAngle); + v16 = v15[v3->pSpriteIDs[ANIM_AtkMelee]].uAnimLength; + v17 = v24; + v3->uCurrentActionLength = 8 * v16; + v3->uCurrentActionTime = v13; + v3->uAIState = AttackingMelee; + Actor::PlaySound(v17, 0); + LODWORD(v18) = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; + v25 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; + if ( SHIDWORD(v3->pActorBuffs[7].uExpireTime) >= (signed int)v13 + && (SHIDWORD(v3->pActorBuffs[7].uExpireTime) > (signed int)v13 || LODWORD(v3->pActorBuffs[7].uExpireTime) > v13) ) + { + LODWORD(v18) = 2 * v18; v25 = v18; - } - if ( pParty->bTurnBasedModeOn != 1 ) + } + if ( pParty->bTurnBasedModeOn != 1 ) v18 = (signed __int64)(flt_6BE3A8_debug_recmod2 * (double)(signed int)v25 * 2.133333333333333); - v3->pMonsterInfo.uRecoveryTime = v18; - v3->vVelocity.z = v13; - v3->vVelocity.y = v13; - v3->vVelocity.x = v13; - v3->UpdateAnimation(); - } - else - Actor::_402AD7(v24, a2, rand() % 2, 64, arg0); + v3->pMonsterInfo.uRecoveryTime = v18; + v3->vVelocity.z = v13; + v3->vVelocity.y = v13; + v3->vVelocity.x = v13; + v3->UpdateAnimation(); + } + else + Actor::Pursue1(v24, sTargetPid, rand() % 2, 64, arg0); } //----- (00438CF3) -------------------------------------------------------- @@ -2231,7 +2243,7 @@ __int16 v9; // [sp-4h] [bp-8h]@3 result = a2 - 1; - v4 = 8 * uActorID | 3; + v4 = PID(OBJECT_Actor,uActorID); switch ( a2 ) { case 1: @@ -2282,42 +2294,42 @@ v9 = 4; v8 = 65536; v7 = 0; - v6 = 8 * uActorID | 3; + v6 = PID(OBJECT_Actor,uActorID); v5 = 901; goto LABEL_16; case 6: v9 = 4; v8 = 65536; v7 = 0; - v6 = 8 * uActorID | 3; + v6 = PID(OBJECT_Actor,uActorID); v5 = 902; goto LABEL_16; case 7: v9 = 4; v8 = 65536; v7 = 0; - v6 = 8 * uActorID | 3; + v6 = PID(OBJECT_Actor,uActorID); v5 = 903; goto LABEL_16; case 8: v9 = 4; v8 = 65536; v7 = 0; - v6 = 8 * uActorID | 3; + v6 = PID(OBJECT_Actor,uActorID); v5 = 900; goto LABEL_16; case 9: v9 = 4; v8 = 65536; v7 = 0; - v6 = 8 * uActorID | 3; + v6 = PID(OBJECT_Actor,uActorID); v5 = 909; goto LABEL_16; case 10: v9 = 4; v8 = 65536; v7 = 0; - v6 = 8 * uActorID | 3; + v6 = PID(OBJECT_Actor,uActorID); v5 = 908; LABEL_16: result = pOtherOverlayList->_4418B6(v5, v6, v7, v8, v9); @@ -2455,7 +2467,7 @@ } //----- (00403A60) -------------------------------------------------------- -void Actor::_403A60(unsigned int uActorID, signed int edx0, AIDirection *pDir) +void Actor::SpellAttack2(unsigned int uActorID, signed int edx0, AIDirection *pDir) { Actor *v3; // ebx@1 AIDirection *v4; // esi@3 @@ -2482,16 +2494,16 @@ v22 = uActorID; v3 = &pActors[uActorID]; a2 = edx0; - if ( (edx0 & 7) == OBJECT_Actor) + if ( PID_TYPE(edx0) == OBJECT_Actor) { - v6 = edx0 >> 3; + v6 = PID_ID(edx0); v4 = (AIDirection *)pActors[v6].vPosition.x; v5 = (AIDirection *)pActors[v6].vPosition.y; v21 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z); } else { - if ( (edx0 & 7) == OBJECT_Player) + if ( PID_TYPE(edx0) == OBJECT_Player) { v4 = (AIDirection *)pParty->vPosition.x; v5 = (AIDirection *)pParty->vPosition.y; @@ -2513,7 +2525,7 @@ v10 = 0; if ( !pDir ) { - v11 = Actor::GetDirectionInfo(8 * v22 | OBJECT_Actor, a2, &a3, 0); + v11 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v22), a2, &a3, 0); v9 = &v18; memcpy(&v18, v11, sizeof(v18)); v10 = 0; @@ -2557,11 +2569,11 @@ v3->UpdateAnimation(); } else - Actor::_402AD7(v22, a2, v22, 64, pDir); + Actor::Pursue1(v22, a2, v22, 64, pDir); } //----- (00403854) -------------------------------------------------------- -void Actor::_403854(unsigned int uActorID, signed int edx0, AIDirection *pDir) +void Actor::SpellAttack1(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) { Actor *v3; // ebx@1 AIDirection *v4; // esi@3 @@ -2580,24 +2592,24 @@ AIDirection a3; // [sp+Ch] [bp-48h]@9 AIDirection v18; // [sp+28h] [bp-2Ch]@9 int v19; // [sp+44h] [bp-10h]@6 - signed int a2; // [sp+48h] [bp-Ch]@1 + //signed int a2; // [sp+48h] [bp-Ch]@1 int v21; // [sp+4Ch] [bp-8h]@3 unsigned int v22; // [sp+50h] [bp-4h]@1 unsigned int pDira; // [sp+5Ch] [bp+8h]@10 v22 = uActorID; v3 = &pActors[uActorID]; - a2 = edx0; - if ( (edx0 & 7) == OBJECT_Actor) + //a2 = edx0; + if ( PID_TYPE(sTargetPid) == OBJECT_Actor) { - v6 = edx0 >> 3; + v6 = PID_ID(sTargetPid); v4 = (AIDirection *)pActors[v6].vPosition.x; v5 = (AIDirection *)pActors[v6].vPosition.y; v21 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z); } else { - if ( (edx0 & 7) == OBJECT_Player) + if ( PID_TYPE(sTargetPid) == OBJECT_Player) { v4 = (AIDirection *)pParty->vPosition.x; v5 = (AIDirection *)pParty->vPosition.y; @@ -2619,7 +2631,7 @@ v10 = 0; if ( !pDir ) { - v11 = Actor::GetDirectionInfo(8 * v22 | OBJECT_Actor, a2, &a3, 0); + v11 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v22), sTargetPid, &a3, 0); v9 = &v18; memcpy(&v18, v11, sizeof(v18)); v10 = 0; @@ -2663,11 +2675,11 @@ v3->UpdateAnimation(); } else - Actor::_402AD7(v22, a2, v22, 64, pDir); + Actor::Pursue1(v22, sTargetPid, v22, 64, pDir); } //----- (0040368B) -------------------------------------------------------- -void Actor::_40368B(unsigned int uActorID, signed int edx0, AIDirection *pDir) +void Actor::MissileAttack2(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) { Actor *v3; // ebx@1 AIDirection *v4; // esi@3 @@ -2685,24 +2697,24 @@ AIDirection a3; // [sp+Ch] [bp-48h]@9 AIDirection v17; // [sp+28h] [bp-2Ch]@9 int v18; // [sp+44h] [bp-10h]@6 - signed int a2; // [sp+48h] [bp-Ch]@1 + //signed int a2; // [sp+48h] [bp-Ch]@1 int v20; // [sp+4Ch] [bp-8h]@3 unsigned int v21; // [sp+50h] [bp-4h]@1 unsigned int pDira; // [sp+5Ch] [bp+8h]@10 v21 = uActorID; v3 = &pActors[uActorID]; - a2 = edx0; - if ( (edx0 & 7) == OBJECT_Actor) + //a2 = edx0; + if ( PID_TYPE(sTargetPid) == OBJECT_Actor) { - v6 = edx0 >> 3; + v6 = PID_ID(sTargetPid); v4 = (AIDirection *)pActors[v6].vPosition.x; v5 = (AIDirection *)pActors[v6].vPosition.y; v20 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z); } else { - if ( (edx0 & 7) == OBJECT_Player) + if ( PID_TYPE(sTargetPid) == OBJECT_Player) { v4 = (AIDirection *)pParty->vPosition.x; v5 = (AIDirection *)pParty->vPosition.y; @@ -2724,7 +2736,7 @@ v10 = 0; if ( !pDir ) { - v11 = Actor::GetDirectionInfo(8 * v21 | OBJECT_Actor, a2, &a3, 0); + v11 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v21), sTargetPid, &a3, 0); v9 = &v17; memcpy(&v17, v11, sizeof(v17)); v10 = 0; @@ -2754,11 +2766,11 @@ v3->UpdateAnimation(); } else - Actor::_402AD7(v21, a2, v21, 64, pDir); + Actor::Pursue1(v21, sTargetPid, v21, 64, pDir); } //----- (00403476) -------------------------------------------------------- -void Actor::_403476(unsigned int uActorID, signed int edx0, AIDirection *pDir) +void Actor::MissileAttack1(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) { Actor *v3; // ebx@1 int v4; // esi@3 @@ -2777,24 +2789,24 @@ AIDirection a3; // [sp+Ch] [bp-48h]@10 AIDirection v18; // [sp+28h] [bp-2Ch]@10 int v19; // [sp+44h] [bp-10h]@6 - signed int a2; // [sp+48h] [bp-Ch]@1 + //signed int a2; // [sp+48h] [bp-Ch]@1 unsigned int v21; // [sp+4Ch] [bp-8h]@1 int v22; // [sp+50h] [bp-4h]@3 unsigned int pDira; // [sp+5Ch] [bp+8h]@11 v21 = uActorID; v3 = &pActors[uActorID]; - a2 = edx0; - if ( (edx0 & 7) == OBJECT_Actor) + //a2 = edx0; + if ( PID_TYPE(sTargetPid) == OBJECT_Actor) { - v6 = edx0 >> 3; + v6 = PID_ID(sTargetPid); v4 = pActors[v6].vPosition.x; v5 = pActors[v6].vPosition.y; v22 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z); } else { - if ( (edx0 & 7) == OBJECT_Player) + if ( PID_TYPE(sTargetPid) == OBJECT_Player) { v4 = pParty->vPosition.x; v5 = pParty->vPosition.y; @@ -2824,7 +2836,7 @@ v11 = 0; if ( !pDir ) { - v12 = Actor::GetDirectionInfo(8 * v21 | OBJECT_Actor, a2, &a3, 0); + v12 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v21), sTargetPid, &a3, 0); v10 = &v18; memcpy(&v18, v12, sizeof(v18)); v11 = 0; @@ -2858,7 +2870,7 @@ v3->UpdateAnimation(); } else - Actor::_402AD7(v21, a2, v21, 64, pDir); + Actor::Pursue1(v21, sTargetPid, v21, 64, pDir); } //----- (004032B2) -------------------------------------------------------- @@ -2998,7 +3010,7 @@ } //----- (004030AD) -------------------------------------------------------- -void Actor::_4030AD(unsigned int uActorID, signed int edx0, int arg0) +void Actor::Stun(unsigned int uActorID, signed int edx0, int arg0) { unsigned int v3; // edi@1 Actor *v4; // ebx@1 @@ -3034,7 +3046,7 @@ && v4->uAIState != 18 && v4->uAIState != 2)) { - memcpy(&v10, Actor::GetDirectionInfo(8 * v3 | 3, a2, &a3, 0), sizeof(v10)); + memcpy(&v10, Actor::GetDirectionInfo(PID(OBJECT_Actor,v3), a2, &a3, 0), sizeof(v10)); v6 = pSpriteFrameTable->pSpriteSFrames; v4->uYawAngle = LOWORD(v10.uYawAngle); v7 = v6[v4->pSpriteIDs[ANIM_GotHit]].uAnimLength; @@ -3058,7 +3070,7 @@ AIDirection a3; // [sp+Ch] [bp-5Ch]@2 if (!a4) - a4 = Actor::GetDirectionInfo(8 * uActorID | OBJECT_Actor, uObjID, &a3, 0); + a4 = Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), uObjID, &a3, 0); actor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[actor->pSpriteIDs[ANIM_Bored]].uAnimLength; @@ -3223,7 +3235,7 @@ } //----- (00402AD7) -------------------------------------------------------- -void Actor::_402AD7(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, AIDirection *pDir) +void Actor::Pursue1(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, AIDirection *pDir) { unsigned int v5; // edi@1 int v6; // eax@1 @@ -3244,7 +3256,7 @@ v6 = 0; v7 = &pActors[uActorID]; v18 = a2; - v8 = 8 * uActorID | 3; + v8 = PID(OBJECT_Actor,uActorID); v9 = v7->pMonsterInfo.uFlying == 0; v17 = v5; if ( !v9 && !pParty->bFlying ) @@ -3304,7 +3316,7 @@ } //----- (00402968) -------------------------------------------------------- -void Actor::_402968(unsigned int uActorID, signed int edx0, int uActionLength, AIDirection *a4) +void Actor::Flee(unsigned int uActorID, signed int sTargetPid, int uActionLength, AIDirection *a4) { unsigned int v4; // esi@1 Actor *v5; // ebx@1 @@ -3318,27 +3330,27 @@ AIDirection v13; // [sp+5Ch] [bp-28h]@4 signed int a1; // [sp+78h] [bp-Ch]@2 unsigned int v15; // [sp+7Ch] [bp-8h]@1 - signed int a2; // [sp+80h] [bp-4h]@1 + //signed int a2; // [sp+80h] [bp-4h]@1 v4 = uActorID; - a2 = edx0; + //a2 = edx0; v15 = uActorID; v5 = &pActors[uActorID]; //result = pActors[uActorID].CanAct(); if ( pActors[uActorID].CanAct() ) { - v7 = 8 * v4 | 3; - a1 = 8 * v4 | 3; + v7 = PID(OBJECT_Actor,v4); + a1 = PID(OBJECT_Actor,v4); if ( !a4 ) { a4 = &v12; - memcpy(&v12, Actor::GetDirectionInfo(v7, a2, &a3, v5->pMonsterInfo.uFlying), sizeof(v12)); + memcpy(&v12, Actor::GetDirectionInfo(v7, sTargetPid, &a3, v5->pMonsterInfo.uFlying), sizeof(v12)); v7 = a1; } memcpy(&a3, Actor::GetDirectionInfo(v7, 4u, &v10, 0), sizeof(a3)); memcpy(&v13, &a3, sizeof(v13)); if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) - || (a2 & 7) == OBJECT_Actor && (double)(signed int)v13.uDistance < 307.2 ) + || PID_TYPE(sTargetPid) == OBJECT_Actor && (double)(signed int)v13.uDistance < 307.2 ) { if ( !uActionLength ) uActionLength = 256; @@ -3365,7 +3377,7 @@ } //----- (0040281C) -------------------------------------------------------- -void Actor::_40281C(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *pDir, int a5) +void Actor::Pursue2(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *pDir, int a5) { unsigned int v5; // edi@1 int v6; // eax@1 @@ -3387,7 +3399,7 @@ v6 = 0; v7 = &pActors[uActorID]; v19 = a2; - v8 = 8 * uActorID | 3; + v8 = PID(OBJECT_Actor,uActorID); v9 = v7->pMonsterInfo.uFlying == 0; v20 = v5; if ( !v9 && !pParty->bFlying ) @@ -3448,14 +3460,14 @@ } //----- (00402686) -------------------------------------------------------- -void Actor::_402686(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *a4) +void Actor::Pursue3(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *a4) { - unsigned int v4; // edi@1 + //unsigned int v4; // edi@1 int v5; // eax@1 Actor *v6; // ebx@1 int v7; // ecx@1 char v8; // zf@1 - AIDirection *v9; // esi@7 + //AIDirection *v9; // esi@7 signed int v10; // edx@12 signed __int16 v12; // cx@19 int v13; // edx@25 @@ -3463,19 +3475,17 @@ unsigned __int16 v15; // ax@26 unsigned __int16 v16; // ax@28 int v17; // [sp-8h] [bp-54h]@12 - AIDirection *v18; // [sp-4h] [bp-50h]@12 + //AIDirection *v18; // [sp-4h] [bp-50h]@12 AIDirection a3; // [sp+Ch] [bp-40h]@8 AIDirection v20; // [sp+28h] [bp-24h]@8 int v21; // [sp+44h] [bp-8h]@1 - unsigned int v22; // [sp+48h] [bp-4h]@1 + //unsigned int v22; // [sp+48h] [bp-4h]@1 - v4 = uActorID; v5 = 0; v6 = &pActors[uActorID]; v21 = a2; - v7 = 8 * uActorID | 3; + v7 = PID(OBJECT_Actor,uActorID); v8 = v6->pMonsterInfo.uFlying == 0; - v22 = v4; if ( !v8 && !pParty->bFlying ) { if ( v6->pMonsterInfo.uMissleAttack1Type && uCurrentlyLoadedLevelType == LEVEL_Outdoor ) @@ -3483,31 +3493,21 @@ else v5 = pParty->uPartyHeight; } - v9 = a4; if ( !a4 ) { memcpy(&v20, Actor::GetDirectionInfo(v7, a2, &a3, v5), sizeof(v20)); - memcpy(0, &v20, 0x1Cu); - v9 = 0; - v4 = v22; } if ( MonsterStats::BelongsToSupertype(v6->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) { if ( !uActionLength ) uActionLength = 256; - v18 = v9; - v17 = uActionLength; - v10 = 4; - return Actor::AI_StandOrBored(v4, v10, v17, v18); + return Actor::AI_StandOrBored(uActorID, 4, uActionLength, a4); } - if ( (double)(signed int)v9->uDistance < 307.2 ) + if ( (double)(signed int)a4->uDistance < 307.2 ) { if ( !uActionLength ) uActionLength = 256; - v10 = v21; - v18 = v9; - v17 = uActionLength; - return Actor::AI_StandOrBored(v4, v10, v17, v18); + return Actor::AI_StandOrBored(uActorID, v21, uActionLength, a4); } if ( uActionLength ) { @@ -3517,25 +3517,25 @@ { v12 = v6->uMovementSpeed; if ( v12 ) - v6->uCurrentActionLength = (signed int)(v9->uDistanceXZ << 7) / v12; + v6->uCurrentActionLength = (signed int)(a4->uDistanceXZ << 7) / v12; else v6->uCurrentActionLength = 0; if ( v6->uCurrentActionLength > 128 ) v6->uCurrentActionLength = 128; } v13 = rand() % 2; - v14 = LOWORD(v9->uYawAngle); + v14 = LOWORD(a4->uYawAngle); if ( v13 ) v15 = v14 + 256; else v15 = v14 - 256; v6->uYawAngle = v15; - v16 = LOWORD(v9->uPitchAngle); + v16 = LOWORD(a4->uPitchAngle); v6->uCurrentActionTime = 0; v6->uPitchAngle = v16; v6->uAIState = Pursuing; if ( rand() % 100 < 2 ) - Actor::PlaySound(v4, 2u); + Actor::PlaySound(uActorID, 2u); v6->UpdateAnimation(); } @@ -3594,7 +3594,7 @@ actor->uAIState == Removed || actor->uAIState == Summoned || actor->uAIState == Disabled || uActorID == i ) continue; - if (_this->uLastCharacterIDToHit == 0 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, _this->uLastCharacterIDToHit != v9) ) + if (_this->uLastCharacterIDToHit == 0 || (v9 = 8 * v5, LOBYTE(v9) = PID(OBJECT_Actor,v5), _this->uLastCharacterIDToHit != v9) ) { v10 = _this->GetActorsRelation(actor); if ( v10 == 0 ) @@ -3640,7 +3640,7 @@ if ( v25 != -1 ) { //v13 = 8 * v21; - //LOBYTE(v13) = 8 * v21 | OBJECT_Actor; + //LOBYTE(v13) = PID(OBJECT_Actor,v21); *a2 = PID(OBJECT_Actor, v21); } @@ -3660,7 +3660,7 @@ v14 = 4; if ( v14 != 0 ) { - v15 = dword_4DF390; + v15 = dword_4DF380[4]; if ( !_this->pMonsterInfo.uHostilityType ) v15 = dword_4DF380[v14]; v16 = abs(_this->vPosition.x - pParty->vPosition.x); @@ -4079,7 +4079,7 @@ if ( v23->uAttributes & 0x80000 ) v8->uAttributes |= 0x80000u; result = 8 * v24; - LOBYTE(result) = 8 * v24 | 3; + LOBYTE(result) = PID(OBJECT_Actor,v24); v8->uSummonerID = result; } return result;
--- a/Actor.h Mon Apr 01 09:05:31 2013 +0600 +++ b/Actor.h Mon Apr 01 09:05:51 2013 +0600 @@ -43,7 +43,7 @@ ACTOR_BUFF_CHARM = 1, // an assumption ACTOR_BUFF_SHRINK = 3, // an assumption ACTOR_BUFF_STONED = 5, - ACTOR_BUFF_PARALYZED = 6, + ACTOR_BUFF_PARALYZED = 6 }; @@ -193,30 +193,30 @@ static void _SelectTarget(unsigned int uActorID, int *a2, bool can_target_party); - static void _402686(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *a4); - static void _40281C(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *pDir, int a5); - static void _402968(unsigned int uActorID, signed int edx0, int uActionLength, struct AIDirection *a4); - static void _402AD7(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, struct AIDirection *pDir); + static void Pursue3(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *a4); + static void Pursue2(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *pDir, int a5); + static void Flee(unsigned int uActorID, signed int edx0, int uActionLength, struct AIDirection *a4); + static void Pursue1(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, struct AIDirection *pDir); static void PlaySound(unsigned int uActorID, unsigned int uSoundID); static void Die(unsigned int uActorID); static void Resurrect(unsigned int uActorID); static void AI_Bored(unsigned int uActorID, unsigned int uObjID, struct AIDirection *a4); - static void _4030AD(unsigned int uActorID, signed int edx0, int arg0); + static void Stun(unsigned int uActorID, signed int edx0, int arg0); static char __fastcall _4031C1_update_job(unsigned int uActorID, signed int a2, int a3); static void _4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength); - static void _403476(unsigned int uActorID, signed int edx0, struct AIDirection *pDir); - static void _40368B(unsigned int uActorID, signed int edx0, struct AIDirection *pDir); - static void _403854(unsigned int uActorID, signed int edx0, struct AIDirection *pDir); - static void _403A60(unsigned int uActorID, signed int edx0, struct AIDirection *pDir); - static void _403C6C(unsigned int uActorID, signed int edx0, struct AIDirection *arg0); + static void MissileAttack1(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir); + static void MissileAttack2(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir); + static void SpellAttack1(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir); + static void SpellAttack2(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir); + static void MeleeAttack(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0); static void __fastcall StandAwhile(unsigned int uActorID); static void AI_Stand(unsigned int uActorID, unsigned int object_to_face_pid, unsigned int uActionLength, struct AIDirection *a4); static void AI_StandOrBored(unsigned int uActorID, signed int uObjID, int uActionLength, struct AIDirection *a4); static void FaceObject(unsigned int uActorID, unsigned int uObjID, int _48, struct AIDirection *a4); static struct AIDirection *__fastcall GetDirectionInfo(unsigned int uObj1ID, unsigned int uObj2ID, struct AIDirection *pOut, int a4); static signed int __fastcall Explode(unsigned int uActorID); - static char __fastcall _404874(unsigned int uActorID, struct AIDirection *a2, int a3, char a4); - static void __fastcall _404AC7(unsigned int uActorID, struct AIDirection *pDir, int spellnum, int a4, unsigned int uSkillLevel); + static char __fastcall RangedAttack(unsigned int uActorID, struct AIDirection *a2, int type, char a4); + static void __fastcall SpellAttack(unsigned int uActorID, struct AIDirection *pDir, int spellnum, int a4, unsigned int uSkillLevel); static void AggroSurroundingPeasants(unsigned int uActorID, int a2); static bool ArePeasantsOfSameFaction(Actor *a1, Actor *a2); static bool StealFrom(unsigned int uActorID);
--- a/Arcomage.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/Arcomage.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -1542,7 +1542,7 @@ ArcomageGame::PlaySound(0x14u); memset(byte_5054E8, 0, sizeof(byte_5054E8)); memset(v9, 0, sizeof(v9)); - v0 = stru_505708[0].arr_44; + v0 = stru_505708[0].arr_44;//variable incorrect do { v1 = v0;
--- a/AudioPlayer.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/AudioPlayer.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -21,7 +21,7 @@ #include "Bink_Smacker.h" #include "mm7_data.h" - +#include "MM7.h" PCMWAVEFORMAT pcmWaveFormat; @@ -773,8 +773,8 @@ } else { - int object_type = a3 & 7, - object_id = a3 >> 7; + int object_type = PID_TYPE(a3), + object_id = PID_ID(a3); switch (object_type) { case OBJECT_BLVDoor: @@ -971,8 +971,8 @@ sample_volume = uVolume; AIL_set_sample_volume(channel->hSample, sample_volume); - int object_type = a3 & 7, - object_id = a3 >> 7; + int object_type = PID_TYPE(a3), + object_id = PID_ID(a3); if (PartyX != -1) { if (!PartyX) PartyX = pParty->vPosition.x; @@ -1065,7 +1065,7 @@ v21 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; goto LABEL_47; } - if ( (a3 & 7) == 2 ) + if ( PID_TYPE(a3) == 2 ) { v22 = pAudioPlayer->uNum3DSamples; if ( v22 < 16 ) @@ -1078,11 +1078,11 @@ v96 = 7; v12 = 5; } - pLayingItem = &pSpriteObjects[a3 >> 3]; + pLayingItem = &pSpriteObjects[PID_ID(a3)]; } else { - if ( (a3 & 7) == 3 ) + if ( PID_TYPE(a3) == 3 ) { v18 = pAudioPlayer->uNum3DSamples; v12 = 0; @@ -1090,7 +1090,7 @@ v96 = 3 * v18 / 16; else v96 = 3; - pActor1 = &pActors[a3 >> 3]; + pActor1 = &pActors[PID_ID(a3)]; v20 = pActor1->vPosition.y; pRenderVertexSoft.vWorldPosition.x = (double)pActor1->vPosition.x; v100 = pActor1->vPosition.z; @@ -1098,10 +1098,10 @@ v21 = (double)v100; goto LABEL_47; } - if ( (a3 & 7) != 5 ) + if ( PID_TYPE(a3) != 5 ) { v13 = pAudioPlayer->uNum3DSamples; - if ( (a3 & 7) == 6 ) + if ( PID_TYPE(a3) == 6 ) { if ( v13 >= 16 ) { @@ -1151,7 +1151,7 @@ v12 = 4; v96 = 4; } - pLayingItem = (SpriteObject *)&pLevelDecorations[a3 >> 3]; + pLayingItem = (SpriteObject *)&pLevelDecorations[PID_ID(a3)]; } pRenderVertexSoft.vWorldPosition.x = (double)pLayingItem->vPosition.x; pRenderVertexSoft.vWorldPosition.y = (double)pLayingItem->vPosition.y; @@ -1273,12 +1273,12 @@ AIL_set_3D_sample_loop_count(*(int *)v42, v86); if ( PartyX == -1 ) { - if ( (a3 & 7) == 1 ) + if ( PID_TYPE(a3) == 1 ) { if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) { //goto LABEL_103; - pBLVDoor = &pIndoor->pDoors[a3 >> 3]; + pBLVDoor = &pIndoor->pDoors[PID_ID(a3)]; if ( !pBLVDoor->uDoorID ) return; pRenderVertexSoft.vWorldPosition.x = (double)*pBLVDoor->pXOffsets; @@ -1323,15 +1323,15 @@ } return; } - if ( (a3 & 7) == 2 ) + if ( PID_TYPE(a3) == 2 ) { - pLayingItem2 = &pSpriteObjects[a3 >> 3]; + pLayingItem2 = &pSpriteObjects[PID_ID(a3)]; } else { - if ( (a3 & 7) == 3 ) + if ( PID_TYPE(a3) == 3 ) { - pActor = &pActors[a3 >> 3]; + pActor = &pActors[PID_ID(a3)]; v46 = pActor->vPosition.y; pRenderVertexSoft.vWorldPosition.x = (double)pActor->vPosition.x; uNumRepeatsb = pActor->vPosition.z; @@ -1339,7 +1339,7 @@ v47 = (double)uNumRepeatsb; goto LABEL_101; } - if ( (a3 & 7) != 5 ) + if ( PID_TYPE(a3) != 5 ) { pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x; v43 = (double)pParty->vPosition.y; @@ -1348,7 +1348,7 @@ v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; goto LABEL_101; } - pLayingItem2 = (SpriteObject *)&pLevelDecorations[a3 >> 3]; + pLayingItem2 = (SpriteObject *)&pLevelDecorations[PID_ID(a3)]; } pRenderVertexSoft.vWorldPosition.x = (double)pLayingItem2->vPosition.x; pRenderVertexSoft.vWorldPosition.y = (double)pLayingItem2->vPosition.y; @@ -1462,7 +1462,7 @@ v6 = this->p3DSamples; while ( 1 ) { - v7 = v6->field_4 & 7; + v7 = PID_TYPE(v6->field_4); if ( AIL_3D_sample_status(v6->hSample) == 2 ) { AIL_end_3D_sample(v6->hSample); @@ -1475,7 +1475,7 @@ break; if ( uCurrentlyLoadedLevelType != LEVEL_Indoor ) goto LABEL_31; - v15 = &pIndoor->pDoors[v6->field_4 >> 3]; + v15 = &pIndoor->pDoors[PID_ID(v6->field_4)]; if ( v15->uDoorID ) { uNumRepeats = *v15->pXOffsets; @@ -1502,7 +1502,7 @@ v10 = v9 - 1; if ( !v10 ) { - v13 = &pActors[v6->field_4 >> 3]; + v13 = &pActors[PID_ID(v6->field_4)]; uNumRepeats = v13->vPosition.x; v14 = v13->vPosition.y; a1.vWorldPosition.x = (double)uNumRepeats; @@ -1518,11 +1518,11 @@ v11 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; goto LABEL_21; } - v12 = (SpriteObject *)&pLevelDecorations[v6->field_4 >> 3]; + v12 = (SpriteObject *)&pLevelDecorations[PID_ID(v6->field_4)]; } else { - v12 = &pSpriteObjects[v6->field_4 >> 3]; + v12 = &pSpriteObjects[PID_ID(v6->field_4)]; } a1.vWorldPosition.x = (double)v12->vPosition.x; a1.vWorldPosition.y = (double)v12->vPosition.y; @@ -1623,8 +1623,8 @@ if (channel->source_pid <= 0) continue; - int source_type = channel->source_pid & 7, - source_id = channel->source_pid >> 3; + int source_type = PID_TYPE(channel->source_pid), + source_id = PID_ID(channel->source_pid); int source_x, source_y, source_z;
--- a/Chest.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/Chest.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -20,7 +20,7 @@ #include "Overlays.h" #include "mm7_data.h" - +#include "MM7.h" @@ -109,9 +109,9 @@ v31 = 813; v32 = 814; v5 = rand() % 4; - v6 = EvtTargetObj >> 3; + v6 = PID_ID(EvtTargetObj); v35 = v5; - if ( (EvtTargetObj & 7) == OBJECT_Decoration) + if ( PID_TYPE(EvtTargetObj) == OBJECT_Decoration) { v16 = v6; v14 = pLevelDecorations[v6].vPosition.x; @@ -121,7 +121,7 @@ } else { - if ( (EvtTargetObj & 7) != OBJECT_BModel) + if ( PID_TYPE(EvtTargetObj) != OBJECT_BModel) goto LABEL_12; if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) {
--- a/GUIWindow.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/GUIWindow.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -1018,76 +1018,97 @@ //----- (004B3157) -------------------------------------------------------- void GUIWindow::HouseDialogManager() { - unsigned __int16 v1; // di@2 - const char *v2; // edx@4 + unsigned __int16 pWhiteColor; // di@2 + const char *pHouseName; // edx@4 signed int v3; // edx@5 char *v4; // edi@9 - int v5; // eax@45 + int pTextHeight; // eax@45 int v6; // edi@45 char *v7; // eax@45 int v8; // edi@46 int v9; // eax@50 unsigned int v10; // [sp-10h] [bp-C8h]@53 - unsigned __int16 v11; // [sp-Ch] [bp-C4h]@53 + //unsigned __int16 v11; // [sp-Ch] [bp-C4h]@53 //unsigned int v12; // [sp-Ch] [bp-C4h]@60 char *v13; // [sp-8h] [bp-C0h]@50 //unsigned int v14; // [sp-8h] [bp-C0h]@60 unsigned int v15; // [sp-4h] [bp-BCh]@50 //Texture *v16; // [sp-4h] [bp-BCh]@60 - GUIWindow w; // [sp+Ch] [bp-ACh]@4 - GUIWindow v18; // [sp+60h] [bp-58h]@2 - int v19; // [sp+B4h] [bp-4h]@2 + GUIWindow pDialogWindow; // [sp+Ch] [bp-ACh]@4 + GUIWindow pWindow; // [sp+60h] [bp-58h]@2 + int pColor2; // [sp+B4h] [bp-4h]@2 if ( !window_SpeakInHouse ) return; - memcpy(&v18, this, sizeof(v18)); - v18.uFrameWidth -= 18; - v18.uFrameZ -= 18; - v1 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu); - v19 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u); + memcpy(&pWindow, this, sizeof(pWindow)); + pWindow.uFrameWidth -= 18; + pWindow.uFrameZ -= 18; + pWhiteColor = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu); + pColor2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u); pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background); pRenderer->DrawTextureTransparent(0x1D4u, 0, &pIcons_LOD->pTextures[uTextureID_507B04]); if ( pDialogueNPCCount != uNumDialogueNPCPortraits || !uHouse_ExitPic ) { - w.uFrameWidth = 130; - w.uFrameHeight = 2 * LOBYTE(pFontCreate->uFontHeight); + pDialogWindow.uFrameWidth = 130; + pDialogWindow.uFrameHeight = 2 * LOBYTE(pFontCreate->uFontHeight); //v2 = (const char *)p2DEvents_minus1_::04[13 * (unsigned int)ptr_507BC0->ptr_1C]; - v2 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].pName; + pHouseName = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].pName; - if ( v2 ) + if ( pHouseName ) { - v3 = 2 * LOBYTE(pFontCreate->uFontHeight) - 6 - pFontCreate->CalcTextHeight(v2, &w, 0, 0); + v3 = 2 * LOBYTE(pFontCreate->uFontHeight) - 6 - pFontCreate->CalcTextHeight(pHouseName, &pDialogWindow, 0, 0); if ( v3 < 0 ) v3 = 0; - v18.DrawTitleText(pFontCreate, 0x1EAu, v3 / 2 + 4, v1, + pWindow.DrawTitleText(pFontCreate, 0x1EAu, v3 / 2 + 4, pWhiteColor, //(const char *)p2DEvents_minus1_::04[13 * (unsigned int)ptr_507BC0->ptr_1C], p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].pName, 3); } } - v18.uFrameWidth += 8; - v18.uFrameZ += 8; + pWindow.uFrameWidth += 8; + pWindow.uFrameZ += 8; if ( !pDialogueNPCCount ) { if ( in_current_building_type == BildingType_Jail ) { JailDialog(); - goto LABEL_58; + if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) + { + pRenderer->DrawTextureIndexed(556, 451, &pIcons_LOD->pTextures[uTextureID_x_x_u]); + pRenderer->DrawTextureIndexed(476, 451, &pIcons_LOD->pTextures[uTextureID_x_ok_u]); + } + else + { + pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uExitCancelTextureId]); + } + return; } if ( current_npc_text ) { - w.uFrameWidth = 458; - w.uFrameZ = 457; - v5 = pFontArrus->CalcTextHeight(current_npc_text, &w, 13, 0); - v6 = v5 + 7; - pRenderer->_4A6A68(8, 352 - (v5 + 7), &pIcons_LOD->pTextures[uTextureID_Leather], pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight - (v5 + 7)); - pRenderer->DrawTextureIndexed(8u, 347 - v6, pTexture_591428); - v7 = FitTextInAWindow(current_npc_text, pFontArrus, &w, 0xDu, 0); + pDialogWindow.uFrameWidth = 458; + pDialogWindow.uFrameZ = 457; + pTextHeight = pFontArrus->CalcTextHeight(current_npc_text, &pDialogWindow, 13, 0); + v6 = pTextHeight + 7; + pRenderer->_4A6A68(8, 352 - (pTextHeight + 7), &pIcons_LOD->pTextures[uTextureID_Leather], + pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight - (pTextHeight + 7)); + pRenderer->DrawTextureIndexed(8, 347 - v6, pTexture_591428); + v7 = FitTextInAWindow(current_npc_text, pFontArrus, &pDialogWindow, 0xDu, 0); window_SpeakInHouse->DrawText(pFontArrus, 13, 354 - v6, 0, v7, 0, 0, 0); } v8 = 0; if ( uNumDialogueNPCPortraits <= 0 ) - goto LABEL_58; + { + if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) + { + pRenderer->DrawTextureIndexed(556, 451, &pIcons_LOD->pTextures[uTextureID_x_x_u]); + pRenderer->DrawTextureIndexed(476, 451, &pIcons_LOD->pTextures[uTextureID_x_ok_u]); + } + else + { + pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uExitCancelTextureId]); + } + return; + } while ( 1 ) { //pRenderer->DrawTextureIndexed(*(&pNPCPortraits_x + v8 + 6 * uNumDialogueNPCPortraits - 6) - 4, @@ -1103,7 +1124,19 @@ LABEL_57: ++v8; if ( v8 >= uNumDialogueNPCPortraits ) - goto LABEL_58; + //goto LABEL_58; + { + if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) + { + pRenderer->DrawTextureIndexed(556, 451, &pIcons_LOD->pTextures[uTextureID_x_x_u]); + pRenderer->DrawTextureIndexed(476, 451, &pIcons_LOD->pTextures[uTextureID_x_ok_u]); + } + else + { + pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uExitCancelTextureId]); + } + return; + } } if ( v8 + 1 == uNumDialogueNPCPortraits && uHouse_ExitPic ) { @@ -1118,16 +1151,16 @@ v15 = 3; //v13 = (char *)p2DEvents_minus1__10[13 * (unsigned int)ptr_507BC0->ptr_1C]; v13 = (char *)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].pProprieterTitle; - v18.DrawTitleText(pFontCreate, 0x1E3u, 113, v19, v13, 3); + pWindow.DrawTitleText(pFontCreate, 0x1E3u, 113, pColor2, v13, 3); goto LABEL_57; } v15 = 3; - v13 = HouseNPCData[v8 - (dword_591080 != 0)]->pName; + v13 = HouseNPCData[(v8 +1) - (dword_591080 != 0)]->pName; v9 = pNPCPortraits_x[6 + (uNumDialogueNPCPortraits - 1)][v8] + pDialogueNPCPortraits[v8]->uTextureHeight + 2; } - v11 = v19; + //v11 = pColor2; v10 = v9; - v18.DrawTitleText(pFontCreate, 0x1E3u, v10, v11, v13, v15); + pWindow.DrawTitleText(pFontCreate, 0x1E3u, v10, pColor2, v13, v15); goto LABEL_57; } v4 = (char *)pDialogueNPCCount - 1; @@ -1136,7 +1169,17 @@ if ( pCurrentScreen == SCREEN_E ) { CharacterUI_InventoryTab_Draw(uActiveCharacter, 1); - goto LABEL_58; + //goto LABEL_58; + if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) + { + pRenderer->DrawTextureIndexed(556, 451, &pIcons_LOD->pTextures[uTextureID_x_x_u]); + pRenderer->DrawTextureIndexed(476, 451, &pIcons_LOD->pTextures[uTextureID_x_ok_u]); + } + else + { + pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uExitCancelTextureId]); + } + return; } if ( v4 || !dword_591080 ) { @@ -1147,7 +1190,7 @@ sprintfex( pTmpBuf, pGlobalTXT_LocalizationStrings[429], p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].pProprieterName, p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].pProprieterTitle); - v18.DrawTitleText(pFontCreate, 0x1E3u, 0x71u, v19, pTmpBuf, 3u); + pWindow.DrawTitleText(pFontCreate, 0x1E3u, 0x71u, pColor2, pTmpBuf, 3); switch ( in_current_building_type ) { case BildingType_WeaponShop: @@ -1203,7 +1246,7 @@ break; } } -LABEL_58: +//LABEL_58: if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) { pRenderer->DrawTextureIndexed(556, 451, &pIcons_LOD->pTextures[uTextureID_x_x_u]); @@ -1928,7 +1971,7 @@ else { if ( v26 || !dword_591080 ) - v27 = HouseNPCData[v26 - (dword_591080 != 0)]->pName; + v27 = HouseNPCData[(v26 +1) - (dword_591080 != 0)]->pName; else //v27 = (char *)p2DEvents_minus1_::08[13 * a4]; v27 = (char *)p2DEvents[pButton - 1].pProprieterName;
--- a/Game.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/Game.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -84,12 +84,13 @@ if ( pParty->vPosition.x != pParty->vPrevPosition.x | pParty->sRotationY != pParty->sPrevRotationY | pParty->vPosition.y != pParty->vPrevPosition.y | pParty->sRotationX != pParty->sPrevRotationX | pParty->vPosition.z != pParty->vPrevPosition.z | pParty->sEyelevel != pParty->sPrevEyelevel ) pParty->uFlags |= 2u; - pParty->vPrevPosition = pParty->vPosition; + pParty->vPrevPosition.x = pParty->vPosition.x; pParty->vPrevPosition.y = pParty->vPosition.y; + pParty->vPrevPosition.z = pParty->vPosition.z; //v0 = &pRenderer; pParty->sPrevRotationY = pParty->sRotationY; - pParty->vPrevPosition.z = pParty->vPosition.z; pParty->sPrevRotationX = pParty->sRotationX; + pParty->sPrevEyelevel = pParty->sEyelevel; pRenderer->BeginSceneD3D();
--- a/GameUIs.cpp Mon Apr 01 09:05:31 2013 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,240 +0,0 @@ -#include <direct.h> -#include <io.h> -#include <assert.h> - -#include "GUIWindow.h" -#include "GUIFont.h" -#include "LOD.h" -#include "SaveLoad.h" -#include "Render.h" -#include "texts.h" - -#include "mm7_data.h" - - -//----- (0045E361) -------------------------------------------------------- -void __fastcall GameUI_DrawLoadMenu(unsigned int uDialogueType) -{ - unsigned int v1; // ebp@5 - unsigned int v2; // eax@5 - //signed int v3; // ebp@11 - FILE *v4; // eax@14 - FILE *v5; // eax@18 - unsigned int v6; // eax@25 - GUIButton *v7; // eax@27 - const char *v8; // [sp-8h] [bp-26Ch]@25 - //char *v9; // [sp-4h] [bp-268h]@19 - enum TEXTURE_TYPE v10; // [sp-4h] [bp-268h]@25 - unsigned int uDialogueType_; // [sp+10h] [bp-254h]@1 - //RGBTexture *pTex; // [sp+10h] [bp-254h]@12 - //SavegameHeader *Dest; // [sp+14h] [bp-250h]@12 - //const char *Str1; // [sp+18h] [bp-24Ch]@12 - LODWriteableFile pLODFile; // [sp+1Ch] [bp-248h]@1 - int v16; // [sp+260h] [bp-4h]@1 - - uDialogueType_ = uDialogueType; - dword_6BE138 = -1; - pIcons_LOD->_inlined_sub2(); - - memset(pSavegameUsedSlots, 0, sizeof(pSavegameUsedSlots)); - memset(pSavegameThumbnails, 0, 45 * sizeof(RGBTexture)); - uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE); - uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE); - uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE); - uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE); - uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE); - uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE); - if ( uDialogueType_ ) - { - pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); - if ( pCurrentScreen == SCREEN_SAVEGAME ) - { - v1 = uTextureID_save_up; - v2 = uTextureID_LS_saveU; - } - else - { - v1 = uTextureID_load_up; - v2 = uTextureID_LS_loadU; - } - pRenderer->DrawTextureIndexed(241, 302, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0)); - pRenderer->DrawTextureIndexed(18, 141, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0)); - pRenderer->DrawTextureIndexed(351, 302, (Texture *)(uTextureID_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_u] : 0)); - } - else - { - pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX); - } - pGUIWindow_CurrentMenu = GUIWindow::Create(saveload_dlg_xs[uDialogueType_], saveload_dlg_ys[uDialogueType_], saveload_dlg_zs[uDialogueType_], - saveload_dlg_ws[uDialogueType_], WINDOW_MainMenu_Load, 0, 0); - pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);// "Reading..." - pRenderer->Present(); - pSavegameList->Initialize(0); - if ( pSaveListPosition > (signed int)uNumSavegameFiles ) - { - pSaveListPosition = 0; - uLoadGameUI_SelectedSlot = 0; - } - pLODFile.AllocSubIndicesAndIO(0x12C, 0); - assert(sizeof(SavegameHeader) == 0x64); - //v3 = 0; - for (uint i = 0; i < uNumSavegameFiles; ++i) - { - - sprintf(pTmpBuf, "saves\\%s", pSavegameList->pFileList[i].pSaveFileName); - if (_access(pTmpBuf, 6)) - { - pSavegameUsedSlots[i] = 0; - strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[72]); // "Empty" - continue; - } - pLODFile.LoadFile(pTmpBuf, 1); - v4 = pLODFile.FindContainer("header.bin", true); - if ( v4 ) - fread(&pSavegameHeader[i], 0x64, 1, v4); - if ( !_strcmpi(pSavegameList->pFileList[i].pSaveFileName, pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7" - strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[16]);// "Autosave" - v5 = pLODFile.FindContainer("image.pcx", true); - if ( !v5 ) - { - pSavegameUsedSlots[i] = 0; - strcpy(pSavegameList->pFileList[i].pSaveFileName, ""); - } - else - { - pSavegameThumbnails[i].LoadFromFILE(v5, 0, true); - pLODFile.CloseWriteFile(); - pSavegameUsedSlots[i] = 1; - } - } - -//LABEL_24: - pLODFile.FreeSubIndexAndIO(); - if ( pCurrentScreen == SCREEN_SAVEGAME ) - { - uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); - uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD",TEXTURE_16BIT_PALETTE); - } - else - { - uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); - uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_loadD",TEXTURE_16BIT_PALETTE); - } - uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE); - uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE); - pGUIWindow_CurrentMenu->CreateButton(21, 198, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(21, 219, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 1, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(21, 240, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 2, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(21, 261, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 3, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(21, 282, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 4, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(21, 303, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 5, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(21, 324, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 6, 0, "", 0); - pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(241, 302, 105, 40, 1, 0, UIMSG_LoadSlot, 0, 0, "", - pIcons_LOD->GetTexture(uTextureID_LS_), 0); - pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(350, 302, 105, 40, 1, 0, UIMSG_Cancel, 0, 0, "", - pIcons_LOD->GetTexture(uTextureID_x_d), 0); - pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton(215, 199, 17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "", - pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0); - pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 0x143, 0x11, 0x11, 1, 0, UIMSG_DownArrow, uNumSavegameFiles, 0, "", - pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0); - -} - -//----- (0045E93E) -------------------------------------------------------- -void GameUI_DrawSaveMenu() -{ - unsigned int v0; // ebp@4 - unsigned int v1; // eax@4 - char *v3; // eax@7 - FILE *v4; // eax@11 - FILE *v5; // eax@11 - LODWriteableFile v11; // [sp+1Ch] [bp-248h]@1 - - ++pIcons_LOD->uTexturePacksCount; - if ( !pIcons_LOD->uNumPrevLoadedFiles ) - pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; - memset(pSavegameUsedSlots, 0, 0xB4u); - memset(&pSavegameThumbnails, 0, 0x708u); - uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE); - uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE); - uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE); - uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE); - uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE); - uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE); - pRenderer->DrawTextureIndexed( 8u, 8u, - (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); - if ( pCurrentScreen == SCREEN_SAVEGAME ) - { - v0 = uTextureID_save_up; - v1 = uTextureID_LS_saveU; - } - else - { - v0 = uTextureID_load_up; - v1 = uTextureID_LS_loadU; - } - pRenderer->DrawTextureIndexed(0xF1u, 0x12Eu, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0)); - pRenderer->DrawTextureIndexed(0x15Fu, 0x12Eu, - (Texture *)(uTextureID_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0)); - pRenderer->DrawTextureIndexed(0x12u, 0x8Du, (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0)); - pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0); - pRenderer->Present(); - pSavegameList->Initialize(1u); - v11.AllocSubIndicesAndIO(0x12Cu, 0); - //v2 = pSavegameUsedSlots; - // Dest = pSavegameHeader; - // this_ = pSavegameThumbnails; - // v8 = (char *)pSavegameList->pSavesNames; - for (uint i = 0; i < 40; ++i) - { - v3 = pSavegameList->pFileList[i].pSaveFileName; - if ( !*pSavegameList->pFileList[i].pSaveFileName ) - v3 = "1.mm7"; - sprintf(pTmpBuf, "saves\\%s", v3); - if ( _access(pTmpBuf, 0) || _access(pTmpBuf, 6) ) - { - pSavegameUsedSlots[i] = 0; - strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[LOCSTR_EMPTY]); - } - else - { - v11.LoadFile(pTmpBuf, 1); - v4 = v11.FindContainer("header.bin", 1); - fread(&pSavegameHeader[i], 100, 1u, v4); - v5 = v11.FindContainer("image.pcx", 1); - if ( v5 ) - { - pSavegameThumbnails[i].LoadFromFILE(v5, 0, 1u); - v11.CloseWriteFile(); - pSavegameUsedSlots[i] = 1; - } - else - { - pSavegameUsedSlots[i] = 0; - } - } - - } - - v11.FreeSubIndexAndIO(); - uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); - uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD", TEXTURE_16BIT_PALETTE); - uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE); - uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE); - pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_17, 0, 0); - pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(21u, 218u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 1u, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(21u, 238u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 2u, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(21u, 258u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 3u, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(21u, 278u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 4u, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(21u, 298u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 5u, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(21u, 318u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 6u, 0, "", 0); - pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0x69u, 0x28u, 1, 0, UIMSG_LoadSlot, 0, 0, "", - (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0), 0); - pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(0x15Eu, 0x12Eu, 0x69u, 0x28u, 1, 0, UIMSG_Cancel, 0, 0, "", - (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0), 0); - pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0xC7u, 0x11u, 0x11u, 1, 0, UIMSG_ArrowUp, 0, 0, "", - (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0), 0); - pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0x143u, 0x11u, 0x11u, 1, 0, UIMSG_DownArrow, 0x22u, 0, "", - (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0), 0); -} \ No newline at end of file
--- a/Indoor.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/Indoor.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -3478,15 +3478,15 @@ //v66 = 0; //v65 = 0; //v64 = 0; - //v7 = 8 * i | OBJECT_BLVDoor; + //v7 = PID(OBJECT_BLVDoor,i); //v63 = 0; //v62 = -1; - //LOBYTE(v7) = 8 * i | OBJECT_BLVDoor; + //LOBYTE(v7) = PID(OBJECT_BLVDoor,i); //v61 = 0; - //v60 = 8 * i | OBJECT_BLVDoor; + //v60 = PID(OBJECT_BLVDoor,i); //v59 = (SoundID)((int)eDoorSoundID + 1); //LABEL_17: - pAudioPlayer->PlaySound((SoundID)((int)eDoorSoundID + 1), 8 * i | OBJECT_BLVDoor, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound((SoundID)((int)eDoorSoundID + 1), PID(OBJECT_BLVDoor,i), 0, -1, 0, 0, 0, 0); //goto LABEL_18; } goto LABEL_18; @@ -3509,14 +3509,14 @@ //v66 = 0; //v65 = 0; //v64 = 0; - //v8 = 8 * i | OBJECT_BLVDoor; + //v8 = PID(OBJECT_BLVDoor,i); //v63 = 0; //v62 = -1; //LOBYTE(v8) = 8 * v1 | 1; //v61 = 1; - //v60 = 8 * i | OBJECT_BLVDoor; + //v60 = PID(OBJECT_BLVDoor,i); //v59 = eDoorSoundID; - pAudioPlayer->PlaySound(eDoorSoundID, 8 * i | OBJECT_BLVDoor, 1, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(eDoorSoundID, PID(OBJECT_BLVDoor,i), 1, -1, 0, 0, 0, 0); //goto LABEL_18; } LABEL_18: @@ -3999,7 +3999,7 @@ { v58 = v22; v24 = 8 * v63; - LOBYTE(v24) = 8 * v63 | 3; + LOBYTE(v24) = PID(OBJECT_Actor,v63); v61 = v22; _this = v24; do @@ -4082,12 +4082,12 @@ v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16; v0->uSectorID = LOWORD(stru_721530.uSectorID); stru_721530.field_70 += stru_721530.field_7C; - v37 = v36 >> 3; - if ( (v36 & 7) != OBJECT_Actor) + v37 = PID_ID(v36); + if ( PID_TYPE(v36) != OBJECT_Actor) { - if ( (v36 & 7) != OBJECT_Player) + if ( PID_TYPE(v36) != OBJECT_Player) { - if ( (v36 & 7) == OBJECT_Decoration) + if ( PID_TYPE(v36) == OBJECT_Decoration) { _this = integer_sqrt(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y); v45 = stru_5C6E00->Atan2( @@ -4104,7 +4104,7 @@ v0->vVelocity.y = WORD1(v48); goto LABEL_119; } - if ( (v36 & 7) == OBJECT_BModel) + if ( PID_TYPE(v36) == OBJECT_BModel) { stru_721530.field_84 = v36 >> 3; v38 = &pIndoor->pFaces[v37]; @@ -4207,7 +4207,7 @@ if ( !pActors[v37].pMonsterInfo.uHostilityType ) goto LABEL_118; LABEL_114: - Actor::_402968(v63, v36, v22, (AIDirection *)v22); + Actor::Flee(v63, v36, v22, (AIDirection *)v22); goto LABEL_119; } }
--- a/Outdoor.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/Outdoor.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -2797,7 +2797,7 @@ pActors[i].vVelocity.y = 0; pActors[i].vVelocity.z = 0; pActors[i].UpdateAnimation(); - pActors[i].pMonsterInfo.uHostilityType = (MonsterInfo::HostilityRadius)0; + pActors[i].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; pActors[i].PrepareSprites(0); } else @@ -2825,7 +2825,7 @@ pActors[i].vVelocity.y = 0; pActors[i].vVelocity.z = 0; pActors[i].UpdateAnimation(); - pActors[i].pMonsterInfo.uHostilityType = (MonsterInfo::HostilityRadius)0; + pActors[i].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; pActors[i].PrepareSprites(0); } else
--- a/Party.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/Party.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -142,7 +142,7 @@ { if ( pTurnEngine->field_4 != 2 || PID_TYPE(pTurnEngine->pQueue[0].uPackedID) != OBJECT_Player) return 0; - v2 = pTurnEngine->pQueue[0].uPackedID >> 3; + v2 = PID_ID(pTurnEngine->pQueue[0].uPackedID); return v2 + 1; } v4 = 0; @@ -835,7 +835,7 @@ v2 = abs(v0->vPosition.y - pParty->vPosition.y); v3 = abs(v0->vPosition.z - pParty->vPosition.z); if (int_get_vector_length(v1, v2, v3) < 512) - Actor::_402968(v4, 4, 0, 0); + Actor::Flee(v4, 4, 0, 0); } ++v4; ++v0;
--- a/Player.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/Player.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -5426,7 +5426,7 @@ } } } - if ( a3 || !v6->HasItemEquipped(EQUIP_OFF_HAND) || (v28 = v27->GetEquippedItemEquipType(EQUIP_OFF_HAND), v28 < 0) || v28 > 2 ) + if ( a3 || !v6->HasItemEquipped(EQUIP_OFF_HAND) || (v28 = v6->GetEquippedItemEquipType(EQUIP_OFF_HAND), v28 < 0) || v28 > 2 ) return v5 + v62 + v61; v15 = pItemsTable->pItems[v29].uDamageMod; v14 = pItemsTable->pItems[v29].uDamageDice * pItemsTable->pItems[v29].uDamageRoll; @@ -5459,7 +5459,7 @@ v5 = pItemsTable->pItems[*(int *)&v6->pInventoryItems[v6->pEquipment.uMainHand-1]].uDamageMod; } } - if ( a3 || !v6->HasItemEquipped(EQUIP_OFF_HAND) || (v19 = v18->GetEquippedItemEquipType(EQUIP_OFF_HAND), v19 < 0) || v19 > 2 ) + if ( a3 || !v6->HasItemEquipped(EQUIP_OFF_HAND) || (v19 = v6->GetEquippedItemEquipType(EQUIP_OFF_HAND), v19 < 0) || v19 > 2 ) return v5 + v62 + v61; v20 = *(int *)&v6->pInventoryItems[v6->pEquipment.uOffHand-1]; goto LABEL_365; @@ -5487,7 +5487,7 @@ } } } - if ( a3 || !v6->HasItemEquipped(EQUIP_OFF_HAND) || (v12 = v11->GetEquippedItemEquipType(EQUIP_OFF_HAND), v12 < 0) || v12 > 2 ) + if ( a3 || !v6->HasItemEquipped(EQUIP_OFF_HAND) || (v12 = v6->GetEquippedItemEquipType(EQUIP_OFF_HAND), v12 < 0) || v12 > 2 ) return v5 + v62 + v61; v14 = pItemsTable->pItems[this->pInventoryItems[this->pEquipment.uOffHand].uItemID].uDamageMod; v15 = pItemsTable->pItems[this->pInventoryItems[this->pEquipment.uOffHand].uItemID].uDamageDice; @@ -7488,7 +7488,7 @@ } pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, a2 - 1); v5 = 8 * a2 + 392; - LOBYTE(v5) = (8 * a2 - 120) | 4; + LOBYTE(v5) = PID(OBJECT_Player,a2 - 120); pAudioPlayer->PlaySound(SOUND_20001, v5, 0, -1, 0, 0, 0, 0); v3->AddVariable(VAR_NumSkillPoints, 2); } @@ -8309,7 +8309,7 @@ } LABEL_172: v25 = 8 * currPlayerId + 400; - LOBYTE(v25) = (8 * currPlayerId - 112) | 4; + LOBYTE(v25) = PID(OBJECT_Player,currPlayerId - 112); pAudioPlayer->PlaySound(SOUND_20001, v25, v5, -1, v5, v5, v5, v5); return; } @@ -8459,7 +8459,7 @@ if ( v31 != 1 ) return; v25 = 8 * currPlayerId + 400; - LOBYTE(v25) = (8 * currPlayerId - 112) | 4; + LOBYTE(v25) = PID(OBJECT_Player,currPlayerId - 112); pAudioPlayer->PlaySound(SOUND_20001, v25, 0, -1, 0, 0, 0, 0); return; case VAR_PlayerItemInHands: @@ -8733,7 +8733,7 @@ return; v5 = 0; v25 = 8 * currPlayerId + 400; - LOBYTE(v25) = (8 * currPlayerId - 112) | 4; + LOBYTE(v25) = PID(OBJECT_Player,currPlayerId - 112); pAudioPlayer->PlaySound(SOUND_20001, v25, 0, -1, 0, 0, 0, 0); return; } @@ -8742,7 +8742,6 @@ } - //----- (0044AFFB) -------------------------------------------------------- void Player::AddVariable(enum VariableType var_type, signed int val) { @@ -9256,7 +9255,7 @@ bFlashHistoryBook = 1; _play_sound: v28 = 8 * uPlayerIdx + 400; - LOBYTE(v28) = (8 * uPlayerIdx - 112) | 4; + LOBYTE(v28) = PID(OBJECT_Player,uPlayerIdx - 112); pAudioPlayer->PlaySound(SOUND_20001, v28, 0, -1, 0, 0, 0, 0); return; } @@ -9466,14 +9465,14 @@ GameUI_DrawFoodAndGold(); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_CurrentHP: ReceiveDamage((signed int)pValue, 4); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_CurrentSP: @@ -9484,28 +9483,28 @@ *(int *)v9 = 0; pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_ACModifier: this->sACModifier -= (unsigned __int8)pValue; pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_BaseLevel: this->uLevel -= (unsigned __int8)pValue; pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_LevelModifier: this->sLevelModifier -= (unsigned __int8)pValue; pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_Age: @@ -9522,7 +9521,7 @@ *((int *)v12 + 1) -= v14 + HIDWORD(v13); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_QBits_QuestsDone: @@ -9543,7 +9542,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_IntellectBonus: @@ -9552,7 +9551,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_PersonalityBonus: @@ -9561,7 +9560,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_EnduranceBonus: @@ -9570,7 +9569,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_SpeedBonus: @@ -9579,7 +9578,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_AccuracyBonus: @@ -9588,7 +9587,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_LuckBonus: @@ -9597,7 +9596,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_BaseMight: @@ -9605,7 +9604,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_BaseIntellect: @@ -9613,7 +9612,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_BasePersonality: @@ -9621,7 +9620,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_BaseEndurance: @@ -9629,7 +9628,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_BaseSpeed: @@ -9637,7 +9636,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_BaseAccuracy: @@ -9645,7 +9644,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_BaseLuck: @@ -9653,7 +9652,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_FireResistance: @@ -9661,7 +9660,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_AirResistance: @@ -9669,7 +9668,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_WaterResistance: @@ -9677,7 +9676,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_EarthResistance: @@ -9685,7 +9684,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_SpiritResistance: @@ -9693,7 +9692,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_MindResistance: @@ -9701,7 +9700,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_BodyResistance: @@ -9709,7 +9708,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_LightResistance: @@ -9717,7 +9716,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_DarkResistance: @@ -9725,7 +9724,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_MagicResistance: @@ -9733,7 +9732,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_FireResistanceBonus: @@ -9741,7 +9740,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_AirResistanceBonus: @@ -9749,7 +9748,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_WaterResistanceBonus: @@ -9757,7 +9756,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_EarthResistanceBonus: @@ -9765,7 +9764,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_SpiritResistanceBonus: @@ -9773,7 +9772,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_MindResistanceBonus: @@ -9781,7 +9780,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_BodyResistanceBonus: @@ -9789,7 +9788,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_LightResistanceBonus: @@ -9797,7 +9796,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_DarkResistanceBonus: @@ -9805,7 +9804,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_MagicResistanceBonus: @@ -9815,14 +9814,14 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)v23, v25); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_FixedFood: Party::TakeFood((unsigned int)pValue); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_StaffSkill: @@ -9858,7 +9857,7 @@ *((short *)&this->pConditions[16] + VarNum) -= (unsigned __int8)pValue; pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_Cursed: @@ -9882,7 +9881,7 @@ *((int *)this + 2 * result - 209) = 0; pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = (8 * v4 - 112) | 4; + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; default:
--- a/Render.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/Render.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -23,6 +23,7 @@ #include "TileFrameTable.h" #include "texts.h" #include "mm7_data.h" +#include "MM7.h" #pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") #pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") @@ -3182,7 +3183,7 @@ HIWORD(v26) = HIWORD(v42); LOWORD(v26) = 0; v27 = (object->uAttributes & 0x20) == 0; - v3->sZValue = v26 + (8 * i | OBJECT_Item); + v3->sZValue = v26 + (PID(OBJECT_Item,i)); v3->dimming_level = 0; v3->uTintColor = 0; if ( !v27 ) @@ -3682,7 +3683,7 @@ v27->world_z = decor->vPosition.z; v27->uScreenSpaceY = v40; HIWORD(v30) = HIWORD(v39); - v31 = 8 * i | OBJECT_Decoration; + v31 = PID(OBJECT_Decoration,i); LOWORD(v30) = 0; v27->uIndoorSectorID = 0; v27->sZValue = v30 + v31; @@ -7599,60 +7600,12 @@ // 4D864C: using guessed type char byte_4D864C; //----- (004A2DA3) -------------------------------------------------------- -void Render::DrawStrip(unsigned int uNumVertices, struct stru148 *a3, IDirect3DTexture2 *pTexture) -{ - //int v4; // ebx@1 - int v7; // eax@7 - float v12; // ST3C_4@8 - int i; - - //v4 = (int)this; - if (!this->uNumD3DSceneBegins) - return; - - if (uNumVertices >= 3) - { - this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP); - if (this->bUsingSpecular) - { - this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); - this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); - this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); - } - - for (i = 0; i < uNumVertices; ++i) - { - pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; - pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; - pVertices[i].pos.z = 0.99989998; - pVertices[i].rhw = array_50AC10[i]._rhw; - - pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, true, false); - v7 = 0; - if (this->bUsingSpecular) - { - v12 = array_50AC10[i].vWorldViewPosition.x; - v7 = sub_47C3D7_get_fog_related_stuff(0, 1, v12); - } - pVertices[i].specular = v7; - pVertices[i].texcoord.x = array_50AC10[i].u; - pVertices[i].texcoord.y = array_50AC10[i].v; - } - pRenderer->pRenderD3D->pDevice->SetTexture(0, pTexture); - pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, - pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); - } -} - -//----- (004A2DA3) -------------------------------------------------------- -void Render::DrawFan(unsigned int uNumVertices, stru148 *a3, IDirect3DTexture2 *pTexture) -{ - //int v4; // ebx@1 +void Render::DrawSkyPolygon(unsigned int uNumVertices, stru148 *a3, IDirect3DTexture2 *pTexture) +{ int v7; // eax@7 float v13; // ST3C_4@8 int i; - //v4 = (int)this; if ( !this->uNumD3DSceneBegins ) return; if ( uNumVertices >= 3 )
--- a/Render.h Mon Apr 01 09:05:31 2013 +0600 +++ b/Render.h Mon Apr 01 09:05:51 2013 +0600 @@ -322,8 +322,7 @@ unsigned int GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6); void DrawPolygon(unsigned int uNumVertices, stru148 *a3, ODMFace *a4, IDirect3DTexture2 *pTexture); void DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders); - void DrawStrip(unsigned int uNumVertices, struct stru148 *a3, IDirect3DTexture2 *pTexture); - void DrawFan(unsigned int uNumVertices, stru148 *a3, IDirect3DTexture2 *a4); + void DrawSkyPolygon(unsigned int uNumVertices, stru148 *a3, IDirect3DTexture2 *pTexture); void _4A2ED5(signed int a2, stru148 *a3, IDirect3DTexture2 *pHwTex); void DrawIndoorPolygon(unsigned int uNumVertices, struct BLVFace *a3, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8); void MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle);
--- a/SaveLoad.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/SaveLoad.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -230,77 +230,31 @@ //----- (0045F469) -------------------------------------------------------- void SaveGame( bool IsAutoSAve, bool NotSaveWorld ) { - int result; // eax@1 unsigned short *pScreenshot; // edi@5 int text_pos; // eax@6 - int v5; // eax@6 - int v6; // eax@6 - const char *v7; // edi@8 - FILE *v8; // edi@24 + FILE *pLLoidFile; // edi@24 char* compressed_buf; // edi@30 - void *v10; // esi@31 - void *v11; // esi@31 - void *v12; // esi@37 - void *v13; // esi@37 - void *v14; // esi@37 - void *v15; // esi@37 - void *v16; // esi@37 - int v17; // esi@37 - unsigned int v18; // ecx@38 - unsigned int v19; // esi@39 - BSPModel *v20; // edx@39 char *data_write_pos; // esi@41 - void *v22; // esi@41 - BSPModel *v23; // eax@42 - signed int v24; // edi@42 - unsigned __int8 v25; // zf@43 - unsigned __int8 v26; // sf@43 - signed int v27; // edi@47 - void *v28; // esi@50 - void *v29; // esi@50 - void *v30; // esi@50 - void *v31; // esi@50 - int v32; // esi@51 - int v33; // eax@51 - DWORD v34; // eax@59 - //std::string v35; // [sp-18h] [bp-288h]@8 - const char *v36; // [sp-10h] [bp-280h]@6 - const char *v37; // [sp-Ch] [bp-27Ch]@6 - unsigned int *v38; // [sp-8h] [bp-278h]@8 - CHAR Buffer; // [sp+Ch] [bp-264h]@59 + CHAR Buffer[128]; // [sp+Ch] [bp-264h]@59 char Dir[255]; // [sp+8Ch] [bp-1E4h]@51 char Drive[255]; // [sp+ACh] [bp-1C4h]@51 SavegameHeader save_header; // [sp+CCh] [bp-1A4h]@10 - //int v43; // [sp+CCh] [bp-1A4h]@10 - //char Dest[20]; // [sp+E0h] [bp-190h]@10 - //unsigned __int64 pTimePlayed; // [sp+F4h] [bp-17Ch]@10 char Filename[255]; // [sp+130h] [bp-140h]@51 char Ext[255]; // [sp+150h] [bp-120h]@51 - char v48; // [sp+151h] [bp-11Fh]@51 char Source[32]; // [sp+170h] [bp-100h]@51 - char Str[120]; // [sp+190h] [bp-E0h]@8 - int v51; // [sp+208h] [bp-68h]@2 + char work_string[120]; // [sp+190h] [bp-E0h]@8 + int pPositionY; // [sp+208h] [bp-68h]@2 int pPositionX; // [sp+20Ch] [bp-64h]@2 - int v53; // [sp+210h] [bp-60h]@2 - int v54; // [sp+214h] [bp-5Ch]@2 + int sPRotationY; // [sp+210h] [bp-60h]@2 + int sPRotationX; // [sp+214h] [bp-5Ch]@2 ODMHeader odm_data; // [sp+218h] [bp-58h]@30 - char v56; // [sp+21Ch] [bp-54h]@30 - char v57; // [sp+21Dh] [bp-53h]@30 - char v58; // [sp+21Eh] [bp-52h]@30 - char v59; // [sp+21Fh] [bp-51h]@30 - int v60; // [sp+220h] [bp-50h]@30 - int v61; // [sp+224h] [bp-4Ch]@30 - int v62; // [sp+228h] [bp-48h]@2 + int res; // [sp+224h] [bp-4Ch]@30 + int pPositionZ; // [sp+228h] [bp-48h]@2 LOD::Directory pLodDirectory; // [sp+22Ch] [bp-44h]@2 size_t Size; // [sp+250h] [bp-20h]@26 - __int16 *v66; // [sp+254h] [bp-1Ch]@1 char *uncompressed_buff; // [sp+258h] [bp-18h]@2 - __int16 *v68; // [sp+25Ch] [bp-14h]@32 unsigned int compressed_block_size; // [sp+260h] [bp-10h]@23 - int v70; // [sp+264h] [bp-Ch]@22 - std::string *v71; // [sp+268h] [bp-8h]@8 - int a3; // [sp+26Fh] [bp-1h]@8 - + //v66 = a2; strcpy(byte_6BE3B0, pCurrentMapName); if (!_strcmpi(pCurrentMapName, "d05.blv")) // arena @@ -309,14 +263,16 @@ uncompressed_buff = (char*)malloc(1000000); pLodDirectory.Reset(); pPositionX = pParty->vPosition.x; - v51 = pParty->vPosition.y; - v62 = pParty->vPosition.z; - v53 = pParty->sRotationY; - v54 = pParty->sRotationX; + pPositionY = pParty->vPosition.y; + pPositionZ = pParty->vPosition.z; + sPRotationY = pParty->sRotationY; + sPRotationX = pParty->sRotationX; pParty->vPosition.x = pParty->vPrevPosition.x; - pParty->vPosition.y = pParty->vPrevPosition.z; - pParty->vPosition.z = pParty->vPrevPosition.y; - pParty->uFallStartY = pParty->vPrevPosition.y; + pParty->vPosition.z = pParty->vPrevPosition.z; + pParty->vPosition.y = pParty->vPrevPosition.y; + + pParty->uFallStartY = pParty->vPrevPosition.z; + pParty->sRotationY = pParty->sPrevRotationY; pParty->sRotationX = pParty->sPrevRotationX; if (uCurrentlyLoadedLevelType == LEVEL_Indoor) @@ -342,8 +298,8 @@ if (pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0)) { - sprintf(Str, pGlobalTXT_LocalizationStrings[612], 200); // ! Code=%d - MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0); + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 200); // ! Code=%d + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0); } assert(sizeof(SavegameHeader) == 100); @@ -356,66 +312,66 @@ pLodDirectory.uDataSize = sizeof(SavegameHeader); if (pNew_LOD->Write(&pLodDirectory, &save_header, 0)) { - sprintf(Str, pGlobalTXT_LocalizationStrings[612], 201); - MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0); + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 201); + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0); } strcpy(pLodDirectory.pFilename, "party.bin"); pLodDirectory.uDataSize = sizeof(Party); //90680; if ( pNew_LOD->Write(&pLodDirectory, pParty, 0) ) { - sprintf(Str, pGlobalTXT_LocalizationStrings[612], 202); - MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0); + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 202); + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0); } strcpy(pLodDirectory.pFilename, "clock.bin"); pLodDirectory.uDataSize =sizeof(Timer);// 40; if ( pNew_LOD->Write(&pLodDirectory, pEventTimer, 0) ) { - sprintf(Str, pGlobalTXT_LocalizationStrings[612], 203); - MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0); + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 203); + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0); } strcpy(pLodDirectory.pFilename, "overlay.bin"); pLodDirectory.uDataSize =sizeof(OtherOverlayList);// 1008; if ( pNew_LOD->Write(&pLodDirectory, pOtherOverlayList, 0) ) { - sprintf(Str, pGlobalTXT_LocalizationStrings[612], 204); - MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0); + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 204); + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0); } strcpy(pLodDirectory.pFilename, "npcdata.bin"); pLodDirectory.uDataSize = 501 * sizeof(NPCData); assert(pLodDirectory.uDataSize == 38076); if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pNewNPCData, 0) ) { - sprintf(Str, pGlobalTXT_LocalizationStrings[612], 205); - MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0); + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 205); + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0); } strcpy(pLodDirectory.pFilename, "npcgroup.bin"); pLodDirectory.uDataSize = 102; if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pGroups_copy, 0) ) { - sprintf(Str, pGlobalTXT_LocalizationStrings[612], 206); - MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0); + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 206); + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0); } for (int i = 1; i <= 4; ++i) // 4 - players { for (int j = 1; j <= 5; ++j) // 5 - images { - sprintf(Str, "data\\lloyd%d%d.pcx", i, j); - v8 = fopen(Str, "rb"); - if ( v8 ) + sprintf(work_string, "data\\lloyd%d%d.pcx", i, j); + pLLoidFile = fopen(work_string, "rb"); + if ( pLLoidFile ) { __debugbreak(); - sprintf(Str, "lloyd%d%d.pcx", i, j); - fseek(v8, 0, 2); - pLodDirectory.uDataSize = ftell(v8); - rewind(v8); - fread(uncompressed_buff, pLodDirectory.uDataSize, 1, v8); - strcpy((char *)&pLodDirectory, Str); - fclose(v8); - remove(Str); + sprintf(work_string, "lloyd%d%d.pcx", i, j); + fseek(pLLoidFile, 0, SEEK_END); + pLodDirectory.uDataSize = ftell(pLLoidFile); + rewind(pLLoidFile); + fread(uncompressed_buff, pLodDirectory.uDataSize, 1, pLLoidFile); + strcpy(pLodDirectory.pFilename, work_string); + fclose(pLLoidFile); + remove(work_string); if ( pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0) ) { - sprintf(Str, pGlobalTXT_LocalizationStrings[612], 207); - MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0); + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 207); + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0); Size = 5080748; } } @@ -467,8 +423,8 @@ data_write_pos += 112 * uNumSpriteObjects; memcpy(data_write_pos, &uNumChests, 4); data_write_pos += 4; - memcpy(data_write_pos, pChests, 5324 * uNumChests); - data_write_pos += 5324 * uNumChests; + memcpy(data_write_pos, pChests, sizeof(Chest)*uNumChests);//5324 * + data_write_pos += sizeof(Chest)* uNumChests; memcpy(data_write_pos, pIndoor->pDoors, 0x3E80); data_write_pos += 16000; memcpy(data_write_pos, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size); @@ -516,8 +472,8 @@ data_write_pos += 112 * uNumSpriteObjects; memcpy(data_write_pos, &uNumChests, 4); data_write_pos += 4; - memcpy(data_write_pos, pChests, 5324 * uNumChests); - data_write_pos += 5324 * uNumChests; + memcpy(data_write_pos, pChests, sizeof(Chest)* uNumChests); + data_write_pos += sizeof(Chest)* uNumChests; memcpy(data_write_pos, &stru_5E4C90, 0xC8); data_write_pos += 200; memcpy(data_write_pos, &pOutdoor->loc_time, 0x38); @@ -525,11 +481,11 @@ } strcpy(Source, pCurrentMapName); _splitpath(Source, Drive, Dir, Filename, Ext); - v48 = 100; + Size = (int)data_write_pos - (int)uncompressed_buff; compressed_block_size = 999984; - LOBYTE(v33) = zlib::MemZip((char *)compressed_buf + 16, (unsigned int *)&compressed_block_size, uncompressed_buff,Size); - if ( v33 || (signed int)compressed_block_size > (signed int)Size ) + res = zlib::MemZip((char *)compressed_buf + 16, (unsigned int *)&compressed_block_size, uncompressed_buff,Size); + if (res || (signed int)compressed_block_size > (signed int)Size ) { memcpy((void *)(compressed_buf + 16), uncompressed_buff, Size); compressed_block_size = Size; @@ -538,12 +494,12 @@ memcpy(&((ODMHeader *)compressed_buf)->uCompressedSize, &compressed_block_size, 4); memcpy(&((ODMHeader *)compressed_buf)->uDecompressedSize, &Size, 4); sprintf(Source, "%s%s", &Filename, &Ext); - strcpy((char *)&pLodDirectory, Source); + strcpy(pLodDirectory.pFilename, Source); pLodDirectory.uDataSize = compressed_block_size; if ( pNew_LOD->Write(&pLodDirectory, (const void *)compressed_buf, 0) ) { - sprintf(Str, pGlobalTXT_LocalizationStrings[612], 208); - MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0); + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 208); + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0); } free((void *)compressed_buf); } @@ -552,18 +508,17 @@ { if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) ) { - v34 = GetLastError(); - FormatMessageA(0x1000, 0, v34, 0x400, &Buffer, 0x80, 0); - sprintf(Str, pGlobalTXT_LocalizationStrings[612], 300); - MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0); + FormatMessageA(0x1000, 0, GetLastError(), 0x400, Buffer, 0x80, 0); + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 300); + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0); } } pParty->vPosition.x = pPositionX; - pParty->vPosition.y = v51; - pParty->vPosition.z = v62; - pParty->uFallStartY = v62; - pParty->sRotationY = v53; - pParty->sRotationX = v54; + pParty->vPosition.y = pPositionY; + pParty->vPosition.z = pPositionZ; + pParty->uFallStartY = pPositionZ; + pParty->sRotationY = sPRotationY; + pParty->sRotationX = sPRotationX; }
--- a/UIHouses.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/UIHouses.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -2591,9 +2591,8 @@ break; } - case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_102: + case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RULES: { - __debugbreak(); pOutString = pFontArrus; strcpy(pTmpBuf, pNPCTopics[354].pText); dialog_window.uFrameWidth = game_viewport_width; @@ -2611,9 +2610,8 @@ window_SpeakInHouse->DrawText(pOutString, 12, 354 - pTextHeight, 0, v63, 0, 0, 0); break; } - case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_103: + case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_VICTORY_CONDITIONS: { - __debugbreak(); strcpy(pTmpBuf, pNPCTopics[(uint)window_SpeakInHouse->ptr_1C + 247].pText); dialog_window.uFrameWidth = game_viewport_width; dialog_window.uFrameZ = 452; @@ -2794,7 +2792,7 @@ pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; v54 = (174 - v48 * (174 - all_text_height) / v48 - all_text_height) / 2 - (174 - all_text_height) / v48 / 2 + 138; v37 = -pDialogueWindow->pNumPresenceButton < 0; - if ( v37 ^ pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton ) + if ( pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton ) { pItemNum = 2; pNumString = 0; @@ -2809,8 +2807,9 @@ pColorText = pColorYellow; if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) pColorText = pColorWhite; - dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, *(const char **)&pOutString->cFirstChar, 3); + dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3); pItemNum++; + ++pNumString; pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; } while ( pItemNum < pNumActiveItem );
--- a/UIHouses.h Mon Apr 01 09:05:31 2013 +0600 +++ b/UIHouses.h Mon Apr 01 09:05:51 2013 +0600 @@ -33,8 +33,8 @@ HOUSE_DIALOGUE_TOWNHALL_99 = 99, HOUSE_DIALOGUE_TOWNHALL_100 = 100, HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN = 101, - HOUSE_DIALOGUE_TAVERN_ARCOMAGE_102 = 102, - HOUSE_DIALOGUE_TAVERN_ARCOMAGE_103 = 103, + HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RULES = 102, + HOUSE_DIALOGUE_TAVERN_ARCOMAGE_VICTORY_CONDITIONS = 103, HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RESULT = 104, HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1 = 105, HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_2 = 106,
--- a/UIPopup.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/UIPopup.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -2131,20 +2131,20 @@ if ( pRenderer->uNumSceneBegins ) { pWindow.DrawMessageBox(1); - MonsterPopup_Draw(v6 >> 3, &pWindow); + MonsterPopup_Draw(PID_ID(v6), &pWindow); } else { pRenderer->BeginScene(); pWindow.DrawMessageBox(1); - MonsterPopup_Draw(v6 >> 3, &pWindow); + MonsterPopup_Draw(PID_ID(v6), &pWindow); pRenderer->EndScene(); } } } else { - v7 = v6 >> 3; + v7 = PID_ID(v6); if ( ! (pObjectList->pObjects[pSpriteObjects[v7].uObjectDescID].uFlags & 0x10 ) ) { v8 = &pSpriteObjects[v7].stru_24;
--- a/UISaveLoad.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/UISaveLoad.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -1,5 +1,5 @@ #include <assert.h> - +#include <io.h> #include "MM7.h" #include "MapInfo.h" @@ -134,7 +134,7 @@ pMapID = pMapStats->GetMapInfo(pSavegameHeader[v6].pLocationName); pWindow.DrawTitleText(pFontSmallnum, 0, 0, 0, pMapStats->pInfos[pMapID].pName, 3); v8 = (signed __int64)(pSavegameHeader[uLoadGameUI_SelectedSlot].uWordTime * 0.234375) / 60; - pMinutes = (int)((signed __int64)(pSavegameHeader[uLoadGameUI_SelectedSlot].uWordTime * 0.234375) / 60) >> 32; + pMinutes = (int)(((signed __int64)(pSavegameHeader[uLoadGameUI_SelectedSlot].uWordTime * 0.234375) / 60) >> 32); v9 = v8; v8 /= 60i64; pAMPM2 = v8; @@ -156,7 +156,7 @@ pWindow.uFrameY = pGUIWindow_CurrentMenu->uFrameY + 261; HIDWORD(pAMPM2) = v14 == 0 && ((signed int)v14 > 0 || (unsigned int)pOurHour >= 12) && (signed int)v14 <= 0 && (v14 != 0 || (unsigned int)pOurHour < 24); - if ( v14 != 0 || (signed int)v14 <= 0 && (unsigned int)pOurHour <= 12 ) + if ( v14 != 0 || ((signed int)v14 <= 0) && (unsigned int)pOurHour <= 12 ) { if ( !(v14 | (unsigned int)pOurHour) ) { @@ -264,3 +264,230 @@ //pAllocator->FreeChunk(pSavegameThumbnails[i].pPixels); pSavegameThumbnails[i].Release(); } + +//----- (0045E361) -------------------------------------------------------- +void __fastcall GameUI_DrawLoadMenu(unsigned int uDialogueType) + { + unsigned int v1; // ebp@5 + unsigned int v2; // eax@5 + //signed int v3; // ebp@11 + FILE *v4; // eax@14 + FILE *v5; // eax@18 + unsigned int v6; // eax@25 + GUIButton *v7; // eax@27 + const char *v8; // [sp-8h] [bp-26Ch]@25 + //char *v9; // [sp-4h] [bp-268h]@19 + enum TEXTURE_TYPE v10; // [sp-4h] [bp-268h]@25 + unsigned int uDialogueType_; // [sp+10h] [bp-254h]@1 + //RGBTexture *pTex; // [sp+10h] [bp-254h]@12 + //SavegameHeader *Dest; // [sp+14h] [bp-250h]@12 + //const char *Str1; // [sp+18h] [bp-24Ch]@12 + LODWriteableFile pLODFile; // [sp+1Ch] [bp-248h]@1 + int v16; // [sp+260h] [bp-4h]@1 + + uDialogueType_ = uDialogueType; + dword_6BE138 = -1; + pIcons_LOD->_inlined_sub2(); + + memset(pSavegameUsedSlots, 0, sizeof(pSavegameUsedSlots)); + memset(pSavegameThumbnails, 0, 45 * sizeof(RGBTexture)); + uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE); + uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE); + uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE); + uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE); + uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE); + uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE); + if ( uDialogueType_ ) + { + pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); + if ( pCurrentScreen == SCREEN_SAVEGAME ) + { + v1 = uTextureID_save_up; + v2 = uTextureID_LS_saveU; + } + else + { + v1 = uTextureID_load_up; + v2 = uTextureID_LS_loadU; + } + pRenderer->DrawTextureIndexed(241, 302, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0)); + pRenderer->DrawTextureIndexed(18, 141, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0)); + pRenderer->DrawTextureIndexed(351, 302, (Texture *)(uTextureID_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_u] : 0)); + } + else + { + pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX); + } + pGUIWindow_CurrentMenu = GUIWindow::Create(saveload_dlg_xs[uDialogueType_], saveload_dlg_ys[uDialogueType_], saveload_dlg_zs[uDialogueType_], + saveload_dlg_ws[uDialogueType_], WINDOW_MainMenu_Load, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);// "Reading..." + pRenderer->Present(); + pSavegameList->Initialize(0); + if ( pSaveListPosition > (signed int)uNumSavegameFiles ) + { + pSaveListPosition = 0; + uLoadGameUI_SelectedSlot = 0; + } + pLODFile.AllocSubIndicesAndIO(0x12C, 0); + assert(sizeof(SavegameHeader) == 0x64); + //v3 = 0; + for (uint i = 0; i < uNumSavegameFiles; ++i) + { + + sprintf(pTmpBuf, "saves\\%s", pSavegameList->pFileList[i].pSaveFileName); + if (_access(pTmpBuf, 6)) + { + pSavegameUsedSlots[i] = 0; + strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[72]); // "Empty" + continue; + } + pLODFile.LoadFile(pTmpBuf, 1); + v4 = pLODFile.FindContainer("header.bin", true); + if ( v4 ) + fread(&pSavegameHeader[i], 0x64, 1, v4); + if ( !_strcmpi(pSavegameList->pFileList[i].pSaveFileName, pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7" + strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[16]);// "Autosave" + v5 = pLODFile.FindContainer("image.pcx", true); + if ( !v5 ) + { + pSavegameUsedSlots[i] = 0; + strcpy(pSavegameList->pFileList[i].pSaveFileName, ""); + } + else + { + pSavegameThumbnails[i].LoadFromFILE(v5, 0, true); + pLODFile.CloseWriteFile(); + pSavegameUsedSlots[i] = 1; + } + } + + //LABEL_24: + pLODFile.FreeSubIndexAndIO(); + if ( pCurrentScreen == SCREEN_SAVEGAME ) + { + uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); + uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD",TEXTURE_16BIT_PALETTE); + } + else + { + uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); + uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_loadD",TEXTURE_16BIT_PALETTE); + } + uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE); + uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE); + pGUIWindow_CurrentMenu->CreateButton(21, 198, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21, 219, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 1, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21, 240, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 2, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21, 261, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 3, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21, 282, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 4, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21, 303, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 5, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21, 324, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 6, 0, "", 0); + pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(241, 302, 105, 40, 1, 0, UIMSG_LoadSlot, 0, 0, "", + pIcons_LOD->GetTexture(uTextureID_LS_), 0); + pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(350, 302, 105, 40, 1, 0, UIMSG_Cancel, 0, 0, "", + pIcons_LOD->GetTexture(uTextureID_x_d), 0); + pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton(215, 199, 17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "", + pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0); + pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 0x143, 0x11, 0x11, 1, 0, UIMSG_DownArrow, uNumSavegameFiles, 0, "", + pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0); + + } + +//----- (0045E93E) -------------------------------------------------------- +void GameUI_DrawSaveMenu() + { + unsigned int v0; // ebp@4 + unsigned int v1; // eax@4 + char *v3; // eax@7 + FILE *v4; // eax@11 + FILE *v5; // eax@11 + LODWriteableFile v11; // [sp+1Ch] [bp-248h]@1 + + ++pIcons_LOD->uTexturePacksCount; + if ( !pIcons_LOD->uNumPrevLoadedFiles ) + pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; + memset(pSavegameUsedSlots, 0, 0xB4u); + memset(&pSavegameThumbnails, 0, 0x708u); + uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE); + uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE); + uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE); + uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE); + uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE); + uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE); + pRenderer->DrawTextureIndexed( 8u, 8u, + (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); + if ( pCurrentScreen == SCREEN_SAVEGAME ) + { + v0 = uTextureID_save_up; + v1 = uTextureID_LS_saveU; + } + else + { + v0 = uTextureID_load_up; + v1 = uTextureID_LS_loadU; + } + pRenderer->DrawTextureIndexed(0xF1u, 0x12Eu, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0)); + pRenderer->DrawTextureIndexed(0x15Fu, 0x12Eu, + (Texture *)(uTextureID_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0)); + pRenderer->DrawTextureIndexed(0x12u, 0x8Du, (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0)); + pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0); + pRenderer->Present(); + pSavegameList->Initialize(1u); + v11.AllocSubIndicesAndIO(0x12Cu, 0); + //v2 = pSavegameUsedSlots; + // Dest = pSavegameHeader; + // this_ = pSavegameThumbnails; + // v8 = (char *)pSavegameList->pSavesNames; + for (uint i = 0; i < 40; ++i) + { + v3 = pSavegameList->pFileList[i].pSaveFileName; + if ( !*pSavegameList->pFileList[i].pSaveFileName ) + v3 = "1.mm7"; + sprintf(pTmpBuf, "saves\\%s", v3); + if ( _access(pTmpBuf, 0) || _access(pTmpBuf, 6) ) + { + pSavegameUsedSlots[i] = 0; + strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[LOCSTR_EMPTY]); + } + else + { + v11.LoadFile(pTmpBuf, 1); + v4 = v11.FindContainer("header.bin", 1); + fread(&pSavegameHeader[i], 100, 1u, v4); + v5 = v11.FindContainer("image.pcx", 1); + if ( v5 ) + { + pSavegameThumbnails[i].LoadFromFILE(v5, 0, 1u); + v11.CloseWriteFile(); + pSavegameUsedSlots[i] = 1; + } + else + { + pSavegameUsedSlots[i] = 0; + } + } + + } + + v11.FreeSubIndexAndIO(); + uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); + uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD", TEXTURE_16BIT_PALETTE); + uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE); + uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE); + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_17, 0, 0); + pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21u, 218u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 1u, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21u, 238u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 2u, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21u, 258u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 3u, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21u, 278u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 4u, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21u, 298u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 5u, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21u, 318u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 6u, 0, "", 0); + pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0x69u, 0x28u, 1, 0, UIMSG_LoadSlot, 0, 0, "", + (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0), 0); + pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(0x15Eu, 0x12Eu, 0x69u, 0x28u, 1, 0, UIMSG_Cancel, 0, 0, "", + (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0), 0); + pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0xC7u, 0x11u, 0x11u, 1, 0, UIMSG_ArrowUp, 0, 0, "", + (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0), 0); + pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0x143u, 0x11u, 0x11u, 1, 0, UIMSG_DownArrow, 0x22u, 0, "", + (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0), 0); + }
--- a/UiGame.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/UiGame.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -516,6 +516,7 @@ int v16; // ecx@46 const char *v17; // eax@49 signed int v18; // eax@55 + signed int v18b; signed int v19; // ecx@63 BLVFace *pFace; // eax@69 __int16 v21; // ax@70 @@ -690,7 +691,8 @@ { if ( uCurrentlyLoadedLevelType != LEVEL_Indoor) { - v21 = pOutdoor->pBModels[(signed int)(unsigned __int16)v18 >> 9].pFaces[v19 & 0x3F].sCogTriggeredID; + v18b = (signed int)(unsigned __int16)v18 >> 9; + v21 = pOutdoor->pBModels[v18b].pFaces[v19 & 0x3F].sCogTriggeredID; //goto LABEL_71; if ( !v21 || (v22 = GetEventHintString(v21)) == 0 ) //goto LABEL_73; @@ -1420,7 +1422,7 @@ if ( pParty->uFlags & 0x20 ) v16 = dword_5079C8; } - pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[pElem->uPackedID >> 3] - 4, + pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[PID_ID(pElem->uPackedID)] - 4, 0x181u, (Texture *)(v16 != -1 ? &pIcons_LOD->pTextures[v16] : 0)); } }
--- a/Vis.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/Vis.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -329,7 +329,7 @@ pGame->pIndoorCameraD3D->ViewTransform(&a1, 1); v9 = _48B561_mess_with_scaling_along_z(/*v8, */a1.vWorldViewPosition.x); LOWORD(v9) = 0; - v15 = (void *)((8 * pFaceID | 6) + v9); + v15 = (void *)((PID(OBJECT_BModel,pFaceID)) + v9); pNumPointers = &list->uNumPointers; //v16 = 2; //v11 = list->uNumPointers; @@ -537,7 +537,7 @@ if (!default_list.uNumPointers) return -1; - return get_object_zbuf_val(default_list.object_pointers[0]); + return get_object_zbuf_val(default_list.object_pointers[0]);//Click to the Rat in dragon cave result crash. Maybe object_pointers incorrect } //----- (004C1C0C) -------------------------------------------------------- @@ -1559,8 +1559,8 @@ case VisObjectType_Sprite: { v5 = filter->field_10; - int object_idx = (pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].object_pid & 0xFFFF) >> 3; - int object_type = pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].object_pid & 7; + int object_idx = PID_ID(pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].object_pid); + int object_type = PID_TYPE(pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].object_pid); if ( v5 & 2 ) { if (object_type == filter->object_id)
--- a/mm7_1.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/mm7_1.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -1076,7 +1076,7 @@ v1 = pMouse->GetCursorPos(&a2); v0 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v25)->y]]; } - if ( (v0 & 7) == OBJECT_Item) + if ( PID_TYPE(v0) == OBJECT_Item) { a2.y = (signed int)(unsigned __int16)v0 >> 3; v21 = (signed int)(unsigned __int16)v0 >> 3; @@ -1111,9 +1111,9 @@ return; goto LABEL_14; } - if ( (v0 & 7) != OBJECT_Actor) + if ( PID_TYPE(v0) != OBJECT_Actor) { - if ( (v0 & 7) == OBJECT_Decoration) + if ( PID_TYPE(v0) == OBJECT_Decoration) { v13 = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[v13->uDecorationDescID].uRadius) >= 512 ) @@ -1139,7 +1139,7 @@ } else { - if ( (v0 & 7) != OBJECT_BModel || (signed)v0 >= 0x2000000 ) + if ( PID_TYPE(v0) != OBJECT_BModel || (signed)v0 >= 0x2000000 ) { v4 = pParty->pPickedItem.uItemID; if ( !pParty->pPickedItem.uItemID )
--- a/mm7_2.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/mm7_2.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -382,7 +382,7 @@ do { v2 = v1->uAIState; - if ( v1->uAIState == Dead || v2 == Removed || v2 == Disabled || (v3 = v1->uSummonerID) != 0 && (v3 & 7) == OBJECT_Player) + if ( v1->uAIState == Dead || v2 == Removed || v2 == Disabled || (v3 = v1->uSummonerID) != 0 && PID_TYPE(v3) == OBJECT_Player) ++v0; ++v1; --v7; @@ -4124,7 +4124,7 @@ { if ( v20 == uNumActors ) ++uNumActors; - v6->uSummonerID = 8 * v17 | 4; + v6->uSummonerID = PID(OBJECT_Player,v17); result = v6->pActorBuffs[2].Apply( pParty->uTimePlayed + (signed __int64)((double)(a3 << 7) * 0.033333335), v16, @@ -4982,7 +4982,7 @@ LOWORD(v7) = v5 & 0xE0; v12 = v7 + v11; LOWORD(v7) = v8 & 0xE0; - return ((v8 & 7) + (v5 & 7) + (a3a & 7) + (v6 & 7)) | (v7 + v12) | ((v8 & 0x1C00) + return (PID_TYPE(v8) + PID_TYPE(v5) + PID_TYPE(a3a) + PID_TYPE(v6)) | (v7 + v12) | ((v8 & 0x1C00) + (v5 & 0x1C00) + v9 + (__PAIR__(v10, (unsigned __int16)a4 >> 2) & 0x1C00)); @@ -10180,7 +10180,7 @@ DoInteractionWithTopmostZObject((unsigned __int16)v1, (signed int)(unsigned __int16)v1 >> 3); } v22 = 0; - v1 = (int *)((signed int)(viewparams->uScreen_BttmR_X + viewparams->uScreen_topL_X) >> 1); + v1 = (int *)((signed int)(viewparams->uScreen_BttmR_X + viewparams->uScreen_topL_X) >> 1);//wrong pointer if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y ) { v2 = (char *)v1 - 50; @@ -10213,11 +10213,11 @@ } while ( v6 < v22 ); } - if ( (v7 & 7) == OBJECT_Decoration) + if ( PID_TYPE(v7) == OBJECT_Decoration) { - v16 = (unsigned int)v7 >> 3; + v16 = (unsigned int)PID_ID(v7); if ( (signed int)(((unsigned int)*v21 >> 16) - - pDecorationList->pDecorations[pLevelDecorations[(unsigned int)v7 >> 3].uDecorationDescID].uRadius) <= 512 ) + - pDecorationList->pDecorations[pLevelDecorations[(unsigned int)PID_ID(v7)].uDecorationDescID].uRadius) <= 512 ) if ( v19 == v22 && v4 < 100 ) { ++v22; @@ -10311,12 +10311,12 @@ v26 = a2; v2 = a1; - switch ( a1 & 7 ) + switch ( PID_TYPE(a1) ) { case OBJECT_Item: // take the item - v17 = a1 >> 3; - v26 = a1 >> 3; - v18 = a1 >> 3; + v17 = PID_ID(a1); + v26 = PID_ID(a1); + v18 = PID_ID(a1); if ( pObjectList->pObjects[pSpriteObjects[v18].uObjectDescID].uFlags & 0x10 || v17 >= 1000 || !pSpriteObjects[v18].uObjectDescID ) @@ -10348,14 +10348,14 @@ break; case OBJECT_Actor: - v12 = a1 >> 3; - v13 = &pActors[a1 >> 3]; + v12 = PID_ID(a1); + v13 = &pActors[PID_ID(a1)]; v14 = v13->uAIState; if ( v14 == 4 || v14 == 17 ) return 1; if ( v14 == 5 ) { - stru_50C198.LootActor(&pActors[a1 >> 3]); + stru_50C198.LootActor(&pActors[PID_ID(a1)]); } else { @@ -10392,7 +10392,7 @@ break; case OBJECT_Decoration: - v8 = &pLevelDecorations[a1 >> 3]; + v8 = &pLevelDecorations[PID_ID(a1)]; v9 = v8->field_16_event_id; if ( v9 ) { @@ -10401,7 +10401,7 @@ } else { - if ( !pLevelDecorations[a1 >> 3].IsInteractive() ) + if ( !pLevelDecorations[PID_ID(a1)].IsInteractive() ) return 1; v10 = v8->_idx_in_stru123; v24 = 1; @@ -10413,7 +10413,7 @@ break; default: - if ( (a1 & 7) != OBJECT_BModel) + if ( PID_TYPE(a1) != OBJECT_BModel) { MessageBoxW(nullptr, L"Warning: Invalid ID reached!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Mouse.cpp:2020", 0); return 1; @@ -10421,13 +10421,13 @@ if ( uCurrentlyLoadedLevelType != LEVEL_Indoor ) { if ( a1 >> 9 >= pOutdoor->uNumBModels - || (v7 = &pOutdoor->pBModels[a1 >> 9].pFaces[(a1 >> 3) & 0x3F], BYTE2(v7->uAttributes) & 0x10) + || (v7 = &pOutdoor->pBModels[a1 >> 9].pFaces[(PID_ID(a1)) & 0x3F], BYTE2(v7->uAttributes) & 0x10) || (v6 = v7->sCogTriggeredID) == 0 ) return 1; EventProcessor((signed __int16)v6, v2, 1); return 0; } - v4 = &pIndoor->pFaces[a1 >> 3]; + v4 = &pIndoor->pFaces[PID_ID(a1)]; v5 = v4->uAttributes; if ( !(v5 & 0x2000000) ) { @@ -10488,11 +10488,11 @@ v6 = ((v12 - v4 - 1) >> 1) + 1; do { - if ( (*(char *)v5 & 7) == OBJECT_Actor) + if ( PID_TYPE(*(char *)v5) == OBJECT_Actor) { if ( *v5 <= a3 << 16 ) { - v7 = (signed int)(unsigned __int16)*v5 >> 3; + v7 = PID_ID((signed int)(unsigned __int16)*v5); v8 = pActors[v7].uAIState; if ( v8 != 5 ) { @@ -10559,11 +10559,11 @@ v3 = pRenderer->GetParentBillboardID(a1a); v4 = pBillboardRenderList[v3].sZValue; v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid; - if ( (v5 & 7) == OBJECT_Actor) + if ( PID_TYPE(v5) == OBJECT_Actor) { if ( v4 <= (unsigned int)(a3 << 16) ) { - v6 = v5 >> 3; + v6 = PID_ID(v5); v7 = v6; v8 = pActors[v6].uAIState; if ( v8 != 5 ) @@ -10817,8 +10817,8 @@ while ( 1 ) { v19 = dword_720020_zvalues[v18] & 0xFFFF; - v20 = (dword_720020_zvalues[v18] & 0xFFFFu) >> 3; - if ( (dword_720020_zvalues[v18] & 7) == OBJECT_Item) + v20 = PID_ID(dword_720020_zvalues[v18]); + if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Item) { if ( v20 >= 0x3E8 ) return 0; @@ -10831,16 +10831,16 @@ } goto LABEL_41; } - if ( (dword_720020_zvalues[v18] & 7) == OBJECT_Actor) + if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Actor) { if ( v20 >= 0xBB8 ) return 0; v24 = (const char *)&pActors[v20]; goto LABEL_51; } - if ( (dword_720020_zvalues[v18] & 7) == OBJECT_Decoration) + if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Decoration) break; - if ( (dword_720020_zvalues[v18] & 7) == OBJECT_BModel) + if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_BModel) { if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) { @@ -10853,7 +10853,7 @@ { if ( (dword_720020_zvalues[v18] & 0xFFFFu) >> 9 >= pOutdoor->uNumBModels ) goto LABEL_41; - v22 = pOutdoor->pBModels[(dword_720020_zvalues[v18] & 0xFFFFu) >> 9].pFaces[((dword_720020_zvalues[v18] & 0xFFFFu) >> 3) & 0x3F].sCogTriggeredID; + v22 = pOutdoor->pBModels[(dword_720020_zvalues[v18] & 0xFFFFu) >> 9].pFaces[v20 & 0x3F].sCogTriggeredID; } if ( v22 ) { @@ -11160,15 +11160,15 @@ v2 = &pSpriteObjects[uLayingItemID]; v3 = &pObjectList->pObjects[v2->uObjectDescID]; v145 = a2; - v151 = a2 & 7; - if ( (a2 & 7) == OBJECT_Actor) - { - if ( (v2->spell_caster_pid & 7) == OBJECT_Actor && !pActors[v2->spell_caster_pid >> 3].GetActorsRelation(&pActors[a2 >> 3]) ) + v151 = PID_TYPE(a2); + if ( PID_TYPE(a2) == OBJECT_Actor) + { + if ( PID_TYPE(v2->spell_caster_pid) == OBJECT_Actor && !pActors[PID_ID(v2->spell_caster_pid)].GetActorsRelation(&pActors[PID_ID(a2)]) ) return 1; } else { - if ( (a2 & 7) == OBJECT_Player && (v2->spell_caster_pid & 7) == OBJECT_Player) + if ( PID_TYPE(a2) == OBJECT_Player && PID_TYPE(v2->spell_caster_pid) == OBJECT_Player) return 1; } if ( pParty->bTurnBasedModeOn == 1 ) @@ -11180,8 +11180,8 @@ v2->uAttributes = v5 & 0xFFFB; } } - if ( v151 == OBJECT_BModel && (v2->spell_caster_pid & 7) != OBJECT_Player) - BYTE2(pActors[v2->spell_caster_pid >> 3].uAttributes) |= 4u; + if ( v151 == OBJECT_BModel && PID_TYPE(v2->spell_caster_pid) != OBJECT_Player) + BYTE2(pActors[PID_ID(v2->spell_caster_pid)].uAttributes) |= 4u; v6 = v2->uType; v7 = v2->uType; if ( v7 > 3060 ) @@ -11283,7 +11283,7 @@ v115 = 8 * v153; v129 = 0; v128 = -1; - LOBYTE(v115) = 8 * v153 | 2; + LOBYTE(v115) = PID(OBJECT_Item,v153); v127 = 0; v126 = v115; v116 = v143; @@ -11295,7 +11295,7 @@ } v106 = v145; v150 = 0; - v139 = v106 >> 3; + v139 = PID_ID(v106); v137 = v2->spell_level; v152 = v2->spell_skill; v136 = v2->spell_id; @@ -11368,7 +11368,7 @@ if ( v7 == 8010 ) { if ( v151 == 3 - && MonsterStats::BelongsToSupertype(pActors[v145 >> 3].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) + && MonsterStats::BelongsToSupertype(pActors[PID_ID(v145)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) sub_43A97E(v153, v145); v93 = pObjectList->uNumObjects; ++v2->uType; @@ -11553,7 +11553,7 @@ LABEL_132: v73 = v2->vPosition.z; v74 = v2->vPosition.y; - v75 = 8 * v72 | 2; + v75 = PID(OBJECT_Item,v72); v2->vVelocity.z = v66; v2->vVelocity.y = v66; v76 = v2->vPosition.x; @@ -11872,7 +11872,7 @@ v2->vVelocity.z = 0; v38 = 8 * v153; v39 = v2->vPosition.y; - LOBYTE(v38) = 8 * v153 | 2; + LOBYTE(v38) = PID(OBJECT_Item,v153); v2->vVelocity.y = 0; v2->vVelocity.x = 0; v40 = v2->vPosition.x; @@ -11930,7 +11930,7 @@ v2->uSpriteFrameID = v32; v102 = 8 * v153; v103 = v2->vPosition.y; - LOBYTE(v102) = 8 * v153 | 2; + LOBYTE(v102) = PID(OBJECT_Item,v153); v2->vVelocity.x = v32; v2->vVelocity.y = v32; v104 = v2->vPosition.x; @@ -12024,7 +12024,7 @@ v13 = 8 * v153; v129 = v9; v128 = -1; - LOBYTE(v13) = 8 * v153 | 2; + LOBYTE(v13) = PID(OBJECT_Item,v153); v127 = v9; v126 = v13; LABEL_28:
--- a/mm7_3.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/mm7_3.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -862,15 +862,15 @@ void __cdecl UpdateActors_ODM() { Actor *v0; // esi@2 - unsigned __int16 v1; // ax@2 - unsigned int v2; // ecx@6 + AIState uAIState; // ax@2 + //unsigned int v2; // ecx@6 int v3; // ebx@6 - int v4; // eax@8 + //int v4; // eax@8 int v5; // eax@10 int v6; // ecx@10 - signed int v7; // ebx@10 + //signed int v7; // ebx@10 signed int v8; // ebx@17 - unsigned __int8 v9; // zf@17 + //unsigned __int8 v9; // zf@17 unsigned __int8 v10; // sf@17 unsigned __int16 v11; // ax@21 int v12; // eax@29 @@ -878,7 +878,7 @@ int v14; // eax@30 unsigned __int64 v15; // qax@30 int v16; // eax@33 - int v17; // edi@34 + //int v17; // edi@34 int v18; // edx@42 int v19; // ecx@42 __int16 v20; // ax@42 @@ -895,12 +895,12 @@ int v31; // edi@57 signed int i; // ebx@57 unsigned int v33; // ecx@58 - int v34; // ebx@64 + //int v34; // ebx@64 int v35; // edi@64 int v36; // eax@64 - unsigned __int16 v37; // cx@66 + //unsigned __int16 v37; // cx@66 signed int v38; // edx@71 - signed int v39; // edi@71 + unsigned int v39; // edi@71 BSPModel *v40; // eax@75 ODMFace *v41; // edi@75 int v42; // ebx@76 @@ -913,9 +913,9 @@ int v49; // edi@85 int v50; // eax@85 unsigned __int64 v51; // qax@85 - unsigned __int8 v52; // zf@87 - unsigned __int8 v53; // sf@87 - unsigned __int8 v54; // of@104 + //unsigned __int8 v52; // zf@87 + //unsigned __int8 v53; // sf@87 + // unsigned __int8 v54; // of@104 int v55; // eax@107 unsigned int v56; // edi@107 int v57; // ST10_4@107 @@ -929,71 +929,64 @@ int v65; // [sp+20h] [bp-30h]@2 int v66; // [sp+24h] [bp-2Ch]@2 bool v67; // [sp+28h] [bp-28h]@10 - unsigned int v68; // [sp+2Ch] [bp-24h]@10 + //unsigned int v68; // [sp+2Ch] [bp-24h]@10 unsigned int v69; // [sp+30h] [bp-20h]@6 unsigned int v70; // [sp+34h] [bp-1Ch]@10 int v71; // [sp+38h] [bp-18h]@62 - int v72; // [sp+3Ch] [bp-14h]@10 + int uIsAboveFloor; // [sp+3Ch] [bp-14h]@10 + int v72b; int v73; // [sp+40h] [bp-10h]@17 - int v74; // [sp+44h] [bp-Ch]@8 + int uIsFlying; // [sp+44h] [bp-Ch]@8 unsigned int v75; // [sp+48h] [bp-8h]@1 - int v76; // [sp+4Ch] [bp-4h]@10 - - v75 = 0; - if ( (signed int)uNumActors <= 0 ) - return; - do + int uIsOnWater; // [sp+4Ch] [bp-4h]@10 + + for(v75=0;(signed int)v75 < (signed int)uNumActors;++v75) { v0 = &pActors[v75]; v66 = v0->vPosition.x; v65 = v0->vPosition.y; - v1 = v0->uAIState; - if ( v1 == 11 || v1 == 19 || v1 == 17 || !v0->uMovementSpeed ) - goto LABEL_121; - v2 = v0->pMonsterInfo.uID; + uAIState = v0->uAIState; + if ( uAIState == Removed || uAIState == Disabled || uAIState == Summoned || !v0->uMovementSpeed ) + { + continue; + } v3 = 0; v69 = 0; - if ( MonsterStats::BelongsToSupertype(v2, MONSTER_SUPERTYPE_WATER_ELEMENTAL) ) + if ( MonsterStats::BelongsToSupertype(v0->pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) ) v3 = 1; - v4 = v0->pMonsterInfo.uFlying; v0->uSectorID = 0; - v74 = v4; + uIsFlying = v0->pMonsterInfo.uFlying; if ( !v0->CanAct() ) - v74 = 0; + uIsFlying = 0; v70 = IsTerrainSlopeTooHigh(v0->vPosition.x, v0->vPosition.y); v5 = ODM_GetFloorLevel( v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, v0->uActorHeight, - &v76, + &uIsOnWater, (int *)&v69, v3); v6 = v0->vPosition.z; - v7 = v5; - v68 = v5; - v72 = 0; + uIsAboveFloor = 0; v67 = v69 == 0; if ( v6 > v5 + 1 ) - v72 = 1; - if ( v0->uAIState == 5 && v76 && !v72 ) + uIsAboveFloor = 1; + if ( uAIState == Dead && uIsOnWater && !uIsAboveFloor ) { v0->uAIState = Removed; - goto LABEL_121; + continue; } if ( v0->uCurrentActionAnimation == ANIM_Walking ) { v8 = v0->uMovementSpeed; - v9 = HIDWORD(v0->pActorBuffs[7].uExpireTime) == 0; - v10 = SHIDWORD(v0->pActorBuffs[7].uExpireTime) < 0; v73 = v0->uMovementSpeed; - if ( !v10 && (!(v10 | v9) || LODWORD(v0->pActorBuffs[7].uExpireTime) > 0) ) + if ( (signed __int64)v0->pActorBuffs[7].uExpireTime > 0 ) { v8 = (signed __int64)((double)v73 * 0.5); v73 = (signed __int64)((double)v73 * 0.5); } - v11 = v0->uAIState; - if ( v11 == 7 || v11 == 6 ) + if ( uAIState == Fleeing || uAIState == Pursuing ) { v8 *= 2; v73 = v8; @@ -1003,15 +996,13 @@ if ( v8 > 1000 ) v8 = 1000; v12 = stru_5C6E00->Cos(v0->uYawAngle); - v69 = v12; v13 = v12 * (signed __int64)v8; v73 = v13 >> 16; v0->vVelocity.x = WORD1(v13); v69 = stru_5C6E00->Sin(v0->uYawAngle); v73 = (unsigned __int64)((signed int)v69 * (signed __int64)v8) >> 16; - v9 = v74 == 0; v0->vVelocity.y = v69 * v8 >> 16; - if ( !v9 ) + if ( uIsFlying ) { v14 = stru_5C6E00->Sin(v0->uPitchAngle); v69 = v14; @@ -1019,7 +1010,7 @@ v73 = v15 >> 16; v0->vVelocity.z = WORD1(v15); } - v7 = v68; + //v7 = v68; } else { @@ -1029,9 +1020,8 @@ v0->vVelocity.x = v73; v73 = v0->vVelocity.y; v73 = (unsigned __int64)((signed int)v69 * (signed __int64)v73) >> 16; - v9 = v74 == 0; v0->vVelocity.y = v73; - if ( !v9 ) + if ( uIsFlying ) { v69 = 55000; v73 = v0->vVelocity.z; @@ -1039,20 +1029,20 @@ v0->vVelocity.z = v73; } } - if ( v0->vPosition.z < v7 ) - { - v16 = v74; - v0->vPosition.z = v7; + if ( v0->vPosition.z < v5 ) + { + v16 = uIsFlying; + v0->vPosition.z = v5; v0->vVelocity.z = v16 != 0 ? 0x14 : 0; } - v17 = 0; - if ( !v72 || v74 ) - { - if ( v70 && !v72 && v67 ) + //v17 = 0; + if ( !uIsAboveFloor || uIsFlying ) + { + if ( v70 && !uIsAboveFloor && v67 ) { v18 = v0->vPosition.y; v19 = v0->vPosition.x; - v0->vPosition.z = v7; + v0->vPosition.z = v5; ODM_GetTerrainNormalAt(v19, v18, &v62); v20 = GetGravityStrength(); v21 = v62.y; @@ -1060,22 +1050,22 @@ v23 = v62.y * v0->vVelocity.y; v0->vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20; v73 = abs(v62.x * v0->vVelocity.x + v22 * v0->vVelocity.z + v23) >> 16; - v72 = v21; + v72b = v21; v0->vVelocity.x += (unsigned int)(v73 * v62.x) >> 16; - v72 = (unsigned __int64)(v73 * (signed __int64)v72) >> 16; - v24 = v72; - v72 = v22; + v72b = (unsigned __int64)(v73 * (signed __int64)v72b) >> 16; + v24 = v72b; + v72b = v22; v0->vVelocity.y += v24; - v72 = (unsigned __int64)(v73 * (signed __int64)v72) >> 16; - v0->vVelocity.z += v72; - v17 = 0; + v72b = (unsigned __int64)(v73 * (signed __int64)v72b) >> 16; + v0->vVelocity.z += v72b; + //v17 = 0; } } else { v0->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); } - if ( pParty->armageddon_timer != v17 && v0->CanAct() ) + if ( pParty->armageddon_timer != 0 && v0->CanAct() ) { v0->vVelocity.x += rand() % 100 - 50; v0->vVelocity.y += rand() % 100 - 50; @@ -1085,14 +1075,13 @@ v0->uYawAngle += v25 % 32 - 16; v0->UpdateAnimation(); } - if ( v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y < 400 && v70 == v17 ) - { - v0->vVelocity.y = v17; - v0->vVelocity.x = v17; - } - v9 = v0->pMonsterInfo.uFlying == 0; + if ( v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y < 400 && v70 == 0 ) + { + v0->vVelocity.y = 0; + v0->vVelocity.x = 0; + } stru_721530.field_0 = 1; - if ( v9 ) + if ( !uIsFlying ) v26 = 40; else v26 = v0->uActorRadius; @@ -1101,8 +1090,8 @@ stru_721530.field_8 = v26; stru_721530.prolly_normal_d = v26; stru_721530.field_C = v27; - stru_721530.field_70 = v17; - v69 = v17; + stru_721530.field_70 = 0; + v69 = 0; while ( 1 ) { stru_721530.field_34.x = v0->vPosition.x; @@ -1125,7 +1114,7 @@ v30 = WorldPosToGridCellX(v0->vPosition.x); _46E26D_collide_against_sprites(v30, v29); _46EF01_collision_chech_player(0); - _46ED8A_collide_against_sprite_objects(8 * v75 | OBJECT_Actor); + _46ED8A_collide_against_sprite_objects(PID(OBJECT_Actor,v75)); v31 = 0; for ( i = 0; v31 < ai_arrays_size; ++v31 ) { @@ -1136,7 +1125,7 @@ v71 = i > 1; if ( stru_721530.field_7C < stru_721530.field_6C ) v70 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; - v34 = 0; + //v34 = 0; v35 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; v36 = ODM_GetFloorLevel( stru_721530.normal2.x, @@ -1146,17 +1135,16 @@ (int *)&v63, &v64, 0); - if ( v76 ) + if ( uIsOnWater ) { if ( v35 < v36 + 60 ) { - v37 = v0->uAIState; - if ( v37 == 5 || v37 == 4 || v37 == 11 || v37 == 19 ) + if ( uAIState == Dead || uAIState == Dying || uAIState == Removed || uAIState == Disabled ) { if ( v64 ) v61 = v36 + 30; else - v61 = v68 + 60; + v61 = v5 + 60; sub_42F960_create_object(v0->vPosition.x, v0->vPosition.y, v61); v0->uAIState = Removed; return; @@ -1170,60 +1158,64 @@ v0->vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1; break; } - v72 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; + v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; v0->vPosition.x += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.x) >> 16; - v72 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; + v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; v0->vPosition.y += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.y) >> 16; - v72 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; + v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; v38 = stru_721530.uFaceID; v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16; stru_721530.field_70 += stru_721530.field_7C; - v39 = v38 >> 3; - switch ( v38 & 7 ) - { - case 3: - if ( pParty->bTurnBasedModeOn != 1 ) - goto LABEL_97; - if ( pTurnEngine->field_4 != 2 && pTurnEngine->field_4 != 3 ) - { - v34 = 0; -LABEL_97: + v39 = PID_ID(v38); + switch ( PID_TYPE(v38) ) + { + case OBJECT_Actor: + if ( pTurnEngine->field_4 != 2 && pTurnEngine->field_4 != 3 || pParty->bTurnBasedModeOn != 1 ) + { + //if(pParty->bTurnBasedModeOn == 1) + //v34 = 0; if ( v0->pMonsterInfo.uHostilityType ) { - if ( v71 == v34 ) - goto LABEL_99; -LABEL_101: - Actor::AI_StandOrBored(v75, 4, v34, (AIDirection *)v34); - break; + if ( v71 == 0 ) + { + Actor::Flee(v75, v38, 0, (AIDirection *)0); + } + else + { + Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0); + } } - if ( v71 != v34 ) - goto LABEL_101; - if ( pActors[v39].pMonsterInfo.uHostilityType ) + else if ( v71 != 0 ) + { + Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0); + } + else if ( pActors[v39].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly ) { -LABEL_99: - Actor::_402968(v75, v38, v34, (AIDirection *)v34); - break; + Actor::Flee(v75, v38, 0, (AIDirection *)0); } -LABEL_103: - Actor::FaceObject(v75, v38, v34, (AIDirection *)v34); - break; + else + { + Actor::FaceObject(v75, v38, 0, (AIDirection *)0); + } } break; - case 4: + case OBJECT_Player: if ( !v0->GetActorsRelation(0) ) { v38 = stru_721530.uFaceID; - goto LABEL_103; - } - v52 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == 0; - v53 = SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) < 0; + Actor::FaceObject(v75, v38, 0, (AIDirection *)0); + break; + } + //v52 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == 0; + //v53 = SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) < 0; v0->vVelocity.y = 0; v0->vVelocity.x = 0; - if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > 0) ) + //if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > 0) ) + if ( (signed __int64)pParty->pPartyBuffs[11].uExpireTime < 0) pParty->pPartyBuffs[11].Reset(); viewparams->bRedrawGameUI = 1; break; - case 5: + case OBJECT_Decoration: v47 = integer_sqrt(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y); v48 = stru_5C6E00->Atan2( v0->vPosition.x - pLevelDecorations[v39].vPosition.x, @@ -1238,7 +1230,7 @@ v70 = v51 >> 16; v0->vVelocity.y = WORD1(v51); break; - case 6: + case OBJECT_BModel: v40 = &pOutdoor->pBModels[v38 >> 9]; v41 = &v40->pFaces[v39 & 0x3F]; if ( !(BYTE3(v41->uAttributes) & 0x20) ) @@ -1258,16 +1250,16 @@ } else { - v72 = abs(v41->pFacePlane.vNormal.y * v0->vVelocity.y + v41->pFacePlane.vNormal.z * v0->vVelocity.z + v72b = abs(v41->pFacePlane.vNormal.y * v0->vVelocity.y + v41->pFacePlane.vNormal.z * v0->vVelocity.z + v41->pFacePlane.vNormal.x * v0->vVelocity.x) >> 16; - if ( stru_721530.field_64 >> 3 > v72 ) - v72 = stru_721530.field_64 >> 3; + if ( stru_721530.field_64 >> 3 > v72b ) + v72b = stru_721530.field_64 >> 3; v73 = v41->pFacePlane.vNormal.x; - v73 = (unsigned __int64)(v72 * (signed __int64)v73) >> 16; + v73 = (unsigned __int64)(v72b * (signed __int64)v73) >> 16; v71 = v41->pFacePlane.vNormal.y; - v71 = (unsigned __int64)(v72 * (signed __int64)v71) >> 16; + v71 = (unsigned __int64)(v72b * (signed __int64)v71) >> 16; v70 = v41->pFacePlane.vNormal.z; - v70 = (unsigned __int64)(v72 * (signed __int64)(signed int)v70) >> 16; + v70 = (unsigned __int64)(v72b * (signed __int64)(signed int)v70) >> 16; v0->vVelocity.x += v73; v0->vVelocity.y += v71; v0->vVelocity.z += v70; @@ -1302,35 +1294,26 @@ v70 = v0->vVelocity.z; v70 = (unsigned __int64)(v71 * (signed __int64)(signed int)v70) >> 16; ++v69; - v54 = v69 < 100; - v10 = (v69 - 100) < 0; + //v54 = v69 < 100; + //v10 = (v69 - 100) < 0; v0->vVelocity.z = v70; - if ( !(v10 ^ v54) ) + if ( v69 >= 100 ) break; v26 = stru_721530.prolly_normal_d; } - v69 = WorldPosToGridCellX(v66); - v55 = WorldPosToGridCellZ(v65); - v56 = v55 - 1; - v57 = v0->vPosition.x; - v71 = v55 - 1; - v68 = WorldPosToGridCellX(v57); - v70 = WorldPosToGridCellZ(v0->vPosition.y) - 1; - v58 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v69, v56) >> 1) & 1; - v59 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v68, v70) >> 1) & 1; - v60 = 0; - if ( v69 == v68 && v71 == v70 && v58 ) - v60 = 1; - if ( !v67 ) - v60 = 1; - if ( !v60 ) + v58 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(v66), WorldPosToGridCellZ(v65) - 1) >> 1) & 1; + v59 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(v0->vPosition.x), WorldPosToGridCellZ(v0->vPosition.y) - 1) >> 1) & 1; + if ( WorldPosToGridCellX(v66) == WorldPosToGridCellX(v0->vPosition.x) + && WorldPosToGridCellZ(v65) == WorldPosToGridCellZ(v0->vPosition.y) + && v58 + || v67 != 0 ) { if ( MonsterStats::BelongsToSupertype(v0->pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) ) { v58 = v58 == 0; v59 = v59 == 0; } - if ( !v74 && v58 && !v59 ) + if ( !uIsFlying && v58 && !v59 ) { v0->vPosition.x = v66; v0->vPosition.y = v65; @@ -1343,10 +1326,7 @@ } } } -LABEL_121: - ++v75; - } - while ( (signed int)v75 < (signed int)uNumActors ); + } } //----- (0047253E) -------------------------------------------------------- @@ -1391,7 +1371,7 @@ v4 = &pObjectList->pObjects[item->uObjectDescID]; if (item->AttachedToActor()) { - v5 = item->spell_target_pid >> 3; + v5 = PID_ID(item->spell_target_pid); *(int *)(v2 - 26) = pActors[v5].vPosition.x; *(int *)(v2 - 22) = pActors[v5].vPosition.y; *(int *)(v2 - 18) = pActors[v5].vPosition.z + pActors[v5].uActorHeight; @@ -1467,7 +1447,7 @@ v10 = i; if ( !(v9 & 0x40) ) goto LABEL_35; - _46BFFA_check_object_intercept(i, 8 * i | OBJECT_Item); + _46BFFA_check_object_intercept(i, PID(OBJECT_Item,i)); } } LABEL_36: @@ -1934,7 +1914,7 @@ uSectorID = stru_721530.uSectorID; stru_721530.field_70 += stru_721530.field_7C; auto v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + new_party_z; - if ( (stru_721530.uFaceID & 7) == OBJECT_Actor) + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor) { if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= 0 && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[11].uExpireTime)) ) @@ -1942,7 +1922,7 @@ viewparams->bRedrawGameUI = 1; goto LABEL_152; } - if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) { v53 = integer_sqrt(v2 * v2 + v1 * v1); v80 = v53; @@ -1954,7 +1934,7 @@ } else { - if ( (stru_721530.uFaceID & 7) == OBJECT_BModel) + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) { v44 = &pIndoor->pFaces[(signed int)stru_721530.uFaceID >> 3]; v45 = v44->uPolygonType; @@ -2363,7 +2343,7 @@ v6 = v108 & 0x3F; /*if ( *(char *)(v7->pFacePlane.vNormal.x + 308 * v6 + 31) & 4 ) { - pParty->field_6F4_packedid = 8 * v108 | OBJECT_BModel; + pParty->field_6F4_packedid = PID(OBJECT_BModel,v108); v103 = *(short *)(v7->pFacePlane.vNormal.x + 308 * v6 + 292); }*/ if ( BYTE3(v7[v6].uAttributes) & 4 ) @@ -2858,7 +2838,7 @@ pY = _angle_y; v45 = stru_721530.uFaceID; pZ = v40; - if ( (stru_721530.uFaceID & 7) == OBJECT_Actor) + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor) { if (pParty->Invisible()) pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); @@ -2866,7 +2846,7 @@ viewparams->bRedrawGameUI = 1; goto LABEL_234; } - if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) { v56 = integer_sqrt(v2 * v2 + v128 * v128); v118 = v56; @@ -2887,7 +2867,7 @@ } else { - if ( (stru_721530.uFaceID & 7) == OBJECT_BModel) + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) { pParty->bFlying = 0; v46 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; @@ -4788,7 +4768,7 @@ if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) { v31 = (LightmapBuilder *)(v50 ? 3 : v49 != 0 ? 5 : 0); - static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(pFace, (BSPVertexBuffer *)v56 - 1); + static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(pFace, &v56->pVertices); if ( pDecalBuilder->uNumDecals > 0 ) { v40 = -1; @@ -5988,7 +5968,7 @@ float v28; // [sp+12Ch] [bp-38h]@2 int v29; // [sp+130h] [bp-34h]@4 int v30; // [sp+134h] [bp-30h]@1 - float v31; // [sp+138h] [bp-2Ch]@2 + //int v31; // [sp+138h] [bp-2Ch]@2 int v32; // [sp+13Ch] [bp-28h]@6 int v33; // [sp+140h] [bp-24h]@2 int v34; // [sp+144h] [bp-20h]@1 @@ -5998,7 +5978,6 @@ int v38; // [sp+158h] [bp-Ch]@1 int v39; // [sp+15Ch] [bp-8h]@4 int v40; // [sp+160h] [bp-4h]@7 - float v41; extern bool new_sky; if (new_sky) @@ -6042,9 +6021,7 @@ array_50AC10[3].vWorldViewProjY = pViewport->uViewportTL_Y; v36 = (double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) * 0.5; - v31 = (signed int)(v36 / tan(0.6457717418670654) + 0.5); - //v41 = v31 + 6.7553994e15; - v33 = 65536 / v31; + v33 = 65536 / (signed int)(v36 / tan(0.6457717418670654) + 0.5); for (int i = 0; i < _this.uNumVertices; ++i) { @@ -6109,28 +6086,29 @@ v37 += ((unsigned __int64)(_this.ptr_38->field_10 * v13) >> 16); v36 += ((unsigned __int64)(_this.ptr_38->field_1C * v13) >> 16); - v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_mul(v37, v18) / 8; - v36 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_mul(v37, v18) / 8; + v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + (signed int)((unsigned __int64)(v37 * v18) >> 16) / 8; + v36 = 224 * pMiscTimer->uTotalGameTimeElapsed + (signed int)((unsigned __int64)(v36 * v18) >> 16) / 8; //array_50AC10[i].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist; //array_50AC10[i].vWorldPosition.x = v36 / (_this.pTexture->uTextureHeight * 65536.0); //array_50AC10[i].vWorldPosition.y = 1.0 / (pOutdoorCamera->shading_dist_mist >> 16); //array_50AC10[i].vWorldPosition.z = v35 / (_this.pTexture->uTextureWidth * 65536.0); - array_50AC10[i]._rhw = 1; - array_50AC10[i].u += 1.0 / 224 * pMiscTimer->uTotalGameTimeElapsed; - array_50AC10[i].v += 1.0 / 224 * pMiscTimer->uTotalGameTimeElapsed; - //float t = (GetTickCount() % 96000) / 96000.0f; - //array_50AC10[i].u += t; + array_50AC10[i]._rhw = 1.0;// / (pOutdoorCamera->shading_dist_mist >> 16); + //array_50AC10[i].u = (double)v35 / (65536.0 * _this.pTexture->uTextureWidth); + //array_50AC10[i].v = (double)v36 / (65536.0 * _this.pTexture->uTextureHeight); + float t = (GetTickCount() % 96000) / 96000.0f; + array_50AC10[i].u += t; + array_50AC10[i].v += t; if ( i == _this.uNumVertices - 1 ) { - pRenderer->DrawFan(_this.uNumVertices, &_this, pBitmaps_LOD->pHardwareTextures[_this.uTileBitmapID]); - - //array_50AC10[0].vWorldViewProjY = v38; - //array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0; - //array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0; - //array_50AC10[3].vWorldViewProjY = v38; - - pRenderer->DrawFan(_this.uNumVertices, &_this, pBitmaps_LOD->pHardwareTextures[_this.uTileBitmapID]); + pRenderer->DrawSkyPolygon(_this.uNumVertices, &_this, pBitmaps_LOD->pHardwareTextures[_this.uTileBitmapID]); + + array_50AC10[0].vWorldViewProjY = v38; + array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0; + array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0; + array_50AC10[3].vWorldViewProjY = v38; + + pRenderer->DrawSkyPolygon(_this.uNumVertices, &_this, pBitmaps_LOD->pHardwareTextures[_this.uTileBitmapID]); return; } } @@ -6247,7 +6225,7 @@ uFaceID = v65; } v56 = 8 * uFaceID; - LOBYTE(v56) = 8 * uFaceID | 6; + LOBYTE(v56) = PID(OBJECT_BModel,uFaceID); v57 = v56; v58 = pFace->GetTexture(); pRenderer->DrawIndoorPolygon(v3, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], v58, v57, -1, 0); @@ -11174,11 +11152,11 @@ v15->uScreenSpaceX = a5; v15->uScreenSpaceY = a6; //v23 = 8 * uDecorationID; - //LOBYTE(v23) = 8 * uDecorationID | OBJECT_Decoration; + //LOBYTE(v23) = PID(OBJECT_Decoration,uDecorationID); //v15->sZValue = v22 + v23; v15->actual_z = HIWORD(x); - v15->object_pid = 8 * uDecorationID | OBJECT_Decoration; + v15->object_pid = PID(OBJECT_Decoration,uDecorationID); v15->uTintColor = 0; v15->pSpriteFrame = v12; @@ -11331,12 +11309,12 @@ v3->uTintColor = 0; v3->uScreenSpaceY = v22; //v23 = 8 * i; - //LOBYTE(v23) = 8 * i | OBJECT_Item; + //LOBYTE(v23) = PID(OBJECT_Item,i); v3->pSpriteFrame = v24; //v12 = (p->uAttributes & 0x20) == 0; //v3->sZValue = v21 + v23; v3->actual_z = HIWORD(x); - v3->object_pid = 8 * i | OBJECT_Item; + v3->object_pid = PID(OBJECT_Item,i); if (p->uAttributes & 0x20) { if ( !pRenderer->pRenderD3D ) @@ -12810,7 +12788,7 @@ ++num_dead_actors; else { - int sumonner_type = pActors[i].uSummonerID & 7;; + int sumonner_type = PID_TYPE(pActors[i].uSummonerID); if (sumonner_type == OBJECT_Player) ++num_dead_actors; } @@ -14993,7 +14971,7 @@ { v20 = &pActors[ai_near_actors_ids[v18]]; if ( v20->uAttributes & 0x8000 - || (v21 = sub_4070EF_prolly_collide_objects(8 * ai_near_actors_ids[v18] | 3, 4u), v18 = i, v21) ) + || (v21 = sub_4070EF_prolly_collide_objects(PID(OBJECT_Actor,ai_near_actors_ids[v18]), 4u), v18 = i, v21) ) { v22 = ai_near_actors_ids[v18]; v20->uAttributes |= 0x8000u; @@ -15114,72 +15092,74 @@ unsigned __int16 v22; // ax@86 //signed int v23; // eax@94 //unsigned int v24; // eax@102 - signed int v25; // edi@102 - SpellBuff *v26; // esi@102 + //signed int v25; // edi@102 + //SpellBuff *v26; // esi@102 unsigned int v27; // ecx@123 unsigned int v28; // eax@123 - unsigned int v29; // eax@127 + //unsigned int v29; // eax@127 AIDirection *v30; // eax@129 unsigned __int16 v31; // ax@132 - unsigned int v32; // esi@142 + //unsigned int v32; // esi@142 int v33; // eax@144 int v34; // eax@147 char v35; // al@150 unsigned int v36; // edi@152 signed int v37; // eax@154 - unsigned __int8 v38; // sf@158 - unsigned __int8 v39; // of@158 - signed int v40; // edx@166 - unsigned int v41; // ecx@166 + //unsigned __int8 v38; // sf@158 + //unsigned __int8 v39; // of@158 + //signed int v40; // edx@166 + //unsigned int v41; // ecx@166 double v42; // st7@176 double v43; // st6@176 - bool v44; // eax@189 + //bool v44; // eax@189 bool v45; // eax@192 unsigned __int8 v46; // cl@197 double v47; // st7@206 double v48; // st7@207 - char v49; // zf@208 - char v50; // zf@214 - signed int v51; // edx@219 - unsigned int v52; // ecx@219 + //char v49; // zf@208 + //char v50; // zf@214 + //signed int v51; // edx@219 + //unsigned int v52; // ecx@219 __int16 v53; // fps@224 - unsigned __int8 v54; // c0@224 - unsigned __int8 v55; // c3@224 + //unsigned __int8 v54; // c0@224 + //unsigned __int8 v55; // c3@224 double v56; // st7@226 AIDirection *v57; // eax@246 double v58; // st7@246 - signed int v59; // [sp-18h] [bp-C8h]@213 - int v60; // [sp-14h] [bp-C4h]@144 - int v61; // [sp-14h] [bp-C4h]@168 - AIDirection *v62; // [sp-14h] [bp-C4h]@213 - signed int v63; // [sp-14h] [bp-C4h]@216 + //signed int v59; // [sp-18h] [bp-C8h]@213 + //int v60; // [sp-14h] [bp-C4h]@144 + //int v61; // [sp-14h] [bp-C4h]@168 + //AIDirection *v62; // [sp-14h] [bp-C4h]@213 + //signed int v63; // [sp-14h] [bp-C4h]@216 unsigned int v64; // [sp-14h] [bp-C4h]@219 unsigned int v65; // [sp-10h] [bp-C0h]@144 char v66; // [sp-10h] [bp-C0h]@147 - AIDirection *v67; // [sp-10h] [bp-C0h]@167 - int v68; // [sp-10h] [bp-C0h]@168 - AIDirection *v69; // [sp-10h] [bp-C0h]@206 + //AIDirection *v67; // [sp-10h] [bp-C0h]@167 + //int v68; // [sp-10h] [bp-C0h]@168 + //AIDirection *v69; // [sp-10h] [bp-C0h]@206 int v70; // [sp-10h] [bp-C0h]@213 - AIDirection *v71; // [sp-10h] [bp-C0h]@216 + //AIDirection *v71; // [sp-10h] [bp-C0h]@216 AIDirection v72; // [sp+0h] [bp-B0h]@246 AIDirection a3; // [sp+1Ch] [bp-94h]@129 AIDirection v74; // [sp+38h] [bp-78h]@246 AIDirection v75; // [sp+54h] [bp-5Ch]@129 - int v76; // [sp+70h] [bp-40h]@83 + int target_pid_type; // [sp+70h] [bp-40h]@83 signed int a1; // [sp+74h] [bp-3Ch]@129 int v78; // [sp+78h] [bp-38h]@79 AIDirection pDir; // [sp+7Ch] [bp-34h]@129 float v80; // [sp+98h] [bp-18h]@33 int v81; // [sp+9Ch] [bp-14h]@100 - int v82; // [sp+A0h] [bp-10h]@45 + //int v82; // [sp+A0h] [bp-10h]@45 //unsigned int uActorID; // [sp+A4h] [bp-Ch]@32 unsigned int v84; // [sp+A8h] [bp-8h]@11 - signed int a2; // [sp+ACh] [bp-4h]@83 + signed int target_pid; // [sp+ACh] [bp-4h]@83 + AIState uAIState; + int v38; if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - MakeActorAIList_ODM(); + MakeActorAIList_ODM(); else - MakeActorAIList_BLV(); + MakeActorAIList_BLV(); //v0 = 0; if ( uCurrentlyLoadedLevelType != LEVEL_Indoor && pParty->armageddon_timer > 0 ) @@ -15196,7 +15176,7 @@ v3 = pParty->sRotationX + v1 % 16 - 8; pParty->sRotationX = v3; if ( v3 > 128 || (v2 = -128, v3 < -128) ) - pParty->sRotationX = v2; + pParty->sRotationX = v2; pParty->uFlags |= 2u; pParty->armageddon_timer -= pMiscTimer->uTimeElapsed; v4 = pParty->field_16140 + 50; @@ -15218,13 +15198,13 @@ { if ( v7 >= 0 ) { - Actor::_4030AD(v84, 4, 0); + Actor::Stun(v84, 4, 0); } else { Actor::Die(v84); if ( v5->pMonsterInfo.uExp ) - GivePartyExp(pMonsterStats->pInfos[v5->pMonsterInfo.uID].uExp); + GivePartyExp(pMonsterStats->pInfos[v5->pMonsterInfo.uID].uExp); } } } @@ -15238,14 +15218,14 @@ { pPlayer = *v8; if ( !(*v8)->pConditions[14] && !pPlayer->pConditions[15] && !pPlayer->pConditions[16] ) - pPlayer->ReceiveDamage(v4, 5); + pPlayer->ReceiveDamage(v4, 5); ++v8; } while ( (signed int)v8 <= (signed int)&pPlayers[4] ); //v0 = 0; } if (pTurnEngine->field_1C) - --pTurnEngine->field_1C; + --pTurnEngine->field_1C; } } @@ -15268,10 +15248,10 @@ //v49 = *(unsigned int *)LODWORD(v80) == 5; ai_near_actors_targets_pid[i] = OBJECT_Player; if (actor->uAIState == Dead || actor->uAIState == Removed || actor->uAIState == Disabled || actor->uAttributes & 0x0400) - continue; + continue; if (!actor->sCurrentHP && actor->uAIState != Dying) - Actor::Die(i); + Actor::Die(i); //v84 = *(_QWORD *)(LODWORD(v80) + 84) <= 0i64 ? 0 : 1; //v82 = *(_QWORD *)(LODWORD(v80) + 52) <= 0i64 ? 0 : 1; @@ -15294,18 +15274,19 @@ ++v14; } while ( v13 < 22 );*/ - if (!actor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime) + if ( (signed __int64)actor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 ) //&& SHIDWORD(pActor->pActorBuffs[3].uExpireTime) <= (signed int)v12 && (SHIDWORD(pActor->pActorBuffs[3].uExpireTime) < (signed int)v12 // || LODWORD(pActor->pActorBuffs[3].uExpireTime) <= v12) ) - actor->uActorHeight = pMonsterList->pMonsters[actor->pMonsterInfo.uID - 1].uMonsterHeight; - if (actor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime) - actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - else - actor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[actor->pMonsterInfo.uID].uHostilityType; + actor->uActorHeight = pMonsterList->pMonsters[actor->pMonsterInfo.uID - 1].uMonsterHeight; + if ( (signed __int64)actor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 ) + actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; + // not sure + else if ( (signed __int64)actor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 ) + actor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[actor->pMonsterInfo.uID].uHostilityType; - if (actor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime || - actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) - continue; + if ((signed __int64)actor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0 + || (signed __int64)actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0) + continue; //v15 = pMiscTimer->uTimeElapsed; //v16 = (char *)&pActor->pMonsterInfo.uRecoveryTime; @@ -15314,17 +15295,18 @@ if (actor->pMonsterInfo.uRecoveryTime) { if (actor->pMonsterInfo.uRecoveryTime < pMiscTimer->uTimeElapsed) - actor->pMonsterInfo.uRecoveryTime = 0; - else actor->pMonsterInfo.uRecoveryTime -= pMiscTimer->uTimeElapsed; + actor->pMonsterInfo.uRecoveryTime = 0; + else + actor->pMonsterInfo.uRecoveryTime -= pMiscTimer->uTimeElapsed; } actor->uCurrentActionTime += pMiscTimer->uTimeElapsed; if (actor->uCurrentActionTime < actor->uCurrentActionLength) - continue; + continue; //v19 = actor->uAIState; if (actor->uAIState == Dying) - actor->uAIState = Dead; + actor->uAIState = Dead; else { if (actor->uAIState != Summoned) @@ -15360,559 +15342,445 @@ v21 = &pActors[actor_id]; Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true); if (v21->pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[actor_id]) - v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - a2 = ai_near_actors_targets_pid[actor_id]; - v76 = a2 & 7; - if ( (a2 & 7) == OBJECT_Actor) - v80 = 0.5; + v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; + target_pid = ai_near_actors_targets_pid[actor_id]; + target_pid_type = PID_TYPE(target_pid); + if ( target_pid_type == OBJECT_Actor) + v80 = 0.5; else - v80 = 1.0; + v80 = 1.0; v22 = v21->uAIState; if ( v22 == Dying || v22 == Dead || v22 == Removed || v22 == Disabled || v22 == Summoned) { continue; } - else - { - if ( !v21->sCurrentHP ) + if ( !v21->sCurrentHP ) Actor::Die(actor_id); - v25 = 0; - v26 = v21->pActorBuffs; - do + for(int i=0;i<22;i++) + { + if ( i != 10 ) { - if ( v25 != 10 ) - { - v26->_4585CA(pParty->uTimePlayed); - //v24 = 0; - } - ++v25; - ++v26; + v21->pActorBuffs[i]._4585CA(pParty->uTimePlayed); } - while ( v25 < 22 ); - if ( (signed __int64)v21->pActorBuffs[3].uExpireTime > 0 - && SHIDWORD(v21->pActorBuffs[3].uExpireTime) <= 0 - && (SHIDWORD(v21->pActorBuffs[3].uExpireTime) < 0 - || LODWORD(v21->pActorBuffs[3].uExpireTime) <= 0) ) + } + if ( (signed __int64)v21->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 ) v21->uActorHeight = pMonsterList->pMonsters[v21->pMonsterInfo.uID - 1].uMonsterHeight; - if ( (signed __int64)v21->pActorBuffs[1].uExpireTime > 0 ) - { - v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - if ( SHIDWORD(v21->pActorBuffs[1].uExpireTime) <= 0 ) - { - if ( SHIDWORD(v21->pActorBuffs[1].uExpireTime) < 0 - || LODWORD(v21->pActorBuffs[1].uExpireTime) <= 0 ) - v21->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[v21->pMonsterInfo.uID].uHostilityType; - } - } - if ( (signed __int64)v21->pActorBuffs[2].uExpireTime > 0 - && SHIDWORD(v21->pActorBuffs[2].uExpireTime) <= 0 - && (SHIDWORD(v21->pActorBuffs[2].uExpireTime) < 0 - || LODWORD(v21->pActorBuffs[2].uExpireTime) <= 0) ) - { - v21->uAIState = Removed; - continue; - } - else if ( v21->pActorBuffs[5].uExpireTime || v21->pActorBuffs[6].uExpireTime ) + if ( (signed __int64)v21->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 ) + v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; + // not sure + else if ( (signed __int64)v21->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 ) + v21->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[v21->pMonsterInfo.uID].uHostilityType; + if ( (signed __int64)v21->pActorBuffs[2].uExpireTime < 0 ) + { + v21->uAIState = Removed; + continue; + } + if ( (signed __int64)v21->pActorBuffs[5].uExpireTime > 0 + || (signed __int64)v21->pActorBuffs[6].uExpireTime > 0) + { + continue; + } + v27 = pMiscTimer->uTimeElapsed; + v28 = v21->pMonsterInfo.uRecoveryTime; + v21->uCurrentActionTime += pMiscTimer->uTimeElapsed; + if ( (signed int)v28 > 0 ) + v21->pMonsterInfo.uRecoveryTime = v28 - v27; + if ( v21->pMonsterInfo.uRecoveryTime < 0 ) + v21->pMonsterInfo.uRecoveryTime = 0; + if ( !(v21->uAttributes & 0x8000) ) + v21->uAttributes |= 0x8000; + a1 = PID(OBJECT_Actor,actor_id); + v30 = Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), target_pid, &a3, 0); + memcpy(&v75, v30, sizeof(v75)); + memcpy(&pDir, &v75, sizeof(pDir)); + uAIState = v21->uAIState; + /*if ( v21->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Friendly + && (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 + && v80 * 307.2 >= (double)(signed int)v75.uDistance + && (uAIState == Pursuing || uAIState == Standing || uAIState == Tethered || uAIState == Fidgeting) + || ( v21->pMonsterInfo.uMissleAttack1Type && uAIState == Stunned ) ) + { + v32 = actor_id; + } + else + */ + if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly + || (signed int)v21->pMonsterInfo.uRecoveryTime > 0 + || v80 * 307.2 < (double)(signed int)v75.uDistance + || uAIState != Pursuing && uAIState != Standing && uAIState != Tethered && uAIState != Fidgeting + && !v21->pMonsterInfo.uMissleAttack1Type || uAIState != Stunned ) + { + if ( (signed int)v21->uCurrentActionTime < v21->uCurrentActionLength ) { continue; } - else + else if ( v21->uAIState == AttackingMelee ) + { + v35 = stru_50C198.special_ability_use_check(v21, actor_id); + stru_50FE08.Add( + a1, + 5120, + v21->vPosition.x, + v21->vPosition.y, + v21->vPosition.z + ((signed int)v21->uActorHeight >> 1), + v35, + 1 + ); + } + else if ( v21->uAIState == AttackingRanged1 ) { - v27 = pMiscTimer->uTimeElapsed; - v28 = v21->pMonsterInfo.uRecoveryTime; - v21->uCurrentActionTime += pMiscTimer->uTimeElapsed; - if ( (signed int)v28 > 0 ) - v21->pMonsterInfo.uRecoveryTime = v28 - v27; - if ( v21->pMonsterInfo.uRecoveryTime< 0 ) - v21->pMonsterInfo.uRecoveryTime = 0; - v29 = v21->uAttributes; - if ( !(v29 & 0x8000) ) - v21->uAttributes = v29 | 0x8000; - a1 = 8 * actor_id | OBJECT_Actor; - v30 = Actor::GetDirectionInfo(8 * actor_id | OBJECT_Actor, a2, &a3, 0); - v49 = v21->pMonsterInfo.uHostilityType == 0; - memcpy(&v75, v30, sizeof(v75)); - memcpy(&pDir, &v75, sizeof(pDir)); - if ( !v49 - && (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 - && v80 * 307.2 >= (double)(signed int)v75.uDistance - && ((v31 = v21->uAIState, v31 == 6) || !v31 || v31 == 1 || v31 == 9) - || v21->pMonsterInfo.uMissleAttack1Type && v21->uAIState == 8 ) - { - v32 = actor_id; - } - else - { - if ( (signed int)v21->uCurrentActionTime < v21->uCurrentActionLength ) - { - continue; - } - else if ( v21->uAIState == 2 ) - { - v32 = actor_id; - v35 = stru_50C198.special_ability_use_check(v21, actor_id); - stru_50FE08.Add( - a1, - 5120, - v21->vPosition.x, - v21->vPosition.y, - v21->vPosition.z + ((signed int)v21->uActorHeight >> 1), - v35, - 1 - ); - } - else if ( v21->uAIState == 3 ) - { - v34 = v21->pMonsterInfo.uMissleAttack1Type; - v66 = 0; - v32 = actor_id; - Actor::_404874(actor_id, &pDir, v34, v66); - } - else if ( v21->uAIState == 12 ) - { - v34 = v21->pMonsterInfo.uMissleAttack2Type; - v66 = 1; - v32 = actor_id; - Actor::_404874(actor_id, &pDir, v34, v66); - } - else - { - v32 = actor_id; - if ( v21->uAIState == 13 ) - { - v65 = v21->pMonsterInfo.uSpellSkillAndMastery1; - v60 = 2; - v33 = v21->pMonsterInfo.uSpell1ID; - Actor::_404AC7(actor_id, &pDir, v33, v60, v65); - } - else if ( v21->uAIState == 18 ) - { - v65 = v21->pMonsterInfo.uSpellSkillAndMastery2; - v60 = 3; - v33 = v21->pMonsterInfo.uSpell2ID; - Actor::_404AC7(actor_id, &pDir, v33, v60, v65); - } - } - } + v34 = v21->pMonsterInfo.uMissleAttack1Type; + Actor::RangedAttack(actor_id, &pDir, v34, 0); + } + else if ( v21->uAIState == AttackingRanged2 ) + { + v34 = v21->pMonsterInfo.uMissleAttack2Type; + Actor::RangedAttack(actor_id, &pDir, v34, 1); + } + else if ( v21->uAIState == AttackingRanged3 ) + { + v65 = v21->pMonsterInfo.uSpellSkillAndMastery1; + v33 = v21->pMonsterInfo.uSpell1ID; + Actor::SpellAttack(actor_id, &pDir, v33, 2, v65); + } + else if ( v21->uAIState == AttackingRanged4 ) + { + v65 = v21->pMonsterInfo.uSpellSkillAndMastery2; + v33 = v21->pMonsterInfo.uSpell2ID; + Actor::SpellAttack(actor_id, &pDir, v33, 3, v65); } } + v36 = v75.uDistance; - if ( !v21->pMonsterInfo.uHostilityType ) + if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly) { - if ( v76 == 3 ) + if ( target_pid_type == OBJECT_Actor ) { v36 = v75.uDistance; v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (v21->pMonsterInfo.uID - 1) / 3] - + (pActors[a2 >> 3].pMonsterInfo.uID - 1) / 3); + + (pActors[PID_ID(target_pid)].pMonsterInfo.uID - 1) / 3); } else { v37 = 4; } + v38=0; if ( v37 == 2 ) { - v39 = __OFSUB__(v36, 1024); - v38 = ((v36 - 1024) & 0x80000000u) != 0; + //v39 = __OFSUB__(v36, 1024); + //v38 = ((v36 - 1024) & 0x80000000u) != 0; + v38 = 1024; } else if ( v37 == 3 ) { - v39 = __OFSUB__(v36, 2560); - v38 = ((v36 - 2560) & 0x80000000u) != 0; + //v39 = __OFSUB__(v36, 2560); + //v38 = ((v36 - 2560) & 0x80000000u) != 0; + v38 = 2560; } else if ( v37 == 4 ) { - v39 = __OFSUB__(v36, 5120); - v38 = ((v36 - 5120) & 0x80000000u) != 0; + //v39 = __OFSUB__(v36, 5120); + //v38 = ((v36 - 5120) & 0x80000000u) != 0; + v38 = 5120; } - if ( v37 >= 1 && v37 <= 4 && v38 ^ v39 || v37 == 1 ) - v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + if ( v37 >= 1 && v37 <= 4 && v36 < v38 || v37 == 1 ) + v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; } + if ( (signed __int64)v21->pActorBuffs[4].uExpireTime > 0 ) { - v40 = a2; - v41 = v32; if ( (signed int)v36 >= 10240 ) { - v68 = 0; - v61 = 1024; - Actor::_4032B2(v41, v40, v61, v68); - continue; + Actor::_4032B2(actor_id, target_pid, 1024, 0); } - v67 = &pDir; - Actor::_402968(v41, v40, 0, v67); + else + { + //peasents after attacked + //guard after attacked + Actor::Flee(actor_id, target_pid, 0, &pDir); + } continue; } - if ( v21->pMonsterInfo.uHostilityType == 4 && a2 ) + + if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long && target_pid ) { - if ( !(v21->uAttributes & 0x020000) || v21->pMonsterInfo.uAIType == 1 ) + + if ( v21->pMonsterInfo.uAIType == 1 ) { - if ( v21->pMonsterInfo.uAIType == 1 ) + if ( v21->pMonsterInfo.uMovementType == 5 ) { - v67 = &pDir; - if ( v21->pMonsterInfo.uMovementType != 5 ) - { - v40 = a2; - v41 = v32; - Actor::_402968(v41, v40, 0, v67); - continue; - } - Actor::AI_Stand( - v32, - a2, - (signed __int64)((double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333), - &pDir); + Actor::AI_Stand(actor_id, target_pid, (signed __int64)((double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333), &pDir); } else { + Actor::Flee(actor_id, target_pid, 0, &pDir); + continue; + } + + } + if ( !(v21->uAttributes & 0x020000) ) + { + if ( v21->pMonsterInfo.uAIType == 2 || v21->pMonsterInfo.uAIType == 3) + { if ( v21->pMonsterInfo.uAIType == 2 ) - { - v84 = v21->sCurrentHP; - v42 = (double)(signed int)v84; v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.2; - } - else - { - v84 = v21->sCurrentHP; - v42 = (double)(signed int)v84; + if ( v21->pMonsterInfo.uAIType == 3 ) v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.1; - } - if ( v21->pMonsterInfo.uAIType == 2 || v21->pMonsterInfo.uAIType == 3 ) + v84 = v21->sCurrentHP; + v42 = (double)(signed int)v84; if ( v43 > v42 && (signed int)v36 < 10240 ) { - v67 = &pDir; - v40 = a2; - v41 = v32; - Actor::_402968(v41, v40, 0, v67); + Actor::Flee(actor_id, target_pid, 0, &pDir); continue; } } } + v81 = v36 - v21->uActorRadius; - if ( v76 == 3 ) - v81 -= pActors[a2 >> 3].uActorRadius; + if ( target_pid_type == OBJECT_Actor ) + v81 -= pActors[PID_ID(target_pid)].uActorRadius; if ( v81 < 0 ) - v81 = 0; + v81 = 0; rand(); - v44 = (signed int)v21->pMonsterInfo.uRecoveryTime <= 0; v21->uAttributes &= 0xFBFFFF; - v82 = 0; - v49 = v21->pMonsterInfo.uMovementType == 5; - v84 = v44; - if ( v49 ) - v82 = 1; if ( v81 < 5120 ) { - v45 = stru_50C198.special_ability_use_check(v21, v32); - if ( !v45 ) + v45 = stru_50C198.special_ability_use_check(v21, actor_id); + if ( v45 == 0 ) { if ( v21->pMonsterInfo.uMissleAttack1Type ) { - if ( v84 ) + if ( (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 ) { - Actor::_403476(v32, a2, &pDir); - continue; - + Actor::MissileAttack1(actor_id, target_pid, &pDir); } - if ( v82 ) + else if ( v21->pMonsterInfo.uMovementType == 5 ) { - v69 = &pDir; v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); + } + else + { + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + if ( v80 * 307.2 > (double)v81 ) + { + v64 = (signed __int64)v47; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); + } + else + { + Actor::Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); + } } - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - //UNDEF(v53); - v69 = &pDir; - if ( !(v54 | v55) ) + } + else + { + v56 = v80 * 307.2; + if ( (double)v81 >= v56 ) { - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69); - continue; - } - v56 = v80 * 307.2; - if ( (double)v81 >= v56 ) - { - if ( v81 >= 1024 ) - { - if ( v82 ) + if ( v81 >= 1024 ) { - v69 = &pDir; + if ( v21->pMonsterInfo.uMovementType == 5 ) + { + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + v64 = (signed __int64)v47; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); + } + else + { + //monsters + Actor::Pursue3(actor_id, target_pid, 0, &pDir); + } + } + else if ( v21->pMonsterInfo.uMovementType == 5 ) + { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } - v71 = &pDir; - v63 = 0; - - Actor::_402686(v32, a2, v63, v71); - continue; + else + { + v70 = (signed __int64)v56; + //monsters + //guard after player runs away + // follow player + Actor::Pursue2(actor_id, target_pid, 0, &pDir, v70); + } } - if ( v82 ) + else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) { - v69 = &pDir; v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } - v70 = (signed __int64)v56; - v62 = &pDir; - v59 = 0; - Actor::_40281C(v32, a2, v59, v62, v70); - continue; + else + { + //monsters + Actor::MeleeAttack(actor_id, target_pid, &pDir); + } } - v49 = v84 == 0; - v69 = &pDir; - if ( v49 ) - { - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - Actor::_403C6C(v32, a2, &pDir); continue; } - if ( v45 != 1 ) + else if ( v45 == 2 || v45 == 3 ) { - if ( v45 > 1 && v45 <= 3 ) + if ( v45 == 2 ) + v46 = v21->pMonsterInfo.uSpell1ID; + else + v46 = v21->pMonsterInfo.uSpell2ID; + if ( v46 ) { - if ( v45 == 2 ) - v46 = v21->pMonsterInfo.uSpell1ID; - else - v46 = v21->pMonsterInfo.uSpell2ID; - if ( v46 ) + if ( (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 ) { - if ( v84 ) - { - if ( v45 == 2 ) - Actor::_403854(v32, a2, &pDir); - else - Actor::_403A60(v32, a2, &pDir); - continue; - } - if ( v80 * 307.2 > (double)v81 || v82 ) - { - v69 = &pDir; - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - - } - v69 = &pDir; + if ( v45 == 2 ) + Actor::SpellAttack1(actor_id, target_pid, &pDir); + else + Actor::SpellAttack2(actor_id, target_pid, &pDir); + } + else if ( v80 * 307.2 > (double)v81 || v21->pMonsterInfo.uMovementType == 5 ) + { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69); - continue; + v64 = (signed __int64)v47; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } + else + { + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + Actor::Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); + } + } + else + { v48 = v80 * 307.2; if ( (double)v81 >= v48 ) { if ( v81 >= 1024 ) { - v50 = v82 == 0; - if ( !v50 ) + if ( v21->pMonsterInfo.uMovementType == 5 ) { - v69 = &pDir; v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } - v71 = &pDir; - v63 = 256; - Actor::_402686(v32, a2, v63, v71); - continue; - + else + { + Actor::Pursue3(actor_id, target_pid, 256, &pDir); + } } - if ( v82 ) + else if ( v21->pMonsterInfo.uMovementType == 5 ) { - v69 = &pDir; v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } - v70 = (signed __int64)v48; - v62 = &pDir; - v59 = 0; - Actor::_40281C(v32, a2, v59, v62, v70); - continue; + else + { + v70 = (signed __int64)v48; + Actor::Pursue2(actor_id, target_pid, 0, &pDir, v70); + } } - v49 = v84 == 0; - v69 = &pDir; - if ( v49 ) + else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } - Actor::_403C6C(v32, a2, &pDir); - continue; + else + { + Actor::MeleeAttack(actor_id, target_pid, &pDir); + } } + continue; } } } - if ( v21->pMonsterInfo.uHostilityType != 4 || !a2 || v81 >= 5120 || v45 != 1 ) + + if ( v21->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long || !target_pid || v81 >= 5120 || v45 != 1 ) { if ( !v21->pMonsterInfo.uMovementType ) { - v68 = 0; - v61 = 1024; - v41 = v32; - v40 = 4; - Actor::_4032B2(v41, v40, v61, v68); - continue; - + Actor::_4032B2(actor_id, 4, 1024, 0); } - if ( v21->pMonsterInfo.uMovementType == 1 ) + else if ( v21->pMonsterInfo.uMovementType == 1 ) { - v68 = 0; - v61 = 2560; - v41 = v32; - v40 = 4; - Actor::_4032B2(v41, v40, v61, v68); - continue; + Actor::_4032B2(actor_id, 4, 2560, 0); } - if ( v21->pMonsterInfo.uMovementType == 2 ) + else if ( v21->pMonsterInfo.uMovementType == 2 ) { - v68 = 0; - v61 = 5120; - v41 = v32; - v40 = 4; - Actor::_4032B2(v41, v40, v61, v68); - continue; + Actor::_4032B2(actor_id, 4, 5120, 0); } - if ( v21->pMonsterInfo.uMovementType == 4 ) + else if ( v21->pMonsterInfo.uMovementType == 4 ) { - v68 = 0; - v61 = 10240; - v41 = v32; - v40 = 4; - Actor::_4032B2(v41, v40, v61, v68); - continue; + Actor::_4032B2(actor_id, 4, 10240, 0); } - if ( v21->pMonsterInfo.uMovementType == 5 ) + else if ( v21->pMonsterInfo.uMovementType == 5 ) { v57 = Actor::GetDirectionInfo(a1, 4u, &v72, 0); v58 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; memcpy(&v74, v57, sizeof(v74)); memcpy(&pDir, &v74, sizeof(pDir)); - v69 = &pDir; - v52 = actor_id; v64 = (signed __int64)v58; - v51 = 4; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - continue; - + Actor::AI_Stand(actor_id, 4, v64, &pDir); + } } - if ( !v21->pMonsterInfo.uMissleAttack2Type ) + else if ( !v21->pMonsterInfo.uMissleAttack2Type ) { v56 = v80 * 307.2; if ( (double)v81 >= v56 ) { if ( v81 >= 1024 ) { - v50 = v82 == 0; - if ( !v50 ) + if ( v21->pMonsterInfo.uMovementType == 5 ) { - v69 = &pDir; v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } - v71 = &pDir; - v63 = 256; - Actor::_402686(v32, a2, v63, v71); - continue; + else + { + Actor::Pursue3(actor_id, target_pid, 256, &pDir); + } } - if ( v82 ) + else if ( v21->pMonsterInfo.uMovementType == 5 ) { - v69 = &pDir; v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } - v70 = (signed __int64)v56; - v62 = &pDir; - v59 = 0; - Actor::_40281C(v32, a2, v59, v62, v70); - continue; - + else + { + v70 = (signed __int64)v56; + Actor::Pursue2(actor_id, target_pid, 0, &pDir, v70); + } } - v49 = v84 == 0; - v69 = &pDir; - if ( v49 ) + else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - Actor::_403C6C(v32, a2, &pDir); - continue; - } - if ( !v84 ) - { - if ( v82 ) - { - v69 = &pDir; - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); + } + else + { + Actor::MeleeAttack(actor_id, target_pid, &pDir); } + } + else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) + { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - //UNDEF(v53); - v69 = &pDir; - if ( !(v54 | v55) ) + if ( v80 * 307.2 > (double)v81 || v21->pMonsterInfo.uMovementType == 5 ) { - v51 = a2; v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); + } + else + { + Actor::Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); } - Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69); - continue; } - Actor::_40368B(v32, a2, &pDir); + else + { + Actor::MissileAttack2(actor_id, target_pid, &pDir); + } } } } @@ -15989,10 +15857,10 @@ v2 = this->pQueue; do { - if ( (v2->uPackedID & 7) == OBJECT_Actor ) - { - v3 = &pActors[v2->uPackedID >> 3]; - v4 = &pActors[v2->uPackedID >> 3]; + if ( PID_TYPE(v2->uPackedID) == OBJECT_Actor ) + { + v3 = &pActors[PID_ID(v2->uPackedID)]; + v4 = &pActors[PID_ID(v2->uPackedID)]; LOBYTE(v4->uAttributes) |= 0x80u; if ( !v4->CanAct() ) { @@ -16001,7 +15869,7 @@ LOBYTE(v3->uAttributes) &= 0x7Fu; } } - if ( (v2->uPackedID & 7) == OBJECT_Player) + if ( PID_TYPE(v2->uPackedID) == OBJECT_Player) { v5 = &pParty->pPlayers[v2->uPackedID >> 3]; if ( v5->pConditions[14] @@ -16037,8 +15905,8 @@ v10 = v7->field_4; if ( v9 < v10 || v9 == v10 - && ((v11 = v8->uPackedID & 7, v11 == OBJECT_Player) && (v7->uPackedID & 7) == OBJECT_Actor - || v11 == (v7->uPackedID & 7) && (v8->uPackedID & 0xFFFFFFF8) < (v7->uPackedID & 0xFFFFFFF8)) ) + && ((v11 = PID_TYPE(v8->uPackedID), v11 == OBJECT_Player) && PID_TYPE(v7->uPackedID) == OBJECT_Actor + || v11 == PID_TYPE(v7->uPackedID) && (v8->uPackedID & 0xFFFFFFF8) < (v7->uPackedID & 0xFFFFFFF8)) ) { v12 = v7->uPackedID; v13 = v7->field_4; @@ -16066,9 +15934,9 @@ } v1->uActorQueueSize = v19; result = v1->pQueue[0].uPackedID; - if ( (v1->pQueue[0].uPackedID & 7) == OBJECT_Player) - { - result = (result >> 3) + 1; + if ( PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) + { + result = PID_ID(result) + 1; uActiveCharacter = result; v1->field_18 |= 4u; } @@ -16083,8 +15951,8 @@ v17 = v1->pQueue; do { - if ( (v17->uPackedID & 7) == OBJECT_Player) - pParty->pPlayers[v17->uPackedID >> 3].uTimeToRecovery = (signed __int64)((double)v17->field_4 * 0.46875); + if ( PID_TYPE(v17->uPackedID) == OBJECT_Player) + pParty->pPlayers[PID_ID(v17->uPackedID)].uTimeToRecovery = (signed __int64)((double)v17->field_4 * 0.46875); ++v22; ++v17; result = v22; @@ -16164,7 +16032,7 @@ { if ( v40->CanAct() ) { - *(&v1->field_0 + 4 * (v1->uActorQueueSize + 2)) = 8 * v3 | OBJECT_Player; + *(&v1->field_0 + 4 * (v1->uActorQueueSize + 2)) = PID(OBJECT_Player,v3); v1->pQueue[v1->uActorQueueSize].field_C = 2; v1->pQueue[v1->uActorQueueSize].uActionLength = 0; pParty->pTurnBasedPlayerRecoveryTimes[v1->uActorQueueSize++] = 0; @@ -16194,8 +16062,8 @@ v8 = ai_near_actors_targets_pid[v5]; LOBYTE(v7) = v7 | 0x80; v6->uAttributes = v7; - v33 = 8 * v5 | OBJECT_Actor; - memcpy(&v31, Actor::GetDirectionInfo(8 * v5 | OBJECT_Actor, v8, &a3, 0), sizeof(v31)); + v33 = PID(OBJECT_Actor,v5); + memcpy(&v31, Actor::GetDirectionInfo(PID(OBJECT_Actor,v5), v8, &a3, 0), sizeof(v31)); memcpy(&v30, &v31, sizeof(v30)); Actor::AI_StandOrBored(v37, 4, 32, &v30); *(&v1->field_0 + 4 * (v1->uActorQueueSize + 2)) = v33; @@ -16221,7 +16089,7 @@ v12 = (char *)&v1->pQueue[0].field_4; while ( 1 ) { - v13 = *((int *)v12 - 1) & 7; + v13 = PID_TYPE(*((int *)v12 - 1)); if ( v13 != OBJECT_Player ) break; v14 = pPlayers[(*((int *)v12 - 1) >> 3) + 1]->uTimeToRecovery;
--- a/mm7_4.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/mm7_4.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -133,7 +133,7 @@ v5 = v8; } if ( (signed int)(((unsigned int)(11 * v5) >> 5) + (v6 >> 2) + v4) < v2 ) - EventProcessor(v1->field_16_event_id, 8 * i | 5, 1); + EventProcessor(v1->field_16_event_id, PID(OBJECT_Decoration,i), 1); } if ( v1->field_2 & 2 ) { @@ -977,7 +977,7 @@ { stru_721530.field_7C = v13; v14 = 8 * v16; - LOBYTE(v14) = 8 * v16 | 3; + LOBYTE(v14) = PID(OBJECT_Actor,v16); stru_721530.uFaceID = v14; } result = 1; @@ -1119,7 +1119,7 @@ do { v4 = *v3; - if ( (v4 & 7) == OBJECT_Decoration) + if ( PID_TYPE(v4) == OBJECT_Decoration) { v5 = &pLevelDecorations[(signed __int16)v4 >> 3]; if ( !(v5->field_2 & 0x20) ) @@ -1515,7 +1515,7 @@ v2 = this; v3 = operator new(8 * a2 + 16); v2->pBlockBase = v3; - v4 = (char *)v3 + (-(signed int)v3 & 7); + v4 = (char *)v3 + PID_TYPE(-(signed int)v3); result = v2; v2->pAlignedBlock = v4; } @@ -2133,11 +2133,11 @@ v17 = pActors[v16].vPosition.y; a1.vPosition.z = pActors[v16].vPosition.z; v18 = 8 * v15; - LOBYTE(v18) = 8 * v15 | 3; + LOBYTE(v18) = PID(OBJECT_Actor,v15); a1.vPosition.y = v17; a1.spell_target_pid = v18; v19 = a1.Create(0, 0, 0, 0); - DamageMonsterFromParty(8 * v19 | 2, *v14, &a3); + DamageMonsterFromParty(PID(OBJECT_Item,v19), *v14, &a3); ++v9; } while ( v9 < v13 ); @@ -5521,7 +5521,7 @@ v68 = v2; v5 = (Texture *)(v4 != -1 ? (int)&pBitmaps_LOD->pTextures[v3] : 0); v6 = 8 * uFaceID; - LOBYTE(v6) = 8 * uFaceID | 6; + LOBYTE(v6) = PID(OBJECT_BModel,uFaceID); stru_F8AD28.field_0 = v6; stru_F8AD28.plane_4.vNormal.x = v1->pFacePlane_old.vNormal.x; stru_F8AD28.plane_4.vNormal.y = v1->pFacePlane_old.vNormal.y; @@ -7931,7 +7931,7 @@ if ( v17->joins ) { num_menu_buttons = 1; - pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, UIMSG_ClickNPCTopic, 0xDu, 0, "", 0); + pDialogueWindow->CreateButton(480u, 160u, 140u, 30, 1, 0, UIMSG_ClickNPCTopic, 0xDu, 0, "", 0); } if ( v17->evt_A) { @@ -8582,8 +8582,8 @@ v7 = this->pQueue; do { - if ( (v7->uPackedID & 7) == OBJECT_Actor ) - LOBYTE(pActors[v7->uPackedID >> 3].uAttributes) &= 0x7Fu; + if ( PID_TYPE(v7->uPackedID) == OBJECT_Actor ) + LOBYTE(pActors[PID_ID(v7->uPackedID)].uAttributes) &= 0x7Fu; ++v4; ++v7; } @@ -8612,8 +8612,8 @@ v11 = v2->pQueue; do { - objType = (ObjectType)(v11->uPackedID & 7); - objID = v11->uPackedID >> 3; + objType = (ObjectType)PID_TYPE(v11->uPackedID); + objID = PID_ID(v11->uPackedID); if ( objType == OBJECT_Player ) { pPlayers[objID + 1]->uTimeToRecovery = (signed __int64)((double)v11->field_4 * 2.133333333333333); @@ -8707,7 +8707,7 @@ if ( (signed int)v4->uCurrentActionTime >= v5 ) { v17 = ai_near_actors_targets_pid[v20]; - v6 = Actor::GetDirectionInfo(8 * v20 | OBJECT_Actor, v17, &a3, v2); + v6 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v20), v17, &a3, v2); v7 = v4->uAIState; memcpy(&v15, v6, sizeof(v15)); v8 = v7 - 4; @@ -8996,9 +8996,9 @@ LOWORD(v25) = 0; LOBYTE(v26) = v41; - //v0->sZValue = v25 + (8 * i | OBJECT_Actor); + //v0->sZValue = v25 + (PID(OBJECT_Actor,i)); v0->actual_z = HIWORD(x); - v0->object_pid = v8 * i | OBJECT_Actor; + v0->object_pid = PID(OBJECT_Actor,i); v29 = HIDWORD(p->pActorBuffs[5].uExpireTime) == 0; v30 = HIDWORD(p->pActorBuffs[5].uExpireTime) < 0;
--- a/mm7_5.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/mm7_5.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -1741,9 +1741,9 @@ v42 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint->y]]; } v44 = (unsigned __int16)v42; - v45 = v44 & 7; + v45 = PID_TYPE(v44); uNumSeconds = v44; - v46 = v44 >> 3; + v46 = PID_ID(v44); if ( v45 == 3 ) { v47 = pActors[v46].uAIState == Dead; @@ -2397,7 +2397,7 @@ v83 = v81; v44 = (unsigned __int16)v81; v84 = v83 >> 16; - if ( (v44 & 7) != 3 || v84 >= 5120 ) + if ( PID_TYPE(v44) != 3 || v84 >= 5120 ) //goto LABEL_90; { v1 = ""; @@ -4532,24 +4532,24 @@ v1 = (char *)stru_50FE08.pZs; do { - v2 = *((short *)v1 - 300) & 7; - v3 = (signed int)*((short *)v1 - 300) >> 3; - v39 = (signed int)*((short *)v1 - 300) >> 3; + v2 = PID_TYPE(*((short *)v1 - 300)); + v3 = PID_ID((signed int)*((short *)v1 - 300)); + v39 = PID_ID((signed int)*((short *)v1 - 300)); if ( v2 == 2 ) { v4 = &pSpriteObjects[v3]; v36 = v4; v5 = v4->spell_caster_pid; - v2 = v5 & 7; - v3 = v5 >> 3; + v2 = PID_TYPE(v5); + v3 = PID_ID(v5); } v41 = v2; v37 = v3; if ( stru_50FE08.field_3EC[v0] & 1 ) { v6 = ai_near_actors_targets_pid[v3]; - v7 = v6 >> 3; - v8 = (v6 & 7) - 3; + v7 = PID_ID(v6); + v8 = PID_TYPE(v6) - 3; uActorID = v7; if ( v8 ) { @@ -4775,9 +4775,9 @@ v61 = 0; v59 = 0; v62 = 0; - if ( (a1 & 7) == OBJECT_Item) - { - v4 = &pSpriteObjects[a1 >> 3]; + if ( PID_TYPE(a1) == OBJECT_Item) + { + v4 = &pSpriteObjects[PID_ID(a1)]; //uDamageAmount = (int)v4; v61 = v4->field_60_distance_related_prolly_lod; a1 = v4->spell_caster_pid; @@ -4785,11 +4785,11 @@ } //v5 = a1 & 7; //uPlayerID = a1 >> 3; - if ((a1 & 7) != OBJECT_Player) + if (PID_TYPE(a1) != OBJECT_Player) return; - assert(abs(a1 >> 3) < 4); - auto player = &pParty->pPlayers[a1 >> 3]; + assert(PID_ID(abs(a1)) < 4); + auto player = &pParty->pPlayers[PID_ID(a1)]; pMonster = &pActors[uActorID_Monster_]; //uPlayerID = pMonster->IsAlive(); if (pMonster->IsNotAlive()) @@ -5046,7 +5046,7 @@ } if ( pMonster->sCurrentHP > 0 ) { - Actor::_4030AD(uActorID_Monster_, a1, 0); + Actor::Stun(uActorID_Monster_, a1, 0); Actor::AggroSurroundingPeasants(uActorID_Monster_, 1); if ( bShowDamage ) { @@ -5250,8 +5250,8 @@ signed int a4a; // [sp+60h] [bp+Ch]@162 Player *a4b; // [sp+60h] [bp+Ch]@168 - v4 = (signed int)uObjID >> 3; - v5 = (uObjID & 7) - 2; + v4 = PID_ID(uObjID); + v5 = PID_TYPE(uObjID) - 2; v74 = a2; uActorID = v4; if ( v5 ) @@ -5321,7 +5321,7 @@ } v17 = (SoundID)a4; LABEL_26: - pAudioPlayer->PlaySound(v17, (8 * a4 + 80) | 4, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(v17, PID(OBJECT_Player,a4 + 80), 0, -1, 0, 0, 0, 0); v18 = Actor::_43B3E0_CalcDamage(v7, v74); v19 = HIDWORD(v7->pActorBuffs[3].uExpireTime) == 0; v20 = SHIDWORD(v7->pActorBuffs[3].uExpireTime) < 0; @@ -5381,7 +5381,7 @@ { if ( v7->sCurrentHP >= 1 ) { - Actor::_4030AD(uActorID, 8 * a4 | OBJECT_Player, 0); + Actor::Stun(uActorID, PID(OBJECT_Player,a4), 0); Actor::AggroSurroundingPeasants(uActorID, 1); } else @@ -5448,10 +5448,10 @@ return; } v37 = &pSpriteObjects[uActorID]; - v38 = v37->spell_caster_pid & 7; - v39 = v37->spell_caster_pid >> 3; - v40 = v37->spell_caster_pid & 7; - uActorID = v37->spell_caster_pid >> 3; + v38 = PID_TYPE(v37->spell_caster_pid); + v39 = PID_ID(v37->spell_caster_pid); + v40 = PID_TYPE(v37->spell_caster_pid); + uActorID = PID_ID(v37->spell_caster_pid); v41 = v40 - 2; if ( !v41 ) goto LABEL_80; @@ -5567,7 +5567,7 @@ { if ( v44->sCurrentHP >= 1 ) { - Actor::_4030AD(uActorID, 8 * a4 | OBJECT_Player, 0); + Actor::Stun(uActorID, PID(OBJECT_Player,a4), 0); Actor::AggroSurroundingPeasants(uActorID, 1); } else @@ -5847,9 +5847,9 @@ a2 = uObjID; if ( !pActors[uActorID].IsNotAlive() ) { - if ( (a2 & 7) == OBJECT_Item) - { - v4 = &pSpriteObjects[(signed int)a2 >> 3]; + if ( PID_TYPE(a2) == OBJECT_Item) + { + v4 = &pSpriteObjects[PID_ID(a2)]; v5 = v4->spell_id; if ( v5 ) { @@ -5859,7 +5859,7 @@ if ( v7 ) { if ( pActor->sCurrentHP > 0 ) - Actor::_4030AD(uActorIDa, a2, 0); + Actor::Stun(uActorIDa, a2, 0); else Actor::Die(uActorIDa); a2a = 20 * v7 / (signed int)pActor->pMonsterInfo.uHP; @@ -5878,7 +5878,7 @@ } else { - Actor::_4030AD(uActorIDa, a2, 0); + Actor::Stun(uActorIDa, a2, 0); } } } @@ -5906,17 +5906,17 @@ v4 = 0; uActorID = a2; v17 = a1; - if ( (a1 & 7) == OBJECT_Item) - { - v5 = &pSpriteObjects[a1 >> 3]; + if ( PID_TYPE(a1) == OBJECT_Item) + { + v5 = &pSpriteObjects[PID_ID(a1)]; v4 = v5->field_60_distance_related_prolly_lod; v17 = v5->spell_caster_pid; } - LOWORD(v6) = v17 & 7; + LOWORD(v6) = PID_TYPE(v17); if ( v6 == OBJECT_Actor) { v7 = &pActors[a2]; - v8 = &pActors[v17 >> 3]; + v8 = &pActors[PID_ID(v17)]; v6 = pActors[a2].IsNotAlive(); if ( !v6 ) { @@ -5967,7 +5967,7 @@ if ( v14 ) { if ( v7->sCurrentHP > 0 ) - Actor::_4030AD(uActorID, v17, 0); + Actor::Stun(uActorID, v17, 0); else Actor::Die(uActorID); Actor::AggroSurroundingPeasants(uActorID, 0); @@ -5987,7 +5987,7 @@ } else { - Actor::_4030AD(uActorID, v17, 0); + Actor::Stun(uActorID, v17, 0); } return; } @@ -6759,7 +6759,7 @@ while ( 1 ) { v5 = v16->uPackedID; - if ( (v16->uPackedID & 7) == OBJECT_Player) + if ( PID_TYPE(v16->uPackedID) == OBJECT_Player) break; LABEL_8: ++v17; @@ -6767,8 +6767,8 @@ if ( v17 >= v1->uActorQueueSize ) goto LABEL_11; } - v15 = v5 >> 3; - if ( !pPlayers[(v5 >> 3) + 1]->CanAct() || v19 != v15 ) + v15 = PID_ID(v5); + if ( !pPlayers[(PID_ID(v5)) + 1]->CanAct() || v19 != v15 ) { v2 = 0; goto LABEL_8; @@ -6779,7 +6779,7 @@ { *(int *)v4 = 100; v6 = 8 * v19; - LOBYTE(v6) = 8 * v19 | 4; + LOBYTE(v6) = PID(OBJECT_Player,v19); *((int *)v4 + 2) = v2; *((int *)v4 - 1) = v6; *((int *)v4 + 1) = v2; @@ -6802,7 +6802,7 @@ v8 = v1->pQueue; do { - if ( (v8->uPackedID & 7) == OBJECT_Actor && ai_near_actors_ids[v20] == v8->uPackedID >> 3 ) + if ( PID_TYPE(v8->uPackedID) == OBJECT_Actor && ai_near_actors_ids[v20] == PID_ID(v8->uPackedID) ) break; ++v18; ++v8; @@ -6815,7 +6815,7 @@ v9 = ai_near_actors_ids[v20]; *(int *)v7 = 1; *((int *)v7 + 2) = v2; - *((int *)v7 - 1) = 8 * v9 | 3; + *((int *)v7 - 1) = PID(OBJECT_Actor,v9); *((int *)v7 + 1) = v2; ++v3; v7 += 16; @@ -6846,7 +6846,7 @@ v13 = (char *)&v1->pQueue[0].field_4; do { - v11 = *((int *)v13 - 1) & 7; + v11 = PID_TYPE(*((int *)v13 - 1)); if ( (char)v11 == 4 ) break; if ( *(int *)v13 > 0 ) @@ -6936,7 +6936,7 @@ if ( v6 != 8 ) goto LABEL_19; v3 = 0; - Actor::AI_StandOrBored(v2->uPackedID >> 3, ai_near_actors_targets_pid[v2->uPackedID >> 3], 32, 0); + Actor::AI_StandOrBored(PID_ID(v2->uPackedID), ai_near_actors_targets_pid[PID_ID(v2->uPackedID)], 32, 0); } } } @@ -7039,7 +7039,7 @@ } else { - v8 = &pActors[v1->pQueue[0].uPackedID >> 3]; + v8 = &pActors[PID_ID(v1->pQueue[0].uPackedID)]; if ( v4 > 0 ) { do @@ -7091,10 +7091,10 @@ v2 = this; v3 = *(&this->field_0 + 4 * (a2 + 2)); - if ( (*((char *)&this->field_0 + 16 * (a2 + 2)) & 7) == OBJECT_Player) - { - v4 = v3 >> 3; - v5 = (char *)&pParty->pTurnBasedPlayerRecoveryTimes[v3 >> 3]; + if ( (*((char *)&this->field_0 + 16 * PID_TYPE(a2 + 2))) == OBJECT_Player) + { + v4 = PID_ID(v3); + v5 = (char *)&pParty->pTurnBasedPlayerRecoveryTimes[PID_ID(v3)]; v6 = *(int *)v5; if ( *(int *)v5 ) *(int *)v5 = 0; @@ -7105,7 +7105,7 @@ } else { - v6 = pMonsterStats->pInfos[pActors[v3 >> 3].pMonsterInfo.uID].uRecoveryTime; + v6 = pMonsterStats->pInfos[pActors[PID_ID(v3)].pMonsterInfo.uID].uRecoveryTime; } v2->pQueue[a2].field_4 = v6; v2->_404544(); @@ -7143,7 +7143,7 @@ //----- (0040652A) -------------------------------------------------------- void stru262_TurnBased::_40652A() { - char *v1; // edx@2 + int *v1; // edx@2 Actor *v2; // eax@5 unsigned __int16 v3; // si@5 unsigned int v4; // esi@8 @@ -7152,14 +7152,14 @@ v5 = 0; if ( this->uActorQueueSize > 0 ) { - v1 = (char *)&this->pQueue[0].field_4; + v1 = &this->pQueue[0].field_4; do { if ( !*(int *)v1 ) { - if ( (*(v1 - 4) & 7) == OBJECT_Player) + if ( PID_TYPE(*(v1 - 4)) == OBJECT_Player) return; - v2 = &pActors[*((int *)v1 - 1) >> 3]; + v2 = &pActors[PID_ID(*(v1 - 1))]; v3 = v2->uAIState; if (v3 == Standing || v3 == Fleeing || v3 == Fidgeting) { @@ -7188,7 +7188,7 @@ v1 = this; LOWORD(v2) = _404544(); if ( v1->pQueue[0].field_4 <= 0 - || ((_4063A1(), v2 = v1->pQueue[0].uPackedID, PID_TYPE(v1->pQueue[0].uPackedID) != OBJECT_Player) ? (uActiveCharacter = 0) : (v2 = (v2 >> 3) + 1, uActiveCharacter = v2), + || ((_4063A1(), v2 = v1->pQueue[0].uPackedID, PID_TYPE(v1->pQueue[0].uPackedID) != OBJECT_Player) ? (uActiveCharacter = 0) : (v2 = (PID_ID(v2)) + 1, uActiveCharacter = v2), viewparams->bRedrawGameUI = 1, v1->pQueue[0].field_4 <= 0) ) { @@ -7199,7 +7199,7 @@ do { v2 = *(int *)v4; - if ( (*(char *)v4 & 7) == OBJECT_Player || *(int *)(v4 + 4) > 0 ) + if ( PID_TYPE(*(char *)v4) == OBJECT_Player || *(int *)(v4 + 4) > 0 ) break; if ( *(int *)(v4 + 8) <= 0 ) { @@ -7262,7 +7262,7 @@ a2a = ai_near_actors_targets_pid[PID_ID(v3)]; memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, ai_near_actors_targets_pid[PID_ID(v3)], &a3, 0), sizeof(a3)); memcpy(&a4, &a3, sizeof(a4)); - v5 = &pActors[PID_ID(v3 >> 3)]; + v5 = &pActors[PID_ID(v3)]; LOWORD(v3) = v5->uAIState; if ( (short)v3 != Dead ) { @@ -7339,7 +7339,7 @@ v22 = 2; v17 = v5->pMonsterInfo.uSpell1ID; } - Actor::_404AC7(v4, &a4, v17, v22, v24); + Actor::SpellAttack(v4, &a4, v17, v22, v24); LABEL_25: v16 = a2a; v23 = &a4; @@ -7355,7 +7355,7 @@ v18 = v5->pMonsterInfo.uMissleAttack1Type; v25 = 0; } - Actor::_404874(v4, &a4, v18, v25); + Actor::RangedAttack(v4, &a4, v18, v25); goto LABEL_25; } } @@ -7369,8 +7369,8 @@ __int16 stru262_TurnBased::_40680F(int a2) { TurnBased_QueueElem *v2; // eax@1 - TurnBased_QueueElem *v3; // eax@1 - TurnBased_QueueElem *v4; // edi@2 + unsigned int v3; // eax@1 + unsigned int v4; // edi@2 Actor *v5; // ebx@2 unsigned int *v6; // esi@7 AIDirection *v7; // esi@10 @@ -7392,13 +7392,13 @@ v2 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2)); v21 = v2; v2->uActionLength = 0; - v3 = (TurnBased_QueueElem *)v2->uPackedID; + v3 = v2->uPackedID; if ( (unsigned __int8)v3 & 3 ) { - v3 = (TurnBased_QueueElem *)((signed int)v3 >> 3); + v3 = PID_ID(v3); v4 = v3; - a2a = (int)v3; - v5 = &pActors[(int)v3]; + a2a = v3; + v5 = &pActors[v3]; LOWORD(v3) = v5->uAIState; if ( (short)v3 != 5 ) { @@ -7409,7 +7409,7 @@ if ( v5->pMonsterInfo.uHostilityType && !*v6 ) v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; v22 = *v6; - v7 = Actor::GetDirectionInfo(8 * (int)v4 | 3, *v6, &a3, 0); + v7 = Actor::GetDirectionInfo(PID(OBJECT_Actor,(int)v4), *v6, &a3, 0); v8 = v5->uActorRadius; memcpy(&a3, v7, sizeof(a3)); memcpy(&v18, &a3, sizeof(v18)); @@ -7421,7 +7421,7 @@ v20 = 0; } if (PID_TYPE(v22) == OBJECT_Actor) - v10 = (unsigned __int8)*(&byte_5C8D1A[89 * (pMonsterStats->pInfos[pActors[v22 >> 3].pMonsterInfo.uID].uID - 1) / 3] + (v5->pMonsterInfo.uID - 1) / 3); + v10 = (unsigned __int8)*(&byte_5C8D1A[89 * (pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID - 1) / 3] + (v5->pMonsterInfo.uID - 1) / 3); else v10 = 4; if ( v10 == 1 ) @@ -7470,7 +7470,7 @@ { if ( v5->pMonsterInfo.uMissleAttack2Type ) { - Actor::_40368B(v13, v22, &v18); + Actor::MissileAttack2(v13, v22, &v18); goto LABEL_43; } } @@ -7485,35 +7485,36 @@ if ( v15 ) { if ( v14 == 2 ) - Actor::_403854(v13, v22, &v18); + Actor::SpellAttack1(v13, v22, &v18); else - Actor::_403A60(v13, v22, &v18); + Actor::SpellAttack2(v13, v22, &v18); goto LABEL_43; } goto LABEL_44; } if ( v5->pMonsterInfo.uMissleAttack1Type ) { - Actor::_403476(v13, v22, &v18); + Actor::MissileAttack1(v13, v22, &v18); LABEL_43: - v3 = v21; + //v3 = v21; v21->field_C = 1; LABEL_48: - v3->uActionLength = v5->uCurrentActionLength; - return (signed __int16)v3; + v21->uActionLength = v5->uCurrentActionLength; + //return (signed __int16)v3; + return (signed __int16)&v21; } } LABEL_44: if ( (double)(signed int)v20 < 307.2 ) { - Actor::_403C6C(v13, v22, &v18); - v3 = v21; + Actor::MeleeAttack(v13, v22, &v18); + //v3 = v21; v21->field_C = 3; goto LABEL_48; } LABEL_47: Actor::AI_Stand(v13, v22, 0x40u, &v18); - v3 = v21; + //v3 = v21; v21->field_C = 0; goto LABEL_48; } @@ -7555,7 +7556,7 @@ v8 = ai_near_actors_targets_pid[PID_ID(v5)]; memcpy(&v7, Actor::GetDirectionInfo(v5, v8, &a3, v2), sizeof(v7)); if ( !v1->_406D10(a2) ) - Actor::AI_Stand(v10->uPackedID >> 3, v8, 0x20u, &v7); + Actor::AI_Stand(PID_ID(v10->uPackedID), v8, 0x20u, &v7); } ++a2; ++v10; @@ -7646,7 +7647,7 @@ a1 = v14->uPackedID; if (PID_TYPE(a1) != OBJECT_Player) { - v5 = v4 >> 3; + v5 = PID_ID(v4); v12 = v5; v6 = &pActors[v5]; if ( SHIDWORD(v6->pActorBuffs[5].uExpireTime) < result @@ -7826,7 +7827,7 @@ goto LABEL_25; } LABEL_24: - Actor::_402968(v16, v15, v21, v23); + Actor::Flee(v16, v15, v21, v23); LABEL_25: v17 = v29; v29->field_C = 4; @@ -7843,9 +7844,9 @@ if ( (signed int)v11 < 5120 ) { if ( v4->pMonsterInfo.uMissleAttack1Type && (signed int)v11 < 1024 ) - Actor::_402AD7(uActorID, a2a, uActorID, 32, &pDir); + Actor::Pursue1(uActorID, a2a, uActorID, 32, &pDir); else - Actor::_40281C(uActorID, a2a, 32, &pDir, 307); + Actor::Pursue2(uActorID, a2a, 32, &pDir, 307); goto LABEL_59; } LABEL_46: @@ -8042,8 +8043,8 @@ int v65; // [sp+60h] [bp-8h]@4 int v66; // [sp+64h] [bp-4h]@7 - v2 = (signed int)uObjID >> 3; - v3 = (uObjID & 7) - 2; + v2 = PID_ID(uObjID); + v3 = PID_TYPE(uObjID) - 2; v4 = uObj2ID; if ( v3 ) { @@ -8078,8 +8079,8 @@ v65 = v11; } v66 = v7; - v12 = v4 >> 3; - v13 = (v4 & 7) - 2; + v12 = PID_ID(v4); + v13 = PID_TYPE(v4) - 2; if ( v13 ) { v14 = v13 - 1;
--- a/mm7_6.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/mm7_6.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -3557,7 +3557,7 @@ a1.vPosition.x = pActors[PID_ID(a2)].vPosition.x; a1.vPosition.z = pActors[PID_ID(a2)].vPosition.z; a1.vPosition.y = pActors[PID_ID(a2)].vPosition.y; - a1.spell_target_pid = PID(OBJECT_Actor, a2 >> 3); + a1.spell_target_pid = PID(OBJECT_Actor, PID_ID(a2)); auto obj_id = a1.Create(0, 0, 0, 0); DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v697); LODWORD(v727) = 1; @@ -3569,12 +3569,12 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - if ( !stru_50C198.GetMagicalResistance(&pActors[a2 >> 3], 3u) ) + if ( !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 3u) ) { LODWORD(v727) = 1; goto play_sound_and_continue; } - pActors[a2 >> 3].pActorBuffs[10].Apply(pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0); + pActors[PID_ID(a2)].pActorBuffs[10].Apply(pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0); v704.x = 0; v704.y = 0; v704.z = 0; @@ -3730,7 +3730,7 @@ if (PID_TYPE(a2) != OBJECT_Actor || (v730 = PID_ID(a2), v721 = (int)&pActors[PID_ID(a2)], - !stru_50C198.GetMagicalResistance(&pActors[a2 >> 3], 9u)) ) + !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 9u)) ) { LODWORD(v727) = 1; goto play_sound_and_continue; @@ -3784,7 +3784,7 @@ v58 = (signed __int64)((double)(23040 * v2) * 0.033333335); v59 = v721; //((SpellBuff *)((char *)&pActors[0].pActorBuffs[7] + v721))->Apply( - pActors[a2 >> 3].pActorBuffs[7].Apply(pParty->uTimePlayed + (signed int)v58, + pActors[PID_ID(a2)].pActorBuffs[7].Apply(pParty->uTimePlayed + (signed int)v58, v731, amount, 0, @@ -3826,7 +3826,7 @@ a1.spell_level = v2; a1.spell_skill = v731; v60 = pObjectList->ObjectIDByItemID(a1.uType); - v61 = a2 >> 3; + v61 = PID_ID(a2); goto LABEL_1086; } @@ -4365,7 +4365,7 @@ } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - LODWORD(v725) = a2 & 7; + LODWORD(v725) = PID_TYPE(a2); if (PID_TYPE(a2) == OBJECT_Actor) { uRequiredMana = pActors[PID_ID(a2)].vPosition.x; @@ -4731,11 +4731,11 @@ } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v208 = a2 & 7; - LODWORD(v725) = a2 & 7; + v208 = PID_TYPE(a2); + LODWORD(v725) = PID_TYPE(a2); if ( v208 == 3 ) { - v209 = a2 >> 3; + v209 = PID_ID(a2); LODWORD(v718) = pActors[v209].vPosition.x; v210 = pActors[v209].vPosition.y; v211 = pActors[v209].vPosition.z; @@ -5672,7 +5672,7 @@ } if (PID_TYPE(v342) == OBJECT_Actor) { - v343 = v342 >> 3; + v343 = PID_ID(v342); HIDWORD(v344) = 0 + ((pParty->uTimePlayed + 1280) >> 32); LODWORD(v344) = LODWORD(pParty->uTimePlayed) + 1280; pActors[v343].pActorBuffs[11].Apply(v344, v731, amount, 0, 0); @@ -7028,7 +7028,7 @@ } goto play_sound_and_continue; } - v577 = (Player *)(v576 >> 3); + v577 = (Player *)(PID_ID(v576)); //v726 = v577; if ( v577 == (Player *)-1 ) { @@ -7791,13 +7791,13 @@ //v7 = pMouse->uPointingObjectID; int target_pid = pMouse->uPointingObjectID; - int target_type = target_pid & 7, - target_id = target_pid >> 3; + int target_type = PID_TYPE(target_pid), + target_id = PID_ID(target_pid); if (target_type != OBJECT_Actor || !pActors[target_id].CanAct()) { target_pid = stru_50C198.FindClosestActor(5120, 0, 0); - target_type = target_pid & 7; - target_id = target_pid >> 3; + target_type = PID_TYPE(target_pid); + target_id = PID_ID(target_pid); } auto actor = &pActors[target_id];
--- a/mm7_data.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/mm7_data.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -346,8 +346,8 @@ int (__stdcall *off_4DAFDC)(char); // weak char asc_4DB724[777]; // idb int dword_4DBD94; // weak -int dword_4DF380[777]; // weak -int dword_4DF390; // weak +int dword_4DF380[5]={0,1024,2560,5120,10240}; // weak +//int dword_4DF390; // weak char Str2[777]; // idb int dword_4DF3A4; // weak char byte_4E185C; // weak
--- a/stru6.cpp Mon Apr 01 09:05:31 2013 +0600 +++ b/stru6.cpp Mon Apr 01 09:05:51 2013 +0600 @@ -832,7 +832,7 @@ AddMobileLight(a2, 0xFF3C1E, 256); if (pRenderer->pRenderD3D) { - result = a2->spell_caster_pid & 7; + result = PID_TYPE(a2->spell_caster_pid); if (PID_TYPE(a2->spell_caster_pid) != OBJECT_Actor && PID_TYPE(a2->spell_caster_pid) != OBJECT_Item) {