Mercurial > mm7
diff mm7_4.cpp @ 2117:c7bf59066842
mm7_4-6 cleaned
author | Ritor1 |
---|---|
date | Mon, 23 Dec 2013 23:38:51 +0600 |
parents | a94c5bee0225 |
children | 16e2ed54f269 |
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;