comparison Indoor.cpp @ 1306:13b7be8b06a0

Слияние
author Ritor1
date Sun, 23 Jun 2013 14:27:57 +0600
parents dcc52e17b517 5450af4f57ef
children ad903bb5b702
comparison
equal deleted inserted replaced
1305:1ab9bff65f01 1306:13b7be8b06a0
35 #include "IndoorCamera.h" 35 #include "IndoorCamera.h"
36 #include "Lights.h" 36 #include "Lights.h"
37 37
38 #include "mm7_data.h" 38 #include "mm7_data.h"
39 #include "MM7.h" 39 #include "MM7.h"
40 40 #include "Sprites.h"
41 41 #include "Game.h"
42 42 #include "stru6.h"
43 43 #include "ParticleEngine.h"
44 #include "Outdoor_stuff.h"
45 #include "texts.h"
46 #include "GUIWindow.h"
44 47
45 48
46 49
47 50
48 51
1333 nodes[num_nodes].uFaceID = uFaceID; 1336 nodes[num_nodes].uFaceID = uFaceID;
1334 nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; 1337 nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX;
1335 nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; 1338 nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ;
1336 nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; 1339 nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY;
1337 nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; 1340 nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW;
1338 nodes[num_nodes].field_C._43F9E1(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY, 1341 nodes[num_nodes].field_C.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY,
1339 pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW); 1342 pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW);
1340 AddBspNodeToRenderList(++num_nodes - 1); 1343 AddBspNodeToRenderList(++num_nodes - 1);
1341 return; 1344 return;
1342 } 1345 }
1343 //v5 = v39; 1346 //v5 = v39;
1489 v3->nodes[v3->num_nodes].uFaceID = uFaceID; 1492 v3->nodes[v3->num_nodes].uFaceID = uFaceID;
1490 v3->nodes[v3->num_nodes].uViewportX = LOWORD(pBLVRenderParams->uViewportX); 1493 v3->nodes[v3->num_nodes].uViewportX = LOWORD(pBLVRenderParams->uViewportX);
1491 v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ); 1494 v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ);
1492 v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY); 1495 v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY);
1493 v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW); 1496 v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW);
1494 v3->nodes[v3->num_nodes++].field_C._43F9E1( 1497 v3->nodes[v3->num_nodes++].field_C.GetViewportData(
1495 SLOWORD(pBLVRenderParams->uViewportX), 1498 SLOWORD(pBLVRenderParams->uViewportX),
1496 pBLVRenderParams->uViewportY, 1499 pBLVRenderParams->uViewportY,
1497 SLOWORD(pBLVRenderParams->uViewportZ), 1500 SLOWORD(pBLVRenderParams->uViewportZ),
1498 pBLVRenderParams->uViewportW); 1501 pBLVRenderParams->uViewportW);
1499 v7 = v3->num_nodes - 1; 1502 v7 = v3->num_nodes - 1;
4637 word_A750E2 = LOWORD(v34[rand() % v30]); 4640 word_A750E2 = LOWORD(v34[rand() % v30]);
4638 } 4641 }
4639 } 4642 }
4640 } 4643 }
4641 } 4644 }
4642 4645 //----- (0046CEC3) --------------------------------------------------------
4646 int BLV_GetFloorLevel(int x, int y, int z, unsigned int uSectorID, unsigned int *pFaceID)
4647 {
4648 int v13; // ecx@13
4649 signed int v14; // ebx@14
4650 int v15; // eax@16
4651 //int v16; // edx@19
4652 //int v17; // ST18_4@19
4653 //signed int v18; // edx@19
4654 //signed __int64 v19; // qtt@19
4655 int v21; // eax@27
4656 //int v22; // ecx@29
4657 signed int v28; // eax@45
4658 int v29; // ebx@47
4659 int v30; // edx@49
4660 //int v31; // ST10_4@49
4661 //signed int v32; // edx@49
4662 signed __int64 v33; // qtt@49
4663 //signed int v34; // eax@54
4664 //signed int v35; // esi@56
4665 //int result; // eax@57
4666 int v38; // edx@62
4667 //int v44; // [sp+20h] [bp-20h]@10
4668 bool v47; // [sp+24h] [bp-1Ch]@43
4669 bool v48; // [sp+28h] [bp-18h]@10
4670 bool v49; // [sp+28h] [bp-18h]@41
4671 bool v50; // [sp+2Ch] [bp-14h]@12
4672 signed int v53; // [sp+30h] [bp-10h]@10
4673 signed int v54; // [sp+30h] [bp-10h]@41
4674 signed int v55; // [sp+34h] [bp-Ch]@1
4675
4676 //LOG_DECOMPILATION_WARNING();
4677
4678 static int blv_floor_id[50]; // 00721200
4679 static int blv_floor_level[50]; // 007212C8
4680
4681 static __int16 word_721390_ys[104]; // idb
4682 static __int16 word_721460_xs[104]; // idb
4683
4684 auto pSector = &pIndoor->pSectors[uSectorID];
4685 v55 = 0;
4686 for (uint i = 0; i < pSector->uNumFloors; ++i)
4687 {
4688 auto pFloor = &pIndoor->pFaces[pSector->pFloors[i]];
4689 if (pFloor->Clickable())
4690 continue;
4691
4692 assert(pFloor->uNumVertices);
4693 if (x <= pFloor->pBounding.x2 && x >= pFloor->pBounding.x1 &&
4694 y <= pFloor->pBounding.y2 && y >= pFloor->pBounding.y1)
4695 {
4696 for (uint j = 0; j < pFloor->uNumVertices; ++j)
4697 {
4698 word_721460_xs[2 * j] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].x;
4699 word_721460_xs[2 * j + 1] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].x;
4700 word_721390_ys[2 * j] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].y;
4701 word_721390_ys[2 * j + 1] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].y;
4702 }
4703 word_721460_xs[2 * pFloor->uNumVertices] = word_721460_xs[0];
4704 word_721390_ys[2 * pFloor->uNumVertices] = word_721390_ys[0];
4705
4706 v50 = word_721390_ys[0] >= y;
4707 v53 = 0;
4708
4709 for (uint j = 0; j < 2 * pFloor->uNumVertices; ++j)
4710 {
4711 if (v53 >= 2)
4712 break;
4713
4714 v48 = v50;
4715 v50 = word_721390_ys[j + 1] >= y;
4716
4717 v13 = i;
4718 if (v48 == v50)
4719 continue;
4720
4721 v14 = word_721460_xs[j + 1] >= x ? 0 : 2;
4722 v15 = v14 | (word_721460_xs[j] < x);
4723
4724 if (v15 == 3)
4725 continue;
4726 else if (!v15)
4727 ++v53;
4728 else
4729 {
4730 auto a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]);
4731 auto res = fixpoint_sub0((signed int)word_721460_xs[j + 1] - (signed int)word_721460_xs[j], a_div_b);
4732
4733 if (res + word_721460_xs[j] >= x)
4734 ++v53;
4735 }
4736 }
4737
4738
4739 if ( v53 == 1 )
4740 {
4741 if ( v55 >= 50 )
4742 break;
4743 if ( pFloor->uPolygonType == POLYGON_Floor || pFloor->uPolygonType == POLYGON_Ceiling )
4744 {
4745 v21 = pIndoor->pVertices[pFloor->pVertexIDs[0]].z;
4746 }
4747 else
4748 {
4749 v21 = fixpoint_sub0(pFloor->zCalc1, x) + fixpoint_sub0(pFloor->zCalc2, y) + (short)(pFloor->zCalc3 >> 16);
4750 }
4751 blv_floor_level[v55] = v21;
4752 blv_floor_id[v55] = pSector->pFloors[i];
4753 v55++;
4754 }
4755 }
4756 }
4757
4758
4759 if ( pSector->field_0 & 8 )
4760 {
4761 for (uint i = 0; i < pSector->uNumPortals; ++i)
4762 {
4763 auto portal = &pIndoor->pFaces[pSector->pPortals[i]];
4764 if (portal->uPolygonType != POLYGON_Floor)
4765 continue;
4766
4767 if (!portal->uNumVertices)
4768 continue;
4769
4770 if (x <= portal->pBounding.x2 && x >= portal->pBounding.x1 &&
4771 y <= portal->pBounding.y2 && y >= portal->pBounding.y1 )
4772 {
4773 for (uint j = 0; j < portal->uNumVertices; ++j)
4774 {
4775 word_721460_xs[2 * j] = portal->pXInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].x;
4776 word_721460_xs[2 * j + 1] = portal->pXInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].x;
4777 word_721390_ys[2 * j] = portal->pYInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].y;
4778 word_721390_ys[2 * j + 1] = portal->pYInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].y;
4779 }
4780 word_721460_xs[2 * portal->uNumVertices] = word_721460_xs[0];
4781 word_721390_ys[2 * portal->uNumVertices] = word_721390_ys[0];
4782 v54 = 0;
4783 v47 = word_721390_ys[0] >= y;
4784
4785 for (uint j = 0; j < 2 * portal->uNumVertices; ++j)
4786 {
4787 v49 = v47;
4788 if ( v54 >= 2 )
4789 break;
4790 v47 = word_721390_ys[j + 1] >= y;
4791 if ( v49 != v47 )
4792 {
4793 v28 = word_721460_xs[j + 1] >= x ? 0 : 2;
4794 v29 = v28 | (word_721460_xs[j] < x);
4795 if ( v29 != 3 )
4796 {
4797 if ( !v29 )
4798 ++v54;
4799 else
4800 {
4801 auto a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]);
4802 auto res = fixpoint_sub0(word_721460_xs[j + 1] - word_721460_xs[j], a_div_b);
4803 if (res + word_721460_xs[j] >= x)
4804 ++v54;
4805 }
4806 }
4807 }
4808 }
4809 if ( v54 == 1 )
4810 {
4811 if ( v55 >= 50 )
4812 break;
4813 blv_floor_level[v55] = -29000;
4814 blv_floor_id[v55] = pSector->pPortals[i];
4815 v55++;
4816 }
4817 }
4818 }
4819 }
4820 if ( v55 == 1 )
4821 {
4822 *pFaceID = blv_floor_id[0];
4823 return blv_floor_level[0];
4824 }
4825 if ( !v55 )
4826 return -30000;
4827 *pFaceID = blv_floor_id[0];
4828 //result = blv_floor_level[0];
4829
4830 /*for ( v35 = 1; v35 < v55; ++v35 )
4831 {
4832 if ( blv_floor_level[0] <= z + 5 )
4833 {
4834 if ( blv_floor_level[v35] >= blv_floor_level[0] || blv_floor_level[v35] > z + 5 )
4835 continue;
4836 blv_floor_level[0] = blv_floor_level[v35];
4837 *pFaceID = blv_floor_id[v35];
4838 continue;
4839 }
4840 if ( blv_floor_level[v35] < blv_floor_level[0] )
4841 {
4842 blv_floor_level[0] = blv_floor_level[v35];
4843 *pFaceID = blv_floor_id[v35];
4844 }
4845 }*/
4846
4847
4848 int result = blv_floor_level[0];
4849 for (uint i = 1; i < v55; ++i)
4850 {
4851 v38 = blv_floor_level[i];
4852 if ( result <= z + 5 )
4853 {
4854 if ( v38 > result && v38 <= z + 5 )
4855 {
4856 result = blv_floor_level[i];
4857 *pFaceID = blv_floor_id[i];
4858 }
4859 }
4860 else if ( v38 < result )
4861 {
4862 result = blv_floor_level[i];
4863 *pFaceID = blv_floor_id[i];
4864 }
4865 }
4866
4867 return result;
4868 }
4869 //----- (004016FA) --------------------------------------------------------
4870 int __cdecl MakeActorAIList_BLV()
4871 {
4872 Actor *v0; // esi@2
4873 int v1; // eax@4
4874 int v2; // ebx@4
4875 unsigned int v3; // ecx@4
4876 int v4; // edx@5
4877 int v5; // edx@7
4878 unsigned int v6; // edx@9
4879 unsigned int v7; // ST24_4@10
4880 int v8; // eax@10
4881 int v9; // edi@10
4882 int v10; // ebx@14
4883 char v11; // zf@16
4884 int v12; // eax@22
4885 int v13; // edx@24
4886 int v14; // ecx@25
4887 int v15; // ebx@26
4888 unsigned int *v16; // ecx@27
4889 unsigned int v17; // esi@27
4890 int v18; // ecx@31
4891 signed int v19; // edi@31
4892 Actor *v20; // esi@32
4893 bool v21; // eax@33
4894 int v22; // eax@34
4895 signed int v23; // ebx@36
4896 Actor *v24; // esi@37
4897 signed int v25; // eax@40
4898 int v26; // eax@43
4899 int v27; // ebx@45
4900 int j; // edi@45
4901 unsigned int v29; // eax@46
4902 int v30; // eax@48
4903 int v31; // ecx@51
4904 int v32; // eax@51
4905 signed int v33; // eax@53
4906 __int64 v34; // qax@55
4907 char *v35; // ecx@56
4908 int v37; // [sp+Ch] [bp-18h]@1
4909 int v38; // [sp+10h] [bp-14h]@4
4910 int v39; // [sp+14h] [bp-10h]@4
4911 int v40; // [sp+18h] [bp-Ch]@10
4912 int v41; // [sp+18h] [bp-Ch]@29
4913 int i; // [sp+18h] [bp-Ch]@31
4914 signed int v43; // [sp+1Ch] [bp-8h]@1
4915 signed int v44; // [sp+1Ch] [bp-8h]@25
4916 int v45; // [sp+20h] [bp-4h]@1
4917
4918 // __debugbreak(); // refactor for blv ai
4919 pParty->uFlags &= 0xFFFFFFCFu;
4920 v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
4921 v45 = 0;
4922 v43 = 0;
4923 if ( (signed int)uNumActors > 0 )
4924 {
4925 v0 = pActors.data();//[0].uAttributes;
4926 do
4927 {
4928 BYTE1(v0->uAttributes) &= 0xFBu;
4929 if ( ! v0->CanAct() )
4930 goto LABEL_60;
4931 v39 = abs(pParty->vPosition.z - v0->vPosition.z);
4932 v38 = abs(pParty->vPosition.y - v0->vPosition.y);
4933 v1 = abs(pParty->vPosition.x - v0->vPosition.x);
4934 v2 = v38;
4935 v3 = v39;
4936 if ( v1 < v38 )
4937 {
4938 v4 = v1;
4939 v1 = v38;
4940 v2 = v4;
4941 }
4942 if ( v1 < v39 )
4943 {
4944 v5 = v1;
4945 v1 = v39;
4946 v3 = v5;
4947 }
4948 if ( v2 < (signed int)v3 )
4949 {
4950 v6 = v3;
4951 v3 = v2;
4952 v2 = v6;
4953 }
4954 v7 = ((unsigned int)(11 * v2) >> 5) + (v3 >> 2) + v1;
4955 v8 = v0->uActorRadius;
4956 v9 = v7 - v8;
4957 v40 = v7 - v8;
4958 if ( v40 < 0 )
4959 {
4960 v9 = 0;
4961 v40 = 0;
4962 }
4963 if ( v9 < 10240 )
4964 {
4965 v10 = v0->uAttributes & 0xFEFFFFFF;
4966 v0->uAttributes = v10;
4967 if ( v10 & 0x80000 || v0->GetActorsRelation(0) )
4968 {
4969 v11 = (pParty->uFlags & 0x10) == 0;
4970 v0->uAttributes = v10 | 0x1000000;
4971 if ( v11 && (double)v40 < 307.2 )
4972 pParty->uFlags |= 0x10u;
4973 if ( !(pParty->uFlags & 0x20) && v9 < 5120 )
4974 pParty->uFlags |= 0x20u;
4975 }
4976 v12 = v45++;
4977 ai_near_actors_distances[v12] = v9;
4978 ai_near_actors_ids[v12] = v43;
4979 }
4980 else
4981 {
4982 LABEL_60:
4983 BYTE1(v0->uAttributes) &= 0xBFu;
4984 }
4985 ++v43;
4986 ++v0;
4987 }
4988 while ( v43 < (signed int)uNumActors );
4989 }
4990 v13 = 0;
4991 if ( v45 > 0 )
4992 {
4993 v14 = 1;
4994 v44 = 1;
4995 do
4996 {
4997 while ( 1 )
4998 {
4999 v41 = v14;
5000 if ( v14 >= v45 )
5001 break;
5002 v15 = ai_near_actors_distances[v13];
5003 if ( v15 > ai_near_actors_distances[v14] )
5004 {
5005 v16 = &ai_near_actors_ids[v14];
5006 v17 = ai_near_actors_ids[v13];
5007 ai_near_actors_ids[v13] = *v16;
5008 *v16 = v17;
5009 v14 = v41;
5010 ai_near_actors_distances[v13] = ai_near_actors_distances[v41];
5011 ai_near_actors_distances[v41] = v15;
5012 }
5013 ++v14;
5014 }
5015 ++v13;
5016 v14 = v44 + 1;
5017 v44 = v14;
5018 }
5019 while ( v14 - 1 < v45 );
5020 }
5021 v18 = 0;
5022 v19 = 0;
5023 for ( i = 0; v18 < v45; i = v18 )
5024 {
5025 v20 = &pActors[ai_near_actors_ids[v18]];
5026 if ( v20->uAttributes & 0x8000
5027 || (v21 = sub_4070EF_prolly_collide_objects(PID(OBJECT_Actor,ai_near_actors_ids[v18]), 4u), v18 = i, v21) )
5028 {
5029 v22 = ai_near_actors_ids[v18];
5030 v20->uAttributes |= 0x8000u;
5031 ai_array_4F6638_actor_ids[v19] = v22;
5032 ai_array_4F5E68[v19++] = ai_near_actors_distances[v18];
5033 if ( v19 >= 30 )
5034 break;
5035 }
5036 ++v18;
5037 }
5038 v23 = 0;
5039 ai_arrays_size = v19;
5040 if ( (signed int)uNumActors > 0 )
5041 {
5042 v24 = pActors.data();//[0].uAttributes;
5043 do
5044 {
5045 if ( v24->CanAct() && v24->uSectorID == v37 )
5046 {
5047 v25 = 0;
5048 if ( v19 <= 0 )
5049 {
5050 LABEL_43:
5051 v26 = ai_arrays_size;
5052 BYTE1(v24->uAttributes) |= 0x40u;
5053 ++ai_arrays_size;
5054 ai_array_4F6638_actor_ids[v26] = v23;
5055 }
5056 else
5057 {
5058 while ( ai_array_4F6638_actor_ids[v25] != v23 )
5059 {
5060 ++v25;
5061 if ( v25 >= v19 )
5062 goto LABEL_43;
5063 }
5064 }
5065 }
5066 ++v23;
5067 ++v24;
5068 }
5069 while ( v23 < (signed int)uNumActors );
5070 }
5071 v27 = ai_arrays_size;
5072 for ( j = 0; j < v45; ++j )
5073 {
5074 v29 = ai_near_actors_ids[j];
5075 if ( pActors[v29].uAttributes & 0xC000 && pActors[v29].CanAct() )
5076 {
5077 v30 = 0;
5078 if ( v27 <= 0 )
5079 {
5080 LABEL_51:
5081 v31 = ai_arrays_size;
5082 v32 = ai_near_actors_ids[j];
5083 ++ai_arrays_size;
5084 ai_array_4F6638_actor_ids[v31] = v32;
5085 }
5086 else
5087 {
5088 while ( ai_array_4F6638_actor_ids[v30] != ai_near_actors_ids[j] )
5089 {
5090 ++v30;
5091 if ( v30 >= v27 )
5092 goto LABEL_51;
5093 }
5094 }
5095 }
5096 }
5097 v33 = ai_arrays_size;
5098 if ( ai_arrays_size > 30 )
5099 {
5100 v33 = 30;
5101 ai_arrays_size = 30;
5102 }
5103 memcpy(ai_near_actors_ids.data(), ai_array_4F6638_actor_ids.data(), 4 * v33);
5104 memcpy(ai_near_actors_distances.data(), ai_array_4F5E68.data(), 4 * ai_arrays_size);
5105 v34 = (unsigned int)ai_arrays_size;
5106 if ( ai_arrays_size > 0 )
5107 {
5108 do
5109 {
5110 v35 = (char *)&pActors[ai_near_actors_ids[HIDWORD(v34)]].uAttributes;
5111 v35[1] |= 4u;
5112 ++HIDWORD(v34);
5113 }
5114 while ( SHIDWORD(v34) < (signed int)v34 );
5115 }
5116 return v34;
5117 }
5118 //----- (0043FDED) --------------------------------------------------------
5119 void PrepareActorRenderList_BLV()
5120 {
5121 RenderBillboard *v0; // esi@0
5122 unsigned __int16 v3; // ax@3
5123 unsigned int v4; // eax@5
5124 unsigned __int16 v5; // cx@5
5125 int v6; // esi@5
5126 unsigned int v7; // eax@7
5127 int v8; // eax@10
5128 SpriteFrame *v9; // eax@16
5129 SpriteFrame *v10; // ebx@18
5130 //int *v11; // eax@18
5131 int v12; // ecx@28
5132 //IndoorCameraD3D **v14; // eax@36
5133 double v15; // st7@36
5134 float v16; // eax@36
5135 //double v17; // ST30_8@36
5136 signed __int64 v18; // qtt@36
5137 int v19; // ST5C_4@36
5138 signed __int64 v20; // qtt@37
5139 int v21; // ST5C_4@37
5140 signed __int16 v22; // cx@39
5141 int v23; // ST50_4@40
5142 signed int v24; // ecx@40
5143 int v25; // edx@44
5144 __int16 v26; // ax@44
5145 //MonsterDesc *v27; // edx@44
5146 //int v28; // ecx@44
5147 unsigned __int8 v29; // zf@44
5148 unsigned __int8 v30; // sf@44
5149 unsigned int v31; // [sp-8h] [bp-5Ch]@15
5150 int v32; // [sp+1Ch] [bp-38h]@5
5151 int a3; // [sp+20h] [bp-34h]@5
5152 int a2; // [sp+24h] [bp-30h]@5
5153 int a1a; // [sp+28h] [bp-2Ch]@5
5154 __int16 a5; // [sp+2Ch] [bp-28h]@5
5155 int a5a; // [sp+2Ch] [bp-28h]@36
5156 int a5b; // [sp+2Ch] [bp-28h]@40
5157 __int16 v41; // [sp+3Ch] [bp-18h]@18
5158 int a6; // [sp+40h] [bp-14h]@34
5159 int v43; // [sp+44h] [bp-10h]@34
5160 int z; // [sp+48h] [bp-Ch]@32
5161 signed int y; // [sp+4Ch] [bp-8h]@32
5162 int x; // [sp+50h] [bp-4h]@32
5163
5164 for (uint i = 0; i < uNumActors; ++i)
5165 {
5166 auto p = &pActors[i];
5167
5168 if (p->uAIState == Removed ||
5169 p->uAIState == Disabled)
5170 continue;
5171
5172 a5 = p->uSectorID;
5173 a2 = p->vPosition.y;
5174 a1a = p->vPosition.x;
5175 a3 = p->vPosition.z;
5176 v4 = stru_5C6E00->Atan2(a1a - pBLVRenderParams->vPartyPos.x, a2 - pBLVRenderParams->vPartyPos.y);
5177 LOWORD(v0) = p->uYawAngle;
5178 v5 = p->uCurrentActionAnimation;
5179 v6 = ((signed int)((char *)v0 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v4 + stru_5C6E00->uIntegerPi) >> 8) & 7;
5180 v32 = v6;
5181 if ( pParty->bTurnBasedModeOn )
5182 {
5183 if ( v5 == 1 )
5184 {
5185 v7 = pMiscTimer->uTotalGameTimeElapsed;
5186 goto LABEL_10;
5187 }
5188 }
5189 else
5190 {
5191 if ( v5 == 1 )
5192 {
5193 v7 = pBLVRenderParams->field_0_timer_;
5194 LABEL_10:
5195 v8 = i * 32 + v7;
5196 goto LABEL_12;
5197 }
5198 }
5199 v8 = p->uCurrentActionTime;
5200 LABEL_12:
5201 if (p->pActorBuffs[5].uExpireTime > 0i64 || p->pActorBuffs[6].uExpireTime > 0i64 )
5202 v8 = 0;
5203 v31 = p->pSpriteIDs[v5];
5204 if (p->uAIState == Resurrected)
5205 v9 = pSpriteFrameTable->GetFrameBy_x(v31, v8);
5206 else
5207 v9 = pSpriteFrameTable->GetFrame(v31, v8);
5208 v41 = 0;
5209 v10 = v9;
5210 //v11 = (int *)v9->uFlags;
5211 if (v9->uFlags & 2)
5212 v41 = 2;
5213 if (v9->uFlags & 0x40000)
5214 v41 |= 0x40u;
5215 if (v9->uFlags & 0x20000)
5216 LOBYTE(v41) = v41 | 0x80;
5217 v0 = (RenderBillboard *)(256 << v6);
5218 if ( (unsigned int)v0 & v9->uFlags)
5219 v41 |= 4u;
5220 if ( v10->uGlowRadius )
5221 {
5222 //LOBYTE(v11) = byte_4E94D3;
5223 pMobileLightsStack->AddLight(
5224 a1a,
5225 a2,
5226 a3,
5227 a5,
5228 v10->uGlowRadius,
5229 0xFFu,
5230 0xFFu,
5231 0xFFu,
5232 byte_4E94D3);
5233 }
5234 v12 = 0;
5235 if ( pBspRenderer->uNumVisibleNotEmptySectors <= 0 )
5236 continue;
5237 while (pBspRenderer->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v12] != p->uSectorID)
5238 {
5239 ++v12;
5240 if ( v12 >= pBspRenderer->uNumVisibleNotEmptySectors )
5241 goto _continue;
5242 }
5243 if ( !pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(a1a, a2, a3, &x, &y, &z, 1)
5244 || (v0 = (RenderBillboard *)abs(x), (signed int)v0 < abs(y)) )
5245 continue;
5246 pGame->pIndoorCameraD3D->Project(x, y, z, &v43, &a6);
5247 v0 = &pBillboardRenderList[uNumBillboardsToDraw];
5248 if (uNumBillboardsToDraw >= 500)
5249 break;
5250 ++uNumBillboardsToDraw;
5251 ++uNumSpritesDrawnThisFrame;
5252 p->uAttributes |= 8u;
5253 v29 = pRenderer->pRenderD3D == 0;
5254 v0->uHwSpriteID = v10->pHwSpriteIDs[v32];
5255 v0->uPalette = v10->uPaletteIndex;
5256 v0->uIndoorSectorID = a5;
5257 if ( v29 )
5258 {
5259 LODWORD(v20) = pBLVRenderParams->field_40 << 16;
5260 HIDWORD(v20) = pBLVRenderParams->field_40 >> 16;
5261 v21 = v20 / x;
5262 v0->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v10->scale * v20 / x) >> 16;
5263 a5a = (unsigned __int64)(v10->scale * (signed __int64)v21) >> 16;
5264 }
5265 else
5266 {
5267 //v14 = &pGame->pIndoorCameraD3D;
5268 v0->fov_x = pGame->pIndoorCameraD3D->fov_x;
5269 v15 = pGame->pIndoorCameraD3D->fov_y;
5270 v16 = v0->fov_x;
5271 v0->fov_y = v15;
5272 //v17 = v16 + 6.7553994e15;
5273 LODWORD(v18) = 0;
5274 HIDWORD(v18) = floorf(v16 + 0.5f);
5275 v19 = v18 / x;
5276 v0->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v10->scale * v18 / x) >> 16;
5277 a5a = (unsigned __int64)(v10->scale * (signed __int64)v19) >> 16;
5278 }
5279 v0->_screenspace_y_scaler_packedfloat = a5a;
5280 if ( (signed __int64)p->pActorBuffs[3].uExpireTime <= 0 )
5281 {
5282 if ( (signed __int64)p->pActorBuffs[10].uExpireTime > 0 )
5283 {
5284 a5b = (unsigned __int64)(pGame->pStru6Instance->_4A806F(p) * (signed __int64)v0->_screenspace_y_scaler_packedfloat) >> 16;
5285 goto LABEL_43;
5286 }
5287 }
5288 else
5289 {
5290 v22 = p->pActorBuffs[3].uPower;
5291 if ( v22 )
5292 {
5293 v23 = (unsigned __int64)(65536 / (unsigned __int16)v22 * (signed __int64)v0->_screenspace_x_scaler_packedfloat) >> 16;
5294 v24 = p->pActorBuffs[3].uPower;
5295 v0->_screenspace_x_scaler_packedfloat = v23;
5296 a5b = (unsigned __int64)(65536 / v24 * (signed __int64)v0->_screenspace_y_scaler_packedfloat) >> 16;
5297 LABEL_43:
5298 v0->_screenspace_y_scaler_packedfloat = a5b;
5299 goto LABEL_44;
5300 }
5301 }
5302 LABEL_44:
5303 HIWORD(v25) = HIWORD(x);
5304 v0->world_x = a1a;
5305 v0->world_y = a2;
5306 v0->world_z = a3;
5307 v0->uScreenSpaceX = v43;
5308 v0->uScreenSpaceY = a6;
5309 LOWORD(v25) = 0;
5310 LOBYTE(v26) = v41;
5311
5312 //v0->sZValue = v25 + (PID(OBJECT_Actor,i));
5313 v0->actual_z = HIWORD(x);
5314 v0->object_pid = PID(OBJECT_Actor,i);
5315
5316 v29 = HIDWORD(p->pActorBuffs[5].uExpireTime) == 0;
5317 v30 = HIDWORD(p->pActorBuffs[5].uExpireTime) < 0;
5318 v0->field_1E = v41;
5319 v0->pSpriteFrame = v10;
5320 v0->uTintColor = pMonsterList->pMonsters[p->pMonsterInfo.uID - 1].uTintColor;
5321 if ( !v30 && (!(v30 | v29) || LODWORD(p->pActorBuffs[5].uExpireTime)) )
5322 {
5323 HIBYTE(v26) = HIBYTE(v41) | 1;
5324 v0->field_1E = v26;
5325 }
5326
5327 _continue:
5328 ;
5329 }
5330 }
5331 //----- (0044028F) --------------------------------------------------------
5332 void PrepareItemsRenderList_BLV()
5333 {
5334 ObjectDesc *v1; // ebx@4
5335 __int16 v2; // ax@5
5336 RenderBillboard *v3; // esi@12
5337 SpriteFrame *v4; // eax@12
5338 SpriteFrame *v5; // ebx@12
5339 unsigned int v6; // eax@12
5340 int v7; // ecx@12
5341 int v8; // edx@12
5342 int v9; // ecx@12
5343 unsigned __int16 v10; // ax@12
5344 int *v11; // eax@20
5345 //char v12; // zf@26
5346 __int64 v18; // ST5C_4@27
5347 signed __int64 v19; // qtt@28
5348 int v20; // ST5C_4@28
5349 //int v21; // edx@29
5350 __int16 v22; // ax@29
5351 //int v23; // eax@29
5352 SpriteFrame *v24; // [sp+1Ch] [bp-40h]@12
5353 //__int16 a5; // [sp+28h] [bp-34h]@12
5354 int a6; // [sp+2Ch] [bp-30h]@12
5355 int a2; // [sp+30h] [bp-2Ch]@12
5356 int a1; // [sp+34h] [bp-28h]@12
5357 int v30; // [sp+38h] [bp-24h]@12
5358 int v31; // [sp+38h] [bp-24h]@27
5359 int a3; // [sp+40h] [bp-1Ch]@12
5360 signed __int16 v34; // [sp+44h] [bp-18h]@14
5361 int v35; // [sp+48h] [bp-14h]@25
5362 int v36; // [sp+4Ch] [bp-10h]@25
5363 signed int z; // [sp+50h] [bp-Ch]@24
5364 signed int y; // [sp+54h] [bp-8h]@24
5365 signed int x; // [sp+58h] [bp-4h]@24
5366
5367 for (uint i = 0; i < uNumSpriteObjects; ++i)
5368 {
5369 auto p = &pSpriteObjects[i];
5370 if (p->uObjectDescID)
5371 {
5372 v1 = &pObjectList->pObjects[p->uObjectDescID];
5373 if ( !(v1->uFlags & 1) )
5374 {
5375 if ( ((v2 = p->uType, v2 < 1000) || v2 >= 10000)
5376 && (v2 < 500 || v2 >= 600)
5377 && (v2 < 811 || v2 >= 815)
5378 || pGame->pStru6Instance->_4A81CA(p))
5379 {
5380 //a5 = p->uSectorID;
5381 a1 = p->vPosition.x;
5382 a2 = p->vPosition.y;
5383 a3 = p->vPosition.z;
5384 v3 = &pBillboardRenderList[uNumBillboardsToDraw];
5385 v4 = pSpriteFrameTable->GetFrame(v1->uSpriteID, p->uSpriteFrameID);
5386 v5 = v4;
5387 v24 = v4;
5388 v30 = v4->uFlags;
5389 a6 = v4->uGlowRadius * p->field_22_glow_radius_multiplier;
5390 v6 = stru_5C6E00->Atan2(p->vPosition.x - pBLVRenderParams->vPartyPos.x,
5391 p->vPosition.y - pBLVRenderParams->vPartyPos.y);
5392 LOWORD(v7) = p->uFacing;
5393 v8 = v30;
5394 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v7 - v6) >> 8) & 7;
5395 v10 = v5->pHwSpriteIDs[v9];
5396 v3->uHwSpriteID = v10;
5397 if ( v30 & 0x20 )
5398 {
5399 v8 = v30;
5400 a3 -= (signed int)((unsigned __int64)(v5->scale * (signed __int64)pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) >> 16) >> 1;
5401 }
5402 v34 = 0;
5403 if ( v8 & 2 )
5404 v34 = 2;
5405 if ( v8 & 0x40000 )
5406 v34 |= 0x40u;
5407 if ( v8 & 0x20000 )
5408 LOBYTE(v34) = v34 | 0x80;
5409 v11 = (int *)(256 << v9);
5410 if ( (256 << v9) & v8 )
5411 v34 |= 4u;
5412 if ( a6 )
5413 {
5414 LOBYTE(v11) = byte_4E94D3;
5415 pMobileLightsStack->AddLight(
5416 a1,
5417 a2,
5418 a3,
5419 p->uSectorID,
5420 a6,
5421 v1->uParticleTrailColorR,
5422 v1->uParticleTrailColorG,
5423 v1->uParticleTrailColorB,
5424 byte_4E94D3);
5425 }
5426 if ( pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(
5427 a1,
5428 a2,
5429 a3,
5430 &x,
5431 &y,
5432 &z,
5433 1) )
5434 {
5435 pGame->pIndoorCameraD3D->Project(x, y, z, &v36, &v35);
5436
5437 assert(uNumBillboardsToDraw < 500);
5438 //if ( (signed int)uNumBillboardsToDraw >= 500 )
5439 // return;
5440 ++uNumBillboardsToDraw;
5441 ++uNumSpritesDrawnThisFrame;
5442 p->uAttributes |= 1u;
5443 //v12 = pRenderer->pRenderD3D == 0;
5444 v3->uPalette = v24->uPaletteIndex;
5445 v3->uIndoorSectorID = p->uSectorID;
5446 if ( pRenderer->pRenderD3D )
5447 {
5448 v3->fov_x = pGame->pIndoorCameraD3D->fov_x;
5449 v3->fov_y = pGame->pIndoorCameraD3D->fov_y;
5450 LODWORD(v18) = 0;
5451 HIDWORD(v18) = (int)floorf(v3->fov_x + 0.5f);
5452 v18 = v18 / x;
5453 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v24->scale * v18) >> 16;
5454 v31 = (unsigned __int64)(v24->scale * v18) >> 16;
5455 }
5456 else
5457 {
5458 LODWORD(v19) = pBLVRenderParams->field_40 << 16;
5459 HIDWORD(v19) = pBLVRenderParams->field_40 >> 16;
5460 v20 = v19 / x;
5461 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v24->scale * v19 / x) >> 16;
5462 v31 = (unsigned __int64)(v24->scale * (signed __int64)v20) >> 16;
5463 }
5464 //HIWORD(v21) = HIWORD(x);
5465 //LOWORD(v21) = 0;
5466 v3->_screenspace_y_scaler_packedfloat = v31;
5467 v3->field_1E = v34;
5468 v3->world_x = a1;
5469 v3->world_y = a2;
5470 v3->world_z = a3;
5471 v3->uScreenSpaceX = v36;
5472 v22 = v35;
5473 v3->uTintColor = 0;
5474 v3->uScreenSpaceY = v22;
5475 //v23 = 8 * i;
5476 //LOBYTE(v23) = PID(OBJECT_Item,i);
5477 v3->pSpriteFrame = v24;
5478 //v12 = (p->uAttributes & 0x20) == 0;
5479 //v3->sZValue = v21 + v23;
5480 v3->actual_z = HIWORD(x);
5481 v3->object_pid = PID(OBJECT_Item,i);
5482 if (p->uAttributes & 0x20)
5483 {
5484 if ( !pRenderer->pRenderD3D )
5485 v3->sZValue = 0;
5486 }
5487 }
5488 }
5489 }
5490 }
5491 }
5492 }
5493
5494 //----- (00440639) --------------------------------------------------------
5495 void AddBspNodeToRenderList(unsigned int node_id)
5496 {
5497 BLVSector *pSector; // esi@1
5498
5499 pSector = &pIndoor->pSectors[pBspRenderer->nodes[node_id].uSectorID];
5500 if ( pRenderer->pRenderD3D )
5501 {
5502 for (uint i = 0; i < pSector->uNumNonBSPFaces; ++i)
5503 //Log::Warning(L"Non-BSP face: %X", v3->pFaceIDs[v2]);
5504 pBspRenderer->AddFaceToRenderList_d3d(node_id, pSector->pFaceIDs[i]);
5505 }
5506 else
5507 {
5508 for (uint i = 0; i < pSector->uNumNonBSPFaces; ++i)
5509 pBspRenderer->AddFaceToRenderList_sw(node_id, pSector->pFaceIDs[i]);
5510 }
5511 if ( pSector->field_0 & 0x10 )
5512 sub_4406BC(node_id, pSector->uFirstBSPNode);
5513 }
5514
5515 //----- (004406BC) --------------------------------------------------------
5516 void __fastcall sub_4406BC(unsigned int node_id, unsigned int uFirstNode)
5517 {
5518 BLVSector *pSector; // esi@2
5519 BSPNode *pNode; // edi@2
5520 BLVFace *pFace; // eax@2
5521 int v5; // ecx@2
5522 __int16 v6; // ax@6
5523 int v7; // ebp@10
5524 int v8; // ebx@10
5525 __int16 v9; // di@18
5526 //int v10; // [sp+10h] [bp-Ch]@1
5527 //bool v11; // [sp+14h] [bp-8h]@5
5528 BspRenderer_stru0 *node; // [sp+18h] [bp-4h]@1
5529
5530 //Log::Warning(L"sub_4406BC(%u, %u)", a1, uFirstNode);
5531
5532 //v10 = a1;
5533 node = &pBspRenderer->nodes[node_id];
5534 while ( 1 )
5535 {
5536 pSector = &pIndoor->pSectors[node->uSectorID];
5537 pNode = &pIndoor->pNodes[uFirstNode];
5538 pFace = &pIndoor->pFaces[pSector->pFaceIDs[pNode->uCoplanarOffset]];
5539 v5 = pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x
5540 + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z;//plane equation
5541 if (pFace->Portal() && pFace->uSectorID != node->uSectorID )
5542 v5 = -v5;
5543 //v11 = v5 > 0;
5544 if ( v5 <= 0 )
5545 v6 = pNode->uFront;
5546 else
5547 v6 = pNode->uBack;
5548 if ( v6 != -1 )
5549 sub_4406BC(node_id, v6);
5550 v7 = pNode->uCoplanarOffset;
5551 v8 = v7 + pNode->uCoplanarSize;
5552
5553 //Log::Warning(L"Node %u: %X to %X (%hX)", uFirstNode, v7, v8, v2->pFaceIDs[v7]);
5554
5555 if ( pRenderer->pRenderD3D )
5556 {
5557 while ( v7 < v8 )
5558 pBspRenderer->AddFaceToRenderList_d3d(node_id, pSector->pFaceIDs[v7++]);
5559 }
5560 else
5561 {
5562 while ( v7 < v8 )
5563 pBspRenderer->AddFaceToRenderList_sw(node_id, pSector->pFaceIDs[v7++]);
5564 }
5565 v9 = v5 > 0 ? pNode->uFront : pNode->uBack;
5566 if ( v9 == -1 )
5567 break;
5568 uFirstNode = v9;
5569 }
5570 }
5571 //----- (0043FA33) --------------------------------------------------------
5572 void __fastcall PrepareDecorationsRenderList_BLV(unsigned int uDecorationID, unsigned int uSectorID)
5573 {
5574 LevelDecoration *v2; // esi@1
5575 DecorationDesc *v3; // ebx@2
5576 __int16 v4; // ax@2
5577 double v5; // st7@3
5578 int v6; // eax@5
5579 int v7; // edx@5
5580 unsigned int v8; // edi@5
5581 int v9; // edi@5
5582 int v10; // eax@7
5583 SpriteFrame *v11; // eax@7
5584 SpriteFrame *v12; // esi@7
5585 int v13; // eax@7
5586 int v14; // ebx@16
5587 RenderBillboard *v15; // ecx@17
5588 char v16; // zf@18
5589 IndoorCameraD3D **v17; // eax@19
5590 double v18; // st7@19
5591 //float v19; // eax@19
5592 signed __int64 v20; // qtt@19
5593 signed __int64 v21; // qtt@20
5594 //int v22; // edx@21
5595 //int v23; // eax@21
5596 Particle_sw local_0; // [sp+Ch] [bp-A0h]@3
5597 //double v25; // [sp+74h] [bp-38h]@19
5598 //unsigned int v26; // [sp+7Ch] [bp-30h]@1
5599 int a2; // [sp+80h] [bp-2Ch]@5
5600 int a3; // [sp+84h] [bp-28h]@5
5601 int a1; // [sp+88h] [bp-24h]@5
5602 int v30; // [sp+8Ch] [bp-20h]@7
5603 //float v31; // [sp+90h] [bp-1Ch]@1
5604 int a5; // [sp+94h] [bp-18h]@17
5605 int z; // [sp+98h] [bp-14h]@15
5606 int a6; // [sp+9Ch] [bp-10h]@17
5607 int y; // [sp+A0h] [bp-Ch]@15
5608 int x; // [sp+A4h] [bp-8h]@15
5609 int v37; // [sp+A8h] [bp-4h]@5
5610
5611 //v26 = uDecorationID;
5612 //LODWORD(v31) = uSectorID;
5613 v2 = &pLevelDecorations[uDecorationID];
5614 if (v2->field_2 & 0x20)
5615 return;
5616
5617 v3 = &pDecorationList->pDecorations[v2->uDecorationDescID];
5618 v4 = v3->uFlags;
5619 if (v3->uFlags & DECORATION_EMITS_FIRE)
5620 {
5621 memset(&local_0, 0, 0x68u); // fire, like at the Pit's tavern
5622 v5 = (double)v2->vPosition.x;
5623 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8;
5624 local_0.uDiffuse = 0xFF3C1E;
5625 local_0.x = v5;
5626 local_0.y = (double)v2->vPosition.y;
5627 local_0.z = (double)v2->vPosition.z;
5628 local_0.flt_10 = 0.0;
5629 local_0.flt_14 = 0.0;
5630 local_0.flt_18 = 0.0;
5631 local_0.flt_28 = 1.0;
5632 local_0.timeToLive = (rand() & 0x80) + 128;
5633 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01");
5634 pGame->pParticleEngine->AddParticle(&local_0);
5635 return;
5636 }
5637
5638
5639 if (v4 & DECORATION_DONT_DRAW)
5640 return;
5641
5642 v6 = v2->vPosition.x;
5643 v7 = v2->vPosition.z;
5644 a2 = v2->vPosition.y;
5645 a1 = v6;
5646 a3 = v7;
5647 v8 = v2->field_10_y_rot
5648 + ((signed int)stru_5C6E00->uIntegerPi >> 3)
5649 - stru_5C6E00->Atan2(v6 - pBLVRenderParams->vPartyPos.x, a2 - pBLVRenderParams->vPartyPos.y);
5650 v37 = pBLVRenderParams->field_0_timer_;
5651 v9 = ((signed int)(stru_5C6E00->uIntegerPi + v8) >> 8) & 7;
5652 if (pParty->bTurnBasedModeOn)
5653 v37 = pMiscTimer->uTotalGameTimeElapsed;
5654 v10 = abs(v2->vPosition.x + v2->vPosition.y);
5655 v11 = pSpriteFrameTable->GetFrame(v3->uSpriteID, v37 + v10);
5656 v30 = 0;
5657 v12 = v11;
5658 v13 = v11->uFlags;
5659 if ( v13 & 2 )
5660 v30 = 2;
5661 if ( v13 & 0x40000 )
5662 v30 |= 0x40u;
5663 if ( v13 & 0x20000 )
5664 LOBYTE(v30) = v30 | 0x80;
5665 if ( (256 << v9) & v13 )
5666 v30 |= 4u;
5667 if ( pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(a1, a2, a3, &x, &y, &z, 1) )
5668 {
5669 v14 = abs(x);
5670 if ( v14 >= abs(y) )
5671 {
5672 pGame->pIndoorCameraD3D->Project(x, y, z, &a5, &a6);
5673
5674 v15 = &pBillboardRenderList[uNumBillboardsToDraw];
5675 assert(uNumBillboardsToDraw < 500);
5676
5677 ++uNumBillboardsToDraw;
5678 ++uNumDecorationsDrawnThisFrame;
5679 v16 = pRenderer->pRenderD3D == 0;
5680 v15->uHwSpriteID = v12->pHwSpriteIDs[v9];
5681 v15->uPalette = v12->uPaletteIndex;
5682 v15->uIndoorSectorID = uSectorID;
5683 if ( v16 )
5684 {
5685 LODWORD(v21) = pBLVRenderParams->field_40 << 16;
5686 HIDWORD(v21) = pBLVRenderParams->field_40 >> 16;
5687 v37 = v21 / x;
5688 //LODWORD(v31) = v12->scale;
5689 v37 = v21 / x;
5690 v15->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v12->scale * v21 / x) >> 16;
5691 v37 = (unsigned __int64)(v12->scale * (signed __int64)v37) >> 16;
5692 }
5693 else
5694 {
5695 v17 = &pGame->pIndoorCameraD3D;
5696 v15->fov_x = pGame->pIndoorCameraD3D->fov_x;
5697 v18 = (*v17)->fov_y;
5698 //v19 = v15->fov_x;
5699 v15->fov_y = v18;
5700 //v31 = v19;
5701 //v25 = v19 + 6.7553994e15;
5702 //v25 = floorf(v15->fov_x + 0.5f);
5703 LODWORD(v20) = 0;
5704 HIDWORD(v20) = floorf(v15->fov_x + 0.5f);
5705 v37 = v20 / x;
5706 //LODWORD(v31) = v12->scale;
5707 v37 = (unsigned __int64)(v12->scale * v20 / x) >> 16;
5708 v15->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v12->scale * v20 / x) >> 16;
5709 //v31 = v15->fov_y;
5710 //v25 = v31 + 6.7553994e15;
5711 //v25 = floorf(v15->fov_y + 0.5f);
5712 LODWORD(v20) = 0;
5713 HIDWORD(v20) = floorf(v15->fov_y + 0.5f);
5714 v37 = v20 / x;
5715 v37 = (unsigned __int64)(v12->scale * v20 / x) >> 16;
5716 }
5717 //HIWORD(v22) = HIWORD(x);
5718 //LOWORD(v22) = 0;
5719 v15->_screenspace_y_scaler_packedfloat = v37;
5720 v15->field_1E = v30;
5721 v15->world_x = a1;
5722 v15->world_y = a2;
5723 v15->world_z = a3;
5724 v15->uScreenSpaceX = a5;
5725 v15->uScreenSpaceY = a6;
5726 //v23 = 8 * uDecorationID;
5727 //LOBYTE(v23) = PID(OBJECT_Decoration,uDecorationID);
5728
5729 //v15->sZValue = v22 + v23;
5730 v15->actual_z = HIWORD(x);
5731 v15->object_pid = PID(OBJECT_Decoration,uDecorationID);
5732
5733 v15->uTintColor = 0;
5734 v15->pSpriteFrame = v12;
5735 }
5736 }
5737 }
5738 //----- (0043F953) --------------------------------------------------------
5739 void PrepareBspRenderList_BLV()
5740 {
5741 pBspRenderer->num_faces = 0;
5742
5743 if (pBLVRenderParams->uPartySectorID)
5744 {
5745 pBspRenderer->nodes[0].uSectorID = pBLVRenderParams->uPartySectorID;
5746 pBspRenderer->nodes[0].uViewportW = pBLVRenderParams->uViewportW;
5747 pBspRenderer->nodes[0].uViewportZ = pBLVRenderParams->uViewportZ;
5748 pBspRenderer->nodes[0].uViewportY = pBLVRenderParams->uViewportY;
5749 pBspRenderer->nodes[0].uViewportX = pBLVRenderParams->uViewportX;
5750 pBspRenderer->nodes[0].field_C.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY,
5751 pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW);
5752 pBspRenderer->nodes[0].uFaceID = -1;
5753 pBspRenderer->nodes[0].viewing_portal_id = -1;
5754 pBspRenderer->num_nodes = 1;
5755 AddBspNodeToRenderList(0);
5756 }
5757
5758 pBspRenderer->MakeVisibleSectorList();
5759 }
5760
5761 //----- (0043F9E1) --------------------------------------------------------
5762 void BspRenderer_stru2::GetViewportData(__int16 x, int y, __int16 z, int w)
5763 {
5764 _viewport_space_y = y;
5765 _viewport_space_w = w;
5766
5767 for (uint i = 0; i < 480; ++i)
5768 {
5769 if ( i < y || i > w )
5770 {
5771 viewport_left_side[i] = 640;
5772 viewport_right_side[i] = -1;
5773 }
5774 else
5775 {
5776 viewport_left_side[i] = x;
5777 viewport_right_side[i] = z;
5778 }
5779 }
5780 }
5781 //----- (0048653D) --------------------------------------------------------
5782 int stru149::_48653D(int a2, int a3, int a4, int a5, int a6, int a7)//portal frustum culling
5783 {
5784 stru149 *v7; // esi@1
5785 int v8; // edi@1
5786 int v9; // eax@1
5787 //int v10; // edx@1
5788 //int v11; // ecx@1
5789 int v12; // eax@1
5790 int v13; // ebx@2
5791 int v14; // ecx@2
5792 int v15; // eax@2
5793 int v16; // ST14_4@3
5794 int v17; // ST10_4@3
5795 int v18; // eax@5
5796 int v19; // ST10_4@6
5797 int v20; // eax@8
5798 int v21; // ST10_4@9
5799 int v22; // eax@10
5800 int v23; // ecx@10
5801 int v24; // eax@10
5802 int result; // eax@10
5803 //int v26; // [sp+14h] [bp-14h]@1
5804 int v27; // [sp+18h] [bp-10h]@1
5805 int v28; // [sp+1Ch] [bp-Ch]@1
5806 int v29; // [sp+24h] [bp-4h]@1
5807 int v30; // [sp+30h] [bp+8h]@10
5808 int v31; // [sp+3Ch] [bp+14h]@10
5809
5810 v7 = this;
5811 v8 = stru_5C6E00->Cos(pBLVRenderParams->sPartyRotY);
5812 v29 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotY);
5813 v28 = stru_5C6E00->Cos(pBLVRenderParams->sPartyRotX);
5814 v9 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotX);
5815 //v11 = -pBLVRenderParams->vPartyPos.y;
5816 //v26 = -pBLVRenderParams->vPartyPos.x;
5817 v27 = v9;
5818 v12 = -pBLVRenderParams->vPartyPos.z;
5819 if ( pBLVRenderParams->sPartyRotX )
5820 {
5821 v16 = v8 * -pBLVRenderParams->vPartyPos.x + v29 * -pBLVRenderParams->vPartyPos.y;
5822 v13 = v28;
5823 v17 = -65536 * pBLVRenderParams->vPartyPos.z;
5824 v7->field_0_party_dir_x = ((unsigned __int64)(v16 * (signed __int64)v28) >> 16)
5825 + ((unsigned __int64)(-65536 * pBLVRenderParams->vPartyPos.z * (signed __int64)v27) >> 16);
5826 v7->field_4_party_dir_y = v8 * -pBLVRenderParams->vPartyPos.y - v29 * -pBLVRenderParams->vPartyPos.x;
5827 v14 = v27;
5828 v15 = ((unsigned __int64)(v17 * (signed __int64)v28) >> 16) - ((unsigned __int64)(v16 * (signed __int64)v27) >> 16);
5829 }
5830 else
5831 {
5832 v7->field_0_party_dir_x = v8 * -pBLVRenderParams->vPartyPos.x + v29 * -pBLVRenderParams->vPartyPos.y;
5833 v13 = v28;
5834 v7->field_4_party_dir_y = v8 * -pBLVRenderParams->vPartyPos.y - v29 * -pBLVRenderParams->vPartyPos.x;
5835 v14 = v27;
5836 v15 = v12 << 16;
5837 }
5838 v7->field_8 = v15;
5839 if ( pBLVRenderParams->sPartyRotX )
5840 {
5841 v19 = ((unsigned __int64)(a2 * (signed __int64)v8) >> 16) + ((unsigned __int64)(a3 * (signed __int64)v29) >> 16);
5842 v7->field_C = ((unsigned __int64)(v19 * (signed __int64)v13) >> 16)
5843 + ((unsigned __int64)(a4 * (signed __int64)v14) >> 16);
5844 v7->field_10 = ((unsigned __int64)(a3 * (signed __int64)v8) >> 16)
5845 - ((unsigned __int64)(a2 * (signed __int64)v29) >> 16);
5846 v18 = ((unsigned __int64)(a4 * (signed __int64)v13) >> 16) - ((unsigned __int64)(v19 * (signed __int64)v14) >> 16);
5847 }
5848 else
5849 {
5850 v7->field_C = ((unsigned __int64)(a2 * (signed __int64)v8) >> 16)
5851 + ((unsigned __int64)(a3 * (signed __int64)v29) >> 16);
5852 v7->field_10 = ((unsigned __int64)(a3 * (signed __int64)v8) >> 16)
5853 - ((unsigned __int64)(a2 * (signed __int64)v29) >> 16);
5854 v18 = a4;
5855 }
5856 v7->field_14 = v18;
5857 if ( pBLVRenderParams->sPartyRotX )
5858 {
5859 v21 = ((unsigned __int64)(a5 * (signed __int64)v8) >> 16) + ((unsigned __int64)(a6 * (signed __int64)v29) >> 16);
5860 v7->field_18 = ((unsigned __int64)(v21 * (signed __int64)v13) >> 16)
5861 + ((unsigned __int64)(a7 * (signed __int64)v14) >> 16);
5862 v7->field_1C = ((unsigned __int64)(a6 * (signed __int64)v8) >> 16)
5863 - ((unsigned __int64)(a5 * (signed __int64)v29) >> 16);
5864 v20 = ((unsigned __int64)(a7 * (signed __int64)v13) >> 16) - ((unsigned __int64)(v21 * (signed __int64)v14) >> 16);
5865 }
5866 else
5867 {
5868 v7->field_18 = ((unsigned __int64)(a5 * (signed __int64)v8) >> 16)
5869 + ((unsigned __int64)(a6 * (signed __int64)v29) >> 16);
5870 v7->field_1C = ((unsigned __int64)(a6 * (signed __int64)v8) >> 16)
5871 - ((unsigned __int64)(a5 * (signed __int64)v29) >> 16);
5872 v20 = a7;
5873 }
5874 v7->field_18 = -v7->field_18;
5875 v7->field_1C = -v7->field_1C;
5876 v7->field_20 = v20;
5877 v22 = v7->field_C;
5878 v7->field_20 = -v7->field_20;
5879 v23 = ((unsigned __int64)(v22 * (signed __int64)v7->field_0_party_dir_x) >> 16)
5880 + ((unsigned __int64)(v7->field_10 * (signed __int64)v7->field_4_party_dir_y) >> 16)
5881 + ((unsigned __int64)(v7->field_14 * (signed __int64)v7->field_8) >> 16);
5882 v30 = v7->field_18;
5883 v24 = v7->field_0_party_dir_x;
5884 v7->field_24 = v23;
5885 v31 = (unsigned __int64)(v30 * (signed __int64)v24) >> 16;
5886 result = (unsigned __int64)(v7->field_1C * (signed __int64)v7->field_4_party_dir_y) >> 16;
5887 v7->field_28 = v31 + result + ((unsigned __int64)(v7->field_20 * (signed __int64)v7->field_8) >> 16);
5888 return result;
5889 }
5890 //----- (00407A1C) --------------------------------------------------------
5891 bool __fastcall sub_407A1C(int x, int z, int y, Vec3_int_ v)
5892 {
5893 unsigned int v4; // esi@1
5894 Vec3_int_ v5; // ST08_12@2
5895 int v6; // edi@2
5896 int v7; // ebx@2
5897 int v8; // esi@2
5898 signed int v9; // ecx@2
5899 int v10; // eax@2
5900 int v11; // ecx@4
5901 int v12; // eax@4
5902 int v13; // ebx@4
5903 int v14; // edx@6
5904 char *v15; // edi@16
5905 ODMFace *v16; // esi@19
5906 int v17; // ST34_4@25
5907 int v18; // ST38_4@25
5908 int v19; // eax@25
5909 char v20; // zf@25
5910 int v21; // ebx@25
5911 int v22; // eax@26
5912 signed int v23; // edi@26
5913 int v24; // ST34_4@30
5914 signed __int64 v25; // qtt@31
5915 int v26; // eax@31
5916 Vec3_int_ v27; // ST08_12@37
5917 Vec3_int_ v28; // ST08_12@37
5918 int v29; // edi@37
5919 int v30; // ebx@37
5920 int v31; // esi@37
5921 signed int v32; // ecx@37
5922 int v33; // eax@37
5923 int v34; // ecx@39
5924 int v35; // eax@39
5925 int v36; // ebx@39
5926 int v37; // edx@41
5927 char *v38; // edi@51
5928 ODMFace *v39; // esi@54
5929 int v40; // ebx@60
5930 int v41; // eax@61
5931 signed int v42; // edi@61
5932 signed __int64 v43; // qtt@66
5933 int v44; // eax@66
5934 Vec3_int_ v45; // ST08_12@73
5935 int v46; // edi@73
5936 int v47; // ebx@73
5937 int v48; // esi@73
5938 signed int v49; // ecx@73
5939 int v50; // eax@73
5940 int v51; // edx@75
5941 int v52; // ecx@75
5942 int v53; // eax@75
5943 int v54; // ebx@75
5944 int v55; // edi@77
5945 int v56; // ecx@77
5946 int v57; // eax@81
5947 int v58; // esi@81
5948 int v59; // eax@90
5949 BLVSector *v60; // edx@90
5950 int v61; // ecx@90
5951 BLVFace *v62; // esi@91
5952 int v63; // ST34_4@98
5953 int v64; // ST30_4@98
5954 int v65; // eax@98
5955 int v66; // ebx@98
5956 int v67; // eax@99
5957 signed int v68; // edi@99
5958 int v69; // ST2C_4@103
5959 signed __int64 v70; // qtt@104
5960 int v71; // eax@104
5961 Vec3_int_ v72; // ST08_12@111
5962 Vec3_int_ v73; // ST08_12@111
5963 int v74; // edi@111
5964 int v75; // ebx@111
5965 int v76; // esi@111
5966 signed int v77; // ecx@111
5967 int v78; // eax@111
5968 int v79; // edx@113
5969 int v80; // ecx@113
5970 int v81; // eax@113
5971 int v82; // ebx@113
5972 int v83; // edi@115
5973 int v84; // ecx@115
5974 int v85; // eax@119
5975 int v86; // esi@119
5976 int v87; // ecx@128
5977 BLVSector *v88; // eax@128
5978 int v89; // ecx@128
5979 BLVFace *v90; // esi@129
5980 int v91; // ebx@136
5981 int v92; // eax@137
5982 signed int v93; // edi@137
5983 signed __int64 v94; // qtt@142
5984 int v95; // eax@142
5985 Vec3_int_ v97; // [sp-18h] [bp-94h]@1
5986 int v98; // [sp-Ch] [bp-88h]@88
5987 int v99; // [sp-Ch] [bp-88h]@126
5988 int v100; // [sp-8h] [bp-84h]@88
5989 int v101; // [sp-8h] [bp-84h]@126
5990 int v102; // [sp-4h] [bp-80h]@88
5991 int v103; // [sp-4h] [bp-80h]@126
5992 int v104; // [sp+Ch] [bp-70h]@13
5993 int v105; // [sp+Ch] [bp-70h]@48
5994 int v106; // [sp+10h] [bp-6Ch]@18
5995 int v107; // [sp+10h] [bp-6Ch]@98
5996 int v108; // [sp+10h] [bp-6Ch]@104
5997 int v109; // [sp+18h] [bp-64h]@25
5998 int v110; // [sp+18h] [bp-64h]@31
5999 int i; // [sp+18h] [bp-64h]@90
6000 int v112; // [sp+18h] [bp-64h]@128
6001 signed int v113; // [sp+20h] [bp-5Ch]@1
6002 signed int v114; // [sp+24h] [bp-58h]@1
6003 unsigned __int64 a4; // [sp+28h] [bp-54h]@1
6004 unsigned int a4_8; // [sp+30h] [bp-4Ch]@1
6005 int v117; // [sp+34h] [bp-48h]@4
6006 int v118; // [sp+34h] [bp-48h]@39
6007 int v119; // [sp+34h] [bp-48h]@75
6008 int v120; // [sp+34h] [bp-48h]@113
6009 int v121; // [sp+38h] [bp-44h]@4
6010 int v122; // [sp+38h] [bp-44h]@39
6011 int v123; // [sp+38h] [bp-44h]@76
6012 int v124; // [sp+38h] [bp-44h]@114
6013 int v125; // [sp+3Ch] [bp-40h]@4
6014 int v126; // [sp+3Ch] [bp-40h]@39
6015 int v127; // [sp+3Ch] [bp-40h]@77
6016 int v128; // [sp+3Ch] [bp-40h]@115
6017 int v129; // [sp+40h] [bp-3Ch]@11
6018 int v130; // [sp+40h] [bp-3Ch]@46
6019 int v131; // [sp+40h] [bp-3Ch]@78
6020 int v132; // [sp+40h] [bp-3Ch]@116
6021 int v133; // [sp+44h] [bp-38h]@10
6022 int v134; // [sp+44h] [bp-38h]@45
6023 int v135; // [sp+44h] [bp-38h]@81
6024 int v136; // [sp+44h] [bp-38h]@119
6025 int v137; // [sp+48h] [bp-34h]@7
6026 int v138; // [sp+48h] [bp-34h]@42
6027 int v139; // [sp+48h] [bp-34h]@82
6028 int v140; // [sp+48h] [bp-34h]@120
6029 int v141; // [sp+4Ch] [bp-30h]@6
6030 int v142; // [sp+4Ch] [bp-30h]@41
6031 int v143; // [sp+4Ch] [bp-30h]@75
6032 int v144; // [sp+4Ch] [bp-30h]@113
6033 int v145; // [sp+50h] [bp-2Ch]@5
6034 int v146; // [sp+50h] [bp-2Ch]@40
6035 int v147; // [sp+50h] [bp-2Ch]@75
6036 int v148; // [sp+50h] [bp-2Ch]@113
6037 int v149; // [sp+54h] [bp-28h]@4
6038 int v150; // [sp+54h] [bp-28h]@39
6039 int v151; // [sp+54h] [bp-28h]@75
6040 int v152; // [sp+54h] [bp-28h]@113
6041 int sDepth; // [sp+58h] [bp-24h]@17
6042 int sDeptha; // [sp+58h] [bp-24h]@52
6043 int sDepthb; // [sp+58h] [bp-24h]@90
6044 char *a5; // [sp+5Ch] [bp-20h]@16
6045 char *a5a; // [sp+5Ch] [bp-20h]@51
6046 signed int a5b; // [sp+5Ch] [bp-20h]@83
6047 signed int a5c; // [sp+5Ch] [bp-20h]@121
6048 signed int v160; // [sp+60h] [bp-1Ch]@12
6049 signed int v161; // [sp+60h] [bp-1Ch]@47
6050 int v162; // [sp+60h] [bp-1Ch]@128
6051 int v163; // [sp+64h] [bp-18h]@2
6052 int outx; // [sp+68h] [bp-14h]@2
6053 int outy; // [sp+6Ch] [bp-10h]@2
6054 int outz; // [sp+70h] [bp-Ch]@2
6055 Vec3_int_ pOut; // [sp+74h] [bp-8h]@2
6056 int ya; // [sp+84h] [bp+8h]@60
6057 int yb; // [sp+84h] [bp+8h]@136
6058 int ve; // [sp+88h] [bp+Ch]@60
6059 int va; // [sp+88h] [bp+Ch]@60
6060 int vb; // [sp+88h] [bp+Ch]@66
6061 int vf; // [sp+88h] [bp+Ch]@136
6062 int vc; // [sp+88h] [bp+Ch]@136
6063 int vd; // [sp+88h] [bp+Ch]@142
6064 int v_4; // [sp+8Ch] [bp+10h]@60
6065 int v_4a; // [sp+8Ch] [bp+10h]@65
6066 int v_4b; // [sp+8Ch] [bp+10h]@136
6067 int v_4c; // [sp+8Ch] [bp+10h]@141
6068 int v_8; // [sp+90h] [bp+14h]@53
6069
6070 a4 = __PAIR__(z, x);
6071 v4 = stru_5C6E00->Atan2(v.x - x, v.y - z);
6072 v114 = 0;
6073 v97.z = y;
6074 v113 = 0;
6075 a4_8 = v4;
6076 *(_QWORD *)&v97.x = a4;
6077 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor)
6078 {
6079 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz);
6080 v45.z = v.z;
6081 *(_QWORD *)&v45.x = *(_QWORD *)&v;
6082 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v45, &outx, &outy, &v163);
6083 v46 = outy - pOut.y;
6084 v47 = v163 - outz;
6085 v48 = outx - pOut.x;
6086 v49 = integer_sqrt(v48 * v48 + v46 * v46 + v47 * v47);
6087 v50 = 65536;
6088 if ( v49 )
6089 v50 = 65536 / v49;
6090 v51 = outx;
6091 v143 = v48 * v50;
6092 v52 = v46 * v50;
6093 v53 = v47 * v50;
6094 v54 = pOut.x;
6095 v147 = v52;
6096 v151 = v53;
6097 v119 = pOut.x;
6098 if ( pOut.x < outx )
6099 {
6100 v123 = outx;
6101 }
6102 else
6103 {
6104 v119 = outx;
6105 v123 = pOut.x;
6106 }
6107 v55 = pOut.y;
6108 v56 = outy;
6109 v127 = pOut.y;
6110 if ( pOut.y < outy )
6111 {
6112 v131 = outy;
6113 }
6114 else
6115 {
6116 v127 = outy;
6117 v131 = pOut.y;
6118 }
6119 v57 = v163;
6120 v58 = outz;
6121 v135 = outz;
6122 if ( outz < v163 )
6123 {
6124 v139 = v163;
6125 }
6126 else
6127 {
6128 v135 = v163;
6129 v139 = outz;
6130 }
6131 a5b = 0;
6132 while ( !v114 )
6133 {
6134 if ( a5b )
6135 {
6136 v102 = v58;
6137 v100 = v55;
6138 v98 = v54;
6139 }
6140 else
6141 {
6142 v102 = v57;
6143 v100 = v56;
6144 v98 = v51;
6145 }
6146 v59 = pIndoor->GetSector(v98, v100, v102);
6147 v60 = pIndoor->pSectors;
6148 v61 = 116 * v59;
6149 sDepthb = 0;
6150 for ( i = 116 * v59;
6151 sDepthb < *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v61)
6152 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v61);
6153 ++sDepthb )
6154 {
6155 v62 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v60->pWalls + v61))[sDepthb]];
6156 if ( v62->Portal()
6157 || v119 > v62->pBounding.x2
6158 || v123 < v62->pBounding.x1
6159 || v127 > v62->pBounding.y2
6160 || v131 < v62->pBounding.y1
6161 || v135 > v62->pBounding.z2
6162 || v139 < v62->pBounding.z1
6163 || (v63 = (unsigned __int64)(v143 * (signed __int64)v62->pFacePlane_old.vNormal.x) >> 16,
6164 v64 = (unsigned __int64)(v151 * (signed __int64)v62->pFacePlane_old.vNormal.z) >> 16,
6165 v65 = (unsigned __int64)(v147 * (signed __int64)v62->pFacePlane_old.vNormal.y) >> 16,
6166 v20 = v63 + v64 + v65 == 0,
6167 v66 = v63 + v64 + v65,
6168 v107 = v63 + v64 + v65,
6169 v20) )
6170 goto LABEL_107;
6171 v67 = outz * v62->pFacePlane_old.vNormal.z;
6172 v68 = -(v62->pFacePlane_old.dist
6173 + v67
6174 + pOut.y * v62->pFacePlane_old.vNormal.y
6175 + pOut.x * v62->pFacePlane_old.vNormal.x);
6176 if ( v66 <= 0 )
6177 {
6178 if ( v62->pFacePlane_old.dist
6179 + v67
6180 + pOut.y * v62->pFacePlane_old.vNormal.y
6181 + pOut.x * v62->pFacePlane_old.vNormal.x < 0 )
6182 goto LABEL_107;
6183 }
6184 else
6185 {
6186 if ( v62->pFacePlane_old.dist
6187 + v67
6188 + pOut.y * v62->pFacePlane_old.vNormal.y
6189 + pOut.x * v62->pFacePlane_old.vNormal.x > 0 )
6190 goto LABEL_107;
6191 }
6192 v69 = abs(-(v62->pFacePlane_old.dist
6193 + v67
6194 + pOut.y * v62->pFacePlane_old.vNormal.y
6195 + pOut.x * v62->pFacePlane_old.vNormal.x)) >> 14;
6196 if ( v69 <= abs(v66) )
6197 {
6198 LODWORD(v70) = v68 << 16;
6199 HIDWORD(v70) = v68 >> 16;
6200 v71 = v70 / v107;
6201 v108 = v70 / v107;
6202 if ( v71 >= 0 )
6203 {
6204 if ( sub_4075DB(
6205 pOut.x + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v143) >> 16) + 32768) >> 16),
6206 pOut.y + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v147) >> 16) + 32768) >> 16),
6207 outz + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v151) >> 16) + 32768) >> 16),
6208 v62) )
6209 {
6210 v114 = 1;
6211 break;
6212 }
6213 }
6214 }
6215 v61 = i;
6216 LABEL_107:
6217 v60 = pIndoor->pSectors;
6218 }
6219 ++a5b;
6220 if ( a5b >= 2 )
6221 break;
6222 v57 = v163;
6223 v56 = outy;
6224 v51 = outx;
6225 v58 = outz;
6226 v55 = pOut.y;
6227 v54 = pOut.x;
6228 }
6229 v72.z = y;
6230 *(_QWORD *)&v72.x = a4;
6231 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v72, &pOut.x, &pOut.y, &outz);
6232 v73.z = v.z;
6233 *(_QWORD *)&v73.x = *(_QWORD *)&v;
6234 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v73, &outx, &outy, &v163);
6235 v74 = outy - pOut.y;
6236 v75 = v163 - outz;
6237 v76 = outx - pOut.x;
6238 v77 = integer_sqrt(v76 * v76 + v74 * v74 + v75 * v75);
6239 v78 = 65536;
6240 if ( v77 )
6241 v78 = 65536 / v77;
6242 v79 = outx;
6243 v144 = v76 * v78;
6244 v80 = v74 * v78;
6245 v81 = v75 * v78;
6246 v82 = pOut.x;
6247 v148 = v80;
6248 v152 = v81;
6249 v120 = pOut.x;
6250 if ( pOut.x < outx )
6251 {
6252 v124 = outx;
6253 }
6254 else
6255 {
6256 v120 = outx;
6257 v124 = pOut.x;
6258 }
6259 v83 = pOut.y;
6260 v84 = outy;
6261 v128 = pOut.y;
6262 if ( pOut.y < outy )
6263 {
6264 v132 = outy;
6265 }
6266 else
6267 {
6268 v128 = outy;
6269 v132 = pOut.y;
6270 }
6271 v85 = v163;
6272 v86 = outz;
6273 v136 = outz;
6274 if ( outz < v163 )
6275 {
6276 v140 = v163;
6277 }
6278 else
6279 {
6280 v136 = v163;
6281 v140 = outz;
6282 }
6283 a5c = 0;
6284 while ( 1 )
6285 {
6286 if ( v113 )
6287 return !v114 || !v113;
6288 if ( a5c )
6289 {
6290 v103 = v86;
6291 v101 = v83;
6292 v99 = v82;
6293 }
6294 else
6295 {
6296 v103 = v85;
6297 v101 = v84;
6298 v99 = v79;
6299 }
6300 v87 = pIndoor->GetSector(v99, v101, v103);
6301 v88 = pIndoor->pSectors;
6302 v89 = 116 * v87;
6303 v162 = 0;
6304 v112 = v89;
6305 if ( *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v89)
6306 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) > 0 )
6307 break;
6308 LABEL_148:
6309 ++a5c;
6310 if ( a5c >= 2 )
6311 return !v114 || !v113;
6312 v85 = v163;
6313 v84 = outy;
6314 v79 = outx;
6315 v86 = outz;
6316 v83 = pOut.y;
6317 v82 = pOut.x;
6318 }
6319 while ( 1 )
6320 {
6321 v90 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v88->pWalls + v89))[v162]];
6322 if ( v90->Portal()
6323 || v120 > v90->pBounding.x2
6324 || v124 < v90->pBounding.x1
6325 || v128 > v90->pBounding.y2
6326 || v132 < v90->pBounding.y1
6327 || v136 > v90->pBounding.z2
6328 || v140 < v90->pBounding.z1
6329 || (yb = (unsigned __int64)(v144 * (signed __int64)v90->pFacePlane_old.vNormal.x) >> 16,
6330 v_4b = (unsigned __int64)(v148 * (signed __int64)v90->pFacePlane_old.vNormal.y) >> 16,
6331 vf = (unsigned __int64)(v152 * (signed __int64)v90->pFacePlane_old.vNormal.z) >> 16,
6332 v20 = yb + vf + v_4b == 0,
6333 v91 = yb + vf + v_4b,
6334 vc = yb + vf + v_4b,
6335 v20) )
6336 goto LABEL_145;
6337 v92 = outz * v90->pFacePlane_old.vNormal.z;
6338 v93 = -(v90->pFacePlane_old.dist
6339 + v92
6340 + pOut.y * v90->pFacePlane_old.vNormal.y
6341 + pOut.x * v90->pFacePlane_old.vNormal.x);
6342 if ( v91 <= 0 )
6343 {
6344 if ( v90->pFacePlane_old.dist
6345 + v92
6346 + pOut.y * v90->pFacePlane_old.vNormal.y
6347 + pOut.x * v90->pFacePlane_old.vNormal.x < 0 )
6348 goto LABEL_145;
6349 }
6350 else
6351 {
6352 if ( v90->pFacePlane_old.dist
6353 + v92
6354 + pOut.y * v90->pFacePlane_old.vNormal.y
6355 + pOut.x * v90->pFacePlane_old.vNormal.x > 0 )
6356 goto LABEL_145;
6357 }
6358 v_4c = abs(-(v90->pFacePlane_old.dist
6359 + v92
6360 + pOut.y * v90->pFacePlane_old.vNormal.y
6361 + pOut.x * v90->pFacePlane_old.vNormal.x)) >> 14;
6362 if ( v_4c <= abs(v91) )
6363 {
6364 LODWORD(v94) = v93 << 16;
6365 HIDWORD(v94) = v93 >> 16;
6366 v95 = v94 / vc;
6367 vd = v94 / vc;
6368 if ( v95 >= 0 )
6369 {
6370 if ( sub_4075DB(
6371 pOut.x + ((signed int)(((unsigned __int64)(vd * (signed __int64)v144) >> 16) + 32768) >> 16),
6372 pOut.y + ((signed int)(((unsigned __int64)(vd * (signed __int64)v148) >> 16) + 32768) >> 16),
6373 outz + ((signed int)(((unsigned __int64)(vd * (signed __int64)v152) >> 16) + 32768) >> 16),
6374 v90) )
6375 {
6376 v113 = 1;
6377 goto LABEL_148;
6378 }
6379 }
6380 }
6381 v89 = v112;
6382 LABEL_145:
6383 v88 = pIndoor->pSectors;
6384 ++v162;
6385 if ( v162 >= *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v89)
6386 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) )
6387 goto LABEL_148;
6388 }
6389 }
6390 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz);
6391 v5.z = v.z;
6392 *(_QWORD *)&v5.x = *(_QWORD *)&v;
6393 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v5, &outx, &outy, &v163);
6394 v6 = outy - pOut.y;
6395 v7 = v163 - outz;
6396 v8 = outx - pOut.x;
6397 v9 = integer_sqrt(v8 * v8 + v6 * v6 + v7 * v7);
6398 v10 = 65536;
6399 if ( v9 )
6400 v10 = 65536 / v9;
6401 v125 = v8 * v10;
6402 v11 = v10;
6403 v12 = v7 * v10;
6404 v13 = pOut.x;
6405 v117 = v12;
6406 v121 = v6 * v11;
6407 v149 = pOut.x;
6408 if ( pOut.x < outx )
6409 {
6410 v145 = outx;
6411 }
6412 else
6413 {
6414 v149 = outx;
6415 v145 = pOut.x;
6416 }
6417 v14 = outy;
6418 v141 = pOut.y;
6419 if ( pOut.y < outy )
6420 {
6421 v137 = outy;
6422 }
6423 else
6424 {
6425 v141 = outy;
6426 v137 = pOut.y;
6427 }
6428 v133 = outz;
6429 if ( outz < v163 )
6430 {
6431 v129 = v163;
6432 }
6433 else
6434 {
6435 v133 = v163;
6436 v129 = outz;
6437 }
6438 v160 = 0;
6439 if ( (signed int)pOutdoor->uNumBModels > 0 )
6440 {
6441 v104 = 0;
6442 while ( 1 )
6443 {
6444 v15 = (char *)&pOutdoor->pBModels[v104].pVertices;
6445 a5 = (char *)&pOutdoor->pBModels[v104].pVertices;
6446 if ( sub_4088E9(v13, pOut.y, outx, v14, pOutdoor->pBModels[v104].vPosition.x, pOutdoor->pBModels[v104].vPosition.y) <= pOutdoor->pBModels[v104].sBoundingRadius + 128 )
6447 {
6448 sDepth = 0;
6449 if ( *((int *)v15 + 2) > 0 )
6450 break;
6451 }
6452 LABEL_36:
6453 ++v160;
6454 ++v104;
6455 if ( v160 >= (signed int)pOutdoor->uNumBModels )
6456 goto LABEL_37;
6457 v14 = outy;
6458 v13 = pOut.x;
6459 }
6460 v106 = 0;
6461 while ( 1 )
6462 {
6463 v16 = (ODMFace *)(v106 + *((int *)a5 + 4));
6464 if ( v149 > v16->pBoundingBox.x2
6465 || v145 < v16->pBoundingBox.x1
6466 || v141 > v16->pBoundingBox.y2
6467 || v137 < v16->pBoundingBox.y1
6468 || v133 > v16->pBoundingBox.z2
6469 || v129 < v16->pBoundingBox.z1
6470 || (v17 = (unsigned __int64)(v125 * (signed __int64)v16->pFacePlane.vNormal.x) >> 16,
6471 v18 = (unsigned __int64)(v121 * (signed __int64)v16->pFacePlane.vNormal.y) >> 16,
6472 v19 = (unsigned __int64)(v117 * (signed __int64)v16->pFacePlane.vNormal.z) >> 16,
6473 v20 = v17 + v18 + v19 == 0,
6474 v21 = v17 + v18 + v19,
6475 v109 = v17 + v18 + v19,
6476 v20) )
6477 goto LABEL_33;
6478 v22 = pOut.y * v16->pFacePlane.vNormal.y;
6479 v23 = -(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x);
6480 if ( v21 <= 0 )
6481 {
6482 if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x < 0 )
6483 goto LABEL_33;
6484 }
6485 else
6486 {
6487 if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x > 0 )
6488 goto LABEL_33;
6489 }
6490 v24 = abs(-(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x)) >> 14;
6491 if ( v24 <= abs(v21) )
6492 {
6493 LODWORD(v25) = v23 << 16;
6494 HIDWORD(v25) = v23 >> 16;
6495 v26 = v25 / v109;
6496 v110 = v25 / v109;
6497 if ( v26 >= 0 )
6498 {
6499 if ( sub_4077F1(
6500 pOut.x + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v125) >> 16) + 32768) >> 16),
6501 pOut.y + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v121) >> 16) + 32768) >> 16),
6502 outz + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v117) >> 16) + 32768) >> 16),
6503 v16,
6504 (BSPVertexBuffer *)a5) )
6505 {
6506 v114 = 1;
6507 goto LABEL_36;
6508 }
6509 }
6510 }
6511 LABEL_33:
6512 ++sDepth;
6513 v106 += 308;
6514 if ( sDepth >= *((int *)a5 + 2) )
6515 goto LABEL_36;
6516 }
6517 }
6518 LABEL_37:
6519 v27.z = y;
6520 *(_QWORD *)&v27.x = a4;
6521 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v27, &pOut.x, &pOut.y, &outz);
6522 v28.z = v.z;
6523 *(_QWORD *)&v28.x = *(_QWORD *)&v;
6524 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v28, &outx, &outy, &v163);
6525 v29 = outy - pOut.y;
6526 v30 = v163 - outz;
6527 v31 = outx - pOut.x;
6528 v32 = integer_sqrt(v31 * v31 + v29 * v29 + v30 * v30);
6529 v33 = 65536;
6530 if ( v32 )
6531 v33 = 65536 / v32;
6532 v126 = v31 * v33;
6533 v34 = v33;
6534 v35 = v30 * v33;
6535 v36 = pOut.x;
6536 v118 = v35;
6537 v122 = v29 * v34;
6538 v150 = pOut.x;
6539 if ( pOut.x < outx )
6540 {
6541 v146 = outx;
6542 }
6543 else
6544 {
6545 v150 = outx;
6546 v146 = pOut.x;
6547 }
6548 v37 = outy;
6549 v142 = pOut.y;
6550 if ( pOut.y < outy )
6551 {
6552 v138 = outy;
6553 }
6554 else
6555 {
6556 v142 = outy;
6557 v138 = pOut.y;
6558 }
6559 v134 = outz;
6560 if ( outz < v163 )
6561 {
6562 v130 = v163;
6563 }
6564 else
6565 {
6566 v134 = v163;
6567 v130 = outz;
6568 }
6569 v161 = 0;
6570 if ( (signed int)pOutdoor->uNumBModels > 0 )
6571 {
6572 v105 = 0;
6573 while ( 1 )
6574 {
6575 v38 = (char *)&pOutdoor->pBModels[v105].pVertices;
6576 a5a = (char *)&pOutdoor->pBModels[v105].pVertices;
6577 if ( sub_4088E9(v36, pOut.y, outx, v37, pOutdoor->pBModels[v105].vPosition.x, pOutdoor->pBModels[v105].vPosition.y) <= pOutdoor->pBModels[v105].sBoundingRadius + 128 )
6578 {
6579 sDeptha = 0;
6580 if ( *((int *)v38 + 2) > 0 )
6581 break;
6582 }
6583 LABEL_71:
6584 ++v161;
6585 ++v105;
6586 if ( v161 >= (signed int)pOutdoor->uNumBModels )
6587 return !v114 || !v113;
6588 v37 = outy;
6589 v36 = pOut.x;
6590 }
6591 v_8 = 0;
6592 while ( 1 )
6593 {
6594 v39 = (ODMFace *)(v_8 + *((int *)a5a + 4));
6595 if ( v150 > v39->pBoundingBox.x2
6596 || v146 < v39->pBoundingBox.x1
6597 || v142 > v39->pBoundingBox.y2
6598 || v138 < v39->pBoundingBox.y1
6599 || v134 > v39->pBoundingBox.z2
6600 || v130 < v39->pBoundingBox.z1
6601 || (ya = (unsigned __int64)(v126 * (signed __int64)v39->pFacePlane.vNormal.x) >> 16,
6602 ve = (unsigned __int64)(v122 * (signed __int64)v39->pFacePlane.vNormal.y) >> 16,
6603 v_4 = (unsigned __int64)(v118 * (signed __int64)v39->pFacePlane.vNormal.z) >> 16,
6604 v20 = ya + ve + v_4 == 0,
6605 v40 = ya + ve + v_4,
6606 va = ya + ve + v_4,
6607 v20) )
6608 goto LABEL_68;
6609 v41 = pOut.y * v39->pFacePlane.vNormal.y;
6610 v42 = -(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x);
6611 if ( v40 <= 0 )
6612 {
6613 if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x < 0 )
6614 goto LABEL_68;
6615 }
6616 else
6617 {
6618 if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x > 0 )
6619 goto LABEL_68;
6620 }
6621 v_4a = abs(-(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x)) >> 14;
6622 if ( v_4a <= abs(v40) )
6623 {
6624 LODWORD(v43) = v42 << 16;
6625 HIDWORD(v43) = v42 >> 16;
6626 v44 = v43 / va;
6627 vb = v43 / va;
6628 if ( v44 >= 0 )
6629 {
6630 if ( sub_4077F1(
6631 pOut.x + ((signed int)(((unsigned __int64)(vb * (signed __int64)v126) >> 16) + 32768) >> 16),
6632 pOut.y + ((signed int)(((unsigned __int64)(vb * (signed __int64)v122) >> 16) + 32768) >> 16),
6633 outz + ((signed int)(((unsigned __int64)(vb * (signed __int64)v118) >> 16) + 32768) >> 16),
6634 v39,
6635 (BSPVertexBuffer *)a5a) )
6636 {
6637 v113 = 1;
6638 goto LABEL_71;
6639 }
6640 }
6641 }
6642 LABEL_68:
6643 ++sDeptha;
6644 v_8 += 308;
6645 if ( sDeptha >= *((int *)a5a + 2) )
6646 goto LABEL_71;
6647 }
6648 }
6649 return !v114 || !v113;
6650 }
6651 //----- (0043F333) --------------------------------------------------------
6652 void BspRenderer::MakeVisibleSectorList()
6653 {
6654 int v6; // ebx@3
6655
6656 uNumVisibleNotEmptySectors = 0;
6657 for (uint i = 0; i < num_nodes; ++i)
6658 {
6659 if (!uNumVisibleNotEmptySectors)
6660 {
6661 pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = nodes[i].uSectorID;
6662 continue;
6663 }
6664
6665 v6 = 0;
6666 while (pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v6] != nodes[i].uSectorID )
6667 {
6668 ++v6;
6669 if ( v6 >= uNumVisibleNotEmptySectors)
6670 {
6671 pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = nodes[i].uSectorID;
6672 }
6673 }
6674
6675 }
6676 }
6677 //----- (0046A334) --------------------------------------------------------
6678 char __fastcall DoInteractionWithTopmostZObject(int a1, int a2)
6679 {
6680 int v2; // edx@1
6681 BLVFace *v4; // eax@9
6682 unsigned int v5; // ecx@9
6683 unsigned __int16 v6; // ax@11
6684 //ODMFace *v7; // eax@16
6685 LevelDecoration *v8; // esi@19
6686 __int16 v9; // ax@19
6687 int v10; // eax@22
6688 int v11; // ecx@22
6689 int v12; // edi@23
6690 Actor *v13; // esi@23
6691 unsigned __int16 v14; // ax@23
6692 unsigned __int16 v15; // ax@33
6693 const char *v16; // eax@34
6694 int v17; // edi@36
6695 int v18; // eax@36
6696 ItemGen *v19; // esi@39
6697 unsigned int v20; // eax@39
6698 int v21; // ecx@40
6699 std::string v22; // [sp-18h] [bp-2Ch]@5
6700 const char *v23; // [sp-8h] [bp-1Ch]@5
6701 int v24; // [sp-4h] [bp-18h]@5
6702 char v25; // [sp+8h] [bp-Ch]@5
6703 int v26; // [sp+Ch] [bp-8h]@1
6704 int a3; // [sp+13h] [bp-1h]@5
6705
6706 v26 = a2;
6707 v2 = a1;
6708 switch ( PID_TYPE(a1) )
6709 {
6710 case OBJECT_Item: // take the item
6711 v17 = PID_ID(a1);
6712 v26 = PID_ID(a1);
6713 v18 = PID_ID(a1);
6714 if ( pObjectList->pObjects[pSpriteObjects[v18].uObjectDescID].uFlags & 0x10
6715 || v17 >= 1000
6716 || !pSpriteObjects[v18].uObjectDescID )
6717 return 1;
6718 v19 = &pSpriteObjects[v18].stru_24;
6719 v20 = pSpriteObjects[v18].stru_24.uItemID;
6720 if ( pItemsTable->pItems[v20].uEquipType == EQUIP_GOLD)
6721 {
6722 party_finds_gold(v19->uSpecEnchantmentType, 0);
6723 viewparams->bRedrawGameUI = 1;
6724 v21 = v17;
6725 }
6726 else
6727 {
6728 if ( pParty->pPickedItem.uItemID )
6729 return 1;
6730 v24 = (int)pItemsTable->pItems[v20].pUnidentifiedName;
6731 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v24);
6732 ShowStatusBarString(pTmpBuf2.data(), 2u);
6733 if ( v19->uItemID == 506 )
6734 _449B7E_toggle_bit(pParty->_quest_bits, 184, 1u);
6735 if ( v19->uItemID == 455 )
6736 _449B7E_toggle_bit(pParty->_quest_bits, 185, 1u);
6737 if ( !pParty->AddItem(v19) )
6738 pParty->SetHoldingItem(v19);
6739 v21 = v26;
6740 }
6741 SpriteObject::OnInteraction(v21);
6742 break;
6743
6744 case OBJECT_Actor:
6745 v12 = PID_ID(a1);
6746 v13 = &pActors[PID_ID(a1)];
6747 v14 = v13->uAIState;
6748 if ( v14 == 4 || v14 == 17 )
6749 return 1;
6750 if ( v14 == 5 )
6751 {
6752 stru_50C198.LootActor(&pActors[PID_ID(a1)]);
6753 }
6754 else
6755 {
6756 if ( !v13->GetActorsRelation(0) && !(BYTE2(v13->uAttributes) & 8) && v13->CanAct() )
6757 {
6758 Actor::AI_FaceObject(v12, 4u, 0, 0);
6759 if ( v13->sNPC_ID )
6760 {
6761 pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v12, 0);
6762 }
6763 else
6764 {
6765 v15 = pNPCStats->pGroups_copy[v13->uGroup];
6766 if ( v15 )
6767 {
6768 v16 = pNPCStats->pCatchPhrases[v15];
6769 if ( v16 )
6770 {
6771 pParty->uFlags |= 2u;
6772 strcpy(byte_5B0938.data(), v16);
6773 sub_4451A8_press_any_key(0, 0, 0);
6774 }
6775 }
6776 }
6777 }
6778 }
6779 break;
6780
6781 case OBJECT_Decoration:
6782 v8 = &pLevelDecorations[PID_ID(a1)];
6783 v9 = v8->field_16_event_id;
6784 if ( v9 )
6785 {
6786 EventProcessor(v9, a1, 1);
6787 LOBYTE(v8->field_2) |= 8u;
6788 }
6789 else
6790 {
6791 if ( !pLevelDecorations[PID_ID(a1)].IsInteractive() )
6792 return 1;
6793 v10 = v8->_idx_in_stru123;
6794 v24 = 1;
6795 v11 = stru_5E4C90._decor_events[v10 - 75] + 380;
6796 activeLevelDecoration = v8;
6797 EventProcessor(v11, 0, 1);
6798 activeLevelDecoration = NULL;
6799 }
6800 break;
6801
6802 default:
6803 MessageBoxW(nullptr, L"Warning: Invalid ID reached!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Mouse.cpp:2020", 0);
6804 return 1;
6805
6806 case OBJECT_BModel:
6807 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
6808 {
6809 int bmodel_id = a1 >> 9,
6810 face_id = PID_ID(a1) & 0x3F;
6811 if (bmodel_id >= pOutdoor->uNumBModels)
6812 return 1;
6813 auto face = &pOutdoor->pBModels[bmodel_id].pFaces[face_id];
6814 if (face->uAttributes & 0x100000 || face->sCogTriggeredID == 0 )
6815 return 1;
6816 EventProcessor((signed __int16)face->sCogTriggeredID, v2, 1);
6817 }
6818 else
6819 {
6820 v4 = &pIndoor->pFaces[PID_ID(a1)];
6821 v5 = v4->uAttributes;
6822 if ( !(v5 & 0x2000000) )
6823 {
6824 ShowNothingHereStatus();
6825 return 1;
6826 }
6827 if ( v5 & 0x100000 || (v6 = pIndoor->pFaceExtras[v4->uFaceExtraID].uEventID) == 0 )
6828 return 1;
6829 if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG )
6830 EventProcessor((signed __int16)v6, v2, 1);
6831 }
6832 return 0;
6833 break;
6834 }
6835 return 0;
6836 }
4643 //----- (0046BDF1) -------------------------------------------------------- 6837 //----- (0046BDF1) --------------------------------------------------------
4644 void __cdecl BLV_UpdateUserInputAndOther() 6838 void __cdecl BLV_UpdateUserInputAndOther()
4645 { 6839 {
4646 UpdateObjects(); 6840 UpdateObjects();
4647 BLV_ProcessPartyActions(); 6841 BLV_ProcessPartyActions();
4648 UpdateActors_BLV(); 6842 UpdateActors_BLV();
4649 BLV_UpdateDoors(); 6843 BLV_UpdateDoors();
4650 check_event_triggers(); 6844 check_event_triggers();
4651 } 6845 }
6846 //----- (00424829) --------------------------------------------------------
6847 bool sub_424829(int pNumVertices, BspRenderer_stru2 *a2, BspRenderer_stru2 *a3, int uFaceID)
6848 {
6849 //int v4; // edi@1
6850 //BspRenderer_stru2 *v5; // ebx@1
6851 int v6; // eax@3
6852 int min_y; // esi@5
6853 int max_y; // edx@5
6854 //int v9; // ecx@6
6855 int v10; // eax@12
6856 //int v11; // edi@13
6857 //int v12; // edx@18
6858 int v13; // eax@22
6859 //int v14; // edi@28
6860 int v15; // ecx@29
6861 //int v16; // edi@30
6862 //int v17; // edx@35
6863 int v18; // eax@39
6864 int v19; // eax@44
6865 int v20; // ecx@44
6866 //int v21; // edi@45
6867 int v22; // edi@46
6868 //__int16 *v23; // ecx@47
6869 int v24; // edx@48
6870 //int v25; // eax@50
6871 int v26; // eax@55
6872 signed int v27; // edi@55
6873 //int v28; // edx@56
6874 int v29; // edx@57
6875 //int v30; // eax@59
6876 int v31; // eax@64
6877 signed int v32; // edi@64
6878 //int v33; // edx@65
6879 int v34; // eax@66
6880 int v35; // dx@66
6881 __int16 v36; // dx@67
6882 __int16 v37; // di@67
6883 __int16 v38; // dx@67
6884 //BspRenderer_stru2 *v39; // ecx@69
6885 //int v40; // edx@69
6886 //int v41; // edi@70
6887 //__int16 *v42; // eax@76
6888 //__int16 *v43; // eax@81
6889 //__int16 *v45; // eax@87
6890 int v46; // edx@87
6891 //__int16 v47; // cx@88
6892 //int v48; // eax@93
6893 int v49; // esi@93
6894 //__int16 *v50; // ecx@94
6895 //int v51; // eax@95
6896 //int v52; // eax@97
6897 int v53; // [sp+Ch] [bp-34h]@44
6898 int v54; // [sp+10h] [bp-30h]@0
6899 int v55; // [sp+14h] [bp-2Ch]@12
6900 //__int16 *v56; // [sp+14h] [bp-2Ch]@47
6901 //__int16 v57; // [sp+14h] [bp-2Ch]@76
6902 //__int16 v58; // [sp+14h] [bp-2Ch]@81
6903 int v59; // [sp+14h] [bp-2Ch]@87
6904 //BspRenderer_stru2 *v60; // [sp+18h] [bp-28h]@1
6905 int v61; // [sp+1Ch] [bp-24h]@29
6906 int v62; // [sp+20h] [bp-20h]@0
6907 signed int v63; // [sp+24h] [bp-1Ch]@3
6908 signed int v64; // [sp+28h] [bp-18h]@3
6909 int v65; // [sp+2Ch] [bp-14h]@5
6910 //int v66; // [sp+2Ch] [bp-14h]@39
6911 //int v67; // [sp+30h] [bp-10h]@22
6912 int v68; // [sp+34h] [bp-Ch]@12
6913 int v69; // [sp+34h] [bp-Ch]@29
6914 int v70; // [sp+34h] [bp-Ch]@46
6915 int v71; // [sp+34h] [bp-Ch]@75
6916 int v72; // [sp+34h] [bp-Ch]@80
6917 //int v73; // [sp+38h] [bp-8h]@11
6918 //int v74; // [sp+3Ch] [bp-4h]@1
6919 //int a3a; // [sp+48h] [bp+8h]@76
6920 //int a3b; // [sp+48h] [bp+8h]@87
6921
6922 //try graphic engine with function returning 1 always, and without
6923 //return true;
6924 if ( pNumVertices <= 1 )
6925 return false;
6926 min_y = stru_50B700._screen_space_y[0];
6927 v65 = 0;
6928 max_y = stru_50B700._screen_space_y[0];
6929 if ( !stru_50B700.field_0 )
6930 {
6931 v63 = 1;
6932 v64 = -1;
6933 }
6934 else
6935 {
6936 v63 = -1;
6937 v64 = 1;
6938 }
6939
6940 for ( v6 = 1; v6 < pNumVertices; ++v6 )
6941 {
6942 if ( stru_50B700._screen_space_y[v6] >= min_y )
6943 {
6944 if ( stru_50B700._screen_space_y[v6] > max_y )
6945 max_y = stru_50B700._screen_space_y[v6];
6946 }
6947 if ( stru_50B700._screen_space_y[v6] < min_y )
6948 {
6949 v65 = v6;
6950 min_y = stru_50B700._screen_space_y[v6];
6951 }
6952 }
6953 if ( max_y == min_y )
6954 return false;
6955
6956 v10 = v65;
6957 a2->_viewport_space_y = min_y;
6958 a2->_viewport_space_w = max_y;
6959 v55 = v65;
6960
6961 for ( v68 = 0; v68 < pNumVertices; ++v68 )
6962 {
6963 v10 += v64;
6964 if ( v10 < pNumVertices )
6965 {
6966 if ( v10 < 0 )
6967 v10 += pNumVertices;
6968 }
6969 else
6970 v10 -= pNumVertices;
6971 if ( stru_50B700._screen_space_y[v10] <= stru_50B700._screen_space_y[v65] )
6972 {
6973 v55 = v10;
6974 v65 = v10;
6975 }
6976 if ( stru_50B700._screen_space_y[v10] == max_y )
6977 break;
6978 }
6979 v13 = v55 + v64;
6980 if ( v13 < pNumVertices )
6981 {
6982 if ( v13 < 0 )
6983 v13 += pNumVertices;
6984 }
6985 else
6986 v13 -= pNumVertices;
6987 if ( stru_50B700._screen_space_y[v13] != stru_50B700._screen_space_y[v55] )
6988 {
6989 v62 = stru_50B700._screen_space_x[v55] << 16;
6990 v54 = ((stru_50B700._screen_space_x[v13] - stru_50B700._screen_space_x[v55]) << 16) / (stru_50B700._screen_space_y[v13] - stru_50B700._screen_space_y[v55]);
6991 a2->viewport_left_side[min_y] = LOWORD(stru_50B700._screen_space_x[v55]);
6992 }
6993 v15 = v65;
6994 v61 = v65;
6995
6996 for ( v69 = 0; v69 < pNumVertices; ++v69 )
6997 {
6998 v15 += v63;
6999 if ( v15 < pNumVertices )
7000 {
7001 if ( v15 < 0 )
7002 v15 += pNumVertices;
7003 }
7004 else
7005 v15 -= pNumVertices;
7006 if ( stru_50B700._screen_space_y[v15] <= stru_50B700._screen_space_y[v65] )
7007 {
7008 v61 = v15;
7009 v65 = v15;
7010 }
7011 if ( stru_50B700._screen_space_y[v15] == max_y )
7012 break;
7013 }
7014 v18 = v63 + v61;
7015 if ( v18 < pNumVertices )
7016 {
7017 if ( v18 < 0 )
7018 v18 += pNumVertices;
7019 }
7020 else
7021 v18 -= pNumVertices;
7022 v19 = v18;
7023 v20 = v61;
7024 if ( stru_50B700._screen_space_y[v19] != stru_50B700._screen_space_y[v61] )
7025 {
7026 v61 = stru_50B700._screen_space_x[v20] << 16;
7027 v53 = ((stru_50B700._screen_space_x[v19] - stru_50B700._screen_space_x[v20]) << 16) / stru_50B700._screen_space_y[v19] - stru_50B700._screen_space_y[v20];
7028 a2->viewport_right_side[max_y] = LOWORD(stru_50B700._screen_space_x[v20]);
7029 }
7030 v22 = min_y;
7031 if ( min_y <= max_y )
7032 {
7033 //v56 = &a2->array_3D8[v7];
7034 //v23 = &a2->array_18[v7];
7035 for ( v70 = min_y; v70 <= max_y; ++v70 )
7036 {
7037 v24 = v13;
7038 if ( v22 >= stru_50B700._screen_space_y[v13] && v22 != max_y )
7039 {
7040 v13 = v64 + v13;
7041 if ( v13 < pNumVertices )
7042 {
7043 if ( v13 < 0 )
7044 v13 += pNumVertices;
7045 }
7046 else
7047 v13 -= pNumVertices;
7048 v26 = v13;
7049 //v27 = stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24];
7050 if ( stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24] > 0 )
7051 {
7052 v54 = ((stru_50B700._screen_space_x[v26] - stru_50B700._screen_space_x[v24]) << 16) / stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24];
7053 v62 = stru_50B700._screen_space_x[v24] << 16;
7054 }
7055 }
7056 v29 = v18;
7057 if ( v70 >= stru_50B700._screen_space_y[v18] && v70 != max_y )
7058 {
7059 v18 += v63;
7060 if ( v18 < pNumVertices )
7061 {
7062 if ( v18 < 0 )
7063 v18 += pNumVertices;
7064 }
7065 else
7066 v18 -= pNumVertices;
7067 v31 = v18;
7068 //v32 = stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29];
7069 if ( stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29] > 0 )
7070 {
7071 v53 = ((stru_50B700._screen_space_x[v31] - stru_50B700._screen_space_x[v29]) << 16) / stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29];
7072 v61 = stru_50B700._screen_space_x[v29] << 16;
7073 }
7074 }
7075 //v34 = (char *)a2->array_18 - (char *)a2->array_3D8;
7076 //v35 = *(__int16 *)((char *)&a2->array_3D8[v70] + v34);
7077 //v35 = HIWORD(v62);
7078 a2->viewport_left_side[v70] = HIWORD(v62);
7079 a2->viewport_right_side[v70] = HIWORD(v61);
7080 //v34 = &a2->array_3D8[v70];
7081 //v35 = a2->array_3D8[v70];
7082 if ( a2->viewport_left_side[v70] > a2->viewport_right_side[v70] )
7083 {
7084 v36 = a2->viewport_left_side[v70] ^ a2->viewport_right_side[v70];
7085 v37 = a2->viewport_right_side[v70];
7086 a2->viewport_left_side[v70] = v36;
7087 v38 = v37 ^ v36;
7088 a2->viewport_left_side[v70] ^= v38;
7089 a2->viewport_right_side[v70] = v38;
7090 }
7091 //++v56;
7092 v62 += v54;
7093 v22 = v70 + 1;
7094 v61 += v53;
7095 //++v23;
7096 }
7097 }
7098 if ( max_y < a3->_viewport_space_y )
7099 return false;
7100 if ( min_y > a3->_viewport_space_w )
7101 return false;
7102 if ( min_y < a3->_viewport_space_y )
7103 min_y = a3->_viewport_space_y;
7104 if ( max_y > a3->_viewport_space_w )
7105 max_y = a3->_viewport_space_w;
7106 if ( min_y <= max_y )
7107 {
7108 //a3a = (char *)a2 - (char *)a3;
7109 //v42 = &a3->array_3D8[v7];
7110 //v57 = *(__int16 *)((char *)v42 + a3a);
7111 for ( v71 = min_y; v71 <= max_y; ++v71 )
7112 {
7113 if ( a2->viewport_left_side[v71] >= a3->viewport_left_side[v71] && a2->viewport_left_side[v71] <= a3->viewport_right_side[v71] )
7114 break;
7115 //++v57;
7116 ++min_y;
7117 //++v42;
7118 }
7119 }
7120 if ( max_y < min_y )
7121 return false;
7122 //a3a = (char *)a2 - (char *)a3;
7123 //v43 = &a3->array_3D8[v8];
7124 //v58 = *(__int16 *)((char *)v43 + a3a);
7125 for ( v72 = max_y; v72 >= min_y; --v72 )
7126 {
7127 if ( a2->viewport_right_side[v72] >= a3->viewport_left_side[v72] && a2->viewport_left_side[v72] <= a3->viewport_right_side[v72] )
7128 break;
7129 //--v58;
7130 --max_y;
7131 //--v43;
7132 //v8 = v8;
7133 }
7134 if ( min_y >= max_y )
7135 return false;
7136 //a3b = (char *)a3 - (char *)a2;
7137 v59 = min_y;
7138 //v45 = &a2->array_18[v7];
7139
7140 for ( v46 = max_y - min_y + 1; v46; --v46 )
7141 {
7142 //v47 = *(__int16 *)((char *)v45 + a3b);
7143 if ( a2->viewport_left_side[v59] < a3->viewport_left_side[v59] )
7144 a2->viewport_left_side[v59] = a3->viewport_left_side[v59];
7145 if ( a2->viewport_right_side[v59] > a3->viewport_right_side[v59] )
7146 a2->viewport_right_side[v59] = a3->viewport_right_side[v59];
7147 ++v59;
7148 //++v45;
7149 }
7150 a2->_viewport_space_y = min_y;
7151 a2->_viewport_space_w = max_y;
7152 a2->field_8 = a2->viewport_left_side[min_y];
7153 //v48 = a2->viewport_right_side[v7];
7154 a2->field_10 = min_y;
7155 a2->field_14 = min_y;
7156 a2->field_C = a2->viewport_right_side[min_y];
7157 v49 = min_y + 1;
7158 if ( v49 <= max_y )
7159 {
7160 //v50 = &a2->array_3D8[v49];
7161 for ( v49; v49 <= max_y; ++v49 )
7162 {
7163 //v51 = a2->array_18[v49];
7164 if ( a2->viewport_left_side[v49] < a2->field_8 )
7165 {
7166 a2->field_8 = a2->viewport_left_side[v49];
7167 a2->field_10 = v49;
7168 }
7169 if ( a2->viewport_right_side[v49] > a2->field_C )
7170 {
7171 a2->field_C = a2->viewport_right_side[v49];
7172 a2->field_14 = v49;
7173 }
7174 //++v50;
7175 }
7176 }
7177 return true;
7178 }
7179 //----- (00423B5D) --------------------------------------------------------
7180 int __fastcall sub_423B5D(unsigned int uFaceID)
7181 {
7182 BLVFace *pFace; // ebx@1
7183 Vec3_short_ *v2; // esi@1
7184 //int v3; // ST28_4@1
7185 //__int16 v4; // ST2C_2@1
7186 signed int v5; // esi@1
7187 //Vec3_short_ *v6; // eax@4
7188 signed int v7; // edi@5
7189 signed int v8; // eax@5
7190 signed int v9; // ecx@10
7191 int v10; // eax@10
7192 int v11; // edx@11
7193 int v12; // ST28_4@12
7194 signed int v13; // edx@12
7195 signed __int64 v14; // qtt@12
7196 char *v15; // ebx@12
7197 int v16; // ST28_4@14
7198 signed int v17; // eax@14
7199 signed __int64 v18; // qtt@14
7200 signed int v19; // edx@15
7201 signed int v20; // edx@17
7202 signed int v21; // ebx@19
7203 signed int v22; // esi@20
7204 int v23; // edi@21
7205 int v24; // eax@21
7206 int v25; // eax@22
7207 int v26; // eax@22
7208 signed int v27; // ST30_4@24
7209 signed __int64 v28; // qtt@24
7210 int v29; // ST18_4@25
7211 int v30; // eax@26
7212 int v31; // eax@27
7213 int v32; // eax@27
7214 signed int v33; // ST30_4@29
7215 signed __int64 v34; // qtt@29
7216 int v35; // ST30_4@30
7217 signed int v36; // edi@31
7218 unsigned int v37; // eax@31
7219 bool v38; // edx@31
7220 int v39; // ecx@31
7221 int v40; // ecx@32
7222 int v41; // esi@32
7223 int v42; // eax@34
7224 signed int v43; // ebx@41
7225 unsigned int v44; // eax@41
7226 signed int v45; // ecx@42
7227 int v46; // esi@42
7228 int v47; // eax@44
7229 signed int v48; // edi@51
7230 unsigned int v49; // eax@51
7231 bool v50; // edx@51
7232 int v51; // ecx@51
7233 int v52; // ecx@52
7234 int v53; // esi@52
7235 int v54; // eax@54
7236 int v55; // ebx@61
7237 unsigned int v56; // eax@61
7238 signed int v57; // ecx@62
7239 int v58; // esi@62
7240 int v59; // eax@64
7241 char v61; // zf@72
7242 signed int v62; // edx@75
7243 int v63; // ecx@76
7244 int v64; // esi@76
7245 int v65; // ecx@83
7246 signed int v66; // [sp+14h] [bp-14h]@3
7247 int v67; // [sp+14h] [bp-14h]@34
7248 int v68; // [sp+14h] [bp-14h]@44
7249 int v69; // [sp+14h] [bp-14h]@54
7250 int v70; // [sp+14h] [bp-14h]@64
7251 signed int v71; // [sp+14h] [bp-14h]@75
7252 IndoorCameraD3D *_this; // [sp+18h] [bp-10h]@1
7253 bool thisa; // [sp+18h] [bp-10h]@9
7254 int thisb; // [sp+18h] [bp-10h]@12
7255 int thisc; // [sp+18h] [bp-10h]@20
7256 bool thisd; // [sp+18h] [bp-10h]@41
7257 bool thise; // [sp+18h] [bp-10h]@61
7258 int thisf; // [sp+18h] [bp-10h]@74
7259 signed int v79; // [sp+1Ch] [bp-Ch]@9
7260 int v80; // [sp+1Ch] [bp-Ch]@76
7261 bool v81; // [sp+20h] [bp-8h]@10
7262 bool v82; // [sp+20h] [bp-8h]@32
7263 bool v83; // [sp+20h] [bp-8h]@42
7264 bool v84; // [sp+20h] [bp-8h]@52
7265 bool v85; // [sp+20h] [bp-8h]@62
7266 signed int v86; // [sp+24h] [bp-4h]@9
7267 signed int v87; // [sp+24h] [bp-4h]@19
7268 signed int v88; // [sp+24h] [bp-4h]@31
7269 signed int v89; // [sp+24h] [bp-4h]@41
7270 signed int v90; // [sp+24h] [bp-4h]@51
7271 signed int v91; // [sp+24h] [bp-4h]@61
7272
7273 pFace = &pIndoor->pFaces[uFaceID];
7274 _this = pGame->pIndoorCameraD3D;
7275 v2 = &pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]];
7276 //v3 = *(_DWORD *)pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].x;
7277 //v4 = pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].z;
7278 v5 = 0;
7279 if ( pFace->pFacePlane_old.vNormal.x * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x)
7280 + pFace->pFacePlane_old.vNormal.y * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y)
7281 + pFace->pFacePlane_old.vNormal.z * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z) < 0 )
7282 {
7283 stru_50B700.field_0 = 1;
7284 }
7285 else
7286 {
7287 stru_50B700.field_0 = 0;
7288 if ( !(pFace->uAttributes & 1) )
7289 return 0;
7290 }
7291 v66 = pFace->uNumVertices;
7292 if ( (signed int)pFace->uNumVertices > 0 )
7293 {
7294 do
7295 {
7296 //v6 = &pIndoor->pVertices[pFace->pVertexIDs[v5]];
7297 pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(
7298 pIndoor->pVertices[pFace->pVertexIDs[v5]].x,
7299 pIndoor->pVertices[pFace->pVertexIDs[v5]].y,
7300 pIndoor->pVertices[pFace->pVertexIDs[v5]].z,
7301 &stru_50B700._view_transformed_xs[v5 + 3],
7302 &stru_50B700._view_transformed_zs[v5 + 3],
7303 &stru_50B700._view_transformed_ys[v5 + 3],
7304 0);
7305 ++v5;
7306 }
7307 while ( v5 < v66 );
7308 }
7309 v7 = v66;
7310 v8 = 0;
7311 if ( v66 <= 0 )
7312 return 0;
7313 do
7314 {
7315 if ( stru_50B700._view_transformed_xs[v8 + 3] >= 524288 )
7316 break;
7317 ++v8;
7318 }
7319 while ( v8 < v66 );
7320 if ( v8 >= v66 )
7321 return 0;
7322 v79 = 0;
7323 stru_50B700._view_transformed_xs[v66 + 3] = stru_50B700._view_transformed_xs[3];
7324 stru_50B700._view_transformed_zs[v66 + 3] = stru_50B700._view_transformed_zs[3];
7325 stru_50B700._view_transformed_ys[v66 + 3] = stru_50B700._view_transformed_ys[3];
7326 thisa = stru_50B700._view_transformed_xs[3] >= 524288;
7327 v86 = 1;
7328 if ( v66 >= 1 )
7329 {
7330 do
7331 {
7332 v9 = v86;
7333 v10 = stru_50B700._view_transformed_xs[v86 + 3];
7334 v81 = v10 >= 524288;
7335 if ( thisa ^ v81 )
7336 {
7337 v11 = stru_50B700._view_transformed_xs[v9 + 2];
7338 if ( v10 >= 524288 )
7339 {
7340 v12 = v10 - v11;
7341 v13 = 524288 - v11;
7342 LODWORD(v14) = v13 << 16;
7343 HIDWORD(v14) = v13 >> 16;
7344 v15 = (char *)&stru_50B700._view_transformed_ys[v9 + 2];
7345 stru_50B700._view_transformed_zs[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[v9 + 3]
7346 - stru_50B700._view_transformed_zs[v9 + 2])
7347 * v14
7348 / v12) >> 16)
7349 + stru_50B700._view_transformed_zs[v9 + 2];
7350 thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[v9 + 3] - stru_50B700._view_transformed_ys[v9 + 2])
7351 * v14
7352 / v12) >> 16;
7353 }
7354 else
7355 {
7356 v16 = v11 - v10;
7357 v17 = 524288 - v10;
7358 LODWORD(v18) = v17 << 16;
7359 HIDWORD(v18) = v17 >> 16;
7360 v15 = (char *)&stru_50B700._view_transformed_ys[v9 + 3];
7361 stru_50B700._view_transformed_zs[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[v9 + 2]
7362 - stru_50B700._view_transformed_zs[v9 + 3])
7363 * v18
7364 / v16) >> 16)
7365 + stru_50B700._view_transformed_zs[v9 + 3];
7366 thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[v9 + 2] - stru_50B700._view_transformed_ys[v9 + 3])
7367 * v18
7368 / v16) >> 16;
7369 }
7370 v19 = v79++;
7371 v7 = v66;
7372 stru_50B700._view_transformed_ys[v19] = thisb + *(_DWORD *)v15;
7373 stru_50B700._view_transformed_xs[v19] = 524288;
7374 }
7375 if ( v81 )
7376 {
7377 v20 = v79++;
7378 stru_50B700._view_transformed_xs[v20] = stru_50B700._view_transformed_xs[v9 + 3];
7379 stru_50B700._view_transformed_zs[v20] = stru_50B700._view_transformed_zs[v9 + 3];
7380 stru_50B700._view_transformed_ys[v20] = stru_50B700._view_transformed_ys[v9 + 3];
7381 }
7382 ++v86;
7383 thisa = v81;
7384 }
7385 while ( v86 <= v7 );
7386 }
7387 v87 = 0;
7388 v21 = v79;
7389 stru_50B700._view_transformed_xs[v79] = stru_50B700._view_transformed_xs[0];
7390 stru_50B700._view_transformed_zs[v79] = stru_50B700._view_transformed_zs[0];
7391 for ( stru_50B700._view_transformed_ys[v79] = stru_50B700._view_transformed_ys[0];
7392 v87 < v79;
7393 stru_50B700._screen_space_y[v22 + 12] = pBLVRenderParams->uViewportCenterY - v35 )
7394 {
7395 v22 = v87;
7396 thisc = abs(stru_50B700._view_transformed_xs[v87]);
7397 if ( abs(stru_50B700._view_transformed_zs[v87]) >> 13 <= thisc )
7398 {
7399 v27 = stru_50B700._view_transformed_zs[v22];
7400 LODWORD(v28) = v27 << 16;
7401 HIDWORD(v28) = v27 >> 16;
7402 v26 = v28 / stru_50B700._view_transformed_xs[v22];
7403 v23 = 0;
7404 }
7405 else
7406 {
7407 v23 = 0;
7408 v24 = 0;
7409 if ( stru_50B700._view_transformed_zs[v22] >= 0 )
7410 {
7411 LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0;
7412 v26 = ((v24 - 1) & 0xFF800000) + 4194304;
7413 }
7414 else
7415 {
7416 LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0;
7417 v25 = v24 - 1;
7418 v26 = (v25 & 0x800000) - 4194304;
7419 }
7420 }
7421 v29 = stru_50B700._view_transformed_ys[v22];
7422 stru_50B700._screen_space_x[v22 + 12] = v26;
7423 if ( abs(v29) >> 13 <= thisc )
7424 {
7425 v33 = stru_50B700._view_transformed_ys[v22];
7426 LODWORD(v34) = v33 << 16;
7427 HIDWORD(v34) = v33 >> 16;
7428 v32 = v34 / stru_50B700._view_transformed_xs[v22];
7429 }
7430 else
7431 {
7432 v30 = 0;
7433 if ( stru_50B700._view_transformed_ys[v22] >= v23 )
7434 {
7435 LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23;
7436 v32 = ((v30 - 1) & 0xFF800000) + 4194304;
7437 }
7438 else
7439 {
7440 LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23;
7441 v31 = v30 - 1;
7442 v32 = (v31 & 0x800000) - 4194304;
7443 }
7444 }
7445 stru_50B700._screen_space_y[v22 + 12] = v32;
7446 stru_50B700._screen_space_x[v22 + 12] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40)
7447 * (signed __int64)stru_50B700._screen_space_x[v22 + 12]) >> 16;
7448 v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)stru_50B700._screen_space_y[v22 + 12]) >> 16;
7449 stru_50B700._screen_space_x[v22 + 12] = pBLVRenderParams->uViewportCenterX - stru_50B700._screen_space_x[v22 + 12];
7450 ++v87;
7451 }
7452 v36 = 0;
7453 stru_50B700._screen_space_x[v21 + 12] = stru_50B700._screen_space_x[12];
7454 stru_50B700._screen_space_y[v21 + 12] = stru_50B700._screen_space_y[12];
7455 v37 = pBLVRenderParams->uViewportX;
7456 v38 = stru_50B700._screen_space_x[12] < (signed int)pBLVRenderParams->uViewportX;
7457 LOBYTE(v38) = stru_50B700._screen_space_x[12] >= (signed int)pBLVRenderParams->uViewportX;
7458 v39 = 1;
7459 v88 = 1;
7460 if ( v79 < 1 )
7461 return 0;
7462 do
7463 {
7464 v40 = v39;
7465 v41 = stru_50B700._screen_space_x[v40 + 12];
7466 v82 = v41 >= (signed int)v37;
7467 if ( v38 ^ v82 )
7468 {
7469 if ( v41 >= (signed int)v37 )
7470 {
7471 v67 = (signed int)(v37 - stru_50B700._screen_space_x[v40 + 11])
7472 * (signed __int64)(stru_50B700._screen_space_y[v40 + 12] - stru_50B700._screen_space_y[v40 + 11])
7473 / (v41 - stru_50B700._screen_space_x[v40 + 11]);
7474 v42 = stru_50B700._screen_space_y[v40 + 11];
7475 }
7476 else
7477 {
7478 v67 = (signed int)(v37 - v41)
7479 * (signed __int64)(stru_50B700._screen_space_y[v40 + 11] - stru_50B700._screen_space_y[v40 + 12])
7480 / (stru_50B700._screen_space_x[v40 + 11] - v41);
7481 v42 = stru_50B700._screen_space_y[v40 + 12];
7482 }
7483 ++v36;
7484 stru_50B700._screen_space_y[v36 + 8] = v67 + v42;
7485 v37 = pBLVRenderParams->uViewportX;
7486 stru_50B700._screen_space_x[v36 + 8] = pBLVRenderParams->uViewportX;
7487 }
7488 v38 = v82;
7489 if ( v82 )
7490 {
7491 stru_50B700._screen_space_x[v36 + 9] = stru_50B700._screen_space_x[v40 + 12];
7492 stru_50B700._screen_space_y[v36++ + 9] = stru_50B700._screen_space_y[v40 + 12];
7493 }
7494 v39 = v88++ + 1;
7495 }
7496 while ( v88 <= v79 );
7497 if ( !v36
7498 || (v43 = 0,
7499 stru_50B700._screen_space_x[v36 + 9] = stru_50B700._screen_space_x[9],
7500 stru_50B700._screen_space_y[v36 + 9] = stru_50B700._screen_space_y[9],
7501 v44 = pBLVRenderParams->uViewportZ,
7502 thisd = stru_50B700._screen_space_x[9] <= (signed int)pBLVRenderParams->uViewportZ,
7503 v89 = 1,
7504 v36 < 1) )
7505 return 0;
7506 do
7507 {
7508 v45 = v89;
7509 v46 = stru_50B700._screen_space_x[v89 + 9];
7510 v83 = v46 <= (signed int)v44;
7511 if ( thisd ^ v83 )
7512 {
7513 if ( v46 <= (signed int)v44 )
7514 {
7515 v68 = (signed int)(v44 - stru_50B700._screen_space_x[v45 + 8])
7516 * (signed __int64)(stru_50B700._screen_space_y[v45 + 9] - stru_50B700._screen_space_y[v45 + 8])
7517 / (v46 - stru_50B700._screen_space_x[v45 + 8]);
7518 v47 = stru_50B700._screen_space_y[v45 + 8];
7519 }
7520 else
7521 {
7522 v68 = (signed int)(v44 - v46)
7523 * (signed __int64)(stru_50B700._screen_space_y[v45 + 8] - stru_50B700._screen_space_y[v45 + 9])
7524 / (stru_50B700._screen_space_x[v45 + 8] - v46);
7525 v47 = stru_50B700._screen_space_y[v45 + 9];
7526 }
7527 ++v43;
7528 stru_50B700._screen_space_y[v43 + 5] = v68 + v47;
7529 v44 = pBLVRenderParams->uViewportZ;
7530 stru_50B700._screen_space_x[v43 + 5] = pBLVRenderParams->uViewportZ;
7531 }
7532 if ( v83 )
7533 {
7534 stru_50B700._screen_space_x[v43 + 6] = stru_50B700._screen_space_x[v45 + 9];
7535 stru_50B700._screen_space_y[v43++ + 6] = stru_50B700._screen_space_y[v45 + 9];
7536 }
7537 ++v89;
7538 thisd = v83;
7539 }
7540 while ( v89 <= v36 );
7541 if ( !v43
7542 || (v48 = 0,
7543 stru_50B700._screen_space_x[v43 + 6] = stru_50B700._screen_space_x[6],
7544 stru_50B700._screen_space_y[v43 + 6] = stru_50B700._screen_space_y[6],
7545 v49 = pBLVRenderParams->uViewportY,
7546 v50 = stru_50B700._screen_space_y[6] < (signed int)pBLVRenderParams->uViewportY,
7547 LOBYTE(v50) = stru_50B700._screen_space_y[6] >= (signed int)pBLVRenderParams->uViewportY,
7548 v51 = 1,
7549 v90 = 1,
7550 v43 < 1) )
7551 return 0;
7552 do
7553 {
7554 v52 = v51;
7555 v53 = stru_50B700._screen_space_y[v52 + 6];
7556 v84 = v53 >= (signed int)v49;
7557 if ( v50 ^ v84 )
7558 {
7559 if ( v53 >= (signed int)v49 )
7560 {
7561 v69 = (signed int)(v49 - stru_50B700._screen_space_y[v52 + 5])
7562 * (signed __int64)(stru_50B700._screen_space_x[v52 + 6] - stru_50B700._screen_space_x[v52 + 5])
7563 / (v53 - stru_50B700._screen_space_y[v52 + 5]);
7564 v54 = stru_50B700._screen_space_x[v52 + 5];
7565 }
7566 else
7567 {
7568 v69 = (signed int)(v49 - v53)
7569 * (signed __int64)(stru_50B700._screen_space_x[v52 + 5] - stru_50B700._screen_space_x[v52 + 6])
7570 / (stru_50B700._screen_space_y[v52 + 5] - v53);
7571 v54 = stru_50B700._screen_space_x[v52 + 6];
7572 }
7573 ++v48;
7574 stru_50B700._screen_space_x[v48 + 2] = v69 + v54;
7575 v49 = pBLVRenderParams->uViewportY;
7576 stru_50B700._screen_space_y[v48 + 2] = pBLVRenderParams->uViewportY;
7577 }
7578 v50 = v84;
7579 if ( v84 )
7580 {
7581 stru_50B700._screen_space_x[v48 + 3] = stru_50B700._screen_space_x[v52 + 6];
7582 stru_50B700._screen_space_y[v48++ + 3] = stru_50B700._screen_space_y[v52 + 6];
7583 }
7584 v51 = v90++ + 1;
7585 }
7586 while ( v90 <= v43 );
7587 if ( !v48
7588 || (v55 = 0,
7589 stru_50B700._screen_space_x[v48 + 3] = stru_50B700._screen_space_x[3],
7590 stru_50B700._screen_space_y[v48 + 3] = stru_50B700._screen_space_y[3],
7591 v56 = pBLVRenderParams->uViewportW,
7592 thise = stru_50B700._screen_space_y[3] <= (signed int)pBLVRenderParams->uViewportW,
7593 v91 = 1,
7594 v48 < 1) )
7595 return 0;
7596 do
7597 {
7598 v57 = v91;
7599 v58 = stru_50B700._screen_space_y[v91 + 3];
7600 v85 = v58 <= (signed int)v56;
7601 if ( thise ^ v85 )
7602 {
7603 if ( v58 <= (signed int)v56 )
7604 {
7605 v70 = (signed int)(v56 - stru_50B700._screen_space_y[v57 + 2])
7606 * (signed __int64)(stru_50B700._screen_space_x[v57 + 3] - stru_50B700._screen_space_x[v57 + 2])
7607 / (v58 - stru_50B700._screen_space_y[v57 + 2]);
7608 v59 = stru_50B700._screen_space_x[v57 + 2];
7609 }
7610 else
7611 {
7612 v70 = (signed int)(v56 - v58)
7613 * (signed __int64)(stru_50B700._screen_space_x[v57 + 2] - stru_50B700._screen_space_x[v57 + 3])
7614 / (stru_50B700._screen_space_y[v57 + 2] - v58);
7615 v59 = stru_50B700._screen_space_x[v57 + 3];
7616 }
7617 ++v55;
7618 //stru_50B700._screen_space_y[v55 + 59] = v70 + v59;
7619 stru_50B700._screen_space_x[v55 - 1] = v70 + v59;
7620 v56 = pBLVRenderParams->uViewportW;
7621 //stru_50B700._view_transformed_xs[v55 + 47] = pBLVRenderParams->uViewportW;
7622 stru_50B700._screen_space_y[v55 - 1] = pBLVRenderParams->uViewportW;
7623 }
7624 if ( v85 )
7625 {
7626 stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[v57 + 3];
7627 stru_50B700._screen_space_y[v55++] = stru_50B700._screen_space_y[v57 + 3];
7628 }
7629 ++v91;
7630 thise = v85;
7631 }
7632 while ( v91 <= v48 );
7633 if ( !v55 )
7634 return 0;
7635 v61 = pRenderer->pRenderD3D == 0;
7636 stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0];
7637 stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0];
7638 if ( v61 && v55 > 3 )
7639 {
7640 stru_50B700._screen_space_x[v55 + 1] = stru_50B700._screen_space_x[1];
7641 stru_50B700._screen_space_y[v55 + 1] = stru_50B700._screen_space_y[1];
7642 thisf = 2 * (stru_50B700.field_0 != 0) - 1;
7643 if ( v55 > 0 )
7644 {
7645 v62 = 1;
7646 v71 = 1;
7647 do
7648 {
7649 v63 = v62 - 1;
7650 v64 = v62 + 1;
7651 v80 = v62 + 1;
7652 if ( v62 - 1 >= v55 )
7653 v63 -= v55;
7654 if ( v62 >= v55 )
7655 v62 -= v55;
7656 if ( v64 >= v55 )
7657 v64 -= v55;
7658 if ( thisf
7659 * ((stru_50B700._screen_space_y[v64] - stru_50B700._screen_space_y[v63])
7660 * (stru_50B700._screen_space_x[v62] - stru_50B700._screen_space_x[v63])
7661 - (stru_50B700._screen_space_y[v62] - stru_50B700._screen_space_y[v63])
7662 * (stru_50B700._screen_space_x[v64] - stru_50B700._screen_space_x[v63])) < 0 )
7663 {
7664 v62 = v80;
7665 v71 = v80;
7666 }
7667 else
7668 {
7669 v62 = v71;
7670 v65 = v71;
7671 if ( v71 < v55 || (v65 = v71 - v55, v71 - v55 < v55) )
7672 {
7673 memcpy(
7674 &stru_50B700._screen_space_y[v65],
7675 &stru_50B700._screen_space_y[v65 + 1],
7676 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
7677 memcpy(
7678 &stru_50B700._screen_space_x[v65],
7679 &stru_50B700._screen_space_x[v65 + 1],
7680 4 * ((unsigned int)(4 * (v55 - v65)) >> 2));
7681 }
7682 --v55;
7683 }
7684 }
7685 while ( v62 - 1 < v55 );
7686 }
7687 stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0];
7688 stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0];
7689 }
7690 return v55;
7691 }