Mercurial > mm7
comparison Game.cpp @ 2463:0f17a30149ec
cleaning project part 1
author | zipi |
---|---|
date | Sun, 17 Aug 2014 15:13:18 +0100 |
parents | ff7f4995aa25 |
children | 104fdbea0386 |
comparison
equal
deleted
inserted
replaced
2462:1d04e48651d4 | 2463:0f17a30149ec |
---|---|
22 #include "Game.h" | 22 #include "Game.h" |
23 #include "Party.h" | 23 #include "Party.h" |
24 #include "Viewport.h" | 24 #include "Viewport.h" |
25 #include "Timer.h" | 25 #include "Timer.h" |
26 #include "Outdoor.h" | 26 #include "Outdoor.h" |
27 #include "Outdoor_stuff.h" | |
28 #include "Overlays.h" | 27 #include "Overlays.h" |
29 #include "AudioPlayer.h" | 28 #include "AudioPlayer.h" |
30 #include "LOD.h" | 29 #include "LOD.h" |
31 #include "GUIWindow.h" | 30 #include "GUIWindow.h" |
32 #include "TurnEngine.h" | 31 #include "TurnEngine.h" |
56 #include "Sprites.h" | 55 #include "Sprites.h" |
57 #include "Registry.h" | 56 #include "Registry.h" |
58 #include "Chest.h" | 57 #include "Chest.h" |
59 | 58 |
60 #include "UI\UIGame.h" | 59 #include "UI\UIGame.h" |
60 | |
61 #include "DecorationList.h" | |
62 #include "IconFrameTable.h" | |
63 #include "PlayerFrameTable.h" | |
64 #include "MapsLongTimer.h" | |
65 #include "StorylineTextTable.h" | |
66 #include "FactionTable.h" | |
67 #include "stru123.h" | |
68 #include "LuaVM.h" | |
69 #include "RenderD3D11.h" | |
70 #include "MMT.h" | |
71 #include "NewUI\MainMenu.h" | |
72 #include <direct.h> | |
73 | |
61 | 74 |
62 | 75 |
63 | 76 |
64 | 77 |
65 Game *pGame; | 78 Game *pGame; |
4468 { | 4481 { |
4469 pAudioPlayer->PlaySound(SOUND_Button2, -2, 0, -1, 0, 0, 0, 0); | 4482 pAudioPlayer->PlaySound(SOUND_Button2, -2, 0, -1, 0, 0, 0, 0); |
4470 pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pBtn_ExitCancel->pTextures[0]); | 4483 pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pBtn_ExitCancel->pTextures[0]); |
4471 pRenderer->Present(); | 4484 pRenderer->Present(); |
4472 } | 4485 } |
4486 | |
4487 //----- (0046BDC0) -------------------------------------------------------- | |
4488 void UpdateUserInput_and_MapSpecificStuff() | |
4489 { | |
4490 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0080_SKIP_USER_INPUT_THIS_FRAME) | |
4491 { | |
4492 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0080_SKIP_USER_INPUT_THIS_FRAME; | |
4493 return; | |
4494 } | |
4495 | |
4496 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
4497 BLV_UpdateUserInputAndOther(); | |
4498 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
4499 ODM_UpdateUserInputAndOther(); | |
4500 | |
4501 area_of_effect__damage_evaluate(); | |
4502 } | |
4503 | |
4504 //----- (004646F0) -------------------------------------------------------- | |
4505 void PrepareWorld(unsigned int _0_box_loading_1_fullscreen) | |
4506 { | |
4507 //if ( pRenderer->pRenderD3D ) | |
4508 pGame->pVisInstance->_4C1A02(); | |
4509 pEventTimer->Pause(); | |
4510 pMiscTimer->Pause(); | |
4511 pParty->uFlags = 2; | |
4512 CastSpellInfoHelpers::_427D48(); | |
4513 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); | |
4514 DoPrepareWorld(0, (_0_box_loading_1_fullscreen == 0) + 1); | |
4515 pMiscTimer->Resume(); | |
4516 pEventTimer->Resume(); | |
4517 } | |
4518 | |
4519 //----- (00464866) -------------------------------------------------------- | |
4520 void DoPrepareWorld(unsigned int bLoading, int _1_fullscreen_loading_2_box) | |
4521 { | |
4522 char *v3; // eax@1 | |
4523 unsigned int v5; // eax@3 | |
4524 char Str1[20]; // [sp+Ch] [bp-18h]@1 | |
4525 unsigned int v9; // [sp+20h] [bp-4h]@1 | |
4526 | |
4527 v9 = bLoading; | |
4528 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); | |
4529 pDecalBuilder->Reset(0); | |
4530 pGameLoadingUI_ProgressBar->Initialize(_1_fullscreen_loading_2_box == 1 ? GUIProgressBar::TYPE_Fullscreen : | |
4531 GUIProgressBar::TYPE_Box); | |
4532 strcpy(Str1, pCurrentMapName); | |
4533 v3 = strtok(Str1, "."); | |
4534 strcpy(Str1, v3); | |
4535 Level_LoadEvtAndStr(Str1); | |
4536 LoadLevel_InitializeLevelEvt(); | |
4537 strcpy(Str1, pCurrentMapName); | |
4538 _strrev(Str1); | |
4539 strtok(Str1, "."); | |
4540 _strrev(Str1); | |
4541 | |
4542 for (uint i = 0; i < 1000; ++i) | |
4543 pSpriteObjects[i].uObjectDescID = 0; | |
4544 | |
4545 v5 = pMapStats->GetMapInfo(pCurrentMapName); | |
4546 bUnderwater = false; | |
4547 uLevelMapStatsID = v5; | |
4548 pGame->uFlags2 &= 0xFFFFFFF7u; | |
4549 if (!_stricmp(pCurrentMapName, "out15.odm")) | |
4550 { | |
4551 bUnderwater = true; | |
4552 pGame->uFlags2 |= GAME_FLAGS_2_ALTER_GRAVITY; | |
4553 } | |
4554 pParty->floor_face_pid = 0; | |
4555 if (_stricmp(Str1, "blv")) | |
4556 PrepareToLoadODM(v9, 0); | |
4557 else | |
4558 PrepareToLoadBLV(v9); | |
4559 pAudioPlayer->SetMapEAX(); | |
4560 _461103_load_level_sub(); | |
4561 if (!_stricmp(pCurrentMapName, "d11.blv") || !_stricmp(pCurrentMapName, "d10.blv")) | |
4562 { | |
4563 //spawning grounds & walls of mist - no loot & exp from monsters | |
4564 | |
4565 for (uint i = 0; i < uNumActors; ++i) | |
4566 { | |
4567 pActors[i].pMonsterInfo.uTreasureType = 0; | |
4568 pActors[i].pMonsterInfo.uTreasureDiceRolls = 0; | |
4569 pActors[i].pMonsterInfo.uExp = 0; | |
4570 } | |
4571 } | |
4572 bDialogueUI_InitializeActor_NPC_ID = 0; | |
4573 OnMapLoad(); | |
4574 pGameLoadingUI_ProgressBar->Progress(); | |
4575 memset(&pRenderer->pBillboardRenderListD3D, 0, sizeof(pRenderer->pBillboardRenderListD3D)); | |
4576 pGameLoadingUI_ProgressBar->Release(); | |
4577 _flushall(); | |
4578 } | |
4579 | |
4580 void IntegrityTest() | |
4581 { | |
4582 static_assert(sizeof(MovieHeader) == 44, "Wrong type size"); | |
4583 static_assert(sizeof(SoundDesc_mm6) == 112, "Wrong type size"); | |
4584 static_assert(sizeof(SoundDesc) == 120, "Wrong type size"); | |
4585 static_assert(sizeof(OverlayDesc) == 8, "Wrong type size"); | |
4586 static_assert(sizeof(ChestDesc) == 36, "Wrong type size"); | |
4587 static_assert(sizeof(ObjectDesc_mm6) == 52, "Wrong type size"); | |
4588 static_assert(sizeof(ObjectDesc) == 56, "Wrong type size"); | |
4589 static_assert(sizeof(DecorationDesc) == 84, "Wrong type size"); | |
4590 static_assert(sizeof(IconFrame) == 32, "Wrong type size"); | |
4591 static_assert(sizeof(PlayerFrame) == 10, "Wrong type size"); | |
4592 static_assert(sizeof(TextureFrame) == 20, "Wrong type size"); | |
4593 static_assert(sizeof(SpriteFrame) == 60, "Wrong type size"); | |
4594 static_assert(sizeof(RenderVertexSoft) == 0x30, "Wrong type size"); | |
4595 static_assert(sizeof(RenderBillboard) == 0x34, "Wrong type size"); | |
4596 static_assert(sizeof(Texture) == 0x48, "Wrong type size"); | |
4597 static_assert(sizeof(RGBTexture) == 0x28, "Wrong type size"); | |
4598 //static_assert(sizeof(LODFile_IconsBitmaps) == 0x11BB8 + 4, "Wrong type size"); // + virtual dtor ptr | |
4599 static_assert(sizeof(AudioPlayer) == 0xC84, "Wrong type size"); | |
4600 static_assert(sizeof(SoundDesc) == 0x78, "Wrong type size"); | |
4601 static_assert(sizeof(stru339_spell_sound) == 0xAFD8, "Wrong type size"); | |
4602 //static_assert(sizeof(VideoPlayer) == 0x108 + 4, "Wrong type size"); | |
4603 static_assert(sizeof(MovieHeader) == 0x2C, "Wrong type size"); | |
4604 static_assert(sizeof(DecorationDesc) == 0x54, "Wrong type size"); | |
4605 static_assert(sizeof(ObjectDesc) == 0x38, "Wrong type size"); | |
4606 static_assert(sizeof(OverlayDesc) == 0x8, "Wrong type size"); | |
4607 static_assert(sizeof(ChestDesc) == 0x24, "Wrong type size"); | |
4608 static_assert(sizeof(TileDesc) == 0x1A, "Wrong type size"); | |
4609 static_assert(sizeof(MonsterDesc_mm6) == 148, "Wrong type size"); | |
4610 static_assert(sizeof(MonsterDesc) == 152, "Wrong type size"); | |
4611 static_assert(sizeof(Timer) == 0x28, "Wrong type size"); | |
4612 static_assert(sizeof(OtherOverlay) == 0x14, "Wrong type size"); | |
4613 static_assert(sizeof(ItemGen) == 0x24, "Wrong type size"); | |
4614 static_assert(sizeof(SpriteObject) == 0x70, "Wrong type size"); | |
4615 static_assert(sizeof(ItemDesc) == 0x30, "Wrong type size"); | |
4616 static_assert(sizeof(ItemsTable) == 0x117A0, "Wrong type size"); | |
4617 static_assert(sizeof(Chest) == 0x14CC, "Wrong type size"); | |
4618 static_assert(sizeof(MapInfo) == 0x44, "Wrong type size"); | |
4619 static_assert(sizeof(SpellInfo) == 0x24, "Wrong type size"); | |
4620 static_assert(sizeof(SpellData) == 0x14, "Wrong type size"); | |
4621 static_assert(sizeof(SpellBuff) == 0x10, "Wrong type size"); | |
4622 static_assert(sizeof(AIDirection) == 0x1C, "Wrong type size"); | |
4623 static_assert(sizeof(ActorJob) == 0xC, "Wrong type size"); | |
4624 static_assert(sizeof(Actor) == 0x344, "Wrong type size"); | |
4625 static_assert(sizeof(LevelDecoration) == 0x20, "Wrong type size"); | |
4626 static_assert(sizeof(KeyboardActionMapping) == 0x20C, "Wrong type size"); | |
4627 static_assert(sizeof(UIAnimation) == 0xD, "Wrong type size"); | |
4628 static_assert(sizeof(SpawnPointMM7) == 0x18, "Wrong type size"); | |
4629 static_assert(sizeof(ODMFace) == 0x134, "Wrong type size"); | |
4630 static_assert(sizeof(BSPNode) == 0x8, "Wrong type size"); | |
4631 static_assert(sizeof(BSPModel) == 0xBC, "Wrong type size"); | |
4632 static_assert(sizeof(OutdoorLocation) == 0x1C28C, "Wrong type size"); | |
4633 static_assert(sizeof(BLVFace) == 0x60, "Wrong type size"); | |
4634 static_assert(sizeof(BLVFaceExtra) == 0x24, "Wrong type size"); | |
4635 static_assert(sizeof(BLVSector) == 0x74, "Wrong type size"); | |
4636 static_assert(sizeof(BLVLightMM7) == 0x10, "Wrong type size"); | |
4637 static_assert(sizeof(BLVDoor) == 0x50, "Wrong type size"); | |
4638 static_assert(sizeof(IndoorLocation) == 0x690, "Wrong type size"); | |
4639 //static_assert(sizeof(ODMRenderParams) == 0x74, "Wrong type size"); | |
4640 static_assert(sizeof(Mouse) == 0x114, "Wrong type size"); | |
4641 static_assert(sizeof(Particle_sw) == 0x68, "Wrong type size"); | |
4642 static_assert(sizeof(Particle) == 0x68, "Wrong type size"); | |
4643 static_assert(sizeof(ParticleEngine) == 0xE430, "Wrong type size"); | |
4644 static_assert(sizeof(Lightmap) == 0xC1C, "Wrong type size"); | |
4645 static_assert(sizeof(LightmapBuilder) == 0x3CBC38, "Wrong type size"); | |
4646 static_assert(sizeof(Vis_SelectionList) == 0x2008, "Wrong type size"); | |
4647 static_assert(sizeof(Vis) == 0x20D0, "Wrong type size"); | |
4648 static_assert(sizeof(PlayerBuffAnim) == 0x10, "Wrong type size"); | |
4649 static_assert(sizeof(ProjectileAnim) == 0x1C, "Wrong type size"); | |
4650 static_assert(sizeof(stru6) == 0x5F8, "Wrong type size"); | |
4651 static_assert(sizeof(IndoorCameraD3D_Vec3) == 0x10, "Wrong type size"); | |
4652 static_assert(sizeof(IndoorCameraD3D_Vec4) == 0x18, "Wrong type size"); //should be 14 (10 vec3 + 4 vdtor) but 18 coz of his +4 from own vdtor, but it is odd since vdtor already present from vec3 | |
4653 //static_assert(sizeof(IndoorCameraD3D) == 0x1A1384, "Wrong type size"); | |
4654 static_assert(sizeof(StationaryLight) == 0xC, "Wrong type size"); | |
4655 static_assert(sizeof(LightsStack_StationaryLight_) == 0x12C8, "Wrong type size"); | |
4656 static_assert(sizeof(MobileLight) == 0x12, "Wrong type size"); | |
4657 static_assert(sizeof(LightsStack_MobileLight_) == 0x1C28, "Wrong type size"); | |
4658 static_assert(sizeof(Game) == 0xE78, "Wrong type size"); | |
4659 static_assert(sizeof(stru141_actor_collision_object) == 0xA8, "Wrong type size"); | |
4660 static_assert(sizeof(ActionQueue) == 0x7C, "Wrong type size"); | |
4661 static_assert(sizeof(NPCData) == 0x4C, "Wrong type size"); | |
4662 static_assert(sizeof(NPCStats) == 0x17FFC, "Wrong type size"); | |
4663 static_assert(sizeof(BspRenderer) == 0x53740, "Wrong type size"); | |
4664 static_assert(sizeof(PaletteManager) == 0x267AF0, "Wrong type size"); | |
4665 static_assert(sizeof(ViewingParams) == 0x26C, "Wrong type size"); | |
4666 //static_assert(sizeof(IndoorCamera) == 0x50, "Wrong type size"); | |
4667 static_assert(sizeof(Bloodsplat) == 0x28, "Wrong type size"); | |
4668 static_assert(sizeof(BloodsplatContainer) == 0xA0C, "Wrong type size"); | |
4669 static_assert(sizeof(TrailParticle) == 0x18, "Wrong type size"); | |
4670 static_assert(sizeof(EventIndex) == 0xC, "Wrong type size"); | |
4671 static_assert(sizeof(_2devent) == 0x34, "Wrong type size"); | |
4672 static_assert(sizeof(MapsLongTimer) == 0x20, "Wrong type size"); | |
4673 static_assert(sizeof(SavegameHeader) == 0x64, "Wrong type size"); | |
4674 static_assert(sizeof(SavegameList) == 0x3138, "Wrong type size"); | |
4675 static_assert(sizeof(StorylineText) == 0x160, "Wrong type size"); | |
4676 static_assert(sizeof(FactionTable) == 0x1EF1, "Wrong type size"); | |
4677 static_assert(sizeof(Decal) == 0xC20, "Wrong type size"); | |
4678 static_assert(sizeof(DecalBuilder) == 0x30C038, "Wrong type size"); | |
4679 static_assert(sizeof(MonsterInfo) == 0x58, "Wrong type size"); | |
4680 static_assert(sizeof(MonsterStats) == 0x5BA0, "Wrong type size"); | |
4681 static_assert(sizeof(RenderD3D) == 0x148, "Wrong type size"); | |
4682 // static_assert(sizeof(Render) == 0x129844, "Wrong type size"); | |
4683 static_assert(sizeof(Player) == 0x1B3C, "Wrong type size"); | |
4684 static_assert(sizeof(PartyTimeStruct) == 0x678, "Wrong type size"); | |
4685 static_assert(sizeof(Party) == 0x16238, "Wrong type size"); | |
4686 static_assert(sizeof(GUIButton) == 0xBC, "Wrong type size"); | |
4687 static_assert(sizeof(GUIWindow) == 0x54, "Wrong type size"); | |
4688 static_assert(sizeof(GUIProgressBar) == 0x1B8, "Wrong type size"); | |
4689 static_assert(sizeof(GUIFont) == 0x1020, "Wrong type size"); | |
4690 // static_assert(sizeof(stru262_TurnBased) == 0x40, "Wrong type size"); | |
4691 static_assert(sizeof(ArcomageGame) == 0xFB, "Wrong type size"); | |
4692 static_assert(sizeof(CastSpellInfo) == 0x14, "Wrong type size"); | |
4693 static_assert(sizeof(ArcomageCard) == 0x6C, "Wrong type size"); | |
4694 static_assert(sizeof(stru320) == 0x3FC, "Wrong type size"); | |
4695 static_assert(sizeof(TravelInfo) == 0x20, "Wrong type size"); | |
4696 static_assert(sizeof(stru336) == 0x798, "Wrong type size"); | |
4697 static_assert(sizeof(Vec3_short_) == 6, "Wrong type size"); | |
4698 static_assert(sizeof(BLVFace) == 96, "Wrong type size"); | |
4699 static_assert(sizeof(BLVFaceExtra) == 36, "Wrong type size"); | |
4700 static_assert(sizeof(BLVSector) == 116, "Wrong type size"); | |
4701 static_assert(sizeof(LevelDecoration) == 32, "Wrong type size"); | |
4702 static_assert(sizeof(BLVLightMM7) == 16, "Wrong type size"); | |
4703 static_assert(sizeof(BSPNode) == 8, "Wrong type size"); | |
4704 static_assert(sizeof(SpawnPointMM7) == 24, "Wrong type size"); | |
4705 static_assert(sizeof(DDM_DLV_Header) == 40, "Wrong type size"); | |
4706 static_assert(sizeof(Actor) == 836, "Wrong type size"); | |
4707 static_assert(sizeof(SpriteObject) == 112, "Wrong type size"); | |
4708 static_assert(sizeof(Chest) == 5324, "Wrong type size"); | |
4709 static_assert(sizeof(stru123) == 0xC8, "Wrong type size"); | |
4710 static_assert(sizeof(BLVMapOutline) == 12, "Wrong type size"); | |
4711 static_assert(sizeof(LODSprite) == 0x28, "Wrong type size"); | |
4712 } | |
4713 | |
4714 | |
4715 //----- (00464761) -------------------------------------------------------- | |
4716 void Game_DeinitializeAndTerminate(int exitCode) | |
4717 { | |
4718 SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); | |
4719 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); | |
4720 pGame->Deinitialize(); | |
4721 pRenderer->Release(); | |
4722 delete window; | |
4723 //if ( !DestroyWindow(hWnd) ) | |
4724 // GetLastError(); | |
4725 exit(exitCode); | |
4726 } | |
4727 | |
4728 //----- (004647AB) -------------------------------------------------------- | |
4729 void FinalInitialization() | |
4730 { | |
4731 pViewport->SetScreen(viewparams->uSomeX, viewparams->uSomeY, viewparams->uSomeZ, viewparams->uSomeW); | |
4732 pViewport->SetFOV(flt_6BE3A0 * 65536.0f); | |
4733 | |
4734 //pIndoorCamera = new IndoorCamera; | |
4735 //pIndoorCamera->Initialize(65, viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X + 1, | |
4736 // viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y + 1); | |
4737 | |
4738 InitializeTurnBasedAnimations(&stru_50C198); | |
4739 pBitmaps_LOD->_inlined_sub1(); | |
4740 pSprites_LOD->_inlined_sub1(); | |
4741 pIcons_LOD->_inlined_sub1(); | |
4742 } | |
4743 // 6BE3A0: using guessed type float flt_6BE3A0; | |
4744 | |
4745 | |
4746 | |
4747 //----- (00464E17) -------------------------------------------------------- | |
4748 bool __fastcall CheckMM7CD(char c) | |
4749 { | |
4750 char DstBuf[256] = { 0 }; | |
4751 char strCommand[256] = { 0 }; // [sp+10Ch] [bp-118h]@1 | |
4752 char Filename[20] = { 0 }; // [sp+20Ch] [bp-18h]@1 | |
4753 | |
4754 wchar_t pMagicPath[1024]; | |
4755 swprintf(pMagicPath, wcslen(L"%C:\\anims\\magic7.vid"), L"%C:\\anims\\magic7.vid", c); | |
4756 if (GetFileAttributesW(pMagicPath) == -1) | |
4757 return false; | |
4758 | |
4759 wsprintfA(strCommand, "open %c: type cdaudio alias CD", c); | |
4760 if (!mciSendStringA(strCommand, DstBuf, 255, 0))//Uninitialized memory access | |
4761 | |
4762 { | |
4763 wsprintfA(strCommand, "info CD UPC wait"); | |
4764 mciSendStringA(strCommand, DstBuf, 255, 0); | |
4765 wsprintfA(strCommand, "close CD"); | |
4766 mciSendStringA(strCommand, DstBuf, 255, 0); | |
4767 } | |
4768 | |
4769 memcpy(Filename, "X:\\anims\\magic7.vid", sizeof(Filename)); | |
4770 *Filename = c; | |
4771 | |
4772 FILE* f = fopen(Filename, "rb"); | |
4773 if (!f) | |
4774 return false; | |
4775 | |
4776 if (!fseek(f, 0, SEEK_END)) | |
4777 { | |
4778 if (!fseek(f, -100, SEEK_CUR)) | |
4779 fread(DstBuf, 1, 0x64u, f); | |
4780 | |
4781 fclose(f); | |
4782 return true; | |
4783 } | |
4784 fclose(f); | |
4785 return false; | |
4786 } | |
4787 | |
4788 //----- (00464F1B) -------------------------------------------------------- | |
4789 signed int __stdcall InsertMM7CDDialogFunc(HWND hDlg, int a2, __int16 a3, int a4) | |
4790 { | |
4791 char v4; // zf@3 | |
4792 int v6; // eax@10 | |
4793 int v7; // eax@11 | |
4794 int v8; // eax@12 | |
4795 int v9; // eax@13 | |
4796 BOOL(__stdcall *v10)(HWND, int, LPCSTR); // edi@15 | |
4797 const CHAR *v11; // [sp-Ch] [bp-Ch]@15 | |
4798 INT_PTR v12; // [sp-4h] [bp-4h]@5 | |
4799 | |
4800 if (a2 == 272) | |
4801 { | |
4802 hInsertCDWindow = hDlg; | |
4803 v6 = (GetUserDefaultLangID() & 0x3FF) - 7; | |
4804 if (v6) | |
4805 { | |
4806 v7 = v6 - 3; | |
4807 if (v7) | |
4808 { | |
4809 v8 = v7 - 2; | |
4810 if (v8) | |
4811 { | |
4812 v9 = v8 - 4; | |
4813 if (v9) | |
4814 { | |
4815 if (v9 != 5) | |
4816 return 0; | |
4817 SetWindowTextA(hDlg, "Wloz CD-ROM numer 2"); | |
4818 v10 = SetDlgItemTextA; | |
4819 SetDlgItemTextA(hDlg, 1010, "Wloz CD-ROM numer 2 Might and Magic® VII."); | |
4820 v11 = "Odwolaj"; | |
4821 } | |
4822 else | |
4823 { | |
4824 SetWindowTextA(hDlg, "Inserire il secondo CD"); | |
4825 v10 = SetDlgItemTextA; | |
4826 SetDlgItemTextA(hDlg, 1010, "Inserire il secondo CD di Might and Magic® VII."); | |
4827 v11 = "Annulla"; | |
4828 } | |
4829 } | |
4830 else | |
4831 { | |
4832 SetWindowTextA(hDlg, "Insérez le CD 2"); | |
4833 v10 = SetDlgItemTextA; | |
4834 SetDlgItemTextA(hDlg, 1010, "Insérez Might & Magic® VII CD 2."); | |
4835 v11 = "Supprimer"; | |
4836 } | |
4837 } | |
4838 else | |
4839 { | |
4840 SetWindowTextA(hDlg, "Por favor, inserte disco 2"); | |
4841 v10 = SetDlgItemTextA; | |
4842 SetDlgItemTextA(hDlg, 1010, "Por favor, inserte disco 2 de Might & Magic® VII."); | |
4843 v11 = "Cancelar"; | |
4844 } | |
4845 } | |
4846 else | |
4847 { | |
4848 SetWindowTextA(hDlg, "Bitte CD 2 einlegen"); | |
4849 v10 = SetDlgItemTextA; | |
4850 SetDlgItemTextA(hDlg, 1010, "Bitte CD 2 von Might and Magic® VII einlegen."); | |
4851 v11 = "Abbrechen"; | |
4852 } | |
4853 v10(hDlg, 2, v11); | |
4854 return 0; | |
4855 } | |
4856 if (a2 == 273) | |
4857 { | |
4858 if (a3 == 2) | |
4859 { | |
4860 v12 = 0; | |
4861 EndDialog(hDlg, v12); | |
4862 return 1; | |
4863 } | |
4864 v4 = a3 == 1; | |
4865 } | |
4866 else | |
4867 { | |
4868 v4 = a2 == 1025; | |
4869 } | |
4870 if (v4) | |
4871 { | |
4872 v12 = 1; | |
4873 EndDialog(hDlg, v12); | |
4874 return 1; | |
4875 } | |
4876 return 0; | |
4877 } | |
4878 | |
4879 //----- (00465061) -------------------------------------------------------- | |
4880 bool __fastcall FindMM7CD(HWND hWnd, char *pCDDrive) | |
4881 { | |
4882 char drive[4] = { 'X', ':', '\\', 0 }; | |
4883 | |
4884 bool bGotCDFromRegistry = false; | |
4885 | |
4886 HKEY hSoftware = nullptr, | |
4887 hNWC = nullptr, | |
4888 hMM7 = nullptr, | |
4889 hVersion = nullptr; | |
4890 if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hSoftware)) | |
4891 { | |
4892 if (!RegOpenKeyExA(hSoftware, "New World Computing", 0, 0x2001Fu, &hNWC)) | |
4893 { | |
4894 if (!RegOpenKeyExA(hNWC, "Might and Magic VII", 0, 0x2001Fu, &hMM7)) | |
4895 { | |
4896 if (!RegOpenKeyExA(hMM7, "1.0", 0, 0x2001Fu, &hVersion)) | |
4897 { | |
4898 DWORD cbData = 3; | |
4899 if (!RegQueryValueExA(hVersion, "CDDrive", 0, 0, (BYTE *)drive, &cbData)) | |
4900 bGotCDFromRegistry = true; | |
4901 } | |
4902 RegCloseKey(hVersion); | |
4903 } | |
4904 RegCloseKey(hMM7); | |
4905 } | |
4906 RegCloseKey(hNWC); | |
4907 } | |
4908 RegCloseKey(hSoftware); | |
4909 | |
4910 if (bGotCDFromRegistry) | |
4911 if (CheckMM7CD(*drive)) | |
4912 { | |
4913 cMM7GameCDDriveLetter = *drive; | |
4914 return true; | |
4915 } | |
4916 | |
4917 while (true) | |
4918 { | |
4919 for (uint i = 0; i < 26; ++i) | |
4920 { | |
4921 drive[0] = 'A' + i; | |
4922 | |
4923 if (GetDriveTypeA(drive) == DRIVE_CDROM) | |
4924 if (CheckMM7CD(*drive)) | |
4925 { | |
4926 cMM7GameCDDriveLetter = *drive; | |
4927 WriteWindowsRegistryString("CDDrive", drive); | |
4928 return true; | |
4929 } | |
4930 } | |
4931 | |
4932 if (DialogBoxParamA(GetModuleHandleW(nullptr), "InsertCD", hWnd, (DLGPROC)InsertMM7CDDialogFunc, 0)) | |
4933 continue; | |
4934 return false; | |
4935 } | |
4936 } | |
4937 | |
4938 //----- (004651F4) -------------------------------------------------------- | |
4939 bool MM7_Initialize(int game_width, int game_height) | |
4940 { | |
4941 wchar_t pCurrentDir[1024]; | |
4942 _wgetcwd(pCurrentDir, 1024); | |
4943 | |
4944 wchar_t pMM6IniFile[1024]; | |
4945 wsprintfW(pMM6IniFile, L"%s\\mm6.ini", pCurrentDir); | |
4946 | |
4947 bCanLoadFromCD = GetPrivateProfileIntW(L"settings", L"use_cd", 1, pMM6IniFile); | |
4948 if (bNoCD) | |
4949 bCanLoadFromCD = false; | |
4950 if (bCanLoadFromCD) | |
4951 { | |
4952 Log::Warning(L"Checking for CD..."); | |
4953 if (!FindMM7CD(nullptr, &cMM7GameCDDriveLetter)) | |
4954 return false; | |
4955 Log::Warning(L"...done."); | |
4956 } | |
4957 | |
4958 | |
4959 srand(GetTickCount()); | |
4960 | |
4961 pEventTimer = Timer::Create(); | |
4962 pEventTimer->Initialize(); | |
4963 window = OSWindow::Create(L"Might and Magic® Trilogy", game_width, game_height);//Create game window | |
4964 | |
4965 bool use_d3d11 = false; | |
4966 if (use_d3d11) | |
4967 pRenderer = RenderD3D11::Create(); | |
4968 else | |
4969 pRenderer = Render::Create();//Create DirectX | |
4970 if (!pRenderer) | |
4971 { | |
4972 Log::Warning(L"Render creation failed"); | |
4973 return false; | |
4974 } | |
4975 else | |
4976 { | |
4977 //bool bWindowMode = ReadWindowsRegistryInt("startinwindow", false); | |
4978 //uint uDefaultDevice = ReadWindowsRegistryInt("D3D Device", 1); | |
4979 | |
4980 if (!pRenderer->Initialize(window/*, bColoredLights, uLevelOfDetail, bTinting*/)) | |
4981 { | |
4982 Log::Warning(L"Render failed to initialize"); | |
4983 return false; | |
4984 } | |
4985 } | |
4986 | |
4987 game_starting_year = 1168; | |
4988 | |
4989 pParty = new Party; | |
4990 memset(&pParty->pHirelings, 0, sizeof(pParty->pHirelings)); | |
4991 pParty->uWalkSpeed = GetPrivateProfileIntW(L"debug", L"walkspeed", 384, pMM6IniFile); | |
4992 pParty->uDefaultEyelevel = GetPrivateProfileIntW(L"party", L"eyelevel", 160, pMM6IniFile); | |
4993 pParty->sEyelevel = pParty->uDefaultEyelevel; | |
4994 pParty->uDefaultPartyHeight = GetPrivateProfileIntW(L"party", L"height", 192, pMM6IniFile); | |
4995 pParty->uPartyHeight = pParty->uDefaultPartyHeight; | |
4996 | |
4997 MM6_Initialize(pMM6IniFile); | |
4998 | |
4999 pKeyActionMap = new KeyboardActionMapping; | |
5000 | |
5001 OnTimer(1); | |
5002 GameUI_StatusBar_UpdateTimedString(1); | |
5003 pGame = Game::Create(); | |
5004 pMouse = pGame->pMouseInstance; | |
5005 | |
5006 | |
5007 pIcons_LOD = new LODFile_IconsBitmaps; | |
5008 if (!pIcons_LOD->Load("data\\icons.lod", "icons")) | |
5009 { | |
5010 MessageBoxW(nullptr, L"Some files are missing\n\nPlease Reinstall.", | |
5011 L"Files Missing", MB_ICONEXCLAMATION); | |
5012 return false; | |
5013 } | |
5014 pIcons_LOD->dword_011BA4 = 0; | |
5015 | |
5016 pEvents_LOD = new LODFile_IconsBitmaps; | |
5017 if (!pEvents_LOD->Load("data\\events.lod", "icons")) | |
5018 { | |
5019 MessageBoxW(nullptr, L"Some files are missing\n\nPlease Reinstall.", | |
5020 L"Files Missing", MB_ICONEXCLAMATION); | |
5021 return false; | |
5022 } | |
5023 | |
5024 InitializeGameText(); | |
5025 | |
5026 pBitmaps_LOD = new LODFile_IconsBitmaps; | |
5027 if (!pBitmaps_LOD->Load("data\\bitmaps.lod", "bitmaps")) | |
5028 { | |
5029 MessageBoxA(nullptr, pGlobalTXT_LocalizationStrings[63], | |
5030 pGlobalTXT_LocalizationStrings[184], MB_ICONEXCLAMATION); | |
5031 return false; | |
5032 } | |
5033 | |
5034 pSprites_LOD = new LODFile_Sprites; | |
5035 if (!pSprites_LOD->LoadSprites("data\\sprites.lod")) | |
5036 { | |
5037 MessageBoxA(nullptr, | |
5038 pGlobalTXT_LocalizationStrings[63], | |
5039 pGlobalTXT_LocalizationStrings[184], MB_ICONEXCLAMATION); | |
5040 return false; | |
5041 } | |
5042 | |
5043 | |
5044 #if 0 | |
5045 if (_access("../MM_VI/data/icons.lod", 0) == 0) | |
5046 { | |
5047 pIcons_LOD_mm6 = new LODFile_IconsBitmaps; | |
5048 if (!pIcons_LOD_mm6->Load("../MM_VI/data/icons.lod", "icons")) | |
5049 { | |
5050 delete pIcons_LOD_mm6; | |
5051 pIcons_LOD_mm6 = nullptr; | |
5052 Log::Warning(L"Unable to load mm6:icons.lod"); | |
5053 } | |
5054 } | |
5055 else | |
5056 Log::Warning(L"Unable to find mm6:icons.lod"); | |
5057 | |
5058 if (_access("../MM_VI/data/bitmaps.lod", 0) == 0) | |
5059 { | |
5060 pBitmaps_LOD_mm6 = new LODFile_IconsBitmaps; | |
5061 if (!pBitmaps_LOD_mm6->Load("../MM_VI/data/bitmaps.lod", "bitmaps")) | |
5062 { | |
5063 delete pBitmaps_LOD_mm6; | |
5064 pBitmaps_LOD_mm6 = nullptr; | |
5065 Log::Warning(L"Unable to load mm6:bitmaps.lod"); | |
5066 } | |
5067 } | |
5068 else | |
5069 Log::Warning(L"Unable to find mm6:bitmaps.lod"); | |
5070 | |
5071 auto mm6_sprite_container_name = bUseLoResSprites ? "../MM_VI/data/spriteLO.lod" | |
5072 : "../MM_VI/data/sprites.lod"; | |
5073 if (_access(mm6_sprite_container_name, 0) == 0) | |
5074 { | |
5075 pSprites_LOD_mm6 = new LODFile_Sprites; | |
5076 if (!pSprites_LOD_mm6->LoadSprites(mm6_sprite_container_name)) | |
5077 { | |
5078 delete pSprites_LOD_mm6; | |
5079 pSprites_LOD_mm6 = nullptr; | |
5080 Log::Warning(L"Unable to load mm6:sprites.lod"); | |
5081 } | |
5082 } | |
5083 else | |
5084 Log::Warning(L"Unable to find mm6:sprites.lod"); | |
5085 | |
5086 | |
5087 if (_access("../mm8/data/icons.lod", 0) == 0) | |
5088 { | |
5089 pIcons_LOD_mm8 = new LODFile_IconsBitmaps; | |
5090 if (!pIcons_LOD_mm8->Load("../mm8/data/icons.lod", "icons")) | |
5091 { | |
5092 delete pIcons_LOD_mm8; | |
5093 pIcons_LOD_mm8 = nullptr; | |
5094 Log::Warning(L"Unable to load mm8:icons.lod"); | |
5095 } | |
5096 } | |
5097 else | |
5098 Log::Warning(L"Unable to find mm8:icons.lod"); | |
5099 | |
5100 | |
5101 if (_access("../mm8/data/bitmaps.lod", 0) == 0) | |
5102 { | |
5103 pBitmaps_LOD_mm8 = new LODFile_IconsBitmaps; | |
5104 if (!pBitmaps_LOD_mm8->Load("../mm8/data/bitmaps.lod", "bitmaps")) | |
5105 { | |
5106 delete pBitmaps_LOD_mm8; | |
5107 pBitmaps_LOD_mm8 = nullptr; | |
5108 Log::Warning(L"Unable to load mm8:bitmaps.lod"); | |
5109 } | |
5110 } | |
5111 else | |
5112 Log::Warning(L"Unable to find mm8:bitmaps.lod"); | |
5113 | |
5114 | |
5115 if (_access("../mm8/data/sprites.lod", 0) == 0) | |
5116 { | |
5117 pSprites_LOD_mm8 = new LODFile_Sprites; | |
5118 if (!pSprites_LOD_mm8->LoadSprites("../mm8/data/sprites.lod")) | |
5119 { | |
5120 delete pSprites_LOD_mm8; | |
5121 pSprites_LOD_mm8 = nullptr; | |
5122 Log::Warning(L"Unable to load mm8:sprites.lod"); | |
5123 } | |
5124 } | |
5125 else | |
5126 Log::Warning(L"Unable to find mm8:sprites.lod"); | |
5127 #endif | |
5128 | |
5129 { | |
5130 void *sft_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dsft.bin", 1) : nullptr, | |
5131 *sft_mm8 = nullptr; | |
5132 void *sft_mm7 = pEvents_LOD->LoadRaw("dsft.bin", 1); | |
5133 pSpriteFrameTable = new SpriteFrameTable; | |
5134 pSpriteFrameTable->FromFile(sft_mm6, sft_mm7, sft_mm8); | |
5135 free(sft_mm6); | |
5136 free(sft_mm7); | |
5137 free(sft_mm8); | |
5138 | |
5139 void *tft_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dtft.bin", 1) : nullptr, | |
5140 *tft_mm8 = nullptr; | |
5141 void *tft_mm7 = pEvents_LOD->LoadRaw("dtft.bin", 1); | |
5142 pTextureFrameTable = new TextureFrameTable; | |
5143 pTextureFrameTable->FromFile(tft_mm6, tft_mm7, tft_mm8); | |
5144 free(tft_mm6); | |
5145 free(tft_mm7); | |
5146 free(tft_mm8); | |
5147 | |
5148 void *tiles_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dtile.bin", 1) : nullptr, | |
5149 *tiles_mm8 = nullptr; | |
5150 void *tiles_mm7 = pEvents_LOD->LoadRaw("dtile.bin", 1); | |
5151 pTileTable = new TileTable; | |
5152 pTileTable->FromFile(tiles_mm6, tiles_mm7, tiles_mm8); | |
5153 free(tiles_mm6); | |
5154 free(tiles_mm7); | |
5155 free(tiles_mm8); | |
5156 | |
5157 void *pft_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dpft.bin", 1) : nullptr, | |
5158 *pft_mm8 = nullptr; | |
5159 void *pft_mm7 = pEvents_LOD->LoadRaw("dpft.bin", 1); | |
5160 pPlayerFrameTable = new PlayerFrameTable; | |
5161 pPlayerFrameTable->FromFile(pft_mm6, pft_mm7, pft_mm8); | |
5162 free(pft_mm6); | |
5163 free(pft_mm7); | |
5164 free(pft_mm8); | |
5165 | |
5166 void *ift_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dift.bin", 1) : nullptr, | |
5167 *ift_mm8 = nullptr; | |
5168 void *ift_mm7 = pEvents_LOD->LoadRaw("dift.bin", 1); | |
5169 pIconsFrameTable = new IconFrameTable; | |
5170 pIconsFrameTable->FromFile(ift_mm6, ift_mm7, ift_mm8); | |
5171 free(ift_mm6); | |
5172 free(ift_mm7); | |
5173 free(ift_mm8); | |
5174 | |
5175 void *decs_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("ddeclist.bin", 1) : nullptr, | |
5176 *decs_mm8 = nullptr; | |
5177 void *decs_mm7 = pEvents_LOD->LoadRaw("ddeclist.bin", 1); | |
5178 pDecorationList = new DecorationList; | |
5179 pDecorationList->FromFile(decs_mm6, decs_mm7, decs_mm8); | |
5180 free(decs_mm6); | |
5181 free(decs_mm7); | |
5182 free(decs_mm8); | |
5183 | |
5184 void *objs_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dobjlist.bin", 1) : nullptr, | |
5185 *objs_mm8 = nullptr; | |
5186 void *objs_mm7 = pEvents_LOD->LoadRaw("dobjlist.bin", 1); | |
5187 pObjectList = new ObjectList; | |
5188 pObjectList->FromFile(objs_mm6, objs_mm7, objs_mm8); | |
5189 free(objs_mm6); | |
5190 free(objs_mm7); | |
5191 free(objs_mm8); | |
5192 | |
5193 void *mons_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dmonlist.bin", 1) : nullptr, | |
5194 *mons_mm8 = nullptr; | |
5195 void *mons_mm7 = pEvents_LOD->LoadRaw("dmonlist.bin", 1); | |
5196 pMonsterList = new MonsterList; | |
5197 pMonsterList->FromFile(mons_mm6, mons_mm7, mons_mm8); | |
5198 free(mons_mm6); | |
5199 free(mons_mm7); | |
5200 free(mons_mm8); | |
5201 | |
5202 void *chests_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dchest.bin", 1) : nullptr, | |
5203 *chests_mm8 = nullptr; | |
5204 void *chests_mm7 = pEvents_LOD->LoadRaw("dchest.bin", 1); | |
5205 pChestList = new ChestList; | |
5206 pChestList->FromFile(chests_mm6, chests_mm7, chests_mm8); | |
5207 free(chests_mm6); | |
5208 free(chests_mm7); | |
5209 free(chests_mm8); | |
5210 | |
5211 void *overlays_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("doverlay.bin", 1) : nullptr, | |
5212 *overlays_mm8 = nullptr; | |
5213 void *overlays_mm7 = pEvents_LOD->LoadRaw("doverlay.bin", 1); | |
5214 pOverlayList = new OverlayList; | |
5215 pOverlayList->FromFile(overlays_mm6, overlays_mm7, overlays_mm8); | |
5216 free(overlays_mm6); | |
5217 free(overlays_mm7); | |
5218 free(overlays_mm8); | |
5219 | |
5220 void *sounds_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dsounds.bin", 1) : nullptr, | |
5221 *sounds_mm8 = nullptr; | |
5222 void *sounds_mm7 = pEvents_LOD->LoadRaw("dsounds.bin", 1); | |
5223 pSoundList = new SoundList; | |
5224 pSoundList->FromFile(sounds_mm6, sounds_mm7, sounds_mm8); | |
5225 free(sounds_mm6); | |
5226 free(sounds_mm7); | |
5227 free(sounds_mm8); | |
5228 } | |
5229 | |
5230 | |
5231 | |
5232 | |
5233 if (dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_RUN_IN_WIDOW) | |
5234 { | |
5235 //window->SetWindowedMode(game_width, game_height); | |
5236 pRenderer->SwitchToWindow(); | |
5237 } | |
5238 else | |
5239 { | |
5240 __debugbreak(); // Nomad | |
5241 window->SetFullscreenMode(); | |
5242 pRenderer->InitializeFullscreen(); | |
5243 } | |
5244 | |
5245 uSoundVolumeMultiplier = min(9, ReadWindowsRegistryInt("soundflag", 9)); | |
5246 uMusicVolimeMultiplier = min(9, ReadWindowsRegistryInt("musicflag", 9)); | |
5247 uVoicesVolumeMultiplier = min(9, ReadWindowsRegistryInt("CharVoices", 9)); | |
5248 bShowDamage = ReadWindowsRegistryInt("ShowDamage", 1) != 0; | |
5249 | |
5250 uGammaPos = min(4, ReadWindowsRegistryInt("GammaPos", 4)); | |
5251 pGame->pGammaController->Initialize(uGammaPos * 0.1 + 0.6); | |
5252 | |
5253 if (ReadWindowsRegistryInt("Bloodsplats", 1)) | |
5254 pGame->uFlags2 |= GAME_FLAGS_2_DRAW_BLOODSPLATS; | |
5255 else | |
5256 pGame->uFlags2 &= ~GAME_FLAGS_2_DRAW_BLOODSPLATS; | |
5257 | |
5258 uTurnSpeed = ReadWindowsRegistryInt("TurnDelta", 3); | |
5259 | |
5260 if (!bNoSound) | |
5261 pAudioPlayer->Initialize(); | |
5262 | |
5263 pMediaPlayer = new Media::MPlayer(); | |
5264 pMediaPlayer->Initialize(window); | |
5265 | |
5266 dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000; | |
5267 | |
5268 switch (uTurnSpeed) | |
5269 { | |
5270 case 0: // undefined turn option | |
5271 __debugbreak(); // really shouldn't use this mode | |
5272 uTurnSpeed = (unsigned int)uCPUSpeed < 199 ? 128 : 64; // adjust turn speed to estimated fps | |
5273 break; | |
5274 | |
5275 case 1u: // 16x | |
5276 Log::Warning(L"x16 Turn Speed"); // really shouldn't use this mode | |
5277 uTurnSpeed = 128; | |
5278 break; | |
5279 | |
5280 case 2u: // 32x | |
5281 Log::Warning(L"x32 Turn Speed"); // really shouldn't use this mode | |
5282 uTurnSpeed = 64; | |
5283 break; | |
5284 | |
5285 case 3u: // smooth | |
5286 uTurnSpeed = 0; | |
5287 break; | |
5288 } | |
5289 | |
5290 return true; | |
5291 } | |
5292 | |
5293 //----- (00465D0B) -------------------------------------------------------- | |
5294 void SecondaryInitialization() | |
5295 { | |
5296 pMouse->Initialize(window); | |
5297 | |
5298 pItemsTable = new ItemsTable; | |
5299 pItemsTable->Initialize(); | |
5300 | |
5301 //pBitmaps_LOD->can_load_hardware_sprites = 1; | |
5302 //pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
5303 pBitmaps_LOD->SetupPalettes(5, 6, 5); | |
5304 //pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
5305 pIcons_LOD->SetupPalettes(5, 6, 5); | |
5306 //pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
5307 pPaletteManager->SetColorChannelInfo(5, 6, 5); | |
5308 | |
5309 pPaletteManager->SetMistColor(128, 128, 128); | |
5310 pPaletteManager->RecalculateAll(); | |
5311 //pSprites_LOD->can_load_hardware_sprites = 1; | |
5312 pObjectList->InitializeSprites(); | |
5313 pOverlayList->InitializeSprites(); | |
5314 | |
5315 if (!bNoSound) | |
5316 pSoundList->Initialize(); | |
5317 | |
5318 | |
5319 for (uint i = 0; i < 4; ++i) | |
5320 { | |
5321 static const char *pUIAnimNames[4] = | |
5322 { | |
5323 "glow03", "glow05", | |
5324 "torchA", "wizeyeA" | |
5325 }; | |
5326 static unsigned short _4E98D0[4][4] = | |
5327 { | |
5328 { 479, 0, 329, 0 }, | |
5329 { 585, 0, 332, 0 }, | |
5330 { 468, 0, 0, 0 }, | |
5331 { 606, 0, 0, 0 } | |
5332 }; | |
5333 | |
5334 pUIAnims[i]->uIconID = pIconsFrameTable->FindIcon(pUIAnimNames[i]); | |
5335 pIconsFrameTable->InitializeAnimation(pUIAnims[i]->uIconID); | |
5336 | |
5337 pUIAnims[i]->uAnimLength = 0; | |
5338 pUIAnims[i]->uAnimTime = 0; | |
5339 pUIAnims[i]->x = _4E98D0[i][0]; | |
5340 pUIAnims[i]->y = _4E98D0[i][2]; | |
5341 } | |
5342 | |
5343 for (unsigned int i = 0; i < pObjectList->uNumObjects; ++i) | |
5344 { | |
5345 pObjectList->pObjects[i].uParticleTrailColor = pObjectList->pObjects[i].uParticleTrailColorB | | |
5346 ((unsigned int)pObjectList->pObjects[i].uParticleTrailColorG << 8) | | |
5347 ((unsigned int)pObjectList->pObjects[i].uParticleTrailColorR << 16); | |
5348 } | |
5349 | |
5350 MainMenuUI_Create(); | |
5351 pGame->pStru6Instance->LoadAnimations(); | |
5352 | |
5353 for (uint i = 0; i < 7; ++i) | |
5354 { | |
5355 char container_name[64]; | |
5356 sprintf(container_name, "HDWTR%03u", i); | |
5357 pRenderer->pHDWaterBitmapIDs[i] = pBitmaps_LOD->LoadTexture(container_name); | |
5358 } | |
5359 | |
5360 pNPCStats = new NPCStats; | |
5361 memset(pNPCStats->pNPCData, 0, 0x94BCu); | |
5362 pNPCStats->Initialize(); | |
5363 | |
5364 Initialize_GlobalEVT(); | |
5365 pBitmaps_LOD->_inlined_sub0(); | |
5366 pSprites_LOD->_inlined_sub0(); | |
5367 pPaletteManager->LockAll(); | |
5368 | |
5369 _mkdir("Saves"); | |
5370 for (uint i = 0; i < 5; ++i) | |
5371 for (uint j = 0; j < 6; ++j) | |
5372 { | |
5373 sprintf(pTmpBuf.data(), "data\\lloyd%d%d.pcx", i, j); | |
5374 remove(pTmpBuf.data()); | |
5375 } | |
5376 | |
5377 Initialize_GamesLOD_NewLOD(); | |
5378 _576E2C_current_minimap_zoom = 512; | |
5379 dword_576E28 = 9; | |
5380 } | |
5381 | |
5382 bool new_sky = false; //new sky(need texture) | |
5383 int max_flight_height = 4000; //maximum altitude | |
5384 | |
5385 | |
5386 //----- (00462C94) -------------------------------------------------------- | |
5387 bool MM_Main(const wchar_t *pCmdLine) | |
5388 { | |
5389 IntegrityTest(); | |
5390 | |
5391 char test[1024]; | |
5392 sprintfex(test, "^Pi[%s]: çíàõàð^R[ü;êà;]", "Çîëòàí"); | |
5393 | |
5394 lua = new LuaVM; | |
5395 lua->Initialize(); | |
5396 | |
5397 bool bNoMargareth = false; | |
5398 if (pCmdLine && *pCmdLine) | |
5399 { | |
5400 //if (wcsstr(pCmdLine, L"-usedefs")) | |
5401 // bDebugResouces = 1; | |
5402 if (wcsstr(pCmdLine, L"-window")) | |
5403 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_RUN_IN_WIDOW; | |
5404 | |
5405 if (wcsstr(pCmdLine, L"-nointro")) | |
5406 bNoIntro = true;//dword_6BE364_game_settings_1 |= 4; | |
5407 if (wcsstr(pCmdLine, L"-nologo")) | |
5408 bNoLogo = true;//dword_6BE364_game_settings_1 |= 8; | |
5409 if (wcsstr(pCmdLine, L"-nosound")) | |
5410 bNoSound = true; //dword_6BE364_game_settings_1 |= 0x10; | |
5411 | |
5412 bWalkSound = ReadWindowsRegistryInt("WalkSound", 1) != 0; | |
5413 if (wcsstr(pCmdLine, L"-nowalksound")) | |
5414 bWalkSound = false;//dword_6BE364_game_settings_1 |= 0x20; | |
5415 if (wcsstr(pCmdLine, L"-novideo")) | |
5416 { | |
5417 dword_6BE364_game_settings_1 |= GAME_SETTINGS_NO_HOUSE_ANIM; | |
5418 bNoVideo = true; | |
5419 } | |
5420 if (wcsstr(pCmdLine, L"-nocd")) | |
5421 bNoCD = true; | |
5422 if (wcsstr(pCmdLine, L"-new_sky")) | |
5423 new_sky = true; | |
5424 if (wcsstr(pCmdLine, L"-nomarg")) | |
5425 bNoMargareth = true; | |
5426 } | |
5427 | |
5428 /*v8 = _4AC1C9_get_cpu_speed(0, (Vec4_int_ *)a2); | |
5429 Rect.left = *(int *)v8; | |
5430 Rect.top = *(int *)(v8 + 4); | |
5431 Rect.right = *(int *)(v8 + 8); | |
5432 Rect.bottom = *(int *)(v8 + 12); | |
5433 uCPUSpeed = Rect.bottom;*/ | |
5434 uCPUSpeed = 2048; // about 2GHz | |
5435 | |
5436 //_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF );//Ritor1: for memory test | |
5437 | |
5438 if (!MM7_Initialize(640, 480)) | |
5439 { | |
5440 Log::Warning(L"MM init: failed"); | |
5441 pGame->Deinitialize(); | |
5442 return 1; | |
5443 } | |
5444 | |
5445 pEventTimer->Pause(); | |
5446 | |
5447 SetUserInterface(PartyAlignment_Neutral, false); | |
5448 ShowLogoVideo(); | |
5449 //ShowIntroVideo_and_LoadingScreen(); | |
5450 WriteWindowsRegistryInt("Ran once", 1); | |
5451 dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000; | |
5452 pGame->InitializeGammaController(); | |
5453 SecondaryInitialization(); | |
5454 pRenderer->SetRasterClipRect(0, 0, window->GetWidth() - 1, window->GetHeight() - 1); | |
5455 FinalInitialization(); | |
5456 | |
5457 //Ritor1: include | |
5458 MMT_MainMenu_Loop(); | |
5459 | |
5460 Log::Warning(L"MM: entering main loop"); | |
5461 while (1) | |
5462 { | |
5463 MainMenuWindow* main_menu_window = MainMenuWindow::Create(); | |
5464 window->AddControl(main_menu_window); | |
5465 MainMenu_Loop(); | |
5466 uGameState = GAME_STATE_PLAYING; | |
5467 while (1) | |
5468 { | |
5469 if (uGameState == GAME_FINISHED || GetCurrentMenuID() == MENU_EXIT_GAME) | |
5470 { | |
5471 pGame->Deinitialize(); | |
5472 return true; | |
5473 } | |
5474 | |
5475 if (GetCurrentMenuID() == MENU_NEWGAME) | |
5476 { | |
5477 if (pAudioPlayer->hAILRedbook) | |
5478 AIL_redbook_stop(pAudioPlayer->hAILRedbook); | |
5479 pParty->Reset(); | |
5480 pOtherOverlayList->Reset(); | |
5481 strcpy(pCurrentMapName, pStartingMapName); | |
5482 pParty->CreateDefaultParty(0); | |
5483 PlayerCreationUI_Initialize(); | |
5484 if (PlayerCreationUI_Loop()) | |
5485 { | |
5486 DeleteCCharFont(); | |
5487 break; | |
5488 } | |
5489 DeleteCCharFont(); | |
5490 bFlashQuestBook = true; | |
5491 pMediaPlayer->PlayFullscreenMovie(MOVIE_Emerald, true); | |
5492 SaveNewGame(); | |
5493 if (bNoMargareth) | |
5494 _449B7E_toggle_bit(pParty->_quest_bits, PARTY_QUEST_EMERALD_MARGARETH_OFF, 1); | |
5495 pGame->Loop(); | |
5496 if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU) | |
5497 { | |
5498 SetCurrentMenuID(MENU_NEWGAME); | |
5499 uGameState = GAME_STATE_PLAYING; | |
5500 continue; | |
5501 } | |
5502 else if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU) | |
5503 break; | |
5504 assert(false && "Invalid game state"); | |
5505 } | |
5506 if (GetCurrentMenuID() == MENU_CREDITS) | |
5507 { | |
5508 if (pAudioPlayer->hAILRedbook) | |
5509 AIL_redbook_stop(pAudioPlayer->hAILRedbook); | |
5510 MainMenuUI_Credits_Loop(); | |
5511 break; | |
5512 } | |
5513 if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu) | |
5514 { | |
5515 uGameState = GAME_STATE_PLAYING; | |
5516 pGame->Loop(); | |
5517 } | |
5518 else | |
5519 { | |
5520 if (GetCurrentMenuID() == MENU_DebugBLVLevel) | |
5521 { | |
5522 pMouse->ChangeActivation(0); | |
5523 pParty->Reset(); | |
5524 pParty->CreateDefaultParty(1); | |
5525 | |
5526 __debugbreak(); | |
5527 /*extern void CreateDefaultBLVLevel(); | |
5528 CreateDefaultBLVLevel(); | |
5529 | |
5530 OPENFILENAMEA ofn; | |
5531 if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) ) | |
5532 { | |
5533 pMouse->ChangeActivation(1); | |
5534 break; | |
5535 } | |
5536 _chdir("..\\"); | |
5537 strcpy(pCurrentMapName, ofn.lpstrFileTitle);*/ | |
5538 pMouse->ChangeActivation(1); | |
5539 pGame->Loop(); | |
5540 } | |
5541 } | |
5542 if (uGameState == GAME_STATE_LOADING_GAME) | |
5543 { | |
5544 SetCurrentMenuID(MENU_5); | |
5545 uGameState = GAME_STATE_PLAYING; | |
5546 continue; | |
5547 } | |
5548 if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU) | |
5549 { | |
5550 SetCurrentMenuID(MENU_NEWGAME); | |
5551 uGameState = GAME_STATE_PLAYING; | |
5552 continue; | |
5553 } | |
5554 if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)// from the loaded game | |
5555 { | |
5556 pAudioPlayer->StopChannels(-1, -1); | |
5557 uGameState = GAME_STATE_PLAYING; | |
5558 break; | |
5559 } | |
5560 } | |
5561 if (!bNoSound && pAudioPlayer->hAILRedbook) | |
5562 { | |
5563 pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); | |
5564 AIL_redbook_stop(pAudioPlayer->hAILRedbook); | |
5565 unsigned int startms, end_ms; | |
5566 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &startms, &end_ms); | |
5567 AIL_redbook_play(pAudioPlayer->hAILRedbook, startms + 1, end_ms); | |
5568 } | |
5569 } | |
5570 //lua_close(L); | |
5571 pGame->Deinitialize(); | |
5572 return 1; | |
5573 } | |
5574 | |
5575 | |
5576 | |
5577 //----- (00466082) -------------------------------------------------------- | |
5578 void MM6_Initialize(const wchar_t *pIniFilename) | |
5579 { | |
5580 size_t v2; // eax@31 | |
5581 size_t v3; // ebx@32 | |
5582 size_t v4; // edi@36 | |
5583 char pDefaultGroundTexture[16]; // [sp+FCh] [bp-8Ch]@32 | |
5584 unsigned int v9; // [sp+184h] [bp-4h]@28 | |
5585 | |
5586 //_getcwd(v5, 120); | |
5587 //sprintfex(pIniFilename, "%s\\mm6.ini", v5); | |
5588 viewparams = new ViewingParams; | |
5589 game_viewport_x = viewparams->uScreen_topL_X = GetPrivateProfileIntW(L"screen", L"vx1", 8, pIniFilename); | |
5590 game_viewport_y = viewparams->uScreen_topL_Y = GetPrivateProfileIntW(L"screen", L"vy1", 8, pIniFilename); | |
5591 game_viewport_z = viewparams->uScreen_BttmR_X = GetPrivateProfileIntW(L"screen", L"vx2", 468, pIniFilename); | |
5592 game_viewport_w = viewparams->uScreen_BttmR_Y = GetPrivateProfileIntW(L"screen", L"vy2", 351, pIniFilename); | |
5593 game_viewport_width = game_viewport_z - game_viewport_x; | |
5594 game_viewport_height = game_viewport_w - game_viewport_y + 1; | |
5595 | |
5596 | |
5597 pAudioPlayer = new AudioPlayer; | |
5598 pAudioPlayer->uMixerChannels = GetPrivateProfileIntW(L"settings", L"mixerchannels", 16, pIniFilename); | |
5599 if (pAudioPlayer->uMixerChannels > 16) | |
5600 pAudioPlayer->uMixerChannels = 16; | |
5601 | |
5602 | |
5603 if (GetPrivateProfileIntW(L"debug", L"nomonster", 0, pIniFilename)) | |
5604 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_NO_ACTORS; | |
5605 if (ReadWindowsRegistryInt("startinwindow", 0)) | |
5606 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_RUN_IN_WIDOW; | |
5607 if (GetPrivateProfileIntW(L"debug", L"showFR", 0, pIniFilename)) | |
5608 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_0002_SHOW_FR; | |
5609 if (GetPrivateProfileIntW(L"debug", L"nodamage", 0, pIniFilename)) | |
5610 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_NO_DAMAGE; | |
5611 if (GetPrivateProfileIntW(L"debug", L"nodecoration", 0, pIniFilename)) | |
5612 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_NO_DECORATIONS; | |
5613 | |
5614 wchar_t pStartingMapNameW[1024]; | |
5615 GetPrivateProfileStringW(L"file", L"startmap", L"out01.odm", pStartingMapNameW, 0x20u, pIniFilename); | |
5616 sprintf(pStartingMapName, "%S", pStartingMapNameW); | |
5617 | |
5618 v9 = 0; | |
5619 if (strlen(pStartingMapName)) | |
5620 { | |
5621 do | |
5622 { | |
5623 if (pStartingMapName[v9] == ' ') | |
5624 pStartingMapName[v9] = 0; | |
5625 ++v9; | |
5626 v2 = strlen(pStartingMapName); | |
5627 } while (v9 < v2); | |
5628 } | |
5629 | |
5630 pODMRenderParams = new ODMRenderParams; | |
5631 pODMRenderParams->outdoor_no_mist = GetPrivateProfileIntW(L"debug", L"noMist", 0, pIniFilename); | |
5632 pODMRenderParams->bNoSky = GetPrivateProfileIntW(L"outdoor", L"nosky", 0, pIniFilename); | |
5633 pODMRenderParams->bDoNotRenderDecorations = GetPrivateProfileIntW(L"render", L"nodecorations", 0, pIniFilename); | |
5634 pODMRenderParams->outdoor_no_wavy_water = GetPrivateProfileIntW(L"outdoor", L"nowavywater", 0, pIniFilename); | |
5635 outdoor_grid_band_1 = GetPrivateProfileIntW(L"outdoor", L"gridband1", 10, pIniFilename); | |
5636 outdoor_grid_band_2 = GetPrivateProfileIntW(L"outdoor", L"gridband2", 15, pIniFilename); | |
5637 outdoor_grid_band_3 = GetPrivateProfileIntW(L"outdoor", L"gridband3", 25, pIniFilename); | |
5638 pODMRenderParams->terrain_gamma = GetPrivateProfileIntW(L"outdoor", L"ter_gamma", 0, pIniFilename); | |
5639 pODMRenderParams->building_gamme = GetPrivateProfileIntW(L"outdoor", L"bld_gamma", 0, pIniFilename); | |
5640 pODMRenderParams->shading_dist_shade = GetPrivateProfileIntW(L"shading", L"dist_shade", 2048, pIniFilename); | |
5641 pODMRenderParams->shading_dist_shademist = GetPrivateProfileIntW(L"shading", L"dist_shademist", 4096, pIniFilename); | |
5642 | |
5643 pODMRenderParams->shading_dist_mist = GetPrivateProfileIntW(L"shading", L"dist_mist", 0x2000, pIniFilename);//drawing dist 0x2000 | |
5644 | |
5645 wchar_t pDefaultSkyTextureW[1024]; | |
5646 GetPrivateProfileStringW(L"textures", L"sky", L"plansky1", pDefaultSkyTextureW, 0x10u, pIniFilename); | |
5647 sprintf(pDefaultSkyTexture.data(), "%S", pDefaultSkyTextureW); | |
5648 | |
5649 wchar_t pDefaultGroundTextureW[1024]; | |
5650 GetPrivateProfileStringW(L"textures", L"default", L"dirt", pDefaultGroundTextureW, 0x10u, pIniFilename); | |
5651 sprintf(pDefaultGroundTexture, "%S", pDefaultGroundTextureW); | |
5652 | |
5653 wchar_t pFloat[1024]; | |
5654 GetPrivateProfileStringW(L"debug", L"recmod1", L"1.0", pFloat, 0x10u, pIniFilename); | |
5655 swscanf(pFloat, L"%f", &flt_6BE3A4_debug_recmod1); | |
5656 | |
5657 GetPrivateProfileStringW(L"debug", L"recmod2", L"1.0", pFloat, 0x10u, pIniFilename); | |
5658 swscanf(pFloat, L"%f", &flt_6BE3A8_debug_recmod2); | |
5659 | |
5660 flt_6BE3AC_debug_recmod1_x_1_6 = flt_6BE3A4_debug_recmod1 * 1.666666666666667; | |
5661 | |
5662 v3 = 0; | |
5663 if (strlen(pDefaultSkyTexture.data())) | |
5664 { | |
5665 do | |
5666 { | |
5667 if (pDefaultSkyTexture[v3] == ' ') | |
5668 pDefaultSkyTexture[v3] = 0; | |
5669 ++v3; | |
5670 } while (v3 < strlen(pDefaultSkyTexture.data())); | |
5671 } | |
5672 v4 = 0; | |
5673 if (strlen(pDefaultGroundTexture)) | |
5674 { | |
5675 do | |
5676 { | |
5677 if (pDefaultGroundTexture[v4] == ' ') | |
5678 pDefaultGroundTexture[v4] = 0; | |
5679 ++v4; | |
5680 } while (v4 < strlen(pDefaultGroundTexture)); | |
5681 } | |
5682 | |
5683 MM7Initialization(); | |
5684 } | |
5685 | |
5686 //----- (004666D5) -------------------------------------------------------- | |
5687 void MM7Initialization() | |
5688 { | |
5689 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
5690 { | |
5691 /*if (byte_6BE388_graphicsmode == 0) | |
5692 { | |
5693 outdoor_grid_band_1 = 10; | |
5694 outdoor_grid_band_2 = 15; | |
5695 outdoor_grid_band_3 = 20; | |
5696 pODMRenderParams->shading_dist_mist = 8192; | |
5697 pODMRenderParams->bNoSky = false; | |
5698 LOBYTE(viewparams->field_20) = 0; | |
5699 }*/ | |
5700 pODMRenderParams->shading_dist_shade = 2048; | |
5701 pODMRenderParams->terrain_gamma = 0; | |
5702 pODMRenderParams->building_gamme = 0; | |
5703 pODMRenderParams->shading_dist_shademist = 4096; | |
5704 pODMRenderParams->outdoor_no_wavy_water = 0; | |
5705 //_47F4D3_initialize_terrain_bezier_stuff(outdoor_grid_band_1, outdoor_grid_band_2, outdoor_grid_band_3); | |
5706 { | |
5707 pODMRenderParams->outdoor_grid_band_3 = outdoor_grid_band_3; | |
5708 pODMRenderParams->uPickDepth = outdoor_grid_band_3 * 512; | |
5709 } | |
5710 } | |
5711 else | |
5712 LOBYTE(viewparams->field_20) = 0; | |
5713 pParty->uFlags |= 2; | |
5714 viewparams->uSomeY = viewparams->uScreen_topL_Y; | |
5715 viewparams->uSomeX = viewparams->uScreen_topL_X; | |
5716 viewparams->uSomeZ = viewparams->uScreen_BttmR_X; | |
5717 viewparams->uSomeW = viewparams->uScreen_BttmR_Y; | |
5718 | |
5719 pViewport->SetScreen(viewparams->uScreen_topL_X, viewparams->uScreen_topL_Y, viewparams->uScreen_BttmR_X, viewparams->uScreen_BttmR_Y); | |
5720 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
5721 pODMRenderParams->Initialize(); | |
5722 } | |
5723 | |
5724 //----- (004610AA) -------------------------------------------------------- | |
5725 void __fastcall PrepareToLoadODM(unsigned int bLoading, ODMRenderParams *a2) | |
5726 { | |
5727 pGameLoadingUI_ProgressBar->Reset(27); | |
5728 pSoundList->_4A9D79(0); | |
5729 uCurrentlyLoadedLevelType = LEVEL_Outdoor; | |
5730 ODM_LoadAndInitialize(pCurrentMapName, a2); | |
5731 if (!bLoading) | |
5732 TeleportToStartingPoint(uLevel_StartingPointType); | |
5733 viewparams->_443365(); | |
5734 PlayLevelMusic(); | |
5735 } | |
5736 // 6BE35C: using guessed type int uLevel_StartingPointType; | |
5737 | |
5738 | |
5739 //----- (004627B7) -------------------------------------------------------- | |
5740 void MainMenu_Loop() | |
5741 { | |
5742 GUIButton *pButton; // eax@27 | |
5743 unsigned int pControlParam; // ecx@35 | |
5744 unsigned int pY; // [sp-18h] [bp-54h]@39 | |
5745 Texture *pTexture; // [sp-14h] [bp-50h]@39 | |
5746 GUIWindow *pWindow; // [sp+4h] [bp-38h]@11 | |
5747 MSG msg; | |
5748 | |
5749 pCurrentScreen = SCREEN_GAME; | |
5750 | |
5751 pGUIWindow2 = 0; | |
5752 pAudioPlayer->StopChannels(-1, -1); | |
5753 pMouse->RemoveHoldingItem(); | |
5754 | |
5755 pIcons_LOD->_inlined_sub2(); | |
5756 | |
5757 pWindow_MainMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); | |
5758 Texture* pNew = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); | |
5759 Texture* pLoad = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE); | |
5760 Texture* pCredits = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE); | |
5761 Texture* pExit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); | |
5762 | |
5763 pMainMenu_BtnNew = pWindow_MainMenu->CreateButton(495, 172, pNew->uTextureWidth, pNew->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowPartyCreationWnd, 0, 'N', "", pNew, 0); | |
5764 pMainMenu_BtnLoad = pWindow_MainMenu->CreateButton(495, 227, pLoad->uTextureWidth, pLoad->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowLoadWindow, 1, 'L', "", pLoad, 0); | |
5765 pMainMenu_BtnCredits = pWindow_MainMenu->CreateButton(495, 282, pCredits->uTextureWidth, pCredits->uTextureHeight, 1, 0, UIMSG_ShowCredits, 2, 'C', "", pCredits, 0); | |
5766 pMainMenu_BtnExit = pWindow_MainMenu->CreateButton(495, 337, pExit->uTextureWidth, pExit->uTextureHeight, 1, 0, UIMSG_ExitToWindows, 3, 0, "", pExit, 0); | |
5767 | |
5768 pTexture_PCX.Release(); | |
5769 pTexture_PCX.Load("title.pcx", 0); | |
5770 SetCurrentMenuID(MENU_MAIN); | |
5771 SetForegroundWindow(window->GetApiHandle()); | |
5772 SendMessageW(window->GetApiHandle(), WM_ACTIVATEAPP, 1, 0); | |
5773 while (GetCurrentMenuID() == MENU_MAIN || GetCurrentMenuID() == MENU_SAVELOAD) | |
5774 { | |
5775 POINT pt; | |
5776 pMouse->GetCursorPos(&pt); | |
5777 pWindow = pWindow_MainMenu; | |
5778 if (GetCurrentMenuID() == MENU_SAVELOAD) | |
5779 { | |
5780 if (pCurrentScreen != SCREEN_LOADGAME) | |
5781 { | |
5782 pTexture_PCX.Release(); | |
5783 pTexture_PCX.Load("lsave640.pcx", 0); | |
5784 pGUIWindow2 = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); | |
5785 pCurrentScreen = SCREEN_LOADGAME; | |
5786 LoadUI_Load(0); | |
5787 } | |
5788 pWindow = pGUIWindow_CurrentMenu; | |
5789 } | |
5790 | |
5791 while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) | |
5792 { | |
5793 if (msg.message == WM_QUIT) | |
5794 Game_DeinitializeAndTerminate(0); | |
5795 TranslateMessage(&msg); | |
5796 DispatchMessageW(&msg); | |
5797 } | |
5798 | |
5799 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE) | |
5800 { | |
5801 WaitMessage(); | |
5802 continue; | |
5803 } | |
5804 | |
5805 pRenderer->BeginScene(); | |
5806 pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX); | |
5807 | |
5808 GUI_MainMenuMessageProc(); | |
5809 GUI_UpdateWindows(); | |
5810 | |
5811 if (GetCurrentMenuID() != MENU_MAIN) | |
5812 { | |
5813 if (GetCurrentMenuID() == MENU_LoadingProcInMainMenu) | |
5814 { | |
5815 pIcons_LOD->RemoveTexturesPackFromTextureList(); | |
5816 pGUIWindow_CurrentMenu->Release(); | |
5817 pGUIWindow_CurrentMenu = 0; | |
5818 pCurrentScreen = SCREEN_GAME; | |
5819 viewparams->bRedrawGameUI = 1; | |
5820 } | |
5821 } | |
5822 else | |
5823 { | |
5824 if (!pModalWindow)// ??? | |
5825 { | |
5826 pButton = pWindow->pControlsHead; | |
5827 for (pButton = pWindow->pControlsHead; pButton; pButton = pButton->pNext) | |
5828 { | |
5829 if (pt.x >= (signed int)pButton->uX && pt.x <= (signed int)pButton->uZ | |
5830 && pt.y >= (signed int)pButton->uY && pt.y <= (signed int)pButton->uW | |
5831 && pWindow == pWindow_MainMenu) | |
5832 { | |
5833 pControlParam = pButton->msg_param; | |
5834 switch (pControlParam) // backlight for buttons | |
5835 { | |
5836 case 0: | |
5837 pTexture = pNew; | |
5838 pY = 172; | |
5839 break; | |
5840 case 1: | |
5841 pTexture = pLoad; | |
5842 pY = 227; | |
5843 break; | |
5844 case 2: | |
5845 pTexture = pCredits; | |
5846 pY = 282; | |
5847 break; | |
5848 case 3: | |
5849 pTexture = pExit; | |
5850 pY = 337; | |
5851 break; | |
5852 } | |
5853 pRenderer->DrawTextureIndexed(495, pY, pTexture); | |
5854 } | |
5855 } | |
5856 } | |
5857 } | |
5858 pRenderer->EndScene(); | |
5859 pRenderer->Present(); | |
5860 } | |
5861 GUI_MainMenuMessageProc(); | |
5862 pRenderer->BeginScene(); | |
5863 GUI_UpdateWindows(); | |
5864 pRenderer->EndScene(); | |
5865 pRenderer->Present(); | |
5866 pTexture_PCX.Release(); | |
5867 if (pGUIWindow2) | |
5868 { | |
5869 pGUIWindow2->Release(); | |
5870 pGUIWindow2 = 0; | |
5871 } | |
5872 pWindow_MainMenu->Release(); | |
5873 pIcons_LOD->RemoveTexturesPackFromTextureList(); | |
5874 } | |
5875 | |
5876 //----- (004BF91E) -------------------------------------------------------- | |
5877 unsigned int GameOverMenu(void *ecx0) | |
5878 { | |
5879 const char *v1; // eax@2 | |
5880 unsigned int result; // eax@3 | |
5881 const char *v6; // eax@10 | |
5882 const char *v7; // edx@10 | |
5883 const char *v8; // ecx@12 | |
5884 const char *v9; // eax@14 | |
5885 unsigned int v10; // eax@25 | |
5886 GUIWindow pWindow; // [sp+34h] [bp-9Ch]@1 | |
5887 unsigned int v14; // [sp+A4h] [bp-2Ch]@5 | |
5888 void *v15; // [sp+A8h] [bp-28h]@1 | |
5889 const char *pInString; // [sp+ACh] [bp-24h]@5 | |
5890 unsigned int v17; // [sp+B0h] [bp-20h]@5 | |
5891 unsigned int v18; // [sp+B4h] [bp-1Ch]@5 | |
5892 unsigned int v19; // [sp+B8h] [bp-18h]@5 | |
5893 int v20; // [sp+BCh] [bp-14h]@7 | |
5894 GUIFont *pFont; // [sp+C4h] [bp-Ch]@1 | |
5895 unsigned __int64 v23; // [sp+C8h] [bp-8h]@5 | |
5896 MSG msg; | |
5897 | |
5898 v15 = ecx0; | |
5899 | |
5900 RGBTexture _this; // [sp+Ch] [bp-C4h]@1 | |
5901 //RGBTexture::RGBTexture(&this); | |
5902 | |
5903 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_4000; | |
5904 bGameoverLoop = 1; | |
5905 pMediaPlayer->bStopBeforeSchedule = 0; | |
5906 pAudioPlayer->StopChannels(-1, -1); | |
5907 pRenderer->BeginScene(); | |
5908 pRenderer->ClearBlack(); | |
5909 pRenderer->EndScene(); | |
5910 pRenderer->Present(); | |
5911 //pMediaPlayer->pResetflag = 0; | |
5912 _449B57_test_bit(pParty->_quest_bits, 99); | |
5913 _this.Load("winbg.pcx", 2); | |
5914 pRenderer->BeginScene(); | |
5915 pRenderer->DrawTextureRGB(0, 0, &_this); | |
5916 pRenderer->EndScene(); | |
5917 free(_this.pPixels); | |
5918 _this.pPixels = 0; | |
5919 window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); | |
5920 pWindow.uFrameX = 75; | |
5921 pWindow.uFrameY = 60; | |
5922 pWindow.uFrameWidth = 469; | |
5923 pWindow.uFrameHeight = 338; | |
5924 pWindow.uFrameZ = 543; | |
5925 pWindow.uFrameW = 397; | |
5926 pFont = LoadFont("endgame.fnt", "FONTPAL", NULL); | |
5927 if (pParty->IsPartyGood()) | |
5928 v1 = pGlobalTXT_LocalizationStrings[675];//"Splendid job! With the activation of the Gate, a thousand worlds lie at your feet. Perhaps on one of them you will find the Ancients themselves, and return with the fruits their great civilization has to offer your world and your kingdom." | |
5929 else | |
5930 { | |
5931 result = pParty->IsPartyEvil(); | |
5932 if (!(short)result) | |
5933 return result; | |
5934 v1 = pGlobalTXT_LocalizationStrings[676];//"Brilliant! The completion of the Heavenly Forge has provided enough Ancient weapons to crush all resistance to your plans. Soon the world will bow to your every whim! Still, you can't help but wonder what was beyond the Gate the other side was trying so hard to build." | |
5935 } | |
5936 pInString = v1; | |
5937 v23 = pParty->uTimePlayed - 138240; | |
5938 v19 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 24; | |
5939 v14 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 24 / 0x1C / 0xC; | |
5940 v18 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 24 / 0x1C % 0xC; | |
5941 v17 = v19 % 0x1C; | |
5942 if (!v19) | |
5943 v19 = 1; | |
5944 pRenderer->BeginScene(); | |
5945 pWindow.DrawTitleText(pFont, 1, 0x23, 1, pGlobalTXT_LocalizationStrings[9], 3);//Congratulations! | |
5946 v23 = 0i64; | |
5947 v20 = 0; | |
5948 for (uint i = 0; i < 4; i++) | |
5949 { | |
5950 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[129], pParty->pPlayers[i].pName, pParty->pPlayers[i].GetBaseLevel(), pClassNames[pParty->pPlayers[i].classType]);//%s the Level %u %s | |
5951 pWindow.DrawTitleText(pFont, 1, i * (LOBYTE(pFont->uFontHeight) - 2) + LOBYTE(pFont->uFontHeight) + 46, 1, pTmpBuf.data(), 3); | |
5952 v23 += pParty->pPlayers[i].uExperience;//__PAIR__(*(int *)(i - 4), *(int *)(i - 8)); | |
5953 } | |
5954 v23 = (signed __int64)v23 / v19; | |
5955 v6 = FitTextInAWindow(pInString, pFont, &pWindow, 0xC, 0); | |
5956 pWindow.DrawTitleText(pFont, 1, 5 * (LOBYTE(pFont->uFontHeight) + 11), 1, v6, 0); | |
5957 strcpy(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[37]);//Total Time: | |
5958 | |
5959 v7 = pGlobalTXT_LocalizationStrings[56]; | |
5960 if (v17 != 1) | |
5961 v7 = pGlobalTXT_LocalizationStrings[57]; | |
5962 | |
5963 v8 = pGlobalTXT_LocalizationStrings[146];//Month | |
5964 if (v18 != 1) | |
5965 v8 = pGlobalTXT_LocalizationStrings[148];//Months | |
5966 | |
5967 v9 = pGlobalTXT_LocalizationStrings[245]; | |
5968 if (v14 != 1) | |
5969 v9 = pGlobalTXT_LocalizationStrings[132]; | |
5970 | |
5971 sprintf(pTmpBuf2.data(), " %lu %s, %lu %s, %lu %s ", v14, v9, v18, v8, v17, v7); | |
5972 strcat(pTmpBuf.data(), pTmpBuf2.data()); | |
5973 pWindow.DrawTitleText(pFont, 1, pWindow.uFrameHeight - 2 * LOBYTE(pFont->uFontHeight) - 5, 1, pTmpBuf.data(), 3); | |
5974 sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[94], v23); | |
5975 pWindow.DrawTitleText(pFont, 1, pWindow.uFrameHeight, 1, pTmpBuf.data(), 3); | |
5976 dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000; | |
5977 pRenderer->EndScene(); | |
5978 pRenderer->Present(); | |
5979 //if ( pRenderer->pRenderD3D ) | |
5980 pRenderer->pBeforePresentFunction(); | |
5981 pRenderer->SaveWinnersCertificate("MM7_Win.Pcx"); | |
5982 free(pFont); | |
5983 window_SpeakInHouse->Release(); | |
5984 window_SpeakInHouse = 0; | |
5985 if (v15 == (void *)2) | |
5986 result = pMessageQueue_50CBD0->uNumMessages; | |
5987 else | |
5988 { | |
5989 LODWORD(v23) = GetTickCount() + 5000; | |
5990 while ((unsigned int)v23 > GetTickCount()) | |
5991 ; | |
5992 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) | |
5993 { | |
5994 if (msg.message == WM_QUIT) | |
5995 Game_DeinitializeAndTerminate(0); | |
5996 TranslateMessage(&msg); | |
5997 DispatchMessage(&msg); | |
5998 } | |
5999 if (pMessageQueue_50CBD0->uNumMessages) | |
6000 { | |
6001 LOBYTE(v10) = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
6002 pMessageQueue_50CBD0->uNumMessages = v10; | |
6003 } | |
6004 pKeyActionMap->ResetKeys(); | |
6005 pKeyActionMap->uLastKeyPressed = 0; | |
6006 do | |
6007 { | |
6008 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) | |
6009 { | |
6010 if (msg.message == WM_QUIT) | |
6011 Game_DeinitializeAndTerminate(0); | |
6012 TranslateMessage(&msg); | |
6013 DispatchMessage(&msg); | |
6014 } | |
6015 } while (!pKeyActionMap->uLastKeyPressed); | |
6016 result = pMessageQueue_50CBD0->uNumMessages; | |
6017 if (pMessageQueue_50CBD0->uNumMessages) | |
6018 { | |
6019 result = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
6020 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
6021 } | |
6022 } | |
6023 if (v15) | |
6024 { | |
6025 /*if ( (signed int)result < 40 ) | |
6026 { | |
6027 pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_Quit; | |
6028 }*/ | |
6029 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Quit, 1, 0); | |
6030 } | |
6031 else | |
6032 { | |
6033 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ShowFinalWindow, 1, 0); | |
6034 /*if ( (signed int)result < 40 ) | |
6035 { | |
6036 pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_C5; | |
6037 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; | |
6038 result = 3 * pMessageQueue_50CBD0->uNumMessages + 3; | |
6039 *(&pMessageQueue_50CBD0->uNumMessages + result) = 0; | |
6040 ++pMessageQueue_50CBD0->uNumMessages; | |
6041 }*/ | |
6042 } | |
6043 bGameoverLoop = 0; | |
6044 return result; | |
6045 } | |
6046 | |
6047 //----- (00464479) -------------------------------------------------------- | |
6048 void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows() | |
6049 { | |
6050 int v0; // esi@9 | |
6051 | |
6052 if (pMouse) | |
6053 pMouse->SetCursorBitmap("MICON1"); | |
6054 | |
6055 pPaletteManager->ResetNonLocked(); | |
6056 pBitmaps_LOD->ReleaseAll2(); | |
6057 pSprites_LOD->DeleteSomeOtherSprites(); | |
6058 pIcons_LOD->ReleaseAll2(); | |
6059 | |
6060 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
6061 pIndoor->Release(); | |
6062 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
6063 pOutdoor->Release(); | |
6064 | |
6065 pAudioPlayer->StopChannels(-1, -1); | |
6066 pSoundList->_4A9D79(0); | |
6067 uCurrentlyLoadedLevelType = LEVEL_null; | |
6068 pSpriteFrameTable->ResetSomeSpriteFlags(); | |
6069 v0 = uNumVisibleWindows; | |
6070 pParty->armageddon_timer = 0; | |
6071 while (v0 > 0) | |
6072 pWindowList[pVisibleWindowsIdxs[v0--] - 1].Release(); | |
6073 } | |
6074 | |
6075 //----- (00461103) -------------------------------------------------------- | |
6076 void _461103_load_level_sub() | |
6077 { | |
6078 int v4; // edx@8 | |
6079 signed int v6; // esi@14 | |
6080 signed int v8; // ecx@16 | |
6081 int v12; // esi@25 | |
6082 int v13; // eax@26 | |
6083 __int16 v14; // ax@41 | |
6084 signed int v17; // [sp+14h] [bp-48h]@3 | |
6085 signed int v18; // [sp+14h] [bp-48h]@23 | |
6086 int v19; // [sp+18h] [bp-44h]@1 | |
6087 signed int v20; // [sp+18h] [bp-44h]@14 | |
6088 int v21[16]; // [sp+1Ch] [bp-40h]@17 | |
6089 | |
6090 GenerateItemsInChest(); | |
6091 pGameLoadingUI_ProgressBar->Progress(); | |
6092 pParty->uFlags |= 2; | |
6093 pParty->field_7B5_in_arena_quest = 0; | |
6094 dword_5C6DF8 = 1; | |
6095 pNPCStats->uNewlNPCBufPos = 0; | |
6096 v19 = pMapStats->GetMapInfo(pCurrentMapName); | |
6097 | |
6098 //v15 = 0; | |
6099 for (uint i = 0; i < uNumActors; ++i) | |
6100 //if ( (signed int)uNumActors > 0 ) | |
6101 { | |
6102 //Actor* pActor = &pActors[i]; | |
6103 //v2 = (char *)&pActors[0].uNPC_ID; | |
6104 //do | |
6105 //{ | |
6106 //v3 = pActors[i].pMonsterInfo.uID; | |
6107 v17 = 0; | |
6108 if (pActors[i].pMonsterInfo.uID >= 115 && pActors[i].pMonsterInfo.uID <= 186 | |
6109 || pActors[i].pMonsterInfo.uID >= 232 && pActors[i].pMonsterInfo.uID <= 249) | |
6110 v17 = 1; | |
6111 //v1 = 0; | |
6112 v4 = (pActors[i].pMonsterInfo.uID - 1) % 3; | |
6113 if (2 == v4) | |
6114 { | |
6115 if (pActors[i].sNPC_ID && pActors[i].sNPC_ID < 5000) | |
6116 continue; | |
6117 } | |
6118 else | |
6119 { | |
6120 if (v4 != 1) | |
6121 { | |
6122 if (v4 == 0 && pActors[i].sNPC_ID == 0) | |
6123 pActors[i].sNPC_ID = 0; | |
6124 continue; | |
6125 } | |
6126 } | |
6127 if (pActors[i].sNPC_ID > 0 && pActors[i].sNPC_ID < 5000) | |
6128 continue; | |
6129 if (v17) | |
6130 { | |
6131 pNPCStats->InitializeAdditionalNPCs(&pNPCStats->pAdditionalNPC[pNPCStats->uNewlNPCBufPos], pActors[i].pMonsterInfo.uID, 0, v19); | |
6132 v14 = LOWORD(pNPCStats->uNewlNPCBufPos) + 5000; | |
6133 ++pNPCStats->uNewlNPCBufPos; | |
6134 pActors[i].sNPC_ID = v14; | |
6135 continue; | |
6136 } | |
6137 pActors[i].sNPC_ID = 0; | |
6138 //++v15; | |
6139 //v2 += 836; | |
6140 //} | |
6141 //while ( v15 < (signed int)uNumActors ); | |
6142 } | |
6143 | |
6144 pGameLoadingUI_ProgressBar->Progress(); | |
6145 | |
6146 //v5 = uNumActors; | |
6147 v6 = 0; | |
6148 v20 = 0; | |
6149 //v16 = v1; | |
6150 | |
6151 for (uint i = 0; i < uNumActors; ++i) | |
6152 { | |
6153 //v7 = (char *)&pActors[0].pMonsterInfo; | |
6154 //do | |
6155 //{ | |
6156 for (v8 = 0; v8 < v6; ++v8) | |
6157 { | |
6158 if (v21[v8] == pActors[i].pMonsterInfo.uID - 1) | |
6159 break; | |
6160 } | |
6161 | |
6162 if (v8 == v6) | |
6163 { | |
6164 v21[v6++] = pActors[i].pMonsterInfo.uID - 1; | |
6165 v20 = v6; | |
6166 if (v6 == 16) | |
6167 break; | |
6168 } | |
6169 //++v16; | |
6170 //v7 += 836; | |
6171 //} | |
6172 //while ( v16 < (signed int)v5 ); | |
6173 } | |
6174 | |
6175 pGameLoadingUI_ProgressBar->Progress(); | |
6176 | |
6177 for (int _v0 = 0; _v0 < v6; ++_v0) | |
6178 { | |
6179 for (v18 = 4; v18; --v18) | |
6180 pSoundList->LoadSound(pMonsterList->pMonsters[v21[_v0]].pSoundSampleIDs[4 - v18], 0); | |
6181 v12 = 0; | |
6182 do | |
6183 v13 = pSoundList->LoadSound(v12++ + word_4EE088_sound_ids[pMonsterStats->pInfos[v21[_v0] + 1].uSpell1ID], 1); | |
6184 while (v13); | |
6185 } | |
6186 //v0 = pGameLoadingUI_ProgressBar; | |
6187 //v1 = 0; | |
6188 | |
6189 pGameLoadingUI_ProgressBar->Progress(); | |
6190 | |
6191 if (dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_ACTORS) | |
6192 uNumActors = 0; | |
6193 if (dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_DECORATIONS) | |
6194 uNumLevelDecorations = 0; | |
6195 init_event_triggers(); | |
6196 | |
6197 pGameLoadingUI_ProgressBar->Progress(); | |
6198 | |
6199 pGame->pIndoorCameraD3D->vPartyPos.x = 0; | |
6200 pGame->pIndoorCameraD3D->vPartyPos.y = 0; | |
6201 pGame->pIndoorCameraD3D->vPartyPos.z = 100; | |
6202 pGame->pIndoorCameraD3D->sRotationX = 0; | |
6203 pGame->pIndoorCameraD3D->sRotationY = 0; | |
6204 viewparams->bRedrawGameUI = true; | |
6205 uLevel_StartingPointType = MapStartPoint_Party; | |
6206 pSprites_LOD->_461397(); | |
6207 pPaletteManager->LockTestAll(); | |
6208 if (pParty->pPickedItem.uItemID != 0) | |
6209 pMouse->SetCursorBitmapFromItemID(pParty->pPickedItem.uItemID); | |
6210 } | |
6211 | |
6212 //----- (004613C4) -------------------------------------------------------- | |
6213 void init_event_triggers() | |
6214 { | |
6215 uint id = pDecorationList->GetDecorIdByName("Event Trigger"); | |
6216 | |
6217 num_event_triggers = 0; | |
6218 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
6219 if (pLevelDecorations[i].uDecorationDescID == id) | |
6220 event_triggers[num_event_triggers++] = i; | |
6221 } | |
6222 | |
6223 //----- (0042F3D6) -------------------------------------------------------- | |
6224 void InitializeTurnBasedAnimations(void *_this) | |
6225 { | |
6226 for (unsigned int i = 0; i < pIconIDs_Turn.size(); ++i) | |
6227 { | |
6228 char icon_name[32]; | |
6229 sprintf(icon_name, "turn%u", i); | |
6230 pIconIDs_Turn[i] = pIconsFrameTable->FindIcon(icon_name); | |
6231 pIconsFrameTable->InitializeAnimation(pIconIDs_Turn[i]); | |
6232 } | |
6233 | |
6234 uIconID_TurnStop = pIconsFrameTable->FindIcon("turnstop"); | |
6235 uIconID_TurnHour = pIconsFrameTable->FindIcon("turnhour"); | |
6236 uIconID_TurnStart = pIconsFrameTable->FindIcon("turnstart"); | |
6237 uIconID_CharacterFrame = pIconsFrameTable->FindIcon("aframe1"); | |
6238 uSpriteID_Spell11 = pSpriteFrameTable->FastFindSprite("spell11"); | |
6239 | |
6240 pIconsFrameTable->InitializeAnimation(uIconID_TurnHour); | |
6241 pIconsFrameTable->InitializeAnimation(uIconID_TurnStop); | |
6242 pIconsFrameTable->InitializeAnimation(uIconID_TurnStart); | |
6243 pIconsFrameTable->InitializeAnimation(uIconID_CharacterFrame); | |
6244 } | |
6245 | |
6246 //----- (00466C40) -------------------------------------------------------- | |
6247 const wchar_t *MENU_STATE_to_string(MENU_STATE m) | |
6248 { | |
6249 switch (m) | |
6250 { | |
6251 case -1: return L"-1"; | |
6252 case MENU_MAIN: return L"MENU_MAIN"; | |
6253 case MENU_NEWGAME: return L"MENU_NEWGAME"; | |
6254 case MENU_CREDITS: return L"MENU_CREDITS"; | |
6255 case MENU_SAVELOAD: return L"MENU_SAVELOAD"; | |
6256 case MENU_EXIT_GAME: return L"MENU_EXIT_GAME"; | |
6257 case MENU_5: return L"MENU_5"; | |
6258 case MENU_CREATEPARTY: return L"MENU_CREATEPARTY"; | |
6259 case MENU_NAMEPANELESC: return L"MENU_NAMEPANELESC"; | |
6260 case MENU_CREDITSPROC: return L"MENU_CREDITSPROC"; | |
6261 case MENU_LoadingProcInMainMenu: return L"MENU_LoadingProcInMainMenu"; | |
6262 case MENU_DebugBLVLevel: return L"MENU_DebugBLVLevel"; | |
6263 case MENU_CREDITSCLOSE: return L"MENU_CREDITSCLOSE"; | |
6264 case MENU_MMT_MAIN_MENU: return L"MENU_MMT_MAIN_MENU"; | |
6265 default: return L"unk"; | |
6266 }; | |
6267 }; | |
6268 void SetCurrentMenuID(MENU_STATE uMenu) | |
6269 { | |
6270 sCurrentMenuID = uMenu; | |
6271 | |
6272 Log::Warning(L"CurrentMenu = %s \n", MENU_STATE_to_string(uMenu)); | |
6273 } | |
6274 | |
6275 //----- (00466CA0) -------------------------------------------------------- | |
6276 MENU_STATE GetCurrentMenuID() | |
6277 { | |
6278 return sCurrentMenuID; | |
6279 } | |
6280 | |
6281 //----- (0046BDA8) -------------------------------------------------------- | |
6282 unsigned int GetGravityStrength() | |
6283 { | |
6284 int v0; // eax@1 | |
6285 | |
6286 v0 = ~LOBYTE(pGame->uFlags2) & 8; | |
6287 LOBYTE(v0) = v0 | 2; | |
6288 return (unsigned int)v0 >> 1; | |
6289 } | |
6290 | |
6291 //----- (00448B45) -------------------------------------------------------- | |
6292 void GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide) | |
6293 { | |
6294 if (bForceHide || GameUI_Footer_TimeLeft && GetTickCount() >= GameUI_Footer_TimeLeft) | |
6295 GameUI_Footer_TimeLeft = 0; | |
6296 } | |
6297 | |
6298 //----- (0044861E) -------------------------------------------------------- | |
6299 void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename) | |
6300 { | |
6301 unsigned int texture; // eax@2 | |
6302 | |
6303 if (uFaceCog) | |
6304 { | |
6305 texture = pBitmaps_LOD->LoadTexture(pFilename); | |
6306 if (texture != -1 ? (int)&pBitmaps_LOD->pTextures[texture] : 0) | |
6307 { | |
6308 pBitmaps_LOD->pTextures[texture].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[texture].palette_id1); | |
6309 | |
6310 if (uCurrentlyLoadedLevelType == 1) | |
6311 { | |
6312 if ((signed int)pIndoor->uNumFaceExtras > 1) | |
6313 { | |
6314 for (uint i = 1; i < (signed int)pIndoor->uNumFaceExtras; ++i) | |
6315 { | |
6316 if (pIndoor->pFaceExtras[i].sCogNumber == uFaceCog) | |
6317 { | |
6318 if (pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes & FACE_TEXTURE_FRAME) | |
6319 { | |
6320 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = pTextureFrameTable->FindTextureByName(pFilename); | |
6321 if (pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID) | |
6322 { | |
6323 pTextureFrameTable->LoadAnimationSequenceAndPalettes(pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID); | |
6324 } | |
6325 else | |
6326 { | |
6327 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = texture; | |
6328 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes &= 0xBF00; | |
6329 } | |
6330 } | |
6331 else | |
6332 { | |
6333 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = texture; | |
6334 } | |
6335 } | |
6336 } | |
6337 } | |
6338 pParty->uFlags |= 2; | |
6339 } | |
6340 else | |
6341 { | |
6342 for (uint j = 0; j < (unsigned int)pOutdoor->uNumBModels; ++j) | |
6343 { | |
6344 for (uint i = 0; i < pOutdoor->pBModels[j].uNumFaces; ++i) | |
6345 { | |
6346 if (pOutdoor->pBModels[j].pFaces[i].sCogNumber == uFaceCog) | |
6347 { | |
6348 if (pOutdoor->pBModels[j].pFaces[i].uAttributes & FACE_TEXTURE_FRAME) | |
6349 { | |
6350 pOutdoor->pBModels[j].pFaces[i].uTextureID = pTextureFrameTable->FindTextureByName(pFilename); | |
6351 if (pOutdoor->pBModels[j].pFaces[i].uTextureID) | |
6352 pTextureFrameTable->LoadAnimationSequenceAndPalettes(pOutdoor->pBModels[j].pFaces[i].uTextureID); | |
6353 else | |
6354 { | |
6355 pOutdoor->pBModels[j].pFaces[i].uTextureID = texture; | |
6356 pOutdoor->pBModels[j].pFaces[i].uAttributes &= 0xBF00; | |
6357 } | |
6358 } | |
6359 else | |
6360 pOutdoor->pBModels[j].pFaces[i].uTextureID = texture; | |
6361 } | |
6362 } | |
6363 } | |
6364 } | |
6365 pParty->uFlags |= 2; | |
6366 } | |
6367 } | |
6368 } | |
6369 | |
6370 //----- (0044892E) -------------------------------------------------------- | |
6371 void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on) | |
6372 { | |
6373 if (sCogNumber) | |
6374 { | |
6375 if (uCurrentlyLoadedLevelType == 1) | |
6376 { | |
6377 for (uint i = 1; i < (unsigned int)pIndoor->uNumFaceExtras; ++i) | |
6378 { | |
6379 if (pIndoor->pFaceExtras[i].sCogNumber == sCogNumber) | |
6380 { | |
6381 if (on) | |
6382 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes |= bit; | |
6383 else | |
6384 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes &= ~bit; | |
6385 } | |
6386 } | |
6387 pParty->uFlags |= 2; | |
6388 } | |
6389 else | |
6390 { | |
6391 for (uint j = 0; j < (unsigned int)pOutdoor->uNumBModels; ++j) | |
6392 { | |
6393 for (uint i = 0; i < (unsigned int)pOutdoor->pBModels[j].uNumFaces; ++i) | |
6394 { | |
6395 if (pOutdoor->pBModels[j].pFaces[i].sCogNumber == sCogNumber) | |
6396 { | |
6397 if (on) | |
6398 pOutdoor->pBModels[j].pFaces[i].uAttributes |= bit; | |
6399 else | |
6400 pOutdoor->pBModels[j].pFaces[i].uAttributes &= ~bit; | |
6401 } | |
6402 } | |
6403 } | |
6404 } | |
6405 pParty->uFlags |= 2; | |
6406 } | |
6407 } | |
6408 | |
6409 //----- (0044882F) -------------------------------------------------------- | |
6410 void __fastcall SetDecorationSprite(uint16_t uCog, bool bHide, const char *pFileName) | |
6411 { | |
6412 for (size_t i = 0; i < uNumLevelDecorations; i++) | |
6413 { | |
6414 if (pLevelDecorations[i].uCog == uCog) | |
6415 { | |
6416 if (pFileName && strcmp(pFileName, "0")) | |
6417 { | |
6418 pLevelDecorations[i].uDecorationDescID = pDecorationList->GetDecorIdByName(pFileName); | |
6419 pDecorationList->InitializeDecorationSprite(pLevelDecorations[i].uDecorationDescID); | |
6420 } | |
6421 | |
6422 if (bHide) | |
6423 pLevelDecorations[i].uFlags &= ~LEVEL_DECORATION_INVISIBLE; | |
6424 else | |
6425 pLevelDecorations[i].uFlags |= LEVEL_DECORATION_INVISIBLE; | |
6426 | |
6427 pParty->uFlags |= 2; | |
6428 } | |
6429 } | |
6430 } |