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