# HG changeset patch # User Ritor1 # Date 1370790632 -21600 # Node ID 7da06d00ad25e604e180266581eab7c4b15e0488 # Parent 6c55c6bd67e08f54c3b52be77484f0a525d707b1# Parent de876af42e0d7df8e1f15a6feab512d436fe0cf0 Слияние diff -r 6c55c6bd67e0 -r 7da06d00ad25 Arcomage.cpp --- a/Arcomage.cpp Sun Jun 09 21:10:18 2013 +0600 +++ b/Arcomage.cpp Sun Jun 09 21:10:32 2013 +0600 @@ -108,7 +108,6 @@ ArcomagePlayer am_Players[2]; Acromage_st1 shown_cards[10]; //amuint_4FAA78; // weak - stru272 array_4FABD0[10]; diff -r 6c55c6bd67e0 -r 7da06d00ad25 GUIWindow.cpp --- a/GUIWindow.cpp Sun Jun 09 21:10:18 2013 +0600 +++ b/GUIWindow.cpp Sun Jun 09 21:10:32 2013 +0600 @@ -1021,11 +1021,11 @@ pWindow.DrawTitleText(pFontCreate, 0x1E3u, 113, pColor2, pTitleText, 3); continue; } - pTitleText = HouseNPCData[v8 - (dword_591080 != 0)]->pName; - v9 = pNPCPortraits_x[6 + (uNumDialogueNPCPortraits - 1)][v8] + pDialogueNPCPortraits[v8]->uTextureHeight + 2; + pTitleText = HouseNPCData[v8 +1 - (dword_591080 != 0)]->pName; + v9 = pNPCPortraits_y[uNumDialogueNPCPortraits - 1][v8] + pDialogueNPCPortraits[v8]->uTextureHeight + 2; } v10 = v9; - pWindow.DrawTitleText(pFontCreate, 0x1E3u, v10, pColor2, pTitleText, 3); + pWindow.DrawTitleText(pFontCreate, 483, v10, pColor2, pTitleText, 3); } } if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) @@ -1827,15 +1827,12 @@ if (eWindowType == WINDOW_HouseInterior) { pCurrentScreen = SCREEN_HOUSE; - pBtn_ExitCancel = pWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[80],// + pBtn_ExitCancel = pWindow->CreateButton(471, 445, 0xA9u, 0x23u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[80],// pIcons_LOD->GetTexture(uExitCancelTextureId), 0); - v25 = uNumDialogueNPCPortraits; - v26 = 0; - if ( uNumDialogueNPCPortraits > 0 ) - { + for ( v26 = 0; v26 < uNumDialogueNPCPortraits; ++v26 ) { - if ( v26 + 1 == v25 && uHouse_ExitPic ) + if ( v26 + 1 == uNumDialogueNPCPortraits && uHouse_ExitPic ) { v30 = pMapStats->pInfos[uHouse_ExitPic].pName; v29 = (char*)pGlobalTXT_LocalizationStrings[LOCSTR_ENTER_S]; @@ -1843,21 +1840,19 @@ else { if ( v26 || !dword_591080 ) - v27 = HouseNPCData[v26 - (dword_591080 != 0)]->pName; + v27 = HouseNPCData[v26 +1 - (dword_591080 != 0)]->pName; else - //v27 = (char *)p2DEvents_minus1_::08[13 * a4]; v27 = (char *)p2DEvents[pButton - 1].pProprieterName; v30 = v27; v29 = (char*)pGlobalTXT_LocalizationStrings[435]; } sprintfex(byte_591180[v26].data(), v29, v30); - HouseNPCData[v26 + 7] = (NPCData *)pWindow->CreateButton(pNPCPortraits_x[uNumDialogueNPCPortraits - 1][v26], + dword_5913F4[v26] = pWindow->CreateButton(pNPCPortraits_x[uNumDialogueNPCPortraits - 1][v26], pNPCPortraits_y[uNumDialogueNPCPortraits - 1][v26], 0x3Fu, 0x49u, 1, 0, UIMSG_ClickHouseNPCPortrait, v26, 0, byte_591180[v26].data(), 0, 0, 0); - v25 = uNumDialogueNPCPortraits; } - } - if ( v25 == 1 ) + + if ( uNumDialogueNPCPortraits == 1 ) { window_SpeakInHouse = &pWindowList[uNextFreeWindowID]; _4B4224_UpdateNPCTopics(0); diff -r 6c55c6bd67e0 -r 7da06d00ad25 Game.cpp --- a/Game.cpp Sun Jun 09 21:10:18 2013 +0600 +++ b/Game.cpp Sun Jun 09 21:10:32 2013 +0600 @@ -550,7 +550,7 @@ dword_6BE340 = 0; pEventTimer->Pause(); ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); - if ( uGameState == GAME_STATE_3 ) + if ( uGameState == GAME_STATE_LOADING_GAME ) { sub_491E3A(); LoadPlayerPortraintsAndVoices(); diff -r 6c55c6bd67e0 -r 7da06d00ad25 Game.h --- a/Game.h Sun Jun 09 21:10:18 2013 +0600 +++ b/Game.h Sun Jun 09 21:10:32 2013 +0600 @@ -16,7 +16,7 @@ GAME_STATE_PLAYING = 0, GAME_FINISHED = 1, GAME_STATE_2 = 2, - GAME_STATE_3 = 3, + GAME_STATE_LOADING_GAME = 3, GAME_STATE_NEWGAME_OUT_GAMEMENU = 4, GAME_STATE_5 = 5, GAME_STATE_STARTING_NEW_GAME = 6, diff -r 6c55c6bd67e0 -r 7da06d00ad25 Math.h --- a/Math.h Sun Jun 09 21:10:18 2013 +0600 +++ b/Math.h Sun Jun 09 21:10:32 2013 +0600 @@ -16,12 +16,12 @@ int pTanTable[520]; int pCosTable[520]; int pInvCosTable[520]; - unsigned int uIntegerPi; - unsigned int uIntegerHalfPi; - unsigned int uIntegerDoublePi; - unsigned int uDoublePiMask; - unsigned int uPiMask; - unsigned int uHalfPiMask; + static const unsigned int uIntegerPi = 1024; + static const unsigned int uIntegerHalfPi = 512; + static const unsigned int uIntegerDoublePi = 2048; + static const unsigned int uDoublePiMask = 2047; + static const unsigned int uPiMask = 1023; + static const unsigned int uHalfPiMask = 511; }; #pragma pack(pop) diff -r 6c55c6bd67e0 -r 7da06d00ad25 Player.cpp --- a/Player.cpp Sun Jun 09 21:10:18 2013 +0600 +++ b/Player.cpp Sun Jun 09 21:10:32 2013 +0600 @@ -564,7 +564,7 @@ //v4 = a2;//102 v5 = 0; pSoundId = 0; - v6 = SoundSetAction[speech];//byte_4ED280 &byte_4ED3D8[4 * v4] ??? + v6 = SoundSetAction[speech].data();//byte_4ED280 &byte_4ED3D8[4 * v4] ??? if (uVoicesVolumeMultiplier) { v7 = 0; diff -r 6c55c6bd67e0 -r 7da06d00ad25 UIHouses.cpp --- a/UIHouses.cpp Sun Jun 09 21:10:18 2013 +0600 +++ b/UIHouses.cpp Sun Jun 09 21:10:32 2013 +0600 @@ -336,110 +336,71 @@ //int v11; // ecx@19 //char pContainer[36]; // [sp+Ch] [bp-54h]@16 int v13; // [sp+30h] [bp-30h]@11 - int Dst[6]; // [sp+34h] [bp-2Ch]@1 + int npc_id_arr[6]; // [sp+34h] [bp-2Ch]@1 //unsigned int v15; // [sp+4Ch] [bp-14h]@1 int uAnimationID; // [sp+50h] [bp-10h]@1 //unsigned int *v17; // [sp+54h] [bp-Ch]@3 //unsigned int v18; // [sp+58h] [bp-8h]@1 //int v19; // [sp+5Ch] [bp-4h]@7 - //v15 = uHouseID; - //v1 = 52 * uHouseID; - //uAnimationID = p2DEvents_minus1___02[26 * uHouseID]; + uAnimationID = p2DEvents[house - 1].uAnimationID; - //v18 = 52 * uHouseID; - memset(Dst, 0, 0x18u); - //uExitPic = *(__int16 *)((char *)p2DEvents_minus1_::2C + v1); - //uExitPic = p2DEvents[uHouseID - 1].uExitPicID; + memset(npc_id_arr, 0, sizeof(npc_id_arr)); uNumDialogueNPCPortraits = 0; uHouse_ExitPic = p2DEvents[house - 1].uExitPicID; if ( uHouse_ExitPic ) { - //uExitMapID = *(__int16 *)((char *)p2DEvents_minus1_::30 + v1); uExitMapID = p2DEvents[house - 1]._quest_related; if ( uExitMapID > 0 ) { - //v17 = (unsigned int *)(uExitMapID - 1); if(_449B57_test_bit(pParty->_quest_bits,uExitMapID)) - // if ( !((unsigned __int8)(0x80u >> (uExitMapID - 1) % 8) & pParty->_quest_bits[(uExitMapID - 1) >> 3]) ) { - //uExitPic = 0; uHouse_ExitPic = 0; } } } - dword_591080 = pAnimatedRooms[uAnimationID].field_8; - //result = dword_591080; - - //v2 = 0; + dword_591080 = pAnimatedRooms[uAnimationID].house_npc_id; + HouseNPCData[0]=0; uNumDialogueNPCPortraits = 0; if ( dword_591080 ) { - //v2 = 1; - Dst[0] = dword_591080; + + npc_id_arr[0] = dword_591080; uNumDialogueNPCPortraits = 1; } - //v19 = 1; - for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i) + for (uint i = 1; i < pNPCStats->uNumNewNPCs; ++i) { - auto npc = pNPCStats->pNewNPCData + i; - //v6 = &pNPCStats->pNewNPCData[1].uFlags; - //v17 = &pNPCStats->pNewNPCData[1].uFlags; - //do - //{ - if (npc->Location2D == house ) + if (pNPCStats->pNewNPCData[i].Location2D == house ) { - if (~npc->uFlags & 0x80) - //if ( !(*(char *)v6 & 0x80) ) + if (!(pNPCStats->pNewNPCData[i].uFlags & 0x80)) { - v7 = uNumDialogueNPCPortraits++ - (dword_591080 != 0) ? 1 : 0; - HouseNPCData[v7] = npc; - //v6 = v17; - //*(&v13 + v2) = *(v17 - 1); - Dst[uNumDialogueNPCPortraits - 1] = npc->uPortraitID; - //v1 = v18; - if ((npc->uFlags & 3) != 2) - ++npc->uFlags; + + HouseNPCData[uNumDialogueNPCPortraits+1- (dword_591080 != 0) ? 1 : 0] = &pNPCStats->pNewNPCData[i]; + npc_id_arr[uNumDialogueNPCPortraits] = pNPCStats->pNewNPCData[i].uPortraitID; + ++uNumDialogueNPCPortraits; + if ((pNPCStats->pNewNPCData[i].uFlags & 3) != 2) + ++pNPCStats->pNewNPCData[i].uFlags; } } - //++v19; - //v6 += 19; - //v17 = v6; - //} - //while ( v19 < (signed int)pNPCStats->uNumNewNPCs ); + } - //uNumDialogueNPCPortraits = v2; - //v19 = 0; for (uint i = 0; i < uNumDialogueNPCPortraits; ++i) - //if ( v2 > 0 ) { - //do - //{ - //v8 = v19; + char icon_name[128]; - sprintfex(icon_name, "npc%03u", Dst[i]); - //v9 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - //++v19; + sprintfex(icon_name, "npc%03u", npc_id_arr[i]); pDialogueNPCPortraits[i] = pIcons_LOD->LoadTexturePtr(icon_name, TEXTURE_16BIT_PALETTE); - //result = v19; - //} - //while ( v19 < uNumDialogueNPCPortraits ); - //uExitPic = uHouse_ExitPic; } if (uHouse_ExitPic) { - //v10 = pIcons_LOD->LoadTexture(pHouse_ExitPictures[uHouse_ExitPic], TEXTURE_16BIT_PALETTE); - //v11 = uNumDialogueNPCPortraits++; - pDialogueNPCPortraits[uNumDialogueNPCPortraits++] = pIcons_LOD->LoadTexturePtr(pHouse_ExitPictures[uHouse_ExitPic], TEXTURE_16BIT_PALETTE); - //result = *(__int16 *)((char *)p2DEvents_minus1_::2E + v1); - //result = p2DEvents[house - 1].uExitMapID; + pDialogueNPCPortraits[uNumDialogueNPCPortraits] = pIcons_LOD->LoadTexturePtr(pHouse_ExitPictures[uHouse_ExitPic], TEXTURE_16BIT_PALETTE); + ++uNumDialogueNPCPortraits; uHouse_ExitPic = p2DEvents[house - 1].uExitMapID; } - //return result; } diff -r 6c55c6bd67e0 -r 7da06d00ad25 mm7_2.cpp --- a/mm7_2.cpp Sun Jun 09 21:10:18 2013 +0600 +++ b/mm7_2.cpp Sun Jun 09 21:10:32 2013 +0600 @@ -879,7 +879,7 @@ //v3 = byte_591180; do { - HouseNPCData[v2 + 7] = (NPCData *)window_SpeakInHouse->CreateButton(pNPCPortraits_x[v1 - 1][v2], pNPCPortraits_y[v1 - 1][v2], + dword_5913F4[v2] = window_SpeakInHouse->CreateButton(pNPCPortraits_x[v1 - 1][v2], pNPCPortraits_y[v1 - 1][v2], 0x3Fu, 0x49u, 1, 0, UIMSG_ClickHouseNPCPortrait, v2, 0, byte_591180[v2].data(), 0, 0, 0); v1 = uNumDialogueNPCPortraits; ++v2; @@ -3769,50 +3769,23 @@ //----- (00452969) -------------------------------------------------------- stru193_math::stru193_math() { - stru193_math *v1; // esi@1 - char *v2; // edi@1 double v3; // ST18_8@2 - signed int v4; // edx@3 - int v5; // eax@4 - int v6; // ecx@4 - signed int v7; // [sp+20h] [bp-4h]@1 - - v1 = this; - this->uIntegerDoublePi = 2048; - this->uIntegerPi = 1024; - this->uIntegerHalfPi = 512; - this->uDoublePiMask = 2047; - this->uPiMask = 1023; - this->uHalfPiMask = 511; + this->pTanTable[0] = 0; this->pCosTable[0] = 65536; this->pInvCosTable[0] = 65536; - v7 = 1; - v2 = (char *)&this->pInvCosTable[1]; - do - { - v3 = (double)v7 * 3.141592653589793 * 0.0009765625; - *((int *)v2 - 1040) = (signed __int64)(tan(v3) * (double)v1->pCosTable[0] + 0.5); - *((int *)v2 - 520) = (signed __int64)(cos(v3) * (double)v1->pCosTable[0] + 0.5); - ++v7; - *(int *)v2 = (signed __int64)(1.0 / cos(v3) * (double)v1->pCosTable[0] + 0.5); - v2 += 4; - } - while ( v7 < (signed int)v1->uIntegerHalfPi ); - v4 = v1->uIntegerHalfPi; - if ( v4 < 520 ) - { - v5 = (int)&v1->pCosTable[v4]; - v6 = 520 - v4; - do - { - *(int *)v5 = 0; - *(int *)(v5 + 2080) = 0xEFFFFFFFu; - *(int *)(v5 - 2080) = 0xEFFFFFFFu; - v5 += 4; - --v6; - } - while ( v6 ); + for(int i = 1; i < (signed int)this->uIntegerHalfPi; i++) + { + v3 = (double)i * 3.141592653589793 / (double)uIntegerPi; + pTanTable[i] = (signed __int64)(tan(v3) * (double)this->pCosTable[0] + 0.5); + pCosTable[i] = (signed __int64)(cos(v3) * (double)this->pCosTable[0] + 0.5); + pInvCosTable[i] = (signed __int64)(1.0 / cos(v3) * (double)this->pCosTable[0] + 0.5); + } + for(int i = this->uIntegerHalfPi; i < 520; i++) + { + this->pTanTable[i] = 0xEFFFFFFFu; + this->pCosTable[i] = 0; + this->pInvCosTable[i] = 0xEFFFFFFFu; } } @@ -8218,7 +8191,7 @@ //LABEL_48: pGame->Loop(); LABEL_49: - if ( uGameState == GAME_STATE_3 ) + if ( uGameState == GAME_STATE_LOADING_GAME ) { SetCurrentMenuID(MENU_5); uGameState = GAME_STATE_PLAYING; diff -r 6c55c6bd67e0 -r 7da06d00ad25 mm7_4.cpp --- a/mm7_4.cpp Sun Jun 09 21:10:18 2013 +0600 +++ b/mm7_4.cpp Sun Jun 09 21:10:32 2013 +0600 @@ -3373,7 +3373,7 @@ if ( dword_5C35D4 ) { //__debugbreak(); // fix - npc = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)]; + npc = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0))]; //- 1 } else npc = GetNPCData(sDialogue_SpeakingActorNPC_ID); @@ -6467,7 +6467,7 @@ //int v25; // [sp-4h] [bp-10h]@49 uDialogueType = uMessageParam + 1; - pCurrentNPCInfo = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)]; + pCurrentNPCInfo = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) )];//- 1 if ( uMessageParam <= 24 ) { switch ( uMessageParam ) @@ -7209,7 +7209,7 @@ } a1.uFrameWidth -= 10; a1.uFrameZ -= 10; - v58 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)]; + v58 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) )];//- 1 v6 = v58; v55 = TargetColor(0xE1u, 0xCDu, 0x23u); v7 = TargetColor(0x15u, 0x99u, 0xE9u); @@ -7763,7 +7763,7 @@ NPCData *v1; // edi@1 v0 = 0; - v1 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)]; + v1 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) )];//- 1 pDialogueWindow->Release(); pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15Eu, WINDOW_MainMenu, 0, 0); pBtn_ExitCancel = pDialogueWindow->CreateButton( 0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, UIMSG_Escape, 0, 0, @@ -7811,7 +7811,7 @@ } else { - v17 = HouseNPCData[_this + 1 - ((dword_591080 != 0) + 1)]; + v17 = HouseNPCData[_this + 1 - ((dword_591080 != 0) )];//+ 1 if ( dialog_menu_id == HOUSE_DIALOGUE_OTHER ) { pDialogueWindow->Release(); @@ -7819,7 +7819,7 @@ else { for ( i = 0; i < uNumDialogueNPCPortraits; ++i ) - ((GUIButton *)HouseNPCData[i + 7])->Release(); + dword_5913F4[i]->Release(); } pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0); pBtn_ExitCancel = pDialogueWindow->CreateButton( 471u, 445u, 169u, 35u, 1, 0, UIMSG_Escape, 0, 0, diff -r 6c55c6bd67e0 -r 7da06d00ad25 mm7_5.cpp --- a/mm7_5.cpp Sun Jun 09 21:10:18 2013 +0600 +++ b/mm7_5.cpp Sun Jun 09 21:10:32 2013 +0600 @@ -486,7 +486,7 @@ if ( pSavegameUsedSlots[uLoadGameUI_SelectedSlot] ) { LoadGame(uLoadGameUI_SelectedSlot); - uGameState = GAME_STATE_3; + uGameState = GAME_STATE_LOADING_GAME; } stru_506E40.Release(); continue; diff -r 6c55c6bd67e0 -r 7da06d00ad25 mm7_data.cpp --- a/mm7_data.cpp Sun Jun 09 21:10:18 2013 +0600 +++ b/mm7_data.cpp Sun Jun 09 21:10:32 2013 +0600 @@ -643,8 +643,8 @@ {1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1},//47 {1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1},//48 }}; -unsigned char SoundSetAction[110][8] = // 4ED3D8 -{ +std::array, 110> SoundSetAction = // 4ED3D8 +{{ { 0, 0, 0, 0, 0, 0, 0, 0}, {38, 0, 0, 37, 38, 45, 0, 0}, {37, 0, 0, 47, 53, 0, 0, 0}, @@ -755,7 +755,7 @@ {39, 0, 0, 48, 0, 0, 0, 0}, {14, 0, 0, 48, 0, 0, 0, 0}, {17, 0, 0, 0, 0, 0, 0, 0} -}; +}}; std::array<__int16, 4> pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing = {34, 149, 264, 379}; std::array< std::array, 36> byte_4ED970_skill_learn_ability_by_class_table = {{ @@ -1116,8 +1116,8 @@ int dword_591178_teleporty; // weak int dword_59117C_teleportx; // weak std::array, 6> byte_591180; // idb -std::array HouseNPCData;//array_5913D8 this array size temporarily increased to 60 from 6 to work aroud house overflow - +std::array HouseNPCData;//0 zero element holds standart house npc +GUIButton* dword_5913F4[6]; struct Texture *pTexture_591428; struct Texture *pTexture_outside; // idb struct Texture *pTexture_Dialogue_Background; diff -r 6c55c6bd67e0 -r 7da06d00ad25 mm7_data.h --- a/mm7_data.h Sun Jun 09 21:10:18 2013 +0600 +++ b/mm7_data.h Sun Jun 09 21:10:32 2013 +0600 @@ -486,7 +486,7 @@ extern std::array pPlayerPortraitsNames; extern std::array< std::array, 48> byte_4ECF08; -extern unsigned char SoundSetAction[110][8]; // weak +extern std::array, 110> SoundSetAction; // weak extern std::array<__int16, 4> pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing; extern std::array< std::array, 36> byte_4ED970_skill_learn_ability_by_class_table; extern std::array dword_4EDEA0; // weak @@ -755,8 +755,8 @@ extern int dword_591178_teleporty; // weak extern int dword_59117C_teleportx; // weak extern std::array, 6> byte_591180; // idb -extern std::array HouseNPCData; //this array size temporarily increased to 60 from 6 to work aroud house overflow - +extern std::array HouseNPCData; //0this array size temporarily increased to 60 from 6 to work aroud house overflow +extern GUIButton* dword_5913F4[6]; extern struct Texture *pTexture_591428; extern struct Texture *pTexture_outside; // idb extern struct Texture *pTexture_Dialogue_Background; diff -r 6c55c6bd67e0 -r 7da06d00ad25 stru159.h --- a/stru159.h Sun Jun 09 21:10:18 2013 +0600 +++ b/stru159.h Sun Jun 09 21:10:32 2013 +0600 @@ -8,7 +8,7 @@ { char *video_name; int field_4; - int field_8; + int house_npc_id; unsigned __int8 uBuildingType; unsigned __int8 uRoomSoundId; unsigned __int16 padding_e;