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