# HG changeset patch # User Ritor1 # Date 1364820739 -21600 # Node ID 4568f1e4d61bda797f884ed39f82cd108e3f45f3 # Parent cd355e4c6104bd9b240d294fadfbd23da72ad6a6# Parent 726f9c2ff38134512cbbe51dd0ee952ba1b93cf8 Слияние diff -r cd355e4c6104 -r 4568f1e4d61b Actor.cpp --- a/Actor.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/Actor.cpp Mon Apr 01 18:52:19 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 = PID(LODWORD(v120),OBJECT_Actor); + v116 = PID(OBJECT_Actor,LODWORD(v120)); do { v26 = rand(); @@ -915,7 +915,7 @@ v102 = 0; v40 = 8 * LODWORD(v120); v101 = -1; - LOBYTE(v40) = PID(LOBYTE(v120),OBJECT_Actor); + 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) = PID(LOBYTE(v120),OBJECT_Actor); + 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) = PID(LOBYTE(v120),OBJECT_Actor); + 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) = PID(LOBYTE(v120),OBJECT_Actor); + 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) = PID(LOBYTE(v120),OBJECT_Actor); + 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) = PID(LOBYTE(v120),OBJECT_Actor); + 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) = PID(LOBYTE(v120),OBJECT_Actor); + 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) = PID(LOBYTE(v120),OBJECT_Actor); + 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) = PID(LOBYTE(v120),OBJECT_Actor); + 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) = PID(LOBYTE(v120),OBJECT_Actor); + 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 @@ -1760,9 +1760,6 @@ v4 = PID_ID(uObj1ID); v5 = PID_TYPE(uObj1ID); v6 = uObj2ID; - v20 = v6; - v21 = PID_TYPE(v6); - v22 = PID_ID(v20); switch(v5) { case OBJECT_Item: @@ -1773,12 +1770,6 @@ v14 = pSpriteObjects[v19].vPosition.z; outy = v13; outz = v14; - 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: @@ -1788,10 +1779,6 @@ LODWORD(v42) = pActors[v4].uActorHeight; v11 = pActors[v4].vPosition.z - (unsigned int)(signed __int64)((double)SLODWORD(v42) * -0.75); outz = v11; - 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: @@ -1856,13 +1843,6 @@ Vec3_int_::Rotate(v35, v18, v36, v37, v38, v39, v40); break; } - LODWORD(v45) = pParty->vPosition.x; - LODWORD(v44) = pParty->vPosition.y; - v29 = a4; - if ( !a4 ) - v29 = pParty->sEyelevel; - v28 = pParty->vPosition.z + v29; - a4 = v28; } case OBJECT_Decoration: { @@ -1872,12 +1852,6 @@ v14 = pLevelDecorations[v12].vPosition.z; outy = v13; outz = v14; - 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: @@ -1885,9 +1859,6 @@ outz = 0; outy = 0; outx = 0; - a4 = 0; - v44 = 0.0; - v45 = 0.0; break; } case OBJECT_BModel: @@ -1900,7 +1871,63 @@ v11 = (v10->pBounding.z1 + v10->pBounding.z2) >> 1; outz = v11; } - else if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + break; + } + } + v20 = v6; + v21 = PID_TYPE(v6); + v22 = PID_ID(v20); + switch(v6) + { + 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; @@ -1912,6 +1939,7 @@ break; } } + v31 = (double)SLODWORD(v45) - (double)outx; v42 = v31; v32 = (double)SLODWORD(v44) - (double)outy; @@ -2037,7 +2065,7 @@ } //----- (00403C6C) -------------------------------------------------------- -void Actor::_403C6C(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0) +void Actor::MeleeAttack(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0) { Actor *v3; // ebx@1 char v4; // zf@1 @@ -2133,7 +2161,7 @@ v3->UpdateAnimation(); } else - Actor::_402AD7(v24, sTargetPid, rand() % 2, 64, arg0); + Actor::Pursue1(v24, sTargetPid, rand() % 2, 64, arg0); } //----- (00438CF3) -------------------------------------------------------- @@ -2215,7 +2243,7 @@ __int16 v9; // [sp-4h] [bp-8h]@3 result = a2 - 1; - v4 = PID(uActorID,OBJECT_Actor); + v4 = PID(OBJECT_Actor,uActorID); switch ( a2 ) { case 1: @@ -2266,42 +2294,42 @@ v9 = 4; v8 = 65536; v7 = 0; - v6 = PID(uActorID,OBJECT_Actor); + v6 = PID(OBJECT_Actor,uActorID); v5 = 901; goto LABEL_16; case 6: v9 = 4; v8 = 65536; v7 = 0; - v6 = PID(uActorID,OBJECT_Actor); + v6 = PID(OBJECT_Actor,uActorID); v5 = 902; goto LABEL_16; case 7: v9 = 4; v8 = 65536; v7 = 0; - v6 = PID(uActorID,OBJECT_Actor); + v6 = PID(OBJECT_Actor,uActorID); v5 = 903; goto LABEL_16; case 8: v9 = 4; v8 = 65536; v7 = 0; - v6 = PID(uActorID,OBJECT_Actor); + v6 = PID(OBJECT_Actor,uActorID); v5 = 900; goto LABEL_16; case 9: v9 = 4; v8 = 65536; v7 = 0; - v6 = PID(uActorID,OBJECT_Actor); + v6 = PID(OBJECT_Actor,uActorID); v5 = 909; goto LABEL_16; case 10: v9 = 4; v8 = 65536; v7 = 0; - v6 = PID(uActorID,OBJECT_Actor); + v6 = PID(OBJECT_Actor,uActorID); v5 = 908; LABEL_16: result = pOtherOverlayList->_4418B6(v5, v6, v7, v8, v9); @@ -2439,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 @@ -2497,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; @@ -2541,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 sTargetPid, AIDirection *pDir) +void Actor::SpellAttack1(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) { Actor *v3; // ebx@1 AIDirection *v4; // esi@3 @@ -2603,7 +2631,7 @@ v10 = 0; if ( !pDir ) { - v11 = Actor::GetDirectionInfo(8 * v22 | OBJECT_Actor, sTargetPid, &a3, 0); + v11 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v22), sTargetPid, &a3, 0); v9 = &v18; memcpy(&v18, v11, sizeof(v18)); v10 = 0; @@ -2647,11 +2675,11 @@ v3->UpdateAnimation(); } else - Actor::_402AD7(v22, sTargetPid, v22, 64, pDir); + Actor::Pursue1(v22, sTargetPid, v22, 64, pDir); } //----- (0040368B) -------------------------------------------------------- -void Actor::_40368B(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) +void Actor::MissileAttack2(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) { Actor *v3; // ebx@1 AIDirection *v4; // esi@3 @@ -2708,7 +2736,7 @@ v10 = 0; if ( !pDir ) { - v11 = Actor::GetDirectionInfo(8 * v21 | OBJECT_Actor, sTargetPid, &a3, 0); + v11 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v21), sTargetPid, &a3, 0); v9 = &v17; memcpy(&v17, v11, sizeof(v17)); v10 = 0; @@ -2738,11 +2766,11 @@ v3->UpdateAnimation(); } else - Actor::_402AD7(v21, sTargetPid, v21, 64, pDir); + Actor::Pursue1(v21, sTargetPid, v21, 64, pDir); } //----- (00403476) -------------------------------------------------------- -void Actor::_403476(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) +void Actor::MissileAttack1(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) { Actor *v3; // ebx@1 int v4; // esi@3 @@ -2808,7 +2836,7 @@ v11 = 0; if ( !pDir ) { - v12 = Actor::GetDirectionInfo(8 * v21 | OBJECT_Actor, sTargetPid, &a3, 0); + v12 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v21), sTargetPid, &a3, 0); v10 = &v18; memcpy(&v18, v12, sizeof(v18)); v11 = 0; @@ -2842,7 +2870,7 @@ v3->UpdateAnimation(); } else - Actor::_402AD7(v21, sTargetPid, v21, 64, pDir); + Actor::Pursue1(v21, sTargetPid, v21, 64, pDir); } //----- (004032B2) -------------------------------------------------------- @@ -2982,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 @@ -3018,7 +3046,7 @@ && v4->uAIState != 18 && v4->uAIState != 2)) { - memcpy(&v10, Actor::GetDirectionInfo(PID(v3,OBJECT_Actor), 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; @@ -3042,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; @@ -3207,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 @@ -3228,7 +3256,7 @@ v6 = 0; v7 = &pActors[uActorID]; v18 = a2; - v8 = PID(uActorID,OBJECT_Actor); + v8 = PID(OBJECT_Actor,uActorID); v9 = v7->pMonsterInfo.uFlying == 0; v17 = v5; if ( !v9 && !pParty->bFlying ) @@ -3288,7 +3316,7 @@ } //----- (00402968) -------------------------------------------------------- -void Actor::_402968(unsigned int uActorID, signed int sTargetPid, 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 @@ -3311,8 +3339,8 @@ //result = pActors[uActorID].CanAct(); if ( pActors[uActorID].CanAct() ) { - v7 = PID(v4,OBJECT_Actor); - a1 = PID(v4,OBJECT_Actor); + v7 = PID(OBJECT_Actor,v4); + a1 = PID(OBJECT_Actor,v4); if ( !a4 ) { a4 = &v12; @@ -3349,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 @@ -3371,7 +3399,7 @@ v6 = 0; v7 = &pActors[uActorID]; v19 = a2; - v8 = PID(uActorID,OBJECT_Actor); + v8 = PID(OBJECT_Actor,uActorID); v9 = v7->pMonsterInfo.uFlying == 0; v20 = v5; if ( !v9 && !pParty->bFlying ) @@ -3432,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 @@ -3447,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 = PID(uActorID,OBJECT_Actor); + v7 = PID(OBJECT_Actor,uActorID); v8 = v6->pMonsterInfo.uFlying == 0; - v22 = v4; if ( !v8 && !pParty->bFlying ) { if ( v6->pMonsterInfo.uMissleAttack1Type && uCurrentlyLoadedLevelType == LEVEL_Outdoor ) @@ -3467,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 ) { @@ -3501,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(); } @@ -3578,7 +3594,7 @@ actor->uAIState == Removed || actor->uAIState == Summoned || actor->uAIState == Disabled || uActorID == i ) continue; - if (_this->uLastCharacterIDToHit == 0 || (v9 = 8 * v5, LOBYTE(v9) = PID(v5,OBJECT_Actor), _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 ) @@ -3624,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); } @@ -4063,7 +4079,7 @@ if ( v23->uAttributes & 0x80000 ) v8->uAttributes |= 0x80000u; result = 8 * v24; - LOBYTE(result) = PID(v24,OBJECT_Actor); + LOBYTE(result) = PID(OBJECT_Actor,v24); v8->uSummonerID = result; } return result; diff -r cd355e4c6104 -r 4568f1e4d61b Actor.h --- a/Actor.h Mon Apr 01 18:52:06 2013 +0600 +++ b/Actor.h Mon Apr 01 18:52:19 2013 +0600 @@ -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 sTargetPid, struct AIDirection *pDir); - static void _40368B(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir); - static void _403854(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir); - static void _403A60(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir); - static void _403C6C(unsigned int uActorID, signed int sTargetPid, 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); diff -r cd355e4c6104 -r 4568f1e4d61b GUIWindow.cpp --- a/GUIWindow.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/GUIWindow.cpp Mon Apr 01 18:52:19 2013 +0600 @@ -1028,12 +1028,7 @@ 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 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 + char *pTitleText; // [sp-8h] [bp-C0h]@50 GUIWindow pDialogWindow; // [sp+Ch] [bp-ACh]@4 GUIWindow pWindow; // [sp+60h] [bp-58h]@2 int pColor2; // [sp+B4h] [bp-4h]@2 @@ -1051,10 +1046,7 @@ { pDialogWindow.uFrameWidth = 130; pDialogWindow.uFrameHeight = 2 * LOBYTE(pFontCreate->uFontHeight); - - //v2 = (const char *)p2DEvents_minus1_::04[13 * (unsigned int)ptr_507BC0->ptr_1C]; pHouseName = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].pName; - if ( pHouseName ) { v3 = 2 * LOBYTE(pFontCreate->uFontHeight) - 6 - pFontCreate->CalcTextHeight(pHouseName, &pDialogWindow, 0, 0); @@ -1095,7 +1087,6 @@ 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 ) { if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) @@ -1109,59 +1100,44 @@ } return; } - while ( 1 ) + for ( v8 = 0; v8 < uNumDialogueNPCPortraits; ++v8 ) { - //pRenderer->DrawTextureIndexed(*(&pNPCPortraits_x + v8 + 6 * uNumDialogueNPCPortraits - 6) - 4, - // *(&pNPCPortraits_y + v8 + 6 * uNumDialogueNPCPortraits - 6) - 4, pRenderer->DrawTextureIndexed(pNPCPortraits_x[uNumDialogueNPCPortraits - 1][v8] - 4, - pNPCPortraits_y[uNumDialogueNPCPortraits - 1][v8] - 4, &pIcons_LOD->pTextures[uTextureID_50795C]); // frame around portrait - //pRenderer->DrawTextureIndexed(*(&pNPCPortraits_x + v8 + 6 * uNumDialogueNPCPortraits - 6), - // *(&pNPCPortraits_y + v8 + 6 * uNumDialogueNPCPortraits - 6), pDialogueNPCPortraits[v8]); + pNPCPortraits_y[uNumDialogueNPCPortraits - 1][v8] - 4, &pIcons_LOD->pTextures[uTextureID_50795C]); pRenderer->DrawTextureIndexed(pNPCPortraits_x[uNumDialogueNPCPortraits - 1][v8], pNPCPortraits_y[uNumDialogueNPCPortraits - 1][v8], pDialogueNPCPortraits[v8]); if ( uNumDialogueNPCPortraits < 4 ) - break; -LABEL_57: - ++v8; - if ( v8 >= uNumDialogueNPCPortraits ) - //goto LABEL_58; { - if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) + if ( v8 + 1 == 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]); + pTitleText = pMapStats->pInfos[uHouse_ExitPic].pName; + v9 = 94 * v8 + 113; } else { - pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uExitCancelTextureId]); + if ( !v8 && dword_591080 ) + { + pTitleText = (char *)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].pProprieterTitle; + pWindow.DrawTitleText(pFontCreate, 0x1E3u, 113, pColor2, pTitleText, 3); + continue; + } + pTitleText = HouseNPCData[v8 - (dword_591080 != 0)]->pName; + v9 = pNPCPortraits_x[6 + (uNumDialogueNPCPortraits - 1)][v8] + pDialogueNPCPortraits[v8]->uTextureHeight + 2; } - return; + v10 = v9; + pWindow.DrawTitleText(pFontCreate, 0x1E3u, v10, pColor2, pTitleText, 3); } } - if ( v8 + 1 == uNumDialogueNPCPortraits && uHouse_ExitPic ) - { - v15 = 3; - v13 = pMapStats->pInfos[uHouse_ExitPic].pName; - v9 = 94 * v8 + 113; - } - else - { - if ( !v8 && dword_591080 ) + if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) { - 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; - pWindow.DrawTitleText(pFontCreate, 0x1E3u, 113, pColor2, v13, 3); - goto LABEL_57; + pRenderer->DrawTextureIndexed(556, 451, &pIcons_LOD->pTextures[uTextureID_x_x_u]); + pRenderer->DrawTextureIndexed(476, 451, &pIcons_LOD->pTextures[uTextureID_x_ok_u]); } - v15 = 3; - v13 = HouseNPCData[(v8 +1) - (dword_591080 != 0)]->pName; - v9 = pNPCPortraits_x[6 + (uNumDialogueNPCPortraits - 1)][v8] + pDialogueNPCPortraits[v8]->uTextureHeight + 2; - } - //v11 = pColor2; - v10 = v9; - pWindow.DrawTitleText(pFontCreate, 0x1E3u, v10, pColor2, v13, v15); - goto LABEL_57; + else + { + pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uExitCancelTextureId]); + } + return; } v4 = (char *)pDialogueNPCCount - 1; pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, &pIcons_LOD->pTextures[uTextureID_50795C]); @@ -1169,7 +1145,6 @@ if ( pCurrentScreen == SCREEN_E ) { CharacterUI_InventoryTab_Draw(uActiveCharacter, 1); - //goto LABEL_58; if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) { pRenderer->DrawTextureIndexed(556, 451, &pIcons_LOD->pTextures[uTextureID_x_x_u]); @@ -1246,7 +1221,6 @@ break; } } -//LABEL_58: if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) { pRenderer->DrawTextureIndexed(556, 451, &pIcons_LOD->pTextures[uTextureID_x_x_u]); @@ -1258,7 +1232,6 @@ } } - //----- (004B1854) -------------------------------------------------------- void GUIWindow::DrawCurrentTime( __int64 a2 ) { @@ -1960,32 +1933,29 @@ v26 = 0; if ( uNumDialogueNPCPortraits > 0 ) { - do + for ( v26 = 0; v26 < uNumDialogueNPCPortraits; ++v26 ) { - uWidtha = v26 + 1; if ( v26 + 1 == v25 && uHouse_ExitPic ) { v30 = pMapStats->pInfos[uHouse_ExitPic].pName; - v29 = (char*)pGlobalTXT_LocalizationStrings[LOCSTR_ENTER_S];// ^Pv[%s] + v29 = (char*)pGlobalTXT_LocalizationStrings[LOCSTR_ENTER_S]; } else { if ( v26 || !dword_591080 ) - v27 = HouseNPCData[(v26 +1) - (dword_591080 != 0)]->pName; + v27 = HouseNPCData[v26 - (dword_591080 != 0)]->pName; else //v27 = (char *)p2DEvents_minus1_::08[13 * a4]; v27 = (char *)p2DEvents[pButton - 1].pProprieterName; v30 = v27; - v29 = (char*)pGlobalTXT_LocalizationStrings[435];// "Converse with %s" ^Pt[%s] + v29 = (char*)pGlobalTXT_LocalizationStrings[435]; } sprintfex(byte_591180[v26], v29, v30); HouseNPCData[v26 + 7] = (NPCData *)pWindow->CreateButton(pNPCPortraits_x[uNumDialogueNPCPortraits - 1][v26], pNPCPortraits_y[uNumDialogueNPCPortraits - 1][v26], 0x3Fu, 0x49u, 1, 0, UIMSG_19A, v26, 0, byte_591180[v26], 0, 0, 0); - ++v26; v25 = uNumDialogueNPCPortraits; } - while ( uWidtha < uNumDialogueNPCPortraits ); } if ( v25 == 1 ) { diff -r cd355e4c6104 -r 4568f1e4d61b Game.cpp --- a/Game.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/Game.cpp Mon Apr 01 18:52:19 2013 +0600 @@ -672,7 +672,7 @@ { v11 = &vis_face_filter; v10 = &vis_sprite_filter_2; - depth = GetPickDepth(); + depth = pGame->pIndoorCameraD3D->GetPickDepth(); } else { diff -r cd355e4c6104 -r 4568f1e4d61b Indoor.cpp --- a/Indoor.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/Indoor.cpp Mon Apr 01 18:52:19 2013 +0600 @@ -373,8 +373,8 @@ _this.field_0_timer = pEventTimer->uTotalGameTimeElapsed; _this.field_1C_mb_fov = 65; - _this.vPosition.x = pParty->vPosition.x - fixpoint_mul(stru_5C6E00->Cos(pParty->sRotationY), pParty->y_rotation_granularity); - _this.vPosition.y = pParty->vPosition.y - fixpoint_mul(stru_5C6E00->Sin(pParty->sRotationY), pParty->y_rotation_granularity); + _this.vPosition.x = pParty->vPosition.x - fixpoint_sub0(stru_5C6E00->Cos(pParty->sRotationY), pParty->y_rotation_granularity); + _this.vPosition.y = pParty->vPosition.y - fixpoint_sub0(stru_5C6E00->Sin(pParty->sRotationY), pParty->y_rotation_granularity); _this.vPosition.z = pParty->vPosition.z + pParty->sEyelevel; _this.sRotationX = pParty->sRotationX; _this.sRotationY = pParty->sRotationY; @@ -3171,16 +3171,16 @@ HIDWORD(v33) = v32 >> 16;*/ //fixpoint_div(v1->x - v2->x, v1->y - v2->y); //_a58 = v33 / (v1->y - v2->y); - //_a59 = fixpoint_mul(_a58, sY - v2->y); + //_a59 = fixpoint_sub0(_a58, sY - v2->y); auto x_div_y = fixpoint_div(v1->x - v2->x, v1->y - v2->y); - auto res = fixpoint_mul(x_div_y, sY - v2->y); // a / b * c - looks like projection + auto res = fixpoint_sub0(x_div_y, sY - v2->y); // a / b * c - looks like projection if (res + v2->x > sX) ++v54; } else { auto x_div_y = fixpoint_div(v2->x - v1->x, v2->y - v1->y); - auto res = fixpoint_mul(x_div_y, sY - v1->y); + auto res = fixpoint_sub0(x_div_y, sY - v1->y); if (res + v1->x > sX) ++v54; @@ -3191,7 +3191,7 @@ LODWORD(v33) = v32 << 16; HIDWORD(v33) = v32 >> 16; _a58 = v33 / (v2->y - v1->y); - _a59 = fixpoint_mul(_a58, sY - v1->y); + _a59 = fixpoint_sub0(_a58, sY - v1->y); if (_a59 + pVertices[k].x > sX) ++v54;*/ @@ -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, PID(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) = PID(v63,OBJECT_Actor); + LOBYTE(v24) = PID(OBJECT_Actor,v63); v61 = v22; _this = v24; do @@ -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; } } diff -r cd355e4c6104 -r 4568f1e4d61b IndoorCameraD3D.cpp --- a/IndoorCameraD3D.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/IndoorCameraD3D.cpp Mon Apr 01 18:52:19 2013 +0600 @@ -94,6 +94,17 @@ //v1->vdestructor_ptr = &stru8_pvdtor; } + +//----- (0043643E) -------------------------------------------------------- +float IndoorCameraD3D::GetPickDepth() +{ + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + return pOutdoorCamera->uPickDepth; + else + return 16192.0; +} + + //----- (004364C5) -------------------------------------------------------- void IndoorCameraD3D::ViewTransfrom_OffsetUV(RenderVertexSoft *pVertices, unsigned int uNumVertices, RenderVertexSoft *pOutVertices, stru320 *a5) { diff -r cd355e4c6104 -r 4568f1e4d61b IndoorCameraD3D.h --- a/IndoorCameraD3D.h Mon Apr 01 18:52:06 2013 +0600 +++ b/IndoorCameraD3D.h Mon Apr 01 18:52:19 2013 +0600 @@ -157,6 +157,7 @@ bool IsCulled(struct BLVFace *pFace); void ViewTransfrom_OffsetUV(struct RenderVertexSoft *pVertices, unsigned int uNumVertices, struct RenderVertexSoft *pOutVertices, struct stru320 *a5); char ApplyViewTransform_TrueIfStillVisible(int x, int y, int z, signed int *pOutX, int *pOutZ, int *pOutY, char bDoNotShow); + float GetPickDepth(); void DebugDrawPortal(struct BLVFace *pFace); diff -r cd355e4c6104 -r 4568f1e4d61b Outdoor.cpp --- a/Outdoor.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/Outdoor.cpp Mon Apr 01 18:52:19 2013 +0600 @@ -92,8 +92,8 @@ pIndoorCamera->sRotationX = pParty->sRotationX; pIndoorCamera->sRotationY = pParty->sRotationY; - pIndoorCamera->pos.x = pParty->vPosition.x - fixpoint_mul(stru_5C6E00->Cos(pParty->sRotationY), pParty->y_rotation_granularity); - pIndoorCamera->pos.y = pParty->vPosition.y - fixpoint_mul(stru_5C6E00->Sin(pParty->sRotationY), pParty->y_rotation_granularity); + pIndoorCamera->pos.x = pParty->vPosition.x - fixpoint_sub0(stru_5C6E00->Cos(pParty->sRotationY), pParty->y_rotation_granularity); + pIndoorCamera->pos.y = pParty->vPosition.y - fixpoint_sub0(stru_5C6E00->Sin(pParty->sRotationY), pParty->y_rotation_granularity); pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel; if (bRedraw || pRenderer->pRenderD3D) { @@ -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 diff -r cd355e4c6104 -r 4568f1e4d61b ParticleEngine.cpp --- a/ParticleEngine.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/ParticleEngine.cpp Mon Apr 01 18:52:19 2013 +0600 @@ -68,20 +68,20 @@ v4->flt_18 = a2->flt_18; v5 = a2->uDiffuse; v4->uParticleColor = v5; - v4->uLightColor = v5; + v4->uLightColor_bgr = v5; //v6 = (v4->uType & 4) == 0; v4->timeToLive = a2->timeToLive; v4->uTextureID = a2->uTextureID; v4->flt_28 = a2->flt_28; if (v4->type & ParticleType_Rotating) { - v4->field_38 = (unsigned __int8)rand() - 128; - v4->_rotation = rand(); + v4->rotation_speed = (rand() % 256) - 128; + v4->angle = rand(); } else { - v4->field_38 = 0; - v4->_rotation = 0; + v4->rotation_speed = 0; + v4->angle = 0; } } } @@ -117,12 +117,12 @@ void ParticleEngine::UpdateParticles() { unsigned int time; // edi@1 - int v5; // eax@3 - char v6; // sf@4 + //int v5; // eax@3 + //char v6; // sf@4 float v7; // ST4C_4@11 double v8; // st7@12 - int v9; // eax@12 - double v10; // st7@14 + //int v9; // eax@12 + //double v10; // st7@14 signed int v19; // [sp+38h] [bp-14h]@1 int v20; // [sp+3Ch] [bp-10h]@1 unsigned int time_; // [sp+40h] [bp-Ch]@1 @@ -133,29 +133,32 @@ v19 = 500; time_ = pMiscTimer->bPaused == 0 ? pEventTimer->uTimeElapsed : 0; - for (uint i = uStartParticle; i < uEndParticle; ++i) + for (uint i = uStartParticle; i <= uEndParticle; ++i) { auto p = pParticles + i; - v5 = p->type; if (p->type == ParticleType_Invalid) continue; - v6 = (p->timeToLive - time) < 0; + if (p->timeToLive <= time) + { + p->timeToLive = 0; + p->type = ParticleType_Invalid; + continue; + } p->timeToLive -= time; - if (v6) - p->type = ParticleType_Invalid; - else - { - if ( BYTE1(v5) & 2 ) + + if (p->type & ParticleType_Line) { p->_x = p->x; p->_y = p->y; p->_z = p->z; } - if ( v5 & 1 ) + + if (p->type & ParticleType_1) p->flt_18 = p->flt_18 - (double)(signed int)time_ * 5.0; - if ( v5 & 8 ) + + if (p->type & ParticleType_8) { v7 = (double)(signed int)time_; *(float *)&p->x += (double)(rand() % 5 - 2) * v7 / 16.0f; @@ -163,23 +166,24 @@ *(float *)&p->z += (double)(rand() % 5 + 4) * v7 / 16.0f; } v8 = (double)(signed int)time_ / 128.0f; - v9 = (signed int)(time * p->field_38) / 16; - *(float *)&p->x += v8 * p->flt_10; - *(float *)&p->y += v8 * p->flt_14; - *(float *)&p->z += v8 * p->flt_18; - p->_rotation += v9; + //v9 = (signed int)(time * p->rotation_speed) / 16; + + p->x += v8 * p->flt_10; + p->y += v8 * p->flt_14; + p->z += v8 * p->flt_18; + + p->angle += time * p->rotation_speed / 16; v22 = 2 * p->timeToLive; - if ( 2 * p->timeToLive >= 255 ) + if (v22 >= 255 ) v22 = 255; - v10 = (double)v22 * 0.0039215689; - p->uLightColor = (uint)floorf(p->b + 0.5) | - ((uint)floorf(p->g + 0.5) << 8) | - ((uint)floorf(p->r + 0.5) << 16); + //v10 = (double)v22 * 0.0039215689; + p->uLightColor_bgr = ((uint)floorf(p->b * (v22 / 255.0f) + 0.5) << 16) | + ((uint)floorf(p->g * (v22 / 255.0f) + 0.5) << 8) | + ((uint)floorf(p->r * (v22 / 255.0f) + 0.5) << 0); if ( i < v19 ) v19 = i; if ( i > v20 ) v20 = i; - } } uEndParticle = v20; @@ -187,12 +191,12 @@ } //----- (0048AE74) -------------------------------------------------------- -bool ParticleEngine::ViewProject_TrueIfStillVisible(unsigned int uParticleID) +bool ParticleEngine::ViewProject_TrueIfStillVisible_BLV(unsigned int uParticleID) { Particle *pParticle; // esi@1 //double v56; // ST28_8@2 - float v4; // eax@4 - double v5; // ST34_8@4 + //float v4; // eax@4 + //double v5; // ST34_8@4 signed __int64 v6; // qtt@4 //double v7; // st7@4 //float v8; // ST18_4@4 @@ -202,7 +206,7 @@ //double v12; // ST4C_8@7 double v13; // ST4C_8@7 int v14; // ecx@7 - signed __int64 v15; // qtt@7 + //signed __int64 v15; // qtt@7 int v16; // eax@7 int v17; // edx@7 float v18; // edx@7 @@ -212,21 +216,21 @@ int v22; // ebx@8 int v23; // ecx@10 int v24; // edi@10 - double v25; // ST44_8@12 - double v26; // ST4C_8@12 + //double v25; // ST44_8@12 + //double v26; // ST4C_8@12 int v27; // edi@12 int v28; // ST40_4@12 int v29; // ecx@12 - signed __int64 v30; // qtt@12 + //signed __int64 v30; // qtt@12 int v31; // eax@12 int v32; // edx@12 float v33; // edx@12 - int v34; // eax@12 + //int v34; // eax@12 int v35; // ecx@12 int v36; // ST38_4@13 int v37; // ST30_4@15 int v38; // eax@16 - signed __int64 v40; // qtt@18 + //signed __int64 v40; // qtt@18 int v41; // eax@18 int v42; // ecx@18 int v43; // eax@18 @@ -278,9 +282,10 @@ v14 = z; HIDWORD(v13) = (unsigned __int64)(SHIDWORD(a5) * (signed __int64)pBLVRenderParams->sSineNegX) >> 16; HIDWORD(a5) = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16; - LODWORD(v15) = pBLVRenderParams->field_40 << 16; - HIDWORD(v15) = pBLVRenderParams->field_40 >> 16; - v16 = v15 / z; + //LODWORD(v15) = pBLVRenderParams->field_40 << 16; + //HIDWORD(v15) = pBLVRenderParams->field_40 >> 16; + //v16 = v15 / z; + v16 = fixpoint_div(pBLVRenderParams->field_40, z); v17 = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16; pParticle->_screenspace_scale = v16; _uParticleID = (unsigned __int64)(v16 * (signed __int64)(a6 + v17)) >> 16; @@ -315,30 +320,27 @@ { if (pParticle->type & ParticleType_Line) { - v25 = pParticle->_x + 6.7553994e15; - int _uParticleID = (LODWORD(v25) - pBLVRenderParams->vPartyPos.x) << 16; - v26 = pParticle->_y + 6.7553994e15; - y = (LODWORD(v26) - pBLVRenderParams->vPartyPos.y) << 16; - HIDWORD(v25) = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sSineY) >> 16; - v27 = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - - HIDWORD(v25); - z = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - - HIDWORD(v25); + //v25 = pParticle->_x + 6.7553994e15; + int _uParticleID = ((int)floorf(pParticle->_x + 0.5f) - pBLVRenderParams->vPartyPos.x) << 16; + //v26 = pParticle->_y + 6.7553994e15; + y = ((int)floorf(pParticle->_y + 0.5f) - pBLVRenderParams->vPartyPos.y) << 16; + auto _hiword_v25 = (__int64)(y * (signed __int64)pBLVRenderParams->sSineY) >> 16; + v27 = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - _hiword_v25; + z = ((unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - _hiword_v25; v28 = (unsigned __int64)((signed int)_uParticleID * (signed __int64)pBLVRenderParams->sSineY) >> 16; - a5 = pParticle->_z + 6.7553994e15; - v29 = (LODWORD(a5) - pBLVRenderParams->vPartyPos.z) << 16; - LODWORD(v30) = pBLVRenderParams->field_40 << 16; - HIDWORD(v30) = pBLVRenderParams->field_40 >> 16; - v31 = v30 / z; + //a5 = pParticle->_z + 6.7553994e15; + v29 = ((int)floorf(pParticle->_z + 0.5f) - pBLVRenderParams->vPartyPos.z) << 16; + //LODWORD(v30) = pBLVRenderParams->field_40 << 16; + //HIDWORD(v30) = pBLVRenderParams->field_40 >> 16; + //v31 = v30 / z; + v31 = fixpoint_div(pBLVRenderParams->field_40, z); v32 = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16; pParticle->_screenspace_scale = v31; _uParticleID = (unsigned __int64)(v31 * (signed __int64)(v28 + v32)) >> 16; - LODWORD(v33) = pBLVRenderParams->uViewportCenterX - - ((signed int)((unsigned __int64)(v31 * (signed __int64)(v28 + v32)) >> 16) >> 16); - v34 = pParticle->_screenspace_scale; + LODWORD(v33) = pBLVRenderParams->uViewportCenterX - ((signed int)((unsigned __int64)(v31 * (signed __int64)(v28 + v32)) >> 16) >> 16); + //v34 = pParticle->_screenspace_scale; pParticle->uScreenSpaceZ = v33; - v35 = pBLVRenderParams->uViewportCenterY - - ((signed int)((unsigned __int64)(v34 * (signed __int64)v29) >> 16) >> 16); + v35 = pBLVRenderParams->uViewportCenterY - ((signed int)((unsigned __int64)(pParticle->_screenspace_scale * (signed __int64)v29) >> 16) >> 16); pParticle->sZValue2 = v27; pParticle->uScreenSpaceW = v35; } @@ -359,9 +361,9 @@ v38 = abs(v22); if ( v38 >= (signed int)_uParticleID ) { - LODWORD(v40) = pBLVRenderParams->field_40 << 16; - HIDWORD(v40) = pBLVRenderParams->field_40 >> 16; - v41 = v40 / z; + //LODWORD(v40) = pBLVRenderParams->field_40 << 16; + //HIDWORD(v40) = pBLVRenderParams->field_40 >> 16; + v41 = fixpoint_div(pBLVRenderParams->field_40, z); pParticle->_screenspace_scale = v41; _uParticleID = (unsigned __int64)(v41 * (signed __int64)a2) >> 16; v42 = pBLVRenderParams->uViewportCenterX - ((signed int)((unsigned __int64)(v41 * (signed __int64)a2) >> 16) >> 16); @@ -395,11 +397,11 @@ return false; pGame->pIndoorCameraD3D->Project(x, y, z, &pParticle->uScreenSpaceX, &pParticle->uScreenSpaceY); pParticle->flt_5C = pGame->pIndoorCameraD3D->fov_x; - v4 = pParticle->flt_5C; + //v4 = pParticle->flt_5C; pParticle->flt_60 = pGame->pIndoorCameraD3D->fov_y; - v5 = v4 + 6.7553994e15; + //v5 = v4 + 6.7553994e15; LODWORD(v6) = 0; - HIDWORD(v6) = SLOWORD(v5); + HIDWORD(v6) = floorf(pParticle->flt_5C + 0.5f); //v7 = pParticle->flt_28; pParticle->_screenspace_scale = v6 / x; //v8 = v7; @@ -412,151 +414,144 @@ //----- (0048B5B3) -------------------------------------------------------- -bool ParticleEngine::_48B5B3(unsigned int uID) +bool ParticleEngine::ViewProject_TrueIfStillVisible_ODM(unsigned int uID) { - ParticleEngine *v2; // ST18_4@1 + //ParticleEngine *v2; // ST18_4@1 int v3; // ebx@1 int v4; // edi@1 int v5; // ecx@1 Particle *v6; // esi@1 - double v7; // ST14_8@2 - double v8; // ST34_8@4 - double v9; // ST3C_8@4 - int v10; // ST50_4@4 + //double v7; // ST14_8@2 + //double v8; // ST34_8@4 + //double v9; // ST3C_8@4 + //int v10; // ST50_4@4 int v11; // ST44_4@4 - double v12; // ST48_8@4 + //double v12; // ST48_8@4 signed __int64 v13; // qtt@4 - int v14; // eax@4 - int v15; // ST28_4@4 + //int v14; // eax@4 + //int v15; // ST28_4@4 int v16; // edi@6 int v17; // eax@6 - double v18; // ST2C_8@8 - double v19; // ST34_8@8 - int v20; // ST50_4@8 - double v21; // ST34_8@8 + //double v18; // ST2C_8@8 + //double v19; // ST34_8@8 + //int v20; // ST50_4@8 + //double v21; // ST34_8@8 signed __int64 v22; // qtt@8 - int v23; // eax@8 - int v24; // ST28_4@8 - int v25; // edx@8 + //int v23; // eax@8 + //int v24; // ST28_4@8 + //int v25; // edx@8 int v26; // edx@9 - int v27; // eax@9 + //int v27; // eax@9 int v28; // ebx@12 signed __int64 v29; // qtt@13 - int v30; // eax@13 - int v31; // ST1C_4@13 + //int v30; // eax@13 + //int v31; // ST1C_4@13 double v32; // st7@13 signed int v33; // eax@13 int v34; // ecx@13 float v35; // ST04_4@13 int v36; // eax@13 int v37; // esi@15 - double v39; // [sp+10h] [bp-40h]@2 + //double v39; // [sp+10h] [bp-40h]@2 int v40; // [sp+14h] [bp-3Ch]@12 - int v41; // [sp+1Ch] [bp-34h]@2 - double v42; // [sp+20h] [bp-30h]@2 - int v43; // [sp+24h] [bp-2Ch]@5 + //int v41; // [sp+1Ch] [bp-34h]@2 + //double v42; // [sp+20h] [bp-30h]@2 + //int v43; // [sp+24h] [bp-2Ch]@5 int v44; // [sp+2Ch] [bp-24h]@1 int v45; // [sp+40h] [bp-10h]@5 int X_4; // [sp+48h] [bp-8h]@5 - int v47; // [sp+4Ch] [bp-4h]@5 - int v48; // [sp+4Ch] [bp-4h]@9 - int uIDc; // [sp+58h] [bp+8h]@4 - int uIDd; // [sp+58h] [bp+8h]@4 - int uIDe; // [sp+58h] [bp+8h]@5 - int uIDa; // [sp+58h] [bp+8h]@5 - int uIDf; // [sp+58h] [bp+8h]@8 - int uIDb; // [sp+58h] [bp+8h]@9 + //int v47; // [sp+4Ch] [bp-4h]@5 + //int v48; // [sp+4Ch] [bp-4h]@9 + //int uIDc; // [sp+58h] [bp+8h]@4 + //int uIDd; // [sp+58h] [bp+8h]@4 + //int uIDe; // [sp+58h] [bp+8h]@5 + //int uIDa; // [sp+58h] [bp+8h]@5 + //int uIDf; // [sp+58h] [bp+8h]@8 + //int uIDb; // [sp+58h] [bp+8h]@9 - v2 = this; v3 = stru_5C6E00->Cos(pIndoorCamera->sRotationX); v44 = stru_5C6E00->Sin(pIndoorCamera->sRotationX); v4 = stru_5C6E00->Cos(pIndoorCamera->sRotationY); v5 = stru_5C6E00->Sin(pIndoorCamera->sRotationY); - v6 = &v2->pParticles[uID]; - if (v6->type != ParticleType_Invalid) - { - v7 = v6->x + 6.7553994e15; - v41 = LODWORD(v7); - v39 = v6->y + 6.7553994e15; - v42 = v6->z + 6.7553994e15; + + v6 = &pParticles[uID]; + if (v6->type == ParticleType_Invalid) + return false; + + //v7 = v6->x + 6.7553994e15; + //v41 = LODWORD(v7); + //v39 = v6->y + 6.7553994e15; + //v42 = v6->z + 6.7553994e15; if ( v3 ) { if (v6->type & ParticleType_Line) { - v8 = v6->_x + 6.7553994e15; - uIDc = (LODWORD(v8) - pIndoorCamera->pos.x) << 16; - v9 = v6->_y + 6.7553994e15; - v10 = (LODWORD(v9) - pIndoorCamera->pos.y) << 16; - v11 = ((unsigned __int64)(uIDc * (signed __int64)v4) >> 16) - + ((unsigned __int64)(v10 * (signed __int64)v5) >> 16); - HIDWORD(v8) = (unsigned __int64)(uIDc * (signed __int64)v5) >> 16; - v12 = v6->_z + 6.7553994e15; - uIDd = (LODWORD(v12) - pIndoorCamera->pos.z) << 16; - HIDWORD(v12) = ((unsigned __int64)(v11 * (signed __int64)v3) >> 16) - + ((unsigned __int64)(uIDd * (signed __int64)v44) >> 16); + //v8 = v6->_x + 6.7553994e15; + //uIDc = (LODWORD(v8) - pIndoorCamera->pos.x) << 16; + //v9 = v6->_y + 6.7553994e15; + //v10 = (LODWORD(v9) - pIndoorCamera->pos.y) << 16; + v11 = fixpoint_mul(v6->x - pIndoorCamera->pos.x, v4) + fixpoint_mul(v6->y - pIndoorCamera->pos.y, v5); + //HIDWORD(v8) = fixpoint_mul(v6->x - pIndoorCamera->pos.x, v5); + //v12 = v6->_z + 6.7553994e15; + //uIDd = (LODWORD(v12) - pIndoorCamera->pos.z) << 16; + auto _hidword_v12 = fixpoint_sub0(v11, v3) + fixpoint_mul(v6->z - pIndoorCamera->pos.z, v44); LODWORD(v13) = 0; HIDWORD(v13) = SLOWORD(pOutdoorCamera->int_fov_rad); - v14 = v13 / SHIDWORD(v12); - v6->_screenspace_scale = v14; - v15 = v6->_screenspace_scale; + //v14 = v13 / _hidword_v12; + v6->_screenspace_scale = v13 / _hidword_v12; + //v15 = v6->_screenspace_scale; v6->uScreenSpaceX = pViewport->uScreenCenterX - - ((signed int)((unsigned __int64)(v14 - * (signed __int64)(signed int)(((unsigned __int64)(v10 * (signed __int64)v4) >> 16) - - HIDWORD(v8))) >> 16) >> 16); + - ((signed int)((unsigned __int64)(v6->_screenspace_scale + * (signed __int64)(fixpoint_mul(v6->y - pIndoorCamera->pos.y, v4) + - fixpoint_mul(v6->x - pIndoorCamera->pos.x, v5))) >> 16) >> 16); v6->uScreenSpaceY = pViewport->uScreenCenterY - - ((signed int)((unsigned __int64)(v15 - * (signed __int64)(signed int)(((unsigned __int64)(uIDd * (signed __int64)v3) >> 16) + - ((signed int)((unsigned __int64)(v6->_screenspace_scale + * (signed __int64)(fixpoint_mul(v6->z - pIndoorCamera->pos.z, v3) - ((unsigned __int64)(v11 * (signed __int64)v44) >> 16))) >> 16) >> 16); - v6->sZValue = HIDWORD(v12); + v6->sZValue = _hidword_v12; } - uIDe = (v41 - pIndoorCamera->pos.x) << 16; - v47 = (LODWORD(v39) - pIndoorCamera->pos.y) << 16; - v45 = ((unsigned __int64)(uIDe * (signed __int64)v4) >> 16) + ((unsigned __int64)(v47 * (signed __int64)v5) >> 16); - HIDWORD(v42) = (unsigned __int64)(uIDe * (signed __int64)v5) >> 16; - uIDa = (LODWORD(v42) - pIndoorCamera->pos.z) << 16; - X_4 = ((unsigned __int64)(uIDa * (signed __int64)v44) >> 16) - + ((unsigned __int64)(v45 * (signed __int64)v3) >> 16); - if ( X_4 < 262144 ) + //uIDe = (v41 - pIndoorCamera->pos.x) << 16; + //v47 = (LODWORD(v39) - pIndoorCamera->pos.y) << 16; + v45 = fixpoint_mul(v6->x - pIndoorCamera->pos.x, v4) + fixpoint_mul(v6->y - pIndoorCamera->pos.y, v5); + //HIDWORD(v42) = fixpoint_mul(v6->x - pIndoorCamera->pos.x, v5); + //uIDa = (LODWORD(v42) - pIndoorCamera->pos.z) << 16; + X_4 = fixpoint_mul(v6->z - pIndoorCamera->pos.z, v44) + fixpoint_sub0(v45, v3); + if ( X_4 < 0x40000 ) return 0; - v16 = ((unsigned __int64)(v47 * (signed __int64)v4) >> 16); //- v43;Ritor1:it's temporarily - v17 = ((unsigned __int64)(uIDa * (signed __int64)v3) >> 16) - - ((unsigned __int64)(v45 * (signed __int64)v44) >> 16); + v16 = fixpoint_mul(v6->y - pIndoorCamera->pos.y, v4) - fixpoint_mul(v6->x - pIndoorCamera->pos.x, v5); + v17 = fixpoint_mul(v6->z - pIndoorCamera->pos.z, v3) - fixpoint_sub0(v45, v44); } else { if (v6->type & ParticleType_Line) { - v18 = v6->_x + 6.7553994e15; - uIDf = (LODWORD(v18) - pIndoorCamera->pos.x) << 16; - v19 = v6->_y + 6.7553994e15; - v20 = (LODWORD(v19) - pIndoorCamera->pos.y) << 16; - v21 = v6->_z + 6.7553994e15; + //v18 = v6->_x + 6.7553994e15; + //uIDf = (LODWORD(v18) - pIndoorCamera->pos.x) << 16; + //v19 = v6->_y + 6.7553994e15; + //v20 = (LODWORD(v19) - pIndoorCamera->pos.y) << 16; + //v21 = v6->_z + 6.7553994e15; LODWORD(v22) = 0; HIDWORD(v22) = SLOWORD(pOutdoorCamera->int_fov_rad); - v23 = v22 - / (signed int)(((unsigned __int64)(v20 * (signed __int64)v5) >> 16) - + ((unsigned __int64)(uIDf * (signed __int64)v4) >> 16)); - v6->_screenspace_scale = v23; - v24 = v6->_screenspace_scale; + auto _var_123 = fixpoint_mul(v6->x - pIndoorCamera->pos.x, v4) + fixpoint_mul(v6->y - pIndoorCamera->pos.y, v5); + //v23 = v22 / _var_123; + v6->_screenspace_scale = v22 / _var_123; + //v24 = v6->_screenspace_scale; v6->uScreenSpaceX = pViewport->uScreenCenterX - - ((signed int)((unsigned __int64)(v23 - * (signed __int64)(signed int)(((unsigned __int64)(v20 * (signed __int64)v4) >> 16) - - ((unsigned __int64)(uIDf * (signed __int64)v5) >> 16))) >> 16) >> 16); - v25 = pViewport->uScreenCenterY - - ((signed int)((unsigned __int64)(v24 * (signed __int64)SLODWORD(v21)) >> 16) >> 16); - v6->sZValue = ((unsigned __int64)(v20 * (signed __int64)v5) >> 16) - + ((unsigned __int64)(uIDf * (signed __int64)v4) >> 16); - v6->uScreenSpaceY = v25; + - ((signed int)((unsigned __int64)(v6->_screenspace_scale + * (signed __int64)(fixpoint_mul(v6->y - pIndoorCamera->pos.y, v4) + - fixpoint_mul(v6->x - pIndoorCamera->pos.x, v5))) >> 16) >> 16); + v6->uScreenSpaceY = pViewport->uScreenCenterY - (fixpoint_mul(v6->z, v6->_screenspace_scale) >> 16); + v6->sZValue = _var_123; } - uIDb = (v41 - pIndoorCamera->pos.x) << 16; - v48 = (LODWORD(v39) - pIndoorCamera->pos.y) << 16; - v26 = (unsigned __int64)(v48 * (signed __int64)v5) >> 16; - v27 = v26 + ((unsigned __int64)(uIDb * (signed __int64)v4) >> 16); - X_4 = v26 + ((unsigned __int64)(uIDb * (signed __int64)v4) >> 16); - if ( v27 < 262144 || v27 > (pOutdoorCamera->uPickDepth - 1000) << 16 ) + //uIDb = (v41 - pIndoorCamera->pos.x) << 16; + //v48 = (LODWORD(v39) - pIndoorCamera->pos.y) << 16; + v26 = fixpoint_mul(v6->y - pIndoorCamera->pos.y, v5); + //v27 = v26 + ((unsigned __int64)(uIDb * (signed __int64)v4) >> 16); + X_4 = v26 + fixpoint_mul(v6->x - pIndoorCamera->pos.x, v4); + if ( X_4 < 0x40000 || X_4 > (pOutdoorCamera->uPickDepth - 1000) << 16 ) return 0; - v17 = LODWORD(v42); - v16 = ((unsigned __int64)(v48 * (signed __int64)v4) >> 16) - ((unsigned __int64)(uIDb * (signed __int64)v5) >> 16); + v17 = v6->z; + v16 = fixpoint_mul(v6->y - pIndoorCamera->pos.y, v4) - fixpoint_mul(v6->x - pIndoorCamera->pos.x, v5); } v40 = v17; v28 = abs(v16); @@ -564,13 +559,13 @@ { LODWORD(v29) = 0; HIDWORD(v29) = SLOWORD(pOutdoorCamera->int_fov_rad); - v30 = v29 / X_4; - v6->_screenspace_scale = v30; - v31 = v6->_screenspace_scale; + //v30 = v29 / X_4; + v6->_screenspace_scale = v29 / X_4; + //v31 = v6->_screenspace_scale; v6->uScreenSpaceX = pViewport->uScreenCenterX - - ((signed int)((unsigned __int64)(v30 * (signed __int64)v16) >> 16) >> 16); + - ((signed int)((unsigned __int64)(v6->_screenspace_scale * (signed __int64)v16) >> 16) >> 16); v32 = v6->flt_28; - v33 = (signed int)((unsigned __int64)(v31 * (signed __int64)v40) >> 16) >> 16; + v33 = (signed int)((unsigned __int64)(v6->_screenspace_scale * (signed __int64)v40) >> 16) >> 16; v34 = pViewport->uScreenCenterY - v33; v6->uScreenSpaceY = pViewport->uScreenCenterY - v33; v35 = v32; @@ -590,8 +585,7 @@ } } } - } - return 0; + return false; } //----- (0048BBA6) -------------------------------------------------------- @@ -612,7 +606,7 @@ if (p->type == ParticleType_Invalid) continue; - if (!ViewProject_TrueIfStillVisible(i)) + if (!ViewProject_TrueIfStillVisible_BLV(i)) continue; if (p->uScreenSpaceX >= pBLVRenderParams->uViewportX && @@ -630,7 +624,7 @@ v15.uScreenSpaceX = p->uScreenSpaceX; v15.uScreenSpaceY = p->uScreenSpaceY; v15.sZValue = p->sZValue; - pRenderer->MakeParticleBillboardAndPush_BLV(&v15, 0, p->uLightColor, p->_rotation); + pRenderer->MakeParticleBillboardAndPush_BLV(&v15, 0, p->uLightColor_bgr, p->angle); return; } if (p->type & ParticleType_Line) @@ -641,7 +635,7 @@ pLines.pLineVertices[2 * pLines.uNumLines].pos.y = p->uScreenSpaceY; pLines.pLineVertices[2 * pLines.uNumLines].pos.z = 1.0 - 1.0 / ((short)p->sZValue * 0.061758894); pLines.pLineVertices[2 * pLines.uNumLines].rhw = 1.0; - pLines.pLineVertices[2 * pLines.uNumLines].diffuse = p->uLightColor; + pLines.pLineVertices[2 * pLines.uNumLines].diffuse = p->uLightColor_bgr; pLines.pLineVertices[2 * pLines.uNumLines].specular = 0; pLines.pLineVertices[2 * pLines.uNumLines].texcoord.x = 0.0; pLines.pLineVertices[2 * pLines.uNumLines].texcoord.y = 0.0; @@ -650,7 +644,7 @@ pLines.pLineVertices[2 * pLines.uNumLines + 1].pos.y = p->uScreenSpaceW; pLines.pLineVertices[2 * pLines.uNumLines + 1].pos.z = 1.0 - 1.0 / ((short)p->sZValue2 * 0.061758894); pLines.pLineVertices[2 * pLines.uNumLines + 1].rhw = 1.0; - pLines.pLineVertices[2 * pLines.uNumLines + 1].diffuse = p->uLightColor; + pLines.pLineVertices[2 * pLines.uNumLines + 1].diffuse = p->uLightColor_bgr; pLines.pLineVertices[2 * pLines.uNumLines + 1].specular = 0; pLines.pLineVertices[2 * pLines.uNumLines + 1].texcoord.x = 0.0; pLines.pLineVertices[2 * pLines.uNumLines++ + 1].texcoord.y = 0.0; @@ -663,9 +657,7 @@ v15.uScreenSpaceX = p->uScreenSpaceX; v15.uScreenSpaceY = p->uScreenSpaceY; v15.sZValue = p->sZValue; - pRenderer->MakeParticleBillboardAndPush_BLV(&v15, pBitmaps_LOD->pHardwareTextures[p->uTextureID], - p->uLightColor, - p->_rotation); + pRenderer->MakeParticleBillboardAndPush_BLV(&v15, pBitmaps_LOD->pHardwareTextures[p->uTextureID], p->uLightColor_bgr, p->angle); } if (p->type & ParticleType_Sprite) { @@ -674,9 +666,7 @@ v15.uScreenSpaceX = p->uScreenSpaceX; v15.uScreenSpaceY = p->uScreenSpaceY; v15.sZValue = p->sZValue; - pRenderer->MakeParticleBillboardAndPush_BLV(&v15, pSprites_LOD->pHardwareSprites[p->uTextureID].pTexture, - p->uLightColor, - p->_rotation); + pRenderer->MakeParticleBillboardAndPush_BLV(&v15, pSprites_LOD->pHardwareSprites[p->uTextureID].pTexture, p->uLightColor_bgr, p->angle); } } else @@ -695,7 +685,7 @@ } else { - pRenderer->MakeParticleBillboardAndPush_BLV_Software(v13, v12, p->sZValue, p->uLightColor, v11); + pRenderer->MakeParticleBillboardAndPush_BLV_Software(v13, v12, p->sZValue, p->uLightColor_bgr, v11); } } } @@ -706,19 +696,19 @@ void ParticleEngine::DrawParticles_ODM() { ParticleEngine *pParticleEngine; // esi@1 - int pParticleNum; // eax@1 + //int pParticleNum; // eax@1 unsigned __int8 v3; // zf@1 char v4; // sf@1 unsigned __int8 v5; // of@1 - char *v7; // edi@2 - int v8; // eax@6 - signed int pNumLines; // eax@8 + //char *v7; // edi@2 + //int v8; // eax@6 + //signed int pNumLines; // eax@8 int v10; // eax@14 int v11; // ecx@16 int v12; // edx@16 - Particle *pParticle; // eax@24 + //Particle *pParticle; // eax@24 RenderBillboardTransform_local0 pBillboard; // [sp+Ch] [bp-58h]@1 - int v15; // [sp+5Ch] [bp-8h]@9 + //int v15; // [sp+5Ch] [bp-8h]@9 int v16; // [sp+60h] [bp-4h]@1 pBillboard.uParentBillboardID = -1; @@ -728,92 +718,86 @@ //v3 = v2 == this->uEndParticle; //v4 = v2 - this->uEndParticle < 0; //v16 = this->uStartParticle; - for (pParticleNum = this->uStartParticle; pParticleNum <= this->uEndParticle; ++pParticleNum) + for (uint i = uStartParticle; i <= uEndParticle; ++i) { - v7 = (char *)&this->pParticles[pParticleNum].sZValue + 2; - //do - //{ - if ( *(_DWORD *)(v7 - 82) && pParticleEngine->_48B5B3(pParticleNum) )//*(_DWORD *)(v7 - 82) = this->pParticles[pParticleNum] or this->pParticles[pParticleNum].uType - { + auto particle = pParticles + i; + if (particle->type == ParticleType_Invalid || !ViewProject_TrueIfStillVisible_ODM(i)) + continue; + if ( pRenderer->pRenderD3D ) { - v8 = *(_DWORD *)(v7 - 82); - if ( BYTE1(v8) & 1 ) + //v8 = *(_DWORD *)(v7 - 82); + if (particle->type & ParticleType_Diffuse) { - pParticle = &pParticleEngine->pParticles[pParticleNum]; - pBillboard._screenspace_x_scaler_packedfloat = pParticle->_screenspace_scale / 4; - pBillboard._screenspace_y_scaler_packedfloat = pParticle->_screenspace_scale / 4; - pBillboard.uScreenSpaceX = pParticle->uScreenSpaceX; - pBillboard.uScreenSpaceY = pParticle->uScreenSpaceY; - pBillboard.sZValue = pParticle->sZValue; - pRenderer->MakeParticleBillboardAndPush_ODM(&pBillboard, 0, pParticle->uLightColor, pParticle->_rotation); + pBillboard._screenspace_x_scaler_packedfloat = particle->_screenspace_scale / 4; + pBillboard._screenspace_y_scaler_packedfloat = particle->_screenspace_scale / 4; + pBillboard.uScreenSpaceX = particle->uScreenSpaceX; + pBillboard.uScreenSpaceY = particle->uScreenSpaceY; + pBillboard.sZValue = particle->sZValue; + pRenderer->MakeParticleBillboardAndPush_ODM(&pBillboard, 0, particle->uLightColor_bgr, particle->angle); return; } - if ( BYTE1(v8) & 2 ) + if (particle->type & ParticleType_Line) { - pNumLines = pParticleEngine->pLines.uNumLines; - if ( pNumLines < 100 ) + if (pLines.uNumLines < 100) { - pParticleEngine->pLines.pLineVertices[2 * pNumLines].pos.x = (double)*(signed int *)(v7 - 18); - pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines].pos.y = (double)*(signed int *)(v7 - 14); - v15 = *(_DWORD *)v7; - pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines].pos.z = 1.0 - 1.0 / ((double)v15 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); - pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines].rhw = 1.0; - pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines].diffuse = *(_DWORD *)(v7 + 18); - pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines].specular = 0; - pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines].texcoord.x = 0.0; - *((float *)&pParticleEngine->pParticles[0].type + 16 * (pParticleEngine->pLines.uNumLines + 813)) = 0.0; - pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines + 1].pos.x = (double)*(signed int *)(v7 - 10); - pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines + 1].pos.y = (double)*(signed int *)(v7 - 6); - v15 = *(_DWORD *)v7; - pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines + 1].pos.z = 1.0 - 1.0 / ((double)v15 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); - pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines + 1].rhw = 1.0; - pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines + 1].diffuse = *(_DWORD *)(v7 + 18); - pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines + 1].specular = 0; - pParticleEngine->pLines.pLineVertices[2 * pParticleEngine->pLines.uNumLines + 1].texcoord.x = 0.0; - __debugbreak();//v1->pLines.pLineVertices[2 * v1->pLines.uNumLines++ + 1].texcoord.y = 0.0; + pLines.pLineVertices[2 * pLines.uNumLines].pos.x = particle->uScreenSpaceX; + pLines.pLineVertices[2 * pLines.uNumLines].pos.y = particle->uScreenSpaceY; + pLines.pLineVertices[2 * pLines.uNumLines].pos.z = 1.0 - 1.0 / ((double)particle->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); + pLines.pLineVertices[2 * pLines.uNumLines].rhw = 1.0; + pLines.pLineVertices[2 * pLines.uNumLines].diffuse = particle->uLightColor_bgr; + pLines.pLineVertices[2 * pLines.uNumLines].specular = 0; + pLines.pLineVertices[2 * pLines.uNumLines].texcoord.x = 0.0; + pLines.pLineVertices[2 * pLines.uNumLines].texcoord.y = 0.0; + + pLines.pLineVertices[2 * pLines.uNumLines + 1].pos.x = particle->uScreenSpaceZ; + pLines.pLineVertices[2 * pLines.uNumLines + 1].pos.y = particle->uScreenSpaceW; + pLines.pLineVertices[2 * pLines.uNumLines + 1].pos.z = 1.0 - 1.0 / ((double)particle->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); + pLines.pLineVertices[2 * pLines.uNumLines + 1].rhw = 1.0; + pLines.pLineVertices[2 * pLines.uNumLines + 1].diffuse = particle->uLightColor_bgr; + pLines.pLineVertices[2 * pLines.uNumLines + 1].specular = 0; + pLines.pLineVertices[2 * pLines.uNumLines + 1].texcoord.x = 0.0; + pLines.pLineVertices[2 * pLines.uNumLines + 1].texcoord.y = 0.0; + pLines.uNumLines++; } } - if ( *(v7 - 81) & 4 ) + if (particle->type & ParticleType_Bitmap) { - pBillboard._screenspace_x_scaler_packedfloat = *(_DWORD *)(v7 + 6); - pBillboard._screenspace_y_scaler_packedfloat = *(_DWORD *)(v7 + 6); - pBillboard.uScreenSpaceX = *(_DWORD *)(v7 - 18); - pBillboard.uScreenSpaceY = *(_DWORD *)(v7 - 14); - pBillboard.sZValue = *(_DWORD *)(v7 - 2); - pRenderer->MakeParticleBillboardAndPush_ODM(&pBillboard, pBitmaps_LOD->pHardwareTextures[*(_DWORD *)(v7 - 46)], *(_DWORD *)(v7 + 18), *(_DWORD *)(v7 - 22)); + pBillboard._screenspace_x_scaler_packedfloat = particle->_screenspace_scale; + pBillboard._screenspace_y_scaler_packedfloat = particle->_screenspace_scale; + pBillboard.uScreenSpaceX = particle->uScreenSpaceX; + pBillboard.uScreenSpaceY = particle->uScreenSpaceY; + pBillboard.sZValue = particle->sZValue; + pRenderer->MakeParticleBillboardAndPush_ODM(&pBillboard, pBitmaps_LOD->pHardwareTextures[particle->uTextureID], particle->uLightColor_bgr, particle->angle); } - if ( *(v7 - 81) & 8 ) + if (particle->type & ParticleType_Sprite) { - pBillboard._screenspace_x_scaler_packedfloat = *(_DWORD *)(v7 + 6); - pBillboard._screenspace_y_scaler_packedfloat = *(_DWORD *)(v7 + 6); - pBillboard.uScreenSpaceX = *(_DWORD *)(v7 - 18); - pBillboard.uScreenSpaceY = *(_DWORD *)(v7 - 14); - pBillboard.sZValue = *(_DWORD *)(v7 - 2); - pRenderer->MakeParticleBillboardAndPush_ODM(&pBillboard, pSprites_LOD->pHardwareSprites[*(_DWORD *)(v7 - 46)].pTexture, *(_DWORD *)(v7 + 18), - *(_DWORD *)(v7 - 22)); + pBillboard._screenspace_x_scaler_packedfloat = particle->_screenspace_scale; + pBillboard._screenspace_y_scaler_packedfloat = particle->_screenspace_scale; + pBillboard.uScreenSpaceX = particle->uScreenSpaceX; + pBillboard.uScreenSpaceY = particle->uScreenSpaceY; + pBillboard.sZValue = particle->sZValue; + pRenderer->MakeParticleBillboardAndPush_ODM(&pBillboard, pSprites_LOD->pHardwareSprites[particle->uTextureID].pTexture, particle->uLightColor_bgr, particle->angle); } } else { - v10 = 13 * *(_DWORD *)(v7 + 6) >> 16; + v10 = 13 * particle->_screenspace_scale >> 16; if ( v10 > 30 ) v10 = 30; - v11 = *(_DWORD *)(v7 - 18) - (v10 >> 1); - v12 = *(_DWORD *)(v7 - 14) - v10; + v11 = particle->uScreenSpaceX - (v10 >> 1); + v12 = particle->uScreenSpaceY - v10; if ( v11 + v10 < pViewport->uViewportTL_X || v11 >= pViewport->uViewportBR_X - || *(_DWORD *)(v7 - 14) < pViewport->uViewportTL_Y + || particle->uScreenSpaceY < pViewport->uViewportTL_Y || v12 >= (signed int)pViewport->uViewportBR_Y ) { ; } else { - pRenderer->MakeParticleBillboardAndPush_BLV_Software(v11, v12, *(_DWORD *)(v7 - 2), *(_DWORD *)(v7 + 18), v10); + pRenderer->MakeParticleBillboardAndPush_BLV_Software(v11, v12, particle->sZValue, particle->uLightColor_bgr, v10); } - } - } - + } } } \ No newline at end of file diff -r cd355e4c6104 -r 4568f1e4d61b ParticleEngine.h --- a/ParticleEngine.h Mon Apr 01 18:52:06 2013 +0600 +++ b/ParticleEngine.h Mon Apr 01 18:52:19 2013 +0600 @@ -64,8 +64,8 @@ float _x; float _y; float _z; - int field_38; - int _rotation; + int rotation_speed; + int angle; int uScreenSpaceX; int uScreenSpaceY; int uScreenSpaceZ; // line end x @@ -83,7 +83,7 @@ int _screenspace_scale; float flt_5C; float flt_60; - int uLightColor; + int uLightColor_bgr; }; #pragma pack(pop) @@ -113,8 +113,8 @@ void AddParticle(Particle_sw *a2); void Draw(); void UpdateParticles(); - bool ViewProject_TrueIfStillVisible(unsigned int uParticleID); - bool _48B5B3(unsigned int uID); + bool ViewProject_TrueIfStillVisible_BLV(unsigned int uParticleID); + bool ViewProject_TrueIfStillVisible_ODM(unsigned int uID); void DrawParticles_BLV(); void DrawParticles_ODM(); diff -r cd355e4c6104 -r 4568f1e4d61b Party.cpp --- a/Party.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/Party.cpp Mon Apr 01 18:52:19 2013 +0600 @@ -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; diff -r cd355e4c6104 -r 4568f1e4d61b Player.cpp --- a/Player.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/Player.cpp Mon Apr 01 18:52:19 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) = PID(a2 - 120,OBJECT_Player); + 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) = PID(currPlayerId - 112,OBJECT_Player); + 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) = PID(currPlayerId - 112,OBJECT_Player); + 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) = PID(currPlayerId - 112,OBJECT_Player); + LOBYTE(v25) = PID(OBJECT_Player,currPlayerId - 112); pAudioPlayer->PlaySound(SOUND_20001, v25, 0, -1, 0, 0, 0, 0); return; } @@ -9255,7 +9255,7 @@ bFlashHistoryBook = 1; _play_sound: v28 = 8 * uPlayerIdx + 400; - LOBYTE(v28) = PID(uPlayerIdx - 112,OBJECT_Player); + LOBYTE(v28) = PID(OBJECT_Player,uPlayerIdx - 112); pAudioPlayer->PlaySound(SOUND_20001, v28, 0, -1, 0, 0, 0, 0); return; } @@ -9465,14 +9465,14 @@ GameUI_DrawFoodAndGold(); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + 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) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_CurrentSP: @@ -9483,28 +9483,28 @@ *(int *)v9 = 0; pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + 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) = PID(v4 - 112,OBJECT_Player); + 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) = PID(v4 - 112,OBJECT_Player); + 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) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_Age: @@ -9521,7 +9521,7 @@ *((int *)v12 + 1) -= v14 + HIDWORD(v13); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_QBits_QuestsDone: @@ -9542,7 +9542,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_IntellectBonus: @@ -9551,7 +9551,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_PersonalityBonus: @@ -9560,7 +9560,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_EnduranceBonus: @@ -9569,7 +9569,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_SpeedBonus: @@ -9578,7 +9578,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_AccuracyBonus: @@ -9587,7 +9587,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_LuckBonus: @@ -9596,7 +9596,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_BaseMight: @@ -9604,7 +9604,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_BaseIntellect: @@ -9612,7 +9612,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_BasePersonality: @@ -9620,7 +9620,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_BaseEndurance: @@ -9628,7 +9628,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_BaseSpeed: @@ -9636,7 +9636,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_BaseAccuracy: @@ -9644,7 +9644,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_BaseLuck: @@ -9652,7 +9652,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_FireResistance: @@ -9660,7 +9660,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_AirResistance: @@ -9668,7 +9668,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_WaterResistance: @@ -9676,7 +9676,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_EarthResistance: @@ -9684,7 +9684,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_SpiritResistance: @@ -9692,7 +9692,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_MindResistance: @@ -9700,7 +9700,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_BodyResistance: @@ -9708,7 +9708,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_LightResistance: @@ -9716,7 +9716,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_DarkResistance: @@ -9724,7 +9724,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_MagicResistance: @@ -9732,7 +9732,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_FireResistanceBonus: @@ -9740,7 +9740,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_AirResistanceBonus: @@ -9748,7 +9748,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_WaterResistanceBonus: @@ -9756,7 +9756,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_EarthResistanceBonus: @@ -9764,7 +9764,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_SpiritResistanceBonus: @@ -9772,7 +9772,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_MindResistanceBonus: @@ -9780,7 +9780,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_BodyResistanceBonus: @@ -9788,7 +9788,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_LightResistanceBonus: @@ -9796,7 +9796,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_DarkResistanceBonus: @@ -9804,7 +9804,7 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_MagicResistanceBonus: @@ -9814,14 +9814,14 @@ pPlayers[v4 + 1]->PlaySound((PlayerSpeech)v23, v25); pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + 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) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_StaffSkill: @@ -9857,7 +9857,7 @@ *((short *)&this->pConditions[16] + VarNum) -= (unsigned __int8)pValue; pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; case VAR_Cursed: @@ -9881,7 +9881,7 @@ *((int *)this + 2 * result - 209) = 0; pGame->pStru6Instance->SetPlayerBuffAnim(0x98u, v4); v8 = 8 * v4 + 400; - LOBYTE(v8) = PID(v4 - 112,OBJECT_Player); + LOBYTE(v8) = PID(OBJECT_Player,v4 - 112); pAudioPlayer->PlaySound(SOUND_20001, v8, 0, -1, 0, 0, 0, 0); return result; default: diff -r cd355e4c6104 -r 4568f1e4d61b Render.cpp --- a/Render.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/Render.cpp Mon Apr 01 18:52:19 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; @@ -5597,7 +5598,7 @@ { pDefaultZBuffer = pActiveZBuffer = nullptr; pDefaultZBuffer = pActiveZBuffer = (int *)pAllocator->AllocNamedChunk(0, 0x12C000, "Z Buf."); - memset32(pActiveZBuffer, 0xFFFF0000u, 0x4B000u); + memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) } } diff -r cd355e4c6104 -r 4568f1e4d61b UIHouses.cpp --- a/UIHouses.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/UIHouses.cpp Mon Apr 01 18:52:19 2013 +0600 @@ -388,7 +388,7 @@ if (~npc->uFlags & 0x80) //if ( !(*(char *)v6 & 0x80) ) { - v7 = uNumDialogueNPCPortraits++ - dword_591080 ? 1 : 0; + v7 = uNumDialogueNPCPortraits++ - (dword_591080 != 0) ? 1 : 0; HouseNPCData[v7] = npc; //v6 = v17; //*(&v13 + v2) = *(v17 - 1); @@ -2451,25 +2451,27 @@ unsigned int v71; // [sp-4h] [bp-278h]@75 const char *v72; // [sp-4h] [bp-278h]@93 unsigned int v73; // [sp-4h] [bp-278h]@99 - char Dest[100]; // [sp+Ch] [bp-268h]@55 - char v75[100]; // [sp+70h] [bp-204h]@59 - char a1[100]; // [sp+D4h] [bp-1A0h]@57 - char v77[100]; // [sp+138h] [bp-13Ch]@59 + char pTopic1[100]; // [sp+Ch] [bp-268h]@55 + char pTopic4[100]; // [sp+70h] [bp-204h]@59 + char pTopic2[100]; // [sp+D4h] [bp-1A0h]@57 + char pTopic3[100]; // [sp+138h] [bp-13Ch]@59 //GUIWindow v78; // [sp+19Ch] [bp-D8h]@99 GUIWindow dialog_window; // [sp+1F0h] [bp-84h]@1 char *Str[2]; // [sp+244h] [bp-30h]@30 unsigned int pColorWhite; // [sp+24Ch] [bp-28h]@1 - unsigned __int8 v82; // [sp+253h] [bp-21h]@59 + unsigned __int8 pTopic3Height; // [sp+253h] [bp-21h]@59 int v83; // [sp+254h] [bp-20h]@1 int pColorYellow; // [sp+258h] [bp-1Ch]@1 Player *pPlayer; // [sp+25Ch] [bp-18h]@1 int all_text_height; // [sp+260h] [bp-14h]@18 unsigned __int8 v87; // [sp+266h] [bp-Eh]@59 - unsigned __int8 v88; // [sp+267h] [bp-Dh]@57 + unsigned __int8 pTopic2Height; // [sp+267h] [bp-Dh]@57 int v89; // [sp+268h] [bp-Ch]@1 - unsigned int pTextHeight; // [sp+26Fh] [bp-5h]@55 + unsigned int pTopic1Height; // [sp+26Fh] [bp-5h]@55 int v91; // [sp+270h] [bp-4h]@3 GUIFont *pOutString; + unsigned __int8 pTopic4Height; + int pTextHeight; pPlayer = pPlayers[uActiveCharacter]; memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); @@ -2507,90 +2509,84 @@ if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) return; - sprintf(Dest, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 2 ? pColorYellow : pColorWhite); + sprintf(pTopic1, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 2 ? pColorYellow : pColorWhite); sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[178], pOutString); // Rent room for %d gold - strcat(Dest, pTmpBuf2); - pTextHeight = pFontArrus->CalcTextHeight(Dest, &dialog_window, 0, 0); - strcat(Dest, "\n \n"); + strcat(pTopic1, pTmpBuf2); + pTopic1Height = pFontArrus->CalcTextHeight(pTopic1, &dialog_window, 0, 0); + strcat(pTopic1, "\n \n"); - sprintf(a1, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 3 ? pColorYellow : pColorWhite); + sprintf(pTopic2, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 3 ? pColorYellow : pColorWhite); sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[86], // Buy food for %d days for %d gold - (unsigned int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier, - v83); - strcat(a1, pTmpBuf2); - v88 = pFontArrus->CalcTextHeight(a1, &dialog_window, 0, 0); - strcat(a1, "\n \n"); + (unsigned int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier, v83); + strcat(pTopic2, pTmpBuf2); + pTopic2Height = pFontArrus->CalcTextHeight(pTopic2, &dialog_window, 0, 0); + strcat(pTopic2, "\n \n"); - sprintf(v77, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 4 ? pColorYellow : pColorWhite); - strcat(v77, pGlobalTXT_LocalizationStrings[160]); // Learn Skills - v82 = pFontArrus->CalcTextHeight(v77, &dialog_window, 0, 0); - strcat(v77, "\n \n"); - v75[0] = 0; - pTextHeight = 0; + sprintf(pTopic3, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 4 ? pColorYellow : pColorWhite); + strcat(pTopic3, pGlobalTXT_LocalizationStrings[160]); // Learn Skills + pTopic3Height = pFontArrus->CalcTextHeight(pTopic3, &dialog_window, 0, 0); + strcat(pTopic3, "\n \n"); + pTopic4[0] = 0; if ( (signed int)window_SpeakInHouse->par1C >= 108 && (signed int)window_SpeakInHouse->par1C <= 120 ) { - sprintf(v75, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 5 ? pColorYellow : pColorWhite); - strcat(v75, pGlobalTXT_LocalizationStrings[611]); // Play Arcomage - pTextHeight = pFontArrus->CalcTextHeight(v75, &dialog_window, 0, 0); + sprintf(pTopic4, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 5 ? pColorYellow : pColorWhite); + strcat(pTopic4, pGlobalTXT_LocalizationStrings[611]); // Play Arcomage + pTopic4Height = pFontArrus->CalcTextHeight(pTopic4, &dialog_window, 0, 0); } pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; v36 = LOBYTE(pFontArrus->uFontHeight) - 3; v37 = -pDialogueWindow->pNumPresenceButton < 0; if ( !(v37 ^ pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton) ) { - sprintf(pTmpBuf, "%s%s%s%s", Dest, a1, v77, v75); - dialog_window.DrawTitleText(pFontArrus, 0, 146, 0, pTmpBuf, 3); - return; - } - while ( 1 ) - { - pButton = pDialogueWindow->GetControl(pNumActiveItem); - if ( pButton->msg_param == 15 ) + do { - v46 = pTextHeight; - pButton->uHeight = pTextHeight; - pButton->uY = 146; - v41 = v46 + 145; - pButton->uW = v41; - } - else if ( pButton->msg_param == 16 ) - { - v44 = v88; - v45 = pTextHeight + v36 + 146; - pButton->uHeight = v88; - pButton->uY = v45; - v41 = v45 + v44 - 1; - pButton->uW = v41; + pButton = pDialogueWindow->GetControl(pNumActiveItem); + if ( pButton->msg_param == 15 ) + { + v46 = pTopic1Height; + pButton->uHeight = pTopic1Height; + pButton->uY = 146; + v41 = v46 + 145; + pButton->uW = v41; + } + else if ( pButton->msg_param == 16 ) + { + v44 = pTopic2Height; + v45 = pTopic1Height + v36 + 146; + pButton->uHeight = pTopic2Height; + pButton->uY = v45; + v41 = v45 + v44 - 1; + pButton->uW = v41; + } + else if ( pButton->msg_param == 96 ) + { + v42 = pTopic1Height + pTopic2Height + 2 * v36 + 146; + v43 = pTopic3Height; + pButton->uY = v42; + pButton->uHeight = v43; + v41 = v43 + v42 - 1; + pButton->uW = v41; + } + else if ( pButton->msg_param == 101 ) + { + v39 = pTopic1Height + 3 * v36 + pTopic4Height + pTopic2Height + 146; + v40 = pTopic4Height; + pButton->uHeight = pTopic4Height; + pButton->uY = v39; + v41 = v39 + v40 - 1; + pButton->uW = v41; + } + pNumActiveItem++; + if ( pNumActiveItem >= pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ) + { + sprintfex(pTmpBuf, "%s%s%s%s", &pTopic1, &pTopic2, &pTopic3, &pTopic4); + dialog_window.DrawTitleText(pFontArrus, 0, 146, 0, pTmpBuf, 3); + } } - else if ( pButton->msg_param == 96 ) - { - v42 = pTextHeight + v88 + 2 * v36 + 146; - v43 = v82; - pButton->uY = v42; - pButton->uHeight = v43; - v41 = v43 + v42 - 1; - pButton->uW = v41; - } - else if ( pButton->msg_param == 101 ) - { - v39 = pTextHeight + 3 * v36 + pTextHeight + v88 + 146; - v40 = v87; - pButton->uHeight = pTextHeight; - pButton->uY = v39; - v41 = v39 + v40 - 1; - pButton->uW = v41; - } - pNumActiveItem++; - if ( pNumActiveItem >= pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ) - { - sprintf(pTmpBuf, "%s%s%s%s", &Dest, &a1, &v77, &v75); - dialog_window.DrawTitleText(pFontArrus, 0, 146, 0, pTmpBuf, 3); - return; - } + while ( pNumActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton ); } break; } - case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RULES: { pOutString = pFontArrus; @@ -4599,7 +4595,7 @@ void GuildDialog() { GUIWindow *v0; // ebx@1 - Player *currPlayer; // edi@1 + //Player *currPlayer; // edi@1 signed int base_teach_price; // ebx@1 int v3; // edi@6 int result; // eax@11 @@ -4656,17 +4652,17 @@ int v55; // [sp+2C8h] [bp-24h]@47 int main_text_color; // [sp+2CCh] [bp-20h]@1 int hi_text_color; // [sp+2D0h] [bp-1Ch]@1 - Player *v58; // [sp+2D4h] [bp-18h]@1 + //Player *v58; // [sp+2D4h] [bp-18h]@1 unsigned __int8 uPlayerID; // [sp+2DBh] [bp-11h]@31 char *Str; // [sp+2DCh] [bp-10h]@35 int v61; // [sp+2E0h] [bp-Ch]@35 unsigned int v62; // [sp+2E4h] [bp-8h]@13 int v63; // [sp+2E8h] [bp-4h]@1 - v0 = window_SpeakInHouse; + v0 = window_SpeakInHouse;//Ritor1: in process memcpy(&working_window, window_SpeakInHouse, sizeof(GUIWindow)); - v58 = pPlayers[uActiveCharacter]; - currPlayer = v58; + //v58 = pPlayers[uActiveCharacter]; + //currPlayer = pPlayers[uActiveCharacter]; working_window.uFrameX = 483; working_window.uFrameWidth = 148; working_window.uFrameZ = 334; @@ -4674,7 +4670,7 @@ hi_text_color = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu); //v2 = (signed __int64)(p2DEvents_minus1__20[13 * (unsigned int)v0->ptr_1C] * 500.0); base_teach_price = (signed __int64)(p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier * 500.0); - v63 = base_teach_price * (100 - currPlayer->GetMerchant()) / 100; + v63 = base_teach_price * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; if ( v63 < base_teach_price / 3 ) v63 = base_teach_price / 3; strcpy(Dest, ""); @@ -4684,12 +4680,12 @@ strcpy(v49, ""); if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN ) { - if ( dialog_menu_id != HOUSE_DIALOGUE_GULD_BUY_BOOKS ) //buy skill + if ( dialog_menu_id != HOUSE_DIALOGUE_GUILD_BUY_BOOKS ) //buy skill { if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) { //v3 = (int)(&currPlayer->uIntelligence + dword_F8B19C); //test skill - if ( v58->pActiveSkills[dialog_menu_id-36] ) + if ( pPlayers[uActiveCharacter]->pActiveSkills[dialog_menu_id-36] ) { sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[403], pClassNames[dialog_menu_id - 16]); //"You already know the %s skill" ShowStatusBarString(pTmpBuf, 2u); @@ -4705,7 +4701,7 @@ else { Party::TakeGold(v63); - v58->pActiveSkills[dialog_menu_id-36] = 1; + pPlayers[uActiveCharacter]->pActiveSkills[dialog_menu_id-36] = 1; } } } @@ -4725,7 +4721,7 @@ { pRenderer->DrawTextureTransparent(v63, 0x5Au, ItemsInShopTexture[v6]); ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 230528), ItemsInShopTexture[v6], v6 + 1); - currPlayer = v58; + //currPlayer = v58; } v63 += 70; v62 += 280; @@ -4743,7 +4739,7 @@ { pRenderer->DrawTextureTransparent(v63, 0xFAu, ItemsInShopTexture[v7]); ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 638448), ItemsInShopTexture[v7], v7 + 1); - currPlayer = v58; + //currPlayer = v58; } v63 += 70; v62 += 280; @@ -4789,7 +4785,7 @@ v15 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v13 + 12 * (int)v14)); v16 = (int)window_SpeakInHouse->ptr_1C; uPlayerID = uActiveCharacter - 1; - v17 = currPlayer->_490EEE( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14, 3, v16, 2); + v17 = pPlayers[uActiveCharacter]->_490EEE( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14, 3, v16, 2); v18 = BuilDialogueString((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0); v19 = pFontArrus->CalcTextHeight(v18, &working_window, 0, 0); working_window.DrawTitleText(pFontArrus, 0, (174 - v19) / 2 + 138, main_text_color, v18, 3); @@ -4799,7 +4795,7 @@ return; } if ( !(unsigned __int16)_449B57_test_bit( - (unsigned __int8 *)currPlayer->_guilds_member_bits, + (unsigned __int8 *)pPlayers[uActiveCharacter]->_guilds_member_bits, guild_mambership_flags[(unsigned int)window_SpeakInHouse->ptr_1C-139]) ) { //you must me member v38 = pFontArrus->CalcTextHeight(pNPCTopics[121].pText, &working_window, 0, 0); @@ -4838,7 +4834,7 @@ else { - if((byte_4ED970_skill_learn_ability_by_class_table[v58->classType][v23-36])&&(v58->pActiveSkills[v23-36])) + if((byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v23-36])&&(pPlayers[uActiveCharacter]->pActiveSkills[v23-36])) // or //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass - 1][v23 + 1] { @@ -4854,7 +4850,7 @@ if ( !v61 ) { LABEL_64: - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v58->pName, pClassNames[v58->classType]); // "Seek knowledge elsewhere %s the %s" + sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); // "Seek knowledge elsewhere %s the %s" strcat(pTmpBuf, "\n \n"); strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further." v19 = pFontArrus->CalcTextHeight(pTmpBuf, &working_window, 0, 0); @@ -4886,7 +4882,7 @@ // __debugbreak(); //pSkillAvailabilityPerClass[8 + v58->uClass][4 + v23] // or - if ((byte_4ED970_skill_learn_ability_by_class_table[v58->classType][v29 - 36])&&(v58->pActiveSkills[v29-36])) + if ((byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v29 - 36])&&(pPlayers[uActiveCharacter]->pActiveSkills[v29-36])) // or //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass - 1][v23 + 1] diff -r cd355e4c6104 -r 4568f1e4d61b UIHouses.h --- a/UIHouses.h Mon Apr 01 18:52:06 2013 +0600 +++ b/UIHouses.h Mon Apr 01 18:52:19 2013 +0600 @@ -21,7 +21,7 @@ HOUSE_DIALOGUE_TAVERN_REST = 15, HOUSE_DIALOGUE_TAVERN_BUY_FOOD = 16, HOUSE_DIALOGUE_TRAININGHALL_TRAIN = 17, - HOUSE_DIALOGUE_GULD_BUY_BOOKS = 18, + HOUSE_DIALOGUE_GUILD_BUY_BOOKS = 18, //... HOUSE_DIALOGUE_GUILD_LEARN_SKILL = 72, //... diff -r cd355e4c6104 -r 4568f1e4d61b UiGame.cpp --- a/UiGame.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/UiGame.cpp Mon Apr 01 18:52:19 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 @@ -554,7 +555,7 @@ { if ( (signed int)pX > 467 || (signed int)pY > 351 ) goto _click_on_game_ui; - if ( pRenderer->pRenderD3D ) + if ( pRenderer->pRenderD3D ) // inlined mm8::4C1E01 { v18 = pGame->pVisInstance->get_picked_object_zbuf_val(); if ( (signed int)pX < (signed int)pViewport->uScreen_TL_X @@ -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; diff -r cd355e4c6104 -r 4568f1e4d61b Viewport.cpp --- a/Viewport.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/Viewport.cpp Mon Apr 01 18:52:19 2013 +0600 @@ -37,7 +37,7 @@ this->uScreenHeight = br_y - tl_y + 1; this->uScreenCenterX = (signed int)(br_x + tl_x) /2; if ( pRenderer->pRenderD3D == 0 ) - this->uScreenCenterY = this->uScreen_BR_Y - fixpoint_mul(field_30, uScreenHeight); + this->uScreenCenterY = this->uScreen_BR_Y - fixpoint_sub0(field_30, uScreenHeight); else this->uScreenCenterY = uScreenHeight/2; SetViewport(this->uScreen_TL_X, this->uScreen_TL_Y, this->uScreen_BR_X, this->uScreen_BR_Y); diff -r cd355e4c6104 -r 4568f1e4d61b Vis.cpp --- a/Vis.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/Vis.cpp Mon Apr 01 18:52:19 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 *)((PID(pFaceID,OBJECT_BModel)) + v9); + v15 = (void *)((PID(OBJECT_BModel,pFaceID)) + v9); pNumPointers = &list->uNumPointers; //v16 = 2; //v11 = list->uNumPointers; diff -r cd355e4c6104 -r 4568f1e4d61b mm7_1.cpp --- a/mm7_1.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/mm7_1.cpp Mon Apr 01 18:52:19 2013 +0600 @@ -64,11 +64,16 @@ return ((__int64)a1 << 16) / a2; } +int fixpoint_mul(int a1, int a2) +{ + return (((__int64)a1 << 16) * a2) >> 16; +} + //----- (004453C0) mm6----------------------------------------------------- //----- (004A1760) mm6_chinese--------------------------------------------- -int fixpoint_mul(int a1, int a2) +int fixpoint_sub0(int a1, int a2) { - return ((__int64)a1 * (__int64)a2) / 65536; + return ((__int64)a1 * (__int64)a2) >> 16; } //----- (004196A0) -------------------------------------------------------- diff -r cd355e4c6104 -r 4568f1e4d61b mm7_2.cpp --- a/mm7_2.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/mm7_2.cpp Mon Apr 01 18:52:19 2013 +0600 @@ -1006,35 +1006,26 @@ } if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) { - v56 = 0; - v52 = 0; - v50 = 0; - v49 = 0; - v48 = -1; - v47 = 0; - v46 = 0; - pAudioPlayer->PlaySound(SOUND_27, v46, v47, v48, v49, v50, v52, v56); + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return; } switch(dialog_menu_id) { - case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT: - { - pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; - sub_421EA6_OnInventoryLeftClick(); - break; - } - case HOUSE_DIALOGUE_GULD_BUY_BOOKS: - { + case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT: + { + pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; + sub_421EA6_OnInventoryLeftClick(); + break; + } + case HOUSE_DIALOGUE_GUILD_BUY_BOOKS://Ritor1: in process + { v17 = pMouse->GetCursorPos(&v63); v18 = pRenderer->pActiveZBuffer[v17->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v61)->y]] & 0xFFFF; if ( !v18 ) return; - v19 = window_SpeakInHouse->ptr_1C; - v20 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)v19)); - //v21 = p2DEvents_minus1__20[13 * (signed int)v19]; - v21 = p2DEvents[(signed int)v19 - 1].fPriceMultiplier; + v20 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)window_SpeakInHouse->ptr_1C)); + v21 = p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; _this = v20; v22 = v20->GetValue(); v23 = v0->GetBuyingPrice(v22, v21); @@ -1043,7 +1034,6 @@ if ( pParty->uNumGold < v23 ) { v24 = 2; - //LABEL_62: PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v24); v9 = pGlobalTXT_LocalizationStrings[155]; v54 = 2; @@ -1062,16 +1052,11 @@ _this->Reset(); pRenderer->ClearZBuffer(0, 479); v27 = v77; - v53 = 0; - v51 = SPEECH_75; - v27->PlaySound((PlayerSpeech)v51, v53); + v27->PlaySound((PlayerSpeech)SPEECH_75, 0); return; } v0->PlaySound(SPEECH_NoRoom, 0); - v54 = 5; - //LABEL_70: - v9 = pGlobalTXT_LocalizationStrings[563]; // "Pack is Full!" - ShowStatusBarString(v9, v54); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 5); // "Pack is Full!" break; } @@ -1341,7 +1326,7 @@ break; } - default: + default:// if click video screen in shop { __debugbreak(); // please do record these dialogue ids to the HOUSE_DIALOGUE_MENU enum if( dialog_menu_id >= 36 && dialog_menu_id <= 72 ) @@ -4124,7 +4109,7 @@ { if ( v20 == uNumActors ) ++uNumActors; - v6->uSummonerID = PID(v17,OBJECT_Player); + v6->uSummonerID = PID(OBJECT_Player,v17); result = v6->pActorBuffs[2].Apply( pParty->uTimePlayed + (signed __int64)((double)(a3 << 7) * 0.033333335), v16, @@ -7148,7 +7133,7 @@ { if (pAsyncMouse) goto _def_wnd_proc; - v33 = GetPickDepth(); + v33 = pGame->pIndoorCameraD3D->GetPickDepth(); pGame->PickMouse(v33, (unsigned __int16)lParam, lParam >> 16, v31, &vis_sprite_filter_2, &vis_door_filter); } if (!pAsyncMouse) @@ -7167,7 +7152,7 @@ { if ( pGame && !pAsyncMouse ) { - v34 = GetPickDepth(); + v34 = pGame->pIndoorCameraD3D->GetPickDepth(); pGame->PickMouse(v34, (unsigned __int16)lParam, lParam >> 16, 1, &vis_sprite_filter_3, &vis_face_filter); return DefWindowProcA(hWnd, Msg, wParam, lParam); } @@ -11283,7 +11268,7 @@ v115 = 8 * v153; v129 = 0; v128 = -1; - LOBYTE(v115) = PID(v153,OBJECT_Item); + LOBYTE(v115) = PID(OBJECT_Item,v153); v127 = 0; v126 = v115; v116 = v143; @@ -11553,7 +11538,7 @@ LABEL_132: v73 = v2->vPosition.z; v74 = v2->vPosition.y; - v75 = PID(v72,OBJECT_Item); + v75 = PID(OBJECT_Item,v72); v2->vVelocity.z = v66; v2->vVelocity.y = v66; v76 = v2->vPosition.x; @@ -11872,7 +11857,7 @@ v2->vVelocity.z = 0; v38 = 8 * v153; v39 = v2->vPosition.y; - LOBYTE(v38) = PID(v153,OBJECT_Item); + LOBYTE(v38) = PID(OBJECT_Item,v153); v2->vVelocity.y = 0; v2->vVelocity.x = 0; v40 = v2->vPosition.x; @@ -11930,7 +11915,7 @@ v2->uSpriteFrameID = v32; v102 = 8 * v153; v103 = v2->vPosition.y; - LOBYTE(v102) = PID(v153,OBJECT_Item); + LOBYTE(v102) = PID(OBJECT_Item,v153); v2->vVelocity.x = v32; v2->vVelocity.y = v32; v104 = v2->vPosition.x; @@ -12024,7 +12009,7 @@ v13 = 8 * v153; v129 = v9; v128 = -1; - LOBYTE(v13) = PID(v153,OBJECT_Item); + LOBYTE(v13) = PID(OBJECT_Item,v153); v127 = v9; v126 = v13; LABEL_28: diff -r cd355e4c6104 -r 4568f1e4d61b mm7_3.cpp --- a/mm7_3.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/mm7_3.cpp Mon Apr 01 18:52:19 2013 +0600 @@ -1114,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 ) { @@ -1178,7 +1178,7 @@ { if ( v71 == 0 ) { - Actor::_402968(v75, v38, 0, (AIDirection *)0); + Actor::Flee(v75, v38, 0, (AIDirection *)0); } else { @@ -1191,7 +1191,7 @@ } else if ( pActors[v39].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly ) { - Actor::_402968(v75, v38, 0, (AIDirection *)0); + Actor::Flee(v75, v38, 0, (AIDirection *)0); } else { @@ -1447,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: @@ -2343,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 ) @@ -4768,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; @@ -6086,8 +6086,8 @@ v37 += ((unsigned __int64)(_this.ptr_38->field_10 * v13) >> 16); v36 += ((unsigned __int64)(_this.ptr_38->field_1C * v13) >> 16); - v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + (signed int)((unsigned __int64)(v37 * v18) >> 16) / 8; - v36 = 224 * pMiscTimer->uTotalGameTimeElapsed + (signed int)((unsigned __int64)(v36 * v18) >> 16) / 8; + v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_sub0(v37, v18) / 8; + v36 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_sub0(v36, v18) / 8; //array_50AC10[i].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist; //array_50AC10[i].vWorldPosition.x = v36 / (_this.pTexture->uTextureHeight * 65536.0); @@ -6225,7 +6225,7 @@ uFaceID = v65; } v56 = 8 * uFaceID; - LOBYTE(v56) = PID(uFaceID,OBJECT_BModel); + LOBYTE(v56) = PID(OBJECT_BModel,uFaceID); v57 = v56; v58 = pFace->GetTexture(); pRenderer->DrawIndoorPolygon(v3, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], v58, v57, -1, 0); @@ -7759,7 +7759,7 @@ v15 = grid_x2 - a1; v13 = grid_z1 - a2; } - return v14 + v8 + fixpoint_mul(v13, (v10 - v8) * 128) + fixpoint_mul(v15, (v9 - v8) * 128); + return v14 + v8 + fixpoint_sub0(v13, (v10 - v8) * 128) + fixpoint_sub0(v15, (v9 - v8) * 128); } else return y_x1z1; @@ -11151,11 +11151,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; @@ -11308,12 +11308,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 ) @@ -14970,7 +14970,7 @@ { v20 = &pActors[ai_near_actors_ids[v18]]; if ( v20->uAttributes & 0x8000 - || (v21 = sub_4070EF_prolly_collide_objects(PID(ai_near_actors_ids[v18],OBJECT_Actor), 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; @@ -15104,8 +15104,8 @@ char v35; // al@150 unsigned int v36; // edi@152 signed int v37; // eax@154 - unsigned __int8 v38; // sf@158 - unsigned __int8 v39; // of@158 + //unsigned __int8 v38; // sf@158 + //unsigned __int8 v39; // of@158 //signed int v40; // edx@166 //unsigned int v41; // ecx@166 double v42; // st7@176 @@ -15114,15 +15114,15 @@ bool v45; // eax@192 unsigned __int8 v46; // cl@197 double v47; // st7@206 - double v48; // st7@207 + //double v48; // st7@207 //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 - double v56; // st7@226 + //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 @@ -15153,6 +15153,7 @@ unsigned int v84; // [sp+A8h] [bp-8h]@11 signed int target_pid; // [sp+ACh] [bp-4h]@83 AIState uAIState; + int v38; if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) MakeActorAIList_ODM(); @@ -15196,7 +15197,7 @@ { if ( v7 >= 0 ) { - Actor::_4030AD(v84, 4, 0); + Actor::Stun(v84, 4, 0); } else { @@ -15279,7 +15280,7 @@ if ( (signed __int64)actor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 ) actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; // not sure - else // if ( (signed __int64)v21->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 ) + else if ( (signed __int64)actor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 ) actor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[actor->pMonsterInfo.uID].uHostilityType; if ((signed __int64)actor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0 @@ -15366,7 +15367,7 @@ 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 ) + 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 ) { @@ -15383,12 +15384,12 @@ v21->uCurrentActionTime += pMiscTimer->uTimeElapsed; if ( (signed int)v28 > 0 ) v21->pMonsterInfo.uRecoveryTime = v28 - v27; - if ( v21->pMonsterInfo.uRecoveryTime< 0 ) + if ( v21->pMonsterInfo.uRecoveryTime < 0 ) v21->pMonsterInfo.uRecoveryTime = 0; if ( !(v21->uAttributes & 0x8000) ) v21->uAttributes |= 0x8000; - a1 = 8 * actor_id | OBJECT_Actor; - v30 = Actor::GetDirectionInfo(8 * actor_id | OBJECT_Actor, target_pid, &a3, 0); + 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; @@ -15428,24 +15429,24 @@ else if ( v21->uAIState == AttackingRanged1 ) { v34 = v21->pMonsterInfo.uMissleAttack1Type; - Actor::_404874(actor_id, &pDir, v34, 0); + Actor::RangedAttack(actor_id, &pDir, v34, 0); } else if ( v21->uAIState == AttackingRanged2 ) { v34 = v21->pMonsterInfo.uMissleAttack2Type; - Actor::_404874(actor_id, &pDir, v34, 1); + Actor::RangedAttack(actor_id, &pDir, v34, 1); } else if ( v21->uAIState == AttackingRanged3 ) { v65 = v21->pMonsterInfo.uSpellSkillAndMastery1; v33 = v21->pMonsterInfo.uSpell1ID; - Actor::_404AC7(actor_id, &pDir, v33, 2, v65); + Actor::SpellAttack(actor_id, &pDir, v33, 2, v65); } else if ( v21->uAIState == AttackingRanged4 ) { v65 = v21->pMonsterInfo.uSpellSkillAndMastery2; v33 = v21->pMonsterInfo.uSpell2ID; - Actor::_404AC7(actor_id, &pDir, v33, 3, v65); + Actor::SpellAttack(actor_id, &pDir, v33, 3, v65); } } @@ -15462,22 +15463,26 @@ { 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 ) + if ( v37 >= 1 && v37 <= 4 && v36 < v38 || v37 == 1 ) v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; } @@ -15491,12 +15496,12 @@ { //peasents after attacked //guard after attacked - Actor::_402968(actor_id, target_pid, 0, &pDir); + Actor::Flee(actor_id, target_pid, 0, &pDir); } continue; } - if ( /*v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long &&*/ target_pid ) // temporary + if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long && target_pid ) { if ( v21->pMonsterInfo.uAIType == 1 ) @@ -15507,7 +15512,7 @@ } else { - Actor::_402968(actor_id, target_pid, 0, &pDir); + Actor::Flee(actor_id, target_pid, 0, &pDir); continue; } @@ -15524,7 +15529,7 @@ v42 = (double)(signed int)v84; if ( v43 > v42 && (signed int)v36 < 10240 ) { - Actor::_402968(actor_id, target_pid, 0, &pDir); + Actor::Flee(actor_id, target_pid, 0, &pDir); continue; } } @@ -15546,7 +15551,7 @@ { if ( (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 ) { - Actor::_403476(actor_id, target_pid, &pDir); + Actor::MissileAttack1(actor_id, target_pid, &pDir); } else if ( v21->pMonsterInfo.uMovementType == 5 ) { @@ -15557,19 +15562,20 @@ else { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - if ( !(v54 | v55) ) + if ( v80 * 307.2 > (double)v81 ) { v64 = (signed __int64)v47; Actor::AI_Stand(actor_id, target_pid, v64, &pDir); - continue; } - Actor::_402AD7(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); + else + { + Actor::Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); + } } } else { - v56 = v80 * 307.2; - if ( (double)v81 >= v56 ) + if ( (double)v81 >= v80 * 307.2 ) { if ( v81 >= 1024 ) { @@ -15582,7 +15588,7 @@ else { //monsters - Actor::_402686(actor_id, target_pid, 0, &pDir); + Actor::Pursue3(actor_id, target_pid, 0, &pDir); } } else if ( v21->pMonsterInfo.uMovementType == 5 ) @@ -15593,11 +15599,11 @@ } else { - v70 = (signed __int64)v56; + v70 = (signed __int64)v80 * 307.2; //monsters //guard after player runs away // follow player - Actor::_40281C(actor_id, target_pid, 0, &pDir, v70); + Actor::Pursue2(actor_id, target_pid, 0, &pDir, v70); } } else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) @@ -15609,7 +15615,7 @@ else { //monsters - Actor::_403C6C(actor_id, target_pid, &pDir); + Actor::MeleeAttack(actor_id, target_pid, &pDir); } } continue; @@ -15625,9 +15631,9 @@ if ( (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 ) { if ( v45 == 2 ) - Actor::_403854(actor_id, target_pid, &pDir); + Actor::SpellAttack1(actor_id, target_pid, &pDir); else - Actor::_403A60(actor_id, target_pid, &pDir); + Actor::SpellAttack2(actor_id, target_pid, &pDir); } else if ( v80 * 307.2 > (double)v81 || v21->pMonsterInfo.uMovementType == 5 ) { @@ -15638,13 +15644,12 @@ else { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - Actor::_402AD7(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); + Actor::Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); } } else { - v48 = v80 * 307.2; - if ( (double)v81 >= v48 ) + if ( (double)v81 >= v80 * 307.2 ) { if ( v81 >= 1024 ) { @@ -15656,7 +15661,7 @@ } else { - Actor::_402686(actor_id, target_pid, 256, &pDir); + Actor::Pursue3(actor_id, target_pid, 256, &pDir); } } else if ( v21->pMonsterInfo.uMovementType == 5 ) @@ -15667,8 +15672,8 @@ } else { - v70 = (signed __int64)v48; - Actor::_40281C(actor_id, target_pid, 0, &pDir, v70); + v70 = (signed __int64)v80 * 307.2; + Actor::Pursue2(actor_id, target_pid, 0, &pDir, v70); } } else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) @@ -15679,7 +15684,7 @@ } else { - Actor::_403C6C(actor_id, target_pid, &pDir); + Actor::MeleeAttack(actor_id, target_pid, &pDir); } } continue; @@ -15717,8 +15722,7 @@ } else if ( !v21->pMonsterInfo.uMissleAttack2Type ) { - v56 = v80 * 307.2; - if ( (double)v81 >= v56 ) + if ( (double)v81 >= v80 * 307.2 ) { if ( v81 >= 1024 ) { @@ -15730,7 +15734,7 @@ } else { - Actor::_402686(actor_id, target_pid, 256, &pDir); + Actor::Pursue3(actor_id, target_pid, 256, &pDir); } } else if ( v21->pMonsterInfo.uMovementType == 5 ) @@ -15741,8 +15745,8 @@ } else { - v70 = (signed __int64)v56; - Actor::_40281C(actor_id, target_pid, 0, &pDir, v70); + v70 = (signed __int64)v80 * 307.2; + Actor::Pursue2(actor_id, target_pid, 0, &pDir, v70); } } else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) @@ -15753,25 +15757,25 @@ } else { - Actor::_403C6C(actor_id, target_pid, &pDir); + Actor::MeleeAttack(actor_id, target_pid, &pDir); } } else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - if ( !(v54 | v55) || v21->pMonsterInfo.uMovementType == 5 ) + if ( v80 * 307.2 > (double)v81 || v21->pMonsterInfo.uMovementType == 5 ) { v64 = (signed __int64)v47; Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { - Actor::_402AD7(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); + Actor::Pursue1(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); } } else { - Actor::_40368B(actor_id, target_pid, &pDir); + Actor::MissileAttack2(actor_id, target_pid, &pDir); } } } @@ -15928,7 +15932,7 @@ result = v1->pQueue[0].uPackedID; if ( PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) { - result = (result >> 3) + 1; + result = PID_ID(result) + 1; uActiveCharacter = result; v1->field_18 |= 4u; } @@ -15944,7 +15948,7 @@ do { if ( PID_TYPE(v17->uPackedID) == OBJECT_Player) - pParty->pPlayers[v17->uPackedID >> 3].uTimeToRecovery = (signed __int64)((double)v17->field_4 * 0.46875); + pParty->pPlayers[PID_ID(v17->uPackedID)].uTimeToRecovery = (signed __int64)((double)v17->field_4 * 0.46875); ++v22; ++v17; result = v22; @@ -16024,7 +16028,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; @@ -16054,8 +16058,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; diff -r cd355e4c6104 -r 4568f1e4d61b mm7_4.cpp --- a/mm7_4.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/mm7_4.cpp Mon Apr 01 18:52:19 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, PID(i,OBJECT_Decoration), 1); + EventProcessor(v1->field_16_event_id, PID(OBJECT_Decoration,i), 1); } if ( v1->field_2 & 2 ) { @@ -306,7 +306,7 @@ else { auto a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]); - auto res = fixpoint_mul((signed int)word_721460_xs[j + 1] - (signed int)word_721460_xs[j], a_div_b); + auto res = fixpoint_sub0((signed int)word_721460_xs[j + 1] - (signed int)word_721460_xs[j], a_div_b); if (res + word_721460_xs[j] >= x) ++v53; @@ -324,7 +324,7 @@ } else { - v21 = fixpoint_mul(pFloor->zCalc1, x) + fixpoint_mul(pFloor->zCalc2, y) + (short)(pFloor->zCalc3 >> 16); + v21 = fixpoint_sub0(pFloor->zCalc1, x) + fixpoint_sub0(pFloor->zCalc2, y) + (short)(pFloor->zCalc3 >> 16); } blv_floor_level[v55] = v21; blv_floor_id[v55] = pSector->pFloors[i]; @@ -377,7 +377,7 @@ else { auto a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]); - auto res = fixpoint_mul(word_721460_xs[j + 1] - word_721460_xs[j], a_div_b); + auto res = fixpoint_sub0(word_721460_xs[j + 1] - word_721460_xs[j], a_div_b); if (res + word_721460_xs[j] >= x) ++v54; } @@ -977,7 +977,7 @@ { stru_721530.field_7C = v13; v14 = 8 * v16; - LOBYTE(v14) = PID(v16,OBJECT_Actor); + LOBYTE(v14) = PID(OBJECT_Actor,v16); stru_721530.uFaceID = v14; } result = 1; @@ -2133,11 +2133,11 @@ v17 = pActors[v16].vPosition.y; a1.vPosition.z = pActors[v16].vPosition.z; v18 = 8 * v15; - LOBYTE(v18) = PID(v15,OBJECT_Actor); + LOBYTE(v18) = PID(OBJECT_Actor,v15); a1.vPosition.y = v17; a1.spell_target_pid = v18; v19 = a1.Create(0, 0, 0, 0); - DamageMonsterFromParty(PID(v19,OBJECT_Item), *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) = PID(uFaceID,OBJECT_BModel); + 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; @@ -6326,7 +6326,7 @@ v7 =&pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v5]; goto LABEL_15; } - if ( in_current_building_type <= BildingType_16 && dialog_menu_id == HOUSE_DIALOGUE_GULD_BUY_BOOKS ) + if ( in_current_building_type <= BildingType_16 && dialog_menu_id == HOUSE_DIALOGUE_GUILD_BUY_BOOKS ) { v1 = pMouse->GetCursorPos(&a2); v2 = v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v16)->y]; @@ -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; diff -r cd355e4c6104 -r 4568f1e4d61b mm7_5.cpp --- a/mm7_5.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/mm7_5.cpp Mon Apr 01 18:52:19 2013 +0600 @@ -3960,18 +3960,6 @@ return result; } -//----- (0043643E) -------------------------------------------------------- -double __cdecl GetPickDepth() -{ - double result; // st7@2 - - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - result = (double)pOutdoorCamera->uPickDepth; - else - result = 16192.0; - return result; -} - //----- (0043648F) -------------------------------------------------------- void Vec3_short__to_RenderVertexSoft(RenderVertexSoft *_this, Vec3_short_ *a2) { @@ -5046,7 +5034,7 @@ } if ( pMonster->sCurrentHP > 0 ) { - Actor::_4030AD(uActorID_Monster_, a1, 0); + Actor::Stun(uActorID_Monster_, a1, 0); Actor::AggroSurroundingPeasants(uActorID_Monster_, 1); if ( bShowDamage ) { @@ -5321,7 +5309,7 @@ } v17 = (SoundID)a4; LABEL_26: - pAudioPlayer->PlaySound(v17, PID(a4 + 80,OBJECT_Player), 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 +5369,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 @@ -5567,7 +5555,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 @@ -5859,7 +5847,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 +5866,7 @@ } else { - Actor::_4030AD(uActorIDa, a2, 0); + Actor::Stun(uActorIDa, a2, 0); } } } @@ -5967,7 +5955,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 +5975,7 @@ } else { - Actor::_4030AD(uActorID, v17, 0); + Actor::Stun(uActorID, v17, 0); } return; } @@ -6281,7 +6269,7 @@ //LABEL_15: pSex = 1; return pSex;*/ - for (uint i = 1; i <= 4; pPlayers[i]) + for (uint i = 1; i <= 4; ++i) { pRace = pPlayers[i]->GetRace(); pSex = pPlayers[i]->GetSexByVoice(); @@ -6779,7 +6767,7 @@ { *(int *)v4 = 100; v6 = 8 * v19; - LOBYTE(v6) = PID(v19,OBJECT_Player); + LOBYTE(v6) = PID(OBJECT_Player,v19); *((int *)v4 + 2) = v2; *((int *)v4 - 1) = v6; *((int *)v4 + 1) = v2; @@ -6815,7 +6803,7 @@ v9 = ai_near_actors_ids[v20]; *(int *)v7 = 1; *((int *)v7 + 2) = v2; - *((int *)v7 - 1) = PID(v9,OBJECT_Actor); + *((int *)v7 - 1) = PID(OBJECT_Actor,v9); *((int *)v7 + 1) = v2; ++v3; v7 += 16; @@ -7339,7 +7327,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 +7343,7 @@ v18 = v5->pMonsterInfo.uMissleAttack1Type; v25 = 0; } - Actor::_404874(v4, &a4, v18, v25); + Actor::RangedAttack(v4, &a4, v18, v25); goto LABEL_25; } } @@ -7409,7 +7397,7 @@ if ( v5->pMonsterInfo.uHostilityType && !*v6 ) v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; v22 = *v6; - v7 = Actor::GetDirectionInfo(PID((int)v4,OBJECT_Actor), *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)); @@ -7470,7 +7458,7 @@ { if ( v5->pMonsterInfo.uMissleAttack2Type ) { - Actor::_40368B(v13, v22, &v18); + Actor::MissileAttack2(v13, v22, &v18); goto LABEL_43; } } @@ -7485,16 +7473,16 @@ 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; v21->field_C = 1; @@ -7507,7 +7495,7 @@ LABEL_44: if ( (double)(signed int)v20 < 307.2 ) { - Actor::_403C6C(v13, v22, &v18); + Actor::MeleeAttack(v13, v22, &v18); //v3 = v21; v21->field_C = 3; goto LABEL_48; @@ -7827,7 +7815,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; @@ -7844,9 +7832,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: diff -r cd355e4c6104 -r 4568f1e4d61b mm7_6.cpp --- a/mm7_6.cpp Mon Apr 01 18:52:06 2013 +0600 +++ b/mm7_6.cpp Mon Apr 01 18:52:19 2013 +0600 @@ -7382,7 +7382,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; pGame->GetIndoorCamera(); - v623 = (signed __int64)GetPickDepth(); + v623 = (signed __int64)pGame->pIndoorCameraD3D->GetPickDepth(); HIDWORD(v733) = sub_46A6AC((int)dword_50BF30, 100, v623); v707.x = 0; v707.y = 0; diff -r cd355e4c6104 -r 4568f1e4d61b mm7_data.h --- a/mm7_data.h Mon Apr 01 18:52:06 2013 +0600 +++ b/mm7_data.h Mon Apr 01 18:52:19 2013 +0600 @@ -8,38 +8,6 @@ typedef unsigned int uint; -/* -#define LOWORD(a) (*((unsigned short *)&a)) -#define SLOWORD(a) (__debugbreak(), *((signed short *)&a)) -#define HIWORD(a) (*((unsigned short *)&a + 1)) -#define SHIWORD(a) (*((short *)&a + 1)) - -#define LODWORD(a) (*((unsigned int *)&a)) -#define HIDWORD(a) (*((unsigned int *)&a + 1)) -#define SLODWORD(a) (*((int *)&a)) -#define SHIDWORD(a) (*((int *)&a + 1)) - -#define LOBYTE(a) (*((unsigned char *)&a)) -#define SLOBYTE(a) (*((signed char *)&a)) - -#define HIBYTE(a) (*((unsigned char *)&a + sizeof(a) - 1)) - -#define BYTE1(a) (*((unsigned char *)&a + 1)) -#define SBYTE1(a) (*((signed char *)&a + 1)) - -#define BYTE2(a) (*((unsigned char *)&a + 2)) -#define BYTE3(a) (*((unsigned char *)&a + 3)) - -#define WORD2(a) (__debugbreak(), *(unsigned short *)((char *)&a + 4)) - -#define __OFSUB__(a, b) (unsigned __int8)((a) == (b)) - - -typedef unsigned __int16 _WORD; -typedef unsigned __int64 _QWORD; -*/ - - @@ -1749,7 +1717,6 @@ void __cdecl back_to_game(); void __cdecl GUI_MainMenuMessageProc(); double __cdecl get_shading_dist_mist(); -double __cdecl GetPickDepth(); void Vec3_short__to_RenderVertexSoft(struct RenderVertexSoft *_this, struct Vec3_short_ *a2); void __cdecl nullsub_4(); // idb void __cdecl nullsub_5(); // idb @@ -2144,8 +2111,9 @@ signed int __fastcall SpawnRandomTreasure(struct MapInfo *a1, struct SpawnPointMM7 *a2); void DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, struct Vec3_int_ *pVelocity); +int fixpoint_sub0(int, int); +int fixpoint_div(int, int); int fixpoint_mul(int, int); -int fixpoint_div(int, int); #define ErrD3D(hr) do {extern void ErrHR(HRESULT, const char *, const char *, const char *, int); ErrHR(hr, "Direct3D", __FUNCTION__, __FILE__, __LINE__);} while(0)