comparison mm7_2.cpp @ 1590:5792fdafe2f5

Слияние
author Ritor1
date Wed, 11 Sep 2013 09:39:09 +0600
parents f408fbf3d9cc 75fafd8ced59
children 1efbaf1d01c3
comparison
equal deleted inserted replaced
1589:f408fbf3d9cc 1590:5792fdafe2f5
34 #include "IndoorCamera.h" 34 #include "IndoorCamera.h"
35 #include "Overlays.h" 35 #include "Overlays.h"
36 #include "Arcomage.h" 36 #include "Arcomage.h"
37 #include "LOD.h" 37 #include "LOD.h"
38 #include "Actor.h" 38 #include "Actor.h"
39 #include "Allocator.h"
40 #include "Events.h" 39 #include "Events.h"
41 #include "Viewport.h" 40 #include "Viewport.h"
42 #include "FrameTableInc.h" 41 #include "FrameTableInc.h"
43 #include "Math.h" 42 #include "Math.h"
44 #include "SpriteObject.h" 43 #include "SpriteObject.h"
343 if ( v5 ) 342 if ( v5 )
344 { 343 {
345 do 344 do
346 { 345 {
347 v6 = v5->pNext; 346 v6 = v5->pNext;
348 pAllocator->FreeChunk(v5); 347 free(v5);
349 v5 = v6; 348 v5 = v6;
350 } 349 }
351 while ( v6 ); 350 while ( v6 );
352 } 351 }
353 pDialogueWindow->pControlsHead = 0; 352 pDialogueWindow->pControlsHead = 0;
778 pRenderer->EndScene(); 777 pRenderer->EndScene();
779 pRenderer->Present(); 778 pRenderer->Present();
780 if ( pRenderer->pRenderD3D ) 779 if ( pRenderer->pRenderD3D )
781 pRenderer->pBeforePresentFunction(); 780 pRenderer->pBeforePresentFunction();
782 pRenderer->_49F1BC("MM7_Win.Pcx"); 781 pRenderer->_49F1BC("MM7_Win.Pcx");
783 pAllocator->FreeChunk(pFont); 782 free(pFont);
784 window_SpeakInHouse->Release(); 783 window_SpeakInHouse->Release();
785 window_SpeakInHouse = 0; 784 window_SpeakInHouse = 0;
786 if ( v15 == (void *)2 ) 785 if ( v15 == (void *)2 )
787 { 786 {
788 result = pMessageQueue_50CBD0->uNumMessages; 787 result = pMessageQueue_50CBD0->uNumMessages;
2062 v2 <<= field_40; 2061 v2 <<= field_40;
2063 return v2 | ((a2 & field_0.field_10) << field_48) | ((a2 & field_0.field_14) << field_50) | ((a2 & field_0.field_18) << field_58); 2062 return v2 | ((a2 & field_0.field_10) << field_48) | ((a2 & field_0.field_14) << field_50) | ((a2 & field_0.field_18) << field_58);
2064 } 2063 }
2065 2064
2066 //----- (00452442) -------------------------------------------------------- 2065 //----- (00452442) --------------------------------------------------------
2067 unsigned int __fastcall sub_452442(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4) 2066 unsigned int __fastcall _452442_color_cvt(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4)
2068 { 2067 {
2069 int v4; // ebx@0 2068 int v4; // ebx@0
2070 __int16 v5; // ST14_2@1 2069 __int16 v5; // ST14_2@1
2071 __int16 v6; // dx@1 2070 __int16 v6; // dx@1
2072 int v7; // ecx@1 2071 int v7; // ecx@1
2355 char* tmp_pos; 2354 char* tmp_pos;
2356 int decode_step; 2355 int decode_step;
2357 int item_counter; 2356 int item_counter;
2358 2357
2359 if ( pMapStatsTXT_Raw ) 2358 if ( pMapStatsTXT_Raw )
2360 pAllocator->FreeChunk(pMapStatsTXT_Raw); 2359 free(pMapStatsTXT_Raw);
2361 pMapStatsTXT_Raw = NULL; 2360 pMapStatsTXT_Raw = NULL;
2362 pMapStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("MapStats.txt", 0); 2361 pMapStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("MapStats.txt", 0);
2363 strtok(pMapStatsTXT_Raw, "\r"); 2362 strtok(pMapStatsTXT_Raw, "\r");
2364 strtok(NULL, "\r"); 2363 strtok(NULL, "\r");
2365 strtok(NULL, "\r"); 2364 strtok(NULL, "\r");
2692 char* tmp_pos; 2691 char* tmp_pos;
2693 int decode_step; 2692 int decode_step;
2694 int item_counter; 2693 int item_counter;
2695 2694
2696 if ( pHostileTXT_Raw ) 2695 if ( pHostileTXT_Raw )
2697 pAllocator->FreeChunk(pHostileTXT_Raw); 2696 free(pHostileTXT_Raw);
2698 pHostileTXT_Raw = NULL; 2697 pHostileTXT_Raw = NULL;
2699 pHostileTXT_Raw = (char *)pEvents_LOD->LoadRaw("hostile.txt", 0); 2698 pHostileTXT_Raw = (char *)pEvents_LOD->LoadRaw("hostile.txt", 0);
2700 strtok(pHostileTXT_Raw, "\r"); 2699 strtok(pHostileTXT_Raw, "\r");
2701 for (i=0; i<89; ++i) 2700 for (i=0; i<89; ++i)
2702 { 2701 {
2729 test_string=tmp_pos+1; 2728 test_string=tmp_pos+1;
2730 } while ((decode_step<92)&&!break_loop); 2729 } while ((decode_step<92)&&!break_loop);
2731 } 2730 }
2732 if ( pHostileTXT_Raw) 2731 if ( pHostileTXT_Raw)
2733 { 2732 {
2734 pAllocator->FreeChunk(pHostileTXT_Raw); 2733 free(pHostileTXT_Raw);
2735 pHostileTXT_Raw = NULL; 2734 pHostileTXT_Raw = NULL;
2736 } 2735 }
2737 } 2736 }
2738 2737
2739 //----- (00458244) -------------------------------------------------------- 2738 //----- (00458244) --------------------------------------------------------
3754 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 3753 return DefWindowProcA(hWnd, uMsg, wParam, lParam);
3755 } 3754 }
3756 } 3755 }
3757 3756
3758 //----- (00464479) -------------------------------------------------------- 3757 //----- (00464479) --------------------------------------------------------
3759 void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows() 3758 void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows()
3760 { 3759 {
3761 int v0; // esi@9 3760 int v0; // esi@9
3762 3761
3763 if (pMouse) 3762 if (pMouse)
3764 pMouse->SetCursorBitmap("MICON1"); 3763 pMouse->SetCursorBitmap("MICON1");
3774 } 3773 }
3775 sub_46080D(); 3774 sub_46080D();
3776 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) 3775 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
3777 pIndoor->Release(); 3776 pIndoor->Release();
3778 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) 3777 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
3779 pOutdoor->Release2(); 3778 pOutdoor->Release();
3780 3779
3781 pAudioPlayer->StopChannels(-1, -1); 3780 pAudioPlayer->StopChannels(-1, -1);
3782 pSoundList->_4A9D79(0); 3781 pSoundList->_4A9D79(0);
3783 uCurrentlyLoadedLevelType = LEVEL_null; 3782 uCurrentlyLoadedLevelType = LEVEL_null;
3784 pSpriteFrameTable->ResetSomeSpriteFlags(); 3783 pSpriteFrameTable->ResetSomeSpriteFlags();
3802 pMiscTimer->Resume(); 3801 pMiscTimer->Resume();
3803 pEventTimer->Resume(); 3802 pEventTimer->Resume();
3804 } 3803 }
3805 3804
3806 //----- (00464761) -------------------------------------------------------- 3805 //----- (00464761) --------------------------------------------------------
3807 void Game_DeinitializeAndTerminate(int exitCode) 3806 void Game_DeinitializeAndTerminate(int exitCode)
3808 { 3807 {
3809 int v1; // esi@1 3808 SetPriorityClass(GetCurrentProcess(), 0x20u);
3810 HANDLE v2; // eax@1
3811
3812 v1 = exitCode;
3813 v2 = GetCurrentProcess();
3814 SetPriorityClass(v2, 0x20u);
3815 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); 3809 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows();
3816 pGame->Deinitialize(); 3810 pGame->Deinitialize();
3817 pRenderer->Release2(); 3811 pRenderer->Release2();
3818 if ( !DestroyWindow(hWnd) ) 3812 if ( !DestroyWindow(hWnd) )
3819 GetLastError(); 3813 GetLastError();
3820 hWnd = 0; 3814 hWnd = 0;
3821 exit(v1); 3815 exit(exitCode);
3822 } 3816 }
3823 3817
3824 //----- (004647AB) -------------------------------------------------------- 3818 //----- (004647AB) --------------------------------------------------------
3825 void FinalInitialization() 3819 void FinalInitialization()
3826 { 3820 {
3837 pIcons_LOD->_inlined_sub1(); 3831 pIcons_LOD->_inlined_sub1();
3838 } 3832 }
3839 // 6BE3A0: using guessed type float flt_6BE3A0; 3833 // 6BE3A0: using guessed type float flt_6BE3A0;
3840 3834
3841 //----- (00464839) -------------------------------------------------------- 3835 //----- (00464839) --------------------------------------------------------
3842 char Is_out15odm_underwater() 3836 char Is_out15odm_underwater()
3843 { 3837 {
3844 return _stricmp(pCurrentMapName, "out15.odm") == 0; 3838 return _stricmp(pCurrentMapName, "out15.odm") == 0;
3845 } 3839 }
3846 3840
3847 //----- (00464851) -------------------------------------------------------- 3841 //----- (00464851) --------------------------------------------------------
3848 void SetUnderwaterFog() 3842 void SetUnderwaterFog()
3849 { 3843 {
3850 day_fogrange_1 = 50; 3844 day_fogrange_1 = 50;
3851 day_fogrange_2 = 5000; 3845 day_fogrange_2 = 5000;
3852 } 3846 }
3853 3847
3886 uLevelMapStatsID = v5; 3880 uLevelMapStatsID = v5;
3887 pGame->uFlags2 &= 0xFFFFFFF7u; 3881 pGame->uFlags2 &= 0xFFFFFFF7u;
3888 if ( !_stricmp(pCurrentMapName, "out15.odm") ) 3882 if ( !_stricmp(pCurrentMapName, "out15.odm") )
3889 { 3883 {
3890 bUnderwater = true; 3884 bUnderwater = true;
3891 pGame->uFlags2 |= 8u; 3885 pGame->uFlags2 |= GAME_FLAGS_2_ALTER_GRAVITY;
3892 } 3886 }
3893 pParty->floor_face_pid = 0; 3887 pParty->floor_face_pid = 0;
3894 if ( _stricmp(Str1, "blv") ) 3888 if ( _stricmp(Str1, "blv") )
3895 PrepareToLoadODM(v9, 0); 3889 PrepareToLoadODM(v9, 0);
3896 else 3890 else
3897 PrepareToLoadBLV(v9); 3891 PrepareToLoadBLV(v9);
3898 pAudioPlayer->SetMapEAX(); 3892 pAudioPlayer->SetMapEAX();
3899 _461103_load_level_sub(); 3893 _461103_load_level_sub();
3900 if ( !_stricmp(pCurrentMapName, "d11.blv") || !_stricmp(pCurrentMapName, "d10.blv") ) 3894 if ( !_stricmp(pCurrentMapName, "d11.blv") || !_stricmp(pCurrentMapName, "d10.blv") )
3901 { 3895 {
3902 //spawning grounds & good analogue - no loot & exp from monsters 3896 //spawning grounds & walls of mist - no loot & exp from monsters
3903 3897
3904 for (uint i = 0; i < uNumActors; ++i) 3898 for (uint i = 0; i < uNumActors; ++i)
3905 { 3899 {
3906 pActors[i].pMonsterInfo.uTreasureType = 0; 3900 pActors[i].pMonsterInfo.uTreasureType = 0;
3907 pActors[i].pMonsterInfo.uTreasureDiceRolls = 0; 3901 pActors[i].pMonsterInfo.uTreasureDiceRolls = 0;
4513 { 4507 {
4514 Log::Warning(L"Render failed to initialize"); 4508 Log::Warning(L"Render failed to initialize");
4515 return false; 4509 return false;
4516 } 4510 }
4517 } 4511 }
4518
4519 pAllocator = Allocator::Create();
4520 if (!pAllocator->Initialize(48 * 1024))
4521 {
4522 MessageBoxW(nullptr,
4523 L"Unable to Allocate 48Mb of RAM",
4524 L"More RAM Memory Required", MB_ICONEXCLAMATION);
4525 return false;
4526 }
4527 4512
4528 game_starting_year = 1168; 4513 game_starting_year = 1168;
4529 4514
4530 pParty = new Party; 4515 pParty = new Party;
4531 memset(&pParty->pHirelings, 0, sizeof(pParty->pHirelings)); 4516 memset(&pParty->pHirelings, 0, sizeof(pParty->pHirelings));
4978 dword_576E28 = 9; 4963 dword_576E28 = 9;
4979 } 4964 }
4980 4965
4981 void IntegrityTest() 4966 void IntegrityTest()
4982 { 4967 {
4968 assert(sizeof(MovieHeader) == 44);
4983 assert(sizeof(SoundDesc_mm6) == 112); 4969 assert(sizeof(SoundDesc_mm6) == 112);
4984 assert(sizeof(SoundDesc) == 120); 4970 assert(sizeof(SoundDesc) == 120);
4985 assert(sizeof(OverlayDesc) == 8); 4971 assert(sizeof(OverlayDesc) == 8);
4986 assert(sizeof(ChestDesc) == 36); 4972 assert(sizeof(ChestDesc) == 36);
4987 assert(sizeof(ObjectDesc_mm6) == 52); 4973 assert(sizeof(ObjectDesc_mm6) == 52);