Mercurial > mm7
comparison mm7_2.cpp @ 2225:080fd5a5433d
Merge
author | Grumpy7 |
---|---|
date | Wed, 19 Feb 2014 22:30:39 +0100 |
parents | e6771956e74a |
children | 6ab7d7c112bb |
comparison
equal
deleted
inserted
replaced
2224:c2eeeb991a87 | 2225:080fd5a5433d |
---|---|
254 int i; // eax@2 | 254 int i; // eax@2 |
255 int rand_monster_id; // edx@3 | 255 int rand_monster_id; // edx@3 |
256 | 256 |
257 uDialogueType = 83; | 257 uDialogueType = 83; |
258 pDialogueWindow->Release(); | 258 pDialogueWindow->Release(); |
259 pDialogueWindow = GUIWindow::Create(0, 0, 640, 350, WINDOW_MainMenu, 0, 0); | 259 pDialogueWindow = GUIWindow::Create(0, 0, window->GetWidth(), 350, WINDOW_MainMenu, 0, 0); |
260 pBtn_ExitCancel = pDialogueWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34],// "Cancel" | 260 pBtn_ExitCancel = pDialogueWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34],// "Cancel" |
261 pIcons_LOD->GetTexture(uExitCancelTextureId), 0); | 261 pIcons_LOD->GetTexture(uExitCancelTextureId), 0); |
262 pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); | 262 pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); |
263 pDialogueWindow->CreateButton(480, 160, 140, 30, 1, 0, UIMSG_0, 83, 0, "", 0); | 263 pDialogueWindow->CreateButton(480, 160, 140, 30, 1, 0, UIMSG_0, 83, 0, "", 0); |
264 pDialogueWindow->_41D08F_set_keyboard_control_group(1, 1, 0, 2); | 264 pDialogueWindow->_41D08F_set_keyboard_control_group(1, 1, 0, 2); |
728 pRenderer->BeginScene(); | 728 pRenderer->BeginScene(); |
729 pRenderer->DrawTextureRGB(0, 0, &_this); | 729 pRenderer->DrawTextureRGB(0, 0, &_this); |
730 pRenderer->EndScene(); | 730 pRenderer->EndScene(); |
731 free(_this.pPixels); | 731 free(_this.pPixels); |
732 _this.pPixels = 0; | 732 _this.pPixels = 0; |
733 window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0); | 733 window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); |
734 pWindow.uFrameX = 75; | 734 pWindow.uFrameX = 75; |
735 pWindow.uFrameY = 60; | 735 pWindow.uFrameY = 60; |
736 pWindow.uFrameWidth = 469; | 736 pWindow.uFrameWidth = 469; |
737 pWindow.uFrameHeight = 338; | 737 pWindow.uFrameHeight = 338; |
738 pWindow.uFrameZ = 543; | 738 pWindow.uFrameZ = 543; |
914 return field20value; | 914 return field20value; |
915 } | 915 } |
916 | 916 |
917 result = (int)pDst; | 917 result = (int)pDst; |
918 v193 = pDst; | 918 v193 = pDst; |
919 v231 = 0; | |
920 if ( dstHeight <= 0 ) | 919 if ( dstHeight <= 0 ) |
921 return result; | 920 return result; |
922 | 921 |
923 do | 922 //do |
923 for ( v231 = 0; v231 < dstHeight; v231++ ) | |
924 { | 924 { |
925 for (int counter = 0; counter < dstWidth; counter++) | 925 for (int counter = 0; counter < dstWidth; counter++) |
926 { | 926 { |
927 a6s = (double)counter / (double)dstWidth * (double)srcWidth; | 927 a6s = (double)counter / (double)dstWidth * (double)srcWidth; |
928 widthRatio = bankersRounding(a6s); | 928 widthRatio = bankersRounding(a6s); |
974 v23 = _450F55(v251 | ((v252 | ((a6b | (v22 << 8)) << 8)) << 8)); | 974 v23 = _450F55(v251 | ((v252 | ((a6b | (v22 << 8)) << 8)) << 8)); |
975 *(_DWORD *)v193 = v23; | 975 *(_DWORD *)v193 = v23; |
976 v193 = (unsigned __int16 *)((char *)v193 + field_20_bits); | 976 v193 = (unsigned __int16 *)((char *)v193 + field_20_bits); |
977 } | 977 } |
978 v193 = (unsigned __int16 *)((char *)v193 + field_20_bits * (dstPitch - dstWidth)); | 978 v193 = (unsigned __int16 *)((char *)v193 + field_20_bits * (dstPitch - dstWidth)); |
979 ++v231; | 979 //++v231; |
980 result = v231; | 980 result = v231; |
981 } | 981 } |
982 while(v231 < dstHeight); | 982 //while(v231 < dstHeight); |
983 return result; | 983 return result; |
984 } | 984 } |
985 | 985 |
986 //----- (0044F57C) -------------------------------------------------------- | 986 //----- (0044F57C) -------------------------------------------------------- |
987 void SpawnEncounter(MapInfo *pMapInfo, SpawnPointMM7 *spawn, int a3, int a4, int a5) | 987 void SpawnEncounter(MapInfo *pMapInfo, SpawnPointMM7 *spawn, int a3, int a4, int a5) |
1579 } | 1579 } |
1580 | 1580 |
1581 //----- (0045063B) -------------------------------------------------------- | 1581 //----- (0045063B) -------------------------------------------------------- |
1582 int __fastcall _45063B_spawn_some_monster(MapInfo *a1, int a2) | 1582 int __fastcall _45063B_spawn_some_monster(MapInfo *a1, int a2) |
1583 { | 1583 { |
1584 signed int v2; // edi@1 | |
1585 Actor *v3; // esi@2 | |
1586 //signed __int64 v4; // qax@3 | |
1587 int result; // eax@8 | 1584 int result; // eax@8 |
1588 int v6; // edi@11 | 1585 int v6; // edi@11 |
1589 int v7; // ebx@11 | 1586 int v7; // ebx@11 |
1590 int v8; // edi@11 | 1587 int v8; // edi@11 |
1591 int v9; // ebx@12 | 1588 int v9; // ebx@12 |
1597 int v15; // eax@20 | 1594 int v15; // eax@20 |
1598 int v16; // eax@20 | 1595 int v16; // eax@20 |
1599 int v17; // eax@20 | 1596 int v17; // eax@20 |
1600 int v18; // eax@21 | 1597 int v18; // eax@21 |
1601 SpawnPointMM7 v19; // [sp+Ch] [bp-38h]@1 | 1598 SpawnPointMM7 v19; // [sp+Ch] [bp-38h]@1 |
1602 int v20; // [sp+24h] [bp-20h]@11 | |
1603 //MapInfo *v21; // [sp+28h] [bp-1Ch]@1 | |
1604 int v22; // [sp+2Ch] [bp-18h]@3 | 1599 int v22; // [sp+2Ch] [bp-18h]@3 |
1605 int v23; // [sp+30h] [bp-14h]@11 | |
1606 //int v24; // [sp+34h] [bp-10h]@1 | |
1607 unsigned int uFaceID; // [sp+38h] [bp-Ch]@10 | 1600 unsigned int uFaceID; // [sp+38h] [bp-Ch]@10 |
1608 int v26; // [sp+3Ch] [bp-8h]@11 | 1601 int v26; // [sp+3Ch] [bp-8h]@11 |
1609 int v27; // [sp+40h] [bp-4h]@11 | 1602 int v27; // [sp+40h] [bp-4h]@11 |
1610 | 1603 |
1611 if (!uNumActors) | 1604 if (!uNumActors) |
1612 return 0; | 1605 return 0; |
1613 | 1606 |
1614 //v21 = a1; | 1607 for ( uint mon_id = 0; mon_id < uNumActors; ++mon_id ) |
1615 //v24 = a2; | 1608 { |
1616 v2 = 0; | 1609 if ((pActors[mon_id].pMonsterInfo.uID < 121 || pActors[mon_id].pMonsterInfo.uID > 123) && // Dwarf FemaleC A-C |
1617 v3 = pActors.data(); | 1610 (pActors[mon_id].pMonsterInfo.uID < 124 || pActors[mon_id].pMonsterInfo.uID > 126) && // Dwarf MaleA A-C |
1618 while ( 1 ) | 1611 (pActors[mon_id].pMonsterInfo.uID < 133 || pActors[mon_id].pMonsterInfo.uID > 135) && // Peasant Elf FemaleA A-C |
1619 { | 1612 pActors[mon_id].CanAct()) |
1620 if (v3->pMonsterInfo.uID >= 121 && v3->pMonsterInfo.uID <= 123 || // Dwarf FemaleC A-C | 1613 { |
1621 v3->pMonsterInfo.uID >= 124 && v3->pMonsterInfo.uID <= 126 || // Dwarf MaleA A-C | 1614 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) |
1622 v3->pMonsterInfo.uID >= 133 && v3->pMonsterInfo.uID <= 135 || // Peasant Elf FemaleA A-C | 1615 { |
1623 !v3->CanAct()) | 1616 v22 = 0; |
1624 { | 1617 uint face_id = 0; |
1625 ++v2; | 1618 for ( face_id; face_id < 100; ++face_id ) |
1626 ++v3; | 1619 { |
1627 | 1620 v6 = rand() % 1024 + 512; |
1628 if (v2 >= uNumActors) | 1621 v7 = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; |
1629 return 0; | 1622 v19.vPosition.x = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v7), v6); |
1630 | 1623 v8 = 0; |
1631 continue; | 1624 v19.uIndex = a2; |
1632 } | 1625 v19.vPosition.y = fixpoint_mul(stru_5C6E00->Sin(v7), v6) + pParty->vPosition.y; |
1633 | 1626 v19.vPosition.z = pParty->vPosition.z; |
1634 break; | 1627 v26 = 0; |
1628 v27 = 0; | |
1629 v19.vPosition.z = ODM_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, pParty->vPosition.z, 0, &v26, &v27, 0); | |
1630 for( int i = 0; i < pOutdoor->uNumBModels; i++ ) | |
1631 { | |
1632 v9 = abs(v19.vPosition.y - pOutdoor->pBModels[i].vBoundingCenter.y); | |
1633 v10 = abs(v19.vPosition.x - pOutdoor->pBModels[i].vBoundingCenter.x); | |
1634 if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[i].sBoundingRadius + 256 ) | |
1635 { | |
1636 v22 = 1; | |
1637 break; | |
1638 } | |
1639 } | |
1640 if ( v22 ) | |
1641 { | |
1642 v11 = face_id == 100; | |
1643 break; | |
1644 } | |
1645 } | |
1646 v11 = face_id == 100; | |
1647 } | |
1648 else if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
1649 { | |
1650 v22 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
1651 for ( uint i = 0; i < 100; ++i ) | |
1652 { | |
1653 v12 = rand() % 512 + 256; | |
1654 v13 = rand(); | |
1655 v14 = v13 % (signed int)stru_5C6E00->uIntegerDoublePi; | |
1656 v15 = stru_5C6E00->Cos(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); | |
1657 v19.vPosition.x = pParty->vPosition.x + fixpoint_mul(v15, v12); | |
1658 v16 = stru_5C6E00->Sin(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); | |
1659 v19.vPosition.y = fixpoint_mul(v16, v12) + pParty->vPosition.y; | |
1660 v19.vPosition.z = pParty->vPosition.z; | |
1661 v19.uIndex = a2; | |
1662 v17 = pIndoor->GetSector(v19.vPosition.x, v19.vPosition.y, pParty->vPosition.z); | |
1663 if ( v17 == v22 ) | |
1664 { | |
1665 v18 = BLV_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, v19.vPosition.z, v17, &uFaceID); | |
1666 v19.vPosition.z = v18; | |
1667 if ( v18 != -30000 ) | |
1668 { | |
1669 if ( abs(v18 - pParty->vPosition.z) <= 1024 ) | |
1670 break; | |
1671 } | |
1672 } | |
1673 } | |
1674 v11 = v26 == 100; | |
1675 } | |
1676 if ( v11 ) | |
1677 result = 0; | |
1678 else | |
1679 { | |
1680 SpawnEncounter(a1, &v19, 0, 0, 1); | |
1681 result = a2; | |
1682 } | |
1683 } | |
1684 | |
1685 //break; | |
1635 //v22 = v3->pMonsterInfo.uID - 1; | 1686 //v22 = v3->pMonsterInfo.uID - 1; |
1636 //v4 = (signed __int64)((double)v22 * 0.3333333333333333); | 1687 //v4 = (signed __int64)((double)v22 * 0.3333333333333333); |
1637 //if ( (int)v4 != 40 ) | 1688 //if ( (int)v4 != 40 ) |
1638 //{ | 1689 //{ |
1639 // if ( (int)v4 != 41 && (int)v4 != 44 && v3->CanAct() ) | 1690 // if ( (int)v4 != 41 && (int)v4 != 44 && v3->CanAct() ) |
1641 //} | 1692 //} |
1642 //++v2; | 1693 //++v2; |
1643 //++v3; | 1694 //++v3; |
1644 //if ( v2 >= (signed int)uNumActors ) | 1695 //if ( v2 >= (signed int)uNumActors ) |
1645 // goto LABEL_8; | 1696 // goto LABEL_8; |
1646 } | |
1647 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
1648 { | |
1649 v22 = 0; | |
1650 uFaceID = 0; | |
1651 while ( 1 ) | |
1652 { | |
1653 ++uFaceID; | |
1654 v6 = rand() % 1024 + 512; | |
1655 v7 = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; | |
1656 v20 = stru_5C6E00->Cos(v7); | |
1657 v23 = (unsigned __int64)(v20 * (signed __int64)v6) >> 16; | |
1658 v19.vPosition.x = pParty->vPosition.x + v23; | |
1659 v20 = stru_5C6E00->Sin(v7); | |
1660 v23 = (unsigned __int64)(v20 * (signed __int64)v6) >> 16; | |
1661 v8 = 0; | |
1662 v19.uIndex = a2; | |
1663 v19.vPosition.y = v23 + pParty->vPosition.y; | |
1664 v19.vPosition.z = pParty->vPosition.z; | |
1665 v26 = 0; | |
1666 v27 = 0; | |
1667 v19.vPosition.z = ODM_GetFloorLevel( | |
1668 v19.vPosition.x, | |
1669 v23 + pParty->vPosition.y, | |
1670 pParty->vPosition.z, | |
1671 0, | |
1672 &v26, | |
1673 &v27, | |
1674 0); | |
1675 v23 = 0; | |
1676 for( int i = 0; i < pOutdoor->uNumBModels; i++ ) | |
1677 { | |
1678 v9 = abs(v19.vPosition.y - pOutdoor->pBModels[i].vBoundingCenter.y); | |
1679 v10 = abs(v19.vPosition.x - pOutdoor->pBModels[i].vBoundingCenter.x); | |
1680 if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[i].sBoundingRadius + 256 ) | |
1681 { | |
1682 v22 = 1; | |
1683 break; | |
1684 } | |
1685 } | |
1686 v11 = uFaceID == 100; | |
1687 if ( uFaceID >= 100 ) | |
1688 break; | |
1689 if ( v22 ) | |
1690 { | |
1691 v11 = uFaceID == 100; | |
1692 break; | |
1693 } | |
1694 } | |
1695 } | |
1696 else | |
1697 { | |
1698 v26 = 0; | |
1699 v22 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
1700 do | |
1701 { | |
1702 ++v26; | |
1703 v12 = rand() % 512 + 256; | |
1704 v13 = rand(); | |
1705 v14 = v13 % (signed int)stru_5C6E00->uIntegerDoublePi; | |
1706 v15 = stru_5C6E00->Cos(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); | |
1707 v20 = v15; | |
1708 v23 = (unsigned __int64)(v15 * (signed __int64)v12) >> 16; | |
1709 v19.vPosition.x = pParty->vPosition.x + v23; | |
1710 v16 = stru_5C6E00->Sin(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); | |
1711 v20 = v16; | |
1712 v23 = (unsigned __int64)(v16 * (signed __int64)v12) >> 16; | |
1713 v19.vPosition.y = v23 + pParty->vPosition.y; | |
1714 v19.vPosition.z = pParty->vPosition.z; | |
1715 v19.uIndex = a2; | |
1716 v17 = pIndoor->GetSector(v19.vPosition.x, v23 + pParty->vPosition.y, pParty->vPosition.z); | |
1717 if ( v17 == v22 ) | |
1718 { | |
1719 v18 = BLV_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, v19.vPosition.z, v17, &uFaceID); | |
1720 v19.vPosition.z = v18; | |
1721 if ( v18 != -30000 ) | |
1722 { | |
1723 if ( abs(v18 - pParty->vPosition.z) <= 1024 ) | |
1724 break; | |
1725 } | |
1726 } | |
1727 } | |
1728 while ( v26 < 100 ); | |
1729 v11 = v26 == 100; | |
1730 } | |
1731 if ( v11 ) | |
1732 { | |
1733 result = 0; | |
1734 } | |
1735 else | |
1736 { | |
1737 SpawnEncounter(a1, &v19, 0, 0, 1); | |
1738 result = a2; | |
1739 } | 1697 } |
1740 return result; | 1698 return result; |
1741 } | 1699 } |
1742 | 1700 |
1743 //----- (00450AAA) -------------------------------------------------------- | 1701 //----- (00450AAA) -------------------------------------------------------- |
2264 //while ( v4 ); | 2222 //while ( v4 ); |
2265 if ( val - result * result >= (unsigned int)(result - 1) ) | 2223 if ( val - result * result >= (unsigned int)(result - 1) ) |
2266 ++result; | 2224 ++result; |
2267 return result; | 2225 return result; |
2268 } | 2226 } |
2269 | |
2270 | |
2271 | 2227 |
2272 //----- (00452B2E) -------------------------------------------------------- | 2228 //----- (00452B2E) -------------------------------------------------------- |
2273 int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides) | 2229 int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides) |
2274 { | 2230 { |
2275 int v3; // esi@1 | 2231 int v3; // esi@1 |
2903 GUIWindow *pWindow; // [sp+4h] [bp-38h]@11 | 2859 GUIWindow *pWindow; // [sp+4h] [bp-38h]@11 |
2904 | 2860 |
2905 pCurrentScreen = SCREEN_GAME; | 2861 pCurrentScreen = SCREEN_GAME; |
2906 | 2862 |
2907 pGUIWindow2 = 0; | 2863 pGUIWindow2 = 0; |
2908 pAudioPlayer->StopChannels(-1, -1); | 2864 pAudioPlayer->StopChannels(-1, -1);//остановить/подготовить канал |
2909 pMouse->RemoveHoldingItem(); | 2865 pMouse->RemoveHoldingItem();//избавить курсор от вещи |
2910 | 2866 |
2911 pIcons_LOD->_inlined_sub2(); | 2867 pIcons_LOD->_inlined_sub2(); |
2912 | 2868 |
2913 pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0); | 2869 pWindow_MainMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); |
2914 Texture* pNew = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); | 2870 Texture* pNew = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); |
2915 Texture* pLoad = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE); | 2871 Texture* pLoad = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE); |
2916 Texture* pCredits = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE); | 2872 Texture* pCredits = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE); |
2917 Texture* pExit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); | 2873 Texture* pExit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); |
2918 | 2874 |
2935 { | 2891 { |
2936 if ( pCurrentScreen != SCREEN_LOADGAME ) | 2892 if ( pCurrentScreen != SCREEN_LOADGAME ) |
2937 { | 2893 { |
2938 pTexture_PCX.Release(); | 2894 pTexture_PCX.Release(); |
2939 pTexture_PCX.Load("lsave640.pcx", 0); | 2895 pTexture_PCX.Load("lsave640.pcx", 0); |
2940 pGUIWindow2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0); | 2896 pGUIWindow2 = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); |
2941 pCurrentScreen = SCREEN_LOADGAME; | 2897 pCurrentScreen = SCREEN_LOADGAME; |
2942 LoadUI_Load(0); | 2898 LoadUI_Load(0); |
2943 } | 2899 } |
2944 pWindow = pGUIWindow_CurrentMenu; | 2900 pWindow = pGUIWindow_CurrentMenu; |
2945 } | 2901 } |
4188 new_sky = true; | 4144 new_sky = true; |
4189 if (wcsstr(pCmdLine, L"-nomarg")) | 4145 if (wcsstr(pCmdLine, L"-nomarg")) |
4190 bNoMargareth = true; | 4146 bNoMargareth = true; |
4191 } | 4147 } |
4192 | 4148 |
4193 | |
4194 /*v8 = _4AC1C9_get_cpu_speed(0, (Vec4_int_ *)a2); | 4149 /*v8 = _4AC1C9_get_cpu_speed(0, (Vec4_int_ *)a2); |
4195 Rect.left = *(int *)v8; | 4150 Rect.left = *(int *)v8; |
4196 Rect.top = *(int *)(v8 + 4); | 4151 Rect.top = *(int *)(v8 + 4); |
4197 Rect.right = *(int *)(v8 + 8); | 4152 Rect.right = *(int *)(v8 + 8); |
4198 Rect.bottom = *(int *)(v8 + 12); | 4153 Rect.bottom = *(int *)(v8 + 12); |
4199 uCPUSpeed = Rect.bottom;*/ | 4154 uCPUSpeed = Rect.bottom;*/ |
4200 uCPUSpeed = 2048; // about 2GHz | 4155 uCPUSpeed = 2048; // about 2GHz |
4201 | 4156 |
4202 constructors(); | 4157 constructors(); |
4203 | 4158 |
4204 if (!MM7_Initialize(640, 480)) | 4159 if (!MM7_Initialize(640, 480))//задаётся размер окна |
4205 { | 4160 { |
4206 Log::Warning(L"MM init: failed"); | 4161 Log::Warning(L"MM init: failed"); |
4207 pGame->Deinitialize(); | 4162 pGame->Deinitialize(); |
4208 return 1; | 4163 return 1; |
4209 } | 4164 } |
4210 | 4165 |
4211 pEventTimer->Pause(); | 4166 pEventTimer->Pause(); |
4212 | 4167 |
4213 SetUserInterface(PartyAlignment_Neutral, false); | 4168 SetUserInterface(PartyAlignment_Neutral, false); |
4214 ShowIntroVideo_and_LoadingScreen(); | 4169 ShowIntroVideo_and_LoadingScreen(); |
4215 WriteWindowsRegistryInt("Ran once", 1); | 4170 WriteWindowsRegistryInt("Ran once", 1); |
4216 dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000; | 4171 dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000; |
4217 pGame->InitializeGammaController(); | 4172 pGame->InitializeGammaController(); |
4218 SecondaryInitialization(); | 4173 SecondaryInitialization(); |
4219 pRenderer->SetRasterClipRect(0, 0, 639, 479); | 4174 pRenderer->SetRasterClipRect(0, 0, window->GetWidth() - 1, window->GetHeight() - 1); |
4220 FinalInitialization(); | 4175 FinalInitialization(); |
4221 | 4176 Log::Warning(L"MM: entering main loop"); |
4222 Log::Warning(L"MM: entering main loop"); | 4177 while ( 1 ) |
4178 { | |
4179 MainMenuWindow* main_menu_window = MainMenuWindow::Create(); | |
4180 window->AddControl(main_menu_window); | |
4181 MainMenu_Loop(); | |
4182 uGameState = GAME_STATE_PLAYING; | |
4223 while ( 1 ) | 4183 while ( 1 ) |
4224 { | 4184 { |
4225 MainMenuWindow* main_menu_window = MainMenuWindow::Create(); | 4185 if (uGameState == GAME_FINISHED || GetCurrentMenuID() == MENU_EXIT_GAME) |
4226 window->AddControl(main_menu_window); | 4186 { |
4227 | 4187 pGame->Deinitialize(); |
4228 MainMenu_Loop(); | 4188 return true; |
4229 uGameState = GAME_STATE_PLAYING; | 4189 } |
4230 while ( 1 ) | 4190 |
4231 { | 4191 if (GetCurrentMenuID() == MENU_NEWGAME) |
4232 if (uGameState == GAME_FINISHED || GetCurrentMenuID() == MENU_EXIT_GAME) | 4192 { |
4193 if ( pAudioPlayer->hAILRedbook ) | |
4194 AIL_redbook_stop(pAudioPlayer->hAILRedbook); | |
4195 pParty->Reset(); | |
4196 pOtherOverlayList->Reset(); | |
4197 strcpy(pCurrentMapName, pStartingMapName); | |
4198 pParty->CreateDefaultParty(0); | |
4199 PlayerCreationUI_Initialize(); | |
4200 if ( PlayerCreationUI_Loop() ) | |
4233 { | 4201 { |
4234 pGame->Deinitialize(); | 4202 DeleteCCharFont(); |
4235 return true; | 4203 break; |
4236 } | 4204 } |
4237 | 4205 DeleteCCharFont(); |
4238 if (GetCurrentMenuID() == MENU_NEWGAME) | 4206 bFlashQuestBook = true; |
4239 { | 4207 PlayFullscreenMovie(MOVIE_Emerald); |
4240 if ( pAudioPlayer->hAILRedbook ) | 4208 //pGame->pCShow->PlayMovie(MOVIE_Emerald, 0); |
4241 AIL_redbook_stop(pAudioPlayer->hAILRedbook); | 4209 SaveNewGame(); |
4242 pParty->Reset(); | 4210 if (bNoMargareth) |
4243 pOtherOverlayList->Reset(); | 4211 _449B7E_toggle_bit(pParty->_quest_bits, PARTY_QUEST_EMERALD_MARGARETH_OFF, 1); |
4244 | 4212 pGame->Loop(); |
4245 strcpy(pCurrentMapName, pStartingMapName); | 4213 if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU) |
4246 pParty->CreateDefaultParty(0); | |
4247 PlayerCreationUI_Initialize(); | |
4248 if ( PlayerCreationUI_Loop() ) | |
4249 { | |
4250 DeleteCCharFont(); | |
4251 break; | |
4252 } | |
4253 DeleteCCharFont(); | |
4254 bFlashQuestBook = true; | |
4255 PlayFullscreenMovie(MOVIE_Emerald); | |
4256 //pGame->pCShow->PlayMovie(MOVIE_Emerald, 0); | |
4257 SaveNewGame(); | |
4258 | |
4259 if (bNoMargareth) | |
4260 _449B7E_toggle_bit(pParty->_quest_bits, PARTY_QUEST_EMERALD_MARGARETH_OFF, 1); | |
4261 pGame->Loop(); | |
4262 | |
4263 if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU) | |
4264 { | |
4265 SetCurrentMenuID(MENU_NEWGAME); | |
4266 uGameState = GAME_STATE_PLAYING; | |
4267 continue; | |
4268 } | |
4269 else if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU) | |
4270 break; | |
4271 | |
4272 assert(false && "Invalid game state"); | |
4273 } | |
4274 if (GetCurrentMenuID() == MENU_CREDITS) | |
4275 { | |
4276 if ( pAudioPlayer->hAILRedbook ) | |
4277 AIL_redbook_stop(pAudioPlayer->hAILRedbook); | |
4278 MainMenuUI_Credits_Loop(); | |
4279 break; | |
4280 } | |
4281 if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu) | |
4282 { | |
4283 uGameState = GAME_STATE_PLAYING; | |
4284 pGame->Loop(); | |
4285 } | |
4286 else | |
4287 { | |
4288 if (GetCurrentMenuID() == MENU_DebugBLVLevel) | |
4289 { | |
4290 pMouse->Activate(0); | |
4291 | |
4292 pParty->Reset(); | |
4293 pParty->CreateDefaultParty(1); | |
4294 | |
4295 __debugbreak(); | |
4296 /*extern void CreateDefaultBLVLevel(); | |
4297 CreateDefaultBLVLevel(); | |
4298 | |
4299 OPENFILENAMEA ofn; | |
4300 if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) ) | |
4301 { | |
4302 pMouse->Activate(1); | |
4303 break; | |
4304 } | |
4305 _chdir("..\\"); | |
4306 strcpy(pCurrentMapName, ofn.lpstrFileTitle);*/ | |
4307 pMouse->Activate(1); | |
4308 pGame->Loop(); | |
4309 } | |
4310 } | |
4311 if ( uGameState == GAME_STATE_LOADING_GAME ) | |
4312 { | |
4313 SetCurrentMenuID(MENU_5); | |
4314 uGameState = GAME_STATE_PLAYING; | |
4315 continue; | |
4316 } | |
4317 if ( uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU ) | |
4318 { | 4214 { |
4319 SetCurrentMenuID(MENU_NEWGAME); | 4215 SetCurrentMenuID(MENU_NEWGAME); |
4320 uGameState = GAME_STATE_PLAYING; | 4216 uGameState = GAME_STATE_PLAYING; |
4321 continue; | 4217 continue; |
4322 } | 4218 } |
4323 if ( uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)// from the loaded game | 4219 else if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU) |
4220 break; | |
4221 assert(false && "Invalid game state"); | |
4222 } | |
4223 if (GetCurrentMenuID() == MENU_CREDITS) | |
4224 { | |
4225 if ( pAudioPlayer->hAILRedbook ) | |
4226 AIL_redbook_stop(pAudioPlayer->hAILRedbook); | |
4227 MainMenuUI_Credits_Loop(); | |
4228 break; | |
4229 } | |
4230 if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu) | |
4231 { | |
4232 uGameState = GAME_STATE_PLAYING; | |
4233 pGame->Loop(); | |
4234 } | |
4235 else | |
4236 { | |
4237 if (GetCurrentMenuID() == MENU_DebugBLVLevel) | |
4324 { | 4238 { |
4325 pAudioPlayer->StopChannels(-1, -1); | 4239 pMouse->ChangeActivation(0); |
4326 uGameState = GAME_STATE_PLAYING; | 4240 pParty->Reset(); |
4327 break; | 4241 pParty->CreateDefaultParty(1); |
4242 | |
4243 __debugbreak(); | |
4244 /*extern void CreateDefaultBLVLevel(); | |
4245 CreateDefaultBLVLevel(); | |
4246 | |
4247 OPENFILENAMEA ofn; | |
4248 if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) ) | |
4249 { | |
4250 pMouse->ChangeActivation(1); | |
4251 break; | |
4252 } | |
4253 _chdir("..\\"); | |
4254 strcpy(pCurrentMapName, ofn.lpstrFileTitle);*/ | |
4255 pMouse->ChangeActivation(1); | |
4256 pGame->Loop(); | |
4328 } | 4257 } |
4329 } | 4258 } |
4330 if (!bNoSound && pAudioPlayer->hAILRedbook) | 4259 if ( uGameState == GAME_STATE_LOADING_GAME ) |
4331 { | 4260 { |
4332 pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); | 4261 SetCurrentMenuID(MENU_5); |
4333 AIL_redbook_stop(pAudioPlayer->hAILRedbook); | 4262 uGameState = GAME_STATE_PLAYING; |
4334 unsigned int startms, end_ms; | 4263 continue; |
4335 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 0xE, &startms, &end_ms); | 4264 } |
4336 AIL_redbook_play(pAudioPlayer->hAILRedbook, startms + 1, end_ms); | 4265 if ( uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU ) |
4337 } | 4266 { |
4338 } | 4267 SetCurrentMenuID(MENU_NEWGAME); |
4268 uGameState = GAME_STATE_PLAYING; | |
4269 continue; | |
4270 } | |
4271 if ( uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)// from the loaded game | |
4272 { | |
4273 pAudioPlayer->StopChannels(-1, -1); | |
4274 uGameState = GAME_STATE_PLAYING; | |
4275 break; | |
4276 } | |
4277 } | |
4278 if (!bNoSound && pAudioPlayer->hAILRedbook) | |
4279 { | |
4280 pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); | |
4281 AIL_redbook_stop(pAudioPlayer->hAILRedbook); | |
4282 unsigned int startms, end_ms; | |
4283 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &startms, &end_ms); | |
4284 AIL_redbook_play(pAudioPlayer->hAILRedbook, startms + 1, end_ms); | |
4285 } | |
4286 } | |
4339 //lua_close(L); | 4287 //lua_close(L); |
4340 pGame->Deinitialize(); | 4288 pGame->Deinitialize(); |
4341 return 1; | 4289 return 1; |
4342 } | 4290 } |
4343 | 4291 |
4493 pODMRenderParams->outdoor_grid_band_3 = outdoor_grid_band_3; | 4441 pODMRenderParams->outdoor_grid_band_3 = outdoor_grid_band_3; |
4494 pODMRenderParams->uPickDepth = outdoor_grid_band_3 * 512; | 4442 pODMRenderParams->uPickDepth = outdoor_grid_band_3 * 512; |
4495 } | 4443 } |
4496 } | 4444 } |
4497 else | 4445 else |
4498 { | |
4499 LOBYTE(viewparams->field_20) = 0; | 4446 LOBYTE(viewparams->field_20) = 0; |
4500 } | |
4501 pParty->uFlags |= 2; | 4447 pParty->uFlags |= 2; |
4502 viewparams->uSomeY = viewparams->uScreen_topL_Y; | 4448 viewparams->uSomeY = viewparams->uScreen_topL_Y; |
4503 viewparams->uSomeX = viewparams->uScreen_topL_X; | 4449 viewparams->uSomeX = viewparams->uScreen_topL_X; |
4504 viewparams->uSomeZ = viewparams->uScreen_BttmR_X; | 4450 viewparams->uSomeZ = viewparams->uScreen_BttmR_X; |
4505 viewparams->uSomeW = viewparams->uScreen_BttmR_Y; | 4451 viewparams->uSomeW = viewparams->uScreen_BttmR_Y; |