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