comparison mm7_2.cpp @ 1055:010a844ef4a0

Слияние
author Ritor1
date Wed, 22 May 2013 22:23:04 +0600
parents 3a5c8df8381d
children 39f42990698f
comparison
equal deleted inserted replaced
1054:5520fdca7a74 1055:010a844ef4a0
1 #include <io.h> 1 #include <io.h>
2 #include <direct.h> 2 #include <direct.h>
3 #include <assert.h> 3 #include <assert.h>
4 4 #include <windows.h>
5
6
7 #include "VideoPlayer.h"
8 #include "Sprites.h"
9 #include "BSPModel.h"
10 #include "OutdoorCamera.h"
11
12 #include "LightmapBuilder.h"
13 #include "DecalBuilder.h"
14 #include "ParticleEngine.h"
15 #include "Mouse.h"
16 #include "Keyboard.h"
17 #include "CShow.h"
18 #include "GammaControl.h"
19 #include "stru6.h"
20
21 #include "Vis.h"
5 #include "MapInfo.h" 22 #include "MapInfo.h"
6 #include "Game.h" 23 #include "Game.h"
7 #include "GUIWindow.h" 24 #include "GUIWindow.h"
8 #include "GUIFont.h" 25 #include "GUIFont.h"
9 #include "Party.h" 26 #include "Party.h"
10 #include "AudioPlayer.h" 27 #include "AudioPlayer.h"
11 #include "Outdoor.h" 28 #include "Outdoor.h"
12 #include "IndoorCamera.h" 29 #include "IndoorCamera.h"
13 #include "Overlays.h" 30 #include "Overlays.h"
14 #include "Monsters.h"
15 #include "Arcomage.h" 31 #include "Arcomage.h"
16 #include "LOD.h" 32 #include "LOD.h"
17 #include "Actor.h" 33 #include "Actor.h"
18 #include "Allocator.h" 34 #include "Allocator.h"
19 #include "Events.h" 35 #include "Events.h"
30 #include "stru176.h" 46 #include "stru176.h"
31 #include "Time.h" 47 #include "Time.h"
32 #include "IconFrameTable.h" 48 #include "IconFrameTable.h"
33 #include "GUIProgressBar.h" 49 #include "GUIProgressBar.h"
34 #include "Bink_Smacker.h" 50 #include "Bink_Smacker.h"
35 #include "TileFrameTable.h"
36 #include "PlayerFrameTable.h" 51 #include "PlayerFrameTable.h"
37 #include "Awards.h"
38 #include "Autonotes.h"
39 #include "stru160.h"
40 #include "TurnEngine.h" 52 #include "TurnEngine.h"
41 #include "FactionTable.h" 53 #include "FactionTable.h"
42 #include "StorylineTextTable.h" 54 #include "StorylineTextTable.h"
43 #include "Random.h" 55 #include "Random.h"
44 #include "CastSpellInfo.h" 56 #include "CastSpellInfo.h"
45 #include "stru298.h" 57 #include "stru298.h"
46 #include "stru12.h"
47 #include "Events2D.h" 58 #include "Events2D.h"
48 #include "stru159.h"
49 #include "Log.h" 59 #include "Log.h"
50 #include "UIHouses.h" 60 #include "UIHouses.h"
51 #include "texts.h" 61 #include "texts.h"
52 #include "mm7_data.h" 62 #include "mm7_data.h"
53 #include "MM7.h" 63 #include "MM7.h"
852 } 862 }
853 pDialogueNPCCount = 0; 863 pDialogueNPCCount = 0;
854 pDialogueWindow->Release(); 864 pDialogueWindow->Release();
855 dialog_menu_id = HOUSE_DIALOGUE_NULL; 865 dialog_menu_id = HOUSE_DIALOGUE_NULL;
856 pDialogueWindow = 0; 866 pDialogueWindow = 0;
857 pIcons_LOD->_40F9C5(); 867 pIcons_LOD->SyncLoadedFilesCount();
858 v1 = uNumDialogueNPCPortraits; 868 v1 = uNumDialogueNPCPortraits;
859 if ( uNumDialogueNPCPortraits != 1 ) 869 if ( uNumDialogueNPCPortraits != 1 )
860 { 870 {
861 v2 = 0; 871 v2 = 0;
862 pBtn_ExitCancel = window_SpeakInHouse->pControlsHead; 872 pBtn_ExitCancel = window_SpeakInHouse->pControlsHead;
938 { 948 {
939 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); 949 PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2);
940 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); 950 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);
941 return; 951 return;
942 } 952 }
943 taken_item = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, bought_item->uItemID); 953 taken_item = pPlayers[uActiveCharacter]->AddItem(-1, bought_item->uItemID);
944 if ( taken_item ) 954 if ( taken_item )
945 { 955 {
946 bought_item->SetIdentified(); 956 bought_item->SetIdentified();
947 memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[taken_item - 1], bought_item, 0x24u); 957 memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[taken_item - 1], bought_item, 0x24u);
948 dword_F8B1E4 = 1; 958 dword_F8B1E4 = 1;
1096 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" 1106 ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold"
1097 return; 1107 return;
1098 } 1108 }
1099 } 1109 }
1100 } 1110 }
1101 v39 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, bought_item->uItemID); 1111 v39 = pPlayers[uActiveCharacter]->AddItem(-1, bought_item->uItemID);
1102 if ( v39 ) 1112 if ( v39 )
1103 { 1113 {
1104 bought_item->SetIdentified(); 1114 bought_item->SetIdentified();
1105 memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v39 - 1], bought_item, sizeof(ItemGen)); 1115 memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v39 - 1], bought_item, sizeof(ItemGen));
1106 if ( pPlayers[uActiveCharacter]->CanSteal() ) 1116 if ( pPlayers[uActiveCharacter]->CanSteal() )
6661 { 6671 {
6662 pTexture_PCX.Release(); 6672 pTexture_PCX.Release();
6663 pTexture_PCX.Load("lsave640.pcx", 0); 6673 pTexture_PCX.Load("lsave640.pcx", 0);
6664 pGUIWindow2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0); 6674 pGUIWindow2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
6665 pCurrentScreen = SCREEN_LOADGAME; 6675 pCurrentScreen = SCREEN_LOADGAME;
6666 GameUI_DrawLoadMenu(0); 6676 LoadUI_Load(0);
6667 } 6677 }
6668 pWindow = pGUIWindow_CurrentMenu; 6678 pWindow = pGUIWindow_CurrentMenu;
6669 } 6679 }
6670 6680
6671 MSG msg; 6681 MSG msg;
6874 pParty->alignment = PartyAlignment_Evil; 6884 pParty->alignment = PartyAlignment_Evil;
6875 SetUserInterface(pParty->alignment, true); 6885 SetUserInterface(pParty->alignment, true);
6876 return 0; 6886 return 0;
6877 6887
6878 //SubMenu "Time" 6888 //SubMenu "Time"
6879 case 40009: pParty->uTimePlayed += Day; return 0; 6889 case 40009: pParty->uTimePlayed += Timer::Day; return 0;
6880 case 40010: pParty->uTimePlayed += Week; return 0; 6890 case 40010: pParty->uTimePlayed += Timer::Week; return 0;
6881 case 40011: pParty->uTimePlayed += Month; return 0; 6891 case 40011: pParty->uTimePlayed += Timer::Month; return 0;
6882 case 40012: pParty->uTimePlayed += Year; return 0; 6892 case 40012: pParty->uTimePlayed += Timer::Year; return 0;
6883 6893
6884 //SubMenu "Items" 6894 //SubMenu "Items"
6885 case 40015: 6895 case 40015:
6886 { 6896 {
6887 int pItemID = rand() % 500; 6897 int pItemID = rand() % 500;
7223 //goto _def_wnd_proc; 7233 //goto _def_wnd_proc;
7224 return DefWindowProcA(hWnd, Msg, wParam, lParam); 7234 return DefWindowProcA(hWnd, Msg, wParam, lParam);
7225 } 7235 }
7226 return DefWindowProcA(hWnd, Msg, wParam, lParam); 7236 return DefWindowProcA(hWnd, Msg, wParam, lParam);
7227 } 7237 }
7228 if ( dword_506E68 != -1 ) 7238 if ( uGameMenuUI_CurentlySelectedKeyIdx != -1 )
7229 { 7239 {
7230 pKeyActionMap->_459F10(wParam); 7240 pKeyActionMap->_459F10(wParam);
7231 return DefWindowProcA(hWnd, Msg, wParam, lParam); 7241 return DefWindowProcA(hWnd, Msg, wParam, lParam);
7232 } 7242 }
7233 if ( !pArcomageGame->bGameInProgress ) 7243 if ( !pArcomageGame->bGameInProgress )
9499 } 9509 }
9500 if (GetCurrentMenuID() == MENU_CREDITS) 9510 if (GetCurrentMenuID() == MENU_CREDITS)
9501 { 9511 {
9502 if ( pAudioPlayer->hAILRedbook ) 9512 if ( pAudioPlayer->hAILRedbook )
9503 AIL_redbook_stop(pAudioPlayer->hAILRedbook); 9513 AIL_redbook_stop(pAudioPlayer->hAILRedbook);
9504 extern MENU_STATE __cdecl CreditsMenu__Loop(); 9514 MainMenuUI_Credits_Loop();
9505 CreditsMenu__Loop();
9506 break; 9515 break;
9507 } 9516 }
9508 if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu) 9517 if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu)
9509 { 9518 {
9510 uGameState = GAME_STATE_PLAYING; 9519 uGameState = GAME_STATE_PLAYING;
9922 } 9931 }
9923 } 9932 }
9924 } 9933 }
9925 9934
9926 //----- (00467F48) -------------------------------------------------------- 9935 //----- (00467F48) --------------------------------------------------------
9927 void __fastcall sub_467F48(signed int a1) 9936 void CreateMsgScrollWindow( signed int mscroll_id )
9928 { 9937 {
9929 signed int v1; // esi@1 9938 signed int v1; // esi@1
9930 9939
9931 v1 = a1; 9940 v1 = mscroll_id;
9932 if ( !pGUIWindow_ScrollWindow && a1 >= 700 ) 9941 if ( !pGUIWindow_ScrollWindow && mscroll_id >= 700 )
9933 { 9942 {
9934 if ( a1 <= 782 ) 9943 if ( mscroll_id <= 782 )
9935 { 9944 {
9936 uTextureID_720980 = pIcons_LOD->LoadTexture("leather", TEXTURE_16BIT_PALETTE); 9945 uTextureID_720980 = pIcons_LOD->LoadTexture("leather", TEXTURE_16BIT_PALETTE);
9937 pGUIWindow_ScrollWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Scroll, v1 - 700, 0); 9946 pGUIWindow_ScrollWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Scroll, v1 - 700, 0);
9938 } 9947 }
9939 } 9948 }
9949 pGUIWindow_ScrollWindow = 0; 9958 pGUIWindow_ScrollWindow = 0;
9950 } 9959 }
9951 } 9960 }
9952 9961
9953 //----- (00467FB6) -------------------------------------------------------- 9962 //----- (00467FB6) --------------------------------------------------------
9954 char __cdecl CreateScrollWindow() 9963 void CreateScrollWindow()
9955 { 9964 {
9956 unsigned int v0; // eax@1 9965 unsigned int v0; // eax@1
9957 char *v1; // ST18_4@3 9966 char *v1; // ST18_4@3
9958 unsigned int v2; // eax@3 9967 unsigned int v2; // eax@3
9959 GUIWindow a1; // [sp+Ch] [bp-54h]@1 9968 GUIWindow a1; // [sp+Ch] [bp-54h]@1
9960 9969
9983 a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1; 9992 a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1;
9984 v1 = pItemsTable->pItems[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C + 700].pName; 9993 v1 = pItemsTable->pItems[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C + 700].pName;
9985 v2 = TargetColor(0xFFu, 0xFFu, 0x9Bu); 9994 v2 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
9986 sprintf(pTmpBuf, format_4E2D80, v2, v1); 9995 sprintf(pTmpBuf, format_4E2D80, v2, v1);
9987 a1.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf, 3u); 9996 a1.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf, 3u);
9988 return a1.DrawText( 9997 a1.DrawText(
9989 pFontSmallnum, 9998 pFontSmallnum,
9990 1, 9999 1,
9991 LOBYTE(pFontCreate->uFontHeight) - 3, 10000 LOBYTE(pFontCreate->uFontHeight) - 3,
9992 0, 10001 0,
9993 pScrolls[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C], 10002 pScrolls[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C],
10542 int v22; // [sp+1Ch] [bp-4h]@4 10551 int v22; // [sp+1Ch] [bp-4h]@4
10543 10552
10544 if ( pRenderer->pRenderD3D ) 10553 if ( pRenderer->pRenderD3D )
10545 { 10554 {
10546 pGame->PickKeyboard(GetAsyncKeyState(VK_CONTROL) & 0x8001, &vis_sprite_filter_3, &vis_door_filter); 10555 pGame->PickKeyboard(GetAsyncKeyState(VK_CONTROL) & 0x8001, &vis_sprite_filter_3, &vis_door_filter);
10547 v1 = (int *)pGame->pVisInstance->get_picked_object_zbuf_val(); 10556 auto pid = pGame->pVisInstance->get_picked_object_zbuf_val();
10548 if ( v1 != (int *)-1 ) 10557 if ( pid != -1 )
10549 DoInteractionWithTopmostZObject((unsigned __int16)v1, (signed int)(unsigned __int16)v1 >> 3); 10558 DoInteractionWithTopmostZObject(pid & 0xFFFF, PID_ID(pid));
10550 } 10559 }
10560
10551 v22 = 0; 10561 v22 = 0;
10552 v1 = (int *)((signed int)(viewparams->uScreen_BttmR_X + viewparams->uScreen_topL_X) >> 1);//wrong pointer 10562 v1 = (int *)((signed int)(viewparams->uScreen_BttmR_X + viewparams->uScreen_topL_X) >> 1);//wrong pointer
10553 if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y ) 10563 if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y )
10554 { 10564 {
10555 v2 = (char *)v1 - 50; 10565 v2 = (char *)v1 - 50;
10654 { 10664 {
10655 int v2; // edx@1 10665 int v2; // edx@1
10656 BLVFace *v4; // eax@9 10666 BLVFace *v4; // eax@9
10657 unsigned int v5; // ecx@9 10667 unsigned int v5; // ecx@9
10658 unsigned __int16 v6; // ax@11 10668 unsigned __int16 v6; // ax@11
10659 ODMFace *v7; // eax@16 10669 //ODMFace *v7; // eax@16
10660 LevelDecoration *v8; // esi@19 10670 LevelDecoration *v8; // esi@19
10661 __int16 v9; // ax@19 10671 __int16 v9; // ax@19
10662 int v10; // eax@22 10672 int v10; // eax@22
10663 int v11; // ecx@22 10673 int v11; // ecx@22
10664 int v12; // edi@23 10674 int v12; // edi@23
10780 activeLevelDecoration = NULL; 10790 activeLevelDecoration = NULL;
10781 } 10791 }
10782 break; 10792 break;
10783 10793
10784 default: 10794 default:
10785 if ( PID_TYPE(a1) != OBJECT_BModel) 10795 MessageBoxW(nullptr, L"Warning: Invalid ID reached!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Mouse.cpp:2020", 0);
10786 { 10796 return 1;
10787 MessageBoxW(nullptr, L"Warning: Invalid ID reached!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Mouse.cpp:2020", 0); 10797
10788 return 1; 10798 case OBJECT_BModel:
10789 } 10799 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
10790 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor ) 10800 {
10791 { 10801 int bmodel_id = a1 >> 9,
10792 if ( a1 >> 9 >= pOutdoor->uNumBModels 10802 face_id = PID_ID(a1) &0x3F;
10793 || (v7 = &pOutdoor->pBModels[a1 >> 9].pFaces[(PID_ID(a1)) & 0x3F], BYTE2(v7->uAttributes) & 0x10) 10803 if (bmodel_id >= pOutdoor->uNumBModels)
10794 || (v6 = v7->sCogTriggeredID) == 0 ) 10804 return 1;
10805 auto face = &pOutdoor->pBModels[bmodel_id].pFaces[face_id];
10806 if (face->uAttributes & 0x100000 || (v6 = face->sCogTriggeredID) == 0 )
10795 return 1; 10807 return 1;
10796 EventProcessor((signed __int16)v6, v2, 1); 10808 EventProcessor((signed __int16)v6, v2, 1);
10797 return 0; 10809 }
10798 } 10810 else
10799 v4 = &pIndoor->pFaces[PID_ID(a1)]; 10811 {
10800 v5 = v4->uAttributes; 10812 v4 = &pIndoor->pFaces[PID_ID(a1)];
10801 if ( !(v5 & 0x2000000) ) 10813 v5 = v4->uAttributes;
10802 { 10814 if ( !(v5 & 0x2000000) )
10803 ShowNothingHereStatus(); 10815 {
10804 return 1; 10816 ShowNothingHereStatus();
10805 } 10817 return 1;
10806 if ( v5 & 0x100000 || (v6 = pIndoor->pFaceExtras[v4->uFaceExtraID].uEventID) == 0 ) 10818 }
10807 return 1; 10819 if ( v5 & 0x100000 || (v6 = pIndoor->pFaceExtras[v4->uFaceExtraID].uEventID) == 0 )
10808 if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG ) 10820 return 1;
10809 { 10821 if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG )
10810 EventProcessor((signed __int16)v6, v2, 1); 10822 EventProcessor((signed __int16)v6, v2, 1);
10811 return 0; 10823 }
10812 } 10824 return 0;
10813 break; 10825 break;
10814 } 10826 }
10815 return 0; 10827 return 0;
10816 } 10828 }
10817 // 4E28F8: using guessed type int pCurrentScreen; 10829 // 4E28F8: using guessed type int pCurrentScreen;
11320 pParty->vPosition.y = 22528; 11332 pParty->vPosition.y = 22528;
11321 } 11333 }
11322 else 11334 else
11323 { 11335 {
11324 pAudioPlayer->StopChannels(-1, -1); 11336 pAudioPlayer->StopChannels(-1, -1);
11325 UI_CreateTravelDialogue(); 11337 TravelUI_Load();
11326 } 11338 }
11327 } 11339 }
11328 UpdateActors_ODM(); 11340 UpdateActors_ODM();
11329 check_event_triggers(); 11341 check_event_triggers();
11330 } 11342 }