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