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