Mercurial > mm7
comparison Game.cpp @ 223:1bd823f52e3a
Merge
author | Gloval |
---|---|
date | Sun, 17 Feb 2013 11:41:44 +0400 |
parents | 650d96af8855 |
children | bcd55744c2f4 |
comparison
equal
deleted
inserted
replaced
222:8113753ed2ae | 223:1bd823f52e3a |
---|---|
14 #include "LOD.h" | 14 #include "LOD.h" |
15 #include "OSInfo.h" | 15 #include "OSInfo.h" |
16 #include "GUIWindow.h" | 16 #include "GUIWindow.h" |
17 #include "Party.h" | 17 #include "Party.h" |
18 #include "TurnEngine.h" | 18 #include "TurnEngine.h" |
19 #include "stru157.h" | |
20 #include "VideoPlayer.h" | 19 #include "VideoPlayer.h" |
21 #include "Bink_Smacker.h" | 20 #include "Bink_Smacker.h" |
22 #include "Events.h" | 21 #include "Events.h" |
23 #include "Arcomage.h" | 22 #include "Arcomage.h" |
24 #include "texts.h" | 23 #include "texts.h" |
24 #include "Actor.h" | |
25 #include "Log.h" | |
25 | 26 |
26 //#include "MM7.h" | 27 //#include "MM7.h" |
27 | 28 |
28 | 29 |
29 | 30 |
581 | 582 |
582 //----- (0044EEA7) -------------------------------------------------------- | 583 //----- (0044EEA7) -------------------------------------------------------- |
583 bool Game::_44EEA7() | 584 bool Game::_44EEA7() |
584 { | 585 { |
585 //Game *v1; // esi@1 | 586 //Game *v1; // esi@1 |
586 double v2; // st7@2 | 587 //double v2; // st7@2 |
587 float depth; // ST00_4@9 | 588 float depth; // ST00_4@9 |
588 bool result; // eax@9 | 589 //bool result; // eax@9 |
589 unsigned int v5; // eax@14 | 590 unsigned int v5; // eax@14 |
590 __int64 v6; // kr00_8@21 | 591 __int64 v6; // kr00_8@21 |
591 unsigned int y; // [sp+4h] [bp-24h]@2 | 592 unsigned int y; // [sp+4h] [bp-24h]@2 |
592 unsigned int x; // [sp+8h] [bp-20h]@2 | 593 unsigned int x; // [sp+8h] [bp-20h]@2 |
593 bool v9; // [sp+Ch] [bp-1Ch]@2 | 594 Vis_SelectionFilter *v10; // [sp+10h] [bp-18h]@2 |
594 stru157 *v10; // [sp+10h] [bp-18h]@2 | 595 Vis_SelectionFilter *v11; // [sp+14h] [bp-14h]@2 |
595 stru157 *v11; // [sp+14h] [bp-14h]@2 | |
596 POINT a2; // [sp+20h] [bp-8h]@1 | 596 POINT a2; // [sp+20h] [bp-8h]@1 |
597 | 597 |
598 //v1 = this; | 598 //v1 = this; |
599 ++qword_5C6DF0; | 599 ++qword_5C6DF0; |
600 pParticleEngine->UpdateParticles(); | 600 pParticleEngine->UpdateParticles(); |
601 pMouseInstance->GetCursorPos(&a2); | 601 pMouseInstance->GetCursorPos(&a2); |
602 | |
603 x = a2.y; | |
604 y = a2.x; | |
602 if ( sub_4637E0_is_there_popup_onscreen() ) | 605 if ( sub_4637E0_is_there_popup_onscreen() ) |
603 { | 606 { |
604 v11 = &a5; | 607 v11 = &vis_face_filter; |
605 v10 = &stru_F93E30; | 608 v10 = &vis_sprite_filter_2; |
606 v9 = 0; | 609 depth = GetPickDepth(); |
607 x = a2.y; | |
608 y = a2.x; | |
609 v2 = GetPickDepth(); | |
610 } | 610 } |
611 else | 611 else |
612 { | 612 { |
613 if ( uFlags2 & 0x10 ) | 613 if ( uFlags2 & 0x10 ) |
614 { | 614 { |
615 v11 = &a5; | 615 v11 = &vis_face_filter; |
616 v10 = &stru_F93E1C; | 616 v10 = &vis_sprite_filter_1; |
617 } | 617 } |
618 else | 618 else |
619 { | 619 { |
620 static bool __init_flag = false; | 620 v11 = &vis_face_filter; |
621 static stru157 static_sub_44EEA7_stru157; | 621 v10 = &vis_sprite_filter_4; |
622 if (!__init_flag) | 622 } |
623 { | 623 depth = 5120.0; |
624 __init_flag = true; | 624 } |
625 static_sub_44EEA7_stru157.field_8 = -1; | 625 //depth = v2; |
626 static_sub_44EEA7_stru157.field_0 = 0; | 626 |
627 static_sub_44EEA7_stru157.field_4 = 2; | 627 PickMouse(depth, y, x, true, v10, v11); |
628 static_sub_44EEA7_stru157.field_C = 0; | |
629 static_sub_44EEA7_stru157.field_10 = 0; | |
630 } | |
631 v11 = &a5; | |
632 v10 = &static_sub_44EEA7_stru157; | |
633 } | |
634 v2 = 5120.0; | |
635 v9 = 0; | |
636 x = a2.y; | |
637 y = a2.x; | |
638 } | |
639 depth = v2; | |
640 | |
641 PickMouse(depth, y, x, v9, v10, v11); | |
642 pLightmapBuilder->std__vector_000004_size = 0; | 628 pLightmapBuilder->std__vector_000004_size = 0; |
643 pLightmapBuilder->std__vector_183808_size = 0; | 629 pLightmapBuilder->std__vector_183808_size = 0; |
644 pDecalBuilder->std__vector_pDecals_size = 0; | 630 pDecalBuilder->std__vector_pDecals_size = 0; |
645 pDecalBuilder->field_308008 = 0; | 631 pDecalBuilder->field_308008 = 0; |
646 result = _44F07B(); | 632 if (!_44F07B()) |
647 if ( result ) | 633 return false; |
648 { | 634 |
649 if ( uFlags & 8 ) | 635 if ( uFlags & 8 ) |
650 LOBYTE(pStru10Instance->field_4) = 0; | 636 LOBYTE(pStru10Instance->field_4) = 0; |
651 if ( pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor) | 637 if ( pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor) |
652 { | 638 { |
653 v5 = GetLevelFogColor(); | 639 v5 = GetLevelFogColor(); |
667 { | 653 { |
668 uFlags2 |= 1u; | 654 uFlags2 |= 1u; |
669 uNumStationaryLights_in_pStationaryLightsStack = pStationaryLightsStack->uNumLightsActive; | 655 uNumStationaryLights_in_pStationaryLightsStack = pStationaryLightsStack->uNumLightsActive; |
670 } | 656 } |
671 _44E904(); | 657 _44E904(); |
672 LOBYTE(result) = 1; | 658 return true; |
673 } | |
674 return result; | |
675 } | 659 } |
676 | 660 |
677 | 661 |
678 //----- (0044EDE4) -------------------------------------------------------- | 662 //----- (0044EDE4) -------------------------------------------------------- |
679 bool Game::AlterGamma(BLVFace *pFace, unsigned int *pColor) | 663 bool Game::AlterGamma(BLVFace *pFace, unsigned int *pColor) |
1036 uSomeGammaStartTime = pEventTimer->Time(); | 1020 uSomeGammaStartTime = pEventTimer->Time(); |
1037 return true; | 1021 return true; |
1038 } | 1022 } |
1039 | 1023 |
1040 //----- (0044EA5E) -------------------------------------------------------- | 1024 //----- (0044EA5E) -------------------------------------------------------- |
1041 char Game::PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, stru157 *a5, stru157 *a6) | 1025 bool Game::PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) |
1042 { | 1026 { |
1043 char result; // al@3 | 1027 if (pCurrentScreen || !pRenderer->pRenderD3D) |
1044 std::string v10; // [sp-4h] [bp-24h]@5 | 1028 return false; |
1045 float v11; // [sp+4h] [bp-1Ch]@10 | 1029 |
1046 float v12; // [sp+8h] [bp-18h]@10 | 1030 if (!pVisInstance) |
1047 const char *v13; // [sp+Ch] [bp-14h]@5 | 1031 { |
1048 int v14; // [sp+10h] [bp-10h]@5 | 1032 MessageBoxW(nullptr, L"The 'Vis' object pointer has not been instatiated, but CGame::Pick() is trying to call through it.", nullptr, 0); |
1049 std::string *v15; // [sp+18h] [bp-8h]@5 | 1033 return false; |
1050 int a3; // [sp+1Fh] [bp-1h]@5 | 1034 } |
1051 | 1035 |
1052 auto v7 = this; | 1036 if (uMouseX >= (signed int)pViewport->uScreenX && |
1053 if (!pCurrentScreen && pRenderer->pRenderD3D) | 1037 uMouseX <= (signed int)pViewport->uScreenZ && |
1054 { | 1038 uMouseY >= (signed int)pViewport->uScreenY && |
1055 if (!pVisInstance) | 1039 uMouseY <= (signed int)pViewport->uScreenW) |
1056 { | 1040 { |
1057 MessageBoxW(nullptr, L"The 'Vis' object pointer has not been instatiated, but CGame::Pick() is trying to call through it.", nullptr, 0); | 1041 pVisInstance->PickMouse(fPickDepth, uMouseX, uMouseY, sprite_filter, face_filter); |
1058 ExitProcess(0); | 1042 |
1059 } | 1043 if (bOutline) |
1060 | 1044 OutlineSelection(); |
1061 if ( (signed int)uMouseX >= (signed int)pViewport->uScreenX | 1045 } |
1062 && (signed int)uMouseX <= (signed int)pViewport->uScreenZ | 1046 |
1063 && (signed int)uMouseY >= (signed int)pViewport->uScreenY | 1047 return true; |
1064 && (signed int)uMouseY <= (signed int)pViewport->uScreenW ) | |
1065 { | |
1066 v14 = (int)a6; | |
1067 v12 = (double)(signed int)uMouseY; | |
1068 v11 = (double)(signed int)uMouseX; | |
1069 pVisInstance->PickMouse(fPickDepth, v11, v12, a5, a6); | |
1070 | |
1071 if (bOutline) | |
1072 OutlineSelection(); | |
1073 } | |
1074 return true; | |
1075 } | |
1076 return false; | |
1077 } | 1048 } |
1078 // 4E28F8: using guessed type int pCurrentScreen; | 1049 // 4E28F8: using guessed type int pCurrentScreen; |
1079 | 1050 |
1080 //----- (0044EB12) -------------------------------------------------------- | 1051 //----- (0044EB12) -------------------------------------------------------- |
1081 bool Game::_44EB12(bool bOutline, stru157 *a3, stru157 *a4) | 1052 bool Game::PickKeyboard(bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) |
1082 { | 1053 { |
1083 if ( !pCurrentScreen && pVisInstance && pRenderer->pRenderD3D ) | 1054 if ( !pCurrentScreen && pVisInstance && pRenderer->pRenderD3D ) |
1084 { | 1055 { |
1085 bool r = pVisInstance->PickKeyboard(&pVisInstance->stru1, a3, a4); | 1056 bool r = pVisInstance->PickKeyboard(&pVisInstance->default_list, sprite_filter, face_filter); |
1086 | 1057 |
1087 if (bOutline) | 1058 if (bOutline) |
1088 OutlineSelection(); | 1059 OutlineSelection(); |
1089 return r; | 1060 return r; |
1090 } | 1061 } |
1105 // 4E28F8: using guessed type int pCurrentScreen; | 1076 // 4E28F8: using guessed type int pCurrentScreen; |
1106 | 1077 |
1107 //----- (0044EB5A) -------------------------------------------------------- | 1078 //----- (0044EB5A) -------------------------------------------------------- |
1108 void Game::OutlineSelection() | 1079 void Game::OutlineSelection() |
1109 { | 1080 { |
1110 Vis *v1; // eax@1 | 1081 if (!pVisInstance) |
1111 Vis_stru1_stru0 *v2; // eax@3 | 1082 return; |
1112 void *v3; // edx@9 | 1083 |
1113 int v4; // eax@10 | 1084 if (!pVisInstance->default_list.uNumPointers) |
1114 int v5; // eax@11 | 1085 return; |
1115 int v6; // eax@14 | 1086 |
1116 int v7; // eax@15 | 1087 auto object_info = pVisInstance->default_list.object_pointers[0]; |
1117 const char *v9; // [sp-8h] [bp-14h]@8 | 1088 if (object_info) |
1118 int v10; // [sp-4h] [bp-10h]@8 | 1089 switch (object_info->object_type) |
1119 char v11; // [sp+0h] [bp-Ch]@18 | 1090 { |
1120 int a3; // [sp+Ah] [bp-2h]@8 | 1091 case VisObjectType_Sprite: |
1121 | 1092 { |
1122 v1 = this->pVisInstance; | 1093 Log::Warning(L"Sprite outline currently unsupported"); |
1123 if ( v1 ) | 1094 return; |
1124 { | 1095 } |
1125 v2 = (Vis_stru1_stru0 *)((signed int)v1->stru1.uNumPointers <= 0 ? 0 : v1->stru1.array_1804[0]); | 1096 |
1126 if ( v2 ) | 1097 case VisObjectType_Face: |
1127 { | 1098 { |
1128 if ( v2->uObjectType == 1 ) | 1099 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) |
1129 { | 1100 { |
1130 MessageBoxW(nullptr, L"Sprite outline currently Unsupported", nullptr, 0); | 1101 auto face = (ODMFace *)object_info->object; |
1102 if (face->uAttributes & FACE_OUTLINED) | |
1103 face->uAttributes &= ~FACE_OUTLINED; | |
1104 else | |
1105 face->uAttributes |= FACE_OUTLINED; | |
1106 } | |
1107 else if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
1108 { | |
1109 auto face = (BLVFace *)object_info->object; | |
1110 if (face->uAttributes & FACE_OUTLINED) | |
1111 face->uAttributes &= ~FACE_OUTLINED; | |
1112 else | |
1113 face->uAttributes |= FACE_OUTLINED; | |
1114 } | |
1115 else assert(false); | |
1116 } | |
1117 | |
1118 default: | |
1119 { | |
1120 MessageBoxW(nullptr, L"Undefined CObjectInfo type requested in CGame::outline_selection()", nullptr, 0); | |
1131 ExitProcess(0); | 1121 ExitProcess(0); |
1132 } | 1122 } |
1133 | 1123 } |
1134 if ( v2->uObjectType == 2 ) | 1124 } |
1135 { | |
1136 v3 = v2->pObjectInfo; // TODO 2 objects for indoor/outdoor | |
1137 // some clues in header for Vis_stru1_stru0 | |
1138 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
1139 { | |
1140 v4 = *((int *)v3 + 11); | |
1141 if ( v4 & 0x10000 ) | |
1142 v5 = v4 & 0xFFFEFFFF; | |
1143 else | |
1144 v5 = v4 | 0x10000; | |
1145 *((int *)v3 + 11) = v5; | |
1146 } | |
1147 else | |
1148 { | |
1149 v6 = *((int *)v3 + 7); | |
1150 if ( v6 & 0x10000 ) | |
1151 v7 = v6 & 0xFFFEFFFF; | |
1152 else | |
1153 v7 = v6 | 0x10000; | |
1154 *((int *)v3 + 7) = v7; | |
1155 } | |
1156 } | |
1157 else | |
1158 { | |
1159 MessageBoxW(nullptr, L"Undefined CObjectInfo type requested in CGame::outline_selection()", nullptr, 0); | |
1160 ExitProcess(0); | |
1161 } | |
1162 } | |
1163 } | |
1164 } |