Mercurial > mm7
changeset 466:91e1ba340f39
Слияние
author | Ritor1 |
---|---|
date | Mon, 25 Feb 2013 09:09:08 +0600 |
parents | e65d75206263 (current diff) 62ca9e2e1432 (diff) |
children | 5d2667144526 |
files | lib/legacy_dx/lib/.svn/all-wcprops lib/legacy_dx/lib/.svn/entries lib/legacy_dx/lib/.svn/prop-base/d3dxof.lib.svn-base lib/legacy_dx/lib/.svn/prop-base/ddraw.lib.svn-base lib/legacy_dx/lib/.svn/prop-base/dinput.lib.svn-base lib/legacy_dx/lib/.svn/prop-base/dinput8.lib.svn-base lib/legacy_dx/lib/.svn/prop-base/dxguid.lib.svn-base lib/legacy_dx/lib/.svn/text-base/d3dxof.lib.svn-base lib/legacy_dx/lib/.svn/text-base/ddraw.lib.svn-base lib/legacy_dx/lib/.svn/text-base/dinput.lib.svn-base lib/legacy_dx/lib/.svn/text-base/dinput8.lib.svn-base lib/legacy_dx/lib/.svn/text-base/dxguid.lib.svn-base mm7_2.cpp mm7_data.cpp mm7_data.h |
diffstat | 61 files changed, 3841 insertions(+), 3988 deletions(-) [+] |
line wrap: on
line diff
--- a/AIL.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/AIL.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -35,7 +35,7 @@ void (__stdcall *mss32_AIL_set_sample_loop_count)(HSAMPLE, int) = 0; void (__stdcall *mss32_AIL_set_sample_playback_rate)(HSAMPLE, int) = 0; void (__stdcall *mss32_AIL_sample_ms_position)(HSAMPLE, int *, int *) = 0; -void (__stdcall *mss32_AIL_start_sample)(HSAMPLE) = 0; +int (__stdcall *mss32_AIL_start_sample)(HSAMPLE) = 0; AILFILETYPE (__stdcall *mss32_AIL_file_type)(void *, int) = 0; int (__stdcall *mss32_AIL_WAV_info)(void *, AILSOUNDINFO *) = 0; int (__stdcall *mss32_AIL_decompress_ADPCM)(AILSOUNDINFO *, void *, void *) = 0; @@ -77,7 +77,7 @@ mss32_AIL_set_sample_loop_count = (void (__stdcall *)(HSAMPLE, int))GetProcAddress(pDll, "_AIL_set_sample_loop_count@8"); mss32_AIL_set_sample_playback_rate = (void (__stdcall *)(HSAMPLE, int))GetProcAddress(pDll, "_AIL_set_sample_playback_rate@8"); mss32_AIL_sample_ms_position = (void (__stdcall *)(HSAMPLE, int *, int *))GetProcAddress(pDll, "_AIL_sample_ms_position@12"); - mss32_AIL_start_sample = (void (__stdcall *)(HSAMPLE))GetProcAddress(pDll, "_AIL_start_sample@4"); + mss32_AIL_start_sample = (int (__stdcall *)(HSAMPLE))GetProcAddress(pDll, "_AIL_start_sample@4"); mss32_AIL_file_type = (AILFILETYPE (__stdcall *)(void *, int))GetProcAddress(pDll, "_AIL_file_type@8"); mss32_AIL_WAV_info = (int (__stdcall *)(void *, AILSOUNDINFO *))GetProcAddress(pDll, "_AIL_WAV_info@8"); mss32_AIL_decompress_ADPCM = (int (__stdcall *)(AILSOUNDINFO *, void *, void *))GetProcAddress(pDll, "_AIL_decompress_ADPCM@12"); @@ -171,10 +171,7 @@ } void __stdcall AIL_3D_provider_attribute(HPROVIDER lib, char *name, void *val) -{ - //__asm int 3 - //return 0; - +{ (mss32_AIL_3D_provider_attribute)(lib,name,val); } @@ -210,9 +207,6 @@ void __stdcall AIL_waveOutClose(HDIGDRIVER drvr) { - //__asm int 3 - //return 0; - (mss32_AIL_waveOutClose)(drvr); } @@ -248,9 +242,6 @@ void __stdcall AIL_release_sample_handle(HSAMPLE s) { - //__asm int 3 - //return 0; - (mss32_AIL_release_sample_handle)(s); } @@ -262,20 +253,20 @@ int __stdcall AIL_close_3D_provider(HPROVIDER) { - //__asm int 3 + __asm int 3 return 0; } int __stdcall AIL_redbook_close(HREDBOOK a1) { - //__asm int 3 + __asm int 3 return 0; } // sub_4D8344: using guessed type int __stdcall AIL_shutdown(); int __stdcall AIL_shutdown() { - //__asm int 3 + __asm int 3 return 0; } @@ -306,9 +297,9 @@ return (mss32_AIL_set_sample_file)(s, file_image, block); } -void __stdcall AIL_start_sample(HSAMPLE s) +int __stdcall AIL_start_sample(HSAMPLE s) { - (mss32_AIL_start_sample)(s); + return (mss32_AIL_start_sample)(s); } void __stdcall AIL_set_sample_playback_rate(HSAMPLE s, int rate)
--- a/AIL.h Mon Feb 25 09:08:13 2013 +0600 +++ b/AIL.h Mon Feb 25 09:09:08 2013 +0600 @@ -272,7 +272,7 @@ void __stdcall AIL_end_sequence(HSEQUENCE a1); void __stdcall AIL_pause_stream(HSTREAM a1, int onoff); int __stdcall AIL_set_sample_file(HSAMPLE, const void *file_image, int block); -void __stdcall AIL_start_sample(HSAMPLE); +int __stdcall AIL_start_sample(HSAMPLE); void __stdcall AIL_set_sample_playback_rate(HSAMPLE, int rate); void __stdcall AIL_sample_ms_position(HSAMPLE, int *pTotalMS, int *pCurrentMS); int __stdcall AIL_3D_sample_status(void *a1);
--- a/Actor.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/Actor.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -151,14 +151,14 @@ NPCData *v4; // eax@1 NPCData *v5; // ebp@1 unsigned int v6; // eax@1 - signed int v7; // eax@3 + //signed int v7; // eax@3 unsigned int v8; // eax@8 int v9; // esi@8 int v10; // eax@11 GUIWindow *v11; // ecx@19 signed int v12; // eax@21 //int v13; // [sp-8h] [bp-44h]@34 - const char *v14; // [sp-4h] [bp-40h]@4 + //const char *v14; // [sp-4h] [bp-40h]@4 //int v15; // [sp-4h] [bp-40h]@34 signed int v16; // [sp-4h] [bp-40h]@35 int v17; // [sp+10h] [bp-2Ch]@1 @@ -181,9 +181,9 @@ v6 = v4->uFlags; if ( (v6 & 3) != 2 ) v5->uFlags = v6 + 1; - v7 = const_2(); + /*v7 = const_2(); sprintf(pContainer, "evt%02d", v7); - if ( !pParty->uAlignment ) + if (pParty->alignment == PartyAlignment_Good) { v14 = "-b"; strcat(pContainer, v14); @@ -192,9 +192,17 @@ { v14 = "-c"; strcat(pContainer, v14); + }*/ + + switch (pParty->alignment) + { + case PartyAlignment_Good: sprintf(pContainer, "evt%02d-b", const_2()); break; + case PartyAlignment_Neutral: sprintf(pContainer, "evt%02d", const_2()); break; + case PartyAlignment_Evil: sprintf(pContainer, "evt%02d-c", const_2()); break; } + v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - array_5913D8[6] = 0; + pDialogueNPCCount = 0; uNumDialogueNPCPortraits = 1; pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v8]; sprintf(pContainer, "npc%03u", v5->uPortraitID); @@ -335,7 +343,7 @@ if ( v2 ) { v1->array_000234[3].uItemID = 197; - v1->array_000234[3].uAdditionalValue = v2; + v1->array_000234[3].uSpecEnchantmentType = v2; } } } @@ -1983,87 +1991,42 @@ v9->UpdateAnimation(); } else - Actor::_402F87(v5, v4, a4); + Actor::AI_Bored(v5, v4, a4); } //----- (00403F58) -------------------------------------------------------- -void Actor::_403F58(unsigned int uActorID, signed int uObjID, int uActionLength, AIDirection *a4) +void Actor::AI_StandOrBored(unsigned int uActorID, signed int uObjID, int uActionLength, AIDirection *a4) { - unsigned int v4; // esi@1 - //unsigned int result; // eax@2 - AIDirection *v6; // eax@3 - unsigned int v7; // edi@3 - Actor *v8; // ebx@3 - AIDirection *v9; // esi@4 - AIDirection a3; // [sp+4h] [bp-3Ch]@4 - AIDirection v11; // [sp+20h] [bp-20h]@4 - signed int a2; // [sp+3Ch] [bp-4h]@1 - - a2 = uObjID; - v4 = uActorID; - if ( rand() % 2 ) - { - Actor::_402F87(v4, a2, a4); - return; - } - - v6 = a4; - v7 = 0; - v8 = &pActors[v4]; - if ( !a4 ) - { - v9 = Actor::GetDirectionInfo(8 * v4 | 3, a2, &a3, 0); - v6 = &v11; - memcpy(&v11, v9, sizeof(v11)); - v7 = 0; - } - v8->uYawAngle = LOWORD(v6->uYawAngle); - v8->uPitchAngle = LOWORD(v6->uPitchAngle); - if ( uActionLength == v7 ) - v8->uCurrentActionLength = rand() % 256 + 256; - else - v8->uCurrentActionLength = uActionLength; - v8->uCurrentActionTime = v7; - v8->uAIState = Standing; - v8->vVelocity.z = v7; - v8->vVelocity.y = v7; - v8->vVelocity.x = v7; - v8->UpdateAnimation(); + if (rand() % 2) + AI_Bored(uActorID, uObjID, a4); + else + AI_Stand(uActorID, uObjID, uActionLength, a4); } //----- (00403EB6) -------------------------------------------------------- -void Actor::_403EB6(unsigned int uActorID, unsigned int a2, unsigned int uActionLength, AIDirection *a4) +void Actor::AI_Stand(unsigned int uActorID, unsigned int object_to_face_pid, unsigned int uActionLength, AIDirection *a4) { - AIDirection *v4; // eax@1 - unsigned int v5; // esi@1 - Actor *v6; // ebx@1 - AIDirection *v7; // esi@2 - AIDirection a3; // [sp+Ch] [bp-38h]@2 - AIDirection v10; // [sp+28h] [bp-1Ch]@2 + assert(uActorID < uNumActors); + auto actor = pActors + uActorID; + + AIDirection a3; + if (!a4) + a4 = Actor::GetDirectionInfo(8 * uActorID | 3, object_to_face_pid, &a3, 0); - v4 = a4; - v5 = 0; - v6 = &pActors[uActorID]; - if ( !a4 ) - { - v7 = Actor::GetDirectionInfo(8 * uActorID | 3, a2, &a3, 0); - v4 = &v10; - memcpy(&v10, v7, sizeof(v10)); - v5 = 0; - } - v6->uYawAngle = LOWORD(v4->uYawAngle); - if ( uActionLength == v5 ) - v6->uCurrentActionLength = rand() % 256 + 256; + actor->uAIState = Standing; + if (!uActionLength) + actor->uCurrentActionLength = rand() % 256 + 256; else - v6->uCurrentActionLength = uActionLength; - v6->uCurrentActionTime = v5; - v6->uAIState = Standing; - v6->vVelocity.z = v5; - v6->vVelocity.y = v5; - v6->vVelocity.x = v5; - v6->UpdateAnimation(); + actor->uCurrentActionLength = uActionLength; + actor->uCurrentActionTime = 0; + actor->uYawAngle = a4->uYawAngle; + actor->uPitchAngle = a4->uPitchAngle; + actor->vVelocity.z = 0; + actor->vVelocity.y = 0; + actor->vVelocity.x = 0; + actor->UpdateAnimation(); } @@ -2115,7 +2078,7 @@ v24 = uActorID; if ( v4 && v3->pMonsterInfo.uAIType == 1 ) { - Actor::_403EB6(uActorID, edx0, 0, arg0); + Actor::AI_Stand(uActorID, edx0, 0, arg0); return; } @@ -2921,6 +2884,8 @@ unsigned int uActorID; // [sp+34h] [bp-8h]@1 int v19; // [sp+38h] [bp-4h]@1 + //v14 never filled, maybe it is passed to function but optimized away as local variable + uActorID = a1; v4 = a1; v5 = &pActors[a1]; @@ -2938,14 +2903,14 @@ { if ( !uActionLength ) uActionLength = 256; - Actor::_403F58(uActorID, 4, uActionLength, &v14); + Actor::AI_StandOrBored(uActorID, OBJECT_Player, uActionLength, &v14); return; } if ( pActors[v4].pMonsterInfo.uMovementType == 3 && v19 < 128 ) { v13 = &v14; v12 = 256; - Actor::_403EB6(uActorID, v16, v12, v13); + Actor::AI_Stand(uActorID, v16, v12, v13); return; } v15 = (rand() & 0xF) << 12; @@ -2961,7 +2926,7 @@ { v13 = &v14; v12 = 256; - Actor::_403EB6(uActorID, v16, v12, v13); + Actor::AI_Stand(uActorID, v16, v12, v13); return; } v11 = v5->uMovementSpeed; @@ -3088,54 +3053,36 @@ } //----- (00402F87) -------------------------------------------------------- -void Actor::_402F87(unsigned int uActorID, unsigned int uObjID, AIDirection *a4) +void Actor::AI_Bored(unsigned int uActorID, unsigned int uObjID, AIDirection *a4) { - int v3; // edi@1 - AIDirection *v4; // esi@1 - Actor *v5; // ebx@1 - SpriteFrame *v6; // ecx@3 unsigned int v7; // eax@3 - int v8; // edx@3 unsigned int v9; // eax@3 - //int result; // eax@4 + + assert(uActorID < uNumActors); + auto actor = pActors + uActorID; + AIDirection a3; // [sp+Ch] [bp-5Ch]@2 - AIDirection v12; // [sp+28h] [bp-40h]@2 - AIDirection v13; // [sp+44h] [bp-24h]@2 - unsigned int v14; // [sp+60h] [bp-8h]@1 - unsigned int v15; // [sp+64h] [bp-4h]@1 + if (!a4) + a4 = Actor::GetDirectionInfo(8 * uActorID | OBJECT_Actor, uObjID, &a3, 0); + + actor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[actor->pSpriteIDs[ANIM_Bored]].uAnimLength; - v3 = uActorID; - v4 = a4; - v5 = &pActors[uActorID]; - v14 = uObjID; - v15 = uActorID; - if ( !a4 ) + v7 = stru_5C6E00->Atan2(actor->vPosition.x - pIndoorCamera->pos.x, actor->vPosition.y - pIndoorCamera->pos.y); + v9 = stru_5C6E00->uIntegerPi + actor->uYawAngle + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7; + + if ( BYTE1(v9) & 7 ) // turned away - just stand + Actor::AI_Stand(uActorID, uObjID, actor->uCurrentActionLength, a4); + else // facing player - play bored anim { - memcpy(&v13, Actor::GetDirectionInfo(8 * uActorID | AI_OBJECT_ACTOR, uObjID, &a3, (int)a4), sizeof(v13)); - memcpy(&v12, &v13, sizeof(v12)); - v3 = v15; - v4 = &v12; - } - v6 = pSpriteFrameTable->pSpriteSFrames; - v5->uYawAngle = LOWORD(v4->uYawAngle); - v5->uCurrentActionLength = 8 * v6[v5->pSpriteIDs[ANIM_Bored]].uAnimLength; - v7 = stru_5C6E00->Atan2(v5->vPosition.x - pIndoorCamera->pos.x, v5->vPosition.y - pIndoorCamera->pos.y); - LOWORD(v8) = v5->uYawAngle; - v9 = stru_5C6E00->uIntegerPi + v8 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7; - if ( BYTE1(v9) & 7 ) - { - Actor::_403EB6(v3, v14, v5->uCurrentActionLength, v4); - } - else - { - v5->uAIState = Fidgeting; - v5->uCurrentActionTime = 0; - v5->vVelocity.z = 0; - v5->vVelocity.y = 0; - v5->vVelocity.x = 0; + actor->uAIState = Fidgeting; + actor->uCurrentActionTime = 0; + actor->uYawAngle = a4->uYawAngle; + actor->vVelocity.z = 0; + actor->vVelocity.y = 0; + actor->vVelocity.x = 0; if ( rand() % 100 < 5 ) - Actor::PlaySound(v3, 3u); - v5->UpdateAnimation(); + Actor::PlaySound(uActorID, 3); + actor->UpdateAnimation(); } } @@ -3278,12 +3225,11 @@ v8 = 0; } v7 = 8 * uActorID; - LOBYTE(v7) = 8 * uActorID | 3; + LOBYTE(v7) = 8 * uActorID | OBJECT_Actor; pAudioPlayer->PlaySound((SoundID)(signed __int16)v3, v7, 0, v8, v9, v10, v11, v12); } } - //----- (00402AD7) -------------------------------------------------------- void Actor::_402AD7(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, AIDirection *pDir) { @@ -3328,19 +3274,19 @@ { if ( !uActionLength ) uActionLength = 256; - Actor::_403F58(v5, 4, uActionLength, v10); + Actor::AI_StandOrBored(v5, 4, uActionLength, v10); return; } if ( (double)(signed int)v10->uDistance < 307.2 ) { if ( !uActionLength ) uActionLength = 256; - Actor::_403EB6(v5, v18, uActionLength, v10); + Actor::AI_Stand(v5, v18, uActionLength, v10); return; } if ( !v7->uMovementSpeed ) { - Actor::_403EB6(v5, v18, uActionLength, v10); + Actor::AI_Stand(v5, v18, uActionLength, v10); return; } v18 = 16; @@ -3404,7 +3350,7 @@ { if ( !uActionLength ) uActionLength = 256; - Actor::_403F58(v15, 4, uActionLength, &v13); + Actor::AI_StandOrBored(v15, 4, uActionLength, &v13); } else { @@ -3475,7 +3421,7 @@ v16 = v10; v15 = uActionLength; v11 = 4; - Actor::_403F58(v5, v11, v15, v16); + Actor::AI_StandOrBored(v5, v11, v15, v16); return; } if ( (signed int)v10->uDistance < a5 ) @@ -3485,7 +3431,7 @@ v11 = v19; v16 = v10; v15 = uActionLength; - Actor::_403F58(v5, v11, v15, v16); + Actor::AI_StandOrBored(v5, v11, v15, v16); return; } if ( uActionLength ) @@ -3562,7 +3508,7 @@ v18 = v9; v17 = uActionLength; v10 = 4; - return Actor::_403F58(v4, v10, v17, v18); + return Actor::AI_StandOrBored(v4, v10, v17, v18); } if ( (double)(signed int)v9->uDistance < 307.2 ) { @@ -3571,7 +3517,7 @@ v10 = v21; v18 = v9; v17 = uActionLength; - return Actor::_403F58(v4, v10, v17, v18); + return Actor::AI_StandOrBored(v4, v10, v17, v18); } if ( uActionLength ) { @@ -3603,146 +3549,137 @@ v6->UpdateAnimation(); } -//----- (00401221) -------------------------------------------------------- -void Actor::_401221(unsigned int uActorID, int *a2, unsigned int a3) +//----- (00SelectTarget) -------------------------------------------------------- +void Actor::_SelectTarget(unsigned int uActorID, int *a2, bool can_target_party) { - Actor *v3; // esi@1 - unsigned int v4; // ebx@1 + //Actor *v3; // esi@1 + //unsigned int v4; // ebx@1 int v5; // ecx@1 - unsigned int v6; // eax@1 - Actor *v7; // edi@2 - __int16 v8; // ax@3 + //unsigned int v6; // eax@1 + //Actor *v7; // edi@2 + //__int16 v8; // ax@3 int v9; // eax@10 signed int v10; // eax@13 int v11; // ebx@16 int v12; // eax@16 - int v13; // eax@25 + //int v13; // eax@25 signed int v14; // eax@31 int v15; // edi@43 int v16; // ebx@45 int v17; // eax@45 - int v18; // eax@51 + //int v18; // eax@51 int v19; // [sp+Ch] [bp-24h]@16 - int *v20; // [sp+10h] [bp-20h]@1 + //int *v20; // [sp+10h] [bp-20h]@1 signed int v21; // [sp+14h] [bp-1Ch]@1 - unsigned int v22; // [sp+18h] [bp-18h]@1 + //unsigned int v22; // [sp+18h] [bp-18h]@1 int v23; // [sp+1Ch] [bp-14h]@16 - unsigned int v24; // [sp+20h] [bp-10h]@1 + //unsigned int v24; // [sp+20h] [bp-10h]@1 int v25; // [sp+24h] [bp-Ch]@1 - signed int v26; // [sp+28h] [bp-8h]@1 + //signed int v26; // [sp+28h] [bp-8h]@1 int v27; // [sp+2Ch] [bp-4h]@16 int v28; // [sp+2Ch] [bp-4h]@45 v25 = -1; - v22 = uActorID; - v3 = &pActors[uActorID]; - v4 = 0; + //v22 = uActorID; + //v3 = &pActors[uActorID]; + //v4 = 0; v5 = 0; - v6 = v3->uLastCharacterIDToHit; + //v6 = v3->uLastCharacterIDToHit; *a2 = 0; - v20 = a2; + //v20 = a2; v21 = 0; - v24 = v6; - v26 = 0; - if ( (signed int)uNumActors > 0 ) + //v24 = v3->uLastCharacterIDToHit; + //v26 = 0; + assert(uActorID < uNumActors); + auto _this = pActors + uActorID; + + for (uint i = 0; i < uNumActors; ++i) { - v7 = pActors; - do - { - v8 = v7->uAIState; - if ( v7->uAIState == 5 || v8 == 4 || v8 == 11 || v8 == 17 || v8 == 19 || v22 == v5 ) + auto actor = pActors + i; + //v7 = pActors; + //do + //{ + //v8 = v7->uAIState; + if (actor->uAIState == Dead || actor->uAIState == Dying || + actor->uAIState == Removed || actor->uAIState == Summoned || actor->uAIState == Disabled || uActorID == i ) + continue; + + if (_this->uLastCharacterIDToHit == 0 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, _this->uLastCharacterIDToHit != v9) ) { - ++v7; - v5 = v26++ + 1; + v10 = _this->GetActorsRelation(actor); + if ( v10 == 0 ) continue; } - if ( v24 == v4 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, v24 != v9) ) + else if (_this->IsNotAlive()) { - v10 = v3->GetActorsRelation(v7); - if ( v10 == v4 ) - { - ++v7; - v5 = v26++ + 1; + _this->uLastCharacterIDToHit = 0; + v10 = _this->GetActorsRelation(actor); + if ( v10 == 0 ) continue; - } - } - else if (v7->IsNotAlive()) - { - v24 = v4; - v3->uLastCharacterIDToHit = v4; - v10 = v3->GetActorsRelation(v7); - if ( v10 == v4 ) - { - ++v7; - v5 = v26++ + 1; - continue; - } } else { - v18 = v7->uGroup; - if ( (v18 != v4 || v3->uGroup != v4) && v18 == v3->uGroup ) - { - ++v7; - v5 = v26++ + 1; + //v18 = actor->uGroup; + if ( (actor->uGroup != 0 || _this->uGroup != 0) && actor->uGroup == _this->uGroup ) continue; - } v10 = 4; } - if ( v3->pMonsterInfo.uHostilityType ) - v10 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uHostilityType; + if ( _this->pMonsterInfo.uHostilityType ) + v10 = pMonsterStats->pInfos[_this->pMonsterInfo.uID].uHostilityType; v11 = dword_4DF380[v10]; - v23 = abs(v3->vPosition.x - v7->vPosition.x); - v27 = abs(v3->vPosition.y - v7->vPosition.y); - v12 = abs(v3->vPosition.z - v7->vPosition.z); + v23 = abs(_this->vPosition.x - actor->vPosition.x); + v27 = abs(_this->vPosition.y - actor->vPosition.y); + v12 = abs(_this->vPosition.z - actor->vPosition.z); v19 = v12; if ( v23 <= v11 && v27 <= v11 && v12 <= v11 - && sub_4070EF_prolly_collide_objects(8 * v26 | 3, 8 * v22 | 3) + && sub_4070EF_prolly_collide_objects(8 * i | OBJECT_Actor, 8 * uActorID | OBJECT_Actor) && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 ) { v25 = v23 * v23 + v27 * v27 + v19 * v19; - v21 = v26; + v21 = i; } - v4 = 0; - ++v7; - v5 = v26++ + 1; - } - while ( v26 < (signed int)uNumActors ); - if ( v25 != -1 ) - { - v13 = 8 * v21; - LOBYTE(v13) = 8 * v21 | 3; - *v20 = v13; - } + //v4 = 0; + //++v7; + //v5 = v26++ + 1; + //} + //while ( v26 < (signed int)uNumActors ); + } - if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= (signed int)v4 - && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > (signed int)v4 || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > v4) ) - a3 = v4; - if ( a3 != v4 ) + if ( v25 != -1 ) + { + //v13 = 8 * v21; + //LOBYTE(v13) = 8 * v21 | OBJECT_Actor; + *a2 = 8 * v21 | OBJECT_Actor; + } + + if (pParty->Invisible()) + can_target_party = false; + + if (can_target_party) { - v14 = v3->GetActorsRelation(0); - if ( BYTE2(v3->uAttributes) & 8 - && SHIDWORD(v3->pActorBuffs[12].uExpireTime) <= (signed int)v4 - && (SHIDWORD(v3->pActorBuffs[12].uExpireTime) < (signed int)v4 || LODWORD(v3->pActorBuffs[12].uExpireTime) <= v4) - && SHIDWORD(v3->pActorBuffs[1].uExpireTime) <= (signed int)v4 - && (SHIDWORD(v3->pActorBuffs[1].uExpireTime) < (signed int)v4 || LODWORD(v3->pActorBuffs[1].uExpireTime) <= v4) - && SHIDWORD(v3->pActorBuffs[2].uExpireTime) <= (signed int)v4 - && (SHIDWORD(v3->pActorBuffs[2].uExpireTime) < (signed int)v4 || LODWORD(v3->pActorBuffs[2].uExpireTime) <= v4) ) + v14 = _this->GetActorsRelation(0); + if ( BYTE2(_this->uAttributes) & 8 + && SHIDWORD(_this->pActorBuffs[12].uExpireTime) <= (signed int)0 + && (SHIDWORD(_this->pActorBuffs[12].uExpireTime) < (signed int)0 || LODWORD(_this->pActorBuffs[12].uExpireTime) <= 0) + && SHIDWORD(_this->pActorBuffs[1].uExpireTime) <= (signed int)0 + && (SHIDWORD(_this->pActorBuffs[1].uExpireTime) < (signed int)0 || LODWORD(_this->pActorBuffs[1].uExpireTime) <= 0) + && SHIDWORD(_this->pActorBuffs[2].uExpireTime) <= (signed int)0 + && (SHIDWORD(_this->pActorBuffs[2].uExpireTime) < (signed int)0 || LODWORD(_this->pActorBuffs[2].uExpireTime) <= 0) ) v14 = 4; - if ( v14 != v4 ) + if ( v14 != 0 ) { v15 = dword_4DF390; - if ( !v3->pMonsterInfo.uHostilityType ) + if ( !_this->pMonsterInfo.uHostilityType ) v15 = dword_4DF380[v14]; - v16 = abs(v3->vPosition.x - pParty->vPosition.x); - v28 = abs(v3->vPosition.y - pParty->vPosition.y); - v17 = abs(v3->vPosition.z - pParty->vPosition.z); + v16 = abs(_this->vPosition.x - pParty->vPosition.x); + v28 = abs(_this->vPosition.y - pParty->vPosition.y); + v17 = abs(_this->vPosition.z - pParty->vPosition.z); if ( v16 <= v15 && v28 <= v15 && v17 <= v15 ) { if ( v16 * v16 + v28 * v28 + v17 * v17 < (unsigned int)v25 ) - *v20 = 4; + *a2 = OBJECT_Player; } } }
--- a/Actor.h Mon Feb 25 09:08:13 2013 +0600 +++ b/Actor.h Mon Feb 25 09:09:08 2013 +0600 @@ -40,6 +40,8 @@ /* 361 */ enum ACTOR_BUFF_INDEX { + ACTOR_BUFF_CHARM = 1, // an assumption + ACTOR_BUFF_SHRINK = 3, // an assumption ACTOR_BUFF_STONED = 5, ACTOR_BUFF_PARALYZED = 6, }; @@ -199,7 +201,7 @@ bool IsPeasant(); - static void _401221(unsigned int uActorID, int *a2, unsigned int a3); + static void _SelectTarget(unsigned int uActorID, int *a2, bool can_target_party); static void _402686(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *a4); static void _40281C(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *pDir, int a5); static void _402968(unsigned int uActorID, signed int edx0, int uActionLength, struct AIDirection *a4); @@ -207,7 +209,7 @@ static void PlaySound(unsigned int uActorID, unsigned int uSoundID); static void Die(unsigned int uActorID); static void Resurrect(unsigned int uActorID); - static void _402F87(unsigned int uActorID, unsigned int uObjID, struct AIDirection *a4); + static void AI_Bored(unsigned int uActorID, unsigned int uObjID, struct AIDirection *a4); static void _4030AD(unsigned int uActorID, signed int edx0, int arg0); static char __fastcall _4031C1_update_job(unsigned int uActorID, signed int a2, int a3); static void _4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength); @@ -217,8 +219,8 @@ static void _403A60(unsigned int uActorID, signed int edx0, struct AIDirection *pDir); static void _403C6C(unsigned int uActorID, signed int edx0, struct AIDirection *arg0); static void __fastcall StandAwhile(unsigned int uActorID); - static void _403EB6(unsigned int uActorID, unsigned int a2, unsigned int uActionLength, struct AIDirection *a4); - static void _403F58(unsigned int uActorID, signed int uObjID, int uActionLength, struct AIDirection *a4); + static void AI_Stand(unsigned int uActorID, unsigned int object_to_face_pid, unsigned int uActionLength, struct AIDirection *a4); + static void AI_StandOrBored(unsigned int uActorID, signed int uObjID, int uActionLength, struct AIDirection *a4); static void FaceObject(unsigned int uActorID, unsigned int uObjID, int _48, struct AIDirection *a4); static struct AIDirection *__fastcall GetDirectionInfo(unsigned int uObj1ID, unsigned int uObj2ID, struct AIDirection *pOut, int a4); static signed int __fastcall Explode(unsigned int uActorID); @@ -263,7 +265,7 @@ char field_B7; unsigned int uCurrentActionTime; unsigned __int16 pSpriteIDs[8]; - unsigned __int16 pSoundSampleIDs[4]; + unsigned __int16 pSoundSampleIDs[4]; // 1 die 3 bored struct SpellBuff pActorBuffs[22]; struct ItemGen array_000234[4]; unsigned int uGroup;
--- a/AudioPlayer.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/AudioPlayer.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -1,4 +1,5 @@ #include <string> +#include <assert.h> #include "AudioPlayer.h" #include "Allocator.h" @@ -13,6 +14,8 @@ #include "OSInfo.h" #include "Math.h" #include "MapInfo.h" +#include "Actor.h" +#include "GUIWindow.h" #include "Log.h" #include "Bink_Smacker.h" @@ -602,9 +605,9 @@ v6 = v2->pMixerChannels; do { - if ( v6->dword_000004 == a2 ) + if ( v6->source_pid == a2 ) { - if ( AIL_sample_status(v6->hSample) == 4 ) + if ( AIL_sample_status(v6->hSample) == AIL::Sample::Playing) { AIL_end_sample(v6->hSample); _4ABE55(v6); @@ -620,17 +623,13 @@ } } } -// 4D82F4: using guessed type int __stdcall AIL_3D_sample_status(int); -// 4D82F8: using guessed type int __stdcall AIL_sample_status(int); -// 4D82FC: using guessed type int __stdcall AIL_end_sample(int); -// 4D8300: using guessed type int __stdcall AIL_end_3D_sample(int); //----- (004AA306) -------------------------------------------------------- void AudioPlayer::PlaySound(SoundID eSoundID, signed int a3, unsigned int uNumRepeats, signed int PartyX, signed int PartyY, int a7, unsigned int uVolume, int sPlaybackRate) { //AudioPlayer *pAudioPlayer1; // esi@1 - signed int pNum; // edx@5 - int *pSoundID; // ecx@6 + //signed int pNum; // edx@5 + //int *pSoundID; // ecx@6 int v12; // edi@13 signed int v13; // ecx@17 signed int v14; // eax@20 @@ -658,7 +657,7 @@ signed int v36; // ebx@74 //AudioPlayer *pAudioPlayer2; // edi@79 AudioPlayer_3DSample *pAudioPlayer_3DSample3; // esi@79 - unsigned int v39; // ebx@80 + //unsigned int v39; // ebx@80 int v40; // eax@81 char *v41; // edi@82 int v42; // esi@82 @@ -677,44 +676,44 @@ //AudioPlayer *pAudioPlayer3; // edx@106 SoundDesc *pSoundDesc; // edx@107 LayingItem *pLayingItem3; // eax@114 - int v58; // edx@115 - int v59; // ecx@115 - Actor *pActor2; // eax@118 - MixerChannel *pMixerChannel; // esi@126 + //int v58; // edx@115 + //int v59; // ecx@115 + //Actor *pActor2; // eax@118 + //MixerChannel *pMixerChannel; // esi@126 signed int v62; // esi@133 //AudioPlayer *pAudioPlayer4; // ebx@133 - MixerChannel *pMixerChannel2; // edi@134 - int v65; // ebx@141 + //MixerChannel *pMixerChannel2; // edi@134 + //int v65; // ebx@141 //AudioPlayer *pAudioPlayer5; // ecx@142 - MixerChannel *pMixerChannel3; // edi@142 + //MixerChannel *pMixerChannel3; // edi@142 int v68; // eax@143 - MixerChannel *pMixerChannel4; // edi@149 - int v70; // ecx@152 - SoundDesc *pSoundDesc2; // eax@153 - int v72; // edi@156 - MixerChannel *pMixerChannel5; // esi@157 - unsigned int pVolume; // eax@157 - int pPartyX; // ebx@159 - int v76; // ebx@160 - LayingItem *pLayingItem4; // edi@164 - unsigned int pPosY; // edx@166 - unsigned int pPosX; // ecx@166 - int v80; // eax@167 - Actor *pActor3; // edi@168 - BLVDoor *pBLVDoor2; // edi@173 - int v83; // eax@183 - int v84; // eax@183 - _SAMPLE *v85; // ST18_4@186 + //MixerChannel *pMixerChannel4; // edi@149 + //int v70; // ecx@152 + //SoundDesc *pSoundDesc2; // eax@153 + //int v72; // edi@156 + //MixerChannel *pMixerChannel5; // esi@157 + //unsigned int pVolume; // eax@157 + //int pPartyX; // ebx@159 + //int v76; // ebx@160 + //LayingItem *pLayingItem4; // edi@164 + //unsigned int pPosY; // edx@166 + //unsigned int pPosX; // ecx@166 + //int v80; // eax@167 + //Actor *pActor3; // edi@168 + //BLVDoor *pBLVDoor2; // edi@173 + //int v83; // eax@183 + //int v84; // eax@183 + //_SAMPLE *v85; // ST18_4@186 unsigned int v86; // [sp+14h] [bp-60h]@84 - int v87; // [sp+14h] [bp-60h]@115 + //int v87; // [sp+14h] [bp-60h]@115 RenderVertexSoft pRenderVertexSoft; // [sp+24h] [bp-50h]@1 - unsigned int v89; // [sp+54h] [bp-20h]@12 + //unsigned int v89; // [sp+54h] [bp-20h]@12 int v90; // [sp+58h] [bp-1Ch]@68 float v91; // [sp+5Ch] [bp-18h]@68 //unsigned int v92; // [sp+60h] [bp-14h]@10 float v93; // [sp+64h] [bp-10h]@1 signed int varC; // [sp+68h] [bp-Ch]@68 - AudioPlayer *pAudioPlayer; // [sp+6Ch] [bp-8h]@1 + //AudioPlayer *pAudioPlayer; // [sp+6Ch] [bp-8h]@1 int v96; // [sp+70h] [bp-4h]@19 signed int uNumRepeatsb; // [sp+84h] [bp+10h]@93 float uNumRepeatsa; // [sp+84h] [bp+10h]@104 @@ -724,213 +723,208 @@ int v102; // [sp+90h] [bp+1Ch]@60 int v103; // [sp+90h] [bp+1Ch]@68 - pAudioPlayer = this; - v35 = this->bPlayerReady == 0; - //pAudioPlayer = this; - pRenderVertexSoft.flt_2C = 0.0; - LODWORD(v93) = 10000; - if ( v35 || !uSoundVolumeMultiplier || !this->hDigDriver || !eSoundID ) + if (!bPlayerReady) + return; + if (!uSoundVolumeMultiplier) + return; + if (!hDigDriver) + return; + if (eSoundID == SOUND_Invalid) return; - pNum = 0; - if ( (signed int)pSoundList->uNumSounds <= 0 ) - { -LABEL_9: - pNum = 0; - } - else + + //pAudioPlayer = this; + //v35 = this->bPlayerReady == 0; + //pAudioPlayer = this; + //LODWORD(v93) = 10000; + int sample_volume = 10000; + + + int sound_id = 0; + for (uint i = 0; i < pSoundList->uNumSounds; ++i) + if (pSoundList->pSounds[i].uSoundID == eSoundID) + { + sound_id = i; + break; + } + + if (!sound_id) { - pSoundID = (int *)&pSoundList->pSounds->uSoundID; - while ( *pSoundID != eSoundID ) - { - ++pNum; - pSoundID += 30; - if ( pNum >= (signed int)pSoundList->uNumSounds ) - goto LABEL_9; - } + Log::Warning(L"SoundID = %u not found", eSoundID); + return; } - /* v92 = pNum;//38 - pNum = 0; - for ( pSoundID = (int *)&pSoundList->pSounds->uSoundID; *pSoundID != eSoundID; pSoundID += 30) - { - ++pNum; - }*/ - if ( !pNum ) - return; - if ( !pAudioPlayer->b3DSoundInitialized || (v89 = 120 * pNum, !(pSoundList->pSounds[pNum].uFlags & 2)) ) + + int start_channel = 0, + end_channel = 0; + + assert(sound_id < pSoundList->uNumSounds); + auto sound_desc = pSoundList->pSounds + sound_id; + if (!b3DSoundInitialized || sound_desc->Is3D()) { - //pSoundDesc = (SoundDesc *)7; - if ( a3 < 0 ) + if (!a3) // generic sound like from UI + { + start_channel = 10; + end_channel = 12; + goto LABEL_133; + } + else if (a3 == -1) // exclusive sounds - can override { - if ( a3 == -1 ) + start_channel = 13; + end_channel = 13; + goto LABEL_133; + } + else + { + if (a3 < 0) // exclusive sounds - no override { - varC = 13; - v96 = 13; - goto LABEL_133; + start_channel = 14; + end_channel = 14; + goto LABEL_123; } - varC = 14; - v96 = 14; -LABEL_123: - if ( a3 ) + else { - if ( a3 != -1 ) + int object_type = a3 & 7, + object_id = a3 >> 7; + switch (object_type) { - LODWORD(v91) = 0; - if ( pAudioPlayer->uMixerChannels > 0 ) + case OBJECT_BLVDoor: + case OBJECT_Player: + { + start_channel = 10; + end_channel = 12; + goto LABEL_133; + } + break; + + case OBJECT_Actor: + { + start_channel = 0; + end_channel = 3; + + assert(object_id < uNumActors); + auto actor = &pActors[object_id]; + + sample_volume = GetSoundStrengthByDistanceFromParty(actor->vPosition.x, actor->vPosition.y, actor->vPosition.z); + if (!sample_volume) + return; + goto LABEL_123; + } + + case OBJECT_Decoration: { - pMixerChannel = pAudioPlayer->pMixerChannels; - do - { - if ( AIL_sample_status(pMixerChannel->hSample) == 4 && pMixerChannel->dword_000004 == a3 - && AIL_sample_status(pMixerChannel->hSample) == 4 ) - { - if ( pMixerChannel->uSourceTrackIdx == pNum ) - return; - AIL_end_sample(pMixerChannel->hSample); - _4ABE55(pMixerChannel); - } - ++LODWORD(v91); - ++pMixerChannel; - } - while ( SLODWORD(v91) < pAudioPlayer->uMixerChannels ); + start_channel = 4; + end_channel = 4; + + assert(object_id < uNumLevelDecorations); + auto decor = &pLevelDecorations[object_id]; + + sample_volume = GetSoundStrengthByDistanceFromParty(decor->vPosition.x, decor->vPosition.y, decor->vPosition.z); + if (!sample_volume) + return; + goto LABEL_123; } + break; + + case OBJECT_Item: + { + start_channel = 5; + end_channel = 7; + + assert(object_id < uNumLayingItems); + auto object = &pLayingItems[object_id]; + + sample_volume = GetSoundStrengthByDistanceFromParty(object->vPosition.x, object->vPosition.y, object->vPosition.z); + if (!sample_volume) + return; + goto LABEL_123; + } + break; + + case OBJECT_BModel: + { + start_channel = 8; + end_channel = 9; + goto LABEL_123; + } + break; + + default: + assert(false); } } + } + + + + + + +LABEL_123: + for (uint i = 0; i < uMixerChannels; ++i) + { + auto channel = pMixerChannels + i; + if (channel->source_pid == a3 && + AIL_sample_status(channel->hSample) == AIL::Sample::Playing) + { + if (channel->uSourceTrackIdx == sound_id) + return; // already playing the same sound from the same source - return + + AIL_end_sample(channel->hSample); // requested new sound from the same source - end & switch + _4ABE55(channel); + } + } + LABEL_133: - v62 = varC; + v62 = start_channel; //pAudioPlayer4 = pAudioPlayer; - if ( varC <= v96 ) + for (v62 = start_channel; v62 <= end_channel; ++v62) { - pMixerChannel2 = &pAudioPlayer->pMixerChannels[varC]; - while ( AIL_sample_status(pMixerChannel2->hSample) != 2 ) + auto channel = pMixerChannels + v62; + if (AIL_sample_status(channel->hSample) == AIL::Sample::Done) + { + AIL_end_sample(channel->hSample); + if (channel->uSourceTrackIdx) + _4ABE55(channel); + break; + } + } + /*if ( start_channel <= end_channel) + { + pMixerChannel2 = &pAudioPlayer->pMixerChannels[start_channel]; + while ( AIL_sample_status(pMixerChannel2->hSample) != AIL::Sample::Done) { ++v62; ++pMixerChannel2; - if ( v62 > v96 ) + if ( v62 > end_channel ) goto LABEL_140; } AIL_end_sample(pMixerChannel2->hSample); if ( pMixerChannel2->uSourceTrackIdx ) _4ABE55(pMixerChannel2); } -LABEL_140: - if ( v62 != v96 + 1 )//10!=13 +LABEL_140:*/ + + if (v62 > end_channel) // no free channel - occupy the quitest one { -LABEL_150: - if ( LODWORD(v93) == 10000 ) - LODWORD(v93) = pAudioPlayer->uMasterVolume; - v70 = 0; - if ( !a7 ) + v62 = -1; + + int min_volume = sample_volume; + for (uint i = start_channel; i <= end_channel; ++i) { - //pSoundDesc = pSoundList->pSounds; - pSoundDesc2 = &pSoundList->pSounds[pNum]; - if ( !pSoundDesc2->pSoundData[0] ) + auto channel = pMixerChannels + i; + + int volume = AIL_sample_volume(channel->hSample); + if (volume < min_volume) { - if (pSoundDesc2->eType == SOUND_DESC_SWAP) - pSoundList->LoadSound(eSoundID, 0); + min_volume = volume; + v62 = i; } } - v72 = 4 * (a7 + 30 * pNum) + 44; - if ( !*(int *)&pSoundList->pSounds->pSoundName[v72] ) - return; - pMixerChannel5 = &pAudioPlayer->pMixerChannels[v62]; - AIL_init_sample(pMixerChannel5->hSample); - AIL_set_sample_file(pMixerChannel5->hSample, (void *)(*(int *)&pSoundList->pSounds->pSoundName[v72] + 4 * (a7 == 0)), -1); - pVolume = uVolume; - if ( !uVolume ) - pVolume = LODWORD(v93); - AIL_set_sample_volume(pMixerChannel5->hSample, pVolume); - pPartyX = PartyX; - if ( PartyX != -1 ) - { - if ( !PartyX ) - pPartyX = pParty->vPosition.x; - if ( !PartyY ) - PartyY = pParty->vPosition.y; - if ( uNumRepeats ) - AIL_set_sample_loop_count(pMixerChannel5->hSample, uNumRepeats - 1); - v83 = sub_4AB66C(pPartyX, PartyY); - AIL_set_sample_pan(pMixerChannel5->hSample, v83); - v84 = GetSoundStrengthByDistanceFromParty(pPartyX, PartyY, pParty->vPosition.z); - AIL_set_sample_volume(pMixerChannel5->hSample, v84); - v76 = a3; - goto LABEL_184; - } - v76 = a3; - if ( (a3 & 7) == 1 ) - { - if ( uCurrentlyLoadedLevelType != LEVEL_Indoor ) - goto LABEL_184; - pBLVDoor2 = &pIndoor->pDoors[a3 >> 3]; - if ( !pBLVDoor2->uDoorID ) - return; - if ( !GetSoundStrengthByDistanceFromParty(*pBLVDoor2->pXOffsets, *pBLVDoor2->pYOffsets, *pBLVDoor2->pZOffsets) ) - { - AIL_end_sample(pMixerChannel5->hSample); - pAudioPlayer->AudioPlayer::_4ABE55(pMixerChannel5); - return; - } - pPosY = *pBLVDoor2->pYOffsets; - pPosX = *pBLVDoor2->pXOffsets; - //goto LABEL_167; - v80 = sub_4AB66C(pPosX, pPosY); - AIL_set_sample_pan(pMixerChannel5->hSample, v80); - goto LABEL_184; - } - if ( (a3 & 7) == 2 ) - { - pLayingItem4 = &pLayingItems[a3 >> 3]; - if ( !GetSoundStrengthByDistanceFromParty(pLayingItem4->vPosition.x, pLayingItem4->vPosition.y, pLayingItem4->vPosition.z) ) - return; - } - else - { - if ( (a3 & 7) == 3 ) - { - pActor3 = &pActors[a3 >> 3]; - if ( !GetSoundStrengthByDistanceFromParty(pActor3->vPosition.x, pActor3->vPosition.y, pActor3->vPosition.z) ) - return; - pPosY = pActor3->vPosition.y; - pPosX = pActor3->vPosition.x; - //goto LABEL_167; - v80 = sub_4AB66C(pPosX, pPosY); - AIL_set_sample_pan(pMixerChannel5->hSample, v80); - goto LABEL_184; - } - if ( (a3 & 7) != 5 ) - { -LABEL_184: - if ( uNumRepeats ) - AIL_set_sample_loop_count(pMixerChannel5->hSample, uNumRepeats - 1); - v85 = pMixerChannel5->hSample; - pMixerChannel5->uSourceTrackIdx = pNum; - pMixerChannel5->dword_000004 = v76; - pMixerChannel5->uSourceTrackID = eSoundID; - AIL_start_sample(v85); - if ( sPlaybackRate ) - AIL_set_sample_playback_rate(pMixerChannel5->hSample, sPlaybackRate); - if ( (v76 & 7) == 4 ) - AIL_sample_ms_position(pMixerChannel5->hSample, &sLastTrackLengthMS, 0); - return; - } - pLayingItem4 = (LayingItem *)&pLevelDecorations[a3 >> 3]; - if ( !GetSoundStrengthByDistanceFromParty(pLayingItem4->vPosition.x, pLayingItem4->vPosition.y, pLayingItem4->vPosition.z) ) - return; - AIL_set_sample_loop_count(pMixerChannel5->hSample, uNumRepeats - 1); - } - pPosY = pLayingItem4->vPosition.y; - pPosX = pLayingItem4->vPosition.x; -//LABEL_167: - v80 = sub_4AB66C(pPosX, pPosY); - AIL_set_sample_pan(pMixerChannel5->hSample, v80); - goto LABEL_184; - } - v65 = varC; - v62 = -1; - v91 = v93; - if ( varC <= v96 ) + /*v65 = start_channel; + v91 = v93; + if (start_channel <= end_channel) { //pAudioPlayer5 = pAudioPlayer; - pMixerChannel3 = &pAudioPlayer->pMixerChannels[varC]; + pMixerChannel3 = &pAudioPlayer->pMixerChannels[start_channel]; do { v68 = AIL_sample_volume(pMixerChannel3->hSample); @@ -942,73 +936,119 @@ ++v65; ++pMixerChannel3; } - while ( v65 <= v96 ); - if ( v62 != -1 ) + while ( v65 <= end_channel );*/ + + if (v62 == -1) // no free channels at all - only channel 13 allows override (a3 == -1) { -//LABEL_149: - //pAudioPlayer4 = pAudioPlayer; - pMixerChannel4 = &pAudioPlayer->pMixerChannels[v62]; - AIL_end_sample(pMixerChannel4->hSample); - _4ABE55(pMixerChannel4); - goto LABEL_150; + if (start_channel != 13) + return; + v62 = 13; } - v65 = varC; + + auto channel = &pMixerChannels[v62]; + AIL_end_sample(channel->hSample); + _4ABE55(channel); } - v62 = 13; - if ( v65 != 13 ) + + if (v62 > end_channel)//10!=13 return; - //goto LABEL_149; - //pAudioPlayer4 = pAudioPlayer; - pMixerChannel4 = &pAudioPlayer->pMixerChannels[v62]; - AIL_end_sample(pMixerChannel4->hSample); - _4ABE55(pMixerChannel4); - goto LABEL_150; - } - if ( (a3 & 7) == 2 ) - { - varC = 5; - v96 = 7; - pLayingItem3 = &pLayingItems[a3 >> 3]; - } - else - { - if ( (a3 & 7) == 3 ) + +//LABEL_150: + if (sample_volume == 10000) + sample_volume = uMasterVolume; + + //v70 = 0; + if ( !a7 ) + { + //pSoundDesc = pSoundList->pSounds; + //pSoundDesc2 = &pSoundList->pSounds[sound_id]; + if (!sound_desc->pSoundData[0]) + { + if (sound_desc->eType == SOUND_DESC_SWAP) + pSoundList->LoadSound(eSoundID, 0); + } + } + //v72 = 4 * (a7 + 30 * sound_id) + 44; + if (!pSoundList->pSounds[sound_id].pSoundData[a7]) + return; + + //pMixerChannel5 = &pAudioPlayer->pMixerChannels[v62]; + auto channel = &pMixerChannels[v62]; + AIL_init_sample(channel->hSample); + AIL_set_sample_file(channel->hSample, (char *)pSoundList->pSounds[sound_id].pSoundData[a7] + 4 * (a7 == 0), -1); + if (uVolume) + sample_volume = uVolume; + AIL_set_sample_volume(channel->hSample, sample_volume); + + int object_type = a3 & 7, + object_id = a3 >> 7; + if (PartyX != -1) + { + if (!PartyX) PartyX = pParty->vPosition.x; + if (!PartyY) PartyY = pParty->vPosition.y; + AIL_set_sample_pan(channel->hSample, sub_4AB66C(PartyX, PartyY)); + AIL_set_sample_volume(channel->hSample, GetSoundStrengthByDistanceFromParty(PartyX, PartyY, pParty->vPosition.z)); + } + else if (object_type == OBJECT_BLVDoor) { - *(float *)&varC = 0.0; - pActor2 = &pActors[a3 >> 3]; - v96 = 3; - v58 = pActor2->vPosition.y; - v87 = pActor2->vPosition.z; - v59 = pActor2->vPosition.x; -LABEL_116: - LODWORD(v93) = GetSoundStrengthByDistanceFromParty(v59, /*(int)pSoundDesc*/ v58, v87); - if ( v93 == 0.0 ) + assert(uCurrentlyLoadedLevelType == LEVEL_Indoor); + + assert(object_id < pIndoor->uNumDoors); + auto door = &pIndoor->pDoors[object_id]; + if (!door->uDoorID) return; - goto LABEL_123; - } - if ( (a3 & 7) != 5 ) - { - if ( (a3 & 7) == 6 ) + + if (!GetSoundStrengthByDistanceFromParty(door->pXOffsets[0], door->pYOffsets[0], door->pZOffsets[0])) { - varC = 8; - v96 = 9; + AIL_end_sample(channel->hSample); + _4ABE55(channel); + return; } - else - { - varC = 10; - v96 = 12; - } - goto LABEL_123; + AIL_set_sample_pan(channel->hSample, sub_4AB66C(door->pXOffsets[0], door->pYOffsets[0])); + } + else if (object_type == OBJECT_Item) + { + assert(object_id < uNumLayingItems); + auto object = &pLayingItems[object_id]; + if (!GetSoundStrengthByDistanceFromParty(object->vPosition.x, object->vPosition.y, object->vPosition.z) ) + return; + AIL_set_sample_pan(channel->hSample, sub_4AB66C(object->vPosition.x, object->vPosition.y)); + } + else if (object_type == OBJECT_Actor) + { + assert(object_id < uNumActors); + auto actor = &pActors[object_id]; + if (!GetSoundStrengthByDistanceFromParty(actor->vPosition.x, actor->vPosition.y, actor->vPosition.z)) + return; + AIL_set_sample_pan(channel->hSample, sub_4AB66C(actor->vPosition.x, actor->vPosition.y)); } - varC = 4; - v96 = 4; - pLayingItem3 = (LayingItem *)&pLevelDecorations[a3 >> 3]; - } - v87 = pLayingItem3->vPosition.z; - v58 = pLayingItem3->vPosition.y; - v59 = pLayingItem3->vPosition.x; - goto LABEL_116; + else if (object_type == OBJECT_Decoration) + { + assert(object_id < uNumLevelDecorations); + auto decor = &pLevelDecorations[object_id]; + if (!GetSoundStrengthByDistanceFromParty(decor->vPosition.x, decor->vPosition.y, decor->vPosition.z)) + return; + AIL_set_sample_pan(channel->hSample, sub_4AB66C(decor->vPosition.x, decor->vPosition.y)); + } + +//LABEL_184: + if (uNumRepeats) + AIL_set_sample_loop_count(channel->hSample, uNumRepeats - 1); + channel->uSourceTrackIdx = sound_id; + channel->source_pid = a3; + channel->uSourceTrackID = eSoundID; + int rval = AIL_start_sample(channel->hSample); + if ( sPlaybackRate ) + AIL_set_sample_playback_rate(channel->hSample, sPlaybackRate); + if (object_type == OBJECT_Player) + AIL_sample_ms_position(channel->hSample, &sLastTrackLengthMS, 0); + return; } + + + + + __debugbreak(); // 3d sound stuff, refactor v12 = 13; if ( a3 < 0 ) { @@ -1144,7 +1184,7 @@ if ( AIL_3D_sample_status(pAudioPlayer_3DSample->hSample) == 4 && pAudioPlayer_3DSample->field_4 == a3 && AIL_3D_sample_status(pAudioPlayer_3DSample->hSample) == 4 ) { - if ( pAudioPlayer_3DSample->field_8 == pNum ) + if ( pAudioPlayer_3DSample->field_8 == sound_id ) return; AIL_end_3D_sample(pAudioPlayer_3DSample->hSample); pAudioPlayer->_4ABF23(pAudioPlayer_3DSample); @@ -1228,12 +1268,12 @@ pAudioPlayer->_4ABF23(pAudioPlayer_3DSample3); v102 = v36; } - v39 = v89; - if ( pSoundList->pSounds[v89 / 0x78].p3DSound || (LOWORD(v40) = pSoundList->LoadSound(eSoundID, 0), v40) ) + //v39 = v89; + if ( pSoundList->pSounds[sound_id].p3DSound || (LOWORD(v40) = pSoundList->LoadSound(eSoundID, 0), v40) ) { v41 = (char *)pAudioPlayer + 16 * v102; v42 = (int)(v41 + 20); - if ( AIL_set_3D_sample_file(*((int *)v41 + 5), *(void **)((char *)&pSoundList->pSounds->p3DSound + v39)) ) + if ( AIL_set_3D_sample_file(*((int *)v41 + 5), *(void **)((char *)&pSoundList->pSounds->p3DSound + sound_id * sizeof(SoundDesc))) ) { if ( uNumRepeats ) v86 = uNumRepeats - 1; @@ -1282,7 +1322,7 @@ AIL_set_3D_orientation((void *)*(int *)v42, LODWORD(v54), 0.0, LODWORD(v53), 0.0, 1.0, 0.0); //pAudioPlayer3 = pAudioPlayer; *((int *)v41 + 6) = a3; - *((int *)v41 + 7) = pNum; + *((int *)v41 + 7) = sound_id; *(&pAudioPlayer->bEAXSupported + 4 * (v102 + 2)) = eSoundID; } else @@ -1340,13 +1380,13 @@ //----- (004AAFCF) -------------------------------------------------------- -void AudioPlayer::_4AAFCF() +void AudioPlayer::UpdateSounds() { - AudioPlayer *pAudioPlayer; // edi@1 + //AudioPlayer *pAudioPlayer; // edi@1 int v2; // ebx@1 - unsigned __int8 v3; // zf@1 - int *v4; // eax@2 - unsigned __int8 v5; // sf@4 + //unsigned __int8 v3; // zf@1 + //int *v4; // eax@2 + //unsigned __int8 v5; // sf@4 AudioPlayer_3DSample *v6; // esi@5 int v7; // ebx@6 int v8; // ebx@9 @@ -1369,31 +1409,31 @@ int v25; // eax@32 float v26; // ST10_4@34 float v27; // ST08_4@34 - MixerChannel *v28; // esi@38 - unsigned __int8 v29; // of@43 - MixerChannel *v30; // esi@44 - int v31; // eax@45 - LayingItem *v32; // eax@49 - Actor *v33; // edi@50 - int v34; // eax@50 - unsigned int v35; // edx@51 - unsigned int v36; // ecx@51 - LayingItem *v37; // edi@53 + //MixerChannel *v28; // esi@38 + //unsigned __int8 v29; // of@43 + //MixerChannel *v30; // esi@44 + //int v31; // eax@45 + //LayingItem *v32; // eax@49 + //Actor *v33; // edi@50 + //int v34; // eax@50 + //unsigned int v35; // edx@51 + //unsigned int v36; // ecx@51 + //LayingItem *v37; // edi@53 int v38; // eax@53 - BLVDoor *v39; // edi@56 - int v40; // eax@57 - int v41; // eax@60 - MixerChannel *v42; // edi@65 - int v43; // ebx@68 - LevelDecoration *v44; // esi@68 - int v45; // ST1C_4@68 - int v46; // edi@68 - int v47; // eax@68 - DecorationDesc *v48; // edi@69 - __int16 v49; // ax@69 - __int16 v50; // ax@70 + //BLVDoor *v39; // edi@56 + //int v40; // eax@57 + //int v41; // eax@60 + //MixerChannel *v42; // edi@65 + //int v43; // ebx@68 + //LevelDecoration *v44; // esi@68 + //int v45; // ST1C_4@68 + //int v46; // edi@68 + //int v47; // eax@68 + //DecorationDesc *v48; // edi@69 + //__int16 v49; // ax@69 + //__int16 v50; // ax@70 __int16 v51; // ax@71 - __int16 v52; // ax@73 + //__int16 v52; // ax@73 signed int v53; // eax@88 RenderVertexSoft a1; // [sp+24h] [bp-48h]@1 float v55; // [sp+54h] [bp-18h]@22 @@ -1401,27 +1441,32 @@ int uNumRepeats; // [sp+5Ch] [bp-10h]@15 float v58; // [sp+60h] [bp-Ch]@23 int v59; // [sp+64h] [bp-8h]@4 - AudioPlayer *thisa; // [sp+68h] [bp-4h]@1 + //AudioPlayer *thisa; // [sp+68h] [bp-4h]@1 - pAudioPlayer = this; + //pAudioPlayer = this; v2 = 0; - thisa = this; - v3 = this->bPlayerReady == 0; - a1.flt_2C = 0.0; - if ( !v3 ) + //thisa = this; + //v3 = this->bPlayerReady == 0; + //a1.flt_2C = 0.0; + if (!bPlayerReady) + return; + + if (field_2D0_time_left <= pEventTimer->uTimeElapsed) + field_2D0_time_left = 32; + else { - v4 = &this->field_2D0_time_left; - *v4 -= pEventTimer->uTimeElapsed; - if ( this->field_2D0_time_left <= 0 ) - { - v3 = this->b3DSoundInitialized == 0; - *v4 = 32; - if ( !v3 ) + field_2D0_time_left -= pEventTimer->uTimeElapsed; + return; + } + + //v3 = this->b3DSoundInitialized == 0; + if (b3DSoundInitialized) { - v3 = this->uNum3DSamples == 0; - v5 = this->uNum3DSamples < 0; + __debugbreak(); // refactor refactor + //v3 = this->uNum3DSamples == 0; + //v5 = this->uNum3DSamples < 0; v59 = 0; - if ( !(v5 | v3) ) + if (uNum3DSamples > 0) { v6 = this->p3DSamples; while ( 1 ) @@ -1459,6 +1504,7 @@ goto LABEL_37; } } + v9 = v8 - 1; if ( v9 ) { @@ -1561,183 +1607,195 @@ goto LABEL_35; } } + + + + + + + LABEL_37: - if ( pAudioPlayer->uMixerChannels > v2 ) + for (uint i = 0; i < uMixerChannels; ++i) + { + auto channel = pMixerChannels + i; + + if (AIL_sample_status(channel->hSample) == AIL::Sample::Done) + { + AIL_end_sample(channel->hSample); + _4ABE55(channel); + } + } + + for (uint i = 0; i < uMixerChannels; ++i) + { + auto channel = pMixerChannels + i; + if (channel->source_pid <= 0) + continue; + + int source_type = channel->source_pid & 7, + source_id = channel->source_pid >> 3; + int source_x, + source_y, + source_z; + + switch (source_type) + { + case 0: + case OBJECT_Player: + case OBJECT_BModel: + continue; + + case OBJECT_BLVDoor: { - v28 = pAudioPlayer->pMixerChannels; - do - { - if ( AIL_sample_status(v28->hSample) == 2 ) - { - AIL_end_sample(v28->hSample); - pAudioPlayer->_4ABE55(v28); - } - ++v2; - ++v28; - } - while ( v2 < pAudioPlayer->uMixerChannels ); - v2 = 0; + assert(uCurrentlyLoadedLevelType == LEVEL_Indoor); + + assert(source_id < pIndoor->uNumDoors); + auto door = pIndoor->pDoors + source_id; + if (!door->uDoorID) + continue; + + source_x = door->pXOffsets[0]; + source_y = door->pYOffsets[0]; + source_z = door->pZOffsets[0]; } - //v29 = __OFSUB__(v1->uMixerChannels, v2); - v29 = pAudioPlayer->uMixerChannels > v2; - v3 = pAudioPlayer->uMixerChannels == v2; - v5 = pAudioPlayer->uMixerChannels - v2 < 0; - v59 = v2; - if ( !((unsigned __int8)(v5 ^ v29) | v3) ) + break; + + case OBJECT_Item: + { + assert(source_id < uNumLayingItems); + auto object = &pLayingItems[source_id]; + + source_x = object->vPosition.x; + source_y = object->vPosition.y; + source_z = object->vPosition.z; + } + break; + + case OBJECT_Decoration: { - v30 = pAudioPlayer->pMixerChannels; - while ( 1 ) - { - v31 = v30->dword_000004; - if ( (v30->dword_000004 & 7) == 1 ) - { - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - { - v39 = &pIndoor->pDoors[v31 >> 3]; - if ( !v39->uDoorID ) - { -LABEL_61: - pAudioPlayer = thisa; - goto LABEL_62; - } - v40 = GetSoundStrengthByDistanceFromParty(*v39->pXOffsets, *v39->pYOffsets, *v39->pZOffsets); - if ( !v40 ) - { -LABEL_58: - AIL_end_sample(v30->hSample); - thisa->_4ABE55(v30); - goto LABEL_61; - } - AIL_set_sample_volume(v30->hSample, v40); - v35 = *v39->pYOffsets; - v36 = *v39->pXOffsets; -LABEL_60: - v41 = sub_4AB66C(v36, v35); - AIL_set_sample_pan(v30->hSample, v41); - goto LABEL_61; - } - } - else - { - if ( (v30->dword_000004 & 7) == 2 ) - { - v32 = &pLayingItems[v31 >> 3]; - goto LABEL_53; - } - if ( (v30->dword_000004 & 7) == 3 ) - { - v33 = &pActors[v31 >> 3]; - v34 = GetSoundStrengthByDistanceFromParty(v33->vPosition.x, v33->vPosition.y, v33->vPosition.z); - if ( !v34 ) - goto LABEL_58; - AIL_set_sample_volume(v30->hSample, v34); - v35 = v33->vPosition.y; - v36 = v33->vPosition.x; - goto LABEL_60; - } - if ( (v30->dword_000004 & 7) == 5 ) - { - v32 = (LayingItem *)&pLevelDecorations[v31 >> 3]; -LABEL_53: - v37 = v32; - v38 = GetSoundStrengthByDistanceFromParty(v32->vPosition.x, v32->vPosition.y, v32->vPosition.z); - if ( !v38 ) - goto LABEL_58; - AIL_set_sample_volume(v30->hSample, v38); - v35 = v37->vPosition.y; - v36 = v37->vPosition.x; - goto LABEL_60; - } - } -LABEL_62: - ++v59; - ++v30; - if ( v59 >= pAudioPlayer->uMixerChannels ) - { - v2 = 0; - break; - } - } + assert(source_id < uNumLevelDecorations); + auto object = (LayingItem *)&pLevelDecorations[source_id]; + + source_x = object->vPosition.x; + source_y = object->vPosition.y; + source_z = object->vPosition.z; + } + break; + + case OBJECT_Actor: + { + assert(source_id < uNumActors); + auto actor = pActors + source_id; + + source_x = actor->vPosition.x; + source_y = actor->vPosition.y; + source_z = actor->vPosition.z; } - if ( pCurrentScreen != v2 ) - { - v42 = &pAudioPlayer->pMixerChannels[4]; - if ( AIL_sample_status(v42->hSample) == 4 ) - AIL_end_sample(v42->hSample); - return; - } - v59 = v2; - if ( _6807E0_num_decorations_with_sounds_6807B8 <= v2 ) - return; - while ( 1 ) - { + break; + + default: + assert(false); + continue; + } + + if (auto sound_strength = GetSoundStrengthByDistanceFromParty(source_x, source_y, source_z)) + { + AIL_set_sample_volume(channel->hSample, sound_strength); + AIL_set_sample_pan(channel->hSample, sub_4AB66C(source_x, source_y)); + } + else + { + AIL_end_sample(channel->hSample); + _4ABE55(channel); + } + } + + + + if (pCurrentScreen != SCREEN_GAME) + { + auto channel = &pMixerChannels[4]; + if (AIL_sample_status(channel->hSample) == AIL::Sample::Playing) + AIL_end_sample(channel->hSample); + return; + } + if (!_6807E0_num_decorations_with_sounds_6807B8) + return; + + v55 = 0; + //v59 = 0; + for (uint i = 0; i < _6807E0_num_decorations_with_sounds_6807B8; ++i) + { + //while ( 1 ) + //{ LODWORD(v56) = 1; - v43 = 4 * v59 + 6817720; - v44 = &pLevelDecorations[_6807B8_level_decorations_ids[v59]]; - v45 = abs(v44->vPosition.z - pParty->vPosition.z); - v46 = abs(v44->vPosition.y - pParty->vPosition.y); - v47 = abs(v44->vPosition.x - pParty->vPosition.x); - if ( int_get_vector_length(v47, v46, v45) <= 8192 ) - break; -LABEL_89: - ++v59; - if ( v59 >= _6807E0_num_decorations_with_sounds_6807B8 ) - return; - } - v48 = &pDecorationList->pDecorations[v44->uDecorationDescID]; - v49 = v48->uFlags; - uNumRepeats = (~(unsigned __int8)v48->uFlags & 0x40) >> 6; - if ( HIBYTE(v49) & 3 ) - { - v50 = v44->field_1A; + //v43 = _6807B8_level_decorations_ids[v59]; + //v44 = &pLevelDecorations[_6807B8_level_decorations_ids[v59]]; + //v45 = abs(v44->vPosition.z - pParty->vPosition.z); + //v46 = abs(v44->vPosition.y - pParty->vPosition.y); + //v47 = abs(v44->vPosition.x - pParty->vPosition.x); + auto decor = &pLevelDecorations[_6807B8_level_decorations_ids[i]]; + if (int_get_vector_length(decor->vPosition.x - pParty->vPosition.x, + decor->vPosition.y - pParty->vPosition.y, + decor->vPosition.z - pParty->vPosition.z) > 8192) + continue; + + auto decor_desc = &pDecorationList->pDecorations[decor->uDecorationDescID]; + //v48 = &pDecorationList->pDecorations[decor->uDecorationDescID]; + //v49 = v48->uFlags; + uNumRepeats = (~(unsigned __int8)decor_desc->uFlags & 0x40) >> 6; + + if (decor_desc->SoundOnDawn() || decor_desc->SoundOnDusk()) + { + //v50 = decor->field_1A; v55 = 0.0; uNumRepeats = 2; - if ( v50 ) + if (decor->field_1A) { - v51 = v50 - 32; - v44->field_1A = v51; + v51 = decor->field_1A - 32; + decor->field_1A = v51; if ( v51 < 0 ) - v44->field_1A = 0; + decor->field_1A = 0; } - } - v52 = v48->uFlags; - if ( !(HIBYTE(v52) & 1) ) - { - if ( !(HIBYTE(v52) & 2) ) - goto LABEL_84; - if ( v55 != 0.0 ) - goto LABEL_85; - } - v56 = 0.0; - if ( pParty->uCurrentHour >= 5 && pParty->uCurrentHour < 6 - || pParty->uCurrentHour >= 0x14 && pParty->uCurrentHour < 0x15 ) - { - if ( !v44->field_1A && rand() % 100 < 100 ) + } + + //v52 = v48->uFlags; + if (!decor_desc->SoundOnDawn()) + { + if (!decor_desc->SoundOnDusk()) + goto LABEL_84; + if ( v55 != 0.0 ) + goto LABEL_85; + } + v56 = 0.0; + + if (pParty->uCurrentHour >= 5 && pParty->uCurrentHour < 6 || + pParty->uCurrentHour >= 20 && pParty->uCurrentHour < 21) + { + if ( !decor->field_1A && rand() % 100 < 100 ) LODWORD(v56) = 1; LODWORD(v55) = 1; - } + } LABEL_84: if ( v55 == 0.0 ) { LABEL_87: if ( v56 != 0.0 ) { - v53 = 8 * *(int *)v43; - LOBYTE(v53) = v53 | 5; - thisa->PlaySound((SoundID)v48->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); + v53 = 8 * _6807B8_level_decorations_ids[i]; + LOBYTE(v53) = v53 | OBJECT_Decoration; + PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); } - goto LABEL_89; + continue; } LABEL_85: - if ( !v44->field_1A ) - v44->field_1A = (rand() % 15 + 1) << 7; + if ( !decor->field_1A ) + decor->field_1A = (rand() % 15 + 1) << 7; goto LABEL_87; - } } } - //----- (004AB66C) -------------------------------------------------------- int __fastcall sub_4AB66C(int a1, int a2) { @@ -1825,7 +1883,7 @@ { AIL_end_sample(pChannel->hSample); _4ABE55(pChannel); - pChannel->dword_000004 = 0; + pChannel->source_pid = 0; } ++v6; ++pChannel; @@ -2167,8 +2225,9 @@ v2 = 0; //v3 = this; - if ( pSoundList->pSounds ) - { + if (!pSoundList->pSounds) + return; + v4 = &pSoundList->pSounds[pChannel->uSourceTrackIdx]; if ( v4->eType == SOUND_DESC_SWAP) { @@ -2189,7 +2248,7 @@ v9 = *(int *)v7; ++v16; v14[v8] = v2; - if ( AIL_sample_status((HSAMPLE)v9) == 4 ) + if ( AIL_sample_status((HSAMPLE)v9) == AIL::Sample::Playing) ++v15; } ++v2; @@ -2217,10 +2276,7 @@ } } } - } } -// 4D82F8: using guessed type int __stdcall AIL_sample_status(int); -// 4ABE55: using guessed type int var_48[16];
--- a/AudioPlayer.h Mon Feb 25 09:08:13 2013 +0600 +++ b/AudioPlayer.h Mon Feb 25 09:09:08 2013 +0600 @@ -56,11 +56,11 @@ struct MixerChannel { inline MixerChannel(): - hSample(nullptr), dword_000004(0), uSourceTrackIdx(0), uSourceTrackID(0) + hSample(nullptr), source_pid(0), uSourceTrackIdx(0), uSourceTrackID(0) {} _SAMPLE *hSample; - int dword_000004; + int source_pid; unsigned int uSourceTrackIdx; unsigned int uSourceTrackID; }; @@ -73,13 +73,14 @@ /* 308 */ enum SoundID { - SOUND_0 = 0, + SOUND_Invalid = 0, SOUND_EnteringAHouse = 0x6, SOUND_8 = 0x8, SOUND_27 = 0x1B, SOUND_Button = 66, SOUND_67 = 67, SOUND_71 = 71, + SOUND_Button2 = 75, SOUND_78 = 78, SOUND_80 = 80, SOUND_81 = 81, @@ -97,6 +98,7 @@ SOUND_Arcomage_TowerUpgrade = 0x81, SOUND_Arcomage_WallUpgrade = 0x84, SOUND_GoldReceived = 0xC8, + SOUND_OpenChest = 208, SOUND_PlayerCantCastSpell = 0xD1, SOUND_Bell = 0xD9, SOUND_20001 = 0x4E21, @@ -144,7 +146,7 @@ void SetMasterVolume(float fVolume); void _4AA258(int a2); void PlaySound(SoundID eSoundID, signed int a3, unsigned int uNumRepeats, signed int a5, signed int a6, int a7, unsigned int uVolume, int sPlaybackRate); - void _4AAFCF(); + void UpdateSounds(); void StopChannels(int uStartChannel, int uEndChannel); void LoadAudioSnd(); void Initialize(HWND hWnd); @@ -236,6 +238,8 @@ struct SoundDesc { + inline bool Is3D() {return uFlags & SOUND_DESC_3D;} + char pSoundName[32]; unsigned int uSoundID; SOUND_DESC_TYPE eType;
--- a/Chest.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/Chest.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -1,8 +1,23 @@ #include <stdio.h> +#include <assert.h> #include "Chest.h" #include "FrameTableInc.h" #include "Allocator.h" +#include "LOD.h" +#include "MapInfo.h" +#include "Actor.h" +#include "Indoor.h" +#include "Outdoor.h" +#include "DecorationList.h" +#include "Party.h" +#include "AudioPlayer.h" +#include "Math.h" +#include "Texts.h" +#include "ObjectList.h" +#include "GUIWindow.h" +#include "Time.h" +#include "Overlays.h" #include "mm7_data.h" @@ -17,6 +32,674 @@ +//----- (0042041E) -------------------------------------------------------- +bool Chest::Open(unsigned int uChestID) +{ + //char *v1; // edi@5 + unsigned int v2; // eax@8 + GUIWindow *v3; // eax@15 + int v5; // edx@16 + int v6; // eax@16 + ODMFace *v7; // eax@19 + int v8; // edx@19 + int v9; // edi@19 + signed int v10; // ebx@19 + int v11; // ecx@19 + int v12; // eax@19 + BLVFace *v13; // eax@20 + int v14; // ebx@21 + int v15; // edi@21 + int v16; // ecx@22 + __int64 v17; // qax@22 + double v18; // st7@23 + double v19; // st6@23 + double v20; // st7@23 + int v21; // ecx@26 + char v22[12]; // ST4C_12@28 + unsigned int *v23; // edi@28 + unsigned __int16 v24; // di@28 + signed int v25; // ecx@28 + char *v26; // edx@29 + unsigned __int16 v27; // ax@32 + //LayingItem a1; // [sp+14h] [bp-B0h]@28 + int v29; // [sp+84h] [bp-40h]@16 + int v30; // [sp+88h] [bp-3Ch]@16 + int v31; // [sp+8Ch] [bp-38h]@16 + int v32; // [sp+90h] [bp-34h]@16 + float v33; // [sp+94h] [bp-30h]@23 + //char *v34; // [sp+98h] [bp-2Ch]@5 + int v35; // [sp+9Ch] [bp-28h]@16 + Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28 + int a4; // [sp+ACh] [bp-18h]@1 + int v38; // [sp+B0h] [bp-14h]@21 + int sRotX; // [sp+B4h] [bp-10h]@23 + float v40; // [sp+B8h] [bp-Ch]@23 + float v41; // [sp+BCh] [bp-8h]@23 + int sRotY; // [sp+C0h] [bp-4h]@8 + + //a4 = uChestID; + assert(uChestID < 20); + auto chest = pChests + uChestID; + + ++pIcons_LOD->uTexturePacksCount; + if (!pIcons_LOD->uNumPrevLoadedFiles) + pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; + + + //v1 = (char *)&pChests[uChestID].uFlags; + //v34 = v1; + if (!chest->Initialized()) + Chest::_420284(uChestID); + + if ( !uActiveCharacter ) + return 0; + *(float *)&sRotY = 0.0; + v2 = pMapStats->GetMapInfo(pCurrentMapName); + if ( !chest->Trapped() || !v2 ) + goto LABEL_12; + if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].LockX5 ) + { + v29 = 811; + v30 = 812; + v31 = 813; + v32 = 814; + v5 = rand() % 4; + v6 = dword_5B5920 >> 3; + v35 = v5; + if ( (dword_5B5920 & 7) == OBJECT_Decoration) + { + v16 = v6; + v14 = pLevelDecorations[v6].vPosition.x; + v38 = pLevelDecorations[v6].vPosition.y; + v17 = pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight; + v15 = pLevelDecorations[v16].vPosition.z + (((signed int)v17 - HIDWORD(v17)) >> 1); + } + else + { + if ( (dword_5B5920 & 7) != OBJECT_BModel) + goto LABEL_12; + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + { + v7 = &pOutdoor->pBModels[dword_5B5920 >> 9].pFaces[(dword_5B5920 >> 3) & 0x3F]; + v8 = v7->pBoundingBox.y1; + v9 = v7->pBoundingBox.z2; + v10 = v7->pBoundingBox.x1 + v7->pBoundingBox.x2; + v11 = v7->pBoundingBox.y2; + v12 = v7->pBoundingBox.z1; + } + else + { + v13 = &pIndoor->pFaces[v6]; + v8 = v13->pBounding.y1; + v9 = v13->pBounding.z2; + v10 = v13->pBounding.x1 + v13->pBounding.x2; + v11 = v13->pBounding.y2; + v12 = v13->pBounding.z1; + } + v14 = v10 >> 1; + v38 = (v8 + v11) >> 1; + v15 = (v12 + v9) >> 1; + } + v18 = (double)pParty->vPosition.x - (double)v14; + *(float *)&a4 = v18; + v19 = (double)pParty->vPosition.y - (double)v38; + v33 = v19; + v41 = (double)pParty->sEyelevel + (double)pParty->vPosition.z - (double)v15; + *(float *)&sRotY = v19 * v19; + *(float *)&sRotX = v18 * v18; + v20 = sqrt(v41 * v41 + *(float *)&sRotX + *(float *)&sRotY); + v40 = v20; + if ( v20 <= 1.0 ) + { + *(float *)&sRotX = 0.0; + *(float *)&sRotY = 0.0; + } + else + { + sRotY = (signed __int64)sqrt(*(float *)&sRotX + *(float *)&sRotY); + sRotX = stru_5C6E00->Atan2((signed __int64)*(float *)&a4, (signed __int64)v33); + sRotY = stru_5C6E00->Atan2(sRotY, (signed __int64)v41); + } + v21 = 256; + if ( v40 < 256.0 ) + v21 = (signed __int64)v40 / 4; + *(int *)&v22[8] = v15; + *(_QWORD *)v22 = __PAIR__(v38, v14); + Vec3_int_::Rotate(v21, sRotX, sRotY, *(Vec3_int_ *)v22, &pOut.x, &pOut.z, &pOut.y); + v23 = (unsigned int *)(&v29 + v35); + sub_42F7EB_DropItemAt(*v23, pOut.x, pOut.z, pOut.y, 0, 1, 0, 0x30u, 0); + + LayingItem a1; // [sp+14h] [bp-B0h]@28 + //LayingItem::LayingItem(&a1); + + a1.stru_24.Reset(); + v24 = *(short *)v23; + v25 = 0; + a1.field_50 = 0; + a1.field_4C = 0; + a1.field_48 = 0; + a1.field_54 = 0; + a1.uItemType = v24; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + { +LABEL_32: + v27 = 0; + } + else + { + v26 = (char *)&pObjectList->pObjects->uObjectID; + while ( v24 != *(short *)v26 ) + { + ++v25; + v26 += 56; + if ( v25 >= (signed int)pObjectList->uNumObjects ) + goto LABEL_32; + } + v27 = v25; + } + a1.uObjectDescID = v27; + a1.vPosition.y = pOut.z; + a1.vPosition.x = pOut.x; + a1.vPosition.z = pOut.y; + a1.uSoundID = 0; + a1.uAttributes = 48; + a1.uSectorID = pIndoor->GetSector(pOut.x, pOut.z, pOut.y); + a1.uSpriteFrameID = 0; + a1.field_58_pid = 0; + a1.field_5C = 0; + a1.uFacing = 0; + a1.Create(0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); + a1._438E35(); + chest->SetInitialized(false);//*v34 &= 0xFEu; + if ( uActiveCharacter && !qword_A750D8 && !dword_507CD8 ) + { + qword_A750D8 = 256i64; + word_A750E0 = 5; + word_A750E2 = uActiveCharacter; + } + pIcons_LOD->_4114F2(); + dword_507CD8 = 0; + return 0; + } + chest->SetInitialized(false);//*v1 &= 0xFEu; + sRotY = 1; +LABEL_12: + pAudioPlayer->StopChannels(-1, -1); + pAudioPlayer->PlaySound(SOUND_OpenChest, 0, 0, -1, 0, 0, 0, 0); + if ( *(float *)&sRotY != 0.0 ) + { + if ( !dword_507CD8 ) + pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0); + } + dword_507CD8 = 0; + v3 = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Chest, a4, 0); + pGUIWindow_CurrentMenu = v3; + pChestWindow = v3; + pBtn_ExitCancel = v3->CreateButton( + 0x1D7u, + 0x1BDu, + 0xA9u, + 0x23u, + 1, + 0, + 0x71u, + 0, + 0, + pGlobalTXT_LocalizationStrings[79],// Exit + (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), + 0); + pChestWindow->CreateButton(7u, 8u, 460u, 343u, 1, 0, 0xCu, 0, 0, "", 0); + pCurrentScreen = SCREEN_CHEST; + pEventTimer->Pause(); + return 1; +} + +//----- (0042092D) -------------------------------------------------------- +void Chest::DrawChestUI(unsigned int uChestID) +{ + Render *v1; // edi@1 + unsigned int v2; // ebx@1 + unsigned int v3; // ebx@1 + int v4; // eax@1 + unsigned int v5; // eax@1 + int v6; // ecx@3 + unsigned int v7; // eax@4 + Texture *v8; // esi@4 + signed int v9; // ecx@4 + signed int v10; // edx@4 + signed int v11; // eax@4 + int v12; // eax@6 + int v13; // eax@6 + unsigned int v14; // ST34_4@8 + int v15; // edi@8 + int *v16; // [sp+Ch] [bp-28h]@1 + int v17; // [sp+10h] [bp-24h]@4 + int v18; // [sp+14h] [bp-20h]@1 + signed int v19; // [sp+18h] [bp-1Ch]@1 + int v20; // [sp+1Ch] [bp-18h]@1 + signed int v21; // [sp+20h] [bp-14h]@1 + char *v22; // [sp+2Ch] [bp-8h]@2 + signed int v23; // [sp+30h] [bp-4h]@1 + + v1 = pRenderer; + v2 = uChestID; + v16 = pRenderer->pActiveZBuffer; + pRenderer->ClearZBuffer(0, 479); + v3 = v2; + v4 = pChests[v3].uChestBitmapID; + v20 = pChestSmthn1ByType[v4]; + v18 = pChestSmthn2ByType[v4]; + v21 = pChestWidthsByType[v4]; + v19 = pChestHeightsByType[v4]; + sprintf(pTmpBuf, "chest%02d", pChestList->pChests[pChests[v3].uChestBitmapID].uTextureID); + v5 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE); + pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0)); + v23 = 0; + if ( v21 * v19 > 0 ) + { + v22 = (char *)pChests[v3].pInventoryIndices; + do + { + v6 = *(short *)v22; + if ( v6 > 0 ) + { + v17 = v18 + 32 * v23 / v19; + v7 = pIcons_LOD->LoadTexture( + pItemsTable->pItems[*(int *)((char *)&pOtherOverlayList->pOverlays[49].field_4 + 36 * v6 + v3 * 5324)].pIconName, + TEXTURE_16BIT_PALETTE); + v8 = (Texture *)(v7 != -1 ? &pIcons_LOD->pTextures[v7] : 0); + v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24); + v10 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureHeight : 26); + v11 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24); + if ( v9 < 14 ) + v11 = 14; + v12 = v11 - 14; + LOBYTE(v12) = v12 & 0xE0; + v13 = v12 + 32; + if ( (signed int)v8->uTextureHeight < 14 ) + v10 = 14; + v14 = v20 + 32 * v23 % v21 + ((v13 - v9) >> 1); + v15 = v17 + ((((v10 - 14) & 0xFFFFFFE0) - v8->uTextureHeight + 32) >> 1); + pRenderer->DrawTextureTransparent( + v14, + v17 + ((((v10 - 14) & 0xFFFFFFE0) - v8->uTextureHeight + 32) >> 1), + v8); + sub_40F92A(&v16[v14 + pSRZBufferLineOffsets[v15]], v8, v23 + 1); + v1 = pRenderer; + } + ++v23; + v22 += 2; + } + while ( v23 < v21 * v19 ); + } + pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, + (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0)); +} + + +//----- (0041FE71) -------------------------------------------------------- +int Chest::CanPlaceItemAt(signed int a1, int a2, unsigned int uChestID) +{ + int v3; // eax@1 + unsigned int v4; // eax@1 + Texture *v5; // ecx@1 + signed int v6; // eax@1 + signed int v7; // edi@3 + signed int v8; // eax@3 + int v9; // edi@3 + int v10; // ebx@5 + int v11; // esi@9 + int v12; // edx@10 + int v13; // ecx@11 + char *v14; // eax@12 + int v16; // [sp+Ch] [bp-Ch]@1 + signed int v17; // [sp+10h] [bp-8h]@1 + signed int v18; // [sp+14h] [bp-4h]@1 + + v17 = a1; + v3 = pChests[uChestID].uChestBitmapID; + v16 = pChestHeightsByType[v3]; + v18 = pChestWidthsByType[v3]; + v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[a2].pIconName, TEXTURE_16BIT_PALETTE); + v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0); + v6 = (v4 != -1 ? pIcons_LOD->pTextures[v4].uTextureWidth : 24); + if ( v6 < 14 ) + v6 = 14; + v7 = v6 - 14; + v8 = v5->uTextureHeight; + v9 = (v7 >> 5) + 1; + if ( v8 < 14 ) + v8 = 14; + v10 = ((v8 - 14) >> 5) + 1; + if ( !areWeLoadingTexture ) + { + v5->Release(); + pIcons_LOD->_40F9C5(); + } + if ( v9 + v17 % v18 <= v18 && v10 + v17 / v18 <= v16 ) + { + v11 = 0; + if ( v10 <= 0 ) + return 1; + v12 = 0; + while ( 1 ) + { + v13 = 0; + if ( v9 > 0 ) + break; +LABEL_15: + v12 += v18; + ++v11; + if ( v11 >= v10 ) + return 1; + } + v14 = (char *)&pChests[0].pInventoryIndices[v17 + v12 + 2662 * uChestID]; + while ( !*(short *)v14 ) + { + ++v13; + v14 += 2; + if ( v13 >= v9 ) + goto LABEL_15; + } + } + return 0; +} +// 506128: using guessed type int areWeLoadingTexture; + +//----- (0041FF64) -------------------------------------------------------- +int Chest::_41FF64(unsigned int uChestID) +{ + unsigned int v1; // ecx@1 + signed int result; // eax@1 + int v3; // edx@1 + ItemGen *pItem; // ecx@2 + + v1 = uChestID; + result = 0; + v3 = pChestWidthsByType[pChests[v1].uChestBitmapID] * pChestHeightsByType[pChests[v1].uChestBitmapID]; + if ( v3 <= 0 ) + { +LABEL_5: + result = -1; + } + else + { + pItem = pChests[v1].mm7__vector_pItems; + while ( pItem->uItemID ) + { + ++result; + ++pItem; + if ( result >= v3 ) + goto LABEL_5; + } + } + return result; +} + +//----- (0041FFA2) -------------------------------------------------------- +int Chest::_41FFA2(int a1, ItemGen *a2, unsigned int uChestID) +{ + int v3; // eax@1 + ItemGen *v4; // edi@1 + int v5; // esi@1 + int result; // eax@11 + unsigned int v7; // eax@12 + int v8; // edx@12 + int v9; // ecx@12 + signed int v10; // eax@12 + signed int v11; // edi@14 + unsigned int v12; // esi@14 + int v13; // edi@16 + void *v14; // edi@21 + int v15; // edi@21 + int i; // ecx@21 + ItemGen *Src; // [sp+Ch] [bp-18h]@1 + signed int v18; // [sp+10h] [bp-14h]@2 + int v19; // [sp+14h] [bp-10h]@1 + int v20; // [sp+18h] [bp-Ch]@19 + signed int v21; // [sp+1Ch] [bp-8h]@1 + signed int v22; // [sp+20h] [bp-4h]@3 + int v23; // [sp+20h] [bp-4h]@19 + + v21 = 0; + v3 = pChests[uChestID].uChestBitmapID; + v4 = a2; + v5 = pChestWidthsByType[v3] * pChestHeightsByType[v3]; + Src = a2; + v19 = pChestWidthsByType[v3]; + if ( a1 == -1 ) + { + v18 = _41FF64(uChestID); + if ( v18 == -1 ) + return 0; + v22 = 0; + if ( v5 > 0 ) + { + while ( !Chest::CanPlaceItemAt(v22, v4->uItemID, (unsigned int)pChestWindow->ptr_1C) ) + { + ++v22; + if ( v22 >= v5 ) + goto LABEL_8; + } + v21 = v22; + } +LABEL_8: + if ( v22 == v5 ) + { + if ( uActiveCharacter ) + pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); + return 0; + } + v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v4->uItemID].pIconName, TEXTURE_16BIT_PALETTE); + HIWORD(v8) = 0; + v9 = v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0; + v10 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24); + if ( v10 < 14 ) + v10 = 14; + v11 = *(short *)(v9 + 26); + v12 = ((v10 - 14) >> 5) + 1; + if ( v11 < 14 ) + v11 = 14; + v13 = ((v11 - 14) >> 5) + 1; + if ( !areWeLoadingTexture ) + { + ((Texture *)v9)->Release(); + pIcons_LOD->_40F9C5(); + } + if ( v13 > 0 ) + { + v23 = 0; + v20 = v13; + do + { + if ( (signed int)v12 > 0 ) + { + v14 = &pChests[0].pInventoryIndices[v21 + v23 + 2662 * uChestID]; + LOWORD(v8) = -1 - v21; + v8 <<= 16; + LOWORD(v8) = -1 - v21; + memset32(v14, v8, v12 >> 1); + v15 = (int)((char *)v14 + 4 * (v12 >> 1)); + for ( i = v12 & 1; i; --i ) + { + *(short *)v15 = v8; + v15 += 2; + } + } + v23 += v19; + --v20; + } + while ( v20 ); + } + pChests[0].pInventoryIndices[v21 + 2662 * uChestID] = v18 + 1; + memcpy(&pChests[uChestID].mm7__vector_pItems[v18], Src, 0x24u); + result = v21 + 1; + } + else + { + result = 1; + } + return result; +} +// 506128: using guessed type int areWeLoadingTexture; + +//----- (0042013E) -------------------------------------------------------- +unsigned int Chest::PlaceItemAt(unsigned int a1, unsigned int uItemIdx, unsigned int uChestID) +{ + int v3; // esi@1 + unsigned int v4; // ebx@1 + int uItemID; // edi@1 + int v6; // edx@4 + unsigned int v7; // eax@5 + Texture *v8; // ecx@5 + signed int v9; // eax@5 + signed int v10; // edi@7 + unsigned int v11; // ebx@7 + int v12; // edi@9 + int v13; // edx@12 + void *v14; // edi@14 + int v15; // edi@14 + int i; // ecx@14 + unsigned int result; // eax@18 + __int16 v18; // [sp+Ch] [bp-10h]@1 + int v19; // [sp+10h] [bp-Ch]@11 + int v20; // [sp+14h] [bp-8h]@12 + unsigned int v21; // [sp+18h] [bp-4h]@1 + + v3 = 5324 * uChestID; + v21 = a1; + v4 = 5324 * uChestID + 36 * uItemIdx; + v18 = uItemIdx; + uItemID = *(unsigned int *)((char *)&pChests[0].mm7__vector_pItems[0].uItemID + v4); + pItemsTable->SetSpecialBonus((ItemGen *)((char *)pChests[0].mm7__vector_pItems + v4)); + if ( uItemID >= 135 && uItemID <= 159 && !*(int *)((char *)&pChests[0].mm7__vector_pItems[0].uNumCharges + v4) ) + { + v6 = rand() % 21 + 10; + *(int *)((char *)&pChests[0].mm7__vector_pItems[0].uNumCharges + v4) = v6; + *(&pChests[0].mm7__vector_pItems[0].uMaxCharges + v4) = v6; + } + v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); + v8 = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0); + v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24); + if ( v9 < 14 ) + v9 = 14; + v10 = v8->uTextureHeight; + v11 = ((v9 - 14) >> 5) + 1; + if ( v10 < 14 ) + v10 = 14; + v12 = ((v10 - 14) >> 5) + 1; + if ( !areWeLoadingTexture ) + { + v8->Release(); + pIcons_LOD->_40F9C5(); + } + v19 = pChestWidthsByType[*(unsigned __int16 *)((char *)&pChests[0].uChestBitmapID + v3)]; + if ( v12 > 0 ) + { + v13 = 0; + v20 = v12; + do + { + if ( (signed int)v11 > 0 ) + { + v14 = &pChests[0].pInventoryIndices[v21 + v13 + 2662 * uChestID]; + LOWORD(v3) = -1 - v21; + v3 <<= 16; + LOWORD(v3) = -1 - v21; + memset32(v14, v3, v11 >> 1); + v15 = (int)((char *)v14 + 4 * (v11 >> 1)); + for ( i = v11 & 1; i; --i ) + { + *(short *)v15 = v3; + v15 += 2; + } + } + v13 += v19; + --v20; + } + while ( v20 ); + } + result = v21 + 2662 * uChestID; + pChests[0].pInventoryIndices[result] = v18 + 1; + return result; +} +// 506128: using guessed type int areWeLoadingTexture; + +//----- (00420284) -------------------------------------------------------- +char *Chest::_420284(unsigned int uChestID) +{ + int v1; // ebx@1 + unsigned int v2; // esi@1 + unsigned int v3; // esi@1 + int uChestArea; // edi@1 + int v5; // eax@2 + int v6; // ebx@11 + char *result; // eax@18 + char Dst[144]; // [sp+Ch] [bp-A0h]@1 + int v9; // [sp+9Ch] [bp-10h]@10 + unsigned int v10; // [sp+A0h] [bp-Ch]@1 + unsigned int v11; // [sp+A4h] [bp-8h]@8 + ItemGen *v12; // [sp+A8h] [bp-4h]@9 + + v1 = 0; + v2 = uChestID; + v10 = uChestID; + pRenderer->ClearZBuffer(0, 479); + v3 = v2; + uChestArea = pChestWidthsByType[pChests[v3].uChestBitmapID] * pChestHeightsByType[pChests[v3].uChestBitmapID]; + memset(Dst, 0, 0x90u); + if ( uChestArea > 0 ) + { + do + { + do + v5 = (unsigned __int8)rand(); + while ( v5 >= uChestArea ); + while ( Dst[v5] ) + { + ++v5; + if ( v5 == uChestArea ) + v5 = 0; + } + Dst[v5] = v1++; + } + while ( v1 < uChestArea ); + } + v11 = 0; + if ( uChestArea > 0 ) + { + v12 = pChests[v3].mm7__vector_pItems;//&pChests[v3].mm7__vector_pItems[0].uAttributes; + do + { + v9 = v12->uItemID; + if ( v9 ) + { + v6 = 0; + while ( !Chest::CanPlaceItemAt((unsigned __int8)Dst[v6], v9, v10) ) + { + ++v6; + if ( v6 >= uChestArea ) + break; + } + if(v6<uChestArea) + { + Chest::PlaceItemAt((unsigned __int8)Dst[v6], v11, v10); + if ( pChests[v3].uFlags & 4 ) + v12->SetIdentified(); + } + } + ++v11; + ++v12; + } + while ( (signed int)v11 < uChestArea ); + } + result = (char *)&pChests[v3].uFlags; + pChests[v3].uFlags = pChests[v3].uFlags & 0xFFFB | 2; + return result; +} +// 420284: using guessed type char Dst[144]; + //----- (00458B03) -------------------------------------------------------- void ChestList::ToFile() {
--- a/Chest.h Mon Feb 25 09:08:13 2013 +0600 +++ b/Chest.h Mon Feb 25 09:09:08 2013 +0600 @@ -49,6 +49,10 @@ #pragma pack(push, 1) struct Chest { + inline bool Initialized() const {return uFlags & CHEST_ITEMS_PLACED;} + inline void SetInitialized(bool b) {if (b) uFlags |= CHEST_ITEMS_PLACED; else uFlags &= ~CHEST_ITEMS_PLACED;} + inline bool Trapped() const {return uFlags & CHEST_TRAPPED;} + static int CanPlaceItemAt(signed int a1, int a2, unsigned int uChestID); static int _41FF64(unsigned int uChestID); static int _41FFA2(int a1, ItemGen *a2, unsigned int uChestID);
--- a/DecorationList.h Mon Feb 25 09:08:13 2013 +0600 +++ b/DecorationList.h Mon Feb 25 09:09:08 2013 +0600 @@ -25,6 +25,11 @@ #pragma pack(push, 1) struct DecorationDesc { + inline bool CanMoveThrough() {return uFlags & DECORATION_MOVE_THROUGH;} + inline bool DontDraw() {return uFlags & DECORATION_DONT_DRAW;} + inline bool SoundOnDawn() {return uFlags & DECORATION_SOUND_ON_DAWN;} + inline bool SoundOnDusk() {return uFlags & DECORATION_SOUND_ON_DUSK;} + char pName[32]; char field_20[32]; __int16 uType;
--- a/Events.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/Events.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -25,14 +25,15 @@ #include "Events.h" #include "Events2D.h" #include "Weather.h" +#include "Party.h" EventIndex pSomeOtherEVT_Events[4400]; -unsigned int uSomeOtherEVT_NumEvents; +signed int uSomeOtherEVT_NumEvents; char *pSomeOtherEVT; EventIndex pSomeEVT_Events[4400]; -unsigned int uSomeEVT_NumEvents; +signed int uSomeEVT_NumEvents; char *pSomeEVT; unsigned int uGlobalEVT_NumEvents; @@ -43,7 +44,7 @@ unsigned int pLevelStrOffsets[500]; unsigned int uLevelStrNumStrings; unsigned int uLevelStrFileSize; -unsigned int uLevelEVT_NumEvents; +signed int uLevelEVT_NumEvents; unsigned int uLevelEVT_Size; char pLevelStr[9216]; char pLevelEVT[9216]; @@ -367,11 +368,11 @@ v16 = RemoveQuotes(Str); VideoPlayer::MovieLoop(v16, 0, v14, 1); if ( !_strcmpi(v16, "arbiter good") ) - { - pParty->uAlignment = 0; + { + pParty->alignment = PartyAlignment_Good; v18 = 0; LOBYTE(v17) = 1; - SetUserInterface(v18, v17); + SetUserInterface(PartyAlignment_Good, v17); if ( !v15 || v128 == 3 ) { pCurrentScreen = v128; @@ -392,9 +393,9 @@ if ( !_strcmpi(v16, "arbiter evil") ) { v18 = 2; - pParty->uAlignment = 2; + pParty->alignment = PartyAlignment_Evil; LOBYTE(v17) = 1; - SetUserInterface(v18, v17); + SetUserInterface(PartyAlignment_Evil, v17); if ( !v15 || v128 == 3 ) { pCurrentScreen = v128; @@ -1518,7 +1519,7 @@ pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; - array_5913D8[6] = 0; + pDialogueNPCCount = 0; pDialogueWindow->Release(); dword_F8B19C = 0; pDialogueWindow = 0;
--- a/Events.h Mon Feb 25 09:08:13 2013 +0600 +++ b/Events.h Mon Feb 25 09:09:08 2013 +0600 @@ -105,14 +105,15 @@ EVENT_GiveItem = 0x29, EVENT_ChangeEvent = 0x2A, EVENT_CheckSkill = 0x2B, - EVENT_OnCanShowDialogItemCmp = 0x2C, - EVENT_EndCanShowDialogItem = 0x2D, - EVENT_SetCanShowDialogItem = 0x2E, + EVENT_OnCanShowDialogItemCmp = 44, + EVENT_EndCanShowDialogItem = 45, + EVENT_SetCanShowDialogItem = 46, EVENT_SetNPCGroupNews = 0x2F, EVENT_SetActorGroup = 0x30, EVENT_NPCSetItem = 0x31, EVENT_SetNPCGreeting = 0x32, EVENT_IsActorAlive = 0x33, + EVENT_IsActorAssasinated =52, EVENT_OnMapLeave = 0x35, EVENT_ChangeGroup = 0x36, EVENT_ChangeGroupAlly = 0x37, @@ -298,10 +299,10 @@ #define EVT_BYTE(x) (unsigned char)x extern EventIndex pSomeOtherEVT_Events[4400]; -extern unsigned int uSomeOtherEVT_NumEvents; +extern signed int uSomeOtherEVT_NumEvents; extern char *pSomeOtherEVT; extern EventIndex pSomeEVT_Events[4400]; -extern unsigned int uSomeEVT_NumEvents; +extern signed int uSomeEVT_NumEvents; extern char *pSomeEVT; extern unsigned int uGlobalEVT_NumEvents; @@ -312,7 +313,7 @@ extern unsigned int pLevelStrOffsets[500]; extern unsigned int uLevelStrNumStrings; extern unsigned int uLevelStrFileSize; -extern unsigned int uLevelEVT_NumEvents; +extern signed int uLevelEVT_NumEvents; extern unsigned int uLevelEVT_Size; extern char pLevelStr[9216]; extern char pLevelEVT[9216];
--- a/GUIProgressBar.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/GUIProgressBar.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -1,3 +1,5 @@ +#include <assert.h> + #include "GUIProgressBar.h" #include "LOD.h" #include "Mouse.h" @@ -15,22 +17,29 @@ -//----- (00443484) -------------------------------------------------------- -bool GUIProgressBar::_443484(Type type) +//----- (00Initialize) -------------------------------------------------------- +bool GUIProgressBar::Initialize(Type type) { //GUIProgressBar *v2; // esi@1 signed int v4; // eax@7 int v5; // ecx@8 int v6; // edi@8 int v7; // edx@14 - const char *v8; // [sp-8h] [bp-84h]@20 - unsigned int v9; // [sp-4h] [bp-80h]@20 + //const char *v8; // [sp-8h] [bp-84h]@20 + //unsigned int v9; // [sp-4h] [bp-80h]@20 char Str1[64]; // [sp+4h] [bp-78h]@16 - if (type < 1 || type > 1) + switch (type) { - __debugbreak(); - return false; + case TYPE_None: + return true; + + case TYPE_Box: + case TYPE_Fullscreen: + break; + + default: + assert(false && "Invalid GUIProgressBar type"); } //v2 = this; @@ -74,7 +83,8 @@ Draw(); return true; } - if ( !pParty->uAlignment ) + + /*if ( !pParty->uAlignment ) { v9 = 2; v8 = "bardata-b"; @@ -92,7 +102,15 @@ v8 = "bardata-c"; LABEL_23: pIcons_LOD->_410522(&pBardata, v8, v9); + }*/ + switch (pParty->alignment) + { + case PartyAlignment_Good: pIcons_LOD->_410522(&pBardata, "bardata-b", 2); break; + case PartyAlignment_Neutral: pIcons_LOD->_410522(&pBardata, "bardata", 2); break; + case PartyAlignment_Evil: pIcons_LOD->_410522(&pBardata, "bardata-c", 2); break; + default: assert(false); } + uProgressCurrent = 0; uProgressMax = 26; Draw();
--- a/GUIProgressBar.h Mon Feb 25 09:08:13 2013 +0600 +++ b/GUIProgressBar.h Mon Feb 25 09:09:08 2013 +0600 @@ -8,10 +8,12 @@ { enum Type: unsigned __int32 { - TYPE_Fullscreen = 1 + TYPE_None = 0, + TYPE_Fullscreen = 1, + TYPE_Box = 2 }; - bool _443484(Type type); + bool Initialize(Type type); void Reset(unsigned __int8 uMaxProgress); void Progress(); void Release();
--- a/GUIWindow.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/GUIWindow.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -465,9 +465,7 @@ unsigned int v19; // edi@43 unsigned int v20; // edi@45 void *v21; // esi@45 - char *v22; // [sp+10h] [bp-5Ch]@9 signed int v23; // [sp+10h] [bp-5Ch]@38 - int v24; // [sp+14h] [bp-58h]@9 char *v25; // [sp+14h] [bp-58h]@21 GUIWindow v26; // [sp+18h] [bp-54h]@8 @@ -720,12 +718,9 @@ if ( dword_506528 < 29 ) { v3 = (__int64 *)&pParty->field_3C.field_4F0[2 * dword_506528]; - v24 = dword_506528 + 1; - //v22 = (char *)&pStorylineText->StoreLine[dword_506528].pPageTitle;//guess //field_4[3 * dword_506528 + 2]; - v22 = (char *)&pStorylineText->StoreLine[dword_506528+1].pText; - do + for(int i=dword_506528+1;i<dword_506528+31;i++) { - v4 = *(char **)v22; + v4 = pStorylineText->StoreLine[i].pText; if ( *v3 ) { if ( v4 ) @@ -736,7 +731,7 @@ v8 = v7 + 1; if ( (signed int)v7 + 1 > 0 ) { - memset32((char *)&pStru179 + 4 * dword_506520 , v24, v8); + memset32((char *)&pStru179 + 4 * dword_506520 , i, v8); do { LODWORD(v7) = dword_506520++; @@ -747,13 +742,9 @@ } } } - v22 += 12; + ++i; ++v3; - ++v24; - //__debugbreak(); // fix condition } - //while ( (signed int)v22 < (signed int)&pFactionTable->relations + 8 ); - while ( (signed int)v22 <= (signed int)&pStorylineText->StoreLine[30].uTime ); } } } @@ -1025,9 +1016,8 @@ } // 50640C: using guessed type int dword_50640C[]; - //----- (004B3157) -------------------------------------------------------- -void GUIWindow::_4B3157() +void GUIWindow::HouseDialogManager() { unsigned __int16 v1; // di@2 const char *v2; // edx@4 @@ -1040,11 +1030,11 @@ int v9; // eax@50 unsigned int v10; // [sp-10h] [bp-C8h]@53 unsigned __int16 v11; // [sp-Ch] [bp-C4h]@53 - unsigned int v12; // [sp-Ch] [bp-C4h]@60 + //unsigned int v12; // [sp-Ch] [bp-C4h]@60 char *v13; // [sp-8h] [bp-C0h]@50 - unsigned int v14; // [sp-8h] [bp-C0h]@60 + //unsigned int v14; // [sp-8h] [bp-C0h]@60 unsigned int v15; // [sp-4h] [bp-BCh]@50 - Texture *v16; // [sp-4h] [bp-BCh]@60 + //Texture *v16; // [sp-4h] [bp-BCh]@60 GUIWindow w; // [sp+Ch] [bp-ACh]@4 GUIWindow v18; // [sp+60h] [bp-58h]@2 int v19; // [sp+B4h] [bp-4h]@2 @@ -1057,8 +1047,8 @@ v1 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu); v19 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u); pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background); - pRenderer->DrawTextureTransparent(0x1D4u, 0, (Texture *)(uTextureID_507B04 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507B04] : 0)); - if ( array_5913D8[6] != (NPCData *)uNumDialogueNPCPortraits || !uHouse_ExitPic ) + pRenderer->DrawTextureTransparent(0x1D4u, 0, &pIcons_LOD->pTextures[uTextureID_507B04]); + if ( pDialogueNPCCount != uNumDialogueNPCPortraits || !uHouse_ExitPic ) { w.uFrameWidth = 130; w.uFrameHeight = 2 * LOBYTE(pFontCreate->uFontHeight); @@ -1078,11 +1068,10 @@ } v18.uFrameWidth += 8; v18.uFrameZ += 8; - if ( !array_5913D8[6] ) + if ( !pDialogueNPCCount ) { if ( dword_F8B198 == 31 ) { -LABEL_36: sub_4B4F4F(); goto LABEL_58; } @@ -1092,8 +1081,7 @@ w.uFrameZ = 457; v5 = pFontArrus->CalcTextHeight(ptr_F8B1E8, &w, 13, 0); v6 = v5 + 7; - pRenderer->_4A6A68(8, 352 - (v5 + 7), (Texture *)(uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0), - (uTextureID_Leather != -1 ? pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight : 26) - (v5 + 7)); + pRenderer->_4A6A68(8, 352 - (v5 + 7), &pIcons_LOD->pTextures[uTextureID_Leather], pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight - (v5 + 7)); pRenderer->DrawTextureIndexed(8u, 347 - v6, pTexture_591428); v7 = FitTextInAWindow(ptr_F8B1E8, pFontArrus, &w, 0xDu, 0); window_SpeakInHouse->DrawText(pFontArrus, 13, 354 - v6, 0, v7, 0, 0, 0); @@ -1103,11 +1091,14 @@ goto LABEL_58; while ( 1 ) { - pRenderer->DrawTextureIndexed(*(&pNPCPortraits_x + v8 + 6 * uNumDialogueNPCPortraits - 6) - 4, - *(&pNPCPortraits_y + v8 + 6 * uNumDialogueNPCPortraits - 6) - 4, - (Texture *)(uTextureID_50795C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50795C] : 0)); - pRenderer->DrawTextureIndexed(*(&pNPCPortraits_x + v8 + 6 * uNumDialogueNPCPortraits - 6), - *(&pNPCPortraits_y + v8 + 6 * uNumDialogueNPCPortraits - 6), pDialogueNPCPortraits[v8]); + //pRenderer->DrawTextureIndexed(*(&pNPCPortraits_x + v8 + 6 * uNumDialogueNPCPortraits - 6) - 4, + // *(&pNPCPortraits_y + v8 + 6 * uNumDialogueNPCPortraits - 6) - 4, + pRenderer->DrawTextureIndexed(pNPCPortraits_x[uNumDialogueNPCPortraits - 1][v8] - 4, + pNPCPortraits_y[uNumDialogueNPCPortraits - 1][v8] - 4, &pIcons_LOD->pTextures[uTextureID_50795C]); // frame around portrait + //pRenderer->DrawTextureIndexed(*(&pNPCPortraits_x + v8 + 6 * uNumDialogueNPCPortraits - 6), + // *(&pNPCPortraits_y + v8 + 6 * uNumDialogueNPCPortraits - 6), pDialogueNPCPortraits[v8]); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[uNumDialogueNPCPortraits - 1][v8], + pNPCPortraits_y[uNumDialogueNPCPortraits - 1][v8], pDialogueNPCPortraits[v8]); if ( uNumDialogueNPCPortraits < 4 ) break; LABEL_57: @@ -1128,24 +1119,21 @@ v15 = 3; //v13 = (char *)p2DEvents_minus1__10[13 * (unsigned int)ptr_507BC0->ptr_1C]; v13 = (char *)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].pProprieterTitle; - v11 = v19; - v10 = 113; -LABEL_56: - v18.DrawTitleText(pFontCreate, 0x1E3u, v10, v11, v13, v15); + v18.DrawTitleText(pFontCreate, 0x1E3u, 113, v19, v13, 3); goto LABEL_57; } v15 = 3; - v13 = array_5913D8[v8 - (dword_591080 != 0)]->pName; - v9 = dword_4E5EC8[v8 + 6 * uNumDialogueNPCPortraits] + pDialogueNPCPortraits[v8]->uTextureHeight + 2; + v13 = HouseNPCData[v8 - (dword_591080 != 0)]->pName; + v9 = pNPCPortraits_x[6 + (uNumDialogueNPCPortraits - 1)][v8] + pDialogueNPCPortraits[v8]->uTextureHeight + 2; } v11 = v19; v10 = v9; - goto LABEL_56; + v18.DrawTitleText(pFontCreate, 0x1E3u, v10, v11, v13, v15); + goto LABEL_57; } - v4 = (char *)array_5913D8[6] - 1; - pRenderer->DrawTextureIndexed(pNPCPortraits_x - 4, pNPCPortraits_y - 4, - (Texture *)(uTextureID_50795C != -1 ? &pIcons_LOD->pTextures[uTextureID_50795C] : 0)); - pRenderer->DrawTextureIndexed(pNPCPortraits_x, pNPCPortraits_y, pDialogueNPCPortraits[(signed int)v4]); + v4 = (char *)pDialogueNPCCount - 1; + pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, &pIcons_LOD->pTextures[uTextureID_50795C]); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pDialogueNPCPortraits[(signed int)v4]); if ( pCurrentScreen == SCREEN_E ) { CharacterUI_InventoryTab_Draw(uActiveCharacter, 1); @@ -1153,7 +1141,7 @@ } if ( v4 || !dword_591080 ) { - sub_4B2A74(); + SimpleHouseAndBoatsDialog(); } else { @@ -1171,23 +1159,23 @@ sub_4B6478(); break; case 1: - _4B910F_shop_interaction(); + WeaponShopDialog(); break; case 2: - sub_4BA928(); + ArmorShopDialog(); break; case 3: - ui_shop_teachers(); + MagicShopDialog(); break; case 4: - sub_4B9CC6(); + AlchemistDialog(); break; default: if ( dword_F8B198 > 4 ) { if ( dword_F8B198 <= 16 ) { - sub_4B5D7C(); + GuildDialog(); } else { @@ -1202,13 +1190,13 @@ switch ( dword_F8B198 ) { case 21: - sub_4B8285_prolly_draw_arcomage_result(); + TavernDialog(); break; case 22: _4B7D7E_bank(); break; case 23: - sub_4B705E(); + TampleDialog(); break; default: if ( dword_F8B198 <= 26 ) @@ -1223,28 +1211,24 @@ { if ( dword_F8B198 != 31 ) break; - goto LABEL_36; + sub_4B4F4F(); + goto LABEL_58; } - ui_training(); + TrainingDialog(); } break; } } LABEL_58: - if ( array_5913D8[6] == (NPCData *)uNumDialogueNPCPortraits && uHouse_ExitPic ) + if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) { - pRenderer->DrawTextureIndexed(0x22Cu, 0x1C3u, (Texture *)(uTextureID_x_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_x_u] : 0)); - v16 = (Texture *)(uTextureID_x_ok_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_ok_u] : 0); - v14 = 451; - v12 = 476; + pRenderer->DrawTextureIndexed(556, 451, &pIcons_LOD->pTextures[uTextureID_x_x_u]); + pRenderer->DrawTextureIndexed(476, 451, &pIcons_LOD->pTextures[uTextureID_x_ok_u]); } else { - v16 = (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0); - v14 = 445; - v12 = 471; + pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uTextureID_506438]); } - pRenderer->DrawTextureIndexed(v12, v14, v16); } @@ -1776,26 +1760,20 @@ //GUIWindow *pWindow; // esi@4 int v10; // eax@4 unsigned int v11; // ebx@15 - NPCData *v12; // ebp@15 - void *v13; // ecx@18 - bool v14; // eax@20 - void *v15; // ecx@23 - bool v16; // eax@25 - void *v17; // ecx@28 - bool v18; // eax@30 - void *v19; // ecx@33 - bool v20; // eax@35 - void *v21; // ecx@38 - bool v22; // eax@40 - void *v23; // ecx@43 - bool v24; // eax@45 + NPCData *speakingNPC; // ebp@15 + int v14; // eax@20 + int v16; // eax@25 + int v18; // eax@30 + int v20; // eax@35 + int v22; // eax@40 + int v24; // eax@45 int v25; // eax@65 unsigned int v26; // ebx@65 char *v27; // eax@71 const char *v29; // [sp-8h] [bp-18h]@68 char *v30; // [sp-4h] [bp-14h]@68 int uWidtha; // [sp+14h] [bp+4h]@66 - int a4a; // [sp+20h] [bp+10h]@15 + int num_menu_buttons; // [sp+20h] [bp+10h]@15 for (uNextFreeWindowID = 0; uNextFreeWindowID < 20; ++uNextFreeWindowID) { @@ -1835,95 +1813,89 @@ (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0), 0); if ( pWindow->ptr_1C != (void *)1 ) { - a4a = 0; + num_menu_buttons = 0; v11 = LOBYTE(pFontArrus->uFontHeight) - 3; - v12 = GetNPCData(uDialogue_SpeakingActorNPC_ID); + speakingNPC = GetNPCData(uDialogue_SpeakingActorNPC_ID); if ( sub_445C8B(uDialogue_SpeakingActorNPC_ID) == 1 ) { - if ( v12->joins ) + if ( speakingNPC->joins ) { pWindow->CreateButton(480, 130, 140, v11, 1, 0, 0x88u, 0xDu, 0, "", 0); - a4a = 1; + num_menu_buttons = 1; } - v13 = (void *)v12->evt_A; - if ( v13 ) + if ( speakingNPC->evt_A ) { - if ( a4a < 4 ) + if ( num_menu_buttons < 4 ) { - v14 = sub_4466C4(v13); + v14 = NPC_EventProcessor(speakingNPC->evt_A); if ( v14 == 1 || v14 == 2 ) - pWindow->CreateButton(0x1E0u, a4a++ * v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x13u, 0, "", 0); + pWindow->CreateButton(0x1E0u, num_menu_buttons++ * v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x13u, 0, "", 0); } } - v15 = (void *)v12->evt_B; - if ( v15 ) + if ( speakingNPC->evt_B ) { - if ( a4a < 4 ) + if ( num_menu_buttons < 4 ) { - v16 = sub_4466C4(v15); + v16 = NPC_EventProcessor(speakingNPC->evt_B); if ( v16 == 1 || v16 == 2 ) - pWindow->CreateButton(0x1E0u, a4a++ * v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x14u, 0, "", 0); + pWindow->CreateButton(0x1E0u, num_menu_buttons++ * v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x14u, 0, "", 0); } } - v17 = (void *)v12->evt_C; - if ( v17 ) + if ( speakingNPC->evt_C ) { - if ( a4a < 4 ) + if ( num_menu_buttons < 4 ) { - v18 = sub_4466C4(v17); + v18 = NPC_EventProcessor(speakingNPC->evt_C); if ( v18 == 1 || v18 == 2 ) - pWindow->CreateButton( 0x1E0u, a4a++ * v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x15u, 0, "", 0); + pWindow->CreateButton( 0x1E0u, num_menu_buttons++ * v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x15u, 0, "", 0); } } - v19 = (void *)v12->evt_D; - if ( v19 ) + if ( speakingNPC->evt_D ) { - if ( a4a < 4 ) + if ( num_menu_buttons < 4 ) { - v20 = sub_4466C4(v19); + v20 = NPC_EventProcessor(speakingNPC->evt_D); if ( v20 == 1 || v20 == 2 ) - pWindow->CreateButton(0x1E0u, a4a++ * v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x16u, 0, "", 0); + pWindow->CreateButton(0x1E0u, num_menu_buttons++ * v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x16u, 0, "", 0); } } - v21 = (void *)v12->evt_E; - if ( v21 ) + if ( speakingNPC->evt_E ) { - if ( a4a < 4 ) + if ( num_menu_buttons < 4 ) { - v22 = sub_4466C4(v21); + v22 = NPC_EventProcessor(speakingNPC->evt_E); if ( v22 == 1 || v22 == 2 ) - pWindow->CreateButton(0x1E0u, a4a++ * v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x17u, 0, "", 0); + pWindow->CreateButton(0x1E0u, num_menu_buttons++ * v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x17u, 0, "", 0); } } - v23 = (void *)v12->evt_F; - if ( v23 ) + if (speakingNPC->evt_F ) { - if ( a4a < 4 ) + if ( num_menu_buttons < 4 ) { - v24 = sub_4466C4(v23); + v24 = NPC_EventProcessor(speakingNPC->evt_F); if ( v24 == 1 || v24 == 2 ) - pWindow->CreateButton(0x1E0u, a4a++ * v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x18u, 0, "", 0); + pWindow->CreateButton(0x1E0u, num_menu_buttons++ * v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x18u, 0, "", 0); } } } else { - if ( v12->joins ) + if ( speakingNPC->joins ) { pWindow->CreateButton(0x1E0u, 0x82u, 0x8Cu, v11, 1, 0, 0x88u, 0x4Du, 0, pGlobalTXT_LocalizationStrings[407], 0);// - if (v12->Hired()) + if (speakingNPC->Hired()) { - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], v12->pName); // + sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], speakingNPC->pName); // pWindow->CreateButton(0x1E0u, v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x4Cu, 0, pTmpBuf, 0); } else { pWindow->CreateButton(0x1E0u, v11 + 130, 0x8Cu, v11, 1, 0, 0x88u, 0x4Cu, 0, pGlobalTXT_LocalizationStrings[406], 0);// } - a4a = 2; + num_menu_buttons = 2; } } - pWindow->_41D08F(a4a, 1, 0, 1); + pWindow->_41D08F(num_menu_buttons, 1, 0, 1); } break; case WINDOW_ChangeLocation: @@ -1933,7 +1905,7 @@ (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), 0); pBtn_YES = pWindow->CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, 0x5Au, 0, 0x59u, pWindow->Hint, (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0), 0); - pWindow->CreateButton(pNPCPortraits_x, pNPCPortraits_y, 0x3Fu, 0x49u, 1, 0, 0x5Au, 1u, 0x20u, pWindow->Hint, 0, 0, 0); + pWindow->CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 0x3Fu, 0x49u, 1, 0, 0x5Au, 1u, 0x20u, pWindow->Hint, 0, 0, 0); pWindow->CreateButton(8u, 8u, 0x1CCu, 0x158u, 1, 0, 0x5Au, 1u, 0, pWindow->Hint, 0); break; case WINDOW_SpellBook: // @@ -1971,21 +1943,21 @@ if ( v26 + 1 == v25 && uHouse_ExitPic ) { v30 = pMapStats->pInfos[uHouse_ExitPic].pName; - v29 = (char*)pGlobalTXT_LocalizationStrings[411];// ^Pv[%s] + v29 = (char*)pGlobalTXT_LocalizationStrings[LOCSTR_ENTER_S];// ^Pv[%s] } else { if ( v26 || !dword_591080 ) - v27 = array_5913D8[v26 - (dword_591080 != 0)]->pName; + v27 = HouseNPCData[v26 - (dword_591080 != 0)]->pName; else //v27 = (char *)p2DEvents_minus1_::08[13 * a4]; v27 = (char *)p2DEvents[pButton - 1].pProprieterName; v30 = v27; - v29 = (char*)pGlobalTXT_LocalizationStrings[435];// ^Pt[%s] + v29 = (char*)pGlobalTXT_LocalizationStrings[435];// "Converse with %s" ^Pt[%s] } sprintf(&byte_591180[100 * v26], v29, v30); - array_5913D8[v26 + 7] = (NPCData *)pWindow->CreateButton(*(&pNPCPortraits_x + v26 + 6 * uNumDialogueNPCPortraits - 6), - *(&pNPCPortraits_y + v26 + 6 * uNumDialogueNPCPortraits - 6), + HouseNPCData[v26 + 7] = (NPCData *)pWindow->CreateButton(pNPCPortraits_x[uNumDialogueNPCPortraits - 1][v26], + pNPCPortraits_y[uNumDialogueNPCPortraits - 1][v26], 0x3Fu, 0x49u, 1, 0, 0x19Au, v26, 0, &byte_591180[100 * v26], 0, 0, 0); ++v26; v25 = uNumDialogueNPCPortraits; @@ -2008,7 +1980,7 @@ (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), 0); pBtn_YES = pWindow->CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, 0x19Bu, 0, 0x59u, pWindow->Hint, (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0), 0); - pWindow->CreateButton(pNPCPortraits_x, pNPCPortraits_y, 0x3Fu, 0x49u, 1, 0, 0x19Bu, 1, 0x20u, pWindow->Hint, 0); + pWindow->CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 0x3Fu, 0x49u, 1, 0, 0x19Bu, 1, 0x20u, pWindow->Hint, 0); pWindow->CreateButton(8u, 8u, 0x1CCu, 0x158u, 1, 0, 0x19Bu, 1u, 0, pWindow->Hint, 0); return pWindow; }
--- a/GUIWindow.h Mon Feb 25 09:08:13 2013 +0600 +++ b/GUIWindow.h Mon Feb 25 09:09:08 2013 +0600 @@ -115,7 +115,7 @@ char *DrawTitleText(GUIFont *a2, unsigned int uHorizontalMargin, unsigned int uVerticalMargin, unsigned __int16 uDefaultColor, const char *pInString, unsigned int uLineSpacing); char *_4B1854(__int64 a2); - void _4B3157(); + void HouseDialogManager(); void OpenSpellBook(); void InitializeBookView(); void DrawMessageBox(int arg0); @@ -190,13 +190,13 @@ UIMSG_PlayerCreationRemoveUpSkill = 0x4A, UIMSG_PlayerCreationRemoveDownSkill = 0x4B, UIMSG_4E = 0x4E, - UIMSG_4F = 0x4F, + UIMSG_SPellbook_ShowHightlightedSpellInfo = 0x4F, UIMSG_51 = 0x51, UIMSG_LoadGame = 0x52, UIMSG_SaveGame = 0x53, UIMSG_54 = 0x54, UIMSG_55 = 0x55, - UIMSG_56 = 0x56, + UIMSG_SelectSpell = 0x56, UIMSG_57 = 0x57, UIMSG_58 = 0x58, UIMSG_5A = 0x5A, @@ -240,7 +240,7 @@ UIMSG_SelectDialogueOption = 0x88, UIMSG_8C = 0x8C, UIMSG_8D = 0x8D, - UIMSG_8E = 0x8E, + UIMSG_CastSpellFromBook = 0x8E, UIMSG_8F = 0x8F, UIMSG_PlayerCreation_VoicePrev = 0x90, UIMSG_PlayerCreation_VoiceNext = 0x91, @@ -309,7 +309,7 @@ UIMSG_195 = 0x195, UIMSG_OpenRestUI = 0x199, UIMSG_19A = 0x19A, - UIMSG_19B = 0x19B, + UIMSG_TransitionUI_Confirm = 0x19B, UIMSG_19C = 0x19C, UIMSG_OpenKeyMappingOptions = 0x19F, UIMSG_SelectKeyPage1 = 0x1A0, @@ -373,7 +373,7 @@ - +#define AddMessage(msg, param, a4) AddMessageImpl((msg), (param), (a4), __FILE__, __LINE__) /* 250 */ #pragma pack(push, 1) struct GUIMessageQueue @@ -383,10 +383,13 @@ {} void PopMessage(UIMessageType *pMsg, int *pParam, int *a4); - void SendMessage(UIMessageType msg, int param, unsigned int a4); + void AddMessageImpl(UIMessageType msg, int param, unsigned int a4, const char *file = nullptr, int line = 0); unsigned int uNumMessages; GUIMessage pMessages[40]; + + const char *files[40]; + int lines[40]; }; #pragma pack(pop)
--- a/Game.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/Game.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -170,7 +170,7 @@ GUI_UpdateWindows(); pParty->UpdatePlayersAndHirelingsEmotions(); ++stru_51076C.field_8; - dword_5B5924 = 0; + _unused_5B5924_is_travel_ui_drawn = false; if (v4) pMouse->field_14 = 1; pMouse->_469EA4(); @@ -328,7 +328,7 @@ v16 = 0; viewparams->bRedrawGameUI = true; } - //pAudioPlayer->_4AAFCF();//Ritor1: it's temporarily, game crash. decorations sounds + pAudioPlayer->UpdateSounds(); if (uGameState == 1) //goto LABEL_96; { @@ -417,16 +417,18 @@ pTurnEngine->End(1); pParty->bTurnBasedModeOn = 0; } - pHealth = &pParty->pPlayers[0].sHealth;//193C - do + //pHealth = &pParty->pPlayers[0].sHealth;//193C + //do + for(int i=0; i<4; ++i) { - memset(pHealth - 0x64F, 0, 0xA0u);//(pConditions, 0, 160) - memset(pHealth - 0x67, 0, 0x180u);//(pPlayerBuffs[0], 0, 384) - *pHealth = 1; - pHealth += 1743; //6CF + memset(pParty->pPlayers[i].pConditions, 0, 0xA0u);//(pConditions, 0, 160) + memset(pParty->pPlayers[i].pPlayerBuffs, 0, 0x180u);//(pPlayerBuffs[0], 0, 384) + //*pHealth = 1; + pParty->pPlayers[i].sHealth=1; + //pHealth += 1743; //6CF uActiveCharacter = 1; } - while ( (signed int)pHealth < (signed int)&pParty->field_871C[567] ); + // while ( (signed int)pHealth < (signed int)&pParty->field_871C[567] ); if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 136) ) { pParty->vPosition.x = -17331; // respawn in harmondale
--- a/GameUIs.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/GameUIs.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -35,7 +35,6 @@ uDialogueType_ = uDialogueType; dword_6BE138 = -1; ++pIcons_LOD->uTexturePacksCount; - v16 = 0; if ( !pIcons_LOD->uNumPrevLoadedFiles ) pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; memset(pSavegameUsedSlots, 0, sizeof(pSavegameUsedSlots)); @@ -82,12 +81,8 @@ //v3 = 0; for (uint i = 0; i < uNumSavegameFiles; ++i) { - //Dest = pSavegameHeader; - //pTex = pSavegameThumbnails; - //Str1 = (const char *)pSavegameList->pSavesNames; - //while ( 1 ) - //{ - sprintf(pTmpBuf, "saves\\%s", pSavegameList->pSavesNames[i]); + + sprintf(pTmpBuf, "saves\\%s", pSavegameList->pFileList[i].pSaveFileName); if (_access(pTmpBuf, 6)) { pSavegameUsedSlots[i] = 0; @@ -98,13 +93,13 @@ v4 = pLODFile.FindContainer("header.bin", true); if ( v4 ) fread(&pSavegameHeader[i], 0x64, 1, v4); - if ( !_strcmpi(pSavegameList->pSavesNames[i], pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7" + if ( !_strcmpi(pSavegameList->pFileList[i].pSaveFileName, pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7" strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[16]);// "Autosave" v5 = pLODFile.FindContainer("image.pcx", true); if ( !v5 ) { pSavegameUsedSlots[i] = 0; - strcpy(pSavegameList->pSavesNames[i], ""); + strcpy(pSavegameList->pFileList[i].pSaveFileName, ""); } else { @@ -112,33 +107,20 @@ pLODFile.CloseWriteFile(); pSavegameUsedSlots[i] = 1; } -//LABEL_23: - //Str1 += 280; - //++pTex; - //++Dest; - //++v3; - //if ( v3 >= (signed int)uNumSavegameFiles ) - // goto LABEL_24; - //} - //goto LABEL_22; } //LABEL_24: pLODFile.FreeSubIndexAndIO(); if ( pCurrentScreen == SCREEN_SAVEGAME ) { - v6 = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); - v10 = (TEXTURE_TYPE)2; - v8 = "LS_saveD"; + uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); + uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD",TEXTURE_16BIT_PALETTE); } else { - v6 = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); - v10 = (TEXTURE_TYPE)2; - v8 = "LS_loadD"; + uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); + uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_loadD",TEXTURE_16BIT_PALETTE); } - uTextureID_x_d = v6; - uTextureID_LS_ = pIcons_LOD->LoadTexture(v8, v10); uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE); uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE); pGUIWindow_CurrentMenu->CreateButton(21, 198, 191, 18, 1, 0, 0xA5, 0, 0, "", 0); @@ -156,29 +138,20 @@ (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0), 0); pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 0x143, 0x11, 0x11, 1, 0, 0xA3, uNumSavegameFiles, 0, "", (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0), 0); - v16 = -1; - //ptr_69BD58 = v7; + } //----- (0045E93E) -------------------------------------------------------- -void __cdecl GameUI_DrawSaveMenu() +void GameUI_DrawSaveMenu() { unsigned int v0; // ebp@4 unsigned int v1; // eax@4 - unsigned int *v2; // ebp@6 char *v3; // eax@7 FILE *v4; // eax@11 FILE *v5; // eax@11 - const char *v6; // ST64_4@14 - GUIButton *v7; // eax@16 - char *v8; // [sp+10h] [bp-254h]@6 - SavegameHeader *Dest; // [sp+14h] [bp-250h]@6 - RGBTexture *this_; // [sp+18h] [bp-24Ch]@6 LODWriteableFile v11; // [sp+1Ch] [bp-248h]@1 - int v12; // [sp+260h] [bp-4h]@1 ++pIcons_LOD->uTexturePacksCount; - v12 = 0; if ( !pIcons_LOD->uNumPrevLoadedFiles ) pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; memset(pSavegameUsedSlots, 0, 0xB4u); @@ -189,9 +162,7 @@ uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE); uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE); uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE); - pRenderer->DrawTextureIndexed( - 8u, - 8u, + pRenderer->DrawTextureIndexed( 8u, 8u, (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); if ( pCurrentScreen == SCREEN_SAVEGAME ) { @@ -204,54 +175,48 @@ v1 = uTextureID_LS_loadU; } pRenderer->DrawTextureIndexed(0xF1u, 0x12Eu, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0)); - pRenderer->DrawTextureIndexed( - 0x15Fu, - 0x12Eu, + pRenderer->DrawTextureIndexed(0x15Fu, 0x12Eu, (Texture *)(uTextureID_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0)); pRenderer->DrawTextureIndexed(0x12u, 0x8Du, (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0)); pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0); pRenderer->Present(); pSavegameList->Initialize(1u); v11.AllocSubIndicesAndIO(0x12Cu, 0); - v2 = pSavegameUsedSlots; - Dest = pSavegameHeader; - this_ = pSavegameThumbnails; - v8 = (char *)pSavegameList->pSavesNames; - do - { - v3 = v8; - if ( !*v8 ) + //v2 = pSavegameUsedSlots; + // Dest = pSavegameHeader; + // this_ = pSavegameThumbnails; + // v8 = (char *)pSavegameList->pSavesNames; + for (uint i = 0; i < 40; ++i) + { + v3 = pSavegameList->pFileList[i].pSaveFileName; + if ( !pSavegameList->pFileList[i].pSaveFileName ) v3 = "1.mm7"; sprintf(pTmpBuf, "saves\\%s", v3); if ( _access(pTmpBuf, 0) || _access(pTmpBuf, 6) ) { - v6 = pGlobalTXT_LocalizationStrings[72]; - *v2 = 0; - strcpy(Dest->pName, v6); + pSavegameUsedSlots[i] = 0; + strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[LOCSTR_EMPTY]); } else { v11.LoadFile(pTmpBuf, 1); v4 = v11.FindContainer("header.bin", 1); - fread(Dest, 0x64u, 1u, v4); + fread(&pSavegameHeader[i], 100, 1u, v4); v5 = v11.FindContainer("image.pcx", 1); if ( v5 ) { - this_->LoadFromFILE(v5, 0, 1u); + pSavegameThumbnails[i].LoadFromFILE(v5, 0, 1u); v11.CloseWriteFile(); - *v2 = 1; + pSavegameUsedSlots[i] = 1; } else { - *v2 = 0; + pSavegameUsedSlots[i] = 0; } } - v8 += 280; - ++this_; - ++Dest; - ++v2; + } - while ( (signed int)v8 < (signed int)&_69FBB4_ptr_iterator_end ); + v11.FreeSubIndexAndIO(); uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD", TEXTURE_16BIT_PALETTE); @@ -273,5 +238,4 @@ (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0), 0); pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0x143u, 0x11u, 0x11u, 1, 0, 0xA3u, 0x22u, 0, "", (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0), 0); - v12 = -1; } \ No newline at end of file
--- a/Indoor.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/Indoor.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -1794,15 +1794,10 @@ const char *v1; // edi@1 signed int v2; // esi@1 - v1 = Str1; - v2 = 0; - while ( _strcmpi(v1, _4E6BDC_loc_names[v2]) ) - { - ++v2; - if ( v2 >= 11 ) - return 0; - } - return v2 + 1; + for (uint i = 0; i < 11; ++i) + if (!strcmpi(Str1, _4E6BDC_loc_names[i])) + return i + 1; + return 0; } @@ -2890,7 +2885,7 @@ { memcpy(v203, pData, 0x36B); LABEL_132: - free(File); + free(pRawDLV); dlv.uLastRepawnDay = a3; if (_v244) ++dlv.uNumRespawns; @@ -2901,7 +2896,7 @@ auto v155 = header.uCompressedSize; auto Count = header.uDecompressedSize; auto Src = (BLVFace *)malloc(header.uDecompressedSize); - File = (FILE *)Src; + pRawDLV = Src; if ( v155 <= Count ) { if ( v155 == Count ) @@ -3458,32 +3453,27 @@ } //----- (0044C23B) -------------------------------------------------------- -int BLVFaceExtra::HasEventint() -{ - signed int v1; // eax@1 - EventIndex *v2; // esi@2 - signed int result; // eax@5 - signed int v4; // eax@6 - - v1 = 0; - if ( (signed int)(uLevelEVT_NumEvents - 1) <= 0 ) - goto LABEL_5; - v2 = pLevelEVT_Index; - while ( v2->uEventID != this->uEventID ) +bool BLVFaceExtra::HasEventint() + { + signed int event_index; // eax@1 + _evt_raw* start_evt; + _evt_raw* end_evt; + + event_index = 0; + if ( (uLevelEVT_NumEvents - 1) <= 0 ) + return false; + while ( pLevelEVT_Index[event_index].uEventID != this->uEventID ) { - ++v1; - ++v2; - if ( v1 >= (signed int)(uLevelEVT_NumEvents - 1) ) - goto LABEL_5; + ++event_index; + if ( event_index >= (signed int)(uLevelEVT_NumEvents - 1) ) + return false; } - v4 = v1; - if ( pLevelEVT[pLevelEVT_Index[v4 + 1].uEventOffsetInEVT + 4] != 1 - || pLevelEVT[pLevelEVT_Index[v4].uEventOffsetInEVT + 4] != 4 ) -LABEL_5: - result = 0; + end_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index+1].uEventOffsetInEVT]; + start_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index].uEventOffsetInEVT]; + if ( (end_evt->_e_type != EVENT_Exit) || (start_evt->_e_type!= EVENT_MouseOver) ) + return false; else - result = 1; - return result; + return true; } @@ -4148,7 +4138,7 @@ { do { - v54 = ai_array_4F7DB0_actor_ids[v25]; + v54 = ai_near_actors_ids[v25]; if ( v54 != v63 ) { v26 = v54; @@ -4345,7 +4335,7 @@ goto LABEL_119; } } - Actor::_403F58(v63, 4, v22, &v53); + Actor::AI_StandOrBored(v63, 4, v22, &v53); goto LABEL_119; } if ( v0->vPosition.x & 1 ) @@ -4359,7 +4349,7 @@ goto LABEL_123; if ( !v0->pMonsterInfo.uHostilityType || v56 != v22 ) { - Actor::_403F58(v63, 4, v22, &v52); + Actor::AI_StandOrBored(v63, 4, v22, &v52); goto LABEL_123; } } @@ -4616,7 +4606,7 @@ if ( !(pDecortaion->field_2 & 0x20) ) { v17 = &pDecorationList->pDecorations[pDecortaion->uDecorationDescID]; - if ( !((unsigned __int8)2 & v17->uFlags) ) + if (!v17->DontDraw()) { v18 = v17->uLightRadius; if ( v18 ) @@ -4670,8 +4660,8 @@ if (uItemID) { if (uItemID != 220 && pItemsTable->pItems[uItemID].uEquipType == EQUIP_POTION && - !p->stru_24._bonus_type) - p->stru_24._bonus_type = rand() % 15 + 5; + !p->stru_24.uEncantmentType) + p->stru_24.uEncantmentType = rand() % 15 + 5; pItemsTable->SetSpecialBonus(&p->stru_24); } }
--- a/Indoor.h Mon Feb 25 09:08:13 2013 +0600 +++ b/Indoor.h Mon Feb 25 09:09:08 2013 +0600 @@ -316,7 +316,7 @@ #pragma pack(push, 1) struct BLVFaceExtra { - int HasEventint(); +bool HasEventint(); __int16 field_0; __int16 field_2;
--- a/Items.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/Items.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -26,170 +26,111 @@ //----- (00439DF3) -------------------------------------------------------- -int ItemGen::_439DF3_get_additional_damage(int *a2, int *a3) -{ - int *v3; // edi@1 - ItemGen *v4; // ebx@1 - signed int v5; // esi@1 - unsigned int v7; // ecx@5 - signed int v8; // ebx@7 - int v9; // edx@22 - int v10; // eax@24 - int v11; // edx@25 - int v12; // ebx@28 - int v13; // ebx@29 - int v14; // ebx@30 - int v15; // ebx@31 - int v16; // ebx@32 - signed int v17; // [sp-4h] [bp-10h]@24 +int ItemGen::_439DF3_get_additional_damage(int *damage_type, bool *draintargetHP) + { + *damage_type = 0; + if ( !uItemID ) + return 0; + UpdateTempBonus(pParty->uTimePlayed); + if (uItemID == 501 ) //Iron Feather -sword + { + *damage_type = 1; + return rand() % 10 + 6; + } + if (uItemID == 507 ) //Ghoulsbane -axe + { + *damage_type = 0; + return rand() % 16 + 3; + } + if ( uItemID == 510 ) //Ullyses -bow + { + *damage_type = 2; + return rand() % 4 + 9; + } + if ( uItemID == 517 ) //Old Nick -dagger + { + *damage_type = 8; + return 8; + } - auto a1 = this; - v3 = a2; - v4 = a1; - v5 = 0; - *a2 = 0; - if ( !a1->uItemID ) - return 0; - UpdateTempBonus(pParty->uTimePlayed); - if ( v4->uItemID == 501 ) - { - *v3 = 1; - v10 = rand(); - v17 = 10; - return v10 % v17 + 6; - } - if ( v4->uItemID == 507 ) - { - *v3 = 0; - v11 = rand() % 16; - return v11 + 3; - } - v7 = 3; - if ( v4->uItemID == 510 ) - { - *v3 = 2; - v9 = rand() % 4; - return v9 + 9; - } - if ( v4->uItemID == 517 ) - { - v5 = 8; - *v3 = v5; - return v5; - } - v8 = v4->uAdditionalValue; - if ( v8 > 46 ) - { - v5 = 0; - *v3 = v5; - return v5; - } - if ( v8 == 46 ) - { - *v3 = 0; - return rand() % 11 + 10; - } - if ( v8 > 11 ) - { - v12 = v8 - 12; - if ( !v12 ) - { - *v3 = 0; - return GetDiceResult(v7, 6u); - } - v13 = v12 - 1; - if ( !v13 ) - { - *v3 = 8; - return 5; - } - v14 = v13 - 1; - if ( v14 ) - { - v15 = v14 - 1; - if ( v15 ) - { - v16 = v15 - 1; - if ( !v16 || v16 == 25 ) - { - *v3 = 10; - *a3 = 1; - return v5; - } - v5 = 0; - *v3 = v5; - return v5; - } - *v3 = 2; - return 12; - } - v5 = 8; - *v3 = v5; - return v5; - } - if ( v8 == 11 ) - { - *v3 = 0; - v7 = 2; - return GetDiceResult(v7, 6u); - } - if ( v8 == 4 ) - { - *v3 = 2; - v11 = rand() % 2; - return v11 + 3; - } - if ( v8 == 5 ) - { - *v3 = 2; - v10 = rand(); - v17 = 3; - return v10 % v17 + 6; - } - if ( v8 == 6 ) - { - *v3 = 2; - v9 = rand() % 4; - return v9 + 9; - } - if ( v8 == 7 ) - { - *v3 = 1; - return rand() % 4 + 2; - } - if ( v8 == 8 ) - { - *v3 = 1; - return rand() % 7 + 4; - } - if ( v8 == 9 ) - { - *v3 = 1; - v10 = rand(); - v17 = 10; - return v10 % v17 + 6; - } - if ( v8 != 10 ) - { - v5 = 0; - *v3 = v5; - return v5; - } - *v3 = 0; - v7 = 1; - return GetDiceResult(v7, 6u); -} + switch (uSpecEnchantmentType) + { + case 4: //Adds 3-4 points of Cold damage. + *damage_type = 2; + return rand() % 2 + 3; + break; + case 5: //Adds 6-8 points of Cold damage. + *damage_type = 2; + return rand() % 3 + 6; + break; + case 6: //Adds 9-12 points of Cold damage. + *damage_type = 2; + return rand() % 4 + 9; + break; + case 7: //Adds 2-5 points of Electrical damage. + *damage_type = 1; + return rand() % 4 + 2; + break; + case 8: //Adds 4-10 points of Electrical damage. + *damage_type = 1; + return rand() % 7 + 4; + break; + case 9: //Adds 6-15 points of Electrical damage. + *damage_type = 1; + return rand() % 10 + 6; + break; + case 10: //Adds 1-6 points of Fire damage. + *damage_type = 0; + return GetDiceResult(1, 6); + break; + case 11: //Adds 2-12 points of Fire damage. + *damage_type = 0; + return GetDiceResult(2, 6); + break; + case 12: //Adds 3-18 points of Fire damage. + *damage_type = 0; + return GetDiceResult(3, 6); + break; + case 13: //Adds 5 points of Body damage. + *damage_type = 8; + return 5; + break; + case 14: //Adds 8 points of Body damage. + *damage_type = 8; + return 8; + break; + case 15: //Adds 12 points of Body damage. + *damage_type = 8; + return 12; + break; + case 16: //Drain Hit Points from target. + case 41: //Drain Hit Points from target and Increased Weapon speed. + *damage_type = 10; + *draintargetHP = true; + return 0; + break; + case 46: //Adds 10-20 points of Fire damage and +25 Might. + *damage_type = 0; + return rand() % 11 + 10; + break; + default: + *damage_type = 0; + return 0; + + } + + } //----- (00402F07) -------------------------------------------------------- void ItemGen::Reset() { - this->field_1A = 0; + this->uHolderPlayer = 0; this->uAttributes = 0; this->uNumCharges = 0; - this->uAdditionalValue = 0; + this->uSpecEnchantmentType = 0; this->_bonus_strength = 0; - this->_bonus_type = 0; + this->uEncantmentType = 0; this->uItemID = 0; this->uBodyAnchor = 0; this->uExpireTime = 0i64; @@ -205,35 +146,31 @@ { if ( uTimePlayed > (signed __int64)this->uExpireTime ) { - this->_bonus_type = 0; + this->uEncantmentType = 0; LOBYTE(v2) = v2 & 0xF7; - this->uAdditionalValue = 0; + this->uSpecEnchantmentType = 0; this->uAttributes = v2; } } } //----- (0045814E) -------------------------------------------------------- -char *ItemsTable::Release() +void ItemsTable::Release() { - ItemsTable *v1; // edi@1 - char *result; // eax@23 - - v1 = this; if ( pMonstersTXT_Raw ) pAllocator->FreeChunk(pMonstersTXT_Raw); if ( pMonsterPlacementTXT_Raw ) pAllocator->FreeChunk(pMonsterPlacementTXT_Raw); if ( pSkillDescTXT_Raw ) pAllocator->FreeChunk(pSkillDescTXT_Raw); - if ( v1->pSpcItemsTXT_Raw ) - pAllocator->FreeChunk(v1->pSpcItemsTXT_Raw); - if ( v1->pStdItemsTXT_Raw ) - pAllocator->FreeChunk(v1->pStdItemsTXT_Raw); - if ( v1->pRndItemsTXT_Raw ) - pAllocator->FreeChunk(v1->pRndItemsTXT_Raw); - if ( v1->pItemsTXT_Raw ) - pAllocator->FreeChunk(v1->pItemsTXT_Raw); + if (pSpcItemsTXT_Raw ) + pAllocator->FreeChunk(pSpcItemsTXT_Raw); + if ( pStdItemsTXT_Raw ) + pAllocator->FreeChunk(pStdItemsTXT_Raw); + if ( pRndItemsTXT_Raw ) + pAllocator->FreeChunk(pRndItemsTXT_Raw); + if ( pItemsTXT_Raw ) + pAllocator->FreeChunk(pItemsTXT_Raw); if ( pHostileTXT_Raw ) pAllocator->FreeChunk(pHostileTXT_Raw); if ( pHistoryTXT_Raw ) @@ -242,13 +179,12 @@ pAllocator->FreeChunk(pPotionsTXT_Raw); if ( pPotionNotesTXT_Raw ) pAllocator->FreeChunk(pPotionNotesTXT_Raw); - v1->pSpcItemsTXT_Raw = 0; - pSkillDescTXT_Raw = 0; - v1->pStdItemsTXT_Raw = 0; - v1->pRndItemsTXT_Raw = pSkillDescTXT_Raw; - result = pSkillDescTXT_Raw; - v1->pItemsTXT_Raw = pSkillDescTXT_Raw; - return result; + pSpcItemsTXT_Raw = NULL; + pSkillDescTXT_Raw = NULL; + pStdItemsTXT_Raw = NULL; + pRndItemsTXT_Raw = NULL; + pItemsTXT_Raw = NULL; + } @@ -444,8 +380,6 @@ pSpecialEnchantmentsSumm[i]+=pSpecialEnchantments[j].to_item_apply[i]; } - - Initialize2DA(); pItemsTXT_Raw = NULL; @@ -573,7 +507,7 @@ } if ( !_strcmpi(test_string, "sscroll") ) { - pItems[item_counter].uEquipType = 15; + pItems[item_counter].uEquipType = EQUIP_SPELL_SCROLL; break; } if ( !_strcmpi(test_string, "book") ) @@ -583,7 +517,7 @@ } if ( !_strcmpi(test_string, "mscroll") ) { - pItems[item_counter].uEquipType = 17; + pItems[item_counter].uEquipType = EQUIP_MESSAGE_SCROLL; break; } if ( !_strcmpi(test_string, "gold") ) @@ -603,70 +537,70 @@ { if ( !_strcmpi(test_string, "staff") ) { - pItems[item_counter].uSkillType = 0; + pItems[item_counter].uSkillType = PLAYER_SKILL_STAFF; break; } if ( !_strcmpi(test_string, "sword") ) { - pItems[item_counter].uSkillType = 1; + pItems[item_counter].uSkillType = PLAYER_SKILL_SWORD; break; } if ( !_strcmpi(test_string, "dagger") ) { - pItems[item_counter].uSkillType = 2; + pItems[item_counter].uSkillType = PLAYER_SKILL_DAGGER; break; } if ( !_strcmpi(test_string, "axe") ) { - pItems[item_counter].uSkillType = 3; + pItems[item_counter].uSkillType = PLAYER_SKILL_AXE; break; } if ( !_strcmpi(test_string, "spear") ) { - pItems[item_counter].uSkillType = 4; + pItems[item_counter].uSkillType = PLAYER_SKILL_SPEAR; break; } if ( !_strcmpi(test_string, "bow") ) { - pItems[item_counter].uSkillType = 5; + pItems[item_counter].uSkillType = PLAYER_SKILL_BOW; break; } if ( !_strcmpi(test_string, "mace") ) { - pItems[item_counter].uSkillType = 6; + pItems[item_counter].uSkillType = PLAYER_SKILL_MACE; break; } if ( !_strcmpi(test_string, "blaster") ) { - pItems[item_counter].uSkillType = 7; + pItems[item_counter].uSkillType = PLAYER_SKILL_BLASTER; break; } if ( !_strcmpi(test_string, "shield") ) { - pItems[item_counter].uSkillType = 8; + pItems[item_counter].uSkillType = PLAYER_SKILL_SHIELD; break; } if ( !_strcmpi(test_string, "leather") ) { - pItems[item_counter].uSkillType = 9; + pItems[item_counter].uSkillType = PLAYER_SKILL_LEATHER; break; } if ( !_strcmpi(test_string, "chain") ) { - pItems[item_counter].uSkillType = 10; + pItems[item_counter].uSkillType = PLAYER_SKILL_CHAIN; break; } if ( !_strcmpi(test_string, "plate") ) { - pItems[item_counter].uSkillType = 11; + pItems[item_counter].uSkillType = PLAYER_SKILL_PLATE; break; } if ( !_strcmpi(test_string, "club") ) { - pItems[item_counter].uSkillType = 37; + pItems[item_counter].uSkillType = PLAYER_SKILL_CLUB; break; } - pItems[item_counter].uSkillType = 38; + pItems[item_counter].uSkillType = PLAYER_SKILL_MISC; break; } case 6: //Mod1 @@ -705,20 +639,20 @@ { if ( !_strcmpi(test_string, "artifact") ) { - pItems[item_counter].uMaterial = 1; + pItems[item_counter].uMaterial = MATERIAL_ARTEFACT; break; } if ( !_strcmpi(test_string, "relic") ) { - pItems[item_counter].uMaterial = 2; + pItems[item_counter].uMaterial = MATERIAL_RELIC; break; } if ( !_strcmpi(test_string, "special") ) { - pItems[item_counter].uMaterial = 3; + pItems[item_counter].uMaterial = MATERIAL_SPECIAL; break; } - pItems[item_counter].uMaterial = 0; + pItems[item_counter].uMaterial = MATERIAL_COMMON; break;} case 9: //ID/Rep/St pItems[item_counter].uItemID_Rep_St=atoi(test_string); @@ -733,7 +667,7 @@ { pItems[item_counter]._additional_value=0; pItems[item_counter]._bonus_type=0; - if (pItems[item_counter].uMaterial==3) + if (pItems[item_counter].uMaterial==MATERIAL_SPECIAL) { for(int ii=0; ii<24; ++ii) { @@ -758,7 +692,7 @@ break; } case 13: //VarB - if ((pItems[item_counter].uMaterial==3)&&(pItems[item_counter]._bonus_type)) + if ((pItems[item_counter].uMaterial==MATERIAL_SPECIAL)&&(pItems[item_counter]._bonus_type)) { char b_s=atoi(test_string); if (b_s) @@ -1194,30 +1128,26 @@ //----- (00456D17) -------------------------------------------------------- void ItemsTable::SetSpecialBonus(ItemGen *pItem) { - ItemDesc *v2; // eax@1 - - v2 = &this->pItems[pItem->uItemID]; - if ( v2->uMaterial == 3 ) + if ( pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL ) { - pItem->_bonus_type = v2->_bonus_type; - pItem->uAdditionalValue = v2->_additional_value; - pItem->_bonus_strength = v2->_bonus_strength; + pItem->uEncantmentType = pItems[pItem->uItemID]._bonus_type; + pItem->uSpecEnchantmentType = pItems[pItem->uItemID]._additional_value; + pItem->_bonus_strength = pItems[pItem->uItemID]._bonus_strength; } } //----- (00456D43) -------------------------------------------------------- -bool ItemsTable::_456D43_is_material_equals_3(ItemGen *pItem) +bool ItemsTable::IsMaterialSpecial(ItemGen *pItem) { - return this->pItems[pItem->uItemID].uMaterial == 3; + return this->pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL; } //----- (00456D5E) -------------------------------------------------------- -bool ItemsTable::_456D5E_is_some_material(ItemGen *pItem) +bool ItemsTable::IsMaterialNonCommon(ItemGen *pItem) { - unsigned __int8 v2; // al@1 - - v2 = this->pItems[pItem->uItemID].uMaterial; - return v2 == 3 || v2 == 1 || v2 == 2; + return pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL || + pItems[pItem->uItemID].uMaterial == MATERIAL_RELIC || + pItems[pItem->uItemID].uMaterial == MATERIAL_ARTEFACT; } @@ -1392,14 +1322,14 @@ v1 = this; uBaseValue = pItemsTable->pItems[this->uItemID].uValue; - if ( this->uAttributes & ITEM_TEMP_BONUS || pItemsTable->_456D5E_is_some_material(this) ) + if ( this->uAttributes & ITEM_TEMP_BONUS || pItemsTable->IsMaterialNonCommon(this) ) return uBaseValue; - if ( v1->_bonus_type ) + if ( v1->uEncantmentType ) { v3 = 100 * v1->_bonus_strength; return uBaseValue + v3; } - v4 = v1->uAdditionalValue; + v4 = v1->uSpecEnchantmentType; if ( !v4 ) { result = uBaseValue; @@ -1426,94 +1356,74 @@ //----- (004564B3) -------------------------------------------------------- const char *ItemGen::GetIdentifiedName() { - ItemGen *v1; // esi@1 - unsigned int v2; // eax@1 - unsigned __int8 v3; // cl@1 - char *v4; // edi@4 - char v5; // al@6 - const char *v6; // esi@8 - int v7; // eax@15 - const char *v9; // [sp-Ch] [bp-14h]@14 - const char *v10; // [sp-8h] [bp-10h]@4 - char *v11; // [sp-4h] [bp-Ch]@4 + unsigned __int8 equip_type; + const char *player_name; + const char *nameModificator; + const char *format_str; - v1 = this; - v2 = this->uItemID; - v3 = pItemsTable->pItems[v2].uEquipType; - if ( v3 >= EQUIP_REAGENT && (v3 <= EQUIP_POTION || v3 == EQUIP_GOLD) ) + equip_type = pItemsTable->pItems[uItemID].uEquipType; + if ( (equip_type == EQUIP_REAGENT) || (equip_type == EQUIP_POTION) || (equip_type == EQUIP_GOLD) ) { - v11 = pItemsTable->pItems[v2].pName; - v4 = item__getname_buffer; - v10 = "%s"; - sprintf(v4, v10, v11); - return v4; + sprintf(item__getname_buffer, "%s", pItemsTable->pItems[uItemID].pName); + return item__getname_buffer; } - v4 = item__getname_buffer; - sprintf(item__getname_buffer, "%s", pItemsTable->pItems[v2].pName); - if ( v1->uItemID == 601 ) + sprintf(item__getname_buffer, "%s", pItemsTable->pItems[uItemID].pName); + if ( uItemID == ITEM_LICH_JAR ) //Lich Jar { - v5 = v1->field_1A; - if ( (unsigned __int8)v5 >= 1u ) - { - if ( (unsigned __int8)v5 <= 4u ) + if ( (uHolderPlayer >0 )&& (uHolderPlayer <= 4) ) { - v6 = pPlayers[(unsigned __int8)v5]->pName; - strlen(pPlayers[(unsigned __int8)v5]->pName); - v11 = (char *)v6; - if ( v6[strlen(v6) - 1] == 115 ) - v10 = pGlobalTXT_LocalizationStrings[655]; + player_name = pPlayers[uHolderPlayer]->pName; + strlen(player_name); + if ( player_name[strlen(player_name) - 1] == 's' ) + format_str = pGlobalTXT_LocalizationStrings[655]; //"%s' Jar" else - v10 = pGlobalTXT_LocalizationStrings[654]; - sprintf(v4, v10, v11); - return v4; + format_str = pGlobalTXT_LocalizationStrings[654]; //"%s's Jar" + sprintf(item__getname_buffer, format_str, pPlayers[uHolderPlayer]->pName); + return item__getname_buffer; } - } } - if ( !pItemsTable->_456D5E_is_some_material(v1) ) + if ( !pItemsTable->IsMaterialNonCommon(this) ) { - if ( v1->_bonus_type ) + if ( uEncantmentType ) { strcat(item__getname_buffer, " "); - v9 = (const char *)*((unsigned int *)&pItemsTable->pItems[799].uEquipType + 5 * v1->_bonus_type); + nameModificator = pItemsTable->pEnchantments[uEncantmentType-1].pOfName; } else { - v7 = v1->uAdditionalValue; - if ( !v7 ) - return v4; - if ( v7 == 16 - || v7 == 39 - || v7 == 40 - || v7 == 45 - || v7 == 56 - || v7 == 57 - || v7 == 58 - || v7 == 60 - || v7 == 61 - || v7 == 59 - || v7 == 63 - || v7 == 64 - || v7 == 67 - || v7 == 68 ) - { - sprintf( - item__getname_buffer, - "%s %s", - pItemsTable->pSpecialEnchantments[v7].pBonusStatement, - pItemsTable->pItems[v1->uItemID].pName); - return v4; + if ( !uSpecEnchantmentType ) + return item__getname_buffer; + if ( uSpecEnchantmentType == 16 //Drain Hit Points from target. + || uSpecEnchantmentType == 39 //Double damage vs Demons. + || uSpecEnchantmentType == 40 //Double damage vs Dragons + || uSpecEnchantmentType == 45 //+5 Speed and Accuracy + || uSpecEnchantmentType == 56 //+5 Might and Endurance. + || uSpecEnchantmentType == 57 //+5 Intellect and Personality. + || uSpecEnchantmentType == 58 //Increased Value. + || uSpecEnchantmentType == 60 //+3 Unarmed and Dodging skills + || uSpecEnchantmentType == 61 //+3 Stealing and Disarm skills. + || uSpecEnchantmentType == 59 //Increased Weapon speed. + || uSpecEnchantmentType == 63 //Double Damage vs. Elves. + || uSpecEnchantmentType == 64 //Double Damage vs. Undead. + || uSpecEnchantmentType == 67 //Adds 5 points of Body damage and +2 Disarm skill. + || uSpecEnchantmentType == 68 ) //Adds 6-8 points of Cold damage and +5 Armor Class. + { //enchantment and name positions inverted! + sprintf( item__getname_buffer, "%s %s", + pItemsTable->pSpecialEnchantments[uSpecEnchantmentType-1].pNameAdd, + pItemsTable->pItems[uItemID].pName); + return item__getname_buffer; } strcat(item__getname_buffer, " "); - v9 = pItemsTable->pSpecialEnchantments[v1->uAdditionalValue].pBonusStatement; + nameModificator = pItemsTable->pSpecialEnchantments[uSpecEnchantmentType-1].pNameAdd; } - strcat(item__getname_buffer, v9); + strcat(item__getname_buffer, nameModificator); } - return v4; + return item__getname_buffer; } //----- (00456620) -------------------------------------------------------- -void ItemsTable::GenerateItem(int treasure_level, int a3, ItemGen *out_item) +void ItemsTable::GenerateItem(int treasure_level, unsigned int uTreasureType, ItemGen *out_item) { ItemGen *v4; // esi@1 @@ -1584,23 +1494,23 @@ v4 = out_item; v6 = treasure_level - 1; - //v54 = treasure_level - 1; - if ( a3 ) + v54 = treasure_level - 1; + if ( uTreasureType ) //generate known treasure type { ITEM_EQUIP_TYPE requested_equip; PLAYER_SKILL_TYPE requested_skill = PLAYER_SKILL_INVALID; - switch (a3) + switch (uTreasureType) { case 20: requested_equip = EQUIP_ONE_OR_TWO_HANDS; break; case 21: requested_equip = EQUIP_ARMOUR; break; - case 22: requested_skill = (PLAYER_SKILL_TYPE)38; __debugbreak();/*check this skill*/ break; + case 22: requested_skill = PLAYER_SKILL_MISC; break; case 23: requested_skill = PLAYER_SKILL_SWORD; break; case 24: requested_skill = PLAYER_SKILL_DAGGER; break; case 25: requested_skill = PLAYER_SKILL_AXE; break; case 26: requested_skill = PLAYER_SKILL_SPEAR; break; case 27: requested_skill = PLAYER_SKILL_BOW; break; case 28: requested_skill = PLAYER_SKILL_MACE; break; - case 29: requested_skill = (PLAYER_SKILL_TYPE)37; __debugbreak();/*check this skill*/break; + case 29: requested_skill = PLAYER_SKILL_CLUB; break; case 30: requested_skill = PLAYER_SKILL_STAFF; break; case 31: requested_skill = PLAYER_SKILL_LEATHER; break; case 32: requested_skill = PLAYER_SKILL_CHAIN; break; @@ -1614,20 +1524,20 @@ case 40: requested_equip = EQUIP_RING; break; case 41: requested_equip = EQUIP_AMULET; break; case 42: requested_equip = EQUIP_WAND; break; - case 43: requested_equip = EQUIP_F; break; + case 43: requested_equip = EQUIP_SPELL_SCROLL; break; case 44: requested_equip = EQUIP_POTION; break; case 45: requested_equip = EQUIP_REAGENT; break; case 46: requested_equip = EQUIP_GEM; break; default: __debugbreak(); // check this condition - requested_equip = (ITEM_EQUIP_TYPE)(a3 - 1); + requested_equip = (ITEM_EQUIP_TYPE)(uTreasureType - 1); break; } memset(Dst, 0, sizeof(Dst)); v52 = 0; v7 = Dst; //a2a = 1; - if (requested_skill == PLAYER_SKILL_INVALID) + if (requested_skill == PLAYER_SKILL_INVALID) // no skill for this item needed { for (uint i = 1; i < 500; ++i) { @@ -1638,7 +1548,7 @@ } } } - else + else //have needed skill { for (uint i = 1; i < 500; ++i) { @@ -1654,11 +1564,11 @@ if ( v52 ) v10 = rand() % v52; - v4->uItemID = *Dst; - if (!v4->uItemID) - v4->uItemID = 1; + out_item->uItemID = *Dst; + if (!out_item->uItemID) + out_item->uItemID = 1; - v11 = pItems[v4->uItemID].uChanceByTreasureLvl[v6]; + v11 = pItems[out_item->uItemID].uChanceByTreasureLvl[v6]; if ( v11 < v10 ) { v12 = (uint *)Dst; @@ -1666,23 +1576,18 @@ { ++v12; v13 = *v12; - v4->uItemID = *v12; + out_item->uItemID = *v12; v11 += pItems[v13].uChanceByTreasureLvl[v6]; } while ( v11 < v10 ); } - if (pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE ) - { - v4->_bonus_type = 0; - v14 = 2; - do - { - v4->_bonus_type += rand() % 4 + 1; - v15 = v4->_bonus_type; - --v14; - } - while ( v14 ); - v4->_bonus_type = v15 * treasure_level; + + if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE ) + {// if it potion set potion spec + out_item->uEncantmentType = 0; + for (int i=0; i<2; ++i) + out_item->uEncantmentType += rand() % 4 + 1; + out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; } } else @@ -1693,40 +1598,38 @@ v56 += pParty->field_7BA[v16++]; while ( v16 < 29 ); v17 = rand() % 29; + if ( v6 == 5 && rand() % 100 < 5 && !pParty->field_7BA[v17] && v56 < 13 ) { pParty->field_7BA[v17] = 1; - v4->uAttributes = 0; - v4->uItemID = v17 + 500; - SetSpecialBonus(v4); + out_item->uAttributes = 0; + out_item->uItemID = v17 + 500; + SetSpecialBonus(out_item); return; } + v57 = 0; v18 = rand() % v5->uChanceByTreasureLvlSumm[v54];// v5->field_11684[v54]; - v4->uItemID = 0; + out_item->uItemID = 0; if ( v18 > 0 ) { do - v57 += pItems[v4->uItemID++ + 1].uChanceByTreasureLvl[v6]; + v57 += pItems[out_item->uItemID++ + 1].uChanceByTreasureLvl[v6]; while ( v57 < v18 ); } + if ( !v18 ) - v4->uItemID = 1; - if ( !v4->uItemID ) - v4->uItemID = 1; - if (pItems[v4->uItemID].uEquipType == EQUIP_POTION && v4->uItemID != ITEM_POTION_BOTTLE) - { - v4->_bonus_type = 0; - v19 = 2; - do - { - v4->_bonus_type += rand() % 4 + 1; - v15 = v4->_bonus_type; - --v19; - } - while ( v19 ); - v4->_bonus_type = v15 * treasure_level; - } + out_item->uItemID = 1; + if ( !out_item->uItemID ) + out_item->uItemID = 1; + if (pItems[out_item->uItemID].uEquipType == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE ) + {// if it potion set potion spec + out_item->uEncantmentType = 0; + for (int i=0; i<2; ++i) + out_item->uEncantmentType += rand() % 4 + 1; + out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; + } + out_item->uEncantmentType = out_item->uEncantmentType * treasure_level; } if ( v4->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION && !(unsigned __int16)_449B57_test_bit(pParty->_award_bits, 239) ) @@ -1735,20 +1638,20 @@ v4->uAttributes = 0; else v4->uAttributes = 1; - if ( pItems[v4->uItemID].uEquipType != EQUIP_POTION ) + if ( pItems[out_item->uItemID].uEquipType != EQUIP_POTION ) { - v4->uAdditionalValue = 0; - v4->_bonus_type = 0; + out_item->uSpecEnchantmentType = 0; + out_item->uEncantmentType = 0; } - v20 = pItems[v4->uItemID].uEquipType; + v20 = pItems[out_item->uItemID].uEquipType; if ( v20 <= EQUIP_BOW ) { v37 = v5->uBonusChanceWpSpecial[v54]; - if ( !*(unsigned int *)v37 ) + if ( !v37 ) return; v38 = rand() % 100; - v36 = __OFSUB__(v38, *(unsigned int *)v37); - v35 = v38 - *(unsigned int *)v37 < 0; + v36 = __OFSUB__(v38, v37); + v35 = v38 - v37 < 0; } else { @@ -1757,35 +1660,34 @@ if ( v20 == EQUIP_WAND ) { v21 = rand() % 6 + pItemsTable->pItems[v4->uItemID].uDamageMod + 1; - v4->uNumCharges = v21; - v4->uMaxCharges = v21; + out_item->uNumCharges = v21; + out_item->uMaxCharges = v21; } return; } - v22 = (int)&uBonusChanceStandart[v6]; - if ( !*(unsigned int *)v22 ) + v22 = uBonusChanceStandart[v6]; + if ( !v22 ) return; - v23 = rand(); - v24 = *(unsigned int *)v22; - v25 = v23 % 100; - if ( !uBonusChanceSpecial[v6] && !(v23 % 100 < v24)) + v24 = v22; + v25 = rand() % 100; + if ( !uBonusChanceSpecial[v6] && !(v25 < v24)) return; - if ( v25 < v24 || v23 % 100 < v24) + if ( v25 < v24 || v25 < v24) { - v26 = rand() % 10;//v5->field_116D8[v5->pItems[v4->uItemID].uEquipType]; + v26 = rand() % v5->uBonusChanceWpSpecial[v5->pItems[v4->uItemID].uEquipType + 3]; v27 = v4->uItemID; - v4->_bonus_type = 0; + v4->uEncantmentType = 0; for ( i = pEnchantments[0].to_item[pItems[v27].uEquipType + 1]; i < v26; - i += pEnchantments[v4->_bonus_type].to_item[pItems[v29].uEquipType + 1] ) + i += pEnchantments[v4->uEncantmentType].to_item[pItems[v29].uEquipType + 1] ) { v29 = v4->uItemID; - ++v4->_bonus_type; + ++v4->uEncantmentType; } - ++v4->_bonus_type; + ++v4->uEncantmentType; v30 = 10;// v5->field_116D8[2 * v54 + 12]; v31 = rand(); - v32 = v4->_bonus_type - 1; + v32 = v4->uEncantmentType - 1; v33 = v31 % 10;//(v5->field_116D8[2 * v54 + 13] - v30 + 1) + v30; v4->_bonus_strength = v33; if ( v32 == 21 || v32 == 22 || v32 == 23 ) @@ -1889,7 +1791,7 @@ while ( a2b < pSpecialEnchantments_count ); } v45 = rand(); - v4->uAdditionalValue = *(uint *)Dst; + v4->uSpecEnchantmentType = *(uint *)Dst; v46 = v45 % v39 + 1; a2c = *((unsigned char *)&uAllItemsCount + 28 * (*(uint *)Dst + 1389) + pItems[v4->uItemID].uEquipType); if ( a2c < v46 ) @@ -1900,13 +1802,13 @@ v49 = (int)(j + 1); v59 = v49; v50 = *(unsigned int *)v49; - v4->uAdditionalValue = v50; + v4->uSpecEnchantmentType = v50; a2c += *((unsigned char *)&uAllItemsCount + 28 * (v50 + 1389) + pItems[v48].uEquipType); if ( a2c >= v46 ) break; } } - ++v4->uAdditionalValue; + ++v4->uSpecEnchantmentType; } //----- (004505CC) -------------------------------------------------------- @@ -1916,32 +1818,27 @@ signed int uNumArtifactsNotFound; // esi@1 int v3; // eax@1 bool result; // eax@6 - int v5[32]; // [sp+8h] [bp-A0h]@3 + int artifacts_list[32]; // [sp+8h] [bp-A0h]@3 char Dst[32]; // [sp+88h] [bp-20h]@1 auto a2 = this; v1 = a2; - memset(Dst, 0, 0x20u); + memset(artifacts_list, 0,sizeof(artifacts_list)); uNumArtifactsNotFound = 0; - v3 = 500; - do - { - if ( !pParty->field_3C.pIsArtifactFound[v3] ) - v5[uNumArtifactsNotFound++] = v3; - ++v3; - } - while ( v3 < 529 ); - v1->Reset(); + + for (int i=500;i<529;++i) + if ( !pParty->field_3C.pIsArtifactFound[i] ) + artifacts_list[uNumArtifactsNotFound++] = i; + + Reset(); if ( uNumArtifactsNotFound ) { - v1->uItemID = v5[rand() % uNumArtifactsNotFound]; - pItemsTable->SetSpecialBonus(v1); - result = 1; + uItemID = artifacts_list[rand() % uNumArtifactsNotFound]; + pItemsTable->SetSpecialBonus(this); + return true; } else - { - result = 0; - } - return result; + return false; + } // 4505CC: using guessed type int var_A0[32]; \ No newline at end of file
--- a/Items.h Mon Feb 25 09:08:13 2013 +0600 +++ b/Items.h Mon Feb 25 09:09:08 2013 +0600 @@ -16,6 +16,14 @@ }; +enum ITEM_MATERIAL +{ + MATERIAL_COMMON =0, + MATERIAL_ARTEFACT = 1, + MATERIAL_RELIC = 2, + MATERIAL_SPECIAL = 3 +}; + /* 330 */ enum ITEM_TYPE { @@ -58,6 +66,7 @@ ITEM_ARTIFACT_PUCK = 0x1F4, ITEM_ARTIFACT_SPLITTER = 506,//1FA ITEM_RELIC_MEKORIGS_HAMMER = 0x210, + ITEM_LICH_JAR = 601 }; /* 331 */ @@ -71,19 +80,19 @@ EQUIP_HELMET = 5, EQUIP_BELT = 6, EQUIP_CLOAK = 7, - EQUIP_GAUNTLETS = 0x8, - EQUIP_BOOTS = 0x9, - EQUIP_RING = 10, - EQUIP_AMULET = 11, - EQUIP_WAND = 12, - EQUIP_REAGENT = 13, - EQUIP_POTION = 14, - EQUIP_F = 0xF, - EQUIP_BOOK = 16, - EQUIP_11 = 17, - EQUIP_GOLD = 18, - EQUIP_GEM = 19, - EQUIP_NONE = 20 + EQUIP_GAUNTLETS = 8, + EQUIP_BOOTS = 9, + EQUIP_RING = 10, + EQUIP_AMULET = 11, + EQUIP_WAND = 12, + EQUIP_REAGENT = 13, + EQUIP_POTION = 14, + EQUIP_SPELL_SCROLL = 15, + EQUIP_BOOK = 16, + EQUIP_MESSAGE_SCROLL = 17, + EQUIP_GOLD = 18, + EQUIP_GEM = 19, + EQUIP_NONE = 20 }; @@ -109,19 +118,19 @@ const char *GetIdentifiedName(); void UpdateTempBonus(__int64 uTimePlayed); void Reset(); - int _439DF3_get_additional_damage(int *a2, int *a3); + int _439DF3_get_additional_damage(int *a2, bool *vampiyr); unsigned int uItemID; - int _bonus_type; + int uEncantmentType; int _bonus_strength; - int uAdditionalValue; + int uSpecEnchantmentType; // 25: +5 levels int uNumCharges; unsigned int uAttributes; unsigned __int8 uBodyAnchor; char uMaxCharges; - char field_1A; + char uHolderPlayer; char field_1B; unsigned __int64 uExpireTime; }; @@ -225,11 +234,11 @@ void Initialize(); void LoadPotions(); void LoadPotionNotes(); - void GenerateItem(int treasure_level, int a3, ItemGen *pItem); + void GenerateItem(int treasure_level, unsigned int uTreasureType, ItemGen *pItem); void SetSpecialBonus(ItemGen *pItem); - bool _456D43_is_material_equals_3(ItemGen *pItem); - bool _456D5E_is_some_material(ItemGen *pItem); - char *Release(); + bool IsMaterialSpecial(ItemGen *pItem); + bool IsMaterialNonCommon(ItemGen *pItem); + void Release(); int uAllItemsCount; ItemDesc pItems[800]; //4-9604h @@ -266,4 +275,79 @@ extern ItemGen *ptr_50C9A4; -extern struct ItemsTable *pItemsTable; \ No newline at end of file +extern struct ItemsTable *pItemsTable; + +/* ++10 to all Resistances. 1 + +10 to all Seven Statistics. 2 + Explosive Impact! 3 + Adds 3-4 points of Cold damage. 4 + Adds 6-8 points of Cold damage. 5 + Adds 9-12 points of Cold damage. 6 + Adds 2-5 points of Electrical damage. 7 + Adds 4-10 points of Electrical damage. 8 + Adds 6-15 points of Electrical damage. 9 + Adds 1-6 points of Fire damage. 10 + Adds 2-12 points of Fire damage. 11 + Adds 3-18 points of Fire damage. 12 + Adds 5 points of Body damage. 13 + Adds 8 points of Body damage. 14 + Adds 12 points of Body damage. 15 + Drain Hit Points from target. 16 + Increases rate of Recovery. 17 + Wearer resistant to Diseases. 18 + Wearer resistant to Insanity. 19 + Wearer resistant to Paralysis. 20 + Wearer resistant to Poison. 21 + Wearer resistant to Sleep. 22 + Wearer resistant to Stone. 23 + Increased Knockback. 24 + +5 Level. 25 + Increases effect of all Air spells. 26 + Increases effect of all Body spells. 27 + Increases effect of all Dark spells. 28 + Increases effect of all Earth spells. 29 + Increases effect of all Fire spells. 30 + Increases effect of all Light spells. 31 + Increases effect of all Mind spells. 32 + Increases effect of all Spirit spells. 33 + Increases effect of all Water spells. 34 + Increases chance of Disarming. 35 + Half damage from all missile attacks. 36 + Regenerate Hit points over time. 37 + Regenerate Spell points over time. 38 + Double damage vs Demons. 39 + Double damage vs Dragons 40 + Drain Hit Points from target and Increased Weapon speed. 41 + +1 to Seven Stats, HP, SP, Armor, Resistances. 42 + +10 to Endurance, Armor, Hit points. 43 + +10 Hit points and Regenerate Hit points over time. 44 + +5 Speed and Accuracy. 45 + Adds 10-20 points of Fire damage and +25 Might. 46 + +10 Spell points and Regenerate Spell points over time. 47 + +15 Endurance and +5 Armor. 48 + +10 Intellect and Luck. 49 + +30 Fire Resistance and Regenerate Hit points over time. 50 + +10 Spell points, Speed, Intellect. 51 + +10 Endurance and Accuracy. 52 + +10 Might and Personality. 53 + +15 Endurance and Regenerate Hit points over time. 54 + +15 Luck and Regenerate Spell points over time. 55 + +5 Might and Endurance. 56 + +5 Intellect and Personality. 57 + Increased Value. 58 + Increased Weapon speed. 59 + +3 Unarmed and Dodging skills. 60 + +3 Stealing and Disarm skills. 61 + +3 ID Item and ID Monster skills. 62 + Double Damage vs. Elves. 63 + Double Damage vs. Undead. 64 + Double Damage vs. Titans. 65 + Regenerate Spell points and Hit points over time. 66 + Adds 5 points of Body damage and +2 Disarm skill. 67 + Adds 6-8 points of Cold damage and +5 Armor Class. 68 + +20 Air Resistance and Shielding. 69 + +10 Water Resistance and +2 Alchemy skill. 70 + Prevents damage from drowning. 71 + Prevents damage from falling. 72 +*/ \ No newline at end of file
--- a/LOD.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/LOD.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -1947,53 +1947,36 @@ //----- (0046188A) -------------------------------------------------------- int LOD::File::LoadSubIndices(const char *pContainer) { - LOD::File *v2; // esi@1 + unsigned int uDir; // edi@1 - int uDir_dup; // ebx@2 - int result; // eax@5 - LOD::Directory *v6; // eax@7 - LOD::Directory *v7; // eax@7 - __int32 v8; // edx@7 - FILE *v9; // ST00_4@7 - LOD::Directory *pSubIndices_dup; // eax@7 + LOD::Directory *curr_index; // eax@7 - v2 = this; + ResetSubIndices(); uDir = 0; - if ( (signed int)v2->header.uNumIndices <= 0 ) - { -LABEL_5: - result = 3; - } + + if ( header.uNumIndices <= 0) + return 3; else - { - uDir_dup = 0; - while ( _strcmpi(pContainer, (const char *)&v2->pRoot[uDir_dup]) ) - { - ++uDir; - ++uDir_dup; - if ( (signed int)uDir >= (signed int)v2->header.uNumIndices ) - goto LABEL_5; - } - strcpy((char *)v2->pContainerName, pContainer); - v6 = v2->pRoot; - v2->uCurrentIndexDir = uDir; - v7 = &v6[uDir]; - v8 = v7->uOfsetFromSubindicesStart; - v2->uOffsetToSubIndex = v8; - v9 = v2->pFile; - v2->uNumSubIndices = v7->uNumSubIndices; - fseek(v9, v8, 0); - pSubIndices_dup = (LOD::Directory *)pAllocator->AllocNamedChunk( - v2->pSubIndices, - 32 * (v2->uNumSubIndices + 5), - "LOD Index"); - v2->pSubIndices = pSubIndices_dup; - if ( pSubIndices_dup ) - fread(pSubIndices_dup, 0x20u, v2->uNumSubIndices, v2->pFile); - result = 0; - } - return result; + { + while (stricmp(pContainer, pRoot[uDir].pFilename)) + { + ++uDir; + if (uDir >= header.uNumIndices ) + return 3; + } + strcpy( pContainerName, pContainer); + uCurrentIndexDir = uDir; + curr_index=(LOD::Directory *)&pRoot[uDir]; + uOffsetToSubIndex =curr_index->uOfsetFromSubindicesStart ; + uNumSubIndices =curr_index->uNumSubIndices;// *(_WORD *)(v8 + 28); + fseek( pFile, uOffsetToSubIndex, 0); + pSubIndices = (LOD::Directory *)pAllocator->AllocNamedChunk(pSubIndices, sizeof(LOD::Directory)*(uNumSubIndices + 5), "LOD Index"); + + if ( pSubIndices) + fread( pSubIndices, sizeof(LOD::Directory), uNumSubIndices, pFile); + return 0; + } } //----- (004617D5) --------------------------------------------------------
--- a/LOD.h Mon Feb 25 09:08:13 2013 +0600 +++ b/LOD.h Mon Feb 25 09:09:08 2013 +0600 @@ -1,6 +1,7 @@ #pragma once #include <stdio.h> #include <memory.h> +#include <assert.h> #include "Texture.h" @@ -158,6 +159,14 @@ void _4114F2(); void _4355F7(); + inline Texture *GetTexture(int idx) + { + assert(idx < 1000); + if (idx == -1) + return nullptr; + return pTextures + idx; + } + /*FILE *pFile; unsigned __int8 pLODName[256];
--- a/LayingItem.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/LayingItem.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -107,7 +107,7 @@ //----- (0042F933) -------------------------------------------------------- -void LayingItem::_42F933(unsigned int uLayingItemID) +void LayingItem::OnItemPickup(unsigned int uLayingItemID) { unsigned int v1; // ecx@1 unsigned __int16 *pAttributes; // ecx@2
--- a/LayingItem.h Mon Feb 25 09:08:13 2013 +0600 +++ b/LayingItem.h Mon Feb 25 09:09:08 2013 +0600 @@ -2,11 +2,18 @@ #include "VectorTypes.h" #include "Items.h" +enum +{ + OBJECT_ATTACHED_TO_ACTOR = 0x80, +}; + /* 72 */ #pragma pack(push, 1) struct LayingItem { + inline bool AttachedToActor() const {return uAttributes & OBJECT_ATTACHED_TO_ACTOR;} + LayingItem(); int Create(int yaw, int pitch, int a4, int a5); void _46BEF1_apply_spells(); @@ -14,7 +21,7 @@ static void UpdateObject_fn0_BLV(unsigned int uLayingItemID); static void UpdateObject_fn0_ODM(unsigned int uLayingItemID); - static void _42F933(unsigned int uLayingItemID); + static void OnItemPickup(unsigned int uLayingItemID); unsigned __int16 uItemType; @@ -27,7 +34,7 @@ __int16 uSectorID; unsigned __int16 uSpriteFrameID; __int16 field_20; - __int16 field_22; + __int16 field_22_glow_radius_multiplier; struct ItemGen stru_24; int field_48; int field_4C;
--- a/NPC.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/NPC.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -670,7 +670,6 @@ pNPCDataBuff->joins = 1; } - //----- (00476387) -------------------------------------------------------- bool PartyHasDragon() { @@ -820,7 +819,6 @@ } } - //----- (00476590) -------------------------------------------------------- void InitializeMerchants() { @@ -923,7 +921,7 @@ if (temp_str_len) { if ( decode_step == 1) - pTransitionStrings[i]=RemoveQuotes(test_string); + pTransitionStrings[i + 1]=RemoveQuotes(test_string); } else {
--- a/NPC.h Mon Feb 25 09:08:13 2013 +0600 +++ b/NPC.h Mon Feb 25 09:09:08 2013 +0600 @@ -1,5 +1,71 @@ #pragma once +/* +enum NPCProffession + { + Smith 1 + Armorer 2 + Alchemist 3 + Scholar 4 + Guide 5 + Tracker 6 + Pathfinder 7 + Sailor 8 + Navigator 9 + Healer 10 + Expert Healer 11 + Master Healer 12 + Teacher 13 + Instructor 14 + Arms Master 15 + Weapons Master 16 + Apprentice 17 + Mystic 18 + Spell Master 19 + Trader 20 + Merchant 21 + Scout 22 + Herbalist 23 + Apothecary 24 + Tinker 25 + Locksmith 26 + Fool 27 + Chimney Sweep 28 + Porter 29 + Quarter Master 30 + Factor 31 + Banker 32 + Cook 33 + Chef 34 + Horseman 35 + Bard 36 + Enchanter 37 + Cartographer 38 + Wind Master 39 + Water Master 40 + Gate Master 41 + Acolyte 42 + Piper 43 + Explorer 44 + Pirate 45 + Squire 46 + Psychic 47 + Gypsy 48 + Diplomat 49 + Duper 50 + Burglar 51 + Fallen Wizard 52 + Acolyte 53 + Initiate 54 + Prelate 55 + Monk 56 + Sage 57 + Hunter 58 + + + }; + */ + struct NPCTopic { @@ -25,6 +91,17 @@ unsigned int uProfession; //18 CheckHiredNPCSpeciality(uProfession) /* + v0 = uDefaultTravelTime_ByFoot; + if ( CheckHiredNPCSpeciality(5u) ) + --v0; + if ( CheckHiredNPCSpeciality(6u) ) + v0 -= 2; + if ( CheckHiredNPCSpeciality(7u) ) + v0 -= 3; + if ( CheckHiredNPCSpeciality(0x2Cu) ) + --v0; + + case PLAYER_SKILL_MONSTER_ID: if ( CheckHiredNPCSpeciality(58) ) skill += 6; @@ -147,8 +224,8 @@ #pragma pack(push, 1) struct NPCGreeting { - char *pGreeting1; - char *pGreeting2; + char *pGreeting1; //at first meet + char *pGreeting2; // at latest meets }; #pragma pack(pop)
--- a/ObjectList.h Mon Feb 25 09:08:13 2013 +0600 +++ b/ObjectList.h Mon Feb 25 09:09:08 2013 +0600 @@ -26,6 +26,8 @@ #pragma pack(push, 1) struct ObjectDesc { + inline bool NoSprite() const {return uFlags & OBJECT_DESC_NO_SPRITE;} + char field_0[32]; __int16 uObjectID; __int16 uRadius;
--- a/Outdoor.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/Outdoor.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -2223,14 +2223,11 @@ pGameLoadingUI_ProgressBar->Progress(); memcpy(&uNumLayingItems, pSrc, 4); - //v93 = (char *)v92 + 4; - if (uNumLayingItems > 1000) - MessageBoxW(nullptr, L"Can't load file!", - L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:954", 0); + assert(uNumLayingItems <= 1000 && "Too many objects"); + assert(sizeof(LayingItem) == 112); pGameLoadingUI_ProgressBar->Progress(); - assert(sizeof(LayingItem) == 112); //pFilename = (char *)(112 * uNumLayingItems); memcpy(pLayingItems, pSrc + 4, uNumLayingItems * sizeof(LayingItem)); pSrc += 4 + uNumLayingItems * sizeof(LayingItem); @@ -3111,9 +3108,9 @@ } v28->uScreenSpaceX = v27; v28->uScreenSpaceY = v46; - v28->some_x = x; - v28->some_y = y; - v28->some_z = z; + v28->world_x = x; + v28->world_y = y; + v28->world_z = z; HIWORD(v34) = HIWORD(X); LOWORD(v34) = 0; v28->uPaletteSubindex = 0; @@ -3143,28 +3140,23 @@ //----- (0044C1E8) -------------------------------------------------------- bool ODMFace::HasEventHint() { - signed int v1; // eax@1 - EventIndex *v2; // esi@2 - bool result; // eax@5 - signed int v4; // eax@6 + signed int event_index; // eax@1 + _evt_raw* start_evt; + _evt_raw* end_evt; - v1 = 0; - if ( (signed int)(uLevelEVT_NumEvents - 1) <= 0 ) - goto LABEL_5; - v2 = pLevelEVT_Index; - while ( v2->uEventID != this->sCogTriggeredID ) + event_index = 0; + if ( (uLevelEVT_NumEvents - 1) <= 0 ) + return false; + while ( pLevelEVT_Index[event_index].uEventID != this->sCogTriggeredID ) { - ++v1; - ++v2; - if ( v1 >= (signed int)(uLevelEVT_NumEvents - 1) ) - goto LABEL_5; + ++event_index; + if ( event_index >= (signed int)(uLevelEVT_NumEvents - 1) ) + return false; } - v4 = v1; - if ( pLevelEVT[pLevelEVT_Index[v4 + 1].uEventOffsetInEVT + 4] != 1 - || pLevelEVT[pLevelEVT_Index[v4].uEventOffsetInEVT + 4] != 4 ) -LABEL_5: - result = 0; + end_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index+1].uEventOffsetInEVT]; + start_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index].uEventOffsetInEVT]; + if ( (end_evt->_e_type != EVENT_Exit) || (start_evt->_e_type!= EVENT_MouseOver) ) + return false; else - result = 1; - return result; + return true; } \ No newline at end of file
--- a/Party.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/Party.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -398,7 +398,7 @@ Dst.Reset(); if ( bGiveItems ) { - pItemsTable->GenerateItem(2, 40, &Dst); + pItemsTable->GenerateItem(2, 40, &Dst); //ring pCharacter->AddItem2(-1, &Dst); //uSkillIdx = 0; //v18 = 0; @@ -555,9 +555,9 @@ uNumGold = 200; uNumGoldInBank = 0; uNumFoodRations = 7; - uAlignment = 1; - SetUserInterface(uAlignment, true); + alignment = PartyAlignment_Neutral; + SetUserInterface(alignment, true); uTimePlayed = 0x21C00u; uLastRegenerationTime = 0x21C00; @@ -780,7 +780,6 @@ } - //----- (0043AD34) -------------------------------------------------------- void Party::Yell() { @@ -1062,7 +1061,7 @@ v8 = 138; do { - if ( v7->uItemID == 601 && (unsigned __int8)v7->field_1A== v15 + 1 ) + if ( v7->uItemID == 601 && (unsigned __int8)v7->uHolderPlayer== v15 + 1 ) v14 = 1; ++v7; --v8;
--- a/Party.h Mon Feb 25 09:08:13 2013 +0600 +++ b/Party.h Mon Feb 25 09:09:08 2013 +0600 @@ -16,7 +16,9 @@ /* 355 */ enum PARTY_FLAGS_1: __int32 { - PARTY_FLAGS_1_LANDING = 0x100, + PARTY_FLAGS_1_ALERT_RED = 0x0010, + PARTY_FLAGS_1_ALERT_YELLOW = 0x0020, + PARTY_FLAGS_1_LANDING = 0x0100, }; enum PARTY_FLAGS_2: __int32 { @@ -95,6 +97,12 @@ +enum PartyAlignment: unsigned __int32 +{ + PartyAlignment_Good = 0, + PartyAlignment_Neutral = 1, + PartyAlignment_Evil = 2 +}; @@ -180,6 +188,11 @@ inline bool FeatherFallActive() {return pPartyBuffs[PARTY_BUFF_FEATHER_FALL].uExpireTime > 0;} inline bool Invisible() {return pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0;} + inline bool GetRedAlert() {return uFlags & PARTY_FLAGS_1_ALERT_RED;} + inline void SetRedAlert() {uFlags |= PARTY_FLAGS_1_ALERT_RED;} + inline bool GetYellowAlert() {return uFlags & PARTY_FLAGS_1_ALERT_YELLOW;} + inline void SetYellowAlert() {uFlags |= PARTY_FLAGS_1_ALERT_YELLOW;} + int field_0; unsigned int uPartyHeight; @@ -253,28 +266,15 @@ unsigned int bTurnBasedModeOn; int field_880; int uFlags2; - unsigned int uAlignment; + PartyAlignment alignment; SpellBuff pPartyBuffs[20]; Player pPlayers[4]; NPCData pHirelings[2]; ItemGen pPickedItem; unsigned int uFlags; - int field_777C[1000]; - int field_871C[1000]; - int field_96BC[1000]; - int field_A65C[1000]; - int field_B5FC[1000]; - int field_C59C[1000]; - int field_D53C[1000]; - int field_E4DC[300]; - int field_E98C[13]; - int dword_E9C0; - int dword_E9C4; - char field_E9C8[5000]; - char field_FD50[5000]; - char field_110D8[5000]; - char field_12460[5000]; - char field_137E8[5000]; + ItemGen field_777C[53][12]; + ItemGen Recipes_Item[53][12]; //D0EC + int field_12A5C[2117]; char field_14B70[5000]; char field_15EF8[250]; char field_15FF2[130]; @@ -283,7 +283,7 @@ int armageddon_timer; int field_16140; int pTurnBasedPlayerRecoveryTimes[4]; - char field_16154[212]; + int field_16154[53]; int uFine; float flt_TorchlightColorR; float flt_TorchlightColorG;
--- a/Player.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/Player.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -1784,7 +1784,7 @@ } // 506128: using guessed type int areWeLoadingTexture; - +//identf //----- (00490EEE) -------------------------------------------------------- int Player::_490EEE(ItemGen *pItem, int a3, int a4, int a5) { @@ -2796,7 +2796,7 @@ v12 = pItemsTable->pItems[v8].uDamageMod + v28; if ( !uTargetActorID ) goto LABEL_28; - v13 = v6->uAdditionalValue; + v13 = v6->uSpecEnchantmentType; if ( v13 == 64 || v7 == 507 || v7 == 508 || v7 == 527 ) { v14 = (MONSTER_SUPERTYPE)1; @@ -2867,7 +2867,7 @@ v4 = pItemsTable->pItems[v17].uDamageMod + v29; if ( !uTargetActorID ) goto LABEL_57; - v19 = v15->uAdditionalValue; + v19 = v15->uSpecEnchantmentType; if ( v19 == 64 || v16 == 507 || v16 == 508 || v16 == 527 ) { v20 = (MONSTER_SUPERTYPE)1; @@ -3048,7 +3048,7 @@ v9 = pItemsTable->pItems[v6].uDamageMod + v17; if ( a2 ) { - v10 = v4->uAdditionalValue; + v10 = v4->uSpecEnchantmentType; if ( v10 == 64 ) { v11 = (MONSTER_SUPERTYPE)1; @@ -3371,7 +3371,7 @@ for (uint i = 0; i < 16; ++i) { if (HasItemEquipped((ITEM_EQUIP_TYPE)i) && - pInventoryItems[i].uAdditionalValue == uEnchantment) + pInventoryItems[i].uSpecEnchantmentType == uEnchantment) // *(int *)&this->field_1F6[36 * pEquipment[i] + 6] != uEnchantment) return true; } @@ -3532,9 +3532,9 @@ } if ( pItemsTable->pItems[v5->array_000234[3].uItemID].uEquipType != 18 ) return _steal_perma; - v20 = (int)&v5->array_000234[3].uAdditionalValue; - if ( (signed int)v19 > v5->array_000234[3].uAdditionalValue ) - v19 = v5->array_000234[3].uAdditionalValue; + v20 = (int)&v5->array_000234[3].uSpecEnchantmentType; + if ( (signed int)v19 > v5->array_000234[3].uSpecEnchantmentType ) + v19 = v5->array_000234[3].uSpecEnchantmentType; v21 = *(int *)v20 == v19; *(int *)v20 -= v19; if ( v21 ) @@ -3580,7 +3580,7 @@ if ( pItemsTable->pItems[v17].uEquipType == 14 ) { if ( v16 != 220 ) - v27._bonus_type = 2 * rand() % 4 + 2; + v27.uEncantmentType = 2 * rand() % 4 + 2; } } else @@ -4661,7 +4661,7 @@ if ( (signed int)v3 >= 16 ) return v2; } - if ( a2 != 24 || this->pInventoryItems[v5].uAdditionalValue != 24 ) + if ( a2 != 24 || this->pInventoryItems[v5].uSpecEnchantmentType != 24 ) goto LABEL_11; return 5; } @@ -4900,8 +4900,8 @@ } v63 = (int)((char *)v6 + 36 * v31); attra = (ItemGen *)(v63 + 532); - if ( pItemsTable->_456D5E_is_some_material((ItemGen *)(v63 + 532)) == 1 - && !pItemsTable->_456D43_is_material_equals_3(attra) ) + if ( pItemsTable->IsMaterialNonCommon((ItemGen *)(v63 + 532)) == 1 + && !pItemsTable->IsMaterialSpecial(attra) ) { v34 = attra->uItemID; switch ( attra->uItemID ) @@ -6969,10 +6969,10 @@ switch ( pParty->pPickedItem.uItemID ) { case 0xDEu: - v25 = pParty->pPickedItem._bonus_type + 10; + v25 = pParty->pPickedItem.uEncantmentType + 10; goto LABEL_110; case 0xDFu: - v26 = pParty->pPickedItem._bonus_type + 10; + v26 = pParty->pPickedItem.uEncantmentType + 10; goto LABEL_114; case 0xE0u: LODWORD(v3->pConditions[1]) = 0; @@ -7005,7 +7005,7 @@ v59 = 0; v50 = 5; v46 = 3; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335); + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335); v29 = (char *)&v3->pPlayerBuffs[7]; goto LABEL_147; case 0xE5u: @@ -7013,7 +7013,7 @@ v59 = 0; v50 = 5; v46 = 3; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335); + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335); v29 = (char *)&v3->pPlayerBuffs[8]; goto LABEL_147; case 0xE6u: @@ -7021,23 +7021,23 @@ v59 = 0; v50 = 5; v46 = 3; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335); + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335); v29 = (char *)&v3->pPlayerBuffs[1]; goto LABEL_147; case 0xE7u: v70 = 0; v59 = 0; - v50 = 3 * LOWORD(pParty->pPickedItem._bonus_type); + v50 = 3 * LOWORD(pParty->pPickedItem.uEncantmentType); v46 = 0; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335); + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335); v29 = (char *)&v3->pPlayerBuffs[11]; goto LABEL_147; case 0xE8u: v70 = 0; v59 = 0; - v50 = 3 * LOWORD(pParty->pPickedItem._bonus_type); + v50 = 3 * LOWORD(pParty->pPickedItem.uEncantmentType); v46 = 0; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335); + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335); v29 = (char *)&v3->pPlayerBuffs[13]; goto LABEL_147; case 0xEAu: @@ -7045,12 +7045,12 @@ v59 = 0; v50 = 5; v46 = 3; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335); + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335); v29 = (char *)&v3->pPlayerBuffs[14]; goto LABEL_147; case 0xEBu: v3->pPlayerBuffs[23].Apply( - pParty->uTimePlayed + (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335), + pParty->uTimePlayed + (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335), 3u, 5u, 0, @@ -7071,49 +7071,49 @@ case 0xF0u: v70 = 0; v59 = 0; - v50 = 3 * LOWORD(pParty->pPickedItem._bonus_type); + v50 = 3 * LOWORD(pParty->pPickedItem.uEncantmentType); v46 = 0; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335); + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335); v29 = (char *)&v3->pPlayerBuffs[19]; goto LABEL_147; case 0xF1u: v70 = 0; v59 = 0; - v50 = 3 * LOWORD(pParty->pPickedItem._bonus_type); + v50 = 3 * LOWORD(pParty->pPickedItem.uEncantmentType); v46 = 0; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335); + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335); v29 = (char *)&v3->pPlayerBuffs[17]; goto LABEL_147; case 0xF2u: v70 = 0; v59 = 0; - v50 = 3 * LOWORD(pParty->pPickedItem._bonus_type); + v50 = 3 * LOWORD(pParty->pPickedItem.uEncantmentType); v46 = 0; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335); + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335); v29 = (char *)&v3->pPlayerBuffs[20]; goto LABEL_147; case 0xF3u: v70 = 0; v59 = 0; - v50 = 3 * LOWORD(pParty->pPickedItem._bonus_type); + v50 = 3 * LOWORD(pParty->pPickedItem.uEncantmentType); v46 = 0; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335); + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335); v29 = (char *)&v3->pPlayerBuffs[16]; goto LABEL_147; case 0xF4u: v70 = 0; v59 = 0; - v50 = 3 * LOWORD(pParty->pPickedItem._bonus_type); + v50 = 3 * LOWORD(pParty->pPickedItem.uEncantmentType); v46 = 0; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335); + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335); v29 = (char *)&v3->pPlayerBuffs[21]; goto LABEL_147; case 0xF5u: v70 = 0; v59 = 0; - v50 = 3 * LOWORD(pParty->pPickedItem._bonus_type); + v50 = 3 * LOWORD(pParty->pPickedItem.uEncantmentType); v46 = 0; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335); + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335); v29 = (char *)&v3->pPlayerBuffs[15]; goto LABEL_147; case 0xFBu: @@ -7136,12 +7136,12 @@ HIDWORD(v3->pConditions[16]) = v35; goto LABEL_112; case 0xFDu: - v25 = 5 * pParty->pPickedItem._bonus_type; + v25 = 5 * pParty->pPickedItem.uEncantmentType; LABEL_110: v69 = v25; goto LABEL_111; case 0xFEu: - v26 = 5 * pParty->pPickedItem._bonus_type; + v26 = 5 * pParty->pPickedItem.uEncantmentType; LABEL_114: v27 = (char *)&v3->sMana; *(int *)v27 += v26; @@ -7149,57 +7149,57 @@ case 0xFFu: v70 = 0; v59 = 0; - v50 = 3 * LOWORD(pParty->pPickedItem._bonus_type); + v50 = 3 * LOWORD(pParty->pPickedItem.uEncantmentType); v46 = 0; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335); + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335); v29 = (char *)&v3->pPlayerBuffs[18]; goto LABEL_147; case 0x100u: v70 = 0; v59 = 0; - v50 = 3 * LOWORD(pParty->pPickedItem._bonus_type); + v50 = 3 * LOWORD(pParty->pPickedItem.uEncantmentType); v46 = 0; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335); + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335); v29 = (char *)&v3->pPlayerBuffs[5]; goto LABEL_147; case 0x101u: v70 = 0; v59 = 0; - v50 = 3 * LOWORD(pParty->pPickedItem._bonus_type); + v50 = 3 * LOWORD(pParty->pPickedItem.uEncantmentType); v46 = 0; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335); + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335); v29 = (char *)v3->pPlayerBuffs; goto LABEL_147; case 0x102u: v70 = 0; v59 = 0; - v50 = 3 * LOWORD(pParty->pPickedItem._bonus_type); + v50 = 3 * LOWORD(pParty->pPickedItem.uEncantmentType); v46 = 0; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335); + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335); v29 = (char *)&v3->pPlayerBuffs[22]; goto LABEL_147; case 0x103u: v70 = 0; v59 = 0; - v50 = 3 * LOWORD(pParty->pPickedItem._bonus_type); + v50 = 3 * LOWORD(pParty->pPickedItem.uEncantmentType); v46 = 0; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335); + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335); v29 = (char *)&v3->pPlayerBuffs[3]; goto LABEL_147; case 0x104u: v70 = 0; v59 = 0; - v50 = 3 * LOWORD(pParty->pPickedItem._bonus_type); + v50 = 3 * LOWORD(pParty->pPickedItem.uEncantmentType); v46 = 0; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335); + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335); v29 = (char *)&v3->pPlayerBuffs[9]; goto LABEL_147; case 0x105u: v70 = 0; v59 = 0; - v50 = 3 * LOWORD(pParty->pPickedItem._bonus_type); + v50 = 3 * LOWORD(pParty->pPickedItem.uEncantmentType); v46 = 0; - v28 = (signed __int64)((double)(230400 * pParty->pPickedItem._bonus_type) * 0.033333335); + v28 = (signed __int64)((double)(230400 * pParty->pPickedItem.uEncantmentType) * 0.033333335); v29 = (char *)&v3->pPlayerBuffs[2]; LABEL_147: ((SpellBuff *)v29)->Apply(pParty->uTimePlayed + v28, v46, v50, v59, v70); @@ -7598,13 +7598,14 @@ { if ( !v73 ) goto LABEL_187; - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); } if ( v73 ) { @@ -7679,27 +7680,23 @@ if ( dword_50C9E8 < 40 ) { dword_50C9EC[3 * dword_50C9E8] = 146; - dword_50C9F0[3 * dword_50C9E8] = v24; - *(&dword_50C9E8 + 3 * dword_50C9E8 + 3) = a2 - 1; + dword_50C9EC[3 * dword_50C9E8 + 1] = v24; + dword_50C9EC[3 * dword_50C9E8 + 2] = a2 - 1; ++dword_50C9E8; } if ( pCurrentScreen && pGUIWindow_CurrentMenu - && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null - && (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; + && pGUIWindow_CurrentMenu->eWindowType != WINDOW_null) + //&& (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + { + /*pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - } - } -} -// 4E28F8: using guessed type int pCurrentScreen; -// 50C9AC: using guessed type int dword_50C9AC; -// 50C9EC: using guessed type int dword_50C9EC[]; -// 6BE3C4: using guessed type char bUnderwater; -// 720984: using guessed type int 720984_unused; + ++pMessageQueue_50CBD0->uNumMessages;*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + } + } +}
--- a/Player.h Mon Feb 25 09:08:13 2013 +0600 +++ b/Player.h Mon Feb 25 09:09:08 2013 +0600 @@ -215,7 +215,8 @@ PLAYER_SKILL_STEALING = 34, PLAYER_SKILL_ALCHEMY = 35, PLAYER_SKILL_LEARNING = 36, - + PLAYER_SKILL_CLUB = 37, + PLAYER_SKILL_MISC = 38, PLAYER_SKILL_INVALID = -1 };
--- a/Render.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/Render.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -3053,17 +3053,17 @@ void Render::DrawLayingItems_Shooting_Magic_ODM() { //char *v0; // edi@2 - ObjectDesc *v1; // ebx@4 + //ObjectDesc *v1; // ebx@4 __int16 v2; // cx@5 RenderBillboard *v3; // esi@10 SpriteFrame *v4; // eax@10 - SpriteFrame *v5; // ebx@10 + //SpriteFrame *v5; // ebx@10 unsigned int v6; // eax@10 - int v7; // ecx@10 - int v8; // edx@10 + //int v7; // ecx@10 + //int v8; // edx@10 int v9; // ecx@10 unsigned __int16 v10; // ax@10 - int *v11; // eax@14 + //int *v11; // eax@14 int v12; // eax@22 int v13; // ST3C_4@23 int v14; // eax@23 @@ -3080,8 +3080,8 @@ int v25; // ST3C_4@30 int v26; // eax@31 char v27; // zf@31 - SpriteFrame *v28; // [sp+Ch] [bp-34h]@10 - __int16 a5; // [sp+10h] [bp-30h]@10 + //SpriteFrame *v28; // [sp+Ch] [bp-34h]@10 + //__int16 a5; // [sp+10h] [bp-30h]@10 int v30; // [sp+14h] [bp-2Ch]@23 int v31; // [sp+14h] [bp-2Ch]@29 __int16 v32; // [sp+14h] [bp-2Ch]@30 @@ -3103,56 +3103,61 @@ //v41 = 0; for (int i = 0; i < uNumLayingItems; ++i) { - auto v0 = (char *)&pLayingItems[i].uSectorID; + auto object = pLayingItems + i; + //auto v0 = (char *)&pLayingItems[i].uSectorID; //v0 = (char *)&pLayingItems[0].uSectorID; //do //{ - if ( *((short *)v0 - 13) ) - { - v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; - if ( !(v1->uFlags & 1) ) - { - if ( ((v2 = *((short *)v0 - 14), v2 < 1000) || v2 >= 10000) && (v2 < 500 || v2 >= 600) - || pGame->pStru6Instance->_4A81CA((LayingItem *)(v0 - 28)) ) - { - a5 = *(short *)v0; - x = *((int *)v0 - 6); - y = *((int *)v0 - 5); - z = *((int *)v0 - 4); - v3 = &pBillboardRenderList[::uNumBillboardsToDraw]; - v4 = pSpriteFrameTable->GetFrame(v1->uSpriteID, *((short *)v0 + 1)); - v5 = v4; - v28 = v4; - v36 = v4->uFlags; - a6 = v4->uGlowRadius * *((short *)v0 + 3); - v6 = stru_5C6E00->Atan2( - *((int *)v0 - 6) - pIndoorCamera->pos.x, - *((int *)v0 - 5) - pIndoorCamera->pos.y); - LOWORD(v7) = *((short *)v0 - 3); - v8 = v36; - v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v7 - v6) >> 8) & 7; - v10 = v5->pHwSpriteIDs[v9]; + if (!object->uObjectDescID) // item probably pciked up + continue; + + assert(object->uObjectDescID < pObjectList->uNumObjects); + auto object_desc = pObjectList->pObjects + object->uObjectDescID; + if (object_desc->NoSprite()) + continue; + + //v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; + //if ( !(v1->uFlags & 1) ) + //{ + //v2 = *((short *)v0 - 14) + v2 = object->uItemType; + if ( (v2 < 1000 || v2 >= 10000) && (v2 < 500 || v2 >= 600) || pGame->pStru6Instance->_4A81CA(object) ) + { + //a5 = *(short *)v0; + x = object->vPosition.x; + y = object->vPosition.y; + z = object->vPosition.z; + v3 = &pBillboardRenderList[::uNumBillboardsToDraw]; + v4 = pSpriteFrameTable->GetFrame(object_desc->uSpriteID, object->uSpriteFrameID); + //v5 = v4; + //v28 = v4; + v36 = v4->uFlags; + a6 = v4->uGlowRadius * object->field_22_glow_radius_multiplier; + v6 = stru_5C6E00->Atan2(object->vPosition.x - pIndoorCamera->pos.x, object->vPosition.y - pIndoorCamera->pos.y); + //LOWORD(v7) = object->uFacing; + //v8 = v36; + v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + object->uFacing - v6) >> 8) & 7; + v10 = v4->pHwSpriteIDs[v9]; v3->uHwSpriteID = v10; if ( v36 & 0x20 ) { - v8 = v36; - z -= (signed int)((unsigned __int64)(v5->scale - * (signed __int64)pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) >> 16) >> 1; + //v8 = v36; + z -= (signed int)((unsigned __int64)(v4->scale * (signed __int64)pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) >> 16) >> 1; } v46 = 0; - if ( v8 & 2 ) + if ( v36 & 2 ) v46 = 2; - v11 = (int *)(256 << v9); - if ( (256 << v9) & v8 ) + //v11 = (int *)(256 << v9); + if ( (256 << v9) & v36 ) v46 |= 4u; - if ( v8 & 0x40000 ) + if ( v36 & 0x40000 ) v46 |= 0x40u; - if ( v8 & 0x20000 ) + if ( v36 & 0x20000 ) LOBYTE(v46) = v46 | 0x80; if ( a6 ) { - LOBYTE(v11) = byte_4E94D3; - pMobileLightsStack->AddLight(x, y, z, a5, a6, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3); + //LOBYTE(v11) = byte_4E94D3; + pMobileLightsStack->AddLight(x, y, z, object->uSectorID, a6, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3); } v12 = (x - pIndoorCamera->pos.x) << 16; if ( pIndoorCamera->sRotationX ) @@ -3185,12 +3190,9 @@ v42 = v20 + v19; if ( v20 + v19 >= 262144 && v16 <= pOutdoorCamera->shading_dist_mist << 16 ) { - v21 = (unsigned __int64)(((x - pIndoorCamera->pos.x) << 16) - * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; - v17 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - - v21; - v40 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - - v21; + v21 = (unsigned __int64)(((x - pIndoorCamera->pos.x) << 16) * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; + v17 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v21; + v40 = ((unsigned __int64)(v34 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v21; v18 = (z - pIndoorCamera->pos.z) << 16; LABEL_29: v31 = v18; @@ -3203,30 +3205,31 @@ v25 = v23 / v42; LODWORD(v23) = 0; HIDWORD(v23) = SLOWORD(pOutdoorCamera->int_fov_rad); - v35 = pViewport->uScreenCenterX - - ((signed int)(((unsigned __int64)(v25 * (signed __int64)v40) >> 16) + 32768) >> 16); - v32 = LOWORD(pViewport->uScreenCenterY) - - (((unsigned int)((unsigned __int64)(v23 / v42 * v31) >> 16) + 32768) >> 16); - if (::uNumBillboardsToDraw >= 500) - return; + v35 = pViewport->uScreenCenterX - ((signed int)(((unsigned __int64)(v25 * (signed __int64)v40) >> 16) + 32768) >> 16); + v32 = LOWORD(pViewport->uScreenCenterY) - (((unsigned int)((unsigned __int64)(v23 / v42 * v31) >> 16) + 32768) >> 16); + + //if (::uNumBillboardsToDraw >= 500) + // return; + assert(::uNumBillboardsToDraw < 500); ++::uNumBillboardsToDraw; ++uNumSpritesDrawnThisFrame; - *(v0 - 2) |= 1u; - v3->uPalette = v28->uPaletteIndex; - v3->uIndoorSectorID = a5; - v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v28->scale * (signed __int64)v24) >> 16; - v26 = (unsigned __int64)(v28->scale * (signed __int64)v24) >> 16; - v3->pSpriteFrame = v28; + + object->uAttributes |= 1; + v3->uPalette = v4->uPaletteIndex; + v3->uIndoorSectorID = object->uSectorID; + v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; + v26 = (unsigned __int64)(v4->scale * (signed __int64)v24) >> 16; + v3->pSpriteFrame = v4; v3->_screenspace_y_scaler_packedfloat = v26; v3->field_1E = v46; - v3->some_x = x; - v3->some_y = y; - v3->some_z = z; + v3->world_x = x; + v3->world_y = y; + v3->world_z = z; v3->uScreenSpaceX = v35; v3->uScreenSpaceY = v32; HIWORD(v26) = HIWORD(v42); LOWORD(v26) = 0; - v27 = (*(v0 - 2) & 0x20) == 0; + v27 = (object->uAttributes & 0x20) == 0; v3->sZValue = v26 + (8 * i | OBJECT_Item); v3->uPaletteSubindex = 0; v3->uTintColor = 0; @@ -3240,8 +3243,7 @@ } } } - } - } + //} LABEL_34: ; //++v41; @@ -3659,9 +3661,9 @@ HIBYTE(v29) |= 2u; v27->uPalette = v28; v27->field_1E = v29; - v27->some_x = x; - v27->some_y = y; - v27->some_z = v36; + v27->world_x = x; + v27->world_y = y; + v27->world_z = v36; v27->uScreenSpaceY = v40; HIWORD(v30) = HIWORD(v39); v31 = 8 * i | OBJECT_Decoration; @@ -10976,7 +10978,7 @@ while ( v2 < (signed int)pObjectList->uNumObjects ); } LOBYTE(v1) = 1; - SetUserInterface(pParty->uAlignment, v1); + SetUserInterface(pParty->alignment, v1); if ( pVideoPlayer->pVideoFrame.pPixels ) pVideoPlayer->pVideoFrame.Load(pVideoPlayer->pVideoFrameTextureFilename, 1); if ( uCurrentMenuID )
--- a/Render.h Mon Feb 25 09:08:13 2013 +0600 +++ b/Render.h Mon Feb 25 09:09:08 2013 +0600 @@ -70,9 +70,9 @@ __int16 uPalette; __int16 uIndoorSectorID; __int16 field_1E; - __int16 some_x; - __int16 some_y; - __int16 some_z; + __int16 world_x; + __int16 world_y; + __int16 world_z; __int16 uScreenSpaceX; __int16 uScreenSpaceY; unsigned __int16 uPaletteSubindex;
--- a/SaveLoad.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/SaveLoad.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -85,7 +85,7 @@ } } - sprintf(pTmpBuf, "saves\\%s", pSavegameList->pSavesNames[uSlot]); + sprintf(pTmpBuf, "saves\\%s", pSavegameList->pFileList[uSlot].pSaveFileName); pNew_LOD->CloseWriteFile(); if (!CopyFileA(pTmpBuf, "data\\new.lod", 0)) @@ -196,7 +196,7 @@ viewparams->bRedrawGameUI = true; - SetUserInterface(pParty->uAlignment, true); + SetUserInterface(pParty->alignment, true); pEventTimer->Resume(); pEventTimer->StopGameTime(); @@ -671,12 +671,13 @@ void SavegameList::Initialize(unsigned int bHideEmptySlots) { memset(pSavegameList, 0, 0x3138); + // Reset(); uNumSavegameFiles = 0; _chdir("saves"); { if (!bHideEmptySlots && _access(pGlobalTXT_LocalizationStrings[613], 0) != -1 ) // AutoSave.MM7 - strcpy(pSavesNames[uNumSavegameFiles++], pGlobalTXT_LocalizationStrings[613]); + strcpy(pSavegameList->pFileList[uNumSavegameFiles++].pSaveFileName, pGlobalTXT_LocalizationStrings[613]); for (uint i = 0; i < 40; ++i) { @@ -687,7 +688,7 @@ uint idx = i; if (!bHideEmptySlots) idx = uNumSavegameFiles; - strcpy(pSavesNames[idx], pTmpBuf); + strcpy(pSavegameList->pFileList[idx].pSaveFileName, pTmpBuf); ++uNumSavegameFiles; }
--- a/SaveLoad.h Mon Feb 25 09:08:13 2013 +0600 +++ b/SaveLoad.h Mon Feb 25 09:09:08 2013 +0600 @@ -1,15 +1,28 @@ #pragma once - +#pragma pack(push, 1) +struct SaveFile_ + { + char field_0[20]; + char pSaveFileName[260]; + }; +#pragma pack(pop) /* 243 */ #pragma pack(push, 1) struct SavegameList { - void Initialize(unsigned int a1); + static void Initialize(unsigned int a1); - char field_0[20]; - char pSavesNames[40][280]; + /*inline void Reset() + { + for (int i = 0; i < 20; ++i) + field_0[i] = 0; + for (int i = 0; i < 44; ++i) + pSavesNames[i][0] = 0; + }*/ + SaveFile_ pFileList[45]; + }; #pragma pack(pop)
--- a/TurnEngine.h Mon Feb 25 09:08:13 2013 +0600 +++ b/TurnEngine.h Mon Feb 25 09:09:08 2013 +0600 @@ -6,6 +6,13 @@ #pragma pack(push, 1) struct TurnBased_QueueElem { + inline TurnBased_QueueElem() + { + uPackedID = 0; + field_4 = 0; + uActionLength = 0; + field_C = 0; + } int uPackedID; int field_4; int uActionLength; @@ -17,6 +24,18 @@ #pragma pack(push, 1) struct stru262_TurnBased { + inline stru262_TurnBased() + { + field_0 = 0; + field_4 = 0; + field_8 = 0; + uActorQueueSize = 0; + field_10 = 0; + uActionPointsLeft = 0; + field_18 = 0; + field_1C = 0; + } + signed int _404544(); void _40471C(); signed int Start();
--- a/VideoPlayer.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/VideoPlayer.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -1125,7 +1125,7 @@ pParty->uFlags &= 0xFFFFFFFDu; if ( EnterHouse((enum HOUSE_TYPE)165) ) { - pAudioPlayer->PlaySound(SOUND_0, 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_Invalid, 0, 0, -1, 0, 0, 0, 0); window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0); window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, "", 0); window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, "", 0);
--- a/lib/legacy_dx/lib/.svn/all-wcprops Mon Feb 25 09:08:13 2013 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/bb7/!svn/ver/289/libs/legacy_dx/lib -END -dinput8.lib -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/bb7/!svn/ver/289/libs/legacy_dx/lib/dinput8.lib -END -ddraw.lib -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/bb7/!svn/ver/289/libs/legacy_dx/lib/ddraw.lib -END -dinput.lib -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/bb7/!svn/ver/289/libs/legacy_dx/lib/dinput.lib -END -dxguid.lib -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/bb7/!svn/ver/289/libs/legacy_dx/lib/dxguid.lib -END -d3dxof.lib -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/bb7/!svn/ver/289/libs/legacy_dx/lib/d3dxof.lib -END
--- a/lib/legacy_dx/lib/.svn/entries Mon Feb 25 09:08:13 2013 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,198 +0,0 @@ -10 - -dir -316 -http://svn2.assembla.com/svn/bb7/libs/legacy_dx/lib -http://svn2.assembla.com/svn/bb7 - - - -2010-12-18T21:09:41.003199Z -289 -Feaerenil - - - - - - - - - - - - - - -0b0191bc-8333-4b8d-b53c-6b3aa212730c - -dinput8.lib -file - - - - -2004-09-03T13:18:30.000000Z -a9300cdf7a34c7da7be2117e099e15a7 -2010-12-18T21:09:41.003199Z -289 -Feaerenil -has-props - - - - - - - - - - - - - - - - - - - - -173542 - -ddraw.lib -file - - - - -2004-09-06T18:58:26.000000Z -77752b153225ae97f64688aa5c16db31 -2010-12-18T21:09:41.003199Z -289 -Feaerenil -has-props - - - - - - - - - - - - - - - - - - - - -4540 - -dinput.lib -file - - - - -2004-09-03T13:18:30.000000Z -21f11641cd6d0b29f2979fcad555a81e -2010-12-18T21:09:41.003199Z -289 -Feaerenil -has-props - - - - - - - - - - - - - - - - - - - - -161464 - -dxguid.lib -file - - - - -2005-05-26T12:11:04.000000Z -b5d00b6a24df5706d25ae59b9ff77658 -2010-12-18T21:09:41.003199Z -289 -Feaerenil -has-props - - - - - - - - - - - - - - - - - - - - -408632 - -d3dxof.lib -file - - - - -2004-09-29T14:47:54.000000Z -f17de8653cb71aa503a45d7908a6c296 -2010-12-18T21:09:41.003199Z -289 -Feaerenil -has-props - - - - - - - - - - - - - - - - - - - - -1746 -
--- a/lib/legacy_dx/lib/.svn/prop-base/d3dxof.lib.svn-base Mon Feb 25 09:08:13 2013 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -K 13 -svn:mime-type -V 24 -application/octet-stream -END
--- a/lib/legacy_dx/lib/.svn/prop-base/ddraw.lib.svn-base Mon Feb 25 09:08:13 2013 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -K 13 -svn:mime-type -V 24 -application/octet-stream -END
--- a/lib/legacy_dx/lib/.svn/prop-base/dinput.lib.svn-base Mon Feb 25 09:08:13 2013 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -K 13 -svn:mime-type -V 24 -application/octet-stream -END
--- a/lib/legacy_dx/lib/.svn/prop-base/dinput8.lib.svn-base Mon Feb 25 09:08:13 2013 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -K 13 -svn:mime-type -V 24 -application/octet-stream -END
--- a/lib/legacy_dx/lib/.svn/prop-base/dxguid.lib.svn-base Mon Feb 25 09:08:13 2013 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -K 13 -svn:mime-type -V 24 -application/octet-stream -END
--- a/mm7_1.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/mm7_1.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -5,6 +5,8 @@ */ //#include <defs.h> +#include <assert.h> + #include "MM7.h" #include "MapInfo.h" @@ -1518,13 +1520,14 @@ if ( result->uHotkey == v3 ) { v6 = result->uControlParam; - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + pMessageQueue_50CBD0->AddMessage((UIMessageType)result->uControlID, v6, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)result->uControlID; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v6; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ return result; } } @@ -2023,14 +2026,15 @@ } LABEL_26: v11 = v9->uControlParam; - if ( (signed int)v2 < 40 ) + /*if ( (signed int)v2 < 40 ) { pMessageQueue_50CBD0->pMessages[v2].eType = (UIMessageType)v9->uControlID; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v11; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = v1; v2 = pMessageQueue_50CBD0->uNumMessages + 1; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ + pMessageQueue_50CBD0->AddMessage((UIMessageType)v9->uControlID, v11, v1); goto LABEL_47; } if ( v26 != 38 ) @@ -2148,13 +2152,14 @@ } LABEL_56: v21 = v19->uControlParam; - if ( (signed int)v2 < 40 ) + /*if ( (signed int)v2 < 40 ) { pMessageQueue_50CBD0->pMessages[v2].eType = (UIMessageType)v19->uControlID; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v21; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = v1; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ + pMessageQueue_50CBD0->AddMessage((UIMessageType)v19->uControlID, v21, v1); return 1; } @@ -2360,7 +2365,7 @@ v77 = 0; //a2.y = v8->uAttributes & 2; if (pItemsTable->pItems[v8->uItemID].uEquipType == EQUIP_GOLD) - v77 = v8->uAdditionalValue; + v77 = v8->uSpecEnchantmentType; if ( uActiveCharacter ) { if (!v8->Identified()) @@ -2499,7 +2504,7 @@ //v23 = item_desc->uEquipType; if (item_desc->uEquipType == 14) { - v24 = _this->_bonus_type; + v24 = _this->uEncantmentType; if ( v24 ) goto LABEL_56; LABEL_65: @@ -2529,7 +2534,7 @@ v79.uFrameHeight = v73->uTextureHeight + v81 + 54; if ( (signed int)Str > (signed int)v79.uFrameHeight ) v79.uFrameHeight = (unsigned int)Str; - if ( _this->uAttributes & 8 && (_this->uAdditionalValue || _this->_bonus_type) ) + if ( _this->uAttributes & 8 && (_this->uSpecEnchantmentType || _this->uEncantmentType) ) v79.uFrameHeight += LOBYTE(v82->uFontHeight); v83 = 0; if ( LOBYTE(pFontArrus->uFontHeight) ) @@ -2596,7 +2601,7 @@ } else { - if ( _this->uAttributes & 8 && (_this->uAdditionalValue || _this->_bonus_type) ) + if ( _this->uAttributes & 8 && (_this->uSpecEnchantmentType || _this->uEncantmentType) ) { sub_493F79(&v67, _this->uExpireTime - pParty->uTimePlayed); strcpy(pTmpBuf, "Duration:"); @@ -2665,7 +2670,7 @@ sprintf(a1 + 200, v49, v54, v59); goto LABEL_65; } - v25 = _this->_bonus_type; + v25 = _this->uEncantmentType; if ( v25 ) { v60 = _this->_bonus_strength; @@ -2675,7 +2680,7 @@ } else { - v26 = _this->uAdditionalValue; + v26 = _this->uSpecEnchantmentType; if ( !v26 ) { if ( _this->uNumCharges ) @@ -3516,8 +3521,6 @@ return result; } - - //----- (0041F54A) -------------------------------------------------------- void __cdecl LoadActualSkyFrame() { @@ -3829,373 +3832,7 @@ (int)pGlobalTXT_LocalizationStrings[81]); } } -// 4E2BC8: using guessed type char byte_4E2BC8; -// 506F14: using guessed type int dword_506F14; -// 506F1C: using guessed type int dword_506F1C; -// 50765C: using guessed type int uTextureID_RestUI_restmain; -// 507CD4: using guessed type int 507CD4_RestUI_hourglass_anim_controller; - -//----- (0041FE71) -------------------------------------------------------- -int Chest::CanPlaceItemAt(signed int a1, int a2, unsigned int uChestID) -{ - int v3; // eax@1 - unsigned int v4; // eax@1 - Texture *v5; // ecx@1 - signed int v6; // eax@1 - signed int v7; // edi@3 - signed int v8; // eax@3 - int v9; // edi@3 - int v10; // ebx@5 - int v11; // esi@9 - int v12; // edx@10 - int v13; // ecx@11 - char *v14; // eax@12 - int v16; // [sp+Ch] [bp-Ch]@1 - signed int v17; // [sp+10h] [bp-8h]@1 - signed int v18; // [sp+14h] [bp-4h]@1 - - v17 = a1; - v3 = pChests[uChestID].uChestBitmapID; - v16 = pChestHeightsByType[v3]; - v18 = pChestWidthsByType[v3]; - v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[a2].pIconName, TEXTURE_16BIT_PALETTE); - v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0); - v6 = (v4 != -1 ? pIcons_LOD->pTextures[v4].uTextureWidth : 24); - if ( v6 < 14 ) - v6 = 14; - v7 = v6 - 14; - v8 = v5->uTextureHeight; - v9 = (v7 >> 5) + 1; - if ( v8 < 14 ) - v8 = 14; - v10 = ((v8 - 14) >> 5) + 1; - if ( !areWeLoadingTexture ) - { - v5->Release(); - pIcons_LOD->_40F9C5(); - } - if ( v9 + v17 % v18 <= v18 && v10 + v17 / v18 <= v16 ) - { - v11 = 0; - if ( v10 <= 0 ) - return 1; - v12 = 0; - while ( 1 ) - { - v13 = 0; - if ( v9 > 0 ) - break; -LABEL_15: - v12 += v18; - ++v11; - if ( v11 >= v10 ) - return 1; - } - v14 = (char *)&pChests[0].pInventoryIndices[v17 + v12 + 2662 * uChestID]; - while ( !*(short *)v14 ) - { - ++v13; - v14 += 2; - if ( v13 >= v9 ) - goto LABEL_15; - } - } - return 0; -} -// 506128: using guessed type int areWeLoadingTexture; - -//----- (0041FF64) -------------------------------------------------------- -int Chest::_41FF64(unsigned int uChestID) -{ - unsigned int v1; // ecx@1 - signed int result; // eax@1 - int v3; // edx@1 - ItemGen *pItem; // ecx@2 - - v1 = uChestID; - result = 0; - v3 = pChestWidthsByType[pChests[v1].uChestBitmapID] * pChestHeightsByType[pChests[v1].uChestBitmapID]; - if ( v3 <= 0 ) - { -LABEL_5: - result = -1; - } - else - { - pItem = pChests[v1].mm7__vector_pItems; - while ( pItem->uItemID ) - { - ++result; - ++pItem; - if ( result >= v3 ) - goto LABEL_5; - } - } - return result; -} - -//----- (0041FFA2) -------------------------------------------------------- -int Chest::_41FFA2(int a1, ItemGen *a2, unsigned int uChestID) -{ - int v3; // eax@1 - ItemGen *v4; // edi@1 - int v5; // esi@1 - int result; // eax@11 - unsigned int v7; // eax@12 - int v8; // edx@12 - int v9; // ecx@12 - signed int v10; // eax@12 - signed int v11; // edi@14 - unsigned int v12; // esi@14 - int v13; // edi@16 - void *v14; // edi@21 - int v15; // edi@21 - int i; // ecx@21 - ItemGen *Src; // [sp+Ch] [bp-18h]@1 - signed int v18; // [sp+10h] [bp-14h]@2 - int v19; // [sp+14h] [bp-10h]@1 - int v20; // [sp+18h] [bp-Ch]@19 - signed int v21; // [sp+1Ch] [bp-8h]@1 - signed int v22; // [sp+20h] [bp-4h]@3 - int v23; // [sp+20h] [bp-4h]@19 - - v21 = 0; - v3 = pChests[uChestID].uChestBitmapID; - v4 = a2; - v5 = pChestWidthsByType[v3] * pChestHeightsByType[v3]; - Src = a2; - v19 = pChestWidthsByType[v3]; - if ( a1 == -1 ) - { - v18 = _41FF64(uChestID); - if ( v18 == -1 ) - return 0; - v22 = 0; - if ( v5 > 0 ) - { - while ( !Chest::CanPlaceItemAt(v22, v4->uItemID, (unsigned int)pChestWindow->ptr_1C) ) - { - ++v22; - if ( v22 >= v5 ) - goto LABEL_8; - } - v21 = v22; - } -LABEL_8: - if ( v22 == v5 ) - { - if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); - return 0; - } - v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v4->uItemID].pIconName, TEXTURE_16BIT_PALETTE); - HIWORD(v8) = 0; - v9 = v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0; - v10 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24); - if ( v10 < 14 ) - v10 = 14; - v11 = *(short *)(v9 + 26); - v12 = ((v10 - 14) >> 5) + 1; - if ( v11 < 14 ) - v11 = 14; - v13 = ((v11 - 14) >> 5) + 1; - if ( !areWeLoadingTexture ) - { - ((Texture *)v9)->Release(); - pIcons_LOD->_40F9C5(); - } - if ( v13 > 0 ) - { - v23 = 0; - v20 = v13; - do - { - if ( (signed int)v12 > 0 ) - { - v14 = &pChests[0].pInventoryIndices[v21 + v23 + 2662 * uChestID]; - LOWORD(v8) = -1 - v21; - v8 <<= 16; - LOWORD(v8) = -1 - v21; - memset32(v14, v8, v12 >> 1); - v15 = (int)((char *)v14 + 4 * (v12 >> 1)); - for ( i = v12 & 1; i; --i ) - { - *(short *)v15 = v8; - v15 += 2; - } - } - v23 += v19; - --v20; - } - while ( v20 ); - } - pChests[0].pInventoryIndices[v21 + 2662 * uChestID] = v18 + 1; - memcpy(&pChests[uChestID].mm7__vector_pItems[v18], Src, 0x24u); - result = v21 + 1; - } - else - { - result = 1; - } - return result; -} -// 506128: using guessed type int areWeLoadingTexture; - -//----- (0042013E) -------------------------------------------------------- -unsigned int Chest::PlaceItemAt(unsigned int a1, unsigned int uItemIdx, unsigned int uChestID) -{ - int v3; // esi@1 - unsigned int v4; // ebx@1 - int uItemID; // edi@1 - int v6; // edx@4 - unsigned int v7; // eax@5 - Texture *v8; // ecx@5 - signed int v9; // eax@5 - signed int v10; // edi@7 - unsigned int v11; // ebx@7 - int v12; // edi@9 - int v13; // edx@12 - void *v14; // edi@14 - int v15; // edi@14 - int i; // ecx@14 - unsigned int result; // eax@18 - __int16 v18; // [sp+Ch] [bp-10h]@1 - int v19; // [sp+10h] [bp-Ch]@11 - int v20; // [sp+14h] [bp-8h]@12 - unsigned int v21; // [sp+18h] [bp-4h]@1 - - v3 = 5324 * uChestID; - v21 = a1; - v4 = 5324 * uChestID + 36 * uItemIdx; - v18 = uItemIdx; - uItemID = *(unsigned int *)((char *)&pChests[0].mm7__vector_pItems[0].uItemID + v4); - pItemsTable->SetSpecialBonus((ItemGen *)((char *)pChests[0].mm7__vector_pItems + v4)); - if ( uItemID >= 135 && uItemID <= 159 && !*(int *)((char *)&pChests[0].mm7__vector_pItems[0].uNumCharges + v4) ) - { - v6 = rand() % 21 + 10; - *(int *)((char *)&pChests[0].mm7__vector_pItems[0].uNumCharges + v4) = v6; - *(&pChests[0].mm7__vector_pItems[0].uMaxCharges + v4) = v6; - } - v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); - v8 = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0); - v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24); - if ( v9 < 14 ) - v9 = 14; - v10 = v8->uTextureHeight; - v11 = ((v9 - 14) >> 5) + 1; - if ( v10 < 14 ) - v10 = 14; - v12 = ((v10 - 14) >> 5) + 1; - if ( !areWeLoadingTexture ) - { - v8->Release(); - pIcons_LOD->_40F9C5(); - } - v19 = pChestWidthsByType[*(unsigned __int16 *)((char *)&pChests[0].uChestBitmapID + v3)]; - if ( v12 > 0 ) - { - v13 = 0; - v20 = v12; - do - { - if ( (signed int)v11 > 0 ) - { - v14 = &pChests[0].pInventoryIndices[v21 + v13 + 2662 * uChestID]; - LOWORD(v3) = -1 - v21; - v3 <<= 16; - LOWORD(v3) = -1 - v21; - memset32(v14, v3, v11 >> 1); - v15 = (int)((char *)v14 + 4 * (v11 >> 1)); - for ( i = v11 & 1; i; --i ) - { - *(short *)v15 = v3; - v15 += 2; - } - } - v13 += v19; - --v20; - } - while ( v20 ); - } - result = v21 + 2662 * uChestID; - pChests[0].pInventoryIndices[result] = v18 + 1; - return result; -} -// 506128: using guessed type int areWeLoadingTexture; - -//----- (00420284) -------------------------------------------------------- -char *Chest::_420284(unsigned int uChestID) -{ - int v1; // ebx@1 - unsigned int v2; // esi@1 - unsigned int v3; // esi@1 - int uChestArea; // edi@1 - int v5; // eax@2 - int v6; // ebx@11 - char *result; // eax@18 - char Dst[144]; // [sp+Ch] [bp-A0h]@1 - int v9; // [sp+9Ch] [bp-10h]@10 - unsigned int v10; // [sp+A0h] [bp-Ch]@1 - unsigned int v11; // [sp+A4h] [bp-8h]@8 - ItemGen *v12; // [sp+A8h] [bp-4h]@9 - - v1 = 0; - v2 = uChestID; - v10 = uChestID; - pRenderer->ClearZBuffer(0, 479); - v3 = v2; - uChestArea = pChestWidthsByType[pChests[v3].uChestBitmapID] * pChestHeightsByType[pChests[v3].uChestBitmapID]; - memset(Dst, 0, 0x90u); - if ( uChestArea > 0 ) - { - do - { - do - v5 = (unsigned __int8)rand(); - while ( v5 >= uChestArea ); - while ( Dst[v5] ) - { - ++v5; - if ( v5 == uChestArea ) - v5 = 0; - } - Dst[v5] = v1++; - } - while ( v1 < uChestArea ); - } - v11 = 0; - if ( uChestArea > 0 ) - { - v12 = pChests[v3].mm7__vector_pItems;//&pChests[v3].mm7__vector_pItems[0].uAttributes; - do - { - v9 = v12->uItemID; - if ( v9 ) - { - v6 = 0; - while ( !Chest::CanPlaceItemAt((unsigned __int8)Dst[v6], v9, v10) ) - { - ++v6; - if ( v6 >= uChestArea ) - break; - } - if(v6<uChestArea) - { - Chest::PlaceItemAt((unsigned __int8)Dst[v6], v11, v10); - if ( pChests[v3].uFlags & 4 ) - v12->SetIdentified(); - } - } - ++v11; - ++v12; - } - while ( (signed int)v11 < uChestArea ); - } - result = (char *)&pChests[v3].uFlags; - pChests[v3].uFlags = pChests[v3].uFlags & 0xFFFB | 2; - return result; -} -// 420284: using guessed type char Dst[144]; + //----- (0042038D) -------------------------------------------------------- void __cdecl sub_42038D() @@ -4221,307 +3858,6 @@ } } -//----- (0042041E) -------------------------------------------------------- -bool Chest::Open(unsigned int uChestID) -{ - char *v1; // edi@5 - unsigned int v2; // eax@8 - GUIWindow *v3; // eax@15 - int v5; // edx@16 - int v6; // eax@16 - ODMFace *v7; // eax@19 - int v8; // edx@19 - int v9; // edi@19 - signed int v10; // ebx@19 - int v11; // ecx@19 - int v12; // eax@19 - BLVFace *v13; // eax@20 - int v14; // ebx@21 - int v15; // edi@21 - int v16; // ecx@22 - __int64 v17; // qax@22 - double v18; // st7@23 - double v19; // st6@23 - double v20; // st7@23 - int v21; // ecx@26 - char v22[12]; // ST4C_12@28 - unsigned int *v23; // edi@28 - unsigned __int16 v24; // di@28 - signed int v25; // ecx@28 - char *v26; // edx@29 - unsigned __int16 v27; // ax@32 - //LayingItem a1; // [sp+14h] [bp-B0h]@28 - int v29; // [sp+84h] [bp-40h]@16 - int v30; // [sp+88h] [bp-3Ch]@16 - int v31; // [sp+8Ch] [bp-38h]@16 - int v32; // [sp+90h] [bp-34h]@16 - float v33; // [sp+94h] [bp-30h]@23 - char *v34; // [sp+98h] [bp-2Ch]@5 - int v35; // [sp+9Ch] [bp-28h]@16 - Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28 - int a4; // [sp+ACh] [bp-18h]@1 - int v38; // [sp+B0h] [bp-14h]@21 - int sRotX; // [sp+B4h] [bp-10h]@23 - float v40; // [sp+B8h] [bp-Ch]@23 - float v41; // [sp+BCh] [bp-8h]@23 - int sRotY; // [sp+C0h] [bp-4h]@8 - - a4 = uChestID; - if ( (uChestID & 0x80000000u) != 0 || (signed int)uChestID >= 20 ) - return 0; - ++pIcons_LOD->uTexturePacksCount; - if ( !pIcons_LOD->uNumPrevLoadedFiles ) - pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; - v1 = (char *)&pChests[uChestID].uFlags; - v34 = v1; - if ( !(*v1 & CHEST_ITEMS_PLACED) ) - Chest::_420284(uChestID); - if ( !uActiveCharacter ) - return 0; - *(float *)&sRotY = 0.0; - v2 = pMapStats->GetMapInfo(pCurrentMapName); - if ( !(*v1 & 1) || !v2 ) - goto LABEL_12; - if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].LockX5 ) - { - v29 = 811; - v30 = 812; - v31 = 813; - v32 = 814; - v5 = rand() % 4; - v6 = dword_5B5920 >> 3; - v35 = v5; - if ( (dword_5B5920 & 7) == OBJECT_Decoration) - { - v16 = v6; - v14 = pLevelDecorations[v6].vPosition.x; - v38 = pLevelDecorations[v6].vPosition.y; - v17 = pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight; - v15 = pLevelDecorations[v16].vPosition.z + (((signed int)v17 - HIDWORD(v17)) >> 1); - } - else - { - if ( (dword_5B5920 & 7) != OBJECT_BModel) - goto LABEL_12; - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - { - v7 = &pOutdoor->pBModels[dword_5B5920 >> 9].pFaces[(dword_5B5920 >> 3) & 0x3F]; - v8 = v7->pBoundingBox.y1; - v9 = v7->pBoundingBox.z2; - v10 = v7->pBoundingBox.x1 + v7->pBoundingBox.x2; - v11 = v7->pBoundingBox.y2; - v12 = v7->pBoundingBox.z1; - } - else - { - v13 = &pIndoor->pFaces[v6]; - v8 = v13->pBounding.y1; - v9 = v13->pBounding.z2; - v10 = v13->pBounding.x1 + v13->pBounding.x2; - v11 = v13->pBounding.y2; - v12 = v13->pBounding.z1; - } - v14 = v10 >> 1; - v38 = (v8 + v11) >> 1; - v15 = (v12 + v9) >> 1; - } - v18 = (double)pParty->vPosition.x - (double)v14; - *(float *)&a4 = v18; - v19 = (double)pParty->vPosition.y - (double)v38; - v33 = v19; - v41 = (double)pParty->sEyelevel + (double)pParty->vPosition.z - (double)v15; - *(float *)&sRotY = v19 * v19; - *(float *)&sRotX = v18 * v18; - v20 = sqrt(v41 * v41 + *(float *)&sRotX + *(float *)&sRotY); - v40 = v20; - if ( v20 <= 1.0 ) - { - *(float *)&sRotX = 0.0; - *(float *)&sRotY = 0.0; - } - else - { - sRotY = (signed __int64)sqrt(*(float *)&sRotX + *(float *)&sRotY); - sRotX = stru_5C6E00->Atan2((signed __int64)*(float *)&a4, (signed __int64)v33); - sRotY = stru_5C6E00->Atan2(sRotY, (signed __int64)v41); - } - v21 = 256; - if ( v40 < 256.0 ) - v21 = (signed __int64)v40 / 4; - *(int *)&v22[8] = v15; - *(_QWORD *)v22 = __PAIR__(v38, v14); - Vec3_int_::Rotate(v21, sRotX, sRotY, *(Vec3_int_ *)v22, &pOut.x, &pOut.z, &pOut.y); - v23 = (unsigned int *)(&v29 + v35); - sub_42F7EB_DropItemAt(*v23, pOut.x, pOut.z, pOut.y, 0, 1, 0, 0x30u, 0); - - LayingItem a1; // [sp+14h] [bp-B0h]@28 - //LayingItem::LayingItem(&a1); - - a1.stru_24.Reset(); - v24 = *(short *)v23; - v25 = 0; - a1.field_50 = 0; - a1.field_4C = 0; - a1.field_48 = 0; - a1.field_54 = 0; - a1.uItemType = v24; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_32: - v27 = 0; - } - else - { - v26 = (char *)&pObjectList->pObjects->uObjectID; - while ( v24 != *(short *)v26 ) - { - ++v25; - v26 += 56; - if ( v25 >= (signed int)pObjectList->uNumObjects ) - goto LABEL_32; - } - v27 = v25; - } - a1.uObjectDescID = v27; - a1.vPosition.y = pOut.z; - a1.vPosition.x = pOut.x; - a1.vPosition.z = pOut.y; - a1.uSoundID = 0; - a1.uAttributes = 48; - a1.uSectorID = pIndoor->GetSector(pOut.x, pOut.z, pOut.y); - a1.uSpriteFrameID = 0; - a1.field_58_pid = 0; - a1.field_5C = 0; - a1.uFacing = 0; - a1.Create(0, 0, 0, 0); - pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); - a1._438E35(); - *v34 &= 0xFEu; - if ( uActiveCharacter && !qword_A750D8 && !dword_507CD8 ) - { - qword_A750D8 = 256i64; - word_A750E0 = 5; - word_A750E2 = uActiveCharacter; - } - pIcons_LOD->_4114F2(); - dword_507CD8 = 0; - return 0; - } - *v1 &= 0xFEu; - sRotY = 1; -LABEL_12: - pAudioPlayer->StopChannels(-1, -1); - pAudioPlayer->PlaySound((SoundID)208, 0, 0, -1, 0, 0, 0, 0); - if ( *(float *)&sRotY != 0.0 ) - { - if ( !dword_507CD8 ) - pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0); - } - dword_507CD8 = 0; - v3 = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Chest, a4, 0); - pGUIWindow_CurrentMenu = v3; - pChestWindow = v3; - pBtn_ExitCancel = v3->CreateButton( - 0x1D7u, - 0x1BDu, - 0xA9u, - 0x23u, - 1, - 0, - 0x71u, - 0, - 0, - pGlobalTXT_LocalizationStrings[79],// Exit - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), - 0); - pChestWindow->CreateButton(7u, 8u, 460u, 343u, 1, 0, 0xCu, 0, 0, "", 0); - pCurrentScreen = SCREEN_CHEST; - pEventTimer->Pause(); - return 1; -} - -//----- (0042092D) -------------------------------------------------------- -void Chest::DrawChestUI(unsigned int uChestID) -{ - Render *v1; // edi@1 - unsigned int v2; // ebx@1 - unsigned int v3; // ebx@1 - int v4; // eax@1 - unsigned int v5; // eax@1 - int v6; // ecx@3 - unsigned int v7; // eax@4 - Texture *v8; // esi@4 - signed int v9; // ecx@4 - signed int v10; // edx@4 - signed int v11; // eax@4 - int v12; // eax@6 - int v13; // eax@6 - unsigned int v14; // ST34_4@8 - int v15; // edi@8 - int *v16; // [sp+Ch] [bp-28h]@1 - int v17; // [sp+10h] [bp-24h]@4 - int v18; // [sp+14h] [bp-20h]@1 - signed int v19; // [sp+18h] [bp-1Ch]@1 - int v20; // [sp+1Ch] [bp-18h]@1 - signed int v21; // [sp+20h] [bp-14h]@1 - char *v22; // [sp+2Ch] [bp-8h]@2 - signed int v23; // [sp+30h] [bp-4h]@1 - - v1 = pRenderer; - v2 = uChestID; - v16 = pRenderer->pActiveZBuffer; - pRenderer->ClearZBuffer(0, 479); - v3 = v2; - v4 = pChests[v3].uChestBitmapID; - v20 = pChestSmthn1ByType[v4]; - v18 = pChestSmthn2ByType[v4]; - v21 = pChestWidthsByType[v4]; - v19 = pChestHeightsByType[v4]; - sprintf(pTmpBuf, "chest%02d", pChestList->pChests[pChests[v3].uChestBitmapID].uTextureID); - v5 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE); - pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0)); - v23 = 0; - if ( v21 * v19 > 0 ) - { - v22 = (char *)pChests[v3].pInventoryIndices; - do - { - v6 = *(short *)v22; - if ( v6 > 0 ) - { - v17 = v18 + 32 * v23 / v19; - v7 = pIcons_LOD->LoadTexture( - pItemsTable->pItems[*(int *)((char *)&pOtherOverlayList->pOverlays[49].field_4 + 36 * v6 + v3 * 5324)].pIconName, - TEXTURE_16BIT_PALETTE); - v8 = (Texture *)(v7 != -1 ? &pIcons_LOD->pTextures[v7] : 0); - v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24); - v10 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureHeight : 26); - v11 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24); - if ( v9 < 14 ) - v11 = 14; - v12 = v11 - 14; - LOBYTE(v12) = v12 & 0xE0; - v13 = v12 + 32; - if ( (signed int)v8->uTextureHeight < 14 ) - v10 = 14; - v14 = v20 + 32 * v23 % v21 + ((v13 - v9) >> 1); - v15 = v17 + ((((v10 - 14) & 0xFFFFFFE0) - v8->uTextureHeight + 32) >> 1); - pRenderer->DrawTextureTransparent( - v14, - v17 + ((((v10 - 14) & 0xFFFFFFE0) - v8->uTextureHeight + 32) >> 1), - v8); - sub_40F92A(&v16[v14 + pSRZBufferLineOffsets[v15]], v8, v23 + 1); - v1 = pRenderer; - } - ++v23; - v22 += 2; - } - while ( v23 < v21 * v19 ); - } - pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0)); -} - //----- (00420B13) -------------------------------------------------------- void __fastcall sub_420B13(int a1, int a2) { @@ -4747,7 +4083,7 @@ v5 = 5324 * (int)v0 + 36 * v4; if ( pItemsTable->pItems[*(unsigned int *)((char *)&pChests[0].mm7__vector_pItems[0].uItemID + v5)].uEquipType == 18 ) { - party_finds_gold(*(int *)((char *)&pChests[0].mm7__vector_pItems[0].uAdditionalValue + v5), 0); + party_finds_gold(*(int *)((char *)&pChests[0].mm7__vector_pItems[0].uSpecEnchantmentType + v5), 0); viewparams->bRedrawGameUI = 1; } else @@ -4918,7 +4254,7 @@ uLastPointedObjectID = pMouse->uPointingObjectID; return; } - v22 = _444732_GetEventHintString(v25); + v22 = GetEventHintString(v25); if ( !v22 ) //goto _return; { @@ -4956,7 +4292,7 @@ { v21 = pOutdoor->pBModels[(signed int)(unsigned __int16)v18 >> 9].pFaces[v19 & 0x3F].sCogTriggeredID; //goto LABEL_71; - if ( !v21 || (v22 = _444732_GetEventHintString(v21)) == 0 ) + if ( !v21 || (v22 = GetEventHintString(v21)) == 0 ) //goto LABEL_73; { pMouse->uPointingObjectID = 0; @@ -4993,7 +4329,7 @@ { v21 = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID; //LABEL_71: - if ( !v21 || (v22 = _444732_GetEventHintString(v21)) == 0 ) + if ( !v21 || (v22 = GetEventHintString(v21)) == 0 ) //goto LABEL_73; { pMouse->uPointingObjectID = 0; @@ -5207,13 +4543,14 @@ return; } v38 = pButton->uControlParam; - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = pMessageType3; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v38; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ + pMessageQueue_50CBD0->AddMessage(pMessageType3, v38, 0); //goto LABEL_131; uLastPointedObjectID = 1; return; @@ -5241,11 +4578,12 @@ v36 = pButton->uControlParam; if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = pMessageType2; + pMessageQueue_50CBD0->AddMessage(pMessageType2, v36, 0); + /*pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = pMessageType2; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v36; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; //goto LABEL_27; - ++pMessageQueue_50CBD0->uNumMessages; + ++pMessageQueue_50CBD0->uNumMessages;*/ v13 = pButton->pButtonName; sub_41C0B8_set_status_string(v13); uLastPointedObjectID = 1; @@ -5332,14 +4670,15 @@ if ( pMessageType1 ) { v12 = pButton->uControlParam; - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + pMessageQueue_50CBD0->AddMessage(pMessageType1, v12, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = pMessageType1; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v12; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; //LABEL_27: ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ } //LABEL_28: v13 = pButton->pButtonName; @@ -5368,13 +4707,14 @@ if ( pMessageType1 ) { v12 = pButton->uControlParam; - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + pMessageQueue_50CBD0->AddMessage(pMessageType1, v12, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = pMessageType1; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v12; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ } v13 = pButton->pButtonName; sub_41C0B8_set_status_string(v13); @@ -5902,7 +5242,7 @@ v23 = pLayingItems[v21].stru_24.uItemID; if ( pItemsTable->pItems[v23].uEquipType == 18 ) { - party_finds_gold(v22->uAdditionalValue, 0); + party_finds_gold(v22->uSpecEnchantmentType, 0); viewparams->bRedrawGameUI = 1; } else @@ -5916,7 +5256,7 @@ if ( !pParty->AddItem(v22) ) pParty->SetHoldingItem(v22); } - LayingItem::_42F933(a2.y); + LayingItem::OnItemPickup(a2.y); return; } goto LABEL_13; @@ -6059,13 +5399,15 @@ } return; } - if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) return; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)161; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v18; LABEL_42: *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; + return;*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v18, 0); return; } if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 ) @@ -6073,11 +5415,12 @@ pTurnEngine->field_18 |= 8u; return; } - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)23; goto LABEL_41; - } + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); } else { @@ -6087,13 +5430,14 @@ return; } if ( uActiveCharacter - && sub_427769_spell(pPlayers[uActiveCharacter]->uQuickSpell) - && (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + && sub_427769_spell(pPlayers[uActiveCharacter]->uQuickSpell)) { + pMessageQueue_50CBD0->AddMessage(UIMSG_19, 0, 0); + /*&& (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)25; LABEL_41: pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - goto LABEL_42; + goto LABEL_42;*/ } } } @@ -6115,21 +5459,16 @@ // 4E28F8: using guessed type int pCurrentScreen; //----- (004226EF) -------------------------------------------------------- -void __fastcall SetUserInterface(int a1, bool bReplace) +void SetUserInterface(PartyAlignment align, bool bReplace) { - int v2; // ecx@2 unsigned int v3; // eax@7 unsigned __int16 v4; // dx@7 unsigned __int16 v5; // cx@7 unsigned __int16 v6; // [sp-4h] [bp-14h]@7 - if ( a1 ) - { - v2 = a1 - 1; - if ( v2 ) + + if (align == PartyAlignment_Evil) { - if ( v2 != 1 ) - return; if ( bReplace ) { pTexture_RightFrame->Reload("ib-r-C.pcx"); @@ -6213,7 +5552,7 @@ v6 = 0; v5 = 10; } - else + else if (align == PartyAlignment_Neutral) { if ( bReplace ) { @@ -6309,8 +5648,7 @@ v5 = 230; v6 = 193; } - } - else + else if (align == PartyAlignment_Good) { if ( bReplace ) { @@ -6361,6 +5699,8 @@ v4 = 225; v6 = 255; } + else assert(false); + uGameUIFontMain = v3; uGameUIFontShadow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v5, v4, v6); } @@ -6932,7 +6272,6 @@ return v55; } - //----- (00424579) -------------------------------------------------------- int __fastcall sub_424579(int uFaceID, stru320 *a2) {
--- a/mm7_2.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/mm7_2.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -222,13 +222,14 @@ if ( v1 <= 0 ) { LABEL_8: - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ return; } if ( v1 > pParty->uNumGold ) @@ -328,13 +329,14 @@ if ( !v6 ) { LABEL_17: - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ return; } if ( v6 > pParty->uNumGold ) @@ -415,7 +417,7 @@ // F8B19C: using guessed type int dword_F8B19C; //----- (004B8285) -------------------------------------------------------- -void __cdecl sub_4B8285_prolly_draw_arcomage_result()//Maybe TavernDialogue +void __cdecl TavernDialog() { GUIWindow *v0; // ebx@1 Player *v1; // edi@1 @@ -638,12 +640,13 @@ pVideoPlayer->Unload(); window_SpeakInHouse->Release(); window_SpeakInHouse = 0; + if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - pMessageQueue_50CBD0->pMessages[0].eType = (UIMessageType)409; + pMessageQueue_50CBD0->pMessages[0].eType = UIMSG_OpenRestUI; pMessageQueue_50CBD0->pMessages[0].param = v27; pMessageQueue_50CBD0->pMessages[0].field_8 = 1; -LABEL_51: +//LABEL_51: ++pMessageQueue_50CBD0->uNumMessages; return; } @@ -754,12 +757,9 @@ HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 3); v5 = 1; LABEL_43: - if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) - return; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v5; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - goto LABEL_51; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0); + return; + //goto LABEL_51; } } ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); @@ -961,7 +961,7 @@ if ( v2 <= 41 ) { v4 = word_4F0576[v2]; - v9 = 22; + v9 = 22; //misc goto LABEL_12; } if ( v2 <= 53 ) @@ -969,19 +969,19 @@ if ( v1 >= 6 ) { v4 = word_4F0578[v2]; - v9 = 45; + v9 = 45; //reagent LABEL_12: v5 = v9; LABEL_13: - pItemsTable->GenerateItem(v4, v5, (ItemGen *)&pParty->field_777C[9 * (v1 + 12 * v2)]); + pItemsTable->GenerateItem(v4, v5, (ItemGen *)&pParty->field_777C[v2][v1]);//9 * (v1 + 12 * v2)]); v0 = window_SpeakInHouse; - pParty->field_777C[9 * (v1 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 5] = 1; + pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v1].uAttributes = 1; //identified goto LABEL_14; } - auto _t = (ItemGen *)&pParty->field_777C[9 * (v1 + 12 * v2)]; + auto _t = (ItemGen *)&pParty->field_777C[v2][v1]; _t->Reset(); v0 = window_SpeakInHouse; - pParty->field_777C[9 * (v1 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] = 220; + pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v1].uItemID = 220; //potion bottle } LABEL_14: v2 = (signed int)v0->ptr_1C; @@ -992,8 +992,8 @@ } v3 = 5 * v2; v2 = (signed int)v0->ptr_1C; - v4 = word_4F03FE[v3]; - v5 = word_4F0400[5 * v2 + rand() % 4]; + v4 = word_4F0404[v3 - 4]; + v5 = word_4F0404[5 * v2 + rand() % 4 - 2]; goto LABEL_13; } LABEL_15: @@ -1005,7 +1005,7 @@ //----- (004B910F) -------------------------------------------------------- -char *__cdecl _4B910F_shop_interaction() +char *__cdecl WeaponShopDialog() { Player *v0; // ebx@1 char *result; // eax@6 @@ -1486,52 +1486,53 @@ v3 = 0; if ( dword_F8B19C == 2 ) { - //v48 = 0; + v48 = 0; v108 = 0; - int a = 0; - //do - for (int i = 0; i < 6; i++) - { - if ( pParty->field_777C[9 * (i + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) - { - v49 = word_F8B158[i]; - v50 = dword_F8B168[i]; + v109 = 0; + do + { + // if ( pParty->field_777C[9 * (int)&v48[3 * (unsigned int)window_SpeakInHouse->ptr_1C]] ) + if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][(int)v48].uItemID); + { + v49 = word_F8B158[(signed int)v48]; + v50 = dword_F8B168[(signed int)v48]; v49 += 30; v51 = 60 - ((signed int)v50->uTextureWidth >> 1); pRenderer->DrawTextureTransparent(v51 + v108, v49, v50); sub_40F92A( &pRenderer->pActiveZBuffer[v51 + v108 + 640 * v49], - dword_F8B168[a], - a++); - i = a; + dword_F8B168[(signed int)v109], + (int)((char *)v109 + 1)); + v48 = v109; } v108 += 70; - i++; - a = i; - } - //while ( (signed int)v48 < 6 ); + v48 = (const char **)((char *)v48 + 1); + v109 = v48; + } + while ( (signed int)v48 < 6 ); } else { - //v109 = 0; + v109 = 0; v108 = 0; - //do - for (int i = 0; i < 6; i++) - { - if ( pParty->field_C59C[9 * (i + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) - { - v52 = word_F8B158[i] + 30; - v53 = dword_F8B168[i]; + do + { + // if ( pParty->field_C59C[9 * (int)&v109[3 * (unsigned int)window_SpeakInHouse->ptr_1C] + 724] ) + if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v109].uItemID) + { + v52 = word_F8B158[(signed int)v109] + 30; + v53 = dword_F8B168[(signed int)v109]; v54 = 60 - ((signed int)v53->uTextureWidth >> 1); - pRenderer->DrawTextureTransparent(v54 + v108, word_F8B158[i] + 30, v53); - sub_40F92A(&pRenderer->pActiveZBuffer[v54 + v108 + 640 * v52], - dword_F8B168[i], - i++); - } - i++; + pRenderer->DrawTextureTransparent(v54 + v108, word_F8B158[(signed int)v109] + 30, v53); + sub_40F92A( + &pRenderer->pActiveZBuffer[v54 + v108 + 640 * v52], + dword_F8B168[(signed int)v109], + (int)((char *)v109 + 1)); + } + v109 = (const char **)((char *)v109 + 1); v108 += 70; } - //while ( (signed int)v109 < 6 ); + while ( (signed int)v109 < 6 ); } result = (char *)sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); if ( result ) @@ -1543,7 +1544,7 @@ v106.x = 0; do { - if ( pParty->field_777C[9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) + if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID);//9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) ++v106.x; ++v55; } @@ -1553,7 +1554,8 @@ { do { - if ( pParty->field_C59C[9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) + // if ( pParty->field_C59C[9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) + if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID) ++v106.x; ++v55; } @@ -1582,10 +1584,10 @@ v60 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1; v106.x = v60; v61 = (int)window_SpeakInHouse->ptr_1C; - v62 = 9 * (v60 + 12 * v61); - v63 = (ItemGen *)&pParty->field_777C[v62]; + // v62 = 9 * (v60 + 12 * v61); + v63 = (ItemGen *)&pParty->field_777C[(int)v61][v60]; if ( dword_F8B19C != 2 ) - v63 = (ItemGen *)&pParty->field_C59C[v62 + 724]; + v63 = &pParty->Recipes_Item[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724]; if ( !v56 || !Str ) { v85 = 0; @@ -1620,7 +1622,7 @@ //----- (004B9CC6) -------------------------------------------------------- -POINT *__cdecl sub_4B9CC6() +POINT *__cdecl AlchemistDialog() { Player *v0; // ebx@1 POINT *result; // eax@7 @@ -2030,7 +2032,8 @@ { do { - if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) + // if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) + if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID); { v46 = dword_F8B168[v114]; v47 = 152 - v46->uTextureHeight; @@ -2060,7 +2063,8 @@ v114 = 0; do { - if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 54] ) + // if ( pParty->field_777C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 54] ) + if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v114+1].uItemID); { v50 = dword_F8B168[v114 + 6]; v51 = 308 - v50->uTextureHeight; @@ -2092,7 +2096,8 @@ { do { - if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) + //if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) + if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID) { v54 = dword_F8B168[v114]; v55 = 152 - v54->uTextureHeight; @@ -2122,7 +2127,8 @@ v114 = 0; do { - if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 778] ) + // if ( pParty->field_C59C[9 * (v114 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 778] ) //weak + if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v114].uItemID) //not itemid { v58 = dword_F8B168[v114 + 6]; v59 = 308 - v58->uTextureHeight; @@ -2159,7 +2165,8 @@ { do { - if ( pParty->field_777C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) + // if ( pParty->field_777C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) + if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID); ++v109; ++v62; } @@ -2169,7 +2176,8 @@ { do { - if ( pParty->field_C59C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) + //if ( pParty->field_C59C[9 * (v62 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) + if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID) ++v109; ++v62; } @@ -2202,10 +2210,10 @@ v67 = (pRenderer->pActiveZBuffer[(int)result] & 0xFFFF) - 1; v109 = v67; v68 = (int)window_SpeakInHouse->ptr_1C; - v69 = 9 * (v67 + 12 * v68); - v70 = (ItemGen *)&pParty->field_777C[v69]; + // v69 = 9 * (v67 + 12 * v68); + v70 = (ItemGen *)&pParty->field_777C[v68][v67]; if ( dword_F8B19C != 2 ) - v70 = (ItemGen *)&pParty->field_C59C[v69 + 724]; + v70 = &pParty->Recipes_Item[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724]; if ( !v63 || !Str ) { v93 = 0; @@ -2232,7 +2240,7 @@ //----- (004BA928) -------------------------------------------------------- -void __cdecl sub_4BA928() +void __cdecl ArmorShopDialog() { Player *v0; // ebx@1 signed int v1; // esi@8 @@ -2409,7 +2417,8 @@ v93 = 0; do { - if ( pParty->field_C59C[9 * (v93 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) + // if ( pParty->field_C59C[9 * (v93 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) + if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v93].uItemID) ++v149; ++v93; } @@ -2424,9 +2433,9 @@ --v149; v96 = window_SpeakInHouse->ptr_1C; v97 = uActiveCharacter - 1; - v98 = (ItemGen *)&pParty->field_C59C[9 * (v95 - 1 + 12 * (int)v96) + 724]; + // v98 = (ItemGen *)&pParty->field_C59C[9 * (v95 - 1 + 12 * (int)v96) + 724]; v99 = _this->_490EEE( - (ItemGen *)&pParty->field_C59C[9 * (v95 - 1 + 12 * (int)v96) + 724], + &pParty->Recipes_Item[(int)v96][v95-1],// (ItemGen *)&pParty->field_C59C[9 * (v95 - 1 + 12 * (int)v96) + 724], 2, (int)window_SpeakInHouse->ptr_1C, 2); @@ -2440,7 +2449,8 @@ v153 = 0; do { - if ( pParty->field_C59C[9 * (v104 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) + //if ( pParty->field_C59C[9 * (v104 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) + if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v104].uItemID) { v105 = dword_F8B168[v104]; if ( v104 >= 4 ) @@ -2627,7 +2637,8 @@ v153 = 0; do { - if ( pParty->field_777C[9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) + // if ( pParty->field_777C[9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) + if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID); { v56 = dword_F8B168[v55]; if ( v55 >= 4 ) @@ -2661,7 +2672,8 @@ v153 = 0; do { - if ( (char *)pParty->field_C59C[9 * (v61 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] != v11 ) + // if ( (char *)pParty->field_C59C[9 * (v61 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] != v11 ) + if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v61].uItemID) { v62 = dword_F8B168[v61]; if ( v61 >= 4 ) @@ -2697,7 +2709,8 @@ { do { - if ( (char *)pParty->field_777C[9 * (v68 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] != v11 ) + // if ( (char *)pParty->field_777C[9 * (v68 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] != v11 ) + if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v68].uItemID); ++v149; ++v68; } @@ -2707,7 +2720,8 @@ { do { - if ( (char *)pParty->field_C59C[9 * (v68 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] != v11 ) + // if ( (char *)pParty->field_C59C[9 * (v68 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] != v11 ) + if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v68].uItemID) ++v149; ++v68; } @@ -2739,7 +2753,7 @@ if ( dword_F8B19C == 2 ) v77 = (ItemGen *)&pParty->field_777C[v76]; else - v77 = (ItemGen *)&pParty->field_C59C[v76 + 724]; + v77 = &pParty->Recipes_Item[(int)75][v74-1];//(ItemGen *)&pParty->field_C59C[v76 + 724]; if ( v69 == (short)v11 || Str == v11 ) { v124 = (__int64 *)v11; @@ -2967,13 +2981,14 @@ { if ( a1 == 41 ) { - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ dword_50C9DC = 195; ptr_50C9E0 = GetNPCData(uDialogue_SpeakingActorNPC_ID); return 0; @@ -3468,13 +3483,14 @@ pParty->sRotationY = 512; pParty->sRotationX = 0; pParty->uFallSpeed = 0; - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); v2 = pParty->pPlayers; do { @@ -3681,28 +3697,19 @@ //----- (004BCA33) -------------------------------------------------------- -GUIButton *__cdecl sub_4BCA33() +GUIButton *__cdecl UI_CreateEndConversationButton() { pDialogueWindow->Release(); - pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0); - pBtn_ExitCancel = pDialogueWindow->CreateButton( - 0x1D7u, - 0x1BDu, - 0xA9u, - 0x23u, - 1, - 0, - 0x71u, - 0, - 0, - pGlobalTXT_LocalizationStrings[74], - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), + pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0); + pBtn_ExitCancel = pDialogueWindow->CreateButton( 471, 445, 169, 35, 1, 0, 0x71u, 0, 0, + pGlobalTXT_LocalizationStrings[74], //"End Conversation" + (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : NULL), 0); - return pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, "", 0); + return pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, 0x51u, 0, 0, "", 0); } //----- (004BCACC) -------------------------------------------------------- -void __fastcall sub_4BCACC_bounties(signed int a1)//Shop_MsgUI +void __fastcall sub_4BCACC_bounties(signed int a1) { unsigned int v1; // edi@1 //signed int v2; // ebx@1 @@ -4092,12 +4099,12 @@ { case 96: pDialogueWindow->eWindowType = WINDOW_MainMenu; - sub_4BCA33(); + UI_CreateEndConversationButton(); sub_4B3703((void *)dword_F8B198); break; case 101: pDialogueWindow->eWindowType = WINDOW_MainMenu; - sub_4BCA33(); + UI_CreateEndConversationButton(); sub_4B3A72(dword_F8B198); break; case 102: @@ -4107,13 +4114,14 @@ dword_F8B19C = 103; break; case 104: - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)29; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v1; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = v1; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_PlayArcomage, v1, v1); dword_F8B19C = 104; break; } @@ -4183,7 +4191,7 @@ if ( a1 == 94 ) { pDialogueWindow->eWindowType = WINDOW_MainMenu; - sub_4BCA33(); + UI_CreateEndConversationButton(); sub_4B3AD4(dword_F8B198); } } @@ -4222,7 +4230,7 @@ { do { - v45 = pParty->field_777C[9 * (v43 + 12 * (int)v42)]; + v45 = pParty->field_777C[(int)v42][v43].uItemID; if ( v45 ) { v46 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v45].pIconName, TEXTURE_16BIT_PALETTE); @@ -4245,7 +4253,8 @@ { do { - if ( pParty->field_777C[9 * (v48 + 12 * (int)v47)] ) + // if ( pParty->field_777C[9 * (v48 + 12 * (int)v47)] ) + if ( pParty->field_777C[(int)v47][v48].uItemID); { v49 = rand(); v8 = window_SpeakInHouse; @@ -4265,7 +4274,8 @@ { do { - v50 = pParty->field_C59C[9 * (v43 + 12 * (int)v42) + 724]; + //v50 = pParty->field_C59C[9 * (v43 + 12 * (int)v42) + 724]; + v50=pParty->Recipes_Item[(unsigned int)v42][(signed int)v43].uItemID; if ( v50 ) { v51 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v50].pIconName, TEXTURE_16BIT_PALETTE); @@ -4288,7 +4298,8 @@ { do { - if ( pParty->field_C59C[9 * (v53 + 12 * (int)v52) + 724] ) + // if ( pParty->field_C59C[9 * (v53 + 12 * (int)v52) + 724] ) + if (pParty->Recipes_Item[(unsigned int)v52][v53].uItemID) { v54 = rand(); v8 = window_SpeakInHouse; @@ -4318,7 +4329,7 @@ pKeyActionMap->ResetKeys(); _5C3420_pDecoration = 0; ptr_F8B1E8 = 0; - if ( array_5913D8[6] ) + if ( pDialogueNPCCount ) { v0 = dword_F8B19C; if ( dword_F8B19C != 2 @@ -4336,7 +4347,7 @@ { if ( v0 == -1 ) { - _4B4224_UpdateNPCTopics((int)((char *)array_5913D8[6] - 1)); + _4B4224_UpdateNPCTopics((int)((char *)pDialogueNPCCount - 1)); LABEL_33: pVideoPlayer->_4BF5B2(); return 1; @@ -4345,7 +4356,7 @@ { if ( v0 == 3 || v0 == 5 || v0 == 4 ) { - sub_4BCA33(); + UI_CreateEndConversationButton(); dword_F8B19C = 94; sub_4B3AD4(dword_F8B198); } @@ -4360,17 +4371,17 @@ return 1; } pVideoPlayer->_4BF5B2(); - sub_4BCA33(); + UI_CreateEndConversationButton(); dword_F8B19C = 101; sub_4B3A72(dword_F8B198); } return 1; } pVideoPlayer->_4BF5B2(); - sub_4BCA33(); + UI_CreateEndConversationButton(); goto LABEL_28; } - array_5913D8[6] = 0; + pDialogueNPCCount = 0; pDialogueWindow->Release(); dword_F8B19C = 0; pDialogueWindow = 0; @@ -4385,7 +4396,7 @@ v3 = byte_591180; do { - array_5913D8[v2 + 7] = (NPCData *)window_SpeakInHouse->CreateButton(*(&pNPCPortraits_x + v2 + 6 * v1 - 6), *(&pNPCPortraits_y + v2 + 6 * v1 - 6), + HouseNPCData[v2 + 7] = (NPCData *)window_SpeakInHouse->CreateButton(pNPCPortraits_x[v1 - 1][v2], pNPCPortraits_y[v1 - 1][v2], 0x3Fu, 0x49u, 1, 0, 0x19Au, v2, 0, v3, 0, 0, 0); v1 = uNumDialogueNPCPortraits; ++v2; @@ -4598,16 +4609,16 @@ if ( !v29 ) return; v30 = window_SpeakInHouse->ptr_1C; - v31 = 9 * (v29 - 1 + 12 * (int)v30); + // v31 = 9 * (v29 - 1 + 12 * (int)v30); if ( dword_F8B19C == 2 ) { - v32 = (ItemGen *)&pParty->field_777C[v31]; - _this = (ItemGen *)&pParty->field_777C[v31]; + v32 = (ItemGen *)&pParty->field_777C[(int)v30][v29]; + _this = (ItemGen *)&pParty->field_777C[(int)v30][v29]; } else { - _this = (ItemGen *)&pParty->field_C59C[v31 + 724]; - v32 = (ItemGen *)&pParty->field_C59C[v31 + 724]; + _this =&pParty->Recipes_Item[(int)v30][v29-1]; //(ItemGen *)&pParty->field_C59C[v31 + 724]; + v32 = &pParty->Recipes_Item[(int)v30][v29-1];//(ItemGen *)&pParty->field_C59C[v31 + 724]; } //v33 = p2DEvents_minus1__20[13 * (signed int)v30]; v33 = p2DEvents[(signed int)v30 - 1].fPriceMultiplier; @@ -5208,24 +5219,28 @@ } if ( v15 ) { - if ( (signed int)result < 40 ) - { - pMessageQueue_50CBD0->pMessages[result].eType = (UIMessageType)132; + /*if ( (signed int)result < 40 ) + { + pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_Quit; goto LABEL_42; - } + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Quit, 1, 0); + goto LABEL_43; } else { - if ( (signed int)result < 40 ) - { - pMessageQueue_50CBD0->pMessages[result].eType = (UIMessageType)197; + pMessageQueue_50CBD0->AddMessage(UIMSG_ShowFinalWindow, 1, 0); + goto LABEL_43; + /*if ( (signed int)result < 40 ) + { + pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_C5; LABEL_42: pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; result = 3 * pMessageQueue_50CBD0->uNumMessages + 3; *(&pMessageQueue_50CBD0->uNumMessages + result) = 0; ++pMessageQueue_50CBD0->uNumMessages; goto LABEL_43; - } + }*/ } LABEL_43: bGameoverLoop = 0; @@ -7921,9 +7936,9 @@ v4 = rand(); v34 = 0; v5 = v4 % 100; - v6 = 2 * (v2->Treasure_prob + 7 * v3->uIndex) - 14; - v7 = (unsigned __int8)byte_4E8168[v6 + 16]; - v8 = (unsigned __int8)byte_4E8168[v6 + 17]; + // v6 = 2 * (v2->Treasure_prob + 7 * v3->uIndex) - 14; + v7 = (unsigned __int8)byte_4E8168[v3->uIndex-1][2*v2->Treasure_prob]; + v8 = (unsigned __int8)byte_4E8168[v3->uIndex-1][2*v2->Treasure_prob+1]; v32 = v5; v33 = v7; v9 = rand(); @@ -7990,7 +8005,7 @@ } a1a.stru_24.SetIdentified(); a1a.uObjectDescID = v18; - a1a.stru_24.uAdditionalValue = v34; + a1a.stru_24.uSpecEnchantmentType = v34; goto LABEL_35; } v14 = rand() % 3001 + 2000; @@ -8099,8 +8114,8 @@ if ( (v3->uItemID & 0x80000000u) == 0 ) goto LABEL_56; v4 = rand() % 5 + 1; - v5 = (unsigned __int8)byte_4E8168[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 2]; - v6 = (unsigned __int8)byte_4E8168[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 3]; + v5 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 2]; + v6 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob+1];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 3]; v7 = rand(); v8 = v6 - v5 + 1; v9 = v5 + v7 % v8; @@ -8148,7 +8163,7 @@ } LABEL_23: v3->SetIdentified(); - v3->uAdditionalValue = v10; + v3->uSpecEnchantmentType = v10; LABEL_25: v11 = v4 - 1; v12 = 0; @@ -8213,7 +8228,7 @@ v14->uItemID = 199; } LABEL_49: - v14->uAdditionalValue = v17; + v14->uSpecEnchantmentType = v17; LABEL_51: v12 = v13 + 1; LABEL_52: @@ -11014,13 +11029,14 @@ { pGUIWindow_CurrentMenu->field_40 = 0; strcpy((char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot, (const char *)pKeyActionMap->pPressedKeysBuffer); - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)83; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_SaveGame, 0, 0); } else { @@ -11671,7 +11687,7 @@ //HDC v9; // edi@41 HDC v10; // edi@50 int v11; // esi@50 - char v12; // zf@132 + //char v12; // zf@132 signed int v13; // eax@135 int v14; // eax@139 int v15; // eax@140 @@ -11937,8 +11953,8 @@ v37 = 0; v36 = 2; v35 = ::hWnd; -LABEL_104: - SendMessageA(v35, v36, v37, v38); +//LABEL_104: + SendMessageA(::hWnd, WM_DESTROY, v37, v38); return 0; } if ( dword_506E68 != -1 ) @@ -11950,37 +11966,39 @@ { if ( pVideoPlayer->pVideoFrame.pPixels ) pVideoPlayer->bStopBeforeSchedule = 1; - if ( wParam != 13 ) - { - if ( wParam == 17 ) + if ( wParam != VK_RETURN ) + { + if ( wParam == VK_CONTROL ) { dword_507B98_ctrl_pressed = 1; return 0; } - if ( wParam == 27 ) - { - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + if ( wParam == VK_ESCAPE ) + { + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, window_SpeakInHouse != 0, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { v12 = window_SpeakInHouse == 0; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = !v12; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ return 0; } - if ( wParam <= 0x24 ) + if ( wParam <= VK_HOME ) return 0; - if ( wParam > 0x28 ) - { - if ( wParam != 115 || pVideoPlayer->AnyMovieLoaded() ) + if ( wParam > VK_DOWN ) + { + if ( wParam != VK_F4 || pVideoPlayer->AnyMovieLoaded() ) return 0; v38 = 0; v37 = 104; LABEL_126: v36 = 273; v35 = hWnd; - goto LABEL_104; + SendMessageA(hWnd, WM_COMMAND, v37, v38); + return 0; } if ( pCurrentScreen && pCurrentScreen != SCREEN_PRESS_ESCAPE_MESSAGE ) @@ -12434,7 +12452,7 @@ v9 = bLoading; ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); pDecalBuilder->Reset(0); - pGameLoadingUI_ProgressBar->_443484((GUIProgressBar::Type)v2); + pGameLoadingUI_ProgressBar->Initialize((GUIProgressBar::Type)v2); strcpy(Str1, pCurrentMapName); v3 = strtok(Str1, "."); strcpy(Str1, v3); @@ -13432,7 +13450,7 @@ Rect.bottom = 246; ClipCursor(&Rect); } - SetUserInterface(1, false); + SetUserInterface(PartyAlignment_Neutral, false); ShowIntroVideo_and_LoadingScreen(); WriteWindowsRegistryInt("Ran once", 1); dword_6BE364_game_settings_1 |= 0x4000; @@ -13807,7 +13825,6 @@ aborting_app = 1; if ( !pRenderer->bWindowMode ) pRenderer->ChangeBetweenWinFullscreenModes(); - __debugbreak; if ( MessageBoxA(0, pGlobalTXT_LocalizationStrings[176], pGlobalTXT_LocalizationStrings[59], 0x34u) == 6 ) SaveGame(1, 0); // "Internal Error" // "Might and Magic VII has detected an internal error and will be forced to close. Would you like us to autosave your game before closing?" @@ -15166,7 +15183,7 @@ v2 = a1; switch ( a1 & 7 ) { - case OBJECT_Item: + case OBJECT_Item: // take the item v17 = a1 >> 3; v26 = a1 >> 3; v18 = a1 >> 3; @@ -15176,9 +15193,9 @@ return 1; v19 = &pLayingItems[v18].stru_24; v20 = pLayingItems[v18].stru_24.uItemID; - if ( pItemsTable->pItems[v20].uEquipType == 18 ) - { - party_finds_gold(v19->uAdditionalValue, 0); + if ( pItemsTable->pItems[v20].uEquipType == EQUIP_GOLD) + { + party_finds_gold(v19->uSpecEnchantmentType, 0); viewparams->bRedrawGameUI = 1; v21 = v17; } @@ -15197,7 +15214,7 @@ pParty->SetHoldingItem(v19); v21 = v26; } - LayingItem::_42F933(v21); + LayingItem::OnItemPickup(v21); break; case OBJECT_Actor: @@ -15217,13 +15234,14 @@ Actor::FaceObject(v12, 4u, 0, 0); if ( v13->uNPC_ID ) { - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v12, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)161; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v12; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ } else { @@ -15707,7 +15725,7 @@ } if ( v22 ) { - v23 = _444732_GetEventHintString(v22); + v23 = GetEventHintString(v22); if ( v23 ) goto LABEL_36; } @@ -15722,7 +15740,7 @@ v27 = v25->field_16_event_id; if ( v27 ) { - v23 = _444732_GetEventHintString(v27); + v23 = GetEventHintString(v27); if ( !v23 ) return v19; goto LABEL_36; @@ -16128,7 +16146,7 @@ } v2->uObjectDescID = v112; if ( !v112 ) - LayingItem::_42F933(v153); + LayingItem::OnItemPickup(v153); v2->vVelocity.z = 0; v2->vVelocity.y = 0; v2->vVelocity.x = 0; @@ -16151,7 +16169,7 @@ goto LABEL_269; } LABEL_246: - LayingItem::_42F933(v153); + LayingItem::OnItemPickup(v153); return 0; } v106 = v145; @@ -16298,7 +16316,7 @@ } v2->uObjectDescID = v58; if ( !v58 ) - LayingItem::_42F933(v153); + LayingItem::OnItemPickup(v153); v14 = v153; v2->vVelocity.z = 0; v2->vVelocity.y = 0; @@ -16354,7 +16372,7 @@ } v2->uObjectDescID = v63; if ( !v63 ) - LayingItem::_42F933(v153); + LayingItem::OnItemPickup(v153); v64 = v2->uFacing - stru_5C6E00->uIntegerDoublePi; v44 = v2->field_50 == 4; v2->vVelocity.z = 0; @@ -16377,7 +16395,7 @@ LABEL_160: v14 = v153; LABEL_34: - LayingItem::_42F933(v14); + LayingItem::OnItemPickup(v14); goto LABEL_35; } if ( v151 == 6 || v151 == 5 || (v66 = 0, !v151) ) @@ -16407,7 +16425,7 @@ } v2->uObjectDescID = v71; if ( !v71 ) - LayingItem::_42F933(v153); + LayingItem::OnItemPickup(v153); v134 = 0; v72 = v153; v132 = 0; @@ -16463,7 +16481,7 @@ } v2->uObjectDescID = v88; if ( !v88 ) - LayingItem::_42F933(v153); + LayingItem::OnItemPickup(v153); v89 = v2->uFacing - stru_5C6E00->uIntegerDoublePi; v2->vVelocity.z = 0; v2->vVelocity.y = 0; @@ -16510,7 +16528,7 @@ } v2->uObjectDescID = v83; if ( !v83 ) - LayingItem::_42F933(v153); + LayingItem::OnItemPickup(v153); v134 = 0; v72 = v153; v132 = v2->field_61; @@ -16555,7 +16573,7 @@ LABEL_42: v2->uObjectDescID = v22; if ( v22 == v18 ) - LayingItem::_42F933(v153); + LayingItem::OnItemPickup(v153); v2->vVelocity.z = v18; v2->vVelocity.y = v18; v2->vVelocity.x = v18; @@ -16585,7 +16603,7 @@ break; case 545: case 550: - if ( v2->stru_24.uItemID != 405 && v2->stru_24.uAdditionalValue != 3 ) + if ( v2->stru_24.uItemID != 405 && v2->stru_24.uSpecEnchantmentType != 3 ) { v14 = v153; v9 = 0; @@ -16632,7 +16650,7 @@ LABEL_24: v2->uObjectDescID = v12; if ( !v12 ) - LayingItem::_42F933(v153); + LayingItem::OnItemPickup(v153); v44 = v2->uItemType == 555; v2->vVelocity.z = 0; v2->vVelocity.y = 0; @@ -16683,7 +16701,7 @@ LABEL_182: v2->uObjectDescID = v95; if ( v95 == (short)v9 ) - LayingItem::_42F933(v153); + LayingItem::OnItemPickup(v153); v96 = v2->uSoundID; v2->vVelocity.z = v9; v2->vVelocity.y = v9; @@ -16728,7 +16746,7 @@ } v2->uObjectDescID = v36; if ( !v36 ) - LayingItem::_42F933(v153); + LayingItem::OnItemPickup(v153); v37 = v2->vPosition.z; v2->vVelocity.z = 0; v38 = 8 * v153; @@ -16785,7 +16803,7 @@ LABEL_196: v2->uObjectDescID = v46; if ( v46 == (short)v32 ) - LayingItem::_42F933(v153); + LayingItem::OnItemPickup(v153); v100 = v2->field_61; v101 = v2->vPosition.z; v2->uSpriteFrameID = v32; @@ -16873,7 +16891,7 @@ } v2->uObjectDescID = v121; if ( !v121 ) - LayingItem::_42F933(v153); + LayingItem::OnItemPickup(v153); v2->vVelocity.z = 0; v2->vVelocity.y = 0; v2->vVelocity.x = 0;
--- a/mm7_3.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/mm7_3.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -1165,7 +1165,7 @@ v31 = 0; for ( i = 0; v31 < ai_arrays_size; ++v31 ) { - v33 = ai_array_4F7DB0_actor_ids[v31]; + v33 = ai_near_actors_ids[v31]; if ( v33 != v75 && _46DF1A_collide_against_actor(v33, 40) ) ++i; } @@ -1229,7 +1229,7 @@ if ( v71 == v34 ) goto LABEL_99; LABEL_101: - Actor::_403F58(v75, 4, v34, (AIDirection *)v34); + Actor::AI_StandOrBored(v75, 4, v34, (AIDirection *)v34); break; } if ( v71 != v34 ) @@ -1448,7 +1448,7 @@ (v1->uSectorID = v4) == 0) || (v42 = _46CEC3_get_floor_level(v1->vPosition.x, v1->vPosition.y, v1->vPosition.z, v4, &uFaceID), v42 == -30000)) ) { - LayingItem::_42F933(uLayingItemID_); + LayingItem::OnItemPickup(uLayingItemID_); return; } v5 = v2->uFlags; @@ -1844,7 +1844,7 @@ if ( v55 ) v9 = v7 + 30; sub_42F960_create_object(v1->vPosition.x, v1->vPosition.y, v9); - LayingItem::_42F933(uLayingItemID_); + LayingItem::OnItemPickup(uLayingItemID_); v7 = v54; } } @@ -2035,7 +2035,7 @@ else v44 = v54 + 60; sub_42F960_create_object(v1->vPosition.x, v1->vPosition.y, v44); - LayingItem::_42F933(uLayingItemID_); + LayingItem::OnItemPickup(uLayingItemID_); return; } if ( stru_721530.field_7C >= stru_721530.field_6C ) @@ -2223,9 +2223,9 @@ { //v3 = item->uObjectDescID; v4 = &pObjectList->pObjects[item->uObjectDescID]; - if (item->uAttributes) - { - v5 = *(int *)(v2 + 62) >> 3; + if (item->AttachedToActor()) + { + v5 = item->field_5C >> 3; *(int *)(v2 - 26) = pActors[v5].vPosition.x; *(int *)(v2 - 22) = pActors[v5].vPosition.y; *(int *)(v2 - 18) = pActors[v5].vPosition.z + pActors[v5].uActorHeight; @@ -2253,7 +2253,7 @@ { v10 = i; LABEL_35: - LayingItem::_42F933(v10); + LayingItem::OnItemPickup(v10); goto LABEL_36; } v11 = v4->uLifetime; @@ -3407,10 +3407,10 @@ cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0); int dx = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; - v2 += dx; + v2 += dx * 12; int dy = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; - v1 += dy; + v1 += dy * 12; v128 = v1; v124 = 1; @@ -12099,9 +12099,9 @@ HIWORD(v22) = HIWORD(x); v15->_screenspace_y_scaler_packedfloat = v37; v15->field_1E = v30; - v15->some_x = a1; - v15->some_y = a2; - v15->some_z = a3; + v15->world_x = a1; + v15->world_y = a2; + v15->world_z = a3; v15->uScreenSpaceX = a5; v15->uScreenSpaceY = a6; v23 = 8 * v26; @@ -12198,10 +12198,9 @@ v5 = v4; v24 = v4; v30 = v4->uFlags; - a6 = v4->uGlowRadius * p->field_22; - v6 = stru_5C6E00->Atan2( - p->vPosition.x - pBLVRenderParams->vPartyPos.x, - p->vPosition.y - pBLVRenderParams->vPartyPos.y); + a6 = v4->uGlowRadius * p->field_22_glow_radius_multiplier; + v6 = stru_5C6E00->Atan2(p->vPosition.x - pBLVRenderParams->vPartyPos.x, + p->vPosition.y - pBLVRenderParams->vPartyPos.y); LOWORD(v7) = p->uFacing; v8 = v30; v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v7 - v6) >> 8) & 7; @@ -12274,9 +12273,9 @@ HIWORD(v21) = HIWORD(x); v3->_screenspace_y_scaler_packedfloat = v31; v3->field_1E = v34; - v3->some_x = a1; - v3->some_y = a2; - v3->some_z = a3; + v3->world_x = a1; + v3->world_y = a2; + v3->world_z = a3; v3->uScreenSpaceX = v36; v22 = v35; v3->uTintColor = 0; @@ -14466,7 +14465,7 @@ { if ( !(BYTE2(v12->uAttributes) & 0x10) ) { - v14 = _444732_GetEventHintString(v13); + v14 = GetEventHintString(v13); v15 = v14; if ( v14 ) { @@ -14567,7 +14566,7 @@ { if ( !(BYTE2(v11->uAttributes) & 0x10) ) { - v13 = _444732_GetEventHintString(v12); + v13 = GetEventHintString(v12); v14 = v13; if ( v13 ) { @@ -14604,11 +14603,10 @@ //----- (00444A51) -------------------------------------------------------- -char *__cdecl TransitionUI_Draw() +void TransitionUI_Draw() { MapInfo *pMapInfo; // esi@5 char *v1; // eax@6 - char *result; // eax@12 std::string v3; // [sp-18h] [bp-84h]@11 unsigned int v4; // [sp-10h] [bp-7Ch]@12 int v5; // [sp-Ch] [bp-78h]@12 @@ -14623,13 +14621,13 @@ v10 = pMapStats->GetMapInfo(pCurrentMapName); v9 = IndoorLocation::GetLocationIndex(dword_591164_teleport_map_name); pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background); - pRenderer->DrawTextureIndexed(pNPCPortraits_x - 4, pNPCPortraits_y - 4, (Texture *)(uTextureID_50795C != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_50795C] : 0)); - pRenderer->DrawTextureIndexed(pNPCPortraits_x, pNPCPortraits_y, pTexture_outside); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, pIcons_LOD->GetTexture(uTextureID_50795C)); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside); uTextureID_507B04 = uTextureID_right_panel; - pRenderer->DrawTextureTransparent(468, 0, (Texture *)(uTextureID_right_panel != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_right_panel] : 0)); - pRenderer->DrawTextureIndexed(556, 451, (Texture *)(uTextureID_x_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_x_u] : 0)); - pRenderer->DrawTextureIndexed(476, 451, (Texture *)(uTextureID_x_ok_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_ok_u] : 0)); - if ( (pVideoPlayer->AnyMovieLoaded() || v9) && *dword_591164_teleport_map_name != 48 ) + pRenderer->DrawTextureTransparent(468, 0, pIcons_LOD->GetTexture(uTextureID_right_panel)); + pRenderer->DrawTextureIndexed(556, 451, pIcons_LOD->GetTexture(uTextureID_x_x_u)); + pRenderer->DrawTextureIndexed(476, 451, pIcons_LOD->GetTexture(uTextureID_x_ok_u)); + if ( (pVideoPlayer->AnyMovieLoaded() || v9) && *dword_591164_teleport_map_name != ' ' ) v10 = pMapStats->GetMapInfo(dword_591164_teleport_map_name); pMapInfo = &pMapStats->pInfos[v10]; v8.uFrameX = 493; @@ -14639,45 +14637,37 @@ v8.uFrameX = 483; v8.uFrameWidth = 148; v8.uFrameZ = 334; + + v1 = ""; if ( uCurrentHouse_Animation ) { - v1 = (&off_4EB080)[4 * uCurrentHouse_Animation]; - } - else - { - if ( v10 ) - { - sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[409], pMapInfo->pName);// "Do you wish to leave %s?" - v4 = (212 - pFontCreate->CalcTextHeight(pTmpBuf, &v8, 0, 0)) / 2 + 101; - result = v8.DrawTitleText(pFontCreate, 0, v4, 0, pTmpBuf, 3); - dword_5B5924 = 1; - return result; - } - v1 = ""; - } - if ( !v1 ) - { - MessageBoxW(nullptr, L"No transition text found!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Events.cpp:1410", 0); - v1 = ""; - } - v4 = (212 - pFontCreate->CalcTextHeight(v1, &v8, 0, 0)) / 2 + 101; - result = v8.DrawTitleText(pFontCreate, 0, v4, 0, v1, 3); - dword_5B5924 = 1; - return result; + v1 = pTransitionStrings[uCurrentHouse_Animation]; + v4 = (212 - pFontCreate->CalcTextHeight(v1, &v8, 0, 0)) / 2 + 101; + v8.DrawTitleText(pFontCreate, 0, v4, 0, v1, 3); + } + else if ( v10 ) + { + sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[409], pMapInfo->pName);// "Do you wish to leave %s?" + v4 = (212 - pFontCreate->CalcTextHeight(pTmpBuf, &v8, 0, 0)) / 2 + 101; + v8.DrawTitleText(pFontCreate, 0, v4, 0, pTmpBuf, 3); + } + else assert(false); + + _unused_5B5924_is_travel_ui_drawn = true; } //----- (00444C8F) -------------------------------------------------------- GUIWindow *__cdecl UI_CreateTravelDialogue() { - signed int v0; // eax@1 + //signed int v0; // eax@1 unsigned int v1; // eax@6 GUIWindow *result; // eax@9 - const char *v3; // [sp-4h] [bp-2Ch]@2 + //const char *v3; // [sp-4h] [bp-2Ch]@2 char pContainer[32]; // [sp+0h] [bp-28h]@1 pEventTimer->Pause(); - v0 = const_2(); + /*v0 = const_2(); sprintf(pContainer, "evt%02d", v0); if ( pParty->uAlignment ) { @@ -14690,15 +14680,23 @@ v3 = "-b"; } strcat(pContainer, v3); -LABEL_6: +LABEL_6:*/ + switch (pParty->alignment) + { + case PartyAlignment_Good: sprintf(pContainer, "evt%02d-b", const_2()); + case PartyAlignment_Neutral: sprintf(pContainer, "evt%02d", const_2()); + case PartyAlignment_Evil: sprintf(pContainer, "evt%02d-c", const_2()); + default: assert(false); + } + pTexture_Dialogue_Background = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)]; pTexture_outside = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("outside", TEXTURE_16BIT_PALETTE)]; v1 = pMapStats->GetMapInfo(pCurrentMapName); if ( v1 ) - sprintf(byte_591098, pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v1].pName);// "Leave %s" - else - strcpy(byte_591098, pGlobalTXT_LocalizationStrings[79]);// "Exit" - result = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)17, 0, (int)byte_591098); + sprintf(sHouseName, pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v1].pName);// "Leave %s" + else + strcpy(sHouseName, pGlobalTXT_LocalizationStrings[79]);// "Exit" + result = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)17, 0, (int)sHouseName); pDialogueWindow = result; return result; } @@ -14742,11 +14740,9 @@ pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pDestinationMapName, 20); v0 = pMapStats->GetMapInfo(pDestinationMapName); pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background); - pRenderer->DrawTextureTransparent(0x1D4u, 0, - (Texture *)(uTextureID_507B04 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507B04] : 0)); - pRenderer->DrawTextureIndexed(pNPCPortraits_x, pNPCPortraits_y, pTexture_outside); - pRenderer->DrawTextureIndexed(0x22Cu, 0x1C3u, - (Texture *)(uTextureID_x_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_x_u] : 0)); + pRenderer->DrawTextureTransparent(0x1D4u, 0, &pIcons_LOD->pTextures[uTextureID_507B04]); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside); + pRenderer->DrawTextureIndexed(0x22Cu, 0x1C3u, &pIcons_LOD->pTextures[uTextureID_x_x_u]); pRenderer->DrawTextureIndexed(0x1DCu, 0x1C3u, (Texture *)(uTextureID_x_ok_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_ok_u] : 0)); if ( v0 ) @@ -14777,7 +14773,7 @@ strcat(pTmpBuf, pTmpBuf2); v4 = pFontCreate->CalcTextHeight(pTmpBuf, &v7, 0, 0); v7.DrawTitleText(pFontCreate, 0, (212 - v4) / 2 + 101, 0, pTmpBuf, 3u); - dword_5B5924 = 1; + _unused_5B5924_is_travel_ui_drawn = 1; } } @@ -14970,8 +14966,8 @@ v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u); pRenderer->DrawTextureIndexed(477, 0, pTexture_Dialogue_Background); pRenderer->DrawTextureTransparent(468, 0, (Texture *)(uTextureID_507B04 != -1 ? &pIcons_LOD->pTextures[uTextureID_507B04] : 0)); - pRenderer->DrawTextureIndexed(pNPCPortraits_x - 4, pNPCPortraits_y - 4, (Texture *)(uTextureID_50795C != -1 ? &pIcons_LOD->pTextures[uTextureID_50795C] : 0)); - pRenderer->DrawTextureIndexed(pNPCPortraits_x, pNPCPortraits_y, pDialogueNPCPortraits[0]); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, (Texture *)(uTextureID_50795C != -1 ? &pIcons_LOD->pTextures[uTextureID_50795C] : 0)); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pDialogueNPCPortraits[0]); if (pNPC->uProfession) { @@ -15127,7 +15123,7 @@ } else if (v16 == 20) { - __debugbreak(); // learn conditions of this event + //__debugbreak(); // learn conditions of this event instruments auto topic = pNPCTopics[pNPC->evt_B - 1].pTopic;//(&dword_721660)[8 * v23]; if (!topic) { @@ -15667,94 +15663,85 @@ } //----- (004466C4) -------------------------------------------------------- -bool __thiscall sub_4466C4(void *_this) -{ - signed int v1; // ebp@1 - bool result; // eax@2 - int v3; // esi@3 - signed int v4; // edx@3 - signed int v5; // eax@4 - unsigned int v6; // ebx@6 - char *v7; // eax@6 - signed int v8; // edi@18 - int v9; // eax@19 - Player *v10; // [sp+8h] [bp-10h]@18 - signed int v11; // [sp+Ch] [bp-Ch]@3 - signed int v12; // [sp+10h] [bp-8h]@3 - void *v13; // [sp+14h] [bp-4h]@1 - - v1 = 0; - v13 = _this; - if ( !_this ) +int NPC_EventProcessor( int npc_event_id ) + { + signed int event_index; // ebp@1 + int evt_seq_num; // esi@3 + bool ready_to_exit; // [sp+Ch] [bp-Ch]@3 + signed int npc_activity; // [sp+10h] [bp-8h]@3 + int result; + + event_index = 0; + if ( !npc_event_id ) return 0; - v3 = start_event_seq_number; + evt_seq_num = start_event_seq_number; pSomeOtherEVT = pGlobalEVT; uSomeOtherEVT_NumEvents = uGlobalEVT_NumEvents; - memcpy(pSomeOtherEVT_Events, pGlobalEVT_Index, 0xCE40u); - v4 = 1; - v12 = 1; - v11 = 0; - if ( (signed int)uSomeOtherEVT_NumEvents <= 0 ) - goto LABEL_16; + memcpy(pSomeOtherEVT_Events, pGlobalEVT_Index, sizeof(EventIndex)*4400); + npc_activity = 1; + ready_to_exit = false; + if ( uSomeOtherEVT_NumEvents <= 0 ) + return 2; do { - v5 = v1; - if ( (void *)pSomeOtherEVT_Events[v1].uEventID == v13 && pSomeOtherEVT_Events[v5].event_sequence_num == v3 ) - { - v6 = pSomeOtherEVT_Events[v5].uEventOffsetInEVT; - v7 = &pSomeOtherEVT[v6]; - if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] == 1 ) - break; - if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] == 44 ) - { - v11 = v4; - v10 = pParty->pPlayers; - v8 = (unsigned __int8)v7[7] - + (((unsigned __int8)v7[8] + (((unsigned __int8)v7[9] + ((unsigned __int8)v7[10] << 8)) << 8)) << 8); - while ( 1 ) - { - LOBYTE(v9) = v10->CompareVariable( - (enum VariableType)((unsigned __int8)pSomeOtherEVT[v6 + 5] - + ((unsigned __int8)pSomeOtherEVT[v6 + 6] << 8)), - v8); - if ( v9 ) - break; - ++v10; - if ( (signed int)v10 >= (signed int)pParty->pHirelings ) - goto LABEL_13; - } - } - else - { - if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] == 45 ) - break; - if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] == 46 ) - { - v11 = v4; - v12 = (unsigned __int8)v7[5]; - goto LABEL_13; - } - if ( (unsigned __int8)pSomeOtherEVT[v6 + 4] != 52 - || !IsActorAlive( - (unsigned __int8)v7[5], - (unsigned __int8)v7[6] - + (((unsigned __int8)v7[7] + (((unsigned __int8)v7[8] + ((unsigned __int8)v7[9] << 8)) << 8)) << 8), - (unsigned __int8)v7[10]) ) - goto LABEL_13; - } - v1 = -1; - v3 = (unsigned __int8)pSomeOtherEVT[v6 + 11] - 1; -LABEL_13: - ++v3; - v4 = 1; - } - ++v1; - } - while ( v1 < (signed int)uSomeOtherEVT_NumEvents ); - if ( v11 ) - result = v12 != 0; - else -LABEL_16: + if ( (pSomeOtherEVT_Events[event_index].uEventID == npc_event_id) && (pSomeOtherEVT_Events[event_index].event_sequence_num == evt_seq_num) ) + { + _evt_raw *_evt = (_evt_raw *)&pSomeOtherEVT[pSomeOtherEVT_Events[event_index].uEventOffsetInEVT]; + switch(_evt->_e_type) + { + case EVENT_Exit: + //exit + if ( ready_to_exit ) + result = npc_activity != 0; + else + result = 2; + return result; + break; + case EVENT_OnCanShowDialogItemCmp: + ready_to_exit = true; + //v8 = (unsigned __int8)v7[7] + (((unsigned __int8)v7[8] + (((unsigned __int8)v7[9] + ((unsigned __int8)v7[10] << 8)) << 8)) << 8); + for(int i=0; i<4; ++i) + { + // if (pParty->pPlayers[i].CompareVariable((enum VariableType)((unsigned __int8)pSomeOtherEVT[v6 + 5] + ((unsigned __int8)pSomeOtherEVT[v6 + 6] << 8)), + // v8)) + if (pParty->pPlayers[i].CompareVariable((enum VariableType)EVT_WORD(_evt->v5), EVT_DWORD(_evt->v7))) + { + event_index = -1; + evt_seq_num = EVT_BYTE(_evt->v11)-1;//(unsigned __int8)pSomeOtherEVT[v6 + 11] - 1; + break; + } + } + break; + case EVENT_EndCanShowDialogItem : + if ( ready_to_exit ) + result = npc_activity != 0; + else + result = 2; + return result; + break; + case EVENT_SetCanShowDialogItem : + ready_to_exit = true; + npc_activity = EVT_BYTE(_evt->v5); //(unsigned __int8)v7[5]; + break; + case EVENT_IsActorAssasinated : + // if (IsActorAlive( (unsigned __int8)v7[5], + // (unsigned __int8)v7[6] + (((unsigned __int8)v7[7] + (((unsigned __int8)v7[8] + ((unsigned __int8)v7[9] << 8)) << 8)) << 8), + // (unsigned __int8)v7[10]) ) + if (IsActorAlive( EVT_BYTE(_evt->v5), EVT_DWORD(_evt->v6), EVT_BYTE(_evt->v10))) + { // drop linear sequense, going to new seq + event_index = -1; + evt_seq_num = EVT_BYTE(_evt->v11)-1;//(unsigned __int8)pSomeOtherEVT[v6 + 11] - 1; + } + break; + } + ++evt_seq_num; + } + ++event_index; + } + while ( event_index < uSomeOtherEVT_NumEvents ); + if ( ready_to_exit ) + result = npc_activity != 0; + else result = 2; return result; } @@ -16876,7 +16863,7 @@ v2 = pMapName; v3 = uStartingPointType; pAudioPlayer->StopChannels(-1, -1); - pGameLoadingUI_ProgressBar->_443484((GUIProgressBar::Type)0); + pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_None); if ( _strcmpi(pCurrentMapName, v2) ) SaveGame(1, 0); uGameState = 2; @@ -17270,9 +17257,8 @@ //----- (004014E6) -------------------------------------------------------- -int __cdecl ODM_4014E6_AI() -{ - Actor *v0; // esi@2 +void MakeActorAIList_ODM() +{ int v1; // eax@4 int v2; // ebx@4 unsigned int v3; // ecx@4 @@ -17280,42 +17266,28 @@ int v5; // edx@7 unsigned int v6; // edx@9 unsigned int v7; // ST20_4@10 - int v8; // eax@10 int v9; // edi@10 int v10; // ebx@14 - char v11; // zf@16 - int v12; // eax@22 - int result; // eax@24 - int v14; // edx@25 - int v15; // ecx@25 - int v16; // ebx@26 - unsigned int *v17; // ecx@27 - unsigned int v18; // esi@27 - int i; // edx@33 - char *v20; // ecx@34 int v21; // [sp+Ch] [bp-14h]@4 int v22; // [sp+10h] [bp-10h]@4 - int v23; // [sp+14h] [bp-Ch]@10 - int v24; // [sp+14h] [bp-Ch]@29 - signed int v25; // [sp+18h] [bp-8h]@1 - signed int v26; // [sp+18h] [bp-8h]@25 - int v27; // [sp+1Ch] [bp-4h]@1 pParty->uFlags &= 0xFFFFFFCFu; - v27 = 0; - v25 = 0; - if ( (signed int)uNumActors > 0 ) - { - v0 = pActors;//[0].uAttributes; - do - { - //*(char *)(v0 + 1) &= 0xFBu; - BYTE1(v0->uAttributes) &= 0xFBu; - if ( ! v0->CanAct() ) - goto LABEL_37; - v22 = abs(pParty->vPosition.z - v0->vPosition.z); - v21 = abs(pParty->vPosition.y - v0->vPosition.y); - v1 = abs(pParty->vPosition.x - v0->vPosition.x); + + ai_arrays_size = 0; + for (uint i = 0; i < uNumActors; ++i) + { + auto actor = pActors + i; + + actor->uAttributes &= 0xFFFFFBFF; + if (!actor->CanAct()) + { + actor->uAttributes &= 0xFFFFBFFF; + continue; + } + + v22 = abs(pParty->vPosition.z - actor->vPosition.z); + v21 = abs(pParty->vPosition.y - actor->vPosition.y); + v1 = abs(pParty->vPosition.x - actor->vPosition.x); v2 = v21; v3 = v22; if ( v1 < v21 ) @@ -17337,42 +17309,37 @@ v2 = v6; } v7 = ((unsigned int)(11 * v2) >> 5) + (v3 >> 2) + v1; - v8 = v0->uActorRadius; - v9 = v7 - v8; - v23 = v7 - v8; - if ( v23 < 0 ) + //v8 = actor->uActorRadius; + v9 = v7 - actor->uActorRadius; + //v23 = v7 - v8; + if ( v9 < 0 ) { v9 = 0; - v23 = 0; - } - if ( v9 < 5632 ) - { - v10 = v0->uAttributes & 0xFEFFFFFF; - v0->uAttributes = v10; - if ( v10 & 0x80000 || v0->GetActorsRelation(0) ) - { - v11 = (pParty->uFlags & 0x10) == 0; - v0->uAttributes = v10 | 0x1000000; - if ( v11 && (double)v23 < 307.2 ) - pParty->uFlags |= 0x10u; - if ( !(pParty->uFlags & 0x20) && v9 < 5120 ) - pParty->uFlags |= 0x20u; - } - BYTE1(v0->uAttributes) |= 0x40u; - v12 = v27++; - ai_array_4F75E0[v12] = v9; - ai_array_4F7DB0_actor_ids[v12] = v25; - } - else - { -LABEL_37: - BYTE1(v0->uAttributes) &= 0xBFu; - } - ++v25; - ++v0; - } - while ( v25 < (signed int)uNumActors ); - } + //v23 = 0; + } + + if (v9 < 5632) + { + v10 = actor->uAttributes & 0xFEFFFFFF; + actor->uAttributes = v10; + if ( v10 & 0x80000 || actor->GetActorsRelation(0) ) + { + //v11 = (pParty->uFlags & 0x10) == 0; + actor->uAttributes = v10 | 0x1000000; + if (v9 < 5120 ) + pParty->SetYellowAlert(); + if (v9 < 307) + pParty->SetRedAlert(); + } + actor->uAttributes |= 0x00004000; + ai_near_actors_distances[ai_arrays_size] = v9; + ai_near_actors_ids[ai_arrays_size++] = i; + } + else + actor->uAttributes &= 0xFFFFBFFF; + } + + /* result = v27; if ( v27 > 0 ) { @@ -17386,16 +17353,16 @@ v24 = v15; if ( v15 >= result ) break; - v16 = ai_array_4F75E0[v14]; - if ( v16 > ai_array_4F75E0[v15] ) - { - v17 = &ai_array_4F7DB0_actor_ids[v15]; - v18 = ai_array_4F7DB0_actor_ids[v14]; - ai_array_4F7DB0_actor_ids[v14] = *v17; + v16 = ai_near_actors_distances[v14]; + if ( v16 > ai_near_actors_distances[v15] ) + { + v17 = &ai_near_actors_ids[v15]; + v18 = ai_near_actors_ids[v14]; + ai_near_actors_ids[v14] = *v17; *v17 = v18; v15 = v24; - ai_array_4F75E0[v14] = ai_array_4F75E0[v24]; - ai_array_4F75E0[v24] = v16; + ai_near_actors_distances[v14] = ai_near_actors_distances[v24]; + ai_near_actors_distances[v24] = v16; } result = v27; ++v15; @@ -17405,24 +17372,32 @@ v26 = v15; } while ( v15 - 1 < result ); - } - ai_arrays_size = result; - if ( result > 30 ) - { - result = 30; + }*/ + + for (uint i = 0; i < ai_arrays_size; ++i) + for (uint j = 0; j < i; ++j) + if (ai_near_actors_distances[j] > ai_near_actors_distances[i]) + { + int tmp = ai_near_actors_distances[j]; + ai_near_actors_distances[j] = ai_near_actors_distances[i]; + ai_near_actors_distances[i] = tmp; + + tmp = ai_near_actors_ids[j]; + ai_near_actors_ids[j] = ai_near_actors_ids[i]; + ai_near_actors_ids[i] = tmp; + } + + + if (ai_arrays_size > 30) ai_arrays_size = 30; - } - for ( i = 0; i < result; ++i ) - { - v20 = (char *)&pActors[ai_array_4F7DB0_actor_ids[i]].uAttributes; - v20[1] |= 4u; - } - return result; + + for (uint i = 0; i < ai_arrays_size; ++i) + pActors[ai_near_actors_ids[i]].uAttributes |= 0x0400; } // 4F75D8: using guessed type int ai_arrays_size; //----- (004016FA) -------------------------------------------------------- -int __cdecl BLV_4016FA_AI() +int __cdecl MakeActorAIList_BLV() { Actor *v0; // esi@2 int v1; // eax@4 @@ -17470,6 +17445,7 @@ signed int v44; // [sp+1Ch] [bp-8h]@25 int v45; // [sp+20h] [bp-4h]@1 +// __debugbreak(); // refactor for blv ai pParty->uFlags &= 0xFFFFFFCFu; v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); v45 = 0; @@ -17528,8 +17504,8 @@ pParty->uFlags |= 0x20u; } v12 = v45++; - ai_array_4F75E0[v12] = v9; - ai_array_4F7DB0_actor_ids[v12] = v43; + ai_near_actors_distances[v12] = v9; + ai_near_actors_ids[v12] = v43; } else { @@ -17553,16 +17529,16 @@ v41 = v14; if ( v14 >= v45 ) break; - v15 = ai_array_4F75E0[v13]; - if ( v15 > ai_array_4F75E0[v14] ) - { - v16 = &ai_array_4F7DB0_actor_ids[v14]; - v17 = ai_array_4F7DB0_actor_ids[v13]; - ai_array_4F7DB0_actor_ids[v13] = *v16; + v15 = ai_near_actors_distances[v13]; + if ( v15 > ai_near_actors_distances[v14] ) + { + v16 = &ai_near_actors_ids[v14]; + v17 = ai_near_actors_ids[v13]; + ai_near_actors_ids[v13] = *v16; *v16 = v17; v14 = v41; - ai_array_4F75E0[v13] = ai_array_4F75E0[v41]; - ai_array_4F75E0[v41] = v15; + ai_near_actors_distances[v13] = ai_near_actors_distances[v41]; + ai_near_actors_distances[v41] = v15; } ++v14; } @@ -17576,14 +17552,14 @@ v19 = 0; for ( i = 0; v18 < v45; i = v18 ) { - v20 = &pActors[ai_array_4F7DB0_actor_ids[v18]]; + v20 = &pActors[ai_near_actors_ids[v18]]; if ( v20->uAttributes & 0x8000 - || (v21 = sub_4070EF_prolly_collide_objects(8 * ai_array_4F7DB0_actor_ids[v18] | 3, 4u), v18 = i, v21) ) - { - v22 = ai_array_4F7DB0_actor_ids[v18]; + || (v21 = sub_4070EF_prolly_collide_objects(8 * ai_near_actors_ids[v18] | 3, 4u), v18 = i, v21) ) + { + v22 = ai_near_actors_ids[v18]; v20->uAttributes |= 0x8000u; ai_array_4F6638_actor_ids[v19] = v22; - ai_array_4F5E68[v19++] = ai_array_4F75E0[v18]; + ai_array_4F5E68[v19++] = ai_near_actors_distances[v18]; if ( v19 >= 30 ) break; } @@ -17625,7 +17601,7 @@ v27 = ai_arrays_size; for ( j = 0; j < v45; ++j ) { - v29 = ai_array_4F7DB0_actor_ids[j]; + v29 = ai_near_actors_ids[j]; if ( pActors[v29].uAttributes & 0xC000 && pActors[v29].CanAct() ) { v30 = 0; @@ -17633,13 +17609,13 @@ { LABEL_51: v31 = ai_arrays_size; - v32 = ai_array_4F7DB0_actor_ids[j]; + v32 = ai_near_actors_ids[j]; ++ai_arrays_size; ai_array_4F6638_actor_ids[v31] = v32; } else { - while ( ai_array_4F6638_actor_ids[v30] != ai_array_4F7DB0_actor_ids[j] ) + while ( ai_array_4F6638_actor_ids[v30] != ai_near_actors_ids[j] ) { ++v30; if ( v30 >= v27 ) @@ -17654,14 +17630,14 @@ v33 = 30; ai_arrays_size = 30; } - memcpy(ai_array_4F7DB0_actor_ids, ai_array_4F6638_actor_ids, 4 * v33); - memcpy(ai_array_4F75E0, ai_array_4F5E68, 4 * ai_arrays_size); + memcpy(ai_near_actors_ids, ai_array_4F6638_actor_ids, 4 * v33); + memcpy(ai_near_actors_distances, ai_array_4F5E68, 4 * ai_arrays_size); v34 = (unsigned int)ai_arrays_size; if ( ai_arrays_size > 0 ) { do { - v35 = (char *)&pActors[ai_array_4F7DB0_actor_ids[HIDWORD(v34)]].uAttributes; + v35 = (char *)&pActors[ai_near_actors_ids[HIDWORD(v34)]].uAttributes; v35[1] |= 4u; ++HIDWORD(v34); } @@ -17674,7 +17650,7 @@ //----- (00401A91) -------------------------------------------------------- void __cdecl sub_401A91_AI() { - unsigned int v0; // esi@4 + //unsigned int v0; // esi@4 int v1; // eax@7 int v2; // ecx@7 int v3; // eax@7 @@ -17684,17 +17660,17 @@ __int16 v7; // cx@14 Player **v8; // esi@20 Player *pPlayer; // ecx@21 - Actor *pActor; // esi@34 - __int16 v11; // ax@34 - unsigned int v12; // eax@47 - signed int v13; // edi@47 - SpellBuff *v14; // ebx@47 - unsigned int v15; // edi@67 - char *v16; // eax@67 - unsigned int v17; // edx@67 - unsigned int v18; // ecx@67 - unsigned __int16 v19; // ax@72 - int *v20; // esi@80 + //Actor *pActor; // esi@34 + //__int16 v11; // ax@34 + //unsigned int v12; // eax@47 + //signed int v13; // edi@47 + //SpellBuff *v14; // ebx@47 + //unsigned int v15; // edi@67 + //char *v16; // eax@67 + //unsigned int v17; // edx@67 + //unsigned int v18; // ecx@67 + //unsigned __int16 v19; // ax@72 + //int *v20; // esi@80 Actor *v21; // ebx@80 unsigned __int16 v22; // ax@86 signed int v23; // eax@94 @@ -17757,15 +17733,16 @@ float v80; // [sp+98h] [bp-18h]@33 int v81; // [sp+9Ch] [bp-14h]@100 int v82; // [sp+A0h] [bp-10h]@45 - unsigned int uActorID; // [sp+A4h] [bp-Ch]@32 + //unsigned int uActorID; // [sp+A4h] [bp-Ch]@32 unsigned int v84; // [sp+A8h] [bp-8h]@11 signed int a2; // [sp+ACh] [bp-4h]@83 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - ODM_4014E6_AI(); - else - BLV_4016FA_AI(); - v0 = 0; + MakeActorAIList_ODM(); + else + MakeActorAIList_BLV(); + + //v0 = 0; if ( uCurrentlyLoadedLevelType != LEVEL_Indoor && pParty->armageddon_timer > 0 ) { if ( pParty->armageddon_timer > 417 ) @@ -17826,37 +17803,48 @@ ++v8; } while ( (signed int)v8 <= (signed int)&pPlayers[4] ); - v0 = 0; - } - if ( pTurnEngine->field_1C != v0 ) + //v0 = 0; + } + if (pTurnEngine->field_1C) --pTurnEngine->field_1C; } } - if ( pParty->bTurnBasedModeOn == 1 ) + + if (pParty->bTurnBasedModeOn) { pTurnEngine->_405E14(); return; } - uActorID = v0; - if ( (signed int)uNumActors > (signed int)v0 ) - { - LODWORD(v80) = (int)(char *)pActors + 176; - do - { - pActor = (Actor *)(LODWORD(v80) - 176); - v11 = *(unsigned int *)LODWORD(v80); - v49 = *(unsigned int *)LODWORD(v80) == 5; - dword_4F6E08[uActorID] = 4; - if ( v49 || v11 == 11 || v11 == 19 || *(char *)(LODWORD(v80) - 139) & 4 ) - goto LABEL_78; - if ( !*(short *)(LODWORD(v80) - 136) && v11 != 4 ) - Actor::Die(uActorID); - v84 = *(_QWORD *)(LODWORD(v80) + 84) <= 0i64 ? 0 : 1; - v82 = *(_QWORD *)(LODWORD(v80) + 52) <= 0i64 ? 0 : 1; - v12 = 0; - v13 = 0; - v14 = (SpellBuff *)(LODWORD(v80) + 36); - do + + + //uActorID = v0; + for (uint i = 0; i < uNumActors; ++i) + { + auto actor = pActors + i; + //LODWORD(v80) = (int)(char *)pActors + 176; // uAIState + //do + //{ + //pActor = (Actor *)(LODWORD(v80) - 176); + //v11 = *(unsigned int *)LODWORD(v80); + //v49 = *(unsigned int *)LODWORD(v80) == 5; + ai_near_actors_targets_pid[i] = OBJECT_Player; + if (actor->uAIState == Dead || actor->uAIState == Removed || actor->uAIState == Disabled || actor->uAttributes & 0x0400) + continue; + + if (!actor->sCurrentHP && actor->uAIState != Dying) + Actor::Die(i); + + //v84 = *(_QWORD *)(LODWORD(v80) + 84) <= 0i64 ? 0 : 1; + //v82 = *(_QWORD *)(LODWORD(v80) + 52) <= 0i64 ? 0 : 1; + //v12 = 0; + //v13 = 0; + //v14 = (SpellBuff *)(LODWORD(v80) + 36); + for (uint j = 0; j < 22; ++j) + { + if (j != 10) + actor->pActorBuffs[j]._4585CA(pParty->uTimePlayed); + } + /*do { if ( v13 != 10 ) { @@ -17866,74 +17854,74 @@ ++v13; ++v14; } - while ( v13 < 22 ); - if ( v84 != v12 - && SHIDWORD(pActor->pActorBuffs[3].uExpireTime) <= (signed int)v12 - && (SHIDWORD(pActor->pActorBuffs[3].uExpireTime) < (signed int)v12 - || LODWORD(pActor->pActorBuffs[3].uExpireTime) <= v12) ) - pActor->uActorHeight = pMonsterList->pMonsters[pActor->pMonsterInfo.uID - 1].uMonsterHeight; - if ( v82 != v12 ) - { - pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - if ( SHIDWORD(pActor->pActorBuffs[1].uExpireTime) <= (signed int)v12 ) - { - if ( SHIDWORD(pActor->pActorBuffs[1].uExpireTime) < (signed int)v12 - || LODWORD(pActor->pActorBuffs[1].uExpireTime) <= v12 ) - pActor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uHostilityType; - } - } - if ( SHIDWORD(pActor->pActorBuffs[5].uExpireTime) > (signed int)v12 - || SHIDWORD(pActor->pActorBuffs[5].uExpireTime) >= (signed int)v12 - && LODWORD(pActor->pActorBuffs[5].uExpireTime) - || SHIDWORD(pActor->pActorBuffs[6].uExpireTime) > 0 - || SHIDWORD(pActor->pActorBuffs[6].uExpireTime) >= 0 && LODWORD(pActor->pActorBuffs[6].uExpireTime) ) - goto LABEL_78; - v15 = pMiscTimer->uTimeElapsed; - v16 = (char *)&pActor->pMonsterInfo.uRecoveryTime; - pActor->uCurrentActionTime += pMiscTimer->uTimeElapsed; - v17 = pActor->uCurrentActionTime; - v18 = pActor->pMonsterInfo.uRecoveryTime; - if ( (signed int)v18 > 0 ) - *(int *)v16 = v18 - v15; - if ( *(int *)v16 < 0 ) - *(int *)v16 = 0; - if ( (signed int)v17 < pActor->uCurrentActionLength ) - goto LABEL_78; - v19 = pActor->uAIState; - if ( v19 == Dying ) - { - pActor->uAIState = Dead; - } - else - { - if ( v19 != 17 ) - { - Actor::_403F58(uActorID, Dying, 256, 0); - goto LABEL_78; - } - pActor->uAIState = Standing; - } - pActor->uCurrentActionTime = 0; - pActor->uCurrentActionLength = 0; - pActor->UpdateAnimation(); -LABEL_78: - ++uActorID; - LODWORD(v80) += 836; - } - while ( (signed int)uActorID < (signed int)uNumActors ); - } + while ( v13 < 22 );*/ + if (!actor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime) + //&& SHIDWORD(pActor->pActorBuffs[3].uExpireTime) <= (signed int)v12 && (SHIDWORD(pActor->pActorBuffs[3].uExpireTime) < (signed int)v12 + // || LODWORD(pActor->pActorBuffs[3].uExpireTime) <= v12) ) + actor->uActorHeight = pMonsterList->pMonsters[actor->pMonsterInfo.uID - 1].uMonsterHeight; + if (actor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime) + actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; + else + actor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[actor->pMonsterInfo.uID].uHostilityType; + + if (actor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime || + actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) + continue; + + //v15 = pMiscTimer->uTimeElapsed; + //v16 = (char *)&pActor->pMonsterInfo.uRecoveryTime; + //v17 = pActor->uCurrentActionTime; + //v18 = pActor->pMonsterInfo.uRecoveryTime; + if (actor->pMonsterInfo.uRecoveryTime) + { + if (actor->pMonsterInfo.uRecoveryTime < pMiscTimer->uTimeElapsed) + actor->pMonsterInfo.uRecoveryTime = 0; + else actor->pMonsterInfo.uRecoveryTime -= pMiscTimer->uTimeElapsed; + } + + actor->uCurrentActionTime += pMiscTimer->uTimeElapsed; + if (actor->uCurrentActionTime < actor->uCurrentActionLength) + continue; + + //v19 = actor->uAIState; + if (actor->uAIState == Dying) + actor->uAIState = Dead; + else + { + if (actor->uAIState != Summoned) + { + Actor::AI_StandOrBored(i, OBJECT_Player, 256, nullptr); + continue; + } + actor->uAIState = Standing; + } + + actor->uCurrentActionTime = 0; + actor->uCurrentActionLength = 0; + actor->UpdateAnimation(); +//LABEL_78: + //++uActorID; + //LODWORD(v80) += 836; + //} + //while ( (signed int)uActorID < (signed int)uNumActors ); + } + + v78 = 0; + int actor_id = -1; if ( ai_arrays_size > 0 ) { while ( 1 ) { - uActorID = ai_array_4F7DB0_actor_ids[v78]; - v20 = &dword_4F6E08[uActorID]; - v21 = &pActors[uActorID]; - Actor::_401221(uActorID, &dword_4F6E08[uActorID], 1u); - if ( v21->pMonsterInfo.uHostilityType && !*v20 ) + actor_id = ai_near_actors_ids[v78]; + assert(actor_id < uNumActors); + + //v20 = &ai_near_actors_targets_pid[actor_id]; + v21 = &pActors[actor_id]; + Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true); + if (v21->pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[actor_id]) v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - a2 = *v20; + a2 = ai_near_actors_targets_pid[actor_id]; v76 = a2 & 7; if ( (a2 & 7) == OBJECT_Actor) v80 = 0.5; @@ -17943,7 +17931,7 @@ if ( v22 == Dying || v22 == Dead || v22 == Removed || v22 == Disabled || v22 == Summoned) goto LABEL_254; if ( !v21->sCurrentHP ) - Actor::Die(uActorID); + Actor::Die(actor_id); if ( (signed __int64)v21->pActorBuffs[3].uExpireTime <= 0 ) { v84 = 0; @@ -18011,8 +17999,8 @@ v29 = v21->uAttributes; if ( !(v29 & 0x8000) ) v21->uAttributes = v29 | 0x8000; - a1 = 8 * uActorID | 3; - v30 = Actor::GetDirectionInfo(8 * uActorID | 3, a2, &a3, 0); + a1 = 8 * actor_id | OBJECT_Actor; + v30 = Actor::GetDirectionInfo(8 * actor_id | OBJECT_Actor, a2, &a3, 0); v49 = v21->pMonsterInfo.uHostilityType == 0; memcpy(&v75, v30, sizeof(v75)); memcpy(&pDir, &v75, sizeof(pDir)); @@ -18022,7 +18010,7 @@ && ((v31 = v21->uAIState, v31 == 6) || !v31 || v31 == 1 || v31 == 9) || v21->pMonsterInfo.uMissleAttack1Type && v21->uAIState == 8 ) { - v32 = uActorID; + v32 = actor_id; goto LABEL_152; } } @@ -18030,8 +18018,8 @@ goto LABEL_254; if ( v21->uAIState == 2 ) { - v32 = uActorID; - v35 = stru_50C198.special_ability_use_check(v21, uActorID); + v32 = actor_id; + v35 = stru_50C198.special_ability_use_check(v21, actor_id); stru_50FE08.Add( a1, 5120, @@ -18053,11 +18041,11 @@ v34 = v21->pMonsterInfo.uMissleAttack2Type; v66 = 1; LABEL_149: - v32 = uActorID; - Actor::_404874(uActorID, &pDir, v34, v66); + v32 = actor_id; + Actor::_404874(actor_id, &pDir, v34, v66); goto LABEL_152; } - v32 = uActorID; + v32 = actor_id; if ( v21->uAIState == 13 ) break; if ( v21->uAIState == 18 ) @@ -18066,7 +18054,7 @@ v60 = 3; v33 = v21->pMonsterInfo.uSpell2ID; LABEL_146: - Actor::_404AC7(uActorID, &pDir, v33, v60, v65); + Actor::_404AC7(actor_id, &pDir, v33, v60, v65); } LABEL_152: v36 = v75.uDistance; @@ -18130,7 +18118,7 @@ v67 = &pDir; if ( v21->pMonsterInfo.uMovementType != 5 ) goto LABEL_181; - Actor::_403EB6( + Actor::AI_Stand( v32, a2, (signed __int64)((double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333), @@ -18246,7 +18234,7 @@ v64 = (signed __int64)v47; v52 = v32; LABEL_247: - Actor::_403EB6(v52, v51, v64, v69); + Actor::AI_Stand(v52, v51, v64, v69); goto LABEL_254; } v69 = &pDir; @@ -18315,7 +18303,7 @@ memcpy(&v74, v57, sizeof(v74)); memcpy(&pDir, &v74, sizeof(pDir)); v69 = &pDir; - v52 = uActorID; + v52 = actor_id; v64 = (signed __int64)v58; v51 = 4; goto LABEL_247; @@ -18580,7 +18568,7 @@ LayingItem *v1; // esi@1 v1 = this; - v1->field_22 = 1; + v1->field_22_glow_radius_multiplier = 1; v1->uSoundID = 0; v1->uFacing = 0; v1->vVelocity.z = 0; @@ -18674,7 +18662,7 @@ v40b = v35; if ( v40b < v40b + ai_arrays_size ) { - v34 = (int *)ai_array_4F7DB0_actor_ids; + v34 = (int *)ai_near_actors_ids; do { v37 = *v34; @@ -18687,13 +18675,13 @@ v7 = v6->uAttributes; if ( v7 & 0x8000 < 0 ) { - v8 = dword_4F6E08[v5]; + v8 = ai_near_actors_targets_pid[v5]; LOBYTE(v7) = v7 | 0x80; v6->uAttributes = v7; v33 = 8 * v5 | OBJECT_Actor; memcpy(&v31, Actor::GetDirectionInfo(8 * v5 | OBJECT_Actor, v8, &a3, 0), sizeof(v31)); memcpy(&v30, &v31, sizeof(v30)); - Actor::_403F58(v37, 4, 32, &v30); + Actor::AI_StandOrBored(v37, 4, 32, &v30); *(&v1->field_0 + 4 * (v1->uActorQueueSize + 2)) = v33; v1->pQueue[v1->uActorQueueSize].field_C = 2; v1->pQueue[v1->uActorQueueSize++].uActionLength = 0;
--- a/mm7_4.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/mm7_4.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -260,7 +260,7 @@ //BLVFace *v23; // eax@33 //int v24; // esi@39 //int v25; // edi@39 - int v26; // esi@41 + //int v26; // esi@41 int v27; // ecx@43 signed int v28; // eax@45 int v29; // ebx@47 @@ -446,7 +446,7 @@ v54 = 0; v51 = 0; v49 = word_721390[0] >= y; - if ( v26 > 0 ) + if ( portal->uNumVertices > 0 ) { do { @@ -480,7 +480,8 @@ ++v51; v49 = v47; } - while ( v51 < v26 ); + while ( v51 < 2 * portal->uNumVertices ); + if ( v54 == 1 ) { if ( v55 >= 50 ) @@ -1012,7 +1013,7 @@ side1_dx = (double)(grid_pos_x1 - grid_pos_x1); side2_dz = (double)(grid_pos_z2 - grid_pos_z2); // bug? z2 - z2 side1_dz = (double)(grid_pos_z2 - grid_pos_z2); // z1 - z2 - Log::Warning(L"%s %s %u\n", __FILE__, __FUNCTION__, __LINE__); + Log::Warning(L"%S %S %u\n", __FILE__, __FUNCTION__, __LINE__); /* |\ side1 | \ |____\ @@ -1165,7 +1166,7 @@ if ( !(v1->field_2 & 0x20) ) { v2 = &pDecorationList->pDecorations[v1->uDecorationDescID]; - if ( !(v2->uFlags & 1) ) + if (!v2->CanMoveThrough()) { v3 = v2->uRadius; v4 = v1->vPosition.x; @@ -1274,7 +1275,7 @@ if ( !(v5->field_2 & 0x20) ) { v6 = &pDecorationList->pDecorations[v5->uDecorationDescID]; - if ( !(v6->uFlags & 1) ) + if (!v6->CanMoveThrough()) { v7 = v6->uRadius; v8 = v5->vPosition.x; @@ -3562,7 +3563,7 @@ } else { - v25 = v21->pInventoryItems[_idx].uAdditionalValue; + v25 = v21->pInventoryItems[_idx].uSpecEnchantmentType; if ( v25 <= 50 ) { if ( v25 != 50 ) @@ -4914,8 +4915,8 @@ NPCData *npc = nullptr; if ( dword_5C35D4 ) { - __debugbreak(); // fix - npc = array_5913D8[(unsigned int)((char *)array_5913D8[6] + -(dword_591080 != 0) - 1)]; + __debugbreak(); // fix + npc = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)]; } else npc = GetNPCData(uDialogue_SpeakingActorNPC_ID); @@ -5865,7 +5866,7 @@ LONG uMouseX; // edi@6 LONG uMouseY; // eax@6 GUIButton *pControlsHead; // edx@6 - unsigned int pNumMessage; // ecx@7 + //unsigned int pNumMessage; // ecx@7 int pControlParam; // esi@12 signed int v8; // edi@30 int v9; // edx@31 @@ -5906,7 +5907,9 @@ uMouseX = pMouse->GetCursorPos(&v25)->x; uMouseY = pMouse->GetCursorPos(&v25)->y; pControlsHead = pGUIWindow_CurrentMenu->pControlsHead; - if ( pControlsHead != (GUIButton *)v1 ) + + //does nothing actually + /*if ( pControlsHead != (GUIButton *)v1 ) { pNumMessage = pMessageQueue_50CBD0->uNumMessages; do @@ -5915,21 +5918,14 @@ && uMouseY >= (signed int)pControlsHead->uY && uMouseY <= (signed int)pControlsHead->uW )//mouse movement { pControlParam = pControlsHead->uControlParam; - if ( (signed int)pNumMessage < 40 ) - { - pMessageQueue_50CBD0->pMessages[pNumMessage].eType = (UIMessageType)pControlsHead->field_1C; - //pTexture = &pTexture_PCX; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = pControlParam; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - pNumMessage = pMessageQueue_50CBD0->uNumMessages + 1; - ++pMessageQueue_50CBD0->uNumMessages; - } + pMessageQueue_50CBD0->AddMessage((UIMessageType)pControlsHead->field_1C, pControlParam, 0); v1 = 0; } pControlsHead = pControlsHead->pNext; } while ( pControlsHead != (GUIButton *)v1 ); - } + }*/ + while ( PeekMessageA(&Msg, (HWND)v1, v1, v1, PM_REMOVE) ) { if ( Msg.message == WM_QUIT ) @@ -6181,6 +6177,7 @@ pColor2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xECu, 0xE6u, 0x9Cu); pString = (char *)operator new(2 * pSize); strncpy(pString, ptr, pSize); + pString[pSize]=0; pFontQuick->_44D2FD_prolly_draw_credits_entry(pFontCChar, 0, a4, (signed __int16)pTexture2.uWidth, (signed __int16)pTexture2.uHeight, pColor1, pColor2, pString, pTexture2.pPixels, (signed __int16)pTexture2.uWidth); free(pString); @@ -9115,7 +9112,8 @@ v6 = 9 * (v5 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C); v7 = (ItemGen *)((char *)&pParty->pPickedItem + 4 * v6 + 4); if ( dword_F8B19C != 2 ) - v7 = (ItemGen *)&pParty->field_C59C[v6 + 715]; + // v7 = (ItemGen *)&pParty->field_C59C[v6 + 715]; + v7 =&pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v5]; goto LABEL_15; } if ( dword_F8B198 <= 16 && dword_F8B19C == 18 ) @@ -9348,9 +9346,9 @@ { if ( v7->uItemID == 601 ) { - if ( !v7->field_1A ) + if ( !v7->uHolderPlayer ) v9 = v7; - if ( v7->field_1A == v5 ) + if ( v7->uHolderPlayer == v5 ) v10 = 1; } ++v7; @@ -9369,7 +9367,7 @@ return; } if ( v9 ) - v9->field_1A = v5; + v9->uHolderPlayer = v5; } } // 4F08EC: using guessed type int dword_4F08EC[]; @@ -9378,11 +9376,11 @@ // F8B1A8: using guessed type int dword_F8B1A8; //----- (004B2001) -------------------------------------------------------- -void __fastcall sub_4B2001(signed int a1) -{ - signed int v1; // eax@1 - NPCData *v2; // ebp@1 - int v3; // ecx@8 +void __fastcall ClickNPCTopic(signed int uMessageParam) +{ + //signed int v1; // eax@1 + NPCData *pCurrentNPCInfo; // ebp@1 + int pEventNumber; // ecx@8 Player *v4; // esi@20 int v5; // eax@28 int v6; // eax@31 @@ -9406,60 +9404,51 @@ char *v24; // [sp-8h] [bp-14h]@73 int v25; // [sp-4h] [bp-10h]@49 - v1 = a1; - uDialogueType = a1 + 1; - v2 = array_5913D8[(unsigned int)((char *)array_5913D8[6] + -(dword_591080 != 0) - 1)]; - if ( a1 <= 23 ) - { - if ( a1 == 23 ) - { - v3 = v2->evt_E; - } - else - { - if ( a1 == 13 ) - { - ptr_F8B1E8 = pNPCStats->pProfessions[v2->uProfession].pJoinText;//(char *)*(&pNPCStats->field_13A64 + 5 * v2->uProfession); - ptr_F8B1E8 = BuilDialogueString((char *)ptr_F8B1E8, uActiveCharacter - 1, 0, 0, 0, 0); - sub_4B40E6(); - dialogue_show_profession_details = false; + //v1 = a1; + uDialogueType = uMessageParam + 1; + pCurrentNPCInfo = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)]; + if ( uMessageParam <= 23 ) + { + switch ( uMessageParam ) + { + case 13: + ptr_F8B1E8 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession].pJoinText;//(char *)*(&pNPCStats->field_13A64 + 5 * v2->uProfession); + ptr_F8B1E8 = BuilDialogueString((char *)ptr_F8B1E8, uActiveCharacter - 1, 0, 0, 0, 0); + sub_4B40E6(); + dialogue_show_profession_details = false; + goto _return; + case 19: + pEventNumber = pCurrentNPCInfo->evt_A; + break; + case 20: + pEventNumber = pCurrentNPCInfo->evt_B; + break; + case 21: + pEventNumber = pCurrentNPCInfo->evt_C; + break; + case 22: + pEventNumber = pCurrentNPCInfo->evt_D; + break; + case 23: + pEventNumber = pCurrentNPCInfo->evt_E; + break; + case 24: + pEventNumber = pCurrentNPCInfo->evt_F; + break; + default: goto _return; - } - switch ( a1 ) - { - case 19: - v3 = v2->evt_A; - break; - case 20: - v3 = v2->evt_B; - break; - case 21: - v3 = v2->evt_C; - break; - default: - if ( a1 != 22 ) - goto _return; - v3 = v2->evt_D; - break; - } - } - goto LABEL_84; - } - if ( a1 == 24 ) - { - v3 = v2->evt_F; -LABEL_84: - if ( v3 < 200 || v3 > 310 ) - { - if ( v3 < 400 || v3 > 410 ) - { - if ( v3 == 139 ) + } + if ( pEventNumber < 200 || pEventNumber > 310 ) + { + if ( pEventNumber < 400 || pEventNumber > 410 ) + { + if ( pEventNumber == 139 ) { sub_4B1ECE(); } else { - if ( v3 == 311 ) + if ( pEventNumber == 311 ) { sub_4BBA85_bounties(); } @@ -9467,32 +9456,32 @@ { ptr_F8B1E8 = 0; _5C3420_pDecoration = (LevelDecoration *)1; - EventProcessor(v3, 0, 1); + EventProcessor(pEventNumber, 0, 1); _5C3420_pDecoration = 0; } } } else { - dword_F8B1D8 = v1; - sub_4B3EF0(v3 - 400); + dword_F8B1D8 = uMessageParam; + DrawJoinGuildWindow(pEventNumber - 400); } } else { - sub_4B3FE5(v3); + sub_4B3FE5(pEventNumber); } goto _return; } - if ( a1 != 76 ) - { - if ( a1 == 77 ) - { - v16 = v2->uProfession; + if ( uMessageParam != 76 ) + { + if ( uMessageParam == 77 ) + { + v16 = pCurrentNPCInfo->uProfession; if (dialogue_show_profession_details) - v17 = pNPCStats->pProfessions[v2->uProfession - 1].pJoinText; + v17 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pJoinText; else - v17 = pNPCStats->pProfessions[v2->uProfession - 1].pBenefits; + v17 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pBenefits; ptr_F8B1E8 = v17; v18 = BuilDialogueString(v17, uActiveCharacter - 1, 0, 0, 0, 0); dialogue_show_profession_details = ~dialogue_show_profession_details; @@ -9500,7 +9489,7 @@ } else { - if ( a1 == 79 ) + if ( uMessageParam == 79 ) { if ( dword_F8B1A8 ) { @@ -9526,18 +9515,19 @@ } pPlayers[uActiveCharacter]->PlaySound(SPEECH_85, 0); } - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ } } else { - if ( a1 == 82 && dword_F8B1A8 ) + if ( uMessageParam == 82 && dword_F8B1A8 ) { Party::TakeGold(gold_transaction_amount); v4 = pParty->pPlayers; @@ -9550,46 +9540,47 @@ switch ( dword_F8B1D8 ) { case 19: - v10 = v2->evt_A; + v10 = pCurrentNPCInfo->evt_A; if ( (signed int)v10 >= 400 && (signed int)v10 <= 416 ) - v2->evt_A = 0; + pCurrentNPCInfo->evt_A = 0; break; case 20: - v9 = v2->evt_B; + v9 = pCurrentNPCInfo->evt_B; if ( v9 >= 400 && v9 <= 416 ) - v2->evt_B = 0; + pCurrentNPCInfo->evt_B = 0; break; case 21: - v8 = v2->evt_C; + v8 = pCurrentNPCInfo->evt_C; if ( v8 >= 400 && v8 <= 416 ) - v2->evt_C = 0; + pCurrentNPCInfo->evt_C = 0; break; case 22: - v7 = v2->evt_D; + v7 = pCurrentNPCInfo->evt_D; if ( v7 >= 400 && v7 <= 416 ) - v2->evt_D = 0; + pCurrentNPCInfo->evt_D = 0; break; case 23: - v6 = v2->evt_E; + v6 = pCurrentNPCInfo->evt_E; if ( v6 >= 400 && v6 <= 416 ) - v2->evt_E = 0; + pCurrentNPCInfo->evt_E = 0; break; case 24: - v5 = v2->evt_F; + v5 = pCurrentNPCInfo->evt_F; if ( v5 >= 400 ) { if ( v5 <= 416 ) - v2->evt_F = 0; + pCurrentNPCInfo->evt_F = 0; } break; } - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ v11 = uActiveCharacter; if ( uActiveCharacter ) { @@ -9612,15 +9603,15 @@ goto _return; } //v20 = v2->uProfession; - if ( v2->uProfession != 51 ) - { - v21 = pNPCStats->pProfessions[v2->uProfession - 1].uHirePrice; + if ( pCurrentNPCInfo->uProfession != 51 ) + { + v21 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].uHirePrice; if ( pParty->uNumGold < v21 ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); dialogue_show_profession_details = false; uDialogueType = 13; - ptr_F8B1E8 = pNPCStats->pProfessions[v2->uProfession - 1].pJoinText; + ptr_F8B1E8 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pJoinText; ptr_F8B1E8 = BuilDialogueString((char *)ptr_F8B1E8, uActiveCharacter - 1, 0, 0, 0, 0); if ( uActiveCharacter ) pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0); @@ -9630,19 +9621,19 @@ Party::TakeGold(v21); } //LOBYTE(v2->uFlags) |= 0x80u; - v2->uFlags = 128; + pCurrentNPCInfo->uFlags = 128; pParty->field_709 = 0; sub_44A56A(); if ( pParty->pHirelings[0].pName ) { - memcpy(&pParty->pHirelings[1], v2, sizeof(pParty->pHirelings[1])); - v24 = v2->pName; + memcpy(&pParty->pHirelings[1], pCurrentNPCInfo, sizeof(pParty->pHirelings[1])); + v24 = pCurrentNPCInfo->pName; v22 = pParty->pHireling2Name; } else { - memcpy(pParty->pHirelings, v2, 0x4Cu); - v24 = v2->pName; + memcpy(pParty->pHirelings, pCurrentNPCInfo, 0x4Cu); + v24 = pCurrentNPCInfo->pName; v22 = pParty->pHireling1Name; } strcpy(v22, v24); @@ -9650,13 +9641,15 @@ sub_44A56A(); PrepareHouse((HOUSE_TYPE)(int)window_SpeakInHouse->ptr_1C); dword_F8B19C = 1; - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ v11 = uActiveCharacter; if ( uActiveCharacter ) { @@ -9665,7 +9658,7 @@ goto LABEL_50; } _return: - pVideoPlayer->_4BF5B2(); + pVideoPlayer->_4BF5B2();//HouseVideo } @@ -10000,23 +9993,14 @@ //----- (004B29F2) -------------------------------------------------------- -const char *__fastcall sub_4B29F2(int a1) -{ - int v1; // esi@1 - Player *v2; // edi@1 - int v3; // eax@1 - Player *v4; // ecx@1 - - v1 = a1; +const char *__fastcall ContractSelectText(int pEventNumber) +{ dword_F8B1A8 = 0; - v2 = pPlayers[uActiveCharacter]; - v3 = a1 + 50; - v4 = pPlayers[uActiveCharacter]; - dword_F8B1AC_something_todo_with_awards = v3; - gold_transaction_amount = dword_4F08EC[v1]; - if ( v4->CanAct() ) - { - if ( (unsigned __int16)_449B57_test_bit((unsigned __int8 *)v2->field_152, dword_F8B1AC_something_todo_with_awards) ) + dword_F8B1AC_something_todo_with_awards = pEventNumber + 50; + gold_transaction_amount = dword_4F08EC[pEventNumber]; + if ( pPlayers[uActiveCharacter]->CanAct() ) + { + if ( (unsigned __int16)_449B57_test_bit((unsigned __int8 *)pPlayers[uActiveCharacter]->field_152, dword_F8B1AC_something_todo_with_awards) ) { return pNPCTopics[123].pText; } @@ -10025,7 +10009,7 @@ if ( gold_transaction_amount <= pParty->uNumGold ) { dword_F8B1A8 = 1; - return pNPCTopics[v1 + 110].pText; + return pNPCTopics[pEventNumber + 110].pText; } else { @@ -10041,7 +10025,7 @@ //----- (004B2A74) -------------------------------------------------------- -char __cdecl sub_4B2A74() +char __cdecl SimpleHouseAndBoatsDialog() { char *v0; // esi@3 char *v1; // ST1C_4@3 @@ -10103,7 +10087,7 @@ NPCData *v58; // [sp+118h] [bp-4h]@6 memcpy(&a1, pDialogueWindow, sizeof(a1)); - if ( array_5913D8[6] == (NPCData *)uNumDialogueNPCPortraits && uHouse_ExitPic ) + if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) { v0 = pMapStats->pInfos[uHouse_ExitPic].pName; v1 = pMapStats->pInfos[uHouse_ExitPic].pName; @@ -10114,7 +10098,7 @@ a1.uFrameX = 483; a1.uFrameWidth = 148; a1.uFrameZ = 334; - v2 = (&off_4EB080)[4 * uHouse_ExitPic]; + v2 = pTransitionStrings[uHouse_ExitPic]; if ( !v2 ) { sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[411], v0); @@ -10127,7 +10111,7 @@ } a1.uFrameWidth -= 10; a1.uFrameZ -= 10; - v58 = array_5913D8[(unsigned int)((char *)array_5913D8[6] + -(dword_591080 != 0) - 1)]; + v58 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)]; v6 = v58; v55 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u); v7 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u); @@ -10202,7 +10186,7 @@ v27 = v26 - 3; if ( !v27 ) { - v33 = (char *)sub_4B29F2((int)v52.ptr_1C); + v33 = (char *)ContractSelectText((int)v52.ptr_1C); goto LABEL_44; } v28 = v27 - 1; @@ -10447,7 +10431,7 @@ if ( v1 ) v21 = word_4F063E[(signed int)v20]; else - v21 = word_4F03FE[(signed int)v20]; + v21 = word_4F0404[(signed int)v20 - 4];//word_4F03FE[(signed int)v20]; v22 = v21 - 23; if ( v22 ) { @@ -11059,42 +11043,17 @@ } //----- (004B3EF0) -------------------------------------------------------- -void __fastcall sub_4B3EF0(int a4) -{ - int v1; // edi@1 - - v1 = a4; +void __fastcall DrawJoinGuildWindow(int pEventNumber) +{ uDialogueType = 81; - ptr_F8B1E8 = (char *)pNPCTopics[a4 + 99].pText; - sub_4B29F2(a4); + ptr_F8B1E8 = (char *)pNPCTopics[pEventNumber + 99].pText; + ContractSelectText(pEventNumber); pDialogueWindow->Release(); - pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15E, WINDOW_MainMenu, v1, 0); - pBtn_ExitCancel = pDialogueWindow->CreateButton( - 0x1D7, - 0x1BD, - 0xA9, - 0x23, - 1, - 0, - 0x71, - 0, - 0, - pGlobalTXT_LocalizationStrings[34], - (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0), - 0); + pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15E, WINDOW_MainMenu, pEventNumber, 0); + pBtn_ExitCancel = pDialogueWindow->CreateButton(0x1D7, 0x1BD, 0xA9, 0x23, 1, 0, 0x71, 0, 0, pGlobalTXT_LocalizationStrings[34], + (Texture *)(uTextureID_506438 != -1 ? &pIcons_LOD->pTextures[uTextureID_506438] : 0), 0); pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, 0x51u, 0, 0, "", 0); - pDialogueWindow->CreateButton( - 0x1E0u, - 0xA0u, - 0x8Cu, - 0x1Eu, - 1, - 0, - 0xAFu, - 0x52u, - 0, - pGlobalTXT_LocalizationStrings[122], - 0); + pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, 0xAFu, 0x52u, 0, pGlobalTXT_LocalizationStrings[122], 0); pDialogueWindow->_41D08F(1, 1, 0, 2); dword_F8B19C = -1; } @@ -11143,7 +11102,7 @@ NPCData *v1; // edi@1 v0 = 0; - v1 = array_5913D8[(unsigned int)((char *)array_5913D8[6] + -(dword_591080 != 0) - 1)]; + v1 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)]; pDialogueWindow->Release(); pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15Eu, WINDOW_MainMenu, 0, 0); pBtn_ExitCancel = pDialogueWindow->CreateButton( @@ -11194,76 +11153,38 @@ //----- (004B4224) -------------------------------------------------------- -GUIButton *_4B4224_UpdateNPCTopics(int _this) -{ - int v1; // ebx@1 - GUIButton *result; // eax@3 +void _4B4224_UpdateNPCTopics( int _this ) + { + int num_menu_buttons; // ebx@1 int i; // ebp@5 - signed int v4; // ebp@9 - void *v5; // ecx@14 - bool v6; // eax@16 - void *v7; // ecx@19 - bool v8; // eax@21 - void *v9; // ecx@24 - bool v10; // eax@26 - void *v11; // ecx@29 - bool v12; // eax@31 - void *v13; // ecx@34 - bool v14; // eax@36 - void *v15; // ecx@39 - bool v16; // eax@41 + // signed int v4; // ebp@9 + int v6; // eax@16 + int v8; // eax@21 + int v10; // eax@26 + int v12; // eax@31 + int v14; // eax@36 + int v16; // eax@41 NPCData *v17; // [sp+10h] [bp-4h]@4 - v1 = 0; - array_5913D8[6] = (NPCData *)(_this + 1); + num_menu_buttons = 0; + pDialogueNPCCount = (_this + 1); if ( _this + 1 == uNumDialogueNPCPortraits && uHouse_ExitPic ) { pDialogueWindow->Release(); pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0); - sprintf(byte_591098, pGlobalTXT_LocalizationStrings[411], pMapStats->pInfos[uHouse_ExitPic].pName); - pBtn_ExitCancel = pDialogueWindow->CreateButton( - 0x236u, - 0x1BDu, - 0x4Bu, - 0x21u, - 1, - 0, - 0x71u, - 0, - 0x4Eu, + sprintf(sHouseName, pGlobalTXT_LocalizationStrings[LOCSTR_ENTER_S], pMapStats->pInfos[uHouse_ExitPic].pName); + pBtn_ExitCancel = pDialogueWindow->CreateButton( 566, 445, 75, 33, 1, 0, 0x71u, 0, 0x4Eu, pGlobalTXT_LocalizationStrings[34],// "Cancel" - (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), - 0); - pBtn_YES = pDialogueWindow->CreateButton( - 486u, - 445u, - 75u, - 33u, - 1, - 0, - 0xBFu, - 1u, - 0x59u, - byte_591098, - (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0), - 0); - pDialogueWindow->CreateButton( - pNPCPortraits_x, - pNPCPortraits_y, - 63u, - 73u, - 1, - 0, - 0xBFu, - 1u, - 0x20u, - byte_591098, - 0); - result = pDialogueWindow->CreateButton(8u, 8u, 460u, 344u, 1, 0, 0xBFu, 1u, 0x59u, byte_591098, 0); + (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0),0); + pBtn_YES = pDialogueWindow->CreateButton( 486u, 445u, 75u, 33u, 1, 0, 0xBFu, 1u, 0x59u, + sHouseName, + (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0), 0); + pDialogueWindow->CreateButton( pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 63u, 73u, 1, 0, 0xBFu, 1u, 0x20u, sHouseName, 0); + pDialogueWindow->CreateButton(8u, 8u, 460u, 344u, 1, 0, 0xBFu, 1u, 0x59u, sHouseName, 0); } else { - v17 = array_5913D8[_this + 1 - ((dword_591080 != 0) + 1)]; + v17 = HouseNPCData[_this + 1 - ((dword_591080 != 0) + 1)]; if ( dword_F8B19C == -1 ) { pDialogueWindow->Release(); @@ -11271,169 +11192,85 @@ else { for ( i = 0; i < uNumDialogueNPCPortraits; ++i ) - GUIButton::_41D0D8((GUIButton *)array_5913D8[i + 7]); - } - v4 = 1; + GUIButton::_41D0D8((GUIButton *)HouseNPCData[i + 7]); + } pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0); - pBtn_ExitCancel = pDialogueWindow->CreateButton( - 471u, - 445u, - 169u, - 35u, - 1, - 0, - 0x71u, - 0, - 0, + pBtn_ExitCancel = pDialogueWindow->CreateButton( 471u, 445u, 169u, 35u, 1, 0, 0x71u, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation" - (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), - 0); + (Texture *)(uTextureID_506438 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_506438] : 0), 0); pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, "", 0); - if ( array_5913D8[6] == (NPCData *)1 && dword_591080 ) - { - result = (GUIButton *)sub_4B3B42(dword_F8B198); + if ( pDialogueNPCCount == 1 && dword_591080 ) + { + sub_4B3B42(dword_F8B198); } else { if ( v17->joins ) { - v1 = 1; + num_menu_buttons = 1; pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, 0xAFu, 0xDu, 0, "", 0); } - v5 = (void *)v17->evt_A; - if ( v5 ) - { - if ( v1 < 4 ) - { - v6 = sub_4466C4(v5); + if ( v17->evt_A) + { + if ( num_menu_buttons < 4 ) + { + v6 = NPC_EventProcessor(v17->evt_A); if ( v6 == 1 || v6 == 2 ) - pDialogueWindow->CreateButton( - 480u, - 30 * v1++ + 160, - 140u, - 30u, - 1, - 0, - 0xAFu, - 0x13u, - 0, - "", - 0); - } - } - v7 = (void *)v17->evt_B; - if ( v7 ) - { - if ( v1 < 4 ) - { - v8 = sub_4466C4(v7); + pDialogueWindow->CreateButton( 480u, 30 * num_menu_buttons++ + 160, 140u, 30u, 1, 0, 0xAFu, 0x13u, 0, "", 0); + } + } + if ( v17->evt_B ) + { + if ( num_menu_buttons < 4 ) + { + v8 = NPC_EventProcessor(v17->evt_B); if ( v8 == 1 || v8 == 2 ) - pDialogueWindow->CreateButton( - 480u, - 30 * v1++ + 160, - 140u, - 30u, - 1, - 0, - 0xAFu, - 0x14u, - 0, - "", - 0); - } - } - v9 = (void *)v17->evt_C; - if ( v9 ) - { - if ( v1 < 4 ) - { - v10 = sub_4466C4(v9); + pDialogueWindow->CreateButton( 480u, 30 * num_menu_buttons++ + 160, 140u, 30u, 1, 0, 0xAFu, 0x14u, 0, "", 0); + } + } + if ( v17->evt_C ) + { + if ( num_menu_buttons < 4 ) + { + v10 = NPC_EventProcessor(v17->evt_C); if ( v10 == 1 || v10 == 2 ) - pDialogueWindow->CreateButton( - 480u, - 30 * v1++ + 160, - 140u, - 30u, - 1, - 0, - 0xAFu, - 0x15u, - 0, - "", - 0); - } - } - v11 = (void *)v17->evt_D; - if ( v11 ) - { - if ( v1 < 4 ) - { - v12 = sub_4466C4(v11); + pDialogueWindow->CreateButton( 480u, 30 * num_menu_buttons++ + 160, 140u, 30u, 1, 0, 0xAFu, 0x15u, 0, "", 0); + } + } + + if ( v17->evt_D ) + { + if ( num_menu_buttons < 4 ) + { + v12 = NPC_EventProcessor(v17->evt_D); if ( v12 == 1 || v12 == 2 ) - pDialogueWindow->CreateButton( - 0x1E0u, - 30 * v1++ + 160, - 0x8Cu, - 0x1Eu, - 1, - 0, - 0xAFu, - 0x16u, - 0, - "", - 0); - } - } - v13 = (void *)v17->evt_E; - if ( v13 ) - { - if ( v1 < 4 ) - { - v14 = sub_4466C4(v13); + pDialogueWindow->CreateButton( 0x1E0u, 30 * num_menu_buttons++ + 160, 0x8Cu, 0x1Eu, 1, 0, 0xAFu, 0x16u, 0, "", 0); + } + } + if ( v17->evt_E ) + { + if ( num_menu_buttons < 4 ) + { + v14 = NPC_EventProcessor(v17->evt_E); if ( v14 == 1 || v14 == 2 ) - pDialogueWindow->CreateButton( - 0x1E0u, - 30 * v1++ + 160, - 0x8Cu, - 0x1Eu, - 1, - 0, - 0xAFu, - 0x17u, - 0, - "", - 0); - } - } - v15 = (void *)v17->evt_F; - if ( v15 ) - { - if ( v1 < 4 ) - { - v16 = sub_4466C4(v15); + pDialogueWindow->CreateButton( 0x1E0u, 30 * num_menu_buttons++ + 160, 0x8Cu, 0x1Eu, 1, 0, 0xAFu, 0x17u, 0, "", 0); + } + } + if ( v17->evt_F ) + { + if ( num_menu_buttons < 4 ) + { + v16 = NPC_EventProcessor(v17->evt_F); if ( v16 == 1 || v16 == 2 ) - pDialogueWindow->CreateButton( - 0x1E0u, - 30 * v1++ + 160, - 0x8Cu, - 0x1Eu, - 1, - 0, - 0xAFu, - 0x18u, - 0, - "", - 0); - } - } - pDialogueWindow->_41D08F(v1, 1, 0, 2); - v4 = 1; - result = (GUIButton *)pDialogueWindow->pNumPresenceButton; + pDialogueWindow->CreateButton( 0x1E0u, 30 * num_menu_buttons++ + 160, 0x8Cu, 0x1Eu, 1, 0, 0xAFu, 0x18u, 0, "", 0); + } + } + pDialogueWindow->_41D08F(num_menu_buttons, 1, 0, 2); dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; } - dword_F8B19C = v4; - } - return result; + dword_F8B19C = 1; + } + } @@ -11465,7 +11302,7 @@ } //----- (004B4710) -------------------------------------------------------- -int __cdecl ui_training() +int __cdecl TrainingDialog() { Player *v0; // ebx@1 int color2; // eax@1 @@ -11732,7 +11569,7 @@ LABEL_55: HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, v63); LABEL_56: - result = pMessageQueue_50CBD0->uNumMessages; + /*result = pMessageQueue_50CBD0->uNumMessages; if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; @@ -11741,7 +11578,9 @@ *(&pMessageQueue_50CBD0->uNumMessages + result) = 0; ++pMessageQueue_50CBD0->uNumMessages; } - return result; + return result;*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + return 1; // void function actually } sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[538], v5 - LODWORD(v0->uExperience), v34 + 1);// // "You need %d more experience to train to level %d" @@ -11861,7 +11700,7 @@ //----- (004B4FCF) -------------------------------------------------------- -int __cdecl ui_shop_teachers() +int __cdecl MagicShopDialog() { Player *v0; // ebx@1 int result; // eax@6 @@ -12328,7 +12167,8 @@ { do { - if ( pParty->field_777C[9 * (v49 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) + // if ( pParty->field_777C[9 * (v49 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) + if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v49].uItemID); { v50 = dword_F8B168[v49]; v51 = 152 - v50->uTextureHeight; @@ -12360,7 +12200,8 @@ v122 = 0; do { - if ( pParty->field_777C[9 * (v122 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 54] ) + //if ( pParty->field_777C[9 * (v122 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 54] ) + if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v122+1].uItemID); { v54 = dword_F8B168[v122 + 6]; v55 = 306 - v54->uTextureHeight; @@ -12390,7 +12231,8 @@ { do { - if ( pParty->field_C59C[9 * (v49 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) + // if ( pParty->field_C59C[9 * (v49 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) + if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v49].uItemID) { v58 = dword_F8B168[v49]; v59 = 152 - v58->uTextureHeight; @@ -12422,7 +12264,8 @@ v122 = 0; do { - if ( pParty->field_C59C[9 * (v122 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 778] ) + //if ( pParty->Spell_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v49] + 778] ) //weak + if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v49].uAttributes) { v62 = dword_F8B168[v122 + 6]; v63 = 306 - v62->uTextureHeight; @@ -12459,7 +12302,7 @@ { do { - if ( pParty->field_777C[9 * (v66 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) + if ( pParty->field_777C[(unsigned int)window_SpeakInHouse->ptr_1C][v66].uItemID); //9 * (v66 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) ++v117; ++v66; } @@ -12469,7 +12312,8 @@ { do { - if ( pParty->field_C59C[9 * (v66 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) + //if ( pParty->field_C59C[9 * (v66 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) + if (pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v66].uItemID) ++v117; ++v66; } @@ -12502,10 +12346,11 @@ v71 = (pRenderer->pActiveZBuffer[result] & 0xFFFF) - 1; v117 = v71; v72 = (int)window_SpeakInHouse->ptr_1C; - v73 = 9 * (v71 + 12 * v72); - v74 = (ItemGen *)&pParty->field_777C[v73]; + // v73 = 9 * (v71 + 12 * v72); + v74 = (ItemGen *)&pParty->field_777C[v72][v71]; if ( dword_F8B19C != 2 ) - v74 = (ItemGen *)&pParty->field_C59C[v73 + 724]; + // v74 = (ItemGen *)&pParty->field_C59C[v73 + 724]; + v74 =&pParty->Recipes_Item[v72][v71]; if ( v67 && Str ) { v10 = pGlobalTXT_LocalizationStrings[181];// "Steal %24" @@ -12612,13 +12457,14 @@ pParty->field_709 = 0; sub_44A56A(); dword_591084 = 0; - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ goto LABEL_89; } v14 = 76; @@ -12673,13 +12519,15 @@ strcpy(v13, v15); pParty->field_709 = 0; sub_44A56A(); - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 ) pDialogue_SpeakingActor->uAIState = Removed; if ( uActiveCharacter ) @@ -12697,13 +12545,14 @@ { if ( v2->uProfession != 41 ) v2->bHasUsedTheAbility = 1; - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); goto LABEL_87; } v7 = pGlobalTXT_LocalizationStrings[140]; @@ -12774,7 +12623,7 @@ else { dword_F8B1D8 = newDialogueType; - sub_4B3EF0(v4 - 400); + DrawJoinGuildWindow(v4 - 400); } } else @@ -12859,7 +12708,7 @@ //----- (004B5D7C) -------------------------------------------------------- -int __cdecl sub_4B5D7C() +int __cdecl GuildDialog() { GUIWindow *v0; // ebx@1 Player *v1; // edi@1 @@ -12972,7 +12821,7 @@ } } } - result = pMessageQueue_50CBD0->uNumMessages; + /*result = pMessageQueue_50CBD0->uNumMessages; if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; @@ -12980,8 +12829,9 @@ result = 3 * pMessageQueue_50CBD0->uNumMessages + 3; *(&pMessageQueue_50CBD0->uNumMessages + result) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } - return result; + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + return 1; // void function actually } pRenderer->DrawTextureIndexed(8u, 8u, dword_F8B164); v5 = 0; @@ -13206,7 +13056,7 @@ //----- (004B705E) -------------------------------------------------------- -int __cdecl sub_4B705E() +int __cdecl TampleDialog() { GUIWindow *v0; // ebx@1 Player *v1; // esi@1 @@ -13262,9 +13112,7 @@ int v51; // eax@73 unsigned int v52; // ecx@73 unsigned __int16 v53; // ax@73 - char a1[100]; // [sp+10h] [bp-1B4h]@64 - char Dest; // [sp+74h] [bp-150h]@66 - char v56; // [sp+D8h] [bp-ECh]@66 + char a1[300]; // [sp+10h] [bp-1B4h]@64 GUIWindow v57; // [sp+13Ch] [bp-88h]@1 __int64 v58; // [sp+190h] [bp-34h]@1 __int64 v59; // [sp+198h] [bp-2Ch]@1 @@ -13518,7 +13366,7 @@ v1->PlaySound(SPEECH_82, 0); pOtherOverlayList->_4418B1(20, uActiveCharacter + 99, 0, 65536); LABEL_46: - result = pMessageQueue_50CBD0->uNumMessages; + /*result = pMessageQueue_50CBD0->uNumMessages; if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; @@ -13526,8 +13374,9 @@ result = 3 * pMessageQueue_50CBD0->uNumMessages + 3; *(&pMessageQueue_50CBD0->uNumMessages + result) = v25; ++pMessageQueue_50CBD0->uNumMessages; - } - return result; + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25); + return result; // void func } v63 = 1; v41 = pDialogueWindow->GetControl(pDialogueWindow->pStartingPosActiveItem); @@ -13539,8 +13388,8 @@ sprintf(a1, "%s %d %s", pGlobalTXT_LocalizationStrings[104], HIDWORD(v60), pGlobalTXT_LocalizationStrings[97]); v63 = 0; } - strcpy(&Dest, pGlobalTXT_LocalizationStrings[68]); - strcpy(&v56, pGlobalTXT_LocalizationStrings[160]); + strcpy(&a1[100], pGlobalTXT_LocalizationStrings[68]); + strcpy(&a1[200], pGlobalTXT_LocalizationStrings[160]); v42 = v63; v43 = pDialogueWindow; v44 = v63; @@ -13598,7 +13447,7 @@ //----- (004B8F94) -------------------------------------------------------- -void *__cdecl sub_4B8F94() +void sub_4B8F94() { GUIWindow *v0; // edi@1 signed int v1; // ebp@1 @@ -13648,18 +13497,21 @@ LABEL_12: v6 = v12; LABEL_13: - pItemsTable->GenerateItem(v5, v6, (ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724]); + pItemsTable->GenerateItem(v5, v6,&pParty->Recipes_Item[v3][v1]);//(ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724]); v0 = window_SpeakInHouse; v2 = (int)&window_SpeakInHouse->ptr_1C; - pParty->field_C59C[9 * (v1 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 729] = 1; + // pParty->field_C59C[9 * (v1 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 729] = 1; + pParty->Recipes_Item[(unsigned int)window_SpeakInHouse->ptr_1C][v1].uAttributes= 1; goto LABEL_14; } - auto _a = (ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724]; + // auto _a = (ItemGen *)&pParty->field_C59C[9 * (v1 + 12 * v3) + 724]; + auto _a =&pParty->Recipes_Item[v3][v1]; _a->Reset(); - v2 = (int)&v0->ptr_1C; - v10 = rand(); - v0 = window_SpeakInHouse; - pParty->field_C59C[9 * (v1 + 12 * *(int *)v2) + 724] = v10 % 32 + 740; + // v2 = (int)&v0->ptr_1C; + //v10 = rand(); + // v0 = window_SpeakInHouse; + // pParty->field_C59C[9 * (v1 + 12 * *(int *)v2) + 724] = v10 % 32 + 740; + pParty->Recipes_Item[(int)v0->ptr_1C][v1].uItemID= rand() % 32 + 740; } LABEL_14: v3 = *(int *)v2; @@ -13676,8 +13528,7 @@ } LABEL_15: result = v0->ptr_1C; - *(int *)&pParty->field_16154[4 * (int)result] = 0; - return result; + pParty->field_16154[(int)v0->ptr_1C] = 0; } @@ -13780,7 +13631,7 @@ { v5 = 0; } - result = pMessageQueue_50CBD0->uNumMessages; + /*result = pMessageQueue_50CBD0->uNumMessages; if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; @@ -13788,8 +13639,9 @@ result = 3 * pMessageQueue_50CBD0->uNumMessages + 3; *(&pMessageQueue_50CBD0->uNumMessages + result) = v5; ++pMessageQueue_50CBD0->uNumMessages; - } - return result; + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v5); + return result; // void func } if ( !(unsigned __int16)_449B57_test_bit( (unsigned __int8 *)v1->field_152, @@ -14130,11 +13982,12 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, 3); - if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) return; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; - goto LABEL_33; + goto LABEL_33;*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); } Party::TakeGold(s1); v47[1] = (const char *)7; @@ -14206,7 +14059,8 @@ sqrt(3.1415926); while ( sub_4BD8B5() ) ; - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; @@ -14214,7 +14068,7 @@ *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; return; - } + }*/ } else { @@ -14381,8 +14235,8 @@ v4->uCurrentActionTime += pMiscTimer->uTimeElapsed; if ( (signed int)v4->uCurrentActionTime >= v5 ) { - v17 = dword_4F6E08[v20]; - v6 = Actor::GetDirectionInfo(8 * v20 | 3, v17, &a3, v2); + v17 = ai_near_actors_targets_pid[v20]; + v6 = Actor::GetDirectionInfo(8 * v20 | OBJECT_Actor, v17, &a3, v2); v7 = v4->uAIState; memcpy(&v15, v6, sizeof(v15)); v8 = v7 - 4; @@ -14396,7 +14250,7 @@ if ( v10 ) { if ( v10 != 8 ) - Actor::_403F58(v20, v17, 32, &v14); + Actor::AI_StandOrBored(v20, v17, 32, &v14); } } } @@ -14667,9 +14521,9 @@ } LABEL_44: HIWORD(v25) = HIWORD(x); - v0->some_x = a1a; - v0->some_y = a2; - v0->some_z = a3; + v0->world_x = a1a; + v0->world_y = a2; + v0->world_z = a3; v0->uScreenSpaceX = v43; v0->uScreenSpaceY = a6; LOWORD(v25) = 0; @@ -14700,66 +14554,57 @@ //----- (00444732) -------------------------------------------------------- -char *_444732_GetEventHintString(unsigned int uEventID) -{ - signed int v1; // edx@1 - char *v2; // eax@2 - int v3; // ebx@4 - int v4; // esi@4 +char *GetEventHintString(unsigned int uEventID) +{ + signed int event_index; // edx@1 + int event_pos; // esi@4 char *result; // eax@6 - int v6; // eax@9 - char *i; // esi@11 - int v8; // edx@12 - - v1 = 0; - if ( (signed int)uLevelEVT_NumEvents <= 0 ) - { -LABEL_6: - result = 0; - } - else - { - v2 = (char *)&pLevelEVT_Index[0].uEventOffsetInEVT; + unsigned int str_index; // eax@9 + int i; // esi@11 + _evt_raw* test_evt; + _evt_raw* last_evt; + + event_index = 0; + if ( uLevelEVT_NumEvents <= 0 ) + return NULL; + + //v2 = (char *)&pLevelEVT_Index[0].uEventOffsetInEVT; while ( 1 ) { - if ( *((int *)v2 - 2) == uEventID ) - { - v3 = *(int *)v2; - v4 = *((int *)v2 + 3); - if ( pLevelEVT[*(int *)v2 + 4] == 4 ) + if ( pLevelEVT_Index[event_index].uEventID == uEventID ) + { + test_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index].uEventOffsetInEVT]; + last_evt=test_evt; + event_pos = pLevelEVT_Index[event_index+1].uEventOffsetInEVT; + if ( test_evt->_e_type == EVENT_MouseOver ) break; } - ++v1; - v2 += 12; - if ( v1 >= (signed int)uLevelEVT_NumEvents ) - goto LABEL_6; - } - if ( pLevelEVT[v4 + 4] == 2 ) - { - v6 = (unsigned __int8)pLevelEVT[v4 + 5] - + (((unsigned __int8)pLevelEVT[v4 + 6] - + (((unsigned __int8)pLevelEVT[v4 + 7] + ((unsigned __int8)pLevelEVT[v4 + 8] << 8)) << 8)) << 8); -LABEL_10: - //result = (char *)p2DEvents_minus1_::04[13 * v6]; - result = (char *)p2DEvents[v6 - 1].pName; + ++event_index; + if ( event_index >= uLevelEVT_NumEvents ) + return NULL; + } + test_evt=(_evt_raw*)&pLevelEVT[event_pos]; + if ( test_evt->_e_type== EVENT_SpeakInHouse ) + { + str_index = EVT_DWORD(test_evt->v5); + result = (char *)p2DEvents[str_index - 1].pName; } else { - for ( i = (char *)pLevelEVT_Index + 4 * (3 * v1 + 3); *(int *)i == uEventID; i += 12 ) - { - v8 = *((int *)i + 2); - if ( pLevelEVT[v8 + 4] == 2 ) - { - v6 = (unsigned __int8)pLevelEVT[v8 + 5] - + (((unsigned __int8)pLevelEVT[v8 + 6] - + (((unsigned __int8)pLevelEVT[v8 + 7] + ((unsigned __int8)pLevelEVT[v8 + 8] << 8)) << 8)) << 8); - if ( (unsigned int)v6 < 0x258 ) - goto LABEL_10; - } - } - result = &pLevelStr[pLevelStrOffsets[(unsigned __int8)pLevelEVT[v3 + 5]]]; - } - } + for ( i = event_index+1; pLevelEVT_Index[i].uEventID == uEventID; ++i ) + { + event_pos = pLevelEVT_Index[i].uEventOffsetInEVT; + test_evt=(_evt_raw*)&pLevelEVT[event_pos]; + if ( test_evt->_e_type == EVENT_SpeakInHouse ) + { + str_index = EVT_DWORD(test_evt->v5); + if ( str_index < 600 ) + return (char *)p2DEvents[str_index - 1].pName; + } + } + result = &pLevelStr[pLevelStrOffsets[EVT_BYTE(last_evt->v5)]]; + } + return result; } @@ -14771,7 +14616,7 @@ { unsigned int v9; // ebx@1 int v10; // edi@1 - signed int v11; // eax@1 + //signed int v11; // eax@1 unsigned int v12; // eax@6 const char *v13; // ST0C_4@6 unsigned int v14; // eax@8 @@ -14779,7 +14624,7 @@ unsigned int v16; // eax@16 unsigned int result; // eax@26 const char *v18; // [sp-8h] [bp-40h]@9 - const char *v19; // [sp-4h] [bp-3Ch]@2 + //const char *v19; // [sp-4h] [bp-3Ch]@2 char *v20; // [sp-4h] [bp-3Ch]@9 const char *v21; // [sp-4h] [bp-3Ch]@11 char pContainer[40]; // [sp+Ch] [bp-2Ch]@1 @@ -14798,7 +14643,15 @@ uCurrentHouse_Animation = v9; pEventTimer->Pause(); pAudioPlayer->StopChannels(-1, -1); - v11 = const_2(); + + switch (pParty->alignment) + { + case PartyAlignment_Good: sprintf(pContainer, "evt%02d-b", const_2()); break; + case PartyAlignment_Neutral: sprintf(pContainer, "evt%02d", const_2()); break; + case PartyAlignment_Evil: sprintf(pContainer, "evt%02d-c", const_2()); break; + default: assert(false); + } + /*v11 = const_2(); sprintf(pContainer, "evt%02d", v11); if ( pParty->uAlignment ) { @@ -14810,8 +14663,9 @@ { v19 = "-b"; } - strcat(pContainer, v19); -LABEL_6: + strcat(pContainer, v19);*/ + +//LABEL_6: v12 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); v13 = pHouse_ExitPictures[v10]; pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v12]; @@ -14832,7 +14686,7 @@ v20 = pMapStats->pInfos[v14].pName; v18 = pGlobalTXT_LocalizationStrings[410]; LABEL_10: - sprintf(byte_591098, v18, v20); + sprintf(sHouseName, v18, v20); goto LABEL_20; } v21 = pGlobalTXT_LocalizationStrings[79]; @@ -14851,9 +14705,9 @@ } v21 = pGlobalTXT_LocalizationStrings[73]; LABEL_19: - strcpy(byte_591098, v21); + strcpy(sHouseName, v21); LABEL_20: - pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)26, 0, (int)byte_591098); + pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)26, 0, (int)sHouseName); //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * v9]].field_C) ) if ( BYTE1(pAnimatedRooms[p2DEvents[v9 - 1].uAnimationID].field_C) ) HousePlaySomeSound(v9, 1); @@ -14939,7 +14793,7 @@ //if ( !(*(char *)v6 & 0x80) ) { v7 = uNumDialogueNPCPortraits++ - dword_591080 ? 1 : 0; - array_5913D8[v7] = npc; + HouseNPCData[v7] = npc; //v6 = v17; //*(&v13 + v2) = *(v17 - 1); Dst[uNumDialogueNPCPortraits - 1] = npc->uPortraitID; @@ -14988,7 +14842,6 @@ - //----- (0044622E) -------------------------------------------------------- bool __fastcall EnterHouse(HOUSE_TYPE uHouseID) { @@ -15007,12 +14860,12 @@ //Player *v13; // esi@25 int v14; // eax@25 //Player *v15; // esi@27 - signed int v16; // eax@32 + //signed int v16; // eax@32 unsigned int v17; // eax@37 signed int v18; // edi@37 signed int v19; // edi@41 //unsigned int v20; // ecx@41 - const char *v22; // [sp-4h] [bp-40h]@33 + //const char *v22; // [sp-4h] [bp-40h]@33 char pContainer[40]; // [sp+Ch] [bp-30h]@32 unsigned int v24; // [sp+34h] [bp-8h]@5 //enum HOUSE_TYPE v25; // [sp+38h] [bp-4h]@1 @@ -15130,7 +14983,8 @@ ++pIcons_LOD->uTexturePacksCount; if ( !pIcons_LOD->uNumPrevLoadedFiles ) pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; - v16 = const_2(); + + /*v16 = const_2(); sprintf(pContainer, "evt%02d", v16); if ( pParty->uAlignment ) { @@ -15142,17 +14996,25 @@ { v22 = "-b"; } - strcat(pContainer, v22); -LABEL_37: + strcat(pContainer, v22);*/ +//LABEL_37: + switch (pParty->alignment) + { + case PartyAlignment_Good: sprintf(pContainer, "evt%02d-b", const_2()); break; + case PartyAlignment_Neutral: sprintf(pContainer, "evt%02d", const_2()); break; + case PartyAlignment_Evil: sprintf(pContainer, "evt%02d-c", const_2()); break; + default: assert(false); + } + v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - array_5913D8[6] = 0; + pDialogueNPCCount = 0; pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v17]; uTextureID_507B04 = uTextureID_right_panel; PrepareHouse(uHouseID); v18 = 1; uTextureID_507B04 = uTextureID_right_panel; if ( uNumDialogueNPCPortraits == 1 ) - array_5913D8[6] = (NPCData *)1; + pDialogueNPCCount = 1; pVideoPlayer->_4BF28F(pAnimatedRooms[uCurrentHouse_Animation].field_0, 1u); if ( (signed int)uHouseID < 139 || (signed int)uHouseID > 172 ) {
--- a/mm7_5.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/mm7_5.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -77,7 +77,7 @@ unsigned int v8; // edx@59 unsigned int v9; // ecx@60 unsigned int v10; // ecx@73 - unsigned int v11; // eax@75 + //unsigned int v11; // eax@75 unsigned __int8 v12; // sf@75 unsigned __int8 v13; // of@75 int v14; // eax@98 @@ -393,8 +393,8 @@ case UIMSG_51: sub_4BDB56_buy_skill____(); continue; - case UIMSG_AF: - sub_4B2001(uMessageParam); + case UIMSG_AF://Click topic + ClickNPCTopic(uMessageParam);//CheckNPCTopic continue; case UIMSG_195: sub_4BCACC_bounties(uMessageParam); @@ -489,23 +489,25 @@ v10 = pSaveListPosition + uMessageParam; if ( dword_6BE138 == pSaveListPosition + uMessageParam ) { - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + pMessageQueue_50CBD0->AddMessage(UIMSG_LoadSlot, 0, 0); + pMessageQueue_50CBD0->AddMessage(UIMSG_LoadGame, 0, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)164; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_LoadSlot; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - v11 = pMessageQueue_50CBD0->uNumMessages + 1; - v13 = pMessageQueue_50CBD0->uNumMessages + 1 > 40; - v12 = (signed int)pMessageQueue_50CBD0->uNumMessages - 39 < 0; + //v11 = pMessageQueue_50CBD0->uNumMessages + 1; + //v13 = pMessageQueue_50CBD0->uNumMessages + 1 > 40; + //v12 = (signed int)pMessageQueue_50CBD0->uNumMessages - 39 < 0; ++pMessageQueue_50CBD0->uNumMessages; if ( v12 ^ v13 ) { - pMessageQueue_50CBD0->pMessages[v11].eType = (UIMessageType)82; + pMessageQueue_50CBD0->pMessages[v11].eType = UIMSG_LoadGame; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; } - } + }*/ } uLoadGameUI_SelectedSlot = v10; dword_6BE138 = v10; @@ -1570,7 +1572,7 @@ } DrawHiredNPCs(); continue; - case UIMSG_19B: + case UIMSG_TransitionUI_Confirm: if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; dword_50CDC8 = v0; @@ -1673,7 +1675,7 @@ pStru277->_427D48(v0); sub_44603D(); pEventTimer->Pause(); - pGameLoadingUI_ProgressBar->_443484((GUIProgressBar::Type)2); + pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_Box); ++pGameLoadingUI_ProgressBar->uProgressMax; SaveGame(v0, 0); pGameLoadingUI_ProgressBar->Progress(); @@ -1918,13 +1920,14 @@ } sub_4BD8B5(); //goto LABEL_434; - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v0, 0); continue; case UIMSG_C3: pAudioPlayer->StopChannels(-1, -1); @@ -1987,12 +1990,13 @@ case UIMSG_B5: dword_50CDC8 = v0; //goto LABEL_453; - if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) continue; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; + ++pMessageQueue_50CBD0->uNumMessages;*/ continue; case UIMSG_B3: pPlayer9 = pPlayers[_506348_current_lloyd_playerid + 1]; @@ -2038,13 +2042,14 @@ pParty->sRotationY = LOWORD(pNPCData4->Location2D); pParty->sRotationX = HIWORD(pNPCData4->Location2D); } - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v0, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ //crt_deconstruct_ptr_6A0118(); pBooksWindow->Release(); pGUIWindow_CurrentMenu->Release(); @@ -2135,14 +2140,15 @@ else pParty->pPlayers[(unsigned __int8)byte_50C0C0].CanCastSpell(0x14u); //LABEL_434: - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0; //LABEL_771: *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v0, 0); continue; } v63 = 210; @@ -2688,13 +2694,14 @@ Rest(v95 % 6 + 60); _506F18_num_hours_to_sleep = 0; dword_506F14 = 0; - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); ShowStatusBarString(pGlobalTXT_LocalizationStrings[481], 2u);// "Encounter!" v165 = 0; v151 = 0; @@ -2753,7 +2760,7 @@ //_set_status_string_pTmpBuf_and_continue: sub_41C0B8_set_status_string(pTmpBuf); continue; - case UIMSG_4F: + case UIMSG_SPellbook_ShowHightlightedSpellInfo: if ( !uActiveCharacter || (uNumSeconds = (unsigned int)pPlayers[uActiveCharacter], !*(char *)(uNumSeconds + 11 * *(char *)(uNumSeconds + 6734) + uMessageParam + 402)) ) continue; @@ -2874,14 +2881,18 @@ v130 = 0; v127 = rand() % 2 + 204; goto _play_sound_and_continue; - case UIMSG_56: - if ( pTurnEngine->field_4 != 3 ) - { - if ( uActiveCharacter ) - { - uNumSeconds = (unsigned int)pPlayers[uActiveCharacter]; - if ( *(char *)(uNumSeconds + 11 * *(char *)(uNumSeconds + 6734) + uMessageParam + 402) ) - { + case UIMSG_SelectSpell: + { + if (pTurnEngine->field_4 == 3) + continue; + if (!uActiveCharacter) + continue; + + // uNumSeconds = (unsigned int)pPlayers[uActiveCharacter]; + auto player = pPlayers[uActiveCharacter]; + if (player->spellbook.pChapters[player->lastOpenedSpellbookPage].bIsSpellAvailable[uMessageParam]) + //if ( *(char *)(uNumSeconds + 11 * *(char *)(uNumSeconds + &lastOpenedSpellbookPage) + uMessageParam + 402) ) + { if ( dword_50654C - 1 == uMessageParam ) { pGUIWindow_CurrentMenu->Release(); @@ -2889,12 +2900,12 @@ viewparams->bRedrawGameUI = v0; pCurrentScreen = SCREEN_GAME; pIcons_LOD->_4114F2(); - v103 = dword_50654C + 11 * *(char *)(uNumSeconds + 6734); + v103 = dword_50654C + 11 * player->lastOpenedSpellbookPage; if ( dword_50C9E8 < 40 ) { - dword_50C9EC[3 * dword_50C9E8] = 142; - dword_50C9F0[3 * dword_50C9E8] = v103; - *(&dword_50C9E8 + 3 * dword_50C9E8 + 3) = uActiveCharacter - 1; + dword_50C9EC[3 * dword_50C9E8] = UIMSG_CastSpellFromBook; + dword_50C9EC[3 * dword_50C9E8 + 1] = v103; + dword_50C9EC[3 * dword_50C9E8 + 2] = uActiveCharacter - 1; ++dword_50C9E8; } } @@ -2903,21 +2914,15 @@ byte_506550 = 1; dword_50654C = uMessageParam + 1; } - } - } - } - continue; - case UIMSG_8E: - if ( pTurnEngine->field_4 == 3 ) - continue; - v175 = 0; - v159 = 0; - v147 = 0; - //goto LABEL_678; - v80 = v199; - v79 = uMessageParam; - _42777D_CastSpell_UseWand_ShootArrow(v79, v80, v147, v159, v175); - continue; + } + } + continue; + + case UIMSG_CastSpellFromBook: + if ( pTurnEngine->field_4 != 3 ) + _42777D_CastSpell_UseWand_ShootArrow(uMessageParam, v199, 0, 0, 0); + continue; + case UIMSG_92: if ( pTurnEngine->field_4 != 3 ) { @@ -3018,13 +3023,14 @@ GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, WINDOW_VoiceSwitcherButton, (int)pBtn_GameSettings, 0); uNumVisibleWindows = uNumVisibleWindows - 1; //Ritor1: Insert //LABEL_453: - if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) continue; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; //goto LABEL_770; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; + ++pMessageQueue_50CBD0->uNumMessages;*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); continue; case UIMSG_C0: dword_50651C = v0; @@ -3314,7 +3320,8 @@ if ( !pMessageQueue_50CBD0->uNumMessages ) //goto LABEL_768; { - if ( (signed int)v115 < 40 ) + pMessageQueue_50CBD0->AddMessage(UIMSG_E, 0, 0); + /*if ( (signed int)v115 < 40 ) //goto LABEL_769; { pMessageQueue_50CBD0->pMessages[v115].eType = (UIMessageType)14; @@ -3322,26 +3329,26 @@ *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; continue; - } + }*/ continue; } if ( pMessageQueue_50CBD0->pMessages[0].field_8 ) { - v115 = v0; pMessageQueue_50CBD0->uNumMessages = v0; -//LABEL_769: + pMessageQueue_50CBD0->AddMessage(UIMSG_E, 0, 0); + /*v115 = v0; + pMessageQueue_50CBD0->uNumMessages = v0; pMessageQueue_50CBD0->pMessages[v115].eType = (UIMessageType)14; -//LABEL_770: pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; //goto LABEL_771; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; + ++pMessageQueue_50CBD0->uNumMessages;*/ continue; } v115 = 0; pMessageQueue_50CBD0->uNumMessages = 0; -//LABEL_768: - if ( (signed int)v115 < 40 ) + pMessageQueue_50CBD0->AddMessage(UIMSG_E, 0, 0); + /*if ( (signed int)v115 < 40 ) //goto LABEL_769; { pMessageQueue_50CBD0->pMessages[v115].eType = (UIMessageType)14; @@ -3349,10 +3356,9 @@ *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; continue; - } + }*/ continue; case UIMSG_E: -//LABEL_772: if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; OnGameViewportClick(); @@ -3368,28 +3374,12 @@ pPoint3 = pMouse->GetCursorPos(&v204); v116 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint3->y]]; } - v163 = 0; pButton2 = (GUIButton *)(unsigned __int16)v116; - pWindowType1 = (WindowType)15; - //goto LABEL_779; - v8 = 0; - v9 = 0; - v137 = 0; - v133 = 0; - GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163); + GUIWindow::Create(0, 0, 0, 0, (WindowType)15, (int)pButton2, 0); continue; case UIMSG_54: - v163 = 0; pButton2 = (GUIButton *)uMessageParam; - pWindowType1 = (WindowType)22; -//LABEL_779: - v8 = 0; - v9 = 0; -//LABEL_732: - v137 = 0; - v133 = 0; -//LABEL_733: - GUIWindow::Create(v9, v8, v133, v137, pWindowType1, (int)pButton2, v163); + GUIWindow::Create(0, 0, 0, 0, (WindowType)22, (int)pButton2, 0); continue; case UIMSG_Game_Action: if ( pMessageQueue_50CBD0->uNumMessages ) @@ -3460,13 +3450,14 @@ dword_50C9E8 = 0; if ( dword_50C9DC ) { - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)dword_50C9DC; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = (int)ptr_50C9E0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ + pMessageQueue_50CBD0->AddMessage((UIMessageType)dword_50C9DC, (int)ptr_50C9E0, 0); dword_50C9DC = 0; } else @@ -3476,13 +3467,14 @@ dword_50C9D8 -= pEventTimer->uTimeElapsed; if ( dword_50C9D8 <= 0 ) { - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)dword_50C9D0; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = dword_50C9D4; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ + pMessageQueue_50CBD0->AddMessage((UIMessageType)dword_50C9D0, dword_50C9D4, 0); dword_50C9D0 = 0; dword_50C9D4 = 0; dword_50C9D8 = 0; @@ -3704,8 +3696,8 @@ v26 = uNum + pSaveListPosition; if ( dword_6BE138 == uNum + pSaveListPosition ) { - pMessageQueue_50CBD0->SendMessage(UIMSG_LoadSlot, 0, 0); - pMessageQueue_50CBD0->SendMessage(UIMSG_LoadGame, 0, 0); + pMessageQueue_50CBD0->AddMessage(UIMSG_LoadSlot, 0, 0); + pMessageQueue_50CBD0->AddMessage(UIMSG_LoadGame, 0, 0); } uLoadGameUI_SelectedSlot = v26; dword_6BE138 = v26; @@ -3782,12 +3774,13 @@ viewparams->bRedrawGameUI = 1; } GUIWindow::Create(602, 450, 0, 0, WINDOW_VoiceSwitcherButton, (int)pBtn_GameSettings, 0); - if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) continue; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; + ++pMessageQueue_50CBD0->uNumMessages;*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); continue; } if ( pUIMessageType == UIMSG_Escape ) @@ -3818,7 +3811,7 @@ SetCurrentMenuID(MENU_CREDITSCLOSE); continue; } - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)5; //LABEL_93: @@ -3826,7 +3819,8 @@ *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; continue; - } + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_ChangeGameState, 0, 0); continue; } v16 = GetCurrentMenuID() == 8; @@ -4754,7 +4748,7 @@ v37 = v3; if ( stru_50FE08.field_3EC[v0] & 1 ) { - v6 = dword_4F6E08[v3]; + v6 = ai_near_actors_targets_pid[v3]; v7 = v6 >> 3; v8 = (v6 & 7) - 3; uActorID = v7; @@ -4968,7 +4962,7 @@ int v59; // [sp+50h] [bp-1Ch]@1 unsigned int uActorID_Monster_; // [sp+54h] [bp-18h]@1 int v61; // [sp+58h] [bp-14h]@1 - int v62; // [sp+5Ch] [bp-10h]@1 + bool v62; // [sp+5Ch] [bp-10h]@1 int uDamageAmount; // [sp+60h] [bp-Ch]@1 int a2; // [sp+64h] [bp-8h]@27 int a3; // [sp+6Bh] [bp-1h]@6 @@ -5179,7 +5173,7 @@ v19 = v4->stru_24.uItemID == 0; uDamageAmount = v17; v57 = 0; - if ( !v19 && v4->stru_24.uAdditionalValue == 3 ) + if ( !v19 && v4->stru_24.uSpecEnchantmentType == 3 ) { a2 = 0; v57 = (PlayerEquipment *)1; @@ -6278,8 +6272,8 @@ char pContainer[128]; // [sp+24h] [bp-14h]@12 uTextureID_MAGNIF_B = pIcons_LOD->LoadTexture("MAGNIF-B", TEXTURE_16BIT_PALETTE); - if ( !pParty->uAlignment || pParty->uAlignment == 1 || pParty->uAlignment == 2 ) - uTextureID_BACKDOLL = pIcons_LOD->LoadTexture("BACKDOLL", TEXTURE_16BIT_PALETTE); + //if ( !pParty->uAlignment || pParty->uAlignment == 1 || pParty->uAlignment == 2 ) + uTextureID_BACKDOLL = pIcons_LOD->LoadTexture("BACKDOLL", TEXTURE_16BIT_PALETTE); uTextureID_507B04 = uTextureID_right_panel; v30 = 0; uTextureID_BACKHAND = pIcons_LOD->LoadTexture("BACKHAND", TEXTURE_16BIT_PALETTE); @@ -9324,7 +9318,7 @@ else v3 = uBaseLightLevel; } - return _43F5C8_get_point_light_level_with_respect_to_lights(v3, a1->uIndoorSectorID, a1->some_x, a1->some_y, a1->some_z); + return _43F5C8_get_point_light_level_with_respect_to_lights(v3, a1->uIndoorSectorID, a1->world_x, a1->world_y, a1->world_z); } //----- (0043F5C8) -------------------------------------------------------- @@ -9592,7 +9586,7 @@ v8 = v1->pQueue; do { - if ( (v8->uPackedID & 7) == OBJECT_Actor && ai_array_4F7DB0_actor_ids[v20] == v8->uPackedID >> 3 ) + if ( (v8->uPackedID & 7) == OBJECT_Actor && ai_near_actors_ids[v20] == v8->uPackedID >> 3 ) break; ++v18; ++v8; @@ -9602,7 +9596,7 @@ } if ( v18 == v1->uActorQueueSize ) { - v9 = ai_array_4F7DB0_actor_ids[v20]; + v9 = ai_near_actors_ids[v20]; *(int *)v7 = 1; *((int *)v7 + 2) = v2; *((int *)v7 - 1) = 8 * v9 | 3; @@ -9726,7 +9720,7 @@ if ( v6 != 8 ) goto LABEL_19; v3 = 0; - Actor::_403F58(v2->uPackedID >> 3, dword_4F6E08[v2->uPackedID >> 3], 32, 0); + Actor::AI_StandOrBored(v2->uPackedID >> 3, ai_near_actors_targets_pid[v2->uPackedID >> 3], 32, 0); } } } @@ -9758,9 +9752,9 @@ { if ( v11 != 17 ) { - v12 = dword_4F6E08[v10]; + v12 = ai_near_actors_targets_pid[v10]; v9->uActionLength = v3; - Actor::_403F58(v10, v12, 32, (AIDirection *)v3); + Actor::AI_StandOrBored(v10, v12, 32, (AIDirection *)v3); } } } @@ -10049,8 +10043,8 @@ if ( (v1->uPackedID & 7) != OBJECT_Player) { v4 = v3 >> 3; // turn based only stuff - a2a = dword_4F6E08[v3 >> 3]; - memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, dword_4F6E08[v3 >> 3], &a3, 0), sizeof(a3)); + a2a = ai_near_actors_targets_pid[v3 >> 3]; + memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, ai_near_actors_targets_pid[v3 >> 3], &a3, 0), sizeof(a3)); memcpy(&a4, &a3, sizeof(a4)); v5 = &pActors[v3 >> 3]; LOWORD(v3) = v5->uAIState; @@ -10104,12 +10098,12 @@ v16 = a2a; if ( !(v14 % 2) ) { - Actor::_402F87(v4, a2a, &a4); + Actor::AI_Bored(v4, a2a, &a4); return; } v21 = 64; LABEL_26: - Actor::_403EB6(v15, v16, v21, v23); + Actor::AI_Stand(v15, v16, v21, v23); return; } LABEL_21: @@ -10194,8 +10188,8 @@ { if ( (short)v3 != 4 && (short)v3 != 11 && (short)v3 != 19 && (short)v3 != 17 ) { - v6 = (unsigned int *)&dword_4F6E08[(int)v4]; - Actor::_401221((unsigned int)v4, &dword_4F6E08[(int)v4], 1u); + v6 = (unsigned int *)&ai_near_actors_targets_pid[(int)v4]; + Actor::_SelectTarget((unsigned int)v4, &ai_near_actors_targets_pid[(int)v4], true); if ( v5->pMonsterInfo.uHostilityType && !*v6 ) v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; v22 = *v6; @@ -10305,7 +10299,7 @@ goto LABEL_48; } LABEL_47: - Actor::_403EB6(v13, v22, 0x40u, &v18); + Actor::AI_Stand(v13, v22, 0x40u, &v18); v3 = v21; v21->field_C = 0; goto LABEL_48; @@ -10345,10 +10339,10 @@ v5 = v10->uPackedID; if ( (v10->uPackedID & 7) == OBJECT_Actor) { - v8 = dword_4F6E08[v5 >> 3]; + v8 = ai_near_actors_targets_pid[v5 >> 3]; memcpy(&v7, Actor::GetDirectionInfo(v5, v8, &a3, v2), sizeof(v7)); if ( !v1->_406D10(a2) ) - Actor::_403EB6(v10->uPackedID >> 3, v8, 0x20u, &v7); + Actor::AI_Stand(v10->uPackedID >> 3, v8, 0x20u, &v7); } ++a2; ++v10; @@ -10389,9 +10383,9 @@ if ( pActors[v3].CanAct() ) { v4 = v2->uPackedID; - v9 = dword_4F6E08[v3]; + v9 = ai_near_actors_targets_pid[v3]; memcpy(&v6, Actor::GetDirectionInfo(v4, v9, &a3, 0), sizeof(v6)); - Actor::_403EB6(v8, v9, 0x20u, &v6); + Actor::AI_Stand(v8, v9, 0x20u, &v6); v2->field_C = 0; v2->uActionLength = 0; v1 = v7; @@ -10452,7 +10446,7 @@ result = 1; if ( !(v13 | result | v6->uAIState == 5 | v6->uAIState == 11 | v6->uAIState == 19) ) { - v13 = dword_4F6E08[v5]; + v13 = ai_near_actors_targets_pid[v5]; memcpy(&v9, Actor::GetDirectionInfo(a1, v13, &a3, 0), sizeof(v9)); v7 = v6->uAIState; if ( v7 == 6 || v7 == 1 ) @@ -10472,7 +10466,7 @@ } if ( !thisa->_406D10(a2) ) LABEL_26: - Actor::_403EB6(v12, v13, 0x20u, &v9); + Actor::AI_Stand(v12, v13, 0x20u, &v9); } } } @@ -10529,12 +10523,12 @@ v5 = v4->uAIState; if ( v5 == 5 || v5 == 4 || v5 == 11 || v5 == 19 || v5 == 17 ) return 1; - v6 = &dword_4F6E08[v3]; + v6 = &ai_near_actors_targets_pid[v3]; v7 = &pTurnEngine->pQueue[a2]; v8 = *v6; v29 = &pTurnEngine->pQueue[a2]; a2a = v8; - Actor::_401221(v3, &dword_4F6E08[v3], 1u); + Actor::_SelectTarget(v3, &ai_near_actors_targets_pid[v3], true); if ( v4->pMonsterInfo.uHostilityType && !*v6 ) v4->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; v9 = Actor::GetDirectionInfo(v7->uPackedID, a2a, &a3, 0); @@ -10614,7 +10608,7 @@ v21 = 32; if ( v4->pMonsterInfo.uMovementType == 5 ) { - Actor::_403EB6(uActorID, a2a, 0x20u, 0); + Actor::AI_Stand(uActorID, a2a, 0x20u, 0); goto LABEL_25; } LABEL_24: @@ -10673,7 +10667,7 @@ } if ( v4->pMonsterInfo.uMovementType == 5 ) { - Actor::_403EB6(uActorID, a2a, 0x20u, 0); + Actor::AI_Stand(uActorID, a2a, 0x20u, 0); LABEL_53: v17 = v29; v29->field_C = 2; @@ -10729,10 +10723,10 @@ { if ( v6 != 17 ) { - v7 = (unsigned int *)&dword_4F6E08[v4]; + v7 = (unsigned int *)&ai_near_actors_targets_pid[v4]; a2 = *v7; v8 = a2; - Actor::_401221(v4, (int *)v7, 1u); + Actor::_SelectTarget(v4, (int *)v7, true); memcpy(&v11, Actor::GetDirectionInfo(*(int *)((char *)&v3->uPackedID + v18), v8, &a3, 0), sizeof(v11)); memcpy(&a4, &v11, sizeof(a4)); v5->uCurrentActionTime += pMiscTimer->uTimeElapsed; @@ -10747,9 +10741,9 @@ return; } if ( rand() % 2 ) - Actor::_403EB6(uActorID, a2, 0x40u, &a4); + Actor::AI_Stand(uActorID, a2, 0x40u, &a4); else - Actor::_402F87(uActorID, a2, &a4); + Actor::AI_Bored(uActorID, a2, &a4); } } } @@ -12103,6 +12097,8 @@ v7 = 1; if (_449B57_test_bit(pParty->_award_bits, 100)) v5 = 1; + + Log::Warning(L"%S %S %u", __FILE__, __FUNCTION__, __LINE__); // ai_near_actors_targets_pid[i] for AI_Stand seems always 0; original code behaviour is identical for (uint i = 0; i < uNumActors; ++i) { auto actor = pActors + i; @@ -12114,7 +12110,9 @@ actor->vPosition.z = actor->vInitialPosition.z; actor->sCurrentHP = actor->pMonsterInfo.uHP; if (actor->uAIState != Disabled) - Actor::_403EB6(i, dword_4F6E08[i], actor->pMonsterInfo.uRecoveryTime, 0); + { + Actor::AI_Stand(i, ai_near_actors_targets_pid[i], actor->pMonsterInfo.uRecoveryTime, 0); + } } actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; @@ -12139,7 +12137,7 @@ if (item->uItemType && (item->uSoundID & 8 || pObjectList->pObjects[item->uItemType].uFlags & 0x10)) - LayingItem::_42F933(i); + LayingItem::OnItemPickup(i); } for (uint i = 0; i < 100; ++i) @@ -13108,7 +13106,7 @@ LABEL_30: if ( byte_506360 ) { - result = pMessageQueue_50CBD0->uNumMessages; + /*result = pMessageQueue_50CBD0->uNumMessages; if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)181; @@ -13116,7 +13114,8 @@ result = 3 * pMessageQueue_50CBD0->uNumMessages + 3; *(&pMessageQueue_50CBD0->uNumMessages + result) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_B5, 0, 0); } return result; } @@ -13874,7 +13873,7 @@ } v2 = 1; v31 = 1; - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); LABEL_15: dword_506568 = 0; pRenderer->DrawTextureTransparent(pViewport->uViewportX + 398, pViewport->uViewportY + 113, pTexture_506394); @@ -13884,7 +13883,7 @@ if ( dword_506568 != v2 ) { v31 = v2; - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); } } else @@ -13908,7 +13907,7 @@ if ( dword_506568 != 2 ) { v31 = v2; - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); } } else @@ -13932,7 +13931,7 @@ if ( dword_506568 != 3 ) { v31 = v2; - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); } } else @@ -13956,7 +13955,7 @@ if ( dword_506568 != 4 ) { v31 = v2; - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); } } else @@ -13980,7 +13979,7 @@ if ( dword_506568 != 5 ) { v31 = v2; - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); } } else @@ -14216,7 +14215,7 @@ //v6 = dword_506534; } if ( dword_506548 | dword_506544 | dword_506540 | dword_50653C | dword_506538 | dword_506534 ) - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); dword_506548 = 0; dword_506544 = 0; dword_506534 = 0; @@ -14477,13 +14476,14 @@ GUIWindow *v0; // ecx@1 v0 = ptr_507BDC; - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + pMessageQueue_50CBD0->AddMessage((UIMessageType)(int)ptr_507BDC->ptr_1C, 0, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)(int)ptr_507BDC->ptr_1C; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ v0->Release(); ptr_507BDC = 0; pCurrentScreen = dword_506F0C[0]; @@ -14863,8 +14863,6 @@ } - - //----- (004151D9) -------------------------------------------------------- void __fastcall DrawPopupWindow(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight) { @@ -15085,7 +15083,7 @@ case WINDOW_5E: // window that initiates savegame loading { if (pWindow->Hint != (char *)1) - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); auto pGUIButton3 = (GUIButton *)pWindow->ptr_1C; pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pGUIButton3->pTextures[0]); pHint = pWindow->Hint; @@ -15094,9 +15092,9 @@ pGUIButton3->DrawLabel(pHint, pFontCreate, 0, 0); pWindow->Release(); if (pCurrentScreen == SCREEN_SAVEGAME) - pMessageQueue_50CBD0->SendMessage(UIMSG_SaveGame, 0, 0); + pMessageQueue_50CBD0->AddMessage(UIMSG_SaveGame, 0, 0); else - pMessageQueue_50CBD0->SendMessage(UIMSG_LoadGame, 0, 0); + pMessageQueue_50CBD0->AddMessage(UIMSG_LoadGame, 0, 0); } continue; } @@ -15108,7 +15106,7 @@ if ( pWindowType == WINDOW_60 )//96 { if ( pWindow->Hint != (char *)1 ) - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); pGUIButton = (GUIButton *)pWindow->ptr_1C; pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pGUIButton->pTextures[0]); pHint = pWindow->Hint; @@ -15116,7 +15114,7 @@ if ( pHint && pHint != (char *)1 ) pGUIButton->DrawLabel(pHint, pFontCreate, 0, 0); pWindow->Release(); - if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) continue; pNumMessages = pMessageQueue_50CBD0->uNumMessages; //LABEL_151: @@ -15124,7 +15122,8 @@ //LABEL_152: pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; + ++pMessageQueue_50CBD0->uNumMessages;*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); continue; } v34 = v33 - 1; @@ -15189,7 +15188,7 @@ GUIButton2.uWidth = 171; GUIButton2.uHeight = 37; GUIButton2.pParent = pButton_RestUI_WaitUntilDawn->pParent; - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)pWindow->ptr_1C + 15)); viewparams->bRedrawGameUI = 1; GUIButton2.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, 0, 0);// 8 @@ -15201,7 +15200,7 @@ continue; } if ( pWindow->Hint != (char *)1 )//pWindowType == WINDOW_61 - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); v32 = pWindow->ptr_1C; pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)v32 + 16)); //goto LABEL_138; @@ -15211,21 +15210,22 @@ ((GUIButton *)v32)->DrawLabel(pHint, pFontCreate, 0, 0); pWindow->Release(); pNumMessages = pMessageQueue_50CBD0->uNumMessages; - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; continue; - } + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); continue; } if ( pWindowType == WINDOW_5F ) { if ( pWindow->Hint != (char *)1 ) - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); v32 = pWindow->ptr_1C; pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)v32 + 15)); //LABEL_138: @@ -15236,7 +15236,7 @@ pWindow->Release(); //LABEL_142: pNumMessages = pMessageQueue_50CBD0->uNumMessages; - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) //goto LABEL_151; { pMessageQueue_50CBD0->pMessages[pNumMessages].eType = (UIMessageType)113; //0x71 @@ -15244,7 +15244,8 @@ *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; continue; - } + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); continue; } v14 = pWindowType - 80; @@ -15278,7 +15279,7 @@ else { if ( v26 >= 221 && v26 < 271 ) - pItemGen._bonus_type = rand() % 10 + 1; + pItemGen.uEncantmentType = rand() % 10 + 1; } pItemsTable->SetSpecialBonus(&pItemGen); pParty->SetHoldingItem(&pItemGen); @@ -15291,7 +15292,7 @@ if ( pWindowType == WINDOW_5A ) // Press buttons in title menu and in game, and escape in game { if ( pWindow->Hint != (char *)1 ) - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); pButtonPtr_1C = (GUIButton *)pWindow->ptr_1C; if ( pButtonPtr_1C->uX >= 0 )//if ( (pButtonPtr_1C->uX & 0x80000000u) == 0 ) { @@ -15342,7 +15343,7 @@ if ( pWindowType == WINDOW_5B )//Change button in Character window { if ( pWindow->Hint != (char *)1 ) - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); pButtonPtr_1C = (GUIButton *)pWindow->ptr_1C; pTexture2 = pButtonPtr_1C->pTextures[1]; //LABEL_94: @@ -15367,7 +15368,7 @@ if ( pWindowType == WINDOW_VoiceSwitcherButton ) // Change page in AutonotesBook { if ( pWindow->Hint != (char *)1 ) - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); pButtonPtr_1C = (GUIButton *)pWindow->ptr_1C; pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, pButtonPtr_1C->pTextures[0]); //goto LABEL_80; @@ -15387,7 +15388,7 @@ if ( pWindowType == WINDOW_5D ) { if ( pWindow->Hint != (char *)1 ) - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)pWindow->ptr_1C + 16)); viewparams->bRedrawGameUI = 1; //goto LABEL_134; @@ -15413,13 +15414,14 @@ { v29 = pMessageQueue_50CBD0->uNumMessages; pWindow->field_40 = 0; - if ( (signed int)v29 < 40 ) + /*if ( (signed int)v29 < 40 ) { pMessageQueue_50CBD0->pMessages[v29].eType = (UIMessageType)(int)ptr_507BD0->ptr_1C; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ + pMessageQueue_50CBD0->AddMessage((UIMessageType)(int)ptr_507BD0->ptr_1C, 0, 0); pEventTimer->Resume(); ptr_507BD0->Release(); pCurrentScreen = SCREEN_GAME; @@ -15520,7 +15522,7 @@ } continue; } - pWindowList[pVisibleWindowsIdxs[i] - 1]._4B3157(); + pWindowList[pVisibleWindowsIdxs[i] - 1].HouseDialogManager(); if ( !window_SpeakInHouse ) continue; v10 = window_SpeakInHouse->ptr_1C; @@ -15541,14 +15543,15 @@ } //goto LABEL_142; pNumMessages = pMessageQueue_50CBD0->uNumMessages; - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; continue; - } + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); continue; } if ( pWindowType == WINDOW_SpellBook ) @@ -15747,7 +15750,7 @@ v27 = &v0->pInventoryItems[pOut.z]; v28 = v27->uItemID; v51 = pItemsTable->pItems[v27->uItemID].uEquipType; - v29 = (ItemGen *)(1800 * pParty->pPickedItem._bonus_type); + v29 = (ItemGen *)(1800 * pParty->pPickedItem.uEncantmentType); if ( pParty->pPickedItem.uItemID != 233 ) { if ( pParty->pPickedItem.uItemID == 236 ) @@ -15768,15 +15771,15 @@ v33 = v27->uItemID; if ( (signed int)v27->uItemID >= 64 && (signed int)v33 <= 65 || (pOut.y = v27->uAttributes, pOut.y & 2) - || v27->uAdditionalValue - || v27->_bonus_type + || v27->uSpecEnchantmentType + || v27->uEncantmentType || v51 && v51 != 1 && v51 != 2 || (signed int)v33 >= 500 ) goto LABEL_92; v34 = *(int *)&aSbwb00[4 * pParty->pPickedItem.uItemID + 4]; a2.y = (int)v29 << 7; v31 = (double)(signed int)((int)v29 << 7); - v27->uAdditionalValue = v34; + v27->uSpecEnchantmentType = v34; } else { @@ -15784,13 +15787,13 @@ || (v27->UpdateTempBonus(pParty->uTimePlayed), v30 = v27->uItemID, (signed int)v27->uItemID >= 64) && (signed int)v30 <= 65 || (pOut.y = v27->uAttributes, pOut.y & 2) - || v27->uAdditionalValue - || v27->_bonus_type + || v27->uSpecEnchantmentType + || v27->uEncantmentType || v51 && v51 != 1 && v51 != 2 || (signed int)v30 >= 500 ) goto LABEL_92; a2.y = (int)v29 << 7; - v27->uAdditionalValue = 40; + v27->uSpecEnchantmentType = 40; v31 = (double)a2.y; } v32 = pParty->uTimePlayed + (signed int)(signed __int64)(v31 * 0.033333335); @@ -15803,7 +15806,7 @@ dword_50C9A8 = 256; goto LABEL_92; } - v36 = (70.0 - (double)pParty->pPickedItem._bonus_type) * 0.01; + v36 = (70.0 - (double)pParty->pPickedItem.uEncantmentType) * 0.01; if ( v36 < 0.0 ) v36 = 0.0; if ( v51 != 12 ) @@ -15909,13 +15912,15 @@ v26 = rand(); v0->ReceiveDamage(v26 % 11 + 10, 0); pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ v42 = (int *)&a2.y; v41 = (int *)&y.y; v40 = (int *)&pOut; @@ -15950,8 +15955,8 @@ *(int *)&v0->field_1F5[36 * v19 + 15] = 1; v20 = v47 + 50 * v15; v0->pInventoryItems[pOut.z].uItemID = v51; - v0->pInventoryItems[pOut.z]._bonus_type = (pParty->pPickedItem._bonus_type - + v0->pInventoryItems[pOut.z]._bonus_type) + v0->pInventoryItems[pOut.z].uEncantmentType = (pParty->pPickedItem.uEncantmentType + + v0->pInventoryItems[pOut.z].uEncantmentType) / 2; v0->SetVariable(VAR_AutoNotes, *(short *)&pItemsTable->potion_note[2 * v20 ]);//field_10168 + 388 LABEL_74: @@ -15968,7 +15973,7 @@ if ( *(int *)(a2.y + 532) == 221 ) *(int *)(a2.y + 532) = pParty->pPickedItem.uItemID; else - *(int *)(a2.y + 536) = pParty->pPickedItem._bonus_type; + *(int *)(a2.y + 536) = pParty->pPickedItem.uEncantmentType; v21 = v0->AddItem(0xFFFFFFFFu, 0xDCu); if ( v21 ) *(int *)&v0->field_1F5[36 * v21 + 15] = 1; @@ -15983,13 +15988,15 @@ } v0->_4160CA(v23); pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)113; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ v42 = (int *)&a2.y; v41 = (int *)&y.y; v40 = (int *)&pOut; @@ -16639,7 +16646,7 @@ pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; } //v11 = i->uControlParam; - pMessageQueue_50CBD0->SendMessage((UIMessageType)i->uControlID, i->uControlParam, 0); + pMessageQueue_50CBD0->AddMessage((UIMessageType)i->uControlID, i->uControlParam, 0); return; } goto LABEL_45; @@ -16658,13 +16665,15 @@ && pPlayers[uActiveCharacter]->CanAct() && pPlayers[uActiveCharacter]->CanSteal() ) { - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)27; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v6 >> 3; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; - } + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_1B, v6 >> 3, 0); + if ( pParty->bTurnBasedModeOn == 1 ) { if ( pTurnEngine->field_4 == 3 )
--- a/mm7_6.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/mm7_6.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -42,6 +42,7 @@ #include "texts.h" #include "StorylineTextTable.h" #include "Events2D.h" +#include "Log.h" #include "mm7_data.h" @@ -1401,7 +1402,7 @@ { if ( pItemsTable->pItems[pActor->array_000234[3].uItemID].uEquipType != 18 ) goto LABEL_9; - v14 = pActor->array_000234[3].uAdditionalValue; + v14 = pActor->array_000234[3].uSpecEnchantmentType; pActor->array_000234[3].Reset(); } if ( v14 ) @@ -1431,7 +1432,7 @@ v4 = Dst.uItemID; } if ( pItemsTable->pItems[v5].uEquipType == 14 && v4 != 220 ) - Dst._bonus_type = 2 * rand() % 4 + 2; + Dst.uEncantmentType = 2 * rand() % 4 + 2; pItemsTable->SetSpecialBonus(&Dst); if ( !pParty->AddItem(&Dst) ) pParty->SetHoldingItem(&Dst); @@ -2172,9 +2173,9 @@ //----- (0042777D) -------------------------------------------------------- void _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6) { - bool result; // eax@2 + //bool result; // eax@2 __int16 v6; // bx@4 - Player *v7; // eax@4 + //Player *v7; // eax@4 char v8; // zf@12 unsigned __int16 v9; // cx@16 unsigned int v10; // eax@18 @@ -2202,11 +2203,20 @@ a3a = uPlayerID; a2a = a1; - if ( pParty->bTurnBasedModeOn != 1 - || (result = pTurnEngine->field_4, pTurnEngine->field_4 != 1) && pTurnEngine->field_4 != 3 ) + + //if ( pParty->bTurnBasedModeOn != 1 + // || (result = pTurnEngine->field_4, pTurnEngine->field_4 != 1) && pTurnEngine->field_4 != 3 ) + if (pParty->bTurnBasedModeOn) { + if (pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 3) + return; + } + + v6 = a5; - v7 = &pParty->pPlayers[uPlayerID]; + //v7 = &pParty->pPlayers[uPlayerID]; + assert(uPlayerID < 4); + auto player = &pParty->pPlayers[uPlayerID]; if ( !(a5 & 0x10) ) { switch ( a1 ) @@ -2267,19 +2277,19 @@ if ( a4 ) v8 = (a4 & 0x1C0) == 0; else - v8 = (v7->pActiveSkills[16] & 0x1C0) == 0; + v8 = (player->pActiveSkills[PLAYER_SKILL_SPIRIT] & 0x1C0) == 0; if ( v8 ) goto LABEL_25; break; case 50: v9 = a4; if ( !a4 ) - v9 = v7->pActiveSkills[16]; + v9 = player->pActiveSkills[PLAYER_SKILL_SPIRIT]; goto LABEL_18; case 95: v9 = a4; if ( !a4 ) - v9 = v7->pActiveSkills[20]; + v9 = player->pActiveSkills[PLAYER_SKILL_DARK]; LABEL_18: v10 = SkillToMastery(v9); v12 = __OFSUB__(v10, 3); @@ -2288,7 +2298,7 @@ case 73: v13 = a4; if ( !a4 ) - v13 = v7->pActiveSkills[18]; + v13 = player->pActiveSkills[PLAYER_SKILL_BODY]; v14 = SkillToMastery(v13); v12 = __OFSUB__(v14, 4); v11 = ((v14 - 4) & 0x80000000u) != 0; @@ -2317,6 +2327,7 @@ break; } } + v15 = pStru277; if ( v6 & 0x3CA ) { @@ -2348,8 +2359,8 @@ } ++v15; } - while ( (signed int)v15 < (signed int)&unk_50C190 ); - result = pStru277->PushStru277(a2a, a3a, a4, v6, a6); + while (v15 < pStru277 + 10); + int result = pStru277->PushStru277(a2a, a3a, a4, v6, a6); if ( result != -1 ) { if ( v6 & 2 ) @@ -2422,19 +2433,8 @@ pGUIWindow_Settings->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 1u, 0x32u, "", 0); pGUIWindow_Settings->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 2u, 0x33u, "", 0); pGUIWindow_Settings->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 3u, 0x34u, "", 0); - v29 = 0; - v28 = ""; - v27 = 0; - v26 = 0; - v25 = 140; - v24 = 0; - v23 = 1; - v22 = 344; - v21 = 460; - v20 = 8; - v19 = 8; - v18 = pGUIWindow_Settings; - goto LABEL_56; + pGUIWindow_Settings->CreateButton(8, 8, 460, 344, 1, 0, 140, 0, 0, "", NULL); + sub_421B2C_PlaceInInventory_or_DropPickedItem(); } if ( HIBYTE(v6) & 2 && !pGUIWindow_Settings ) { @@ -2469,7 +2469,6 @@ pGUIWindow_Settings->CreateButton(0x231u, 0x95u, 0x40u, 0x4Au, 1, 0, 0x8Fu, 5u, 0x36u, "", 0); } } - } } @@ -3852,7 +3851,7 @@ v721 = (int)&pActors[a2 >> 3], !stru_50C198.GetMagicalResistance(&pActors[a2 >> 3], 9u)) ) goto LABEL_1056; - Actor::_403EB6(v730, 4u, 0x80u, (AIDirection *)v1); + Actor::AI_Stand(v730, 4u, 0x80u, (AIDirection *)v1); v726 = (Player *)(23040 * v2); v54 = (signed __int64)((double)(23040 * v2) * 0.033333335); v55 = v721; @@ -4004,14 +4003,14 @@ { if (!v730c->Broken()) { - if ( v730c->uAdditionalValue == v1 ) + if ( v730c->uSpecEnchantmentType == v1 ) { - if ( v730c->_bonus_type == v1 ) + if ( v730c->uEncantmentType == v1 ) { v68 = BYTE4(v726->pConditions[3]); if ( !v68 || v68 == 1 || v68 == 2 ) { - if ( !pItemsTable->_456D5E_is_some_material(v730c) ) + if ( !pItemsTable->IsMaterialNonCommon(v730c) ) { v69 = v730c; v14 = v731 == 4; @@ -5413,8 +5412,8 @@ { if ( v731 != 4 || (v245 = (int)&v726->pInventoryItems[a2], v246 = *(int *)v245, *(int *)v245 > 134) - || v726->pInventoryItems[a2].uAdditionalValue != v1 - || v726->pInventoryItems[a2]._bonus_type != v1 + || v726->pInventoryItems[a2].uSpecEnchantmentType != v1 + || v726->pInventoryItems[a2].uEncantmentType != v1 || v726->pInventoryItems[a2]._bonus_strength != v1 || (_this = (ItemGen *)((char *)&v726->pInventoryItems[a2] + 20), v726->pInventoryItems[a2].Broken()) ) goto LABEL_616; @@ -5518,8 +5517,8 @@ v290 = v289->uItemID; LODWORD(v725) = (int)(char *)&pItemsTable + 48 * v290 + 4; if ( v290 > 134 - || _this->uAdditionalValue != v1 - || _this->_bonus_type != v1 + || _this->uSpecEnchantmentType != v1 + || _this->uEncantmentType != v1 || _this->_bonus_strength != v1 || (v291 = pItemsTable->pItems[v290].uEquipType) == 0 || v291 == 1 @@ -5571,7 +5570,7 @@ } v302 = rand() % SLODWORD(v725); v303 = v679; - v294->uAdditionalValue = v679; + v294->uSpecEnchantmentType = v679; v304 = pItemsTable->pSpecialEnchantments[v303].to_item_apply[pItemsTable->pItems[v294->uItemID].uEquipType + 4]; v305 = v302 + 1; if ( v304 < v305 ) @@ -5581,26 +5580,26 @@ v307 = (int)(jj + 1); v732 = v307; v308 = *(int *)v307; - v294->uAdditionalValue = v308; + v294->uSpecEnchantmentType = v308; v304 += pItemsTable->pSpecialEnchantments[v308].to_item_apply[pItemsTable->pItems[v294->uItemID].uEquipType + 4]; if ( v304 >= v305 ) break; } } - ++v294->uAdditionalValue; + ++v294->uSpecEnchantmentType; } else { v293 = rand(); v294 = _this; v295 = v293 % 10;// pItemsTable->field_116D8[pItemsTable->pItems[_this->uItemID].uEquipType]; - _this->_bonus_type = 0; + _this->uEncantmentType = 0; for ( kk = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[v294->uItemID].uEquipType + 1]; ; - kk += pItemsTable->pEnchantments[v294->_bonus_type].to_item[pItemsTable->pItems[v294->uItemID].uEquipType + kk += pItemsTable->pEnchantments[v294->uEncantmentType].to_item[pItemsTable->pItems[v294->uItemID].uEquipType + 1] ) { - ++v294->_bonus_type; + ++v294->uEncantmentType; if ( kk >= v295 ) break; } @@ -5616,7 +5615,7 @@ if ( pParty->uFlags & 0x30 && v12 != 4 || rand() % 100 >= amount && v731 != 4 ) goto LABEL_200; byte_50C0C0 = LOBYTE(v3->uPlayerID); - pMessageQueue_50CBD0->SendMessage((UIMessageType)195, v1, v1); + pMessageQueue_50CBD0->AddMessage(UIMSG_C3, v1, v1); goto LABEL_1056; case 33: LODWORD(v733) = 604800 * v2; @@ -5626,7 +5625,7 @@ if ( pPlayer->sMana >= (signed int)uRequiredMana ) { pEventTimer->Pause(); - pMessageQueue_50CBD0->SendMessage((UIMessageType)177, v1, v1); + pMessageQueue_50CBD0->AddMessage(UIMSG_B1, v1, v1); qword_506350 = (signed int)v733; _506348_current_lloyd_playerid = v3->uPlayerID; ::uRequiredMana = v319; @@ -6472,7 +6471,7 @@ if ( !pParty->AddItem(&pLayingItems[v445].stru_24) ) pParty->SetHoldingItem(&pLayingItems[v445].stru_24); } - LayingItem::_42F933(v445); + LayingItem::OnItemPickup(v445); } else { @@ -7327,7 +7326,7 @@ || *(int *)(HIDWORD(v733) + 12) != v1 || *(int *)(HIDWORD(v733) + 4) != v1 || (v591 = *(char *)(v732 + 28)) != 0 && v591 != 1 && v591 != 2 - || pItemsTable->_456D5E_is_some_material((ItemGen *)HIDWORD(v733)) ) + || pItemsTable->IsMaterialNonCommon((ItemGen *)HIDWORD(v733)) ) goto LABEL_199; v592 = HIDWORD(v733); v14 = v731 == 4; @@ -7798,11 +7797,115 @@ return 8 * this->pIcons[uIconID].uAnimLength; } + +const wchar_t *UIMessage2String(UIMessageType msg) +{ + #define CASE(xxx) case xxx: _swprintf(b, L"%03X/%s", msg, L#xxx); return b; + static wchar_t b[256]; // bad for threads + switch (msg) + { + CASE(UIMSG_SelectSpell) + CASE(UIMSG_ChangeGameState) + CASE(UIMSG_Attack) + CASE(UIMSG_PlayArcomage) + CASE(UIMSG_MainMenu_ShowPartyCreationWnd) + CASE(UIMSG_MainMenu_ShowLoadWindow) + CASE(UIMSG_ShowCredits) + CASE(UIMSG_ExitToWindows) + CASE(UIMSG_PlayerCreationChangeName) + CASE(UIMSG_PlayerCreationClickPlus) + CASE(UIMSG_PlayerCreationClickMinus) + CASE(UIMSG_PlayerCreationSelectActiveSkill) + CASE(UIMSG_PlayerCreationSelectClass) + CASE(UIMSG_PlayerCreationClickOK) + CASE(UIMSG_PlayerCreationClickReset) + CASE(UIMSG_AutonotesBook) + CASE(UIMSG_PlayerCreationRemoveUpSkill) + CASE(UIMSG_PlayerCreationRemoveDownSkill) + CASE(UIMSG_SPellbook_ShowHightlightedSpellInfo) + CASE(UIMSG_LoadGame) + CASE(UIMSG_SaveGame) + CASE(UIMSG_ShowStatus_DateTime) + CASE(UIMSG_ShowStatus_ManaHP) + CASE(UIMSG_ShowStatus_Player) + CASE(UIMSG_Wait5Minutes) + CASE(UIMSG_Wait1Hour) + CASE(UIMSG_ShowStatus_Food) + CASE(UIMSG_ShowStatus_Funds) + CASE(UIMSG_QuickReference) + CASE(UIMSG_GameMenuButton) + CASE(UIMSG_AlreadyResting) + CASE(UIMSG_SelectCharacter) + CASE(UIMSG_ChangeSoundVolume) + CASE(UIMSG_ChangeMusicVolume) + CASE(UIMSG_Escape) + CASE(UIMSG_PlayerCreation_SelectAttribute) + CASE(UIMSG_InventoryLeftClick) + CASE(UIMSG_SkillUp) + CASE(UIMSG_GameMenu_ReturnToGame) + CASE(UIMSG_StartNewGame) + CASE(UIMSG_Game_OpenLoadGameDialog) + CASE(UIMSG_Game_OpenSaveGameDialog) + CASE(UIMSG_Game_OpenOptionsDialog) + CASE(UIMSG_SetGraphicsMode) + CASE(UIMSG_Quit) + CASE(UIMSG_StartHireling1Dialogue) + CASE(UIMSG_StartHireling2Dialogue) + CASE(UIMSG_SelectDialogueOption) + CASE(UIMSG_CastSpellFromBook) + CASE(UIMSG_PlayerCreation_VoicePrev) + CASE(UIMSG_PlayerCreation_VoiceNext) + CASE(UIMSG_StartNPCDialogue) + CASE(UIMSG_ArrowUp) + CASE(UIMSG_DownArrow) + CASE(UIMSG_LoadSlot) + CASE(UIMSG_SelectLoadSlot) + CASE(UIMSG_Cancel) + CASE(UIMSG_ExitRest) + CASE(UIMSG_PlayerCreation_FacePrev) + CASE(UIMSG_PlayerCreation_FaceNext) + CASE(UIMSG_CycleCharacters) + CASE(UIMSG_SetTurnSpeed) + CASE(UIMSG_ToggleWalkSound) + CASE(UIMSG_ChangeVoiceVolume) + CASE(UIMSG_ToggleShowDamage) + CASE(UIMSG_ScrollNPCPanel) + CASE(UIMSG_ShowFinalWindow) + CASE(UIMSG_OpenQuestBook) + CASE(UIMSG_OpenAutonotes) + CASE(UIMSG_OpenMapBook) + CASE(UIMSG_OpenCalendar) + CASE(UIMSG_OpenHistoryBook) + CASE(UIMSG_ToggleAlwaysRun) + CASE(UIMSG_ToggleFlipOnExit) + CASE(UIMSG_Game_Action) + CASE(UIMSG_OpenRestUI) + CASE(UIMSG_TransitionUI_Confirm) + CASE(UIMSG_OpenKeyMappingOptions) + CASE(UIMSG_SelectKeyPage1) + CASE(UIMSG_SelectKeyPage2) + CASE(UIMSG_ResetKeyMapping) + CASE(UIMSG_ChangeKeyButton) + CASE(UIMSG_OpenVideoOptions) + CASE(UIMSG_ToggleBloodsplats) + CASE(UIMSG_ToggleColoredLights) + CASE(UIMSG_ToggleTint) + default: + _swprintf(b, L"UIMSG_%03X", msg); return b; + }; + #undef CASE +} + + //----- (0042EB8D) -------------------------------------------------------- -void GUIMessageQueue::SendMessage(UIMessageType msg, int param, unsigned int a4) +void GUIMessageQueue::AddMessageImpl(UIMessageType msg, int param, unsigned int a4, const char *file, int line) { + Log::Warning(L"%s @ (%S %u)", UIMessage2String(msg), file, line); if (uNumMessages < 40) { + files[uNumMessages] = file; + lines[uNumMessages] = line; + pMessages[uNumMessages].eType = msg; pMessages[uNumMessages].param = param; pMessages[uNumMessages++].field_8 = a4; @@ -8777,7 +8880,7 @@ //----- (0042FBDD) -------------------------------------------------------- void __cdecl sub_42FBDD() { - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); pRenderer->DrawTextureTransparent(pBtn_YES->uX, pBtn_YES->uY, pBtn_YES->pTextures[0]); pRenderer->Present(); } @@ -8785,7 +8888,7 @@ //----- (0042FC15) -------------------------------------------------------- void __cdecl CloseWindowBackground() { - pAudioPlayer->PlaySound((SoundID)75, -2, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_Button2, -2, 0, -1, 0, 0, 0, 0); pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pBtn_ExitCancel->pTextures[0]); pRenderer->Present(); } @@ -9087,8 +9190,9 @@ { pActionQueue = pPartyActionQueue; LABEL_120: - - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); + break; + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Attack; //goto _send_message; @@ -9096,7 +9200,7 @@ *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; break; - } + }*/ } else { @@ -9104,8 +9208,8 @@ if ( dword_50C9E8 < 40 ) { dword_50C9EC[3 * dword_50C9E8] = 25; - dword_50C9F0[3 * dword_50C9E8] = 0; - *(&dword_50C9E8 + 3 * dword_50C9E8 + 3) = 0; + dword_50C9EC[3 * dword_50C9E8 + 1] = 0; + dword_50C9EC[3 * dword_50C9E8 + 2] = 0; ++dword_50C9E8; } } @@ -9122,13 +9226,15 @@ case INPUT_EventTrigger: if (pCurrentScreen == SCREEN_GAME) { - if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) break; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Game_Action; //goto _send_message; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; + break;*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Game_Action, 0, 0); break; } if ( pCurrentScreen == SCREEN_NPC_DIALOGUE ) @@ -9136,6 +9242,8 @@ v11 = pMessageQueue_50CBD0->uNumMessages; if ( pMessageQueue_50CBD0->uNumMessages ) { + v11 = 0; + pMessageQueue_50CBD0->uNumMessages = 0; if ( pMessageQueue_50CBD0->pMessages[0].field_8 ) { v11 = 1; @@ -9148,10 +9256,9 @@ ++pMessageQueue_50CBD0->uNumMessages; break; } - v11 = 0; - pMessageQueue_50CBD0->uNumMessages = 0; + break; } - if ( (signed int)v11 < 40 ) + /*if ( (signed int)v11 < 40 ) //goto LABEL_132; { pMessageQueue_50CBD0->pMessages[v11].eType = UIMSG_Escape; @@ -9159,7 +9266,8 @@ *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; break; - } + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); } break; case INPUT_CharCycle: @@ -9169,8 +9277,8 @@ break; dword_50C9EC[3 * dword_50C9E8] = 176; //goto LABEL_155; - dword_50C9F0[3 * dword_50C9E8] = 0; - *(&dword_50C9E8 + 3 * dword_50C9E8 + 3) = 0; + dword_50C9EC[3 * dword_50C9E8 + 1] = 0; + dword_50C9EC[3 * dword_50C9E8 + 2] = 0; ++dword_50C9E8; break; case INPUT_LookUp: @@ -9238,8 +9346,8 @@ break; dword_50C9EC[3 * dword_50C9E8] = 367; //goto LABEL_155; - dword_50C9F0[3 * dword_50C9E8] = 0; - *(&dword_50C9E8 + 3 * dword_50C9E8 + 3) = 0; + dword_50C9EC[3 * dword_50C9E8 + 1] = 0; + dword_50C9EC[3 * dword_50C9E8 + 2] = 0; ++dword_50C9E8; break; case INPUT_ZoomOut: @@ -9248,8 +9356,8 @@ { dword_50C9EC[3 * dword_50C9E8] = 368; //LABEL_155: - dword_50C9F0[3 * dword_50C9E8] = 0; - *(&dword_50C9E8 + 3 * dword_50C9E8 + 3) = 0; + dword_50C9EC[3 * dword_50C9E8 + 1] = 0; + dword_50C9EC[3 * dword_50C9E8 + 2] = 0; ++dword_50C9E8; } break; @@ -9279,13 +9387,14 @@ { if ( !pCurrentScreen ) { - if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) goto LABEL_175; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)404; //goto LABEL_174; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; + ++pMessageQueue_50CBD0->uNumMessages;*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Game_Action, 0, 0); goto LABEL_175; } if ( pCurrentScreen == SCREEN_NPC_DIALOGUE @@ -9298,9 +9407,9 @@ if ( pMessageQueue_50CBD0->pMessages[0].field_8 ) { v15 = 1; - pMessageQueue_50CBD0->uNumMessages = 1; + pMessageQueue_50CBD0->uNumMessages = 0; //goto LABEL_173; - pMessageQueue_50CBD0->pMessages[v15].eType = (UIMessageType)113; + pMessageQueue_50CBD0->pMessages[v15].eType = UIMSG_Escape; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; @@ -9308,14 +9417,15 @@ } pMessageQueue_50CBD0->uNumMessages = 0; } - if ( (signed int)v15 >= 40 ) + /*if ( (signed int)v15 >= 40 ) goto LABEL_175; //LABEL_173: pMessageQueue_50CBD0->pMessages[v15].eType = (UIMessageType)113; //LABEL_174: pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; + ++pMessageQueue_50CBD0->uNumMessages;*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); goto LABEL_175; } }
--- a/mm7_data.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/mm7_data.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -67,7 +67,7 @@ Award pAwards[104]; #include "stru159.h" -stru159 pAnimatedRooms[196] = +stru159 pAnimatedRooms[196] = //0x4E5F70 { "", 0x4, 0x1F4, 0, "Human Armor01", 0x20, 0x2C0, 0x3A02, @@ -144,10 +144,13 @@ "Lord And Judge Out01", 1, 0, 0x271D, "Human Poor House 1", 8, 0, 0x1D, "Human Poor House 2", 8, 0, 0x1D, + "Human Poor House 3", 8, 0, 0x1D, "Human Medium House 1", 8, 0, 0x1D, "Human Medium House 2", 8, 0, 0x1D, + "Human Medium House 3", 8, 0, 0x1D, "Human Rich House 1", 8, 0, 0x1D, "Human Rich House 2", 8, 0, 0x1D, + "Human Rich House 3", 8, 0, 0x1D, "Elven Poor House 1", 8, 0, 0x1D, "Elven Poor House 2", 8, 0, 0x1D, "Elven Poor House 3", 8, 0, 0x1D, @@ -219,11 +222,13 @@ "Out10 The Maze", 0x24, 0, 0x19, "Out10 Connecting Tunnel Cave #1", 0x24, 0, 0x19, "", 0x24, 0, 0x19, + "", 0x24, 0, 0x19, "Out11 Stone City", 0x24, 0, 0x19, "", 0x24, 0, 0x19, "Out12 Colony Zod", 0x24, 0, 0x19, "Out12 Connecting Tunnel Cave #1", 0x24, 0, 0x19, "", 0x24, 0, 0x19, + "", 0x24, 0, 0x19, "Out13 Mercenary Guild", 0x24, 0, 0x19, "Out13 Tidewater Caverns", 0x24, 0, 0x19, "Out13 Wine Cellar", 0x24, 0, 0x19, @@ -247,9 +252,13 @@ "Arbiter Evil Town", 0x24, 0, 0x1D, "Necromancer Throne Room Empty", 0x24, 0, 0x14, "", 0x24, 0, 0x1D, + "", 0x24, 0, 0x1D, + "", 0x24, 0, 0x1D, + "", 0x24, 0, 0x1D, "Boat01", 0xF, 0, 0x3351D, "", 0x24, 0, 0x1C, "", 0x24, 0, 0x1D, + "", 0x24, 0, 0x1D, "Arbiter Room Neutral", 0x24, 0, 0x1D, "Out02 Castle Harmondy Abandoned", 0x24, 0, 0x19, "Human Temple02", 0x24, 0x3AB, 0x1B17, @@ -676,10 +685,10 @@ char _4E2B21_buff_spell_tooltip_colors[80]; char byte_4E2B70[777]; // weak char byte_4E2BC8; // weak -int pChestSmthn1ByType[8]; -int pChestSmthn2ByType[8]; -int pChestWidthsByType[8]; -int pChestHeightsByType[8]; +int pChestSmthn1ByType[8] = {42, 18, 18, 42, 42, 42, 18, 42}; +int pChestSmthn2ByType[8] = {34, 30, 30, 34, 34, 34, 30, 34}; +int pChestWidthsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9}; +int pChestHeightsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9}; char aSS[777]; // idb char ascii_4E2C54[6]; char ascii_4E2C5C[7]; @@ -949,9 +958,24 @@ char aBardataC[10]; // weak char aLoadprog[777]; // idb char aLoadingD_pcx[777]; // idb -int pNPCPortraits_x = 521; // idb -int dword_4E5EC8[777]; // weak -int pNPCPortraits_y = 38; // idb +int pNPCPortraits_x[6][6] = // 004E5E50 +{ + {521, 0, 0, 0, 0, 0}, + {521, 521, 0, 0, 0, 0}, + {521, 521, 521, 0, 0, 0}, + {521, 486, 564, 521, 0, 0}, + {521, 486, 564, 486, 564, 0}, + {486, 564, 486, 564, 486, 564} +}; +int pNPCPortraits_y[6][6] = // 004E5EE0 +{ + {38, 0, 0, 0, 0, 0}, + {38, 165, 0, 0, 0, 0}, + {38, 133, 228, 0, 0, 0}, + {38, 133, 133, 228, 0, 0}, + {38, 133, 133, 228, 228, 0}, + {38, 38, 133, 133, 228, 228} +}; const char *pHouse_ExitPictures[11]= { "", @@ -1080,7 +1104,14 @@ char aEWorkMsdevMm_7[777]; // idb char aGammaControlNo[777]; // idb __int16 word_4E8152[11] = {0, 0, 0, 90, 8, 2, 70, 20, 10, 50, 30}; -char byte_4E8168[116]; +char byte_4E8168[7][14]={ //byte_4E8178 + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, + { 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, + { 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3}, + { 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4}, + { 2, 2, 2, 2, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5}, + { 2, 2, 2, 2, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6}, + { 2, 2, 2, 2, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}}; char aD3dTextureName[777]; // idb char aLogd3d_txt[777]; // idb char byte_4E8394[204] = @@ -1106,8 +1137,8 @@ unsigned int saveload_dlg_zs[2] = {460, 640}; unsigned int saveload_dlg_ws[2] = {344, 480}; int dword_4E98BC_bApplicationActive; // weak -char *off_4EB080; // idb -char *pTransitionStrings[464]; +//char *off_4EB080; // idb +char *pTransitionStrings[465] = {"", nullptr}; // 004EB080 char aAwards_txt[777]; // idb char aScroll_txt[777]; // idb char aMerchant_txt[777]; // idb @@ -1585,15 +1616,53 @@ "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF", - "MAGSHELF" + "MAGSHELF", "MAGSHELF", "MAGSHELF" +}; +//__int16 word_4F03FE[777]; // weak +//__int16 word_4F0400[777]; // weak +__int16 word_4F0404[] = +{ + 0, 0, 1, 0x17, 0x1B, 0x14, 0x14, 1, 0x17, 0x18, 0x1C, + 0x14, 2, 0x17, 0x18, 0x19, 0x14, 2, 0x1B, 0x1B, 0x1A, 0x1A, + 4, 0x18, 0x1E, 0x19, 0x1B, 4, 0x18, 0x1E, 0x19, 0x1B, 3, 0x1E, + 0x18, 0x14, 0x14, 2, 0x14, 0x14, 0x14, 0x14, 3, 0x1B, 0x1B, 0x1A, 0x1A, + 3, 0x1C, 0x1C, 0x19, 0x19, 2, 0x17, 0x17, 0x18, 0x18, + 3, 0x17, 0x17, 0x1A, 0x1A, 2, 0x1E, 0x1A, 0x1A, 0x1A, 2, 0x1C, + 0x19, 0x1C, 0x1D, 0, 0 }; -__int16 word_4F03FE[777]; // weak -__int16 word_4F0400[777]; // weak -__int16 word_4F0498[777]; // weak -__int16 word_4F0576[777]; // weak +//__int16 word_4F0498[777]; // weak +__int16 word_4F0498[] = +{ +1, 0x23, 0x23, 0x26, 0x26, 1, 0x1F, 0x1F, 0x1F, 0x22, 1, 0x23, 0x23, +0x26, 0x26, 1, 0x1F, 0x1F, 0x20, 0x22, 2, 0x23, 0x23, +0x26, 0x26, 2, 0x1F, 0x20, 0x20, 0x21, 2, 0x23, 0x23, +0x26, 0x26, 2, 0x1F, 0x1F, 0x20, 0x20, 4, 0x23, 0x23, +0x26, 0x26, 4, 0x1F, 0x20, 0x21, 0x22, 4, 0x23, 0x23, 0x26, 0x26, +4, 0x1F, 0x20, 0x21, 0x22, 3, 0x23, 0x23, 0x26, 0x26, 3, +0x1F, 0x1F, 0x1F, 0x1F, 2, 0x23, 0x23, 0x26, 0x26, 2, 0x1F, 0x20, +0x22, 0x22, 3, 0x23, 0x23, 0x26, 0x26, 3, 0x1F, 0x1F, +0x20, 0x20, 3, 0x23, 0x23, 0x26, 0x26, 3, 0x20, 0x20, 0x20, +0x21, 3, 0x23, 0x23, 0x26, 0x26, 3, 0x1F, 0x1F, 0x1F, 0x20 +}; +//__int16 word_4F0576[777]; // weak +__int16 word_4F0576[] = +{ +0x23, 0x23, 0x26, 0x26, 3, 0x21, 0x1F, 0x20, 0x22, 3, 0x23, 0x23, +0x26, 0x26, 3, 0x21, 0x1F, 0x20, 0x22, 4, 0x23, 0x23, 0x26, 0x26, +4, 0x21, 0x1F, 0x20, 0x22, 0x1, 0x1, 0x2, 0x2, 0x4, 0x4, +3, 2, 2, 2, 2, 2, 2, 0, 0x1, 0x1, 0x2, 0x2, 0x3, 0x3, 0x4, 0x4, +2, 2, 2, 2, 0x0, 0x0, 1, 0, 0xA3, 0xA3, 0xA2, 0xA1, 0xA0, +2, 0, 0xA3, 0xA3, 0xA2, 0xA1, 0xA0, 2, 0, 0xA3, 0xA3, +0xA2, 0xA1, 0xA0, 2, 0, 0x0A3, 0x0A3, 0xA2, 0xA1, 0xA0, +3, 0, 0xA3, 0xA3, 0xA2, 0xA1, 0xA0, 3, 0, 0xA3, 0xA3, +0xA2, 0xA1, 0xA0 +}; + __int16 word_4F0578[777]; // weak __int16 word_4F05AE[777]; // weak -char _4F063C_smthn_by_2da_uType[3] = {0, 6, 8}; // weak +char _4F063C_smthn_by_2da_uType[31]={ // weak +0, 6, 8, 12, 12, 0, 0, 0, 0, 0, 0, 0, 2, 0, 25, 0, 30, +0, 20, 0, 20, 0, 2, 0, 23, 0, 24, 0, 28, 0, 20}; __int16 word_4F063E[290]; __int16 word_4F06D8[22]; __int16 word_4F0704[40]; @@ -1666,10 +1735,10 @@ int dword_4F5D98_xs[777]; // idb int ai_array_4F5E68[500]; int ai_array_4F6638_actor_ids[500]; -int dword_4F6E08[500]; +int ai_near_actors_targets_pid[500]; int ai_arrays_size; // weak -int ai_array_4F75E0[500]; -unsigned int ai_array_4F7DB0_actor_ids[500]; +int ai_near_actors_distances[500]; +unsigned int ai_near_actors_ids[500]; int dword_4F8580[182]; // weak int dword_4FA9B0[777]; // weak int dword_4FA9B4[777]; // weak @@ -1875,9 +1944,8 @@ int dword_50C9DC; // weak struct NPCData *ptr_50C9E0; int dword_50C9E8; // idb -int dword_50C9EC[777]; // weak -int dword_50C9F0[120]; // idb -int dword_50CDC8; // weak +int dword_50C9EC[120]; // weak +int dword_50CDC8; int dword_50CDCC; // weak int bProcessorIsNotIntel; // weak Vec3_int_ layingitem_vel_50FDFC; @@ -1922,7 +1990,7 @@ unsigned int uDialogueType; unsigned int uDialogue_SpeakingActorNPC_ID; struct LevelDecoration *_591094_decoration; -char byte_591098[200]; // idb +char sHouseName[200]; // idb int uCurrentHouse_Animation; // weak char *dword_591164_teleport_map_name; // idb int dword_591168_teleport_speedz; // weak @@ -1932,7 +2000,8 @@ int dword_591178_teleporty; // weak int dword_59117C_teleportx; // weak char byte_591180[600]; // idb -struct NPCData *array_5913D8[12]; +struct NPCData *HouseNPCData[6];//array_5913D8 +int pDialogueNPCCount; struct Texture *pDialogueNPCPortraits[6]; int uNumDialogueNPCPortraits; // weak struct Texture *pTexture_591428; @@ -1942,7 +2011,7 @@ int start_event_seq_number; // weak char byte_5B0938[2000]; int dword_5B5920; // weak -int dword_5B5924; // weak +int _unused_5B5924_is_travel_ui_drawn = false; // 005B5924 int _5B65A8_npcdata_uflags_or_other; // weak int _5B65AC_npcdata_fame_or_other; // weak int _5B65B0_npcdata_rep_or_other; // weak
--- a/mm7_data.h Mon Feb 25 09:08:13 2013 +0600 +++ b/mm7_data.h Mon Feb 25 09:09:08 2013 +0600 @@ -681,9 +681,8 @@ extern char aBardataC[10]; // weak extern char aLoadprog[]; // idb extern char aLoadingD_pcx[]; // idb -extern int pNPCPortraits_x; // idb -extern int dword_4E5EC8[]; // weak -extern int pNPCPortraits_y; // idb +extern int pNPCPortraits_x[6][6]; // 004E5E50 +extern int pNPCPortraits_y[6][6]; // 004E5EE0 extern const char *pHouse_ExitPictures[11]; extern const char *_4E6BDC_loc_names[11]; extern char aOutside[]; // idb @@ -787,7 +786,7 @@ extern char aEWorkMsdevMm_7[]; // idb extern char aGammaControlNo[]; // idb extern __int16 word_4E8152[11]; -extern char byte_4E8168[116]; +extern char byte_4E8168[7][14]; extern char aD3dTextureName[]; // idb extern char aLogd3d_txt[]; // idb extern char byte_4E8394[]; // weak @@ -802,8 +801,7 @@ extern unsigned int saveload_dlg_zs[2]; extern unsigned int saveload_dlg_ws[2]; extern int dword_4E98BC_bApplicationActive; // weak -extern char *off_4EB080; // idb -extern char *pTransitionStrings[464]; +extern char *pTransitionStrings[]; // 4EB080 extern char aAwards_txt[]; // idb extern char aScroll_txt[]; // idb extern char aMerchant_txt[]; // idb @@ -1000,8 +998,9 @@ extern void *off_4EFDB0; // weak extern int dword_4F031C[]; // weak extern const char *off_4F03B8[]; // idb -extern __int16 word_4F03FE[]; // weak -extern __int16 word_4F0400[]; // weak +//extern __int16 word_4F03FE[]; // weak +//extern __int16 word_4F0400[]; // weak +extern __int16 word_4F0404[]; extern __int16 word_4F0498[]; // weak extern __int16 word_4F0576[]; // weak extern __int16 word_4F0578[]; // weak @@ -1070,10 +1069,10 @@ extern int dword_4F5D98_xs[]; // idb extern int ai_array_4F5E68[500]; extern int ai_array_4F6638_actor_ids[500]; -extern int dword_4F6E08[500]; +extern int ai_near_actors_targets_pid[500]; extern int ai_arrays_size; // weak -extern int ai_array_4F75E0[500]; -extern unsigned int ai_array_4F7DB0_actor_ids[500]; +extern int ai_near_actors_distances[500]; +extern unsigned int ai_near_actors_ids[500]; extern int dword_4F8580[]; // weak extern int dword_4FA9B0[]; // weak extern int dword_4FA9B4[]; // weak @@ -1278,9 +1277,8 @@ extern int dword_50C9DC; // weak extern struct NPCData *ptr_50C9E0; extern int dword_50C9E8; // idb -extern int dword_50C9EC[]; // weak -extern int dword_50C9F0[120]; // idb -extern int dword_50CDC8; // weak +extern int dword_50C9EC[]; // 50C9EC +extern int dword_50CDC8; extern int dword_50CDCC; // weak extern int bProcessorIsNotIntel; // weak extern Vec3_int_ layingitem_vel_50FDFC; @@ -1325,7 +1323,7 @@ extern unsigned int uDialogueType; extern unsigned int uDialogue_SpeakingActorNPC_ID; extern struct LevelDecoration *_591094_decoration; -extern char byte_591098[200]; // idb +extern char sHouseName[200]; // idb extern int uCurrentHouse_Animation; // weak extern char *dword_591164_teleport_map_name; // idb extern int dword_591168_teleport_speedz; // weak @@ -1335,7 +1333,8 @@ extern int dword_591178_teleporty; // weak extern int dword_59117C_teleportx; // weak extern char byte_591180[600]; // idb -extern struct NPCData *array_5913D8[12]; +extern struct NPCData *HouseNPCData[6]; +extern int pDialogueNPCCount; extern struct Texture *pDialogueNPCPortraits[6]; extern int uNumDialogueNPCPortraits; // weak extern struct Texture *pTexture_591428; @@ -1345,7 +1344,7 @@ extern int start_event_seq_number; // weak extern char byte_5B0938[2000]; extern int dword_5B5920; // weak -extern int dword_5B5924; // weak +extern int _unused_5B5924_is_travel_ui_drawn; // 005B5924 extern int _5B65A8_npcdata_uflags_or_other; // weak extern int _5B65AC_npcdata_fame_or_other; // weak extern int _5B65B0_npcdata_rep_or_other; // weak @@ -1753,8 +1752,8 @@ #define __thiscall __cdecl // Test compile in C mode void __stdcall mm7__vector_constructor(void *a1, int objSize, int numObjs, int (__thiscall *constructor)(int)); -int __cdecl ODM_4014E6_AI(); -int __cdecl BLV_4016FA_AI(); +void MakeActorAIList_ODM(); +int __cdecl MakeActorAIList_BLV(); void __cdecl sub_401A91_AI(); bool __fastcall sub_4070EF_prolly_collide_objects(unsigned int uObjID, unsigned int uObj2ID); bool __fastcall sub_4075DB(int a1, int a2, int a3, struct BLVFace *a4); @@ -1915,7 +1914,7 @@ void __cdecl sub_421EA6_OnInventoryLeftClick(); void __cdecl OnGameViewportClick(); bool PauseGameDrawing(); -void __fastcall SetUserInterface(int a1, bool bReplace); +void SetUserInterface(enum PartyAlignment alignment, bool bReplace); void __cdecl reset_some_strus_flt_2Cs(); void __cdecl j_sub_423B4A(); void __cdecl sub_423B4A(); @@ -2011,9 +2010,9 @@ void __thiscall Level_LoadEvtAndStr(const char *pLevelName); char *__cdecl _4443D5_GetMinimapRightClickText(); const char *__cdecl sub_444564(); -char *__thiscall _444732_GetEventHintString(unsigned int uEventID); // idb +char *__thiscall GetEventHintString(unsigned int uEventID); // idb unsigned int __fastcall sub_444839_move_map(unsigned int a1, int a2, int x, int y, int z, int directiony, int directionx, int a8, const char *pLocationName); // idb -char *__cdecl TransitionUI_Draw(); +void TransitionUI_Draw(); struct GUIWindow *__cdecl UI_CreateTravelDialogue(); signed int __cdecl GetTravelTime(); void __cdecl TravelUI_Draw(); @@ -2031,7 +2030,7 @@ int sub_4465DF_check_season(int a1); int __fastcall IsActorAlive(unsigned int uType, unsigned int uParam, unsigned int uNumAlive); // idb // void __cdecl crt_construct_5773C4(); -bool __thiscall sub_4466C4(void *_this); +int NPC_EventProcessor(int npc_event_id); void __fastcall sub_448518_npc_set_item(int npc, unsigned int item, int a3); void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename); @@ -2304,45 +2303,45 @@ void __cdecl sub_4B1D27(); void __fastcall HousePlaySomeSound(unsigned int uHouseID, int a2); // idb void __cdecl sub_4B1ECE(); -void __fastcall sub_4B2001(signed int a1); +void __fastcall ClickNPCTopic(signed int uMessageParam); char *__thiscall _4B254D_SkillMasteryTeacher(int _this); -const char *__fastcall sub_4B29F2(int a1); -char __cdecl sub_4B2A74(); +const char *__fastcall ContractSelectText(int pEventNumber); +char __cdecl SimpleHouseAndBoatsDialog(); struct GUIButton *__fastcall sub_4B36CC(int a1, unsigned int a2); int __thiscall sub_4B3703(void *_this); int __thiscall sub_4B3A72(int a1); // idb int __fastcall sub_4B3AD4(signed int a1); int __fastcall sub_4B3B42(signed int a1); void __cdecl sub_4B3E1E(); -void __fastcall sub_4B3EF0(int a4); +void __fastcall DrawJoinGuildWindow(int pEventNumber); void __fastcall sub_4B3FE5(int a4); void __cdecl sub_4B40E6(); -struct GUIButton *__thiscall _4B4224_UpdateNPCTopics(int _this); +void _4B4224_UpdateNPCTopics(int _this); char __fastcall sub_4B46A5(const char *Str, int a5); int __fastcall sub_4B46F8(int a1); -int __cdecl ui_training(); +int __cdecl TrainingDialog(); char *__cdecl sub_4B4F4F(); -int __cdecl ui_shop_teachers(); -int __cdecl sub_4B5D7C(); +int __cdecl MagicShopDialog(); +int __cdecl GuildDialog(); int __cdecl sub_4B6478(); bool __fastcall sub_4B68EA(int a1); void __cdecl TravelByTransport(); -int __cdecl sub_4B705E(); +int __cdecl TampleDialog(); void __cdecl sub_4B7911(); void __cdecl _4B7D7E_bank(); -void __cdecl sub_4B8285_prolly_draw_arcomage_result(); +void __cdecl TavernDialog(); void *__cdecl GenerateShopItems(); -void *__cdecl sub_4B8F94(); -char *__cdecl _4B910F_shop_interaction(); -POINT *__cdecl sub_4B9CC6(); -void __cdecl sub_4BA928(); +void sub_4B8F94(); +char *__cdecl WeaponShopDialog(); +POINT *__cdecl AlchemistDialog(); +void __cdecl ArmorShopDialog(); signed int __fastcall sub_4BB756(signed int a1); const char *sub_4BBA85_bounties(); void __cdecl sub_4BBCDD(); void __fastcall _4BBF61_summon_actor(int a1, __int16 x, int y, int z); // idb void __cdecl ArenaFight(); struct Texture *__cdecl sub_4BC8D5(); -struct GUIButton *__cdecl sub_4BCA33(); +struct GUIButton *__cdecl UI_CreateEndConversationButton(); void __fastcall sub_4BCACC_bounties(signed int a1); signed int __cdecl sub_4BD8B5(); bool __fastcall sub_4BDAAF(ItemGen *a1, int _2da_idx);
--- a/stru6.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/stru6.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -777,6 +777,7 @@ signed int v35; // [sp+0h] [bp-18h]@81 char pContainer[7]; // [sp+10h] [bp-8h]@81 + __debugbreak(); // need to refactor carefully & collect data v2 = this; result = a2->uItemType; if ( result <= 545 )
--- a/stru9.cpp Mon Feb 25 09:08:13 2013 +0600 +++ b/stru9.cpp Mon Feb 25 09:09:08 2013 +0600 @@ -227,7 +227,7 @@ //----- (00498737) -------------------------------------------------------- void stru9::AddVertex(struct VertexBuffer *pVertexBuffer, struct RenderVertexSoft *pVertex) { - __debugbreak(); +// __debugbreak(); RenderVertexSoft *v3; // eax@1 v3 = &pVertexBuffer->pVertices[pVertexBuffer->uNumVertices];