Mercurial > mm7
annotate mm7_3.cpp @ 2138:7cc14d9d966d
1
author | Ritor1 |
---|---|
date | Thu, 02 Jan 2014 09:11:01 +0600 |
parents | 87be06553c76 |
children | f9b55be70c1b |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
4 |
1323 | 5 #include "Weather.h" |
1262 | 6 #include "Texture.h" |
7 #include "mm7_data.h" | |
1016 | 8 #include "Sprites.h" |
9 #include "BSPModel.h" | |
10 #include "LightmapBuilder.h" | |
11 #include "DecalBuilder.h" | |
12 #include "ParticleEngine.h" | |
13 #include "Mouse.h" | |
14 #include "Keyboard.h" | |
15 #include "stru6.h" | |
1263 | 16 #include "FactionTable.h" |
0 | 17 #include "MapInfo.h" |
18 #include "Game.h" | |
19 #include "GUIWindow.h" | |
20 #include "GUIFont.h" | |
21 #include "GUIProgressBar.h" | |
22 #include "Party.h" | |
23 #include "AudioPlayer.h" | |
24 #include "Outdoor.h" | |
1277 | 25 #include "Outdoor_stuff.h" |
0 | 26 #include "Overlays.h" |
27 #include "LOD.h" | |
28 #include "Actor.h" | |
29 #include "Events.h" | |
30 #include "Viewport.h" | |
2037
7a9477135943
Renamed Math.h -> OurMath.h (file resolution was sometimes ambiguous)
Nomad
parents:
2030
diff
changeset
|
31 #include "OurMath.h" |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
32 #include "SpriteObject.h" |
0 | 33 #include "ObjectList.h" |
34 #include "PaletteManager.h" | |
35 #include "DecorationList.h" | |
36 #include "stru123.h" | |
2044 | 37 #include "Timer.h" |
0 | 38 #include "IconFrameTable.h" |
39 #include "TurnEngine.h" | |
40 #include "Events2D.h" | |
41 #include "stru176.h" | |
42 #include "stru298.h" | |
189 | 43 #include "texts.h" |
0 | 44 #include "Log.h" |
1262 | 45 #include "Lights.h" |
1828
35c1e4ff6ba7
party_finds_gold to Party::PartyFindsGold, cleaned up, moved Level/Decoration.h reference out of Indoor.h
Grumpy7
parents:
1813
diff
changeset
|
46 #include "Level/Decoration.h" |
828
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
47 |
0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
Nomad
parents:
824
diff
changeset
|
48 #include "MM7.h" |
0 | 49 |
50 //----- (0046E44E) -------------------------------------------------------- | |
1458 | 51 int _46E44E_collide_against_faces_and_portals(unsigned int b1) |
0 | 52 { |
717 | 53 BLVSector *pSector; // edi@1 |
0 | 54 signed int v2; // ebx@1 |
717 | 55 BLVFace *pFace; // esi@2 |
56 __int16 pNextSector; // si@10 | |
57 int pArrayNum; // ecx@12 | |
0 | 58 unsigned __int8 v6; // sf@12 |
59 unsigned __int8 v7; // of@12 | |
60 int result; // eax@14 | |
2138 | 61 //int v10; // ecx@15 |
717 | 62 int pFloor; // eax@16 |
0 | 63 int v15; // eax@24 |
64 int v16; // edx@25 | |
65 int v17; // eax@29 | |
66 unsigned int v18; // eax@33 | |
67 int v21; // eax@35 | |
68 int v22; // ecx@36 | |
69 int v23; // eax@40 | |
70 unsigned int v24; // eax@44 | |
71 int a3; // [sp+10h] [bp-48h]@28 | |
72 int v26; // [sp+14h] [bp-44h]@15 | |
73 int i; // [sp+18h] [bp-40h]@1 | |
74 int a10; // [sp+1Ch] [bp-3Ch]@1 | |
75 int v29; // [sp+20h] [bp-38h]@14 | |
76 int v32; // [sp+2Ch] [bp-2Ch]@15 | |
717 | 77 int pSectorsArray[10]; // [sp+30h] [bp-28h]@1 |
78 | |
79 pSector = &pIndoor->pSectors[stru_721530.uSectorID]; | |
2138 | 80 i = 1; |
0 | 81 a10 = b1; |
717 | 82 pSectorsArray[0] = stru_721530.uSectorID; |
2138 | 83 for ( v2 = 0; v2 < pSector->uNumPortals; ++v2 ) |
717 | 84 { |
85 pFace = &pIndoor->pFaces[pSector->pPortals[v2]]; | |
2138 | 86 if ( stru_721530.sMaxX <= pFace->pBounding.x2 && stru_721530.sMinX >= pFace->pBounding.x1 |
87 && stru_721530.sMaxY <= pFace->pBounding.y2 && stru_721530.sMinY >= pFace->pBounding.y1 | |
88 && stru_721530.sMaxZ <= pFace->pBounding.z2 && stru_721530.sMinZ >= pFace->pBounding.z1 | |
717 | 89 && abs((pFace->pFacePlane_old.dist |
90 + stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x | |
91 + stru_721530.normal.y * pFace->pFacePlane_old.vNormal.y | |
92 + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z) >> 16) <= stru_721530.field_6C + 16 ) | |
93 { | |
94 pNextSector = pFace->uSectorID == stru_721530.uSectorID ? pFace->uBackSectorID : pFace->uSectorID;//FrontSectorID | |
95 pArrayNum = i++; | |
96 v7 = i < 10; | |
0 | 97 v6 = i - 10 < 0; |
717 | 98 pSectorsArray[pArrayNum] = pNextSector; |
0 | 99 if ( !(v6 ^ v7) ) |
100 break; | |
101 } | |
102 } | |
103 result = 0; | |
2138 | 104 for ( v29 = 0; v29 < i; v29++ ) |
0 | 105 { |
2138 | 106 pSector = &pIndoor->pSectors[pSectorsArray[v29]]; |
107 v32 = pSector->uNumFloors + pSector->uNumWalls + pSector->uNumCeilings; | |
108 for ( v26 = 0; v26 < v32; v26++ ) | |
0 | 109 { |
2138 | 110 pFloor = pSector->pFloors[v26]; |
111 pFace = &pIndoor->pFaces[pSector->pFloors[v26]]; | |
112 if ( !pFace->Portal() | |
113 && stru_721530.sMaxX <= pFace->pBounding.x2 && stru_721530.sMinX >= pFace->pBounding.x1 | |
114 && stru_721530.sMaxY <= pFace->pBounding.y2 && stru_721530.sMinY >= pFace->pBounding.y1 | |
115 && stru_721530.sMaxZ <= pFace->pBounding.z2 && stru_721530.sMinZ >= pFace->pBounding.z1 | |
116 && pFloor != stru_721530.field_84 ) | |
117 { | |
118 v15 = ( pFace->pFacePlane_old.dist + stru_721530.normal.x * pFace->pFacePlane_old.vNormal.x | |
119 + stru_721530.normal.y * pFace->pFacePlane_old.vNormal.y | |
120 + stru_721530.normal.z * pFace->pFacePlane_old.vNormal.z ) >> 16; | |
0 | 121 if ( v15 > 0 ) |
122 { | |
2138 | 123 v16 = ( pFace->pFacePlane_old.dist + stru_721530.normal2.x * pFace->pFacePlane_old.vNormal.x |
124 + stru_721530.normal2.y * pFace->pFacePlane_old.vNormal.y | |
125 + stru_721530.normal2.z * pFace->pFacePlane_old.vNormal.z ) >> 16; | |
0 | 126 if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d ) |
127 { | |
128 if ( v16 <= v15 ) | |
129 { | |
130 a3 = stru_721530.field_6C; | |
717 | 131 if ( sub_47531C(stru_721530.prolly_normal_d, &a3, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z, |
2138 | 132 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10) ) |
0 | 133 { |
134 v17 = a3; | |
135 } | |
136 else | |
137 { | |
138 a3 = stru_721530.field_6C + stru_721530.prolly_normal_d; | |
1546 | 139 if ( !sub_475D85(&stru_721530.normal, &stru_721530.direction, &a3, pFace) ) |
0 | 140 goto LABEL_34; |
141 v17 = a3 - stru_721530.prolly_normal_d; | |
142 a3 -= stru_721530.prolly_normal_d; | |
143 } | |
144 if ( v17 < stru_721530.field_7C ) | |
145 { | |
146 stru_721530.field_7C = v17; | |
717 | 147 v18 = 8 * pSector->pFloors[v26]; |
0 | 148 LOBYTE(v18) = v18 | 6; |
149 stru_721530.uFaceID = v18; | |
150 } | |
151 } | |
152 } | |
153 } | |
154 LABEL_34: | |
155 if ( !(stru_721530.field_0 & 1) | |
2138 | 156 || (v21 = ( pFace->pFacePlane_old.dist + stru_721530.position.x * pFace->pFacePlane_old.vNormal.x |
157 + stru_721530.position.y * pFace->pFacePlane_old.vNormal.y | |
158 + stru_721530.position.z * pFace->pFacePlane_old.vNormal.z) >> 16, v21 <= 0) | |
159 || (v22 = ( pFace->pFacePlane_old.dist + stru_721530.field_4C * pFace->pFacePlane_old.vNormal.x | |
160 + stru_721530.field_50 * pFace->pFacePlane_old.vNormal.y | |
161 + stru_721530.field_54 * pFace->pFacePlane_old.vNormal.z) >> 16, v21 > stru_721530.prolly_normal_d) | |
162 && v22 > stru_721530.prolly_normal_d || v22 > v21 ) | |
163 continue; | |
0 | 164 a3 = stru_721530.field_6C; |
1546 | 165 if ( sub_47531C(stru_721530.field_8_radius, &a3, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z, |
166 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, pFace, a10) ) | |
0 | 167 { |
168 v23 = a3; | |
169 goto LABEL_43; | |
170 } | |
1546 | 171 a3 = stru_721530.field_6C + stru_721530.field_8_radius; |
172 if ( sub_475D85(&stru_721530.position, &stru_721530.direction, &a3, pFace) ) | |
0 | 173 { |
174 v23 = a3 - stru_721530.prolly_normal_d; | |
175 a3 -= stru_721530.prolly_normal_d; | |
176 LABEL_43: | |
177 if ( v23 < stru_721530.field_7C ) | |
178 { | |
179 stru_721530.field_7C = v23; | |
717 | 180 v24 = 8 * pSector->pFloors[v26]; |
0 | 181 LOBYTE(v24) = v24 | 6; |
182 stru_721530.uFaceID = v24; | |
183 } | |
184 } | |
2138 | 185 } |
0 | 186 } |
2138 | 187 result = v29 + 1; |
0 | 188 } |
189 return result; | |
190 } | |
191 // 46E44E: using guessed type int var_28[10]; | |
192 | |
193 //----- (0046E889) -------------------------------------------------------- | |
194 int __fastcall _46E889_collide_against_bmodels(unsigned int ecx0) | |
195 { | |
196 int result; // eax@1 | |
197 int v3; // ebx@9 | |
198 int v8; // eax@19 | |
199 int v9; // ecx@20 | |
200 int v10; // eax@24 | |
201 unsigned int v14; // eax@28 | |
202 int v15; // eax@30 | |
203 int v16; // ecx@31 | |
204 unsigned int v17; // eax@36 | |
205 int v21; // eax@42 | |
206 unsigned int v22; // eax@43 | |
207 int a11; // [sp+70h] [bp-18h]@1 | |
208 int a10; // [sp+80h] [bp-8h]@1 | |
209 int a2; // [sp+84h] [bp-4h]@23 | |
210 | |
211 a11 = ecx0; | |
212 | |
213 BLVFace f; // [sp+Ch] [bp-7Ch]@1 | |
214 | |
215 result = 0; | |
2138 | 216 for ( a10 = 0; a10 < (signed int)pOutdoor->uNumBModels; ++a10 ) |
0 | 217 { |
2138 | 218 if ( stru_721530.sMaxX <= pOutdoor->pBModels[a10].sMaxX && stru_721530.sMinX >= pOutdoor->pBModels[a10].sMinX |
219 && stru_721530.sMaxY <= pOutdoor->pBModels[a10].sMaxY && stru_721530.sMinY >= pOutdoor->pBModels[a10].sMinY | |
220 && stru_721530.sMaxZ <= pOutdoor->pBModels[a10].sMaxZ && stru_721530.sMinZ >= pOutdoor->pBModels[a10].sMinZ ) | |
0 | 221 { |
2138 | 222 for ( v3 = 0; v3 < pOutdoor->pBModels[a10].uNumFaces; ++v3 ) |
0 | 223 { |
2138 | 224 if ( stru_721530.sMaxX <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x2 && stru_721530.sMinX >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x1 |
225 && stru_721530.sMaxY <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y2 && stru_721530.sMinY >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y1 | |
226 && stru_721530.sMaxZ <= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z2 && stru_721530.sMinZ >= pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z1 ) | |
0 | 227 { |
2138 | 228 f.pFacePlane_old.vNormal.x = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.x; |
229 f.pFacePlane_old.vNormal.y = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.y; | |
230 f.pFacePlane_old.vNormal.z = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.vNormal.z; | |
231 f.pFacePlane_old.dist = pOutdoor->pBModels[a10].pFaces[v3].pFacePlane.dist; | |
232 f.uAttributes = pOutdoor->pBModels[a10].pFaces[v3].uAttributes; | |
233 f.pBounding.x1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x1; | |
234 f.pBounding.y1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y1; | |
235 f.pBounding.z1 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z1; | |
236 f.pBounding.x2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.x2; | |
237 f.pBounding.y2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.y2; | |
238 f.pBounding.z2 = pOutdoor->pBModels[a10].pFaces[v3].pBoundingBox.z2; | |
239 f.zCalc1 = pOutdoor->pBModels[a10].pFaces[v3].zCalc1; | |
240 f.zCalc2 = pOutdoor->pBModels[a10].pFaces[v3].zCalc2; | |
241 f.zCalc3 = pOutdoor->pBModels[a10].pFaces[v3].zCalc3; | |
242 f.pXInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pXInterceptDisplacements; | |
243 f.pYInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pYInterceptDisplacements; | |
244 f.pZInterceptDisplacements = pOutdoor->pBModels[a10].pFaces[v3].pZInterceptDisplacements; | |
245 f.uPolygonType = (PolygonType)pOutdoor->pBModels[a10].pFaces[v3].uPolygonType; | |
246 f.uNumVertices = pOutdoor->pBModels[a10].pFaces[v3].uNumVertices; | |
247 f.uBitmapID = pOutdoor->pBModels[a10].pFaces[v3].uTextureID; | |
248 f.pVertexIDs = pOutdoor->pBModels[a10].pFaces[v3].pVertexIDs; | |
249 if ( !f.Ethereal() && !f.Portal() ) | |
0 | 250 { |
2138 | 251 v8 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.normal.x |
252 + f.pFacePlane_old.vNormal.y * stru_721530.normal.y | |
253 + f.pFacePlane_old.vNormal.z * stru_721530.normal.z ) >> 16; | |
254 if ( v8 > 0 ) | |
0 | 255 { |
2138 | 256 v9 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.normal2.x |
257 + f.pFacePlane_old.vNormal.y * stru_721530.normal2.y | |
258 + f.pFacePlane_old.vNormal.z * stru_721530.normal2.z) >> 16; | |
259 if ( v8 <= stru_721530.prolly_normal_d || v9 <= stru_721530.prolly_normal_d ) | |
0 | 260 { |
2138 | 261 if ( v9 <= v8 ) |
0 | 262 { |
2138 | 263 a2 = stru_721530.field_6C; |
264 if ( sub_4754BF(stru_721530.prolly_normal_d, &a2, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z, | |
265 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &f, a10, a11) ) | |
266 { | |
267 v10 = a2; | |
268 } | |
269 else | |
270 { | |
271 a2 = stru_721530.prolly_normal_d + stru_721530.field_6C; | |
272 if ( !sub_475F30( &a2, &f, stru_721530.normal.x, stru_721530.normal.y, stru_721530.normal.z, | |
273 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, a10) ) | |
274 goto LABEL_29; | |
275 v10 = a2 - stru_721530.prolly_normal_d; | |
276 a2 -= stru_721530.prolly_normal_d; | |
277 } | |
278 if ( v10 < stru_721530.field_7C ) | |
279 { | |
280 stru_721530.field_7C = v10; | |
281 v14 = 8 * (v3 | (a10 << 6)); | |
282 LOBYTE(v14) = v14 | 6; | |
283 stru_721530.uFaceID = v14; | |
284 } | |
285 } | |
286 } | |
287 } | |
288 LABEL_29: | |
289 if ( stru_721530.field_0 & 1 ) | |
290 { | |
291 v15 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.position.x | |
292 + f.pFacePlane_old.vNormal.y * stru_721530.position.y | |
293 + f.pFacePlane_old.vNormal.z * stru_721530.position.z) >> 16; | |
294 if ( v15 > 0 ) | |
295 { | |
296 v16 = (f.pFacePlane_old.dist + f.pFacePlane_old.vNormal.x * stru_721530.field_4C | |
297 + f.pFacePlane_old.vNormal.y * stru_721530.field_50 | |
298 + f.pFacePlane_old.vNormal.z * stru_721530.field_54) >> 16; | |
299 if ( v15 <= stru_721530.prolly_normal_d || v16 <= stru_721530.prolly_normal_d ) | |
300 { | |
301 if ( v16 <= v15 ) | |
302 { | |
303 a2 = stru_721530.field_6C; | |
304 if ( sub_4754BF(stru_721530.field_8_radius, &a2, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z, | |
305 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, &f, a10, a11) ) | |
306 { | |
307 if ( a2 < stru_721530.field_7C ) | |
308 { | |
309 stru_721530.field_7C = a2; | |
310 v17 = 8 * (v3 | (a10 << 6)); | |
311 LOBYTE(v17) = v17 | 6; | |
312 stru_721530.uFaceID = v17; | |
313 } | |
314 } | |
315 else | |
316 { | |
317 a2 = stru_721530.field_6C + stru_721530.field_8_radius; | |
318 if ( sub_475F30(&a2, &f, stru_721530.position.x, stru_721530.position.y, stru_721530.position.z, | |
319 stru_721530.direction.x, stru_721530.direction.y, stru_721530.direction.z, a10) ) | |
320 { | |
321 v21 = a2 - stru_721530.prolly_normal_d; | |
322 a2 -= stru_721530.prolly_normal_d; | |
323 if ( a2 < stru_721530.field_7C ) | |
324 { | |
325 stru_721530.field_7C = v21; | |
326 v22 = 8 * (v3 | (a10 << 6)); | |
327 LOBYTE(v22) = v22 | 6; | |
328 stru_721530.uFaceID = v22; | |
329 } | |
330 } | |
331 } | |
332 } | |
0 | 333 } |
334 } | |
335 } | |
336 } | |
337 } | |
338 } | |
339 } | |
2138 | 340 result = a10; |
0 | 341 } |
342 return result; | |
343 } | |
344 | |
345 //----- (0046ED1B) -------------------------------------------------------- | |
783 | 346 int collide_against_floor(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID) |
0 | 347 { |
348 uint uFaceID = -1; | |
723 | 349 int floor_level = BLV_GetFloorLevel(x, y, z, *pSectorID, &uFaceID); |
0 | 350 |
351 if (floor_level != -30000 && floor_level <= z + 50) | |
352 { | |
353 *pFaceID = uFaceID; | |
354 return floor_level; | |
355 } | |
356 | |
357 uint uSectorID = pIndoor->GetSector(x, y, z); | |
358 *pSectorID = uSectorID; | |
359 | |
723 | 360 floor_level = BLV_GetFloorLevel(x, y, z, uSectorID, &uFaceID); |
0 | 361 if (uSectorID && floor_level != -30000) |
362 *pFaceID = uFaceID; | |
363 else return -30000; | |
364 return floor_level; | |
365 } | |
366 | |
367 //----- (0046ED8A) -------------------------------------------------------- | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
368 void __fastcall _46ED8A_collide_against_sprite_objects(unsigned int _this) |
0 | 369 { |
2138 | 370 ObjectDesc *object; // edx@4 |
0 | 371 int v10; // ecx@12 |
372 int v11; // esi@13 | |
2138 | 373 |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
374 if ( (signed int)uNumSpriteObjects > 0 ) |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
375 { |
2138 | 376 for ( uint i = 0; i < uNumSpriteObjects; ++i ) |
0 | 377 { |
2138 | 378 if ( pSpriteObjects[i].uObjectDescID ) |
0 | 379 { |
2138 | 380 object = &pObjectList->pObjects[pSpriteObjects[i].uObjectDescID]; |
381 if ( !(object->uFlags & OBJECT_DESC_NO_COLLISION) ) | |
0 | 382 { |
2138 | 383 if ( stru_721530.sMaxX <= pSpriteObjects[i].vPosition.x + object->uRadius |
384 && stru_721530.sMinX >= pSpriteObjects[i].vPosition.x - object->uRadius | |
385 && stru_721530.sMaxY <= pSpriteObjects[i].vPosition.y + object->uRadius | |
386 && stru_721530.sMinY >= pSpriteObjects[i].vPosition.y - object->uRadius | |
387 && stru_721530.sMaxZ <= pSpriteObjects[i].vPosition.z + object->uHeight | |
388 && stru_721530.sMinZ >= pSpriteObjects[i].vPosition.z ) | |
0 | 389 { |
2138 | 390 if ( abs(((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.y |
391 - (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16) <= object->uHeight | |
392 + stru_721530.prolly_normal_d ) | |
0 | 393 { |
2138 | 394 v10 = ((pSpriteObjects[i].vPosition.x - stru_721530.normal.x) * stru_721530.direction.x |
395 + (pSpriteObjects[i].vPosition.y - stru_721530.normal.y) * stru_721530.direction.y) >> 16; | |
396 if ( v10 > 0 ) | |
0 | 397 { |
2138 | 398 v11 = stru_721530.normal.z + ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v10) >> 16); |
399 if ( v11 >= pSpriteObjects[i].vPosition.z - stru_721530.prolly_normal_d ) | |
0 | 400 { |
2138 | 401 if ( v11 <= object->uHeight + stru_721530.prolly_normal_d + pSpriteObjects[i].vPosition.z ) |
0 | 402 { |
2138 | 403 if ( v10 < stru_721530.field_7C ) |
404 sub_46DEF2(_this, i); | |
0 | 405 } |
406 } | |
407 } | |
408 } | |
409 } | |
410 } | |
411 } | |
412 } | |
413 } | |
414 } | |
415 | |
416 //----- (0046EF01) -------------------------------------------------------- | |
1546 | 417 int _46EF01_collision_chech_player(int a1) |
0 | 418 { |
419 int v1; // edx@1 | |
420 int result; // eax@1 | |
421 int v3; // ebx@7 | |
422 int v4; // esi@7 | |
423 int v5; // edi@8 | |
424 int v6; // ecx@9 | |
425 int v7; // edi@12 | |
426 int v8; // [sp+Ch] [bp-10h]@1 | |
427 unsigned int v9; // [sp+10h] [bp-Ch]@1 | |
428 int v10; // [sp+14h] [bp-8h]@7 | |
429 int v11; // [sp+18h] [bp-4h]@7 | |
430 | |
431 v8 = a1; | |
1546 | 432 v1 = 2 * pParty->field_14_radius; |
0 | 433 result = pParty->vPosition.x; |
434 v9 = pParty->uPartyHeight; | |
2138 | 435 if ( stru_721530.sMaxX <= pParty->vPosition.x + v1 && stru_721530.sMinX >= pParty->vPosition.x - v1 |
436 && stru_721530.sMaxY <= pParty->vPosition.y + v1 && stru_721530.sMinY >= pParty->vPosition.y - v1 | |
437 && stru_721530.sMaxZ <= (signed int)(pParty->vPosition.z + pParty->uPartyHeight) | |
438 && stru_721530.sMinZ >= pParty->vPosition.z ) | |
0 | 439 { |
2138 | 440 v3 = stru_721530.prolly_normal_d + v1; |
441 v11 = pParty->vPosition.x - stru_721530.normal.x; | |
442 v4 = ((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y | |
443 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16; | |
444 v10 = pParty->vPosition.y - stru_721530.normal.y; | |
445 result = abs(((pParty->vPosition.x - stru_721530.normal.x) * stru_721530.direction.y | |
446 - (pParty->vPosition.y - stru_721530.normal.y) * stru_721530.direction.x) >> 16); | |
447 if ( result <= stru_721530.prolly_normal_d + v1 ) | |
0 | 448 { |
2138 | 449 result = v10 * stru_721530.direction.y; |
450 v5 = (v10 * stru_721530.direction.y + v11 * stru_721530.direction.x) >> 16; | |
451 if ( v5 > 0 ) | |
0 | 452 { |
2138 | 453 v6 = ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v5) >> 16) + stru_721530.normal.z; |
454 result = pParty->vPosition.z; | |
455 if ( v6 >= pParty->vPosition.z ) | |
0 | 456 { |
2138 | 457 result = v9 + pParty->vPosition.z; |
458 if ( v6 <= (signed int)(v9 + pParty->vPosition.z) || v8 ) | |
0 | 459 { |
2138 | 460 result = integer_sqrt(v3 * v3 - v4 * v4); |
461 v7 = v5 - integer_sqrt(v3 * v3 - v4 * v4); | |
462 if ( v7 < 0 ) | |
463 v7 = 0; | |
464 if ( v7 < stru_721530.field_7C ) | |
0 | 465 { |
2138 | 466 stru_721530.field_7C = v7; |
467 stru_721530.uFaceID = 4; | |
0 | 468 } |
469 } | |
470 } | |
471 } | |
472 } | |
473 } | |
474 return result; | |
475 } | |
476 | |
477 //----- (0046F04E) -------------------------------------------------------- | |
1459 | 478 int _46F04E_collide_against_portals() |
0 | 479 { |
480 unsigned int v1; // eax@1 | |
2138 | 481 BLVFace *face; // eax@3 |
0 | 482 int v4; // ecx@9 |
483 int v5; // edx@9 | |
484 signed int result; // eax@21 | |
485 unsigned int v10; // [sp+8h] [bp-Ch]@1 | |
486 int a3; // [sp+Ch] [bp-8h]@13 | |
487 int v12; // [sp+10h] [bp-4h]@15 | |
488 | |
489 v1 = 0xFFFFFFu; | |
490 v10 = 0xFFFFFFu; | |
2138 | 491 for ( uint i = 0; i < pIndoor->pSectors[stru_721530.uSectorID].uNumPortals; ++i ) |
0 | 492 { |
2138 | 493 if ( pIndoor->pSectors[stru_721530.uSectorID].pPortals[i] != stru_721530.field_80 ) |
0 | 494 { |
2138 | 495 face = &pIndoor->pFaces[pIndoor->pSectors[stru_721530.uSectorID].pPortals[i]]; |
496 if ( stru_721530.sMaxX <= face->pBounding.x2 && stru_721530.sMinX >= face->pBounding.x1 | |
497 && stru_721530.sMaxY <= face->pBounding.y2 && stru_721530.sMinY >= face->pBounding.y1 | |
498 && stru_721530.sMaxZ <= face->pBounding.z2 && stru_721530.sMinZ >= face->pBounding.z1 ) | |
0 | 499 { |
2138 | 500 v4 = (stru_721530.normal.x * face->pFacePlane_old.vNormal.x + face->pFacePlane_old.dist |
501 + stru_721530.normal.y * face->pFacePlane_old.vNormal.y | |
502 + stru_721530.normal.z * face->pFacePlane_old.vNormal.z) >> 16; | |
503 v5 = (stru_721530.normal2.z * face->pFacePlane_old.vNormal.z + face->pFacePlane_old.dist | |
504 + stru_721530.normal2.x * face->pFacePlane_old.vNormal.x | |
505 + stru_721530.normal2.y * face->pFacePlane_old.vNormal.y) >> 16; | |
506 if ( (v4 < stru_721530.prolly_normal_d || v5 < stru_721530.prolly_normal_d) | |
507 && (v4 > -stru_721530.prolly_normal_d || v5 > -stru_721530.prolly_normal_d) | |
508 && (a3 = stru_721530.field_6C, sub_475D85(&stru_721530.normal, &stru_721530.direction, &a3, face)) | |
509 && a3 < (signed int)v10 ) | |
0 | 510 { |
2138 | 511 v10 = a3; |
512 v12 = pIndoor->pSectors[stru_721530.uSectorID].pPortals[i]; | |
0 | 513 } |
514 } | |
515 } | |
516 } | |
2138 | 517 v1 = v10; |
0 | 518 if ( stru_721530.field_7C >= (signed int)v1 && (signed int)v1 <= stru_721530.field_6C ) |
519 { | |
520 stru_721530.field_80 = v12; | |
2138 | 521 if ( pIndoor->pFaces[v12].uSectorID == stru_721530.uSectorID ) |
522 stru_721530.uSectorID = pIndoor->pFaces[v12].uBackSectorID; | |
0 | 523 else |
2138 | 524 stru_721530.uSectorID = pIndoor->pFaces[v12].uSectorID; |
0 | 525 stru_721530.field_7C = 268435455; |
526 result = 0; | |
527 } | |
528 else | |
529 { | |
530 result = 1; | |
531 } | |
532 return result; | |
533 } | |
534 | |
535 //----- (0047050A) -------------------------------------------------------- | |
1546 | 536 int stru141_actor_collision_object::_47050A(int dt) |
0 | 537 { |
1799 | 538 //stru141_actor_collision_object *v2; // esi@1 |
1546 | 539 //signed int v3; // eax@1 |
540 //int v4; // ecx@1 | |
541 //int v5; // edx@1 | |
542 //int v6; // edx@1 | |
0 | 543 int v7; // eax@1 |
1799 | 544 //int v8; // eax@3 |
0 | 545 signed int result; // eax@4 |
1799 | 546 //int v10; // eax@5 |
547 //int v11; // eax@5 | |
548 //int v12; // ebx@5 | |
549 //int v13; // edx@5 | |
550 //int v14; // edi@5 | |
551 //int v15; // ecx@5 | |
552 //int v16; // eax@5 | |
0 | 553 int v17; // eax@5 |
554 int v18; // eax@7 | |
1799 | 555 //int v19; // edx@9 |
556 //int v20; // edi@9 | |
0 | 557 int v21; // eax@9 |
558 int v22; // eax@11 | |
1799 | 559 //int v23; // edx@13 |
560 //int v24; // eax@13 | |
561 //int v25; // eax@14 | |
562 //int v26; // eax@16 | |
563 //int v27; // eax@17 | |
564 //int v28; // [sp+14h] [bp+8h]@5 | |
565 | |
566 //v2 = this; | |
1546 | 567 int speed = 1 | integer_sqrt(this->velocity.z * this->velocity.z + this->velocity.y * this->velocity.y + this->velocity.x * this->velocity.x); |
568 | |
1799 | 569 this->direction.x = 65536 / speed * this->velocity.x; |
570 this->direction.y = 65536 / speed * this->velocity.y; | |
571 this->direction.z = 65536 / speed * this->velocity.z; | |
572 | |
573 this->speed = speed; | |
574 this->inv_speed = 65536 / speed; | |
1546 | 575 |
576 if (dt) | |
577 v7 = dt; | |
578 else | |
0 | 579 v7 = pEventTimer->dt_in_some_format; |
1546 | 580 |
1799 | 581 //v8 = fixpoint_mul(v7, speed) - this->field_70; // speed * dt - something |
582 this->field_6C = fixpoint_mul(v7, speed) - this->field_70; | |
583 if ( this->field_6C > 0 ) | |
584 { | |
585 //v10 = fixpoint_mul(v8, this->direction.x) + this->normal.x; | |
586 this->field_4C = fixpoint_mul(this->field_6C, this->direction.x) + this->normal.x; | |
587 this->normal2.x = fixpoint_mul(this->field_6C, this->direction.x) + this->normal.x; | |
588 //v11 = fixpoint_mul(this->field_6C, this->direction.y) + this->normal.y; | |
589 this->field_50 = fixpoint_mul(this->field_6C, this->direction.y) + this->normal.y; | |
590 this->normal2.y = fixpoint_mul(this->field_6C, this->direction.y) + this->normal.y; | |
591 this->normal2.z = fixpoint_mul(this->field_6C, this->direction.z) + this->normal.z; | |
592 //v12 = this->position.z; | |
593 //v13 = this->normal.x; | |
594 //v14 = this->normal2.x; | |
595 //v15 = this->prolly_normal_d; | |
596 //v16 = this->position.z + fixpoint_mul(this->field_6C, this->direction.z); | |
597 //v28 = this->position.z + fixpoint_mul(this->field_6C, this->direction.z); | |
598 this->field_54 = this->position.z + fixpoint_mul(this->field_6C, this->direction.z); | |
599 v17 = this->normal.x; | |
600 if ( v17 >= this->normal2.x ) | |
601 v17 = this->normal2.x; | |
602 this->sMaxX = v17 - this->prolly_normal_d; | |
603 v18 = this->prolly_normal_d + this->normal.x; | |
604 if ( this->normal.x <= this->normal2.x ) | |
605 v18 = this->prolly_normal_d + this->normal2.x; | |
606 //v19 = this->normal.y; | |
607 //v20 = this->normal2.y; | |
608 this->sMinX = v18; | |
609 v21 = this->normal.y; | |
610 if ( v21 >= this->normal2.y ) | |
611 v21 = this->normal2.y; | |
612 this->sMaxY = v21 - this->prolly_normal_d; | |
613 v22 = this->prolly_normal_d + this->normal.y; | |
614 if ( this->normal.y <= this->normal2.y ) | |
615 v22 = this->normal2.y + this->prolly_normal_d; | |
616 //v23 = this->normal2.z; | |
617 this->sMinY = v22; | |
618 //v24 = this->normal.z; | |
619 if ( this->normal.z >= this->normal2.z ) | |
620 this->sMaxZ = this->normal2.z - this->prolly_normal_d; | |
0 | 621 else |
1799 | 622 this->sMaxZ = this->normal.z - this->prolly_normal_d; |
623 //this->sMaxZ = v25; | |
624 //v26 = this->field_8_radius; | |
625 if ( this->position.z <= this->position.z + fixpoint_mul(this->field_6C, this->direction.z) ) | |
626 this->sMinZ = (this->position.z + fixpoint_mul(this->field_6C, this->direction.z)) + this->field_8_radius; | |
0 | 627 else |
1799 | 628 this->sMinZ = this->position.z + this->field_8_radius; |
629 this->uFaceID = 0; | |
630 this->field_80 = -1; | |
631 this->field_88 = -1; | |
632 //this->sMinZ = v27; | |
633 this->field_7C = 0xFFFFFFu; | |
0 | 634 result = 0; |
635 } | |
636 else | |
637 { | |
638 result = 1; | |
639 } | |
640 return result; | |
641 } | |
642 | |
643 //----- (004706C6) -------------------------------------------------------- | |
1545 | 644 void UpdateActors_ODM() |
0 | 645 { |
646 int v3; // ebx@6 | |
647 int v5; // eax@10 | |
648 int v6; // ecx@10 | |
649 signed int v8; // ebx@17 | |
650 unsigned __int8 v10; // sf@17 | |
651 unsigned __int16 v11; // ax@21 | |
652 __int16 v20; // ax@42 | |
653 int v25; // eax@45 | |
654 signed int v26; // ecx@50 | |
655 int v28; // eax@54 | |
656 signed int v29; // ebx@57 | |
657 signed int v30; // eax@57 | |
658 int v31; // edi@57 | |
659 signed int i; // ebx@57 | |
660 unsigned int v33; // ecx@58 | |
661 int v35; // edi@64 | |
662 int v36; // eax@64 | |
848 | 663 unsigned int v39; // edi@71 |
2138 | 664 ODMFace *face; // edi@75 |
0 | 665 int v46; // ecx@82 |
666 signed int v47; // ebx@85 | |
667 int v48; // edi@85 | |
668 int v55; // eax@107 | |
669 unsigned int v56; // edi@107 | |
670 int v57; // ST10_4@107 | |
671 unsigned int v58; // edi@107 | |
672 unsigned int v59; // ebx@107 | |
673 signed int v60; // eax@107 | |
674 int v61; // eax@124 | |
675 Vec3_int_ v62; // [sp+Ch] [bp-44h]@42 | |
153 | 676 int v63; // [sp+18h] [bp-38h]@64 |
0 | 677 int v64; // [sp+1Ch] [bp-34h]@64 |
678 bool v67; // [sp+28h] [bp-28h]@10 | |
679 unsigned int v69; // [sp+30h] [bp-20h]@6 | |
680 unsigned int v70; // [sp+34h] [bp-1Ch]@10 | |
681 int v71; // [sp+38h] [bp-18h]@62 | |
845 | 682 int uIsAboveFloor; // [sp+3Ch] [bp-14h]@10 |
683 int v72b; | |
1545 | 684 //int v73; // [sp+40h] [bp-10h]@17 |
845 | 685 int uIsFlying; // [sp+44h] [bp-Ch]@8 |
0 | 686 unsigned int v75; // [sp+48h] [bp-8h]@1 |
845 | 687 int uIsOnWater; // [sp+4Ch] [bp-4h]@10 |
688 | |
1545 | 689 for (v75 = 0; v75 < uNumActors; ++v75) |
0 | 690 { |
2138 | 691 if ( pActors[v75].uAIState == Removed || pActors[v75].uAIState == Disabled || pActors[v75].uAIState == Summoned |
692 || !pActors[v75].uMovementSpeed ) | |
693 continue; | |
0 | 694 v3 = 0; |
695 v69 = 0; | |
2138 | 696 if ( MonsterStats::BelongsToSupertype(pActors[v75].pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) ) |
0 | 697 v3 = 1; |
2138 | 698 pActors[v75].uSectorID = 0; |
699 uIsFlying = pActors[v75].pMonsterInfo.uFlying; | |
700 if ( !pActors[v75].CanAct() ) | |
845 | 701 uIsFlying = 0; |
2138 | 702 v70 = IsTerrainSlopeTooHigh(pActors[v75].vPosition.x, pActors[v75].vPosition.y); |
703 v5 = ODM_GetFloorLevel(pActors[v75].vPosition.x, pActors[v75].vPosition.y, pActors[v75].vPosition.z, | |
704 pActors[v75].uActorHeight, &uIsOnWater, (int *)&v69, v3); | |
705 v6 = pActors[v75].vPosition.z; | |
845 | 706 uIsAboveFloor = 0; |
0 | 707 v67 = v69 == 0; |
708 if ( v6 > v5 + 1 ) | |
845 | 709 uIsAboveFloor = 1; |
2138 | 710 if ( pActors[v75].uAIState == Dead && uIsOnWater && !uIsAboveFloor ) |
0 | 711 { |
2138 | 712 pActors[v75].uAIState = Removed; |
713 continue; | |
0 | 714 } |
2138 | 715 if ( pActors[v75].uCurrentActionAnimation == ANIM_Walking ) |
0 | 716 { |
2138 | 717 v8 = pActors[v75].uMovementSpeed; |
718 if ( (signed __int64)pActors[v75].pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0 ) | |
0 | 719 { |
1545 | 720 v8 = (signed __int64)((double)v8 * 0.5); |
0 | 721 } |
2138 | 722 if ( pActors[v75].uAIState == Fleeing || pActors[v75].uAIState == Pursuing ) |
0 | 723 { |
724 v8 *= 2; | |
725 } | |
1340 | 726 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 1 ) |
1545 | 727 v8 *= flt_6BE3AC_debug_recmod1_x_1_6; |
0 | 728 if ( v8 > 1000 ) |
729 v8 = 1000; | |
1545 | 730 |
2138 | 731 pActors[v75].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(pActors[v75].uYawAngle), v8); |
732 pActors[v75].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(pActors[v75].uYawAngle), v8); | |
845 | 733 if ( uIsFlying ) |
0 | 734 { |
2138 | 735 pActors[v75].vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pActors[v75].uPitchAngle), v8); |
0 | 736 } |
846 | 737 //v7 = v68; |
0 | 738 } |
739 else | |
740 { | |
2138 | 741 pActors[v75].vVelocity.x = fixpoint_mul(55000, pActors[v75].vVelocity.x); |
742 pActors[v75].vVelocity.y = fixpoint_mul(55000, pActors[v75].vVelocity.y); | |
845 | 743 if ( uIsFlying ) |
2138 | 744 pActors[v75].vVelocity.z = fixpoint_mul(55000, pActors[v75].vVelocity.z); |
0 | 745 } |
2138 | 746 if ( pActors[v75].vPosition.z < v5 ) |
0 | 747 { |
2138 | 748 pActors[v75].vPosition.z = v5; |
749 pActors[v75].vVelocity.z = uIsFlying != 0 ? 0x14 : 0; | |
0 | 750 } |
846 | 751 //v17 = 0; |
845 | 752 if ( !uIsAboveFloor || uIsFlying ) |
753 { | |
754 if ( v70 && !uIsAboveFloor && v67 ) | |
0 | 755 { |
2138 | 756 pActors[v75].vPosition.z = v5; |
757 ODM_GetTerrainNormalAt(pActors[v75].vPosition.x, pActors[v75].vPosition.y, &v62); | |
0 | 758 v20 = GetGravityStrength(); |
1545 | 759 //v21 = v62.y; |
760 //v22 = v62.z; | |
761 //v23 = v62.y * v0->vVelocity.y; | |
2138 | 762 pActors[v75].vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20; |
763 int v73 = abs(v62.x * pActors[v75].vVelocity.x + v62.z * pActors[v75].vVelocity.z + v62.y * pActors[v75].vVelocity.y) >> 16; | |
1545 | 764 //v72b = v21; |
2138 | 765 pActors[v75].vVelocity.x += fixpoint_mul(v73, v62.x); |
766 pActors[v75].vVelocity.y += fixpoint_mul(v73, v62.y); | |
767 pActors[v75].vVelocity.z += fixpoint_mul(v73, v62.z); | |
846 | 768 //v17 = 0; |
0 | 769 } |
770 } | |
771 else | |
772 { | |
2138 | 773 pActors[v75].vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); |
0 | 774 } |
2138 | 775 if ( pParty->armageddon_timer != 0 && pActors[v75].CanAct() ) |
0 | 776 { |
2138 | 777 pActors[v75].vVelocity.x += rand() % 100 - 50; |
778 pActors[v75].vVelocity.y += rand() % 100 - 50; | |
779 pActors[v75].vVelocity.z += rand() % 100 - 20; | |
0 | 780 v25 = rand(); |
2138 | 781 pActors[v75].uAIState = Stunned; |
782 pActors[v75].uYawAngle += v25 % 32 - 16; | |
783 pActors[v75].UpdateAnimation(); | |
0 | 784 } |
2138 | 785 if ( pActors[v75].vVelocity.x * pActors[v75].vVelocity.x + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y < 400 && v70 == 0 ) |
846 | 786 { |
2138 | 787 pActors[v75].vVelocity.y = 0; |
788 pActors[v75].vVelocity.x = 0; | |
0 | 789 } |
790 stru_721530.field_0 = 1; | |
845 | 791 if ( !uIsFlying ) |
0 | 792 v26 = 40; |
793 else | |
2138 | 794 v26 = pActors[v75].uActorRadius; |
1546 | 795 |
0 | 796 stru_721530.field_84 = -1; |
1546 | 797 stru_721530.field_8_radius = v26; |
0 | 798 stru_721530.prolly_normal_d = v26; |
2138 | 799 stru_721530.height = pActors[v75].uActorHeight; |
846 | 800 stru_721530.field_70 = 0; |
2138 | 801 |
802 for ( v69 = 0; v69 < 100; ++v69 ) | |
0 | 803 { |
2138 | 804 stru_721530.position.x = pActors[v75].vPosition.x; |
1546 | 805 stru_721530.normal.x = stru_721530.position.x; |
2138 | 806 stru_721530.position.y = pActors[v75].vPosition.y; |
1546 | 807 stru_721530.normal.y = stru_721530.position.y; |
2138 | 808 v28 = pActors[v75].vPosition.z; |
0 | 809 stru_721530.normal.z = v28 + v26 + 1; |
1546 | 810 stru_721530.position.z = v28 - v26 + stru_721530.height - 1; |
811 if ( stru_721530.position.z < stru_721530.normal.z ) | |
812 stru_721530.position.z = v28 + v26 + 1; | |
2138 | 813 stru_721530.velocity.x = pActors[v75].vVelocity.x; |
0 | 814 stru_721530.uSectorID = 0; |
2138 | 815 stru_721530.velocity.y = pActors[v75].vVelocity.y; |
816 stru_721530.velocity.z = pActors[v75].vVelocity.z; | |
0 | 817 if ( stru_721530._47050A(0) ) |
818 break; | |
2138 | 819 _46E889_collide_against_bmodels(1); |
820 v29 = WorldPosToGridCellZ(pActors[v75].vPosition.y); | |
821 v30 = WorldPosToGridCellX(pActors[v75].vPosition.x); | |
0 | 822 _46E26D_collide_against_sprites(v30, v29); |
823 _46EF01_collision_chech_player(0); | |
862 | 824 _46ED8A_collide_against_sprite_objects(PID(OBJECT_Actor,v75)); |
0 | 825 v31 = 0; |
826 for ( i = 0; v31 < ai_arrays_size; ++v31 ) | |
827 { | |
390 | 828 v33 = ai_near_actors_ids[v31]; |
1897
436553b0603c
_46DF1A_collide_against_actor cleaned up, moved to Actor.h
Grumpy7
parents:
1861
diff
changeset
|
829 if ( v33 != v75 && Actor::_46DF1A_collide_against_actor(v33, 40) ) |
0 | 830 ++i; |
831 } | |
832 v71 = i > 1; | |
833 if ( stru_721530.field_7C < stru_721530.field_6C ) | |
1643 | 834 v70 = fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); |
845 | 835 //v34 = 0; |
0 | 836 v35 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; |
2138 | 837 v36 = ODM_GetFloorLevel(stru_721530.normal2.x, stru_721530.normal2.y, |
0 | 838 stru_721530.normal2.z - stru_721530.prolly_normal_d - 1, |
2138 | 839 pActors[v75].uActorHeight, (int *)&v63, &v64, 0); |
845 | 840 if ( uIsOnWater ) |
0 | 841 { |
842 if ( v35 < v36 + 60 ) | |
843 { | |
2138 | 844 if ( pActors[v75].uAIState == Dead || pActors[v75].uAIState == Dying || pActors[v75].uAIState == Removed |
845 || pActors[v75].uAIState == Disabled ) | |
0 | 846 { |
847 if ( v64 ) | |
848 v61 = v36 + 30; | |
849 else | |
846 | 850 v61 = v5 + 60; |
2138 | 851 sub_42F960_create_object(pActors[v75].vPosition.x, pActors[v75].vPosition.y, v61); |
852 pActors[v75].uAIState = Removed; | |
0 | 853 return; |
854 } | |
855 } | |
856 } | |
857 if ( stru_721530.field_7C >= stru_721530.field_6C ) | |
858 { | |
2138 | 859 pActors[v75].vPosition.x = LOWORD(stru_721530.normal2.x); |
860 pActors[v75].vPosition.y = LOWORD(stru_721530.normal2.y); | |
861 pActors[v75].vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1; | |
0 | 862 break; |
863 } | |
1643 | 864 //v72b = fixpoint_mul(stru_721530.field_7C, stru_721530.field_58.x); |
2138 | 865 pActors[v75].vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x); |
1545 | 866 //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; |
2138 | 867 pActors[v75].vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y); |
1545 | 868 //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; |
2138 | 869 pActors[v75].vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); |
0 | 870 stru_721530.field_70 += stru_721530.field_7C; |
2138 | 871 v39 = PID_ID(stru_721530.uFaceID); |
872 switch ( PID_TYPE(stru_721530.uFaceID) ) | |
845 | 873 { |
874 case OBJECT_Actor: | |
1340 | 875 if ( pTurnEngine->turn_stage != 2 && pTurnEngine->turn_stage != 3 || pParty->bTurnBasedModeOn != 1 ) |
845 | 876 { |
877 //if(pParty->bTurnBasedModeOn == 1) | |
878 //v34 = 0; | |
2138 | 879 if ( pActors[v75].pMonsterInfo.uHostilityType ) |
0 | 880 { |
845 | 881 if ( v71 == 0 ) |
2138 | 882 Actor::AI_Flee(v75, stru_721530.uFaceID, 0, (AIDirection *)0); |
883 else | |
884 Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0); | |
0 | 885 } |
1545 | 886 else if ( v71 ) |
845 | 887 Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0); |
2138 | 888 else if ( pActors[v39].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly ) |
889 Actor::AI_Flee(v75, stru_721530.uFaceID, 0, (AIDirection *)0); | |
890 else | |
891 Actor::AI_FaceObject(v75, stru_721530.uFaceID, 0, (AIDirection *)0); | |
0 | 892 } |
893 break; | |
845 | 894 case OBJECT_Player: |
2138 | 895 if ( !pActors[v75].GetActorsRelation(0) ) |
0 | 896 { |
2138 | 897 Actor::AI_FaceObject(v75, stru_721530.uFaceID, 0, (AIDirection *)0); |
845 | 898 break; |
0 | 899 } |
1167 | 900 //v52 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) == 0; |
901 //v53 = SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) < 0; | |
2138 | 902 pActors[v75].vVelocity.y = 0; |
903 pActors[v75].vVelocity.x = 0; | |
1167 | 904 //if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0) ) |
2138 | 905 if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime < 0) |
1167 | 906 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); |
0 | 907 viewparams->bRedrawGameUI = 1; |
908 break; | |
845 | 909 case OBJECT_Decoration: |
2138 | 910 v47 = integer_sqrt(pActors[v75].vVelocity.x * pActors[v75].vVelocity.x + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y); |
911 v48 = stru_5C6E00->Atan2( pActors[v75].vPosition.x - pLevelDecorations[v39].vPosition.x, | |
912 pActors[v75].vPosition.y - pLevelDecorations[v39].vPosition.y); | |
913 //v49 = v48; | |
914 pActors[v75].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v48), v47); | |
915 pActors[v75].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v48), v47); | |
0 | 916 break; |
845 | 917 case OBJECT_BModel: |
2138 | 918 face = &pOutdoor->pBModels[stru_721530.uFaceID >> 9].pFaces[v39 & 0x3F]; |
919 if ( !face->Ethereal() ) | |
0 | 920 { |
2138 | 921 if ( face->uPolygonType == 3 ) |
0 | 922 { |
2138 | 923 pActors[v75].vVelocity.z = 0; |
924 pActors[v75].vPosition.z = LOWORD(pOutdoor->pBModels[stru_721530.uFaceID >> 9].pVertices.pVertices[face->pVertexIDs[0]].z) + 1; | |
925 if ( pActors[v75].vVelocity.x * pActors[v75].vVelocity.x | |
926 + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y < 400 ) | |
0 | 927 { |
2138 | 928 pActors[v75].vVelocity.y = 0; |
929 pActors[v75].vVelocity.x = 0; | |
0 | 930 } |
931 } | |
932 else | |
933 { | |
2138 | 934 v72b = abs(face->pFacePlane.vNormal.y * pActors[v75].vVelocity.y + face->pFacePlane.vNormal.z * pActors[v75].vVelocity.z |
935 + face->pFacePlane.vNormal.x * pActors[v75].vVelocity.x) >> 16; | |
1546 | 936 if ( (stru_721530.speed >> 3) > v72b ) |
937 v72b = stru_721530.speed >> 3; | |
1545 | 938 |
2138 | 939 pActors[v75].vVelocity.x += fixpoint_mul(v72b, face->pFacePlane.vNormal.x); |
940 pActors[v75].vVelocity.y += fixpoint_mul(v72b, face->pFacePlane.vNormal.y); | |
941 pActors[v75].vVelocity.z += fixpoint_mul(v72b, face->pFacePlane.vNormal.z); | |
942 if ( face->uPolygonType != 4 ) | |
0 | 943 { |
944 v46 = stru_721530.prolly_normal_d | |
2138 | 945 - ((face->pFacePlane.dist |
946 + face->pFacePlane.vNormal.x * pActors[v75].vPosition.x | |
947 + face->pFacePlane.vNormal.y * pActors[v75].vPosition.y | |
948 + face->pFacePlane.vNormal.z * pActors[v75].vPosition.z) >> 16); | |
0 | 949 if ( v46 > 0 ) |
950 { | |
2138 | 951 pActors[v75].vPosition.x += (unsigned int)(v46 * face->pFacePlane.vNormal.x) >> 16; |
952 pActors[v75].vPosition.y += (unsigned int)(v46 * face->pFacePlane.vNormal.y) >> 16; | |
953 pActors[v75].vPosition.z += (unsigned int)(v46 * face->pFacePlane.vNormal.z) >> 16; | |
0 | 954 } |
2138 | 955 pActors[v75].uYawAngle = stru_5C6E00->Atan2(pActors[v75].vVelocity.x, pActors[v75].vVelocity.y); |
0 | 956 } |
957 } | |
958 } | |
959 break; | |
960 } | |
1545 | 961 |
2138 | 962 pActors[v75].vVelocity.x = fixpoint_mul(58500, pActors[v75].vVelocity.x); |
963 pActors[v75].vVelocity.y = fixpoint_mul(58500, pActors[v75].vVelocity.y); | |
964 pActors[v75].vVelocity.z = fixpoint_mul(58500, pActors[v75].vVelocity.z); | |
965 | |
0 | 966 v26 = stru_721530.prolly_normal_d; |
967 } | |
2138 | 968 |
969 v58 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(pActors[v75].vPosition.x), WorldPosToGridCellZ(pActors[v75].vPosition.y) - 1) >> 1) & 1; | |
970 v59 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(pActors[v75].vPosition.x), WorldPosToGridCellZ(pActors[v75].vPosition.y) - 1) >> 1) & 1; | |
971 if ( WorldPosToGridCellX(pActors[v75].vPosition.x) == WorldPosToGridCellX(pActors[v75].vPosition.x) | |
972 && WorldPosToGridCellZ(pActors[v75].vPosition.y) == WorldPosToGridCellZ(pActors[v75].vPosition.y) | |
973 && v58 || v67 != 0 ) | |
0 | 974 { |
2138 | 975 if ( MonsterStats::BelongsToSupertype(pActors[v75].pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL) ) |
0 | 976 { |
977 v58 = v58 == 0; | |
978 v59 = v59 == 0; | |
979 } | |
845 | 980 if ( !uIsFlying && v58 && !v59 ) |
0 | 981 { |
2138 | 982 pActors[v75].vPosition.x = pActors[v75].vPosition.x; |
983 pActors[v75].vPosition.y = pActors[v75].vPosition.y; | |
984 if ( pActors[v75].CanAct() ) | |
0 | 985 { |
2138 | 986 pActors[v75].uYawAngle -= 32; |
987 pActors[v75].uCurrentActionTime = 0; | |
988 pActors[v75].uCurrentActionLength = 128; | |
989 pActors[v75].uAIState = Fleeing; | |
0 | 990 } |
991 } | |
992 } | |
845 | 993 } |
0 | 994 } |
995 | |
996 //----- (0047253E) -------------------------------------------------------- | |
997 void UpdateObjects() | |
998 { | |
999 unsigned int v0; // ebx@0 | |
1000 //unsigned int v1; // edi@1 | |
1083 | 1001 //char *v2; // esi@2 |
0 | 1002 //__int16 v3; // dx@5 |
2138 | 1003 ObjectDesc *object; // eax@5 |
0 | 1004 int v5; // ecx@6 |
1005 __int16 v6; // cx@7 | |
1006 signed int v7; // eax@9 | |
2138 | 1007 //unsigned int v10; // ecx@16 |
0 | 1008 signed int v11; // eax@17 |
1009 int v12; // edi@27 | |
1010 int v13; // eax@27 | |
1011 int v14; // ebx@27 | |
1012 unsigned int v15; // ecx@27 | |
1013 unsigned int v16; // edx@30 | |
1014 unsigned int v17; // edx@32 | |
1015 int v18; // [sp+4h] [bp-10h]@27 | |
1016 int v19; // [sp+8h] [bp-Ch]@27 | |
1017 //signed int v20; // [sp+10h] [bp-4h]@1 | |
1018 | |
1019 //v1 = 0; | |
1020 //v20 = 0; | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
1021 for (uint i = 0; i < uNumSpriteObjects; ++i) |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
1022 { |
1980 | 1023 SpriteObject* item = &pSpriteObjects[i]; |
1083 | 1024 //v2 = (char *)&item->uSpriteFrameID; |
0 | 1025 //do |
1026 //{ | |
1027 //LOWORD(v0) = item->uAttributes; | |
1545 | 1028 if (item->uAttributes & OBJECT_40) |
1029 item->uAttributes &= ~OBJECT_40; | |
0 | 1030 else |
1031 { | |
2138 | 1032 object = &pObjectList->pObjects[item->uObjectDescID]; |
430 | 1033 if (item->AttachedToActor()) |
1034 { | |
848 | 1035 v5 = PID_ID(item->spell_target_pid); |
2138 | 1036 item->vPosition.x = pActors[v5].vPosition.x; |
1083 | 1037 item->vPosition.y = pActors[v5].vPosition.y; |
1038 item->vPosition.z = pActors[v5].vPosition.z + pActors[v5].uActorHeight; | |
2138 | 1039 if ( !item->uObjectDescID ) |
1083 | 1040 continue; |
2138 | 1041 item->uSpriteFrameID += pEventTimer->uTimeElapsed; |
1042 if ( !(object->uFlags & OBJECT_DESC_TEMPORARY)) | |
1043 continue; | |
1044 if ( item->uSpriteFrameID >= 0 ) | |
0 | 1045 { |
2138 | 1046 v7 = object->uLifetime; |
1047 if (item->uAttributes & ITEM_BROKEN) | |
1083 | 1048 v7 = item->field_20; |
2138 | 1049 if ( item->uSpriteFrameID < v7 ) |
1083 | 1050 continue; |
1051 } | |
2138 | 1052 SpriteObject::OnInteraction(i); |
1053 continue; | |
0 | 1054 } |
1055 | |
1056 if ( item->uObjectDescID ) | |
1057 { | |
2138 | 1058 item->uSpriteFrameID += pEventTimer->uTimeElapsed; |
1059 if ( object->uFlags & OBJECT_DESC_TEMPORARY ) | |
1060 { | |
1061 if ( item->uSpriteFrameID < 0 ) | |
1062 { | |
1063 SpriteObject::OnInteraction(i); | |
1064 continue; | |
1065 } | |
1066 v11 = object->uLifetime; | |
1067 if (item->uAttributes & ITEM_BROKEN) | |
1068 v11 = item->field_20; | |
1069 } | |
1070 if ( !(object->uFlags & OBJECT_DESC_TEMPORARY) || item->uSpriteFrameID < v11 ) | |
1083 | 1071 { |
0 | 1072 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
1073 SpriteObject::UpdateObject_fn0_BLV(i); |
0 | 1074 else |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
1075 SpriteObject::UpdateObject_fn0_ODM(i); |
1083 | 1076 if ( pParty->bTurnBasedModeOn != 1 || !(item->uSectorID & 4) ) |
1077 continue; | |
1078 v12 = abs(pParty->vPosition.x - item->vPosition.x); | |
1079 v18 = abs(pParty->vPosition.y - item->vPosition.y); | |
1080 v19 = abs(pParty->vPosition.z - item->vPosition.z); | |
0 | 1081 v13 = v12; |
1082 v14 = v18; | |
1083 v15 = v19; | |
1084 if ( v12 < v18 ) | |
1085 { | |
1086 v13 = v18; | |
1087 v14 = v12; | |
1088 } | |
1089 if ( v13 < v19 ) | |
1090 { | |
1091 v16 = v13; | |
1092 v13 = v19; | |
1093 v15 = v16; | |
1094 } | |
1095 if ( v14 < (signed int)v15 ) | |
1096 { | |
1097 v17 = v15; | |
1098 v15 = v14; | |
1099 v14 = v17; | |
1100 } | |
1101 v0 = (unsigned int)(11 * v14) >> 5; | |
1102 if ( (signed int)(v0 + (v15 >> 2) + v13) <= 5120 ) | |
1083 | 1103 continue; |
2138 | 1104 SpriteObject::OnInteraction(i); |
1083 | 1105 continue; |
0 | 1106 } |
2138 | 1107 if ( !(object->uFlags & OBJECT_DESC_INTERACTABLE) ) |
1108 { | |
1109 SpriteObject::OnInteraction(i); | |
1083 | 1110 continue; |
2138 | 1111 } |
862 | 1112 _46BFFA_check_object_intercept(i, PID(OBJECT_Item,i)); |
0 | 1113 } |
1114 } | |
1115 } | |
1116 } | |
1117 | |
1118 //----- (0047272C) -------------------------------------------------------- | |
831 | 1119 int collide_against_floor_approximate(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID) |
0 | 1120 { |
1121 signed int v5; // ebx@1 | |
1122 int result; // eax@1 | |
1123 int v7; // [sp+10h] [bp-8h]@1 | |
1124 signed int v8; // [sp+14h] [bp-4h]@1 | |
1125 | |
1126 v5 = x - 2; | |
1127 v7 = x; | |
1128 v8 = y; | |
1129 *pSectorID = pIndoor->GetSector(x - 2, y, z + 40); | |
783 | 1130 result = collide_against_floor(v5, v8, z + 40, pSectorID, pFaceID); |
0 | 1131 if ( result == -30000 || !*pSectorID ) |
1132 { | |
1133 *pSectorID = pIndoor->GetSector(v7 + 2, v8, z + 40); | |
783 | 1134 result = collide_against_floor(v7 + 2, v8, z + 40, pSectorID, pFaceID); |
0 | 1135 if ( result == -30000 || !*pSectorID ) |
1136 { | |
1137 *pSectorID = pIndoor->GetSector(v7, v8 - 2, z + 40); | |
783 | 1138 result = collide_against_floor(v7, v8 - 2, z + 40, pSectorID, pFaceID); |
0 | 1139 if ( result == -30000 || !*pSectorID ) |
1140 { | |
1141 *pSectorID = pIndoor->GetSector(v7, v8 + 2, z + 40); | |
783 | 1142 result = collide_against_floor(v7, v8 + 2, z + 40, pSectorID, pFaceID); |
0 | 1143 if ( result == -30000 || !*pSectorID ) |
1144 { | |
1145 *pSectorID = pIndoor->GetSector(v7, v8, z + 140); | |
783 | 1146 result = collide_against_floor(v7, v8, z + 140, pSectorID, pFaceID); |
0 | 1147 } |
1148 } | |
1149 } | |
1150 } | |
1151 return result; | |
1152 } | |
1153 | |
2138 | 1154 //----- (0047531C) -------------------------------------------------------- |
1155 bool sub_47531C(int a1, int *a2, int pos_x, int pos_y, int pos_z, int dir_x, int dir_y, int dir_z, BLVFace *face, int a10) | |
0 | 1156 { |
1157 int v11; // ST1C_4@3 | |
1158 int v12; // edi@3 | |
1159 int v13; // esi@3 | |
1160 int v14; // edi@4 | |
1161 signed __int64 v15; // qtt@6 | |
1162 __int16 v16; // si@7 | |
1163 int a7a; // [sp+30h] [bp+18h]@7 | |
1164 int a9b; // [sp+38h] [bp+20h]@3 | |
1165 int a9a; // [sp+38h] [bp+20h]@3 | |
1166 int a10b; // [sp+3Ch] [bp+24h]@3 | |
1167 signed int a10a; // [sp+3Ch] [bp+24h]@4 | |
1168 int a10c; // [sp+3Ch] [bp+24h]@5 | |
1169 | |
2138 | 1170 if ( a10 && face->Ethereal() ) |
0 | 1171 return 0; |
2138 | 1172 v11 = (unsigned __int64)(dir_x * (signed __int64)face->pFacePlane_old.vNormal.x) >> 16; |
1173 a10b = (unsigned __int64)(dir_y * (signed __int64)face->pFacePlane_old.vNormal.y) >> 16; | |
1174 a9b = (unsigned __int64)(dir_z * (signed __int64)face->pFacePlane_old.vNormal.z) >> 16; | |
0 | 1175 v12 = v11 + a9b + a10b; |
1176 a9a = v11 + a9b + a10b; | |
1177 v13 = (a1 << 16) | |
2138 | 1178 - pos_x * face->pFacePlane_old.vNormal.x |
1179 - pos_y * face->pFacePlane_old.vNormal.y | |
1180 - pos_z * face->pFacePlane_old.vNormal.z | |
1181 - face->pFacePlane_old.dist; | |
0 | 1182 if ( abs((a1 << 16) |
2138 | 1183 - pos_x * face->pFacePlane_old.vNormal.x |
1184 - pos_y * face->pFacePlane_old.vNormal.y | |
1185 - pos_z * face->pFacePlane_old.vNormal.z - face->pFacePlane_old.dist) >= a1 << 16 ) | |
0 | 1186 { |
1187 a10c = abs(v13) >> 14; | |
1188 if ( a10c > abs(v12) ) | |
1189 return 0; | |
1190 LODWORD(v15) = v13 << 16; | |
1191 HIDWORD(v15) = v13 >> 16; | |
2138 | 1192 v14 = a1; |
0 | 1193 a10a = v15 / a9a; |
1194 } | |
1195 else | |
1196 { | |
1197 a10a = 0; | |
1198 v14 = abs(v13) >> 16; | |
1199 } | |
2138 | 1200 v16 = pos_y + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)dir_y) >> 16) >> 16); |
1201 LOWORD(a7a) = (short)pos_x | |
1202 + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)dir_x) >> 16) >> 16) | |
1203 - ((unsigned int)(v14 * face->pFacePlane_old.vNormal.x) >> 16); | |
1204 HIWORD(a7a) = v16 - ((unsigned int)(v14 * face->pFacePlane_old.vNormal.y) >> 16); | |
1205 if ( !sub_475665(face, a7a, (short)pos_z + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)dir_z) >> 16) >> 16) | |
1206 - ((unsigned int)(v14 * face->pFacePlane_old.vNormal.z) >> 16)) ) | |
0 | 1207 return 0; |
2138 | 1208 *a2 = a10a >> 16; |
0 | 1209 if ( a10a >> 16 < 0 ) |
2138 | 1210 *a2 = 0; |
0 | 1211 return 1; |
1212 } | |
1213 | |
1214 //----- (004754BF) -------------------------------------------------------- | |
2138 | 1215 bool sub_4754BF(int a1, int *a2, int X, int Y, int Z, int dir_x, int dir_y, int dir_z, BLVFace *face, int a10, int a11) |
0 | 1216 { |
1217 int v12; // ST1C_4@3 | |
1218 int v13; // edi@3 | |
1219 int v14; // esi@3 | |
1220 int v15; // edi@4 | |
1221 signed __int64 v16; // qtt@6 | |
1222 __int16 v17; // si@7 | |
1223 int a7a; // [sp+30h] [bp+18h]@7 | |
1224 int a1b; // [sp+38h] [bp+20h]@3 | |
1225 int a1a; // [sp+38h] [bp+20h]@3 | |
1226 int a11b; // [sp+40h] [bp+28h]@3 | |
1227 signed int a11a; // [sp+40h] [bp+28h]@4 | |
1228 int a11c; // [sp+40h] [bp+28h]@5 | |
1229 | |
2138 | 1230 if ( a11 && face->Ethereal() ) |
1231 return false; | |
1232 v12 = (unsigned __int64)(dir_x * (signed __int64)face->pFacePlane_old.vNormal.x) >> 16; | |
1233 a11b = (unsigned __int64)(dir_y * (signed __int64)face->pFacePlane_old.vNormal.y) >> 16; | |
1234 a1b = (unsigned __int64)(dir_z * (signed __int64)face->pFacePlane_old.vNormal.z) >> 16; | |
0 | 1235 v13 = v12 + a1b + a11b; |
1236 a1a = v12 + a1b + a11b; | |
1237 v14 = (a1 << 16) | |
2138 | 1238 - X * face->pFacePlane_old.vNormal.x |
1239 - Y * face->pFacePlane_old.vNormal.y | |
1240 - Z * face->pFacePlane_old.vNormal.z | |
1241 - face->pFacePlane_old.dist; | |
0 | 1242 if ( abs((a1 << 16) |
2138 | 1243 - X * face->pFacePlane_old.vNormal.x |
1244 - Y * face->pFacePlane_old.vNormal.y | |
1245 - Z * face->pFacePlane_old.vNormal.z - face->pFacePlane_old.dist) >= a1 << 16 ) | |
0 | 1246 { |
1247 a11c = abs(v14) >> 14; | |
1248 if ( a11c > abs(v13) ) | |
2138 | 1249 return false; |
0 | 1250 LODWORD(v16) = v14 << 16; |
1251 HIDWORD(v16) = v14 >> 16; | |
2138 | 1252 v15 = a1; |
0 | 1253 a11a = v16 / a1a; |
1254 } | |
1255 else | |
1256 { | |
1257 a11a = 0; | |
1258 v15 = abs(v14) >> 16; | |
1259 } | |
2138 | 1260 v17 = Y + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)dir_y) >> 16) >> 16); |
1261 LOWORD(a7a) = (short)X | |
1262 + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)dir_x) >> 16) >> 16) | |
1263 - ((unsigned int)(v15 * face->pFacePlane_old.vNormal.x) >> 16); | |
1264 HIWORD(a7a) = v17 - ((unsigned int)(v15 * face->pFacePlane_old.vNormal.y) >> 16); | |
1265 if ( !sub_4759C9(face, a10, a7a, (short)Z + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)dir_z) >> 16) >> 16) | |
1266 - ((unsigned int)(v15 * face->pFacePlane_old.vNormal.z) >> 16)) ) | |
1267 return false; | |
1268 *a2 = a11a >> 16; | |
0 | 1269 if ( a11a >> 16 < 0 ) |
2138 | 1270 *a2 = 0; |
1271 return true; | |
0 | 1272 } |
1273 | |
1274 //----- (00475665) -------------------------------------------------------- | |
1459 | 1275 int sub_475665(BLVFace *_this, int a2, __int16 a3) |
0 | 1276 { |
1277 unsigned int v3; // eax@1 | |
1278 Vec3_short_ *v4; // edx@3 | |
1279 signed int v5; // eax@4 | |
1280 int v6; // esi@4 | |
1281 signed int v7; // eax@7 | |
1282 Vec3_short_ *v8; // edx@8 | |
1283 signed int v9; // eax@9 | |
1284 int v10; // esi@9 | |
1285 signed int v11; // eax@11 | |
1286 Vec3_short_ *v12; // edx@12 | |
1287 signed int v13; // eax@13 | |
1288 int v14; // esi@13 | |
1289 int v15; // esi@14 | |
1290 bool v16; // edi@14 | |
1291 int v17; // ecx@16 | |
1292 signed int v18; // edx@16 | |
1293 int v19; // eax@17 | |
1294 signed int v20; // ebx@18 | |
1295 int v21; // edi@20 | |
1296 signed int v22; // ST14_4@22 | |
1297 signed __int64 v23; // qtt@22 | |
1298 signed int result; // eax@25 | |
1299 int v25; // [sp+14h] [bp-10h]@14 | |
1300 int v26; // [sp+1Ch] [bp-8h]@2 | |
1301 signed int v27; // [sp+20h] [bp-4h]@2 | |
1302 signed int v28; // [sp+30h] [bp+Ch]@2 | |
1303 signed int v29; // [sp+30h] [bp+Ch]@7 | |
1304 signed int v30; // [sp+30h] [bp+Ch]@11 | |
1305 signed int v31; // [sp+30h] [bp+Ch]@14 | |
1306 | |
1307 v3 = _this->uAttributes; | |
1308 if ( BYTE1(v3) & 1 ) | |
1309 { | |
1310 v28 = 0; | |
1311 v26 = (signed __int16)a2; | |
1312 v27 = SHIWORD(a2); | |
1313 if ( _this->uNumVertices ) | |
1314 { | |
1315 v4 = pIndoor->pVertices; | |
1316 do | |
1317 { | |
1318 v5 = v28; | |
1319 v6 = 2 * v28; | |
1320 word_720C10_intercepts_xs[2 * v28] = _this->pXInterceptDisplacements[v28] + v4[_this->pVertexIDs[v28]].x; | |
1321 word_720B40_intercepts_zs[2 * v28] = _this->pYInterceptDisplacements[v5] + v4[_this->pVertexIDs[v5]].y; | |
1322 word_720C10_intercepts_xs[2 * v28++ + 1] = _this->pXInterceptDisplacements[v5 + 1] | |
1323 + v4[_this->pVertexIDs[v5 + 1]].x; | |
1324 word_720B40_intercepts_zs[v6 + 1] = _this->pYInterceptDisplacements[v5 + 1] + v4[_this->pVertexIDs[v5 + 1]].y; | |
1325 } | |
1326 while ( v28 < _this->uNumVertices ); | |
1327 } | |
1328 } | |
1329 else | |
1330 { | |
1331 if ( BYTE1(v3) & 2 ) | |
1332 { | |
1333 v26 = (signed __int16)a2; | |
1334 v7 = a3; | |
1335 v29 = 0; | |
1336 v27 = v7; | |
1337 if ( _this->uNumVertices ) | |
1338 { | |
1339 v8 = pIndoor->pVertices; | |
1340 do | |
1341 { | |
1342 v9 = v29; | |
1343 v10 = 2 * v29; | |
1344 word_720C10_intercepts_xs[2 * v29] = _this->pXInterceptDisplacements[v29] + v8[_this->pVertexIDs[v29]].x; | |
1345 word_720B40_intercepts_zs[2 * v29] = _this->pZInterceptDisplacements[v9] + v8[_this->pVertexIDs[v9]].z; | |
1346 word_720C10_intercepts_xs[2 * v29++ + 1] = _this->pXInterceptDisplacements[v9 + 1] + v8[_this->pVertexIDs[v9 + 1]].x; | |
1347 word_720B40_intercepts_zs[v10 + 1] = _this->pZInterceptDisplacements[v9 + 1] + v8[_this->pVertexIDs[v9 + 1]].z; | |
1348 } | |
1349 while ( v29 < _this->uNumVertices ); | |
1350 } | |
1351 } | |
1352 else | |
1353 { | |
1354 v26 = SHIWORD(a2); | |
1355 v11 = a3; | |
1356 v30 = 0; | |
1357 v27 = v11; | |
1358 if ( _this->uNumVertices ) | |
1359 { | |
1360 v12 = pIndoor->pVertices; | |
1361 do | |
1362 { | |
1363 v13 = v30; | |
1364 v14 = 2 * v30; | |
1365 word_720C10_intercepts_xs[2 * v30] = _this->pYInterceptDisplacements[v30] + v12[_this->pVertexIDs[v30]].y; | |
1366 word_720B40_intercepts_zs[2 * v30] = _this->pZInterceptDisplacements[v13] + v12[_this->pVertexIDs[v13]].z; | |
1367 word_720C10_intercepts_xs[2 * v30++ + 1] = _this->pYInterceptDisplacements[v13 + 1] + v12[_this->pVertexIDs[v13 + 1]].y; | |
1368 word_720B40_intercepts_zs[v14 + 1] = _this->pZInterceptDisplacements[v13 + 1] + v12[_this->pVertexIDs[v13 + 1]].z; | |
1369 } | |
1370 while ( v30 < _this->uNumVertices ); | |
1371 } | |
1372 } | |
1373 } | |
1374 v15 = 2 * _this->uNumVertices; | |
1375 v31 = 0; | |
1376 word_720C10_intercepts_xs[2 * _this->uNumVertices] = word_720C10_intercepts_xs[0]; | |
1377 word_720B40_intercepts_zs[v15] = word_720B40_intercepts_zs[0]; | |
1378 v25 = 0; | |
1379 v16 = word_720B40_intercepts_zs[0] >= v27; | |
1380 if ( v15 <= 0 ) | |
1418 | 1381 return 0; |
0 | 1382 do |
1383 { | |
1384 if ( v31 >= 2 ) | |
1385 break; | |
1386 v17 = v25; | |
1387 v18 = word_720B40_intercepts_zs[v25 + 1]; | |
1110 | 1388 if ( v16 ^ (v18 >= v27) ) |
0 | 1389 { |
1390 v19 = word_720C10_intercepts_xs[v17 + 1]; | |
1391 if ( v19 >= v26 ) | |
1392 v20 = 0; | |
1393 else | |
1394 v20 = 2; | |
1110 | 1395 v21 = v20 | (word_720C10_intercepts_xs[v17] < v26); |
0 | 1396 if ( v21 != 3 ) |
1397 { | |
1398 if ( !v21 | |
1399 || (v22 = v19 - word_720C10_intercepts_xs[v17], | |
1400 LODWORD(v23) = v22 << 16, | |
1401 HIDWORD(v23) = v22 >> 16, | |
1402 word_720C10_intercepts_xs[v17] | |
1403 + ((signed int)(((unsigned __int64)(v23 | |
1404 / (v18 - word_720B40_intercepts_zs[v17]) | |
1405 * ((v27 - (signed int)word_720B40_intercepts_zs[v17]) << 16)) >> 16) | |
1406 + 32768) >> 16) >= v26) ) | |
1407 ++v31; | |
1408 } | |
1409 } | |
1410 ++v25; | |
1411 v16 = v18 >= v27; | |
1412 } | |
1413 while ( v25 < v15 ); | |
1414 result = 1; | |
1415 if ( v31 != 1 ) | |
1416 result = 0; | |
1417 return result; | |
1418 } | |
1419 | |
1420 //----- (004759C9) -------------------------------------------------------- | |
1421 bool __fastcall sub_4759C9(BLVFace *a1, int a2, int a3, __int16 a4) | |
1422 { | |
2138 | 1423 //unsigned int v4; // eax@1 |
1424 //int v5; // edx@4 | |
0 | 1425 __int16 v6; // si@4 |
2138 | 1426 //int v7; // edx@9 |
0 | 1427 __int16 v8; // si@9 |
2138 | 1428 //int v9; // edx@13 |
0 | 1429 __int16 v10; // si@13 |
1430 int v11; // esi@14 | |
1431 bool v12; // edi@14 | |
1432 int v13; // ecx@16 | |
1433 signed int v14; // edx@16 | |
1434 int v15; // eax@17 | |
1435 signed int v16; // ebx@18 | |
1436 int v17; // edi@20 | |
1437 signed int v18; // ST14_4@22 | |
1438 signed __int64 v19; // qtt@22 | |
1439 bool result; // eax@25 | |
1440 int v21; // [sp+14h] [bp-10h]@14 | |
1441 signed int v22; // [sp+18h] [bp-Ch]@1 | |
1442 int v23; // [sp+1Ch] [bp-8h]@2 | |
1443 signed int v24; // [sp+20h] [bp-4h]@2 | |
1444 Vec3_int_ **a4a; // [sp+30h] [bp+Ch]@3 | |
1445 Vec3_int_ **a4b; // [sp+30h] [bp+Ch]@8 | |
1446 Vec3_int_ **a4c; // [sp+30h] [bp+Ch]@12 | |
1447 signed int a4d; // [sp+30h] [bp+Ch]@14 | |
1448 | |
2138 | 1449 //v4 = a1->uAttributes; |
0 | 1450 v22 = 0; |
2138 | 1451 if ( BYTE1(a1->uAttributes) & 1 ) |
0 | 1452 { |
1453 v23 = (signed __int16)a3; | |
1454 v24 = SHIWORD(a3); | |
1455 if ( a1->uNumVertices ) | |
1456 { | |
1457 a4a = &pOutdoor->pBModels[a2].pVertices.pVertices; | |
1458 do | |
1459 { | |
2138 | 1460 //v5 = 2 * v22; |
0 | 1461 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].x); |
1462 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4a)[a1->pVertexIDs[v22]].y); | |
1463 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].x); | |
2138 | 1464 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = v6 = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4a)[a1->pVertexIDs[v22 + 1]].y); |
0 | 1465 ++v22; |
1466 } | |
1467 while ( v22 < a1->uNumVertices ); | |
1468 } | |
1469 } | |
1470 else | |
1471 { | |
2138 | 1472 if ( BYTE1(a1->uAttributes) & 2 ) |
0 | 1473 { |
1474 v23 = (signed __int16)a3; | |
1475 v24 = a4; | |
1476 if ( a1->uNumVertices ) | |
1477 { | |
1478 a4b = &pOutdoor->pBModels[a2].pVertices.pVertices; | |
1479 do | |
1480 { | |
2138 | 1481 //v7 = 2 * v22; |
0 | 1482 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pXInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].x); |
1483 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4b)[a1->pVertexIDs[v22]].z); | |
1484 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pXInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].x); | |
2138 | 1485 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = v8 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4b)[a1->pVertexIDs[v22 + 1]].z); |
0 | 1486 ++v22; |
1487 } | |
1488 while ( v22 < a1->uNumVertices ); | |
1489 } | |
1490 } | |
1491 else | |
1492 { | |
1493 v23 = SHIWORD(a3); | |
1494 v24 = a4; | |
1495 if ( a1->uNumVertices ) | |
1496 { | |
1497 a4c = &pOutdoor->pBModels[a2].pVertices.pVertices; | |
1498 do | |
1499 { | |
2138 | 1500 //v9 = 2 * v22; |
0 | 1501 word_720A70_intercepts_xs_plus_xs[2 * v22] = a1->pYInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].y); |
1502 word_7209A0_intercepts_ys_plus_ys[2 * v22] = a1->pZInterceptDisplacements[v22] + LOWORD((*a4c)[a1->pVertexIDs[v22]].z); | |
1503 word_720A70_intercepts_xs_plus_xs[2 * v22 + 1] = a1->pYInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].y); | |
2138 | 1504 word_7209A0_intercepts_ys_plus_ys[2 * v22 + 1] = v10 = a1->pZInterceptDisplacements[v22 + 1] + LOWORD((*a4c)[a1->pVertexIDs[v22 + 1]].z); |
0 | 1505 ++v22; |
1506 } | |
1507 while ( v22 < a1->uNumVertices ); | |
1508 } | |
1509 } | |
1510 } | |
1511 v11 = 2 * a1->uNumVertices; | |
1512 a4d = 0; | |
1513 word_720A70_intercepts_xs_plus_xs[2 * a1->uNumVertices] = word_720A70_intercepts_xs_plus_xs[0]; | |
1514 word_7209A0_intercepts_ys_plus_ys[v11] = word_7209A0_intercepts_ys_plus_ys[0]; | |
1515 v21 = 0; | |
1516 v12 = word_7209A0_intercepts_ys_plus_ys[0] >= v24; | |
1517 if ( v11 <= 0 ) | |
1418 | 1518 return 0; |
0 | 1519 do |
1520 { | |
1521 if ( a4d >= 2 ) | |
1522 break; | |
1523 v13 = v21; | |
1524 v14 = word_7209A0_intercepts_ys_plus_ys[v21 + 1]; | |
1110 | 1525 if ( v12 ^ (v14 >= v24) ) |
0 | 1526 { |
1527 v15 = word_720A70_intercepts_xs_plus_xs[v13 + 1]; | |
1528 if ( v15 >= v23 ) | |
1529 v16 = 0; | |
1530 else | |
1531 v16 = 2; | |
1110 | 1532 v17 = v16 | (word_720A70_intercepts_xs_plus_xs[v13] < v23); |
0 | 1533 if ( v17 != 3 ) |
1534 { | |
1535 if ( !v17 | |
1536 || (v18 = v15 - word_720A70_intercepts_xs_plus_xs[v13], | |
1537 LODWORD(v19) = v18 << 16, | |
1538 HIDWORD(v19) = v18 >> 16, | |
1539 word_720A70_intercepts_xs_plus_xs[v13] | |
1540 + ((signed int)(((unsigned __int64)(v19 | |
1541 / (v14 - word_7209A0_intercepts_ys_plus_ys[v13]) | |
1542 * ((v24 - (signed int)word_7209A0_intercepts_ys_plus_ys[v13]) << 16)) >> 16) | |
1543 + 32768) >> 16) >= v23) ) | |
1544 ++a4d; | |
1545 } | |
1546 } | |
1547 ++v21; | |
1548 v12 = v14 >= v24; | |
1549 } | |
1550 while ( v21 < v11 ); | |
1551 result = 1; | |
1552 if ( a4d != 1 ) | |
1553 result = 0; | |
1554 return result; | |
1555 } | |
1556 | |
1557 //----- (00475D85) -------------------------------------------------------- | |
1558 bool __fastcall sub_475D85(Vec3_int_ *a1, Vec3_int_ *a2, int *a3, BLVFace *a4) | |
1559 { | |
1560 BLVFace *v4; // ebx@1 | |
1561 int v5; // ST24_4@2 | |
1562 int v6; // ST28_4@2 | |
1563 int v7; // edi@2 | |
1564 int v8; // eax@5 | |
1565 signed int v9; // esi@5 | |
1566 signed __int64 v10; // qtt@10 | |
1567 Vec3_int_ *v11; // esi@11 | |
1568 int v12; // ST14_4@11 | |
1569 Vec3_int_ *v14; // [sp+Ch] [bp-18h]@1 | |
1570 Vec3_int_ *v15; // [sp+14h] [bp-10h]@1 | |
1571 int v16; // [sp+18h] [bp-Ch]@2 | |
1572 int v17; // [sp+20h] [bp-4h]@10 | |
1573 int a4b; // [sp+30h] [bp+Ch]@2 | |
1574 int a4c; // [sp+30h] [bp+Ch]@9 | |
1575 signed int a4a; // [sp+30h] [bp+Ch]@10 | |
1576 | |
1577 v4 = a4; | |
1578 v15 = a2; | |
1579 v14 = a1; | |
1580 if ( BYTE3(a4->uAttributes) & 0x20 | |
1581 || (v5 = (unsigned __int64)(a2->x * (signed __int64)a4->pFacePlane_old.vNormal.x) >> 16, | |
1582 a4b = (unsigned __int64)(a2->y * (signed __int64)a4->pFacePlane_old.vNormal.y) >> 16, | |
1583 v6 = (unsigned __int64)(a2->z * (signed __int64)v4->pFacePlane_old.vNormal.z) >> 16, | |
1584 v7 = v5 + v6 + a4b, | |
1585 (v16 = v5 + v6 + a4b) == 0) | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
675
diff
changeset
|
1586 || v7 > 0 && !v4->Portal()) |
0 | 1587 return 0; |
1588 v8 = v4->pFacePlane_old.vNormal.z * a1->z; | |
1589 v9 = -(v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x); | |
1590 if ( v7 <= 0 ) | |
1591 { | |
1592 if ( v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x < 0 ) | |
1593 return 0; | |
1594 } | |
1595 else | |
1596 { | |
1597 if ( v9 < 0 ) | |
1598 return 0; | |
1599 } | |
1600 a4c = abs(-(v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x)) >> 14; | |
1601 if ( a4c > abs(v7) | |
1602 || (LODWORD(v10) = v9 << 16, HIDWORD(v10) = v9 >> 16, a4a = v10 / v16, v17 = v10 / v16, v17 > *a3 << 16) | |
1603 || (v11 = v14, | |
1604 LOWORD(v12) = LOWORD(v14->x) | |
1605 + (((unsigned int)((unsigned __int64)(v17 * (signed __int64)v15->x) >> 16) + 32768) >> 16), | |
1606 HIWORD(v12) = LOWORD(v11->y) | |
1607 + (((unsigned int)((unsigned __int64)(v17 * (signed __int64)v15->y) >> 16) + 32768) >> 16), | |
1608 !sub_475665( | |
1609 v4, | |
1610 v12, | |
1611 LOWORD(v11->z) + (((unsigned int)((unsigned __int64)(v17 * (signed __int64)v15->z) >> 16) + 32768) >> 16))) ) | |
1612 return 0; | |
1613 *a3 = a4a >> 16; | |
1614 return 1; | |
1615 } | |
1616 | |
1617 //----- (00475F30) -------------------------------------------------------- | |
1618 bool __fastcall sub_475F30(int *a1, BLVFace *a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9) | |
1619 { | |
2138 | 1620 //BLVFace *v9; // ebx@1 |
0 | 1621 int v10; // ST20_4@2 |
1622 int v11; // ST28_4@2 | |
1623 int v12; // ST24_4@2 | |
1624 char v13; // zf@2 | |
1625 int v14; // edi@2 | |
1626 int v15; // eax@5 | |
1627 signed int v16; // esi@5 | |
1628 int v17; // ST20_4@9 | |
1629 signed __int64 v18; // qtt@10 | |
1630 int v19; // ST14_4@11 | |
2138 | 1631 //int *v21; // [sp+14h] [bp-10h]@1 |
0 | 1632 int v22; // [sp+1Ch] [bp-8h]@2 |
1633 int v23; // [sp+1Ch] [bp-8h]@10 | |
1634 signed int v24; // [sp+20h] [bp-4h]@10 | |
1635 | |
2138 | 1636 //v9 = a2; |
1637 //v21 = a1; | |
1638 if ( a2->Ethereal() | |
0 | 1639 || (v10 = (unsigned __int64)(a6 * (signed __int64)a2->pFacePlane_old.vNormal.x) >> 16, |
1640 v11 = (unsigned __int64)(a7 * (signed __int64)a2->pFacePlane_old.vNormal.y) >> 16, | |
1641 v12 = (unsigned __int64)(a8 * (signed __int64)a2->pFacePlane_old.vNormal.z) >> 16, | |
1642 v13 = v10 + v12 + v11 == 0, | |
1643 v14 = v10 + v12 + v11, | |
1644 v22 = v10 + v12 + v11, | |
1645 v13) | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
675
diff
changeset
|
1646 || v14 > 0 && !a2->Portal()) |
0 | 1647 return 0; |
1648 v15 = a4 * a2->pFacePlane_old.vNormal.y; | |
1649 v16 = -(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z); | |
1650 if ( v14 <= 0 ) | |
1651 { | |
1652 if ( a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z < 0 ) | |
1653 return 0; | |
1654 } | |
1655 else | |
1656 { | |
1657 if ( v16 < 0 ) | |
1658 return 0; | |
1659 } | |
1660 v17 = abs(-(a2->pFacePlane_old.dist + v15 + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z)) >> 14; | |
1661 if ( v17 > abs(v14) | |
2138 | 1662 || (LODWORD(v18) = v16 << 16, HIDWORD(v18) = v16 >> 16, v24 = v18 / v22, v23 = v18 / v22, v23 > *a1 << 16) |
0 | 1663 || (LOWORD(v19) = a3 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a6) >> 16) + 32768) >> 16), |
1664 HIWORD(v19) = a4 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a7) >> 16) + 32768) >> 16), | |
2138 | 1665 !sub_4759C9(a2, a9, v19, |
0 | 1666 a5 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a8) >> 16) + 32768) >> 16))) ) |
1667 return 0; | |
2138 | 1668 *a1 = v24 >> 16; |
0 | 1669 return 1; |
1670 } | |
1671 | |
1672 //----- (004760D5) -------------------------------------------------------- | |
1673 PartyAction ActionQueue::Next() | |
1674 { | |
1675 if (!uNumActions) | |
1676 return PARTY_INVALID; | |
1677 | |
1980 | 1678 PartyAction result = pActions[0]; |
0 | 1679 for (unsigned int i = 0; i < uNumActions - 1; ++i) |
1680 pActions[i] = pActions[i + 1]; | |
1681 --uNumActions; | |
1682 | |
1683 return result; | |
1684 } | |
1685 | |
1686 //----- (004775ED) -------------------------------------------------------- | |
1687 int stru6_stru1_indoor_sw_billboard::_4775ED(float a2) | |
1688 { | |
1689 char *v2; // edi@1 | |
1690 int v3; // eax@1 | |
1691 char *v4; // edx@2 | |
1692 char *v5; // esi@3 | |
1693 double v6; // st7@6 | |
1694 signed __int64 v7; // ST84_8@6 | |
1695 double v8; // ST0C_8@6 | |
1696 int v9; // esi@6 | |
1697 double v10; // ST44_8@6 | |
1698 int v11; // ecx@6 | |
1699 double v12; // ST34_8@6 | |
1700 int v13; // ecx@6 | |
1701 double v14; // ST14_8@6 | |
1702 double v15; // st7@8 | |
1703 unsigned int v16; // ecx@8 | |
1704 signed __int64 v17; // ST64_8@8 | |
1705 double v18; // ST24_8@8 | |
1706 int v19; // edi@8 | |
1707 double v20; // ST3C_8@8 | |
1708 int v21; // ecx@8 | |
1709 double v22; // ST2C_8@8 | |
1710 int v23; // ST9C_4@8 | |
1711 double v24; // ST1C_8@8 | |
1712 int *v25; // edi@8 | |
1713 int v26; // esi@8 | |
1714 int *v27; // edi@10 | |
1715 int v28; // esi@10 | |
1716 int result; // eax@12 | |
1717 __int64 v30; // [sp+A8h] [bp-30h]@8 | |
1718 float v31; // [sp+B0h] [bp-28h]@6 | |
1719 float v32; // [sp+B4h] [bp-24h]@6 | |
1720 int v33; // [sp+B8h] [bp-20h]@6 | |
1721 int v34; // [sp+BCh] [bp-1Ch]@2 | |
1722 stru6_stru1_indoor_sw_billboard *v35; // [sp+C0h] [bp-18h]@1 | |
1723 float v36; // [sp+C4h] [bp-14h]@6 | |
1724 int v37; // [sp+C8h] [bp-10h]@6 | |
1725 int v38; // [sp+CCh] [bp-Ch]@1 | |
1726 float v39; // [sp+D0h] [bp-8h]@6 | |
1727 int *v40; // [sp+D4h] [bp-4h]@2 | |
1728 | |
1390 | 1729 v2 = (char *)&this->field_64[4 * this->uNumVertices]; |
0 | 1730 v38 = 0; |
1390 | 1731 *(int *)v2 = this->field_64[0]; |
0 | 1732 v2 += 4; |
1390 | 1733 *(int *)v2 = this->field_64[1]; |
0 | 1734 v2 += 4; |
1390 | 1735 *(int *)v2 = this->field_64[2]; |
1736 *((int *)v2 + 1) = this->field_64[3]; | |
1737 v3 = this->uNumVertices; | |
0 | 1738 v35 = this; |
1739 if ( v3 > 0 ) | |
1740 { | |
1390 | 1741 v40 = &this->field_64[20]; |
1742 v4 = (char *)&this->field_64[3] + 3; | |
0 | 1743 v34 = v3; |
1744 while ( 1 ) | |
1745 { | |
1746 v5 = v4 - 15; | |
1747 if ( *(float *)(v4 - 15) <= (double)a2 && *(float *)(v4 + 1) <= (double)a2 ) | |
1418 | 1748 { |
1749 v4 += 16; | |
1750 --v34; | |
1751 if ( !v34 ) | |
1752 return this->uNumVertices = v38; | |
1753 continue; | |
1754 } | |
0 | 1755 if ( *(float *)v5 <= (double)a2 ) |
1418 | 1756 { |
1757 v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); | |
1758 v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4; | |
1759 v36 = v6; | |
1760 v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11); | |
1761 v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7); | |
1762 *(float *)&v37 = (double)v7 * v6; | |
1763 v8 = *(float *)&v37 + 6.7553994e15; | |
1764 v9 = (unsigned __int8)*v4; | |
1765 *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; | |
1766 v10 = *(float *)&v37 + 6.7553994e15; | |
1767 v11 = (unsigned __int8)*(v4 - 2); | |
1768 v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1); | |
1769 v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36; | |
1770 v12 = v39 + 6.7553994e15; | |
1771 v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2); | |
1772 v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; | |
1773 v14 = v39 + 6.7553994e15; | |
1774 v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8); | |
1775 //this = v35; | |
1776 v5 = (char *)&v30 + 4; | |
1777 } | |
1778 else if ( *(float *)(v4 + 1) <= (double)a2 ) | |
0 | 1779 { |
1780 v15 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); | |
1781 v16 = (unsigned __int8)*v4; | |
1782 HIDWORD(v30) = LODWORD(a2); | |
1783 v17 = (unsigned __int8)v4[16] - v16; | |
1784 v36 = v15; | |
1785 v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v15 + *(float *)(v4 - 11); | |
1786 v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v15 + *(float *)(v4 - 7); | |
1787 v39 = (double)v17 * v15; | |
1788 v18 = v39 + 6.7553994e15; | |
1789 v19 = (unsigned __int8)*v4; | |
1790 v39 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; | |
1791 v20 = v39 + 6.7553994e15; | |
1792 v21 = (unsigned __int8)*(v4 - 2); | |
1793 v37 = LODWORD(v20) + (unsigned __int8)*(v4 - 1); | |
1794 v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v21) * v36; | |
1795 v22 = v39 + 6.7553994e15; | |
1796 v23 = LODWORD(v22) + (unsigned __int8)*(v4 - 2); | |
1797 v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; | |
1798 v24 = v39 + 6.7553994e15; | |
1799 v33 = (LODWORD(v24) + (*(int *)(v4 - 3) & 0xFF)) | ((v23 | ((v37 | ((LODWORD(v18) + v19) << 8)) << 8)) << 8); | |
1800 v25 = v40; | |
1801 *v40 = *(int *)v5; | |
1802 v26 = (int)(v5 + 4); | |
1803 ++v25; | |
1804 *v25 = *(int *)v26; | |
1805 v26 += 4; | |
1806 ++v25; | |
1807 ++v38; | |
1808 v40 += 4; | |
1809 *v25 = *(int *)v26; | |
1810 v25[1] = *(int *)(v26 + 4); | |
1418 | 1811 v5 = (char *)&v30 + 4; |
0 | 1812 } |
1813 v27 = v40; | |
1814 ++v38; | |
1815 *v40 = *(int *)v5; | |
1816 v28 = (int)(v5 + 4); | |
1817 ++v27; | |
1818 *v27 = *(int *)v28; | |
1819 v28 += 4; | |
1820 ++v27; | |
1821 v40 += 4; | |
1822 *v27 = *(int *)v28; | |
1823 v27[1] = *(int *)(v28 + 4); | |
1824 v4 += 16; | |
1825 --v34; | |
1826 if ( !v34 ) | |
1418 | 1827 return this->uNumVertices = v38; |
0 | 1828 } |
1418 | 1829 } |
1390 | 1830 return this->uNumVertices = v38; |
0 | 1831 } |
1832 | |
1833 //----- (00477927) -------------------------------------------------------- | |
1834 int stru6_stru1_indoor_sw_billboard::_477927(float a2) | |
1835 { | |
1836 char *v2; // edi@1 | |
1837 int v3; // eax@1 | |
1838 char *v4; // edx@2 | |
1839 char *v5; // esi@3 | |
1840 double v6; // st7@6 | |
1841 signed __int64 v7; // ST84_8@6 | |
1842 double v8; // ST0C_8@6 | |
1843 int v9; // esi@6 | |
1844 double v10; // ST44_8@6 | |
1845 int v11; // ecx@6 | |
1846 double v12; // ST34_8@6 | |
1847 int v13; // ecx@6 | |
1848 double v14; // ST14_8@6 | |
1849 double v15; // st7@8 | |
1850 unsigned int v16; // ecx@8 | |
1851 signed __int64 v17; // ST64_8@8 | |
1852 double v18; // ST24_8@8 | |
1853 int v19; // edi@8 | |
1854 double v20; // ST3C_8@8 | |
1855 int v21; // ecx@8 | |
1856 double v22; // ST2C_8@8 | |
1857 int v23; // ST9C_4@8 | |
1858 double v24; // ST1C_8@8 | |
1859 int *v25; // edi@8 | |
1860 int v26; // esi@8 | |
1861 int *v27; // edi@10 | |
1862 int v28; // esi@10 | |
1863 int result; // eax@12 | |
1864 __int64 v30; // [sp+A8h] [bp-30h]@8 | |
1865 float v31; // [sp+B0h] [bp-28h]@6 | |
1866 float v32; // [sp+B4h] [bp-24h]@6 | |
1867 int v33; // [sp+B8h] [bp-20h]@6 | |
1868 int v34; // [sp+BCh] [bp-1Ch]@2 | |
1869 stru6_stru1_indoor_sw_billboard *v35; // [sp+C0h] [bp-18h]@1 | |
1870 float v36; // [sp+C4h] [bp-14h]@6 | |
1871 int v37; // [sp+C8h] [bp-10h]@6 | |
1872 int v38; // [sp+CCh] [bp-Ch]@1 | |
1873 float v39; // [sp+D0h] [bp-8h]@6 | |
1874 int *v40; // [sp+D4h] [bp-4h]@2 | |
1875 | |
1390 | 1876 v2 = (char *)&this->field_64[4 * this->uNumVertices]; |
0 | 1877 v38 = 0; |
1390 | 1878 *(int *)v2 = this->field_64[0]; |
0 | 1879 v2 += 4; |
1390 | 1880 *(int *)v2 = this->field_64[1]; |
0 | 1881 v2 += 4; |
1390 | 1882 *(int *)v2 = this->field_64[2]; |
1883 *((int *)v2 + 1) = this->field_64[3]; | |
1884 v3 = this->uNumVertices; | |
0 | 1885 v35 = this; |
1886 if ( v3 > 0 ) | |
1887 { | |
1390 | 1888 v40 = &this->field_64[20]; |
1889 v4 = (char *)&this->field_64[3] + 3; | |
0 | 1890 v34 = v3; |
1891 while ( 1 ) | |
1892 { | |
1893 v5 = v4 - 15; | |
1894 if ( *(float *)(v4 - 15) >= (double)a2 && *(float *)(v4 + 1) >= (double)a2 ) | |
1418 | 1895 { |
1896 v4 += 16; | |
1897 --v34; | |
1898 if ( !v34 ) | |
1899 return this->uNumVertices = v38; | |
1900 continue; | |
1901 } | |
0 | 1902 if ( *(float *)v5 >= (double)a2 ) |
1418 | 1903 { |
1904 v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); | |
1905 v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4; | |
1906 v36 = v6; | |
1907 v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11); | |
1908 v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7); | |
1909 *(float *)&v37 = (double)v7 * v6; | |
1910 v8 = *(float *)&v37 + 6.7553994e15; | |
1911 v9 = (unsigned __int8)*v4; | |
1912 *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; | |
1913 v10 = *(float *)&v37 + 6.7553994e15; | |
1914 v11 = (unsigned __int8)*(v4 - 2); | |
1915 v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1); | |
1916 v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36; | |
1917 v12 = v39 + 6.7553994e15; | |
1918 v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2); | |
1919 v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; | |
1920 v14 = v39 + 6.7553994e15; | |
1921 v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8); | |
1922 //this = v35; | |
1923 v5 = (char *)&v30 + 4; | |
1924 } | |
1925 else if ( *(float *)(v4 + 1) >= (double)a2 ) | |
0 | 1926 { |
1927 v15 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); | |
1928 v16 = (unsigned __int8)*v4; | |
1929 HIDWORD(v30) = LODWORD(a2); | |
1930 v17 = (unsigned __int8)v4[16] - v16; | |
1931 v36 = v15; | |
1932 v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v15 + *(float *)(v4 - 11); | |
1933 v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v15 + *(float *)(v4 - 7); | |
1934 v39 = (double)v17 * v15; | |
1935 v18 = v39 + 6.7553994e15; | |
1936 v19 = (unsigned __int8)*v4; | |
1937 v39 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; | |
1938 v20 = v39 + 6.7553994e15; | |
1939 v21 = (unsigned __int8)*(v4 - 2); | |
1940 v37 = LODWORD(v20) + (unsigned __int8)*(v4 - 1); | |
1941 v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v21) * v36; | |
1942 v22 = v39 + 6.7553994e15; | |
1943 v23 = LODWORD(v22) + (unsigned __int8)*(v4 - 2); | |
1944 v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; | |
1945 v24 = v39 + 6.7553994e15; | |
1946 v33 = (LODWORD(v24) + (*(int *)(v4 - 3) & 0xFF)) | ((v23 | ((v37 | ((LODWORD(v18) + v19) << 8)) << 8)) << 8); | |
1947 v25 = v40; | |
1948 *v40 = *(int *)v5; | |
1949 v26 = (int)(v5 + 4); | |
1950 ++v25; | |
1951 *v25 = *(int *)v26; | |
1952 v26 += 4; | |
1953 ++v25; | |
1954 ++v38; | |
1955 v40 += 4; | |
1956 *v25 = *(int *)v26; | |
1957 v25[1] = *(int *)(v26 + 4); | |
1418 | 1958 v5 = (char *)&v30 + 4; |
0 | 1959 } |
1960 v27 = v40; | |
1961 ++v38; | |
1962 *v40 = *(int *)v5; | |
1963 v28 = (int)(v5 + 4); | |
1964 ++v27; | |
1965 *v27 = *(int *)v28; | |
1966 v28 += 4; | |
1967 ++v27; | |
1968 v40 += 4; | |
1969 *v27 = *(int *)v28; | |
1970 v27[1] = *(int *)(v28 + 4); | |
1971 v4 += 16; | |
1972 --v34; | |
1973 if ( !v34 ) | |
1418 | 1974 return this->uNumVertices = v38; |
0 | 1975 } |
1418 | 1976 } |
1390 | 1977 return this->uNumVertices = v38; |
0 | 1978 } |
1979 | |
1980 //----- (00477C61) -------------------------------------------------------- | |
1981 int stru6_stru1_indoor_sw_billboard::sub_477C61() | |
1982 { | |
998 | 1983 //stru6_stru1_indoor_sw_billboard *v1; // ebx@1 |
0 | 1984 int v2; // ecx@2 |
1985 int v3; // eax@3 | |
1986 double v4; // st7@4 | |
1987 double v5; // st7@5 | |
1988 double v6; // st6@5 | |
1989 double v7; // st5@6 | |
1990 float v8; // ST30_4@8 | |
1991 float v9; // ST24_4@8 | |
1992 double v10; // st7@8 | |
1993 double v11; // st6@8 | |
1994 double v12; // st5@8 | |
1995 float v13; // ST24_4@13 | |
1996 int v14; // esi@13 | |
1997 char *v15; // esi@15 | |
1638
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
1998 //signed int v16; // eax@16 |
0 | 1999 __int16 v17; // fps@16 |
2000 unsigned __int8 v18; // c2@16 | |
2001 unsigned __int8 v19; // c3@16 | |
2002 double v20; // st6@16 | |
2003 float v21; // ST18_4@17 | |
2004 float v22; // ST2C_4@17 | |
2005 float v23; // ST34_4@17 | |
2006 float v24; // ST24_4@17 | |
2007 double v25; // st7@17 | |
2008 double v26; // st6@17 | |
2009 float v27; // ST34_4@18 | |
2010 float v28; // ST30_4@18 | |
2011 int v29; // eax@19 | |
2012 signed int v31; // [sp+8h] [bp-28h]@15 | |
2013 float v32; // [sp+Ch] [bp-24h]@16 | |
2014 float v33; // [sp+14h] [bp-1Ch]@16 | |
2015 float v34; // [sp+18h] [bp-18h]@16 | |
2016 float v35; // [sp+1Ch] [bp-14h]@17 | |
2017 float v36; // [sp+20h] [bp-10h]@4 | |
2018 float v37; // [sp+24h] [bp-Ch]@4 | |
2019 float v38; // [sp+24h] [bp-Ch]@16 | |
2020 float v39; // [sp+28h] [bp-8h]@9 | |
2021 float v40; // [sp+28h] [bp-8h]@16 | |
2022 float v41; // [sp+2Ch] [bp-4h]@6 | |
2023 float v42; // [sp+2Ch] [bp-4h]@9 | |
2024 | |
998 | 2025 //v1 = this; |
0 | 2026 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) |
2027 { | |
2028 v2 = 0; | |
1390 | 2029 if ( this->uNumVertices > 0 ) |
998 | 2030 { |
2031 v3 = (int)&this->field_14[1]; | |
0 | 2032 do |
2033 { | |
2034 v4 = *(float *)(v3 - 4); | |
2035 LODWORD(v37) = *(int *)v3; | |
2036 LODWORD(v36) = *(int *)(v3 + 4); | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2037 if (pGame->pIndoorCameraD3D->sRotationX) |
0 | 2038 { |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2039 v5 = v4 - (double)pGame->pIndoorCameraD3D->vPartyPos.x; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2040 v6 = v37 - (double)pGame->pIndoorCameraD3D->vPartyPos.y; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2041 //if ( pRenderer->pRenderD3D ) |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2042 //{ |
1642 | 2043 v41 = pGame->pIndoorCameraD3D->fRotationYSine * v6 + pGame->pIndoorCameraD3D->fRotationYCosine * v5; |
2044 v7 = pGame->pIndoorCameraD3D->fRotationYSine * v5 - pGame->pIndoorCameraD3D->fRotationYCosine * v6; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2045 /*} |
0 | 2046 else |
2047 { | |
2048 v41 = pBLVRenderParams->fCosineY * v5 - pBLVRenderParams->fSineY * v6; | |
2049 v7 = pBLVRenderParams->fSineY * v5 + pBLVRenderParams->fCosineY * v6; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2050 }*/ |
0 | 2051 v8 = v7; |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2052 v9 = v36 - (double)pGame->pIndoorCameraD3D->vPartyPos.z; |
1642 | 2053 v10 = pGame->pIndoorCameraD3D->fRotationXCosine * v41 - pGame->pIndoorCameraD3D->fRotationXSine * v9; |
0 | 2054 v11 = v8; |
1642 | 2055 v12 = pGame->pIndoorCameraD3D->fRotationXCosine * v9 + pGame->pIndoorCameraD3D->fRotationXSine * v41; |
0 | 2056 } |
2057 else | |
2058 { | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2059 v42 = v4 - (double)pGame->pIndoorCameraD3D->vPartyPos.x; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2060 v39 = v37 - (double)pGame->pIndoorCameraD3D->vPartyPos.y; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2061 //if ( pRenderer->pRenderD3D ) |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2062 //{ |
1642 | 2063 v10 = pGame->pIndoorCameraD3D->fRotationYSine * v39 + pGame->pIndoorCameraD3D->fRotationYCosine * v42; |
2064 v11 = pGame->pIndoorCameraD3D->fRotationYSine * v42 - pGame->pIndoorCameraD3D->fRotationYCosine * v39; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2065 /*} |
0 | 2066 else |
2067 { | |
2068 v10 = pBLVRenderParams->fCosineY * v42 - pBLVRenderParams->fSineY * v39; | |
2069 v11 = pBLVRenderParams->fSineY * v42 + pBLVRenderParams->fCosineY * v39; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2070 }*/ |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2071 v12 = v36 - (double)pGame->pIndoorCameraD3D->vPartyPos.z; |
0 | 2072 } |
2073 v13 = v12; | |
2074 ++v2; | |
2075 *(int *)(v3 + 84) = LODWORD(v13); | |
2076 v14 = *(int *)(v3 + 8); | |
2077 *(float *)(v3 + 76) = v10; | |
2078 *(int *)(v3 + 88) = v14; | |
2079 *(float *)(v3 + 80) = v11; | |
2080 v3 += 16; | |
2081 } | |
1390 | 2082 while ( v2 < this->uNumVertices ); |
0 | 2083 } |
2084 } | |
2085 else | |
2086 { | |
2087 v15 = (char *)&this->field_14[1]; | |
2088 v31 = 3; | |
2089 do | |
2090 { | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2091 v40 = (double)stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX) * 0.0000152587890625; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2092 v32 = (double)stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX) * 0.0000152587890625; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2093 v34 = (double)stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY) * 0.0000152587890625; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2094 v33 = (double)stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY) * 0.0000152587890625; |
1638
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
2095 //v16 = stru_5C6E00->Sin(pODMRenderParams->rotation_y); |
0 | 2096 LODWORD(v38) = *(int *)v15; |
2097 //UNDEF(v17); | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2098 v20 = *((float *)v15 - 1) - (double)pGame->pIndoorCameraD3D->vPartyPos.x; |
1090 | 2099 //if ( v19 | v18 ) |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2100 if (pGame->pIndoorCameraD3D->vPartyPos.x == 0) |
0 | 2101 { |
2102 v27 = v20; | |
2103 LODWORD(v35) = *((int *)v15 + 1); | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2104 v28 = v38 - (double)pGame->pIndoorCameraD3D->vPartyPos.y; |
0 | 2105 v25 = v33 * v28 + v34 * v27; |
2106 v26 = v34 * v28 - v33 * v27; | |
2107 } | |
2108 else | |
2109 { | |
2110 v21 = v20; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2111 v22 = v38 - (double)pGame->pIndoorCameraD3D->vPartyPos.y; |
0 | 2112 v23 = v33 * v22 + v34 * v21; |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2113 v24 = *((float *)v15 + 1) - (double)pGame->pIndoorCameraD3D->vPartyPos.z; |
0 | 2114 v25 = v32 * v24 + v40 * v23; |
2115 v26 = v34 * v22 - v33 * v21; | |
2116 v35 = v40 * v24 - v32 * v23; | |
2117 } | |
2118 *((int *)v15 + 21) = LODWORD(v35); | |
2119 v29 = *((int *)v15 + 2); | |
2120 *((float *)v15 + 19) = v25; | |
2121 *((int *)v15 + 22) = v29; | |
2122 *((float *)v15 + 20) = v26; | |
2123 v15 += 16; | |
2124 --v31; | |
2125 } | |
2126 while ( v31 ); | |
2127 } | |
1390 | 2128 this->uNumVertices = 3; |
0 | 2129 return 1; |
2130 } | |
2131 | |
2132 //----- (00477F63) -------------------------------------------------------- | |
2133 bool stru6_stru1_indoor_sw_billboard::sub_477F63() | |
2134 { | |
2135 signed int v1; // ebx@1 | |
2136 stru6_stru1_indoor_sw_billboard *v2; // esi@1 | |
2137 double v3; // st7@2 | |
2138 int v4; // edx@4 | |
2139 char *v5; // ecx@5 | |
2140 int v6; // edi@5 | |
2141 float v7; // ST08_4@13 | |
2142 signed int v9; // [sp+Ch] [bp-8h]@1 | |
2143 float v10; // [sp+10h] [bp-4h]@2 | |
2144 | |
1980 | 2145 stru6_stru1_indoor_sw_billboard* a1 = this; |
0 | 2146 |
2147 v1 = 0; | |
2148 v2 = a1; | |
2149 v9 = 0; | |
2150 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
2151 { | |
2152 v10 = 16192.0; | |
1641 | 2153 v3 = (double)pBLVRenderParams->fov_rad_fixpoint * 0.000015258789; |
0 | 2154 } |
2155 else | |
2156 { | |
1637 | 2157 v10 = (double)pODMRenderParams->shading_dist_mist; |
0 | 2158 v3 = 8.0; |
2159 } | |
1390 | 2160 v4 = a1->uNumVertices; |
0 | 2161 if ( v4 <= 0 ) |
1418 | 2162 { |
2163 memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4); | |
2164 return v2->uNumVertices != 0; | |
2165 } | |
0 | 2166 v5 = (char *)&a1->field_14[20]; |
2167 v6 = v4; | |
2168 do | |
2169 { | |
2170 if ( v3 >= *(float *)v5 || *(float *)v5 >= (double)v10 ) | |
2171 { | |
2172 if ( v3 < *(float *)v5 ) | |
2173 v9 = 1; | |
2174 else | |
2175 v1 = 1; | |
2176 } | |
2177 v5 += 16; | |
2178 --v6; | |
2179 } | |
2180 while ( v6 ); | |
2181 if ( !v1 ) | |
2182 { | |
2183 if ( v9 ) | |
2184 { | |
2185 v2->_477927(v10); | |
1390 | 2186 return v2->uNumVertices != 0; |
0 | 2187 } |
2188 memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4); | |
1390 | 2189 return v2->uNumVertices != 0; |
0 | 2190 } |
2191 v7 = v3; | |
2192 _4775ED(v7); | |
1390 | 2193 return v2->uNumVertices != 0; |
0 | 2194 } |
2195 | |
2196 //----- (0047802A) -------------------------------------------------------- | |
2197 int stru6_stru1_indoor_sw_billboard::sub_47802A() | |
2198 { | |
2199 double v6; // st7@4 | |
2200 double v12; // st7@16 | |
2201 signed int v16; // [sp+38h] [bp-Ch]@1 | |
2202 int a6; // [sp+3Ch] [bp-8h]@5 | |
2203 int a5; // [sp+40h] [bp-4h]@5 | |
2204 | |
1980 | 2205 stru6_stru1_indoor_sw_billboard* a1 = this; |
0 | 2206 |
2207 v16 = 0; | |
2208 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) | |
2209 { | |
1390 | 2210 for(int i = 0; i < a1->uNumVertices; i++) |
1117
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2211 { |
1641 | 2212 v6 = (double)pBLVRenderParams->fov_rad_fixpoint * 0.000015258789 / a1->field_B4[i*4]; |
1117
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2213 if ( pRenderer->pRenderD3D ) |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2214 { |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2215 pGame->pIndoorCameraD3D->Project( |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2216 round(a1->field_B4[i*4]), |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2217 round(a1->field_B4[i*4+1]), |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2218 round(a1->field_B4[i*4+2]), |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2219 &a5, |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2220 &a6); |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2221 a1->field_B4[i*4+16] = (double)a5; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2222 a1->field_B4[i*4+17] = (double)a6; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2223 a1->field_B4[i*4+18] = round(a1->field_B4[i*4]); |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2224 } |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2225 else |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2226 { |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2227 a1->field_B4[i*4+16] = (double)pBLVRenderParams->uViewportCenterX - v6 * a1->field_B4[i*4+1]; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2228 a1->field_B4[i*4+17] = (double)pBLVRenderParams->uViewportCenterY - v6 * a1->field_B4[i*4+2]; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2229 a1->field_B4[i*4+18] = a1->field_B4[i*4]; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2230 } |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2231 a1->field_B4[i*4+19] = a1->field_B4[i*4+3]; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2232 if ( (double)(signed int)pViewport->uViewportTL_X <= a1->field_B4[i*4+16] |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2233 && (double)(signed int)pViewport->uViewportBR_X > a1->field_B4[i*4+16] |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2234 && (double)(signed int)pViewport->uViewportTL_Y <= a1->field_B4[i*4+17] |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2235 && (double)(signed int)pViewport->uViewportBR_Y > a1->field_B4[i*4+17] ) |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2236 v16 = 1; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2237 } |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2238 } |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2239 else |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2240 { |
1390 | 2241 for(int i = 0; i < a1->uNumVertices; i++) |
1117
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2242 { |
1637 | 2243 v12 = (double)pODMRenderParams->int_fov_rad / a1->field_B4[i*4]; |
1117
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2244 a1->field_B4[i*4+20] = (double)pViewport->uScreenCenterX - v12 * a1->field_B4[i*4+1]; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2245 a1->field_B4[i*4+21] = (double)pViewport->uScreenCenterY - v12 * a1->field_B4[i*4+2]; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2246 *((int *)&a1->field_B4[i*4+22]) = (int)a1->field_B4[i*4]; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2247 *((int *)&a1->field_B4[i*4+23]) = a1->field_B4[i*4+3]; |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2248 if ( (double)(signed int)pViewport->uViewportTL_X <= a1->field_B4[i*4+20] |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2249 && (double)(signed int)pViewport->uViewportBR_X > a1->field_B4[i*4+20] |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2250 && (double)(signed int)pViewport->uViewportTL_Y <= a1->field_B4[i*4+21] |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2251 && (double)(signed int)pViewport->uViewportBR_Y > a1->field_B4[i*4+21] ) |
ad89d1905b48
* stru6_stru1_indoor_sw_billboard::sub_47802A() cleaned, fireball working
zipi
parents:
1113
diff
changeset
|
2252 v16 = 1; |
0 | 2253 } |
2254 } | |
2255 return v16; | |
2256 } | |
2257 | |
2258 // 73C84C: using guessed type char static_RenderBuildingsD3D_byte_73C84C_init_flag; | |
2259 | |
2260 //----- (00479089) -------------------------------------------------------- | |
323 | 2261 bool __fastcall IsBModelVisible(unsigned int uModelID, int *reachable) |
0 | 2262 { |
2263 BSPModel *v2; // eax@1 | |
2264 int v3; // edi@1 | |
2265 int v4; // ebx@1 | |
2266 int v5; // ST28_4@1 | |
2267 int v6; // ecx@1 | |
2268 int v7; // ebx@3 | |
2269 int v8; // eax@3 | |
2270 int v9; // eax@3 | |
323 | 2271 //int v10; // ebx@3 |
0 | 2272 signed int v11; // esi@6 |
2273 int v12; // esi@8 | |
2274 bool result; // eax@9 | |
323 | 2275 //unsigned int v14; // [sp+Ch] [bp-20h]@1 |
0 | 2276 int v15; // [sp+Ch] [bp-20h]@5 |
323 | 2277 //int *v16; // [sp+10h] [bp-1Ch]@1 |
0 | 2278 int v17; // [sp+1Ch] [bp-10h]@1 |
2279 int v18; // [sp+20h] [bp-Ch]@1 | |
2280 int v19; // [sp+20h] [bp-Ch]@3 | |
2281 int angle; // [sp+24h] [bp-8h]@1 | |
2282 int v21; // [sp+28h] [bp-4h]@1 | |
323 | 2283 //int v22; // [sp+28h] [bp-4h]@3 |
2284 | |
2285 //v16 = unused; | |
1637 | 2286 angle = (signed int)(pODMRenderParams->uCameraFovInDegrees << 11) / 360 >> 1; |
323 | 2287 //v14 = uModelID; |
0 | 2288 v2 = &pOutdoor->pBModels[uModelID]; |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2289 v3 = v2->vBoundingCenter.x - pGame->pIndoorCameraD3D->vPartyPos.x; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2290 v4 = v2->vBoundingCenter.y - pGame->pIndoorCameraD3D->vPartyPos.y; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2291 v5 = stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY); |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2292 v21 = stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY); |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2293 v18 = stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationX); |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2294 stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationX); |
0 | 2295 v6 = v5; |
2296 v17 = v3 * v5 + v4 * v21; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2297 if (pGame->pIndoorCameraD3D->sRotationX) |
0 | 2298 v17 = (unsigned __int64)(v17 * (signed __int64)v18) >> 16; |
2299 v19 = v4 * v6 - v3 * v21; | |
2300 v7 = abs(v4); | |
2301 v8 = abs(v3); | |
322 | 2302 v9 = int_get_vector_length(v8, v7, 0); |
323 | 2303 //v10 = v14 * 188; |
2304 //v22 = v9; | |
2305 *reachable = false; | |
2306 if ( v9 < pOutdoor->pBModels[uModelID].sBoundingRadius + 256 ) | |
2307 *reachable = true; | |
2308 v15 = stru_5C6E00->Sin(angle); | |
0 | 2309 if ( v19 >= 0 ) |
323 | 2310 v11 = ((unsigned __int64)(v15 * (signed __int64)v17) >> 16) - ((unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)v19) >> 16); |
2311 else | |
2312 v11 = ((unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)v19) >> 16) + ((unsigned __int64)(v15 * (signed __int64)v17) >> 16); | |
0 | 2313 v12 = v11 >> 16; |
1637 | 2314 if ( v9 <= pODMRenderParams->shading_dist_mist + 2048 ) |
0 | 2315 { |
79 | 2316 //if ( abs(v12) > *(int *)((char *)&pOutdoor->pBModels->sBoundingRadius + v10) + 512 ) |
323 | 2317 if ( abs(v12) > pOutdoor->pBModels[uModelID].sBoundingRadius + 512 ) |
0 | 2318 { |
2319 result = v12 < 0; | |
2320 LOBYTE(result) = v12 >= 0; | |
323 | 2321 return result; |
2322 } | |
2323 else | |
2324 return true; | |
2325 } | |
2326 return false; | |
0 | 2327 } |
2328 | |
2329 //----- (00479295) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
2330 int Polygon::_479295() |
0 | 2331 { |
2332 ODMFace *v2; // esi@1 | |
2333 int v3; // ecx@4 | |
2334 int v4; // eax@4 | |
2335 int v5; // edx@4 | |
2336 int v6; // ST14_4@5 | |
2337 int v7; // ST04_4@5 | |
2338 stru149 *v8; // ecx@5 | |
2339 Vec3_int_ thisa; // [sp+Ch] [bp-10h]@8 | |
2340 int v11; // [sp+18h] [bp-4h]@4 | |
2341 | |
2342 v2 = this->pODMFace; | |
2343 if ( !v2->pFacePlane.vNormal.z ) | |
2344 { | |
2345 v3 = v2->pFacePlane.vNormal.x; | |
2346 v4 = -v2->pFacePlane.vNormal.y; | |
2347 v5 = 0; | |
2348 v11 = 65536; | |
1418 | 2349 } |
2350 else if ( (v2->pFacePlane.vNormal.x || v2->pFacePlane.vNormal.y) && abs(v2->pFacePlane.vNormal.z) < 59082 ) | |
0 | 2351 { |
2352 thisa.x = -v2->pFacePlane.vNormal.y; | |
2353 thisa.y = v2->pFacePlane.vNormal.x; | |
2354 thisa.z = 0; | |
2355 thisa.Normalize_float(); | |
2356 v4 = thisa.x; | |
2357 v3 = thisa.y; | |
1418 | 2358 v5 = 0; |
2359 v11 = 65536; | |
2360 } | |
2361 else | |
2362 { | |
2363 v3 = 0; | |
2364 v4 = 65536; | |
2365 v11 = 0; | |
2366 v5 = -65536; | |
2367 } | |
0 | 2368 v6 = v11; |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
2369 sTextureDeltaU = v2->sTextureDeltaU; |
0 | 2370 v7 = v3; |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
2371 v8 = ptr_38; |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
2372 sTextureDeltaV = v2->sTextureDeltaV; |
1544 | 2373 v8->_48616B_frustum_odm(v4, v7, 0, 0, v5, v6); |
0 | 2374 return 1; |
2375 } | |
2376 | |
2377 | |
168 | 2378 unsigned short *LoadTgaTexture(const wchar_t *filename, int *out_width = nullptr, int *out_height = nullptr) |
2379 { | |
2380 #pragma pack(push, 1) | |
2381 struct TGAHeader | |
2382 { | |
2383 unsigned char tgaSkip; | |
2384 unsigned char colourmaptype; // type of colour map 0=none, 1=has palette | |
2385 unsigned char tgaType; // type of image 0=none,1=indexed,2=rgb,3=grey,+8=rle packed | |
2386 | |
2387 short colourmapstart; // first colour map entry in palette | |
2388 short colourmaplength; // number of colours in palette | |
2389 char colourmapbits; // number of bits per palette entry 15,16,24,32 | |
2390 | |
2391 //unsigned char tgaDontCare2[9]; | |
2392 short xstart; // image x origin | |
2393 short ystart; // image y origin | |
2394 | |
2395 unsigned short tgaWidth; | |
2396 unsigned short tgaHeight; | |
2397 unsigned char tgaBPP; | |
2398 | |
2399 char descriptor; // image descriptor bits: 00vhaaaa | |
2400 // h horizontal flip | |
2401 // v vertical flip | |
2402 // a alpha bits | |
2403 }; | |
2404 #pragma pack(pop) | |
2405 | |
2406 if (out_width) | |
2407 *out_width = 0; | |
2408 if (out_height) | |
2409 *out_height = 0; | |
2410 | |
2411 DWORD w; | |
1980 | 2412 void* file = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr); |
168 | 2413 if (file == INVALID_HANDLE_VALUE) |
2414 return nullptr; | |
2415 | |
2416 TGAHeader header; | |
2417 ReadFile(file, &header, sizeof(header), &w, nullptr); | |
2418 SetFilePointer(file, header.tgaSkip, nullptr, FILE_CURRENT); | |
2419 | |
2420 if (header.tgaBPP != 24 || header.tgaType != 2) | |
2421 { | |
2422 CloseHandle(file); | |
2423 return nullptr; | |
2424 } | |
2425 | |
2426 int imgSize = header.tgaWidth * header.tgaHeight * 3; | |
1980 | 2427 unsigned char* pixels = new unsigned char[imgSize]; |
168 | 2428 ReadFile(file, pixels, imgSize, &w, nullptr); |
2429 CloseHandle(file); | |
2430 | |
2431 if (w != imgSize) | |
2432 { | |
2433 delete [] pixels; | |
2434 return nullptr; | |
2435 } | |
2436 | |
2437 if (out_width) | |
2438 *out_width = header.tgaWidth; | |
2439 if (out_height) | |
2440 *out_height = header.tgaHeight; | |
2441 | |
1980 | 2442 unsigned short* pixels_16bit = new unsigned short[imgSize / 3]; |
168 | 2443 for (int i = 0; i < imgSize / 3; ++i) |
2444 { | |
2445 pixels_16bit[i] = (pixels[i * 3] / 8 & 0x1F) | | |
2446 ((pixels[i * 3 + 1] / 4 & 0x3F) << 5) | | |
2447 ((pixels[i * 3 + 2] / 8 & 0x1F) << 11); | |
2448 } | |
2449 delete [] pixels; | |
2450 return pixels_16bit; | |
2451 } | |
2452 | |
2453 unsigned short *skybox_xn, *skybox_xp, | |
2454 *skybox_yn, *skybox_yp, | |
2455 *skybox_zn, *skybox_zp; | |
2456 int skybox_width, skybox_height; | |
781 | 2457 |
168 | 2458 IDirect3DTexture2 *skybox_texture; |
2459 IDirectDrawSurface4 *skybox_surface; | |
781 | 2460 |
168 | 2461 bool Skybox_Initialize(const wchar_t *skybox_name) |
2462 { | |
2463 wchar_t xn_filename[1024], xp_filename[1024], | |
2464 yn_filename[1024], yp_filename[1024], | |
2465 zn_filename[1024], zp_filename[1024]; | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
2466 swprintf(xn_filename, wcslen(L"%s_xn.tga"), L"%s_xn.tga", skybox_name); swprintf(xp_filename, wcslen(L"%s_xp.tga"), L"%s_xp.tga", skybox_name); |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
2467 swprintf(yn_filename, wcslen(L"%s_yn.tga"), L"%s_yn.tga", skybox_name); swprintf(yp_filename, wcslen(L"%s_yp.tga"), L"%s_yp.tga", skybox_name); |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1160
diff
changeset
|
2468 swprintf(zn_filename, wcslen(L"%s_zn.tga"), L"%s_zn.tga", skybox_name); swprintf(zp_filename, wcslen(L"%s_zp.tga"), L"%s_zp.tga", skybox_name); |
168 | 2469 |
2470 int xn_width, xn_height; | |
2471 skybox_xn = LoadTgaTexture(xn_filename, &xn_width, &xn_height); | |
2472 if (!skybox_xn) | |
2473 return false; | |
2474 | |
2475 int xp_width, xp_height; | |
2476 skybox_xp = LoadTgaTexture(xp_filename, &xp_width, &xp_height); | |
2477 if (!skybox_xp || xp_width != xn_width || xp_height != xn_height) | |
2478 { | |
2479 delete [] skybox_xn; | |
2480 if (skybox_xp) delete [] skybox_xp; | |
2481 return false; | |
2482 } | |
2483 | |
2484 int yn_width, yn_height; | |
2485 skybox_yn = LoadTgaTexture(yn_filename, &yn_width, &yn_height); | |
2486 if (!skybox_yn || yn_width != xn_width || yn_height != xn_height) | |
2487 { | |
2488 delete [] skybox_xn; | |
2489 if (skybox_xp) delete [] skybox_xp; | |
2490 if (skybox_yn) delete [] skybox_yn; | |
2491 return false; | |
2492 } | |
2493 | |
2494 int yp_width, yp_height; | |
2495 skybox_yp = LoadTgaTexture(yp_filename, &yp_width, &yp_height); | |
2496 if (!skybox_yp || yp_width != xn_width || yp_height != xn_height) | |
2497 { | |
2498 delete [] skybox_xn; | |
2499 if (skybox_xp) delete [] skybox_xp; | |
2500 if (skybox_yn) delete [] skybox_yn; | |
2501 if (skybox_yp) delete [] skybox_yp; | |
2502 return false; | |
2503 } | |
2504 | |
2505 int zn_width, zn_height; | |
2506 skybox_zn = LoadTgaTexture(zn_filename, &zn_width, &zn_height); | |
2507 if (!skybox_zn || zn_width != xn_width || zn_height != xn_height) | |
2508 { | |
2509 delete [] skybox_xn; | |
2510 if (skybox_xp) delete [] skybox_xp; | |
2511 if (skybox_yn) delete [] skybox_yn; | |
2512 if (skybox_yp) delete [] skybox_yp; | |
2513 if (skybox_zn) delete [] skybox_zn; | |
2514 return false; | |
2515 } | |
2516 | |
2517 int zp_width, zp_height; | |
2518 skybox_zp = LoadTgaTexture(zp_filename, &zp_width, &zp_height); | |
2519 if (!skybox_zp || zp_width != xn_width || zp_height != xn_height) | |
2520 { | |
2521 delete [] skybox_xn; | |
2522 if (skybox_xp) delete [] skybox_xp; | |
2523 if (skybox_yn) delete [] skybox_yn; | |
2524 if (skybox_yp) delete [] skybox_yp; | |
2525 if (skybox_zn) delete [] skybox_zn; | |
2526 if (skybox_zp) delete [] skybox_zp; | |
2527 return false; | |
2528 } | |
2529 | |
2530 skybox_width = xn_width; | |
2531 skybox_height = xn_height; | |
2532 | |
2533 | |
2534 if (!pRenderer->pRenderD3D->CreateTexture(skybox_width, skybox_height, &skybox_surface, &skybox_texture, | |
2535 false, false, pRenderer->uMinDeviceTextureDim)) | |
2536 return false; | |
2537 | |
2538 return true; | |
2539 } | |
2540 | |
2541 struct vector | |
2542 { | |
2543 float x, y, z; | |
2544 }; | |
781 | 2545 |
168 | 2546 struct matrix |
2547 { | |
2548 float m[4][4]; | |
2549 }; | |
781 | 2550 |
168 | 2551 void VectorNormalize(vector *v) |
2552 { | |
2553 float invmag = 1.0f / sqrtf(v->x * v->x + v->y * v->y + v->z * v->z); | |
2554 v->x *= invmag; | |
2555 v->y *= invmag; | |
2556 v->z *= invmag; | |
2557 } | |
781 | 2558 |
168 | 2559 void MatrixRotationAxis(matrix *pout, CONST vector *pv, float angle) |
2560 { | |
2561 memset(pout, 0, sizeof(matrix)); | |
2562 pout->m[3][0] = 0; | |
2563 pout->m[3][1] = 0; | |
2564 pout->m[3][2] = 0; | |
2565 pout->m[3][3] = 1; | |
2566 | |
2567 vector v; | |
2568 v.x = pv->x; v.y = pv->y; v.z = pv->z; | |
2569 VectorNormalize(&v); | |
2570 | |
2571 pout->m[0][0] = (1.0f - cos(angle)) * v.x * v.x + cos(angle); | |
2572 pout->m[1][0] = (1.0f - cos(angle)) * v.x * v.y - sin(angle) * v.z; | |
2573 pout->m[2][0] = (1.0f - cos(angle)) * v.x * v.z + sin(angle) * v.y; | |
2574 pout->m[0][1] = (1.0f - cos(angle)) * v.y * v.x + sin(angle) * v.z; | |
2575 pout->m[1][1] = (1.0f - cos(angle)) * v.y * v.y + cos(angle); | |
2576 pout->m[2][1] = (1.0f - cos(angle)) * v.y * v.z - sin(angle) * v.x; | |
2577 pout->m[0][2] = (1.0f - cos(angle)) * v.z * v.x - sin(angle) * v.y; | |
2578 pout->m[1][2] = (1.0f - cos(angle)) * v.z * v.y + sin(angle) * v.x; | |
2579 pout->m[2][2] = (1.0f - cos(angle)) * v.z * v.z + cos(angle); | |
2580 } | |
781 | 2581 |
168 | 2582 void VectorTransform(const matrix *m, const vector *v, vector *out) |
2583 { | |
2584 out->x = m->m[0][0] * v->x + m->m[1][0] * v->y + m->m[2][0] * v->z + m->m[3][0]; | |
2585 out->y = m->m[0][1] * v->x + m->m[1][1] * v->y + m->m[2][1] * v->z + m->m[3][1]; | |
2586 out->z = m->m[0][2] * v->x + m->m[1][2] * v->y + m->m[2][2] * v->z + m->m[3][2]; | |
2587 } | |
2588 | |
2589 bool DrawSkyD3D_Skybox() | |
2590 { | |
2591 static bool initialized = false, | |
2592 initialization_failed = false; | |
2593 if (initialization_failed) | |
2594 return false; | |
2595 | |
2596 static int last_camera_rot_y, | |
2597 last_camera_rot_x; | |
2598 if (!initialized) | |
2599 { | |
2600 if (!Skybox_Initialize(L"data/skybox/stars")) | |
2601 { | |
2602 initialization_failed = true; | |
2603 return false; | |
2604 } | |
2605 initialized = true; | |
2606 | |
2607 last_camera_rot_y = pParty->sRotationY + 1; // force update for the first run | |
2608 last_camera_rot_x = pParty->sRotationX + 1; | |
2609 } | |
2610 | |
2611 /* | |
2612 r(y) = | |
2613 cos y 0 sin y 0 | |
2614 0 1 0 0 | |
2615 -sin y 0 cos y 0 | |
2616 0 0 0 1 | |
2617 | |
2618 x cos y - z sin y | |
2619 y | |
2620 x sin y + z cos y | |
2621 1 | |
2622 | |
2623 | |
2624 | |
2625 r(x) = // should be r(right) actually | |
2626 1 0 0 0 | |
2627 0 cos x -sin x 0 | |
2628 0 sin x cos x 0 | |
2629 0 0 0 1 | |
2630 | |
2631 | |
2632 x | |
2633 y cos x + z sin x | |
2634 -y sin x + z cos x | |
2635 1 | |
2636 | |
2637 */ | |
2638 | |
2639 if (last_camera_rot_y == pParty->sRotationY && | |
2640 last_camera_rot_x == pParty->sRotationX) | |
2641 { | |
2642 draw: | |
2643 struct RenderVertexD3D3 v[6]; | |
2644 | |
692 | 2645 v[0].pos.x = pViewport->uScreen_TL_X; |
2646 v[0].pos.y = pViewport->uScreen_TL_Y; | |
168 | 2647 v[0].pos.z = 0.99989998; |
2648 v[0].rhw = 1; | |
2006 | 2649 v[0].diffuse = -1; |
168 | 2650 v[0].specular = 0; |
2651 v[0].texcoord.x = 0; | |
2652 v[0].texcoord.y = 0; | |
2653 | |
692 | 2654 v[1].pos.x = pViewport->uScreen_TL_X + pViewport->uScreenWidth; |
2655 v[1].pos.y = pViewport->uScreen_TL_Y + pViewport->uScreenHeight; | |
168 | 2656 v[1].pos.z = 0.99989998; |
2657 v[1].rhw = 1; | |
2006 | 2658 v[1].diffuse = -1; |
168 | 2659 v[1].specular = 0; |
2660 v[1].texcoord.x = (float)pViewport->uScreenWidth / skybox_width; | |
2661 v[1].texcoord.y = (float)pViewport->uScreenHeight / skybox_height; | |
2662 | |
692 | 2663 v[2].pos.x = pViewport->uScreen_TL_X + pViewport->uScreenWidth; |
2664 v[2].pos.y = pViewport->uScreen_TL_Y; | |
168 | 2665 v[2].pos.z = 0.99989998; |
2666 v[2].rhw = 1; | |
2006 | 2667 v[2].diffuse = -1; |
168 | 2668 v[2].specular = 0; |
2669 v[2].texcoord.x = (float)pViewport->uScreenWidth / skybox_width; | |
2670 v[2].texcoord.y = 0; | |
2671 | |
2672 memcpy(&v[3], &v[0], sizeof(*v)); | |
2673 | |
692 | 2674 v[4].pos.x = pViewport->uScreen_TL_X; |
2675 v[4].pos.y = pViewport->uScreen_TL_Y + pViewport->uScreenHeight; | |
168 | 2676 v[4].pos.z = 0.99989998; |
2677 v[4].rhw = 1; | |
2006 | 2678 v[4].diffuse = -1; |
168 | 2679 v[4].specular = 0; |
2680 v[4].texcoord.x = 0; | |
2681 v[4].texcoord.y = (float)pViewport->uScreenHeight / skybox_height; | |
2682 | |
2683 memcpy(&v[5], &v[1], sizeof(*v)); | |
2684 | |
2685 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); | |
2686 pRenderer->pRenderD3D->pDevice->SetTexture(0, skybox_texture); | |
2687 pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v, 6, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); | |
2688 //pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v + 1, 3, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); | |
2689 | |
2690 return true; | |
2691 } | |
2692 | |
2693 | |
2694 DDSURFACEDESC2 desc; | |
2695 desc.dwSize = sizeof(desc); | |
2696 if (!pRenderer->LockSurface_DDraw4(skybox_surface, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY)) | |
2697 return false; | |
2698 | |
2699 last_camera_rot_y = pParty->sRotationY; | |
2700 last_camera_rot_x = pParty->sRotationX; | |
2701 | |
2702 float aspect = (float)pViewport->uScreenWidth / (float)pViewport->uScreenHeight; | |
1637 | 2703 float fov_x = 3.141592f * (pODMRenderParams->uCameraFovInDegrees + 0) / 360.0f; |
168 | 2704 float fov_y = fov_x / aspect; |
2705 | |
2706 float ray_dx = fov_x / (float)pViewport->uScreenWidth, | |
2707 ray_dy = fov_y / (float)pViewport->uScreenHeight; | |
2708 float party_angle_x = 2 * 3.141592653589 * pParty->sRotationX / 2048.0, | |
2709 party_angle_y = 2 * 3.141592653589 * pParty->sRotationY / 2048.0; | |
2710 for (int y = 0; y < pViewport->uScreenHeight; ++y) | |
2711 for (int x = 0; x < pViewport->uScreenWidth; ++x) | |
2712 { | |
2713 float angle_x = party_angle_x - (y - pViewport->uScreenHeight / 2) * ray_dy; | |
2714 float angle_y = party_angle_y - (x - pViewport->uScreenWidth / 2) * ray_dx; | |
2715 | |
2716 float _dir_x_ = 1, | |
2717 _dir_y_ = 0, | |
2718 _dir_z_ = 0; | |
2719 | |
2720 float dir_x_ = _dir_x_ * cosf(angle_y);// - _dir_z_ * sinf(angle_y); // rotation around y | |
2721 //float dir_y_ = _dir_y_; | |
2722 float dir_z_ = _dir_x_ * sinf(angle_y);// + _dir_z_ * cosf(angle_y); | |
2723 | |
2724 //float dir_x = dir_x_; // rotation around x | |
2725 //float dir_y = /*dir_y_ * cosf(angle_x)*/ + dir_z_ * sinf(angle_x); | |
2726 //float dir_z = /*-dir_y_ * sinf(angle_x)*/ + dir_z_ * cosf(angle_x); | |
2727 | |
2728 vector right; // rotate around right actually to avoid space distortion | |
2729 right.x = /*dir_y * 0*/ - dir_z_ * 1; | |
2730 right.y = /*dir_z_ * 0 - dir_x_ * */0; | |
2731 right.z = dir_x_ * 1/* - dir_y_ * 0*/; | |
2732 //VectorNormalize(&right); | |
2733 | |
2734 matrix rightMatrix; | |
2735 MatrixRotationAxis(&rightMatrix, &right, angle_x); | |
2736 | |
2737 vector v1, v2; | |
2738 v1.x = dir_x_; v1.y = 0; v1.z = dir_z_; | |
2739 VectorTransform(&rightMatrix, &v1, &v2); | |
2740 | |
2741 float dir_x = v2.x, | |
2742 dir_y = v2.y, | |
2743 dir_z = v2.z; | |
2744 | |
2745 float abs_dir_x = fabsf(dir_x), | |
2746 abs_dir_y = fabsf(dir_y), | |
2747 abs_dir_z = fabsf(dir_z); | |
2748 | |
2749 unsigned short color = (0x1F << 11) | (0x1F << 5) | (5); //default to orange | |
2750 if (abs_dir_x >= abs_dir_y) | |
2751 { | |
2752 if (abs_dir_x >= abs_dir_z) | |
2753 { | |
2754 if (dir_x >= 0) | |
2755 { | |
2756 float instersect_y = dir_y / (2.0f * dir_x); // plane equation for this side is x + 0.5 = 0 | |
2757 float instersect_z = dir_z / (2.0f * dir_x); | |
2758 | |
2759 float u = 1.0f - (instersect_z + 0.5f), | |
2760 v = 1.0f - (instersect_y + 0.5f); | |
2761 | |
2762 int tx = u * (skybox_width - 1), | |
2763 ty = v * (skybox_height - 1); | |
2764 | |
2765 color = skybox_xp[ty * skybox_width + tx]; | |
2766 //color = ty * 0x1F / skybox_height; | |
2767 } | |
2768 else | |
2769 { | |
2770 float instersect_y = dir_y / (2.0f * dir_x); | |
2771 float instersect_z = dir_z / (2.0f * dir_x); | |
2772 | |
2773 float u = 1.0f - (instersect_z + 0.5f), | |
2774 v = instersect_y + 0.5f; | |
2775 | |
2776 int tx = u * (skybox_width - 1), | |
2777 ty = v * (skybox_height - 1); | |
2778 | |
2779 color = skybox_xn[ty * skybox_width + tx]; | |
2780 //color = tx * 0x1F / skybox_height; | |
2781 } | |
2782 } | |
2783 else if (dir_z >= 0) | |
2784 goto DIR_ZP; | |
2785 else | |
2786 goto DIR_ZN; | |
2787 } | |
2788 else if (abs_dir_y >= abs_dir_z) | |
2789 { | |
2790 if (dir_y >= 0) | |
2791 { | |
2792 float instersect_x = dir_x / (2.0f * dir_y); | |
2793 float instersect_z = dir_z / (2.0f * dir_y); | |
2794 | |
2795 float u = instersect_x + 0.5f, | |
2796 v = instersect_z + 0.5f; | |
2797 | |
2798 int tx = u * (skybox_width - 1), | |
2799 ty = v * (skybox_height - 1); | |
2800 | |
2801 color = skybox_yp[ty * skybox_width + tx]; | |
2802 //color = tx * 0x1F / skybox_height; | |
2803 } | |
2804 /*else should never be seen i guess | |
2805 { | |
2806 __debugbreak(); | |
2807 // -y | |
2808 //Log::Warning(L"(%03u, %03u): -y", x, y); | |
2809 }*/ | |
2810 } | |
2811 else if (dir_z >= 0) | |
2812 { | |
2813 DIR_ZP: | |
2814 // +z | |
2815 float instersect_x = dir_x / (2.0f * dir_z); | |
2816 float instersect_y = dir_y / (2.0f * dir_z); | |
2817 //float intersect_z = 0.5f; | |
2818 | |
2819 float u = instersect_x + 0.5f, | |
2820 v = -instersect_y + 0.5f; | |
2821 | |
2822 int tx = u * (skybox_width - 1), | |
2823 ty = v * (skybox_height - 1); | |
2824 | |
2825 color = skybox_zp[ty * skybox_width + tx]; | |
2826 } | |
2827 else | |
2828 { | |
2829 DIR_ZN: | |
2830 // -z | |
2831 float instersect_x = -dir_x / (2.0f * dir_z); | |
2832 float instersect_y = -dir_y / (2.0f * dir_z); | |
2833 //float intersect_z = -0.5f; | |
2834 | |
2835 float u = 1.0f - instersect_x - 0.5f, | |
2836 v = -instersect_y + 0.5f; | |
2837 | |
2838 int tx = u * (skybox_width - 1), | |
2839 ty = v * (skybox_height - 1); | |
2840 | |
2841 color = skybox_zn[ty * skybox_width + tx]; | |
2842 } | |
2843 | |
2844 //pRenderer->pTargetSurface[(pViewport->uScreenY + y) * pRenderer->uTargetSurfacePitch + pViewport->uScreenX + x] = color; | |
2845 ((unsigned __int16 *)((char *)desc.lpSurface + y * desc.lPitch))[x] = color; | |
2846 } | |
2847 | |
2848 ErrD3D((skybox_surface)->Unlock(0)); | |
2849 goto draw; | |
2850 } | |
0 | 2851 //----- (0047A384) -------------------------------------------------------- |
1637 | 2852 void ODM_LoadAndInitialize(const char *pLevelFilename, ODMRenderParams *thisa) |
0 | 2853 { |
2854 int v2; // ebx@3 | |
2855 unsigned int v3; // eax@3 | |
2856 MapInfo *v4; // edi@4 | |
2857 //int v5; // eax@8 | |
2858 //SpawnPointMM7 *v6; // edx@14 | |
2859 size_t v7; // eax@19 | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2860 //char *v8; // eax@19 |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2861 //char *v9; // eax@21 |
0 | 2862 char Source[120]; // [sp+Ch] [bp-84h]@19 |
2863 const char *pFilename; // [sp+84h] [bp-Ch]@1 | |
2864 //unsigned int v12; // [sp+88h] [bp-8h]@12 | |
2865 //int v13; // [sp+8Ch] [bp-4h]@11 | |
2866 | |
2867 pFilename = pLevelFilename; | |
1583 | 2868 //thisa->AllocSoftwareDrawBuffers(); |
1637 | 2869 pODMRenderParams->Initialize(); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2870 pWeather->bRenderSnow = false; |
0 | 2871 pRenderer->ClearZBuffer(0, 479); |
1637 | 2872 thisa = (ODMRenderParams *)1; |
0 | 2873 GetAlertStatus(); |
2874 if ( qword_A750D8 ) | |
1583 | 2875 qword_A750D8 = 0; |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1470
diff
changeset
|
2876 v2 = pMapStats->GetMapInfo(pCurrentMapName); |
0 | 2877 v3 = 0; |
2878 if ( v2 ) | |
2879 { | |
2880 v4 = &pMapStats->pInfos[v2]; | |
2881 v3 = v4->uRespawnIntervalDays; | |
2882 } | |
2883 else | |
2884 { | |
2885 v4 = (MapInfo *)thisa; | |
2886 } | |
767 | 2887 day_attrib &= ~DAY_ATTRIB_FOG; |
0 | 2888 dword_6BE13C_uCurrentlyLoadedLocationID = v2; |
2889 pOutdoor->Initialize( | |
2890 pFilename, | |
2891 (unsigned int)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) / 0x3C / 0x3C / 0x18 + 1, | |
2892 v3, | |
2893 (int)&thisa); | |
2061 | 2894 if ( !(dword_6BE364_game_settings_1 & GAME_SETTINGS_2000) ) |
0 | 2895 { |
2896 InitializeActors(); | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
510
diff
changeset
|
2897 InitializeSpriteObjects(); |
0 | 2898 } |
2061 | 2899 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_2000; |
0 | 2900 //v5 = 0; |
2901 if ( !v2 ) | |
2902 thisa = 0; | |
1637 | 2903 if ( thisa == (ODMRenderParams *)1 ) |
0 | 2904 { |
2905 //v13 = 0; | |
2906 for (uint i = 0; i < pOutdoor->uNumSpawnPoints; ++i) | |
2907 { | |
2908 //v12 = 0; | |
2909 //while ( 1 ) | |
2910 //{ | |
1980 | 2911 SpawnPointMM7* spawn = pOutdoor->pSpawnPoints + i; |
0 | 2912 //v6 = &pOutdoor->pSpawnPoints[v12 / 0x18]; |
2913 if (spawn->uKind == 3 ) | |
2914 SpawnEncounter(v4, spawn, 0, 0, 0); | |
2915 else | |
2916 v4->SpawnRandomTreasure(spawn); | |
2917 //++v13; | |
2918 //v12 += 24; | |
2919 //if ( v13 >= (signed int)pOutdoor->uNumSpawnPoints ) | |
2920 // break; | |
2921 //v5 = 0; | |
2922 //} | |
2923 } | |
2924 RespawnGlobalDecorations(); | |
2925 } | |
2926 pOutdoor->PrepareDecorations(); | |
2065
87be06553c76
rename int _47F223_LooksLikeGenerateMonsterLoot() to void ArrangeSpriteObjects()
Ritor1
parents:
2061
diff
changeset
|
2927 pOutdoor->ArrangeSpriteObjects(); |
0 | 2928 pOutdoor->InitalizeActors(v2); |
2929 pOutdoor->MessWithLUN(); | |
2930 v7 = strlen("levels\\"); | |
2931 strcpy(Source, &pFilename[v7]); | |
2932 strcpy(pOutdoor->pLevelFilename, Source); | |
2933 pWeather->Initialize(); | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2934 pGame->pIndoorCameraD3D->sRotationY = pParty->sRotationY; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
2935 pGame->pIndoorCameraD3D->sRotationX = pParty->sRotationX; |
1642 | 2936 //pODMRenderParams->RotationToInts(); |
0 | 2937 pOutdoor->UpdateSunlightVectors(); |
1638
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
2938 |
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
2939 float fov_rad; |
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
2940 float fov_rad_inv; |
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
2941 //----- (0042394D) -------------------------------------------------------- |
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
2942 //void IndoorCamera::Initialize(int degFov, unsigned int uViewportWidth, unsigned int uViewportHeight) |
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
2943 { |
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
2944 //pIndoorCamera->Initialize(65, viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X + 1, |
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
2945 // viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y + 1); |
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
2946 |
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
2947 int uViewportWidth = viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X + 1; |
1641 | 2948 |
2949 extern float _calc_fov(int viewport_width, int angle_degree); | |
2950 fov_rad = _calc_fov(uViewportWidth, 65); | |
2951 fov_rad_inv = 65536.0 / fov_rad; | |
1638
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
2952 } |
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
2953 pODMRenderParams->int_fov_rad = (signed __int64)fov_rad; |
ccde94f02b75
class IndoorCamera split into BLVRenderParams and ODMRenderParams
Nomad
parents:
1637
diff
changeset
|
2954 pODMRenderParams->int_fov_rad_inv = (signed __int64)fov_rad_inv; |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2955 |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2956 for (int i = 0; i < 20000; ++i) |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2957 { |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2958 array_77EC08[i].ptr_38 = &stru_8019C8; |
1644 | 2959 |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2960 array_77EC08[i].ptr_48 = nullptr; |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2961 } |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2962 |
0 | 2963 MM7Initialization(); |
2964 } | |
2965 | |
2966 //----- (0047C370) -------------------------------------------------------- | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2967 unsigned int GetLevelFogColor() |
0 | 2968 { |
2969 signed __int64 v1; // qax@5 | |
2970 int v2; // eax@6 | |
2971 | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2972 if (bUnderwater) |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2973 return 0xFF258F5C; |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2974 |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2975 if (day_attrib & DAY_ATTRIB_FOG) |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2976 { |
767 | 2977 if ( pWeather->bNight ) // night-time fog |
750 | 2978 { |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2979 __debugbreak(); // decompilation can be inaccurate, please send savegame to Nomad |
750 | 2980 v2 = -(pWeather->bNight != 1); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2981 return (v2 & 0xE0E0E1) - 0xE0E0E1; |
0 | 2982 } |
2983 else | |
2984 { | |
2985 v1 = (signed __int64)((1.0 - pOutdoor->fFogDensity) * 200.0 + pOutdoor->fFogDensity * 31.0); | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2986 return v1 | (((unsigned int)v1 | (((unsigned int)v1 | 0xFFFFFF00) << 8)) << 8); |
0 | 2987 } |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2988 } |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2989 |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
2990 return 0; |
0 | 2991 } |
2992 | |
2993 //----- (0047C3D7) -------------------------------------------------------- | |
2994 int __fastcall sub_47C3D7_get_fog_related_stuff(int a1, int a2, float a3) | |
2995 { | |
2996 int v3; // ecx@1 | |
2997 double v5; // st7@10 | |
2998 signed int v7; // ecx@11 | |
2999 double v8; // st6@12 | |
3000 double v9; // st7@15 | |
3001 double v10; // st6@16 | |
3002 float v11; // ST14_4@17 | |
3003 double v12; // ST08_8@17 | |
3004 | |
750 | 3005 v3 = pWeather->bNight; |
0 | 3006 if ( bUnderwater == 1 ) |
3007 v3 = 0; | |
767 | 3008 if ( pParty->armageddon_timer || !(day_attrib & DAY_ATTRIB_FOG) && !bUnderwater ) |
349 | 3009 return 0xFF000000; |
0 | 3010 if ( v3 ) |
3011 { | |
3012 v5 = (double)day_fogrange_1; | |
3013 if ( a3 < v5 ) | |
1418 | 3014 { |
3015 v7 = 0; | |
3016 if ( a3 == 0.0 ) | |
3017 { | |
3018 v7 = 216; | |
3019 } | |
3020 goto LABEL_21; | |
3021 } | |
3022 else | |
3023 { | |
3024 v8 = (double)day_fogrange_2; | |
3025 if ( a3 > v8 ) | |
3026 { | |
3027 v7 = 216; | |
3028 if ( a3 == 0.0 ) | |
3029 { | |
3030 v7 = 216; | |
3031 } | |
3032 goto LABEL_21; | |
3033 } | |
3034 v7 = (signed __int64)((a3 - v5) / (v8 - v5) * 216.0); | |
3035 } | |
0 | 3036 } |
3037 else | |
3038 { | |
3039 v9 = (double)day_fogrange_1; | |
3040 if ( a3 < v9 ) | |
3041 { | |
3042 v7 = 0; | |
1418 | 3043 if ( a3 == 0.0 ) |
3044 { | |
3045 v7 = 216; | |
3046 } | |
3047 goto LABEL_21; | |
0 | 3048 } |
1418 | 3049 else |
3050 { | |
3051 v10 = (double)day_fogrange_2; | |
3052 if ( a3 > v10 ) | |
3053 { | |
3054 v7 = 216; | |
3055 if ( a3 == 0.0 ) | |
3056 { | |
3057 v7 = 216; | |
3058 } | |
3059 goto LABEL_21; | |
3060 } | |
3061 else | |
3062 { | |
3063 v11 = (a3 - v9) * 216.0 / (v10 - v9); | |
3064 v12 = v11 + 6.7553994e15; | |
3065 v7 = LODWORD(v12); | |
3066 } | |
3067 } | |
3068 } | |
3069 if ( v7 > 216 ) | |
3070 { | |
3071 v7 = 216; | |
3072 } | |
3073 else | |
3074 { | |
3075 if ( a3 == 0.0 ) | |
3076 { | |
3077 v7 = 216; | |
3078 } | |
3079 } | |
0 | 3080 LABEL_21: |
3081 if ( a2 ) | |
3082 v7 = 248; | |
3083 return (-1 - v7) << 24; | |
3084 } | |
349 | 3085 |
0 | 3086 //----- (0047C4FC) -------------------------------------------------------- |
1459 | 3087 int __fastcall GetActorTintColor(int max_dimm, int min_dimm, float distance, int a4, RenderBillboard *a5) |
349 | 3088 { |
3089 //int v5; // esi@1 | |
0 | 3090 signed int v6; // edx@1 |
349 | 3091 //signed int result; // eax@2 |
0 | 3092 int v8; // eax@3 |
3093 double v9; // st7@12 | |
750 | 3094 //double v10; // ST0C_8@18 |
0 | 3095 int v11; // ecx@28 |
349 | 3096 //signed int v12; // edi@28 |
3097 //double v13; // ST0C_8@33 | |
3098 //double v14; // ST0C_8@34 | |
0 | 3099 double v15; // st7@44 |
349 | 3100 //double v16; // ST0C_8@44 |
3101 //double v17; // ST0C_8@44 | |
0 | 3102 int v18; // ST14_4@44 |
349 | 3103 //double v19; // ST0C_8@44 |
0 | 3104 signed int v20; // [sp+10h] [bp-4h]@10 |
3105 float a3a; // [sp+1Ch] [bp+8h]@33 | |
638 | 3106 //float a3b; // [sp+1Ch] [bp+8h]@34 |
0 | 3107 float a3c; // [sp+1Ch] [bp+8h]@44 |
349 | 3108 //float a3d; // [sp+1Ch] [bp+8h]@44 |
750 | 3109 //float a4b; // [sp+20h] [bp+Ch]@18 |
638 | 3110 //int a4a; // [sp+20h] [bp+Ch]@33 |
349 | 3111 //float a4c; // [sp+20h] [bp+Ch]@44 |
3112 //float a4d; // [sp+20h] [bp+Ch]@44 | |
0 | 3113 int a5a; // [sp+24h] [bp+10h]@44 |
3114 | |
349 | 3115 //v5 = a2; |
0 | 3116 v6 = 0; |
349 | 3117 |
3118 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
638 | 3119 return 8 * (31 - max_dimm) | ((8 * (31 - max_dimm) | ((31 - max_dimm) << 11)) << 8); |
3120 | |
349 | 3121 if (pParty->armageddon_timer) |
3122 return 0xFFFF0000; | |
3123 | |
750 | 3124 v8 = pWeather->bNight; |
638 | 3125 if (bUnderwater) |
0 | 3126 v8 = 0; |
3127 if ( v8 ) | |
3128 { | |
3129 v20 = 1; | |
349 | 3130 if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0 ) |
3131 v20 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower; | |
0 | 3132 v9 = (double)v20 * 1024.0; |
3133 if ( a4 ) | |
1901 | 3134 { |
3135 v6 = 216; | |
3136 goto LABEL_20; | |
3137 } | |
638 | 3138 if ( distance <= v9 ) |
3139 { | |
3140 if ( distance > 0.0 ) | |
3141 { | |
750 | 3142 //a4b = distance * 216.0 / v9; |
3143 //v10 = a4b + 6.7553994e15; | |
3144 //v6 = LODWORD(v10); | |
3145 v6 = floorf(0.5f + distance * 216.0 / v9); | |
3146 if (v6 > 216 ) | |
1901 | 3147 { |
3148 v6 = 216; | |
3149 goto LABEL_20; | |
3150 } | |
0 | 3151 } |
3152 } | |
3153 else | |
3154 { | |
3155 v6 = 216; | |
3156 } | |
638 | 3157 if ( distance != 0.0 ) |
0 | 3158 { |
3159 LABEL_20: | |
3160 if ( a5 ) | |
3161 v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3); | |
3162 if ( v6 > 216 ) | |
3163 v6 = 216; | |
3164 return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8); | |
3165 } | |
1901 | 3166 //LABEL_19: |
0 | 3167 v6 = 216; |
3168 goto LABEL_20; | |
3169 } | |
349 | 3170 |
3171 | |
3172 | |
638 | 3173 if (fabsf(distance) < 1.0e-6f) |
349 | 3174 return 0xFFF8F8F8; |
3175 | |
638 | 3176 // dim in measured in 8-steps |
3177 v11 = 8 * (max_dimm - min_dimm); | |
349 | 3178 //v12 = v11; |
0 | 3179 if ( v11 >= 0 ) |
3180 { | |
3181 if ( v11 > 216 ) | |
349 | 3182 v11 = 216; |
3183 } | |
3184 else | |
3185 v11 = 0; | |
3186 | |
638 | 3187 float fog_density_mult = 216.0f; |
3188 if (a4) | |
1637 | 3189 fog_density_mult += distance / (double)pODMRenderParams->shading_dist_shade * 32.0; |
638 | 3190 |
3191 v6 = v11 + floorf(pOutdoor->fFogDensity * fog_density_mult + 0.5f); | |
3192 /*if ( a4 ) | |
3193 { | |
3194 //a3b = pOutdoor->fFogDensity * 216.0; | |
349 | 3195 //v14 = a3b + 6.7553994e15; |
638 | 3196 //a4a = floorf(a3b + 0.5f);//LODWORD(v14); |
3197 } | |
3198 else | |
3199 { | |
1637 | 3200 //a3a = (distance / (double)pODMRenderParams->shading_dist_shade * 32.0 + 216.0) * pOutdoor->fFogDensity; |
349 | 3201 //v13 = a3a + 6.7553994e15; |
638 | 3202 //a4a = floorf(a3a + 0.5f);//LODWORD(v13); |
3203 } | |
3204 v6 = a4a + v11;*/ | |
0 | 3205 if ( a5 ) |
3206 v6 = 8 * _43F55F_get_billboard_light_level(a5, v6 >> 3); | |
3207 if ( v6 > 216 ) | |
3208 v6 = 216; | |
349 | 3209 if ( v6 < v11 ) |
3210 v6 = v11; | |
638 | 3211 if ( v6 > 8 * pOutdoor->max_terrain_dimming_level ) |
3212 v6 = 8 * pOutdoor->max_terrain_dimming_level; | |
0 | 3213 if ( !bUnderwater ) |
3214 return (255 - v6) | ((255 - v6) << 16) | ((255 - v6) << 8); | |
349 | 3215 else |
3216 { | |
0 | 3217 v15 = (double)(255 - v6) * 0.0039215689; |
3218 a3c = v15; | |
349 | 3219 //a4c = v15 * 16.0; |
3220 //v16 = a4c + 6.7553994e15; | |
3221 a5a = floorf(v15 * 16.0 + 0.5f);//LODWORD(v16); | |
3222 //a4d = a3c * 194.0; | |
3223 //v17 = a4d + 6.7553994e15; | |
3224 v18 = floorf(a3c * 194.0 + 0.5f);//LODWORD(v17); | |
3225 //a3d = a3c * 153.0; | |
3226 //v19 = a3d + 6.7553994e15; | |
3227 return (int)floorf(a3c * 153.0 + 0.5f)/*LODWORD(v19)*/ | ((v18 | (a5a << 8)) << 8); | |
3228 } | |
0 | 3229 } |
3230 // 6BE3C4: using guessed type char bUnderwater; | |
3231 | |
3232 //----- (0047F44B) -------------------------------------------------------- | |
1412 | 3233 unsigned int WorldPosToGridCellX(int sWorldPosX) |
67 | 3234 { |
1412 | 3235 return (sWorldPosX >> 9) + 64; // sar is in original exe, resulting -880 / 512 = -1 |
3236 // and -880 sar 9 = -2 | |
0 | 3237 } |
3238 | |
3239 //----- (0047F458) -------------------------------------------------------- | |
1412 | 3240 unsigned int WorldPosToGridCellZ(int sWorldPosZ) |
67 | 3241 { |
1412 | 3242 return 64 - (sWorldPosZ >> 9); // sar is in original exe, resulting -880 / 512 = -1 |
3243 // and -880 sar 9 = -2 | |
0 | 3244 } |
3245 | |
3246 //----- (0047F469) -------------------------------------------------------- | |
1459 | 3247 int GridCellToWorldPosX(int a1) |
0 | 3248 { |
3249 return (a1 - 64) << 9; | |
3250 } | |
3251 | |
3252 //----- (0047F476) -------------------------------------------------------- | |
1459 | 3253 int GridCellToWorldPosZ(int a1) |
0 | 3254 { |
3255 return (64 - a1) << 9; | |
3256 } | |
3257 | |
3258 | |
3259 //----- (004811A3) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
3260 void Polygon::DrawBorderTiles() |
1338 | 3261 { |
3262 //__debugbreak(); | |
3263 | |
3264 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false); | |
0 | 3265 pRenderer->DrawTerrainPolygon(uNumVertices, this, |
1338 | 3266 pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]], false, true); |
3267 | |
3268 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true); | |
3269 //pRenderer->DrawTerrainPolygon(uNumVertices, this, pBitmaps_LOD->pHardwareTextures[uTileBitmapID], true, true); | |
0 | 3270 } |
3271 | |
3272 | |
3273 //----- (00481ED9) -------------------------------------------------------- | |
1637 | 3274 void sub_481ED9_MessWithODMRenderParams() |
0 | 3275 { |
1544 | 3276 stru_8019C8._48616B_frustum_odm(65536, 0, 0, 0, 65536, 0); |
1637 | 3277 pODMRenderParams->uNumPolygons = 0; |
1642 | 3278 //pODMRenderParams->uNumEdges = 0; |
3279 //pODMRenderParams->uNumSpans = 0; | |
3280 //pODMRenderParams->uNumSurfs = 0; | |
1637 | 3281 pODMRenderParams->uNumBillboards = 0; |
3282 pODMRenderParams->field_44 = 0; | |
0 | 3283 } |
3284 | |
3285 //----- (004823F4) -------------------------------------------------------- | |
138 | 3286 bool IsTerrainSlopeTooHigh(int pos_x, int pos_z) |
3287 { | |
3288 //unsigned int v2; // ebx@1 | |
3289 //unsigned int v3; // edi@1 | |
3290 //int v4; // eax@1 | |
3291 //int v6; // esi@5 | |
3292 //int v7; // ecx@6 | |
3293 //int v8; // edx@6 | |
3294 //int v9; // eax@6 | |
3295 //int v10; // esi@10 | |
3296 //int v11; // [sp+14h] [bp-8h]@1 | |
3297 //int v12; // [sp+18h] [bp-4h]@1 | |
3298 | |
3299 //v12 = a1; | |
3300 //v11 = a2; | |
1980 | 3301 unsigned int grid_x = WorldPosToGridCellX(pos_x); |
3302 unsigned int grid_z = WorldPosToGridCellZ(pos_z) - 1; | |
3303 | |
3304 int party_grid_x1 = GridCellToWorldPosX(grid_x); | |
138 | 3305 //dword_76D56C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(grid_x + 1); |
3306 //dword_76D570_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(grid_x + 1); | |
3307 //dword_76D574_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(grid_x); | |
1980 | 3308 int party_grid_z1 = GridCellToWorldPosZ(grid_z); |
138 | 3309 //dword_76D55C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(grid_z); |
3310 //dword_76D560_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(grid_z + 1); | |
3311 //dword_76D564_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(grid_z + 1); | |
1980 | 3312 int party_x1z1_y = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z); |
3313 int party_x2z1_y = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z); | |
3314 int party_x2z2_y = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z + 1); | |
3315 int party_x1z2_y = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z + 1); | |
138 | 3316 //dword_76D554_terrain_cell_world_pos_around_party_y = v4; |
3317 if (party_x1z1_y == party_x2z1_y && | |
3318 party_x2z1_y == party_x2z2_y && | |
3319 party_x2z2_y == party_x1z2_y ) | |
3320 return false; | |
3321 | |
1980 | 3322 int dx = abs(pos_x - party_grid_x1), |
138 | 3323 dz = abs(party_grid_z1 - pos_z); |
3324 | |
3325 int y1, y2, y3; | |
3326 if (dz >= dx) | |
3327 { | |
3328 y1 = party_x1z2_y; // lower-left triangle | |
3329 y2 = party_x2z2_y; // y3 | \ | |
3330 y3 = party_x1z1_y; // | \ | |
3331 /* | \ | |
3332 |______ \ | |
3333 y1 y2 */ | |
3334 } | |
3335 else | |
3336 { | |
3337 y1 = party_x2z1_y; // upper-right | |
3338 y2 = party_x1z1_y; // y2_______ y1 | |
3339 y3 = party_x2z2_y; // \ | | |
3340 /* \ | | |
3341 \ | | |
3342 y3 */ | |
3343 } | |
3344 | |
3345 int y_min = min(y1, min(y2, y3)), | |
3346 y_max = max(y1, max(y2, y3)); | |
1545 | 3347 return (y_max - y_min) > 512; |
138 | 3348 |
3349 /*if ( y1 >= y2 ) | |
3350 { | |
3351 y_min = y2; | |
3352 if ( y2 < y3 ) | |
0 | 3353 goto LABEL_13; |
3354 LABEL_12: | |
138 | 3355 y_min = y3; |
0 | 3356 goto LABEL_13; |
3357 } | |
138 | 3358 else if ( y1 >= y3 ) |
0 | 3359 goto LABEL_12; |
138 | 3360 else |
3361 y_min = y1; | |
3362 | |
0 | 3363 LABEL_13: |
138 | 3364 if ( y1 <= y2 ) |
3365 { | |
3366 if ( y2 > y3 ) | |
3367 y3 = y2; | |
3368 } | |
3369 else | |
3370 { | |
3371 if ( y1 > y3 ) | |
3372 y3 = y1; | |
3373 } | |
3374 return y3 - v10 > 512;*/ | |
0 | 3375 } |
3376 | |
3377 //----- (0048257A) -------------------------------------------------------- | |
812 | 3378 int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *pIsOnWater, int bFloatAboveWater) |
3379 { | |
3380 //unsigned int v4; // ebx@1 | |
3381 //unsigned int v5; // edi@1 | |
0 | 3382 int result; // eax@9 |
812 | 3383 //int v7; // ebx@10 |
0 | 3384 int v8; // ebx@11 |
3385 int v9; // eax@11 | |
3386 int v10; // ecx@11 | |
812 | 3387 //int v11; // [sp+Ch] [bp-Ch]@1 |
3388 //int v12; // [sp+10h] [bp-8h]@1 | |
0 | 3389 int v13; // [sp+10h] [bp-8h]@11 |
3390 signed int v14; // [sp+14h] [bp-4h]@3 | |
3391 int v15; // [sp+24h] [bp+Ch]@11 | |
3392 | |
812 | 3393 //v11 = a1; |
3394 //v12 = a2; | |
1980 | 3395 unsigned int grid_x = WorldPosToGridCellX(a1); |
3396 unsigned int grid_z = WorldPosToGridCellZ(a2) - 1; | |
3397 | |
3398 int grid_x1 = GridCellToWorldPosX(grid_x), | |
812 | 3399 grid_x2 = GridCellToWorldPosX(grid_x + 1); |
1980 | 3400 int grid_z1 = GridCellToWorldPosZ(grid_z), |
812 | 3401 grid_z2 = GridCellToWorldPosZ(grid_z + 1); |
3402 | |
1980 | 3403 int y_x1z1 = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z), |
812 | 3404 y_x2z1 = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z), |
3405 y_x2z2 = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z + 1), | |
3406 y_x1z2 = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z + 1); | |
3407 //v4 = WorldPosToGridCellX(a1); | |
3408 //v5 = WorldPosToGridCellZ(v12) - 1; | |
3409 //dword_76D538_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4); | |
3410 //dword_76D53C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1); | |
3411 //dword_76D540_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1); | |
3412 //dword_76D544_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4); | |
3413 //dword_76D528_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5); | |
3414 //dword_76D52C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5); | |
3415 //dword_76D530_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1); | |
3416 //dword_76D534_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1); | |
3417 //dword_76D518_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5); | |
3418 //dword_76D51C_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5); | |
3419 //dword_76D520_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5 + 1); | |
3420 //dword_76D524_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5 + 1); | |
791 | 3421 *pIsOnWater = false; |
812 | 3422 if ( pOutdoor->ActuallyGetSomeOtherTileInfo(grid_x, grid_z) & 2 ) |
791 | 3423 *pIsOnWater = true; |
0 | 3424 v14 = 0; |
812 | 3425 if ( !bFloatAboveWater && *pIsOnWater ) |
0 | 3426 v14 = -60; |
812 | 3427 if ( y_x1z1 != y_x2z1 || |
3428 y_x2z1 != y_x2z2 || | |
3429 y_x2z2 != y_x1z2 ) | |
3430 { | |
3431 if ( abs(grid_z1 - a2) >= abs(a1 - grid_x1) ) | |
3432 { | |
3433 v8 = y_x1z2; | |
3434 v9 = y_x2z2; | |
3435 v10 = y_x1z1; | |
3436 v15 = a1 - grid_x1; | |
3437 v13 = a2 - grid_z2; | |
0 | 3438 } |
3439 else | |
3440 { | |
812 | 3441 v8 = y_x2z1; |
3442 v9 = y_x1z1; | |
3443 v10 = y_x2z2; | |
3444 v15 = grid_x2 - a1; | |
3445 v13 = grid_z1 - a2; | |
3446 } | |
1643 | 3447 return v14 + v8 + fixpoint_mul(v13, (v10 - v8) * 128) + fixpoint_mul(v15, (v9 - v8) * 128); |
812 | 3448 } |
3449 else | |
3450 return y_x1z1; | |
0 | 3451 } |
3452 | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
3453 |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
3454 |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
3455 |
0 | 3456 |
3457 //----- (00485F53) -------------------------------------------------------- | |
1458 | 3458 void sr_485F53(Vec2_int_ *v) |
0 | 3459 { |
3460 ++v->y; | |
3461 if ( v->y > 1000 ) | |
3462 v->y = 0; | |
3463 } | |
3464 | |
3465 //----- (0048607B) -------------------------------------------------------- | |
1427 | 3466 void Polygon::Create_48607B(stru149 *a2) |
0 | 3467 { |
3468 this->pTexture = 0; | |
3469 this->ptr_38 = a2; | |
3470 } | |
3471 | |
3472 //----- (00486089) -------------------------------------------------------- | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
3473 void Polygon::_normalize_v_18() |
0 | 3474 { |
3475 double v2; // st7@1 | |
3476 double v3; // st6@1 | |
3477 double v5; // st5@1 | |
3478 | |
1025 | 3479 //v1 = this; |
0 | 3480 v2 = (double)this->v_18.x; |
3481 v3 = (double)this->v_18.y; | |
3482 v5 = (double)this->v_18.z; | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
3483 float len = sqrt(v5 * v5 + v3 * v3 + v2 * v2); |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
3484 if (fabsf(len) < 1e-6f) |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
3485 { |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
3486 v_18.x = 0; |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
3487 v_18.y = 0; |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
3488 v_18.z = 65536; |
0 | 3489 } |
3490 else | |
3491 { | |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
3492 v_18.x = round(v2 / len * 65536.0); |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
3493 v_18.y = round(v3 / len * 65536.0); |
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1401
diff
changeset
|
3494 v_18.y = round(v5 / len * 65536.0); |
0 | 3495 } |
3496 } | |
3497 | |
3498 //----- (0048616B) -------------------------------------------------------- | |
1544 | 3499 void stru149::_48616B_frustum_odm(int a2, int a3, int a4, int a5, int a6, int a7) |
0 | 3500 { |
3501 int v7; // ebx@1 | |
1544 | 3502 //int v8; // esi@1 |
0 | 3503 int v9; // edi@1 |
1544 | 3504 //int v10; // eax@1 |
0 | 3505 int v11; // edx@1 |
1544 | 3506 //int v12; // esi@2 |
3507 //int v13; // eax@2 | |
3508 //int v14; // ST10_4@3 | |
3509 //int v15; // esi@3 | |
3510 //int v16; // eax@5 | |
0 | 3511 int v17; // ST0C_4@6 |
1544 | 3512 //int v18; // eax@8 |
0 | 3513 int v19; // ST0C_4@9 |
1544 | 3514 //int v20; // eax@10 |
3515 //int v21; // edx@10 | |
3516 //int v22; // eax@10 | |
3517 //int result; // eax@10 | |
0 | 3518 int v24; // [sp+14h] [bp-14h]@1 |
3519 int v25; // [sp+18h] [bp-10h]@1 | |
1544 | 3520 //int v26; // [sp+1Ch] [bp-Ch]@1 |
0 | 3521 int v27; // [sp+24h] [bp-4h]@1 |
1544 | 3522 //int v28; // [sp+30h] [bp+8h]@10 |
3523 //int v29; // [sp+3Ch] [bp+14h]@10 | |
0 | 3524 |
1642 | 3525 v25 = pGame->pIndoorCameraD3D->int_cosine_x; |
3526 v7 = pGame->pIndoorCameraD3D->int_sine_y; | |
3527 v27 = pGame->pIndoorCameraD3D->int_sine_x; | |
1544 | 3528 //v8 = -pIndoorCamera->pos.y; |
1642 | 3529 v9 = pGame->pIndoorCameraD3D->int_cosine_y; |
1544 | 3530 //v26 = -pIndoorCamera->pos.z; |
1642 | 3531 v11 = pGame->pIndoorCameraD3D->int_cosine_y * -pGame->pIndoorCameraD3D->vPartyPos.x + pGame->pIndoorCameraD3D->int_sine_y * -pGame->pIndoorCameraD3D->vPartyPos.y; |
3532 v24 = pGame->pIndoorCameraD3D->int_cosine_y * -pGame->pIndoorCameraD3D->vPartyPos.y - pGame->pIndoorCameraD3D->int_sine_y * -pGame->pIndoorCameraD3D->vPartyPos.x; | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
3533 if (pGame->pIndoorCameraD3D->sRotationX) |
0 | 3534 { |
1643 | 3535 this->field_0_party_dir_x = fixpoint_mul(v11, pGame->pIndoorCameraD3D->int_cosine_x) + |
3536 fixpoint_mul((-pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x); | |
1544 | 3537 this->field_4_party_dir_y = v24; |
1643 | 3538 this->field_8_party_dir_z = fixpoint_mul((-pGame->pIndoorCameraD3D->vPartyPos.z) << 16, v25) - fixpoint_mul(v11, v27); |
0 | 3539 } |
3540 else | |
3541 { | |
755 | 3542 this->field_0_party_dir_x = v11; |
1544 | 3543 this->field_4_party_dir_y = v24; |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
3544 this->field_8_party_dir_z = (-pGame->pIndoorCameraD3D->vPartyPos.z) << 16; |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
3545 } |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
3546 |
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
3547 if (pGame->pIndoorCameraD3D->sRotationX) |
1544 | 3548 { |
1643 | 3549 v17 = fixpoint_mul(a2, v9) + fixpoint_mul(a3, v7); |
3550 | |
1809 | 3551 this->angle_from_north = fixpoint_mul(v17, v25) + fixpoint_mul(a4, v27); |
3552 this->angle_from_west = fixpoint_mul(a3, v9) - fixpoint_mul(a2, v7); | |
1844 | 3553 this->viewing_angle_from_west_east = fixpoint_mul(a4, v25) - fixpoint_mul(v17, v27); |
0 | 3554 } |
3555 else | |
3556 { | |
1809 | 3557 this->angle_from_north = fixpoint_mul(a2, v9) + fixpoint_mul(a3, v7); |
3558 this->angle_from_west = fixpoint_mul(a3, v9) - fixpoint_mul(a2, v7); | |
1844 | 3559 this->viewing_angle_from_west_east = a4; |
1544 | 3560 } |
3561 | |
1640
afc1c3514dd5
Some common code from ODM and BLV RenderParams moved to IndoorCameraD3D
Nomad
parents:
1638
diff
changeset
|
3562 if (pGame->pIndoorCameraD3D->sRotationX) |
1544 | 3563 { |
1643 | 3564 v19 = fixpoint_mul(a5, v9) + fixpoint_mul(a6, v7); |
3565 | |
1809 | 3566 this->angle_from_east = fixpoint_mul(v19, v25) + fixpoint_mul(a7, v27); |
3567 this->angle_from_south = fixpoint_mul(a6, v9) - fixpoint_mul(a5, v7); | |
1844 | 3568 this->viewing_angle_from_north_south = fixpoint_mul(a7, v25) - fixpoint_mul(v19, v27); |
0 | 3569 } |
3570 else | |
3571 { | |
1809 | 3572 this->angle_from_east = fixpoint_mul(a5, v9) + fixpoint_mul(a6, v7); |
3573 this->angle_from_south = fixpoint_mul(a6, v9) - fixpoint_mul(a5, v7); | |
1844 | 3574 this->viewing_angle_from_north_south = a7; |
1544 | 3575 } |
3576 | |
1809 | 3577 this->angle_from_east = -this->angle_from_east; |
3578 this->angle_from_south = -this->angle_from_south; | |
1844 | 3579 this->viewing_angle_from_north_south = -this->viewing_angle_from_north_south; |
1544 | 3580 |
1809 | 3581 this->field_24 = fixpoint_dot(this->angle_from_north, this->field_0_party_dir_x, |
3582 this->angle_from_west, this->field_4_party_dir_y, | |
1844 | 3583 this->viewing_angle_from_west_east, this->field_8_party_dir_z); |
1809 | 3584 this->field_28 = fixpoint_dot(this->angle_from_east, this->field_0_party_dir_x, |
3585 this->angle_from_south, this->field_4_party_dir_y, | |
1844 | 3586 this->viewing_angle_from_north_south, this->field_8_party_dir_z); |
0 | 3587 } |
3588 | |
3589 //----- (0048694B) -------------------------------------------------------- | |
1544 | 3590 void stru149::_48694B_frustum_sky() |
0 | 3591 { |
1809 | 3592 this->angle_from_east = -this->angle_from_east; |
3593 this->angle_from_south = -this->angle_from_south; | |
1844 | 3594 this->viewing_angle_from_north_south = -this->viewing_angle_from_north_south; |
1544 | 3595 |
1809 | 3596 this->field_24 = fixpoint_dot(this->angle_from_north, this->field_0_party_dir_x, |
3597 this->angle_from_west, this->field_4_party_dir_y, | |
1844 | 3598 this->viewing_angle_from_west_east, this->field_8_party_dir_z); |
1809 | 3599 this->field_28 = fixpoint_dot(this->angle_from_east, this->field_0_party_dir_x, |
3600 this->angle_from_south, this->field_4_party_dir_y, | |
1844 | 3601 this->viewing_angle_from_north_south, this->field_8_party_dir_z); |
0 | 3602 } |
3603 | |
3604 //----- (0044100D) -------------------------------------------------------- | |
994 | 3605 bool sub_44100D() |
0 | 3606 { |
569 | 3607 return pCurrentScreen == SCREEN_NPC_DIALOGUE || pCurrentScreen == SCREEN_CHARACTERS || |
3608 pCurrentScreen > SCREEN_LOADGAME && pCurrentScreen <= SCREEN_E || | |
3609 pCurrentScreen > SCREEN_VIDEO && pCurrentScreen <= SCREEN_INPUT_BLV || pCurrentScreen == SCREEN_CASTING; | |
0 | 3610 } |
3611 // 4E28F8: using guessed type int pCurrentScreen; | |
3612 | |
3613 //----- (00441A4E) -------------------------------------------------------- | |
910 | 3614 __int16 __fastcall sub_441A4E(int a1)//for blessing |
0 | 3615 { |
3616 __int16 result; // ax@1 | |
3617 int v2; // ebx@1 | |
3618 char *v3; // esi@1 | |
3619 int v4; // edi@4 | |
1110 | 3620 bool v5; // ecx@4 |
1523
53265d238d94
interaction_distance_limit for 3DModel in DrawStatusText
Ritor1
parents:
1504
diff
changeset
|
3621 SpriteFrame *pFrame; // eax@6 |
53265d238d94
interaction_distance_limit for 3DModel in DrawStatusText
Ritor1
parents:
1504
diff
changeset
|
3622 //SpriteFrame *v7; // edi@6 |
0 | 3623 int v8; // eax@6 |
3624 unsigned __int16 v9; // ax@6 | |
3625 RenderBillboardTransform_local0 v10; // [sp+Ch] [bp-5Ch]@1 | |
3626 int v11; // [sp+5Ch] [bp-Ch]@6 | |
3627 int v12; // [sp+60h] [bp-8h]@1 | |
3628 int v13; // [sp+64h] [bp-4h]@6 | |
3629 | |
2002 | 3630 v10.sParentBillboardID = -1; |
0 | 3631 v10.pTarget = pRenderer->pTargetSurface; |
3632 v10.pTargetZ = pRenderer->pActiveZBuffer; | |
3633 v10.uTargetPitch = pRenderer->field_10; | |
3634 result = 0; | |
3635 v2 = a1; | |
3636 v10.uViewportX = 0; | |
3637 v10.uViewportY = 0; | |
3638 v10.uViewportZ = 639; | |
3639 v10.uViewportW = 479; | |
3640 v12 = 0; | |
921 | 3641 //v3 = (char *)&pOtherOverlayList->pOverlays[0].field_C; |
3642 //do | |
3643 for ( uint i = 0; i < 50; ++i ) | |
3644 { | |
3645 if ( pOtherOverlayList->pOverlays[i].field_6 > 0 ) | |
3646 { | |
3647 result = pOtherOverlayList->pOverlays[i].field_0; | |
3648 if ( pOtherOverlayList->pOverlays[i].field_0 >= 300 ) | |
3649 { | |
3650 //v4 = result; | |
3651 v5 = pOtherOverlayList->pOverlays[i].field_0 == v2 + 320 | |
1110 | 3652 || pOtherOverlayList->pOverlays[i].field_0 == v2 + 330 |
3653 || pOtherOverlayList->pOverlays[i].field_0 == v2 + 340 | |
3654 || pOtherOverlayList->pOverlays[i].field_0 == v2 + 350; | |
921 | 3655 pOtherOverlayList->pOverlays[i].field_0 = v2 + 310; |
1110 | 3656 if ( pOtherOverlayList->pOverlays[i].field_0 == v2 + 310 || v5 ) |
921 | 3657 { |
3658 if ( !pOtherOverlayList->pOverlays[i].field_0 ) | |
3659 { | |
1523
53265d238d94
interaction_distance_limit for 3DModel in DrawStatusText
Ritor1
parents:
1504
diff
changeset
|
3660 pFrame = pSpriteFrameTable->GetFrame(pOverlayList->pOverlays[pOtherOverlayList->pOverlays[i].field_2].uSpriteFramesetID, |
921 | 3661 pOtherOverlayList->pOverlays[i].field_4); |
1523
53265d238d94
interaction_distance_limit for 3DModel in DrawStatusText
Ritor1
parents:
1504
diff
changeset
|
3662 //v7 = v6; |
921 | 3663 v11 = pOtherOverlayList->pOverlays[i].field_E; |
1523
53265d238d94
interaction_distance_limit for 3DModel in DrawStatusText
Ritor1
parents:
1504
diff
changeset
|
3664 //v13 = pFrame->scale; |
53265d238d94
interaction_distance_limit for 3DModel in DrawStatusText
Ritor1
parents:
1504
diff
changeset
|
3665 v13 = (unsigned __int64)(v11 * (signed __int64)pFrame->scale) >> 16; |
921 | 3666 v10.uScreenSpaceX = pOtherOverlayList->pOverlays[i].field_8; |
3667 v10.uScreenSpaceY = pOtherOverlayList->pOverlays[i].field_A; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
142
diff
changeset
|
3668 v10._screenspace_x_scaler_packedfloat = v13; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
142
diff
changeset
|
3669 v10._screenspace_y_scaler_packedfloat = v13; |
1523
53265d238d94
interaction_distance_limit for 3DModel in DrawStatusText
Ritor1
parents:
1504
diff
changeset
|
3670 v10.pPalette = PaletteManager::Get_Dark_or_Red_LUT(pFrame->uPaletteIndex, 0, 1); |
921 | 3671 v8 = pOtherOverlayList->pOverlays[i].field_2; |
0 | 3672 v10.sZValue = 0; |
3673 v10.uFlags = 0; | |
3674 v9 = pOverlayList->pOverlays[v8].uOverlayType; | |
3675 if ( !v9 || v9 == 2 ) | |
1523
53265d238d94
interaction_distance_limit for 3DModel in DrawStatusText
Ritor1
parents:
1504
diff
changeset
|
3676 v10.uScreenSpaceY += pSprites_LOD->pSpriteHeaders[pFrame->pHwSpriteIDs[0]].uHeight >> 1; |
53265d238d94
interaction_distance_limit for 3DModel in DrawStatusText
Ritor1
parents:
1504
diff
changeset
|
3677 result = pSprites_LOD->pSpriteHeaders[pFrame->pHwSpriteIDs[0]]._4AD2D1(&v10, 0); |
0 | 3678 ++v12; |
3679 if ( v12 == 5 ) | |
3680 break; | |
3681 } | |
3682 } | |
3683 } | |
3684 } | |
921 | 3685 //v3 += 20; |
3686 } | |
3687 //while ( (signed int)v3 < (signed int)&pOverlayList->pOverlays ); | |
0 | 3688 return result; |
3689 } | |
3690 | |
3691 //----- (00443801) -------------------------------------------------------- | |
237 | 3692 void Initialize2DA() |
3693 { | |
3694 | |
3695 int i; | |
3696 char* test_string; | |
3697 unsigned char c; | |
3698 bool break_loop; | |
3699 unsigned int temp_str_len; | |
3700 char* tmp_pos; | |
3701 int decode_step; | |
3702 | |
3703 if ( p2DEventsTXT_Raw ) | |
1583 | 3704 free(p2DEventsTXT_Raw); |
237 | 3705 p2DEventsTXT_Raw = NULL; |
3706 p2DEventsTXT_Raw = (char *)pEvents_LOD->LoadRaw("2dEvents.txt", 0); | |
3707 strtok(p2DEventsTXT_Raw, "\r"); | |
3708 strtok(NULL, "\r"); | |
3709 | |
3710 for (i=0;i<525;++i) | |
3711 { | |
3712 test_string = strtok(NULL, "\r") + 1; | |
3713 break_loop = false; | |
3714 decode_step=0; | |
3715 do | |
3716 { | |
3717 c = *(unsigned char*)test_string; | |
3718 temp_str_len = 0; | |
3719 while((c!='\t')&&(c>0)) | |
3720 { | |
3721 ++temp_str_len; | |
3722 c=test_string[temp_str_len]; | |
3723 } | |
3724 tmp_pos=test_string+temp_str_len; | |
3725 if (*tmp_pos == 0) | |
3726 break_loop = true; | |
3727 *tmp_pos = 0; | |
3728 if (temp_str_len) | |
3729 { | |
3730 switch (decode_step) | |
3731 { | |
3732 case 2: | |
3733 { | |
3734 if ( !_strnicmp(test_string, "wea", 3) ) | |
3735 { | |
1411 | 3736 p2DEvents[i].uType = BuildingType_WeaponShop; |
237 | 3737 break; |
3738 } | |
3739 if ( !_strnicmp(test_string, "arm", 3) ) | |
3740 { | |
1411 | 3741 p2DEvents[i].uType = BuildingType_ArmorShop; |
237 | 3742 break; |
3743 } | |
3744 if ( !_strnicmp(test_string, "mag", 3) ) | |
3745 { | |
1411 | 3746 p2DEvents[i].uType = BuildingType_MagicShop; |
237 | 3747 break; |
3748 } | |
3749 if ( !_strnicmp(test_string, "alc", 3) ) | |
3750 { | |
1411 | 3751 p2DEvents[i].uType = BuildingType_AlchemistShop; |
237 | 3752 break; |
3753 } | |
3754 if ( !_strnicmp(test_string, "sta", 3) ) | |
3755 { | |
1411 | 3756 p2DEvents[i].uType = BuildingType_Stables; |
237 | 3757 break; |
3758 } | |
3759 if ( !_strnicmp(test_string, "boa", 3) ) | |
3760 { | |
1411 | 3761 p2DEvents[i].uType = BuildingType_Boats; |
237 | 3762 break; |
3763 } | |
3764 if ( !_strnicmp(test_string, "tem", 3) ) | |
3765 { | |
1411 | 3766 p2DEvents[i].uType = BuildingType_Temple; |
237 | 3767 break; |
3768 } | |
3769 if ( !_strnicmp(test_string, "tra", 3) ) | |
3770 { | |
1411 | 3771 p2DEvents[i].uType = BuildingType_Training; |
237 | 3772 break; |
3773 } | |
3774 if ( !_strnicmp(test_string, "tow", 3) ) | |
3775 { | |
1411 | 3776 p2DEvents[i].uType = BuildingType_TownHall; |
237 | 3777 break; |
3778 } | |
3779 | |
3780 if ( !_strnicmp(test_string, "tav", 3) ) | |
3781 { | |
1411 | 3782 p2DEvents[i].uType = BuildingType_Tavern; |
237 | 3783 break; |
3784 } | |
3785 if ( !_strnicmp(test_string, "ban", 3) ) | |
3786 { | |
1411 | 3787 p2DEvents[i].uType = BuildingType_Bank; |
237 | 3788 break; |
3789 } | |
3790 if ( !_strnicmp(test_string, "fir", 3) ) | |
3791 { | |
1411 | 3792 p2DEvents[i].uType = BuildingType_FireGuild; |
237 | 3793 break; |
3794 } | |
3795 if ( !_strnicmp(test_string, "air", 3) ) | |
3796 { | |
1411 | 3797 p2DEvents[i].uType = BuildingType_AirGuild; |
237 | 3798 break; |
3799 } | |
3800 if ( !_strnicmp(test_string, "wat", 3) ) | |
3801 { | |
1411 | 3802 p2DEvents[i].uType = BuildingType_WaterGuild; |
237 | 3803 break; |
3804 } | |
3805 if ( !_strnicmp(test_string, "ear", 3) ) | |
3806 { | |
1411 | 3807 p2DEvents[i].uType = BuildingType_EarthGuild; |
237 | 3808 break; |
3809 } | |
3810 if ( !_strnicmp(test_string, "spi", 3) ) | |
3811 { | |
1411 | 3812 p2DEvents[i].uType = BuildingType_SpiritGuild; |
237 | 3813 break; |
3814 } | |
3815 if ( !_strnicmp(test_string, "min", 3) ) | |
3816 { | |
1411 | 3817 p2DEvents[i].uType = BuildingType_MindGuild; |
237 | 3818 break; |
3819 } | |
3820 if ( !_strnicmp(test_string, "bod", 3) ) | |
3821 { | |
1411 | 3822 p2DEvents[i].uType = BuildingType_BodyGuild; |
237 | 3823 break; |
3824 } | |
3825 if ( !_strnicmp(test_string, "lig", 3) ) | |
3826 { | |
1411 | 3827 p2DEvents[i].uType = BuildingType_LightGuild; |
237 | 3828 break; |
3829 } | |
3830 if ( !_strnicmp(test_string, "dar", 3) ) | |
3831 { | |
1411 | 3832 p2DEvents[i].uType = BuildingType_DarkGuild; |
237 | 3833 break; |
3834 } | |
1644 | 3835 if ( !_strnicmp(test_string, "ele", 3) ) // "Element Guild" from mm6 |
237 | 3836 { |
1644 | 3837 p2DEvents[i].uType = BuildingType_ElementalGuild; |
237 | 3838 break; |
3839 } | |
3840 if ( !_strnicmp(test_string, "sel", 3) ) | |
3841 { | |
1644 | 3842 p2DEvents[i].uType = BuildingType_SelfGuild; |
237 | 3843 break; |
3844 } | |
3845 if ( !_strnicmp(test_string, "mir", 3) ) | |
3846 { | |
1411 | 3847 p2DEvents[i].uType = BuildingType_16; |
237 | 3848 break; |
3849 } | |
1644 | 3850 if ( !_strnicmp(test_string, "mer", 3) ) // "Merc Guild" from mm6 |
237 | 3851 { |
1411 | 3852 p2DEvents[i].uType = BuildingType_TownHall; |
237 | 3853 break; |
3854 } | |
1411 | 3855 p2DEvents[i].uType = BuildingType_18; |
237 | 3856 } |
3857 break; | |
3858 | |
3859 case 4: | |
3860 p2DEvents[i].uAnimationID = atoi(test_string); | |
3861 break; | |
3862 case 5: | |
3863 p2DEvents[i].pName = RemoveQuotes(test_string); | |
3864 break; | |
3865 case 6: | |
3866 p2DEvents[i].pProprieterName = RemoveQuotes(test_string); | |
3867 break; | |
3868 case 7: | |
3869 p2DEvents[i].pProprieterTitle = RemoveQuotes(test_string); | |
3870 break; | |
3871 case 8: | |
3872 p2DEvents[i].field_14 = atoi(test_string); | |
3873 break; | |
3874 case 9: | |
3875 p2DEvents[i]._state = atoi(test_string); | |
3876 break; | |
3877 case 10: | |
3878 p2DEvents[i]._rep = atoi(test_string); | |
3879 break; | |
3880 case 11: | |
3881 p2DEvents[i]._per = atoi(test_string); | |
3882 break; | |
3883 case 12: | |
3884 p2DEvents[i].fPriceMultiplier = atof(test_string); | |
3885 break; | |
3886 case 13: | |
3887 p2DEvents[i].flt_24 = atof(test_string); | |
3888 break; | |
3889 case 15: | |
3890 p2DEvents[i].field_1C = atoi(test_string); | |
3891 break; | |
3892 case 18: | |
3893 p2DEvents[i].uOpenTime = atoi(test_string); | |
3894 break; | |
3895 case 19: | |
3896 p2DEvents[i].uCloseTime = atoi(test_string); | |
3897 break; | |
3898 case 20: | |
3899 p2DEvents[i].uExitPicID = atoi(test_string); | |
3900 break; | |
3901 case 21: | |
3902 p2DEvents[i].uExitMapID = atoi(test_string); | |
3903 break; | |
3904 case 22: | |
3905 p2DEvents[i]._quest_related = atoi(test_string); | |
3906 break; | |
3907 case 23: | |
3908 p2DEvents[i].pEnterText = RemoveQuotes(test_string); | |
3909 break; | |
3910 } | |
3911 } | |
3912 ++decode_step; | |
3913 test_string=tmp_pos+1; | |
3914 } while ((decode_step<24)&&!break_loop); | |
3915 } | |
3916 | |
0 | 3917 } |
3918 | |
3919 //----- (00443E31) -------------------------------------------------------- | |
601 | 3920 void LoadLevel_InitializeLevelStr() |
3921 { | |
329 | 3922 |
3923 char Args[100]; | |
3924 int string_num; | |
3925 int max_string_length; | |
3926 int current_string_length; | |
3927 int prev_string_offset; | |
3928 | |
3929 if (sizeof(pLevelStrOffsets) != 2000) | |
0 | 3930 Log::Warning(L"pLevelStrOffsets: deserialization warning"); |
1202 | 3931 memset(pLevelStrOffsets.data(), 0, 2000); |
0 | 3932 |
329 | 3933 max_string_length = 0; |
3934 string_num = 1; | |
3935 prev_string_offset = 0; | |
336 | 3936 pLevelStrOffsets[0]=0; |
0 | 3937 for (uint i = 0; i < uLevelStrFileSize; ++i) |
3938 { | |
3939 if ( !pLevelStr[i] ) | |
3940 { | |
329 | 3941 pLevelStrOffsets[string_num] = i + 1; |
3942 ++string_num; | |
3943 if ( i - prev_string_offset > max_string_length ) | |
3944 max_string_length = i - prev_string_offset; | |
3945 prev_string_offset = i; | |
3946 } | |
3947 } | |
3948 | |
3949 uLevelStrNumStrings = string_num - 1; | |
3950 if ( max_string_length > 800 ) | |
1545 | 3951 Error("MAX_EVENT_TEXT_LENGTH needs to be increased to %lu", max_string_length+1); |
329 | 3952 |
3953 if ( uLevelStrNumStrings > 0 ) | |
3954 { | |
336 | 3955 for(uint i = 0; i <uLevelStrNumStrings ; ++i) |
329 | 3956 { |
3957 if ( RemoveQuotes(&pLevelStr[pLevelStrOffsets[i]]) != &pLevelStr[pLevelStrOffsets[i]] ) | |
3958 ++pLevelStrOffsets[i]; | |
3959 } | |
0 | 3960 } |
3961 } | |
3962 | |
3963 //----- (00443F95) -------------------------------------------------------- | |
1458 | 3964 void OnMapLeave() |
0 | 3965 { |
336 | 3966 _evt_raw *test_event; |
3967 if ( uLevelEVT_NumEvents > 0 ) | |
3968 { | |
3969 for (uint i = 0; i < uLevelEVT_NumEvents; ++i) | |
3970 { | |
3971 test_event=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[i].uEventOffsetInEVT]; | |
1052 | 3972 if ( test_event->_e_type == EVENT_OnMapLeave ) |
3973 { | |
3974 EventProcessor(pLevelEVT_Index[i].uEventID, 0, 1, pLevelEVT_Index[i].event_sequence_num); | |
336 | 3975 } |
3976 } | |
0 | 3977 } |
3978 } | |
3979 | |
3980 //----- (00443FDC) -------------------------------------------------------- | |
3981 void OnMapLoad() | |
781 | 3982 { |
363 | 3983 stru176 *v3; // esi@7 |
3984 __int16 v4; // cx@9 | |
3985 __int16 v5; // di@9 | |
3986 int v6; // eax@9 | |
3987 signed __int64 v8; // qax@26 | |
3988 unsigned int v9; // ecx@26 | |
3989 signed __int64 v10; // qax@26 | |
3990 signed __int64 v11; // qax@26 | |
3991 int v12; // ST50_4@26 | |
3992 signed __int64 v13; // qax@26 | |
3993 signed __int64 v14; // qax@26 | |
3994 int v15; // ST58_4@26 | |
3995 signed __int64 v16; // qax@26 | |
3996 int hours; // ebx@26 | |
3997 unsigned __int64 v18; // [sp+Ch] [bp-44h]@12 | |
3998 signed __int64 seconds; // [sp+14h] [bp-3Ch]@26 | |
3999 unsigned __int64 v20; // [sp+1Ch] [bp-34h]@7 | |
4000 int minutes; // [sp+2Ch] [bp-24h]@26 | |
4001 int years; // [sp+34h] [bp-1Ch]@26 | |
4002 int weeks; // [sp+38h] [bp-18h]@26 | |
4003 int v26; // [sp+3Ch] [bp-14h]@15 | |
4004 int days; // [sp+3Ch] [bp-14h]@26 | |
4005 int months; // [sp+40h] [bp-10h]@26 | |
4006 __int16 v29; // [sp+46h] [bp-Ah]@9 | |
4007 __int16 v30; // [sp+48h] [bp-8h]@9 | |
4008 __int16 v31; // [sp+4Ah] [bp-6h]@9 | |
4009 __int16 v32; // [sp+4Ch] [bp-4h]@9 | |
4010 __int16 v33; // [sp+4Eh] [bp-2h]@9 | |
4011 | |
4012 for (uint i = 0; i < uLevelEVT_NumEvents; ++i) | |
781 | 4013 { |
1980 | 4014 EventIndex pEvent = pLevelEVT_Index[i]; |
4015 | |
4016 _evt_raw* _evt = (_evt_raw *)(&pLevelEVT[pEvent.uEventOffsetInEVT]); | |
363 | 4017 |
4018 if (_evt->_e_type == EVENT_PlaySound) | |
781 | 4019 { |
601 | 4020 pSoundList->LoadSound(EVT_DWORD(_evt->v5), 0); |
781 | 4021 } |
363 | 4022 else if (_evt->_e_type == EVENT_OnMapReload) |
781 | 4023 { |
1052 | 4024 EventProcessor(pEvent.uEventID, 0, 0, pEvent.event_sequence_num); |
781 | 4025 } |
1052 | 4026 else if (_evt->_e_type == EVENT_OnTimer || _evt->_e_type == EVENT_Initialize) |
781 | 4027 { |
363 | 4028 v3 = &array_5B5928_timers[dword_5B65C8_timers_count]; |
810 | 4029 v20 = pOutdoor->loc_time.uLastVisitDay; |
363 | 4030 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) |
4031 v20 = pIndoor->stru1.uLastVisitDay; | |
4032 | |
4033 v3->timer_evt_type = _evt->_e_type; | |
4034 v3->timer_evt_ID = pEvent.uEventID; | |
4035 v3->timer_evt_seq_num = pEvent.event_sequence_num; | |
4036 | |
4037 v3->field_10 = _evt->v5; | |
4038 v3->field_12 = _evt->v6; | |
4039 v3->field_14 = _evt->v7; | |
4040 v3->field_16 = _evt->v8; | |
4041 v3->field_18 = _evt->v9; | |
4042 v3->field_1A = _evt->v10; | |
4043 | |
4044 | |
4045 v6 = ((unsigned short)_evt->v12 << 8) + _evt->v11; | |
4046 | |
789 | 4047 v3->time_left_to_fire = ((unsigned short)_evt->v12 << 8) + _evt->v11; |
4048 v3->fire_interval = ((unsigned short)_evt->v12 << 8) + _evt->v11; | |
1052 | 4049 if (v3->timer_evt_type == EVENT_Initialize && !(short)v6 ) |
781 | 4050 { |
363 | 4051 if ( v20 ) |
4052 v18 = pParty->uTimePlayed - v20; | |
4053 else | |
4054 v18 = 0i64; | |
4055 v26 = (signed int)(signed __int64)((double)(signed __int64)v18 * 0.234375) / 60 / 60 / 24; | |
4056 | |
4057 if ( v26 / 7 / 4 / 12 ) | |
781 | 4058 { |
363 | 4059 if ( v3->field_10 ) |
781 | 4060 { |
363 | 4061 ++dword_5B65C8_timers_count; |
789 | 4062 v3->next_fire_time = 0; |
363 | 4063 continue; |
4064 } | |
781 | 4065 } |
363 | 4066 if (v26 / 7 / 4 != 0 && v3->field_12 != 0 || |
4067 v26 / 7 != 0 && v3->field_14 != 0 || | |
4068 v26 != 0 || !v20) | |
781 | 4069 { |
363 | 4070 ++dword_5B65C8_timers_count; |
789 | 4071 v3->next_fire_time = 0; |
363 | 4072 continue; |
4073 } | |
781 | 4074 } |
363 | 4075 else |
781 | 4076 { |
363 | 4077 v8 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375); |
4078 v9 = v8; | |
4079 v10 = (signed int)v8 / 60; | |
4080 minutes = v10 % 60; | |
4081 v11 = (signed int)(v10 / 60); | |
4082 v12 = v11 % 24; | |
4083 v13 = (signed int)(v11 / 24); | |
4084 days = v13 % 7; | |
4085 v14 = (signed int)(v13 / 7); | |
4086 v15 = v14 % 4; | |
4087 v16 = (signed int)(v14 / 4); | |
4088 years = v16 / 12; | |
4089 | |
1980 | 4090 unsigned __int64 _1 = (unsigned __int64)((double)pParty->uTimePlayed * 0.234375) >> 32; |
4091 __int64 _2 = ((__int64)v9 << 32) | _1; | |
363 | 4092 |
4093 seconds = _2 % 60; | |
4094 //v19 = (signed __int64)__PAIR__((unsigned __int64)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) >> 32, | |
4095 // v9) | |
4096 // % 60; | |
4097 | |
4098 hours = v12; | |
4099 weeks = v15; | |
4100 months = v16 % 12; | |
4101 if ( v3->field_10 ) | |
781 | 4102 { |
363 | 4103 ++years; |
781 | 4104 } |
363 | 4105 else |
781 | 4106 { |
363 | 4107 if ( v3->field_12 ) |
781 | 4108 { |
4109 ++months; | |
4110 } | |
4111 else | |
4112 { | |
4113 if ( v3->field_14 ) | |
363 | 4114 { |
781 | 4115 ++weeks; |
363 | 4116 } |
781 | 4117 else |
363 | 4118 { |
4119 ++days; | |
4120 minutes = v3->field_18; | |
4121 hours = v3->field_16; | |
4122 seconds = v3->field_1A; | |
4123 } | |
4124 } | |
781 | 4125 } |
789 | 4126 v3->next_fire_time = (signed __int64)((double)((seconds |
363 | 4127 + 60 * minutes |
4128 + 3600 * hours | |
4129 + 0x93A80 * weeks | |
4130 + 0x15180 * days | |
4131 + 0x24EA00 * (months + 12i64 * years)) << 7) | |
4132 * 0.033333335); | |
4133 | |
4134 ++dword_5B65C8_timers_count; | |
4135 } | |
4136 } | |
4137 } | |
781 | 4138 } |
0 | 4139 |
4140 //----- (00444360) -------------------------------------------------------- | |
1411 | 4141 void Level_LoadEvtAndStr(const char *pLevelName) |
0 | 4142 { |
4143 char pContainerName[120]; // [sp+8h] [bp-98h]@1 | |
4144 | |
4145 sprintf(pContainerName, "%s.evt", pLevelName); | |
1541 | 4146 uLevelEVT_Size = LoadEventsToBuffer(pContainerName, pLevelEVT.data(), 9216); |
0 | 4147 |
4148 sprintf(pContainerName, "%s.str", pLevelName); | |
1541 | 4149 uLevelStrFileSize = LoadEventsToBuffer(pContainerName, pLevelStr.data(), 9216); |
0 | 4150 if (uLevelStrFileSize) |
4151 LoadLevel_InitializeLevelStr(); | |
4152 } | |
4153 | |
4154 //----- (00444D80) -------------------------------------------------------- | |
1411 | 4155 int GetTravelTime() |
0 | 4156 { |
4157 signed int v0; // esi@1 | |
4158 | |
4159 v0 = uDefaultTravelTime_ByFoot; | |
652 | 4160 if ( CheckHiredNPCSpeciality(Guide) ) |
0 | 4161 --v0; |
652 | 4162 if ( CheckHiredNPCSpeciality(Tracker) ) |
0 | 4163 v0 -= 2; |
652 | 4164 if ( CheckHiredNPCSpeciality(Pathfinder) ) |
0 | 4165 v0 -= 3; |
652 | 4166 if ( CheckHiredNPCSpeciality(Explorer) ) |
0 | 4167 --v0; |
4168 if ( v0 < 1 ) | |
4169 v0 = 1; | |
4170 return v0; | |
4171 } | |
4172 // 6BD07C: using guessed type int uDefaultTravelTime_ByFoot; | |
4173 | |
4174 //----- (004451A8) -------------------------------------------------------- | |
4175 void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4) | |
4176 { | |
4177 int v3; // esi@1 | |
4178 int v4; // edi@1 | |
4179 | |
4180 v3 = a2; | |
4181 v4 = a1; | |
4182 if ( !pGUIWindow2 ) | |
4183 { | |
4184 if ( pParty->uFlags & 2 ) | |
4185 pGame->Draw(); | |
1052 | 4186 pAudioPlayer->StopChannels(-1, -1); |
0 | 4187 pMiscTimer->Pause(); |
4188 pEventTimer->Pause(); | |
4189 dword_5C3418 = v4; | |
4190 dword_5C341C = v3; | |
520
35f28d4c0ff9
GlobalEventInfo changed to LevelDecoration* activeLevelDecoration
Gloval
parents:
515
diff
changeset
|
4191 _591094_decoration = activeLevelDecoration; |
948 | 4192 pGUIWindow2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_GreetingNPC, a4, 0); |
4193 pGUIWindow2->CreateButton( 61, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); | |
4194 pGUIWindow2->CreateButton(177, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); | |
4195 pGUIWindow2->CreateButton(292, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); | |
4196 pGUIWindow2->CreateButton(407, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); | |
0 | 4197 } |
4198 } | |
4199 | |
4200 //----- (004452BB) -------------------------------------------------------- | |
1546 | 4201 void sub_4452BB() |
0 | 4202 { |
4203 pGUIWindow2->Release(); | |
4204 pGUIWindow2 = 0; | |
520
35f28d4c0ff9
GlobalEventInfo changed to LevelDecoration* activeLevelDecoration
Gloval
parents:
515
diff
changeset
|
4205 activeLevelDecoration = _591094_decoration; |
1052 | 4206 EventProcessor(dword_5C3418, 0, 1, dword_5C341C); |
520
35f28d4c0ff9
GlobalEventInfo changed to LevelDecoration* activeLevelDecoration
Gloval
parents:
515
diff
changeset
|
4207 activeLevelDecoration = NULL; |
0 | 4208 pEventTimer->Resume(); |
4209 } | |
4210 | |
4211 //----- (004465DF) -------------------------------------------------------- | |
4212 int sub_4465DF_check_season(int a1) | |
4213 { | |
4214 unsigned int v1; // eax@1 | |
4215 unsigned int v2; // edx@1 | |
4216 int v3; // ecx@2 | |
4217 int v4; // ecx@3 | |
4218 char v6; // zf@9 | |
4219 | |
4220 v1 = pParty->uCurrentMonth + 1; | |
4221 v2 = pParty->uDaysPlayed + 1; | |
4222 if ( a1 ) | |
4223 { | |
4224 v3 = a1 - 1; | |
4225 if ( v3 ) | |
4226 { | |
4227 v4 = v3 - 1; | |
4228 if ( v4 ) | |
4229 { | |
4230 if ( v4 != 1 ) | |
4231 return 0; | |
4232 if ( v1 != 12 ) | |
4233 { | |
4234 if ( (signed int)v1 >= 1 && (signed int)v1 <= 2 ) | |
4235 return 1; | |
4236 v6 = v1 == 3; | |
4237 LABEL_24: | |
4238 if ( !v6 || (signed int)v2 >= 21 ) | |
4239 return 0; | |
4240 return 1; | |
4241 } | |
4242 } | |
4243 else | |
4244 { | |
4245 if ( v1 != 9 ) | |
4246 { | |
4247 if ( (signed int)v1 >= 10 && (signed int)v1 <= 11 ) | |
4248 return 1; | |
4249 v6 = v1 == 12; | |
4250 goto LABEL_24; | |
4251 } | |
4252 } | |
4253 } | |
4254 else | |
4255 { | |
4256 if ( v1 != 6 ) | |
4257 { | |
4258 if ( (signed int)v1 >= 7 && (signed int)v1 <= 8 ) | |
4259 return 1; | |
4260 v6 = v1 == 9; | |
4261 goto LABEL_24; | |
4262 } | |
4263 } | |
4264 } | |
4265 else | |
4266 { | |
4267 if ( v1 != 3 ) | |
4268 { | |
4269 if ( (signed int)v1 >= 4 && (signed int)v1 <= 5 ) | |
4270 return 1; | |
4271 v6 = v1 == 6; | |
4272 goto LABEL_24; | |
4273 } | |
4274 } | |
4275 if ( (signed int)v2 >= 21 ) | |
4276 return 1; | |
4277 return 0; | |
4278 } | |
4279 | |
4280 //----- (0044861E) -------------------------------------------------------- | |
4281 void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename) | |
4282 { | |
4283 unsigned int v2; // eax@2 | |
4284 unsigned __int16 v3; // di@2 | |
4285 signed int v4; // esi@5 | |
4286 BLVFace *v5; // eax@7 | |
4287 unsigned int *v6; // eax@8 | |
4288 char *v7; // eax@9 | |
4289 int v8; // edi@16 | |
4290 char *v9; // esi@16 | |
4291 ODMFace *v10; // eax@17 | |
4292 unsigned int *v11; // eax@19 | |
4293 unsigned __int16 v12; // [sp+Ch] [bp-18h]@2 | |
4294 const char *Str2; // [sp+10h] [bp-14h]@1 | |
4295 unsigned int v14; // [sp+14h] [bp-10h]@1 | |
4296 signed int v15; // [sp+18h] [bp-Ch]@14 | |
4297 int v16; // [sp+1Ch] [bp-8h]@15 | |
4298 signed int v17; // [sp+20h] [bp-4h]@4 | |
4299 signed int v18; // [sp+20h] [bp-4h]@16 | |
4300 | |
4301 Str2 = pFilename; | |
4302 v14 = uFaceCog; | |
4303 if ( uFaceCog ) | |
4304 { | |
4305 v2 = pBitmaps_LOD->LoadTexture(pFilename); | |
4306 v3 = v2; | |
4307 v12 = v2; | |
4308 if ( v2 != -1 ? (int)&pBitmaps_LOD->pTextures[v2] : 0 ) | |
4309 { | |
4310 pBitmaps_LOD->pTextures[v2].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v2].palette_id1); | |
4311 | |
4312 if ( uCurrentlyLoadedLevelType == 1 ) | |
4313 { | |
4314 v17 = 1; | |
4315 if ( (signed int)pIndoor->uNumFaceExtras > 1 ) | |
4316 { | |
4317 v4 = 1; | |
4318 do | |
4319 { | |
4320 if ( pIndoor->pFaceExtras[v4].sCogNumber == v14 ) | |
4321 { | |
4322 v5 = &pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C]; | |
4323 if ( BYTE1(v5->uAttributes) & 0x40 ) | |
4324 { | |
4325 pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uBitmapID = pTextureFrameTable->FindTextureByName( | |
4326 Str2); | |
4327 v6 = (unsigned int *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uBitmapID; | |
4328 if ( *(_WORD *)v6 ) | |
4329 { | |
4330 pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(_WORD *)v6); | |
4331 } | |
4332 else | |
4333 { | |
4334 *(_WORD *)v6 = v3; | |
4335 v7 = (char *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uAttributes; | |
4336 v7[1] &= 0xBFu; | |
4337 } | |
4338 } | |
4339 else | |
4340 { | |
4341 v5->uBitmapID = v3; | |
4342 } | |
4343 } | |
4344 ++v17; | |
4345 ++v4; | |
4346 } | |
4347 while ( v17 < (signed int)pIndoor->uNumFaceExtras ); | |
4348 } | |
4349 pParty->uFlags |= 2u; | |
4350 } | |
4351 else | |
4352 { | |
4353 v15 = 0; | |
4354 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
4355 { | |
4356 v16 = 0; | |
4357 do | |
4358 { | |
4359 v8 = 0; | |
4360 v9 = (char *)&pOutdoor->pBModels[v16].pVertices; | |
4361 v18 = 0; | |
4362 if ( (signed int)pOutdoor->pBModels[v16].uNumFaces > 0 ) | |
4363 { | |
4364 do | |
4365 { | |
4366 v10 = (ODMFace *)(v8 + *((_DWORD *)v9 + 4)); | |
4367 if ( v10->sCogNumber == v14 ) | |
4368 { | |
4369 if ( BYTE1(v10->uAttributes) & 0x40 ) | |
4370 { | |
4371 *(_WORD *)(*((_DWORD *)v9 + 4) + v8 + 272) = pTextureFrameTable->FindTextureByName( | |
4372 Str2); | |
4373 v11 = (unsigned int *)(*((_DWORD *)v9 + 4) + v8 + 272); | |
4374 if ( *(_WORD *)v11 ) | |
4375 { | |
4376 pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(_WORD *)v11); | |
4377 } | |
4378 else | |
4379 { | |
4380 *(_WORD *)v11 = v12; | |
4381 *(_BYTE *)(*((_DWORD *)v9 + 4) + v8 + 29) &= 0xBFu; | |
4382 } | |
4383 } | |
4384 else | |
4385 { | |
4386 v10->uTextureID = v12; | |
4387 } | |
4388 } | |
4389 ++v18; | |
4390 v8 += 308; | |
4391 } | |
4392 while ( v18 < *((_DWORD *)v9 + 2) ); | |
4393 } | |
4394 ++v15; | |
4395 ++v16; | |
4396 } | |
4397 while ( v15 < (signed int)pOutdoor->uNumBModels ); | |
4398 } | |
4399 } | |
4400 pParty->uFlags |= 2u; | |
4401 } | |
4402 } | |
4403 } | |
4404 | |
4405 //----- (0044882F) -------------------------------------------------------- | |
1515 | 4406 void __fastcall SetDecorationSprite(uint16_t uCog, bool bHide, const char *pFileName) |
0 | 4407 { |
1515 | 4408 for (size_t i = 0; i < uNumLevelDecorations; i++) |
4409 { | |
4410 if (pLevelDecorations[i].uCog == uCog) | |
0 | 4411 { |
1515 | 4412 if (pFileName && strcmp(pFileName, "0")) |
0 | 4413 { |
1515 | 4414 pLevelDecorations[i].uDecorationDescID = pDecorationList->GetDecorIdByName(pFileName); |
4415 pDecorationList->InitializeDecorationSprite(pLevelDecorations[i].uDecorationDescID); | |
0 | 4416 } |
1515 | 4417 |
4418 if (bHide) | |
4419 pLevelDecorations[i].uFlags &= ~LEVEL_DECORATION_INVISIBLE; | |
4420 else | |
4421 pLevelDecorations[i].uFlags |= LEVEL_DECORATION_INVISIBLE; | |
4422 | |
4423 pParty->uFlags |= 2u; | |
0 | 4424 } |
4425 } | |
4426 } | |
4427 | |
4428 //----- (0044892E) -------------------------------------------------------- | |
4429 void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on) | |
4430 { | |
4431 signed int v3; // esi@2 | |
4432 signed int v4; // ecx@4 | |
4433 char *v5; // eax@6 | |
4434 int v6; // edi@13 | |
4435 char *v7; // esi@13 | |
4436 signed int v8; // ecx@13 | |
4437 ODMFace *v9; // eax@14 | |
4438 int v10; // [sp+0h] [bp-Ch]@1 | |
4439 signed int v11; // [sp+4h] [bp-8h]@11 | |
4440 int v12; // [sp+8h] [bp-4h]@12 | |
4441 | |
4442 v10 = sCogNumber; | |
4443 if ( sCogNumber ) | |
4444 { | |
4445 v3 = 1; | |
4446 if ( uCurrentlyLoadedLevelType == 1 ) | |
4447 { | |
4448 if ( (signed int)pIndoor->uNumFaceExtras > 1 ) | |
4449 { | |
4450 v4 = 1; | |
4451 do | |
4452 { | |
4453 if ( pIndoor->pFaceExtras[v4].sCogNumber == v10 ) | |
4454 { | |
4455 v5 = (char *)&pIndoor->pFaces[pIndoor->pFaceExtras[v4].field_C].uAttributes; | |
4456 if ( on ) | |
4457 *(_DWORD *)v5 |= bit; | |
4458 else | |
4459 *(_DWORD *)v5 &= ~bit; | |
4460 } | |
4461 ++v3; | |
4462 ++v4; | |
4463 } | |
4464 while ( v3 < (signed int)pIndoor->uNumFaceExtras ); | |
4465 } | |
4466 pParty->uFlags |= 2u; | |
4467 } | |
4468 else | |
4469 { | |
4470 v11 = 0; | |
4471 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
4472 { | |
4473 v12 = 0; | |
4474 do | |
4475 { | |
4476 v6 = 0; | |
4477 v7 = (char *)&pOutdoor->pBModels[v12].pVertices; | |
4478 v8 = 0; | |
4479 if ( (signed int)pOutdoor->pBModels[v12].uNumFaces > 0 ) | |
4480 { | |
4481 do | |
4482 { | |
4483 v9 = (ODMFace *)(v6 + *((_DWORD *)v7 + 4)); | |
4484 if ( v9->sCogNumber == v10 ) | |
4485 { | |
4486 if ( on ) | |
4487 v9->uAttributes |= bit; | |
4488 else | |
4489 v9->uAttributes &= ~bit; | |
4490 } | |
4491 ++v8; | |
4492 v6 += 308; | |
4493 } | |
4494 while ( v8 < *((_DWORD *)v7 + 2) ); | |
4495 } | |
4496 ++v11; | |
4497 ++v12; | |
4498 } | |
4499 while ( v11 < (signed int)pOutdoor->uNumBModels ); | |
4500 } | |
4501 } | |
4502 pParty->uFlags |= 2u; | |
4503 } | |
4504 } | |
4505 | |
4506 //----- (00448A98) -------------------------------------------------------- | |
4507 void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle) | |
4508 { | |
4509 unsigned int v3; // ebx@1 | |
4510 unsigned int v4; // ebp@1 | |
4511 signed int v5; // edi@1 | |
82 | 4512 Actor *v6; // esi@4 |
0 | 4513 size_t v7; // ecx@10 |
82 | 4514 Actor *v8; // eax@11 |
0 | 4515 unsigned __int16 v9; // dx@14 |
4516 | |
4517 v4 = uGroupID; | |
4518 v5 = Standing; | |
4519 v3 = uFlag; | |
4520 if ( uGroupID ) | |
4521 { | |
4522 if ( bToggle ) | |
4523 { | |
4524 if ( (signed int)uNumActors > Standing ) | |
4525 { | |
1202 | 4526 v6 = pActors.data();//[0].uAttributes; |
0 | 4527 do |
4528 { | |
82 | 4529 if ( v6->uGroup == v4 ) |
4530 { | |
4531 v6->uAttributes |= v3; | |
0 | 4532 if ( v3 == 0x10000 ) |
4533 { | |
82 | 4534 v6->uAIState = Disabled; |
4535 v6->UpdateAnimation(); | |
0 | 4536 } |
4537 } | |
4538 ++v5; | |
82 | 4539 ++v6; |
0 | 4540 } |
4541 while ( v5 < (signed int)uNumActors ); | |
4542 } | |
4543 } | |
4544 else | |
4545 { | |
4546 v7 = uNumActors; | |
4547 if ( (signed int)uNumActors > Standing ) | |
4548 { | |
1202 | 4549 v8 = pActors.data();//[0].uAIState; |
0 | 4550 do |
4551 { | |
82 | 4552 if ( v8->uGroup == v4 ) |
0 | 4553 { |
4554 if ( v3 == 0x10000 ) | |
4555 { | |
82 | 4556 v9 = v8->uAIState; |
4557 if ( v8->uAIState != Dead ) | |
0 | 4558 { |
4559 if ( v9 != 4 && v9 != 11 ) | |
82 | 4560 v8->uAIState = Standing; |
4561 } | |
4562 } | |
4563 LODWORD(v8->uAttributes) &= ~v3; | |
4564 } | |
4565 ++v8; | |
0 | 4566 --v7; |
4567 } | |
4568 while ( v7 ); | |
4569 } | |
4570 } | |
4571 } | |
4572 } | |
4573 | |
4574 //----- (00448B45) -------------------------------------------------------- | |
1458 | 4575 void GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide) |
0 | 4576 { |
783 | 4577 if ( bForceHide || GameUI_Footer_TimeLeft && GetTickCount() >= GameUI_Footer_TimeLeft ) |
4578 GameUI_Footer_TimeLeft = 0; | |
0 | 4579 } |
4580 | |
4581 //----- (00448B67) -------------------------------------------------------- | |
790 | 4582 void OnTimer(int __unused) |
4583 { | |
789 | 4584 if (pEventTimer->bPaused) |
4585 return; | |
4586 | |
790 | 4587 if (__unused) |
4588 _5773C0_unused = 0; | |
789 | 4589 |
1980 | 4590 long long v13 = (signed __int64)(pParty->uTimePlayed - _5773B8_event_timer) / 128; |
789 | 4591 if (!v13) |
4592 return; | |
4593 | |
4594 //uint _v2v3 = pParty->uTimePlayed; | |
4595 //v3 = HIDWORD(pParty->uTimePlayed); | |
4596 //v2 = LODWORD(pParty->uTimePlayed); | |
4597 | |
4598 _5773B8_event_timer = pParty->uTimePlayed; | |
4599 | |
4600 for (uint i = 0; i < dword_5B65C8_timers_count; ++i) | |
4601 { | |
4602 //v4 = (char *)&array_5B5928_timers[0].field_C; | |
1980 | 4603 stru176* timer = &array_5B5928_timers[i]; |
789 | 4604 //while ( 1 ) |
4605 //{ | |
4606 //v5 = *(short *)v4; | |
4607 if (timer->time_left_to_fire) | |
4608 { | |
4609 if (v13 < timer->time_left_to_fire) | |
4610 timer->time_left_to_fire -= v13; | |
4611 else | |
4612 { | |
4613 timer->time_left_to_fire = timer->fire_interval; | |
1052 | 4614 EventProcessor(timer->timer_evt_ID, 0, 1, timer->timer_evt_seq_num); |
789 | 4615 } |
4616 } | |
4617 else | |
4618 { | |
4619 if (timer->next_fire_time < pParty->uTimePlayed) | |
4620 { | |
4621 uint next_trigger_time = 1 * 60 * 60 * 24; // 1 day | |
4622 if (timer->field_10) | |
4623 next_trigger_time = 336 * 60 * 60 * 24; // 1 year | |
4624 else if (timer->field_12) | |
4625 next_trigger_time = 28 * 60 * 60 * 24; // 1 month | |
4626 else if (timer->field_14) | |
4627 next_trigger_time = 7 * 60 * 60 * 24; // 1 week | |
4628 | |
4629 timer->next_fire_time += (next_trigger_time * 128) / 3.0f; | |
1052 | 4630 if (timer->next_fire_time < pParty->uTimePlayed) // make sure in wont fire several times in a row if big time interval has lapsed |
789 | 4631 timer->next_fire_time = pParty->uTimePlayed; |
4632 | |
1052 | 4633 EventProcessor(timer->timer_evt_ID, 0, 1, timer->timer_evt_seq_num); |
0 | 4634 } |
4635 } | |
4636 } | |
4637 } | |
4638 | |
4639 //----- (00481D77) -------------------------------------------------------- | |
4640 void _outdoor_project(RenderVertexSoft *v) | |
4641 { | |
4642 double v1; // st7@1 | |
4643 double v2; // st7@1 | |
4644 | |
4645 v1 = 1.0 / (v->vWorldViewPosition.x + 0.0000001); | |
168 | 4646 v->_rhw = v1; |
1637 | 4647 v2 = v1 * (double)pODMRenderParams->int_fov_rad; |
0 | 4648 v->vWorldViewProjX = (double)pViewport->uScreenCenterX - v2 * v->vWorldViewPosition.y; |
4649 v->vWorldViewProjY = (double)pViewport->uScreenCenterY - v2 * v->vWorldViewPosition.z; | |
4650 } | |
4651 | |
4652 //----- (00448CF4) -------------------------------------------------------- | |
4653 void __fastcall sub_448CF4_spawn_monsters(__int16 typeindex, __int16 level, int count, int x, int y, int z, int group, unsigned int uUniqueName) | |
4654 { | |
4655 __int16 v8; // di@1 | |
4656 __int16 v9; // si@1 | |
4657 unsigned int v10; // eax@1 | |
4658 size_t v11; // ebx@2 | |
4659 signed int v12; // esi@2 | |
35 | 4660 Actor *pActor;//Actor_uYawAngle_cr *v13; // ebx@3 |
0 | 4661 AIDirection a3; // [sp+Ch] [bp-50h]@2 |
4662 AIDirection v15; // [sp+28h] [bp-34h]@2 | |
4663 //SpawnPointMM7 v16; // [sp+44h] [bp-18h]@1 | |
4664 | |
4665 v8 = typeindex; | |
4666 v9 = level; | |
4667 | |
4668 SpawnPointMM7 v16; // [sp+44h] [bp-18h]@1 | |
4669 //SpawnPointMM7::SpawnPointMM7(&v16); | |
4670 | |
4671 v16.vPosition.x = x; | |
4672 v16.vPosition.y = y; | |
4673 v16.vPosition.z = z; | |
4674 v16.uGroup = group; | |
4675 v16.uRadius = 32; | |
4676 v16.uKind = 3; | |
4677 v16.uIndex = v8 + 2 * v9 + v9; | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1470
diff
changeset
|
4678 v10 = pMapStats->GetMapInfo(pCurrentMapName); |
0 | 4679 if ( v10 ) |
4680 { | |
4681 v11 = uNumActors; | |
1546 | 4682 SpawnEncounter(&pMapStats->pInfos[v10], &v16, 0, count, 0); |
1910
8d3723ca71e6
Actor::GetDirectionInfo changed the signature to a less confusing one
Grumpy7
parents:
1905
diff
changeset
|
4683 Actor::GetDirectionInfo(PID(OBJECT_Actor, v11), 4u, &v15, 1); |
0 | 4684 v12 = v11; |
4685 if ( (signed int)v11 < (signed int)uNumActors ) | |
4686 { | |
35 | 4687 for ( pActor = &pActors[v11]; v12 < (signed int)uNumActors; ++pActor ) |
4688 { | |
4689 pActor->PrepareSprites(0); | |
0 | 4690 ++v12; |
35 | 4691 pActor->uYawAngle = v15.uYawAngle; |
4692 pActor->dword_000334_unique_name = uUniqueName; | |
4693 } | |
0 | 4694 } |
4695 } | |
4696 } | |
4697 | |
4698 | |
4699 //----- (0044987B) -------------------------------------------------------- | |
783 | 4700 void sub_44987B(const char *pMapName, MapStartPoint start_point) |
0 | 4701 { |
4702 const char *v2; // edi@1 | |
4703 | |
4704 v2 = pMapName; | |
4705 pAudioPlayer->StopChannels(-1, -1); | |
434 | 4706 pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_None); |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1470
diff
changeset
|
4707 if ( _stricmp(pCurrentMapName, v2) ) |
0 | 4708 SaveGame(1, 0); |
783 | 4709 |
978 | 4710 uGameState = GAME_STATE_2; |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1470
diff
changeset
|
4711 strcpy(pCurrentMapName, v2); |
783 | 4712 uLevel_StartingPointType = start_point; |
0 | 4713 } |
4714 // 6BE35C: using guessed type int uLevel_StartingPointType; | |
4715 | |
4716 //----- (004498D5) -------------------------------------------------------- | |
783 | 4717 void TeleportToStartingPoint(MapStartPoint point) |
4718 { | |
4719 //unsigned int v1; // ecx@2 | |
4720 //int v2; // ecx@3 | |
4721 //int v3; // ecx@4 | |
0 | 4722 unsigned __int16 v4; // ax@11 |
4723 signed int v5; // ecx@12 | |
4724 LevelDecoration *v6; // edx@13 | |
4725 signed int v7; // ecx@17 | |
4726 int v8; // eax@17 | |
4727 int v9; // ecx@17 | |
4728 const char *v10; // [sp-4h] [bp-84h]@6 | |
4729 char pName[128]; // [sp+8h] [bp-78h]@11 | |
4730 | |
783 | 4731 switch (point) |
4732 { | |
4733 case MapStartPoint_Party: v10 = "Party Start"; break; | |
4734 case MapStartPoint_North: v10 = "North Start"; break; | |
4735 case MapStartPoint_South: v10 = "South Start"; break; | |
4736 case MapStartPoint_East: v10 = "East Start"; break; | |
4737 case MapStartPoint_West: v10 = "West Start"; break; | |
1546 | 4738 default: |
4739 Error("Invalid enum value: %u", point); | |
783 | 4740 } |
4741 | |
0 | 4742 strcpy(pName, v10); |
4743 v4 = pDecorationList->GetDecorIdByName(pName); | |
4744 if ( v4 ) | |
4745 { | |
4746 v5 = 0; | |
4747 if ( (signed int)uNumLevelDecorations > 0 ) | |
4748 { | |
1202 | 4749 v6 = pLevelDecorations.data(); |
0 | 4750 while ( v6->uDecorationDescID != (signed __int16)v4 ) |
4751 { | |
4752 ++v5; | |
4753 ++v6; | |
4754 if ( v5 >= (signed int)uNumLevelDecorations ) | |
4755 goto LABEL_20; | |
4756 } | |
4757 v7 = v5; | |
4758 pParty->vPosition.x = pLevelDecorations[v7].vPosition.x; | |
4759 pParty->vPosition.y = pLevelDecorations[v7].vPosition.y; | |
4760 pParty->vPosition.z = pLevelDecorations[v7].vPosition.z; | |
4761 pParty->uFallStartY = pParty->vPosition.z; | |
4762 v8 = (signed int)(stru_5C6E00->uIntegerHalfPi * pLevelDecorations[v7].field_1A) / 90; | |
4763 v9 = pLevelDecorations[v7].field_10_y_rot; | |
4764 pParty->sRotationY = v8; | |
4765 if ( v9 ) | |
4766 pParty->sRotationY = v9; | |
4767 pParty->sRotationX = 0; | |
4768 pParty->uFallSpeed = 0; | |
4769 } | |
4770 LABEL_20: | |
4771 if ( dword_5B65C0 ) | |
4772 { | |
4773 if ( _5B65A8_npcdata_uflags_or_other ) | |
4774 pParty->vPosition.x = _5B65A8_npcdata_uflags_or_other; | |
4775 if ( _5B65AC_npcdata_fame_or_other ) | |
4776 pParty->vPosition.y = _5B65AC_npcdata_fame_or_other; | |
4777 if ( _5B65B0_npcdata_rep_or_other ) | |
4778 { | |
4779 pParty->vPosition.z = _5B65B0_npcdata_rep_or_other; | |
4780 pParty->uFallStartY = _5B65B0_npcdata_rep_or_other; | |
4781 } | |
1516
f3cd08b89476
Fix assertion error when exiting Harmondale's castle. Possibly original bug.
yoctozepto
parents:
1515
diff
changeset
|
4782 if ( _5B65B4_npcdata_loword_house_or_other != -1 ) |
0 | 4783 pParty->sRotationY = _5B65B4_npcdata_loword_house_or_other; |
4784 if ( _5B65B8_npcdata_hiword_house_or_other ) | |
4785 pParty->sRotationX = _5B65B8_npcdata_hiword_house_or_other; | |
4786 if ( dword_5B65BC ) | |
4787 pParty->uFallSpeed = dword_5B65BC; | |
4788 } | |
4789 _5B65B4_npcdata_loword_house_or_other = -1; | |
4790 dword_5B65C0 = 0; | |
4791 dword_5B65BC = 0; | |
4792 _5B65B8_npcdata_hiword_house_or_other = 0; | |
4793 _5B65B0_npcdata_rep_or_other = 0; | |
4794 _5B65AC_npcdata_fame_or_other = 0; | |
4795 _5B65A8_npcdata_uflags_or_other = 0; | |
4796 } | |
4797 } | |
1035 | 4798 |
0 | 4799 //----- (00449A49) -------------------------------------------------------- |
2138 | 4800 void Door_switch_animation(unsigned int uDoorID, int a2) |
0 | 4801 { |
2138 | 4802 int old_state; // eax@1 |
4803 signed int door_id; // esi@2 | |
4804 | |
0 | 4805 if ( !pIndoor->pDoors ) |
2138 | 4806 return; |
4807 for ( door_id = 0; door_id < 200; ++door_id ) | |
0 | 4808 { |
2138 | 4809 if ( pIndoor->pDoors[door_id].uDoorID == uDoorID ) |
0 | 4810 break; |
4811 } | |
2138 | 4812 if ( door_id >= 200 ) |
0 | 4813 { |
1545 | 4814 Error("Unable to find Door ID: %i!", uDoorID); |
0 | 4815 } |
2138 | 4816 old_state = pIndoor->pDoors[door_id].uState; |
4817 if ( a2 == 2 ) | |
0 | 4818 { |
2138 | 4819 if ( pIndoor->pDoors[door_id].uState == BLVDoor::Closing || pIndoor->pDoors[door_id].uState == BLVDoor::Opening ) |
4820 return; | |
4821 if ( pIndoor->pDoors[door_id].uState ) | |
4822 { | |
4823 if ( pIndoor->pDoors[door_id].uState != BLVDoor::Closed && pIndoor->pDoors[door_id].uState != BLVDoor::Closing ) | |
4824 { | |
4825 pIndoor->pDoors[door_id].uState = BLVDoor::Closing; | |
4826 if ( old_state == BLVDoor::Open ) | |
4827 { | |
4828 pIndoor->pDoors[door_id].uTimeSinceTriggered = 0; | |
4829 return; | |
4830 } | |
4831 if ( pIndoor->pDoors[door_id].uTimeSinceTriggered != 15360 ) | |
4832 { | |
4833 pIndoor->pDoors[door_id].uTimeSinceTriggered = (pIndoor->pDoors[door_id].uMoveLength << 7) / pIndoor->pDoors[door_id].uOpenSpeed | |
4834 - ((signed int)(pIndoor->pDoors[door_id].uTimeSinceTriggered * pIndoor->pDoors[door_id].uCloseSpeed) | |
4835 / 128 << 7) / pIndoor->pDoors[door_id].uOpenSpeed; | |
4836 return; | |
4837 } | |
4838 pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360; | |
4839 } | |
4840 return; | |
4841 } | |
0 | 4842 } |
4843 else | |
4844 { | |
2138 | 4845 if ( a2 == 0 ) |
0 | 4846 { |
2138 | 4847 if ( pIndoor->pDoors[door_id].uState != BLVDoor::Closed && pIndoor->pDoors[door_id].uState != BLVDoor::Closing ) |
0 | 4848 { |
2138 | 4849 pIndoor->pDoors[door_id].uState = BLVDoor::Closing; |
4850 if ( old_state == BLVDoor::Open ) | |
0 | 4851 { |
2138 | 4852 pIndoor->pDoors[door_id].uTimeSinceTriggered = 0; |
4853 return; | |
0 | 4854 } |
2138 | 4855 if ( pIndoor->pDoors[door_id].uTimeSinceTriggered != 15360 ) |
0 | 4856 { |
2138 | 4857 pIndoor->pDoors[door_id].uTimeSinceTriggered = (pIndoor->pDoors[door_id].uMoveLength << 7) / pIndoor->pDoors[door_id].uOpenSpeed |
4858 - ((signed int)(pIndoor->pDoors[door_id].uTimeSinceTriggered * pIndoor->pDoors[door_id].uCloseSpeed) | |
4859 / 128 << 7) / pIndoor->pDoors[door_id].uOpenSpeed; | |
4860 return; | |
0 | 4861 } |
2138 | 4862 pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360; |
0 | 4863 } |
2138 | 4864 return; |
0 | 4865 } |
2138 | 4866 if ( a2 != 1 ) |
4867 return; | |
0 | 4868 } |
2138 | 4869 if ( old_state != BLVDoor::Open && old_state != BLVDoor::Opening ) |
0 | 4870 { |
2138 | 4871 pIndoor->pDoors[door_id].uState = BLVDoor::Opening; |
4872 if ( old_state == BLVDoor::Closed ) | |
4873 { | |
4874 pIndoor->pDoors[door_id].uTimeSinceTriggered = 0; | |
4875 return; | |
4876 } | |
4877 if ( pIndoor->pDoors[door_id].uTimeSinceTriggered != 15360 ) | |
0 | 4878 { |
2138 | 4879 pIndoor->pDoors[door_id].uTimeSinceTriggered = (pIndoor->pDoors[door_id].uMoveLength << 7) / pIndoor->pDoors[door_id].uCloseSpeed |
4880 - ((signed int)(pIndoor->pDoors[door_id].uTimeSinceTriggered * pIndoor->pDoors[door_id].uOpenSpeed) | |
4881 / 128 << 7) / pIndoor->pDoors[door_id].uCloseSpeed; | |
4882 return; | |
0 | 4883 } |
2138 | 4884 pIndoor->pDoors[door_id].uTimeSinceTriggered = 15360; |
0 | 4885 } |
2138 | 4886 return; |
0 | 4887 } |
4888 | |
4889 //----- (00449B57) -------------------------------------------------------- | |
521 | 4890 bool _449B57_test_bit( unsigned __int8 *a1, __int16 a2 ) |
1035 | 4891 { |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1112
diff
changeset
|
4892 return (a1[(a2 - 1) >> 3] & (0x80u >> (a2 - 1) % 8)) != 0; |
0 | 4893 } |
4894 | |
4895 //----- (00449B7E) -------------------------------------------------------- | |
501 | 4896 void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle) |
0 | 4897 { |
4898 signed int v3; // esi@1 | |
501 | 4899 unsigned char set_bit; // edx@1 |
0 | 4900 |
4901 v3 = a2 - 1; | |
501 | 4902 set_bit = 0x80 >> v3 % 8; |
0 | 4903 if ( bToggle ) |
501 | 4904 pArray[v3 / 8] |= set_bit; |
4905 else | |
4906 pArray[v3 / 8] &= ~set_bit; | |
0 | 4907 } |
4908 | |
4909 //----- (0044C175) -------------------------------------------------------- | |
1160 | 4910 void ShowStatusBarString( const char *pString, unsigned int uNumSeconds ) |
1546 | 4911 { |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
4912 strcpy(GameUI_Footer_TimedString.data(), pString); |
1546 | 4913 GameUI_Footer_TimeLeft = 1000 * uNumSeconds + GetTickCount(); |
4914 | |
2138 | 4915 for (int i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); i > 450; |
4916 i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()) ) | |
1470 | 4917 GameUI_Footer_TimedString[strlen(GameUI_Footer_TimedString.data()) - 1] = 0; |
0 | 4918 } |
4919 | |
4920 //----- (0044C1D0) -------------------------------------------------------- | |
1035 | 4921 void ShowNothingHereStatus() |
0 | 4922 { |
783 | 4923 if ( !GameUI_Footer_TimeLeft ) |
1546 | 4924 ShowStatusBarString(pGlobalTXT_LocalizationStrings[521], 2);// Nothing here |
0 | 4925 } |
4926 | |
4927 //----- (0044C28B) -------------------------------------------------------- | |
1459 | 4928 int const_2() |
0 | 4929 { |
4930 return 2; | |
4931 } | |
4932 | |
4933 //----- (0044C28F) -------------------------------------------------------- | |
1459 | 4934 bool TeleportToNWCDungeon() |
0 | 4935 { |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1470
diff
changeset
|
4936 if (!_stricmp("nwc.blv", pCurrentMapName)) |
1459 | 4937 return false; |
4938 | |
4939 _5B65A8_npcdata_uflags_or_other = 0; | |
4940 _5B65AC_npcdata_fame_or_other = 0; | |
4941 _5B65B0_npcdata_rep_or_other = 0; | |
4942 _5B65B4_npcdata_loword_house_or_other = 0; | |
4943 _5B65B8_npcdata_hiword_house_or_other = 0; | |
4944 dword_5B65BC = 0; | |
4945 dword_5B65C0 = 0; | |
4946 | |
4947 pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; | |
4948 sub_44987B("nwc.blv", MapStartPoint_Party); | |
4949 pCurrentScreen = SCREEN_GAME; | |
4950 return true; | |
0 | 4951 } |
4952 | |
4953 //----- (00401000) -------------------------------------------------------- | |
1458 | 4954 void mm7__vector_constructor(void *a1, int objSize, int numObjs, int ( *constructor)(int)) |
0 | 4955 { |
4956 void *v4; // esi@2 | |
2138 | 4957 |
4958 if ( numObjs > 0 ) | |
0 | 4959 { |
4960 v4 = a1; | |
2138 | 4961 for ( int i = numObjs; i; --i ) |
0 | 4962 { |
4963 constructor((int)v4); | |
4964 v4 = (char *)v4 + objSize; | |
4965 } | |
4966 } | |
4967 } | |
4968 | |
4969 //----- (0040261D) -------------------------------------------------------- | |
1546 | 4970 void stru298::Add(__int16 uID, __int16 a3, __int16 x, __int16 y, __int16 z, char a7, char a8) |
0 | 4971 { |
1546 | 4972 if (count < 100) |
4973 { | |
4974 pIDs[count] = uID; | |
4975 pXs[count] = x; | |
4976 pYs[count] = y; | |
4977 pZs[count] = z; | |
4978 field_324[count] = a3; | |
4979 field_3EC[count] = a8; | |
4980 field_450[count++] = a7; | |
4981 } | |
0 | 4982 } |
4983 | |
4984 //----- (00402CAE) -------------------------------------------------------- | |
323 | 4985 int stru193_math::Cos(int angle) |
0 | 4986 { |
4987 int v2; // eax@1 | |
4988 | |
4989 //a2: (angle - uIntegerHalfPi) for sin(angle) | |
4990 // (angle) for cos(angle) | |
4991 | |
4992 v2 = uDoublePiMask & angle; | |
4993 | |
4994 if ( v2 > uIntegerPi ) | |
4995 v2 = uIntegerDoublePi - v2; | |
4996 if ( v2 >= uIntegerHalfPi ) | |
4997 return -pCosTable[uIntegerPi - v2]; | |
4998 else | |
4999 return pCosTable[v2]; | |
5000 } | |
5001 |