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