Mercurial > mm7
diff mm7_4.cpp @ 2139:f9b55be70c1b
Слияние
author | Ritor1 |
---|---|
date | Thu, 02 Jan 2014 09:11:28 +0600 |
parents | 49de109bbab5 |
children | d44b7775fc06 |
line wrap: on
line diff
--- a/mm7_4.cpp Thu Jan 02 09:11:01 2014 +0600 +++ b/mm7_4.cpp Thu Jan 02 09:11:28 2014 +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; } } } @@ -203,9 +172,9 @@ v = v_replace; HSV2RGB(&r, &g, &b, h, s, v); - return (((uint)round(r * 255.0f) & 0xFF) << 16) | - (((uint)round(g * 255.0f) & 0xFF) << 8) | - (((uint)round(b * 255.0f) & 0xFF)); + return (((uint)round_to_int(r * 255.0f) & 0xFF) << 16) | + (((uint)round_to_int(g * 255.0f) & 0xFF) << 8) | + (((uint)round_to_int(b * 255.0f) & 0xFF)); } //----- (0048B561) -------------------------------------------------------- @@ -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->pSounds->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->pSounds->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 ); } @@ -989,36 +917,33 @@ { int v3; // esi@1 int result; // eax@1 - stru339_spell_sound *v5; // ebx@1 - int *v6; // edi@2 + //stru339_spell_sound *v5; // ebx@1 + //int *v6; // edi@2 unsigned int v7; // eax@3 int v8; // [sp+Ch] [bp-8h]@3 int v9; // [sp+10h] [bp-4h]@2 int a2a; // [sp+1Ch] [bp+8h]@1 - return 0; + //return 0; v3 = 0; result = word_4EE088_sound_ids[uSoundID]; - v5 = this; + //v5 = this; a2a = word_4EE088_sound_ids[uSoundID]; - if ( result ) + if ( word_4EE088_sound_ids[uSoundID] ) { - v9 = 0; - v6 = this->pSoundsOffsets; - do + //v6 = this->pSoundsOffsets; + for ( v9 = 0; v9 < 2; ++v9 ) { v7 = a2a++; - result = pSoundList->LoadSound(v7, (char *)v5 + v3, 44744 - v3, &v8, a6); + result = pSoundList->LoadSound(v7, (char *)this + v3, 44744 - v3, &v8, a6); if ( !result ) break; a6 += 4; result = v8 + 256; - *v6 = v3; + this->pSoundsOffsets[v9] = v3; v3 += result; - ++v9; - *(v6 - 2) = result; - ++v6; + this->pSoundsSizes[v9] = v8 + 256; + //++v6; } - while ( v9 < 2 ); } return result; } @@ -1027,36 +952,18 @@ //----- (00494AED) -------------------------------------------------------- unsigned int PlayerFrameTable::GetFrameIdByExpression(CHARACTER_EXPRESSION_ID expression) { - unsigned int _uNumFrames; // edx@1 - unsigned int result; // eax@1 - PlayerFrame *v4; // ecx@2 - - _uNumFrames = this->uNumFrames; - result = 0; - if ( (signed int)this->uNumFrames <= 0 ) + for ( uint i = 0; i < this->uNumFrames; i++ ) { - result = 0; + if ( this->pFrames[i].expression == expression ) + return i; } - else - { - v4 = this->pFrames; - while ( v4->expression != expression ) - { - ++result; - ++v4; - if ( (signed int)result >= (signed int)_uNumFrames ) - return 0; - } - } - return result; + return 0; } //----- (00494B10) -------------------------------------------------------- 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 @@ -1064,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 ) @@ -1077,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) -------------------------------------------------------- @@ -1122,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); } @@ -1146,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 @@ -1162,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 @@ -1173,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; @@ -1199,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) ) { @@ -1213,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; } @@ -1273,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 @@ -1286,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]; @@ -1558,7 +1445,7 @@ break; case 17:// { - uint pay_percentage = pNPCStats->pProfessions[npc->uProfession - 1].uHirePrice / 100; + uint pay_percentage = pNPCStats->pProfessions[npc->uProfession].uHirePrice / 100; if ( !pay_percentage ) pay_percentage = 1; sprintf(a1, "%lu", pay_percentage); @@ -1589,7 +1476,7 @@ i += 2; break; case 24:// - sprintfex(a1, format_4E2D80, TargetColor(255, 255, 155), a3->GetDisplayName()); + sprintfex(a1, format_4E2D80, Color16(255, 255, 155), a3->GetDisplayName()); strcat(pTmpBuf2.data(), a1); dst = strlen(pTmpBuf2.data()); i += 2; @@ -1771,64 +1658,30 @@ //----- (0049B13D) -------------------------------------------------------- void stru154::GetFacePlane(ODMFace *pFace, BSPVertexBuffer *pVertices, Vec3_float_ *pOutNormal, float *pOutDist) { - ODMFace *v5; // ebx@1 - //int v6; // eax@1 - //unsigned __int16 *v7; // ebx@2 - //Vec3_int_ *v8; // eax@3 - Vec3_int_ *v9; // ecx@3 - //double v10; // st7@3 - //int v11; // ecx@3 - Vec3_int_ *v12; // ecx@3 - //double v13; // st7@3 - //double v14; // st6@3 - //double v15; // st5@3 - //int v16; // ecx@3 - Vec3_int_ *v17; // eax@3 - //double v18; // st5@3 Vec3_float_ *v19; // eax@3 - //int result; // eax@8 - //float v21; // ecx@10 - //double v22; // st7@10 - //double v23; // st6@10 Vec3_float_ v2; // [sp+4h] [bp-64h]@3 - //float v25; // [sp+18h] [bp-50h]@3 float v26; // [sp+1Ch] [bp-4Ch]@3 float v27; // [sp+20h] [bp-48h]@3 float v28; // [sp+24h] [bp-44h]@3 - //float v29; // [sp+2Ch] [bp-3Ch]@3 - //float v30; // [sp+30h] [bp-38h]@3 - //float v31; // [sp+34h] [bp-34h]@3 - //float v32; // [sp+38h] [bp-30h]@3 - //float v33; // [sp+3Ch] [bp-2Ch]@3 Vec3_float_ v1; // [sp+40h] [bp-28h]@1 - //float v35; // [sp+4Ch] [bp-1Ch]@3 - //float v36; // [sp+50h] [bp-18h]@3 - //float v37; // [sp+54h] [bp-14h]@3 Vec3_float_ v38; // [sp+58h] [bp-10h]@3 - //int v39; // [sp+64h] [bp-4h]@1 - //v39 = 0; v1.x = 0.0; - v5 = pFace; - //v6 = pFace->uNumVertices; v1.y = 0.0; v1.z = 0.0; if (pFace->uNumVertices >= 2) { - int i = 0; - while ( i < pFace->uNumVertices - 2 ) + for ( int i = 0; i < pFace->uNumVertices - 2; i++ ) { - v9 = &pVertices->pVertices[pFace->pVertexIDs[i]]; - v12 = &pVertices->pVertices[pFace->pVertexIDs[i + 1]]; - v17 = &pVertices->pVertices[pFace->pVertexIDs[i + 2]]; - i++; - v1.x = v12->x - v9->x; - v26 = v17->x - v12->x; - v1.y = v12->y - v9->y; - v27 = v17->y - v12->y; - v1.z = v12->z - v9->z; - v28 = v17->z - v12->z; + v1.x = pVertices->pVertices[pFace->pVertexIDs[i + 1]].x - pVertices->pVertices[pFace->pVertexIDs[i]].x; + v1.y = pVertices->pVertices[pFace->pVertexIDs[i + 1]].y - pVertices->pVertices[pFace->pVertexIDs[i]].y; + v1.z = pVertices->pVertices[pFace->pVertexIDs[i + 1]].z - pVertices->pVertices[pFace->pVertexIDs[i]].z; + + v26 = pVertices->pVertices[pFace->pVertexIDs[i + 2]].x - pVertices->pVertices[pFace->pVertexIDs[i + 1]].x; + v27 = pVertices->pVertices[pFace->pVertexIDs[i + 2]].y - pVertices->pVertices[pFace->pVertexIDs[i + 1]].y; + v28 = pVertices->pVertices[pFace->pVertexIDs[i + 2]].z - pVertices->pVertices[pFace->pVertexIDs[i + 1]].z; + v19 = Vec3_float_::Cross(&v1, &v2, v26, v27, v28); v38.x = v19->x; v38.y = v19->y; @@ -1841,28 +1694,28 @@ pOutNormal->y = v38.y; pOutNormal->z = v38.z; - *pOutDist = -(v9->x * v38.x + v9->y * v38.y + v9->z * v38.z); + *pOutDist = -(pVertices->pVertices[pFace->pVertexIDs[i]].x * v38.x + + pVertices->pVertices[pFace->pVertexIDs[i]].y * v38.y + + pVertices->pVertices[pFace->pVertexIDs[i]].z * v38.z); return; } } } - pOutNormal->x = (double)(v5->pFacePlane.vNormal.x & 0xFFFF) / 65535.0f + (double)(v5->pFacePlane.vNormal.x >> 16); - pOutNormal->y = (double)(v5->pFacePlane.vNormal.y & 0xFFFF) / 65535.0f + (double)(v5->pFacePlane.vNormal.y >> 16); - pOutNormal->z = (double)(v5->pFacePlane.vNormal.z & 0xFFFF) / 65535.0f + (double)(v5->pFacePlane.vNormal.z >> 16); - *pOutDist = (double)(v5->pFacePlane.dist & 0xFFFF) / 65535.0f + (double)(v5->pFacePlane.dist >> 16); + pOutNormal->x = (double)(pFace->pFacePlane.vNormal.x & 0xFFFF) / 65535.0f + (double)(pFace->pFacePlane.vNormal.x >> 16); + pOutNormal->y = (double)(pFace->pFacePlane.vNormal.y & 0xFFFF) / 65535.0f + (double)(pFace->pFacePlane.vNormal.y >> 16); + pOutNormal->z = (double)(pFace->pFacePlane.vNormal.z & 0xFFFF) / 65535.0f + (double)(pFace->pFacePlane.vNormal.z >> 16); + *pOutDist = (double)(pFace->pFacePlane.dist & 0xFFFF) / 65535.0f + (double)(pFace->pFacePlane.dist >> 16); } //----- (0049D700) -------------------------------------------------------- unsigned int __fastcall GetMaxMipLevels(unsigned int uDim) { - unsigned int v1; // eax@1 int v2; // ecx@1 unsigned int v3; // eax@1 - v1 = uDim; v2 = 0; - v3 = v1 - 1; + v3 = uDim - 1; while ( v3 & 1 ) { v3 >>= 1; @@ -1913,207 +1766,34 @@ return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8);*/ } -//----- (004A46E6) -------------------------------------------------------- -int __fastcall sr_4A46E6_draw_particle_segment(unsigned int x, signed int y, signed int _z, int a4, unsigned int lightColor) +void Present32(unsigned __int32 *src, unsigned int src_pitch, + unsigned __int32 *dst, unsigned int dst_pitch) { - int v5; // eax@1 - int z; // eax@1 - unsigned int v7; // eax@9 - unsigned int v8; // ecx@9 - int v9; // eax@9 - unsigned int v10; // eax@10 - int *v11; // esi@10 - int *v12; // edi@10 - int v13; // ecx@10 - int v14; // edx@10 - unsigned int v15; // eax@22 - int *v16; // esi@22 - int *v17; // edi@22 - int v18; // ecx@22 - int v19; // edx@22 - unsigned __int16 *pTarget; // [sp+Ch] [bp-8h]@9 - int *pTargetZ; // [sp+10h] [bp-4h]@9 - unsigned int v22; // [sp+1Ch] [bp+8h]@9 - signed int v23; // [sp+20h] [bp+Ch]@1 + for (uint y = 0; y < 8; ++y) + memcpy(dst + y * dst_pitch, + src + y * src_pitch, src_pitch * sizeof(__int32)); - v5 = a4; - v23 = _z >> 16; - z = x + v5; - if ( z >= (signed int)pViewport->uViewportTL_X - && (signed int)x <= (signed int)pViewport->uViewportBR_X - && y >= (signed int)pViewport->uViewportTL_Y - && y <= (signed int)pViewport->uViewportBR_Y ) - { - if ( (signed int)x < (signed int)pViewport->uViewportTL_X ) - x = pViewport->uViewportTL_X; - if ( z > (signed int)pViewport->uViewportBR_X ) - z = pViewport->uViewportBR_X; - pTarget = &pRenderer->pTargetSurface[x + y * pRenderer->uTargetSurfacePitch]; - v22 = z - x; - pTargetZ = &pRenderer->pActiveZBuffer[x + 640 * y]; - v7 = lightColor >> 3; - v8 = lightColor & 0xF0; - v9 = v7 & 0x1E0000; - if ( pRenderer->uTargetGBits == 5 ) - { - v10 = (v8 | (((unsigned __int16)(lightColor & 0xF000) | (unsigned int)v9) >> 3)) >> 4; - v11 = (int *)pTarget; - v12 = pTargetZ; - v13 = v22; - v14 = (v10 << 16) | v10; - z = (unsigned __int8)pTarget & 2; - if ( (unsigned __int8)pTarget & 2 ) - { - z = (unsigned int)*pTargetZ >> 16; - if ( z > v23 ) - { - z = v14 + ((*pTarget & 0x7BDEu) >> 1); - *pTarget = z; - } - v13 = v22 - 1; - v11 = (int *)(pTarget + 1); - v12 = pTargetZ + 1; - } - while ( v13 != 1 ) - { - if ( v13 < 1 ) - return z; - z = (unsigned int)*v12 >> 16; - if ( z <= v23 ) - { - v13 -= 2; - ++v11; - v12 += 2; - } - else - { - v12 += 2; - z = v14 + ((*v11 & 0x7BDE7BDEu) >> 1); - v13 -= 2; - *v11 = z; - ++v11; - } - } - z = (unsigned int)*v12 >> 16; - if ( z > v23 ) - { - z = v14 + ((*(short *)v11 & 0x7BDEu) >> 1); - *(short *)v11 = z; - } - } - else - { - v15 = (v8 | (((unsigned __int16)(lightColor & 0xF800) | (unsigned int)v9) >> 2)) >> 4; - v16 = (int *)pTarget; - v17 = pTargetZ; - v18 = v22; - v19 = (v15 << 16) | v15; - z = (unsigned __int8)pTarget & 2; - if ( (unsigned __int8)pTarget & 2 ) - { - z = (unsigned int)*pTargetZ >> 16; - if ( z > v23 ) + for (uint y = 8; y < 352; ++y) { - z = v19 + ((*pTarget & 0xF7DEu) >> 1); - *pTarget = z; - } - v18 = v22 - 1; - v16 = (int *)(pTarget + 1); - v17 = pTargetZ + 1; - } - while ( v18 != 1 ) - { - if ( v18 < 1 ) - return z; - z = (unsigned int)*v17 >> 16; - if ( z <= v23 ) - { - v18 -= 2; - ++v16; - v17 += 2; + memcpy(dst + y * dst_pitch, + src + y * src_pitch, 8 * sizeof(__int32)); + memcpy(dst + 8 + game_viewport_width + y * dst_pitch, + src + 8 + game_viewport_width + y * src_pitch, 174/*172*/ * sizeof(__int32)); } - else - { - v17 += 2; - z = v19 + ((*v16 & 0xF7DEF7DEu) >> 1); - v18 -= 2; - *v16 = z; - ++v16; - } - } - z = (unsigned int)*v17 >> 16; - if ( z > v23 ) - { - z = v19 + ((*(short *)v16 & 0xF7DEu) >> 1); - *(short *)v16 = z; - } - } - } - return z; -} -//----- (004A57E9) -------------------------------------------------------- -void Present_ColorKey() -{ - HRESULT v0; // eax@3 - HRESULT v1; // eax@3 - HRESULT v2; // eax@3 - HRESULT v3; // eax@3 - HRESULT v4; // eax@3 - RECT a2; // [sp+4h] [bp-14h]@3 - //CheckHRESULT_stru0 this; // [sp+14h] [bp-4h]@3 + for (uint y = 352; y < 480; ++y) + memcpy(dst + y * dst_pitch, + src + y * src_pitch, src_pitch * sizeof(__int32)); - if ( !pRenderer->uNumSceneBegins ) - { - if ( pRenderer->field_40110 ) - { - a2.bottom = pViewport->uViewportTL_Y; - a2.left = 0; - a2.top = 0; - a2.right = 640; - ErrD3D(pRenderer->pBackBuffer4->BltFast(0, 0, pRenderer->pColorKeySurface4, &a2, 16u)); - a2.right = 640; - a2.left = 0; - a2.top = pViewport->uViewportBR_Y + 1; - a2.bottom = 480; - ErrD3D(pRenderer->pBackBuffer4->BltFast( - 0, - pViewport->uViewportBR_Y + 1, - pRenderer->pColorKeySurface4, - &a2, - 16u)); - a2.right = pViewport->uViewportTL_X; - a2.bottom = pViewport->uViewportBR_Y + 1; - a2.left = 0; - a2.top = pViewport->uViewportTL_Y; - ErrD3D(pRenderer->pBackBuffer4->BltFast( - 0, - pViewport->uViewportTL_Y, - pRenderer->pColorKeySurface4, - &a2, - 16u)); - a2.left = pViewport->uViewportBR_X; - a2.top = pViewport->uViewportTL_Y; - a2.right = 640; - a2.bottom = pViewport->uViewportBR_Y + 1; - ErrD3D(pRenderer->pBackBuffer4->BltFast( - pViewport->uViewportBR_X, - pViewport->uViewportTL_Y, - pRenderer->pColorKeySurface4, - &a2, - 16u)); - a2.right = pViewport->uViewportBR_X; - a2.bottom = pViewport->uViewportBR_Y + 1; - a2.left = pViewport->uViewportTL_X; - a2.top = pViewport->uViewportTL_Y; - ErrD3D(pRenderer->pBackBuffer4->BltFast( - pViewport->uViewportTL_X, - pViewport->uViewportTL_Y, - pRenderer->pColorKeySurface4, - &a2, - 17u)); - } - } + for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y) + { + for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) + { + //if (src[x + y * src_pitch] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask)) + if (src[x + y * src_pitch] != 0xFFF8FCF8) // FFF8FCF8 = Color32(Color16(g_mask | b_mask)) + dst[x + y * dst_pitch] = src[x + y * src_pitch]; + } + } } //----- (004A597D) -------------------------------------------------------- @@ -2138,7 +1818,7 @@ int v17; // eax@16 HRESULT v18; // eax@22 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-98h]@3 - int v20; // [sp+88h] [bp-1Ch]@10 + //int v20; // [sp+88h] [bp-1Ch]@10 int v21; // [sp+8Ch] [bp-18h]@10 __int32 v22; // [sp+90h] [bp-14h]@10 //unsigned __int32 v23; // [sp+94h] [bp-10h]@10 @@ -2146,21 +1826,24 @@ //unsigned int _this; // [sp+9Ch] [bp-8h]@10 //LPVOID v26; // [sp+A0h] [bp-4h]@4 + int r_mask = 0xF800; + int g_mask = 0x7E0; + int b_mask = 0x1F; + if ( !pRenderer->uNumSceneBegins ) { - if ( pRenderer->field_40110 ) + if ( pRenderer->using_software_screen_buffer ) { memset(&Dst, 0, 0x7Cu); Dst.dwSize = 124; if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) { //v26 = Dst.lpSurface; - pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface; - v24 = pRenderer->uTargetGMask | pRenderer->uTargetBMask | - ((pRenderer->uTargetGMask | pRenderer->uTargetBMask) << 16); - pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface; - pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch; - v1 = pRenderer->pTargetSurface; + //pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface; + v24 = g_mask | b_mask | ((g_mask | b_mask) << 16); + //pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface; + //pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch; + //v1 = pRenderer->pTargetSurface; v2 = Dst.lpSurface; @@ -2170,8 +1853,12 @@ for (uint x = 0; x < 640; ++x) pDst[x] = pRenderer->uTargetRMask | pRenderer->uTargetBMask; }*/ - - ushort* pSrc = pRenderer->pTargetSurface; + + if (!FORCE_16_BITS) + Present32((unsigned __int32 *)pRenderer->pTargetSurface, pRenderer->uTargetSurfacePitch, (unsigned __int32 *)Dst.lpSurface, Dst.lPitch / 4); + else + { + ushort* pSrc = (unsigned short *)pRenderer->pTargetSurface; short* pDst = (__int16 *)Dst.lpSurface; for (uint y = 0; y < 8; ++y) @@ -2205,7 +1892,7 @@ //v26 = (LPVOID)(pViewport->uViewportW - pViewport->uViewportY + 1); v10 = (int)pSrc_x1y1; v11 = (int)pDst_x1y1; - int uHalfWidth = v20 = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2; + int uHalfWidth = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2; v13 = v24; for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y) @@ -2214,10 +1901,11 @@ // pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16)); for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) { - if (pSrc[y * 640 + x] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask)) + if (pSrc[y * 640 + x] != (g_mask | b_mask)) pDst[y * Dst.lPitch / 2 + x] = pSrc[y * 640 + x]; } } + } ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); @@ -2302,8 +1990,6 @@ return (a << 24) | (r << 16) | (g << 8) | b; } - - //----- (004B1447) -------------------------------------------------------- void sub_4B1447_party_fine(int a1, int a2, int a3) { @@ -2320,12 +2006,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; @@ -2423,7 +2107,7 @@ v7 = pSpellStats->pInfos[v1].pName; a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1; a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1; - v8 = TargetColor(0xFFu, 0xFFu, 0x9Bu); + v8 = Color16(0xFFu, 0xFFu, 0x9Bu); a1.DrawTitleText(pFontArrus, 0x78u, 0xCu, v8, v7, 3u); a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2.data(), 0, 0, 0); a1.uFrameZ = a1.uFrameX + 107; @@ -2455,28 +2139,29 @@ uDialogueType = 84; current_npc_text = (char *)pNPCTopics[667].pText; v0 = _4F0882_evt_VAR_PlayerItemInHands_vals.data(); - while ( 1 ) + //while ( 1 ) + for ( uint i = 0; i <= 53; i++ ) { if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, *v0) ) { - v1 = 0; - v2 = pParty->pPlayers.data(); - do + //v1 = 0; + //v2 = pParty->pPlayers.data(); + for ( uint pl = 0; pl < 4; pl++ ) { - LOBYTE(v3) = v2->CompareVariable(VAR_PlayerItemInHands, *(v0+1)); - if ( v3 ) + //LOBYTE(v3) = pParty->pPlayers[pl].CompareVariable(VAR_PlayerItemInHands, *(v0+1)); + if ( pParty->pPlayers[pl].CompareVariable(VAR_PlayerItemInHands, *(v0+1)) ) break; - ++v2; - ++v1; + //++v2; + //++v1; } - while ( (signed int)v2 < (signed int)pParty->pHirelings.data() ); - if ( v1 == 4 ) - break; + //while ( (signed int)v2 < (signed int)pParty->pHirelings.data() ); + //if ( v1 == 4 ) + //break; } ++v11; - v0 += 2; - if ( v0 > &_4F0882_evt_VAR_PlayerItemInHands_vals[53] ) - break; + //v0 += 2; + //if ( v0 > &_4F0882_evt_VAR_PlayerItemInHands_vals[53] ) + //break; } if ( v0 <= &_4F0882_evt_VAR_PlayerItemInHands_vals[53] ) { @@ -2488,41 +2173,35 @@ if ( contract_approved == 601 ) { v5 = 0; - v12 = pParty->pPlayers.data();//[0].uClass; + //v12 = pParty->pPlayers.data();//[0].uClass; v9 = 0; - while ( 1 ) + //while ( 1 ) + for ( uint i = 0; i < 4; i++ ) { - if ( v12->classType == PLAYER_CLASS_LICH ) + if ( pParty->pPlayers[i].classType == PLAYER_CLASS_LICH ) { v10 = 0; - v6 = pParty->pPlayers.data();//[0].pInventoryItems[0].field_1A; - do + //v6 = pParty->pPlayers.data();//[0].pInventoryItems[0].field_1A; + for ( uint pl = 0; pl < 4; pl++ ) { - v7 = v6->pInventoryItemList.data(); - v8 = 138; - do + for ( v8 = 0; v8 < 126; v8++ )//138 { - if ( v7->uItemID == ITEM_LICH_JAR_FULL ) + if ( pParty->pPlayers[pl].pInventoryItemList[v8].uItemID == ITEM_LICH_JAR_FULL ) { - if ( !v7->uHolderPlayer ) - v9 = v7; - if ( v7->uHolderPlayer == v5 ) + if ( !pParty->pPlayers[pl].pInventoryItemList[v8].uHolderPlayer ) + v9 = &pParty->pPlayers[pl].pInventoryItemList[v8]; + if ( pParty->pPlayers[pl].pInventoryItemList[v8].uHolderPlayer == v5 ) v10 = 1; } - ++v7; - --v8; } - while ( v8 ); - ++v6; } - while ( v6 <= &pParty->pPlayers[3] ); if ( !v10 ) break; } - ++v12; +// ++v12; ++v5; - if ( v12 > &pParty->pPlayers[3] ) - return; + // if ( v12 > &pParty->pPlayers[3] ) + // return; } if ( v9 ) v9->uHolderPlayer = v5; @@ -2543,8 +2222,8 @@ signed int v9; // esi@8 int v10; // eax@8 char *v11; // ecx@8 - int v12; // edi@9 - char *v13; // edx@9 + //int v12; // edi@9 + //char *v13; // edx@9 signed int v14; // edi@10 unsigned int v16; // eax@29 //int v17; // eax@36 @@ -2603,27 +2282,23 @@ if ( v6 < v2 + 2 ) { //v8 = v33; - v9 = 0; + v10 = pClassType - pClassType % 4; v11 = &byte_4ED970_skill_learn_ability_by_class_table[pClassType - pClassType % 4][v3]; - do + for ( v9 = 0; v9 < 4; ++v9 ) { - v12 = (unsigned __int8)*v11; - v13 = &v28[4 * v9]; - *(int *)v13 = 0; - if ( v12 < v34 ) + v28[4 * v9] = 0; + if ( (unsigned __int8)*v11 < v34 ) { v14 = 1; } else { v14 = 1; - *(int *)v13 = 1; + v28[4 * v9] = 1; } - ++v9; v11 += 37; } - while ( v9 < 4 ); __debugbreak(); // warning C4700: uninitialized local variable 'v29' used if ( v29 == v14 ) { @@ -2931,20 +2606,18 @@ //----- (004B3FE5) -------------------------------------------------------- void __fastcall _4B3FE5_training_dialogue(int a4) { - int v1; // edi@1 const char *v2; // edi@1 - + __debugbreak(); - v1 = a4; uDialogueType = 78; current_npc_text = (char *)pNPCTopics[a4 + 168].pText; _4B254D_SkillMasteryTeacher(a4); pDialogueWindow->Release(); - pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15Eu, WINDOW_MainMenu, v1, 0); - v2 = ""; - pBtn_ExitCancel = pDialogueWindow->CreateButton( 0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, UIMSG_Escape, 0, 0, + pDialogueWindow = GUIWindow::Create(0, 0, 640, 350, WINDOW_MainMenu, a4, 0); + pBtn_ExitCancel = pDialogueWindow->CreateButton( 471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uExitCancelTextureId), 0); pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); + v2 = ""; if ( contract_approved ) v2 = pGlobalTXT_LocalizationStrings[535]; pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x4Fu, 0, v2, 0); @@ -2957,10 +2630,8 @@ //----- (004B46A5) -------------------------------------------------------- void __fastcall DrawTextAtStatusBar( const char *Str, int a5 ) { - int v4; // eax@1 pRenderer->DrawTextureRGB(0, 352, pTexture_StatusBar); - v4 = pFontLucida->AlignText_Center(450, Str); - pPrimaryWindow->DrawText(pFontLucida, v4 + 11, 357, a5, Str, 0, 0, 0); + pPrimaryWindow->DrawText(pFontLucida, pFontLucida->AlignText_Center(450, Str) + 11, 357, a5, Str, 0, 0, 0); } //----- (004B46F8) -------------------------------------------------------- @@ -2978,235 +2649,170 @@ //----- (004BC49B) -------------------------------------------------------- void OnSelectNPCDialogueOption(DIALOGUE_TYPE newDialogueType) { - //unsigned int v1; // esi@1 - NPCData *speakingNPC; // ebp@1 - //unsigned int v3; // eax@1 - int npc_event_id; // ecx@10 - signed int v5; // edi@14 - char *v6; // esi@15 - const char *v7; // ecx@22 - signed int v8; // edi@37 - //unsigned int v9; // eax@56 - unsigned int v10; // ecx@57 - void *v11; // [sp-Ch] [bp-1Ch]@46 - int v12; // [sp-8h] [bp-18h]@46 - char *v13; // [sp-8h] [bp-18h]@60 - size_t v14; // [sp-4h] [bp-14h]@46 - const char *v15; // [sp-4h] [bp-14h]@60 - - //v1 = _this; - speakingNPC = GetNPCData(sDialogue_SpeakingActorNPC_ID); - //v3 = v1; - uDialogueType = newDialogueType; - if (!speakingNPC->uFlags) - { - speakingNPC->uFlags = 1; - //v3 = uDialogueType; - } - - if(newDialogueType == DIALOGUE_PROFESSION_DETAILS) - { - dialogue_show_profession_details = ~dialogue_show_profession_details; - } - else if(newDialogueType == DIALOGUE_76) - { - if (speakingNPC->Hired()) - { - v8 = 0; - if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) - { - v6 = (char *)pNPCStats->pNewNPCData; - while ( !(v6[8] & 0x80) || strcmp(speakingNPC->pName, *(const char **)v6) ) - { - ++v8; - v6 += 76; - if ( v8 >= (signed int)pNPCStats->uNumNewNPCs ) - break; - } - if( v8 < (signed int)pNPCStats->uNumNewNPCs ) - v6[8] &= 0x7Fu; - } - if ( pParty->pHirelings[0].pName && !_stricmp(pParty->pHirelings[0].pName, speakingNPC->pName) ) - { - v11 = pParty->pHirelings.data(); - memset(v11, 0, sizeof(NPCData)); - } - else if ( pParty->pHirelings[1].pName && !_stricmp(pParty->pHirelings[1].pName, speakingNPC->pName) ) - { - v11 = &pParty->pHirelings[1]; - memset(v11, 0, sizeof(NPCData)); - } - pParty->hirelingScrollPosition = 0; - pParty->CountHirelings(); - dword_591084 = 0; - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - dword_7241C8 = 0; - return; - } - if ( pParty->pHirelings[0].pName && pParty->pHirelings[1].pName ) - { - v7 = pGlobalTXT_LocalizationStrings[533]; // ""I cannot join you, you're party is full"" - ShowStatusBarString(v7, 2u); - } - else - { - //v9 = v2->uProfession; - if ( speakingNPC->uProfession != 51 ) - { - v10 = pNPCStats->pProfessions[speakingNPC->uProfession - 1].uHirePrice; - if ( pParty->uNumGold < v10 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);// "You don't have enough gold" - dialogue_show_profession_details = false; - uDialogueType = 13; - if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0); - v7 = pGlobalTXT_LocalizationStrings[155]; - ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); - if ( !dword_7241C8 ) - pGame->Draw(); - dword_7241C8 = 0; - return; - } - Party::TakeGold(v10); - } - LOBYTE(speakingNPC->uFlags) |= 0x80u; - if ( pParty->pHirelings[0].pName ) - { - memcpy(&pParty->pHirelings[1], speakingNPC, sizeof(pParty->pHirelings[1])); - v15 = speakingNPC->pName; - v13 = pParty->pHireling2Name; - } - else - { - memcpy(pParty->pHirelings.data(), speakingNPC, 0x4Cu); - v15 = speakingNPC->pName; - v13 = pParty->pHireling1Name; - } - strcpy(v13, v15); - pParty->hirelingScrollPosition = 0; - pParty->CountHirelings(); + NPCData *speakingNPC; // ebp@1 + int npc_event_id; // ecx@10 + char *v13; // [sp-8h] [bp-18h]@60 - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - - if ( sDialogue_SpeakingActorNPC_ID >= 0 ) - pDialogue_SpeakingActor->uAIState = Removed; - if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0); - } - } - else if ( (signed int)newDialogueType > 84 && (signed int)newDialogueType <= 88 ) - { - ArenaFight(); - return; - } - else if(newDialogueType == DIALOGUE_USE_NPC_ABILITY) - { - if (UseNPCSkill((NPCProf)speakingNPC->uProfession) == 0) - { - if ( speakingNPC->uProfession != GateMaster ) - speakingNPC->bHasUsedTheAbility = 1; - - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - } - else - ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2); //"Your packs are already full!" - } - else if(newDialogueType == DIALOGUE_13) - { - if (!speakingNPC->Hired()) - { - sub_4B3E1E(); - dialogue_show_profession_details = false; - } - else - { - v5 = 0; - if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) - { - v6 = (char *)pNPCStats->pNewNPCData; - while ( !(v6[8] & 0x80) || strcmp(speakingNPC->pName, *(const char **)v6) ) - { - ++v5; - v6 += 76; - if ( v5 >= (signed int)pNPCStats->uNumNewNPCs ) - break; - } - if ( v5 < (signed int)pNPCStats->uNumNewNPCs ) - v6[8] &= 0x7Fu; - } - if ( pParty->pHirelings[0].pName && !_stricmp(pParty->pHirelings[0].pName, speakingNPC->pName) ) - { - v11 = pParty->pHirelings.data(); - memset(v11, 0, sizeof(NPCData)); - } - else if ( pParty->pHirelings[1].pName && !_stricmp(pParty->pHirelings[1].pName, speakingNPC->pName) ) - { - v11 = &pParty->pHirelings[1]; - memset(v11, 0, sizeof(NPCData)); - } - pParty->hirelingScrollPosition = 0; - pParty->CountHirelings(); - dword_591084 = 0; - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - dword_7241C8 = 0; - return; - } - } - else if(newDialogueType >= 19 && newDialogueType <= 24) - { - switch(newDialogueType) - { - case DIALOGUE_19: npc_event_id = speakingNPC->evt_A; break; - case DIALOGUE_20: npc_event_id = speakingNPC->evt_B; break; - case DIALOGUE_21: npc_event_id = speakingNPC->evt_C; break; - case DIALOGUE_22: npc_event_id = speakingNPC->evt_D; break; - case DIALOGUE_23: npc_event_id = speakingNPC->evt_E; break; - case DIALOGUE_24: npc_event_id = speakingNPC->evt_F; break; - } - if ( (npc_event_id >= 200) && (npc_event_id <= 310) ) - _4B3FE5_training_dialogue(npc_event_id); //200-310 - else if (( npc_event_id >= 400) && (npc_event_id <= 410) ) - { //400-410 - dword_F8B1D8 = newDialogueType; - DrawJoinGuildWindow(npc_event_id - 400); - } - else - { - switch ( npc_event_id ) - { - case 139: - OracleDialogue(); - break; - case 311: - CheckBountyRespawnAndAward(); - break; - case 399: - Arena_SelectionFightLevel(); - break; - default: - activeLevelDecoration = (LevelDecoration*)1; - current_npc_text = 0; - EventProcessor(npc_event_id, 0, 1); - activeLevelDecoration = NULL; - break; - } - } - } - if ( !dword_7241C8 ) - pGame->Draw(); - dword_7241C8 = 0; + speakingNPC = GetNPCData(sDialogue_SpeakingActorNPC_ID); + uDialogueType = newDialogueType; + if (!speakingNPC->uFlags) + speakingNPC->uFlags = 1; + if(newDialogueType == DIALOGUE_PROFESSION_DETAILS) + dialogue_show_profession_details = ~dialogue_show_profession_details; + else if(newDialogueType == DIALOGUE_76) + { + if (speakingNPC->Hired()) + { + if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) + { + for ( uint i = 0; i < (unsigned int)pNPCStats->uNumNewNPCs; ++i ) + { + if ( pNPCStats->pNewNPCData[i].uFlags & 0x80 && !strcmp(speakingNPC->pName, pNPCStats->pNewNPCData[i].pName) ) + pNPCStats->pNewNPCData[i].uFlags &= 0x7Fu; + } + } + if ( pParty->pHirelings[0].pName && !_stricmp(pParty->pHirelings[0].pName, speakingNPC->pName) ) + memset(&pParty->pHirelings[0], 0, sizeof(NPCData)); + else if ( pParty->pHirelings[1].pName && !_stricmp(pParty->pHirelings[1].pName, speakingNPC->pName) ) + memset(&pParty->pHirelings[1], 0, sizeof(NPCData)); + pParty->hirelingScrollPosition = 0; + pParty->CountHirelings(); + dword_591084 = 0; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + dword_7241C8 = 0; + return; + } + if ( pParty->pHirelings[0].pName && pParty->pHirelings[1].pName ) + ShowStatusBarString(pGlobalTXT_LocalizationStrings[533], 2);// ""I cannot join you, you're party is full"" + else + { + if ( speakingNPC->uProfession != 51 ) //burglars have no hiring price + { + if ( pParty->uNumGold < pNPCStats->pProfessions[speakingNPC->uProfession].uHirePrice ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" + dialogue_show_profession_details = false; + uDialogueType = 13; + if ( uActiveCharacter ) + pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0); + if ( !dword_7241C8 ) + pGame->Draw(); + dword_7241C8 = 0; + return; + } + Party::TakeGold(pNPCStats->pProfessions[speakingNPC->uProfession].uHirePrice); + } + LOBYTE(speakingNPC->uFlags) |= 0x80u; + if ( pParty->pHirelings[0].pName ) + { + memcpy(&pParty->pHirelings[1], speakingNPC, sizeof(pParty->pHirelings[1])); + v13 = pParty->pHireling2Name; + } + else + { + memcpy(&pParty->pHirelings[0], speakingNPC, sizeof(pParty->pHirelings[0])); + v13 = pParty->pHireling1Name; + } + strcpy(v13, speakingNPC->pName); + pParty->hirelingScrollPosition = 0; + pParty->CountHirelings(); + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + if ( sDialogue_SpeakingActorNPC_ID >= 0 ) + pDialogue_SpeakingActor->uAIState = Removed; + if ( uActiveCharacter ) + pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0); + } + } + else if ( (signed int)newDialogueType > DIALOGUE_84 && (signed int)newDialogueType <= DIALOGUE_ARENA_SELECT_CHAMPION ) // + { + ArenaFight(); + return; + } + else if(newDialogueType == DIALOGUE_USE_NPC_ABILITY) + { + if (UseNPCSkill((NPCProf)speakingNPC->uProfession) == 0) + { + if ( speakingNPC->uProfession != GateMaster ) + speakingNPC->bHasUsedTheAbility = 1; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + } + else + ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2); //"Your packs are already full!" + } + else if(newDialogueType == DIALOGUE_13) + { + if (!speakingNPC->Hired()) + { + sub_4B3E1E(); + dialogue_show_profession_details = false; + } + else + { + for ( uint i = 0; i < (signed int)pNPCStats->uNumNewNPCs; ++i ) + { + if ( pNPCStats->pNewNPCData[i].uFlags & 0x80 && !strcmp(speakingNPC->pName, pNPCStats->pNewNPCData[i].pName) ) + pNPCStats->pNewNPCData[i].uFlags &= 0x7Fu; + } + if ( pParty->pHirelings[0].pName && !_stricmp(pParty->pHirelings[0].pName, speakingNPC->pName) ) + memset(&pParty->pHirelings[0], 0, sizeof(NPCData)); + else if ( pParty->pHirelings[1].pName && !_stricmp(pParty->pHirelings[1].pName, speakingNPC->pName) ) + memset(&pParty->pHirelings[1], 0, sizeof(NPCData)); + pParty->hirelingScrollPosition = 0; + pParty->CountHirelings(); + dword_591084 = 0; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + dword_7241C8 = 0; + return; + } + } + else if(newDialogueType >= DIALOGUE_EVT_A && newDialogueType <= DIALOGUE_EVT_F) + { + switch(newDialogueType) + { + case DIALOGUE_EVT_A: npc_event_id = speakingNPC->evt_A; break; + case DIALOGUE_EVT_B: npc_event_id = speakingNPC->evt_B; break; + case DIALOGUE_EVT_C: npc_event_id = speakingNPC->evt_C; break; + case DIALOGUE_EVT_D: npc_event_id = speakingNPC->evt_D; break; + case DIALOGUE_EVT_E: npc_event_id = speakingNPC->evt_E; break; + case DIALOGUE_EVT_F: npc_event_id = speakingNPC->evt_F; break; + } + if ( (npc_event_id >= 200) && (npc_event_id <= 310) ) + _4B3FE5_training_dialogue(npc_event_id); //200-310 + else if (( npc_event_id >= 400) && (npc_event_id <= 410) ) + { //400-410 + dword_F8B1D8 = newDialogueType; + DrawJoinGuildWindow(npc_event_id - 400); + } + else + { + switch ( npc_event_id ) + { + case 139: + OracleDialogue(); + break; + case 311: + CheckBountyRespawnAndAward(); + break; + case 399: + Arena_SelectionFightLevel(); + break; + default: + activeLevelDecoration = (LevelDecoration*)1; + current_npc_text = 0; + EventProcessor(npc_event_id, 0, 1); + activeLevelDecoration = NULL; + break; + } + } + } + if ( !dword_7241C8 ) + pGame->Draw(); + dword_7241C8 = 0; } //----- (004BDAAF) -------------------------------------------------------- bool MerchandiseTest(ItemGen *item, int _2da_idx) { - int v6; // edx@8 - int v7; // edx@9 - int v8; // edx@10 - unsigned __int8 v9; // zf@16 - char v10; // sf@16 - unsigned __int8 v11; // of@16 bool test; if ( (p2DEvents[_2da_idx - 1].uType != 4 || (signed int)item->uItemID < 740 || (signed int)item->uItemID > 771)