Mercurial > mm7
annotate Indoor.cpp @ 1414:110eac219e5a
ChestUI_WritePointedObjectStatusString
author | Nomad |
---|---|
date | Sat, 27 Jul 2013 16:32:20 +0200 |
parents | 38df78aba732 |
children | b67a3e0d6fc3 |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1132
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1132
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1132
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1132
diff
changeset
|
4 |
0 | 5 #include <assert.h> |
6 | |
1016 | 7 #include "LightmapBuilder.h" |
8 #include "DecalBuilder.h" | |
9 #include "stru9.h" | |
10 #include "stru10.h" | |
1078 | 11 #include "stru367.h" |
1016 | 12 |
13 #include "BSPModel.h" | |
0 | 14 #include "Outdoor.h" |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
15 #include "SpriteObject.h" |
0 | 16 #include "Events.h" |
17 #include "Game.h" | |
18 #include "Viewport.h" | |
19 #include "Time.h" | |
20 #include "Party.h" | |
21 #include "Math.h" | |
22 #include "Allocator.h" | |
23 #include "LOD.h" | |
24 #include "DecorationList.h" | |
25 #include "ObjectList.h" | |
26 #include "Actor.h" | |
27 #include "Chest.h" | |
28 #include "GUIProgressBar.h" | |
29 #include "stru123.h" | |
30 #include "AudioPlayer.h" | |
31 #include "Log.h" | |
32 #include "TurnEngine.h" | |
33 #include "PaletteManager.h" | |
34 #include "MapInfo.h" | |
186 | 35 #include "IndoorCamera.h" |
1262 | 36 #include "Lights.h" |
0 | 37 |
38 #include "mm7_data.h" | |
831 | 39 #include "MM7.h" |
1295 | 40 #include "Sprites.h" |
41 #include "Game.h" | |
42 #include "stru6.h" | |
43 #include "ParticleEngine.h" | |
44 #include "Outdoor_stuff.h" | |
1297 | 45 #include "texts.h" |
46 #include "GUIWindow.h" | |
0 | 47 |
48 | |
49 | |
50 | |
51 | |
52 IndoorLocation *pIndoor = new IndoorLocation; | |
53 BLVRenderParams *pBLVRenderParams = new BLVRenderParams; | |
54 | |
55 struct DecorationList *pDecorationList; | |
56 | |
1202 | 57 std::array<LevelDecoration, 3000> pLevelDecorations; |
0 | 58 size_t uNumLevelDecorations; |
520
35f28d4c0ff9
GlobalEventInfo changed to LevelDecoration* activeLevelDecoration
Gloval
parents:
515
diff
changeset
|
59 LevelDecoration* activeLevelDecoration; |
0 | 60 |
61 LEVEL_TYPE uCurrentlyLoadedLevelType = LEVEL_null; | |
62 | |
63 stru320 stru_F8AD28; // idb | |
64 stru337 stru_F81018; | |
1376 | 65 BspRenderer_PortalViewportData stru_F8A590; |
0 | 66 BspRenderer *pBspRenderer = new BspRenderer; // idb |
67 stru141 stru_721530; | |
1202 | 68 std::array<stru352, 480> stru_F83B80; |
0 | 69 |
70 | |
71 | |
72 unsigned __int16 pDoorSoundIDsByLocationID[78] = | |
73 { | |
74 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, | |
75 300, 300, 300, 404, 302, 306, 308, 304, 308, 302, 400, 302, 300, | |
76 308, 308, 306, 308, 308, 304, 300, 404, 406, 300, 400, 406, 404, | |
77 306, 302, 408, 304, 300, 300, 300, 300, 300, 300, 300, 300, 300, | |
78 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 404, 304, | |
79 400, 300, 300, 404, 304, 400, 300, 300, 404, 304, 400, 300, 300 | |
80 }; | |
81 | |
82 | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
83 std::array<const char *, 11> _4E6BDC_loc_names= |
1006 | 84 { |
85 "mdt12.blv", | |
86 "d18.blv", | |
87 "mdt14.blv", | |
88 "d37.blv", | |
89 "mdk01.blv", | |
90 "mdt01.blv", | |
91 "mdr01.blv", | |
92 "mdt10.blv", | |
93 "mdt09.blv", | |
94 "mdt15.blv", | |
95 "mdt11.blv" | |
96 }; | |
97 | |
0 | 98 |
99 //----- (0043F39E) -------------------------------------------------------- | |
100 void __fastcall PrepareDrawLists_BLV(IndoorLocation_drawstru *_this) | |
101 { | |
102 //int *v1; // ecx@1 | |
103 //double v2; // ST30_8@3 | |
104 //double v3; // ST30_8@6 | |
105 //double v4; // ST28_8@6 | |
106 int v5; // eax@4 | |
707 | 107 //int v6; // eax@7 |
0 | 108 unsigned int v7; // ebx@8 |
109 BLVSector *v8; // esi@8 | |
707 | 110 //unsigned __int16 *v9; // edi@8 |
111 //int i; // [sp+18h] [bp-8h]@7 | |
0 | 112 //unsigned __int8 v11; // [sp+1Ch] [bp-4h]@3 |
707 | 113 //signed int v12; // [sp+1Ch] [bp-4h]@8 |
0 | 114 |
115 pBLVRenderParams->Reset(_this); | |
116 pMobileLightsStack->uNumLightsActive = 0; | |
117 //uNumMobileLightsApplied = 0; | |
118 uNumDecorationsDrawnThisFrame = 0; | |
119 _unused000 = 0; | |
120 uNumSpritesDrawnThisFrame = 0; | |
121 uNumBillboardsToDraw = 0; | |
707 | 122 |
123 if ( !byte_4D864C || !(pGame->uFlags & 0x1000) ) // lightspot around party | |
0 | 124 { |
125 //v2 = pParty->flt_TorchlightColorB + 6.7553994e15; | |
126 //v11 = LOBYTE(v2); | |
127 v5 = 800; | |
128 if (pParty->TorchlightActive()) | |
707 | 129 v5 *= pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower; |
0 | 130 //LOBYTE(v1) = byte_4E94D0; |
131 //v4 = pParty->flt_TorchlightColorR + 6.7553994e15; | |
132 //v3 = pParty->flt_TorchlightColorG + 6.7553994e15; | |
707 | 133 pMobileLightsStack->AddLight(pBLVRenderParams->vPartyPos.x, |
134 pBLVRenderParams->vPartyPos.y, | |
135 pBLVRenderParams->vPartyPos.z, | |
136 pBLVRenderParams->uPartySectorID, | |
137 v5, | |
138 floorf(pParty->flt_TorchlightColorR + 0.5f), | |
139 floorf(pParty->flt_TorchlightColorG + 0.5f), | |
140 floorf(pParty->flt_TorchlightColorB + 0.5f), | |
141 byte_4E94D0); | |
0 | 142 } |
143 PrepareBspRenderList_BLV(); | |
144 PrepareItemsRenderList_BLV(); | |
145 PrepareActorRenderList_BLV(); | |
707 | 146 |
147 //v6 = 0; | |
148 for (uint i = 0; i < pBspRenderer->uNumVisibleNotEmptySectors; ++i) | |
0 | 149 { |
707 | 150 v7 = pBspRenderer->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[i]; |
151 //v12 = 0; | |
152 v8 = &pIndoor->pSectors[pBspRenderer->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[i]]; | |
153 //v9 = v8->pDecorationIDs; | |
154 | |
155 for (uint j = 0; j < v8->uNumDecorations; ++j) | |
156 //if ( v8->uNumDecorations > 0 ) | |
0 | 157 { |
707 | 158 // do |
159 PrepareDecorationsRenderList_BLV(v8->pDecorationIDs[j], v7); | |
160 // while ( v12 < v8->uNumDecorations ); | |
0 | 161 } |
707 | 162 //v6 = i + 1; |
0 | 163 } |
657 | 164 FindBillboardsLightLevels_BLV(); |
0 | 165 pGame->PrepareBloodsplats(); |
166 } | |
167 | |
168 | |
169 | |
170 //----- (004407D9) -------------------------------------------------------- | |
171 int BLVRenderParams::Reset(IndoorLocation_drawstru *a2) | |
172 { | |
173 IndoorLocation_drawstru *v2; // ebx@1 | |
174 int v4; // ST08_4@1 | |
175 int v5; // ST04_4@1 | |
176 int v6; // ST00_4@1 | |
177 int v7; // eax@1 | |
178 int v8; // ST08_4@2 | |
179 int v9; // ST04_4@2 | |
180 int v10; // ST00_4@2 | |
181 unsigned int v11; // edi@4 | |
182 unsigned int v12; // ecx@4 | |
183 int v13; // edx@4 | |
184 signed int v14; // ecx@4 | |
185 unsigned int v15; // edx@4 | |
186 unsigned int v16; // eax@4 | |
187 double v17; // st7@5 | |
188 int v18; // eax@5 | |
189 double v19; // st7@5 | |
190 int v20; // eax@5 | |
191 double v21; // st7@5 | |
192 int v22; // eax@5 | |
193 unsigned int v23; // edx@5 | |
194 unsigned int v24; // ecx@5 | |
195 int v25; // eax@5 | |
196 int v26; // eax@5 | |
197 signed int v27; // eax@6 | |
198 int result; // eax@6 | |
199 int v29; // [sp+24h] [bp+8h]@5 | |
200 | |
201 v2 = a2; | |
202 this->field_0_timer_ = a2->field_0_timer; | |
203 this->uFlags = a2->uFlags; | |
204 this->vPartyPos.x = a2->vPosition.x; | |
205 this->vPartyPos.y = a2->vPosition.y; | |
206 this->vPartyPos.z = a2->vPosition.z; | |
207 v4 = this->vPartyPos.z; | |
208 v5 = this->vPartyPos.y; | |
209 this->sPartyRotY = a2->sRotationY; | |
210 v6 = this->vPartyPos.x; | |
211 this->sPartyRotX = a2->sRotationX; | |
212 v7 = pIndoor->GetSector(v6, v5, v4); | |
1006 | 213 this->uPartySectorID = v7; |
0 | 214 if ( !v7 ) |
215 { | |
1006 | 216 v8 = this->vPartyPos.z; |
217 this->vPartyPos.x = pParty->vPosition.x; | |
0 | 218 v9 = pParty->vPosition.y; |
1006 | 219 v10 = this->vPartyPos.x; |
220 this->vPartyPos.y = pParty->vPosition.y; | |
221 this->uPartySectorID = pIndoor->GetSector(v10, v9, v8); | |
0 | 222 } |
223 if ( pRenderer->pRenderD3D ) | |
224 { | |
1006 | 225 this->sCosineY = stru_5C6E00->Cos(this->sPartyRotY); |
226 this->sSineY = stru_5C6E00->Sin(this->sPartyRotY); | |
227 this->sCosineNegX = stru_5C6E00->Cos(-this->sPartyRotX); | |
228 this->sSineNegX = stru_5C6E00->Sin(-this->sPartyRotX); | |
229 this->fCosineY = cos((3.141592653589793 + 3.141592653589793) * (double)this->sPartyRotY * 0.00048828125); | |
230 this->fSineY = sin((3.141592653589793 + 3.141592653589793) * (double)this->sPartyRotY * 0.00048828125); | |
231 this->fCosineNegX = cos((3.141592653589793 + 3.141592653589793) * (double)-this->sPartyRotX * 0.00048828125); | |
232 this->fSineNegX = sin((3.141592653589793 + 3.141592653589793) * (double)-this->sPartyRotX * 0.00048828125); | |
233 this->field_64 = a2->field_3C; | |
234 v11 = this->uViewportW; | |
235 v12 = this->uViewportX; | |
236 v13 = this->uViewportZ - v12; | |
237 v14 = this->uViewportZ + v12; | |
238 this->field_70 = v13 + 1; | |
239 v15 = this->uViewportY; | |
240 this->uViewportHeight = v11 - v15 + 1; | |
241 v16 = this->uViewportW; | |
242 this->uViewportCenterX = v14 >> 1; | |
243 this->uViewportCenterY = (signed int)(v16 + v15) >> 1; | |
0 | 244 } |
245 else | |
246 { | |
1006 | 247 this->sCosineY = stru_5C6E00->Cos(-this->sPartyRotY); |
248 this->sSineY = stru_5C6E00->Sin(-this->sPartyRotY); | |
249 this->sCosineNegX = stru_5C6E00->Cos(-this->sPartyRotX); | |
250 this->sSineNegX = stru_5C6E00->Sin(-this->sPartyRotX); | |
251 v17 = cos((double)-this->sPartyRotY * 0.0030664064); | |
252 v18 = this->sPartyRotY; | |
253 this->fCosineY = v17; | |
0 | 254 v19 = sin((double)-v18 * 0.0030664064); |
1006 | 255 v20 = this->sPartyRotX; |
256 this->fSineY = v19; | |
0 | 257 v21 = cos((double)-v20 * 0.0030664064); |
1006 | 258 v22 = this->sPartyRotX; |
259 this->fCosineNegX = v21; | |
260 this->fSineNegX = sin((double)-v22 * 0.0030664064); | |
261 v23 = this->uViewportX; | |
262 this->field_64 = a2->field_3C; | |
263 v24 = this->uViewportZ; | |
264 this->field_70 = this->uViewportZ - v23 + 1; | |
265 v25 = this->uViewportW - this->uViewportY + 1; | |
266 this->uViewportHeight = v25; | |
0 | 267 v29 = v25; |
1006 | 268 v26 = this->field_64; |
269 this->uViewportCenterX = (signed int)(v24 + v23) >> 1; | |
270 this->uViewportCenterY = this->uViewportW - ((unsigned __int64)(v26 * (signed __int64)v29) >> 16); | |
0 | 271 } |
1006 | 272 v27 = (unsigned int)(signed __int64)((double)this->field_70 * 0.5 / tan((double)(v2->field_1C_mb_fov >> 1) * 0.01745329) |
0 | 273 + 0.5) << 16; |
1006 | 274 this->field_40 = v27; |
275 this->field_44 = 0x100000000i64 / v27; | |
276 this->pRenderTarget = v2->pRenderTarget; | |
277 this->uTargetWidth = v2->uTargetWidth; | |
278 this->uTargetHeight = v2->uTargetHeight; | |
279 this->uViewportX = v2->uViewportX; | |
280 this->uViewportY = v2->uViewportY; | |
281 this->uViewportZ = v2->uViewportZ; | |
282 this->uViewportW = v2->uViewportW; | |
283 this->pTargetZBuffer = v2->pTargetZ; | |
0 | 284 result = 0; |
1006 | 285 this->field_8C = 0; |
286 this->field_84 = 0; | |
287 this->uNumFacesRenderedThisFrame = 0; | |
288 this->field_88 = 0; | |
0 | 289 pBLVRenderParams->field_90 = 64; |
290 pBLVRenderParams->field_94 = 6; | |
291 return result; | |
292 } | |
293 | |
294 //----- (00440B44) -------------------------------------------------------- | |
295 void IndoorLocation::ExecDraw(bool bD3D) | |
296 { | |
297 int v2; // eax@3 | |
795 | 298 //IndoorCameraD3D_Vec4 *v3; // edx@4 |
299 //unsigned int v5; // ecx@9 | |
300 //RenderVertexSoft *v6; // [sp-4h] [bp-8h]@4 | |
0 | 301 |
302 if (bD3D) | |
303 { | |
304 pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
305 for (uint i = 0; i < pBspRenderer->num_faces; ++i) |
0 | 306 { |
1187 | 307 //v2 = pBspRenderer->faces[i].uNodeID; |
308 if (pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].viewing_portal_id == -1) | |
795 | 309 IndoorLocation::ExecDraw_d3d(pBspRenderer->faces[i].uFaceID, nullptr, 4, nullptr); |
1187 | 310 else |
311 IndoorLocation::ExecDraw_d3d(pBspRenderer->faces[i].uFaceID, pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].std__vector_0007AC, 4, pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].pPortalBounding); | |
0 | 312 } |
313 } | |
795 | 314 else for (uint j = 0; j < pBspRenderer->num_faces; ++j ) |
0 | 315 { |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
316 __debugbreak(); // no SW |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
317 //pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[j].uNodeID].PortalScreenData; |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1390
diff
changeset
|
318 //IndoorLocation::ExecDraw_sw(pBspRenderer->faces[j].uFaceID); |
0 | 319 } |
320 } | |
321 | |
322 //----- (00440BED) -------------------------------------------------------- | |
323 void __fastcall sub_440BED(IndoorLocation_drawstru *_this) | |
324 { | |
325 unsigned __int16 *v1; // edi@7 | |
1074 | 326 BspRenderer_stru0 *v2; // esi@8 |
0 | 327 int v3; // ecx@9 |
328 unsigned int v4; // edx@9 | |
1074 | 329 short *v5; // eax@10 |
0 | 330 signed int v6; // [sp+8h] [bp-8h]@7 |
331 int v7; // [sp+Ch] [bp-4h]@8 | |
1074 | 332 short *v8; |
0 | 333 |
334 PrepareDrawLists_BLV(_this); | |
335 if (pBLVRenderParams->uPartySectorID) | |
336 IndoorLocation::ExecDraw(pRenderer->pRenderD3D != 0); | |
337 pRenderer->DrawBillboardList_BLV(); | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
338 |
0 | 339 if ( !pRenderer->pRenderD3D ) |
340 { | |
486 | 341 if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_D3D_OUTLINES) |
342 pBspRenderer->DrawFaceOutlines(); | |
343 if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) | |
0 | 344 { |
345 v1 = pBLVRenderParams->pRenderTarget; | |
1074 | 346 v7 = 0; |
347 for(int i=0; i < pBspRenderer->num_nodes; i++) | |
348 { | |
349 BspRenderer_stru0 *pNode = &pBspRenderer->nodes[i]; | |
1376 | 350 v4 = pRenderer->uTargetSurfacePitch * pNode->PortalScreenData._viewport_space_y; |
351 if ( pNode->PortalScreenData._viewport_space_y <= pNode->PortalScreenData._viewport_space_w ) | |
1074 | 352 { |
353 //v5 = (char *)&pBspRenderer->nodes[0].field_C.array_3D8[pNode->field_C._viewport_space_y + v7]; | |
1376 | 354 v5 = &pNode->PortalScreenData.viewport_right_side[pNode->PortalScreenData._viewport_space_y]; |
355 v8 = &pNode->PortalScreenData.viewport_left_side[pNode->PortalScreenData._viewport_space_y]; | |
1074 | 356 do |
357 { | |
358 v1[v4 + *v8] = 255; | |
1376 | 359 ++pNode->PortalScreenData._viewport_space_y; |
1074 | 360 v1[v4 + *v5] = 255; |
361 v4 += pRenderer->uTargetSurfacePitch; | |
362 ++v5; | |
363 ++v8; | |
364 } | |
1376 | 365 while ( pNode->PortalScreenData._viewport_space_y <= pNode->PortalScreenData._viewport_space_w ); |
1074 | 366 } |
367 } | |
0 | 368 } |
369 } | |
370 } | |
371 | |
372 | |
373 | |
374 | |
375 | |
376 //----- (00441BD4) -------------------------------------------------------- | |
377 void IndoorLocation::Draw() | |
378 { | |
186 | 379 //int v0; // eax@1 |
0 | 380 IndoorLocation_drawstru _this; // [sp+0h] [bp-4Ch]@5 |
381 int v2; // [sp+44h] [bp-8h]@5 | |
382 int v3; // [sp+48h] [bp-4h]@5 | |
383 | |
186 | 384 _this.uFlags = 0; |
385 if (viewparams->draw_sw_outlines) | |
386 _this.uFlags |= INDOOR_CAMERA_DRAW_SW_OUTLINES; | |
387 if (viewparams->draw_d3d_outlines) | |
388 _this.uFlags |= INDOOR_CAMERA_DRAW_D3D_OUTLINES; | |
389 | |
791 | 390 _this.uFlags |= INDOOR_CAMERA_DRAW_D3D_OUTLINES; |
391 _this.uFlags |= INDOOR_CAMERA_DRAW_SW_OUTLINES; | |
392 //INDOOR_CAMERA_DRAW_TERRAIN_OUTLINES | |
393 | |
0 | 394 _this.field_0_timer = pEventTimer->uTotalGameTimeElapsed; |
395 _this.field_1C_mb_fov = 65; | |
871 | 396 _this.vPosition.x = pParty->vPosition.x - fixpoint_sub0(stru_5C6E00->Cos(pParty->sRotationY), pParty->y_rotation_granularity); |
397 _this.vPosition.y = pParty->vPosition.y - fixpoint_sub0(stru_5C6E00->Sin(pParty->sRotationY), pParty->y_rotation_granularity); | |
581 | 398 _this.vPosition.z = pParty->vPosition.z + pParty->sEyelevel; |
399 _this.sRotationX = pParty->sRotationX; | |
0 | 400 _this.sRotationY = pParty->sRotationY; |
401 _this.pRenderTarget = pRenderer->pTargetSurface; | |
692 | 402 _this.uViewportX = pViewport->uScreen_TL_X; |
403 _this.uViewportY = pViewport->uScreen_TL_Y; | |
404 _this.uViewportZ = pViewport->uScreen_BR_X; | |
405 _this.uViewportW = pViewport->uScreen_BR_Y; | |
0 | 406 _this.field_3C = pViewport->field_30; |
581 | 407 |
0 | 408 _this.uTargetWidth = 640; |
409 _this.uTargetHeight = 480; | |
410 _this.pTargetZ = pRenderer->pActiveZBuffer; | |
411 sub_440BED(&_this); | |
569 | 412 pParty->uFlags &= ~2; |
0 | 413 pGame->DrawParticles(); |
1410
38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
Nomad
parents:
1408
diff
changeset
|
414 trail_particle_generator.UpdateParticles(); |
0 | 415 } |
416 | |
417 //----- (004C0EF2) -------------------------------------------------------- | |
1025 | 418 void BLVFace::FromODM(ODMFace *face) |
0 | 419 { |
1025 | 420 this->pFacePlane_old.vNormal.x = face->pFacePlane.vNormal.x; |
421 this->pFacePlane_old.vNormal.y = face->pFacePlane.vNormal.y; | |
422 this->pFacePlane_old.vNormal.z = face->pFacePlane.vNormal.z; | |
423 this->pFacePlane_old.dist = face->pFacePlane.dist; | |
424 this->pFacePlane.vNormal.x = (double)(face->pFacePlane.vNormal.x & 0xFFFF) * 0.000015259022 | |
425 + (double)(face->pFacePlane.vNormal.x >> 16); | |
426 this->pFacePlane.vNormal.y = (double)(face->pFacePlane.vNormal.y & 0xFFFF) * 0.000015259022 | |
427 + (double)(face->pFacePlane.vNormal.y >> 16); | |
428 this->pFacePlane.vNormal.z = (double)(face->pFacePlane.vNormal.z & 0xFFFF) * 0.000015259022 | |
429 + (double)(face->pFacePlane.vNormal.z >> 16); | |
430 this->pFacePlane.dist = (double)(face->pFacePlane.dist & 0xFFFF) * 0.000015259022 + (double)(face->pFacePlane.dist >> 16); | |
431 this->uAttributes = face->uAttributes; | |
432 this->pBounding.x1 = face->pBoundingBox.x1; | |
433 this->pBounding.y1 = face->pBoundingBox.y1; | |
434 this->pBounding.z1 = face->pBoundingBox.z1; | |
435 this->pBounding.x2 = face->pBoundingBox.x2; | |
436 this->pBounding.y2 = face->pBoundingBox.y2; | |
437 this->pBounding.z2 = face->pBoundingBox.z2; | |
438 this->zCalc1 = face->zCalc1; | |
439 this->zCalc2 = face->zCalc2; | |
440 this->zCalc3 = face->zCalc3; | |
441 this->pXInterceptDisplacements = face->pXInterceptDisplacements; | |
442 this->pYInterceptDisplacements = face->pYInterceptDisplacements; | |
443 this->pZInterceptDisplacements = face->pZInterceptDisplacements; | |
444 this->uPolygonType = (PolygonType)face->uPolygonType; | |
445 this->uNumVertices = face->uNumVertices; | |
446 this->uBitmapID = face->uTextureID; | |
447 this->pVertexIDs = face->pVertexIDs; | |
0 | 448 } |
449 | |
450 //----- (004B0A25) -------------------------------------------------------- | |
794 | 451 void IndoorLocation::ExecDraw_d3d(unsigned int uFaceID, IndoorCameraD3D_Vec4 *pVertices, unsigned int uNumVertices, RenderVertexSoft *pPortalBounding) |
0 | 452 { |
453 //unsigned int v4; // esi@1 | |
454 char *v5; // eax@4 | |
455 signed int v6; // ecx@4 | |
456 char *v7; // eax@8 | |
457 signed int v8; // ecx@8 | |
458 //BLVFace *v9; // esi@13 | |
459 //IndoorCameraD3D *v10; // edi@16 | |
460 //int v11; // ebx@17 | |
461 //Vec3_short_ *v12; // ecx@18 | |
462 //char *v13; // edx@18 | |
463 //int v14; // eax@19 | |
464 //unsigned __int8 v15; // sf@19 | |
465 //unsigned __int8 v16; // of@19 | |
466 int v17; // ebx@25 | |
467 //double v18; // st7@27 | |
468 //double v19; // st6@27 | |
469 //double v20; // st5@27 | |
470 //char v21; // dl@27 | |
471 //unsigned int v22; // eax@44 | |
472 unsigned int v23; // eax@35 | |
473 //DWORD v24; // eax@37 | |
474 //int v25; // eax@38 | |
475 //char *v26; // edi@38 | |
476 IDirect3DTexture2 *v27; // eax@42 | |
477 Texture *v28; // [sp+Ch] [bp-1Ch]@15 | |
478 //int i; // [sp+10h] [bp-18h]@38 | |
479 //LightmapBuilder *pStru4; // [sp+14h] [bp-14h]@16 | |
480 //IndoorCameraD3D *v31; // [sp+18h] [bp-10h]@16 | |
481 //IndoorCameraD3D_Vec4 *a7; // [sp+1Ch] [bp-Ch]@1 | |
482 //unsigned int uFaceID_; // [sp+20h] [bp-8h]@1 | |
483 unsigned int uNumVerticesa; // [sp+24h] [bp-4h]@17 | |
484 int a4a; // [sp+34h] [bp+Ch]@25 | |
485 //unsigned int a4b; // [sp+34h] [bp+Ch]@38 | |
486 | |
487 //v4 = uFaceID; | |
488 //a7 = pVertices; | |
489 //uFaceID_ = uFaceID; | |
490 if (uFaceID >= pIndoor->uNumFaces) | |
491 return; | |
492 | |
493 static RenderVertexSoft static_vertices_F7C228[64]; | |
494 static RenderVertexSoft static_vertices_F7B628[64]; | |
495 static stru154 stru_F7B60C; // idb | |
496 | |
497 //v9 = &pIndoor->pFaces[uFaceID]; | |
498 auto pFace = &pIndoor->pFaces[uFaceID]; | |
499 if (pFace->uNumVertices < 3) | |
500 return; | |
501 | |
502 | |
503 if (pFace->Invisible()) | |
504 return; | |
505 | |
506 ++pBLVRenderParams->uNumFacesRenderedThisFrame; | |
507 pFace->uAttributes |= 0x80u; | |
508 | |
509 if (!pFace->GetTexture()) | |
510 return; | |
511 | |
512 v28 = pFace->GetTexture(); | |
513 | |
514 if (!pGame->pIndoorCameraD3D->IsCulled(pFace)) | |
515 { | |
516 uNumVerticesa = pFace->uNumVertices; | |
517 for (uint i = 0; i < pFace->uNumVertices; ++i) | |
518 { | |
519 static_vertices_F7C228[i].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[i]].x; | |
520 static_vertices_F7C228[i].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[i]].y; | |
521 static_vertices_F7C228[i].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[i]].z; | |
522 static_vertices_F7C228[i].u = (signed short)pFace->pVertexUIDs[i]; | |
523 static_vertices_F7C228[i].v = (signed short)pFace->pVertexVIDs[i]; | |
524 } | |
525 | |
526 if (!pVertices || | |
1187 | 527 (pGame->pStru9Instance->_498377(pPortalBounding, 4, pVertices, static_vertices_F7C228, &uNumVerticesa), uNumVerticesa) ) |
0 | 528 { |
795 | 529 if (pGame->pIndoorCameraD3D->CalcPortalShape(static_vertices_F7C228, &uNumVerticesa, |
581 | 530 static_vertices_F7B628, pGame->pIndoorCameraD3D->std__vector_000034_prolly_frustrum, 4, false, 0) != 1 || uNumVerticesa ) |
0 | 531 { |
532 a4a = SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel); | |
1006 | 533 v17 = (248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) | (((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) |
534 | ((248 - 8 * SHIWORD(stru_F8AD28.uCurrentAmbientLightLevel)) << 8)) << 8); | |
0 | 535 sub_4B0E07(uFaceID); |
536 pGame->pLightmapBuilder->ApplyLights_IndoorFace(uFaceID); | |
537 pDecalBuilder->ApplyBloodsplatDecals_IndoorFace(uFaceID); | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
538 pGame->pIndoorCameraD3D->ViewTransfrom_OffsetUV(static_vertices_F7B628, uNumVerticesa, array_507D30, &stru_F8AD28); |
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
539 pGame->pIndoorCameraD3D->Project(array_507D30, uNumVerticesa, 0); |
0 | 540 pGame->pLightmapBuilder->std__vector_000004_size = 0; |
541 if (stru_F8AD28.uNumLightsApplied > 0 || | |
542 pDecalBuilder->uNumDecals > 0) | |
543 { | |
544 stru_F7B60C.face_plane.vNormal.x = pFace->pFacePlane.vNormal.x; | |
545 stru_F7B60C.polygonType = pFace->uPolygonType; | |
546 stru_F7B60C.face_plane.vNormal.y = pFace->pFacePlane.vNormal.y; | |
547 stru_F7B60C.face_plane.vNormal.z = pFace->pFacePlane.vNormal.z; | |
548 stru_F7B60C.face_plane.dist = pFace->pFacePlane.dist; | |
549 } | |
550 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
551 if (stru_F8AD28.uNumLightsApplied > 0 && !(pFace->uAttributes & FACE_DO_NOT_LIGHT)) |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
552 pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &stru_F7B60C, uNumVerticesa, array_507D30, pVertices, 0); |
0 | 553 |
554 if (pDecalBuilder->uNumDecals > 0) | |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
555 pDecalBuilder->ApplyDecals(a4a, 1, &stru_F7B60C, uNumVerticesa, array_507D30, pVertices, 0, pFace->uSectorID); |
0 | 556 |
791 | 557 if (pFace->Fluid()) |
0 | 558 { |
831 | 559 if (pFace->uBitmapID == pRenderer->hd_water_tile_id) |
560 { | |
561 v23 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; | |
562 v27 = pBitmaps_LOD->pHardwareTextures[v23]; | |
563 } | |
805 | 564 else |
831 | 565 { |
566 //auto v24 = GetTickCount() / 4; | |
567 //auto v25 = v24 - stru_5C6E00->uIntegerHalfPi; | |
568 uint eightSeconds = GetTickCount() % 8000; | |
569 float angle = (eightSeconds / 8000.0f) * 2 * 3.1415f; | |
570 | |
571 //animte lava back and forth | |
572 for (uint i = 0; i < uNumVerticesa; ++i) | |
573 //array_507D30[i].v += (double)(pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 & (unsigned int)(stru_5C6E00->SinCos(v25) >> 8)); | |
574 array_507D30[i].v += pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 * cosf(angle); | |
575 v23 = pFace->uBitmapID; | |
576 v27 = pBitmaps_LOD->pHardwareTextures[v23]; | |
577 } | |
0 | 578 } |
595 | 579 else if (pFace->uAttributes & 0x4000) |
0 | 580 { |
581 | 581 v23 = pTextureFrameTable->GetFrameTexture(pFace->uBitmapID, pBLVRenderParams->field_0_timer_); |
582 v27 = pBitmaps_LOD->pHardwareTextures[v23]; | |
0 | 583 } |
831 | 584 else |
585 { | |
1394 | 586 v17 = 0xFF808080; |
831 | 587 v23 = pFace->uBitmapID; |
588 v27 = pBitmaps_LOD->pHardwareTextures[v23]; | |
589 } | |
590 | |
805 | 591 if (pFace->uAttributes & FACE_DO_NOT_LIGHT) |
1390 | 592 pRenderer->DrawIndoorPolygonNoLight(uNumVerticesa, uFaceID); |
805 | 593 else |
831 | 594 pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, PID(OBJECT_BModel, uFaceID), v17, 0); |
595 return; | |
0 | 596 } |
597 } | |
598 } | |
599 } | |
600 | |
601 | |
602 | |
603 | |
604 //----- (004B0E07) -------------------------------------------------------- | |
605 unsigned int __fastcall sub_4B0E07(unsigned int uFaceID) | |
606 { | |
607 BLVFace *v1; // edi@1 | |
608 BLVFaceExtra *v2; // ecx@1 | |
609 Texture *v3; // esi@1 | |
610 unsigned int v4; // eax@1 | |
611 unsigned int v5; // ecx@1 | |
612 unsigned int result; // eax@1 | |
613 unsigned int v7; // ecx@5 | |
614 | |
615 v1 = &pIndoor->pFaces[uFaceID]; | |
616 v2 = &pIndoor->pFaceExtras[v1->uFaceExtraID]; | |
945 | 617 v3 = pBitmaps_LOD->GetTexture(v1->uBitmapID); |
0 | 618 stru_F8AD28.pDeltaUV[0] = v2->sTextureDeltaU; |
619 stru_F8AD28.pDeltaUV[1] = v2->sTextureDeltaV; | |
620 v4 = GetTickCount(); | |
621 v5 = v1->uAttributes; | |
622 result = v4 >> 3; | |
623 if ( v5 & 4 ) | |
624 { | |
625 stru_F8AD28.pDeltaUV[1] -= result & v3->uHeightMinus1; | |
626 } | |
627 else | |
628 { | |
629 if ( v5 & 0x20 ) | |
630 stru_F8AD28.pDeltaUV[1] += result & v3->uHeightMinus1; | |
631 } | |
632 v7 = v1->uAttributes; | |
633 if ( BYTE1(v7) & 8 ) | |
634 { | |
635 stru_F8AD28.pDeltaUV[0] -= result & v3->uWidthMinus1; | |
636 } | |
637 else | |
638 { | |
639 if ( v7 & 0x40 ) | |
640 stru_F8AD28.pDeltaUV[0] += result & v3->uWidthMinus1; | |
641 } | |
642 return result; | |
643 } | |
644 | |
645 //----- (004B0EA8) -------------------------------------------------------- | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
646 void BspRenderer::AddFaceToRenderList_d3d(unsigned int node_id, unsigned int uFaceID) |
0 | 647 { |
648 //unsigned int v3; // edx@1 | |
649 //stru170 *v4; // ebx@1 | |
650 //BLVFace *v5; // eax@1 | |
651 //int v6; // ecx@2 | |
1319 | 652 unsigned __int16 pTransitionSector; // ax@11 |
0 | 653 Vec3_short_ *v8; // esi@15 |
654 int v9; // edx@15 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
655 //signed int v10; // eax@18 |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
656 //signed int v11; // edi@19 |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
657 //signed int v12; // ecx@19 |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
658 //signed int v13; // esi@19 |
0 | 659 signed int v14; // edx@20 |
660 int v15; // edx@24 | |
661 //int v16; // esi@29 | |
662 //BLVFace *v17; // edi@34 | |
1319 | 663 //unsigned __int16 v18; // ax@34 |
0 | 664 char *v19; // eax@38 |
665 signed int v20; // ecx@38 | |
666 char *v21; // eax@42 | |
667 signed int v22; // ecx@42 | |
668 //signed int v23; // edx@45 | |
669 //char *v24; // ecx@46 | |
670 //int v25; // eax@47 | |
671 //Vec3_short_ *v26; // eax@47 | |
672 //double v27; // st7@47 | |
673 //signed int v28; // ST28_4@47 | |
674 char v29; // al@48 | |
795 | 675 //signed int v30; // eax@51 |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
676 //int v31; // eax@52 |
0 | 677 //unsigned int v32; // eax@55 |
678 //__int16 v33; // cx@56 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
679 //signed int v34; // [sp+Ch] [bp-14h]@18 |
0 | 680 //int a0; // [sp+14h] [bp-Ch]@2 |
681 //IndoorCameraD3D *a0a; // [sp+14h] [bp-Ch]@36 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
682 //signed int v37; // [sp+18h] [bp-8h]@19 |
0 | 683 //stru10 *v38; // [sp+18h] [bp-8h]@36 |
684 //BLVFace *v39; // [sp+1Ch] [bp-4h]@1 | |
685 | |
686 //v3 = uFaceID; | |
687 //v4 = this; | |
688 //v5 = &pIndoor->pFaces[uFaceID]; | |
795 | 689 nodes[num_nodes].viewing_portal_id = -1; |
0 | 690 //v39 = &pIndoor->pFaces[uFaceID]; |
691 | |
692 auto pFace = &pIndoor->pFaces[uFaceID]; | |
1309 | 693 |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
694 if (!pFace->Portal()) |
0 | 695 { |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
696 if (num_faces < 1000) |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
697 { |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
698 faces[num_faces].uFaceID = uFaceID; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
699 faces[num_faces++].uNodeID = node_id; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
700 } |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
701 return; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
702 } |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
703 |
1319 | 704 if (nodes[node_id].uFaceID == uFaceID) |
705 return; | |
706 if (!node_id && | |
707 pBLVRenderParams->vPartyPos.x >= pFace->pBounding.x1 - 16 && // we are probably standing at the portal plane | |
708 pBLVRenderParams->vPartyPos.x <= pFace->pBounding.x2 + 16 && | |
709 pBLVRenderParams->vPartyPos.y >= pFace->pBounding.y1 - 16 && | |
710 pBLVRenderParams->vPartyPos.y <= pFace->pBounding.y2 + 16 && | |
711 pBLVRenderParams->vPartyPos.z >= pFace->pBounding.z1 - 16 && | |
712 pBLVRenderParams->vPartyPos.z <= pFace->pBounding.z2 + 16 ) | |
713 { | |
714 if ( abs(pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x | |
715 + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y | |
716 + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 ) // we sure are standing at the portal plane | |
0 | 717 { |
1319 | 718 pTransitionSector = pFace->uSectorID; |
719 if ( nodes[0].uSectorID == pTransitionSector ) // draw back sector | |
720 pTransitionSector = pFace->uBackSectorID; | |
721 nodes[num_nodes].uSectorID = pTransitionSector; | |
722 nodes[num_nodes].uFaceID = uFaceID; | |
723 nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; | |
724 nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; | |
725 nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; | |
726 nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; | |
1376 | 727 nodes[num_nodes].PortalScreenData.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY, |
1319 | 728 pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW); |
729 AddBspNodeToRenderList(++num_nodes - 1); | |
730 return; | |
0 | 731 } |
1319 | 732 } |
733 | |
734 v9 = pFace->pFacePlane_old.vNormal.x * (pIndoor->pVertices[pFace->pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x) | |
735 + pFace->pFacePlane_old.vNormal.y * (pIndoor->pVertices[pFace->pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y) | |
736 + pFace->pFacePlane_old.vNormal.z * (pIndoor->pVertices[pFace->pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z); | |
737 if (nodes[node_id].uSectorID != pFace->uSectorID) | |
738 v9 = -v9; | |
739 if (v9 >= 0) | |
740 return; | |
741 | |
1344 | 742 auto num_vertices = GetPortalScreenCoord(uFaceID); |
1319 | 743 if (num_vertices < 2) |
744 return; | |
745 | |
1344 | 746 auto face_min_screenspace_x = PortalFace._screen_space_x[0], |
747 face_max_screenspace_x = PortalFace._screen_space_x[0]; | |
748 auto face_min_screenspace_y = PortalFace._screen_space_y[0], | |
749 face_max_screenspace_y = PortalFace._screen_space_y[0]; | |
1319 | 750 for (uint i = 1; i < num_vertices; ++i) |
751 { | |
1344 | 752 if (face_min_screenspace_x > PortalFace._screen_space_x[i]) |
753 face_min_screenspace_x = PortalFace._screen_space_x[i]; | |
754 if (face_max_screenspace_x < PortalFace._screen_space_x[i]) | |
755 face_max_screenspace_x = PortalFace._screen_space_x[i]; | |
756 | |
757 if (face_min_screenspace_y > PortalFace._screen_space_y[i]) | |
758 face_min_screenspace_y = PortalFace._screen_space_y[i]; | |
759 if (face_max_screenspace_y < PortalFace._screen_space_y[i]) | |
760 face_max_screenspace_y = PortalFace._screen_space_y[i]; | |
1319 | 761 } |
1132 | 762 //_screen_space_x = 719, 568, 493 |
763 //savegame: qw , 0Bh and 0x1D4h | |
764 //problem here when standing near/on portal, condition is false because of face_min_screenspace_x > p->uViewportZ | |
1319 | 765 if (face_max_screenspace_x >= nodes[node_id].uViewportX && |
766 face_min_screenspace_x <= nodes[node_id].uViewportZ && | |
767 face_max_screenspace_y >= nodes[node_id].uViewportY && | |
768 face_min_screenspace_y <= nodes[node_id].uViewportW && | |
1376 | 769 PortalFrustrum(num_vertices, &nodes[num_nodes].PortalScreenData, &nodes[node_id].PortalScreenData, uFaceID)) |
1319 | 770 { |
771 pTransitionSector = pFace->uSectorID; | |
772 if (nodes[node_id].uSectorID == pTransitionSector ) | |
773 pTransitionSector = pFace->uBackSectorID; | |
774 nodes[num_nodes].uSectorID = pTransitionSector; | |
775 nodes[num_nodes].uFaceID = uFaceID; | |
776 nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; | |
777 nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; | |
778 nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; | |
779 nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; | |
780 v29 = false; | |
781 if (nodes[node_id].viewing_portal_id == -1)//первый портал на который я смотрю | |
782 v29 = pGame->pStru10Instance->CalcPortalShape(pFace, nodes[num_nodes].std__vector_0007AC, nodes[num_nodes].pPortalBounding); | |
783 else//следующие порталы в портале | |
784 { | |
785 static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F7AA08[64]; | |
786 static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F79E08[64]; | |
787 | |
788 for (uint k = 0; k < pFace->uNumVertices; ++k) | |
789 { | |
790 static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[k]].x; | |
791 static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[k]].y; | |
792 static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[k]].z; | |
793 } | |
794 | |
795 unsigned int pNewNumVertices = pFace->uNumVertices; | |
796 pGame->pIndoorCameraD3D->CalcPortalShape(static_subAddFaceToRenderList_d3d_stru_F7AA08, &pNewNumVertices, | |
797 static_subAddFaceToRenderList_d3d_stru_F79E08, nodes[node_id].std__vector_0007AC, 4, 0, 0); | |
798 | |
799 v29 = pGame->pStru10Instance->_49C5DA(pFace, static_subAddFaceToRenderList_d3d_stru_F79E08, &pNewNumVertices, | |
800 nodes[num_nodes].std__vector_0007AC, nodes[num_nodes].pPortalBounding); | |
801 } | |
802 if ( 1 ) | |
803 { | |
804 assert(num_nodes < 150); | |
805 | |
806 nodes[num_nodes].viewing_portal_id = uFaceID; | |
807 AddBspNodeToRenderList(++num_nodes - 1); | |
808 } | |
809 if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) | |
810 pGame->pIndoorCameraD3D->PrepareAndDrawDebugOutline(pFace, 0x1E1EFF); | |
811 //pGame->pIndoorCameraD3D->DebugDrawPortal(pFace); | |
812 } | |
0 | 813 } |
814 | |
815 | |
816 //----- (004AFB86) -------------------------------------------------------- | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
817 void BspRenderer::AddFaceToRenderList_sw(unsigned int node_id, unsigned int uFaceID) |
0 | 818 { |
819 BspRenderer *v3; // ebx@1 | |
820 BLVFace *v4; // eax@1 | |
821 char *v5; // ecx@2 | |
822 unsigned __int16 v6; // ax@11 | |
823 int v7; // ecx@13 | |
824 Vec3_short_ *v8; // esi@16 | |
825 int v9; // edx@16 | |
826 signed int v10; // eax@19 | |
827 signed int v11; // edi@20 | |
828 signed int v12; // ecx@20 | |
829 signed int v13; // esi@20 | |
830 int v14; // edx@21 | |
831 int v15; // edx@25 | |
832 unsigned __int16 v16; // ax@35 | |
833 signed int v17; // eax@37 | |
834 int v18; // eax@38 | |
835 signed int v19; // [sp+Ch] [bp-14h]@19 | |
836 char *v20; // [sp+14h] [bp-Ch]@2 | |
837 BLVFace *v21; // [sp+18h] [bp-8h]@1 | |
838 signed int v22; // [sp+1Ch] [bp-4h]@20 | |
839 signed int v23; // [sp+28h] [bp+8h]@20 | |
840 | |
841 v3 = this; | |
842 v4 = &pIndoor->pFaces[uFaceID]; | |
843 v21 = v4; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
844 if (v4->Portal()) |
0 | 845 { |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
846 v5 = (char *)this + 2252 * node_id; |
0 | 847 v20 = v5; |
848 if ( uFaceID == *((short *)v5 + 2982) ) | |
849 return; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
850 if (!node_id |
0 | 851 && pBLVRenderParams->vPartyPos.x >= v4->pBounding.x1 - 16 |
852 && pBLVRenderParams->vPartyPos.x <= v4->pBounding.x2 + 16 | |
853 && pBLVRenderParams->vPartyPos.y >= v4->pBounding.y1 - 16 | |
854 && pBLVRenderParams->vPartyPos.y <= v4->pBounding.y2 + 16 | |
855 && pBLVRenderParams->vPartyPos.z >= v4->pBounding.z1 - 16 | |
856 && pBLVRenderParams->vPartyPos.z <= v4->pBounding.z2 + 16 ) | |
857 { | |
858 if ( abs(v4->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * v4->pFacePlane_old.vNormal.x | |
859 + pBLVRenderParams->vPartyPos.y * v4->pFacePlane_old.vNormal.y | |
860 + pBLVRenderParams->vPartyPos.z * v4->pFacePlane_old.vNormal.z) <= 589824 ) | |
861 { | |
862 v6 = v21->uSectorID; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
863 if ( v3->nodes[0].uSectorID == v6 ) |
0 | 864 v6 = v21->uBackSectorID; |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
865 v3->nodes[v3->num_nodes].uSectorID = v6; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
866 v3->nodes[v3->num_nodes].uFaceID = uFaceID; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
867 v3->nodes[v3->num_nodes].uViewportX = LOWORD(pBLVRenderParams->uViewportX); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
868 v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
869 v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
870 v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW); |
1376 | 871 v3->nodes[v3->num_nodes++].PortalScreenData.GetViewportData( |
0 | 872 SLOWORD(pBLVRenderParams->uViewportX), |
873 pBLVRenderParams->uViewportY, | |
874 SLOWORD(pBLVRenderParams->uViewportZ), | |
875 pBLVRenderParams->uViewportW); | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
876 v7 = v3->num_nodes - 1; |
0 | 877 goto LABEL_14; |
878 } | |
879 v4 = v21; | |
880 v5 = v20; | |
881 } | |
882 v8 = &pIndoor->pVertices[*v4->pVertexIDs]; | |
883 v9 = v4->pFacePlane_old.vNormal.x * ((signed __int16)*(int *)&v8->x - pBLVRenderParams->vPartyPos.x) | |
884 + v4->pFacePlane_old.vNormal.y * ((signed __int16)(*(int *)&v8->x >> 16) - pBLVRenderParams->vPartyPos.y) | |
885 + v4->pFacePlane_old.vNormal.z * (v8->z - pBLVRenderParams->vPartyPos.z); | |
886 if ( *((short *)v5 + 2004) != v4->uSectorID ) | |
887 v9 = -v9; | |
888 if ( v9 < 0 ) | |
889 { | |
1344 | 890 v10 = GetPortalScreenCoord(uFaceID); |
0 | 891 v19 = v10; |
892 if ( v10 ) | |
893 { | |
1344 | 894 v11 = PortalFace._screen_space_x[0]; |
895 v12 = PortalFace._screen_space_y[0]; | |
896 v23 = PortalFace._screen_space_x[0]; | |
0 | 897 v13 = 1; |
1344 | 898 v22 = PortalFace._screen_space_y[0]; |
0 | 899 if ( v10 > 1 ) |
900 { | |
901 do | |
902 { | |
1344 | 903 v14 = PortalFace._screen_space_x[v13]; |
0 | 904 if ( v14 < v23 ) |
1344 | 905 v23 = PortalFace._screen_space_x[v13]; |
0 | 906 if ( v14 > v11 ) |
1344 | 907 v11 = PortalFace._screen_space_x[v13]; |
908 v15 = PortalFace._screen_space_y[v13]; | |
0 | 909 if ( v15 < v22 ) |
1344 | 910 v22 = PortalFace._screen_space_y[v13]; |
0 | 911 if ( v15 > v12 ) |
1344 | 912 v12 = PortalFace._screen_space_y[v13]; |
0 | 913 v10 = v19; |
914 ++v13; | |
915 } | |
916 while ( v13 < v19 ); | |
917 } | |
918 if ( v11 >= *((short *)v20 + 2005) | |
919 && v23 <= *((short *)v20 + 2007) | |
920 && v12 >= *((short *)v20 + 2006) | |
921 && v22 <= *((short *)v20 + 2008) | |
1376 | 922 && PortalFrustrum(v10, &v3->nodes[v3->num_nodes].PortalScreenData, (BspRenderer_PortalViewportData *)(v20 + 4020), uFaceID) ) |
0 | 923 { |
924 v16 = v21->uSectorID; | |
925 if ( *((short *)v20 + 2004) == v16 ) | |
926 v16 = v21->uBackSectorID; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
927 v3->nodes[v3->num_nodes].uSectorID = v16; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
928 v3->nodes[v3->num_nodes].uFaceID = uFaceID; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
929 v3->nodes[v3->num_nodes].uViewportX = LOWORD(pBLVRenderParams->uViewportX); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
930 v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
931 v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
932 v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW); |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
933 v17 = v3->num_nodes; |
0 | 934 if ( v17 < 150 ) |
935 { | |
936 v18 = v17 + 1; | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
937 v3->num_nodes = v18; |
0 | 938 v7 = v18 - 1; |
939 LABEL_14: | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
940 AddBspNodeToRenderList(v7); |
0 | 941 return; |
942 } | |
943 } | |
944 } | |
945 } | |
946 } | |
947 else | |
948 { | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
949 if (num_faces < 1000) |
0 | 950 { |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
951 faces[num_faces].uFaceID = uFaceID; |
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
952 faces[num_faces++].uNodeID = node_id; |
0 | 953 } |
954 } | |
955 } | |
956 | |
957 //----- (004B0967) -------------------------------------------------------- | |
486 | 958 void BspRenderer::DrawFaceOutlines() |
0 | 959 { |
960 signed int i; // edi@1 | |
961 int v1; // esi@2 | |
962 unsigned int v2; // ecx@4 | |
963 int v3; // eax@4 | |
964 int v4; // eax@6 | |
965 unsigned __int16 *v5; // edx@6 | |
966 int v6; // ecx@7 | |
967 int v7; // esi@8 | |
968 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
969 for ( i = 0; i < (signed int)pBspRenderer->num_faces; ++i ) |
0 | 970 { |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
971 v1 = pBspRenderer->faces[i].uFaceID; |
0 | 972 if ( v1 >= 0 ) |
973 { | |
974 if ( v1 < (signed int)pIndoor->uNumFaces ) | |
975 { | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
666
diff
changeset
|
976 v2 = pBspRenderer->faces[i].uFaceID; |
1376 | 977 pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].PortalScreenData; |
1344 | 978 v3 = GetPortalScreenCoord(v2); |
0 | 979 if ( v3 ) |
980 { | |
1372 | 981 if ( PortalFrustrum(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1) ) |
0 | 982 { |
983 v4 = stru_F8A590._viewport_space_y; | |
984 v5 = pBLVRenderParams->pRenderTarget; | |
985 if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w ) | |
986 { | |
987 v6 = 640 * stru_F8A590._viewport_space_y; | |
988 do | |
989 { | |
1281 | 990 v5[v6 + stru_F8A590.viewport_left_side[v4]] = -1; |
991 v7 = v6 + stru_F8A590.viewport_right_side[v4]; | |
0 | 992 v6 += 640; |
993 v5[v7] = -1; | |
994 ++v4; | |
995 } | |
996 while ( v4 <= stru_F8A590._viewport_space_w ); | |
997 } | |
998 } | |
999 } | |
1000 } | |
1001 } | |
1002 } | |
1003 } | |
1004 | |
1005 | |
1006 //----- (004AE5BA) -------------------------------------------------------- | |
1007 Texture *BLVFace::GetTexture() | |
1008 { | |
1009 unsigned int v1; // ecx@2 | |
1010 | |
1011 if ( uAttributes & 0x4000 ) | |
1012 v1 = pTextureFrameTable->GetFrameTexture(this->uBitmapID, pBLVRenderParams->field_0_timer_); | |
1013 else | |
1014 v1 = uBitmapID; | |
945 | 1015 return pBitmaps_LOD->GetTexture(v1); |
0 | 1016 } |
1017 | |
1018 | |
1019 //----- (00498B15) -------------------------------------------------------- | |
1020 void IndoorLocation::Release() | |
1021 { | |
1022 IndoorLocation *v1; // esi@1 | |
1023 char *v2; // ebp@1 | |
1024 void *v3; // ST00_4@1 | |
1025 | |
1026 v1 = this; | |
1027 v2 = (char *)&this->ptr_0002B4_doors_ddata; | |
1028 pAllocator->FreeChunk(this->ptr_0002B4_doors_ddata); | |
1029 *(int *)v2 = 0; | |
1030 pAllocator->FreeChunk(v1->ptr_0002B0_sector_rdata); | |
1031 v1->ptr_0002B0_sector_rdata = 0; | |
1032 pAllocator->FreeChunk(v1->ptr_0002B8_sector_lrdata); | |
1033 v1->ptr_0002B8_sector_lrdata = 0; | |
1006 | 1034 pAllocator->FreeChunk(v1->pLFaces); |
1035 v1->pLFaces = 0; | |
0 | 1036 pAllocator->FreeChunk(v1->pSpawnPoints); |
1037 v3 = v1->pVertices; | |
1038 v1->pSpawnPoints = 0; | |
1039 v1->uNumSectors = 0; | |
1040 v1->uNumFaces = 0; | |
1041 v1->uNumVertices = 0; | |
1042 v1->uNumNodes = 0; | |
1043 v1->uNumDoors = 0; | |
1044 v1->uNumLights = 0; | |
1045 pAllocator->FreeChunk(v3); | |
1046 pAllocator->FreeChunk(v1->pFaces); | |
1047 pAllocator->FreeChunk(v1->pFaceExtras); | |
1048 pAllocator->FreeChunk(v1->pSectors); | |
1049 pAllocator->FreeChunk(v1->pLights); | |
1050 pAllocator->FreeChunk(v1->pDoors); | |
1051 pAllocator->FreeChunk(v1->pNodes); | |
1052 pAllocator->FreeChunk(v1->pMapOutlines); | |
1053 v1->pVertices = 0; | |
1054 v1->pFaces = 0; | |
1055 v1->pFaceExtras = 0; | |
1056 v1->pSectors = 0; | |
1057 v1->pLights = 0; | |
1058 v1->pDoors = 0; | |
1059 v1->pNodes = 0; | |
1060 v1->pMapOutlines = 0; | |
1061 v1->bLoaded = 0; | |
1062 } | |
1063 | |
1064 //----- (00498C45) -------------------------------------------------------- | |
711 | 1065 bool IndoorLocation::Alloc() |
1066 { | |
1067 pVertices = (Vec3_short_ *) pAllocator->AllocNamedChunk(pVertices, 15000*sizeof(Vec3_short_), "L.V");//0x15F90u | |
1068 pFaces = (BLVFace *) pAllocator->AllocNamedChunk(pFaces, 10000*sizeof(BLVFace), "L.F");//0xEA600u | |
1069 pFaceExtras = (BLVFaceExtra *) pAllocator->AllocNamedChunk(pFaceExtras,5000*sizeof(BLVFaceExtra), "L.FX"); //0x2BF20u | |
1070 pSectors = (BLVSector *) pAllocator->AllocNamedChunk(pSectors, 512*sizeof(BLVSector), "L.R");//0xE800u | |
1071 pLights = (BLVLightMM7 *) pAllocator->AllocNamedChunk(pLights, 400*sizeof(BLVLightMM7), "L.L");//0x1900u | |
1072 pDoors = (BLVDoor *) pAllocator->AllocNamedChunk(pDoors, 200*sizeof(BLVDoor), "L.D");//0x3E80u | |
1073 pNodes = (BSPNode *) pAllocator->AllocNamedChunk(pNodes, 5000*sizeof(BSPNode), "L.BSP");//0x9C40u | |
1074 pMapOutlines =(BLVMapOutlines *)pAllocator->AllocNamedChunk(pMapOutlines, sizeof(BLVMapOutlines), "L.Map");//0x14824u | |
1075 if (pVertices && pFaces && pFaceExtras && pSectors && pLights && pDoors && pNodes && pMapOutlines ) | |
0 | 1076 { |
711 | 1077 memset(pVertices, 0, 15000*sizeof(Vec3_short_)); |
1078 memset(pFaces, 0, 10000*sizeof(BLVFace)); | |
1079 memset(pFaceExtras,0, 5000*sizeof(BLVFaceExtra)); | |
1080 memset(pSectors, 0, 512*sizeof(BLVSector)); | |
1081 memset(pLights, 0, 400*sizeof(BLVLightMM7)); | |
1082 memset(pDoors, 0, 200*sizeof(BLVDoor)); | |
1083 memset(pNodes, 0, 5000*sizeof(BSPNode)); | |
1084 memset(pMapOutlines,0, sizeof(BLVMapOutlines)); | |
1085 return true; | |
0 | 1086 } |
1087 else | |
1088 { | |
711 | 1089 return false; |
0 | 1090 } |
1091 } | |
1092 | |
1093 | |
1094 | |
1095 //----- (00444810) -------------------------------------------------------- | |
1096 unsigned int IndoorLocation::GetLocationIndex(const char *Str1) | |
1097 { | |
1098 const char *v1; // edi@1 | |
1099 signed int v2; // esi@1 | |
1100 | |
434 | 1101 for (uint i = 0; i < 11; ++i) |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1132
diff
changeset
|
1102 if (!_stricmp(Str1, _4E6BDC_loc_names[i])) |
434 | 1103 return i + 1; |
1104 return 0; | |
0 | 1105 } |
1106 | |
1107 | |
1108 | |
1109 //----- (004488F7) -------------------------------------------------------- | |
711 | 1110 void IndoorLocation::ToggleLight(signed int sLightID, unsigned int bToggle) |
0 | 1111 { |
711 | 1112 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && (sLightID <= pIndoor->uNumLights - 1) && (sLightID >= 0) ) |
0 | 1113 { |
1114 if ( bToggle ) | |
1063 | 1115 pIndoor->pLights[sLightID].uAtributes &= 0xFFFFFFF7u; |
0 | 1116 else |
1063 | 1117 pIndoor->pLights[sLightID].uAtributes |= 8u; |
0 | 1118 pParty->uFlags |= 2u; |
1119 } | |
1120 } | |
1121 | |
1122 | |
1123 //----- (00498E0A) -------------------------------------------------------- | |
1124 bool IndoorLocation::Load(char *pFilename, int a3, size_t _i, char *pDest) | |
1125 { | |
1126 /*unsigned int v5; // ebx@1 | |
1127 //IndoorLocation *v6; // esi@1 | |
1128 FILE *v7; // edi@3 | |
1129 bool result; // eax@3 | |
1130 char *v9; // ecx@4 | |
1131 void *v10; // eax@4 | |
1132 //unsigned __int8 v11; // zf@4 | |
1133 //unsigned __int8 v12; // sf@4 | |
1134 int v13; // eax@5 | |
1135 size_t v14; // ecx@6 | |
1136 char *v15; // ecx@6 | |
1137 int v16; // edx@6 | |
1138 size_t v17; // ecx@6 | |
1139 char *v18; // ecx@6 | |
1140 int v19; // edx@6 | |
1141 unsigned __int16 *v20; // edx@6 | |
1142 unsigned __int16 *v21; // edx@6 | |
1143 unsigned __int16 *v22; // edx@6 | |
1144 __int16 v23; // ax@10 | |
1145 char *v24; // ecx@10 | |
1146 __int16 v25; // cx@10 | |
1147 __int16 v26; // ax@11 | |
1148 char *v27; // ecx@11 | |
1149 unsigned __int16 v28; // ax@17 | |
1150 BLVFaceExtra *v29; // ecx@17 | |
1151 char *v30; // edx@17 | |
1152 int v31; // ecx@20 | |
1153 void *v32; // eax@25 | |
1154 int v33; // eax@26 | |
1155 unsigned __int16 *v34; // edx@27 | |
1156 size_t v35; // ecx@27 | |
1157 char *v36; // ecx@27 | |
1158 int v37; // edx@27 | |
1159 size_t v38; // ecx@27 | |
1160 char *v39; // ecx@27 | |
1161 int v40; // edx@27 | |
1162 unsigned __int16 *v41; // edx@27 | |
1163 unsigned __int16 *v42; // edx@27 | |
1164 unsigned __int16 *v43; // edx@27 | |
1165 unsigned __int16 *v44; // edx@27 | |
1166 size_t v45; // ecx@27 | |
1167 unsigned __int16 *v46; // edx@27 | |
1168 void *v47; // eax@28 | |
1169 BLVSector *v48; // eax@29 | |
1170 size_t v49; // ecx@29 | |
1171 unsigned __int16 *v50; // edx@31 | |
1172 void *v51; // eax@32 | |
1173 int v52; // eax@33 | |
1174 unsigned __int16 *v53; // edx@34 | |
1175 size_t v54; // ecx@34 | |
1176 char *v55; // ecx@34 | |
1177 int v56; // edx@34 | |
1178 size_t v57; // ecx@34 | |
1179 char *v58; // ecx@34 | |
1180 int v59; // edx@34 | |
1181 unsigned __int16 *v60; // edx@34 | |
1182 unsigned __int16 *v61; // edx@34 | |
1183 unsigned __int16 *v62; // edx@34 | |
1184 unsigned __int16 *v63; // edx@34 | |
1185 int v64; // ecx@34 | |
1186 BLVDoor *v65; // ecx@36 | |
1187 char *v66; // eax@37 | |
1188 int v67; // edx@38 | |
1189 int v68; // ecx@38 | |
1190 BLVFace *v69; // edx@38 | |
1191 int v70; // ecx@38 | |
1192 int v71; // edx@38 | |
1193 int v72; // eax@38 | |
1194 unsigned __int16 v73; // ax@42 | |
1195 char *v74; // ecx@42 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
1196 SpriteObject *v75; // ecx@44 |
0 | 1197 size_t v76; // eax@45 |
1198 int j; // edx@46 | |
1199 unsigned __int16 v78; // ax@50 | |
1200 void *v79; // eax@52 | |
1201 void **v80; // esi@52 | |
1202 unsigned int v145; // eax@103 | |
1203 void *v146; // eax@103 | |
1204 unsigned int v147; // ecx@103 | |
1205 int v148; // ebx@103 | |
1206 unsigned int *v149; // ecx@103*/ | |
1207 //size_t v150; // eax@103 | |
1208 //unsigned int v151; // ebx@109 | |
1209 //unsigned int v152; // ecx@116 | |
1210 //unsigned int v153; // eax@117 | |
1211 //size_t v154; // ebx@126 | |
1212 //unsigned int v155; // ebx@134 | |
1213 //size_t v156; // eax@140 | |
1214 //signed int v157; // ebx@142 | |
1215 //int v158; // ebx@148 | |
1216 //BLVFace *v159; // eax@149 | |
1217 // BLVFaceExtra *v160; // ecx@149 | |
1218 //BLVFaceExtra *v161; // ecx@149 | |
1219 //signed int v162; // ebx@154 | |
1220 //unsigned int v163; // ebx@157 | |
1221 //unsigned int v164; // ebx@157 | |
1222 //unsigned int v165; // edx@158 | |
1223 //char *v166; // ecx@158 | |
1224 //unsigned __int16 v167; // ax@161 | |
1225 //__int16 v168; // ax@165 | |
1226 //unsigned int v169; // ebx@168 | |
1227 //void *v170; // eax@168 | |
1228 //size_t v171; // ebx@168 | |
1229 //int v172; // edx@168 | |
1230 //BLVDoor *v173; // ecx@169 | |
1231 //int k; // eax@169 | |
1232 //BLVDoor *v175; // ecx@172 | |
1233 //int v176; // edx@172 | |
1234 //BLVDoor *v177; // ecx@172 | |
1235 //int v178; // edx@172 | |
1236 //BLVDoor *v179; // ecx@172 | |
1237 //int v180; // edx@172 | |
1238 //BLVDoor *v181; // ecx@172 | |
1239 //int v182; // edx@172 | |
1240 //BLVDoor *v183; // ecx@172 | |
1241 //int v184; // edx@172 | |
1242 //BLVDoor *v185; // ecx@172 | |
1243 //int v186; // edx@172 | |
1244 //BLVDoor *v187; // ecx@172 | |
1245 //int v188; // edx@172 | |
1246 //unsigned __int16 *v189; // ebx@172 | |
1247 //char *v190; // edx@173 | |
1248 //BLVDoor *v191; // ecx@174 | |
1249 //BLVDoor *l; // eax@175 | |
1250 //signed int v193; // ebx@176 | |
1251 //int v194; // ecx@176 | |
1252 //BLVFaceExtra *v195; // ecx@176 | |
1253 //BLVFace *v196; // ebx@178 | |
1254 //std::string v197; // [sp-18h] [bp-680h]@66 | |
1255 //void *v198; // [sp-14h] [bp-67Ch]@72 | |
1256 //size_t v199; // [sp-10h] [bp-678h]@72 | |
1257 //size_t v200; // [sp-Ch] [bp-674h]@72 | |
1258 //const char *v201; // [sp-8h] [bp-670h]@4 | |
1259 //int v202; // [sp-4h] [bp-66Ch]@4 | |
1260 char v203[875]; // [sp+Ch] [bp-65Ch]@130 | |
1261 char FileName[260]; // [sp+378h] [bp-2F0h]@1 | |
1262 //char DstBuf; // [sp+47Ch] [bp-1ECh]@4 | |
1263 __int32 Offset; // [sp+480h] [bp-1E8h]@4 | |
1264 __int32 v207; // [sp+48Ch] [bp-1DCh]@4 | |
1265 __int32 v208; // [sp+498h] [bp-1D0h]@4 | |
1266 __int32 v209; // [sp+4A4h] [bp-1C4h]@4 | |
1267 __int32 v210; // [sp+4B0h] [bp-1B8h]@4 | |
1268 __int32 v211; // [sp+4BCh] [bp-1ACh]@15 | |
1269 __int32 v212; // [sp+4C8h] [bp-1A0h]@15 | |
1270 __int32 v213; // [sp+4D4h] [bp-194h]@25 | |
1271 __int32 v214; // [sp+4E0h] [bp-188h]@25 | |
1272 __int32 v215; // [sp+4ECh] [bp-17Ch]@32 | |
1273 __int32 v216; // [sp+4F8h] [bp-170h]@32 | |
1274 __int32 v217; // [sp+504h] [bp-164h]@40 | |
1275 __int32 v218; // [sp+510h] [bp-158h]@40 | |
1276 __int32 v219; // [sp+51Ch] [bp-14Ch]@43 | |
1277 __int32 v220; // [sp+528h] [bp-140h]@43 | |
1278 __int32 v221; // [sp+534h] [bp-134h]@52 | |
1279 __int32 v222; // [sp+540h] [bp-128h]@52 | |
1280 __int32 v223; // [sp+54Ch] [bp-11Ch]@52 | |
1281 __int32 v224; // [sp+558h] [bp-110h]@52 | |
1282 __int32 v225; // [sp+564h] [bp-104h]@52 | |
1283 __int32 v226; // [sp+570h] [bp-F8h]@52 | |
1284 __int32 v227; // [sp+57Ch] [bp-ECh]@52 | |
1285 __int32 v228; // [sp+588h] [bp-E0h]@52 | |
1286 __int32 v229; // [sp+594h] [bp-D4h]@52 | |
1287 __int32 v230; // [sp+5A0h] [bp-C8h]@52 | |
1288 __int32 v231; // [sp+5ACh] [bp-BCh]@52 | |
1289 __int32 v232; // [sp+5B8h] [bp-B0h]@52 | |
1290 __int32 v233; // [sp+5C4h] [bp-A4h]@52 | |
1291 __int32 v234; // [sp+5D0h] [bp-98h]@52 | |
1292 //char pName[40]; // [sp+5FCh] [bp-6Ch]@42 | |
1293 //size_t pSource; // [sp+624h] [bp-44h]@67 | |
1294 //char Dst[12]; // [sp+628h] [bp-40h]@9 | |
1295 //char *v238; // [sp+634h] [bp-34h]@38 | |
1296 ODMHeader header; // [sp+638h] [bp-30h]@61 | |
1297 //void *ptr; // [sp+648h] [bp-20h]@66 | |
1298 //size_t Count; // [sp+64Ch] [bp-1Ch]@109 | |
1299 //int uSourceLen; // [sp+653h] [bp-15h]@66 | |
1300 FILE *File; // [sp+658h] [bp-10h]@56 | |
1301 //BLVSector *v244; // [sp+65Ch] [bp-Ch]@72 | |
1302 //int v245; // [sp+660h] [bp-8h]@72 | |
1303 //BLVFace *Src; // [sp+664h] [bp-4h]@73 | |
1304 signed int Argsa; // [sp+670h] [bp+8h]@4 | |
1305 signed int Argsb; // [sp+670h] [bp+8h]@7 | |
1306 signed int Argsc; // [sp+670h] [bp+8h]@15 | |
1307 signed int Argsd; // [sp+670h] [bp+8h]@18 | |
1308 int Argse; // [sp+670h] [bp+8h]@25 | |
1309 int Argsf; // [sp+670h] [bp+8h]@28 | |
1310 int Argsg; // [sp+670h] [bp+8h]@32 | |
1311 int Argsh; // [sp+670h] [bp+8h]@35 | |
1312 signed int Argsi; // [sp+670h] [bp+8h]@40 | |
1313 signed int Argsj; // [sp+670h] [bp+8h]@45 | |
1314 //int Argsk; // [sp+670h] [bp+8h]@143 | |
1315 //void *Argsl; // [sp+670h] [bp+8h]@155 | |
1316 //signed int Argsm; // [sp+670h] [bp+8h]@161 | |
1317 //signed int Argsn; // [sp+670h] [bp+8h]@175 | |
1318 | |
1319 //v5 = 0; | |
1320 //v6 = this; | |
1321 _6807E0_num_decorations_with_sounds_6807B8 = 0; | |
1322 | |
1323 #pragma region "loading from txt" | |
1324 /*sprintf(FileName, "levels\\%s", pFilename); | |
1325 if ( GetFileAttributesA(FileName) != -1 ) | |
1326 { | |
1327 Release(); | |
1328 if ( Alloc() ) | |
1329 { | |
1330 v7 = fopen(FileName, "rb"); | |
1331 result = 1; | |
1332 if ( !v7 ) | |
1333 return result; | |
1334 v9 = pDest; | |
1335 bLoaded = 1; | |
1336 v202 = (int)v7; | |
1337 v201 = (const char *)1; | |
1338 *(int *)v9 = 1; | |
1339 fread(&DstBuf, 0x180u, (size_t)v201, (FILE *)v202); | |
1340 fseek(v7, Offset, 0); | |
1341 fread(&blv, 0x88u, 1u, v7); | |
1342 fseek(v7, v207, 0); | |
1343 fread(&uNumVertices, 1u, 4u, v7); | |
1344 fseek(v7, v208, 0); | |
1345 fread(pVertices, 6u, uNumVertices, v7); | |
1346 fseek(v7, v209, 0); | |
1347 fread(&uNumFaces, 4u, 1u, v7); | |
1348 fseek(v7, v210, 0); | |
1349 fread(pFaces, 0x60u, uNumFaces, v7); | |
1350 v10 = pAllocator->AllocNamedChunk(ptr_2AC, blv.uFaces_fdata_Size, "L.FData"); | |
1351 v202 = (int)v7; | |
1352 ptr_2AC = (unsigned __int16 *)v10; | |
1353 fread(v10, 1u, blv.uFaces_fdata_Size, (FILE *)v202); | |
1354 v11 = uNumFaces == 0; | |
1355 v12 = (uNumFaces & 0x80000000u) != 0; | |
1356 pDest = 0; | |
1357 Argsa = 0; | |
1358 if ( !(v12 | v11) ) | |
1359 { | |
1360 v13 = 0; | |
1361 do | |
1362 { | |
1363 pFaces[v13].pVertexIDs = (unsigned __int16 *)&pDest[(unsigned int)ptr_2AC]; | |
1364 v14 = (size_t)&pFaces[v13]; | |
1365 i = v14; | |
1366 v15 = &pDest[2 * *(char *)(v14 + 93) + 2]; | |
1367 v16 = (int)&v15[(unsigned int)ptr_2AC]; | |
1368 pDest = v15; | |
1369 *(int *)(i + 52) = v16; | |
1370 v17 = (size_t)&pFaces[v13]; | |
1371 i = v17; | |
1372 v18 = &pDest[2 * *(char *)(v17 + 93) + 2]; | |
1373 v19 = (int)&v18[(unsigned int)ptr_2AC]; | |
1374 pDest = v18; | |
1375 *(int *)(i + 56) = v19; | |
1376 i = (size_t)&pFaces[v13]; | |
1377 v20 = ptr_2AC; | |
1378 pDest += 2 * *(char *)(i + 93) + 2; | |
1379 *(int *)(i + 60) = (int)(char *)v20 + (int)pDest; | |
1380 i = (size_t)&pFaces[v13]; | |
1381 v21 = ptr_2AC; | |
1382 pDest += 2 * *(char *)(i + 93) + 2; | |
1383 *(int *)(i + 64) = (int)(char *)v21 + (int)pDest; | |
1384 i = (size_t)&pFaces[v13]; | |
1385 ++v13; | |
1386 v22 = ptr_2AC; | |
1387 pDest += 2 * *(char *)(i + 93) + 2; | |
1388 ++Argsa; | |
1389 *(int *)(i + 68) = (int)(char *)v22 + (int)pDest; | |
1390 pDest += 2 * *((char *)&pFaces[v13] - 3) + 2; | |
1391 } | |
1392 while ( Argsa < (signed int)uNumFaces ); | |
1393 } | |
1394 Argsb = 0; | |
1395 if ( (signed int)uNumFaces > 0 ) | |
1396 { | |
1397 pDest = 0; | |
1398 do | |
1399 { | |
1400 fread(Dst, 1u, 0xAu, v7); | |
1401 if ( pDest[(unsigned int)pFaces + 45] & 0x40 ) | |
1402 { | |
1403 v23 = pTextureFrameTable->FindTextureByName(Dst); | |
1404 v24 = pDest; | |
1405 *(short *)&pDest[(unsigned int)pFaces + 74] = v23; | |
1406 v25 = *(short *)&v24[(unsigned int)pFaces + 74]; | |
1407 if ( v25 ) | |
1408 { | |
1409 pTextureFrameTable->LoadAnimationSequenceAndPalettes(v25); | |
1410 } | |
1411 else | |
1412 { | |
1413 v26 = pBitmaps_LOD->LoadTexture(Dst); | |
1414 v27 = pDest; | |
1415 *(short *)&pDest[(unsigned int)pFaces + 74] = v26; | |
1416 v27[(unsigned int)pFaces + 45] &= 0xBFu; | |
1417 } | |
1418 } | |
1419 else | |
1420 { | |
1421 *(short *)&pDest[(unsigned int)pFaces + 74] = pBitmaps_LOD->LoadTexture(Dst); | |
1422 } | |
1423 ++Argsb; | |
1424 pDest += 96; | |
1425 } | |
1426 while ( Argsb < (signed int)uNumFaces ); | |
1427 } | |
1428 fseek(v7, v211, 0); | |
1429 fread(&uNumFaceExtras, 4u, 1u, v7); | |
1430 fseek(v7, v212, 0); | |
1431 fread(pFaceExtras, 0x24u, uNumFaceExtras, v7); | |
1432 Argsc = 0; | |
1433 if ( (signed int)uNumFaceExtras > 0 ) | |
1434 { | |
1435 pDest = 0; | |
1436 do | |
1437 { | |
1438 fread(Dst, 1u, 0xAu, v7); | |
1439 v28 = pBitmaps_LOD->LoadTexture(Dst); | |
1440 v29 = pFaceExtras; | |
1441 v30 = pDest; | |
1442 ++Argsc; | |
1443 pDest += 36; | |
1444 *(unsigned __int16 *)((char *)&v29->uAdditionalBitmapID + (int)v30) = v28; | |
1445 } | |
1446 while ( Argsc < (signed int)uNumFaceExtras ); | |
1447 } | |
1448 Argsd = 0; | |
1449 if ( (signed int)uNumFaces > 0 ) | |
1450 { | |
1451 pDest = 0; | |
1452 do | |
1453 { | |
1454 v31 = (int)&pFaceExtras[*(short *)&pDest[(unsigned int)pFaces + 72]]; | |
1455 if ( *(short *)(v31 + 26) ) | |
1456 { | |
1457 if ( ((BLVFaceExtra *)v31)->HasEventint() ) | |
1458 pDest[(unsigned int)pFaces + 46] |= 0x10u; | |
1459 else | |
1460 pDest[(unsigned int)pFaces + 46] &= 0xEFu; | |
1461 } | |
1462 ++Argsd; | |
1463 pDest += 96; | |
1464 } | |
1465 while ( Argsd < (signed int)uNumFaces ); | |
1466 } | |
1467 fseek(v7, v213, 0); | |
1468 fread(&uNumSectors, 4u, 1u, v7); | |
1469 fseek(v7, v214, 0); | |
1470 fread(pSectors, 0x74u, uNumSectors, v7); | |
1471 v32 = pAllocator->AllocNamedChunk(ptr_0002B0_sector_rdata, blv.uSector_rdata_Size, "L.RData"); | |
1472 v202 = (int)v7; | |
1473 ptr_0002B0_sector_rdata = (unsigned __int16 *)v32; | |
1474 fread(v32, 1u, blv.uSector_rdata_Size, (FILE *)v202); | |
1475 v11 = uNumSectors == 0; | |
1476 v12 = uNumSectors < 0; | |
1477 pDest = 0; | |
1478 Argse = 0; | |
1479 if ( !(v12 | v11) ) | |
1480 { | |
1481 v33 = 0; | |
1482 do | |
1483 { | |
1484 pSectors[v33].pFloors = (unsigned __int16 *)&pDest[(unsigned int)ptr_0002B0_sector_rdata]; | |
1485 i = (size_t)&pSectors[v33]; | |
1486 v34 = ptr_0002B0_sector_rdata; | |
1487 pDest += 2 * *(short *)(i + 4); | |
1488 *(int *)(i + 16) = (int)(char *)v34 + (int)pDest; | |
1489 v35 = (size_t)&pSectors[v33]; | |
1490 i = v35; | |
1491 v36 = &pDest[2 * *(short *)(v35 + 12)]; | |
1492 v37 = (int)&v36[(unsigned int)ptr_0002B0_sector_rdata]; | |
1493 pDest = v36; | |
1494 *(int *)(i + 24) = v37; | |
1495 v38 = (size_t)&pSectors[v33]; | |
1496 i = v38; | |
1497 v39 = &pDest[2 * *(short *)(v38 + 20)]; | |
1498 v40 = (int)&v39[(unsigned int)ptr_0002B0_sector_rdata]; | |
1499 pDest = v39; | |
1500 *(int *)(i + 32) = v40; | |
1501 i = (size_t)&pSectors[v33]; | |
1502 v41 = ptr_0002B0_sector_rdata; | |
1503 pDest += 2 * *(short *)(i + 28); | |
1504 *(int *)(i + 40) = (int)(char *)v41 + (int)pDest; | |
1505 i = (size_t)&pSectors[v33]; | |
1506 v42 = ptr_0002B0_sector_rdata; | |
1507 pDest += 2 * *(short *)(i + 36); | |
1508 *(int *)(i + 48) = (int)(char *)v42 + (int)pDest; | |
1509 i = (size_t)&pSectors[v33]; | |
1510 v43 = ptr_0002B0_sector_rdata; | |
1511 pDest += 2 * *(short *)(i + 44); | |
1512 *(int *)(i + 64) = (int)(char *)v43 + (int)pDest; | |
1513 i = (size_t)&pSectors[v33]; | |
1514 v44 = ptr_0002B0_sector_rdata; | |
1515 pDest += 2 * *(short *)(i + 60); | |
1516 *(int *)(i + 72) = (int)(char *)v44 + (int)pDest; | |
1517 v45 = (size_t)&pSectors[v33]; | |
1518 ++v33; | |
1519 i = v45; | |
1520 v46 = ptr_0002B0_sector_rdata; | |
1521 pDest += 2 * *(short *)(v45 + 68); | |
1522 ++Argse; | |
1523 *(int *)(v45 + 80) = (int)(char *)v46 + (int)pDest; | |
1524 pDest += 2 * *((short *)&pSectors[v33] - 20); | |
1525 } | |
1526 while ( Argse < uNumSectors ); | |
1527 } | |
1528 v47 = pAllocator->AllocNamedChunk( | |
1529 ptr_0002B8_sector_lrdata, | |
1530 blv.uSector_lrdata_Size, | |
1531 "L.RLData"); | |
1532 v202 = (int)v7; | |
1533 ptr_0002B8_sector_lrdata = (unsigned __int16 *)v47; | |
1534 fread(v47, 1u, blv.uSector_lrdata_Size, (FILE *)v202); | |
1535 v11 = uNumSectors == 0; | |
1536 v12 = uNumSectors < 0; | |
1537 pDest = 0; | |
1538 Argsf = 0; | |
1539 if ( !(v12 | v11) ) | |
1540 { | |
1541 v48 = pSectors; | |
1542 v49 = 0; | |
1543 for ( i = 0; ; v49 = i ) | |
1544 { | |
1545 v50 = ptr_0002B8_sector_lrdata; | |
1546 i += 116; | |
1547 ++Argsf; | |
1548 *(BLVLightMM7 **)((char *)&v48->pLights + v49) = (BLVLightMM7 *)((char *)v50 + (int)pDest); | |
1549 v48 = pSectors; | |
1550 pDest += 2 * *(__int16 *)((char *)&v48->uNumLights + v49); | |
1551 if ( Argsf >= uNumSectors ) | |
1552 break; | |
1553 } | |
1554 } | |
1555 fseek(v7, v215, 0); | |
1556 fread(&uNumDoors, 4u, 1u, v7); | |
1557 fseek(v7, v216, 0); | |
1558 fread(pDoors, 0x50u, 0xC8u, v7); | |
1559 v51 = pAllocator->AllocNamedChunk(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData"); | |
1560 v202 = (int)v7; | |
1561 ptr_0002B4_doors_ddata = (unsigned __int16 *)v51; | |
1562 fread(v51, 1u, blv.uDoors_ddata_Size, (FILE *)v202); | |
1563 v11 = uNumDoors == 0; | |
1564 v12 = uNumDoors < 0; | |
1565 pDest = 0; | |
1566 Argsg = 0; | |
1567 if ( !(v12 | v11) ) | |
1568 { | |
1569 v52 = 0; | |
1570 do | |
1571 { | |
1572 pDoors[v52].pVertexIDs = (unsigned __int16 *)&pDest[(unsigned int)ptr_0002B4_doors_ddata]; | |
1573 i = (size_t)&pDoors[v52]; | |
1574 v53 = ptr_0002B4_doors_ddata; | |
1575 pDest += 2 * *(short *)(i + 68); | |
1576 *(int *)(i + 40) = (int)(char *)v53 + (int)pDest; | |
1577 v54 = (size_t)&pDoors[v52]; | |
1578 i = v54; | |
1579 v55 = &pDest[2 * *(short *)(v54 + 70)]; | |
1580 v56 = (int)&v55[(unsigned int)ptr_0002B4_doors_ddata]; | |
1581 pDest = v55; | |
1582 *(int *)(i + 44) = v56; | |
1583 v57 = (size_t)&pDoors[v52]; | |
1584 i = v57; | |
1585 v58 = &pDest[2 * *(short *)(v57 + 72)]; | |
1586 v59 = (int)&v58[(unsigned int)ptr_0002B4_doors_ddata]; | |
1587 pDest = v58; | |
1588 *(int *)(i + 48) = v59; | |
1589 i = (size_t)&pDoors[v52]; | |
1590 v60 = ptr_0002B4_doors_ddata; | |
1591 pDest += 2 * *(short *)(i + 70); | |
1592 *(int *)(i + 52) = (int)(char *)v60 + (int)pDest; | |
1593 i = (size_t)&pDoors[v52]; | |
1594 v61 = ptr_0002B4_doors_ddata; | |
1595 pDest += 2 * *(short *)(i + 70); | |
1596 *(int *)(i + 56) = (int)(char *)v61 + (int)pDest; | |
1597 i = (size_t)&pDoors[v52]; | |
1598 v62 = ptr_0002B4_doors_ddata; | |
1599 pDest += 2 * *(short *)(i + 74); | |
1600 *(int *)(i + 60) = (int)(char *)v62 + (int)pDest; | |
1601 i = (size_t)&pDoors[v52]; | |
1602 v63 = ptr_0002B4_doors_ddata; | |
1603 pDest += 2 * *(short *)(i + 74); | |
1604 *(int *)(i + 64) = (int)(char *)v63 + (int)pDest; | |
1605 ++Argsg; | |
1606 v64 = pDoors[v52].uNumOffsets; | |
1607 ++v52; | |
1608 pDest += 2 * v64; | |
1609 } | |
1610 while ( Argsg < uNumDoors ); | |
1611 } | |
1612 Argsh = 0; | |
1613 if ( uNumDoors > 0 ) | |
1614 { | |
1615 v65 = pDoors; | |
1616 pDest = 0; | |
1617 do | |
1618 { | |
1619 i = 0; | |
1620 v66 = &pDest[(int)v65]; | |
1621 if ( *(short *)&pDest[(int)v65 + 70] > 0 ) | |
1622 { | |
1623 do | |
1624 { | |
1625 v67 = *((int *)v66 + 10); | |
1626 a3 = 2 * i; | |
1627 v68 = *(short *)(v67 + 2 * i); | |
1628 v69 = pFaces; | |
1629 ++i; | |
1630 v70 = (int)&pFaceExtras[v69[v68].uFaceExtraID]; | |
1631 v71 = *((int *)v66 + 12); | |
1632 v72 = a3; | |
1633 v238 = (char *)v70; | |
1634 *(short *)(a3 + v71) = *(short *)(v70 + 20); | |
1635 *(__int16 *)(*(char **)((char *)&pDoors->pDeltaVs + (unsigned int)pDest) + v72) = *((short *)v238 + 11); | |
1636 v65 = pDoors; | |
1637 v66 = &pDest[(int)v65]; | |
1638 } | |
1639 while ( (signed int)i < *(short *)&pDest[(int)v65 + 70] ); | |
1640 } | |
1641 ++Argsh; | |
1642 pDest += 80; | |
1643 } | |
1644 while ( Argsh < uNumDoors ); | |
1645 } | |
1646 fseek(v7, v217, 0); | |
1647 fread(&uNumLevelDecorations, 4u, 1u, v7); | |
1648 fseek(v7, v218, 0); | |
1649 fread(pLevelDecorations, 0x20u, uNumLevelDecorations, v7); | |
1650 Argsi = 0; | |
1651 if ( (signed int)uNumLevelDecorations > 0 ) | |
1652 { | |
1653 pDest = (char *)pLevelDecorations; | |
1654 do | |
1655 { | |
1656 fread(pName, 1u, 0x20u, v7); | |
1657 v73 = pDecorationList->GetDecorIdByName(pName); | |
1658 v74 = pDest; | |
1659 ++Argsi; | |
1660 pDest += 32; | |
1661 *(short *)v74 = v73; | |
1662 } | |
1663 while ( Argsi < (signed int)uNumLevelDecorations ); | |
1664 } | |
1665 fseek(v7, v219, 0); | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
1666 fread(&uNumSpriteObjects, 4u, 1u, v7); |
0 | 1667 fseek(v7, v220, 0); |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
1668 fread(pSpriteObjects, 0x70u, uNumSpriteObjects, v7); |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
1669 if ( (signed int)uNumSpriteObjects > 0 ) |
0 | 1670 { |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
1671 v75 = pSpriteObjects; |
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
1672 pDest = (char *)uNumSpriteObjects; |
0 | 1673 do |
1674 { | |
1675 Argsj = 0; | |
1676 v76 = 48 * v75->stru_24.uItemID; | |
1677 v11 = pObjectList->uNumObjects == 0; | |
1678 v12 = (pObjectList->uNumObjects & 0x80000000u) != 0; | |
1679 LOWORD(v76) = *(unsigned __int16 *)((char *)&pItemsTable->pItems[0].uSpriteID + v76); | |
1680 i = v76; | |
1681 v75->uItemType = v76; | |
1682 if ( v12 | v11 ) | |
1683 { | |
1684 LABEL_50: | |
1685 v78 = 0; | |
1686 } | |
1687 else | |
1688 { | |
1689 for ( j = (int)&pObjectList->pObjects->uObjectID; (short)v76 != *(short *)j; j = a3 ) | |
1690 { | |
1691 ++Argsj; | |
1692 a3 = j + 56; | |
1693 if ( Argsj >= (signed int)pObjectList->uNumObjects ) | |
1694 goto LABEL_50; | |
1695 LOWORD(v76) = i; | |
1696 } | |
1697 v78 = Argsj; | |
1698 } | |
1699 v75->uObjectDescID = v78; | |
1700 ++v75; | |
1701 --pDest; | |
1702 } | |
1703 while ( pDest ); | |
1704 } | |
1705 fseek(v7, v221, 0); | |
1706 fread(&uNumActors, 4u, 1u, v7); | |
1707 fseek(v7, v222, 0); | |
1708 fread(pActors, 0x344u, uNumActors, v7); | |
1709 fseek(v7, v228, 0); | |
1710 fread(&uNumChests, 4u, 1u, v7); | |
1711 fseek(v7, v229, 0); | |
1712 fread(pChests, 0x14CCu, uNumChests, v7); | |
1713 fseek(v7, v224, 0); | |
1714 fread(&uNumLights, 4u, 1u, v7); | |
1715 fseek(v7, v225, 0); | |
1716 fread(pLights, 0x10u, uNumLights, v7); | |
1717 fseek(v7, v226, 0); | |
1718 fread(&uNumNodes, 4u, 1u, v7); | |
1719 fseek(v7, v227, 0); | |
1720 fread(pNodes, 8u, uNumNodes, v7); | |
1721 fseek(v7, v230, 0); | |
1722 fread(&uNumSpawnPoints, 4u, 1u, v7); | |
1723 v79 = pAllocator->AllocNamedChunk(pSpawnPoints, 24 * uNumSpawnPoints, "Spawn"); | |
1724 v202 = 0; | |
1725 pSpawnPoints = (SpawnPointMM7 *)v79; | |
1726 fseek(v7, v231, v202); | |
1727 fread(pSpawnPoints, 0x18u, uNumSpawnPoints, v7); | |
1728 fseek(v7, v232, 0); | |
1729 fread(&dlv, 0x28u, 1u, v7); | |
1730 fseek(v7, v233, 0); | |
1731 fread(&stru_5E4C90, 1u, 0xC8u, v7); | |
1732 fseek(v7, v234, 0); | |
1733 fread(&uLastVisitDay, 1u, 0x38u, v7); | |
1734 fseek(v7, v223, 0); | |
1735 v80 = (void **)&pMapOutlines; | |
1736 fread(*v80, 4u, 1u, v7); | |
1737 fread((char *)*v80 + 4, 0xCu, *(int *)*v80, v7); | |
1738 fclose(v7); | |
1739 goto LABEL_179; | |
1740 } | |
1741 return 4; | |
1742 }*/ | |
1743 #pragma endregion | |
1744 | |
1745 if (bLoaded) | |
1746 { | |
1747 Log::Warning(L"BLV is already loaded"); | |
1748 return 3; | |
1749 } | |
1750 | |
1751 if ( !pGames_LOD->DoesContainerExist(pFilename) ) | |
1752 Abortf("Unable to find %s in Games.LOD", pFilename); | |
1753 | |
1754 //v238 = pFilename - 4; | |
1755 //v81 = strlen(pFilename); | |
1756 strcpy(this->pFilename, pFilename); | |
1757 strcpy(&pFilename[strlen(pFilename) - 4], ".blv"); | |
1758 File = pGames_LOD->FindContainer(pFilename, 1); | |
1759 //File = v82; | |
1760 | |
1761 Release(); | |
1762 if ( !Alloc() ) | |
1763 return 4; | |
1764 | |
1765 header.uVersion = 91969; | |
1766 header.pMagic[0] = 'm'; | |
1767 header.pMagic[1] = 'v'; | |
1768 header.pMagic[2] = 'i'; | |
1769 header.pMagic[3] = 'i'; | |
1770 header.uCompressedSize = 0; | |
1771 header.uDecompressedSize = 0; | |
1772 fread(&header, sizeof(ODMHeader), 1u, File); | |
1773 if (header.uVersion != 91969 || | |
1774 header.pMagic[0] != 'm' || | |
1775 header.pMagic[1] != 'v' || | |
1776 header.pMagic[2] != 'i' || | |
1777 header.pMagic[3] != 'i' ) | |
1778 { | |
1779 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:792", 0); | |
1780 } | |
1781 //v83 = header.uCompressedSize; | |
1782 //pSource = header.uDecompressedSize; | |
1783 //v84 = malloc(header.uDecompressedSize); | |
1784 //v85 = v84; | |
1785 //ptr = v84; | |
1786 auto pRawBLV = malloc(header.uDecompressedSize); | |
1787 memset(pRawBLV, 0, header.uDecompressedSize); | |
1788 | |
1789 if (header.uCompressedSize == header.uDecompressedSize) | |
1790 fread(pRawBLV, header.uDecompressedSize, 1, File); | |
1791 else if (header.uCompressedSize < header.uDecompressedSize) | |
1792 { | |
1793 auto pTmpMem = malloc(header.uCompressedSize); | |
1794 { | |
1795 fread(pTmpMem, header.uCompressedSize, 1, File); | |
1796 | |
1797 uint uDecompressedSize = header.uDecompressedSize; | |
1798 zlib::MemUnzip(pRawBLV, &uDecompressedSize, pTmpMem, header.uCompressedSize); | |
1799 | |
1800 if (uDecompressedSize != header.uDecompressedSize) | |
1801 Log::Warning(L"uDecompressedSize != header.uDecompressedSize in BLV"); | |
1802 } | |
1803 free(pTmpMem); | |
1804 } | |
1805 else | |
1806 { | |
1807 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:803", 0); | |
1808 return 0; | |
1809 } | |
1810 | |
1811 bLoaded = true; | |
1812 | |
1813 auto pData = (char *)pRawBLV; | |
1814 | |
1815 pGameLoadingUI_ProgressBar->Progress(); | |
1816 | |
1817 memcpy(&blv, pData, 136); | |
1818 memcpy(&uNumVertices, pData += 136, 4); | |
1819 memcpy(pVertices, pData += 4, uNumVertices * sizeof(Vec3_short_)); | |
1820 | |
1821 pGameLoadingUI_ProgressBar->Progress(); | |
1822 | |
1823 memcpy(&uNumFaces, pData += uNumVertices * sizeof(Vec3_short_), 4); | |
1824 | |
1825 pGameLoadingUI_ProgressBar->Progress(); | |
1826 | |
1827 memcpy(pFaces, pData += 4, uNumFaces * sizeof (BLVFace)); | |
1006 | 1828 pLFaces = (unsigned __int16 *)pAllocator->AllocNamedChunk(pLFaces, blv.uFaces_fdata_Size, "L.FData"); |
1829 | |
1830 memcpy(pLFaces, pData += uNumFaces * sizeof (BLVFace), blv.uFaces_fdata_Size); | |
0 | 1831 |
1832 for (uint i = 0, j = 0; i < uNumFaces; ++i) | |
1833 { | |
1834 auto pFace = pFaces + i; | |
1835 | |
1006 | 1836 pFace->pVertexIDs = pLFaces + j; |
0 | 1837 |
1838 j += pFace->uNumVertices + 1; | |
1006 | 1839 pFace->pXInterceptDisplacements = (short *)(pLFaces + j); |
0 | 1840 |
1841 j += pFace->uNumVertices + 1; | |
1006 | 1842 pFace->pYInterceptDisplacements = (short *)(pLFaces + j); |
0 | 1843 |
1844 j += pFace->uNumVertices + 1; | |
1006 | 1845 pFace->pZInterceptDisplacements = (short *)(pLFaces + j); |
0 | 1846 |
1847 j += pFace->uNumVertices + 1; | |
1006 | 1848 pFace->pVertexUIDs = (__int16 *)(pLFaces + j); |
0 | 1849 |
1850 j += pFace->uNumVertices + 1; | |
1006 | 1851 pFace->pVertexVIDs = (__int16 *)(pLFaces + j); |
0 | 1852 |
1853 j += pFace->uNumVertices + 1; | |
1854 /*v93 = &pFaces[v92]; | |
1855 Src = v93; | |
1856 v94 = (BLVSector *)((char *)v244 + 2 * v93->uNumVertices + 2); | |
1857 v95 = (unsigned __int16 *)((char *)v94 + (unsigned int)ptr_2AC); | |
1858 v244 = v94; | |
1859 Src->pXInterceptDisplacements = v95; | |
1860 v96 = (int)&pFaces[v92]; | |
1861 Src = (BLVFace *)v96; | |
1862 v97 = (BLVSector *)((char *)v244 + 2 * *(char *)(v96 + 93) + 2); | |
1863 v98 = (unsigned __int16 *)((char *)v97 + (unsigned int)ptr_2AC); | |
1864 v244 = v97; | |
1865 Src->pYInterceptDisplacements = v98; | |
1866 Src = &pFaces[v92]; | |
1867 v99 = ptr_2AC; | |
1868 v244 = (BLVSector *)((char *)v244 + 2 * Src->uNumVertices + 2); | |
1869 Src->pZInterceptDisplacements = (unsigned __int16 *)((char *)v99 + (int)v244); | |
1870 Src = &pFaces[v92]; | |
1871 v100 = ptr_2AC; | |
1872 v244 = (BLVSector *)((char *)v244 + 2 * Src->uNumVertices + 2); | |
1873 Src->pVertexUIDs = (unsigned __int16 *)((char *)v100 + (int)v244); | |
1874 Src = &pFaces[v92]; | |
1875 ++v92; | |
1876 v101 = ptr_2AC; | |
1877 v244 = (BLVSector *)((char *)v244 + 2 * Src->uNumVertices + 2); | |
1878 ++v245; | |
1879 Src->pVertexVIDs = (unsigned __int16 *)((char *)v101 + (int)v244); | |
1880 v244 = (BLVSector *)((char *)v244 + 2 * *((char *)&pFaces[v92] - 3) + 2);*/ | |
1881 } | |
1882 | |
1883 pGameLoadingUI_ProgressBar->Progress(); | |
1884 | |
1885 pData += blv.uFaces_fdata_Size; | |
1886 | |
1887 for (uint i = 0; i < uNumFaces; ++i) | |
1888 { | |
1889 auto pFace = pFaces + i; | |
1890 | |
1891 char pTexName[16]; | |
1892 strncpy(pTexName, pData, 10); | |
1893 pData += 10; | |
1894 | |
1895 if (pFace->uAttributes & 0x4000) | |
1896 { | |
1897 pFace->uBitmapID = pTextureFrameTable->FindTextureByName(pTexName); | |
1898 if (pFace->uBitmapID) | |
1899 pTextureFrameTable->LoadAnimationSequenceAndPalettes(pFace->uBitmapID); | |
1900 else | |
1901 { | |
1902 pFace->uBitmapID = pBitmaps_LOD->LoadTexture(pTexName); | |
1903 pFace->uAttributes &= ~0x4000; | |
1904 } | |
1905 } | |
1906 else | |
1907 pFace->uBitmapID = pBitmaps_LOD->LoadTexture(pTexName); | |
1908 } | |
1909 | |
1910 pGameLoadingUI_ProgressBar->Progress(); | |
1911 | |
1912 memcpy(&uNumFaceExtras, pData, 4u); | |
1913 memcpy(pFaceExtras, pData += 4, uNumFaceExtras * sizeof(BLVFaceExtra)); | |
1914 pData += uNumFaceExtras * sizeof(BLVFaceExtra); | |
1915 | |
1916 pGameLoadingUI_ProgressBar->Progress(); | |
1917 | |
1918 //v108 = (char *)v107 + 36 * uNumFaceExtras; | |
1919 //v245 = 0; | |
1920 //*(int *)((char *)&uSourceLen + 1) = 0; | |
1921 for (uint i = 0; i < uNumFaceExtras; ++i) | |
1922 { | |
1923 char pTexName[32]; | |
1924 strncpy(pTexName, pData, 10); | |
1925 pData += 10; | |
1926 | |
1927 if (!strcmp(pTexName, "")) | |
1928 pFaceExtras[i].uAdditionalBitmapID = -1; | |
1929 else | |
1930 pFaceExtras[i].uAdditionalBitmapID = pBitmaps_LOD->LoadTexture(pTexName); | |
1931 } | |
1932 | |
1933 | |
1934 for (uint i = 0; i < uNumFaces; ++i) | |
1935 { | |
1936 auto pFace = pFaces + i; | |
1937 auto pFaceExtra = pFaceExtras + pFace->uFaceExtraID; | |
1938 | |
1939 if (pFaceExtra->uEventID) | |
1940 { | |
1941 if (pFaceExtra->HasEventint()) | |
1942 pFace->uAttributes |= 0x100000; | |
1943 else | |
1944 pFace->uAttributes &= ~0x100000; | |
1945 } | |
1946 } | |
1947 | |
1948 pGameLoadingUI_ProgressBar->Progress(); | |
1949 | |
1950 memcpy(&uNumSectors, pData, 4); | |
1951 memcpy(pSectors, pData + 4, uNumSectors * sizeof(BLVSector)); | |
1952 pData += 4 + uNumSectors * sizeof(BLVSector); | |
1953 | |
1954 pGameLoadingUI_ProgressBar->Progress(); | |
1955 | |
1956 ptr_0002B0_sector_rdata = (unsigned short *)pAllocator->AllocNamedChunk(ptr_0002B0_sector_rdata, blv.uSector_rdata_Size, "L.RData"); | |
1957 memcpy(ptr_0002B0_sector_rdata, pData, blv.uSector_rdata_Size); | |
1958 pData += blv.uSector_rdata_Size; | |
1959 | |
1960 for (uint i = 0, j = 0; i < uNumSectors; ++i) | |
1961 { | |
1962 auto pSector = pSectors + i; | |
1963 | |
1964 pSector->pFloors = ptr_0002B0_sector_rdata + j; | |
1965 j += pSector->uNumFloors; | |
1966 | |
1967 pSector->pWalls = ptr_0002B0_sector_rdata + j; | |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
1968 j += pSector->uNumWalls; |
0 | 1969 |
1970 pSector->pCeilings = ptr_0002B0_sector_rdata + j; | |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
1971 j += pSector->uNumCeilings; |
0 | 1972 |
1973 pSector->pFluids = ptr_0002B0_sector_rdata + j; | |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
1974 j += pSector->uNumFluids; |
0 | 1975 |
1976 pSector->pPortals = ptr_0002B0_sector_rdata + j; | |
1977 j += pSector->uNumPortals; | |
1978 | |
1979 pSector->pFaceIDs = ptr_0002B0_sector_rdata + j; | |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
1980 j += pSector->uNumFaces; |
0 | 1981 |
1982 pSector->pCogs = ptr_0002B0_sector_rdata + j; | |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
1983 j += pSector->uNumCogs; |
0 | 1984 |
1985 pSector->pDecorationIDs = ptr_0002B0_sector_rdata + j; | |
1986 j += pSector->uNumDecorations; | |
1987 | |
1988 pSector->pMarkers = ptr_0002B0_sector_rdata + j; | |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
1989 j += pSector->uNumMarkers; |
0 | 1990 |
1991 | |
1992 //do | |
1993 //{ | |
1994 /*pSectors[v118].pFloors = (unsigned __int16 *)((char *)Src + (unsigned int)ptr_0002B0_sector_rdata); | |
1995 v244 = &pSectors[v118]; | |
1996 v119 = ptr_0002B0_sector_rdata; | |
1997 Src = (BLVFace *)((char *)Src + 2 * v244->field_4); | |
1998 v244->pWalls = (unsigned __int16 *)((char *)v119 + (int)Src); | |
1999 v120 = (int)&pSectors[v118]; | |
2000 v244 = (BLVSector *)v120; | |
2001 v121 = (BLVFace *)((char *)Src + 2 * *(short *)(v120 + 12)); | |
2002 v122 = (unsigned __int16 *)((char *)v121 + (unsigned int)ptr_0002B0_sector_rdata); | |
2003 Src = v121; | |
2004 v244->pCeilings = v122; | |
2005 v123 = (int)&pSectors[v118]; | |
2006 v244 = (BLVSector *)v123; | |
2007 v124 = (BLVFace *)((char *)Src + 2 * *(short *)(v123 + 20)); | |
2008 v125 = (unsigned __int16 *)((char *)v124 + (unsigned int)ptr_0002B0_sector_rdata); | |
2009 Src = v124; | |
2010 v244->pFluids = v125; | |
2011 v244 = &pSectors[v118]; | |
2012 v126 = ptr_0002B0_sector_rdata; | |
2013 Src = (BLVFace *)((char *)Src + 2 * v244->field_1C); | |
2014 v244->pPortals = (unsigned __int16 *)((char *)v126 + (int)Src); | |
2015 v244 = &pSectors[v118]; | |
2016 v127 = ptr_0002B0_sector_rdata; | |
2017 Src = (BLVFace *)((char *)Src + 2 * v244->uNumPortals); | |
2018 v244->pFaceIDs = (unsigned __int16 *)((char *)v127 + (int)Src); | |
2019 v244 = &pSectors[v118]; | |
2020 v128 = ptr_0002B0_sector_rdata; | |
2021 Src = (BLVFace *)((char *)Src + 2 * v244->field_2C); | |
2022 v244->pCogs = (unsigned __int16 *)((char *)v128 + (int)Src); | |
2023 v244 = &pSectors[v118]; | |
2024 v129 = ptr_0002B0_sector_rdata; | |
2025 Src = (BLVFace *)((char *)Src + 2 * v244->field_3C); | |
2026 v244->pDecorationIDs = (unsigned __int16 *)((char *)v129 + (int)Src); | |
2027 v130 = (int)&pSectors[v118]; | |
2028 ++v118; | |
2029 v244 = (BLVSector *)v130; | |
2030 v131 = ptr_0002B0_sector_rdata; | |
2031 Src = (BLVFace *)((char *)Src + 2 * *(short *)(v130 + 68)); | |
2032 ++v245; | |
2033 *(int *)(v130 + 80) = (int)(char *)v131 + (int)Src; | |
2034 Src = (BLVFace *)((char *)Src + 2 * *((short *)&pSectors[v118] - 20));*/ | |
2035 //} | |
2036 //while ( v245 < uNumSectors ); | |
2037 } | |
2038 | |
2039 ptr_0002B8_sector_lrdata = (unsigned __int16 *)pAllocator->AllocNamedChunk(ptr_0002B8_sector_lrdata, blv.uSector_lrdata_Size, "L.RLData"); | |
2040 memcpy(ptr_0002B8_sector_lrdata, pData, blv.uSector_lrdata_Size); | |
2041 pData += blv.uSector_lrdata_Size; | |
2042 | |
2043 pGameLoadingUI_ProgressBar->Progress(); | |
2044 | |
2045 for (uint i = 0, j = 0; i < uNumSectors; ++i) | |
2046 { | |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
2047 pSectors[i].pLights = ptr_0002B8_sector_lrdata + j; |
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
2048 j += pSectors[i].uNumLights; |
0 | 2049 } |
2050 | |
2051 pGameLoadingUI_ProgressBar->Progress(); | |
2052 | |
2053 memcpy(&uNumDoors, pData, 4); | |
2054 pData += 4; | |
2055 | |
2056 pGameLoadingUI_ProgressBar->Progress(); | |
2057 pGameLoadingUI_ProgressBar->Progress(); | |
2058 | |
2059 memcpy(&uNumLevelDecorations, pData, 4); | |
1202 | 2060 memcpy(pLevelDecorations.data(), pData + 4, uNumLevelDecorations * sizeof(LevelDecoration)); |
0 | 2061 pData += 4 + uNumLevelDecorations * sizeof(LevelDecoration); |
2062 | |
2063 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
2064 { | |
2065 pLevelDecorations[i].uDecorationDescID = pDecorationList->GetDecorIdByName(pData); | |
2066 | |
2067 pData += 32; | |
2068 } | |
2069 | |
2070 pGameLoadingUI_ProgressBar->Progress(); | |
2071 | |
2072 memcpy(&uNumLights, pData, 4); | |
2073 memcpy(pLights, pData + 4, uNumLights * sizeof(BLVLightMM7)); | |
2074 pData += 4 + uNumLights * sizeof(BLVLightMM7); | |
2075 | |
2076 pGameLoadingUI_ProgressBar->Progress(); | |
2077 pGameLoadingUI_ProgressBar->Progress(); | |
2078 | |
2079 memcpy(&uNumNodes, pData, 4); | |
2080 memcpy(pNodes, pData + 4, uNumNodes * sizeof(BSPNode)); | |
2081 pData += 4 + uNumNodes * sizeof(BSPNode); | |
2082 | |
2083 pGameLoadingUI_ProgressBar->Progress(); | |
2084 pGameLoadingUI_ProgressBar->Progress(); | |
2085 | |
2086 memcpy(&uNumSpawnPoints, pData, 4); | |
2087 pSpawnPoints = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(pSpawnPoints, uNumSpawnPoints * sizeof(SpawnPointMM7), "Spawn"); | |
2088 memcpy(pSpawnPoints, pData + 4, uNumSpawnPoints * sizeof(SpawnPointMM7)); | |
2089 pData += 4 + uNumSpawnPoints * sizeof(SpawnPointMM7); | |
2090 | |
2091 pGameLoadingUI_ProgressBar->Progress(); | |
2092 pGameLoadingUI_ProgressBar->Progress(); | |
2093 | |
2094 //v201 = (const char *)v148; | |
2095 //v200 = (size_t)pMapOutlines; | |
2096 memcpy(&pMapOutlines->uNumOutlines, pData, 4); | |
2097 memcpy(pMapOutlines->pOutlines, pData + 4, pMapOutlines->uNumOutlines * sizeof(BLVMapOutline)); | |
2098 //v149 = pMapOutlines; | |
2099 //v199 = 12 * *v149; | |
2100 //memcpy(v149 + 1, (const void *)(v148 + 4), v199); | |
2101 free(pRawBLV); | |
2102 pRawBLV = nullptr; | |
2103 | |
2104 void *pRawDLV = nullptr; | |
2105 strcpy(&pFilename[strlen(pFilename) - 4], ".dlv"); | |
2106 File = pNew_LOD->FindContainer(pFilename, 1); | |
2107 fread(&header, 0x10u, 1u, File);//(FILE *)v245); | |
2108 bool _v244 = false; | |
2109 if (header.uVersion != 91969 || | |
2110 header.pMagic[0] != 'm' || | |
2111 header.pMagic[1] != 'v' || | |
2112 header.pMagic[2] != 'i' || | |
2113 header.pMagic[3] != 'i' ) | |
2114 { | |
2115 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:1090", 0); | |
2116 _v244 = true; | |
2117 } | |
2118 else | |
2119 { | |
2120 pRawDLV = malloc(header.uDecompressedSize); | |
2121 if (header.uCompressedSize == header.uDecompressedSize) | |
2122 fread(pRawDLV, 1, header.uCompressedSize, File); | |
2123 else if (header.uCompressedSize < header.uDecompressedSize) | |
2124 { | |
2125 auto pTmpMem = malloc(header.uCompressedSize); | |
2126 { | |
2127 fread(pTmpMem, header.uCompressedSize, 1, File); | |
2128 | |
2129 uint uDecompressedSize = header.uDecompressedSize; | |
2130 zlib::MemUnzip(pRawDLV, &uDecompressedSize, pTmpMem, header.uCompressedSize); | |
2131 | |
2132 if (uDecompressedSize != header.uDecompressedSize) | |
2133 Log::Warning(L"uDecompressedSize != header.uDecompressedSize in DLV"); | |
2134 } | |
2135 free(pTmpMem); | |
2136 } | |
2137 else | |
2138 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:1108", 0); | |
2139 | |
2140 pData = (char *)pRawDLV; | |
2141 } | |
2142 | |
2143 memcpy(&dlv, pData, 40); | |
2144 pData += 40; | |
2145 | |
2146 //v152 = dlv.uNumFacesInBModels; | |
2147 if (dlv.uNumFacesInBModels) | |
2148 { | |
2149 //v153 = dlv.uNumDecorations; | |
2150 if (dlv.uNumDecorations) | |
2151 { | |
2152 if (dlv.uNumFacesInBModels != uNumFaces || | |
2153 dlv.uNumDecorations != uNumLevelDecorations) | |
2154 _v244 = true; | |
2155 } | |
2156 } | |
2157 | |
2158 if (dword_6BE364_game_settings_1 & 0x2000 ) | |
2159 _i = 29030400; | |
2160 bool _a = false; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
2161 if ( a3 - dlv.uLastRepawnDay >= _i && _stricmp(pCurrentMapName.data(), "d29.dlv") ) |
0 | 2162 _a = true; |
2163 | |
2164 //v154 = 875; | |
2165 if (_v244) | |
2166 { | |
2167 memset(v203, 0, 0x36B); | |
2168 goto LABEL_132; | |
2169 } | |
2170 if (_a || !dlv.uLastRepawnDay ) | |
2171 { | |
2172 memcpy(v203, pData, 0x36B); | |
2173 LABEL_132: | |
435 | 2174 free(pRawDLV); |
0 | 2175 dlv.uLastRepawnDay = a3; |
2176 if (_v244) | |
2177 ++dlv.uNumRespawns; | |
2178 //v201 = pFilename; | |
2179 *(int *)pDest = 1; | |
2180 File = pGames_LOD->FindContainer(pFilename, 0); | |
2181 fread(&header, 0x10u, 1u, File); | |
2182 auto v155 = header.uCompressedSize; | |
2183 auto Count = header.uDecompressedSize; | |
2184 auto Src = (BLVFace *)malloc(header.uDecompressedSize); | |
435 | 2185 pRawDLV = Src; |
0 | 2186 if ( v155 <= Count ) |
2187 { | |
2188 if ( v155 == Count ) | |
2189 { | |
2190 fread(Src, 1u, Count, File); | |
2191 } | |
2192 else | |
2193 { | |
2194 auto _uSourceLen = malloc(v155); | |
2195 fread(_uSourceLen, v155, 1u, File); | |
2196 zlib::MemUnzip(Src, &Count, _uSourceLen, v155); | |
2197 free(_uSourceLen); | |
2198 } | |
2199 } | |
2200 else | |
2201 { | |
2202 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Polydata.cpp:1195", 0); | |
2203 } | |
2204 pData = ((char *)Src + 40); | |
2205 //v154 = 875; | |
2206 goto LABEL_140; | |
2207 } | |
2208 *(int *)pDest = 0; | |
2209 LABEL_140: | |
2210 //v202 = (int)".blv"; | |
2211 //v156 = strlen(pFilename); | |
2212 strcpy(&pFilename[strlen(pFilename) - 4], ".blv"); | |
2213 memcpy(_visible_outlines, pData, 875); | |
2214 pData += 875; | |
2215 | |
2216 if ( *(int *)pDest ) | |
2217 memcpy(_visible_outlines, v203, 875); | |
2218 | |
2219 for (uint i = 0; i < pMapOutlines->uNumOutlines; ++i) | |
2220 { | |
2221 auto pVertex = pMapOutlines->pOutlines + i; | |
2222 if ((unsigned __int8)(1 << (7 - i % 8)) & _visible_outlines[i / 8]) | |
2223 pVertex->uFlags |= 1; | |
2224 } | |
2225 | |
2226 | |
2227 for (uint i = 0; i < uNumFaces; ++i) | |
2228 { | |
2229 auto pFace = pFaces + i; | |
2230 auto pFaceExtra = pFaceExtras + pFace->uFaceExtraID; | |
2231 | |
2232 memcpy(&pFace->uAttributes, pData, 4); | |
2233 pData += 4; | |
2234 | |
2235 if (pFaceExtra->uEventID) | |
2236 { | |
2237 if (pFaceExtra->HasEventint()) | |
2238 pFace->uAttributes |= 0x100000; | |
2239 else | |
2240 pFace->uAttributes &= ~0x100000; | |
2241 } | |
2242 } | |
2243 | |
2244 pGameLoadingUI_ProgressBar->Progress(); | |
2245 | |
2246 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
2247 { | |
2248 memcpy(&pLevelDecorations[i].field_2, pData, 2); | |
2249 pData += 2; | |
2250 } | |
2251 | |
2252 pGameLoadingUI_ProgressBar->Progress(); | |
2253 | |
2254 memcpy(&uNumActors, pData, 4); | |
1202 | 2255 memcpy(pActors.data(), pData + 4, uNumActors * sizeof(Actor)); |
0 | 2256 pData += 4 + uNumActors * sizeof(Actor); |
2257 | |
2258 pGameLoadingUI_ProgressBar->Progress(); | |
2259 pGameLoadingUI_ProgressBar->Progress(); | |
2260 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2261 memcpy(&uNumSpriteObjects, pData, 4); |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
2262 memcpy(pSpriteObjects.data(), pData + 4, uNumSpriteObjects * sizeof(SpriteObject)); |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2263 pData += 4 + uNumSpriteObjects * sizeof(SpriteObject); |
0 | 2264 |
2265 pGameLoadingUI_ProgressBar->Progress(); | |
2266 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2267 for (uint i = 0; i < uNumSpriteObjects; ++i) |
0 | 2268 { |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
2269 auto pItem = &pSpriteObjects[i]; |
0 | 2270 |
2271 if (pItem->stru_24.uItemID && !(pItem->uAttributes & 0x0100)) | |
2272 { | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2273 pItem->uType = pItemsTable->pItems[pItem->stru_24.uItemID - 1].uSpriteID; |
0 | 2274 |
2275 uint uObjectID = 0; | |
2276 for (uint j = 0; j < pObjectList->uNumObjects; ++j) | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
2277 if (pItem->uType == pObjectList->pObjects[j].uObjectID) |
0 | 2278 { |
2279 pItem->uObjectDescID = j; | |
2280 break; | |
2281 } | |
2282 } | |
2283 } | |
2284 | |
2285 pGameLoadingUI_ProgressBar->Progress(); | |
2286 | |
2287 memcpy(&uNumChests, pData, 4); | |
1202 | 2288 memcpy(pChests.data(), pData + 4, uNumChests * sizeof(Chest)); |
0 | 2289 pData += 4 + uNumChests * sizeof(Chest); |
2290 | |
2291 pGameLoadingUI_ProgressBar->Progress(); | |
2292 pGameLoadingUI_ProgressBar->Progress(); | |
2293 | |
2294 memcpy(pDoors, pData, 0x3E80); | |
2295 pData += 0x3E80; | |
2296 | |
2297 //v201 = (const char *)blv.uDoors_ddata_Size; | |
2298 //v200 = (size_t)ptr_0002B4_doors_ddata; | |
2299 //v170 = pAllocator->AllocNamedChunk(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData"); | |
2300 //v171 = blv.uDoors_ddata_Size; | |
2301 ptr_0002B4_doors_ddata = (unsigned __int16 *)pAllocator->AllocNamedChunk(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData"); | |
2302 memcpy(ptr_0002B4_doors_ddata, pData, blv.uDoors_ddata_Size); | |
2303 pData += blv.uDoors_ddata_Size; | |
2304 | |
2305 //Src = (BLVFace *)((char *)Src + v171); | |
2306 //v172 = 0; | |
2307 //v245 = 0; | |
2308 //if (uNumDoors > 0) | |
2309 for (uint i = 0, j = 0; i < uNumDoors; ++i) | |
2310 { | |
2311 auto pDoor = pDoors + i; | |
2312 | |
2313 pDoor->pVertexIDs = ptr_0002B4_doors_ddata + j; | |
2314 j += pDoor->uNumVertices; | |
2315 | |
2316 pDoor->pFaceIDs = ptr_0002B4_doors_ddata + j; | |
2317 j += pDoor->uNumFaces; | |
2318 | |
2319 pDoor->pSectorIDs = ptr_0002B4_doors_ddata + j; | |
2320 j += pDoor->field_48; | |
2321 | |
2322 pDoor->pDeltaUs = (short *)(ptr_0002B4_doors_ddata + j); | |
2323 j += pDoor->uNumFaces; | |
2324 | |
2325 pDoor->pDeltaVs = (short *)(ptr_0002B4_doors_ddata + j); | |
2326 j += pDoor->uNumFaces; | |
2327 | |
2328 pDoor->pXOffsets = ptr_0002B4_doors_ddata + j; | |
2329 j += pDoor->uNumOffsets; | |
2330 | |
2331 pDoor->pYOffsets = ptr_0002B4_doors_ddata + j; | |
2332 j += pDoor->uNumOffsets; | |
2333 | |
2334 pDoor->pZOffsets = ptr_0002B4_doors_ddata + j; | |
2335 j += pDoor->uNumOffsets; | |
2336 /*v173 = pDoors; | |
2337 for ( k = 0; ; v172 = v188 + 2 * *((short *)&v173[k] - 3) ) | |
2338 { | |
2339 v173[k].pVertexIDs = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v172); | |
2340 v175 = &pDoors[k]; | |
2341 v176 = v172 + 2 * v175->uNumVertices; | |
2342 v175->pFaceIDs = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v176); | |
2343 v177 = &pDoors[k]; | |
2344 v178 = v176 + 2 * v177->uNumFaces; | |
2345 v177->pSectorIDs = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v178); | |
2346 v179 = &pDoors[k]; | |
2347 v180 = v178 + 2 * v179->field_48; | |
2348 v179->pDeltaUs = (__int16 *)((char *)ptr_0002B4_doors_ddata + v180); | |
2349 v181 = &pDoors[k]; | |
2350 v182 = v180 + 2 * v181->uNumFaces; | |
2351 v181->pDeltaVs = (__int16 *)((char *)ptr_0002B4_doors_ddata + v182); | |
2352 v183 = &pDoors[k]; | |
2353 v184 = v182 + 2 * v183->uNumFaces; | |
2354 v183->pXOffsets = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v184); | |
2355 v185 = &pDoors[k]; | |
2356 v186 = v184 + 2 * v185->uNumOffsets; | |
2357 v185->pYOffsets = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v186); | |
2358 v187 = &pDoors[k]; | |
2359 ++k; | |
2360 v188 = v186 + 2 * v187->uNumOffsets; | |
2361 v189 = (unsigned __int16 *)((char *)ptr_0002B4_doors_ddata + v188); | |
2362 ++v245; | |
2363 v187->pZOffsets = v189; | |
2364 v173 = pDoors; | |
2365 if ( v245 >= uNumDoors ) | |
2366 break; | |
2367 }*/ | |
2368 } | |
2369 //v190 = 0; | |
2370 //v245 = 0; | |
2371 for (uint i = 0; i < uNumDoors; ++i) | |
2372 { | |
2373 auto pDoor = pDoors + i; | |
2374 | |
2375 for (uint j = 0; j < pDoor->uNumFaces; ++j) | |
2376 { | |
2377 auto pFace = pFaces + pDoor->pFaceIDs[j]; | |
2378 auto pFaceExtra = pFaceExtras + pFace->uFaceExtraID; | |
2379 | |
2380 pDoor->pDeltaUs[j] = pFaceExtra->sTextureDeltaU; | |
2381 pDoor->pDeltaVs[j] = pFaceExtra->sTextureDeltaV; | |
2382 } | |
2383 //v191 = pDoors; | |
2384 //pDest = 0; | |
2385 //do | |
2386 // { | |
2387 /*Argsn = 0; | |
2388 for ( l = (BLVDoor *)&v190[(int)v191]; | |
2389 Argsn < *(short *)&v190[(int)v191 + 70]; | |
2390 l = (BLVDoor *)&v190[(int)v191] ) | |
2391 { | |
2392 v193 = Argsn; | |
2393 v194 = l->pFaceIDs[Argsn++]; | |
2394 v195 = &pFaceExtras[pFaces[v194].uFaceExtraID]; | |
2395 l->pDeltaUs[v193] = v195->sTextureDeltaU; | |
2396 v190 = pDest; | |
2397 *(short *)(v193 * 2 + *(int *)&pDest[(unsigned int)pDoors + 52]) = v195->sTextureDeltaV; | |
2398 v191 = pDoors; | |
2399 } | |
2400 ++v245; | |
2401 v190 += 80; | |
2402 pDest = v190;*/ | |
2403 //} | |
2404 //while ( v245 < uNumDoors ); | |
2405 } | |
2406 | |
2407 | |
2408 pGameLoadingUI_ProgressBar->Progress(); | |
2409 | |
2410 memcpy(&stru_5E4C90, pData, 0xC8); | |
2411 pData += 0xC8; | |
2412 | |
2413 pGameLoadingUI_ProgressBar->Progress(); | |
2414 | |
2415 memcpy(&stru1, pData, 0x38u); | |
2416 pData += 0x38; | |
2417 | |
2418 free(pRawDLV); | |
2419 //v5 = 0; | |
2420 | |
2421 pSoundList->LoadSound(64, 0); | |
2422 pSoundList->LoadSound(103, 0); | |
2423 pSoundList->LoadSound(63, 0); | |
2424 pSoundList->LoadSound(102, 0); | |
2425 pSoundList->LoadSound(50, 0); | |
2426 pSoundList->LoadSound(89, 0); | |
2427 | |
2428 return 0; | |
2429 } | |
2430 | |
2431 | |
2432 //----- (0049AC17) -------------------------------------------------------- | |
2433 int IndoorLocation::GetSector(int sX, int sY, int sZ) | |
2434 { | |
2435 int v4; // esi@1 | |
2436 //unsigned __int8 v5; // zf@1 | |
2437 //unsigned __int8 v6; // sf@1 | |
2438 //unsigned __int8 v7; // of@1 | |
2439 //BLVSector *v8; // eax@3 | |
2440 //int v9; // edi@9 | |
2441 //int v10; // eax@9 | |
2442 //int v11; // edx@9 | |
2443 //int v12; // eax@10 | |
2444 //unsigned __int16 v13; // ax@12 | |
2445 //int v14; // edi@14 | |
2446 //BLVFace *v15; // eax@14 | |
2447 //BLVFace *v16; // edi@14 | |
2448 //PolygonType v17; // al@14 | |
2449 //unsigned __int16 *pVertexIDs; // esi@16 | |
2450 //Vec3_short_ *v19; // eax@16 | |
2451 //int v20; // edx@16 | |
2452 //unsigned __int16 *v21; // esi@17 | |
2453 //int v22; // edi@19 | |
2454 //int v23; // edi@20 | |
2455 //Vec3_short_ *v24; // edx@20 | |
2456 signed int v25; // edx@21 | |
2457 int v26; // ebx@23 | |
2458 //int v27; // edx@26 | |
2459 //signed __int64 v28; // qtt@26 | |
2460 ///Vec3_short_ *v29; // eax@26 | |
2461 //Vec3_short_ *v30; // edx@26 | |
2462 //int v31; // edx@26 | |
791 | 2463 //signed int v32; // edi@27 |
0 | 2464 signed __int64 v33; // qtt@27 |
2465 //Vec3_short_ *v34; // edx@27 | |
791 | 2466 //int v35; // edx@32 |
0 | 2467 int v37; // edi@38 |
717 | 2468 int pSectorID; // ebx@40 |
0 | 2469 int v39; // eax@41 |
717 | 2470 BLVFace *pFace; // esi@42 |
2471 PolygonType pPolygonType; // dl@42 | |
0 | 2472 int v42; // edx@43 |
2473 int v43[50]; // [sp+Ch] [bp-108h]@1 | |
2474 //int v44; // [sp+D4h] [bp-40h]@9 | |
2475 //int v45; // [sp+D8h] [bp-3Ch]@14 | |
2476 //int v46; // [sp+DCh] [bp-38h]@14 | |
2477 //int v47; // [sp+E0h] [bp-34h]@19 | |
2478 //int v48; // [sp+E4h] [bp-30h]@9 | |
2479 //Vec3_short_ *v49; // [sp+E8h] [bp-2Ch]@19 | |
2480 bool v50; // [sp+ECh] [bp-28h]@19 | |
2481 int v51; // [sp+F0h] [bp-24h]@9 | |
2482 //unsigned int v52; // [sp+F4h] [bp-20h]@2 | |
2483 int v53; // [sp+F8h] [bp-1Ch]@10 | |
2484 int v54; // [sp+FCh] [bp-18h]@16 | |
2485 int v55; // [sp+100h] [bp-14h]@1 | |
2486 int v56; // [sp+104h] [bp-10h]@1 | |
2487 int v57; // [sp+108h] [bp-Ch]@16 | |
2488 //Vec3_short_ *v58; // [sp+10Ch] [bp-8h]@20 | |
2489 int v59; // [sp+110h] [bp-4h]@16 | |
2490 | |
2491 v4 = 0; | |
791 | 2492 v43[0] = 0; |
2493 | |
0 | 2494 v55 = 0; |
791 | 2495 |
0 | 2496 if (uNumSectors < 2) |
2497 return 0; | |
2498 | |
2499 for (uint i = 1; i < uNumSectors; ++i) | |
2500 { | |
2501 auto pSector = pSectors + i; | |
2502 | |
791 | 2503 if (pSector->pBounding.x1 > sX || pSector->pBounding.x2 < sX || |
2504 pSector->pBounding.y1 > sY || pSector->pBounding.y2 < sY || | |
2505 pSector->pBounding.z1 - 64 > sZ || pSector->pBounding.z2 + 64 < sZ) | |
2506 continue; | |
2507 | |
618
5cfb5dadf330
Margareth righ-click (addded constructor to NPCProfession) and cleaned BLV debug logs
Nomad
parents:
595
diff
changeset
|
2508 //Log::Warning(L"Sector[%u]", i); |
791 | 2509 v51 = pSector->uNumFloors + pSector->uNumPortals; |
2510 if (!v51) | |
2511 continue; | |
2512 | |
2513 | |
2514 for (uint j = 0; j < v51; ++j) | |
2515 { | |
2516 uint uFaceID; | |
2517 if (j < pSector->uNumFloors) | |
2518 uFaceID = pSector->pFloors[j]; | |
2519 else | |
2520 uFaceID = pSector->pPortals[j - pSector->uNumFloors]; | |
2521 | |
2522 auto pFace = pFaces + uFaceID; | |
2523 if (pFace->uPolygonType != POLYGON_Floor && | |
2524 pFace->uPolygonType != POLYGON_InBetweenFloorAndWall) | |
2525 continue; | |
2526 | |
2527 v54 = 0; | |
2528 v50 = pVertices[pFace->pVertexIDs[0]].y >= sY; | |
2529 | |
793 | 2530 for (uint k = 1; k <= pFace->uNumVertices; k++) |
791 | 2531 { |
2532 v59 = v50; | |
2533 | |
2534 if (v54 >= 2) | |
2535 break; | |
2536 | |
2537 auto v2 = &pVertices[pFace->pVertexIDs[k]]; | |
2538 v50 = v2->y >= sY; | |
2539 | |
793 | 2540 if (v59 == v50) |
791 | 2541 continue; |
2542 | |
2543 auto v1 = &pVertices[pFace->pVertexIDs[k - 1]]; | |
2544 v25 = v2->x >= sX ? 0 : 2; | |
2545 v26 = v25 | (v1->x < sX); | |
2546 | |
2547 if (v26 == 3) | |
2548 continue; | |
2549 | |
2550 if (!v26) | |
2551 ++v54; | |
2552 else | |
2553 { | |
2554 if (v1->x >= v2->x) | |
2555 { | |
2556 /*int _a58; | |
0 | 2557 int _a59; |
2558 | |
2559 v32 = v1->x - v2->x; | |
2560 LODWORD(v33) = v32 << 16; | |
791 | 2561 HIDWORD(v33) = v32 >> 16;*/ |
2562 //fixpoint_div(v1->x - v2->x, v1->y - v2->y); | |
2563 //_a58 = v33 / (v1->y - v2->y); | |
871 | 2564 //_a59 = fixpoint_sub0(_a58, sY - v2->y); |
791 | 2565 auto x_div_y = fixpoint_div(v1->x - v2->x, v1->y - v2->y); |
871 | 2566 auto res = fixpoint_sub0(x_div_y, sY - v2->y); // a / b * c - looks like projection |
793 | 2567 if (res + v2->x > sX) |
791 | 2568 ++v54; |
2569 } | |
2570 else | |
2571 { | |
2572 auto x_div_y = fixpoint_div(v2->x - v1->x, v2->y - v1->y); | |
871 | 2573 auto res = fixpoint_sub0(x_div_y, sY - v1->y); |
791 | 2574 |
2575 if (res + v1->x > sX) | |
2576 ++v54; | |
2577 | |
2578 /*int _a58; | |
0 | 2579 int _a59; |
791 | 2580 auto v32 = v2->x - v1->x; |
0 | 2581 LODWORD(v33) = v32 << 16; |
2582 HIDWORD(v33) = v32 >> 16; | |
2583 _a58 = v33 / (v2->y - v1->y); | |
871 | 2584 _a59 = fixpoint_sub0(_a58, sY - v1->y); |
0 | 2585 |
787 | 2586 if (_a59 + pVertices[k].x > sX) |
791 | 2587 ++v54;*/ |
0 | 2588 } |
717 | 2589 } |
791 | 2590 } |
2591 | |
2592 if (pFace->uNumVertices && v54 == 1) | |
2593 v43[v55++] = uFaceID; | |
2594 } | |
0 | 2595 } |
2596 | |
791 | 2597 v4 = v43[0]; |
0 | 2598 if ( v55 == 1 ) |
2599 return this->pFaces[v4].uSectorID; | |
2600 v37 = 0; | |
2601 if ( !v55 ) | |
2602 return 0; | |
717 | 2603 pSectorID = 0; |
0 | 2604 v53 = 0xFFFFFFu; |
2605 if ( v55 > 0 ) | |
2606 { | |
2607 v39 = sY; | |
2608 while ( 1 ) | |
2609 { | |
717 | 2610 pFace = &this->pFaces[v43[v37]]; |
2611 //pPolygonType = pFace->uPolygonType; | |
2612 if ( pFace->uPolygonType == POLYGON_Floor ) | |
0 | 2613 { |
717 | 2614 v42 = this->pVertices[*pFace->pVertexIDs].z; |
2615 v39 = sZ - v42; | |
2616 //goto LABEL_47; | |
2617 } | |
2618 if ( pFace->uPolygonType == POLYGON_InBetweenFloorAndWall ) | |
2619 { | |
2620 //v51 = pFace->zCalc1; | |
2621 v57 = (unsigned __int64)(pFace->zCalc1 * (signed __int64)(sX << 16)) >> 16; | |
2622 //v56 = sY << 16; | |
2623 //v51 = pFace->zCalc2; | |
2624 v56 = (unsigned __int64)(pFace->zCalc2 * (signed __int64)(sY << 16)) >> 16; | |
2625 v42 = (v56 + pFace->zCalc3 + v57 + 32768) >> 16; | |
662 | 2626 v39 = sZ - v42; |
0 | 2627 } |
717 | 2628 //LABEL_47: |
0 | 2629 if ( v39 >= 0 ) |
2630 { | |
2631 if ( v39 < v53 ) | |
2632 { | |
717 | 2633 pSectorID = pFace->uSectorID; |
0 | 2634 v53 = v39; |
2635 } | |
2636 } | |
2637 ++v37; | |
2638 if ( v37 >= v55 ) | |
717 | 2639 return pSectorID; |
0 | 2640 } |
2641 } | |
1113
39eaa6b00141
something to bool cast (performance warning) mostly fixed
Grumpy7
parents:
1104
diff
changeset
|
2642 return pSectorID; |
0 | 2643 } |
2644 // 49AC17: using guessed type int var_108[50]; | |
2645 | |
2646 | |
2647 //----- (00498A41) -------------------------------------------------------- | |
2648 char BLVFace::_get_normals(Vec3_int_ *a2, Vec3_int_ *a3) | |
2649 { | |
2650 BLVFace *v3; // ebx@1 | |
2651 int v4; // eax@1 | |
2652 signed __int64 v5; // qax@2 | |
2653 double v6; // st7@8 | |
2654 Vec3_float_ a1; // [sp+Ch] [bp-Ch]@8 | |
2655 | |
2656 v3 = this; | |
2657 LOBYTE(v4) = this->uPolygonType; | |
2658 if ( (char)v4 == POLYGON_VerticalWall ) | |
2659 { | |
2660 a2->x = -this->pFacePlane_old.vNormal.y; | |
2661 LODWORD(v5) = this->pFacePlane_old.vNormal.x; | |
2662 LABEL_9: | |
2663 a2->y = v5; | |
2664 v4 = 0; | |
2665 a2->z = 0; | |
2666 a3->y = 0; | |
2667 a3->z = 0xFFFF0000u; | |
2668 LABEL_11: | |
2669 a3->x = v4; | |
2670 goto LABEL_12; | |
2671 } | |
2672 if ( (char)v4 == POLYGON_Floor || (char)v4 == POLYGON_Ceiling ) | |
2673 { | |
2674 LABEL_10: | |
2675 v4 = 0; | |
2676 a2->x = 0x10000u; | |
2677 a2->z = 0; | |
2678 a2->y = 0; | |
2679 a3->y = 0xFFFF0000u; | |
2680 a3->z = 0; | |
2681 goto LABEL_11; | |
2682 } | |
2683 if ( (char)v4 == POLYGON_InBetweenFloorAndWall || (char)v4 == POLYGON_InBetweenCeilingAndWall ) | |
2684 { | |
2685 if ( abs(this->pFacePlane_old.vNormal.z) < 46441 ) | |
2686 { | |
2687 a1.x = (double)-v3->pFacePlane_old.vNormal.y; | |
2688 a1.y = (double)v3->pFacePlane_old.vNormal.x; | |
2689 a1.z = 0.0; | |
2690 a1.Normalize(); | |
2691 v6 = a1.y * 65536.0; | |
2692 a2->x = (signed __int64)(a1.x * 65536.0); | |
2693 v5 = (signed __int64)v6; | |
2694 goto LABEL_9; | |
2695 } | |
2696 goto LABEL_10; | |
2697 } | |
2698 LABEL_12: | |
2699 if ( BYTE2(v3->uAttributes) & 0x80 ) | |
2700 { | |
2701 a2->x = -a2->x; | |
2702 a2->y = -a2->y; | |
2703 a2->z = -a2->z; | |
2704 } | |
2705 if ( BYTE3(v3->uAttributes) & 1 ) | |
2706 { | |
2707 a3->x = -a3->x; | |
2708 a3->y = -a3->y; | |
2709 a3->z = -a3->z; | |
2710 } | |
2711 return v4; | |
2712 } | |
2713 | |
2714 //----- (0044C23B) -------------------------------------------------------- | |
428 | 2715 bool BLVFaceExtra::HasEventint() |
2716 { | |
2717 signed int event_index; // eax@1 | |
2718 _evt_raw* start_evt; | |
2719 _evt_raw* end_evt; | |
2720 | |
2721 event_index = 0; | |
2722 if ( (uLevelEVT_NumEvents - 1) <= 0 ) | |
2723 return false; | |
2724 while ( pLevelEVT_Index[event_index].uEventID != this->uEventID ) | |
0 | 2725 { |
428 | 2726 ++event_index; |
2727 if ( event_index >= (signed int)(uLevelEVT_NumEvents - 1) ) | |
2728 return false; | |
0 | 2729 } |
428 | 2730 end_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index+1].uEventOffsetInEVT]; |
2731 start_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index].uEventOffsetInEVT]; | |
2732 if ( (end_evt->_e_type != EVENT_Exit) || (start_evt->_e_type!= EVENT_MouseOver) ) | |
2733 return false; | |
0 | 2734 else |
428 | 2735 return true; |
0 | 2736 } |
2737 | |
2738 | |
2739 | |
2740 | |
2741 //----- (0046F228) -------------------------------------------------------- | |
2742 void __cdecl BLV_UpdateDoors() | |
2743 { | |
472 | 2744 //int v0; // ebx@1 |
2745 //int v1; // edi@1 | |
2746 //BLVDoor *v2; // esi@3 | |
2747 //unsigned __int16 v3; // ax@3 | |
2748 //unsigned int v4; // ecx@5 | |
2749 //int v5; // eax@8 | |
2750 //int v6; // ecx@8 | |
2751 //int v7; // eax@12 | |
2752 //int v8; // eax@16 | |
2753 //unsigned __int8 v9; // zf@18 | |
2754 //char v10; // sf@18 | |
2755 //unsigned __int8 v11; // of@18 | |
2756 //int v12; // edi@19 | |
2757 //int v13; // ecx@19 | |
2758 //__int16 v14; // ax@19 | |
0 | 2759 BLVFace *v15; // ebx@24 |
472 | 2760 //unsigned __int16 *v16; // ecx@24 |
0 | 2761 Vec3_short_ *v17; // esi@24 |
2762 int v18; // eax@24 | |
2763 int v19; // edx@24 | |
2764 signed int v20; // eax@24 | |
472 | 2765 //Vec3_short_ *v21; // ecx@24 |
2766 //double v22; // st7@24 | |
2767 //double v23; // st6@24 | |
0 | 2768 int v24; // esi@25 |
2769 int v25; // eax@25 | |
472 | 2770 //BLVDoor *v26; // edi@25 |
0 | 2771 signed __int64 v27; // qtt@27 |
2772 BLVFaceExtra *v28; // esi@32 | |
2773 int v29; // ecx@34 | |
2774 int v30; // edx@34 | |
2775 unsigned __int64 v31; // qax@34 | |
2776 int v32; // eax@34 | |
472 | 2777 //unsigned __int16 *v33; // eax@35 |
0 | 2778 Vec3_short_ *v34; // eax@35 |
2779 int v35; // ecx@35 | |
2780 int v36; // edx@35 | |
2781 signed int v37; // eax@35 | |
2782 signed int v38; // edx@35 | |
2783 int v39; // eax@35 | |
2784 int v40; // edx@35 | |
472 | 2785 //unsigned __int8 v41; // cf@35 |
2786 //unsigned __int16 *v42; // edi@36 | |
0 | 2787 Vec3_short_ *v43; // edi@36 |
472 | 2788 //int v44; // ecx@36 |
2789 //int v45; // edi@36 | |
2790 //int v46; // ecx@36 | |
2791 //__int16 *v47; // edx@44 | |
2792 //int v48; // ecx@44 | |
0 | 2793 unsigned int v49; // ecx@46 |
2794 unsigned __int16 v50; // ax@48 | |
2795 unsigned int v51; // eax@51 | |
2796 unsigned __int16 v52; // ax@54 | |
2797 int v53; // ecx@57 | |
472 | 2798 //int v54; // edx@57 |
0 | 2799 unsigned __int64 v55; // qax@57 |
2800 int v56; // ecx@58 | |
2801 int v57; // eax@58 | |
472 | 2802 //int v58; // eax@59 |
2803 //SoundID v59; // [sp-24h] [bp-88h]@12 | |
2804 //signed int v60; // [sp-20h] [bp-84h]@12 | |
2805 //unsigned int v61; // [sp-1Ch] [bp-80h]@12 | |
2806 //signed int v62; // [sp-18h] [bp-7Ch]@12 | |
2807 //signed int v63; // [sp-14h] [bp-78h]@12 | |
2808 //int v64; // [sp-10h] [bp-74h]@12 | |
2809 //unsigned int v65; // [sp-Ch] [bp-70h]@12 | |
2810 //int v66; // [sp-8h] [bp-6Ch]@12 | |
2811 Vec3_int_ v67; | |
2812 //int v67; // [sp+8h] [bp-5Ch]@31 | |
2813 //int v68; // [sp+Ch] [bp-58h]@34 | |
2814 //int v69; // [sp+10h] [bp-54h]@34 | |
2815 Vec3_int_ v70; | |
2816 //int v70; // [sp+14h] [bp-50h]@31 | |
2817 //int v71; // [sp+18h] [bp-4Ch]@34 | |
2818 //int v72; // [sp+1Ch] [bp-48h]@34 | |
0 | 2819 int v73; // [sp+20h] [bp-44h]@24 |
472 | 2820 //__int16 v74; // [sp+24h] [bp-40h]@24 |
0 | 2821 int v75; // [sp+28h] [bp-3Ch]@36 |
2822 int v76; // [sp+2Ch] [bp-38h]@36 | |
2823 int v77; // [sp+30h] [bp-34h]@36 | |
472 | 2824 //int v78; // [sp+34h] [bp-30h]@36 |
2825 //int v79; // [sp+38h] [bp-2Ch]@19 | |
2826 //unsigned int v80; // [sp+3Ch] [bp-28h]@2 | |
2827 //int v81; // [sp+40h] [bp-24h]@1 | |
0 | 2828 int v82; // [sp+44h] [bp-20h]@35 |
2829 int v83; // [sp+48h] [bp-1Ch]@34 | |
2830 int v84; // [sp+4Ch] [bp-18h]@34 | |
2831 int v85; // [sp+50h] [bp-14h]@19 | |
2832 SoundID eDoorSoundID; // [sp+54h] [bp-10h]@1 | |
472 | 2833 //BLVDoor *v87; // [sp+58h] [bp-Ch]@3 |
0 | 2834 int v88; // [sp+5Ch] [bp-8h]@18 |
2835 int v89; // [sp+60h] [bp-4h]@6 | |
2836 | |
472 | 2837 //v0 = 0; |
2838 //v1 = 0; | |
0 | 2839 eDoorSoundID = (SoundID)pDoorSoundIDsByLocationID[dword_6BE13C_uCurrentlyLoadedLocationID]; |
472 | 2840 //v81 = 0; |
2841 //if ( pIndoor->uNumDoors > 0 ) | |
2842 for (uint i = 0; i < pIndoor->uNumDoors; ++i) | |
0 | 2843 { |
472 | 2844 auto door = pIndoor->pDoors + i; |
2845 //v80 = 0; | |
2846 //do | |
2847 //{ | |
2848 //v2 = &pIndoor->pDoors[v80 / 0x50]; | |
2849 //v87 = &pIndoor->pDoors[v80 / 0x50]; | |
2850 //v3 = door->uState; | |
2851 if (door->uState == BLVDoor::Closed || door->uState == BLVDoor::Open) | |
0 | 2852 { |
472 | 2853 door->uAttributes &= 0xFFFFFFFDu; |
0 | 2854 goto LABEL_62; |
2855 } | |
472 | 2856 door->uTimeSinceTriggered += pEventTimer->uTimeElapsed; |
2857 //v4 = door->uTimeSinceTriggered; | |
2858 if (door->uState == BLVDoor::Opening) | |
0 | 2859 { |
472 | 2860 v89 = (signed int)(door->uTimeSinceTriggered * door->uCloseSpeed) / 128; |
2861 if ( v89 >= door->uMoveLength ) | |
0 | 2862 { |
472 | 2863 v89 = door->uMoveLength; |
2864 door->uState = BLVDoor::Open; | |
0 | 2865 LABEL_10: |
472 | 2866 if ( !(door->uAttributes & 6) && door->uNumVertices != 0) |
0 | 2867 { |
472 | 2868 //v66 = 0; |
2869 //v65 = 0; | |
2870 //v64 = 0; | |
862 | 2871 //v7 = PID(OBJECT_BLVDoor,i); |
472 | 2872 //v63 = 0; |
2873 //v62 = -1; | |
862 | 2874 //LOBYTE(v7) = PID(OBJECT_BLVDoor,i); |
472 | 2875 //v61 = 0; |
862 | 2876 //v60 = PID(OBJECT_BLVDoor,i); |
472 | 2877 //v59 = (SoundID)((int)eDoorSoundID + 1); |
2878 //LABEL_17: | |
862 | 2879 pAudioPlayer->PlaySound((SoundID)((int)eDoorSoundID + 1), PID(OBJECT_BLVDoor,i), 0, -1, 0, 0, 0, 0); |
472 | 2880 //goto LABEL_18; |
0 | 2881 } |
2882 goto LABEL_18; | |
2883 } | |
2884 } | |
2885 else | |
2886 { | |
472 | 2887 auto v5 = (signed int)(door->uTimeSinceTriggered * door->uOpenSpeed) / 128; |
2888 //v6 = door->uMoveLength; | |
2889 if ( v5 >= door->uMoveLength) | |
0 | 2890 { |
472 | 2891 v89 = 0; |
2892 door->uState = BLVDoor::Closed; | |
0 | 2893 goto LABEL_10; |
2894 } | |
472 | 2895 v89 = door->uMoveLength - v5; |
0 | 2896 } |
472 | 2897 if ( !(door->uAttributes & 6) && door->uNumVertices) |
0 | 2898 { |
472 | 2899 //v66 = 0; |
2900 //v65 = 0; | |
2901 //v64 = 0; | |
862 | 2902 //v8 = PID(OBJECT_BLVDoor,i); |
472 | 2903 //v63 = 0; |
2904 //v62 = -1; | |
2905 //LOBYTE(v8) = 8 * v1 | 1; | |
2906 //v61 = 1; | |
862 | 2907 //v60 = PID(OBJECT_BLVDoor,i); |
472 | 2908 //v59 = eDoorSoundID; |
862 | 2909 pAudioPlayer->PlaySound(eDoorSoundID, PID(OBJECT_BLVDoor,i), 1, -1, 0, 0, 0, 0); |
472 | 2910 //goto LABEL_18; |
0 | 2911 } |
2912 LABEL_18: | |
472 | 2913 //v11 = __OFSUB__(v2->uNumVertices, 0); |
2914 //v9 = v2->uNumVertices == 0; | |
2915 //v10 = (signed __int16)(v2->uNumVertices - 0) < 0; | |
2916 //v88 = 0; | |
2917 //if (door->uNumVertices > 0) | |
2918 for (uint j = 0; j < door->uNumVertices; ++j) | |
0 | 2919 { |
472 | 2920 //do |
2921 //{ | |
2922 //v12 = v88; | |
2923 //v13 = door->pVertexIDs[v88]; | |
2924 //v85 = v89; | |
2925 //v79 = door->vDirection.x; | |
2926 //v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; | |
2927 //v13 *= 6; | |
2928 pIndoor->pVertices[door->pVertexIDs[j]].x = ((unsigned int)(door->vDirection.x * v89) >> 16) + door->pXOffsets[j]; | |
2929 //v85 = v89; | |
2930 //v79 = door->vDirection.y; | |
2931 //v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; | |
2932 pIndoor->pVertices[door->pVertexIDs[j]].y = ((unsigned int)(door->vDirection.y * v89) >> 16) + door->pYOffsets[j]; | |
2933 //v85 = v89; | |
2934 //v79 = door->vDirection.z; | |
2935 //v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; | |
2936 //v14 = ((unsigned int)(door->vDirection.z * v89) >> 16) + door->pZOffsets[j]; | |
2937 pIndoor->pVertices[door->pVertexIDs[j]].z = ((unsigned int)(door->vDirection.z * v89) >> 16) + door->pZOffsets[j]; | |
2938 //++v88; | |
2939 //} | |
2940 //while ( v88 < door->uNumVertices ); | |
2941 //v1 = v81; | |
0 | 2942 } |
472 | 2943 //v11 = __OFSUB__(v2->uNumFaces, 0); |
2944 //v9 = v2->uNumFaces == 0; | |
2945 //v10 = (signed __int16)(v2->uNumFaces - 0) < 0; | |
2946 v88 = 0; | |
2947 if (door->uNumFaces > 0) | |
0 | 2948 { |
2949 while ( 1 ) | |
2950 { | |
472 | 2951 v15 = &pIndoor->pFaces[door->pFaceIDs[v88]]; |
2952 //v16 = v15->pVertexIDs; | |
2953 v17 = &pIndoor->pVertices[v15->pVertexIDs[0]]; | |
0 | 2954 v18 = v15->pFacePlane_old.vNormal.y; |
2955 v73 = *(int *)&v17->x; | |
472 | 2956 //v74 = v17->z; |
0 | 2957 v19 = v15->pFacePlane_old.vNormal.z; |
472 | 2958 v20 = -(v19 * (int)v17->z + (signed __int16)v73 * v15->pFacePlane_old.vNormal.x + SHIWORD(v73) * v18); |
0 | 2959 v15->pFacePlane_old.dist = v20; |
472 | 2960 //v21 = &pIndoor->pVertices[v15->pVertexIDs[0]]; |
2961 //v79 = v21->x; | |
2962 //v22 = (double)v21->x; | |
2963 //v23 = (double)v21->y; | |
2964 //v79 = v21->z; | |
2965 v15->pFacePlane.dist = -((double)v17->z * v15->pFacePlane.vNormal.z | |
2966 + (double)v17->y * v15->pFacePlane.vNormal.y | |
2967 + (double)v17->x * v15->pFacePlane.vNormal.x); | |
0 | 2968 if ( v19 ) |
2969 { | |
2970 v24 = abs(v20 >> 15); | |
2971 v25 = abs(v15->pFacePlane_old.vNormal.z); | |
472 | 2972 //v26 = v87; |
0 | 2973 if ( v24 > v25 ) |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
2974 Abortf("Door Error\ndoor id: %i\nfacet no: %i\n\nOverflow dividing facet->d [%i] by facet->nz [%i]", |
472 | 2975 door->uDoorID, |
2976 door->pFaceIDs[v88], | |
0 | 2977 v15->pFacePlane_old.dist, |
2978 v15->pFacePlane_old.vNormal.z); | |
472 | 2979 //v79 = v15->pFacePlane_old.vNormal.z; |
2980 //v85 = v15->pFacePlane_old.dist; | |
2981 LODWORD(v27) = v15->pFacePlane_old.dist << 16; | |
2982 HIDWORD(v27) = v15->pFacePlane_old.dist >> 16; | |
2983 //v85 = v27 / v15->pFacePlane_old.vNormal.z; | |
2984 v15->zCalc3 = -v27 / v15->pFacePlane_old.vNormal.z; | |
0 | 2985 } |
472 | 2986 /*else |
0 | 2987 { |
2988 v26 = v87; | |
472 | 2989 }*/ |
0 | 2990 if ( BYTE2(v15->uAttributes) & 4 || pRenderer->pRenderD3D ) |
472 | 2991 v15->_get_normals(&v70, &v67); |
0 | 2992 v28 = &pIndoor->pFaceExtras[v15->uFaceExtraID]; |
2993 if ( !pRenderer->pRenderD3D ) | |
2994 { | |
2995 if ( !(BYTE2(v15->uAttributes) & 4) ) | |
2996 goto LABEL_59; | |
472 | 2997 //v79 = door->vDirection.x; |
2998 v83 = (unsigned __int64)(door->vDirection.x * (signed __int64)v70.x) >> 16; | |
2999 //v85 = v71; | |
3000 //v79 = door->vDirection.y; | |
3001 v85 = (unsigned __int64)(door->vDirection.y * (signed __int64)v70.y) >> 16; | |
3002 //v84 = v72; | |
3003 //v79 = door->vDirection.z; | |
3004 v84 = (unsigned __int64)(door->vDirection.z * (signed __int64)v70.z) >> 16; | |
3005 //v79 = v83 + v85 + v84; | |
0 | 3006 v29 = v89; |
472 | 3007 //v83 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; |
3008 v28->sTextureDeltaU = -((v83 + v85 + v84) * (signed __int64)v89) >> 16; | |
3009 //v79 = door->vDirection.x; | |
3010 v85 = (unsigned __int64)(door->vDirection.x * (signed __int64)v67.x) >> 16; | |
3011 //v83 = v68; | |
3012 //v79 = door->vDirection.y; | |
3013 v83 = (unsigned __int64)(door->vDirection.y * (signed __int64)v67.y) >> 16; | |
3014 //v84 = v69; | |
3015 //v79 = door->vDirection.z; | |
3016 v84 = (unsigned __int64)(door->vDirection.z * (signed __int64)v67.z) >> 16; | |
3017 //v30 = v83 + v84; | |
3018 //v79 = v85 + v30; | |
3019 v31 = (v85 + v83 + v84) * (signed __int64)v29; | |
3020 //v83 = v31 >> 16; | |
0 | 3021 v32 = v31 >> 16; |
3022 goto LABEL_58; | |
3023 } | |
3024 v28->sTextureDeltaU = 0; | |
3025 v28->sTextureDeltaV = 0; | |
472 | 3026 //v33 = v15->pVertexIDs; |
3027 //v85 = 1; | |
3028 v34 = &pIndoor->pVertices[v15->pVertexIDs[0]]; | |
0 | 3029 v35 = v34->z; |
3030 v36 = v34->y; | |
3031 v82 = v34->x; | |
472 | 3032 //v79 = v36; |
3033 v37 = v70.x * v82 + v70.y * v36 + v70.z * v35; | |
3034 v38 = v67.x * v82 + v67.y * v36 + v67.z * v35; | |
0 | 3035 v39 = v37 >> 16; |
3036 *v15->pVertexUIDs = v39; | |
3037 v40 = v38 >> 16; | |
3038 *v15->pVertexVIDs = v40; | |
472 | 3039 //v41 = v15->uNumVertices < 1u; |
3040 //v9 = v15->uNumVertices == 1; | |
3041 //v83 = v40; | |
0 | 3042 v84 = v39; |
3043 v82 = v40; | |
472 | 3044 //if (v15->uNumVertices > 1) |
3045 for (uint j = 1; j < v15->uNumVertices; ++j) | |
0 | 3046 { |
472 | 3047 //do |
3048 //{ | |
3049 //v42 = v15->pVertexIDs; | |
3050 //v75 = 2 * v85; | |
3051 v43 = &pIndoor->pVertices[v15->pVertexIDs[j]]; | |
3052 //v79 = v43->z; | |
3053 //v44 = v43->y; | |
3054 //v45 = v43->x; | |
3055 //v78 = v43->y; | |
3056 v76 = ((__int64)v70.z * v43->z + (__int64)v70.x * v43->x + (__int64)v70.y * v43->y) >> 16; | |
3057 //v46 = (v67 * v45 + v68 * v44 + v79 * v69) >> 16; | |
3058 v77 = ((__int64)v67.x * v43->x + (__int64)v67.y * v43->y + (__int64)v43->z * v67.z) >> 16; | |
0 | 3059 if ( v76 < v39 ) |
3060 v39 = v76; | |
472 | 3061 if ( v77 < v40 ) |
3062 v40 = v77; | |
0 | 3063 if ( v76 > v84 ) |
3064 v84 = v76; | |
472 | 3065 if ( v77 > v82 ) |
3066 v82 = v77; | |
3067 //v40 = v83; | |
3068 //v47 = v15->pVertexUIDs; | |
3069 //v48 = v75; | |
3070 //++v85; | |
3071 v15->pVertexUIDs[j] = v76; | |
3072 v15->pVertexVIDs[j] = v77; | |
3073 //} | |
3074 //while ( v85 < v15->uNumVertices ); | |
3075 //v26 = v87; | |
0 | 3076 } |
3077 v49 = v15->uAttributes; | |
3078 if ( BYTE1(v49) & 0x10 ) | |
3079 goto LABEL_50; | |
3080 if ( SBYTE1(v49) < 0 ) | |
3081 { | |
3082 v50 = v15->uBitmapID; | |
3083 if ( v50 != -1 ) | |
3084 break; | |
3085 } | |
3086 LABEL_51: | |
3087 v51 = v15->uAttributes; | |
3088 if ( v51 & 8 ) | |
3089 { | |
3090 v28->sTextureDeltaV -= v40; | |
3091 } | |
3092 else | |
3093 { | |
3094 if ( v51 & 0x20000 ) | |
3095 { | |
3096 v52 = v15->uBitmapID; | |
3097 if ( v52 != -1 ) | |
945 | 3098 v28->sTextureDeltaV -= v82 + pBitmaps_LOD->GetTexture(v52)->uTextureHeight; |
0 | 3099 } |
3100 } | |
3101 if ( BYTE2(v15->uAttributes) & 4 ) | |
3102 { | |
472 | 3103 //v75 = door->vDirection.x; |
3104 v84 = (unsigned __int64)(door->vDirection.x * (signed __int64)v70.x) >> 16; | |
3105 //v82 = v71; | |
3106 //v75 = door->vDirection.y; | |
3107 v82 = (unsigned __int64)(door->vDirection.y * (signed __int64)v70.y) >> 16; | |
3108 //v83 = v72; | |
3109 //v75 = door->vDirection.z; | |
3110 v83 = (unsigned __int64)(door->vDirection.z * (signed __int64)v70.z) >> 16; | |
3111 v75 = v84 + v82 + v83; | |
0 | 3112 v53 = v89; |
3113 v82 = (unsigned __int64)(v75 * (signed __int64)v89) >> 16; | |
472 | 3114 v28->sTextureDeltaU = -v82; |
3115 //v75 = door->vDirection.x; | |
3116 v84 = (unsigned __int64)(door->vDirection.x * (signed __int64)v67.x) >> 16; | |
3117 //v82 = v68; | |
3118 //v75 = door->vDirection.y; | |
3119 v82 = (unsigned __int64)(door->vDirection.y * (signed __int64)v67.y) >> 16; | |
3120 //v83 = v69; | |
3121 //v75 = door->vDirection.z; | |
3122 v83 = (unsigned __int64)(door->vDirection.z * (signed __int64)v67.z) >> 16; | |
3123 //v54 = v82 + v83; | |
3124 v75 = v84 + v82 + v83; | |
3125 v55 = v75 * (signed __int64)v53; | |
3126 //v82 = v55 >> 16; | |
0 | 3127 v32 = v55 >> 16; |
3128 LABEL_58: | |
3129 v56 = v88; | |
3130 v57 = -v32; | |
3131 v28->sTextureDeltaV = v57; | |
472 | 3132 v28->sTextureDeltaU += door->pDeltaUs[v56]; |
3133 v28->sTextureDeltaV = v57 + door->pDeltaVs[v56]; | |
0 | 3134 } |
3135 LABEL_59: | |
472 | 3136 //v58 = door->uNumFaces; |
0 | 3137 ++v88; |
472 | 3138 if ( v88 >= door->uNumFaces) |
0 | 3139 { |
472 | 3140 //v1 = v81; |
3141 //v0 = 0; | |
0 | 3142 goto LABEL_62; |
3143 } | |
472 | 3144 //v2 = v87; |
0 | 3145 } |
554
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
3146 LOWORD(v39) = v84; |
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
3147 if (v15->uBitmapID != -1) |
9caf59edb1ee
Cave and Temple load and even doesn't crash (for a while).
Nomad
parents:
520
diff
changeset
|
3148 LOWORD(v39) += pBitmaps_LOD->pTextures[v15->uBitmapID].uTextureWidth; |
0 | 3149 LABEL_50: |
3150 v28->sTextureDeltaU -= v39; | |
3151 goto LABEL_51; | |
3152 } | |
3153 LABEL_62: | |
472 | 3154 ; |
3155 //v80 += 80; | |
3156 //++v1; | |
3157 //v81 = v1; | |
3158 //} | |
3159 //while ( v1 < pIndoor->uNumDoors ); | |
0 | 3160 } |
3161 } | |
3162 // 6BE13C: using guessed type int dword_6BE13C_uCurrentlyLoadedLocationID; | |
3163 | |
3164 //----- (0046F90C) -------------------------------------------------------- | |
3165 void __cdecl UpdateActors_BLV() | |
3166 { | |
3167 Actor *v0; // esi@2 | |
3168 unsigned __int16 v1; // ax@2 | |
3169 int v2; // edi@6 | |
3170 int v3; // eax@6 | |
3171 int v4; // eax@8 | |
3172 __int16 v5; // ax@11 | |
3173 signed int v6; // ebx@14 | |
3174 unsigned __int8 v7; // zf@14 | |
3175 unsigned __int8 v8; // sf@14 | |
3176 signed __int16 v9; // ax@17 | |
3177 signed __int64 v10; // qax@18 | |
3178 unsigned __int16 v11; // ax@21 | |
3179 int v12; // eax@29 | |
3180 unsigned __int64 v13; // qax@29 | |
3181 int v14; // eax@30 | |
3182 unsigned __int64 v15; // qax@30 | |
3183 int v16; // ecx@33 | |
3184 BLVFace *v17; // edx@33 | |
3185 int v18; // ecx@33 | |
3186 BLVFace *v19; // eax@34 | |
3187 int v20; // ecx@46 | |
3188 int v21; // eax@46 | |
3189 int v22; // edi@46 | |
3190 int v23; // eax@48 | |
3191 unsigned int v24; // eax@51 | |
3192 int v25; // eax@52 | |
3193 int v26; // ebx@54 | |
3194 int v27; // ST08_4@54 | |
3195 int v28; // edi@54 | |
3196 int v29; // eax@54 | |
3197 int v30; // ecx@62 | |
3198 int v31; // ebx@62 | |
3199 int v32; // eax@62 | |
3200 int v33; // eax@64 | |
3201 unsigned int v34; // ecx@64 | |
3202 int v35; // ecx@64 | |
3203 signed int v36; // edx@85 | |
3204 signed int v37; // ebx@85 | |
3205 BLVFace *v38; // edi@89 | |
3206 int v39; // ecx@90 | |
3207 int v40; // ebx@90 | |
3208 PolygonType v41; // al@94 | |
3209 int v42; // eax@96 | |
3210 __int16 v43; // dx@96 | |
3211 int v44; // ecx@96 | |
3212 int v45; // edi@101 | |
3213 int v46; // edi@101 | |
3214 int v47; // eax@101 | |
3215 unsigned __int64 v48; // qax@101 | |
3216 unsigned __int8 v49; // zf@103 | |
3217 unsigned __int8 v50; // sf@103 | |
3218 unsigned __int8 v51; // of@103 | |
3219 AIDirection v52; // [sp+0h] [bp-60h]@75 | |
3220 AIDirection v53; // [sp+1Ch] [bp-44h]@116 | |
3221 int v54; // [sp+38h] [bp-28h]@53 | |
3222 unsigned int uSectorID; // [sp+3Ch] [bp-24h]@6 | |
3223 int v56; // [sp+40h] [bp-20h]@6 | |
3224 unsigned int _this; // [sp+44h] [bp-1Ch]@51 | |
3225 int v58; // [sp+48h] [bp-18h]@51 | |
3226 int v59; // [sp+4Ch] [bp-14h]@8 | |
3227 unsigned int uFaceID; // [sp+50h] [bp-10h]@6 | |
3228 int v61; // [sp+54h] [bp-Ch]@14 | |
3229 int v62; // [sp+58h] [bp-8h]@6 | |
3230 unsigned int v63; // [sp+5Ch] [bp-4h]@1 | |
3231 | |
3232 v63 = 0; | |
3233 if ( (signed int)uNumActors > 0 ) | |
3234 { | |
3235 while ( 1 ) | |
3236 { | |
3237 v0 = &pActors[v63]; | |
3238 v1 = v0->uAIState; | |
3239 if ( v1 == 11 || v1 == 19 || v1 == 17 || !v0->uMovementSpeed ) | |
3240 goto LABEL_123; | |
3241 uSectorID = v0->uSectorID; | |
783 | 3242 v2 = collide_against_floor(v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, &uSectorID, &uFaceID); |
0 | 3243 v0->uSectorID = uSectorID; |
3244 v3 = v0->pMonsterInfo.uFlying; | |
3245 v56 = v2; | |
3246 v62 = v3; | |
3247 if ( !v0->CanAct() ) | |
3248 v62 = 0; | |
3249 v4 = v0->vPosition.z; | |
3250 v59 = 0; | |
3251 if ( v4 > v2 + 1 ) | |
3252 v59 = 1; | |
3253 if ( v2 <= -30000 ) | |
3254 { | |
3255 v5 = pIndoor->GetSector(v0->vPosition.x, v0->vPosition.y, v4); | |
3256 v0->uSectorID = v5; | |
3257 if ( !v5 | |
723 | 3258 || (v56 = BLV_GetFloorLevel(v0->vPosition.x, v0->vPosition.y, v0->vPosition.z, v5, &uFaceID), v56 == -30000) ) |
0 | 3259 goto LABEL_123; |
3260 } | |
305 | 3261 if ( v0->uCurrentActionAnimation == ANIM_Walking) |
0 | 3262 { |
3263 v6 = v0->uMovementSpeed; | |
3264 v7 = HIDWORD(v0->pActorBuffs[7].uExpireTime) == 0; | |
3265 v8 = SHIDWORD(v0->pActorBuffs[7].uExpireTime) < 0; | |
3266 v61 = v0->uMovementSpeed; | |
3267 if ( !v8 && (!(v8 | v7) || LODWORD(v0->pActorBuffs[7].uExpireTime)) ) | |
3268 { | |
3269 v9 = v0->pActorBuffs[7].uPower; | |
3270 if ( v9 ) | |
3271 LODWORD(v10) = v6 / (unsigned __int16)v9; | |
3272 else | |
3273 v10 = (signed __int64)((double)v61 * 0.5); | |
3274 v6 = v10; | |
3275 v61 = v10; | |
3276 } | |
3277 v11 = v0->uAIState; | |
3278 if ( v11 == 6 || v11 == 7 ) | |
3279 { | |
3280 v6 *= 2; | |
3281 v61 = v6; | |
3282 } | |
1340 | 3283 if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 1 ) |
0 | 3284 v6 = (signed __int64)((double)v61 * flt_6BE3AC_debug_recmod1_x_1_6); |
3285 if ( v6 > 1000 ) | |
3286 v6 = 1000; | |
323 | 3287 v12 = stru_5C6E00->Cos(v0->uYawAngle); |
0 | 3288 uSectorID = v12; |
3289 v13 = v12 * (signed __int64)v6; | |
3290 v61 = v13 >> 16; | |
3291 v0->vVelocity.x = WORD1(v13); | |
323 | 3292 uSectorID = stru_5C6E00->Sin(v0->uYawAngle); |
0 | 3293 v61 = (unsigned __int64)(uSectorID * (signed __int64)v6) >> 16; |
3294 v7 = v62 == 0; | |
3295 v0->vVelocity.y = (unsigned int)(uSectorID * v6) >> 16; | |
3296 if ( !v7 ) | |
3297 { | |
323 | 3298 v14 = stru_5C6E00->Sin(v0->uPitchAngle); |
0 | 3299 uSectorID = v14; |
3300 v15 = v14 * (signed __int64)v6; | |
3301 v61 = v15 >> 16; | |
3302 v0->vVelocity.z = WORD1(v15); | |
3303 } | |
3304 } | |
3305 else | |
3306 { | |
3307 v61 = v0->vVelocity.x; | |
3308 uSectorID = 55000; | |
3309 v61 = (unsigned __int64)(55000i64 * v61) >> 16; | |
3310 v0->vVelocity.x = v61; | |
3311 v61 = v0->vVelocity.y; | |
3312 v61 = (unsigned __int64)(uSectorID * (signed __int64)v61) >> 16; | |
3313 v7 = v62 == 0; | |
3314 v0->vVelocity.y = v61; | |
3315 if ( !v7 ) | |
3316 { | |
3317 uSectorID = 55000; | |
3318 v61 = v0->vVelocity.z; | |
3319 v61 = (unsigned __int64)(55000i64 * v61) >> 16; | |
3320 v0->vVelocity.z = v61; | |
3321 } | |
3322 } | |
3323 v16 = v0->vPosition.z; | |
3324 v17 = pIndoor->pFaces; | |
3325 v51 = __OFSUB__(v16, v56); | |
3326 v8 = v16 - v56 < 0; | |
3327 v18 = uFaceID; | |
3328 if ( v8 ^ v51 ) | |
3329 { | |
3330 v0->vPosition.z = v56 + 1; | |
3331 v19 = &v17[v18]; | |
3332 if ( v19->uPolygonType == 3 ) | |
3333 { | |
3334 if ( v0->vVelocity.z < 0 ) | |
3335 v0->vVelocity.z = 0; | |
3336 } | |
3337 else | |
3338 { | |
3339 if ( v19->pFacePlane_old.vNormal.z < 45000 ) | |
3340 v0->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); | |
3341 } | |
3342 } | |
3343 else | |
3344 { | |
3345 if ( v59 && !v62 ) | |
3346 v0->vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); | |
3347 } | |
3348 if ( v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y + v0->vVelocity.z * v0->vVelocity.z >= 400 ) | |
3349 break; | |
3350 v0->vVelocity.z = 0; | |
3351 v0->vVelocity.y = 0; | |
3352 v0->vVelocity.x = 0; | |
3353 if ( BYTE2(v17[v18].uAttributes) & 0x40 ) | |
3354 { | |
3355 if (v0->uAIState == Dead) | |
3356 v0->uAIState = Removed; | |
3357 } | |
3358 LABEL_123: | |
3359 ++v63; | |
3360 if ( (signed int)v63 >= (signed int)uNumActors ) | |
3361 return; | |
3362 } | |
3363 v20 = v0->uActorRadius; | |
3364 v21 = v0->uActorHeight; | |
3365 stru_721530.field_84 = -1; | |
3366 stru_721530.field_70 = 0; | |
3367 uSectorID = 0; | |
3368 stru_721530.field_0 = 1; | |
3369 stru_721530.field_8 = v20; | |
3370 stru_721530.prolly_normal_d = v20; | |
3371 stru_721530.field_C = v21; | |
3372 v22 = 0; | |
3373 while ( 1 ) | |
3374 { | |
3375 stru_721530.field_34.x = v0->vPosition.x; | |
3376 stru_721530.normal.x = stru_721530.field_34.x; | |
3377 stru_721530.field_34.y = v0->vPosition.y; | |
3378 stru_721530.normal.y = stru_721530.field_34.y; | |
3379 v23 = v0->vPosition.z; | |
3380 stru_721530.normal.z = v23 + v20 + 1; | |
3381 stru_721530.field_34.z = v23 - v20 + stru_721530.field_C - 1; | |
3382 if ( stru_721530.field_34.z < stru_721530.normal.z ) | |
3383 stru_721530.field_34.z = v23 + v20 + 1; | |
3384 stru_721530.field_1C = v0->vVelocity.x; | |
3385 stru_721530.field_20 = v0->vVelocity.y; | |
3386 stru_721530.field_24 = v0->vVelocity.z; | |
3387 stru_721530.uSectorID = v0->uSectorID; | |
3388 if ( !stru_721530._47050A(v22) ) | |
3389 { | |
3390 v58 = v22; | |
3391 v24 = 8 * v63; | |
862 | 3392 LOBYTE(v24) = PID(OBJECT_Actor,v63); |
0 | 3393 v61 = v22; |
3394 _this = v24; | |
3395 do | |
3396 { | |
3397 _46E44E_collide_against_faces_and_portals(1u); | |
3398 _46E0B2_collide_against_decorations(); | |
3399 _46EF01_collision_chech_player(0); | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
3400 _46ED8A_collide_against_sprite_objects(_this); |
0 | 3401 v25 = 0; |
3402 v56 = 0; | |
3403 if ( ai_arrays_size > v22 ) | |
3404 { | |
3405 do | |
3406 { | |
390 | 3407 v54 = ai_near_actors_ids[v25]; |
0 | 3408 if ( v54 != v63 ) |
3409 { | |
3410 v26 = v54; | |
3411 v27 = abs(pActors[v54].vPosition.z - v0->vPosition.z); | |
3412 v28 = abs(pActors[v26].vPosition.y - v0->vPosition.y); | |
3413 v29 = abs(pActors[v26].vPosition.x - v0->vPosition.x); | |
322 | 3414 if ( int_get_vector_length(v29, v28, v27) >= v0->uActorRadius + (signed int)pActors[v26].uActorRadius |
0 | 3415 && _46DF1A_collide_against_actor(v54, 40) ) |
3416 ++v58; | |
3417 v22 = 0; | |
3418 } | |
3419 v25 = v56++ + 1; | |
3420 } | |
3421 while ( v56 < ai_arrays_size ); | |
3422 } | |
3423 if ( _46F04E_collide_against_portals() ) | |
3424 break; | |
3425 ++v61; | |
3426 } | |
3427 while ( v61 < 100 ); | |
3428 v56 = v58 > 1; | |
3429 if ( stru_721530.field_7C >= stru_721530.field_6C ) | |
3430 { | |
3431 v30 = stru_721530.normal2.x; | |
3432 v31 = stru_721530.normal2.y; | |
3433 v32 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; | |
3434 } | |
3435 else | |
3436 { | |
3437 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; | |
3438 v30 = v58 + v0->vPosition.x; | |
3439 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; | |
3440 v31 = v58 + v0->vPosition.y; | |
3441 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; | |
3442 v32 = v58 + v0->vPosition.z; | |
3443 } | |
783 | 3444 v33 = collide_against_floor(v30, v31, v32, &stru_721530.uSectorID, &uFaceID); |
0 | 3445 v34 = pIndoor->pFaces[uFaceID].uAttributes; |
3446 v35 = v34 & 0x400000; | |
3447 if (v35 && v0->uAIState == Dead) | |
3448 { | |
3449 v0->uAIState = Removed; | |
3450 goto LABEL_120; | |
3451 } | |
3452 if ( v59 != v22 || v62 != v22 || v35 == v22 ) | |
3453 { | |
3454 if ( v33 == -30000 ) | |
3455 goto LABEL_120; | |
3456 if ( v0->uCurrentActionAnimation != 1 || v33 >= v0->vPosition.z - 100 || v59 != v22 || v62 != v22 ) | |
3457 { | |
3458 if ( stru_721530.field_7C >= stru_721530.field_6C ) | |
3459 { | |
3460 v0->vPosition.x = LOWORD(stru_721530.normal2.x); | |
3461 v0->vPosition.y = LOWORD(stru_721530.normal2.y); | |
3462 v0->vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1; | |
3463 v0->uSectorID = LOWORD(stru_721530.uSectorID); | |
3464 goto LABEL_123; | |
3465 } | |
3466 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16; | |
3467 v0->vPosition.x += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.x) >> 16; | |
3468 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; | |
3469 v0->vPosition.y += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.y) >> 16; | |
3470 v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; | |
3471 v36 = stru_721530.uFaceID; | |
3472 v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16; | |
3473 v0->uSectorID = LOWORD(stru_721530.uSectorID); | |
3474 stru_721530.field_70 += stru_721530.field_7C; | |
848 | 3475 v37 = PID_ID(v36); |
3476 if ( PID_TYPE(v36) != OBJECT_Actor) | |
0 | 3477 { |
848 | 3478 if ( PID_TYPE(v36) != OBJECT_Player) |
0 | 3479 { |
848 | 3480 if ( PID_TYPE(v36) == OBJECT_Decoration) |
0 | 3481 { |
295 | 3482 _this = integer_sqrt(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y); |
0 | 3483 v45 = stru_5C6E00->Atan2( |
3484 v0->vPosition.x - pLevelDecorations[v37].vPosition.x, | |
3485 v0->vPosition.y - pLevelDecorations[v37].vPosition.y); | |
323 | 3486 v54 = stru_5C6E00->Cos(v45); |
0 | 3487 v56 = (unsigned __int64)(v54 * (signed __int64)(signed int)_this) >> 16; |
3488 v46 = v45 - stru_5C6E00->uIntegerHalfPi; | |
3489 v0->vVelocity.x = v54 * _this >> 16; | |
323 | 3490 v47 = stru_5C6E00->Sin(v45); |
0 | 3491 v54 = v47; |
3492 v48 = v47 * (signed __int64)(signed int)_this; | |
3493 v56 = v48 >> 16; | |
3494 v0->vVelocity.y = WORD1(v48); | |
3495 goto LABEL_119; | |
3496 } | |
848 | 3497 if ( PID_TYPE(v36) == OBJECT_BModel) |
0 | 3498 { |
3499 stru_721530.field_84 = v36 >> 3; | |
3500 v38 = &pIndoor->pFaces[v37]; | |
3501 if ( v38->uPolygonType == 3 ) | |
3502 { | |
3503 v39 = v0->vVelocity.x; | |
3504 v40 = v0->vVelocity.y * v0->vVelocity.y; | |
3505 v0->vVelocity.z = 0; | |
3506 v0->vPosition.z = pIndoor->pVertices[*v38->pVertexIDs].z + 1; | |
3507 if ( v39 * v39 + v40 < 400 ) | |
3508 { | |
3509 v0->vVelocity.y = 0; | |
3510 v0->vVelocity.x = 0; | |
3511 goto LABEL_119; | |
3512 } | |
3513 } | |
3514 else | |
3515 { | |
3516 v61 = abs(v38->pFacePlane_old.vNormal.x * v0->vVelocity.x + v38->pFacePlane_old.vNormal.y | |
3517 * v0->vVelocity.y | |
3518 + v38->pFacePlane_old.vNormal.z | |
3519 * v0->vVelocity.z) >> 16; | |
3520 if ( stru_721530.field_64 >> 3 > v61 ) | |
3521 v61 = stru_721530.field_64 >> 3; | |
3522 v58 = v38->pFacePlane_old.vNormal.x; | |
3523 v58 = (unsigned __int64)(v61 * (signed __int64)v58) >> 16; | |
3524 _this = v38->pFacePlane_old.vNormal.y; | |
3525 _this = (unsigned __int64)(v61 * (signed __int64)(signed int)_this) >> 16; | |
3526 v56 = v38->pFacePlane_old.vNormal.z; | |
3527 v56 = (unsigned __int64)(v61 * (signed __int64)v56) >> 16; | |
3528 v0->vVelocity.x += v58; | |
3529 v0->vVelocity.y += _this; | |
3530 v0->vVelocity.z += v56; | |
3531 v41 = v38->uPolygonType; | |
3532 if ( v41 != 4 && v41 != 3 ) | |
3533 { | |
3534 v42 = v38->pFacePlane_old.vNormal.x; | |
3535 v43 = v0->vPosition.z; | |
3536 v44 = stru_721530.prolly_normal_d | |
3537 - ((v38->pFacePlane_old.dist | |
3538 + v38->pFacePlane_old.vNormal.z * v0->vPosition.z | |
3539 + v38->pFacePlane_old.vNormal.y * v0->vPosition.y | |
3540 + v42 * v0->vPosition.x) >> 16); | |
3541 if ( v44 > 0 ) | |
3542 { | |
3543 v0->vPosition.x += (unsigned int)(v44 * v42) >> 16; | |
3544 v0->vPosition.y += (unsigned int)(v44 * v38->pFacePlane_old.vNormal.y) >> 16; | |
3545 v0->vPosition.z = v43 + ((unsigned int)(v44 * v38->pFacePlane_old.vNormal.z) >> 16); | |
3546 } | |
3547 v0->uYawAngle = stru_5C6E00->Atan2(v0->vVelocity.x, v0->vVelocity.y); | |
3548 } | |
3549 } | |
3550 if ( BYTE3(v38->uAttributes) & 8 ) | |
3551 EventProcessor(pIndoor->pFaceExtras[v38->uFaceExtraID].uEventID, 0, 1); | |
3552 } | |
3553 LABEL_119: | |
3554 v56 = v0->vVelocity.x; | |
3555 v54 = 58500; | |
3556 v56 = (unsigned __int64)(58500i64 * v56) >> 16; | |
3557 v0->vVelocity.x = v56; | |
3558 v56 = v0->vVelocity.y; | |
3559 v56 = (unsigned __int64)(v54 * (signed __int64)v56) >> 16; | |
3560 v54 = 58500; | |
3561 v0->vVelocity.y = v56; | |
3562 v56 = v0->vVelocity.z; | |
3563 v56 = (unsigned __int64)(v54 * (signed __int64)v56) >> 16; | |
3564 v22 = 0; | |
3565 v0->vVelocity.z = v56; | |
3566 goto LABEL_120; | |
3567 } | |
3568 if ( v0->GetActorsRelation(0) ) | |
3569 { | |
1167 | 3570 v51 = __OFSUB__(HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime), v22); |
3571 v49 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) == v22; | |
3572 v50 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) - v22 < 0; | |
0 | 3573 v0->vVelocity.y = v22; |
3574 v0->vVelocity.x = v22; | |
3575 if ( !(v50 ^ v51) | |
1167 | 3576 && (!((unsigned __int8)(v50 ^ v51) | v49) || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > v22) ) |
3577 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); | |
0 | 3578 viewparams->bRedrawGameUI = 1; |
3579 goto LABEL_119; | |
3580 } | |
3581 v36 = stru_721530.uFaceID; | |
3582 LABEL_118: | |
1060 | 3583 Actor::AI_FaceObject(v63, v36, v22, (AIDirection *)v22); |
0 | 3584 goto LABEL_119; |
3585 } | |
1340 | 3586 if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == 2 || pTurnEngine->turn_stage == 3) ) |
0 | 3587 goto LABEL_119; |
3588 if ( v0->pMonsterInfo.uHostilityType ) | |
3589 { | |
3590 if ( v56 == v22 ) | |
3591 goto LABEL_114; | |
3592 } | |
3593 else | |
3594 { | |
3595 if ( v56 == v22 ) | |
3596 { | |
3597 if ( !pActors[v37].pMonsterInfo.uHostilityType ) | |
3598 goto LABEL_118; | |
3599 LABEL_114: | |
1060 | 3600 Actor::AI_Flee(v63, v36, v22, (AIDirection *)v22); |
0 | 3601 goto LABEL_119; |
3602 } | |
3603 } | |
414 | 3604 Actor::AI_StandOrBored(v63, 4, v22, &v53); |
0 | 3605 goto LABEL_119; |
3606 } | |
3607 if ( v0->vPosition.x & 1 ) | |
3608 v0->uYawAngle += 100; | |
3609 else | |
3610 v0->uYawAngle -= 100; | |
3611 } | |
3612 else | |
3613 { | |
1340 | 3614 if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == 2 || pTurnEngine->turn_stage == 3) ) |
0 | 3615 goto LABEL_123; |
3616 if ( !v0->pMonsterInfo.uHostilityType || v56 != v22 ) | |
3617 { | |
414 | 3618 Actor::AI_StandOrBored(v63, 4, v22, &v52); |
0 | 3619 goto LABEL_123; |
3620 } | |
3621 } | |
3622 } | |
3623 LABEL_120: | |
3624 ++uSectorID; | |
3625 if ( uSectorID >= 100 ) | |
3626 goto LABEL_123; | |
3627 v20 = stru_721530.prolly_normal_d; | |
3628 } | |
3629 } | |
3630 } | |
3631 // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int); | |
3632 // 4F75D8: using guessed type int ai_arrays_size; | |
3633 | |
3634 | |
3635 | |
3636 | |
3637 | |
3638 | |
3639 //----- (00460A78) -------------------------------------------------------- | |
3640 void __thiscall PrepareToLoadBLV(unsigned int bLoading) | |
3641 { | |
3642 unsigned int v1; // ebx@1 | |
3643 unsigned int v2; // eax@8 | |
3644 MapInfo *v3; // edi@9 | |
3645 int v4; // eax@11 | |
3646 int v5; // eax@12 | |
3647 int v6; // eax@13 | |
3648 int v7; // esi@27 | |
3649 SpawnPointMM7 *v8; // edx@28 | |
3650 //char v9; // bl@33 | |
3651 //int v10; // eax@34 | |
3652 //char *v11; // ecx@37 | |
3653 //int v12; // edi@44 | |
3654 //unsigned int v13; // edi@48 | |
3655 char *v14; // esi@49 | |
3656 __int16 v15; // ax@50 | |
3657 int v16; // ecx@52 | |
3658 DecorationDesc *v17; // eax@54 | |
3659 int v18; // ecx@55 | |
3660 //int *v19; // edi@58 | |
3661 //unsigned char v20; // dl@58 | |
3662 int v21; // eax@64 | |
3663 char v22; // cl@64 | |
3664 //signed int v23; // ebx@67 | |
3665 //char *v24; // esi@68 | |
3666 //int v25; // eax@70 | |
3667 //char *v26; // esi@78 | |
3668 //int v27; // eax@79 | |
3669 char v28; // zf@81 | |
3670 __int16 v29; // ax@85 | |
3671 signed int v30; // edi@94 | |
3672 int v31; // esi@94 | |
3673 char Args; // [sp+350h] [bp-C4h]@16 | |
3674 int v34[4]; // [sp+3E8h] [bp-2Ch]@96 | |
3675 int v35; // [sp+3F8h] [bp-1Ch]@1 | |
3676 //char b[4]; // [sp+3FCh] [bp-18h]@58 | |
3677 MapInfo *v37; // [sp+400h] [bp-14h]@1 | |
3678 int v38; // [sp+404h] [bp-10h]@1 | |
3679 unsigned int v39; // [sp+408h] [bp-Ch]@8 | |
3680 int pDest; // [sp+40Ch] [bp-8h]@1 | |
3681 //int i; // [sp+410h] [bp-4h]@27 | |
3682 | |
3683 v37 = (MapInfo *)bLoading; | |
3684 v1 = 0; | |
3685 v35 = 0; | |
3686 pGameLoadingUI_ProgressBar->Reset(0x20u); | |
3687 bUnderwater = 0; | |
3688 bNoNPCHiring = 0; | |
3689 v38 = 0; | |
3690 pDest = 1; | |
3691 uCurrentlyLoadedLevelType = LEVEL_Indoor; | |
3692 pGame->uFlags2 &= 0xFFFFFFF7u; | |
3693 if ( Is_out15odm_underwater() ) | |
3694 { | |
3695 bUnderwater = 1; | |
3696 pGame->uFlags2 |= 8u; | |
3697 } | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
3698 if ( !_stricmp(pCurrentMapName.data(), "out15.odm") || !_stricmp(pCurrentMapName.data(), "d23.blv") ) |
0 | 3699 bNoNPCHiring = 1; |
3700 pPaletteManager->pPalette_tintColor[0] = 0; | |
3701 pPaletteManager->pPalette_tintColor[1] = 0; | |
3702 pPaletteManager->pPalette_tintColor[2] = 0; | |
3703 pPaletteManager->RecalculateAll(); | |
3704 if ( qword_A750D8 ) | |
3705 qword_A750D8 = 0i64; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
3706 v2 = pMapStats->GetMapInfo(pCurrentMapName.data()); |
0 | 3707 v39 = v2; |
3708 if ( v2 ) | |
3709 { | |
3710 v3 = &pMapStats->pInfos[v2]; | |
3711 v1 = v3->uRespawnIntervalDays; | |
3712 v38 = GetAlertStatus(); | |
3713 } | |
3714 else | |
3715 { | |
3716 v3 = v37; | |
3717 } | |
3718 dword_6BE13C_uCurrentlyLoadedLocationID = v39; | |
3719 pAllocator->FreeChunk(ptr_6A0D08); | |
3720 ptr_6A0D08 = 0; | |
3721 _6A0D0C_txt_lod_loading = 0; | |
3722 TryLoadLevelFromLOD(); | |
3723 pStationaryLightsStack->uNumLightsActive = 0; | |
3724 v4 = pIndoor->Load( | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1202
diff
changeset
|
3725 pCurrentMapName.data(), |
0 | 3726 (unsigned int)(signed __int64)((double)pParty->uTimePlayed * 0.234375) / 60 / 60 / 24 + 1, |
3727 v1, | |
3728 (char *)&pDest) | |
3729 - 1; | |
3730 if ( !v4 ) | |
3731 { | |
3732 sprintf(&Args, "Unable to open %s", pCurrentMapName); | |
3733 Abortf(&Args); | |
3734 } | |
3735 v5 = v4 - 1; | |
3736 if ( !v5 ) | |
3737 { | |
3738 sprintf(&Args, "File %s is not a BLV File", pCurrentMapName); | |
3739 Abortf(&Args); | |
3740 } | |
3741 v6 = v5 - 1; | |
3742 if ( !v6 ) | |
3743 Abortf("Attempt to open new level before clearing old"); | |
3744 if ( v6 == 1 ) | |
3745 Abortf("Out of memory loading indoor level"); | |
3746 if ( !(dword_6BE364_game_settings_1 & 0x2000) ) | |
3747 { | |
3748 InitializeActors(); | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
3749 InitializeSpriteObjects(); |
0 | 3750 } |
3751 BYTE1(dword_6BE364_game_settings_1) &= 0xDFu; | |
3752 if ( !v39 ) | |
3753 pDest = 0; | |
3754 if ( pDest == 1 ) | |
3755 { | |
3756 v7 = 0; | |
3757 for (uint i = 0; i < pIndoor->uNumSpawnPoints; ++v7 ) | |
3758 { | |
3759 v8 = &pIndoor->pSpawnPoints[v7]; | |
3760 if ( pIndoor->pSpawnPoints[v7].uKind == 3 ) | |
3761 SpawnEncounter(v3, v8, 0, 0, 0); | |
3762 else | |
3763 v3->SpawnRandomTreasure(v8); | |
3764 ++i; | |
3765 } | |
3766 RespawnGlobalDecorations(); | |
3767 } | |
3768 | |
3769 pSoundList->LoadSound(pDoorSoundIDsByLocationID[v39], 0); | |
3770 pSoundList->LoadSound(pDoorSoundIDsByLocationID[v39] + 1, 0); | |
3771 | |
3772 for (uint i = 0; i < pIndoor->uNumDoors; ++i) | |
3773 { | |
3774 auto pDoor = pIndoor->pDoors + i; | |
3775 | |
3776 if (pDoor->uAttributes & 0x01) | |
3777 { | |
3778 pDoor->uState = BLVDoor::Opening; | |
3779 pDoor->uTimeSinceTriggered = 15360; | |
3780 pDoor->uAttributes = 2; | |
3781 } | |
3782 | |
3783 if (pDoor->uState == BLVDoor::Closed) | |
3784 { | |
3785 pDoor->uState = BLVDoor::Closing; | |
3786 pDoor->uTimeSinceTriggered = 15360; | |
3787 pDoor->uAttributes = 2; | |
3788 } | |
3789 else if (pDoor->uState == BLVDoor::Open) | |
3790 { | |
3791 pDoor->uState = BLVDoor::Opening; | |
3792 pDoor->uTimeSinceTriggered = 15360; | |
3793 pDoor->uAttributes = 2; | |
3794 } | |
3795 } | |
3796 | |
3797 /* | |
3798 i = 0; | |
3799 v9 = 2; | |
3800 if ( pIndoor->uNumDoors > 0 ) | |
3801 { | |
3802 v10 = 0; | |
3803 while ( 1 ) | |
3804 { | |
3805 if ( pIndoor->pDoors[v10].uAttributes & 1 ) | |
3806 { | |
3807 pIndoor->pDoors[v10].uState = 1; | |
3808 pIndoor->pDoors[v10].uTimeSinceTriggered = 15360; | |
3809 pIndoor->pDoors[v10].uAttributes = 2; | |
3810 } | |
3811 v11 = (char *)&pIndoor->pDoors[v10].uState; | |
3812 if ( !*(short *)v11 ) | |
3813 break; | |
3814 if ( *(short *)v11 == 2 ) | |
3815 { | |
3816 *(short *)v11 = 1; | |
3817 goto LABEL_41; | |
3818 } | |
3819 LABEL_42: | |
3820 ++i; | |
3821 ++v10; | |
3822 if ( i >= pIndoor->uNumDoors ) | |
3823 goto LABEL_43; | |
3824 } | |
3825 *(short *)v11 = 3; | |
3826 LABEL_41: | |
3827 pIndoor->pDoors[v10].uTimeSinceTriggered = 15360; | |
3828 pIndoor->pDoors[v10].uAttributes = 2; | |
3829 goto LABEL_42; | |
3830 } | |
3831 LABEL_43: | |
3832 */ | |
3833 | |
3834 for (uint i = 0; i < pIndoor->uNumFaces; ++i) | |
3835 { | |
3836 auto pFace = pIndoor->pFaces + i; | |
3837 if (!pFace->uBitmapID != -1) | |
3838 pBitmaps_LOD->pTextures[pFace->uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pFace->uBitmapID].palette_id1); | |
3839 } | |
3840 | |
3841 /*i = 0; | |
3842 if ( (signed int)pIndoor->uNumFaces > 0 ) | |
3843 { | |
3844 v12 = 0; | |
3845 do | |
3846 { | |
3847 if ( pIndoor->pFaces[v12].uBitmapID != -1 ) | |
3848 pBitmaps_LOD->pTextures[pIndoor->pFaces[v12].uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pIndoor->pFaces[v12].uBitmapID].palette_id1); | |
3849 ++i; | |
3850 ++v12; | |
3851 } | |
3852 while ( i < (signed int)pIndoor->uNumFaces ); | |
3853 }*/ | |
3854 | |
3855 | |
3856 pGameLoadingUI_ProgressBar->Progress(); | |
3857 | |
3858 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
3859 { | |
1202 | 3860 auto pDecortaion = &pLevelDecorations[i]; |
0 | 3861 |
3862 pDecorationList->InitializeDecorationSprite(pDecortaion->uDecorationDescID); | |
3863 | |
3864 v15 = pDecorationList->pDecorations[pDecortaion->uDecorationDescID].uSoundID; | |
3865 if (v15 && _6807E0_num_decorations_with_sounds_6807B8 < 9) | |
3866 { | |
3867 pSoundList->LoadSound(v15, 0); | |
3868 v16 = _6807E0_num_decorations_with_sounds_6807B8++; | |
3869 _6807B8_level_decorations_ids[v16] = i; | |
3870 } | |
3871 | |
3872 if ( !(pDecortaion->field_2 & 0x20) ) | |
3873 { | |
3874 v17 = &pDecorationList->pDecorations[pDecortaion->uDecorationDescID]; | |
380 | 3875 if (!v17->DontDraw()) |
0 | 3876 { |
3877 v18 = v17->uLightRadius; | |
3878 if ( v18 ) | |
3879 { | |
3880 unsigned char r = 255, | |
3881 g = 255, | |
3882 b = 255; | |
3883 if (pRenderer->pRenderD3D && pRenderer->bUseColoredLights) | |
3884 { | |
3885 r = v17->uColoredLightRed; | |
3886 g = v17->uColoredLightGreen; | |
3887 b = v17->uColoredLightBlue; | |
3888 } | |
3889 pStationaryLightsStack->AddLight(pDecortaion->vPosition.x, | |
3890 pDecortaion->vPosition.y, | |
3891 pDecortaion->vPosition.z + v17->uDecorationHeight, | |
3892 v18, | |
3893 r, | |
3894 g, | |
3895 b, | |
3896 byte_4E94D0); | |
3897 } | |
3898 } | |
3899 } | |
3900 | |
3901 if (!pDecortaion->field_16_event_id) | |
3902 { | |
3903 if (pDecortaion->IsInteractive()) | |
3904 { | |
3905 if ( v35 < 124 ) | |
3906 { | |
3907 v21 = v35 + 1; | |
3908 pDecortaion->_idx_in_stru123 = v35 + 75; | |
3909 v22 = stru_5E4C90._decor_events[v21 + 74 - 75]; | |
3910 v35 = v21; | |
3911 if ( !v22 ) | |
3912 pDecortaion->field_2 |= 0x20; | |
3913 } | |
3914 } | |
3915 } | |
3916 } | |
3917 | |
3918 pGameLoadingUI_ProgressBar->Progress(); | |
3919 | |
515
cb0ad52d6a26
LayingItem -> SpriteObject (long-waited rename, old name was inaccurate and confused people)
Nomad
parents:
486
diff
changeset
|
3920 for (uint i = 0; i < uNumSpriteObjects; ++i) |
0 | 3921 { |
1207
96a81634669e
arrays to std::arrays phase 3 - finishing global arrays
Grumpy7
parents:
1206
diff
changeset
|
3922 auto p = &pSpriteObjects[i]; |
0 | 3923 if (p->uObjectDescID) |
3924 { | |
3925 auto uItemID = p->stru_24.uItemID; | |
3926 if (uItemID) | |
3927 { | |
3928 if (uItemID != 220 && pItemsTable->pItems[uItemID].uEquipType == EQUIP_POTION && | |
570 | 3929 !p->stru_24.uEnchantmentType) |
3930 p->stru_24.uEnchantmentType = rand() % 15 + 5; | |
0 | 3931 pItemsTable->SetSpecialBonus(&p->stru_24); |
3932 } | |
3933 } | |
3934 } | |
3935 | |
3936 for (uint i = 0; i < uNumActors; ++i) | |
3937 //if ( (signed int)uNumActors > (signed int)v13 ) | |
3938 { | |
1202 | 3939 Actor *pActor = &pActors[i]; |
0 | 3940 //v26 = (char *)&pActors[0].uAttributes; |
3941 //do | |
3942 //{ | |
3943 //v27 = *(int *)v26; | |
3944 if (pActor->uAttributes & 0x100000) | |
3945 { | |
3946 if ( !v39 ) | |
3947 { | |
3948 pActor->pMonsterInfo.field_3E = 19; | |
3949 pActor->uAttributes |= 0x10000; | |
3950 continue; | |
3951 } | |
3952 v28 = v38 == 0; | |
3953 } | |
3954 else | |
3955 { | |
3956 v28 = v38 == 1; | |
3957 } | |
3958 | |
3959 if ( !v28 ) | |
3960 { | |
3961 pActor->PrepareSprites(0); | |
3962 v29 = pActor->pMonsterInfo.field_3E; | |
3963 pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
3964 if ( v29 != 11 && v29 != 19 && (!pActor->sCurrentHP || !pActor->pMonsterInfo.uHP) ) | |
3965 { | |
3966 pActor->pMonsterInfo.field_3E = 5; | |
3967 pActor->UpdateAnimation(); | |
3968 } | |
3969 } | |
3970 else | |
3971 { | |
3972 pActor->pMonsterInfo.field_3E = 19; | |
3973 pActor->uAttributes |= 0x10000; | |
3974 } | |
3975 //} | |
3976 //while ( i < (signed int)uNumActors ); | |
3977 } | |
3978 | |
3979 pGameLoadingUI_ProgressBar->Progress(); | |
3980 | |
3981 Actor this_; | |
3982 this_.pMonsterInfo.uID = 45; | |
3983 this_.PrepareSprites(0); | |
3984 if ( !v37 ) | |
3985 { | |
3986 pParty->sRotationX = 0; | |
3987 pParty->sRotationY = 0; | |
3988 pParty->vPosition.z = 0; | |
3989 pParty->vPosition.y = 0; | |
3990 pParty->vPosition.x = 0; | |
3991 pParty->uFallStartY = 0; | |
3992 pParty->uFallSpeed = 0; | |
3993 TeleportToStartingPoint(uLevel_StartingPointType); | |
3994 } | |
3995 viewparams->_443365(); | |
3996 PlayLevelMusic(); | |
3997 if ( !v37 ) | |
3998 { | |
3999 v30 = 0; | |
4000 v31 = 1; | |
4001 do | |
4002 { | |
4003 if ( pPlayers[v31]->CanAct() ) | |
4004 v34[v30++] = v31; | |
4005 ++v31; | |
4006 } | |
4007 while ( v31 <= 4 ); | |
4008 if ( v30 ) | |
4009 { | |
4010 if ( pDest ) | |
4011 { | |
4012 qword_A750D8 = 256i64; | |
1406 | 4013 PlayerSpeechID = SPEECH_46; |
1407 | 4014 uSpeakingCharacter = LOWORD(v34[rand() % v30]); |
0 | 4015 } |
4016 } | |
4017 } | |
1295 | 4018 } |
4019 //----- (0046CEC3) -------------------------------------------------------- | |
4020 int BLV_GetFloorLevel(int x, int y, int z, unsigned int uSectorID, unsigned int *pFaceID) | |
4021 { | |
4022 int v13; // ecx@13 | |
4023 signed int v14; // ebx@14 | |
4024 int v15; // eax@16 | |
4025 //int v16; // edx@19 | |
4026 //int v17; // ST18_4@19 | |
4027 //signed int v18; // edx@19 | |
4028 //signed __int64 v19; // qtt@19 | |
4029 int v21; // eax@27 | |
4030 //int v22; // ecx@29 | |
4031 signed int v28; // eax@45 | |
4032 int v29; // ebx@47 | |
4033 int v30; // edx@49 | |
4034 //int v31; // ST10_4@49 | |
4035 //signed int v32; // edx@49 | |
4036 signed __int64 v33; // qtt@49 | |
4037 //signed int v34; // eax@54 | |
4038 //signed int v35; // esi@56 | |
4039 //int result; // eax@57 | |
4040 int v38; // edx@62 | |
4041 //int v44; // [sp+20h] [bp-20h]@10 | |
4042 bool v47; // [sp+24h] [bp-1Ch]@43 | |
4043 bool v48; // [sp+28h] [bp-18h]@10 | |
4044 bool v49; // [sp+28h] [bp-18h]@41 | |
4045 bool v50; // [sp+2Ch] [bp-14h]@12 | |
4046 signed int v53; // [sp+30h] [bp-10h]@10 | |
4047 signed int v54; // [sp+30h] [bp-10h]@41 | |
4048 signed int v55; // [sp+34h] [bp-Ch]@1 | |
4049 | |
4050 //LOG_DECOMPILATION_WARNING(); | |
4051 | |
4052 static int blv_floor_id[50]; // 00721200 | |
4053 static int blv_floor_level[50]; // 007212C8 | |
4054 | |
4055 static __int16 word_721390_ys[104]; // idb | |
4056 static __int16 word_721460_xs[104]; // idb | |
4057 | |
4058 auto pSector = &pIndoor->pSectors[uSectorID]; | |
4059 v55 = 0; | |
4060 for (uint i = 0; i < pSector->uNumFloors; ++i) | |
4061 { | |
4062 auto pFloor = &pIndoor->pFaces[pSector->pFloors[i]]; | |
4063 if (pFloor->Clickable()) | |
4064 continue; | |
4065 | |
4066 assert(pFloor->uNumVertices); | |
4067 if (x <= pFloor->pBounding.x2 && x >= pFloor->pBounding.x1 && | |
4068 y <= pFloor->pBounding.y2 && y >= pFloor->pBounding.y1) | |
4069 { | |
4070 for (uint j = 0; j < pFloor->uNumVertices; ++j) | |
4071 { | |
4072 word_721460_xs[2 * j] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].x; | |
4073 word_721460_xs[2 * j + 1] = pFloor->pXInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].x; | |
4074 word_721390_ys[2 * j] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j]].y; | |
4075 word_721390_ys[2 * j + 1] = pFloor->pYInterceptDisplacements[j] + pIndoor->pVertices[pFloor->pVertexIDs[j + 1]].y; | |
4076 } | |
4077 word_721460_xs[2 * pFloor->uNumVertices] = word_721460_xs[0]; | |
4078 word_721390_ys[2 * pFloor->uNumVertices] = word_721390_ys[0]; | |
4079 | |
4080 v50 = word_721390_ys[0] >= y; | |
4081 v53 = 0; | |
4082 | |
4083 for (uint j = 0; j < 2 * pFloor->uNumVertices; ++j) | |
4084 { | |
4085 if (v53 >= 2) | |
4086 break; | |
4087 | |
4088 v48 = v50; | |
4089 v50 = word_721390_ys[j + 1] >= y; | |
4090 | |
4091 v13 = i; | |
4092 if (v48 == v50) | |
4093 continue; | |
4094 | |
4095 v14 = word_721460_xs[j + 1] >= x ? 0 : 2; | |
4096 v15 = v14 | (word_721460_xs[j] < x); | |
4097 | |
4098 if (v15 == 3) | |
4099 continue; | |
4100 else if (!v15) | |
4101 ++v53; | |
4102 else | |
4103 { | |
4104 auto a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]); | |
4105 auto res = fixpoint_sub0((signed int)word_721460_xs[j + 1] - (signed int)word_721460_xs[j], a_div_b); | |
4106 | |
4107 if (res + word_721460_xs[j] >= x) | |
4108 ++v53; | |
4109 } | |
4110 } | |
4111 | |
4112 | |
4113 if ( v53 == 1 ) | |
4114 { | |
4115 if ( v55 >= 50 ) | |
4116 break; | |
4117 if ( pFloor->uPolygonType == POLYGON_Floor || pFloor->uPolygonType == POLYGON_Ceiling ) | |
4118 { | |
4119 v21 = pIndoor->pVertices[pFloor->pVertexIDs[0]].z; | |
4120 } | |
4121 else | |
4122 { | |
4123 v21 = fixpoint_sub0(pFloor->zCalc1, x) + fixpoint_sub0(pFloor->zCalc2, y) + (short)(pFloor->zCalc3 >> 16); | |
4124 } | |
4125 blv_floor_level[v55] = v21; | |
4126 blv_floor_id[v55] = pSector->pFloors[i]; | |
4127 v55++; | |
4128 } | |
4129 } | |
4130 } | |
4131 | |
4132 | |
4133 if ( pSector->field_0 & 8 ) | |
4134 { | |
4135 for (uint i = 0; i < pSector->uNumPortals; ++i) | |
4136 { | |
4137 auto portal = &pIndoor->pFaces[pSector->pPortals[i]]; | |
4138 if (portal->uPolygonType != POLYGON_Floor) | |
4139 continue; | |
4140 | |
4141 if (!portal->uNumVertices) | |
4142 continue; | |
4143 | |
4144 if (x <= portal->pBounding.x2 && x >= portal->pBounding.x1 && | |
4145 y <= portal->pBounding.y2 && y >= portal->pBounding.y1 ) | |
4146 { | |
4147 for (uint j = 0; j < portal->uNumVertices; ++j) | |
4148 { | |
4149 word_721460_xs[2 * j] = portal->pXInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].x; | |
4150 word_721460_xs[2 * j + 1] = portal->pXInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].x; | |
4151 word_721390_ys[2 * j] = portal->pYInterceptDisplacements[j] + pIndoor->pVertices[portal->pVertexIDs[j]].y; | |
4152 word_721390_ys[2 * j + 1] = portal->pYInterceptDisplacements[j + 1] + pIndoor->pVertices[portal->pVertexIDs[j + 1]].y; | |
4153 } | |
4154 word_721460_xs[2 * portal->uNumVertices] = word_721460_xs[0]; | |
4155 word_721390_ys[2 * portal->uNumVertices] = word_721390_ys[0]; | |
4156 v54 = 0; | |
4157 v47 = word_721390_ys[0] >= y; | |
4158 | |
4159 for (uint j = 0; j < 2 * portal->uNumVertices; ++j) | |
4160 { | |
4161 v49 = v47; | |
4162 if ( v54 >= 2 ) | |
4163 break; | |
4164 v47 = word_721390_ys[j + 1] >= y; | |
4165 if ( v49 != v47 ) | |
4166 { | |
4167 v28 = word_721460_xs[j + 1] >= x ? 0 : 2; | |
4168 v29 = v28 | (word_721460_xs[j] < x); | |
4169 if ( v29 != 3 ) | |
4170 { | |
4171 if ( !v29 ) | |
4172 ++v54; | |
4173 else | |
4174 { | |
4175 auto a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]); | |
4176 auto res = fixpoint_sub0(word_721460_xs[j + 1] - word_721460_xs[j], a_div_b); | |
4177 if (res + word_721460_xs[j] >= x) | |
4178 ++v54; | |
4179 } | |
4180 } | |
4181 } | |
4182 } | |
4183 if ( v54 == 1 ) | |
4184 { | |
4185 if ( v55 >= 50 ) | |
4186 break; | |
4187 blv_floor_level[v55] = -29000; | |
4188 blv_floor_id[v55] = pSector->pPortals[i]; | |
4189 v55++; | |
4190 } | |
4191 } | |
4192 } | |
4193 } | |
4194 if ( v55 == 1 ) | |
4195 { | |
4196 *pFaceID = blv_floor_id[0]; | |
4197 return blv_floor_level[0]; | |
4198 } | |
4199 if ( !v55 ) | |
4200 return -30000; | |
4201 *pFaceID = blv_floor_id[0]; | |
4202 //result = blv_floor_level[0]; | |
4203 | |
4204 /*for ( v35 = 1; v35 < v55; ++v35 ) | |
4205 { | |
4206 if ( blv_floor_level[0] <= z + 5 ) | |
4207 { | |
4208 if ( blv_floor_level[v35] >= blv_floor_level[0] || blv_floor_level[v35] > z + 5 ) | |
4209 continue; | |
4210 blv_floor_level[0] = blv_floor_level[v35]; | |
4211 *pFaceID = blv_floor_id[v35]; | |
4212 continue; | |
4213 } | |
4214 if ( blv_floor_level[v35] < blv_floor_level[0] ) | |
4215 { | |
4216 blv_floor_level[0] = blv_floor_level[v35]; | |
4217 *pFaceID = blv_floor_id[v35]; | |
4218 } | |
4219 }*/ | |
4220 | |
4221 | |
4222 int result = blv_floor_level[0]; | |
4223 for (uint i = 1; i < v55; ++i) | |
4224 { | |
4225 v38 = blv_floor_level[i]; | |
4226 if ( result <= z + 5 ) | |
4227 { | |
4228 if ( v38 > result && v38 <= z + 5 ) | |
4229 { | |
4230 result = blv_floor_level[i]; | |
4231 *pFaceID = blv_floor_id[i]; | |
4232 } | |
4233 } | |
4234 else if ( v38 < result ) | |
4235 { | |
4236 result = blv_floor_level[i]; | |
4237 *pFaceID = blv_floor_id[i]; | |
4238 } | |
4239 } | |
4240 | |
4241 return result; | |
4242 } | |
4243 //----- (004016FA) -------------------------------------------------------- | |
4244 int __cdecl MakeActorAIList_BLV() | |
4245 { | |
4246 Actor *v0; // esi@2 | |
4247 int v1; // eax@4 | |
4248 int v2; // ebx@4 | |
4249 unsigned int v3; // ecx@4 | |
4250 int v4; // edx@5 | |
4251 int v5; // edx@7 | |
4252 unsigned int v6; // edx@9 | |
4253 unsigned int v7; // ST24_4@10 | |
4254 int v8; // eax@10 | |
4255 int v9; // edi@10 | |
4256 int v10; // ebx@14 | |
4257 char v11; // zf@16 | |
4258 int v12; // eax@22 | |
4259 int v13; // edx@24 | |
4260 int v14; // ecx@25 | |
4261 int v15; // ebx@26 | |
4262 unsigned int *v16; // ecx@27 | |
4263 unsigned int v17; // esi@27 | |
4264 int v18; // ecx@31 | |
4265 signed int v19; // edi@31 | |
4266 Actor *v20; // esi@32 | |
4267 bool v21; // eax@33 | |
4268 int v22; // eax@34 | |
4269 signed int v23; // ebx@36 | |
4270 Actor *v24; // esi@37 | |
4271 signed int v25; // eax@40 | |
4272 int v26; // eax@43 | |
4273 int v27; // ebx@45 | |
4274 int j; // edi@45 | |
4275 unsigned int v29; // eax@46 | |
4276 int v30; // eax@48 | |
4277 int v31; // ecx@51 | |
4278 int v32; // eax@51 | |
4279 signed int v33; // eax@53 | |
4280 __int64 v34; // qax@55 | |
4281 char *v35; // ecx@56 | |
4282 int v37; // [sp+Ch] [bp-18h]@1 | |
4283 int v38; // [sp+10h] [bp-14h]@4 | |
4284 int v39; // [sp+14h] [bp-10h]@4 | |
4285 int v40; // [sp+18h] [bp-Ch]@10 | |
4286 int v41; // [sp+18h] [bp-Ch]@29 | |
4287 int i; // [sp+18h] [bp-Ch]@31 | |
4288 signed int v43; // [sp+1Ch] [bp-8h]@1 | |
4289 signed int v44; // [sp+1Ch] [bp-8h]@25 | |
4290 int v45; // [sp+20h] [bp-4h]@1 | |
4291 | |
4292 // __debugbreak(); // refactor for blv ai | |
4293 pParty->uFlags &= 0xFFFFFFCFu; | |
4294 v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
4295 v45 = 0; | |
4296 v43 = 0; | |
4297 if ( (signed int)uNumActors > 0 ) | |
4298 { | |
4299 v0 = pActors.data();//[0].uAttributes; | |
4300 do | |
4301 { | |
4302 BYTE1(v0->uAttributes) &= 0xFBu; | |
4303 if ( ! v0->CanAct() ) | |
4304 goto LABEL_60; | |
4305 v39 = abs(pParty->vPosition.z - v0->vPosition.z); | |
4306 v38 = abs(pParty->vPosition.y - v0->vPosition.y); | |
4307 v1 = abs(pParty->vPosition.x - v0->vPosition.x); | |
4308 v2 = v38; | |
4309 v3 = v39; | |
4310 if ( v1 < v38 ) | |
4311 { | |
4312 v4 = v1; | |
4313 v1 = v38; | |
4314 v2 = v4; | |
4315 } | |
4316 if ( v1 < v39 ) | |
4317 { | |
4318 v5 = v1; | |
4319 v1 = v39; | |
4320 v3 = v5; | |
4321 } | |
4322 if ( v2 < (signed int)v3 ) | |
4323 { | |
4324 v6 = v3; | |
4325 v3 = v2; | |
4326 v2 = v6; | |
4327 } | |
4328 v7 = ((unsigned int)(11 * v2) >> 5) + (v3 >> 2) + v1; | |
4329 v8 = v0->uActorRadius; | |
4330 v9 = v7 - v8; | |
4331 v40 = v7 - v8; | |
4332 if ( v40 < 0 ) | |
4333 { | |
4334 v9 = 0; | |
4335 v40 = 0; | |
4336 } | |
4337 if ( v9 < 10240 ) | |
4338 { | |
4339 v10 = v0->uAttributes & 0xFEFFFFFF; | |
4340 v0->uAttributes = v10; | |
4341 if ( v10 & 0x80000 || v0->GetActorsRelation(0) ) | |
4342 { | |
4343 v11 = (pParty->uFlags & 0x10) == 0; | |
4344 v0->uAttributes = v10 | 0x1000000; | |
4345 if ( v11 && (double)v40 < 307.2 ) | |
4346 pParty->uFlags |= 0x10u; | |
4347 if ( !(pParty->uFlags & 0x20) && v9 < 5120 ) | |
4348 pParty->uFlags |= 0x20u; | |
4349 } | |
4350 v12 = v45++; | |
4351 ai_near_actors_distances[v12] = v9; | |
4352 ai_near_actors_ids[v12] = v43; | |
4353 } | |
4354 else | |
4355 { | |
4356 LABEL_60: | |
4357 BYTE1(v0->uAttributes) &= 0xBFu; | |
4358 } | |
4359 ++v43; | |
4360 ++v0; | |
4361 } | |
4362 while ( v43 < (signed int)uNumActors ); | |
4363 } | |
4364 v13 = 0; | |
4365 if ( v45 > 0 ) | |
4366 { | |
4367 v14 = 1; | |
4368 v44 = 1; | |
4369 do | |
4370 { | |
4371 while ( 1 ) | |
4372 { | |
4373 v41 = v14; | |
4374 if ( v14 >= v45 ) | |
4375 break; | |
4376 v15 = ai_near_actors_distances[v13]; | |
4377 if ( v15 > ai_near_actors_distances[v14] ) | |
4378 { | |
4379 v16 = &ai_near_actors_ids[v14]; | |
4380 v17 = ai_near_actors_ids[v13]; | |
4381 ai_near_actors_ids[v13] = *v16; | |
4382 *v16 = v17; | |
4383 v14 = v41; | |
4384 ai_near_actors_distances[v13] = ai_near_actors_distances[v41]; | |
4385 ai_near_actors_distances[v41] = v15; | |
4386 } | |
4387 ++v14; | |
4388 } | |
4389 ++v13; | |
4390 v14 = v44 + 1; | |
4391 v44 = v14; | |
4392 } | |
4393 while ( v14 - 1 < v45 ); | |
4394 } | |
4395 v18 = 0; | |
4396 v19 = 0; | |
4397 for ( i = 0; v18 < v45; i = v18 ) | |
4398 { | |
4399 v20 = &pActors[ai_near_actors_ids[v18]]; | |
4400 if ( v20->uAttributes & 0x8000 | |
4401 || (v21 = sub_4070EF_prolly_collide_objects(PID(OBJECT_Actor,ai_near_actors_ids[v18]), 4u), v18 = i, v21) ) | |
4402 { | |
4403 v22 = ai_near_actors_ids[v18]; | |
4404 v20->uAttributes |= 0x8000u; | |
4405 ai_array_4F6638_actor_ids[v19] = v22; | |
4406 ai_array_4F5E68[v19++] = ai_near_actors_distances[v18]; | |
4407 if ( v19 >= 30 ) | |
4408 break; | |
4409 } | |
4410 ++v18; | |
4411 } | |
4412 v23 = 0; | |
4413 ai_arrays_size = v19; | |
4414 if ( (signed int)uNumActors > 0 ) | |
4415 { | |
4416 v24 = pActors.data();//[0].uAttributes; | |
4417 do | |
4418 { | |
4419 if ( v24->CanAct() && v24->uSectorID == v37 ) | |
4420 { | |
4421 v25 = 0; | |
4422 if ( v19 <= 0 ) | |
4423 { | |
4424 LABEL_43: | |
4425 v26 = ai_arrays_size; | |
4426 BYTE1(v24->uAttributes) |= 0x40u; | |
4427 ++ai_arrays_size; | |
4428 ai_array_4F6638_actor_ids[v26] = v23; | |
4429 } | |
4430 else | |
4431 { | |
4432 while ( ai_array_4F6638_actor_ids[v25] != v23 ) | |
4433 { | |
4434 ++v25; | |
4435 if ( v25 >= v19 ) | |
4436 goto LABEL_43; | |
4437 } | |
4438 } | |
4439 } | |
4440 ++v23; | |
4441 ++v24; | |
4442 } | |
4443 while ( v23 < (signed int)uNumActors ); | |
4444 } | |
4445 v27 = ai_arrays_size; | |
4446 for ( j = 0; j < v45; ++j ) | |
4447 { | |
4448 v29 = ai_near_actors_ids[j]; | |
4449 if ( pActors[v29].uAttributes & 0xC000 && pActors[v29].CanAct() ) | |
4450 { | |
4451 v30 = 0; | |
4452 if ( v27 <= 0 ) | |
4453 { | |
4454 LABEL_51: | |
4455 v31 = ai_arrays_size; | |
4456 v32 = ai_near_actors_ids[j]; | |
4457 ++ai_arrays_size; | |
4458 ai_array_4F6638_actor_ids[v31] = v32; | |
4459 } | |
4460 else | |
4461 { | |
4462 while ( ai_array_4F6638_actor_ids[v30] != ai_near_actors_ids[j] ) | |
4463 { | |
4464 ++v30; | |
4465 if ( v30 >= v27 ) | |
4466 goto LABEL_51; | |
4467 } | |
4468 } | |
4469 } | |
4470 } | |
4471 v33 = ai_arrays_size; | |
4472 if ( ai_arrays_size > 30 ) | |
4473 { | |
4474 v33 = 30; | |
4475 ai_arrays_size = 30; | |
4476 } | |
4477 memcpy(ai_near_actors_ids.data(), ai_array_4F6638_actor_ids.data(), 4 * v33); | |
4478 memcpy(ai_near_actors_distances.data(), ai_array_4F5E68.data(), 4 * ai_arrays_size); | |
4479 v34 = (unsigned int)ai_arrays_size; | |
4480 if ( ai_arrays_size > 0 ) | |
4481 { | |
4482 do | |
4483 { | |
4484 v35 = (char *)&pActors[ai_near_actors_ids[HIDWORD(v34)]].uAttributes; | |
4485 v35[1] |= 4u; | |
4486 ++HIDWORD(v34); | |
4487 } | |
4488 while ( SHIDWORD(v34) < (signed int)v34 ); | |
4489 } | |
4490 return v34; | |
4491 } | |
4492 //----- (0043FDED) -------------------------------------------------------- | |
4493 void PrepareActorRenderList_BLV() | |
4494 { | |
4495 RenderBillboard *v0; // esi@0 | |
4496 unsigned __int16 v3; // ax@3 | |
4497 unsigned int v4; // eax@5 | |
4498 unsigned __int16 v5; // cx@5 | |
4499 int v6; // esi@5 | |
4500 unsigned int v7; // eax@7 | |
4501 int v8; // eax@10 | |
4502 SpriteFrame *v9; // eax@16 | |
4503 SpriteFrame *v10; // ebx@18 | |
4504 //int *v11; // eax@18 | |
4505 int v12; // ecx@28 | |
4506 //IndoorCameraD3D **v14; // eax@36 | |
4507 double v15; // st7@36 | |
4508 float v16; // eax@36 | |
4509 //double v17; // ST30_8@36 | |
4510 signed __int64 v18; // qtt@36 | |
4511 int v19; // ST5C_4@36 | |
4512 signed __int64 v20; // qtt@37 | |
4513 int v21; // ST5C_4@37 | |
4514 signed __int16 v22; // cx@39 | |
4515 int v23; // ST50_4@40 | |
4516 signed int v24; // ecx@40 | |
4517 int v25; // edx@44 | |
4518 __int16 v26; // ax@44 | |
4519 //MonsterDesc *v27; // edx@44 | |
4520 //int v28; // ecx@44 | |
4521 unsigned __int8 v29; // zf@44 | |
4522 unsigned __int8 v30; // sf@44 | |
4523 unsigned int v31; // [sp-8h] [bp-5Ch]@15 | |
4524 int v32; // [sp+1Ch] [bp-38h]@5 | |
4525 int a3; // [sp+20h] [bp-34h]@5 | |
4526 int a2; // [sp+24h] [bp-30h]@5 | |
4527 int a1a; // [sp+28h] [bp-2Ch]@5 | |
4528 __int16 a5; // [sp+2Ch] [bp-28h]@5 | |
4529 int a5a; // [sp+2Ch] [bp-28h]@36 | |
4530 int a5b; // [sp+2Ch] [bp-28h]@40 | |
4531 __int16 v41; // [sp+3Ch] [bp-18h]@18 | |
4532 int a6; // [sp+40h] [bp-14h]@34 | |
4533 int v43; // [sp+44h] [bp-10h]@34 | |
4534 int z; // [sp+48h] [bp-Ch]@32 | |
4535 signed int y; // [sp+4Ch] [bp-8h]@32 | |
4536 int x; // [sp+50h] [bp-4h]@32 | |
4537 | |
4538 for (uint i = 0; i < uNumActors; ++i) | |
4539 { | |
4540 auto p = &pActors[i]; | |
4541 | |
4542 if (p->uAIState == Removed || | |
4543 p->uAIState == Disabled) | |
4544 continue; | |
4545 | |
4546 a5 = p->uSectorID; | |
4547 a2 = p->vPosition.y; | |
4548 a1a = p->vPosition.x; | |
4549 a3 = p->vPosition.z; | |
4550 v4 = stru_5C6E00->Atan2(a1a - pBLVRenderParams->vPartyPos.x, a2 - pBLVRenderParams->vPartyPos.y); | |
4551 LOWORD(v0) = p->uYawAngle; | |
4552 v5 = p->uCurrentActionAnimation; | |
4553 v6 = ((signed int)((char *)v0 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v4 + stru_5C6E00->uIntegerPi) >> 8) & 7; | |
4554 v32 = v6; | |
4555 if ( pParty->bTurnBasedModeOn ) | |
4556 { | |
4557 if ( v5 == 1 ) | |
4558 { | |
4559 v7 = pMiscTimer->uTotalGameTimeElapsed; | |
4560 goto LABEL_10; | |
4561 } | |
4562 } | |
4563 else | |
4564 { | |
4565 if ( v5 == 1 ) | |
4566 { | |
4567 v7 = pBLVRenderParams->field_0_timer_; | |
4568 LABEL_10: | |
4569 v8 = i * 32 + v7; | |
4570 goto LABEL_12; | |
4571 } | |
4572 } | |
4573 v8 = p->uCurrentActionTime; | |
4574 LABEL_12: | |
4575 if (p->pActorBuffs[5].uExpireTime > 0i64 || p->pActorBuffs[6].uExpireTime > 0i64 ) | |
4576 v8 = 0; | |
4577 v31 = p->pSpriteIDs[v5]; | |
4578 if (p->uAIState == Resurrected) | |
4579 v9 = pSpriteFrameTable->GetFrameBy_x(v31, v8); | |
4580 else | |
4581 v9 = pSpriteFrameTable->GetFrame(v31, v8); | |
4582 v41 = 0; | |
4583 v10 = v9; | |
4584 //v11 = (int *)v9->uFlags; | |
4585 if (v9->uFlags & 2) | |
4586 v41 = 2; | |
4587 if (v9->uFlags & 0x40000) | |
4588 v41 |= 0x40u; | |
4589 if (v9->uFlags & 0x20000) | |
4590 LOBYTE(v41) = v41 | 0x80; | |
4591 v0 = (RenderBillboard *)(256 << v6); | |
4592 if ( (unsigned int)v0 & v9->uFlags) | |
4593 v41 |= 4u; | |
4594 if ( v10->uGlowRadius ) | |
4595 { | |
4596 //LOBYTE(v11) = byte_4E94D3; | |
4597 pMobileLightsStack->AddLight( | |
4598 a1a, | |
4599 a2, | |
4600 a3, | |
4601 a5, | |
4602 v10->uGlowRadius, | |
4603 0xFFu, | |
4604 0xFFu, | |
4605 0xFFu, | |
4606 byte_4E94D3); | |
4607 } | |
4608 v12 = 0; | |
4609 if ( pBspRenderer->uNumVisibleNotEmptySectors <= 0 ) | |
4610 continue; | |
4611 while (pBspRenderer->pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v12] != p->uSectorID) | |
4612 { | |
4613 ++v12; | |
4614 if ( v12 >= pBspRenderer->uNumVisibleNotEmptySectors ) | |
4615 goto _continue; | |
4616 } | |
4617 if ( !pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(a1a, a2, a3, &x, &y, &z, 1) | |
4618 || (v0 = (RenderBillboard *)abs(x), (signed int)v0 < abs(y)) ) | |
4619 continue; | |
4620 pGame->pIndoorCameraD3D->Project(x, y, z, &v43, &a6); | |
4621 v0 = &pBillboardRenderList[uNumBillboardsToDraw]; | |
4622 if (uNumBillboardsToDraw >= 500) | |
4623 break; | |
4624 ++uNumBillboardsToDraw; | |
4625 ++uNumSpritesDrawnThisFrame; | |
4626 p->uAttributes |= 8u; | |
4627 v29 = pRenderer->pRenderD3D == 0; | |
4628 v0->uHwSpriteID = v10->pHwSpriteIDs[v32]; | |
4629 v0->uPalette = v10->uPaletteIndex; | |
4630 v0->uIndoorSectorID = a5; | |
4631 if ( v29 ) | |
4632 { | |
4633 LODWORD(v20) = pBLVRenderParams->field_40 << 16; | |
4634 HIDWORD(v20) = pBLVRenderParams->field_40 >> 16; | |
4635 v21 = v20 / x; | |
4636 v0->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v10->scale * v20 / x) >> 16; | |
4637 a5a = (unsigned __int64)(v10->scale * (signed __int64)v21) >> 16; | |
4638 } | |
4639 else | |
4640 { | |
4641 //v14 = &pGame->pIndoorCameraD3D; | |
4642 v0->fov_x = pGame->pIndoorCameraD3D->fov_x; | |
4643 v15 = pGame->pIndoorCameraD3D->fov_y; | |
4644 v16 = v0->fov_x; | |
4645 v0->fov_y = v15; | |
4646 //v17 = v16 + 6.7553994e15; | |
4647 LODWORD(v18) = 0; | |
4648 HIDWORD(v18) = floorf(v16 + 0.5f); | |
4649 v19 = v18 / x; | |
4650 v0->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v10->scale * v18 / x) >> 16; | |
4651 a5a = (unsigned __int64)(v10->scale * (signed __int64)v19) >> 16; | |
4652 } | |
4653 v0->_screenspace_y_scaler_packedfloat = a5a; | |
4654 if ( (signed __int64)p->pActorBuffs[3].uExpireTime <= 0 ) | |
4655 { | |
4656 if ( (signed __int64)p->pActorBuffs[10].uExpireTime > 0 ) | |
4657 { | |
4658 a5b = (unsigned __int64)(pGame->pStru6Instance->_4A806F(p) * (signed __int64)v0->_screenspace_y_scaler_packedfloat) >> 16; | |
4659 goto LABEL_43; | |
4660 } | |
4661 } | |
4662 else | |
4663 { | |
4664 v22 = p->pActorBuffs[3].uPower; | |
4665 if ( v22 ) | |
4666 { | |
4667 v23 = (unsigned __int64)(65536 / (unsigned __int16)v22 * (signed __int64)v0->_screenspace_x_scaler_packedfloat) >> 16; | |
4668 v24 = p->pActorBuffs[3].uPower; | |
4669 v0->_screenspace_x_scaler_packedfloat = v23; | |
4670 a5b = (unsigned __int64)(65536 / v24 * (signed __int64)v0->_screenspace_y_scaler_packedfloat) >> 16; | |
4671 LABEL_43: | |
4672 v0->_screenspace_y_scaler_packedfloat = a5b; | |
4673 goto LABEL_44; | |
4674 } | |
4675 } | |
4676 LABEL_44: | |
4677 HIWORD(v25) = HIWORD(x); | |
4678 v0->world_x = a1a; | |
4679 v0->world_y = a2; | |
4680 v0->world_z = a3; | |
4681 v0->uScreenSpaceX = v43; | |
4682 v0->uScreenSpaceY = a6; | |
4683 LOWORD(v25) = 0; | |
4684 LOBYTE(v26) = v41; | |
4685 | |
4686 //v0->sZValue = v25 + (PID(OBJECT_Actor,i)); | |
4687 v0->actual_z = HIWORD(x); | |
4688 v0->object_pid = PID(OBJECT_Actor,i); | |
4689 | |
4690 v29 = HIDWORD(p->pActorBuffs[5].uExpireTime) == 0; | |
4691 v30 = HIDWORD(p->pActorBuffs[5].uExpireTime) < 0; | |
4692 v0->field_1E = v41; | |
4693 v0->pSpriteFrame = v10; | |
4694 v0->uTintColor = pMonsterList->pMonsters[p->pMonsterInfo.uID - 1].uTintColor; | |
4695 if ( !v30 && (!(v30 | v29) || LODWORD(p->pActorBuffs[5].uExpireTime)) ) | |
4696 { | |
4697 HIBYTE(v26) = HIBYTE(v41) | 1; | |
4698 v0->field_1E = v26; | |
4699 } | |
4700 | |
4701 _continue: | |
4702 ; | |
4703 } | |
4704 } | |
4705 //----- (0044028F) -------------------------------------------------------- | |
4706 void PrepareItemsRenderList_BLV() | |
4707 { | |
4708 ObjectDesc *v1; // ebx@4 | |
4709 __int16 v2; // ax@5 | |
4710 RenderBillboard *v3; // esi@12 | |
4711 SpriteFrame *v4; // eax@12 | |
4712 SpriteFrame *v5; // ebx@12 | |
4713 unsigned int v6; // eax@12 | |
4714 int v7; // ecx@12 | |
4715 int v8; // edx@12 | |
4716 int v9; // ecx@12 | |
4717 unsigned __int16 v10; // ax@12 | |
4718 int *v11; // eax@20 | |
4719 //char v12; // zf@26 | |
4720 __int64 v18; // ST5C_4@27 | |
4721 signed __int64 v19; // qtt@28 | |
4722 int v20; // ST5C_4@28 | |
4723 //int v21; // edx@29 | |
4724 __int16 v22; // ax@29 | |
4725 //int v23; // eax@29 | |
4726 SpriteFrame *v24; // [sp+1Ch] [bp-40h]@12 | |
4727 //__int16 a5; // [sp+28h] [bp-34h]@12 | |
4728 int a6; // [sp+2Ch] [bp-30h]@12 | |
4729 int a2; // [sp+30h] [bp-2Ch]@12 | |
4730 int a1; // [sp+34h] [bp-28h]@12 | |
4731 int v30; // [sp+38h] [bp-24h]@12 | |
4732 int v31; // [sp+38h] [bp-24h]@27 | |
4733 int a3; // [sp+40h] [bp-1Ch]@12 | |
4734 signed __int16 v34; // [sp+44h] [bp-18h]@14 | |
4735 int v35; // [sp+48h] [bp-14h]@25 | |
4736 int v36; // [sp+4Ch] [bp-10h]@25 | |
4737 signed int z; // [sp+50h] [bp-Ch]@24 | |
4738 signed int y; // [sp+54h] [bp-8h]@24 | |
4739 signed int x; // [sp+58h] [bp-4h]@24 | |
4740 | |
4741 for (uint i = 0; i < uNumSpriteObjects; ++i) | |
4742 { | |
4743 auto p = &pSpriteObjects[i]; | |
4744 if (p->uObjectDescID) | |
4745 { | |
4746 v1 = &pObjectList->pObjects[p->uObjectDescID]; | |
4747 if ( !(v1->uFlags & 1) ) | |
4748 { | |
4749 if ( ((v2 = p->uType, v2 < 1000) || v2 >= 10000) | |
4750 && (v2 < 500 || v2 >= 600) | |
4751 && (v2 < 811 || v2 >= 815) | |
4752 || pGame->pStru6Instance->_4A81CA(p)) | |
4753 { | |
4754 //a5 = p->uSectorID; | |
4755 a1 = p->vPosition.x; | |
4756 a2 = p->vPosition.y; | |
4757 a3 = p->vPosition.z; | |
4758 v3 = &pBillboardRenderList[uNumBillboardsToDraw]; | |
4759 v4 = pSpriteFrameTable->GetFrame(v1->uSpriteID, p->uSpriteFrameID); | |
4760 v5 = v4; | |
4761 v24 = v4; | |
4762 v30 = v4->uFlags; | |
4763 a6 = v4->uGlowRadius * p->field_22_glow_radius_multiplier; | |
4764 v6 = stru_5C6E00->Atan2(p->vPosition.x - pBLVRenderParams->vPartyPos.x, | |
4765 p->vPosition.y - pBLVRenderParams->vPartyPos.y); | |
4766 LOWORD(v7) = p->uFacing; | |
4767 v8 = v30; | |
4768 v9 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v7 - v6) >> 8) & 7; | |
4769 v10 = v5->pHwSpriteIDs[v9]; | |
4770 v3->uHwSpriteID = v10; | |
4771 if ( v30 & 0x20 ) | |
4772 { | |
4773 v8 = v30; | |
4774 a3 -= (signed int)((unsigned __int64)(v5->scale * (signed __int64)pSprites_LOD->pSpriteHeaders[(signed __int16)v10].uHeight) >> 16) >> 1; | |
4775 } | |
4776 v34 = 0; | |
4777 if ( v8 & 2 ) | |
4778 v34 = 2; | |
4779 if ( v8 & 0x40000 ) | |
4780 v34 |= 0x40u; | |
4781 if ( v8 & 0x20000 ) | |
4782 LOBYTE(v34) = v34 | 0x80; | |
4783 v11 = (int *)(256 << v9); | |
4784 if ( (256 << v9) & v8 ) | |
4785 v34 |= 4u; | |
4786 if ( a6 ) | |
4787 { | |
4788 LOBYTE(v11) = byte_4E94D3; | |
4789 pMobileLightsStack->AddLight( | |
4790 a1, | |
4791 a2, | |
4792 a3, | |
4793 p->uSectorID, | |
4794 a6, | |
4795 v1->uParticleTrailColorR, | |
4796 v1->uParticleTrailColorG, | |
4797 v1->uParticleTrailColorB, | |
4798 byte_4E94D3); | |
4799 } | |
4800 if ( pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible( | |
4801 a1, | |
4802 a2, | |
4803 a3, | |
4804 &x, | |
4805 &y, | |
4806 &z, | |
4807 1) ) | |
4808 { | |
4809 pGame->pIndoorCameraD3D->Project(x, y, z, &v36, &v35); | |
4810 | |
4811 assert(uNumBillboardsToDraw < 500); | |
4812 //if ( (signed int)uNumBillboardsToDraw >= 500 ) | |
4813 // return; | |
4814 ++uNumBillboardsToDraw; | |
4815 ++uNumSpritesDrawnThisFrame; | |
4816 p->uAttributes |= 1u; | |
4817 //v12 = pRenderer->pRenderD3D == 0; | |
4818 v3->uPalette = v24->uPaletteIndex; | |
4819 v3->uIndoorSectorID = p->uSectorID; | |
4820 if ( pRenderer->pRenderD3D ) | |
4821 { | |
4822 v3->fov_x = pGame->pIndoorCameraD3D->fov_x; | |
4823 v3->fov_y = pGame->pIndoorCameraD3D->fov_y; | |
4824 LODWORD(v18) = 0; | |
4825 HIDWORD(v18) = (int)floorf(v3->fov_x + 0.5f); | |
4826 v18 = v18 / x; | |
4827 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v24->scale * v18) >> 16; | |
4828 v31 = (unsigned __int64)(v24->scale * v18) >> 16; | |
4829 } | |
4830 else | |
4831 { | |
4832 LODWORD(v19) = pBLVRenderParams->field_40 << 16; | |
4833 HIDWORD(v19) = pBLVRenderParams->field_40 >> 16; | |
4834 v20 = v19 / x; | |
4835 v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v24->scale * v19 / x) >> 16; | |
4836 v31 = (unsigned __int64)(v24->scale * (signed __int64)v20) >> 16; | |
4837 } | |
4838 //HIWORD(v21) = HIWORD(x); | |
4839 //LOWORD(v21) = 0; | |
4840 v3->_screenspace_y_scaler_packedfloat = v31; | |
4841 v3->field_1E = v34; | |
4842 v3->world_x = a1; | |
4843 v3->world_y = a2; | |
4844 v3->world_z = a3; | |
4845 v3->uScreenSpaceX = v36; | |
4846 v22 = v35; | |
4847 v3->uTintColor = 0; | |
4848 v3->uScreenSpaceY = v22; | |
4849 //v23 = 8 * i; | |
4850 //LOBYTE(v23) = PID(OBJECT_Item,i); | |
4851 v3->pSpriteFrame = v24; | |
4852 //v12 = (p->uAttributes & 0x20) == 0; | |
4853 //v3->sZValue = v21 + v23; | |
4854 v3->actual_z = HIWORD(x); | |
4855 v3->object_pid = PID(OBJECT_Item,i); | |
4856 if (p->uAttributes & 0x20) | |
4857 { | |
4858 if ( !pRenderer->pRenderD3D ) | |
4859 v3->sZValue = 0; | |
4860 } | |
4861 } | |
4862 } | |
4863 } | |
4864 } | |
4865 } | |
4866 } | |
4867 | |
4868 //----- (00440639) -------------------------------------------------------- | |
4869 void AddBspNodeToRenderList(unsigned int node_id) | |
4870 { | |
4871 BLVSector *pSector; // esi@1 | |
4872 | |
4873 pSector = &pIndoor->pSectors[pBspRenderer->nodes[node_id].uSectorID]; | |
4874 if ( pRenderer->pRenderD3D ) | |
4875 { | |
4876 for (uint i = 0; i < pSector->uNumNonBSPFaces; ++i) | |
4877 //Log::Warning(L"Non-BSP face: %X", v3->pFaceIDs[v2]); | |
4878 pBspRenderer->AddFaceToRenderList_d3d(node_id, pSector->pFaceIDs[i]); | |
4879 } | |
4880 else | |
4881 { | |
4882 for (uint i = 0; i < pSector->uNumNonBSPFaces; ++i) | |
4883 pBspRenderer->AddFaceToRenderList_sw(node_id, pSector->pFaceIDs[i]); | |
4884 } | |
4885 if ( pSector->field_0 & 0x10 ) | |
4886 sub_4406BC(node_id, pSector->uFirstBSPNode); | |
4887 } | |
4888 | |
4889 //----- (004406BC) -------------------------------------------------------- | |
4890 void __fastcall sub_4406BC(unsigned int node_id, unsigned int uFirstNode) | |
4891 { | |
4892 BLVSector *pSector; // esi@2 | |
4893 BSPNode *pNode; // edi@2 | |
4894 BLVFace *pFace; // eax@2 | |
4895 int v5; // ecx@2 | |
4896 __int16 v6; // ax@6 | |
4897 int v7; // ebp@10 | |
4898 int v8; // ebx@10 | |
4899 __int16 v9; // di@18 | |
4900 //int v10; // [sp+10h] [bp-Ch]@1 | |
4901 //bool v11; // [sp+14h] [bp-8h]@5 | |
4902 BspRenderer_stru0 *node; // [sp+18h] [bp-4h]@1 | |
4903 | |
4904 //Log::Warning(L"sub_4406BC(%u, %u)", a1, uFirstNode); | |
4905 | |
4906 //v10 = a1; | |
4907 node = &pBspRenderer->nodes[node_id]; | |
4908 while ( 1 ) | |
4909 { | |
4910 pSector = &pIndoor->pSectors[node->uSectorID]; | |
4911 pNode = &pIndoor->pNodes[uFirstNode]; | |
4912 pFace = &pIndoor->pFaces[pSector->pFaceIDs[pNode->uCoplanarOffset]]; | |
4913 v5 = pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x | |
4914 + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z;//plane equation | |
4915 if (pFace->Portal() && pFace->uSectorID != node->uSectorID ) | |
4916 v5 = -v5; | |
4917 //v11 = v5 > 0; | |
4918 if ( v5 <= 0 ) | |
4919 v6 = pNode->uFront; | |
4920 else | |
4921 v6 = pNode->uBack; | |
4922 if ( v6 != -1 ) | |
4923 sub_4406BC(node_id, v6); | |
4924 v7 = pNode->uCoplanarOffset; | |
4925 v8 = v7 + pNode->uCoplanarSize; | |
4926 | |
4927 //Log::Warning(L"Node %u: %X to %X (%hX)", uFirstNode, v7, v8, v2->pFaceIDs[v7]); | |
4928 | |
4929 if ( pRenderer->pRenderD3D ) | |
4930 { | |
4931 while ( v7 < v8 ) | |
4932 pBspRenderer->AddFaceToRenderList_d3d(node_id, pSector->pFaceIDs[v7++]); | |
4933 } | |
4934 else | |
4935 { | |
4936 while ( v7 < v8 ) | |
4937 pBspRenderer->AddFaceToRenderList_sw(node_id, pSector->pFaceIDs[v7++]); | |
4938 } | |
4939 v9 = v5 > 0 ? pNode->uFront : pNode->uBack; | |
4940 if ( v9 == -1 ) | |
4941 break; | |
4942 uFirstNode = v9; | |
4943 } | |
4944 } | |
4945 //----- (0043FA33) -------------------------------------------------------- | |
4946 void __fastcall PrepareDecorationsRenderList_BLV(unsigned int uDecorationID, unsigned int uSectorID) | |
4947 { | |
4948 LevelDecoration *v2; // esi@1 | |
4949 DecorationDesc *v3; // ebx@2 | |
4950 __int16 v4; // ax@2 | |
4951 double v5; // st7@3 | |
4952 int v6; // eax@5 | |
4953 int v7; // edx@5 | |
4954 unsigned int v8; // edi@5 | |
4955 int v9; // edi@5 | |
4956 int v10; // eax@7 | |
4957 SpriteFrame *v11; // eax@7 | |
4958 SpriteFrame *v12; // esi@7 | |
4959 int v13; // eax@7 | |
4960 int v14; // ebx@16 | |
4961 RenderBillboard *v15; // ecx@17 | |
4962 char v16; // zf@18 | |
4963 IndoorCameraD3D **v17; // eax@19 | |
4964 double v18; // st7@19 | |
4965 //float v19; // eax@19 | |
4966 signed __int64 v20; // qtt@19 | |
4967 signed __int64 v21; // qtt@20 | |
4968 //int v22; // edx@21 | |
4969 //int v23; // eax@21 | |
4970 Particle_sw local_0; // [sp+Ch] [bp-A0h]@3 | |
4971 //double v25; // [sp+74h] [bp-38h]@19 | |
4972 //unsigned int v26; // [sp+7Ch] [bp-30h]@1 | |
4973 int a2; // [sp+80h] [bp-2Ch]@5 | |
4974 int a3; // [sp+84h] [bp-28h]@5 | |
4975 int a1; // [sp+88h] [bp-24h]@5 | |
4976 int v30; // [sp+8Ch] [bp-20h]@7 | |
4977 //float v31; // [sp+90h] [bp-1Ch]@1 | |
4978 int a5; // [sp+94h] [bp-18h]@17 | |
4979 int z; // [sp+98h] [bp-14h]@15 | |
4980 int a6; // [sp+9Ch] [bp-10h]@17 | |
4981 int y; // [sp+A0h] [bp-Ch]@15 | |
4982 int x; // [sp+A4h] [bp-8h]@15 | |
4983 int v37; // [sp+A8h] [bp-4h]@5 | |
4984 | |
4985 //v26 = uDecorationID; | |
4986 //LODWORD(v31) = uSectorID; | |
4987 v2 = &pLevelDecorations[uDecorationID]; | |
4988 if (v2->field_2 & 0x20) | |
4989 return; | |
4990 | |
4991 v3 = &pDecorationList->pDecorations[v2->uDecorationDescID]; | |
4992 v4 = v3->uFlags; | |
4993 if (v3->uFlags & DECORATION_EMITS_FIRE) | |
4994 { | |
4995 memset(&local_0, 0, 0x68u); // fire, like at the Pit's tavern | |
4996 v5 = (double)v2->vPosition.x; | |
4997 local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; | |
4998 local_0.uDiffuse = 0xFF3C1E; | |
4999 local_0.x = v5; | |
5000 local_0.y = (double)v2->vPosition.y; | |
5001 local_0.z = (double)v2->vPosition.z; | |
1390 | 5002 local_0.r = 0.0; |
5003 local_0.g = 0.0; | |
5004 local_0.b = 0.0; | |
1295 | 5005 local_0.flt_28 = 1.0; |
5006 local_0.timeToLive = (rand() & 0x80) + 128; | |
5007 local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); | |
5008 pGame->pParticleEngine->AddParticle(&local_0); | |
5009 return; | |
5010 } | |
5011 | |
5012 | |
5013 if (v4 & DECORATION_DONT_DRAW) | |
5014 return; | |
5015 | |
5016 v6 = v2->vPosition.x; | |
5017 v7 = v2->vPosition.z; | |
5018 a2 = v2->vPosition.y; | |
5019 a1 = v6; | |
5020 a3 = v7; | |
5021 v8 = v2->field_10_y_rot | |
5022 + ((signed int)stru_5C6E00->uIntegerPi >> 3) | |
5023 - stru_5C6E00->Atan2(v6 - pBLVRenderParams->vPartyPos.x, a2 - pBLVRenderParams->vPartyPos.y); | |
5024 v37 = pBLVRenderParams->field_0_timer_; | |
5025 v9 = ((signed int)(stru_5C6E00->uIntegerPi + v8) >> 8) & 7; | |
5026 if (pParty->bTurnBasedModeOn) | |
5027 v37 = pMiscTimer->uTotalGameTimeElapsed; | |
5028 v10 = abs(v2->vPosition.x + v2->vPosition.y); | |
5029 v11 = pSpriteFrameTable->GetFrame(v3->uSpriteID, v37 + v10); | |
5030 v30 = 0; | |
5031 v12 = v11; | |
5032 v13 = v11->uFlags; | |
5033 if ( v13 & 2 ) | |
5034 v30 = 2; | |
5035 if ( v13 & 0x40000 ) | |
5036 v30 |= 0x40u; | |
5037 if ( v13 & 0x20000 ) | |
5038 LOBYTE(v30) = v30 | 0x80; | |
5039 if ( (256 << v9) & v13 ) | |
5040 v30 |= 4u; | |
5041 if ( pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(a1, a2, a3, &x, &y, &z, 1) ) | |
5042 { | |
5043 v14 = abs(x); | |
5044 if ( v14 >= abs(y) ) | |
5045 { | |
5046 pGame->pIndoorCameraD3D->Project(x, y, z, &a5, &a6); | |
5047 | |
5048 v15 = &pBillboardRenderList[uNumBillboardsToDraw]; | |
5049 assert(uNumBillboardsToDraw < 500); | |
5050 | |
5051 ++uNumBillboardsToDraw; | |
5052 ++uNumDecorationsDrawnThisFrame; | |
5053 v16 = pRenderer->pRenderD3D == 0; | |
5054 v15->uHwSpriteID = v12->pHwSpriteIDs[v9]; | |
5055 v15->uPalette = v12->uPaletteIndex; | |
5056 v15->uIndoorSectorID = uSectorID; | |
5057 if ( v16 ) | |
5058 { | |
5059 LODWORD(v21) = pBLVRenderParams->field_40 << 16; | |
5060 HIDWORD(v21) = pBLVRenderParams->field_40 >> 16; | |
5061 v37 = v21 / x; | |
5062 //LODWORD(v31) = v12->scale; | |
5063 v37 = v21 / x; | |
5064 v15->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v12->scale * v21 / x) >> 16; | |
5065 v37 = (unsigned __int64)(v12->scale * (signed __int64)v37) >> 16; | |
5066 } | |
5067 else | |
5068 { | |
5069 v17 = &pGame->pIndoorCameraD3D; | |
5070 v15->fov_x = pGame->pIndoorCameraD3D->fov_x; | |
5071 v18 = (*v17)->fov_y; | |
5072 //v19 = v15->fov_x; | |
5073 v15->fov_y = v18; | |
5074 //v31 = v19; | |
5075 //v25 = v19 + 6.7553994e15; | |
5076 //v25 = floorf(v15->fov_x + 0.5f); | |
5077 LODWORD(v20) = 0; | |
5078 HIDWORD(v20) = floorf(v15->fov_x + 0.5f); | |
5079 v37 = v20 / x; | |
5080 //LODWORD(v31) = v12->scale; | |
5081 v37 = (unsigned __int64)(v12->scale * v20 / x) >> 16; | |
5082 v15->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v12->scale * v20 / x) >> 16; | |
5083 //v31 = v15->fov_y; | |
5084 //v25 = v31 + 6.7553994e15; | |
5085 //v25 = floorf(v15->fov_y + 0.5f); | |
5086 LODWORD(v20) = 0; | |
5087 HIDWORD(v20) = floorf(v15->fov_y + 0.5f); | |
5088 v37 = v20 / x; | |
5089 v37 = (unsigned __int64)(v12->scale * v20 / x) >> 16; | |
5090 } | |
5091 //HIWORD(v22) = HIWORD(x); | |
5092 //LOWORD(v22) = 0; | |
5093 v15->_screenspace_y_scaler_packedfloat = v37; | |
5094 v15->field_1E = v30; | |
5095 v15->world_x = a1; | |
5096 v15->world_y = a2; | |
5097 v15->world_z = a3; | |
5098 v15->uScreenSpaceX = a5; | |
5099 v15->uScreenSpaceY = a6; | |
5100 //v23 = 8 * uDecorationID; | |
5101 //LOBYTE(v23) = PID(OBJECT_Decoration,uDecorationID); | |
5102 | |
5103 //v15->sZValue = v22 + v23; | |
5104 v15->actual_z = HIWORD(x); | |
5105 v15->object_pid = PID(OBJECT_Decoration,uDecorationID); | |
5106 | |
5107 v15->uTintColor = 0; | |
5108 v15->pSpriteFrame = v12; | |
5109 } | |
5110 } | |
5111 } | |
5112 //----- (0043F953) -------------------------------------------------------- | |
5113 void PrepareBspRenderList_BLV() | |
5114 { | |
5115 pBspRenderer->num_faces = 0; | |
5116 | |
5117 if (pBLVRenderParams->uPartySectorID) | |
5118 { | |
5119 pBspRenderer->nodes[0].uSectorID = pBLVRenderParams->uPartySectorID; | |
5120 pBspRenderer->nodes[0].uViewportW = pBLVRenderParams->uViewportW; | |
5121 pBspRenderer->nodes[0].uViewportZ = pBLVRenderParams->uViewportZ; | |
5122 pBspRenderer->nodes[0].uViewportY = pBLVRenderParams->uViewportY; | |
5123 pBspRenderer->nodes[0].uViewportX = pBLVRenderParams->uViewportX; | |
1376 | 5124 pBspRenderer->nodes[0].PortalScreenData.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY, |
1295 | 5125 pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW); |
5126 pBspRenderer->nodes[0].uFaceID = -1; | |
5127 pBspRenderer->nodes[0].viewing_portal_id = -1; | |
5128 pBspRenderer->num_nodes = 1; | |
5129 AddBspNodeToRenderList(0); | |
5130 } | |
5131 | |
5132 pBspRenderer->MakeVisibleSectorList(); | |
5133 } | |
5134 | |
5135 //----- (0043F9E1) -------------------------------------------------------- | |
1376 | 5136 void BspRenderer_PortalViewportData::GetViewportData(__int16 x, int y, __int16 z, int w) |
1295 | 5137 { |
5138 _viewport_space_y = y; | |
5139 _viewport_space_w = w; | |
5140 | |
5141 for (uint i = 0; i < 480; ++i) | |
5142 { | |
5143 if ( i < y || i > w ) | |
5144 { | |
5145 viewport_left_side[i] = 640; | |
5146 viewport_right_side[i] = -1; | |
5147 } | |
5148 else | |
5149 { | |
5150 viewport_left_side[i] = x; | |
5151 viewport_right_side[i] = z; | |
5152 } | |
5153 } | |
5154 } | |
5155 //----- (0048653D) -------------------------------------------------------- | |
5156 int stru149::_48653D(int a2, int a3, int a4, int a5, int a6, int a7)//portal frustum culling | |
5157 { | |
5158 stru149 *v7; // esi@1 | |
5159 int v8; // edi@1 | |
5160 int v9; // eax@1 | |
5161 //int v10; // edx@1 | |
5162 //int v11; // ecx@1 | |
5163 int v12; // eax@1 | |
5164 int v13; // ebx@2 | |
5165 int v14; // ecx@2 | |
5166 int v15; // eax@2 | |
5167 int v16; // ST14_4@3 | |
5168 int v17; // ST10_4@3 | |
5169 int v18; // eax@5 | |
5170 int v19; // ST10_4@6 | |
5171 int v20; // eax@8 | |
5172 int v21; // ST10_4@9 | |
5173 int v22; // eax@10 | |
5174 int v23; // ecx@10 | |
5175 int v24; // eax@10 | |
5176 int result; // eax@10 | |
5177 //int v26; // [sp+14h] [bp-14h]@1 | |
5178 int v27; // [sp+18h] [bp-10h]@1 | |
5179 int v28; // [sp+1Ch] [bp-Ch]@1 | |
5180 int v29; // [sp+24h] [bp-4h]@1 | |
5181 int v30; // [sp+30h] [bp+8h]@10 | |
5182 int v31; // [sp+3Ch] [bp+14h]@10 | |
5183 | |
5184 v7 = this; | |
5185 v8 = stru_5C6E00->Cos(pBLVRenderParams->sPartyRotY); | |
5186 v29 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotY); | |
5187 v28 = stru_5C6E00->Cos(pBLVRenderParams->sPartyRotX); | |
5188 v9 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotX); | |
5189 //v11 = -pBLVRenderParams->vPartyPos.y; | |
5190 //v26 = -pBLVRenderParams->vPartyPos.x; | |
5191 v27 = v9; | |
5192 v12 = -pBLVRenderParams->vPartyPos.z; | |
5193 if ( pBLVRenderParams->sPartyRotX ) | |
5194 { | |
5195 v16 = v8 * -pBLVRenderParams->vPartyPos.x + v29 * -pBLVRenderParams->vPartyPos.y; | |
5196 v13 = v28; | |
5197 v17 = -65536 * pBLVRenderParams->vPartyPos.z; | |
5198 v7->field_0_party_dir_x = ((unsigned __int64)(v16 * (signed __int64)v28) >> 16) | |
5199 + ((unsigned __int64)(-65536 * pBLVRenderParams->vPartyPos.z * (signed __int64)v27) >> 16); | |
5200 v7->field_4_party_dir_y = v8 * -pBLVRenderParams->vPartyPos.y - v29 * -pBLVRenderParams->vPartyPos.x; | |
5201 v14 = v27; | |
5202 v15 = ((unsigned __int64)(v17 * (signed __int64)v28) >> 16) - ((unsigned __int64)(v16 * (signed __int64)v27) >> 16); | |
5203 } | |
5204 else | |
5205 { | |
5206 v7->field_0_party_dir_x = v8 * -pBLVRenderParams->vPartyPos.x + v29 * -pBLVRenderParams->vPartyPos.y; | |
5207 v13 = v28; | |
5208 v7->field_4_party_dir_y = v8 * -pBLVRenderParams->vPartyPos.y - v29 * -pBLVRenderParams->vPartyPos.x; | |
5209 v14 = v27; | |
5210 v15 = v12 << 16; | |
5211 } | |
5212 v7->field_8 = v15; | |
5213 if ( pBLVRenderParams->sPartyRotX ) | |
5214 { | |
5215 v19 = ((unsigned __int64)(a2 * (signed __int64)v8) >> 16) + ((unsigned __int64)(a3 * (signed __int64)v29) >> 16); | |
5216 v7->field_C = ((unsigned __int64)(v19 * (signed __int64)v13) >> 16) | |
5217 + ((unsigned __int64)(a4 * (signed __int64)v14) >> 16); | |
5218 v7->field_10 = ((unsigned __int64)(a3 * (signed __int64)v8) >> 16) | |
5219 - ((unsigned __int64)(a2 * (signed __int64)v29) >> 16); | |
5220 v18 = ((unsigned __int64)(a4 * (signed __int64)v13) >> 16) - ((unsigned __int64)(v19 * (signed __int64)v14) >> 16); | |
5221 } | |
5222 else | |
5223 { | |
5224 v7->field_C = ((unsigned __int64)(a2 * (signed __int64)v8) >> 16) | |
5225 + ((unsigned __int64)(a3 * (signed __int64)v29) >> 16); | |
5226 v7->field_10 = ((unsigned __int64)(a3 * (signed __int64)v8) >> 16) | |
5227 - ((unsigned __int64)(a2 * (signed __int64)v29) >> 16); | |
5228 v18 = a4; | |
5229 } | |
5230 v7->field_14 = v18; | |
5231 if ( pBLVRenderParams->sPartyRotX ) | |
5232 { | |
5233 v21 = ((unsigned __int64)(a5 * (signed __int64)v8) >> 16) + ((unsigned __int64)(a6 * (signed __int64)v29) >> 16); | |
5234 v7->field_18 = ((unsigned __int64)(v21 * (signed __int64)v13) >> 16) | |
5235 + ((unsigned __int64)(a7 * (signed __int64)v14) >> 16); | |
5236 v7->field_1C = ((unsigned __int64)(a6 * (signed __int64)v8) >> 16) | |
5237 - ((unsigned __int64)(a5 * (signed __int64)v29) >> 16); | |
5238 v20 = ((unsigned __int64)(a7 * (signed __int64)v13) >> 16) - ((unsigned __int64)(v21 * (signed __int64)v14) >> 16); | |
5239 } | |
5240 else | |
5241 { | |
5242 v7->field_18 = ((unsigned __int64)(a5 * (signed __int64)v8) >> 16) | |
5243 + ((unsigned __int64)(a6 * (signed __int64)v29) >> 16); | |
5244 v7->field_1C = ((unsigned __int64)(a6 * (signed __int64)v8) >> 16) | |
5245 - ((unsigned __int64)(a5 * (signed __int64)v29) >> 16); | |
5246 v20 = a7; | |
5247 } | |
5248 v7->field_18 = -v7->field_18; | |
5249 v7->field_1C = -v7->field_1C; | |
5250 v7->field_20 = v20; | |
5251 v22 = v7->field_C; | |
5252 v7->field_20 = -v7->field_20; | |
5253 v23 = ((unsigned __int64)(v22 * (signed __int64)v7->field_0_party_dir_x) >> 16) | |
5254 + ((unsigned __int64)(v7->field_10 * (signed __int64)v7->field_4_party_dir_y) >> 16) | |
5255 + ((unsigned __int64)(v7->field_14 * (signed __int64)v7->field_8) >> 16); | |
5256 v30 = v7->field_18; | |
5257 v24 = v7->field_0_party_dir_x; | |
5258 v7->field_24 = v23; | |
5259 v31 = (unsigned __int64)(v30 * (signed __int64)v24) >> 16; | |
5260 result = (unsigned __int64)(v7->field_1C * (signed __int64)v7->field_4_party_dir_y) >> 16; | |
5261 v7->field_28 = v31 + result + ((unsigned __int64)(v7->field_20 * (signed __int64)v7->field_8) >> 16); | |
5262 return result; | |
1297 | 5263 } |
5264 //----- (00407A1C) -------------------------------------------------------- | |
5265 bool __fastcall sub_407A1C(int x, int z, int y, Vec3_int_ v) | |
5266 { | |
5267 unsigned int v4; // esi@1 | |
5268 Vec3_int_ v5; // ST08_12@2 | |
5269 int v6; // edi@2 | |
5270 int v7; // ebx@2 | |
5271 int v8; // esi@2 | |
5272 signed int v9; // ecx@2 | |
5273 int v10; // eax@2 | |
5274 int v11; // ecx@4 | |
5275 int v12; // eax@4 | |
5276 int v13; // ebx@4 | |
5277 int v14; // edx@6 | |
5278 char *v15; // edi@16 | |
5279 ODMFace *v16; // esi@19 | |
5280 int v17; // ST34_4@25 | |
5281 int v18; // ST38_4@25 | |
5282 int v19; // eax@25 | |
5283 char v20; // zf@25 | |
5284 int v21; // ebx@25 | |
5285 int v22; // eax@26 | |
5286 signed int v23; // edi@26 | |
5287 int v24; // ST34_4@30 | |
5288 signed __int64 v25; // qtt@31 | |
5289 int v26; // eax@31 | |
5290 Vec3_int_ v27; // ST08_12@37 | |
5291 Vec3_int_ v28; // ST08_12@37 | |
5292 int v29; // edi@37 | |
5293 int v30; // ebx@37 | |
5294 int v31; // esi@37 | |
5295 signed int v32; // ecx@37 | |
5296 int v33; // eax@37 | |
5297 int v34; // ecx@39 | |
5298 int v35; // eax@39 | |
5299 int v36; // ebx@39 | |
5300 int v37; // edx@41 | |
5301 char *v38; // edi@51 | |
5302 ODMFace *v39; // esi@54 | |
5303 int v40; // ebx@60 | |
5304 int v41; // eax@61 | |
5305 signed int v42; // edi@61 | |
5306 signed __int64 v43; // qtt@66 | |
5307 int v44; // eax@66 | |
5308 Vec3_int_ v45; // ST08_12@73 | |
5309 int v46; // edi@73 | |
5310 int v47; // ebx@73 | |
5311 int v48; // esi@73 | |
5312 signed int v49; // ecx@73 | |
5313 int v50; // eax@73 | |
5314 int v51; // edx@75 | |
5315 int v52; // ecx@75 | |
5316 int v53; // eax@75 | |
5317 int v54; // ebx@75 | |
5318 int v55; // edi@77 | |
5319 int v56; // ecx@77 | |
5320 int v57; // eax@81 | |
5321 int v58; // esi@81 | |
5322 int v59; // eax@90 | |
5323 BLVSector *v60; // edx@90 | |
5324 int v61; // ecx@90 | |
5325 BLVFace *v62; // esi@91 | |
5326 int v63; // ST34_4@98 | |
5327 int v64; // ST30_4@98 | |
5328 int v65; // eax@98 | |
5329 int v66; // ebx@98 | |
5330 int v67; // eax@99 | |
5331 signed int v68; // edi@99 | |
5332 int v69; // ST2C_4@103 | |
5333 signed __int64 v70; // qtt@104 | |
5334 int v71; // eax@104 | |
5335 Vec3_int_ v72; // ST08_12@111 | |
5336 Vec3_int_ v73; // ST08_12@111 | |
5337 int v74; // edi@111 | |
5338 int v75; // ebx@111 | |
5339 int v76; // esi@111 | |
5340 signed int v77; // ecx@111 | |
5341 int v78; // eax@111 | |
5342 int v79; // edx@113 | |
5343 int v80; // ecx@113 | |
5344 int v81; // eax@113 | |
5345 int v82; // ebx@113 | |
5346 int v83; // edi@115 | |
5347 int v84; // ecx@115 | |
5348 int v85; // eax@119 | |
5349 int v86; // esi@119 | |
5350 int v87; // ecx@128 | |
5351 BLVSector *v88; // eax@128 | |
5352 int v89; // ecx@128 | |
5353 BLVFace *v90; // esi@129 | |
5354 int v91; // ebx@136 | |
5355 int v92; // eax@137 | |
5356 signed int v93; // edi@137 | |
5357 signed __int64 v94; // qtt@142 | |
5358 int v95; // eax@142 | |
5359 Vec3_int_ v97; // [sp-18h] [bp-94h]@1 | |
5360 int v98; // [sp-Ch] [bp-88h]@88 | |
5361 int v99; // [sp-Ch] [bp-88h]@126 | |
5362 int v100; // [sp-8h] [bp-84h]@88 | |
5363 int v101; // [sp-8h] [bp-84h]@126 | |
5364 int v102; // [sp-4h] [bp-80h]@88 | |
5365 int v103; // [sp-4h] [bp-80h]@126 | |
5366 int v104; // [sp+Ch] [bp-70h]@13 | |
5367 int v105; // [sp+Ch] [bp-70h]@48 | |
5368 int v106; // [sp+10h] [bp-6Ch]@18 | |
5369 int v107; // [sp+10h] [bp-6Ch]@98 | |
5370 int v108; // [sp+10h] [bp-6Ch]@104 | |
5371 int v109; // [sp+18h] [bp-64h]@25 | |
5372 int v110; // [sp+18h] [bp-64h]@31 | |
5373 int i; // [sp+18h] [bp-64h]@90 | |
5374 int v112; // [sp+18h] [bp-64h]@128 | |
5375 signed int v113; // [sp+20h] [bp-5Ch]@1 | |
5376 signed int v114; // [sp+24h] [bp-58h]@1 | |
5377 unsigned __int64 a4; // [sp+28h] [bp-54h]@1 | |
5378 unsigned int a4_8; // [sp+30h] [bp-4Ch]@1 | |
5379 int v117; // [sp+34h] [bp-48h]@4 | |
5380 int v118; // [sp+34h] [bp-48h]@39 | |
5381 int v119; // [sp+34h] [bp-48h]@75 | |
5382 int v120; // [sp+34h] [bp-48h]@113 | |
5383 int v121; // [sp+38h] [bp-44h]@4 | |
5384 int v122; // [sp+38h] [bp-44h]@39 | |
5385 int v123; // [sp+38h] [bp-44h]@76 | |
5386 int v124; // [sp+38h] [bp-44h]@114 | |
5387 int v125; // [sp+3Ch] [bp-40h]@4 | |
5388 int v126; // [sp+3Ch] [bp-40h]@39 | |
5389 int v127; // [sp+3Ch] [bp-40h]@77 | |
5390 int v128; // [sp+3Ch] [bp-40h]@115 | |
5391 int v129; // [sp+40h] [bp-3Ch]@11 | |
5392 int v130; // [sp+40h] [bp-3Ch]@46 | |
5393 int v131; // [sp+40h] [bp-3Ch]@78 | |
5394 int v132; // [sp+40h] [bp-3Ch]@116 | |
5395 int v133; // [sp+44h] [bp-38h]@10 | |
5396 int v134; // [sp+44h] [bp-38h]@45 | |
5397 int v135; // [sp+44h] [bp-38h]@81 | |
5398 int v136; // [sp+44h] [bp-38h]@119 | |
5399 int v137; // [sp+48h] [bp-34h]@7 | |
5400 int v138; // [sp+48h] [bp-34h]@42 | |
5401 int v139; // [sp+48h] [bp-34h]@82 | |
5402 int v140; // [sp+48h] [bp-34h]@120 | |
5403 int v141; // [sp+4Ch] [bp-30h]@6 | |
5404 int v142; // [sp+4Ch] [bp-30h]@41 | |
5405 int v143; // [sp+4Ch] [bp-30h]@75 | |
5406 int v144; // [sp+4Ch] [bp-30h]@113 | |
5407 int v145; // [sp+50h] [bp-2Ch]@5 | |
5408 int v146; // [sp+50h] [bp-2Ch]@40 | |
5409 int v147; // [sp+50h] [bp-2Ch]@75 | |
5410 int v148; // [sp+50h] [bp-2Ch]@113 | |
5411 int v149; // [sp+54h] [bp-28h]@4 | |
5412 int v150; // [sp+54h] [bp-28h]@39 | |
5413 int v151; // [sp+54h] [bp-28h]@75 | |
5414 int v152; // [sp+54h] [bp-28h]@113 | |
5415 int sDepth; // [sp+58h] [bp-24h]@17 | |
5416 int sDeptha; // [sp+58h] [bp-24h]@52 | |
5417 int sDepthb; // [sp+58h] [bp-24h]@90 | |
5418 char *a5; // [sp+5Ch] [bp-20h]@16 | |
5419 char *a5a; // [sp+5Ch] [bp-20h]@51 | |
5420 signed int a5b; // [sp+5Ch] [bp-20h]@83 | |
5421 signed int a5c; // [sp+5Ch] [bp-20h]@121 | |
5422 signed int v160; // [sp+60h] [bp-1Ch]@12 | |
5423 signed int v161; // [sp+60h] [bp-1Ch]@47 | |
5424 int v162; // [sp+60h] [bp-1Ch]@128 | |
5425 int v163; // [sp+64h] [bp-18h]@2 | |
5426 int outx; // [sp+68h] [bp-14h]@2 | |
5427 int outy; // [sp+6Ch] [bp-10h]@2 | |
5428 int outz; // [sp+70h] [bp-Ch]@2 | |
5429 Vec3_int_ pOut; // [sp+74h] [bp-8h]@2 | |
5430 int ya; // [sp+84h] [bp+8h]@60 | |
5431 int yb; // [sp+84h] [bp+8h]@136 | |
5432 int ve; // [sp+88h] [bp+Ch]@60 | |
5433 int va; // [sp+88h] [bp+Ch]@60 | |
5434 int vb; // [sp+88h] [bp+Ch]@66 | |
5435 int vf; // [sp+88h] [bp+Ch]@136 | |
5436 int vc; // [sp+88h] [bp+Ch]@136 | |
5437 int vd; // [sp+88h] [bp+Ch]@142 | |
5438 int v_4; // [sp+8Ch] [bp+10h]@60 | |
5439 int v_4a; // [sp+8Ch] [bp+10h]@65 | |
5440 int v_4b; // [sp+8Ch] [bp+10h]@136 | |
5441 int v_4c; // [sp+8Ch] [bp+10h]@141 | |
5442 int v_8; // [sp+90h] [bp+14h]@53 | |
5443 | |
5444 a4 = __PAIR__(z, x); | |
5445 v4 = stru_5C6E00->Atan2(v.x - x, v.y - z); | |
5446 v114 = 0; | |
5447 v97.z = y; | |
5448 v113 = 0; | |
5449 a4_8 = v4; | |
5450 *(_QWORD *)&v97.x = a4; | |
5451 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor) | |
5452 { | |
5453 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz); | |
5454 v45.z = v.z; | |
5455 *(_QWORD *)&v45.x = *(_QWORD *)&v; | |
5456 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v45, &outx, &outy, &v163); | |
5457 v46 = outy - pOut.y; | |
5458 v47 = v163 - outz; | |
5459 v48 = outx - pOut.x; | |
5460 v49 = integer_sqrt(v48 * v48 + v46 * v46 + v47 * v47); | |
5461 v50 = 65536; | |
5462 if ( v49 ) | |
5463 v50 = 65536 / v49; | |
5464 v51 = outx; | |
5465 v143 = v48 * v50; | |
5466 v52 = v46 * v50; | |
5467 v53 = v47 * v50; | |
5468 v54 = pOut.x; | |
5469 v147 = v52; | |
5470 v151 = v53; | |
5471 v119 = pOut.x; | |
5472 if ( pOut.x < outx ) | |
5473 { | |
5474 v123 = outx; | |
5475 } | |
5476 else | |
5477 { | |
5478 v119 = outx; | |
5479 v123 = pOut.x; | |
5480 } | |
5481 v55 = pOut.y; | |
5482 v56 = outy; | |
5483 v127 = pOut.y; | |
5484 if ( pOut.y < outy ) | |
5485 { | |
5486 v131 = outy; | |
5487 } | |
5488 else | |
5489 { | |
5490 v127 = outy; | |
5491 v131 = pOut.y; | |
5492 } | |
5493 v57 = v163; | |
5494 v58 = outz; | |
5495 v135 = outz; | |
5496 if ( outz < v163 ) | |
5497 { | |
5498 v139 = v163; | |
5499 } | |
5500 else | |
5501 { | |
5502 v135 = v163; | |
5503 v139 = outz; | |
5504 } | |
5505 a5b = 0; | |
5506 while ( !v114 ) | |
5507 { | |
5508 if ( a5b ) | |
5509 { | |
5510 v102 = v58; | |
5511 v100 = v55; | |
5512 v98 = v54; | |
5513 } | |
5514 else | |
5515 { | |
5516 v102 = v57; | |
5517 v100 = v56; | |
5518 v98 = v51; | |
5519 } | |
5520 v59 = pIndoor->GetSector(v98, v100, v102); | |
5521 v60 = pIndoor->pSectors; | |
5522 v61 = 116 * v59; | |
5523 sDepthb = 0; | |
5524 for ( i = 116 * v59; | |
5525 sDepthb < *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v61) | |
5526 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v61); | |
5527 ++sDepthb ) | |
5528 { | |
5529 v62 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v60->pWalls + v61))[sDepthb]]; | |
5530 if ( v62->Portal() | |
5531 || v119 > v62->pBounding.x2 | |
5532 || v123 < v62->pBounding.x1 | |
5533 || v127 > v62->pBounding.y2 | |
5534 || v131 < v62->pBounding.y1 | |
5535 || v135 > v62->pBounding.z2 | |
5536 || v139 < v62->pBounding.z1 | |
5537 || (v63 = (unsigned __int64)(v143 * (signed __int64)v62->pFacePlane_old.vNormal.x) >> 16, | |
5538 v64 = (unsigned __int64)(v151 * (signed __int64)v62->pFacePlane_old.vNormal.z) >> 16, | |
5539 v65 = (unsigned __int64)(v147 * (signed __int64)v62->pFacePlane_old.vNormal.y) >> 16, | |
5540 v20 = v63 + v64 + v65 == 0, | |
5541 v66 = v63 + v64 + v65, | |
5542 v107 = v63 + v64 + v65, | |
5543 v20) ) | |
5544 goto LABEL_107; | |
5545 v67 = outz * v62->pFacePlane_old.vNormal.z; | |
5546 v68 = -(v62->pFacePlane_old.dist | |
5547 + v67 | |
5548 + pOut.y * v62->pFacePlane_old.vNormal.y | |
5549 + pOut.x * v62->pFacePlane_old.vNormal.x); | |
5550 if ( v66 <= 0 ) | |
5551 { | |
5552 if ( v62->pFacePlane_old.dist | |
5553 + v67 | |
5554 + pOut.y * v62->pFacePlane_old.vNormal.y | |
5555 + pOut.x * v62->pFacePlane_old.vNormal.x < 0 ) | |
5556 goto LABEL_107; | |
5557 } | |
5558 else | |
5559 { | |
5560 if ( v62->pFacePlane_old.dist | |
5561 + v67 | |
5562 + pOut.y * v62->pFacePlane_old.vNormal.y | |
5563 + pOut.x * v62->pFacePlane_old.vNormal.x > 0 ) | |
5564 goto LABEL_107; | |
5565 } | |
5566 v69 = abs(-(v62->pFacePlane_old.dist | |
5567 + v67 | |
5568 + pOut.y * v62->pFacePlane_old.vNormal.y | |
5569 + pOut.x * v62->pFacePlane_old.vNormal.x)) >> 14; | |
5570 if ( v69 <= abs(v66) ) | |
5571 { | |
5572 LODWORD(v70) = v68 << 16; | |
5573 HIDWORD(v70) = v68 >> 16; | |
5574 v71 = v70 / v107; | |
5575 v108 = v70 / v107; | |
5576 if ( v71 >= 0 ) | |
5577 { | |
5578 if ( sub_4075DB( | |
5579 pOut.x + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v143) >> 16) + 32768) >> 16), | |
5580 pOut.y + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v147) >> 16) + 32768) >> 16), | |
5581 outz + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v151) >> 16) + 32768) >> 16), | |
5582 v62) ) | |
5583 { | |
5584 v114 = 1; | |
5585 break; | |
5586 } | |
5587 } | |
5588 } | |
5589 v61 = i; | |
5590 LABEL_107: | |
5591 v60 = pIndoor->pSectors; | |
5592 } | |
5593 ++a5b; | |
5594 if ( a5b >= 2 ) | |
5595 break; | |
5596 v57 = v163; | |
5597 v56 = outy; | |
5598 v51 = outx; | |
5599 v58 = outz; | |
5600 v55 = pOut.y; | |
5601 v54 = pOut.x; | |
5602 } | |
5603 v72.z = y; | |
5604 *(_QWORD *)&v72.x = a4; | |
5605 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v72, &pOut.x, &pOut.y, &outz); | |
5606 v73.z = v.z; | |
5607 *(_QWORD *)&v73.x = *(_QWORD *)&v; | |
5608 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v73, &outx, &outy, &v163); | |
5609 v74 = outy - pOut.y; | |
5610 v75 = v163 - outz; | |
5611 v76 = outx - pOut.x; | |
5612 v77 = integer_sqrt(v76 * v76 + v74 * v74 + v75 * v75); | |
5613 v78 = 65536; | |
5614 if ( v77 ) | |
5615 v78 = 65536 / v77; | |
5616 v79 = outx; | |
5617 v144 = v76 * v78; | |
5618 v80 = v74 * v78; | |
5619 v81 = v75 * v78; | |
5620 v82 = pOut.x; | |
5621 v148 = v80; | |
5622 v152 = v81; | |
5623 v120 = pOut.x; | |
5624 if ( pOut.x < outx ) | |
5625 { | |
5626 v124 = outx; | |
5627 } | |
5628 else | |
5629 { | |
5630 v120 = outx; | |
5631 v124 = pOut.x; | |
5632 } | |
5633 v83 = pOut.y; | |
5634 v84 = outy; | |
5635 v128 = pOut.y; | |
5636 if ( pOut.y < outy ) | |
5637 { | |
5638 v132 = outy; | |
5639 } | |
5640 else | |
5641 { | |
5642 v128 = outy; | |
5643 v132 = pOut.y; | |
5644 } | |
5645 v85 = v163; | |
5646 v86 = outz; | |
5647 v136 = outz; | |
5648 if ( outz < v163 ) | |
5649 { | |
5650 v140 = v163; | |
5651 } | |
5652 else | |
5653 { | |
5654 v136 = v163; | |
5655 v140 = outz; | |
5656 } | |
5657 a5c = 0; | |
5658 while ( 1 ) | |
5659 { | |
5660 if ( v113 ) | |
5661 return !v114 || !v113; | |
5662 if ( a5c ) | |
5663 { | |
5664 v103 = v86; | |
5665 v101 = v83; | |
5666 v99 = v82; | |
5667 } | |
5668 else | |
5669 { | |
5670 v103 = v85; | |
5671 v101 = v84; | |
5672 v99 = v79; | |
5673 } | |
5674 v87 = pIndoor->GetSector(v99, v101, v103); | |
5675 v88 = pIndoor->pSectors; | |
5676 v89 = 116 * v87; | |
5677 v162 = 0; | |
5678 v112 = v89; | |
5679 if ( *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v89) | |
5680 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) > 0 ) | |
5681 break; | |
5682 LABEL_148: | |
5683 ++a5c; | |
5684 if ( a5c >= 2 ) | |
5685 return !v114 || !v113; | |
5686 v85 = v163; | |
5687 v84 = outy; | |
5688 v79 = outx; | |
5689 v86 = outz; | |
5690 v83 = pOut.y; | |
5691 v82 = pOut.x; | |
5692 } | |
5693 while ( 1 ) | |
5694 { | |
5695 v90 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v88->pWalls + v89))[v162]]; | |
5696 if ( v90->Portal() | |
5697 || v120 > v90->pBounding.x2 | |
5698 || v124 < v90->pBounding.x1 | |
5699 || v128 > v90->pBounding.y2 | |
5700 || v132 < v90->pBounding.y1 | |
5701 || v136 > v90->pBounding.z2 | |
5702 || v140 < v90->pBounding.z1 | |
5703 || (yb = (unsigned __int64)(v144 * (signed __int64)v90->pFacePlane_old.vNormal.x) >> 16, | |
5704 v_4b = (unsigned __int64)(v148 * (signed __int64)v90->pFacePlane_old.vNormal.y) >> 16, | |
5705 vf = (unsigned __int64)(v152 * (signed __int64)v90->pFacePlane_old.vNormal.z) >> 16, | |
5706 v20 = yb + vf + v_4b == 0, | |
5707 v91 = yb + vf + v_4b, | |
5708 vc = yb + vf + v_4b, | |
5709 v20) ) | |
5710 goto LABEL_145; | |
5711 v92 = outz * v90->pFacePlane_old.vNormal.z; | |
5712 v93 = -(v90->pFacePlane_old.dist | |
5713 + v92 | |
5714 + pOut.y * v90->pFacePlane_old.vNormal.y | |
5715 + pOut.x * v90->pFacePlane_old.vNormal.x); | |
5716 if ( v91 <= 0 ) | |
5717 { | |
5718 if ( v90->pFacePlane_old.dist | |
5719 + v92 | |
5720 + pOut.y * v90->pFacePlane_old.vNormal.y | |
5721 + pOut.x * v90->pFacePlane_old.vNormal.x < 0 ) | |
5722 goto LABEL_145; | |
5723 } | |
5724 else | |
5725 { | |
5726 if ( v90->pFacePlane_old.dist | |
5727 + v92 | |
5728 + pOut.y * v90->pFacePlane_old.vNormal.y | |
5729 + pOut.x * v90->pFacePlane_old.vNormal.x > 0 ) | |
5730 goto LABEL_145; | |
5731 } | |
5732 v_4c = abs(-(v90->pFacePlane_old.dist | |
5733 + v92 | |
5734 + pOut.y * v90->pFacePlane_old.vNormal.y | |
5735 + pOut.x * v90->pFacePlane_old.vNormal.x)) >> 14; | |
5736 if ( v_4c <= abs(v91) ) | |
5737 { | |
5738 LODWORD(v94) = v93 << 16; | |
5739 HIDWORD(v94) = v93 >> 16; | |
5740 v95 = v94 / vc; | |
5741 vd = v94 / vc; | |
5742 if ( v95 >= 0 ) | |
5743 { | |
5744 if ( sub_4075DB( | |
5745 pOut.x + ((signed int)(((unsigned __int64)(vd * (signed __int64)v144) >> 16) + 32768) >> 16), | |
5746 pOut.y + ((signed int)(((unsigned __int64)(vd * (signed __int64)v148) >> 16) + 32768) >> 16), | |
5747 outz + ((signed int)(((unsigned __int64)(vd * (signed __int64)v152) >> 16) + 32768) >> 16), | |
5748 v90) ) | |
5749 { | |
5750 v113 = 1; | |
5751 goto LABEL_148; | |
5752 } | |
5753 } | |
5754 } | |
5755 v89 = v112; | |
5756 LABEL_145: | |
5757 v88 = pIndoor->pSectors; | |
5758 ++v162; | |
5759 if ( v162 >= *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v89) | |
5760 + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) ) | |
5761 goto LABEL_148; | |
5762 } | |
5763 } | |
5764 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz); | |
5765 v5.z = v.z; | |
5766 *(_QWORD *)&v5.x = *(_QWORD *)&v; | |
5767 Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v5, &outx, &outy, &v163); | |
5768 v6 = outy - pOut.y; | |
5769 v7 = v163 - outz; | |
5770 v8 = outx - pOut.x; | |
5771 v9 = integer_sqrt(v8 * v8 + v6 * v6 + v7 * v7); | |
5772 v10 = 65536; | |
5773 if ( v9 ) | |
5774 v10 = 65536 / v9; | |
5775 v125 = v8 * v10; | |
5776 v11 = v10; | |
5777 v12 = v7 * v10; | |
5778 v13 = pOut.x; | |
5779 v117 = v12; | |
5780 v121 = v6 * v11; | |
5781 v149 = pOut.x; | |
5782 if ( pOut.x < outx ) | |
5783 { | |
5784 v145 = outx; | |
5785 } | |
5786 else | |
5787 { | |
5788 v149 = outx; | |
5789 v145 = pOut.x; | |
5790 } | |
5791 v14 = outy; | |
5792 v141 = pOut.y; | |
5793 if ( pOut.y < outy ) | |
5794 { | |
5795 v137 = outy; | |
5796 } | |
5797 else | |
5798 { | |
5799 v141 = outy; | |
5800 v137 = pOut.y; | |
5801 } | |
5802 v133 = outz; | |
5803 if ( outz < v163 ) | |
5804 { | |
5805 v129 = v163; | |
5806 } | |
5807 else | |
5808 { | |
5809 v133 = v163; | |
5810 v129 = outz; | |
5811 } | |
5812 v160 = 0; | |
5813 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
5814 { | |
5815 v104 = 0; | |
5816 while ( 1 ) | |
5817 { | |
5818 v15 = (char *)&pOutdoor->pBModels[v104].pVertices; | |
5819 a5 = (char *)&pOutdoor->pBModels[v104].pVertices; | |
5820 if ( sub_4088E9(v13, pOut.y, outx, v14, pOutdoor->pBModels[v104].vPosition.x, pOutdoor->pBModels[v104].vPosition.y) <= pOutdoor->pBModels[v104].sBoundingRadius + 128 ) | |
5821 { | |
5822 sDepth = 0; | |
5823 if ( *((int *)v15 + 2) > 0 ) | |
5824 break; | |
5825 } | |
5826 LABEL_36: | |
5827 ++v160; | |
5828 ++v104; | |
5829 if ( v160 >= (signed int)pOutdoor->uNumBModels ) | |
5830 goto LABEL_37; | |
5831 v14 = outy; | |
5832 v13 = pOut.x; | |
5833 } | |
5834 v106 = 0; | |
5835 while ( 1 ) | |
5836 { | |
5837 v16 = (ODMFace *)(v106 + *((int *)a5 + 4)); | |
5838 if ( v149 > v16->pBoundingBox.x2 | |
5839 || v145 < v16->pBoundingBox.x1 | |
5840 || v141 > v16->pBoundingBox.y2 | |
5841 || v137 < v16->pBoundingBox.y1 | |
5842 || v133 > v16->pBoundingBox.z2 | |
5843 || v129 < v16->pBoundingBox.z1 | |
5844 || (v17 = (unsigned __int64)(v125 * (signed __int64)v16->pFacePlane.vNormal.x) >> 16, | |
5845 v18 = (unsigned __int64)(v121 * (signed __int64)v16->pFacePlane.vNormal.y) >> 16, | |
5846 v19 = (unsigned __int64)(v117 * (signed __int64)v16->pFacePlane.vNormal.z) >> 16, | |
5847 v20 = v17 + v18 + v19 == 0, | |
5848 v21 = v17 + v18 + v19, | |
5849 v109 = v17 + v18 + v19, | |
5850 v20) ) | |
5851 goto LABEL_33; | |
5852 v22 = pOut.y * v16->pFacePlane.vNormal.y; | |
5853 v23 = -(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x); | |
5854 if ( v21 <= 0 ) | |
5855 { | |
5856 if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x < 0 ) | |
5857 goto LABEL_33; | |
5858 } | |
5859 else | |
5860 { | |
5861 if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x > 0 ) | |
5862 goto LABEL_33; | |
5863 } | |
5864 v24 = abs(-(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x)) >> 14; | |
5865 if ( v24 <= abs(v21) ) | |
5866 { | |
5867 LODWORD(v25) = v23 << 16; | |
5868 HIDWORD(v25) = v23 >> 16; | |
5869 v26 = v25 / v109; | |
5870 v110 = v25 / v109; | |
5871 if ( v26 >= 0 ) | |
5872 { | |
5873 if ( sub_4077F1( | |
5874 pOut.x + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v125) >> 16) + 32768) >> 16), | |
5875 pOut.y + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v121) >> 16) + 32768) >> 16), | |
5876 outz + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v117) >> 16) + 32768) >> 16), | |
5877 v16, | |
5878 (BSPVertexBuffer *)a5) ) | |
5879 { | |
5880 v114 = 1; | |
5881 goto LABEL_36; | |
5882 } | |
5883 } | |
5884 } | |
5885 LABEL_33: | |
5886 ++sDepth; | |
5887 v106 += 308; | |
5888 if ( sDepth >= *((int *)a5 + 2) ) | |
5889 goto LABEL_36; | |
5890 } | |
5891 } | |
5892 LABEL_37: | |
5893 v27.z = y; | |
5894 *(_QWORD *)&v27.x = a4; | |
5895 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v27, &pOut.x, &pOut.y, &outz); | |
5896 v28.z = v.z; | |
5897 *(_QWORD *)&v28.x = *(_QWORD *)&v; | |
5898 Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v28, &outx, &outy, &v163); | |
5899 v29 = outy - pOut.y; | |
5900 v30 = v163 - outz; | |
5901 v31 = outx - pOut.x; | |
5902 v32 = integer_sqrt(v31 * v31 + v29 * v29 + v30 * v30); | |
5903 v33 = 65536; | |
5904 if ( v32 ) | |
5905 v33 = 65536 / v32; | |
5906 v126 = v31 * v33; | |
5907 v34 = v33; | |
5908 v35 = v30 * v33; | |
5909 v36 = pOut.x; | |
5910 v118 = v35; | |
5911 v122 = v29 * v34; | |
5912 v150 = pOut.x; | |
5913 if ( pOut.x < outx ) | |
5914 { | |
5915 v146 = outx; | |
5916 } | |
5917 else | |
5918 { | |
5919 v150 = outx; | |
5920 v146 = pOut.x; | |
5921 } | |
5922 v37 = outy; | |
5923 v142 = pOut.y; | |
5924 if ( pOut.y < outy ) | |
5925 { | |
5926 v138 = outy; | |
5927 } | |
5928 else | |
5929 { | |
5930 v142 = outy; | |
5931 v138 = pOut.y; | |
5932 } | |
5933 v134 = outz; | |
5934 if ( outz < v163 ) | |
5935 { | |
5936 v130 = v163; | |
5937 } | |
5938 else | |
5939 { | |
5940 v134 = v163; | |
5941 v130 = outz; | |
5942 } | |
5943 v161 = 0; | |
5944 if ( (signed int)pOutdoor->uNumBModels > 0 ) | |
5945 { | |
5946 v105 = 0; | |
5947 while ( 1 ) | |
5948 { | |
5949 v38 = (char *)&pOutdoor->pBModels[v105].pVertices; | |
5950 a5a = (char *)&pOutdoor->pBModels[v105].pVertices; | |
5951 if ( sub_4088E9(v36, pOut.y, outx, v37, pOutdoor->pBModels[v105].vPosition.x, pOutdoor->pBModels[v105].vPosition.y) <= pOutdoor->pBModels[v105].sBoundingRadius + 128 ) | |
5952 { | |
5953 sDeptha = 0; | |
5954 if ( *((int *)v38 + 2) > 0 ) | |
5955 break; | |
5956 } | |
5957 LABEL_71: | |
5958 ++v161; | |
5959 ++v105; | |
5960 if ( v161 >= (signed int)pOutdoor->uNumBModels ) | |
5961 return !v114 || !v113; | |
5962 v37 = outy; | |
5963 v36 = pOut.x; | |
5964 } | |
5965 v_8 = 0; | |
5966 while ( 1 ) | |
5967 { | |
5968 v39 = (ODMFace *)(v_8 + *((int *)a5a + 4)); | |
5969 if ( v150 > v39->pBoundingBox.x2 | |
5970 || v146 < v39->pBoundingBox.x1 | |
5971 || v142 > v39->pBoundingBox.y2 | |
5972 || v138 < v39->pBoundingBox.y1 | |
5973 || v134 > v39->pBoundingBox.z2 | |
5974 || v130 < v39->pBoundingBox.z1 | |
5975 || (ya = (unsigned __int64)(v126 * (signed __int64)v39->pFacePlane.vNormal.x) >> 16, | |
5976 ve = (unsigned __int64)(v122 * (signed __int64)v39->pFacePlane.vNormal.y) >> 16, | |
5977 v_4 = (unsigned __int64)(v118 * (signed __int64)v39->pFacePlane.vNormal.z) >> 16, | |
5978 v20 = ya + ve + v_4 == 0, | |
5979 v40 = ya + ve + v_4, | |
5980 va = ya + ve + v_4, | |
5981 v20) ) | |
5982 goto LABEL_68; | |
5983 v41 = pOut.y * v39->pFacePlane.vNormal.y; | |
5984 v42 = -(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x); | |
5985 if ( v40 <= 0 ) | |
5986 { | |
5987 if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x < 0 ) | |
5988 goto LABEL_68; | |
5989 } | |
5990 else | |
5991 { | |
5992 if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x > 0 ) | |
5993 goto LABEL_68; | |
5994 } | |
5995 v_4a = abs(-(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x)) >> 14; | |
5996 if ( v_4a <= abs(v40) ) | |
5997 { | |
5998 LODWORD(v43) = v42 << 16; | |
5999 HIDWORD(v43) = v42 >> 16; | |
6000 v44 = v43 / va; | |
6001 vb = v43 / va; | |
6002 if ( v44 >= 0 ) | |
6003 { | |
6004 if ( sub_4077F1( | |
6005 pOut.x + ((signed int)(((unsigned __int64)(vb * (signed __int64)v126) >> 16) + 32768) >> 16), | |
6006 pOut.y + ((signed int)(((unsigned __int64)(vb * (signed __int64)v122) >> 16) + 32768) >> 16), | |
6007 outz + ((signed int)(((unsigned __int64)(vb * (signed __int64)v118) >> 16) + 32768) >> 16), | |
6008 v39, | |
6009 (BSPVertexBuffer *)a5a) ) | |
6010 { | |
6011 v113 = 1; | |
6012 goto LABEL_71; | |
6013 } | |
6014 } | |
6015 } | |
6016 LABEL_68: | |
6017 ++sDeptha; | |
6018 v_8 += 308; | |
6019 if ( sDeptha >= *((int *)a5a + 2) ) | |
6020 goto LABEL_71; | |
6021 } | |
6022 } | |
6023 return !v114 || !v113; | |
6024 } | |
6025 //----- (0043F333) -------------------------------------------------------- | |
6026 void BspRenderer::MakeVisibleSectorList() | |
6027 { | |
6028 int v6; // ebx@3 | |
6029 | |
6030 uNumVisibleNotEmptySectors = 0; | |
6031 for (uint i = 0; i < num_nodes; ++i) | |
6032 { | |
6033 if (!uNumVisibleNotEmptySectors) | |
6034 { | |
6035 pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = nodes[i].uSectorID; | |
6036 continue; | |
6037 } | |
6038 | |
6039 v6 = 0; | |
6040 while (pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v6] != nodes[i].uSectorID ) | |
6041 { | |
6042 ++v6; | |
6043 if ( v6 >= uNumVisibleNotEmptySectors) | |
6044 { | |
6045 pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = nodes[i].uSectorID; | |
6046 } | |
6047 } | |
6048 | |
6049 } | |
6050 } | |
6051 //----- (0046A334) -------------------------------------------------------- | |
6052 char __fastcall DoInteractionWithTopmostZObject(int a1, int a2) | |
6053 { | |
6054 int v2; // edx@1 | |
6055 BLVFace *v4; // eax@9 | |
6056 unsigned int v5; // ecx@9 | |
6057 unsigned __int16 v6; // ax@11 | |
6058 //ODMFace *v7; // eax@16 | |
6059 LevelDecoration *v8; // esi@19 | |
6060 __int16 v9; // ax@19 | |
6061 int v10; // eax@22 | |
6062 int v11; // ecx@22 | |
6063 int v12; // edi@23 | |
6064 Actor *v13; // esi@23 | |
6065 unsigned __int16 v14; // ax@23 | |
6066 unsigned __int16 v15; // ax@33 | |
6067 const char *v16; // eax@34 | |
6068 int v17; // edi@36 | |
6069 int v18; // eax@36 | |
6070 ItemGen *v19; // esi@39 | |
6071 unsigned int v20; // eax@39 | |
6072 int v21; // ecx@40 | |
6073 std::string v22; // [sp-18h] [bp-2Ch]@5 | |
6074 const char *v23; // [sp-8h] [bp-1Ch]@5 | |
6075 int v24; // [sp-4h] [bp-18h]@5 | |
6076 char v25; // [sp+8h] [bp-Ch]@5 | |
6077 int v26; // [sp+Ch] [bp-8h]@1 | |
6078 int a3; // [sp+13h] [bp-1h]@5 | |
6079 | |
6080 v26 = a2; | |
6081 v2 = a1; | |
6082 switch ( PID_TYPE(a1) ) | |
6083 { | |
6084 case OBJECT_Item: // take the item | |
6085 v17 = PID_ID(a1); | |
6086 v26 = PID_ID(a1); | |
6087 v18 = PID_ID(a1); | |
6088 if ( pObjectList->pObjects[pSpriteObjects[v18].uObjectDescID].uFlags & 0x10 | |
6089 || v17 >= 1000 | |
6090 || !pSpriteObjects[v18].uObjectDescID ) | |
6091 return 1; | |
6092 v19 = &pSpriteObjects[v18].stru_24; | |
6093 v20 = pSpriteObjects[v18].stru_24.uItemID; | |
6094 if ( pItemsTable->pItems[v20].uEquipType == EQUIP_GOLD) | |
6095 { | |
6096 party_finds_gold(v19->uSpecEnchantmentType, 0); | |
6097 viewparams->bRedrawGameUI = 1; | |
6098 v21 = v17; | |
6099 } | |
6100 else | |
6101 { | |
6102 if ( pParty->pPickedItem.uItemID ) | |
6103 return 1; | |
6104 v24 = (int)pItemsTable->pItems[v20].pUnidentifiedName; | |
6105 sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v24); | |
6106 ShowStatusBarString(pTmpBuf2.data(), 2u); | |
6107 if ( v19->uItemID == 506 ) | |
6108 _449B7E_toggle_bit(pParty->_quest_bits, 184, 1u); | |
6109 if ( v19->uItemID == 455 ) | |
6110 _449B7E_toggle_bit(pParty->_quest_bits, 185, 1u); | |
6111 if ( !pParty->AddItem(v19) ) | |
6112 pParty->SetHoldingItem(v19); | |
6113 v21 = v26; | |
6114 } | |
6115 SpriteObject::OnInteraction(v21); | |
6116 break; | |
6117 | |
6118 case OBJECT_Actor: | |
6119 v12 = PID_ID(a1); | |
6120 v13 = &pActors[PID_ID(a1)]; | |
6121 v14 = v13->uAIState; | |
6122 if ( v14 == 4 || v14 == 17 ) | |
6123 return 1; | |
6124 if ( v14 == 5 ) | |
6125 { | |
6126 stru_50C198.LootActor(&pActors[PID_ID(a1)]); | |
6127 } | |
6128 else | |
6129 { | |
6130 if ( !v13->GetActorsRelation(0) && !(BYTE2(v13->uAttributes) & 8) && v13->CanAct() ) | |
6131 { | |
6132 Actor::AI_FaceObject(v12, 4u, 0, 0); | |
6133 if ( v13->sNPC_ID ) | |
6134 { | |
6135 pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v12, 0); | |
6136 } | |
6137 else | |
6138 { | |
6139 v15 = pNPCStats->pGroups_copy[v13->uGroup]; | |
6140 if ( v15 ) | |
6141 { | |
6142 v16 = pNPCStats->pCatchPhrases[v15]; | |
6143 if ( v16 ) | |
6144 { | |
6145 pParty->uFlags |= 2u; | |
6146 strcpy(byte_5B0938.data(), v16); | |
6147 sub_4451A8_press_any_key(0, 0, 0); | |
6148 } | |
6149 } | |
6150 } | |
6151 } | |
6152 } | |
6153 break; | |
6154 | |
6155 case OBJECT_Decoration: | |
6156 v8 = &pLevelDecorations[PID_ID(a1)]; | |
6157 v9 = v8->field_16_event_id; | |
6158 if ( v9 ) | |
6159 { | |
6160 EventProcessor(v9, a1, 1); | |
6161 LOBYTE(v8->field_2) |= 8u; | |
6162 } | |
6163 else | |
6164 { | |
6165 if ( !pLevelDecorations[PID_ID(a1)].IsInteractive() ) | |
6166 return 1; | |
6167 v10 = v8->_idx_in_stru123; | |
6168 v24 = 1; | |
6169 v11 = stru_5E4C90._decor_events[v10 - 75] + 380; | |
6170 activeLevelDecoration = v8; | |
6171 EventProcessor(v11, 0, 1); | |
6172 activeLevelDecoration = NULL; | |
6173 } | |
6174 break; | |
6175 | |
6176 default: | |
6177 MessageBoxW(nullptr, L"Warning: Invalid ID reached!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Mouse.cpp:2020", 0); | |
6178 return 1; | |
6179 | |
6180 case OBJECT_BModel: | |
6181 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | |
6182 { | |
6183 int bmodel_id = a1 >> 9, | |
6184 face_id = PID_ID(a1) & 0x3F; | |
6185 if (bmodel_id >= pOutdoor->uNumBModels) | |
6186 return 1; | |
6187 auto face = &pOutdoor->pBModels[bmodel_id].pFaces[face_id]; | |
6188 if (face->uAttributes & 0x100000 || face->sCogTriggeredID == 0 ) | |
6189 return 1; | |
6190 EventProcessor((signed __int16)face->sCogTriggeredID, v2, 1); | |
6191 } | |
6192 else | |
6193 { | |
6194 v4 = &pIndoor->pFaces[PID_ID(a1)]; | |
6195 v5 = v4->uAttributes; | |
6196 if ( !(v5 & 0x2000000) ) | |
6197 { | |
6198 ShowNothingHereStatus(); | |
6199 return 1; | |
6200 } | |
6201 if ( v5 & 0x100000 || (v6 = pIndoor->pFaceExtras[v4->uFaceExtraID].uEventID) == 0 ) | |
6202 return 1; | |
6203 if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG ) | |
6204 EventProcessor((signed __int16)v6, v2, 1); | |
6205 } | |
6206 return 0; | |
6207 break; | |
6208 } | |
6209 return 0; | |
6210 } | |
6211 //----- (0046BDF1) -------------------------------------------------------- | |
6212 void __cdecl BLV_UpdateUserInputAndOther() | |
6213 { | |
6214 UpdateObjects(); | |
6215 BLV_ProcessPartyActions(); | |
6216 UpdateActors_BLV(); | |
6217 BLV_UpdateDoors(); | |
6218 check_event_triggers(); | |
6219 } | |
6220 //----- (00424829) -------------------------------------------------------- | |
1378 | 6221 // Finds out if current portal can be seen through the previous portal |
1376 | 6222 bool PortalFrustrum(int pNumVertices, BspRenderer_PortalViewportData *far_portal, BspRenderer_PortalViewportData *near_portal, int uFaceID) |
1297 | 6223 { |
6224 int min_y; // esi@5 | |
6225 int max_y; // edx@5 | |
1372 | 6226 int current_ID; // eax@12 |
1297 | 6227 int v13; // eax@22 |
6228 int v15; // ecx@29 | |
6229 int v18; // eax@39 | |
6230 int v19; // eax@44 | |
6231 int v20; // ecx@44 | |
6232 int v22; // edi@46 | |
6233 int v24; // edx@48 | |
6234 int v26; // eax@55 | |
6235 signed int v27; // edi@55 | |
6236 int v29; // edx@57 | |
6237 int v31; // eax@64 | |
6238 signed int v32; // edi@64 | |
6239 int v34; // eax@66 | |
6240 int v35; // dx@66 | |
6241 __int16 v36; // dx@67 | |
1379 | 6242 //__int16 v37; // di@67 |
1297 | 6243 __int16 v38; // dx@67 |
6244 int v46; // edx@87 | |
6245 int v49; // esi@93 | |
6246 int v53; // [sp+Ch] [bp-34h]@44 | |
6247 int v54; // [sp+10h] [bp-30h]@0 | |
1372 | 6248 int min_y_ID2; // [sp+14h] [bp-2Ch]@12 |
1297 | 6249 int v59; // [sp+14h] [bp-2Ch]@87 |
6250 int v61; // [sp+1Ch] [bp-24h]@29 | |
6251 int v62; // [sp+20h] [bp-20h]@0 | |
1372 | 6252 signed int direction1; // [sp+24h] [bp-1Ch]@3 |
6253 signed int direction2; // [sp+28h] [bp-18h]@3 | |
6254 int min_y_ID; // [sp+2Ch] [bp-14h]@5 | |
1297 | 6255 int v69; // [sp+34h] [bp-Ch]@29 |
6256 int v70; // [sp+34h] [bp-Ch]@46 | |
1370 | 6257 |
1297 | 6258 if ( pNumVertices <= 1 ) |
6259 return false; | |
1344 | 6260 min_y = PortalFace._screen_space_y[0]; |
1372 | 6261 min_y_ID = 0; |
1344 | 6262 max_y = PortalFace._screen_space_y[0]; |
1372 | 6263 //face direction(направление фейса) |
1344 | 6264 if ( !PortalFace.direction ) |
1297 | 6265 { |
1372 | 6266 direction1 = 1; |
6267 direction2 = -1; | |
1297 | 6268 } |
6269 else | |
6270 { | |
1372 | 6271 direction1 = -1; |
6272 direction2 = 1; | |
6273 } | |
6274 | |
6275 //get min and max y for portal(дать минимальное и максимальное значение y для портала) | |
6276 for ( uint i = 1; i < pNumVertices; ++i ) | |
6277 { | |
1378 | 6278 if (PortalFace._screen_space_y[i] < min_y) |
1297 | 6279 { |
1372 | 6280 min_y_ID = i; |
6281 min_y = PortalFace._screen_space_y[i]; | |
1297 | 6282 } |
1378 | 6283 else if (PortalFace._screen_space_y[i] > max_y) |
6284 { | |
6285 max_y = PortalFace._screen_space_y[i]; | |
6286 } | |
1297 | 6287 } |
6288 if ( max_y == min_y ) | |
6289 return false; | |
6290 | |
1372 | 6291 //***************************************************************************************************************************** |
1376 | 6292 far_portal->_viewport_space_y = min_y; |
6293 far_portal->_viewport_space_w = max_y; | |
1372 | 6294 current_ID = min_y_ID; |
6295 min_y_ID2 = min_y_ID; | |
6296 | |
6297 for ( uint i = 0; i < pNumVertices; ++i ) | |
6298 { | |
6299 current_ID += direction2; | |
6300 if ( current_ID < pNumVertices ) | |
1297 | 6301 { |
1372 | 6302 if ( current_ID < 0 ) |
6303 current_ID += pNumVertices; | |
1297 | 6304 } |
6305 else | |
1372 | 6306 current_ID -= pNumVertices; |
6307 if ( PortalFace._screen_space_y[current_ID] <= PortalFace._screen_space_y[min_y_ID] )//определение минимальной у | |
1297 | 6308 { |
1372 | 6309 min_y_ID2 = current_ID; |
6310 min_y_ID = current_ID; | |
1297 | 6311 } |
1372 | 6312 if ( PortalFace._screen_space_y[current_ID] == max_y ) |
1297 | 6313 break; |
6314 } | |
1372 | 6315 |
6316 v13 = min_y_ID2 + direction2; | |
1297 | 6317 if ( v13 < pNumVertices ) |
6318 { | |
6319 if ( v13 < 0 ) | |
6320 v13 += pNumVertices; | |
6321 } | |
6322 else | |
6323 v13 -= pNumVertices; | |
1372 | 6324 if ( PortalFace._screen_space_y[v13] != PortalFace._screen_space_y[min_y_ID2] ) |
6325 { | |
6326 v62 = PortalFace._screen_space_x[min_y_ID2] << 16; | |
1378 | 6327 v54 = ((PortalFace._screen_space_x[v13] - PortalFace._screen_space_x[min_y_ID2]) << 16) / |
6328 (PortalFace._screen_space_y[v13] - PortalFace._screen_space_y[min_y_ID2]); | |
6329 far_portal->viewport_left_side[min_y] = (short)PortalFace._screen_space_x[min_y_ID2]; | |
1372 | 6330 } |
6331 //**************************************************************************************************************************************** | |
6332 // | |
6333 v15 = min_y_ID; | |
6334 v61 = min_y_ID; | |
1297 | 6335 for ( v69 = 0; v69 < pNumVertices; ++v69 ) |
6336 { | |
1372 | 6337 v15 += direction1; |
1297 | 6338 if ( v15 < pNumVertices ) |
6339 { | |
6340 if ( v15 < 0 ) | |
6341 v15 += pNumVertices; | |
6342 } | |
6343 else | |
6344 v15 -= pNumVertices; | |
1372 | 6345 if ( PortalFace._screen_space_y[v15] <= PortalFace._screen_space_y[min_y_ID] ) |
1297 | 6346 { |
6347 v61 = v15; | |
1372 | 6348 min_y_ID = v15; |
1297 | 6349 } |
1344 | 6350 if ( PortalFace._screen_space_y[v15] == max_y ) |
1297 | 6351 break; |
6352 } | |
1372 | 6353 v18 = direction1 + v61; |
1297 | 6354 if ( v18 < pNumVertices ) |
6355 { | |
6356 if ( v18 < 0 ) | |
6357 v18 += pNumVertices; | |
6358 } | |
6359 else | |
6360 v18 -= pNumVertices; | |
6361 v19 = v18; | |
6362 v20 = v61; | |
1344 | 6363 if ( PortalFace._screen_space_y[v19] != PortalFace._screen_space_y[v61] ) |
6364 { | |
6365 v61 = PortalFace._screen_space_x[v20] << 16; | |
1378 | 6366 v53 = ((PortalFace._screen_space_x[v19] - PortalFace._screen_space_x[v20]) << 16) / |
6367 (PortalFace._screen_space_y[v19] - PortalFace._screen_space_y[v20]); | |
6368 far_portal->viewport_right_side[max_y] = (short)PortalFace._screen_space_x[v20]; | |
1372 | 6369 } |
6370 //**************************************************************************************************************************************** | |
1297 | 6371 v22 = min_y; |
6372 if ( min_y <= max_y ) | |
6373 { | |
6374 for ( v70 = min_y; v70 <= max_y; ++v70 ) | |
6375 { | |
6376 v24 = v13; | |
1344 | 6377 if ( v22 >= PortalFace._screen_space_y[v13] && v22 != max_y ) |
1297 | 6378 { |
1372 | 6379 v13 = direction2 + v13; |
1297 | 6380 if ( v13 < pNumVertices ) |
6381 { | |
6382 if ( v13 < 0 ) | |
6383 v13 += pNumVertices; | |
6384 } | |
6385 else | |
6386 v13 -= pNumVertices; | |
6387 v26 = v13; | |
1344 | 6388 if ( PortalFace._screen_space_y[v26] - PortalFace._screen_space_y[v24] > 0 ) |
1297 | 6389 { |
1378 | 6390 v54 = ((PortalFace._screen_space_x[v26] - PortalFace._screen_space_x[v24]) << 16) / (PortalFace._screen_space_y[v26] - PortalFace._screen_space_y[v24]); |
1344 | 6391 v62 = PortalFace._screen_space_x[v24] << 16; |
1297 | 6392 } |
6393 } | |
6394 v29 = v18; | |
1344 | 6395 if ( v70 >= PortalFace._screen_space_y[v18] && v70 != max_y ) |
1297 | 6396 { |
1372 | 6397 v18 += direction1; |
1297 | 6398 if ( v18 < pNumVertices ) |
6399 { | |
6400 if ( v18 < 0 ) | |
6401 v18 += pNumVertices; | |
6402 } | |
6403 else | |
6404 v18 -= pNumVertices; | |
6405 v31 = v18; | |
1344 | 6406 if ( PortalFace._screen_space_y[v31] - PortalFace._screen_space_y[v29] > 0 ) |
1297 | 6407 { |
1378 | 6408 v53 = ((PortalFace._screen_space_x[v31] - PortalFace._screen_space_x[v29]) << 16) / (PortalFace._screen_space_y[v31] - PortalFace._screen_space_y[v29]); |
1344 | 6409 v61 = PortalFace._screen_space_x[v29] << 16; |
1297 | 6410 } |
6411 } | |
1376 | 6412 far_portal->viewport_left_side[v70] = HIWORD(v62); |
6413 far_portal->viewport_right_side[v70] = HIWORD(v61); | |
6414 if ( far_portal->viewport_left_side[v70] > far_portal->viewport_right_side[v70] ) | |
1297 | 6415 { |
1376 | 6416 v36 = far_portal->viewport_left_side[v70] ^ far_portal->viewport_right_side[v70]; |
1379 | 6417 //v37 = far_portal->viewport_right_side[v70]; |
1376 | 6418 far_portal->viewport_left_side[v70] = v36; |
1379 | 6419 v38 = far_portal->viewport_right_side[v70] ^ v36; |
1376 | 6420 far_portal->viewport_left_side[v70] ^= v38; |
6421 far_portal->viewport_right_side[v70] = v38; | |
1297 | 6422 } |
6423 v62 += v54; | |
6424 v22 = v70 + 1; | |
6425 v61 += v53; | |
6426 } | |
6427 } | |
1376 | 6428 //***************************************************************************************************************************** |
6429 // check portals coordinates and determine max, min(проверка координат порталов и определение макс, мин-ой у) | |
6430 if ( max_y < near_portal->_viewport_space_y ) | |
1297 | 6431 return false; |
1376 | 6432 if ( min_y > near_portal->_viewport_space_w ) |
1297 | 6433 return false; |
1376 | 6434 if ( min_y < near_portal->_viewport_space_y ) |
6435 min_y = near_portal->_viewport_space_y; | |
6436 if ( max_y > near_portal->_viewport_space_w ) | |
6437 max_y = near_portal->_viewport_space_w; | |
1297 | 6438 if ( min_y <= max_y ) |
6439 { | |
1376 | 6440 for ( min_y; min_y <= max_y; ++min_y ) |
1297 | 6441 { |
1376 | 6442 if ( far_portal->viewport_right_side[min_y] >= near_portal->viewport_left_side[min_y] |
6443 && far_portal->viewport_left_side[min_y] <= near_portal->viewport_right_side[min_y] ) | |
1297 | 6444 break; |
6445 } | |
6446 } | |
6447 if ( max_y < min_y ) | |
6448 return false; | |
1376 | 6449 for ( max_y; max_y >= min_y; --max_y ) |
6450 { | |
6451 if ( far_portal->viewport_right_side[max_y] >= near_portal->viewport_left_side[max_y] | |
6452 && far_portal->viewport_left_side[max_y] <= near_portal->viewport_right_side[max_y] ) | |
1297 | 6453 break; |
6454 } | |
6455 if ( min_y >= max_y ) | |
1390 | 6456 return false; |
1376 | 6457 //************************************************************************************************************************************* |
1297 | 6458 v59 = min_y; |
6459 for ( v46 = max_y - min_y + 1; v46; --v46 ) | |
6460 { | |
1376 | 6461 if ( far_portal->viewport_left_side[v59] < near_portal->viewport_left_side[v59] ) |
6462 far_portal->viewport_left_side[v59] = near_portal->viewport_left_side[v59]; | |
6463 if ( far_portal->viewport_right_side[v59] > near_portal->viewport_right_side[v59] ) | |
6464 far_portal->viewport_right_side[v59] = near_portal->viewport_right_side[v59]; | |
1297 | 6465 ++v59; |
1376 | 6466 } |
6467 far_portal->_viewport_space_y = min_y; | |
6468 far_portal->_viewport_space_w = max_y; | |
6469 far_portal->_viewport_space_x = far_portal->viewport_left_side[min_y]; | |
1379 | 6470 far_portal->_viewport_space_z = far_portal->viewport_right_side[min_y]; |
1376 | 6471 far_portal->_viewport_x_minID = min_y; |
6472 far_portal->_viewport_z_maxID = min_y; | |
1297 | 6473 v49 = min_y + 1; |
6474 if ( v49 <= max_y ) | |
6475 { | |
6476 for ( v49; v49 <= max_y; ++v49 ) | |
6477 { | |
1376 | 6478 if ( far_portal->viewport_left_side[v49] < far_portal->_viewport_space_x ) |
1297 | 6479 { |
1376 | 6480 far_portal->_viewport_space_x = far_portal->viewport_left_side[v49]; |
6481 far_portal->_viewport_x_minID = v49; | |
1297 | 6482 } |
1376 | 6483 if ( far_portal->viewport_right_side[v49] > far_portal->_viewport_space_z ) |
1297 | 6484 { |
1376 | 6485 far_portal->_viewport_space_z = far_portal->viewport_right_side[v49]; |
6486 far_portal->_viewport_z_maxID = v49; | |
1297 | 6487 } |
6488 } | |
6489 } | |
6490 return true; | |
6491 } | |
6492 //----- (00423B5D) -------------------------------------------------------- | |
1344 | 6493 int __fastcall GetPortalScreenCoord(unsigned int uFaceID) |
1297 | 6494 { |
6495 BLVFace *pFace; // ebx@1 | |
1344 | 6496 int pNextVertices; // edx@11 |
6497 int t; // ST28_4@12 | |
6498 int pScreenX; // eax@22 | |
6499 int pScreenY; // eax@27 | |
6500 signed int left_num_vertices; // edi@31 | |
6501 signed int right_num_vertices; // ebx@41 | |
6502 signed int top_num_vertices; // edi@51 | |
6503 int bottom_num_vertices; // ebx@61 | |
1297 | 6504 signed int v62; // edx@75 |
6505 int v63; // ecx@76 | |
6506 int v64; // esi@76 | |
6507 int v65; // ecx@83 | |
6508 signed int v71; // [sp+14h] [bp-14h]@75 | |
1301 | 6509 bool current_vertices_flag; // [sp+18h] [bp-10h]@9 |
1297 | 6510 int thisf; // [sp+18h] [bp-10h]@74 |
1301 | 6511 signed int depth_num_vertices; // [sp+1Ch] [bp-Ch]@9 |
1297 | 6512 int v80; // [sp+1Ch] [bp-Ch]@76 |
1301 | 6513 bool next_vertices_flag; // [sp+20h] [bp-8h]@10 |
1297 | 6514 |
6515 pFace = &pIndoor->pFaces[uFaceID]; | |
1344 | 6516 memset(&PortalFace, 0, sizeof(stru367)); |
6517 | |
6518 //get direction the face(определение направленности фейса)********************************************************************************* | |
1297 | 6519 if ( pFace->pFacePlane_old.vNormal.x * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x) |
6520 + pFace->pFacePlane_old.vNormal.y * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y) | |
6521 + pFace->pFacePlane_old.vNormal.z * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z) < 0 ) | |
6522 { | |
1344 | 6523 PortalFace.direction = true; |
1297 | 6524 } |
6525 else | |
6526 { | |
1344 | 6527 PortalFace.direction = false; |
1301 | 6528 if ( !(pFace->Portal()) ) |
1297 | 6529 return 0; |
6530 } | |
1344 | 6531 //***************************************************************************************************************************************** |
6532 //generate/cinvertetion in camera location coordinates(генерация/конвертирование в координаты пространства камеры) | |
6533 | |
6534 //for new coordinates: | |
6535 //int x = 0x AAAA BBBB; | |
6536 //AAAA - integer(целая часть), BBBB - fractional(дробная) | |
6537 //float v = HIWORD(x) + LOWORD(x) / 65535.0f; | |
6538 //0x0351A281 это 849(351 в шестнадцатиричной) в целой части и A281 в дробной(хотя как точно BBBB считалась не помню) | |
6539 //if in HIWORD: FFFF = -1 | |
6540 //FFFE = -2 | |
6541 //FFFD = -3 | |
6542 //.... | |
6543 //8000 = -32767 | |
6544 //7FFF = 32767 | |
6545 //7FFE = 32766 | |
6546 //если в LOWORD например лежит FFFF то не совсем понятно, что это | |
6547 //потому что если и hiword и loword равны FFFF FFFF то двойное отрицание как бы, нужно тестировать что конкретно получается чтобы понять что это значит | |
6548 //всё что больше 7FFF для верхнего слова это идёт уже с минусом/Nomad/ | |
6549 | |
1297 | 6550 if ( (signed int)pFace->uNumVertices > 0 ) |
6551 { | |
1301 | 6552 for (uint i = 0; i < pFace->uNumVertices; ++i) |
1297 | 6553 { |
1344 | 6554 pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(pIndoor->pVertices[pFace->pVertexIDs[i]].x, |
6555 pIndoor->pVertices[pFace->pVertexIDs[i]].y, | |
6556 pIndoor->pVertices[pFace->pVertexIDs[i]].z, | |
6557 &PortalFace._view_transformed_z[i + 3], &PortalFace._view_transformed_x[i + 3], &PortalFace._view_transformed_y[i + 3], 0); | |
1297 | 6558 } |
1301 | 6559 } |
1344 | 6560 //***************************************************************************************************************************************** |
6561 //check vertices for the nearest plane(проверка вершин есть ли в области за ближайшей плоскостью) | |
1301 | 6562 if ( pFace->uNumVertices <= 0 ) |
1297 | 6563 return 0; |
1301 | 6564 bool bFound = false; |
6565 for (uint i = 0; i < pFace->uNumVertices; ++i) | |
6566 { | |
1344 | 6567 if ( PortalFace._view_transformed_z[i + 3] >= 524288 )// 8.0(0x80000) |
1301 | 6568 { |
6569 bFound = true; | |
1297 | 6570 break; |
1301 | 6571 } |
6572 } | |
6573 if ( !bFound ) | |
1297 | 6574 return 0; |
1344 | 6575 //***************************************************************************************************************************************** |
6576 //check for near clip plane(проверка по ближней границе) | |
6577 // | |
6578 // v0 v1 | |
6579 // ._________________. | |
6580 // / \ | |
6581 // / \ | |
6582 // v5. . v2 | |
6583 // | | | |
6584 // | | | |
6585 // | | | |
6586 // ---------------------------- 8.0(near_clip) | |
6587 // | | | |
6588 // ._______________________. | |
6589 // v4 v3 | |
1301 | 6590 depth_num_vertices = 0; |
1344 | 6591 PortalFace._view_transformed_z[pFace->uNumVertices + 3] = PortalFace._view_transformed_z[3]; |
6592 PortalFace._view_transformed_x[pFace->uNumVertices + 3] = PortalFace._view_transformed_x[3]; | |
6593 PortalFace._view_transformed_y[pFace->uNumVertices + 3] = PortalFace._view_transformed_y[3]; | |
6594 current_vertices_flag = PortalFace._view_transformed_z[3] >= 524288;// 8.0(0x80000) | |
1301 | 6595 if ( pFace->uNumVertices >= 1 ) |
6596 { | |
6597 for ( uint i = 1; i <= pFace->uNumVertices; ++i) | |
1297 | 6598 { |
1344 | 6599 next_vertices_flag = PortalFace._view_transformed_z[i + 3] >= 524288;// 8.0(0x80000) |
6600 if ( current_vertices_flag ^ next_vertices_flag )//или текущая или следующая вершина за ближней границей | |
1297 | 6601 { |
1344 | 6602 if ( next_vertices_flag )//следующая вершина за ближней границей |
1297 | 6603 { |
1344 | 6604 //t = near_clip - v0.z / v1.z - v0.z |
1370 | 6605 t = fixpoint_div(524288 - PortalFace._view_transformed_z[i + 2], PortalFace._view_transformed_z[i + 3] - PortalFace._view_transformed_z[i + 2]); |
1344 | 6606 //New_x = (v1.x - v0.x)*t + v0.x |
6607 PortalFace._view_transformed_x[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_x[i + 3] | |
6608 - PortalFace._view_transformed_x[i + 2]) * t) >> 16) + PortalFace._view_transformed_x[i + 2]; | |
6609 //New_y = (v1.y - v0.y)*t + v0.y | |
6610 PortalFace._view_transformed_y[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_y[i + 3] - PortalFace._view_transformed_y[i + 2]) | |
6611 * t) >> 16) + PortalFace._view_transformed_y[i + 2]; | |
6612 //New_z = 8.0(0x80000) | |
6613 PortalFace._view_transformed_z[depth_num_vertices] = 524288; | |
1297 | 6614 } |
1344 | 6615 else// текущая вершина за ближней границей |
1297 | 6616 { |
1344 | 6617 //t = near_clip - v1.z / v0.z - v1.z |
1370 | 6618 t = fixpoint_div(524288 - PortalFace._view_transformed_z[i + 3], PortalFace._view_transformed_z[i + 2] - PortalFace._view_transformed_z[i + 3]); |
1344 | 6619 //New_x = (v0.x - v1.x)*t + v1.x |
6620 PortalFace._view_transformed_x[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_x[i + 2] | |
6621 - PortalFace._view_transformed_x[i + 3]) * t) >> 16) + PortalFace._view_transformed_x[i + 3]; | |
6622 //New_y = (v0.x - v1.y)*t + v1.y | |
6623 PortalFace._view_transformed_y[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_y[i + 2] - PortalFace._view_transformed_y[i + 3]) | |
6624 * t) >> 16) + PortalFace._view_transformed_y[i + 3]; | |
6625 //New_z = 8.0(0x80000) | |
6626 PortalFace._view_transformed_z[depth_num_vertices] = 524288; | |
1297 | 6627 } |
1344 | 6628 depth_num_vertices++; |
1297 | 6629 } |
1344 | 6630 if ( next_vertices_flag )//если следующая вершина за ближней границей |
1297 | 6631 { |
1344 | 6632 pNextVertices = depth_num_vertices++; |
6633 PortalFace._view_transformed_z[pNextVertices] = PortalFace._view_transformed_z[i + 3]; | |
6634 PortalFace._view_transformed_x[pNextVertices] = PortalFace._view_transformed_x[i + 3]; | |
6635 PortalFace._view_transformed_y[pNextVertices] = PortalFace._view_transformed_y[i + 3]; | |
1297 | 6636 } |
1301 | 6637 current_vertices_flag = next_vertices_flag; |
1297 | 6638 } |
1301 | 6639 } |
1344 | 6640 //результат: нет моргания на границе портала(когда проходим сквозь портал) |
6641 //************************************************************************************************************************************ | |
6642 //convertion in screen coordinates(конвертирование в координаты экрана) | |
6643 PortalFace._view_transformed_z[depth_num_vertices] = PortalFace._view_transformed_z[0]; | |
6644 PortalFace._view_transformed_x[depth_num_vertices] = PortalFace._view_transformed_x[0]; | |
6645 PortalFace._view_transformed_y[depth_num_vertices] = PortalFace._view_transformed_y[0]; | |
6646 for ( uint i = 0; i < depth_num_vertices; ++i ) | |
6647 { | |
6648 if ( (abs(PortalFace._view_transformed_x[i]) >> 13) <= abs(PortalFace._view_transformed_z[i]) ) | |
6649 pScreenX = fixpoint_div(PortalFace._view_transformed_x[i], PortalFace._view_transformed_z[i]); | |
1297 | 6650 else |
6651 { | |
1344 | 6652 if ( PortalFace._view_transformed_x[i] >= 0 ) |
1297 | 6653 { |
1344 | 6654 if (PortalFace._view_transformed_z[i] >= 0) |
6655 pScreenX = 0x400000; // 64.0 | |
1301 | 6656 else |
1344 | 6657 pScreenX = 0xFFC00000; // -63.0 |
1297 | 6658 } |
6659 else | |
6660 { | |
1344 | 6661 if (PortalFace._view_transformed_z[i] >= 0) |
6662 pScreenX = 0xFFC00000; // -63.0 | |
1301 | 6663 else |
1344 | 6664 pScreenX = 0x400000; // 64.0 |
1297 | 6665 } |
6666 } | |
1301 | 6667 |
1344 | 6668 if ( (abs(PortalFace._view_transformed_y[i]) >> 13) <= abs(PortalFace._view_transformed_z[i]) ) |
6669 pScreenY = fixpoint_div(PortalFace._view_transformed_y[i], PortalFace._view_transformed_z[i]); | |
1297 | 6670 else |
6671 { | |
1344 | 6672 if ( PortalFace._view_transformed_y[i] >= 0 ) |
1297 | 6673 { |
1344 | 6674 if (PortalFace._view_transformed_z[i] >= 0) |
6675 pScreenY = 0x400000; // 64.0 | |
1301 | 6676 else |
1344 | 6677 pScreenY = 0xFFC00000; // -63.0 |
1297 | 6678 } |
6679 else | |
6680 { | |
1344 | 6681 if (PortalFace._view_transformed_z[i] >= 0) |
6682 pScreenY = 0xFFC00000; // -63.0 | |
1301 | 6683 else |
1344 | 6684 pScreenY = 0x400000; // 64.0 |
1297 | 6685 } |
6686 } | |
1344 | 6687 PortalFace._screen_space_x[i + 12] = pBLVRenderParams->uViewportCenterX - ((unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)pScreenX) >> 16); |
6688 PortalFace._screen_space_y[i + 12] = pBLVRenderParams->uViewportCenterY - ((unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)pScreenY) >> 16); | |
6689 } | |
6690 // результат: при повороте камеры, когда граница портала сдвигается к краю экрана, портал остается прозрачным(видимым) | |
6691 //****************************************************************************************************************************************** | |
1381 | 6692 //координаты как в Ида-базе игры так и в данном проекте перевёрнутые,т.е. портал который в правой части экрана имеет экранные координаты |
6693 //которые для левой части экрана. Например, x(оригинал) = 8, у нас х = 468(противоположный край экрана), точно также и с у. | |
6694 // | |
1344 | 6695 //check for left_clip plane(порверка по левой границе) |
6696 left_num_vertices = 0; | |
6697 PortalFace._screen_space_x[depth_num_vertices + 12] = PortalFace._screen_space_x[12]; | |
6698 PortalFace._screen_space_y[depth_num_vertices + 12] = PortalFace._screen_space_y[12]; | |
1370 | 6699 current_vertices_flag = PortalFace._screen_space_x[12] >= (signed int)pBLVRenderParams->uViewportX;//8.0 |
1301 | 6700 if ( depth_num_vertices < 1 ) |
1297 | 6701 return 0; |
1344 | 6702 for ( uint i = 1; i <= depth_num_vertices; ++i ) |
6703 { | |
6704 next_vertices_flag = PortalFace._screen_space_x[i + 12] >= (signed int)pBLVRenderParams->uViewportX; | |
6705 if ( current_vertices_flag ^ next_vertices_flag ) | |
1297 | 6706 { |
1344 | 6707 if ( next_vertices_flag ) |
1297 | 6708 { |
1344 | 6709 //t = left_clip - v0.x / v1.x - v0.x |
1370 | 6710 t = fixpoint_div(pBLVRenderParams->uViewportX - PortalFace._screen_space_x[i + 11], PortalFace._screen_space_x[i + 12] - PortalFace._screen_space_x[i + 11]); |
1344 | 6711 //New_y = (v1.y - v0.y)*t + v0.y |
1370 | 6712 PortalFace._screen_space_y[left_num_vertices + 9] = ((signed int)((PortalFace._screen_space_y[i + 12]- PortalFace._screen_space_y[i + 11]) |
6713 * t) >> 16) + PortalFace._screen_space_y[i + 11]; | |
1344 | 6714 //New_x = left_clip |
6715 PortalFace._screen_space_x[left_num_vertices + 9] = pBLVRenderParams->uViewportX; | |
1297 | 6716 } |
6717 else | |
6718 { | |
1344 | 6719 //t = left_clip - v1.x / v0.x - v1.x |
1370 | 6720 t = fixpoint_div(pBLVRenderParams->uViewportX - PortalFace._screen_space_x[i + 12], PortalFace._screen_space_x[i + 11] - PortalFace._screen_space_x[i + 12]); |
1344 | 6721 //New_y = (v0.y - v1.y)*t + v1.y |
1370 | 6722 PortalFace._screen_space_y[left_num_vertices + 9] = ((signed int)(( PortalFace._screen_space_y[i + 11] - PortalFace._screen_space_y[i + 12]) |
6723 * t) >> 16) + PortalFace._screen_space_y[i + 12]; | |
1344 | 6724 //New_x = left_clip |
6725 PortalFace._screen_space_x[left_num_vertices + 9] = pBLVRenderParams->uViewportX; | |
1297 | 6726 } |
1344 | 6727 left_num_vertices++; |
1297 | 6728 } |
1344 | 6729 if ( next_vertices_flag ) |
1297 | 6730 { |
1344 | 6731 pNextVertices = left_num_vertices++; |
6732 PortalFace._screen_space_x[pNextVertices + 9] = PortalFace._screen_space_x[i + 12]; | |
6733 PortalFace._screen_space_y[pNextVertices + 9] = PortalFace._screen_space_y[i + 12]; | |
1297 | 6734 } |
1344 | 6735 current_vertices_flag = next_vertices_flag; |
6736 } | |
6737 //********************************************************************************************************************************* | |
6738 //for right_clip plane(проверка по правой плоскости) | |
6739 right_num_vertices = 0; | |
6740 PortalFace._screen_space_x[left_num_vertices + 9] = PortalFace._screen_space_x[9]; | |
6741 PortalFace._screen_space_y[left_num_vertices + 9] = PortalFace._screen_space_y[9]; | |
1370 | 6742 current_vertices_flag = PortalFace._screen_space_x[9] <= (signed int)pBLVRenderParams->uViewportZ;//468.0 |
1344 | 6743 if (left_num_vertices < 1) |
1297 | 6744 return 0; |
1344 | 6745 for ( uint i = 1; i <= left_num_vertices; ++i ) |
6746 { | |
6747 next_vertices_flag = PortalFace._screen_space_x[i + 9] <= (signed int)pBLVRenderParams->uViewportZ; | |
6748 if ( current_vertices_flag ^ next_vertices_flag ) | |
1297 | 6749 { |
1344 | 6750 if ( next_vertices_flag ) |
1297 | 6751 { |
1344 | 6752 //t = right_clip - v1.x / v0.x - v1.x |
1370 | 6753 t = fixpoint_div(pBLVRenderParams->uViewportZ - PortalFace._screen_space_x[i + 8], PortalFace._screen_space_x[i + 9] - PortalFace._screen_space_x[i + 8]); |
1344 | 6754 //New_y = (v0.y - v1.y)*t + v1.y |
1370 | 6755 PortalFace._screen_space_y[right_num_vertices + 6] = ((signed int)((PortalFace._screen_space_y[i + 9] - PortalFace._screen_space_y[i + 8]) |
6756 * t) >> 16) + PortalFace._screen_space_y[i + 8]; | |
1344 | 6757 //New_x = right_clip |
6758 PortalFace._screen_space_x[right_num_vertices + 6] = pBLVRenderParams->uViewportZ; | |
1297 | 6759 } |
6760 else | |
6761 { | |
1344 | 6762 //t = right_clip - v0.x / v1.x - v0.x |
1370 | 6763 t = fixpoint_div(pBLVRenderParams->uViewportZ - PortalFace._screen_space_x[i + 9], PortalFace._screen_space_x[i + 8] - PortalFace._screen_space_x[i + 9]); |
1344 | 6764 //New_y = (v1.y - v0.y)*t + v0.y |
1370 | 6765 PortalFace._screen_space_y[right_num_vertices + 6] = ((signed int)((PortalFace._screen_space_y[i + 8] - PortalFace._screen_space_y[i + 9]) |
6766 * t) >> 16) + PortalFace._screen_space_y[i + 9]; | |
1344 | 6767 //New_x = right_clip |
6768 PortalFace._screen_space_x[right_num_vertices + 6] = pBLVRenderParams->uViewportZ; | |
1297 | 6769 } |
1344 | 6770 right_num_vertices++; |
1297 | 6771 } |
1344 | 6772 if ( next_vertices_flag ) |
1297 | 6773 { |
1344 | 6774 pNextVertices = right_num_vertices++; |
6775 PortalFace._screen_space_x[pNextVertices + 6] = PortalFace._screen_space_x[i + 9]; | |
6776 PortalFace._screen_space_y[pNextVertices + 6] = PortalFace._screen_space_y[i + 9]; | |
1297 | 6777 } |
1344 | 6778 current_vertices_flag = next_vertices_flag; |
6779 } | |
6780 //************************************************************************************************************************************ | |
6781 // for top clip plane | |
6782 top_num_vertices = 0; | |
6783 PortalFace._screen_space_x[right_num_vertices + 6] = PortalFace._screen_space_x[6]; | |
6784 PortalFace._screen_space_y[right_num_vertices + 6] = PortalFace._screen_space_y[6]; | |
6785 | |
1370 | 6786 current_vertices_flag = PortalFace._screen_space_y[6] >= (signed int)pBLVRenderParams->uViewportY;//8.0 |
1344 | 6787 if ( right_num_vertices < 1 ) |
1297 | 6788 return 0; |
1344 | 6789 for ( uint i = 1; i <= right_num_vertices; ++i ) |
6790 { | |
6791 next_vertices_flag = PortalFace._screen_space_y[i + 6] >= (signed int)pBLVRenderParams->uViewportY; | |
6792 if ( current_vertices_flag ^ next_vertices_flag ) | |
1297 | 6793 { |
1344 | 6794 if ( next_vertices_flag ) |
1297 | 6795 { |
1370 | 6796 t = fixpoint_div(pBLVRenderParams->uViewportY - PortalFace._screen_space_y[i + 5], PortalFace._screen_space_y[i + 6] - PortalFace._screen_space_y[i + 5]); |
6797 PortalFace._screen_space_x[top_num_vertices + 3] = ((signed int)((PortalFace._screen_space_x[i + 6] - PortalFace._screen_space_x[i + 5]) | |
6798 * t) >> 16) + PortalFace._screen_space_x[i + 5]; | |
1344 | 6799 PortalFace._screen_space_y[top_num_vertices + 3] = pBLVRenderParams->uViewportY; |
1297 | 6800 } |
6801 else | |
6802 { | |
1370 | 6803 t = fixpoint_div(pBLVRenderParams->uViewportY - PortalFace._screen_space_y[i + 6], PortalFace._screen_space_y[i + 5] - PortalFace._screen_space_y[i + 6]); |
6804 PortalFace._screen_space_x[top_num_vertices + 3] = ((signed int)((PortalFace._screen_space_x[i + 5]- PortalFace._screen_space_x[i + 6]) | |
6805 * t) >> 16) + PortalFace._screen_space_x[i + 6]; | |
1344 | 6806 PortalFace._screen_space_y[top_num_vertices + 3] = pBLVRenderParams->uViewportY; |
1297 | 6807 } |
1344 | 6808 top_num_vertices++; |
1297 | 6809 } |
1344 | 6810 current_vertices_flag = next_vertices_flag; |
6811 if ( next_vertices_flag ) | |
1297 | 6812 { |
1344 | 6813 pNextVertices = top_num_vertices++; |
6814 PortalFace._screen_space_x[pNextVertices + 3] = PortalFace._screen_space_x[i + 6]; | |
6815 PortalFace._screen_space_y[pNextVertices + 3] = PortalFace._screen_space_y[i + 6]; | |
1297 | 6816 } |
1344 | 6817 } |
6818 //********************************************************************************************************************************** | |
6819 //for bottom_clip plane(проверка по нижней плоскости) | |
6820 bottom_num_vertices = 0; | |
6821 PortalFace._screen_space_x[top_num_vertices + 3] = PortalFace._screen_space_x[3]; | |
6822 PortalFace._screen_space_y[top_num_vertices + 3] = PortalFace._screen_space_y[3]; | |
1370 | 6823 current_vertices_flag = PortalFace._screen_space_y[3] <= (signed int)pBLVRenderParams->uViewportW;//351.0 |
1344 | 6824 if ( top_num_vertices < 1 ) |
1297 | 6825 return 0; |
1344 | 6826 for ( uint i =1; i <= top_num_vertices; ++i ) |
6827 { | |
6828 next_vertices_flag = PortalFace._screen_space_y[i + 3] <= (signed int)pBLVRenderParams->uViewportW; | |
6829 if ( current_vertices_flag ^ next_vertices_flag ) | |
1297 | 6830 { |
1344 | 6831 if ( next_vertices_flag ) |
1297 | 6832 { |
1370 | 6833 t = fixpoint_div(pBLVRenderParams->uViewportW - PortalFace._screen_space_y[i + 2], PortalFace._screen_space_y[i + 3] - PortalFace._screen_space_y[i + 2]); |
6834 PortalFace._screen_space_x[bottom_num_vertices] = ((signed int)((PortalFace._screen_space_x[i + 3] - PortalFace._screen_space_x[i + 2]) | |
6835 * t) >> 16) + PortalFace._screen_space_x[i + 2]; | |
1344 | 6836 PortalFace._screen_space_y[bottom_num_vertices] = pBLVRenderParams->uViewportW; |
1297 | 6837 } |
6838 else | |
6839 { | |
1370 | 6840 t = fixpoint_div(pBLVRenderParams->uViewportW - PortalFace._screen_space_y[i + 3], PortalFace._screen_space_y[i + 2] - PortalFace._screen_space_y[i + 3]); |
6841 PortalFace._screen_space_x[bottom_num_vertices] = ((signed int)((PortalFace._screen_space_x[i + 2] - PortalFace._screen_space_x[i + 3]) | |
6842 * t) >> 16) + PortalFace._screen_space_x[i + 3]; | |
1344 | 6843 PortalFace._screen_space_y[bottom_num_vertices] = pBLVRenderParams->uViewportW; |
1297 | 6844 } |
1344 | 6845 bottom_num_vertices++; |
1297 | 6846 } |
1344 | 6847 if ( next_vertices_flag ) |
1297 | 6848 { |
1344 | 6849 pNextVertices = bottom_num_vertices++; |
6850 PortalFace._screen_space_x[pNextVertices] = PortalFace._screen_space_x[i + 3]; | |
6851 PortalFace._screen_space_y[pNextVertices] = PortalFace._screen_space_y[i + 3]; | |
1297 | 6852 } |
1344 | 6853 current_vertices_flag = next_vertices_flag; |
6854 } | |
6855 //*************************************************************************************************************************************** | |
6856 | |
6857 if ( !bottom_num_vertices ) | |
1297 | 6858 return 0; |
1344 | 6859 PortalFace._screen_space_x[bottom_num_vertices] = PortalFace._screen_space_x[0]; |
6860 PortalFace._screen_space_y[bottom_num_vertices] = PortalFace._screen_space_y[0]; | |
6861 //check for software(проверка для софтвар) | |
6862 if ( !pRenderer->pRenderD3D && bottom_num_vertices > 3 ) | |
6863 { | |
6864 PortalFace._screen_space_x[bottom_num_vertices + 1] = PortalFace._screen_space_x[1]; | |
6865 PortalFace._screen_space_y[bottom_num_vertices + 1] = PortalFace._screen_space_y[1]; | |
6866 thisf = PortalFace.direction == true ? 1 : - 1; | |
6867 if ( bottom_num_vertices > 0 ) | |
1297 | 6868 { |
6869 v62 = 1; | |
6870 v71 = 1; | |
6871 do | |
6872 { | |
6873 v63 = v62 - 1; | |
6874 v64 = v62 + 1; | |
6875 v80 = v62 + 1; | |
1344 | 6876 if ( v62 - 1 >= bottom_num_vertices ) |
6877 v63 -= bottom_num_vertices; | |
6878 if ( v62 >= bottom_num_vertices ) | |
6879 v62 -= bottom_num_vertices; | |
6880 if ( v64 >= bottom_num_vertices ) | |
6881 v64 -= bottom_num_vertices; | |
6882 if ( thisf * ((PortalFace._screen_space_y[v64] - PortalFace._screen_space_y[v63]) | |
6883 * (PortalFace._screen_space_x[v62] - PortalFace._screen_space_x[v63]) | |
6884 - (PortalFace._screen_space_y[v62] - PortalFace._screen_space_y[v63]) | |
6885 * (PortalFace._screen_space_x[v64] - PortalFace._screen_space_x[v63])) < 0 ) | |
1297 | 6886 { |
6887 v62 = v80; | |
6888 v71 = v80; | |
6889 } | |
6890 else | |
6891 { | |
6892 v62 = v71; | |
6893 v65 = v71; | |
1344 | 6894 if ( v71 < bottom_num_vertices || (v65 = v71 - bottom_num_vertices, v71 - bottom_num_vertices < bottom_num_vertices) ) |
1297 | 6895 { |
1344 | 6896 memcpy(&PortalFace._screen_space_y[v65], &PortalFace._screen_space_y[v65 + 1], |
6897 4 * ((unsigned int)(4 * (bottom_num_vertices - v65)) >> 2)); | |
6898 memcpy(&PortalFace._screen_space_x[v65], &PortalFace._screen_space_x[v65 + 1], | |
6899 4 * ((unsigned int)(4 * (bottom_num_vertices - v65)) >> 2)); | |
1297 | 6900 } |
1344 | 6901 --bottom_num_vertices; |
1297 | 6902 } |
6903 } | |
1344 | 6904 while ( v62 - 1 < bottom_num_vertices ); |
1297 | 6905 } |
1344 | 6906 PortalFace._screen_space_x[bottom_num_vertices] = PortalFace._screen_space_x[0]; |
6907 PortalFace._screen_space_y[bottom_num_vertices] = PortalFace._screen_space_y[0]; | |
6908 } | |
6909 return bottom_num_vertices; | |
1408 | 6910 } |
6911 | |
6912 //----- (004AAEA6) -------------------------------------------------------- | |
6913 int __fastcall sub_4AAEA6_transform(RenderVertexSoft *a1) | |
6914 { | |
6915 double v4; // st5@2 | |
6916 double v5; // st4@3 | |
6917 float v11; // [sp+8h] [bp-8h]@2 | |
6918 float v12; // [sp+8h] [bp-8h]@6 | |
6919 float v13; // [sp+Ch] [bp-4h]@2 | |
6920 float v14; // [sp+Ch] [bp-4h]@6 | |
6921 | |
6922 if ( pBLVRenderParams->sPartyRotX ) | |
6923 { | |
6924 v13 = a1->vWorldPosition.x - (double)pParty->vPosition.x; | |
6925 v11 = a1->vWorldPosition.y - (double)pParty->vPosition.y; | |
6926 v4 = a1->vWorldPosition.z - (double)pParty->vPosition.z; | |
6927 if ( pRenderer->pRenderD3D ) | |
6928 { | |
6929 v5 = v11 * pBLVRenderParams->fSineY + v13 * pBLVRenderParams->fCosineY; | |
6930 a1->vWorldViewPosition.y = v13 * pBLVRenderParams->fSineY - v11 * pBLVRenderParams->fCosineY; | |
6931 } | |
6932 else | |
6933 { | |
6934 v5 = v13 * pBLVRenderParams->fCosineY - v11 * pBLVRenderParams->fSineY; | |
6935 a1->vWorldViewPosition.y = v13 * pBLVRenderParams->fSineY + v11 * pBLVRenderParams->fCosineY; | |
6936 } | |
6937 a1->vWorldViewPosition.x = v5 * pBLVRenderParams->fCosineNegX - v4 * pBLVRenderParams->fSineNegX; | |
6938 a1->vWorldViewPosition.z = v5 * pBLVRenderParams->fSineNegX + v4 * pBLVRenderParams->fCosineNegX; | |
6939 } | |
6940 else | |
6941 { | |
6942 v14 = a1->vWorldPosition.x - (double)pParty->vPosition.x; | |
6943 v12 = a1->vWorldPosition.y - (double)pParty->vPosition.y; | |
6944 a1->vWorldViewPosition.z = a1->vWorldPosition.z - (double)pParty->vPosition.z; | |
6945 if ( pRenderer->pRenderD3D ) | |
6946 { | |
6947 a1->vWorldViewPosition.x = v12 * pBLVRenderParams->fSineY + v14 * pBLVRenderParams->fCosineY; | |
6948 a1->vWorldViewPosition.y = v14 * pBLVRenderParams->fSineY - v12 * pBLVRenderParams->fCosineY; | |
6949 } | |
6950 else | |
6951 { | |
6952 a1->vWorldViewPosition.x = v14 * pBLVRenderParams->fCosineY - v12 * pBLVRenderParams->fSineY; | |
6953 a1->vWorldViewPosition.y = v14 * pBLVRenderParams->fSineY + v12 * pBLVRenderParams->fCosineY; | |
6954 } | |
6955 } | |
6956 return 0; | |
0 | 6957 } |