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