comparison mm7_4.cpp @ 1572:19f1735fca80

Слияние
author Ritor1
date Sun, 08 Sep 2013 17:07:58 +0600
parents 9f8b3e904e14
children d3d539924e5e 75fafd8ced59 a52a01aaf439
comparison
equal deleted inserted replaced
1571:ef20d4608b1a 1572:19f1735fca80
1 #ifdef _MSC_VER 1 #ifdef _MSC_VER
2 #define _CRT_SECURE_NO_WARNINGS 2 #define _CRT_SECURE_NO_WARNINGS
3 #endif 3 #endif
4
5 #include <assert.h>
6 4
7 #include "Texture.h" 5 #include "Texture.h"
8 #include "mm7_data.h" 6 #include "mm7_data.h"
9 #include "VideoPlayer.h" 7 #include "VideoPlayer.h"
10 #include "Sprites.h" 8 #include "Sprites.h"
47 #include "Lights.h" 45 #include "Lights.h"
48 46
49 //----- (0046CC4B) -------------------------------------------------------- 47 //----- (0046CC4B) --------------------------------------------------------
50 void check_event_triggers() 48 void check_event_triggers()
51 { 49 {
52 int v0; // eax@1
53 LevelDecoration *v1; // esi@2 50 LevelDecoration *v1; // esi@2
54 signed int v2; // edi@2 51
55 int v3; // ebx@2 52 for (size_t i = 0; i < num_event_triggers; i++)
56 int v4; // eax@3 53 {
57 int v5; // ebx@3 54 v1 = &pLevelDecorations[event_triggers[i]];
58 unsigned int v6; // ecx@3 55
59 unsigned int v7; // edx@6 56 if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_TOUCH
60 unsigned int v8; // edx@8 57 && v1->vPosition.GetDistanceTo(pParty->vPosition) < v1->uTriggerRange)
61 Actor *v9; // edi@13 58 {
62 int v10; // ebx@14 59 EventProcessor(v1->uEventID, PID(OBJECT_Decoration,i), 1);
63 int v11; // eax@14 60 }
64 int v12; // ebx@14 61 else if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_MONSTER)
65 unsigned int v13; // ecx@14 62 {
66 int v14; // edx@15 63 for (size_t j = 0; j < uNumActors; j++)
67 unsigned int v15; // edx@17 64 {
68 unsigned int v16; // edx@19 65 if (v1->vPosition.GetDistanceTo(pActors[j].vPosition) < v1->uTriggerRange)
69 char *v17; // edi@25 66 EventProcessor(v1->uEventID, 0, 1);
70 int v18; // ebx@26 67 }
71 int v19; // eax@26 68 }
72 int v20; // ebx@26 69 else if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_OBJECT)
73 unsigned int v21; // ecx@26 70 {
74 int v22; // edx@27 71 for (size_t j = 0; j < uNumSpriteObjects; j++)
75 unsigned int v23; // edx@29 72 {
76 unsigned int v24; // edx@31 73 if (v1->vPosition.GetDistanceTo(pSpriteObjects[j].vPosition) < v1->uTriggerRange)
77 int v25; // [sp+0h] [bp-24h]@3 74 EventProcessor(v1->uEventID, 0, 1);
78 int v26; // [sp+0h] [bp-24h]@14 75 }
79 int v27; // [sp+0h] [bp-24h]@26 76 }
80 int v28; // [sp+4h] [bp-20h]@3
81 int v29; // [sp+4h] [bp-20h]@14
82 int v30; // [sp+4h] [bp-20h]@26
83 signed int v31; // [sp+8h] [bp-1Ch]@2
84 int v32; // [sp+Ch] [bp-18h]@2
85 int v33; // [sp+10h] [bp-14h]@2
86 int i; // [sp+14h] [bp-10h]@1
87 int v35; // [sp+18h] [bp-Ch]@2
88 int v36; // [sp+1Ch] [bp-8h]@3
89 signed int v37; // [sp+1Ch] [bp-8h]@12
90 signed int v38; // [sp+20h] [bp-4h]@24
91
92 v0 = 0;
93 for ( i = 0; i < num_event_triggers; ++i )
94 {
95 v1 = &pLevelDecorations[event_triggers[v0]];
96 v2 = v1->field_18;
97 v3 = v1->vPosition.y;
98 v33 = v1->vPosition.x;
99 v32 = v1->vPosition.y;
100 v35 = v1->vPosition.z;
101 v31 = v1->field_18;
102 if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_TOUCH)
103 {
104 v36 = abs(v1->vPosition.x - pParty->vPosition.x);
105 v25 = abs(v3 - pParty->vPosition.y);
106 v28 = abs(v35 - pParty->vPosition.z);
107 v4 = v36;
108 v5 = v25;
109 v6 = v28;
110 if ( v36 < v25 )
111 {
112 v4 = v25;
113 v5 = v36;
114 }
115 if ( v4 < v28 )
116 {
117 v7 = v4;
118 v4 = v28;
119 v6 = v7;
120 }
121 if ( v5 < (signed int)v6 )
122 {
123 v8 = v6;
124 v6 = v5;
125 v5 = v8;
126 }
127 if ( (signed int)(((unsigned int)(11 * v5) >> 5) + (v6 >> 2) + v4) < v2 )
128 EventProcessor(v1->field_16_event_id, PID(OBJECT_Decoration,i), 1);
129 }
130 if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_MONSTER)
131 {
132 v37 = 0;
133 if ( (signed int)uNumActors > 0 )
134 {
135 v9 = pActors.data();//[0].vPosition.y;
136 do
137 {
138 v10 = abs(v33 - v9->vPosition.x);
139 v29 = abs(v32 - v9->vPosition.y);
140 v26 = abs(v35 - v9->vPosition.z);
141 v11 = v10;
142 v12 = v29;
143 v13 = v26;
144 if ( v11 < v29 )
145 {
146 v14 = v11;
147 v11 = v29;
148 v12 = v14;
149 }
150 if ( v11 < v26 )
151 {
152 v15 = v11;
153 v11 = v26;
154 v13 = v15;
155 }
156 if ( v12 < (signed int)v13 )
157 {
158 v16 = v13;
159 v13 = v12;
160 v12 = v16;
161 }
162 if ( (signed int)(((unsigned int)(11 * v12) >> 5) + (v13 >> 2) + v11) < v31 )
163 EventProcessor(v1->field_16_event_id, 0, 1);
164 ++v37;
165 ++v9;
166 }
167 while ( v37 < (signed int)uNumActors );
168 }
169 }
170 if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_OBJECT)
171 {
172 v38 = 0;
173 if ( (signed int)uNumSpriteObjects > 0 )
174 {
175 v17 = (char *)&pSpriteObjects[0].vPosition.y;
176 do
177 {
178 v18 = abs(v33 - *((int *)v17 - 1));
179 v30 = abs(v32 - *(int *)v17);
180 v27 = abs(v35 - *((int *)v17 + 1));
181 v19 = v18;
182 v20 = v30;
183 v21 = v27;
184 if ( v19 < v30 )
185 {
186 v22 = v19;
187 v19 = v30;
188 v20 = v22;
189 }
190 if ( v19 < v27 )
191 {
192 v23 = v19;
193 v19 = v27;
194 v21 = v23;
195 }
196 if ( v20 < (signed int)v21 )
197 {
198 v24 = v21;
199 v21 = v20;
200 v20 = v24;
201 }
202 if ( (signed int)(((unsigned int)(11 * v20) >> 5) + (v21 >> 2) + v19) < v31 )
203 EventProcessor(v1->field_16_event_id, 0, 1);
204 ++v38;
205 v17 += 112;
206 }
207 while ( v38 < (signed int)uNumSpriteObjects );
208 }
209 }
210 v0 = i + 1;
211 } 77 }
212 } 78 }
213 // 6836C8: using guessed type int 6836C8_num_decorations_6807E8; 79 // 6836C8: using guessed type int 6836C8_num_decorations_6807E8;
214 80
215 //----- (0046D8E3) -------------------------------------------------------- 81 //----- (0046D8E3) --------------------------------------------------------
490 if ( stru_721530.sMinZ >= v7 ) 356 if ( stru_721530.sMinZ >= v7 )
491 { 357 {
492 v16 = v4 - stru_721530.normal.x; 358 v16 = v4 - stru_721530.normal.x;
493 v15 = v5 - stru_721530.normal.y; 359 v15 = v5 - stru_721530.normal.y;
494 v8 = stru_721530.prolly_normal_d + v3; 360 v8 = stru_721530.prolly_normal_d + v3;
495 v17 = ((v4 - stru_721530.normal.x) * stru_721530.field_58.y 361 v17 = ((v4 - stru_721530.normal.x) * stru_721530.direction.y
496 - (v5 - stru_721530.normal.y) * stru_721530.field_58.x) >> 16; 362 - (v5 - stru_721530.normal.y) * stru_721530.direction.x) >> 16;
497 if ( abs(v17) <= stru_721530.prolly_normal_d + v3 ) 363 if ( abs(v17) <= stru_721530.prolly_normal_d + v3 )
498 { 364 {
499 v9 = (v16 * stru_721530.field_58.x + v15 * stru_721530.field_58.y) >> 16; 365 v9 = (v16 * stru_721530.direction.x + v15 * stru_721530.direction.y) >> 16;
500 if ( v9 > 0 ) 366 if ( v9 > 0 )
501 { 367 {
502 v10 = v1->vPosition.z; 368 v10 = v1->vPosition.z;
503 v11 = stru_721530.normal.z 369 v11 = stru_721530.normal.z + fixpoint_sub0(stru_721530.direction.z, v9);
504 + ((unsigned __int64)(stru_721530.field_58.z * (signed __int64)v9) >> 16);
505 if ( v11 >= v10 ) 370 if ( v11 >= v10 )
506 { 371 {
507 if ( v11 <= v18 + v10 ) 372 if ( v11 <= v18 + v10 )
508 { 373 {
509 v12 = v9 - integer_sqrt(v8 * v8 - v17 * v17); 374 v12 = v9 - integer_sqrt(v8 * v8 - v17 * v17);
1688 1553
1689 v1 = Str; 1554 v1 = Str;
1690 v2 = fopen("data\\dpft.bin", "wb"); 1555 v2 = fopen("data\\dpft.bin", "wb");
1691 v3 = v2; 1556 v3 = v2;
1692 if ( !v2 ) 1557 if ( !v2 )
1693 Abortf("Unable to save dpft.bin!"); 1558 Error("Unable to save dpft.bin");
1694 fwrite(v1, 4u, 1u, v2); 1559 fwrite(v1, 4u, 1u, v2);
1695 fwrite(v1->pFrames, 0xAu, v1->uNumFrames, v3); 1560 fwrite(v1->pFrames, 0xAu, v1->uNumFrames, v3);
1696 fclose(v3); 1561 fclose(v3);
1697 } 1562 }
1698 1563
1745 v2 = this; 1610 v2 = this;
1746 //TileTable::dtor((TileTable *)this); 1611 //TileTable::dtor((TileTable *)this);
1747 v3 = fopen(Args, "r"); 1612 v3 = fopen(Args, "r");
1748 File = v3; 1613 File = v3;
1749 if ( !v3 ) 1614 if ( !v3 )
1750 Abortf("PlayerFrameTable::load - Unable to open file: %s.", Args); 1615 Error("PlayerFrameTable::load - Unable to open file: %s.", Args);
1751 v4 = 0; 1616 v4 = 0;
1752 v25 = 0; 1617 v25 = 0;
1753 v26 = 1; 1618 v26 = 1;
1754 if ( fgets(&Buf, 490, v3) ) 1619 if ( fgets(&Buf, 490, v3) )
1755 { 1620 {
1758 *strchr(&Buf, 10) = 0; 1623 *strchr(&Buf, 10) = 0;
1759 memcpy(&v24, txt_file_frametable_parser(&Buf, &v23), sizeof(v24)); 1624 memcpy(&v24, txt_file_frametable_parser(&Buf, &v23), sizeof(v24));
1760 if ( v24.uPropCount && *v24.pProperties[0] != 47 ) 1625 if ( v24.uPropCount && *v24.pProperties[0] != 47 )
1761 { 1626 {
1762 if ( v24.uPropCount < 3 ) 1627 if ( v24.uPropCount < 3 )
1763 Abortf("PlayerFrameTable::load, too few arguments, %s line %i.", Args, v26); 1628 Error("PlayerFrameTable::load, too few arguments, %s line %i.", Args, v26);
1764 ++v25; 1629 ++v25;
1765 } 1630 }
1766 ++v26; 1631 ++v26;
1767 } 1632 }
1768 while ( fgets(&Buf, 490, File) ); 1633 while ( fgets(&Buf, 490, File) );
1770 } 1635 }
1771 v2->uNumFrames = v4; 1636 v2->uNumFrames = v4;
1772 v5 = pAllocator->AllocNamedChunk(v2->pFrames, 10 * v4, "P Frames"); 1637 v5 = pAllocator->AllocNamedChunk(v2->pFrames, 10 * v4, "P Frames");
1773 v2->pFrames = (PlayerFrame *)v5; 1638 v2->pFrames = (PlayerFrame *)v5;
1774 if ( !v5 ) 1639 if ( !v5 )
1775 Abortf("PlayerFrameTable::load - Out of Memory!"); 1640 Error("PlayerFrameTable::load - Out of Memory!");
1776 v6 = File; 1641 v6 = File;
1777 v2->uNumFrames = 0; 1642 v2->uNumFrames = 0;
1778 fseek(v6, 0, 0); 1643 fseek(v6, 0, 0);
1779 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) 1644 for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) )
1780 { 1645 {
2188 case 27:// 2053 case 27://
2189 v29 = pPlayer->GetBuyingPrice(a3->GetValue(), p2DEvents[(signed int)a4 - 1].fPriceMultiplier); 2054 v29 = pPlayer->GetBuyingPrice(a3->GetValue(), p2DEvents[(signed int)a4 - 1].fPriceMultiplier);
2190 if ( a5 == 3 ) 2055 if ( a5 == 3 )
2191 { 2056 {
2192 v29 = pPlayer->GetPriceSell(a3->GetValue(), p2DEvents[(signed int)a4 - 1].fPriceMultiplier); 2057 v29 = pPlayer->GetPriceSell(a3->GetValue(), p2DEvents[(signed int)a4 - 1].fPriceMultiplier);
2193 if (a3->Broken()) 2058 if (a3->IsBroken())
2194 v29 = 1; 2059 v29 = 1;
2195 sprintfex(a1, "%lu", v29); 2060 sprintfex(a1, "%lu", v29);
2196 strcat(pTmpBuf2.data(), a1); 2061 strcat(pTmpBuf2.data(), a1);
2197 dst = strlen(pTmpBuf2.data()); 2062 dst = strlen(pTmpBuf2.data());
2198 i += 2; 2063 i += 2;
2205 else 2070 else
2206 { 2071 {
2207 if ( a5 == 6 ) 2072 if ( a5 == 6 )
2208 { 2073 {
2209 v29 = pPlayer->GetPriceSell(a3->GetValue(), p2DEvents[(signed int)a4 - 1].fPriceMultiplier) / 2; 2074 v29 = pPlayer->GetPriceSell(a3->GetValue(), p2DEvents[(signed int)a4 - 1].fPriceMultiplier) / 2;
2210 if (a3->Broken()) 2075 if (a3->IsBroken())
2211 v29 = 1; 2076 v29 = 1;
2212 if (!v29) 2077 if (!v29)
2213 v29 = 1; 2078 v29 = 1;
2214 sprintfex(a1, "%lu", v29); 2079 sprintfex(a1, "%lu", v29);
2215 strcat(pTmpBuf2.data(), a1); 2080 strcat(pTmpBuf2.data(), a1);
3759 { 3624 {
3760 case 139: 3625 case 139:
3761 OracleDialogue(); 3626 OracleDialogue();
3762 break; 3627 break;
3763 case 311: 3628 case 311:
3764 sub_4BBA85_bounties(); 3629 CheckBountyRespawnAndAward();
3765 break; 3630 break;
3766 case 399: 3631 case 399:
3767 __debugbreak(); // what kind of dialogue is that? 3632 __debugbreak(); // what kind of dialogue is that?
3768 sub_4BBCDD(); 3633 sub_4BBCDD();
3769 break; 3634 break;
3791 char v10; // sf@16 3656 char v10; // sf@16
3792 unsigned __int8 v11; // of@16 3657 unsigned __int8 v11; // of@16
3793 bool test; 3658 bool test;
3794 3659
3795 if ( (p2DEvents[_2da_idx - 1].uType != 4 || (signed int)item->uItemID < 740 || (signed int)item->uItemID > 771) 3660 if ( (p2DEvents[_2da_idx - 1].uType != 4 || (signed int)item->uItemID < 740 || (signed int)item->uItemID > 771)
3796 && ((signed int)item->uItemID >= 600 || (signed int)item->uItemID >= 529 && (signed int)item->uItemID <= 599) || item->Stolen()) 3661 && ((signed int)item->uItemID >= 600 || (signed int)item->uItemID >= 529 && (signed int)item->uItemID <= 599) || item->IsStolen())
3797 return 0; 3662 return 0;
3798 switch( p2DEvents[_2da_idx - 1].uType ) 3663 switch( p2DEvents[_2da_idx - 1].uType )
3799 { 3664 {
3800 case BuildingType_WeaponShop: 3665 case BuildingType_WeaponShop:
3801 { 3666 {