Mercurial > mm7
changeset 604:8724a4b3ca45
Слияние
author | Ritor1 |
---|---|
date | Thu, 07 Mar 2013 09:15:15 +0600 |
parents | ac6fe92c7e36 (current diff) 628694cd5744 (diff) |
children | a8dec6a3fc9e |
files | Game.cpp |
diffstat | 25 files changed, 1507 insertions(+), 1349 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Thu Mar 07 09:14:57 2013 +0600 +++ b/Actor.cpp Thu Mar 07 09:15:15 2013 +0600 @@ -46,7 +46,7 @@ v3 = 0; if ( (signed int)uNumActors > 0 ) { - v4 = (int *)&pActors[0].uNPC_ID; + v4 = (int *)&pActors[0].sNPC_ID; while ( *(short *)v4 != npc ) { ++v3; @@ -147,7 +147,7 @@ void Actor::InitializeDialogue(int bPlayerSaysHello) { Actor *v2; // esi@1 - unsigned int v3; // ecx@1 + signed int v3; // ecx@1 NPCData *v4; // eax@1 NPCData *v5; // ebp@1 unsigned int v6; // eax@1 @@ -173,8 +173,8 @@ pMiscTimer->Pause(); pAudioPlayer->StopChannels(-1, -1); uDialogueType = 0; - v3 = v2->uNPC_ID; - uDialogue_SpeakingActorNPC_ID = v2->uNPC_ID; + v3 = v2->sNPC_ID; + sDialogue_SpeakingActorNPC_ID = v2->sNPC_ID; pDialogue_SpeakingActor = v2; v4 = GetNPCData(v3); v5 = v4; @@ -247,7 +247,7 @@ } } } - if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) != 0 ) + if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) != 0 ) v9 = 4; v11 = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)10, v9, 0); pDialogueWindow = v11; @@ -3895,7 +3895,7 @@ { this->pActorName[0] = 0; this->word_000086_some_monster_id = 0; - this->uNPC_ID = 0; + this->sNPC_ID = 0; this->vPosition.z = 0; this->vPosition.y = 0; this->vPosition.x = 0;
--- a/Actor.h Thu Mar 07 09:14:57 2013 +0600 +++ b/Actor.h Thu Mar 07 09:15:15 2013 +0600 @@ -238,7 +238,7 @@ char pActorName[32]; - unsigned __int16 uNPC_ID; + signed __int16 sNPC_ID; __int16 field_22; unsigned int uAttributes; __int16 sCurrentHP;
--- a/AudioPlayer.cpp Thu Mar 07 09:14:57 2013 +0600 +++ b/AudioPlayer.cpp Thu Mar 07 09:15:15 2013 +0600 @@ -90,7 +90,7 @@ if ( pSoundList->pSounds[v2].eType != SOUND_DESC_SYSTEM || (sprintf(pSoundName, "%s", pSounds[v2].pSoundName), pSoundList->pSounds[v2].pSoundData[0] = ::LoadSound(pSoundName, (SoundData *)0xFFFFFFFF, pSounds[v2].uSoundID), !pAudioPlayer->b3DSoundInitialized) - || (pSoundDesc = &pSoundList->pSounds[v2], !(pSoundDesc->uFlags & 2)) + || (pSoundDesc = &pSoundList->pSounds[v2], !(pSoundDesc->uFlags & SOUND_DESC_SWAP)) || !pSoundDesc->pSoundData[0] ) // goto LABEL_17; pSoundData = pSoundDesc->pSoundData[0]; @@ -163,8 +163,8 @@ if (!pSound) return 0; - if (pSound->uFlags & 2 && pSound->p3DSound || - ~pSound->uFlags & 2 && pSound->pSoundData[0]) + if (pSound->uFlags & SOUND_DESC_SWAP && pSound->p3DSound || + ~pSound->uFlags & SOUND_DESC_SWAP && pSound->pSoundData[0]) return uSoundIdx; if (!pSound->pSoundData[0]) @@ -174,12 +174,12 @@ return 0; if (a3) - pSound->uFlags |= 1u; + pSound->uFlags |= SOUND_DESC_SYSTEM; if (!pAudioPlayer->b3DSoundInitialized) return uSoundIdx; - if (~pSound->uFlags & 2 || !pSound->pSoundData[0]) + if (~pSound->uFlags & SOUND_DESC_SWAP || !pSound->pSoundData[0]) return uSoundIdx; @@ -368,7 +368,7 @@ ReleaseSoundData(v7); v2->pSounds[v3].pSoundData[0] = 0; } - v2->pSounds[v3].uFlags &= 0xFFFFFFFEu; + v2->pSounds[v3].uFlags &= ~SOUND_DESC_SYSTEM; } ++i; } @@ -387,19 +387,19 @@ v5 = &this->pSounds[uSoundID]; if ( v5->eType != SOUND_DESC_SYSTEM ) { - if ( v5->uFlags & 2 && v5->p3DSound && a3 ) + if ( v5->uFlags & SOUND_DESC_SWAP && v5->p3DSound && a3 ) { if ( LOBYTE(v5->bDecompressed) ) AIL_mem_free_lock(v5->p3DSound); pSounds[v3].p3DSound = 0; - pSounds[v3].uFlags &= 0xFFFFFFFEu; + pSounds[v3].uFlags &= ~SOUND_DESC_SYSTEM; } v6 = pSounds[v3].pSoundData[0]; if ( v6 ) { ReleaseSoundData(v6); pSounds[v3].pSoundData[0] = 0; - pSounds[v3].uFlags &= 0xFFFFFFFEu; + pSounds[v3].uFlags &= ~SOUND_DESC_SYSTEM; } } } @@ -521,7 +521,7 @@ if ( v19.field_0 >= 4 && !_strcmpi(v19.pProperties[3], "3D") ) { v15 = (int)&v2->pSounds[v2->uNumSounds].uFlags; - *(int *)v15 |= 2u; + *(int *)v15 |= SOUND_DESC_SWAP; } ++v2->uNumSounds; } @@ -1743,7 +1743,7 @@ auto decor_desc = &pDecorationList->pDecorations[decor->uDecorationDescID]; //v48 = &pDecorationList->pDecorations[decor->uDecorationDescID]; //v49 = v48->uFlags; - uNumRepeats = (~(unsigned __int8)decor_desc->uFlags & 0x40) >> 6; + uNumRepeats = (~(unsigned __int8)decor_desc->uFlags & DECORATION_SLOW_LOOP) >> 6; if (decor_desc->SoundOnDawn() || decor_desc->SoundOnDusk()) { @@ -2231,7 +2231,7 @@ v4 = &pSoundList->pSounds[pChannel->uSourceTrackIdx]; if ( v4->eType == SOUND_DESC_SWAP) { - if ( v4->pSoundData[0] && !(v4->uFlags & 1) ) + if ( v4->pSoundData[0] && !(v4->uFlags & SOUND_DESC_SYSTEM) ) { v5 = this->uMixerChannels == 0; v6 = this->uMixerChannels < 0; @@ -2371,7 +2371,7 @@ v4 = &pSoundList->pSounds[a2->field_8]; if ( v4->eType == SOUND_DESC_SWAP) { - if ( v4->p3DSound && !(v4->uFlags & 1) ) + if ( v4->p3DSound && !(v4->uFlags & SOUND_DESC_SYSTEM) ) { v5 = this->uNum3DSamples == 0; v6 = this->uNum3DSamples < 0;
--- a/Chest.cpp Thu Mar 07 09:14:57 2013 +0600 +++ b/Chest.cpp Thu Mar 07 09:15:15 2013 +0600 @@ -302,9 +302,9 @@ v13 = v12 + 32; if ( itemPixelHeght < 14 ) itemPixelHeght = 14; - itemPixelPosX = chest_offs_x + 32 * (item_counter % chestWidthCells) + ((v13 - itemPixelWidth) >> 1); + itemPixelPosX = chest_offs_x + 32 * (item_counter % chestWidthCells) + ((signed int)(v13 - itemPixelWidth)/2); itemPixelPosY = chest_offs_y + 32 * (item_counter / chestHeghtCells) + - ((((itemPixelHeght - 14) & 0xFFFFFFE0) - item_texture->uTextureHeight + 32) >> 1); + ((signed int)(((itemPixelHeght - 14) & 0xFFFFFFE0) + 32- item_texture->uTextureHeight ) /2); pRenderer->DrawTextureTransparent( itemPixelPosX, itemPixelPosY, item_texture); sub_40F92A(&v16[itemPixelPosX + pSRZBufferLineOffsets[itemPixelPosY]], item_texture, item_counter + 1); } @@ -613,7 +613,7 @@ if(test_position<uChestArea) { Chest::PlaceItemAt((unsigned __int8)chest_cells_map[test_position], items_counter, uChestID); - if ( pChests[uChestID].uFlags & 4 ) + if ( pChests[uChestID].uFlags & CHEST_OPENED) pChests[uChestID].igChestItems[items_counter].SetIdentified(); } }
--- a/Events.cpp Thu Mar 07 09:14:57 2013 +0600 +++ b/Events.cpp Thu Mar 07 09:15:15 2013 +0600 @@ -121,6 +121,17 @@ //----- (00443EF8) -------------------------------------------------------- void LoadLevel_InitializeLevelEvt() { + struct raw_event_header + { + unsigned char evt_size; + unsigned char evt_id_l; + unsigned char evt_id_h; + unsigned char evt_sequence_num; + } ; + uint events_count; + unsigned int offset_in; + raw_event_header *current_hdr; + if (!uLevelEVT_Size) return; @@ -130,6 +141,19 @@ uLevelEVT_NumEvents = 0; dword_5B65C8_timers_count = 0; + current_hdr=(raw_event_header *)pLevelEVT; + offset_in=0; + for (events_count = 0, offset_in = 0; offset_in < uLevelEVT_Size; ++events_count) + { + pLevelEVT_Index[events_count].uEventID=current_hdr->evt_id_l+(current_hdr->evt_id_h<<8); + pLevelEVT_Index[events_count].event_sequence_num=current_hdr->evt_sequence_num; + pLevelEVT_Index[events_count].uEventOffsetInEVT=offset_in; + offset_in+=current_hdr->evt_size+1; + current_hdr=(raw_event_header *)&pLevelEVT[offset_in]; + } + uLevelEVT_NumEvents = events_count; + +/* for (uint i = 0, j = 0; j < uLevelEVT_Size; ++i) { pLevelEVT_Index[i].uEventID = pLevelEVT[j + 1] + ((unsigned short)pLevelEVT[j + 2] << 8); @@ -137,7 +161,7 @@ pLevelEVT_Index[i].uEventOffsetInEVT = j; j += pLevelEVT[j] + 1; uLevelEVT_NumEvents++; - } + }*/ } @@ -507,7 +531,7 @@ //Actor::Actor(&Dst); memset(&Dst, 0, 0x344u); dword_5B65D0_dialogue_actor_npc_id = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8); - Dst.uNPC_ID = dword_5B65D0_dialogue_actor_npc_id; + Dst.sNPC_ID = dword_5B65D0_dialogue_actor_npc_id; Dst.InitializeDialogue(0); } else
--- a/GUIWindow.cpp Thu Mar 07 09:14:57 2013 +0600 +++ b/GUIWindow.cpp Thu Mar 07 09:15:15 2013 +0600 @@ -1796,8 +1796,8 @@ { num_menu_buttons = 0; v11 = LOBYTE(pFontArrus->uFontHeight) - 3; - speakingNPC = GetNPCData(uDialogue_SpeakingActorNPC_ID); - if ( sub_445C8B(uDialogue_SpeakingActorNPC_ID) == 1 ) + speakingNPC = GetNPCData(sDialogue_SpeakingActorNPC_ID); + if ( sub_445C8B(sDialogue_SpeakingActorNPC_ID) == 1 ) { if ( speakingNPC->joins ) {
--- a/Game.cpp Thu Mar 07 09:14:57 2013 +0600 +++ b/Game.cpp Thu Mar 07 09:15:15 2013 +0600 @@ -610,7 +610,7 @@ } else { - if ( uFlags2 & 0x10 ) + if ( uFlags2 & GAME_FLAGS_2_TARGETING_MODE ) { v11 = &vis_face_filter; v10 = &vis_sprite_filter_1;
--- a/Game.h Thu Mar 07 09:14:57 2013 +0600 +++ b/Game.h Thu Mar 07 09:15:15 2013 +0600 @@ -16,7 +16,10 @@ -#define GAME_FLAGS_2_DRAW_BLOODSPLATS 0x20 +#define GAME_FLAGS_2_SATURATE_LIGHTMAPS 0x02 +#define GAME_FLAGS_2_ALTER_GRAVITY 0x08 +#define GAME_FLAGS_2_TARGETING_MODE 0x10 +#define GAME_FLAGS_2_DRAW_BLOODSPLATS 0x20
--- a/Indoor.cpp Thu Mar 07 09:14:57 2013 +0600 +++ b/Indoor.cpp Thu Mar 07 09:15:15 2013 +0600 @@ -527,8 +527,7 @@ stru_F7B60C.face_plane.dist = pFace->pFacePlane.dist; } - if (stru_F8AD28.uNumLightsApplied > 0 && !pFace->uAttributes) - //!(pFace->uAttributes & 0x400000)) + if (stru_F8AD28.uNumLightsApplied > 0 && !(pFace->uAttributes & 0x400000)) pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &stru_F7B60C, uNumVerticesa, array_507D30, pVertices, 0); if (pDecalBuilder->uNumDecals > 0) @@ -557,17 +556,20 @@ v23 = pFace->uBitmapID; goto LABEL_42; } - else if (pFace->uAttributes)//(pFace->uAttributes & 0x4000) + else if (pFace->uAttributes & 0x4000) { v23 = pTextureFrameTable->GetFrameTexture(pFace->uBitmapID, pBLVRenderParams->field_0_timer_); LABEL_42: v27 = pBitmaps_LOD->pHardwareTextures[v23]; - if (pFace->uAttributes & 0x400000) + if (pFace->uAttributes & FACE_DO_NOT_LIGHT) _479A53_draw_some_blv_poly(uNumVerticesa, uFaceID); else pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, 8 * uFaceID | 6, v17, 0); return; } + //v17 = 0xFFFFFFFF; + v23 = pFace->uBitmapID; + goto LABEL_42; } } }
--- a/Indoor.h Thu Mar 07 09:14:57 2013 +0600 +++ b/Indoor.h Thu Mar 07 09:15:15 2013 +0600 @@ -257,6 +257,7 @@ #define FACE_TEXTURE_FRAME 0x00004000 // Texture ID is a frameset from TextureFrameTable, otherwise BitmapID #define FACE_OUTLINED 0x00010000 // outline face edges #define FACE_TEXTURE_FLOW 0x00040000 // The texture moves slowly. For horizontal facets only. +#define FACE_DO_NOT_LIGHT 0x00400000 #define FACE_CLICKABLE 0x02000000 // Event can be triggered by clicking on the facet. #define FACE_PRESSURE_PLATE 0x04000000 // Event can be triggered by stepping on the facet. #define FACE_ETHEREAL 0x20000000 // Untouchable. You can pass through it.
--- a/Items.cpp Thu Mar 07 09:14:57 2013 +0600 +++ b/Items.cpp Thu Mar 07 09:15:15 2013 +0600 @@ -925,7 +925,7 @@ memset(&uChanceByTreasureLvlSumm, 0, 24); for(i=0;i<6;++i) { - for (j=0;j<800;++j) + for (j=1;j<item_counter;++j) uChanceByTreasureLvlSumm[i]+=pItems[j].uChanceByTreasureLvl[i]; } @@ -1723,7 +1723,10 @@ if ( v18 > 0 ) { do - v57 += pItems[out_item->uItemID++ + 1].uChanceByTreasureLvl[v6]; + { + v57 += pItems[out_item->uItemID + 1].uChanceByTreasureLvl[v6]; + ++out_item->uItemID; + } while ( v57 < v18 ); } @@ -2019,204 +2022,162 @@ //----- (00450218) -------------------------------------------------------- -void sub_450218_prolly_generate_chests_loot() +void GenerateItemsInChest() { - unsigned int v0; // eax@1 - Chest *v1; // ebx@1 - MapInfo *v2; // esi@1 - ItemGen *v3; // ebx@2 - int v4; // ebp@4 - int v5; // edi@4 - int v6; // esi@4 - int v7; // eax@4 - signed int v8; // esi@4 - int v9; // edx@4 - int v10; // esi@8 - int v11; // ebp@25 - int v12; // esi@25 - signed int v13; // ebp@27 - ItemGen *v14; // edi@28 - signed int v15; // edx@32 - signed __int64 v16; // qtt@32 - int v17; // esi@34 - signed int v18; // [sp+10h] [bp-18h]@1 - int v19; // [sp+14h] [bp-14h]@4 - MapInfo *v20; // [sp+18h] [bp-10h]@1 - Chest *v21; // [sp+1Ch] [bp-Ch]@1 - int v22; // [sp+20h] [bp-8h]@26 - signed int v23; // [sp+24h] [bp-4h]@2 + unsigned int v0; // eax@1 + Chest *v1; // ebx@1 + MapInfo *v2; // esi@1 + ItemGen *v3; // ebx@2 + int v4; // ebp@4 + int v5; // edi@4 + int v6; // esi@4 + int v7; // eax@4 + signed int v8; // esi@4 + int v9; // edx@4 + int v10; // esi@8 + int v11; // ebp@25 + int v12; // esi@25 + signed int v13; // ebp@27 + ItemGen *v14; // edi@28 + signed int v15; // edx@32 + signed __int64 v16; // qtt@32 + int v17; // esi@34 + signed int v18; // [sp+10h] [bp-18h]@1 + int v19; // [sp+14h] [bp-14h]@4 + MapInfo *v20; // [sp+18h] [bp-10h]@1 + Chest *v21; // [sp+1Ch] [bp-Ch]@1 + int v22; // [sp+20h] [bp-8h]@26 + signed int v23; // [sp+24h] [bp-4h]@2 - v18 = rand() % 100; - v0 = pMapStats->GetMapInfo(pCurrentMapName); - v1 = pChests; - v2 = &pMapStats->pInfos[v0]; - v21 = pChests; - v20 = &pMapStats->pInfos[v0]; - for(int i=0; i<20;++i) - { - for(int j=0; j<140;++j) - { - v3 = &pChests[i].igChestItems[j]; - if ( v3->uItemID < 0 ) - { - v4 = rand() % 5 + 1; - 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; - v19 = v5 + v7 % v8; - /* switch (v9) - { - default: - - }*/ - + v18 = rand() % 100; //main random + v0 = pMapStats->GetMapInfo(pCurrentMapName); + // v1 = pChests; + v2 = &pMapStats->pInfos[v0]; + //v21 = pChests; + //v20 = &pMapStats->pInfos[v0]; + for(int i=1; i<20;++i) + { + for(int j=0; j<140;++j) + { - if ( v9 < 7 ) - { - if ( v18 < 20 ) - { - v3->Reset(); - goto LABEL_25; - } - if ( v18 < 60 ) - { - v10 = 0; - v3->Reset(); - if ( v19 == 1 ) - { - v10 = rand() % 51 + 50; - } - else - { - if ( v19 != 2 ) - { - if ( v19 == 3 ) - { - v10 = rand() % 301 + 200; - } - else - { - if ( v19 != 4 ) - { - if ( v19 == 5 ) - { - v10 = rand() % 1001 + 1000; -LABEL_15: - v3->uItemID = 199; - } - else - { - if ( v19 == 6 ) - { - v10 = rand() % 3001 + 2000; - goto LABEL_15; - } - } -LABEL_23: - v3->SetIdentified(); - v3->uSpecEnchantmentType = v10; -LABEL_25: - v11 = v4 - 1; - v12 = 0; - if ( v11 > 0 ) - { - v22 = v11; - while ( 1 ) - { - v13 = v12; - if ( v12 >= 140 ) - goto LABEL_52; - v14 = &v21->igChestItems[v12]; - while ( v14->uItemID ) - { - ++v13; - ++v14; - if ( v13 >= 140 ) - goto LABEL_52; - } - v16 = rand(); - v15 = v16 % 100; - v18 = v16 % 100; - if ( v15 < 20 ) - goto LABEL_52; - if ( v15 >= 60 ) - { - pItemsTable->GenerateItem(v19, 0, v14); - goto LABEL_51; - } - v17 = 0; - v14->Reset(); - if ( v19 == 1 ) - { - v17 = rand() % 51 + 50; - goto LABEL_48; - } - if ( v19 == 2 ) - { - v17 = rand() % 101 + 100; -LABEL_48: - v14->uItemID = 197; - goto LABEL_49; - } - if ( v19 == 3 ) - { - v17 = rand() % 301 + 200; - goto LABEL_44; - } - if ( v19 == 4 ) - { - v17 = rand() % 501 + 500; -LABEL_44: - v14->uItemID = 198; - goto LABEL_49; - } - if ( v19 == 5 ) - break; - if ( v19 == 6 ) - { - v17 = rand() % 3001 + 2000; -LABEL_41: - v14->uItemID = 199; - } -LABEL_49: - v14->uSpecEnchantmentType = v17; -LABEL_51: - v12 = v13 + 1; -LABEL_52: - --v22; - if ( !v22 ) - goto LABEL_55; - } - v17 = rand() % 1001 + 1000; - goto LABEL_41; - } - goto LABEL_55; - } - v10 = rand() % 501 + 500; - } - v3->uItemID = 198; - goto LABEL_23; - } - v10 = rand() % 101 + 100; - } - v3->uItemID = 197; - goto LABEL_23; - } - pItemsTable->GenerateItem(v9, 0, v3); - goto LABEL_25; - } - v3->GenerateArtifact(); - -LABEL_55: - v2 = v20; -LABEL_56: ; + v3 = &pChests[i].igChestItems[j]; + if ( v3->uItemID < 0 ) + { + v4 = rand() % 5; //additional items in chect + v5 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob]; + v6 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob+1]; + v8 = v6 - v5 + 1; + v9 = v5 + rand() % v8; //treasure level + if (v9<7) + { + if (v18<20) + { + v3->Reset(); + } + else if (v18<60) //generate gold + { + v10=0; + v3->Reset(); + switch (v9) + { + case 1: //small gold + v10 = rand() % 51 + 50; + v3->uItemID = 197; + break; + case 2://small gold + v10 = rand() % 101 + 100; + v3->uItemID = 197; + break; + case 3: //medium + v10 = rand() % 301 + 200; + v3->uItemID = 198; + break; + case 4: //medium + v10 = rand() % 501 + 500; + v3->uItemID = 198; + break; + case 5: //big + v10 = rand() % 1001 + 1000; + v3->uItemID = 199; + break; + case 6: //big + v10 = rand() % 3001 + 2000; + v3->uItemID = 199; + break; + } + v3->SetIdentified(); + v3->uSpecEnchantmentType = v10; + } + else + { + pItemsTable->GenerateItem(v9, 0, v3); + } + + v12 = 0; + //generate more items + for (v11=0; v11<v4; ++v11) + { + + if ( v12 >= 140 ) + break; + while ( !(pChests[i].igChestItems[v12].uItemID==0) &&(v12<140)) + { + ++v12; + } + v14=&pChests[i].igChestItems[v12]; + v18 = rand() % 100; + if (v18<20) + { + v3->Reset(); + } + else if (v18<60) //generate gold + { + v10=0; + v3->Reset(); + switch (v9) + { + case 1: //small gold + v10 = rand() % 51 + 50; + v14->uItemID = 197; + break; + case 2://small gold + v10 = rand() % 101 + 100; + v14->uItemID = 197; + break; + case 3: //medium + v10 = rand() % 301 + 200; + v14->uItemID = 198; + break; + case 4: //medium + v10 = rand() % 501 + 500; + v14->uItemID = 198; + break; + case 5: //big + v10 = rand() % 1001 + 1000; + v14->uItemID = 199; + break; + case 6: //big + v10 = rand() % 3001 + 2000; + v14->uItemID = 199; + break; + } + v14->SetIdentified(); + v14->uSpecEnchantmentType = v10; + } + else + { + pItemsTable->GenerateItem(v9, 0, v14); + } + ++v12; + } + } + else + v3->GenerateArtifact(); } - } - } - - } + } + } + + }
--- a/Items.h Thu Mar 07 09:14:57 2013 +0600 +++ b/Items.h Thu Mar 07 09:15:15 2013 +0600 @@ -289,6 +289,7 @@ void GenerateStandartShopItems(); void GenerateSpecialShopItems(); +void GenerateItemsInChest(); extern const char uItemsAmountPerShopType[]; // weak extern ItemGen *ptr_50C9A4;
--- a/LightmapBuilder.cpp Thu Mar 07 09:14:57 2013 +0600 +++ b/LightmapBuilder.cpp Thu Mar 07 09:15:15 2013 +0600 @@ -1621,7 +1621,7 @@ { //v30 = 0.0; //v4 = pRenderer->pRenderD3D->pDevice; - ErrD3D(v4->SetTextureStageState(0, D3DTSS_ADDRESS, 3u)); + ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3u)); //v6 = (char *)stru_69BD44.c_str(); //if ( !stru_69BD44.c_str() ) // v6 = (char *)&dword_4D86F0;
--- a/Party.cpp Thu Mar 07 09:14:57 2013 +0600 +++ b/Party.cpp Thu Mar 07 09:15:15 2013 +0600 @@ -198,38 +198,31 @@ //----- (00492AD5) -------------------------------------------------------- -__int16 Party::SetFood(unsigned int uNumFood) +void Party::SetFood(unsigned int uNumFood) { - __int16 result; // ax@1 - pUIAnim_Food->uAnimTime = 0; pParty->uNumFoodRations = uNumFood; - result = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Food->uIconID].uAnimLength; - pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Food->uIconID].uAnimLength; - return result; + pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Food->uIconID].uAnimLength; } //----- (00492B03) -------------------------------------------------------- void Party::TakeFood(unsigned int uNumFood) { - if ( ((pParty->uNumFoodRations - uNumFood) & 0x80000000u) == 0 ) - pParty->uNumFoodRations -= uNumFood; + if (pParty->uNumFoodRations <= uNumFood) + pParty->uNumFoodRations = 0; else - pParty->uNumFoodRations = 0; + pParty->uNumFoodRations -= uNumFood; + pUIAnim_Food->uAnimTime = 0; - pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Food->uIconID].uAnimLength; + pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Food->uIconID].uAnimLength; } //----- (00492B42) -------------------------------------------------------- -__int16 Party::GiveFood(unsigned int _this) +void Party::GiveFood(unsigned int _this) { - __int16 result; // ax@1 - pParty->uNumFoodRations += _this; pUIAnim_Food->uAnimTime = 0; - result = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Food->uIconID].uAnimLength; - pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Food->uIconID].uAnimLength; - return result; + pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Food->uIconID].uAnimLength; } //----- (00492B70) -------------------------------------------------------- @@ -237,7 +230,7 @@ { pParty->uNumGold = uNumGold; pUIAnim_Gold->uAnimTime = 0; - pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Gold->uIconID].uAnimLength; + pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Gold->uIconID].uAnimLength; pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); } @@ -249,7 +242,7 @@ else pParty->uNumGold = 0; pUIAnim_Gold->uAnimTime = 0; - pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Gold->uIconID].uAnimLength; + pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Gold->uIconID].uAnimLength; pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); } @@ -752,6 +745,7 @@ uFlags = 0; memset(_autonote_bits, 0, 12); memset(_quest_bits, 0, 64); + memset(pIsArtifactFound, 0, 29); _449B7E_toggle_bit(_quest_bits, 1, 1); _449B7E_toggle_bit(_quest_bits, 2, 1); _449B7E_toggle_bit(_quest_bits, 3, 1);
--- a/Party.h Thu Mar 07 09:14:57 2013 +0600 +++ b/Party.h Thu Mar 07 09:15:15 2013 +0600 @@ -180,9 +180,9 @@ static void SetGold(unsigned int uNumGold); static void TakeGold(unsigned int uNumGold); - static __int16 SetFood(unsigned int uNumFood); + static void SetFood(unsigned int uNumFood); static void TakeFood(unsigned int uNumFood); - static __int16 GiveFood(unsigned int _this); + static void GiveFood(unsigned int _this); inline bool WizardEyeActive() {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uExpireTime > 0;} inline int WizardEyeSkillLevel() {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uSkill;}
--- a/Player.cpp Thu Mar 07 09:14:57 2013 +0600 +++ b/Player.cpp Thu Mar 07 09:15:15 2013 +0600 @@ -9386,7 +9386,7 @@ { case 232: VarNum = (VariableType)0; - GetNewNPCData(uDialogue_SpeakingActorNPC_ID, (int)&VarNum); + GetNewNPCData(sDialogue_SpeakingActorNPC_ID, (int)&VarNum); result = (bool) pValue; dword_5B65CC = 0; if ( (int)VarNum == pValue )
--- a/Render.cpp Thu Mar 07 09:14:57 2013 +0600 +++ b/Render.cpp Thu Mar 07 09:15:15 2013 +0600 @@ -7800,14 +7800,14 @@ double v17; // st6@10 //char v18; // zf@10 Texture *v19; // edx@10 - Texture *v23; // edx@16 - char *v24; // ecx@16 - char *v25; // eax@16 - double v26; // st6@17 - int v27; // esi@17 - double v28; // st6@17 - unsigned int v33; // ecx@18 - char *v34; // eax@19 + //Texture *v23; // edx@16 + //char *v24; // ecx@16 + //char *v25; // eax@16 + //double v26; // st6@17 + //int v27; // esi@17 + //double v28; // st6@17 + //unsigned int v33; // ecx@18 + //char *v34; // eax@19 //Texture *v45; // edx@23 //char *v46; // ecx@23 //char *v47; // eax@23 @@ -7908,36 +7908,47 @@ } else { - __debugbreak(); - if ( (signed int)uNumVertices > 0 ) - { - v23 = pTex; - v24 = (char *)&array_507D30[0].vWorldViewPosition; - v25 = (char *)&d3d_vertex_buffer[0].pos.y; - pTex = (Texture *)uNumVertices; - uint v18; - do - { - v26 = *(float *)v24 * 0.061758894; - v27 = *((int *)v24 + 3); - *((int *)v25 + 4) = 0; - *((int *)v25 - 1) = v27; - *(int *)v25 = *((int *)v24 + 4); - *((int *)v25 + 3) = uColor; - v25 += 32; - *((float *)v25 - 7) = 1.0 - 1.0 / v26; - v28 = 1.0 / *(float *)v24; - v24 += 48; - v18 = pTex == (Texture *)1; - pTex = (Texture *)((char *)pTex - 1); - *((float *)v25 - 6) = v28; + for (uint i = 0; i < uNumVertices; ++i) + { + d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; + d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; + d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); + d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; + d3d_vertex_buffer[i].diffuse = uColor; + d3d_vertex_buffer[i].specular = 0; + d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; + d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; + } + //__debugbreak(); + //if ( (signed int)uNumVertices > 0 ) + //{ + //v23 = pTex; + //v24 = (char *)&array_507D30[0].vWorldViewPosition; + //v25 = (char *)&d3d_vertex_buffer[0].pos.y; + //pTex = (Texture *)uNumVertices; + //uint v18; + //do + //{ + //v26 = *(float *)v24 * 0.061758894; + //v27 = *((int *)v24 + 3); + //*((int *)v25 + 4) = 0; + //*((int *)v25 - 1) = v27; + //*(int *)v25 = *((int *)v24 + 4); + //*((int *)v25 + 3) = uColor; + //v25 += 32; + //*((float *)v25 - 7) = 1.0 - 1.0 / v26; + //v28 = 1.0 / *(float *)v24; + //v24 += 48; + //v18 = pTex == (Texture *)1; + //pTex = (Texture *)((char *)pTex - 1); + //*((float *)v25 - 6) = v28; //a3 = (BLVFace *)v23->uTextureWidth; - *((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; + //*((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; //a3 = (BLVFace *)v23->uTextureHeight; - *((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; - } - while ( !v18 ); - } + //*((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; + //} + //while ( !v18 ); + //} ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); @@ -7946,9 +7957,13 @@ d3d_vertex_buffer, uNumVertices, 28)); - ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1)); + + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); - v33 = uNumVertices; + + for (uint i = 0; i < uNumVertices; ++i) + d3d_vertex_buffer[i].diffuse = uCorrectedColor; + /*v33 = uNumVertices; if ( (signed int)uNumVertices > 0 ) { v34 = (char *)&d3d_vertex_buffer[0].diffuse; @@ -7959,7 +7974,7 @@ --v33; } while ( v33 ); - } + }*/ ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE));
--- a/mm7_1.cpp Thu Mar 07 09:14:57 2013 +0600 +++ b/mm7_1.cpp Thu Mar 07 09:15:15 2013 +0600 @@ -664,24 +664,23 @@ { result += awards_count; dword_506528 = result; - if ( (signed int)(awards_count + result) <= awards_count2 ) - goto LABEL_14; - result = awards_count2 - awards_count; - goto LABEL_13; + if ( (signed int)(awards_count + result) > awards_count2 ) + { + result = awards_count2 - awards_count; + dword_506528 = result; + } } - if ( dword_50651C > 0 ) + else if ( dword_50651C > 0 ) { result -= awards_count; dword_506528 = result; if ( (result & 0x80000000u) != 0 ) { result = 0; -LABEL_13: dword_506528 = result; - goto LABEL_14; } } -LABEL_14: +//LABEL_14: dword_506544 = 0; dword_506548 = 0; awards_count = 0; @@ -695,12 +694,71 @@ v20 = achievedAwardsIndex[v21]; v6 = (char *)pAwards[v20].pText;//(char *)dword_723E80_award_related[v20 / 4]; if ( v5 != 1 ) - break; - v17 = pParty->uFine; -LABEL_42: - sprintf(pTmpBuf, v6, v17); - v6 = pTmpBuf; -LABEL_43: + { + if (!( (v5 < 85 || v5 > 91) && (v5 < 103 || v5 > 104) )) + { + if ( v5 > 89 ) + { + if ( v5 == 90 ) + { + v10 = (unsigned __int8)pParty->uNumArenaKnightWins; + v22 = v10; + } + else if ( v5 == 91 ) + { + v10 = (unsigned __int8)pParty->uNumArenaLordWins; + v22 = v10; + } + else if ( v5 == 103 ) + { + v10 = pParty->field_874; + v22 = v10; + } + else if ( v5 == 104 ) + { + v10 = pParty->field_878; + v22 = v10; + } + } + else + { + if ( v5 == 89 ) + { + v10 = (unsigned __int8)pParty->uNumArenaSquireWins; + v22 = v10; + } + else if ( v5 == 85 ) + { + v10 = pParty->uNumDeaths; + v22 = v10; + } + else if ( v5 == 86 ) + { + v10 = pParty->uNumBountiesCollected; + v22 = v10; + } + else if ( v5 == 87 ) + { + v10 = pParty->uNumPrisonTerms; + v22 = v10; + } + else if ( v5 == 88) + { + v10 = (unsigned __int8)pParty->uNumArenaPageWins; + v22 = v10; + } + } + v17 = v22; + sprintf(pTmpBuf, v6, v17); + v6 = pTmpBuf; + } + } + else + { + v17 = pParty->uFine; + sprintf(pTmpBuf, v6, v17); + v6 = pTmpBuf; + } v14 = pAwards[v20].uSort;//dword_723E84[v20 / 4]; ++awards_count; v15 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat( @@ -720,70 +778,7 @@ } return; } - if ( (v5 < 85 || v5 > 91) && (v5 < 103 || v5 > 104) ) - goto LABEL_43; - if ( v5 > 89 ) - { - v11 = v5 - 90; - if ( !v11 ) - { - v10 = (unsigned __int8)pParty->uNumArenaKnightWins; - goto LABEL_40; - } - v12 = v11 - 1; - if ( !v12 ) - { - v10 = (unsigned __int8)pParty->uNumArenaLordWins; - goto LABEL_40; - } - v13 = v12 - 12; - if ( !v13 ) - { - v10 = pParty->field_874; - goto LABEL_40; - } - if ( v13 == 1 ) - { - v10 = pParty->field_878; - goto LABEL_40; - } - } - else - { - if ( v5 == 89 ) - { - v10 = (unsigned __int8)pParty->uNumArenaSquireWins; - goto LABEL_40; - } - v7 = v5 - 85; - if ( !v7 ) - { - v10 = pParty->uNumDeaths; - goto LABEL_40; - } - v8 = v7 - 1; - if ( !v8 ) - { - v10 = pParty->uNumBountiesCollected; - goto LABEL_40; - } - v9 = v8 - 1; - if ( !v9 ) - { - v10 = pParty->uNumPrisonTerms; - goto LABEL_40; - } - if ( v9 == 1 ) - { - v10 = (unsigned __int8)pParty->uNumArenaPageWins; -LABEL_40: - v22 = v10; - goto LABEL_41; - } - } -LABEL_41: - v17 = v22; - goto LABEL_42; + } return; } @@ -1205,7 +1200,8 @@ v7 = pIcons_LOD->LoadTexture("ib-cd1-d", TEXTURE_16BIT_PALETTE); pTexture = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0); pButton = pCharacterScreen_StatsBtn; - break; + pRenderer->DrawTextureIndexed(pButton->uX, pButton->uY, pTexture); + break; case WINDOW_CharacterWindow_Skills: // skills if ( dword_507CC0 != uActiveCharacter ) { @@ -1217,7 +1213,8 @@ v6 = pIcons_LOD->LoadTexture("ib-cd2-d", TEXTURE_16BIT_PALETTE); pTexture = (Texture *)(v6 != -1 ? (int)&pIcons_LOD->pTextures[v6] : 0); pButton = pCharacterScreen_SkillsBtn; - break; + pRenderer->DrawTextureIndexed(pButton->uX, pButton->uY, pTexture); + break; case WINDOW_CharacterWindow_Awards: // awards sub_4196A0(); sub_419379(); @@ -1226,20 +1223,20 @@ v5 = pIcons_LOD->LoadTexture("ib-cd4-d", TEXTURE_16BIT_PALETTE); pTexture = (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0); pButton = pCharacterScreen_AwardsBtn; + pRenderer->DrawTextureIndexed(pButton->uX, pButton->uY, pTexture); break; - default: // inventory and other - if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] != 103 ) - goto LABEL_13; + case WINDOW_CharacterWindow_Inventory: // inventory and other sub_4196A0(); sub_419379(); CharacterUI_InventoryTab_Draw(v1, 0); v2 = pIcons_LOD->LoadTexture("ib-cd3-d", TEXTURE_16BIT_PALETTE); pTexture = (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0); pButton = pCharacterScreen_InventoryBtn; + pRenderer->DrawTextureIndexed(pButton->uX, pButton->uY, pTexture); break; + default: + break; } - pRenderer->DrawTextureIndexed(pButton->uX, pButton->uY, pTexture); -LABEL_13: if ( bRingsShownInCharScreen ) CharacterUI_DrawPaperdollWithRingOverlay(v1); else @@ -1321,17 +1318,14 @@ if ( v5 <= (signed int)(signed __int64)(0.34 * v6) ) { v7 = uTextureID_mhp_red; -LABEL_9: v9 = v7; - goto LABEL_10; } - if ( v5 <= (signed int)(signed __int64)(v6 * 0.67) ) + else if ( v5 <= (signed int)(signed __int64)(v6 * 0.67) ) { v7 = uTextureID_mhp_yel; - goto LABEL_9; + v9 = v7; } } -LABEL_10: v8 = a2->uFrameX + (signed int)(a2->uFrameWidth - v4) / 2; pRenderer->Clip(v8, a2->uFrameY + 32, v8 + v4, a2->uFrameY + 52); pRenderer->DrawTextureIndexed( @@ -1386,61 +1380,59 @@ { v1 = &pParty->pPlayers[v16]; v11 = v1; - if ( v1->sHealth <= 0 ) - goto LABEL_24; - v11 = &pParty->pPlayers[v16]; - v2 = (double)v1->sHealth; - v3 = v2 / (double)v1->GetMaxHealth(); - if ( v3 <= 0.5 ) - { - if ( v3 <= 0.25 ) - { - if ( v3 <= 0.0 ) - goto LABEL_24; - if ( v16 == 2 || v16 == 3 ) - v17 = 2; - else - v17 = 0; - pRenderer->Clip( - v17 + pHealthBarPos[v16], - (unsigned __int64)(signed __int64)((1.0 - v3) * v15) + 402, - v17 + pHealthBarPos[v16] + v13->uTextureWidth, - v13->uTextureHeight + 402); - v9 = v13; - } - else - { - if ( v16 == 2 || v16 == 3 ) - v17 = 2; - else - v17 = 0; - pRenderer->Clip( - v17 + pHealthBarPos[v16], - (unsigned __int64)(signed __int64)((1.0 - v3) * v15) + 402, - v17 + pHealthBarPos[v16] + v14->uTextureWidth, - v14->uTextureHeight + 402); - v9 = v14; - } - } - else - { - if ( v3 > 1.0 ) - v3 = 1.0; - v4 = (signed __int64)((1.0 - v3) * v15); - if ( v16 == 2 || v16 == 3 ) - v17 = 2; - else - v17 = 0; - pRenderer->Clip( - v17 + pHealthBarPos[v16], - v4 + 402, - v17 + pHealthBarPos[v16] + v0->uTextureWidth, - v0->uTextureHeight + 402); - v9 = v0; - } - pRenderer->DrawTextureIndexed(v17 + pHealthBarPos[v16], 0x192u, v9); - pRenderer->ResetClip(); -LABEL_24: + if ( v1->sHealth > 0 ) + { + v11 = &pParty->pPlayers[v16]; + v2 = (double)v1->sHealth; + v3 = v2 / (double)v1->GetMaxHealth(); + if( v3 > 0.5 ) + { + if ( v3 > 1.0 ) + v3 = 1.0; + v4 = (signed __int64)((1.0 - v3) * v15); + if ( v16 == 2 || v16 == 3 ) + v17 = 2; + else + v17 = 0; + pRenderer->Clip( + v17 + pHealthBarPos[v16], + v4 + 402, + v17 + pHealthBarPos[v16] + v0->uTextureWidth, + v0->uTextureHeight + 402); + v9 = v0; + } + else if ( v3 > 0.25 ) + { + if ( v16 == 2 || v16 == 3 ) + v17 = 2; + else + v17 = 0; + pRenderer->Clip( + v17 + pHealthBarPos[v16], + (unsigned __int64)(signed __int64)((1.0 - v3) * v15) + 402, + v17 + pHealthBarPos[v16] + v14->uTextureWidth, + v14->uTextureHeight + 402); + v9 = v14; + } + else if ( v3 > 0.0 ) + { + if ( v16 == 2 || v16 == 3 ) + v17 = 2; + else + v17 = 0; + pRenderer->Clip( + v17 + pHealthBarPos[v16], + (unsigned __int64)(signed __int64)((1.0 - v3) * v15) + 402, + v17 + pHealthBarPos[v16] + v13->uTextureWidth, + v13->uTextureHeight + 402); + v9 = v13; + } + if( v3 > 0.0 ) + { + pRenderer->DrawTextureIndexed(v17 + pHealthBarPos[v16], 0x192u, v9); + pRenderer->ResetClip(); + } + } v5 = v11; v12 = v11->sMana; if ( v12 > 0 ) @@ -1939,214 +1931,241 @@ while ( 1 ) { v3 = pVisibleWindowsIdxs[v27] - 1; - if ( pWindowList[v3].field_44 == v1 ) - goto LABEL_47; - if ( v26 != 34 ) - break; - if ( pWindowList[v3].field_30 != v1 ) - { - pMouse->GetClickPos(&uClickX, &uClickY); - v4 = pWindowList[v3].pStartingPosActiveItem; - v29 = v4 + pWindowList[v3].pNumPresenceButton; - if ( v4 < v4 + pWindowList[v3].pNumPresenceButton ) - { - while ( 1 ) - { - v14 = pWindowList[v3].pControlsHead; - if ( v4 > 0 ) - { - v15 = v4; - do - { - v14 = v14->pNext; - --v15; - } - while ( v15 ); - } - if ( (signed int)uClickX >= (signed int)v14->uX - && (signed int)uClickX <= (signed int)v14->uZ - && (signed int)uClickY >= (signed int)v14->uY - && (signed int)uClickY <= (signed int)v14->uW ) - goto LABEL_66; - ++v4; - if ( v4 >= v29 ) - { -LABEL_45: - v1 = 0; - goto LABEL_46; - } - } - } - goto LABEL_46; - } -LABEL_47: + if ( pWindowList[v3].field_44 != v1 ) + { + switch(v26) + { + case VK_LEFT: + { + v12 = pWindowList[v3].field_34; + if ( pWindowList[v3].pCurrentPosActiveItem - pWindowList[v3].pStartingPosActiveItem - v12 >= 0 ) + { + v8 = pCurrentScreen == SCREEN_PARTY_CREATION; + pWindowList[v3].pCurrentPosActiveItem -= v12; + if ( v8 ) + { + pAudioPlayer->PlaySound(SOUND_Button, v1, v1, -1, v1, v1, v1, v1); + v2 = pMessageQueue_50CBD0->uNumMessages; + } + } + if ( pWindowList[v3].field_30 != v1 ) + { + break; + } + v9 = pWindowList[v3].pControlsHead; + v13 = pWindowList[v3].pCurrentPosActiveItem; + if ( v13 > (signed int)v1 ) + { + do + { + v9 = v9->pNext; + --v13; + } + while ( v13 ); + } + v11 = v9->uControlParam; + /*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); + break; + } + case VK_RIGHT: + { + v7 = pWindowList[v3].pCurrentPosActiveItem + pWindowList[v3].field_34; + if ( v7 < pWindowList[v3].pNumPresenceButton + pWindowList[v3].pStartingPosActiveItem ) + { + v8 = pCurrentScreen == SCREEN_PARTY_CREATION; + pWindowList[v3].pCurrentPosActiveItem = v7; + if ( v8 ) + { + pAudioPlayer->PlaySound(SOUND_Button, v1, v1, -1, v1, v1, v1, v1); + v2 = pMessageQueue_50CBD0->uNumMessages; + } + } + if ( pWindowList[v3].field_30 != v1 ) + { + break; + } + v9 = pWindowList[v3].pControlsHead; + v10 = pWindowList[v3].pCurrentPosActiveItem; + if ( v10 > (signed int)v1 ) + { + do + { + v9 = v9->pNext; + --v10; + } + while ( v10 ); + } + v11 = v9->uControlParam; + pMessageQueue_50CBD0->AddMessage((UIMessageType)v9->uControlID, v11, v1); + break; + } + case VK_DOWN: + { + v17 = pWindowList[v3].pStartingPosActiveItem; + v18 = pWindowList[v3].pCurrentPosActiveItem; + if ( v18 >= pWindowList[v3].pNumPresenceButton + v17 - 1 ) + pWindowList[v3].pCurrentPosActiveItem = v17; + else + pWindowList[v3].pCurrentPosActiveItem = v18 + 1; + if ( pWindowList[v3].field_30 != v1 ) + return 1; + v19 = pWindowList[v3].pControlsHead; + v20 = pWindowList[v3].pCurrentPosActiveItem; + if ( v20 > (signed int)v1 ) + { + do + { + v19 = v19->pNext; + --v20; + } + while ( v20 ); + } + v21 = v19->uControlParam; + pMessageQueue_50CBD0->AddMessage((UIMessageType)v19->uControlID, v21, v1); + return 1; + } + case VK_SELECT: + { + pMouse->GetClickPos(&uClickX, &uClickY); + v4 = pWindowList[v3].pStartingPosActiveItem; + v28 = v4 + pWindowList[v3].pNumPresenceButton; + if ( v4 < v4 + pWindowList[v3].pNumPresenceButton ) + { + while ( 1 ) + { + v5 = pWindowList[v3].pControlsHead; + if ( v4 > 0 ) + { + v6 = v4; + do + { + v5 = v5->pNext; + --v6; + } + while ( v6 ); + } + if ( (signed int)uClickX >= (signed int)v5->uX + && (signed int)uClickX <= (signed int)v5->uZ + && (signed int)uClickY >= (signed int)v5->uY + && (signed int)uClickY <= (signed int)v5->uW ) + break; + ++v4; + if ( v4 >= v28 ) + { + v1 = 0; + v2 = pMessageQueue_50CBD0->uNumMessages; + --v27; + if ( v27 < 0 ) + return 0; + continue; + } + } + pWindowList[v3].pCurrentPosActiveItem = v4; + return 1; + } + v2 = pMessageQueue_50CBD0->uNumMessages; + break; + } + case VK_UP: + { + v22 = pWindowList[v3].pCurrentPosActiveItem; + v23 = pWindowList[v3].pStartingPosActiveItem; + if ( v22 <= v23 ) + v24 = pWindowList[v3].pNumPresenceButton + v23 - 1; + else + v24 = v22 - 1; + v8 = pWindowList[v3].field_30 == v1; + pWindowList[v3].pCurrentPosActiveItem = v24; + if ( !v8 ) + return 1; + v19 = pWindowList[v3].pControlsHead; + v25 = pWindowList[v3].pCurrentPosActiveItem; + if ( v25 > (signed int)v1 ) + { + do + { + v19 = v19->pNext; + --v25; + } + while ( v25 ); + } + v21 = v19->uControlParam; + /*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; + } + case VK_NEXT: + { + if ( pWindowList[v3].field_30 != v1 ) + { + pMouse->GetClickPos(&uClickX, &uClickY); + v4 = pWindowList[v3].pStartingPosActiveItem; + v29 = v4 + pWindowList[v3].pNumPresenceButton; + if ( v4 < v4 + pWindowList[v3].pNumPresenceButton ) + { + while ( 1 ) + { + v14 = pWindowList[v3].pControlsHead; + if ( v4 > 0 ) + { + v15 = v4; + do + { + v14 = v14->pNext; + --v15; + } + while ( v15 ); + } + if ( (signed int)uClickX >= (signed int)v14->uX + && (signed int)uClickX <= (signed int)v14->uZ + && (signed int)uClickY >= (signed int)v14->uY + && (signed int)uClickY <= (signed int)v14->uW ) + { + pWindowList[v3].pCurrentPosActiveItem = v4; + return 1; + } + ++v4; + if ( v4 >= v29 ) + { + v1 = 0; + v2 = pMessageQueue_50CBD0->uNumMessages; + break; + } + } + } + else + { + v2 = pMessageQueue_50CBD0->uNumMessages; + } + } + break; + } + default: + { + break; + } + + } + } --v27; if ( v27 < 0 ) return 0; } - if ( v26 == 37 ) - { - v12 = pWindowList[v3].field_34; - if ( pWindowList[v3].pCurrentPosActiveItem - pWindowList[v3].pStartingPosActiveItem - v12 >= 0 ) - { - v8 = pCurrentScreen == SCREEN_PARTY_CREATION; - pWindowList[v3].pCurrentPosActiveItem -= v12; - if ( v8 ) - { - pAudioPlayer->PlaySound(SOUND_Button, v1, v1, -1, v1, v1, v1, v1); - v2 = pMessageQueue_50CBD0->uNumMessages; - } - } - if ( pWindowList[v3].field_30 != v1 ) - goto LABEL_47; - v9 = pWindowList[v3].pControlsHead; - v13 = pWindowList[v3].pCurrentPosActiveItem; - if ( v13 > (signed int)v1 ) - { - do - { - v9 = v9->pNext; - --v13; - } - while ( v13 ); - } -LABEL_26: - v11 = v9->uControlParam; - /*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 ) - { - if ( v26 == 39 ) - { - v7 = pWindowList[v3].pCurrentPosActiveItem + pWindowList[v3].field_34; - if ( v7 < pWindowList[v3].pNumPresenceButton + pWindowList[v3].pStartingPosActiveItem ) - { - v8 = pCurrentScreen == SCREEN_PARTY_CREATION; - pWindowList[v3].pCurrentPosActiveItem = v7; - if ( v8 ) - { - pAudioPlayer->PlaySound(SOUND_Button, v1, v1, -1, v1, v1, v1, v1); - v2 = pMessageQueue_50CBD0->uNumMessages; - } - } - if ( pWindowList[v3].field_30 != v1 ) - goto LABEL_47; - v9 = pWindowList[v3].pControlsHead; - v10 = pWindowList[v3].pCurrentPosActiveItem; - if ( v10 > (signed int)v1 ) - { - do - { - v9 = v9->pNext; - --v10; - } - while ( v10 ); - } - goto LABEL_26; - } - if ( v26 == 40 ) - { - v17 = pWindowList[v3].pStartingPosActiveItem; - v18 = pWindowList[v3].pCurrentPosActiveItem; - if ( v18 >= pWindowList[v3].pNumPresenceButton + v17 - 1 ) - pWindowList[v3].pCurrentPosActiveItem = v17; - else - pWindowList[v3].pCurrentPosActiveItem = v18 + 1; - if ( pWindowList[v3].field_30 != v1 ) - return 1; - v19 = pWindowList[v3].pControlsHead; - v20 = pWindowList[v3].pCurrentPosActiveItem; - if ( v20 > (signed int)v1 ) - { - do - { - v19 = v19->pNext; - --v20; - } - while ( v20 ); - } - goto LABEL_56; - } - if ( v26 == 41 ) - { - pMouse->GetClickPos(&uClickX, &uClickY); - v4 = pWindowList[v3].pStartingPosActiveItem; - v28 = v4 + pWindowList[v3].pNumPresenceButton; - if ( v4 < v4 + pWindowList[v3].pNumPresenceButton ) - { - while ( 1 ) - { - v5 = pWindowList[v3].pControlsHead; - if ( v4 > 0 ) - { - v6 = v4; - do - { - v5 = v5->pNext; - --v6; - } - while ( v6 ); - } - if ( (signed int)uClickX >= (signed int)v5->uX - && (signed int)uClickX <= (signed int)v5->uZ - && (signed int)uClickY >= (signed int)v5->uY - && (signed int)uClickY <= (signed int)v5->uW ) - break; - ++v4; - if ( v4 >= v28 ) - goto LABEL_45; - } -LABEL_66: - pWindowList[v3].pCurrentPosActiveItem = v4; - return 1; - } -LABEL_46: - v2 = pMessageQueue_50CBD0->uNumMessages; - goto LABEL_47; - } - goto LABEL_47; - } - v22 = pWindowList[v3].pCurrentPosActiveItem; - v23 = pWindowList[v3].pStartingPosActiveItem; - if ( v22 <= v23 ) - v24 = pWindowList[v3].pNumPresenceButton + v23 - 1; - else - v24 = v22 - 1; - v8 = pWindowList[v3].field_30 == v1; - pWindowList[v3].pCurrentPosActiveItem = v24; - if ( !v8 ) - return 1; - v19 = pWindowList[v3].pControlsHead; - v25 = pWindowList[v3].pCurrentPosActiveItem; - if ( v25 > (signed int)v1 ) - { - do - { - v19 = v19->pNext; - --v25; - } - while ( v25 ); - } -LABEL_56: - v21 = v19->uControlParam; - /*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; + } //----- (0041D20D) -------------------------------------------------------- @@ -2416,7 +2435,13 @@ v18 = v17 >> 1; v19 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x19u, 0x19u); wHintWindow.DrawTitleText(pFontArrus, 0x64u, ((signed int)wHintWindow.uFrameHeight >> 1) - v18, v19, pGlobalTXT_LocalizationStrings[32], 3); //"Broken Item" - goto LABEL_116; + pRenderer->ResetClip(); + if ( !areWeLoadingTexture ) + { + v73->Release(); + pIcons_LOD->_40F9C5(); + } + return; } if (!inspect_item->Identified()) { @@ -2434,7 +2459,13 @@ v18 = v17 >> 1; v19 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x19u, 0x19u); wHintWindow.DrawTitleText(pFontArrus, 0x64u, ((signed int)wHintWindow.uFrameHeight >> 1) - v18, v19, pGlobalTXT_LocalizationStrings[232], 3); - goto LABEL_116; + pRenderer->ResetClip(); + if ( !areWeLoadingTexture ) + { + v73->Release(); + pIcons_LOD->_40F9C5(); + } + return; } sprintfex(out_text, pGlobalTXT_LocalizationStrings[463], item_desc->pUnidentifiedName); //"Type: %s" @@ -2482,34 +2513,35 @@ } - if ( v77 ) - goto LABEL_65; - if (item_desc->uEquipType==EQUIP_POTION) - { - if ( inspect_item->uEnchantmentType ) - sprintf(out_text + 200, "%s: %d",pGlobalTXT_LocalizationStrings[449] , inspect_item->uEnchantmentType); //"Power" - } - else if (item_desc->uEquipType== EQUIP_REAGENT) - {sprintf(out_text + 200, "%s: %d", pGlobalTXT_LocalizationStrings[449], pItemsTable->pItems[inspect_item->uItemID].uDamageDice); //"Power" - } - else if ( inspect_item->uEnchantmentType ) - { - sprintf(out_text + 200, "%s: %s +%d", pGlobalTXT_LocalizationStrings[210], - pItemsTable->pEnchantments[inspect_item->uEnchantmentType-1].pBonusStat, inspect_item->_bonus_strength); //"Special" - } - else if ( inspect_item->uSpecEnchantmentType ) - { - sprintf(out_text + 200, "%s: %s", pGlobalTXT_LocalizationStrings[210], - pItemsTable->pSpecialEnchantments[inspect_item->uSpecEnchantmentType-1].pBonusStatement, inspect_item->_bonus_strength); - } + if ( !v77 ) + { + if (item_desc->uEquipType ==EQUIP_POTION) //this is CORRECT! do not move to switch! + { + if ( inspect_item->uEnchantmentType ) + sprintf(out_text + 200, "%s: %d",pGlobalTXT_LocalizationStrings[449] , inspect_item->uEnchantmentType); //"Power" + } + else if (item_desc->uEquipType == EQUIP_REAGENT) + { + sprintf(out_text + 200, "%s: %d", pGlobalTXT_LocalizationStrings[449], pItemsTable->pItems[inspect_item->uItemID].uDamageDice); //"Power" + } + + else if ( inspect_item->uEnchantmentType ) + { + sprintf(out_text + 200, "%s: %s +%d", pGlobalTXT_LocalizationStrings[210], + pItemsTable->pEnchantments[inspect_item->uEnchantmentType-1].pBonusStat, inspect_item->_bonus_strength); //"Special" + } + else if ( inspect_item->uSpecEnchantmentType ) + { + sprintf(out_text + 200, "%s: %s", pGlobalTXT_LocalizationStrings[210], + pItemsTable->pSpecialEnchantments[inspect_item->uSpecEnchantmentType-1].pBonusStatement, inspect_item->_bonus_strength); + } - else if ( inspect_item->uNumCharges ) - { - sprintf(out_text + 200, "%s: %lu", pGlobalTXT_LocalizationStrings[464], inspect_item->uNumCharges); //"Charges" - - } - -LABEL_65: + else if ( inspect_item->uNumCharges ) + { + sprintf(out_text + 200, "%s: %lu", pGlobalTXT_LocalizationStrings[464], inspect_item->uNumCharges); //"Charges" + + } + } wHintWindow.uFrameWidth -= 12; v85 = 3; wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1; @@ -2643,7 +2675,15 @@ else { if ( !(BYTE1(v38) & 2) ) - goto LABEL_116; + { + pRenderer->ResetClip(); + if ( !areWeLoadingTexture ) + { + v73->Release(); + pIcons_LOD->_40F9C5(); + } + return; + } v61 = 0; v56 = 0; v51 = 0; @@ -2657,7 +2697,6 @@ v41 = v39 + 132; } wHintWindow.DrawText(v40, v41, v42, v44, v47, v51, v56, v61); -LABEL_116: pRenderer->ResetClip(); if ( !areWeLoadingTexture ) { @@ -2792,7 +2831,7 @@ v3 = &pActors[v2]; v121 = v3; v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xFFu, 0x9Bu); - v5 = v3->uNPC_ID; + v5 = v3->sNPC_ID; a5 = v4; v6 = GetNPCData(v5); v7 = v3->pMonsterInfo.uID; @@ -3007,7 +3046,7 @@ if ( v36 >= 0 ) pSprites_LOD->pSpriteHeaders[v36]._4ACC38(&v106, 0); } - if ( v121->uNPC_ID ) + if ( v121->sNPC_ID ) { v37 = v112[6]; if ( v37 ) @@ -3029,7 +3068,7 @@ else v72 = pMonsterStats->pInfos[v121->pMonsterInfo.uID].pName; } - if(!v121->uNPC_ID || (v121->uNPC_ID && !v37)) + if(!v121->sNPC_ID || (v121->sNPC_ID && !v37)) strncpy(pTmpBuf, v72, v77); v39 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu); a1->DrawTitleText(pFontComic, 0, 0xCu, v39, pTmpBuf, 3u); @@ -3156,132 +3195,139 @@ v74 = 0; v69 = 0; v66 = pGlobalTXT_LocalizationStrings[630]; - goto LABEL_123; + a1->DrawText((GUIFont *)a2, 28, v50, a5, v66, v69, v74, v78); } - a4 = 0; - v51 = &v121->pActorBuffs[1]; - v222 = 0; - v120 = &v121->pActorBuffs[1]; - do + else { - if ( (signed __int64)v51->uExpireTime > 0 ) - { - switch ( (int)v51 ) - { - case 0u: - v124 = 60; - a4 = pGlobalTXT_LocalizationStrings[591]; - break; - case 1u: - v124 = 82; - a4 = pGlobalTXT_LocalizationStrings[649]; - break; - case 2u: - v124 = 92; - a4 = pGlobalTXT_LocalizationStrings[592]; - break; - case 3u: - v124 = 63; - a4 = pGlobalTXT_LocalizationStrings[4]; - break; - case 4u: - v52 = pGlobalTXT_LocalizationStrings[220]; - goto LABEL_100; - case 5u: - v52 = pGlobalTXT_LocalizationStrings[162]; -LABEL_100: - a4 = v52; - v124 = 81; - break; - case 6u: - v53 = pGlobalTXT_LocalizationStrings[593]; - v124 = 35; - goto LABEL_103; - case 8u: - v53 = pGlobalTXT_LocalizationStrings[608]; - v124 = 62; -LABEL_103: - a4 = v53; - break; - case 7u: - case 9u: - a4 = 0; - v124 = 0; - goto LABEL_119; - case 0xAu: - v124 = 47; - a4 = pGlobalTXT_LocalizationStrings[221]; - break; - case 0xBu: - v124 = 66; - a4 = pGlobalTXT_LocalizationStrings[607]; - break; - case 0xCu: - v124 = 85; - a4 = pGlobalTXT_LocalizationStrings[610]; - break; - case 0xDu: - v124 = 86; - a4 = pGlobalTXT_LocalizationStrings[609]; - break; - case 0xEu: - v124 = 17; - a4 = pGlobalTXT_LocalizationStrings[279]; - break; - case 0xFu: - v124 = 38; - a4 = pGlobalTXT_LocalizationStrings[442]; - break; - case 0x10u: - v124 = 46; - a4 = pGlobalTXT_LocalizationStrings[443]; - break; - case 0x11u: - v124 = 51; - a4 = pGlobalTXT_LocalizationStrings[440]; - break; - case 0x12u: - v124 = 5; - a4 = pGlobalTXT_LocalizationStrings[441]; - break; - case 0x13u: - v124 = 95; - a4 = pGlobalTXT_LocalizationStrings[229]; - break; - case 0x14u: - v124 = 73; - a4 = pGlobalTXT_LocalizationStrings[228]; - break; - default: - a4 = 0; - break; - } - if ( a4 ) - { - v54 = a4; - v55 = GetSpellColor(v124); - a1->DrawText((GUIFont *)a2, 28, v50, v55, v54, 0, 0, 0); - v50 = v50 + BYTE5(a2->pConditions[0]) - 3; - v51 = v120; - } - } -LABEL_119: - ++v51; - v222 = (IDirectDrawSurface *)((char *)v222 + 1); - v120 = v51; - - __debugbreak(); // fix condition - } - //while ( (signed int)((char *)&v222->lpVtbl + 1) < 22 ); - while (true); - if ( !a4 ) - { - v78 = 0; - v74 = 0; - v69 = 0; - v66 = pGlobalTXT_LocalizationStrings[153]; -LABEL_123: - a1->DrawText((GUIFont *)a2, 28, v50, a5, v66, v69, v74, v78); + a4 = 0; + v51 = &v121->pActorBuffs[1]; + v222 = 0; + v120 = &v121->pActorBuffs[1]; + do + { + if ( (signed __int64)v51->uExpireTime > 0 ) + { + switch ( (int)v51 ) + { + case 0u: + v124 = 60; + a4 = pGlobalTXT_LocalizationStrings[591]; + break; + case 1u: + v124 = 82; + a4 = pGlobalTXT_LocalizationStrings[649]; + break; + case 2u: + v124 = 92; + a4 = pGlobalTXT_LocalizationStrings[592]; + break; + case 3u: + v124 = 63; + a4 = pGlobalTXT_LocalizationStrings[4]; + break; + case 4u: + v52 = pGlobalTXT_LocalizationStrings[220]; + a4 = v52; + v124 = 81; + break; + case 5u: + v52 = pGlobalTXT_LocalizationStrings[162]; + a4 = v52; + v124 = 81; + break; + case 6u: + v53 = pGlobalTXT_LocalizationStrings[593]; + v124 = 35; + a4 = v53; + break; + case 8u: + v53 = pGlobalTXT_LocalizationStrings[608]; + v124 = 62; + a4 = v53; + break; + case 7u: + case 9u: + a4 = 0; + v124 = 0; + ++v51; + v222 = (IDirectDrawSurface *)((char *)v222 + 1); + v120 = v51; + __debugbreak(); // fix condition + continue; + case 0xAu: + v124 = 47; + a4 = pGlobalTXT_LocalizationStrings[221]; + break; + case 0xBu: + v124 = 66; + a4 = pGlobalTXT_LocalizationStrings[607]; + break; + case 0xCu: + v124 = 85; + a4 = pGlobalTXT_LocalizationStrings[610]; + break; + case 0xDu: + v124 = 86; + a4 = pGlobalTXT_LocalizationStrings[609]; + break; + case 0xEu: + v124 = 17; + a4 = pGlobalTXT_LocalizationStrings[279]; + break; + case 0xFu: + v124 = 38; + a4 = pGlobalTXT_LocalizationStrings[442]; + break; + case 0x10u: + v124 = 46; + a4 = pGlobalTXT_LocalizationStrings[443]; + break; + case 0x11u: + v124 = 51; + a4 = pGlobalTXT_LocalizationStrings[440]; + break; + case 0x12u: + v124 = 5; + a4 = pGlobalTXT_LocalizationStrings[441]; + break; + case 0x13u: + v124 = 95; + a4 = pGlobalTXT_LocalizationStrings[229]; + break; + case 0x14u: + v124 = 73; + a4 = pGlobalTXT_LocalizationStrings[228]; + break; + default: + a4 = 0; + break; + } + if ( a4 ) + { + v54 = a4; + v55 = GetSpellColor(v124); + a1->DrawText((GUIFont *)a2, 28, v50, v55, v54, 0, 0, 0); + v50 = v50 + BYTE5(a2->pConditions[0]) - 3; + v51 = v120; + } + } + + ++v51; + v222 = (IDirectDrawSurface *)((char *)v222 + 1); + v120 = v51; + + __debugbreak(); // fix condition + } + //while ( (signed int)((char *)&v222->lpVtbl + 1) < 22 ); + while (true); + if ( !a4 ) + { + v78 = 0; + v74 = 0; + v69 = 0; + v66 = pGlobalTXT_LocalizationStrings[153]; + a1->DrawText((GUIFont *)a2, 28, v50, a5, v66, v69, v74, v78); + } } v56 = pFontSmallnum; a4 = (char *)v106.uViewportY; @@ -3348,42 +3394,47 @@ v76 = 0; v71 = pGlobalTXT_LocalizationStrings[628]; v68 = "%s\f%05u\t080%s\n"; - goto LABEL_144; - } - v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[628]; - v59 = v121; - v114 = v121->pMonsterInfo.uSpell1ID; - if ( v114 && v121->pMonsterInfo.uSpell2ID ) - v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[629]; - if ( v114 ) - { - sprintf(pTmpBuf, "%s\f%05u\t060%s\n", v120, 0, pSpellStats->pInfos[v114].pShortName); - a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); - v58 = LOBYTE(v56->uFontHeight); - a4 = &a4[v58 - 3]; - v59 = v121; - } - v60 = v59->pMonsterInfo.uSpell2ID; - if ( v60 ) - { - sprintf(pTmpBuf, "\f%05u\t060%s\n", 0, pSpellStats->pInfos[v60].pShortName); - a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); - v58 = LOBYTE(v56->uFontHeight); - a4 = &a4[v58 - 3]; - v59 = v121; - } - if ( !v59->pMonsterInfo.uSpell1ID && !v59->pMonsterInfo.uSpell2ID ) - { - v80 = pGlobalTXT_LocalizationStrings[153]; - v76 = 0; - v71 = pGlobalTXT_LocalizationStrings[628]; - v68 = "%s\f%05u\t060%s\n"; -LABEL_144: sprintf(pTmpBuf, v68, v71, v76, v80); a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); v58 = LOBYTE(v56->uFontHeight); a4 = &a4[v58 - 3]; } + else + { + v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[628]; + v59 = v121; + v114 = v121->pMonsterInfo.uSpell1ID; + if ( v114 && v121->pMonsterInfo.uSpell2ID ) + v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[629]; + if ( v114 ) + { + sprintf(pTmpBuf, "%s\f%05u\t060%s\n", v120, 0, pSpellStats->pInfos[v114].pShortName); + a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); + v58 = LOBYTE(v56->uFontHeight); + a4 = &a4[v58 - 3]; + v59 = v121; + } + v60 = v59->pMonsterInfo.uSpell2ID; + if ( v60 ) + { + sprintf(pTmpBuf, "\f%05u\t060%s\n", 0, pSpellStats->pInfos[v60].pShortName); + a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); + v58 = LOBYTE(v56->uFontHeight); + a4 = &a4[v58 - 3]; + v59 = v121; + } + if ( !v59->pMonsterInfo.uSpell1ID && !v59->pMonsterInfo.uSpell2ID ) + { + v80 = pGlobalTXT_LocalizationStrings[153]; + v76 = 0; + v71 = pGlobalTXT_LocalizationStrings[628]; + v68 = "%s\f%05u\t060%s\n"; + sprintf(pTmpBuf, v68, v71, v76, v80); + a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); + v58 = LOBYTE(v56->uFontHeight); + a4 = &a4[v58 - 3]; + } + } a4 = &a4[v58 - 3]; a1->DrawText(v56, 150, (int)a4, a5, pGlobalTXT_LocalizationStrings[626], 0, 0, 0); a4 = &a4[LOBYTE(v56->uFontHeight) - 3]; @@ -3936,9 +3987,9 @@ else v3 = -1; v4 = pChests[chest_id].pInventoryIndices[v3] - 1; - if ( pItemsTable->pItems[pChests[chest_id].igChestItems[v4].uItemID].uEquipType == 18 ) + if ( pItemsTable->pItems[pChests[chest_id].igChestItems[v4].uItemID].uEquipType == EQUIP_GOLD ) { - party_finds_gold(pItemsTable->pItems[pChests[chest_id].igChestItems[v4].uItemID].uValue, 0); //recheck + party_finds_gold(pChests[chest_id].igChestItems[v4].uSpecEnchantmentType, 0); viewparams->bRedrawGameUI = 1; } else @@ -4286,9 +4337,131 @@ return; } v1 = uNumVisibleWindows; - if ( uNumVisibleWindows <= 0 ) + if ( uNumVisibleWindows > 0 ) { -LABEL_38: + while ( 1 ) // some other fullscreen ui + { + pWindow = &pWindowList[pVisibleWindowsIdxs[v1] - 1]; + if ( (signed int)pX >= (signed int)pWindow->uFrameX + && (signed int)pX <= (signed int)pWindow->uFrameZ + && (signed int)pY >= (signed int)pWindow->uFrameY + && (signed int)pY <= (signed int)pWindow->uFrameW ) + { + for ( pButton = pWindow->pControlsHead; ; pButton = pButton->pNext ) + { + if ( !pButton ) + break; + if ( pButton->uButtonType == 1 ) + { + if ( (signed int)pX >= (signed int)pButton->uX + && (signed int)pX <= (signed int)pButton->uZ + && (signed int)pY >= (signed int)pButton->uY + && (signed int)pY <= (signed int)pButton->uW ) + { + //LABEL_24: + pMessageType1 = (UIMessageType)pButton->field_1C; + if ( pMessageType1 ) + { + v12 = pButton->uControlParam; + 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; + //_set_status_and_ret: + sub_41C0B8_set_status_string(v13); + //LABEL_131: + uLastPointedObjectID = 1; + return; + } + } + else + { + if ( pButton->uButtonType == 2 ) + { + v45 = pX - pButton->uX; + v45 = pY - pButton->uY; + if ( (double)(signed int)pButton->uWidth != 0.0 ) + { + if ( (double)(signed int)pButton->uHeight != 0.0 ) + { + //UNDEF(v8); + //if ( v9 | v10 ) + //goto LABEL_24; + //{ + pMessageType1 = (UIMessageType)pButton->field_1C; + if ( pMessageType1 ) + { + v12 = pButton->uControlParam; + 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); + uLastPointedObjectID = 1; + return; + //} + } + } + } + else // click on skill + { + if ( pButton->uButtonType == 3 + && (signed int)pX >= (signed int)pButton->uX + && (signed int)pX <= (signed int)pButton->uZ + && (signed int)pY >= (signed int)pButton->uY + && (signed int)pY <= (signed int)pButton->uW ) + { + //LABEL_19: + pPlayer = pPlayers[uActiveCharacter]; + v5 = LOBYTE(pPlayer->pActiveSkills[pButton->uControlParam]); + v6 = pPlayer->uSkillPoints; + v7 = (v5 & 0x3F) + 1; + if ( v6 < v7 ) + { + v41 = v7 - v6; + v39 = pGlobalTXT_LocalizationStrings[469];// "You need %d more Skill Points to advance here" + } + else + { + v41 = v7; + v39 = pGlobalTXT_LocalizationStrings[468];// "Clicking here will spend %d Skill Points" + } + sprintf(Str1, v39, v41); + v13 = Str1; + //goto _set_status_and_ret; + sub_41C0B8_set_status_string(v13); + uLastPointedObjectID = 1; + return; + } + } + } + } + } + if ( pWindow->uFrameHeight == 480 ) + break; + --v1; + if ( v1 <= 0 ) + { + break; + } + } + } + if ( uNumVisibleWindows <= 0 || (uNumVisibleWindows > 0 && pWindow->uFrameHeight != 480 && v1 <= 0)) + { if ( pCurrentScreen == SCREEN_CHEST ) { sub_42038D(); @@ -4501,126 +4674,6 @@ uLastPointedObjectID = pMouse->uPointingObjectID; return; } - while ( 1 ) // some other fullscreen ui - { - pWindow = &pWindowList[pVisibleWindowsIdxs[v1] - 1]; - if ( (signed int)pX >= (signed int)pWindow->uFrameX - && (signed int)pX <= (signed int)pWindow->uFrameZ - && (signed int)pY >= (signed int)pWindow->uFrameY - && (signed int)pY <= (signed int)pWindow->uFrameW ) - { - for ( pButton = pWindow->pControlsHead; ; pButton = pButton->pNext ) - { - if ( !pButton ) - break; - if ( pButton->uButtonType == 1 ) - { - if ( (signed int)pX >= (signed int)pButton->uX - && (signed int)pX <= (signed int)pButton->uZ - && (signed int)pY >= (signed int)pButton->uY - && (signed int)pY <= (signed int)pButton->uW ) - { -//LABEL_24: - pMessageType1 = (UIMessageType)pButton->field_1C; - if ( pMessageType1 ) - { - v12 = pButton->uControlParam; - 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; -//_set_status_and_ret: - sub_41C0B8_set_status_string(v13); -//LABEL_131: - uLastPointedObjectID = 1; - return; - } - } - else - { - if ( pButton->uButtonType == 2 ) - { - v45 = pX - pButton->uX; - v45 = pY - pButton->uY; - if ( (double)(signed int)pButton->uWidth != 0.0 ) - { - if ( (double)(signed int)pButton->uHeight != 0.0 ) - { - //UNDEF(v8); - //if ( v9 | v10 ) - //goto LABEL_24; - //{ - pMessageType1 = (UIMessageType)pButton->field_1C; - if ( pMessageType1 ) - { - v12 = pButton->uControlParam; - 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); - uLastPointedObjectID = 1; - return; - //} - } - } - } - else // click on skill - { - if ( pButton->uButtonType == 3 - && (signed int)pX >= (signed int)pButton->uX - && (signed int)pX <= (signed int)pButton->uZ - && (signed int)pY >= (signed int)pButton->uY - && (signed int)pY <= (signed int)pButton->uW ) - { -//LABEL_19: - pPlayer = pPlayers[uActiveCharacter]; - v5 = LOBYTE(pPlayer->pActiveSkills[pButton->uControlParam]); - v6 = pPlayer->uSkillPoints; - v7 = (v5 & 0x3F) + 1; - if ( v6 < v7 ) - { - v41 = v7 - v6; - v39 = pGlobalTXT_LocalizationStrings[469];// "You need %d more Skill Points to advance here" - } - else - { - v41 = v7; - v39 = pGlobalTXT_LocalizationStrings[468];// "Clicking here will spend %d Skill Points" - } - sprintf(Str1, v39, v41); - v13 = Str1; - //goto _set_status_and_ret; - sub_41C0B8_set_status_string(v13); - uLastPointedObjectID = 1; - return; - } - } - } - } - } - if ( pWindow->uFrameHeight == 480 ) - break; - --v1; - if ( v1 <= 0 ) - { - goto LABEL_38; - } - } } @@ -4842,14 +4895,13 @@ if (!player->CanAct()) { - if ( pPlayers[uActiveCharacter]->CanAct()) - goto LABEL_9; player = pPlayers[uActiveCharacter]; } - player->PlaySound(SPEECH_NoRoom, 0); + if(player->CanAct() || !pPlayers[uActiveCharacter]->CanAct()) + player->PlaySound(SPEECH_NoRoom, 0); } -LABEL_9: +//LABEL_9: if (pCurrentScreen == SCREEN_GAME) { viewparams->bRedrawGameUI = true; @@ -5009,7 +5061,8 @@ memcpy(&pParty->pPickedItem, &v0->pInventoryItems[v8-1], sizeof(pParty->pPickedItem)); v0->RemoveItemAtInventoryIndex(a4); v9 = pParty->pPickedItem.uItemID; - goto LABEL_24; + pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); + return; } v13 = v8; if ( v8 ) @@ -5030,7 +5083,6 @@ } v9 = this_.uItemID; memcpy(&pParty->pPickedItem, &this_, sizeof(pParty->pPickedItem)); -LABEL_24: pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); return; } @@ -5116,7 +5168,10 @@ SpriteObject::OnInteraction(a2.y); return; } - goto LABEL_13; + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + return; + goto LABEL_14; } if ( (v0 & 7) != OBJECT_Actor) { @@ -5124,7 +5179,12 @@ { v13 = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[v13->uDecorationDescID].uRadius) >= 512 ) - goto LABEL_13; + { + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + return; + goto LABEL_14; + } v14 = v13->field_16_event_id; if ( !v14 ) { @@ -5142,7 +5202,12 @@ else { if ( (v0 & 7) != OBJECT_BModel || (unsigned int)v0 >= 0x2000000 ) - goto LABEL_13; + { + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + return; + goto LABEL_14; + } v2 = (signed int)(unsigned __int16)v0 >> 3; if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) { @@ -5150,61 +5215,61 @@ if ( !(v3->uAttributes & 0x2000000) ) { LABEL_11: - v4 = pParty->pPickedItem.uItemID; - if ( pParty->pPickedItem.uItemID ) - { + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + { + ShowNothingHereStatus(); + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + return; + } LABEL_14: - v5 = pItemsTable->pItems[v4].uSpriteID; - v6 = 0; - a1.uType = v5; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_18: - LOWORD(v6) = 0; - } - else - { - v7 = (char *)&pObjectList->pObjects->uObjectID; - while ( v5 != *(short *)v7 ) - { - ++v6; - v7 += 56; - if ( v6 >= (signed int)pObjectList->uNumObjects ) - goto LABEL_18; - } - } - a1.uObjectDescID = v6; - a1.vPosition.y = pParty->vPosition.y; - a1.field_58_pid = OBJECT_Player; - a1.vPosition.x = pParty->vPosition.x; - a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; - a1.uSoundID = 0; - a1.uFacing = 0; - a1.uAttributes = 8; - a1.uSectorID = pIndoor->GetSector( - pParty->vPosition.x, - pParty->vPosition.y, - pParty->sEyelevel + pParty->vPosition.z); - a1.uSpriteFrameID = 0; - memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); - v8 = (int *)pMouse->GetCursorPos(&v25); - v9 = UnprojectX(*v8); - a1.Create(pParty->sRotationY + v9, 184, 200, 0); - v10 = pIcons_LOD->LoadTexture( - pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, - TEXTURE_16BIT_PALETTE); - if (v10 != -1) - pIcons_LOD->pTextures[v10].Release(); - pMouse->RemoveHoldingItem(); - pIcons_LOD->_40F9C5(); - return; - } - ShowNothingHereStatus(); -LABEL_13: - v4 = pParty->pPickedItem.uItemID; - if ( !pParty->pPickedItem.uItemID ) - return; - goto LABEL_14; + v5 = pItemsTable->pItems[v4].uSpriteID; + v6 = 0; + a1.uType = v5; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + { + LOWORD(v6) = 0; + } + else + { + v7 = (char *)&pObjectList->pObjects->uObjectID; + while ( v5 != *(short *)v7 ) + { + ++v6; + v7 += 56; + if ( v6 >= (signed int)pObjectList->uNumObjects ) + { + LOWORD(v6) = 0; + break; + } + } + } + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.field_58_pid = OBJECT_Player; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + a1.uSectorID = pIndoor->GetSector( + pParty->vPosition.x, + pParty->vPosition.y, + pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); + v8 = (int *)pMouse->GetCursorPos(&v25); + v9 = UnprojectX(*v8); + a1.Create(pParty->sRotationY + v9, 184, 200, 0); + v10 = pIcons_LOD->LoadTexture( + pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, + TEXTURE_16BIT_PALETTE); + if (v10 != -1) + pIcons_LOD->pTextures[v10].Release(); + pMouse->RemoveHoldingItem(); + pIcons_LOD->_40F9C5(); + return; } v11 = pIndoor->pFaceExtras[v3->uFaceExtraID].uEventID; } @@ -5229,19 +5294,27 @@ stru_50C198.LootActor(&pActors[v16]); return; } - goto LABEL_13; + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + return; + goto LABEL_14; } if ( GetAsyncKeyState(VK_SHIFT) >= 0 ) { if ( !v17->GetActorsRelation(0) && !(BYTE2(v17->uAttributes) & 8) ) { if ( (unsigned int)v0 >= 0x2000000 ) - goto LABEL_13; + { + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + return; + goto LABEL_14; + } if ( !v17->CanAct() ) return; v18 = a2.y; Actor::FaceObject(a2.y, 4u, 0, 0); - if ( !v17->uNPC_ID ) + if ( !v17->sNPC_ID ) { v19 = pNPCStats->pGroups_copy[v17->uGroup]; if ( v19 )
--- a/mm7_2.cpp Thu Mar 07 09:14:57 2013 +0600 +++ b/mm7_2.cpp Thu Mar 07 09:15:15 2013 +0600 @@ -3172,7 +3172,7 @@ ++pMessageQueue_50CBD0->uNumMessages; }*/ dword_50C9DC = 195; - ptr_50C9E0 = GetNPCData(uDialogue_SpeakingActorNPC_ID); + ptr_50C9E0 = GetNPCData(sDialogue_SpeakingActorNPC_ID); return 0; } if ( a1 == 42 ) @@ -3247,7 +3247,8 @@ v22 = 0; v21 = (SoundID)11090; } - goto LABEL_40; + pAudioPlayer->PlaySound(v21, v22, v23, v24, v25, v27, v29, v31); + return 0; } if ( a1 == 10 ) { @@ -3828,37 +3829,31 @@ { //v3 = p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C]; v3 = p2DEvents[window_SpeakInHouse->par1C - 1].uType; - if ( v3 < 5 ) - goto LABEL_12; - if ( v3 <= 13 ) - { - v0 = rand() % word_4F0F30[(signed int)v1] - //+ 11 * p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C] - + 11 * p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType - + 345; - } - else - { - if ( v3 == 14 ) - { - v4 = rand() % 4; - } - else - { - if ( v3 == 15 ) - { - v4 = rand() % 3 + 4; - } - else - { - if ( v3 != 16 ) - goto LABEL_12; - v4 = rand() % 2 + 7; - } - } - v0 = rand() % word_4F0F30[(signed int)v1] + 11 * v4 + 400; - } -LABEL_12: + if ( v3 >= 5 ) + { + if ( v3 <= 13 ) + { + v0 = rand() % word_4F0F30[(signed int)v1] + //+ 11 * p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C] + + 11 * p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType + + 345; + } + else + { + if ( v3 == 14 ) + { + v4 = rand() % 4; + } + else if ( v3 == 15 ) + { + v4 = rand() % 3 + 4; + } + else if ( v3 == 16 ) + v4 = rand() % 2 + 7; + if( v3 <= 16 ) + v0 = rand() % word_4F0F30[(signed int)v1] + 11 * v4 + 400; + } + } if ( v0 == 487 ) { if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 239) ) @@ -3958,58 +3953,72 @@ pRenderer->ClearZBuffer(0, 479); //v3 = dword_F8B198; if ( dword_F8B19C != 1 ) - goto LABEL_13; - if ( in_current_building_type == BildingType_Training ) - { - if ( uMessageParam == 17 ) - { - v4 = 0; - v5 = 0; - //v6 = pPlayers[uActiveCharacter]; - //v7 = pPlayers[uActiveCharacter]->uLevel; - if ( pPlayers[uActiveCharacter]->uLevel > 0 ) - { - do - v4 += v5++ + 1; - while ( v5 < pPlayers[uActiveCharacter]->uLevel ); - } - if ( pPlayers[uActiveCharacter]->uLevel < (unsigned __int16)word_4F0866[(unsigned int)window_SpeakInHouse->ptr_1C] - && (signed __int64)pPlayers[uActiveCharacter]->uExperience < 1000 * v4 ) - return; - } - goto LABEL_9; - } - v8 = window_SpeakInHouse; - if ( (in_current_building_type == BildingType_Stables || in_current_building_type == BildingType_Boats) - && (v1 = 0, *(&byte_4F09B1[32 * (unsigned __int8)*(&byte_4F0CCF[4 * (unsigned int)window_SpeakInHouse->ptr_1C] + uMessageParam)] + pParty->uDaysPlayed % 7)) - || in_current_building_type != BildingType_Temple || uMessageParam != BildingType_MindGuild ) - { -LABEL_9: - pDialogueWindow->Release(); - pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, v1, v1); - pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, v1, 0x71u, v1, v1, pGlobalTXT_LocalizationStrings[74],// "End Conversation" - (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), v1); - pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, v1, 0x51u, v1, v1, "", (Texture *)v1); -LABEL_10: - //v3 = dword_F8B198; - v8 = window_SpeakInHouse; - goto LABEL_11; - } - if ( uActiveCharacter != v1 ) - { - if ( !pPlayers[uActiveCharacter]->_4B6FF9() ) - return; - goto LABEL_10; - } -LABEL_11: - dword_F8B19C = uMessageParam; - if ( in_current_building_type < BildingType_19 ) - { - v9 = pIcons_LOD->LoadTexture(off_4F03B8[in_current_building_type], TEXTURE_16BIT_PALETTE); - //v3 = dword_F8B198; - ShopTexture = &pIcons_LOD->pTextures[v9]; -LABEL_13: - v8 = window_SpeakInHouse; + { + v8 = window_SpeakInHouse; + } + else + { + if ( in_current_building_type == BildingType_Training ) + { + if ( uMessageParam == 17 ) + { + v4 = 0; + v5 = 0; + //v6 = pPlayers[uActiveCharacter]; + //v7 = pPlayers[uActiveCharacter]->uLevel; + if ( pPlayers[uActiveCharacter]->uLevel > 0 ) + { + do + v4 += v5++ + 1; + while ( v5 < pPlayers[uActiveCharacter]->uLevel ); + } + if ( pPlayers[uActiveCharacter]->uLevel < (unsigned __int16)word_4F0866[(unsigned int)window_SpeakInHouse->ptr_1C] + && (signed __int64)pPlayers[uActiveCharacter]->uExperience < 1000 * v4 ) + return; + } + pDialogueWindow->Release(); + pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, v1, v1); + pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, v1, 0x71u, v1, v1, pGlobalTXT_LocalizationStrings[74],// "End Conversation" + (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), v1); + pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, v1, 0x51u, v1, v1, "", (Texture *)v1); +// LABEL_10: + //v3 = dword_F8B198; + v8 = window_SpeakInHouse; + } + else + { + v8 = window_SpeakInHouse; + if ( (in_current_building_type == BildingType_Stables || in_current_building_type == BildingType_Boats) + && (v1 = 0, *(&byte_4F09B1[32 * (unsigned __int8)*(&byte_4F0CCF[4 * (unsigned int)window_SpeakInHouse->ptr_1C] + uMessageParam)] + pParty->uDaysPlayed % 7)) + || in_current_building_type != BildingType_Temple || uMessageParam != BildingType_MindGuild ) + { + //LABEL_9: + pDialogueWindow->Release(); + pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, v1, v1); + pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, v1, 0x71u, v1, v1, pGlobalTXT_LocalizationStrings[74],// "End Conversation" + (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), v1); + pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, v1, 0x51u, v1, v1, "", (Texture *)v1); + // LABEL_10: + //v3 = dword_F8B198; + v8 = window_SpeakInHouse; + } + else if ( uActiveCharacter != v1 ) + { + if ( !pPlayers[uActiveCharacter]->_4B6FF9() ) + return; + v8 = window_SpeakInHouse; + } + } + //LABEL_11: + dword_F8B19C = uMessageParam; + if ( in_current_building_type < BildingType_19 ) + { + v9 = pIcons_LOD->LoadTexture(off_4F03B8[in_current_building_type], TEXTURE_16BIT_PALETTE); + //v3 = dword_F8B198; + ShopTexture = &pIcons_LOD->pTextures[v9]; + //LABEL_13: + v8 = window_SpeakInHouse; + } } if ( in_current_building_type > BildingType_Tavern ) { @@ -4263,12 +4272,10 @@ v1 = 0; dword_F8B1A4 = pNPCTopics[352].pText; } - goto LABEL_196; - } - if ( uMessageParam == 100 ) + } + else if ( uMessageParam == 100 ) { pKeyActionMap->EnterText(1, 10, v8); - goto LABEL_196; } } } @@ -4527,7 +4534,7 @@ if ( v0 == -1 ) { _4B4224_UpdateNPCTopics((int)((char *)pDialogueNPCCount - 1)); -LABEL_33: +//LABEL_33: pVideoPlayer->_4BF5B2(); return 1; } @@ -4544,7 +4551,7 @@ if ( v0 != 102 && v0 != 103 && v0 != 104 ) { pVideoPlayer->_4BF5B2(); -LABEL_28: +//LABEL_28: dword_F8B19C = 1; sub_4B3B42(in_current_building_type); return 1; @@ -4558,7 +4565,9 @@ } pVideoPlayer->_4BF5B2(); UI_CreateEndConversationButton(); - goto LABEL_28; + dword_F8B19C = 1; + sub_4B3B42(in_current_building_type); + return 1; } pDialogueNPCCount = 0; pDialogueWindow->Release(); @@ -4583,7 +4592,8 @@ } while ( (signed int)v2 < uNumDialogueNPCPortraits ); } - goto LABEL_33; + pVideoPlayer->_4BF5B2(); + return 1; } } return 0; @@ -4682,7 +4692,10 @@ v0 = pPlayers[uActiveCharacter]; v77 = pPlayers[uActiveCharacter]; if ( pCurrentScreen == SCREEN_E ) - goto LABEL_73; + { + sub_421EA6_OnInventoryLeftClick(); + return; + } if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) { v56 = 0; @@ -4692,7 +4705,8 @@ v48 = -1; v47 = 0; v46 = 0; - goto LABEL_87; + pAudioPlayer->PlaySound(SOUND_27, v46, v47, v48, v49, v50, v52, v56); + return; } if ( dword_F8B19C > 18 ) { @@ -4719,14 +4733,17 @@ v55 = 4; else v55 = 2; - goto LABEL_84; + HousePlaySomeSound((unsigned int)v13, v55); + return; } Party::TakeGold(v44); v53 = 0; dword_F8B1E4 = 1; *pSkill = 1; v51 = 78; - goto LABEL_80; + v27 = v0; + v27->PlaySound((PlayerSpeech)v51, v53); + return; } } return; @@ -4738,7 +4755,7 @@ goto LABEL_49; } pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; -LABEL_73: +//LABEL_73: sub_421EA6_OnInventoryLeftClick(); return; } @@ -4760,11 +4777,12 @@ if ( pParty->uNumGold < v23 ) { v24 = 2; -LABEL_62: +//LABEL_62: HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, v24); v9 = pGlobalTXT_LocalizationStrings[155]; v54 = 2; - goto LABEL_71; + ShowStatusBarString(v9, v54); + return; } v25 = v0->AddItem(0xFFFFFFFFu, v20->uItemID); if ( v25 ) @@ -4772,13 +4790,23 @@ v26 = 1; v20->SetIdentified(); memcpy(&v0->pInventoryItems[v25-1], v20, 0x24u); - goto LABEL_42; + dword_F8B1E4 = v26; + Party::TakeGold(v80); + viewparams->bRedrawGameUI = v26; + _this->Reset(); + pRenderer->ClearZBuffer(0, 479); + v27 = v77; + v53 = 0; + v51 = SPEECH_75; + v27->PlaySound((PlayerSpeech)v51, v53); + return; } v0->PlaySound(SPEECH_NoRoom, 0); v54 = 5; -LABEL_70: +//LABEL_70: v9 = pGlobalTXT_LocalizationStrings[563]; // "Pack is Full!" - goto LABEL_71; + ShowStatusBarString(v9, v54); + return; } if ( dword_F8B19C == 2 ) { @@ -4832,7 +4860,13 @@ if ( uNumSeconds != 2 ) { if ( uNumSeconds != 1 ) - goto LABEL_62; + { + HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, v24); + v9 = pGlobalTXT_LocalizationStrings[155]; + v54 = 2; + ShowStatusBarString(v9, v54); + return; + } } } v39 = v0->AddItem(0xFFFFFFFFu, v32->uItemID); @@ -4851,27 +4885,36 @@ { *(char *)(v40 + 517) |= 1u; sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, v41, a6); - goto LABEL_43; - } - } - } -LABEL_42: + viewparams->bRedrawGameUI = v26; + _this->Reset(); + pRenderer->ClearZBuffer(0, 479); + v27 = v77; + v53 = 0; + v51 = SPEECH_75; + v27->PlaySound((PlayerSpeech)v51, v53); + return; + } + } + } +//LABEL_42: dword_F8B1E4 = v26; Party::TakeGold(v80); -LABEL_43: +//LABEL_43: viewparams->bRedrawGameUI = v26; _this->Reset(); pRenderer->ClearZBuffer(0, 479); v27 = v77; v53 = 0; v51 = SPEECH_75; -LABEL_81: +//LABEL_81: v27->PlaySound((PlayerSpeech)v51, v53); return; } v0->PlaySound(SPEECH_NoRoom, 0); v54 = 2; - goto LABEL_70; + v9 = pGlobalTXT_LocalizationStrings[563]; // "Pack is Full!" + ShowStatusBarString(v9, v54); + return; } if ( dword_F8B19C == 3 ) { @@ -4890,8 +4933,10 @@ pRenderer->ClearZBuffer(0, 479); v53 = 0; v51 = 77; - goto LABEL_80; - } + v27 = v0; + v27->PlaySound((PlayerSpeech)v51, v53); + return; + } v0->PlaySound(SPEECH_79, 0); v56 = 0; v52 = 0; @@ -4900,7 +4945,7 @@ v48 = -1; v47 = 0; v46 = 0; -LABEL_87: +//LABEL_87: pAudioPlayer->PlaySound(SOUND_27, v46, v47, v48, v49, v50, v52, v56); return; } @@ -4930,19 +4975,29 @@ *(int *)(v12 + 20) |= 1u; v0->PlaySound(SPEECH_73, 0); v9 = pGlobalTXT_LocalizationStrings[569]; - goto LABEL_25; + v54 = 2; + ShowStatusBarString(v9, v54); + return; } - goto LABEL_26; + v13 = _this; + v55 = 2; + HousePlaySomeSound((unsigned int)v13, v55); + return; } pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); v53 = 0; - goto LABEL_28; + v51 = 79; + v27 = v0; + v27->PlaySound((PlayerSpeech)v51, v53); + return; } v53 = 0; -LABEL_30: +//LABEL_30: v51 = 76; - goto LABEL_80; - } + v27 = v0; + v27->PlaySound((PlayerSpeech)v51, v53); + return; + } } } } @@ -4983,30 +5038,34 @@ *(int *)(v3 + 20) = v8 | 1; v0->PlaySound(SPEECH_74, 0); v9 = pGlobalTXT_LocalizationStrings[570]; -LABEL_25: +//LABEL_25: v54 = 2; -LABEL_71: +//LABEL_71: ShowStatusBarString(v9, v54); return; } -LABEL_26: +//LABEL_26: v13 = _this; v55 = 2; -LABEL_84: +//LABEL_84: HousePlaySomeSound((unsigned int)v13, v55); return; } pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); v53 = 0; -LABEL_28: +//LABEL_28: v51 = 79; -LABEL_80: +//LABEL_80: v27 = v0; - goto LABEL_81; + v27->PlaySound((PlayerSpeech)v51, v53); + return; } v53 = 0; - goto LABEL_30; - } + v51 = 76; + v27 = v0; + v27->PlaySound((PlayerSpeech)v51, v53); + return; + } } } } @@ -5130,15 +5189,26 @@ *v2 = v5; if ( !v5 ) { -LABEL_23: +//LABEL_23: *v2 = 0; break; } if ( v5 == ',' ) { if ( v3 ) - goto LABEL_18; - *v2 = 0; + { + if ( v4 ) + { + stru_F8B5E8.pProperties[stru_F8B5E8.field_0] = v2; + ++stru_F8B5E8.field_0; + } + v4 = 0; + } + else + { + *v2 = 0; + v4 = 1; + } } else { @@ -5161,35 +5231,50 @@ ++stru_F8B5E8.field_0; } } - goto LABEL_21; - } -LABEL_18: - if ( v4 ) - { - stru_F8B5E8.pProperties[stru_F8B5E8.field_0] = v2; - ++stru_F8B5E8.field_0; - } - v4 = 0; - goto LABEL_21; - } - if ( v3 ) - goto LABEL_18; - *v2 = 0; - if ( v4 ) - { - stru_F8B5E8.pProperties[stru_F8B5E8.field_0] = v2; - ++stru_F8B5E8.field_0; - } - } - v4 = 1; -LABEL_21: + } + else + { +//LABEL_18: + if ( v4 ) + { + stru_F8B5E8.pProperties[stru_F8B5E8.field_0] = v2; + ++stru_F8B5E8.field_0; + } + v4 = 0; + } + } + else + { + if ( v3 ) + { + if ( v4 ) + { + stru_F8B5E8.pProperties[stru_F8B5E8.field_0] = v2; + ++stru_F8B5E8.field_0; + } + v4 = 0; + } + else + { + *v2 = 0; + if ( v4 ) + { + stru_F8B5E8.pProperties[stru_F8B5E8.field_0] = v2; + ++stru_F8B5E8.field_0; + } + v4 = 1; + } + } + } +//LABEL_21: if ( stru_F8B5E8.field_0 < 30 ) { ++v2; if ( (unsigned int)v2 < (unsigned int)&unk_F8B5E0 ) continue; } - goto LABEL_23; + *v2 = 0; + break; } } result = a2; @@ -11212,7 +11297,7 @@ signed int v20; // [sp+18h] [bp-44h]@14 int v21[16]; // [sp+1Ch] [bp-40h]@17 - sub_450218_prolly_generate_chests_loot(); + GenerateItemsInChest(); //v0 = pGameLoadingUI_ProgressBar; pGameLoadingUI_ProgressBar->Progress(); pParty->uFlags |= 2u; @@ -11238,30 +11323,30 @@ v4 = (v3 - 1) % 3; if ( 2 == v4 ) { - if ( pActor->uNPC_ID && pActor->uNPC_ID < 5000 ) + if ( pActor->sNPC_ID && pActor->sNPC_ID < 5000 ) continue; } else { if ( v4 != 1 ) { - if ( v4 != 0 || pActor->uNPC_ID ) + if ( v4 != 0 || pActor->sNPC_ID ) continue; goto LABEL_12; } } - if ( pActor->uNPC_ID > 0 && pActor->uNPC_ID < 5000 ) + if ( pActor->sNPC_ID > 0 && pActor->sNPC_ID < 5000 ) continue; if ( v17 ) { pNPCStats->InitializeAdditionalNPCs(&pNPCStats->pAdditionalNPC[pNPCStats->uNewlNPCBufPos], v3, 0, v19); v14 = LOWORD(pNPCStats->uNewlNPCBufPos) + 5000; ++pNPCStats->uNewlNPCBufPos; - pActor->uNPC_ID = v14; + pActor->sNPC_ID = v14; continue; } LABEL_12: - pActor->uNPC_ID = 0; + pActor->sNPC_ID = 0; //LABEL_13: //++v15; //v2 += 836; @@ -11616,8 +11701,6 @@ pIcons_LOD->_4114F2(); } - - //----- (004637EB) -------------------------------------------------------- int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam) { @@ -13166,7 +13249,7 @@ if ( ReadWindowsRegistryInt("Bloodsplats", 1) ) pGame->uFlags2 |= GAME_FLAGS_2_DRAW_BLOODSPLATS; else - pGame->uFlags2 &= ~GAME_FLAGS_2_DRAW_BLOODSPLATS; + pGame->uFlags2 &= GAME_FLAGS_2_DRAW_BLOODSPLATS; uTurnSpeed = ReadWindowsRegistryInt("TurnDelta", 0); dword_6BE384_2dacceloff = ReadWindowsRegistryInt("2dacceloff", 0); @@ -15370,7 +15453,7 @@ if ( !v13->GetActorsRelation(0) && !(BYTE2(v13->uAttributes) & 8) && v13->CanAct() ) { Actor::FaceObject(v12, 4u, 0, 0); - if ( v13->uNPC_ID ) + if ( v13->sNPC_ID ) { pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v12, 0); /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
--- a/mm7_3.cpp Thu Mar 07 09:14:57 2013 +0600 +++ b/mm7_3.cpp Thu Mar 07 09:15:15 2013 +0600 @@ -13310,8 +13310,8 @@ //----- (00443E31) -------------------------------------------------------- -void __cdecl LoadLevel_InitializeLevelStr() -{ +void LoadLevel_InitializeLevelStr() + { char Args[100]; int string_num; @@ -13417,10 +13417,7 @@ if (_evt->_e_type == EVENT_PlaySound) { - pSoundList->LoadSound( - _evt->v5 + - ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8), - 0); + pSoundList->LoadSound(EVT_DWORD(_evt->v5), 0); } else if (_evt->_e_type == EVENT_OnMapReload) { @@ -14125,8 +14122,8 @@ if ( !pDialogueWindow ) return; memcpy(&v51, pDialogueWindow, sizeof(v51)); - pNPC = GetNPCData(uDialogue_SpeakingActorNPC_ID); - v1 = sub_445C8B(uDialogue_SpeakingActorNPC_ID); + pNPC = GetNPCData(sDialogue_SpeakingActorNPC_ID); + v1 = sub_445C8B(sDialogue_SpeakingActorNPC_ID); v51.uFrameWidth -= 10; v51.uFrameZ -= 10; //v54 = v1; @@ -14426,7 +14423,7 @@ } //----- (004459F9) -------------------------------------------------------- -NPCData *__fastcall GetNPCData(unsigned int npcid) +NPCData *__fastcall GetNPCData(signed int npcid) { unsigned int v1; // esi@1 NPCData *result; // eax@5 @@ -14463,13 +14460,13 @@ } if ( (signed int)npcid >= 5000 ) return &pNPCStats->array_13EF4[npcid - 5000]; - if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 ) + if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 ) { result = 0; } else { - v3 = abs((int)uDialogue_SpeakingActorNPC_ID) - 1; + v3 = abs((int)sDialogue_SpeakingActorNPC_ID) - 1; v4 = 0; v5 = 0; v6 = pParty->pHirelings; @@ -14521,16 +14518,16 @@ if ( npcid >= 5000 ) return &pNPCStats->pAdditionalNPC[npcid - 5000]; - if (uDialogue_SpeakingActorNPC_ID >= 0) + if (sDialogue_SpeakingActorNPC_ID >= 0) { result = 0; } else { - v3 = uDialogue_SpeakingActorNPC_ID - 1; + v3 = abs(sDialogue_SpeakingActorNPC_ID) - 1; v4 = 0; - for (i = 0; i < 4; ++i) + for (i = 0; i < 2; ++i) { if (pParty->pHirelings[i].pName) pTmpBuf[v4++] = i; @@ -14600,14 +14597,14 @@ } if ( npcid >= 5000 ) goto LABEL_7; - if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 ) + if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 ) { *(int *)a2 = 0; result = 0; } else { - v5 = abs((int)uDialogue_SpeakingActorNPC_ID) - 1; + v5 = abs((int)sDialogue_SpeakingActorNPC_ID) - 1; v6 = 0; v7 = 0; v8 = pParty->pHirelings; @@ -14674,7 +14671,7 @@ } if ( a1 >= 5000 ) return 2; - v3 = abs((int)uDialogue_SpeakingActorNPC_ID) - 1; + v3 = abs((int)sDialogue_SpeakingActorNPC_ID) - 1; v4 = 0; v5 = 0; v6 = pParty->pHirelings; @@ -14709,7 +14706,7 @@ //----- (0044603D) -------------------------------------------------------- void __cdecl sub_44603D() { - uDialogue_SpeakingActorNPC_ID = 0; + sDialogue_SpeakingActorNPC_ID = 0; pDialogueWindow->Release(); pDialogueWindow = 0; pMiscTimer->Resume();
--- a/mm7_4.cpp Thu Mar 07 09:14:57 2013 +0600 +++ b/mm7_4.cpp Thu Mar 07 09:15:15 2013 +0600 @@ -4904,7 +4904,7 @@ npc = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)]; } else - npc = GetNPCData(uDialogue_SpeakingActorNPC_ID); + npc = GetNPCData(sDialogue_SpeakingActorNPC_ID); //v65 = v9; //v10 = 0; //v64 = 0; @@ -10589,7 +10589,7 @@ //GUIWindow *v2; // ecx@1 __debugbreak(); - v0 = GetNPCData(uDialogue_SpeakingActorNPC_ID); + v0 = GetNPCData(sDialogue_SpeakingActorNPC_ID); v1 = 0; pDialogueWindow->eWindowType = WINDOW_MainMenu; pDialogueWindow->Release(); @@ -11943,7 +11943,7 @@ const char *v15; // [sp-4h] [bp-14h]@60 //v1 = _this; - speakingNPC = GetNPCData(uDialogue_SpeakingActorNPC_ID); + speakingNPC = GetNPCData(sDialogue_SpeakingActorNPC_ID); //v3 = v1; uDialogueType = newDialogueType; if ( !speakingNPC->uFlags ) @@ -12050,7 +12050,7 @@ pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 ) + if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 ) pDialogue_SpeakingActor->uAIState = Removed; if ( uActiveCharacter ) pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0);
--- a/mm7_5.cpp Thu Mar 07 09:14:57 2013 +0600 +++ b/mm7_5.cpp Thu Mar 07 09:15:15 2013 +0600 @@ -299,7 +299,7 @@ //Actor::Actor(&actor); memset(&actor, 0, 0x344u); dword_5B65D0_dialogue_actor_npc_id = bDialogueUI_InitializeActor_NPC_ID; - actor.uNPC_ID = bDialogueUI_InitializeActor_NPC_ID; + actor.sNPC_ID = bDialogueUI_InitializeActor_NPC_ID; actor.InitializeDialogue(0); bDialogueUI_InitializeActor_NPC_ID = 0; } @@ -329,7 +329,7 @@ viewparams->field_48 = v0; if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - dword_5B65D0_dialogue_actor_npc_id = pActors[uMessageParam].uNPC_ID; + dword_5B65D0_dialogue_actor_npc_id = pActors[uMessageParam].sNPC_ID; pActor = &pActors[uMessageParam]; //goto _actor_init_dlg; pActor->InitializeDialogue(v0); @@ -383,7 +383,7 @@ { //Actor::Actor(&actor); memset(&actor, 0, 0x344u); - actor.uNPC_ID += -1 - (unsigned __int8)pParty->field_709 - hireling_idx; + actor.sNPC_ID += -1 - (unsigned __int8)pParty->field_709 - hireling_idx; pActor = &actor; pActor->InitializeDialogue(v0); } @@ -15811,8 +15811,8 @@ } if ( (signed int)((char *)v17 + (unsigned __int8)pParty->field_709) < v1 ) { - uDialogue_SpeakingActorNPC_ID = -1 - (unsigned __int8)pParty->field_709 - (int)v17; - v5 = GetNewNPCData(uDialogue_SpeakingActorNPC_ID, (int)&a2); + sDialogue_SpeakingActorNPC_ID = -1 - (unsigned __int8)pParty->field_709 - (int)v17; + v5 = GetNewNPCData(sDialogue_SpeakingActorNPC_ID, (int)&a2); v6 = v5; if ( v5 ) { @@ -15978,8 +15978,12 @@ v9 = pX + pSRZBufferLineOffsets[pY]; if ( pRenderer->pActiveZBuffer[v9] & 0xFFFF ) { - v8 = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + 18* *((short *)&pChests[0].igChestItems[139].uExpireTime - + (pRenderer->pActiveZBuffer[v9] & 0xFFFF) + 2662 * (unsigned int)pChestWindow->ptr_1C + 3)); + + // __debugbreak(); // invalid indexing will result in invalid object ptr + // v8 = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + 18* *((short *)&pChests[0].igChestItems[139].uExpireTime + // + (pRenderer->pActiveZBuffer[v9] & 0xFFFF) + 2662 * (unsigned int)pChestWindow->ptr_1C + 3)); + v10=pChests[pChestWindow->par1C].pInventoryIndices[(pRenderer->pActiveZBuffer[v9] & 0xFFFF)-1]; + v8 =&pChests[pChestWindow->par1C].igChestItems[v10-1]; GameUI_DrawItemInfo(v8); } } @@ -16025,10 +16029,6 @@ pAudioPlayer->StopChannels(-1, -1); v3 = (void *)1; } - else - { - sub_416B01(v3); - } } else {
--- a/mm7_6.cpp Thu Mar 07 09:14:57 2013 +0600 +++ b/mm7_6.cpp Thu Mar 07 09:15:15 2013 +0600 @@ -1735,148 +1735,152 @@ signed int v8; // edx@50 SpellBuff *v9; // ecx@50 - if ( a2 > 73 ) + switch(a2) { - if ( a2 == 77 ) - { - if ( pActor->sCurrentHP >= (signed int)pActor->pMonsterInfo.uHP ) - return 0; - return 1; - } - if ( a2 == 80 ) - { - v6 = pParty->pPartyBuffs; - while ( (signed __int64)v6->uExpireTime <= 0 ) - { - ++v6; - if ( v6 > &pParty->pPartyBuffs[19] ) - { - v7 = pParty->pPlayers;//[0].pPlayerBuffs; - v8 = 0; - v9 = v7->pPlayerBuffs; - while ( v9->uExpireTime <= 0i64 ) - { - ++v8; - ++v9; - if ( v8 >= 24 ) - { - ++v7; - if ( v7 <= &pParty->pPlayers[3] ) - { - v8 = 0; - v9 = v7->pPlayerBuffs; - } - else - return 0; - } - } - return 1; - } - } - return 1; - } - if ( a2 == 85 ) - { - if ( SHIDWORD(pActor->pActorBuffs[13].uExpireTime) < 0 ) - return 1; - if ( SHIDWORD(pActor->pActorBuffs[13].uExpireTime) > 0 ) - return 0; - v3 = 0; - v4 = LODWORD(pActor->pActorBuffs[13].uExpireTime) == 0; - } - else - { - if ( a2 == 86 ) - { + case 77: + { + if ( pActor->sCurrentHP >= (signed int)pActor->pMonsterInfo.uHP ) + return 0; + return 1; + } + case 80: + { + v6 = pParty->pPartyBuffs; + while ( (signed __int64)v6->uExpireTime <= 0 ) + { + ++v6; + if ( v6 > &pParty->pPartyBuffs[19] ) + { + v7 = pParty->pPlayers;//[0].pPlayerBuffs; + v8 = 0; + v9 = v7->pPlayerBuffs; + while ( v9->uExpireTime <= 0i64 ) + { + ++v8; + ++v9; + if ( v8 >= 24 ) + { + ++v7; + if ( v7 <= &pParty->pPlayers[3] ) + { + v8 = 0; + v9 = v7->pPlayerBuffs; + } + else + return 0; + } + } + return 1; + } + } + return 1; + } + case 85: + { + if ( SHIDWORD(pActor->pActorBuffs[13].uExpireTime) < 0 ) + return 1; + if ( SHIDWORD(pActor->pActorBuffs[13].uExpireTime) > 0 ) + return 0; + v3 = 0; + v4 = LODWORD(pActor->pActorBuffs[13].uExpireTime) == 0; + break; + } + case 86: + { if ( SHIDWORD(pActor->pActorBuffs[14].uExpireTime) < 0 ) - return 1; + return 1; if ( SHIDWORD(pActor->pActorBuffs[14].uExpireTime) > 0 ) - return 0; + return 0; v3 = 0; v4 = LODWORD(pActor->pActorBuffs[14].uExpireTime) == 0; - } - else - { - if ( a2 != 95 || SHIDWORD(pActor->pActorBuffs[20].uExpireTime) < 0 ) - return 1; + break; + } + case 95: + { + if ( SHIDWORD(pActor->pActorBuffs[20].uExpireTime) < 0 ) + return 1; if ( SHIDWORD(pActor->pActorBuffs[20].uExpireTime) > 0 ) - return 0; + return 0; v3 = 0; v4 = LODWORD(pActor->pActorBuffs[20].uExpireTime) == 0; - } - } - } - else - { - if ( a2 == 73 ) - { - if ( SHIDWORD(pActor->pActorBuffs[21].uExpireTime) < 0 ) - return 1; - if ( SHIDWORD(pActor->pActorBuffs[21].uExpireTime) > 0 ) - return 0; - v3 = 0; - v4 = LODWORD(pActor->pActorBuffs[21].uExpireTime) == 0; - } - else if ( a2 == 5 ) - { - if ( SHIDWORD(pActor->pActorBuffs[19].uExpireTime) < 0 ) - return 1; - if ( SHIDWORD(pActor->pActorBuffs[19].uExpireTime) > 0 ) - return 0; - v3 = 0; - v4 = LODWORD(pActor->pActorBuffs[19].uExpireTime) == 0; - } - else if ( a2 == 17 ) - { - if ( SHIDWORD(pActor->pActorBuffs[15].uExpireTime) < 0 ) - return 1; - if ( SHIDWORD(pActor->pActorBuffs[15].uExpireTime) > 0 ) - return 0; - v3 = 0; - v4 = LODWORD(pActor->pActorBuffs[15].uExpireTime) == 0; - } - else if ( a2 == 38 ) - { - if ( SHIDWORD(pActor->pActorBuffs[16].uExpireTime) < 0 ) - return 1; - if ( SHIDWORD(pActor->pActorBuffs[16].uExpireTime) > 0 ) - return 0; - v3 = 0; - v4 = LODWORD(pActor->pActorBuffs[16].uExpireTime) == 0; - } - else if ( a2 == 46 ) - { - if ( SHIDWORD(pActor->pActorBuffs[17].uExpireTime) < 0 ) - return 1; - if ( SHIDWORD(pActor->pActorBuffs[17].uExpireTime) > 0 ) - return 0; - v3 = 0; - v4 = LODWORD(pActor->pActorBuffs[17].uExpireTime) == 0; - } - else - { - if ( a2 != 47 ) + break; + } + case 73: + { + if ( SHIDWORD(pActor->pActorBuffs[21].uExpireTime) < 0 ) + return 1; + if ( SHIDWORD(pActor->pActorBuffs[21].uExpireTime) > 0 ) + return 0; + v3 = 0; + v4 = LODWORD(pActor->pActorBuffs[21].uExpireTime) == 0; + break; + } + case 5: + { + if ( SHIDWORD(pActor->pActorBuffs[19].uExpireTime) < 0 ) + return 1; + if ( SHIDWORD(pActor->pActorBuffs[19].uExpireTime) > 0 ) + return 0; + v3 = 0; + v4 = LODWORD(pActor->pActorBuffs[19].uExpireTime) == 0; + break; + } + case 17: + { + if ( SHIDWORD(pActor->pActorBuffs[15].uExpireTime) < 0 ) + return 1; + if ( SHIDWORD(pActor->pActorBuffs[15].uExpireTime) > 0 ) + return 0; + v3 = 0; + v4 = LODWORD(pActor->pActorBuffs[15].uExpireTime) == 0; + break; + } + case 38: { - if ( a2 != 51 || SHIDWORD(pActor->pActorBuffs[18].uExpireTime) < 0 ) + if ( SHIDWORD(pActor->pActorBuffs[16].uExpireTime) < 0 ) + return 1; + if ( SHIDWORD(pActor->pActorBuffs[16].uExpireTime) > 0 ) + return 0; + v3 = 0; + v4 = LODWORD(pActor->pActorBuffs[16].uExpireTime) == 0; + } + case 46: + { + if ( SHIDWORD(pActor->pActorBuffs[17].uExpireTime) < 0 ) return 1; - if ( SHIDWORD(pActor->pActorBuffs[18].uExpireTime) <= 0 ) - { + if ( SHIDWORD(pActor->pActorBuffs[17].uExpireTime) > 0 ) + return 0; + v3 = 0; + v4 = LODWORD(pActor->pActorBuffs[17].uExpireTime) == 0; + break; + } + case 47: + { + if ( SHIDWORD(pActor->pActorBuffs[11].uExpireTime) < 0 ) + return 1; + if ( SHIDWORD(pActor->pActorBuffs[11].uExpireTime) > 0 ) + return 0; + v3 = 0; + v4 = LODWORD(pActor->pActorBuffs[11].uExpireTime) == 0; + break; + } + case 51: + { + if ( SHIDWORD(pActor->pActorBuffs[18].uExpireTime) < 0 ) + return 1; + if ( SHIDWORD(pActor->pActorBuffs[18].uExpireTime) <= 0 ) + { v3 = 0; v4 = LODWORD(pActor->pActorBuffs[18].uExpireTime) == 0; - } - else - return 0; } else + return 0; + break; + } + default: { - if ( SHIDWORD(pActor->pActorBuffs[11].uExpireTime) < 0 ) - return 1; - if ( SHIDWORD(pActor->pActorBuffs[11].uExpireTime) > 0 ) - return 0; - v3 = 0; - v4 = LODWORD(pActor->pActorBuffs[11].uExpireTime) == 0; + return 1; } - } } if ( !(v3 | v4) ) return 0;
--- a/mm7_data.cpp Thu Mar 07 09:14:57 2013 +0600 +++ b/mm7_data.cpp Thu Mar 07 09:15:15 2013 +0600 @@ -2005,7 +2005,7 @@ int dword_591084; // weak struct Actor *pDialogue_SpeakingActor; unsigned int uDialogueType; -unsigned int uDialogue_SpeakingActorNPC_ID; +signed int sDialogue_SpeakingActorNPC_ID; struct LevelDecoration *_591094_decoration; char sHouseName[200]; // idb int uCurrentHouse_Animation; // weak @@ -2039,7 +2039,7 @@ int dword_5B65C4; // weak int dword_5B65C8_timers_count; // weak int dword_5B65CC; // weak -int dword_5B65D0_dialogue_actor_npc_id; // weak +signed int dword_5B65D0_dialogue_actor_npc_id; // weak int dword_5C3418; // weak int dword_5C341C; // weak int _5C3420_pDecoration;
--- a/mm7_data.h Thu Mar 07 09:14:57 2013 +0600 +++ b/mm7_data.h Thu Mar 07 09:15:15 2013 +0600 @@ -1320,7 +1320,7 @@ extern int dword_591084; // weak extern struct Actor *pDialogue_SpeakingActor; extern unsigned int uDialogueType; -extern unsigned int uDialogue_SpeakingActorNPC_ID; +extern signed int sDialogue_SpeakingActorNPC_ID; extern struct LevelDecoration *_591094_decoration; extern char sHouseName[200]; // idb extern int uCurrentHouse_Animation; // weak @@ -2002,7 +2002,7 @@ int __fastcall DrawBook_Map_sub(unsigned int x, unsigned int y, unsigned int a4, int a5, int _48074); // idb void Initialize2DA(); -void __cdecl LoadLevel_InitializeLevelStr(); +void LoadLevel_InitializeLevelStr(); void __cdecl OnMapLeave(); void /*__usercall*/ OnMapLoad(); @@ -2020,7 +2020,7 @@ void __cdecl sub_4452BB(); const char *GetProfessionActionText(int a1); void __cdecl DrawDialogueUI(); -struct NPCData *__fastcall GetNPCData(unsigned int npcid); +struct NPCData *__fastcall GetNPCData(signed int npcid); struct NPCData *__fastcall GetNewNPCData(signed int npcid, int a2); int __fastcall sub_445C8B(signed int a1); void __cdecl sub_44603D(); @@ -2053,7 +2053,7 @@ // int __cdecl crt_deconstruct_44C42C(); void SpawnEncounter(struct MapInfo *pMapInfo, struct SpawnPointMM7 *spawn, int a3, int a4, int a5); int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3); -void sub_450218_prolly_generate_chests_loot(); + signed int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6); int __fastcall sub_45063B(struct MapInfo *a1, int a2); void RespawnGlobalDecorations();