Mercurial > mm7
changeset 2117:c7bf59066842
mm7_4-6 cleaned
author | Ritor1 |
---|---|
date | Mon, 23 Dec 2013 23:38:51 +0600 |
parents | 68fbaf45ef66 |
children | 16e2ed54f269 |
files | mm7_4.cpp mm7_5.cpp mm7_6.cpp |
diffstat | 3 files changed, 209 insertions(+), 373 deletions(-) [+] |
line wrap: on
line diff
--- a/mm7_4.cpp Mon Dec 23 17:30:22 2013 +0600 +++ b/mm7_4.cpp Mon Dec 23 23:38:51 2013 +0600 @@ -45,31 +45,27 @@ //----- (0046CC4B) -------------------------------------------------------- void check_event_triggers() { - LevelDecoration *v1; // esi@2 - for (size_t i = 0; i < num_event_triggers; i++) { - v1 = &pLevelDecorations[event_triggers[i]]; - - if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_TOUCH - && v1->vPosition.GetDistanceTo(pParty->vPosition) < v1->uTriggerRange) + if (pLevelDecorations[event_triggers[i]].uFlags & LEVEL_DECORATION_TRIGGERED_BY_TOUCH + && pLevelDecorations[event_triggers[i]].vPosition.GetDistanceTo(pParty->vPosition) < pLevelDecorations[event_triggers[i]].uTriggerRange) { - EventProcessor(v1->uEventID, PID(OBJECT_Decoration,i), 1); + EventProcessor(pLevelDecorations[event_triggers[i]].uEventID, PID(OBJECT_Decoration,i), 1); } - else if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_MONSTER) + else if (pLevelDecorations[event_triggers[i]].uFlags & LEVEL_DECORATION_TRIGGERED_BY_MONSTER) { for (size_t j = 0; j < uNumActors; j++) { - if (v1->vPosition.GetDistanceTo(pActors[j].vPosition) < v1->uTriggerRange) - EventProcessor(v1->uEventID, 0, 1); + if (pLevelDecorations[event_triggers[i]].vPosition.GetDistanceTo(pActors[j].vPosition) < pLevelDecorations[event_triggers[i]].uTriggerRange) + EventProcessor(pLevelDecorations[event_triggers[i]].uEventID, 0, 1); } } - else if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_OBJECT) + else if (pLevelDecorations[event_triggers[i]].uFlags & LEVEL_DECORATION_TRIGGERED_BY_OBJECT) { for (size_t j = 0; j < uNumSpriteObjects; j++) { - if (v1->vPosition.GetDistanceTo(pSpriteObjects[j].vPosition) < v1->uTriggerRange) - EventProcessor(v1->uEventID, 0, 1); + if (pLevelDecorations[event_triggers[i]].vPosition.GetDistanceTo(pSpriteObjects[j].vPosition) < pLevelDecorations[event_triggers[i]].uTriggerRange) + EventProcessor(pLevelDecorations[event_triggers[i]].uEventID, 0, 1); } } } @@ -90,17 +86,11 @@ //----- (0046E0B2) -------------------------------------------------------- void _46E0B2_collide_against_decorations() { - BLVSector *v0; // ebp@1 - LevelDecoration *v1; // edi@2 - DecorationDesc *v2; // esi@3 - int v3; // edx@4 - int v4; // eax@4 - int v5; // ecx@6 - int v6; // ebx@8 - int v7; // esi@8 + BLVSector *sector; // ebp@1 + LevelDecoration *decor; // edi@2 + DecorationDesc *decor_desc; // esi@3 int v8; // ebx@10 int v9; // esi@11 - int v10; // edi@12 int v11; // eax@12 int v12; // esi@14 unsigned int v13; // eax@17 @@ -108,65 +98,44 @@ int v15; // [sp+8h] [bp-10h]@10 int v16; // [sp+Ch] [bp-Ch]@10 int v17; // [sp+10h] [bp-8h]@10 - int v18; // [sp+14h] [bp-4h]@8 - v0 = &pIndoor->pSectors[stru_721530.uSectorID]; - for ( i = 0; i < v0->uNumDecorations; ++i ) + sector = &pIndoor->pSectors[stru_721530.uSectorID]; + for ( i = 0; i < sector->uNumDecorations; ++i ) { - v1 = &pLevelDecorations[v0->pDecorationIDs[i]]; - if (!(v1->uFlags & LEVEL_DECORATION_INVISIBLE)) + decor = &pLevelDecorations[sector->pDecorationIDs[i]]; + if (!(decor->uFlags & LEVEL_DECORATION_INVISIBLE)) { - v2 = &pDecorationList->pDecorations[v1->uDecorationDescID]; - if (!v2->CanMoveThrough()) + decor_desc = &pDecorationList->pDecorations[decor->uDecorationDescID]; + if (!decor_desc->CanMoveThrough()) { - v3 = v2->uRadius; - v4 = v1->vPosition.x; - if ( stru_721530.sMaxX <= v4 + v3 ) + if ( stru_721530.sMaxX <= decor->vPosition.x + decor_desc->uRadius && stru_721530.sMinX >= decor->vPosition.x - decor_desc->uRadius + && stru_721530.sMaxY <= decor->vPosition.y + decor_desc->uRadius && stru_721530.sMinY >= decor->vPosition.y - decor_desc->uRadius + && stru_721530.sMaxZ <= decor->vPosition.z + decor_desc->uDecorationHeight && stru_721530.sMinZ >= decor->vPosition.z ) { - if ( stru_721530.sMinX >= v4 - v3 ) + v16 = decor->vPosition.x - stru_721530.normal.x; + v15 = decor->vPosition.y - stru_721530.normal.y; + v8 = stru_721530.prolly_normal_d + decor_desc->uRadius; + v17 = ((decor->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y + - (decor->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16; + if ( abs(v17) <= stru_721530.prolly_normal_d + decor_desc->uRadius ) { - v5 = v1->vPosition.y; - if ( stru_721530.sMaxY <= v5 + v3 ) + v9 = (v16 * stru_721530.direction.x + v15 * stru_721530.direction.y) >> 16; + if ( v9 > 0 ) { - if ( stru_721530.sMinY >= v5 - v3 ) + v11 = stru_721530.normal.z + fixpoint_mul(stru_721530.direction.z, v9); + if ( v11 >= decor->vPosition.z ) { - v6 = v2->uDecorationHeight; - v7 = v1->vPosition.z; - v18 = v6; - if ( stru_721530.sMaxZ <= v7 + v6 ) + if ( v11 <= decor_desc->uDecorationHeight + decor->vPosition.z ) { - if ( stru_721530.sMinZ >= v7 ) + v12 = v9 - integer_sqrt(v8 * v8 - v17 * v17); + if ( v12 < 0 ) + v12 = 0; + if ( v12 < stru_721530.field_7C ) { - v16 = v4 - stru_721530.normal.x; - v15 = v5 - stru_721530.normal.y; - v8 = stru_721530.prolly_normal_d + v3; - v17 = ((v4 - stru_721530.normal.x) * stru_721530.direction.y - - (v5 - stru_721530.normal.y) * stru_721530.direction.x) >> 16; - if ( abs(v17) <= stru_721530.prolly_normal_d + v3 ) - { - v9 = (v16 * stru_721530.direction.x + v15 * stru_721530.direction.y) >> 16; - if ( v9 > 0 ) - { - v10 = v1->vPosition.z; - v11 = stru_721530.normal.z + fixpoint_mul(stru_721530.direction.z, v9); - if ( v11 >= v10 ) - { - if ( v11 <= v18 + v10 ) - { - v12 = v9 - integer_sqrt(v8 * v8 - v17 * v17); - if ( v12 < 0 ) - v12 = 0; - if ( v12 < stru_721530.field_7C ) - { - stru_721530.field_7C = v12; - v13 = 8 * v0->pDecorationIDs[i]; - LOBYTE(v13) = v13 | 5; - stru_721530.uFaceID = v13; - } - } - } - } - } + stru_721530.field_7C = v12; + v13 = 8 * sector->pDecorationIDs[i]; + LOBYTE(v13) = v13 | 5; + stru_721530.uFaceID = v13; } } } @@ -225,95 +194,54 @@ //----- (00491E3A) -------------------------------------------------------- void sub_491E3A() { - Player *v0; // ebx@1 signed int v1; // esi@3 - char *v2; // eax@4 unsigned int v3; // eax@7 unsigned int v4; // edx@8 - char *v5; // ecx@9 int v6; // edi@17 - Texture *v7; // ebx@18 - struct IDirect3DTexture2 **v8; // eax@19 - struct IDirect3DTexture2 *v9; // eax@20 - struct IDirectDrawSurface **v10; // eax@22 - struct IDirectDrawSurface *v11; // eax@23 int v12; // eax@26 - v0 = pParty->pPlayers.data(); - do + __debugbreak();//Ritor1 + for ( uint pl = 0; pl < 4; pl++ ) { if (SoundSetAction[24][0]) { - v1 = 0; - if ( (signed int)pSoundList->sNumSounds <= 0 ) - { -LABEL_7: - v3 = 0; - } - else + v3 = 0; + for ( v1 = 0; v1 < (signed int)pSoundList->sNumSounds; ++v1 ) { - v2 = (char *)&pSoundList->pSL_Sounds->uSoundID; - while ( *(int *)v2 != 2 * (SoundSetAction[24][0] + 50 * v0->uVoiceID) + 4998 ) - { - ++v1; - v2 += 120; - if ( v1 >= (signed int)pSoundList->sNumSounds ) - goto LABEL_7; - } - v3 = v1; + if ( pSoundList->pSL_Sounds[v1].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[pl].uVoiceID) + 4998 ) + v3 = v1; } pSoundList->UnloadSound(v3, 1); - v4 = 0; - if ( (signed int)pSoundList->sNumSounds <= 0 ) - { -LABEL_12: - v4 = 0; - } - else + for ( v4 = 0; (signed int)v4 < (signed int)pSoundList->sNumSounds; ++v4 ) { - v5 = (char *)&pSoundList->pSL_Sounds->uSoundID; - while ( *(int *)v5 != 2 * (SoundSetAction[24][0] + 50 * v0->uVoiceID) + 4999 ) - { - ++v4; - v5 += 120; - if ( (signed int)v4 >= (signed int)pSoundList->sNumSounds ) - goto LABEL_12; - } + if ( pSoundList->pSL_Sounds[v4].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[pl].uVoiceID) + 4999 ) + pSoundList->UnloadSound(v4, 1); } - pSoundList->UnloadSound(v4, 1); } - ++v0; } - while ( (signed int)v0 < (signed int)pParty->pHirelings.data() ); v6 = pIcons_LOD->uNumLoadedFiles - 1; if ( v6 >= pIcons_LOD->pFacesLock ) { - v7 = &pIcons_LOD->pTextures[v6]; do { - v7->Release(); - v8 = pIcons_LOD->pHardwareTextures; - if ( v8 ) + pIcons_LOD->pTextures[v6].Release(); + if ( pIcons_LOD->pHardwareTextures ) { - v9 = v8[v6]; - if ( v9 ) + if ( pIcons_LOD->pHardwareTextures[v6] ) { - v9->Release(); + pIcons_LOD->pHardwareTextures[v6]->Release(); pIcons_LOD->pHardwareTextures[v6] = 0; } } - v10 = pIcons_LOD->pHardwareSurfaces; - if ( v10 ) + if ( pIcons_LOD->pHardwareSurfaces ) { - v11 = v10[v6]; - if ( v11 ) + if ( pIcons_LOD->pHardwareSurfaces[v6] ) { - v11->Release(); + pIcons_LOD->pHardwareSurfaces[v6]->Release(); pIcons_LOD->pHardwareSurfaces[v6] = 0; } } --v6; - --v7; } while ( v6 >= pIcons_LOD->pFacesLock ); } @@ -990,7 +918,7 @@ int v3; // esi@1 int result; // eax@1 //stru339_spell_sound *v5; // ebx@1 - int *v6; // edi@2 + //int *v6; // edi@2 unsigned int v7; // eax@3 int v8; // [sp+Ch] [bp-8h]@3 int v9; // [sp+10h] [bp-4h]@2 @@ -1002,7 +930,7 @@ a2a = word_4EE088_sound_ids[uSoundID]; if ( word_4EE088_sound_ids[uSoundID] ) { - v6 = this->pSoundsOffsets; + //v6 = this->pSoundsOffsets; for ( v9 = 0; v9 < 2; ++v9 ) { v7 = a2a++; @@ -1014,7 +942,7 @@ this->pSoundsOffsets[v9] = v3; v3 += result; this->pSoundsSizes[v9] = v8 + 256; - ++v6; + //++v6; } } return result; @@ -1036,8 +964,6 @@ PlayerFrame *PlayerFrameTable::GetFrameBy_x(unsigned int uFramesetID, unsigned int uFrameID) { unsigned int v3; // esi@1 - PlayerFrame *v4; // edi@1 - PlayerFrame *v5; // ecx@1 __int16 v6; // dx@2 int v7; // edx@3 char *i; // eax@3 @@ -1045,12 +971,10 @@ PlayerFrame *result; // eax@6 v3 = uFramesetID; - v4 = this->pFrames; - v5 = &v4[uFramesetID]; - if ( v5->uFlags & 1 && (v6 = v5->uAnimLength) != 0 ) + if ( this->pFrames[uFramesetID].uFlags & 1 && (v6 = this->pFrames[uFramesetID].uAnimLength) != 0 ) { v7 = ((signed int)uFrameID >> 3) % (unsigned __int16)v6; - for ( i = (char *)&v5->uAnimTime; ; i += 10 ) + for ( i = (char *)&this->pFrames[uFramesetID].uAnimTime; ; i += 10 ) { v9 = *(short *)i; if ( v7 <= v9 ) @@ -1058,35 +982,29 @@ v7 -= v9; ++v3; } - result = &v4[v3]; + result = &this->pFrames[v3]; } else - { - result = &v4[uFramesetID]; - } + result = &this->pFrames[uFramesetID]; return result; } //----- (00494B5E) -------------------------------------------------------- PlayerFrame *PlayerFrameTable::GetFrameBy_y(int *pFramesetID, int *pAnimTime, int a4) { - PlayerFrameTable *v4; // edi@1 int v5; // esi@1 int v6; // eax@2 - v4 = this; v5 = a4 + *pAnimTime; if ( v5 < 8 * this->pFrames[*pFramesetID].uAnimTime ) - { *pAnimTime = v5; - } else { v6 = rand() % 4 + 21; *pFramesetID = v6; - *pAnimTime = 8 * v5 % v4->pFrames[v6].uAnimTime; + *pAnimTime = 8 * v5 % this->pFrames[v6].uAnimTime; } - return &v4->pFrames[*pFramesetID]; + return &this->pFrames[*pFramesetID]; } //----- (00494BC3) -------------------------------------------------------- @@ -1103,7 +1021,7 @@ v3 = v2; if ( !v2 ) Error("Unable to save dpft.bin"); - fwrite(v1, 4u, 1u, v2); + fwrite(v1, 4, 1, v2); fwrite(v1->pFrames, 0xAu, v1->uNumFrames, v3); fclose(v3); } @@ -1127,7 +1045,7 @@ //----- (00494C5A) -------------------------------------------------------- int PlayerFrameTable::FromFileTxt(const char *Args) { - PlayerFrameTable *v2; // ebx@1 + //PlayerFrameTable *v2; // ebx@1 FILE *v3; // eax@1 int v4; // esi@3 void *v5; // eax@10 @@ -1143,7 +1061,7 @@ int v15; // ecx@23 int v16; // eax@24 signed int k; // eax@27 - PlayerFrame *v18; // edx@28 + //PlayerFrame *v18; // edx@28 int v19; // esi@28 int l; // ecx@29 char Buf; // [sp+Ch] [bp-2F8h]@3 @@ -1154,7 +1072,7 @@ FILE *File; // [sp+300h] [bp-4h]@1 int Argsa; // [sp+30Ch] [bp+8h]@28 - v2 = this; + __debugbreak();//Ritor1; //TileTable::dtor((TileTable *)this); v3 = fopen(Args, "r"); File = v3; @@ -1180,13 +1098,13 @@ while ( fgets(&Buf, 490, File) ); v4 = v25; } - v2->uNumFrames = v4; + this->uNumFrames = v4; v5 = malloc(10 * v4); - v2->pFrames = (PlayerFrame *)v5; + this->pFrames = (PlayerFrame *)v5; if ( !v5 ) Error("PlayerFrameTable::load - Out of Memory!"); v6 = File; - v2->uNumFrames = 0; + this->uNumFrames = 0; fseek(v6, 0, 0); for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) { @@ -1194,55 +1112,50 @@ memcpy(&v24, txt_file_frametable_parser(&Buf, &v23), sizeof(v24)); if ( v24.uPropCount && *v24.pProperties[0] != 47 ) { - v8 = atoi(v24.pProperties[0]); - v9 = v24.pProperties[1]; - v2->pFrames[v2->uNumFrames].expression = (CHARACTER_EXPRESSION_ID)v8; - v10 = atoi(v9); - v11 = v24.pProperties[2]; - v2->pFrames[v2->uNumFrames].uTextureID = v10; - v2->pFrames[v2->uNumFrames].uAnimTime = atoi(v11); - v2->pFrames[v2->uNumFrames].uAnimLength = 0; - v2->pFrames[v2->uNumFrames].uFlags = 0; + //v8 = atoi(v24.pProperties[0]); + //v9 = v24.pProperties[1]; + this->pFrames[this->uNumFrames].expression = (CHARACTER_EXPRESSION_ID)atoi(v24.pProperties[0]); + //v10 = atoi(v9); + //v11 = v24.pProperties[2]; + this->pFrames[this->uNumFrames].uTextureID = atoi(v24.pProperties[1]); + this->pFrames[this->uNumFrames].uAnimTime = atoi(v24.pProperties[2]); + this->pFrames[this->uNumFrames].uAnimLength = 0; + this->pFrames[this->uNumFrames].uFlags = 0; for ( j = 3; j < v24.uPropCount; ++j ) { if ( !_stricmp(v24.pProperties[j], "New") ) - { - v13 = (int)&v2->pFrames[v2->uNumFrames].uFlags; - *(char *)v13 |= 4u; - } + this->pFrames[this->uNumFrames].uFlags |= 4; } - ++v2->uNumFrames; + ++this->uNumFrames; } } fclose(File); - v14 = 0; - if ( (signed int)(v2->uNumFrames - 1) > 0 ) + + if ( (signed int)(this->uNumFrames - 1) > 0 ) { v15 = 0; - do + for ( v14 = 0; v14 < this->uNumFrames - 1; ++v14 ) { - v16 = (int)&v2->pFrames[v15]; + v16 = (int)&this->pFrames[v15]; if ( !(*(char *)(v16 + 18) & 4) ) - *(char *)(v16 + 8) |= 1u; - ++v14; + this->pFrames[v14].uFlags |= 1; ++v15; } - while ( v14 < (signed int)(v2->uNumFrames - 1) ); } - for ( k = 0; k < (signed int)v2->uNumFrames; *(short *)(Argsa + 6) = v19 ) + for ( k = 0; k < (signed int)this->uNumFrames; *(short *)(Argsa + 6) = v19 ) { - v18 = v2->pFrames; - Argsa = (int)&v18[k]; + //v18 = this->pFrames; + Argsa = (int)&this->pFrames[k]; v19 = *(short *)(Argsa + 4); - if ( *(char *)(Argsa + 8) & 1 ) + if ( this->pFrames[k].uFlags & 1 ) { ++k; - for ( l = (int)&v18[k]; *(char *)(l + 8) & 1; l += 10 ) + for ( l = (int)&this->pFrames[k]; this->pFrames[k].uFlags & 1; l += 10 ) { v19 += *(short *)(l + 4); ++k; } - LOWORD(v19) = v18[k].uAnimTime + v19; + LOWORD(v19) = this->pFrames[k].uAnimTime + v19; } ++k; } @@ -1254,7 +1167,7 @@ { int v2; // edi@1 int v3; // edx@2 - int v4; // esi@3 + //int v4; // esi@3 int v5; // ebx@5 signed int v7; // [sp+Ch] [bp-14h]@1 signed int v8; // [sp+10h] [bp-10h]@1 @@ -1267,40 +1180,33 @@ v8 = 0; v7 = 0; if ( dword_AE336C == a1 ) - { v3 = dword_AE3370; - } else { - v4 = a2; + //v4 = a2; dword_AE336C = a1; - v10 = 0; - if ( (signed int)pNPCStats->uNumNPCNames[v4] <= 0 ) - { - v3 = rand() % (signed int)pNPCStats->uNumNPCNames[v4]; - } - else - { - v9 = (int **)((char *)pNPCStats->pNPCNames + v4 * 4); - do + if ( (signed int)pNPCStats->uNumNPCNames[a2] <= 0 ) + v3 = rand() % (signed int)pNPCStats->uNumNPCNames[a2]; + else { - v5 = tolower(*(char *)*v9); - if ( v5 == tolower(v2) ) + v9 = (int **)((char *)pNPCStats->pNPCNames + a2 * 4); + for ( v10 = 0; v10 < (signed int)pNPCStats->uNumNPCNames[a2]; ++v10 ) { - if ( v8 ) - v7 = v10; - else - v8 = v10; + v5 = tolower(*(char *)*v9); + if ( v5 == tolower(v2) ) + { + if ( v8 ) + v7 = v10; + else + v8 = v10; + } + v9 += 2; } - ++v10; - v9 += 2; + if ( v8 && v8 != v7 ) + v3 = v8 + rand() % (v7 - v8); + else + v3 = rand() % (signed int)pNPCStats->uNumNPCNames[a2]; } - while ( v10 < (signed int)pNPCStats->uNumNPCNames[v4] ); - if ( v8 && v8 != v7 ) - v3 = v8 + rand() % (v7 - v8); - else - v3 = rand() % (signed int)pNPCStats->uNumNPCNames[v4]; - } } dword_AE3370 = v3; return pNPCStats->pNPCNames[0][v11 + 2 * v3]; @@ -2081,8 +1987,6 @@ return (a << 24) | (r << 16) | (g << 8) | b; } - - //----- (004B1447) -------------------------------------------------------- void sub_4B1447_party_fine(int a1, int a2, int a3) { @@ -2099,12 +2003,10 @@ v3 = 2; if ( a2 == 2 ) v3 = 2; - goto LABEL_13; + goto LABEL_13; } else - { v3 = 1; - } if ( pParty->uFine < 4000000 ) { v4 = a3 + pParty->uFine < 0;
--- a/mm7_5.cpp Mon Dec 23 17:30:22 2013 +0600 +++ b/mm7_5.cpp Mon Dec 23 23:38:51 2013 +0600 @@ -100,7 +100,7 @@ { v10 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; a1 = pParty->vPosition.x - AttackerInfo.pXs[attacker_id]; - v48 = v10; + v48 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; if ( a1 * a1 + v10 * v10 + ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - AttackerInfo.pZs[attacker_id])) * ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - AttackerInfo.pZs[attacker_id])) @@ -149,7 +149,7 @@ v23 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; v24 = ((signed int)pParty->uPartyHeight >> 1) - AttackerInfo.pZs[attacker_id]; a1 = pParty->vPosition.x - AttackerInfo.pXs[attacker_id]; - v48 = v23; + v48 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; if ( a1 * a1 + v23 * v23 + (pParty->vPosition.z + v24) * (pParty->vPosition.z + v24) < (unsigned int)((AttackerInfo.field_324[attacker_id] + 32) * (AttackerInfo.field_324[attacker_id] + 32)) ) {//party damage (повреждения группе) attacker_coord.x = AttackerInfo.pXs[attacker_id]; @@ -250,21 +250,18 @@ //----- (0043AE12) -------------------------------------------------------- double __fastcall sub_43AE12(signed int a1) { - signed int v1; // ST00_4@1 + //signed int v1; // ST00_4@1 signed int v2; // ecx@1 double v3; // st7@1 double result; // st7@6 - v1 = a1; - v2 = 0; - v3 = (double)v1; - do + __debugbreak();//Ritor1 + v3 = (double)a1; + for ( v2 = 0; v2 < 5; ++v2 ) { if ( v3 < flt_4E4A80[v2 + 5] ) break; - ++v2; } - while ( v2 < 5 ); if ( v2 <= 0 || v2 >= 5 ) { if ( v2 ) @@ -273,62 +270,49 @@ result = flt_4E4A80[0]; } else - { result = (flt_4E4A80[v2] - flt_4E4A80[v2 - 1]) * (v3 - flt_4E4A80[v2 + 4]) / (flt_4E4A80[v2 + 5] - flt_4E4A80[v2 + 4]) + flt_4E4A80[v2]; - } return result; } //----- (0043B057) -------------------------------------------------------- void __fastcall sub_43B057(unsigned int uObjID, unsigned int uActorID, Vec3_int_ *pVelocity) { - Actor *pActor; // esi@1 - SpriteObject *v4; // eax@3 - int v5; // ecx@3 int v6; // eax@4 int v7; // edi@4 - unsigned int uActorIDa; // [sp+8h] [bp-8h]@1 - unsigned int a2; // [sp+Ch] [bp-4h]@1 int a2a; // [sp+Ch] [bp-4h]@8 - uActorIDa = uActorID; - pActor = &pActors[uActorID]; - a2 = uObjID; + __debugbreak();//Ritor1 if ( !pActors[uActorID].IsNotAlive() ) { - if ( PID_TYPE(a2) == OBJECT_Item) + if ( PID_TYPE(uObjID) == OBJECT_Item) { - v4 = &pSpriteObjects[PID_ID(a2)]; - v5 = v4->spell_id; - if ( v5 ) + if ( pSpriteObjects[PID_ID(uObjID)].spell_id ) { - v6 = _43AFE3_calc_spell_damage(v5, v4->spell_level, v4->spell_skill, pActor->sCurrentHP); - v7 = stru_50C198.CalcMagicalDamageToActor(pActor, 0, v6); - pActor->sCurrentHP -= v7; + v6 = _43AFE3_calc_spell_damage(pSpriteObjects[PID_ID(uObjID)].spell_id, pSpriteObjects[PID_ID(uObjID)].spell_level, pSpriteObjects[PID_ID(uObjID)].spell_skill, pActors[uActorID].sCurrentHP); + v7 = stru_50C198.CalcMagicalDamageToActor(&pActors[uActorID], 0, v6); + pActors[uActorID].sCurrentHP -= v7; if ( v7 ) { - if ( pActor->sCurrentHP > 0 ) - Actor::AI_Stun(uActorIDa, a2, 0); + if ( pActors[uActorID].sCurrentHP > 0 ) + Actor::AI_Stun(uActorID, uObjID, 0); else - Actor::Die(uActorIDa); - a2a = 20 * v7 / (signed int)pActor->pMonsterInfo.uHP; - if ( 20 * v7 / (signed int)pActor->pMonsterInfo.uHP > 10 ) + Actor::Die(uActorID); + a2a = 20 * v7 / (signed int)pActors[uActorID].pMonsterInfo.uHP; + if ( 20 * v7 / (signed int)pActors[uActorID].pMonsterInfo.uHP > 10 ) a2a = 10; - if ( !MonsterStats::BelongsToSupertype(pActor->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) + if ( !MonsterStats::BelongsToSupertype(pActors[uActorID].pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) { pVelocity->x = (unsigned __int64)(a2a * (signed __int64)pVelocity->x) >> 16; pVelocity->y = (unsigned __int64)(a2a * (signed __int64)pVelocity->y) >> 16; pVelocity->z = (unsigned __int64)(a2a * (signed __int64)pVelocity->z) >> 16; - pActor->vVelocity.x = 50 * LOWORD(pVelocity->x); - pActor->vVelocity.y = 50 * LOWORD(pVelocity->y); - pActor->vVelocity.z = 50 * LOWORD(pVelocity->z); + pActors[uActorID].vVelocity.x = 50 * LOWORD(pVelocity->x); + pActors[uActorID].vVelocity.y = 50 * LOWORD(pVelocity->y); + pActors[uActorID].vVelocity.z = 50 * LOWORD(pVelocity->z); } - Actor::AddBloodsplatOnDamageOverlay(uActorIDa, 1, v7); + Actor::AddBloodsplatOnDamageOverlay(uActorID, 1, v7); } else - { - Actor::AI_Stun(uActorIDa, a2, 0); - } + Actor::AI_Stun(uActorID, uObjID, 0); } } } @@ -338,17 +322,11 @@ void ActorDamageFromMonster(signed int attacker_id, unsigned int actor_id, Vec3_int_ *pVelocity, signed int a4) { int v4; // ebx@1 - //SpriteObject *v5; // eax@2 int v6; // eax@3 - //Actor *v7; // esi@4 - //Actor *v8; // edi@4 - //char v9; // zf@5 __int64 v10; // qax@8 - //signed __int16 v11; // cx@9 signed int v12; // ecx@20 int v13; // ecx@22 int v14; // edi@30 - //unsigned int uActorID; // [sp+Ch] [bp-8h]@1 signed int v17; // [sp+10h] [bp-4h]@1 int v18; // [sp+20h] [bp+Ch]@34 @@ -364,17 +342,14 @@ v6 = pActors[actor_id].IsNotAlive(); if ( !v6 ) { - //v9 = pActors[actor_id].uAIState == 7; pActors[actor_id].uLastCharacterIDToHit = v17; if ( pActors[actor_id].uAIState == Fleeing ) BYTE2(pActors[actor_id].uAttributes) |= 2; - //v6 = pActors[PID_ID(v17)]._4273BB_DoesHitOtherActor(&pActors[actor_id], v4, 0); if ( pActors[PID_ID(v17)]._4273BB_DoesHitOtherActor(&pActors[actor_id], v4, 0) ) { v10 = (unsigned int)pActors[PID_ID(v17)]._43B3E0_CalcDamage(a4); if ( (signed __int64)pActors[PID_ID(v17)].pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime > 0 ) { - //v11 = pActors[PID_ID(v17)].pActorBuffs[ACTOR_BUFF_SHRINK].uPower; if ( pActors[PID_ID(v17)].pActorBuffs[ACTOR_BUFF_SHRINK].uPower ) v10 = (signed int)v10 / (unsigned __int16)pActors[PID_ID(v17)].pActorBuffs[ACTOR_BUFF_SHRINK].uPower; } @@ -382,66 +357,50 @@ && (SHIDWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) > SHIDWORD(v10) || LODWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) > HIDWORD(v10)) ) LODWORD(v10) = 0; - if ( a4 != HIDWORD(v10) ) + if ( a4 == HIDWORD(v10) ) + v12 = pActors[PID_ID(v17)].pMonsterInfo.uAttack1Type; + else if ( a4 - HIDWORD(v10) == 1 ) { - if ( a4 - HIDWORD(v10) == 1 ) - { - v12 = pActors[PID_ID(v17)].pMonsterInfo.uAttack2Type; - if ( SHIDWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime) >= SHIDWORD(v10) - && (SHIDWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime) > SHIDWORD(v10) - || LODWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime) > HIDWORD(v10)) ) - LODWORD(v10) = (signed int)v10 >> 1; - goto LABEL_30; - } - if ( a4 - HIDWORD(v10) == 2 ) - { - v13 = pActors[actor_id].pMonsterInfo.uSpell1ID; - } + v12 = pActors[PID_ID(v17)].pMonsterInfo.uAttack2Type; + if ( SHIDWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime) >= SHIDWORD(v10) + && (SHIDWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime) > SHIDWORD(v10) + || LODWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime) > HIDWORD(v10)) ) + LODWORD(v10) = (signed int)v10 / 2; + } + else if ( a4 - HIDWORD(v10) == 2 ) + v12 = LOBYTE(pSpellStats->pInfos[pActors[actor_id].pMonsterInfo.uSpell1ID].uSchool); + else if ( a4 - HIDWORD(v10) == 3 ) + v12 = LOBYTE(pSpellStats->pInfos[pActors[actor_id].pMonsterInfo.uSpell2ID].uSchool); + else if ( a4 - HIDWORD(v10) == 4 ) + v12 = pActors[PID_ID(v17)].pMonsterInfo.field_3C_some_special_attack; + else + v12 = 4; + v14 = stru_50C198.CalcMagicalDamageToActor(&pActors[actor_id], v12, v10); + pActors[actor_id].sCurrentHP -= v14; + if ( v14 ) + { + if ( pActors[actor_id].sCurrentHP > 0 ) + Actor::AI_Stun(actor_id, v17, 0); else + Actor::Die(actor_id); + Actor::AggroSurroundingPeasants(actor_id, 0); + v18 = 20 * v14 / (signed int)pActors[actor_id].pMonsterInfo.uHP; + if ( 20 * v14 / (signed int)pActors[actor_id].pMonsterInfo.uHP > 10 ) + v18 = 10; + if ( !MonsterStats::BelongsToSupertype(pActors[actor_id].pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) { - if ( a4 - HIDWORD(v10) != 3 ) - { - if ( a4 - HIDWORD(v10) == 4 ) - v12 = pActors[PID_ID(v17)].pMonsterInfo.field_3C_some_special_attack; - else - v12 = 4; -LABEL_30: - v14 = stru_50C198.CalcMagicalDamageToActor(&pActors[actor_id], v12, v10); - pActors[actor_id].sCurrentHP -= v14; - if ( v14 ) - { - if ( pActors[actor_id].sCurrentHP > 0 ) - Actor::AI_Stun(actor_id, v17, 0); - else - Actor::Die(actor_id); - Actor::AggroSurroundingPeasants(actor_id, 0); - v18 = 20 * v14 / (signed int)pActors[actor_id].pMonsterInfo.uHP; - if ( 20 * v14 / (signed int)pActors[actor_id].pMonsterInfo.uHP > 10 ) - v18 = 10; - if ( !MonsterStats::BelongsToSupertype(pActors[actor_id].pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) - { - pVelocity->x = (unsigned __int64)(v18 * (signed __int64)pVelocity->x) >> 16; - pVelocity->y = (unsigned __int64)(v18 * (signed __int64)pVelocity->y) >> 16; - pVelocity->z = (unsigned __int64)(v18 * (signed __int64)pVelocity->z) >> 16; - pActors[actor_id].vVelocity.x = 50 * LOWORD(pVelocity->x); - pActors[actor_id].vVelocity.y = 50 * LOWORD(pVelocity->y); - pActors[actor_id].vVelocity.z = 50 * LOWORD(pVelocity->z); - } - Actor::AddBloodsplatOnDamageOverlay(actor_id, 1, v14); - } - else - { - Actor::AI_Stun(actor_id, v17, 0); - } - return; - } - v13 = pActors[actor_id].pMonsterInfo.uSpell2ID; + pVelocity->x = (unsigned __int64)(v18 * (signed __int64)pVelocity->x) >> 16; + pVelocity->y = (unsigned __int64)(v18 * (signed __int64)pVelocity->y) >> 16; + pVelocity->z = (unsigned __int64)(v18 * (signed __int64)pVelocity->z) >> 16; + pActors[actor_id].vVelocity.x = 50 * LOWORD(pVelocity->x); + pActors[actor_id].vVelocity.y = 50 * LOWORD(pVelocity->y); + pActors[actor_id].vVelocity.z = 50 * LOWORD(pVelocity->z); } - v12 = LOBYTE(pSpellStats->pInfos[v13].uSchool); - goto LABEL_30; + Actor::AddBloodsplatOnDamageOverlay(actor_id, 1, v14); } - v12 = pActors[PID_ID(v17)].pMonsterInfo.uAttack1Type; - goto LABEL_30; + else + Actor::AI_Stun(actor_id, v17, 0); + return; } } }
--- a/mm7_6.cpp Mon Dec 23 17:30:22 2013 +0600 +++ b/mm7_6.cpp Mon Dec 23 23:38:51 2013 +0600 @@ -52,15 +52,12 @@ int v7; // esi@8 int v8; // eax@9 int v9; // edx@11 - int v10; // edx@13 - int v11; // esi@13 unsigned __int8 v12; // sf@13 unsigned __int8 v13; // of@13 int v14; // edx@14 int v15; // eax@14 signed int result; // eax@17 - __debugbreak();//Ritor1 v5 = pActor->pMonsterInfo.uAC; v6 = 0; if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_SOMETHING_THAT_HALVES_AC].uExpireTime > 0 ) @@ -78,27 +75,25 @@ if ( a3 == 2 ) { v14 = a4 + v9; - v15 = ((v7 + 15) >> 1) + v7 + 15; - v13 = __OFSUB__(v14, v15); + v15 = ((v7 + 15) / 2) + v7 + 15; + v13 = __OFSUB__(v14, v15); v12 = v14 - v15 < 0; } - else + else if ( a3 == 3 ) { - if ( a3 != 3 ) - { - v10 = a4 + v9; - v11 = v7 + 15; - v13 = __OFSUB__(v10, v11); - v12 = v10 - v11 < 0; - } - else - { - v14 = a4 + v9; - v15 = 2 * v7 + 30; - v13 = __OFSUB__(v14, v15); - v12 = v14 - v15 < 0; - } + v14 = a4 + v9; + v15 = 2 * v7 + 30; + v13 = __OFSUB__(v14, v15); + v12 = v14 - v15 < 0; } + else + { + v14 = a4 + v9; + v15 = v7 + 15; + v13 = __OFSUB__(v14, v15); + v12 = v14 - v15 < 0; + } + if ( v12 ^ v13 ) result = 0; else @@ -503,10 +498,10 @@ int *v9; // edx@8 signed int v10; // ebx@10 int v11; // edi@11 - Actor *v12; // esi@12 - unsigned __int16 v13; // ax@12 + //Actor *v12; // esi@12 + //unsigned __int16 v13; // ax@12 int v14; // eax@22 - char v15; // zf@30 + //char v15; // zf@30 int v16; // esi@32 int v17; // ecx@34 stru319 *v18; // eax@39 @@ -514,18 +509,18 @@ int v20; // ecx@41 unsigned __int16 v21; // ax@42 unsigned int v22; // [sp+8h] [bp-24h]@11 - unsigned int v23; // [sp+Ch] [bp-20h]@7 + //unsigned int v23; // [sp+Ch] [bp-20h]@7 stru319 *v24; // [sp+10h] [bp-1Ch]@1 unsigned int v25; // [sp+14h] [bp-18h]@8 int *v26; // [sp+18h] [bp-14h]@8 int v27; // [sp+1Ch] [bp-10h]@10 int *v28; // [sp+20h] [bp-Ch]@10 - unsigned int v29; // [sp+24h] [bp-8h]@7 + //unsigned int v29; // [sp+24h] [bp-8h]@7 int v30; // [sp+28h] [bp-4h]@6 int i; // [sp+38h] [bp+Ch]@33 signed int v32; // [sp+3Ch] [bp+10h]@32 - __debugbreak();//Ritor1 + //__debugbreak();//Ritor1 v4 = 0; v5 = this; v24 = this; @@ -544,49 +539,39 @@ v30 = 0; if ( pRenderer->pActiveZBuffer ) { - v29 = viewparams->uScreen_topL_X; - v23 = viewparams->uScreen_BttmR_X; if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y ) { - v25 = viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y; v9 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y]; v26 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y]; - do + for ( v25 = viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y; v25; --v25 ) { - if ( (signed int)v29 < (signed int)v23 ) + if ( (signed int)viewparams->uScreen_topL_X < (signed int)viewparams->uScreen_BttmR_X ) { v28 = v9; v10 = v4; - v27 = v23 - v29; - do + for ( v27 = viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X; v27; --v27 ) { v22 = *v28; v11 = *v28 & 0xFFFF; if (PID_TYPE(v11) == OBJECT_Actor) { - v12 = &pActors[PID_ID(v11)]; - v13 = v12->uAIState; - if ( v13 != 5 ) + if ( pActors[PID_ID(v11)].uAIState != Dead ) { - if ( v13 != 4 - && v13 != 11 - && v13 != 19 - && v13 != 17 + if ( pActors[PID_ID(v11)].uAIState != Dying && pActors[PID_ID(v11)].uAIState != Removed + && pActors[PID_ID(v11)].uAIState != Summoned && pActors[PID_ID(v11)].uAIState != Disabled && (!a3 || pActors[PID_ID(v11)].GetActorsRelation(0)) ) { - if ( (!a4 || MonsterStats::BelongsToSupertype(v12->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD)) + if ( (!a4 || MonsterStats::BelongsToSupertype(pActors[PID_ID(v11)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD)) && v22 <= pick_depth << 16 ) { v14 = 0; if ( v10 > 0 ) { - do + for ( v14; v14 < v30; ++v14 ) { if ( dword_50BDA0[v14] == v11 ) break; - ++v14; } - while ( v14 < v30 ); } if ( v14 == v30 && v10 < 100 ) { @@ -600,49 +585,39 @@ } } ++v28; - --v27; } - while ( v27 ); v4 = v30; v5 = v24; } v9 = v26 + 640; - v15 = v25-- == 1; v26 += 640; } - while ( !v15 ); } if ( v4 > 0 ) { - v32 = 1; v16 = (int)dword_50BC10.data(); - do + for ( v32 = 1; v32 - 1 < v4; ++v32 ) { for ( i = v32; i < v4; ++i ) { v17 = dword_50BC10[i]; - if ( v17 < *(int *)v16 ) + if ( dword_50BC10[i] < *(int *)v16 ) { dword_50BC10[i] = *(int *)v16; *(int *)v16 = v17; } } - ++v32; v16 += 4; } - while ( v32 - 1 < v4 ); v5 = v24; if ( v4 > 0 ) { v18 = v24; - v19 = v4; - do + for ( v19 = v4; v19; --v19 ) { *(int *)&v18->field_0 = (*(int *)&v18[(char *)dword_50BC10.data() - (char *)v24].field_0 >> 3) & 0x1FFF; v18 += 4; - --v19; } - while ( v19 ); } } v20 = 0;