Mercurial > mm7
annotate Outdoor.cpp @ 222:8113753ed2ae
more item init fixing
author | Gloval |
---|---|
date | Sun, 17 Feb 2013 11:29:10 +0400 |
parents | 49728858c35e |
children | 07eb7d649bd5 |
rev | line source |
---|---|
0 | 1 #include <assert.h> |
2 | |
3 #include "Outdoor.h" | |
4 #include "Party.h" | |
5 #include "LayingItem.h" | |
6 #include "LOD.h" | |
7 #include "Render.h" | |
8 #include "MapInfo.h" | |
9 #include "Allocator.h" | |
10 #include "Weather.h" | |
11 #include "PaletteManager.h" | |
12 #include "GUIProgressBar.h" | |
13 #include "AudioPlayer.h" | |
14 #include "IndoorCamera.h" | |
15 #include "DecorationList.h" | |
16 #include "TileFrameTable.h" | |
17 #include "Math.h" | |
18 #include "ObjectList.h" | |
19 #include "Game.h" | |
20 #include "Actor.h" | |
21 #include "Chest.h" | |
22 #include "stru123.h" | |
23 #include "Time.h" | |
24 #include "Viewport.h" | |
25 #include "Events.h" | |
26 | |
27 #include "mm7_data.h" | |
28 //#include "MM7.h" | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 OutdoorLocation *pOutdoor = new OutdoorLocation; | |
35 OutdoorCamera *pOutdoorCamera; | |
36 | |
37 | |
38 stru149 stru_8019C8; | |
39 stru148 array_77EC08[2000]; | |
40 Surf stru_80C980; | |
41 Edge defaultEdge; // weak | |
42 Edge stru_80C9A4; | |
43 Edge stru_80C9D8; | |
44 | |
45 | |
46 //----- (0047A59E) -------------------------------------------------------- | |
47 void OutdoorLocation::ExecDraw(unsigned int bRedraw) | |
48 { | |
121 | 49 //unsigned int v2; // ebx@1 |
0 | 50 int v3; // ST18_4@3 |
51 int v4; // ST04_4@19 | |
52 int v5; // eax@19 | |
53 | |
186 | 54 pIndoorCamera->flags = 0; |
55 if (viewparams->draw_d3d_outlines) | |
56 pIndoorCamera->flags |= INDOOR_CAMERA_DRAW_D3D_OUTLINES; | |
57 | |
0 | 58 pIndoorCamera->sRotationX = pParty->sRotationX; |
59 pIndoorCamera->sRotationY = pParty->sRotationY; | |
60 pIndoorCamera->pos.x = pParty->vPosition.x | |
61 - ((unsigned __int64)(stru_5C6E00->SinCos(pParty->sRotationY) | |
120 | 62 * (signed __int64)pParty->y_rotation_granularity) >> 16); |
63 pIndoorCamera->pos.y = pParty->vPosition.y - pParty->y_rotation_granularity * ((stru_5C6E00->SinCos(pParty->sRotationY)) >> 16); | |
0 | 64 pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel; |
121 | 65 if (bRedraw || pRenderer->pRenderD3D) |
0 | 66 { |
67 ResetStru148s(); | |
68 pOutdoorCamera->RotationToInts(); | |
69 sub_481ED9_MessWithOutdoorCamera(); | |
70 } | |
71 pIndoorCamera->uMapGridCellX = WorldPosToGridCellX(pParty->vPosition.x); | |
72 pIndoorCamera->uMapGridCellZ = WorldPosToGridCellZ(pParty->vPosition.y); | |
121 | 73 if (bRedraw) |
0 | 74 { |
75 Software_ResetNewEdges(); | |
76 sub_487DA9(); | |
77 ptr_80C97C_Surfs = pSurfs; | |
78 ptr_80C978_Edges = pEdges; | |
79 } | |
80 if ( pParty->uCurrentMinute != pOutdoor->uLastSunlightUpdateMinute ) | |
81 pOutdoor->UpdateSunlightVectors(); | |
82 pOutdoor->UpdateFog(); | |
83 pGame->pIndoorCameraD3D->Reset_list_0037C(); | |
121 | 84 if (!bRedraw) |
0 | 85 { |
86 if ( !pRenderer->pRenderD3D ) | |
87 { | |
88 pRenderer->OnOutdoorRedrawSW(); | |
89 } | |
83 | 90 else |
91 { | |
92 pRenderer->DrawSkyD3D(); | |
93 pRenderer->DrawBuildingsD3D(); | |
103 | 94 pRenderer->RenderTerrainD3D();//pRenderer->DrawBezierTerrain();// Ritor1: temporarily lag |
83 | 95 } |
0 | 96 } |
121 | 97 else if (pRenderer->pRenderD3D) |
0 | 98 { |
99 pRenderer->DrawSkyD3D(); | |
100 pRenderer->DrawBuildingsD3D(); | |
103 | 101 pRenderer->RenderTerrainD3D();//pRenderer->DrawBezierTerrain();// Ritor1: temporarily lag |
0 | 102 } |
83 | 103 else |
104 { | |
105 pRenderer->DrawBuildingsSW(); | |
103 | 106 pRenderer->RenderTerrainD3D();//pRenderer->DrawBezierTerrain();// Ritor1: temporarily lag |
83 | 107 sr_sub_486F92_MessWithEdgesAndSpans(); |
108 pOutdoorCamera->_487355(); | |
109 } | |
0 | 110 pMobileLightsStack->uNumLightsActive = 0; |
111 pStationaryLightsStack->uNumLightsActive = 0; | |
112 if ( !pRenderer->pRenderD3D ) | |
113 { | |
114 pRenderer->ExecOutdoorDrawSW(); | |
115 pGame->pIndoorCameraD3D->_438240_draw_lits(); | |
116 } | |
117 pGame->PushStationaryLights(-1); | |
118 pGame->PrepareBloodsplats(); | |
121 | 119 if (bRedraw) |
0 | 120 { |
121 v4 = WorldPosToGridCellZ(pParty->vPosition.y); | |
122 v5 = WorldPosToGridCellX(pParty->vPosition.x); | |
123 pOutdoor->_47EF60(v5, v4, 1); | |
124 } | |
125 pGame->uFlags2 &= 0xFFFFFFFEu; | |
142 | 126 if (pRenderer->pRenderD3D && pRenderer->bUsingSpecular) |
0 | 127 pGame->pLightmapBuilder->uFlags |= 1u; |
128 else | |
129 pGame->pLightmapBuilder->uFlags &= 0xFFFFFFFEu; | |
142 | 130 |
0 | 131 uNumDecorationsDrawnThisFrame = 0; |
132 _unused000 = 0; | |
133 uNumSpritesDrawnThisFrame = 0; | |
134 uNumBillboardsToDraw = 0; | |
142 | 135 |
136 PrepareActorsDrawList(); | |
137 if (!pOutdoorCamera->bDoNotRenderDecorations) | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
142
diff
changeset
|
138 pRenderer->PrepareDecorationsRenderList_ODM(); |
142 | 139 |
0 | 140 pRenderer->DrawLayingItems_Shooting_Magic_ODM(); |
161 | 141 pRenderer->TransformBillboardsAndSetPalettesODM(); |
0 | 142 sub_485F53((Vec2_int_ *)unnamed_6BE060); |
143 } | |
144 | |
145 | |
146 | |
147 //----- (00441CFF) -------------------------------------------------------- | |
148 void OutdoorLocation::Draw() | |
149 { | |
121 | 150 bool redrawWorld = true; |
151 if ( !(pParty->uFlags & 2) && !(pGame->uFlags2 & 1) ) | |
152 redrawWorld = false; | |
153 pOutdoor->ExecDraw(redrawWorld); | |
0 | 154 |
155 pGame->DrawParticles(); | |
156 pWeather->Draw(); | |
157 array_5118E8._440F07(); | |
158 } | |
159 | |
160 | |
161 //----- (00488E23) -------------------------------------------------------- | |
162 double OutdoorLocation::GetFogDensityByTime() | |
163 { | |
164 int v1; // eax@3 | |
165 double v2; // st7@3 | |
166 | |
167 if ( pParty->uCurrentHour < 5 ) | |
168 goto LABEL_9; | |
169 if ( pParty->uCurrentHour >= 6 ) | |
170 { | |
171 if ( pParty->uCurrentHour < 0x14 ) | |
172 { | |
173 pWeather->field_FA0 = 0; | |
174 v2 = 0.0; | |
175 return v2 * 0.016666668; | |
176 } | |
177 if ( pParty->uCurrentHour < 0x15 ) | |
178 { | |
179 v1 = 0; | |
180 v2 = (double)(pParty->uCurrentHour - 20) * 60.0 + (double)(signed int)pParty->uCurrentMinute; | |
181 goto LABEL_4; | |
182 } | |
183 LABEL_9: | |
184 v2 = 60.0; | |
185 pWeather->field_FA0 = 1; | |
186 return v2 * 0.016666668; | |
187 } | |
188 v1 = 0; | |
189 v2 = 60.0 - (double)(60 * pParty->uCurrentHour + pParty->uCurrentMinute - 300); | |
190 LABEL_4: | |
191 pWeather->field_FA0 = v1; | |
192 return v2 * 0.016666668; | |
193 } | |
194 | |
195 //----- (00488EB1) -------------------------------------------------------- | |
196 int OutdoorLocation::GetSomeOtherTileInfo(int sX, int sY) | |
197 { | |
67 | 198 //OutdoorLocation *v3; // esi@1 |
0 | 199 unsigned int v4; // edi@1 |
200 unsigned int v5; // eax@1 | |
201 int result; // eax@5 | |
202 | |
67 | 203 /* v3 = this; |
0 | 204 v4 = WorldPosToGridCellZ(sY); |
205 v5 = WorldPosToGridCellX(sX); | |
206 if ( (v5 & 0x80000000u) != 0 || (signed int)v5 > 127 || (v4 & 0x80000000u) != 0 || (signed int)v4 > 127 ) | |
207 result = 0; | |
208 else | |
209 result = ActuallyGetSomeOtherTileInfo(v5, v4); | |
67 | 210 return result;*/ |
211 v4 = WorldPosToGridCellZ(sY); | |
212 v5 = WorldPosToGridCellX(sX); | |
213 if ( v5 < 0 || v5 > 127 || v4 < 0 || v4 > 127 ) | |
214 return 0; | |
215 return ActuallyGetSomeOtherTileInfo(v5, v4); | |
0 | 216 } |
217 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); | |
218 // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); | |
219 | |
220 //----- (00488EEF) -------------------------------------------------------- | |
67 | 221 unsigned int OutdoorLocation::GetTileTexture(int sX, int sY) |
0 | 222 { |
67 | 223 //OutdoorLocation *v3; // esi@1 |
0 | 224 unsigned int v4; // edi@1 |
225 unsigned int v5; // eax@1 | |
67 | 226 // unsigned int result; // eax@5 |
0 | 227 |
67 | 228 /*v3 = this; |
0 | 229 v4 = WorldPosToGridCellZ(sZ); |
230 v5 = WorldPosToGridCellX(sX); | |
67 | 231 if ( v5< 0 || (signed int)v5 > 127 || v4 < 0 || (signed int)v4 > 127 )//if ( (v5 & 0x80000000u) != 0 || (signed int)v5 > 127 || (v4 & 0x80000000u) != 0 || (signed int)v4 > 127 ) |
0 | 232 result = -1; |
233 else | |
234 result = DoGetTileTexture(v5, v4); | |
67 | 235 return result;*/ |
236 v4 = WorldPosToGridCellZ(sY); | |
237 v5 = WorldPosToGridCellX(sX); | |
238 if ( v5 < 0 || v5 > 127 || v4 < 0 || v4 > 127 ) | |
239 return -1; | |
240 return DoGetTileTexture(v5, v4); | |
0 | 241 } |
242 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); | |
243 // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); | |
244 | |
245 //----- (00488F2E) -------------------------------------------------------- | |
246 int OutdoorLocation::GetHeightOnTerrain(int sX, int sZ) | |
49 | 247 /* Ôóíêöèÿ ïðåäîñòàâëÿåò âîçìîæíîñòü ïåðåìåùàòü êàìåðó òàêèì îáðàçîì, ÷òîáû îíà èìèòèðîâàëà õîäüáó ïî ëàíäøàôòó. |
248 Òî åñòü íàì íàäî ìåíÿòü âûñîòó êàìåðû (êîîðäèíàòó Y) â çàâèñèìîñòè îò òîãî, â êàêîì ìåñòå ëàíäøàôòà ìû íàõîäèìñÿ. | |
249 Äëÿ ýòîãî ìû ñíà÷àëà äîëæíû îïðåäåëèòü ïî êîîðäèíàòàì X è Z êàìåðû êâàäðàò ëàíäøàôòà â êîòîðîì ìû íàõîäèìñÿ. | |
250 Âñå ýòî äåëàåò ôóíêöèÿ Terrain::getHeight; â ñâîèõ ïàðàìåòðàõ îíà ïîëó÷àåò êîîðäèíàòû X è Z êàìåðû è âîçâðàùàåò âûñîòó, | |
251 íà êîòîðîé äîëæíà áûòü ðàñïîëîæåíà êàìåðà, ÷òîáû îíà îêàçàëàñü íàä ëàíäøàôòîì.*/ | |
0 | 252 { |
253 int result; // eax@5 | |
254 | |
255 if ( sX < 0 || sX > 127 || sZ < 0 || sZ > 127 ) | |
256 result = 0; | |
257 else | |
258 result = DoGetHeightOnTerrain(sX, sZ); | |
259 return result; | |
260 } | |
261 | |
262 //----- (00488F5C) -------------------------------------------------------- | |
263 bool OutdoorLocation::Initialize(const char *pFilename, int File, size_t uRespawnInterval, int thisa) | |
264 { | |
265 OutdoorLocation *v5; // esi@1 | |
266 bool result; // eax@2 | |
267 | |
268 v5 = this; | |
269 if ( pFilename ) | |
270 { | |
271 Release(); | |
272 pBitmaps_LOD->ReleaseAll2(); | |
273 pSprites_LOD->DeleteSomeOtherSprites(); | |
274 pSpriteFrameTable->ResetSomeSpriteFlags(); | |
275 pIcons_LOD->ReleaseAll2(); | |
276 sub_46080D(); | |
277 TryLoadLevelFromLOD(); | |
119 | 278 if ( !Load(pFilename, (ODMFace *)File, uRespawnInterval, thisa) ) |
0 | 279 { |
280 MessageBoxA(0, "Error!", "Couldn't Load Map!", 0); | |
281 CreateDebugLocation(); | |
282 } | |
283 day_attrib = v5->day_attrib; | |
284 day_fogrange_1 = v5->day_fogrange_1; | |
285 day_fogrange_2 = v5->day_fogrange_2; | |
286 if ( Is_out15odm_underwater() ) | |
287 SetUnderwaterFog(); | |
288 _6BE134_odm_main_tile_group = v5->pTileTypes[0].uTileGroup; | |
289 result = 1; | |
290 } | |
291 else | |
292 { | |
293 result = 0; | |
294 } | |
295 return result; | |
296 } | |
297 | |
298 //----- (0048901B) -------------------------------------------------------- | |
299 bool OutdoorLocation::Release2() | |
300 { | |
301 Release(); | |
302 pOutdoorCamera->ReleaseSoftwareDrawBuffers(); | |
303 return true; | |
304 } | |
305 | |
306 //----- (0048902E) -------------------------------------------------------- | |
307 bool OutdoorLocation::GetTravelDestination(signed int sPartyX, signed int sPartyZ, char *pOut, signed int a5) | |
308 { | |
309 OutdoorLocation *v5; // esi@1 | |
310 char *v6; // eax@3 | |
311 int v7; // eax@3 | |
312 int v8; // edx@3 | |
313 signed int v9; // esi@7 | |
314 int v10; // esi@23 | |
315 signed int v11; // eax@23 | |
316 int v12; // ST14_4@25 | |
317 signed int v14; // [sp-4h] [bp-84h]@6 | |
138 | 318 char Str[140]; // [sp+8h] [bp-78h]@3 |
0 | 319 int a5a; // [sp+94h] [bp+14h]@3 |
320 | |
321 auto Source = this; | |
322 | |
323 v5 = Source; | |
324 if ( a5 < 10 | |
325 || strlen(Source->pLevelFilename) != 9 | |
138 | 326 || (strcpy(Str, v5->pLevelFilename), |
327 _strlwr(Str), | |
328 v6 = strtok(Str, "out"), | |
0 | 329 v6[2] = 0, |
330 v7 = atoi(v6), | |
331 v8 = v7, | |
332 a5a = v7, | |
333 v7 < 1) | |
334 || v7 > 15 ) | |
335 return 0; | |
336 if ( sPartyX < -22528 ) | |
337 { | |
338 v14 = 4; | |
339 LABEL_7: | |
340 v9 = v14; | |
341 goto LABEL_14; | |
342 } | |
343 if ( sPartyX > 22528 ) | |
344 { | |
345 v14 = 3; | |
346 goto LABEL_7; | |
347 } | |
348 if ( sPartyZ < -22528 ) | |
349 { | |
350 v14 = 2; | |
351 goto LABEL_7; | |
352 } | |
353 if ( sPartyZ <= 22528 ) | |
354 return 0; | |
355 v9 = 1; | |
356 LABEL_14: | |
357 if ( v7 == 14 ) | |
358 { | |
359 if ( v9 == 4 ) | |
360 { | |
361 if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(0) ) | |
362 { | |
363 uDefaultTravelTime_ByFoot = 1; | |
364 strcpy(pOut, "out15.odm"); | |
365 uLevel_StartingPointType = 3; | |
366 LABEL_18: | |
367 LOWORD(pParty->uFlags) &= 0xFD7Bu; | |
368 return 1; | |
369 } | |
370 v8 = a5a; | |
371 } | |
372 } | |
373 else | |
374 { | |
375 if ( v7 == 15 && v9 == 3 ) | |
376 { | |
377 uDefaultTravelTime_ByFoot = 1; | |
378 strcpy(pOut, "out14.odm"); | |
379 uLevel_StartingPointType = 4; | |
380 goto LABEL_18; | |
381 } | |
382 } | |
383 v10 = v9 + 4 * v8; | |
384 v11 = (unsigned __int8)aTiletableLoadU[v10 + 39]; | |
385 if ( v11 >= 1 && v11 <= 15 ) | |
386 { | |
387 v12 = (unsigned __int8)aTiletableLoadU[v10 + 39]; | |
388 uDefaultTravelTime_ByFoot = (unsigned __int8)byte_4ECA93[v10]; | |
389 sprintf(pOut, "out%02d.odm", v12); | |
390 uLevel_StartingPointType = (unsigned __int8)byte_4ECACF[v10]; | |
391 return 1; | |
392 } | |
393 return 0; | |
394 } | |
395 // 6BD07C: using guessed type int uDefaultTravelTime_ByFoot; | |
396 // 6BE35C: using guessed type int uLevel_StartingPointType; | |
397 | |
398 //----- (0048917E) -------------------------------------------------------- | |
399 void OutdoorLocation::MessWithLUN() | |
400 { | |
401 OutdoorLocation *v1; // esi@1 | |
402 unsigned int *v2; // ebp@1 | |
403 unsigned int v3; // eax@1 | |
404 unsigned __int16 v4; // ax@1 | |
405 signed int v5; // ebx@1 | |
406 | |
407 v1 = this; | |
408 v2 = this->pSpriteIDs_LUN; | |
409 this->pSpriteIDs_LUN[0] = -1; | |
410 this->pSpriteIDs_LUN[2] = pSpriteFrameTable->FastFindSprite("LUN1-4"); | |
411 v1->pSpriteIDs_LUN[4] = pSpriteFrameTable->FastFindSprite("LUN1-2"); | |
412 v1->pSpriteIDs_LUN[6] = pSpriteFrameTable->FastFindSprite("LUN3-4"); | |
413 v1->uSpriteID_LUNFULL = pSpriteFrameTable->FastFindSprite("LUNFULL"); | |
414 v1->uSpriteID_LUN3_4_cp = pSpriteFrameTable->FastFindSprite("LUN3-4"); | |
415 v1->uSpriteID_LUN1_2_cp = pSpriteFrameTable->FastFindSprite("LUN1-2"); | |
416 v3 = pSpriteFrameTable->FastFindSprite("LUN1-4"); | |
417 v1->field_D60 = -1; | |
418 v1->uSpriteID_LUN1_4_cp = v3; | |
419 v1->field_CF0 = 4; | |
420 v1->field_CF8 = 4; | |
421 v1->field_D00 = 4; | |
422 LOWORD(v3) = *(short *)v2; | |
423 v1->pSpriteIDs_LUN[1] = 0; | |
424 v1->pSpriteIDs_LUN[3] = 0; | |
425 v1->pSpriteIDs_LUN[5] = 0; | |
426 v1->pSpriteIDs_LUN[7] = 0; | |
427 v1->field_CE8 = 0; | |
428 LOWORD(v1->field_D3C) = v3; | |
429 v1->field_D40 = 0; | |
430 v1->field_D44 = 0; | |
431 v1->field_D48 = 0; | |
432 v1->field_D4C = 131072; | |
433 v1->field_D5C = 0; | |
434 v1->field_D64 = 0; | |
435 v4 = pSpriteFrameTable->FastFindSprite("LUN-SUN"); | |
436 v1->field_D28 = -1; | |
437 v1->field_D08 = 0; | |
438 v1->field_D0C = 0; | |
439 v1->field_D10 = 0; | |
440 v1->field_D24 = 0; | |
441 v1->field_D2C = 0; | |
442 v1->uSpriteID_LUN_SUN = v4; | |
443 v1->field_D14 = -131072; | |
444 v5 = 8; | |
445 do | |
446 { | |
447 pSpriteFrameTable->InitializeSprite(*v2); | |
448 v2 += 2; | |
449 --v5; | |
450 } | |
451 while ( v5 ); | |
452 pSpriteFrameTable->InitializeSprite(v1->uSpriteID_LUN_SUN); | |
453 } | |
454 | |
455 //----- (004892E6) -------------------------------------------------------- | |
456 unsigned int OutdoorLocation::UpdateSunlightVectors() | |
457 { | |
458 unsigned int result; // eax@1 | |
459 OutdoorLocation *v2; // esi@1 | |
460 unsigned int v3; // edi@3 | |
461 int v4; // ebx@3 | |
462 int v5; // eax@3 | |
463 int v6; // eax@3 | |
464 int v7; // ecx@3 | |
465 double v8; // st7@4 | |
466 | |
467 result = pParty->uCurrentHour; | |
468 v2 = this; | |
469 if ( pParty->uCurrentHour >= 5 && pParty->uCurrentHour < 0x15 ) | |
470 { | |
471 v3 = pParty->uCurrentMinute + 60 * (pParty->uCurrentHour - 5); | |
472 v4 = (signed int)(v3 * stru_5C6E00->uIntegerPi) / 960; | |
473 v5 = stru_5C6E00->SinCos((signed int)(v3 * stru_5C6E00->uIntegerPi) / 960); | |
474 v2->field_D1C = 0; | |
475 v2->field_D18 = v5; | |
476 v6 = stru_5C6E00->SinCos(v4 - stru_5C6E00->uIntegerHalfPi); | |
477 v7 = v2->field_D18; | |
478 v2->field_D20 = v6; | |
479 v2->vSunlight.x = -v7; | |
480 v2->vSunlight.y = -v2->field_D1C; | |
481 v2->vSunlight.z = -v6; | |
482 if ( (signed int)v3 >= 480 ) | |
483 v8 = (double)(signed int)(960 - v3); | |
484 else | |
485 v8 = (double)(signed int)v3; | |
486 v2->field_CBC_terrain_triangles_shade_type = (signed __int64)(20.0 - v8 * 0.002083333333333333 * 20.0); | |
487 result = pParty->uCurrentMinute; | |
488 v2->uLastSunlightUpdateMinute = pParty->uCurrentMinute; | |
489 } | |
490 return result; | |
491 } | |
492 | |
493 //----- (004893C1) -------------------------------------------------------- | |
494 void OutdoorLocation::UpdateFog() | |
495 { | |
496 fFogDensity = GetFogDensityByTime(); | |
497 } | |
498 | |
499 //----- (004893CF) -------------------------------------------------------- | |
500 int OutdoorLocation::GetNumFoodRequiredToRestInCurrentPos(int x, signed int y, int z) | |
501 { | |
502 OutdoorLocation *v4; // ebx@1 | |
503 signed int v5; // edi@4 | |
504 int v6; // eax@4 | |
505 int v7; // eax@4 | |
506 int v8; // eax@4 | |
507 int v9; // eax@5 | |
508 int v10; // eax@6 | |
509 int v11; // eax@7 | |
510 int v12; // eax@8 | |
511 int v15; // [sp+8h] [bp-8h]@2 | |
512 int v16; // [sp+Ch] [bp-4h]@2 | |
513 | |
514 v4 = this; | |
515 if ( pParty->uFlags & 8 | |
516 || (v15 = 0, | |
517 v16 = 0, | |
518 sub_46D49E_prolly_get_world_y_under_party(x, y, z, pParty->uDefaultPartyHeight, &v15, &v16, 0), | |
519 v16) | |
520 || v15 ) | |
521 return 2; | |
522 v5 = WorldPosToGridCellX(pParty->vPosition.x); | |
523 v6 = WorldPosToGridCellZ(pParty->vPosition.y); | |
524 v7 = _47ED83(v5, v6 - 1); | |
525 v8 = pTileTable->pTiles[_47ECC1(v7)].uTerrainType; | |
526 if ( v8 ) | |
527 { | |
528 v9 = v8 - 1; | |
529 if ( !v9 ) | |
530 return 3; | |
531 v10 = v9 - 1; | |
532 if ( !v10 ) | |
533 return 5; | |
534 v11 = v10 - 1; | |
535 if ( !v11 || (v12 = v11 - 3) == 0 ) | |
536 return 4; | |
537 if ( v12 == 1 ) | |
538 return 3; | |
539 return 2; | |
540 } | |
541 return 1; | |
542 } | |
543 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); | |
544 // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); | |
545 | |
546 //----- (00489487) -------------------------------------------------------- | |
547 int OutdoorLocation::SetFog() | |
548 { | |
549 int result; // eax@1 | |
550 int v2; // esi@1 | |
551 int v3; // edx@5 | |
552 unsigned __int8 *v4; // eax@5 | |
553 int v5; // ecx@5 | |
554 int v6; // esi@7 | |
555 unsigned __int8 v7; // al@9 | |
556 | |
557 strcpy(pOutdoor->pLevelFilename, pCurrentMapName); | |
558 result = pMapStats->GetMapInfo(pCurrentMapName); | |
559 v2 = result; | |
560 if ( result < 1 || result == 7 || result == 8 || result > 15 ) | |
561 return result; | |
562 day_attrib &= 0xFFFFFFFEu; | |
563 v3 = rand() % 100; | |
564 v4 = (unsigned __int8 *)&byte_4ECB0C[4 * v2]; | |
565 v5 = *v4; | |
566 if ( v3 < v5 ) | |
567 { | |
568 day_fogrange_1 = 4096; | |
569 day_fogrange_2 = 8192; | |
570 LABEL_13: | |
571 day_attrib |= 1u; | |
572 goto LABEL_14; | |
573 } | |
574 v6 = v4[1]; | |
575 if ( v3 < v6 + v5 ) | |
576 { | |
577 day_fogrange_2 = 4096; | |
578 LABEL_12: | |
579 day_fogrange_1 = 0; | |
580 goto LABEL_13; | |
581 } | |
582 v7 = v4[2]; | |
583 if ( v7 && v3 < v5 + v6 + v7 ) | |
584 { | |
585 day_fogrange_2 = 2048; | |
586 goto LABEL_12; | |
587 } | |
588 LABEL_14: | |
589 if ( Is_out15odm_underwater() ) | |
590 SetUnderwaterFog(); | |
591 pOutdoor->day_fogrange_1 = day_fogrange_1; | |
592 pOutdoor->day_fogrange_2 = day_fogrange_2; | |
593 result = day_attrib; | |
594 pOutdoor->day_attrib = day_attrib; | |
595 return result; | |
596 } | |
597 // 6BE030: using guessed type int day_attrib; | |
598 // 6BE040: using guessed type int day_fogrange_1; | |
599 // 6BE044: using guessed type int day_fogrange_2; | |
600 | |
601 //----- (00482170) -------------------------------------------------------- | |
602 bool ODMFace::IsBackfaceCulled(ODMFace *a1, RenderVertexSoft *a2, stru148 *a3) | |
603 { | |
604 stru148 *v3; // edi@1 | |
605 RenderVertexSoft *v4; // esi@1 | |
606 unsigned int v5; // edx@1 | |
607 RenderVertexSoft *v6; // ecx@2 | |
608 double v7; // st7@5 | |
609 double v8; // st6@5 | |
610 double v9; // st5@5 | |
611 double v10; // st6@9 | |
612 double v11; // st5@9 | |
613 double v12; // st4@9 | |
614 bool result; // eax@16 | |
615 double v14; // ST2C_8@17 | |
616 double v15; // ST20_8@17 | |
617 double v16; // ST0C_8@17 | |
618 double v17; // ST0C_8@17 | |
619 float v18; // [sp+8h] [bp-38h]@5 | |
620 float v19; // [sp+10h] [bp-30h]@5 | |
621 float v20; // [sp+14h] [bp-2Ch]@5 | |
622 float v21; // [sp+18h] [bp-28h]@5 | |
623 float v22; // [sp+1Ch] [bp-24h]@5 | |
624 float v23; // [sp+24h] [bp-1Ch]@5 | |
625 float v24; // [sp+28h] [bp-18h]@5 | |
626 float v25; // [sp+30h] [bp-10h]@5 | |
627 float v26; // [sp+34h] [bp-Ch]@5 | |
628 float v27; // [sp+38h] [bp-8h]@5 | |
629 float v28; // [sp+3Ch] [bp-4h]@5 | |
630 float a3a; // [sp+48h] [bp+8h]@5 | |
631 float a3b; // [sp+48h] [bp+8h]@17 | |
632 float a3c; // [sp+48h] [bp+8h]@17 | |
633 float a3d; // [sp+48h] [bp+8h]@17 | |
634 float a3e; // [sp+48h] [bp+8h]@17 | |
635 | |
636 v3 = a3; | |
637 v4 = a2; | |
638 v5 = a3->uNumVertices; | |
639 if ( (signed int)v5 < 3 ) | |
640 goto LABEL_20; | |
641 v6 = &v4[v5 - 1]; | |
642 if ( v4->vWorldPosition.z == v4[1].vWorldPosition.z && v4[1].vWorldPosition.z == v6->vWorldPosition.z ) | |
643 *(int *)&a3->flags |= 0x10u; | |
644 v19 = v4[1].vWorldViewPosition.x - v4->vWorldViewPosition.x; | |
645 v18 = v4[1].vWorldViewPosition.y - v4->vWorldViewPosition.y; | |
646 v20 = v4[1].vWorldViewPosition.z - v4->vWorldViewPosition.z; | |
647 v21 = v6->vWorldViewPosition.x - v4->vWorldViewPosition.x; | |
648 v22 = v6->vWorldViewPosition.y - v4->vWorldViewPosition.y; | |
649 v23 = v6->vWorldViewPosition.z - v4->vWorldViewPosition.z; | |
650 v28 = v4[1].vWorldPosition.x - v4->vWorldPosition.x; | |
651 v27 = v4[1].vWorldPosition.y - v4->vWorldPosition.y; | |
652 a3a = v4[1].vWorldPosition.z - v4->vWorldPosition.z; | |
653 v7 = v6->vWorldPosition.x - v4->vWorldPosition.x; | |
654 v8 = v6->vWorldPosition.y - v4->vWorldPosition.y; | |
655 v9 = v6->vWorldPosition.z - v4->vWorldPosition.z; | |
656 v26 = v27 * v9 - v8 * a3a; | |
657 v24 = v7 * a3a - v9 * v28; | |
658 v25 = v8 * v28 - v7 * v27; | |
659 if ( v26 == 0.0 && v24 == 0.0 && v25 == 0.0 ) | |
660 { | |
661 while ( 1 ) | |
662 { | |
663 --v5; | |
664 if ( (signed int)v5 < 2 ) | |
665 break; | |
666 v10 = v6->vWorldPosition.x - v4->vWorldPosition.x; | |
667 v11 = v6->vWorldPosition.y - v4->vWorldPosition.y; | |
668 v12 = v6->vWorldPosition.z - v4->vWorldPosition.z; | |
669 v26 = v27 * v12 - v11 * a3a; | |
670 v24 = v10 * a3a - v12 * v28; | |
671 v25 = v11 * v28 - v10 * v27; | |
672 if ( v26 != 0.0 ) | |
673 break; | |
674 if ( v24 != 0.0 || v25 != 0.0 ) | |
675 break; | |
676 --v6; | |
677 } | |
678 v21 = v6->vWorldViewPosition.x - v4->vWorldViewPosition.x; | |
679 v22 = v6->vWorldViewPosition.y - v4->vWorldViewPosition.y; | |
680 v23 = v6->vWorldViewPosition.z - v4->vWorldViewPosition.z; | |
681 } | |
682 if ( ((double)pIndoorCamera->pos.x - v4->vWorldPosition.x) * v26 | |
683 + ((double)pIndoorCamera->pos.z - v4->vWorldPosition.z) * v25 | |
684 + ((double)pIndoorCamera->pos.y - v4->vWorldPosition.y) * v24 > 0.0 ) | |
685 { | |
686 a3b = v23 * v18 - v22 * v20; | |
687 v14 = a3b + 6.7553994e15; | |
688 v3->v_18.x = LODWORD(v14); | |
689 a3c = v21 * v20 - v23 * v19; | |
690 v15 = a3c + 6.7553994e15; | |
691 v3->v_18.y = LODWORD(v15); | |
692 a3d = v22 * v19 - v21 * v18; | |
693 v16 = a3d + 6.7553994e15; | |
694 v3->v_18.z = LODWORD(v16); | |
695 v3->_486089_normalize_v_18(); | |
696 a3e = -((double)v3->v_18.x * v4->vWorldViewPosition.x) | |
697 - (double)v3->v_18.y * v4->vWorldViewPosition.y | |
698 - (double)v3->v_18.z * v4->vWorldViewPosition.z; | |
699 v17 = a3e + 6.7553994e15; | |
700 v3->field_24 = LODWORD(v17); | |
701 result = 1; | |
702 } | |
703 else | |
704 { | |
705 LABEL_20: | |
706 result = 0; | |
707 } | |
708 return result; | |
709 } | |
710 | |
711 | |
712 //----- (0047C7A9) -------------------------------------------------------- | |
713 void OutdoorLocationTerrain::_47C7A9() | |
714 { | |
715 this->field_10 = 0; | |
716 this->field_12 = 0; | |
717 this->field_16 = 0; | |
718 this->field_14 = 0; | |
719 this->field_1C = 0; | |
720 this->field_18 = 0; | |
721 } | |
722 | |
723 //----- (0047C7C2) -------------------------------------------------------- | |
49 | 724 void OutdoorLocationTerrain::Release()//î÷èñòèòü ëîêàöèþ |
0 | 725 { |
726 if (pHeightmap) | |
727 { | |
728 pAllocator->FreeChunk(this->pHeightmap); | |
729 pHeightmap = nullptr; | |
730 } | |
731 if (pTilemap) | |
732 { | |
733 pAllocator->FreeChunk(pTilemap); | |
734 pTilemap = nullptr; | |
735 } | |
736 if (pAttributemap) | |
737 { | |
738 pAllocator->FreeChunk(pAttributemap); | |
739 pAttributemap = nullptr; | |
740 } | |
741 if (ptr_C) | |
742 { | |
743 pAllocator->FreeChunk(ptr_C); | |
744 ptr_C = nullptr; | |
745 } | |
746 | |
747 _47C7A9(); | |
748 } | |
749 | |
750 //----- (0047C80A) -------------------------------------------------------- | |
751 int OutdoorLocationTerrain::_47C80A(int a2, int a3, int a4, int a5) | |
752 { | |
49 | 753 OutdoorLocationTerrain *pOutLocTerrain; // ebx@1 |
0 | 754 double v6; // st7@1 |
755 double v7; // st7@2 | |
756 double v8; // st7@2 | |
757 int result; // eax@3 | |
758 int v10; // eax@4 | |
759 int v11; // ecx@5 | |
760 int v12; // ecx@6 | |
761 int v13; // edi@7 | |
762 int v14; // edx@9 | |
763 int v15; // eax@15 | |
49 | 764 unsigned __int8 *pMapHeight; // ebx@15 |
0 | 765 int v17; // eax@15 |
766 int v18; // ecx@15 | |
767 int v19; // esi@15 | |
768 int v20; // edi@15 | |
769 int v21; // edx@15 | |
770 int v22; // ecx@15 | |
771 int v23; // ebx@15 | |
772 int v24; // ecx@15 | |
773 int v25; // ST28_4@15 | |
774 double v26; // st7@15 | |
775 double v27; // st6@15 | |
776 double v28; // st5@15 | |
777 double v29; // st7@15 | |
778 double v30; // st7@16 | |
779 double v31; // st7@17 | |
780 int v32; // eax@21 | |
781 double v33; // st7@21 | |
782 double v34; // st6@21 | |
783 double v35; // st5@21 | |
784 double v36; // st7@21 | |
785 double v37; // st7@22 | |
786 double v38; // st7@23 | |
787 int v39; // [sp+14h] [bp-34h]@8 | |
788 int v40; // [sp+18h] [bp-30h]@15 | |
789 int v41; // [sp+1Ch] [bp-2Ch]@15 | |
790 int v42; // [sp+20h] [bp-28h]@15 | |
49 | 791 OutdoorLocationTerrain *pOutLocTerrain2; // [sp+24h] [bp-24h]@1 |
0 | 792 int v44; // [sp+28h] [bp-20h]@21 |
793 float v45; // [sp+2Ch] [bp-1Ch]@1 | |
794 float v46; // [sp+30h] [bp-18h]@1 | |
795 float v47; // [sp+34h] [bp-14h]@1 | |
796 int v48; // [sp+38h] [bp-10h]@7 | |
797 int v49; // [sp+3Ch] [bp-Ch]@10 | |
798 int v50; // [sp+40h] [bp-8h]@9 | |
799 float v51; // [sp+44h] [bp-4h]@15 | |
800 float v52; // [sp+44h] [bp-4h]@21 | |
801 float v53; // [sp+50h] [bp+8h]@15 | |
802 float v54; // [sp+50h] [bp+8h]@21 | |
803 int v55; // [sp+54h] [bp+Ch]@15 | |
804 float v56; // [sp+54h] [bp+Ch]@15 | |
805 float v57; // [sp+54h] [bp+Ch]@21 | |
806 | |
807 v46 = -64.0; | |
808 v47 = -64.0; | |
49 | 809 pOutLocTerrain = this; |
0 | 810 v45 = 64.0; |
49 | 811 pOutLocTerrain2 = this; |
0 | 812 v6 = sqrt(12288.0); |
813 if ( v6 != 0.0 ) | |
814 { | |
815 v7 = 1.0 / v6; | |
816 v45 = 64.0 * v7; | |
817 v8 = v7 * -64.0; | |
818 v46 = v8; | |
819 v47 = v8; | |
820 } | |
821 result = a3; | |
822 if ( a3 > a5 ) | |
823 { | |
824 v10 = a5 ^ a3; | |
825 a5 ^= a3 ^ a5; | |
826 result = a5 ^ v10; | |
827 } | |
828 v11 = a2; | |
829 if ( a2 > a4 ) | |
830 { | |
831 v12 = a4 ^ a2; | |
832 a4 ^= a2 ^ a4; | |
833 v11 = a4 ^ v12; | |
834 } | |
835 v13 = result - 1; | |
836 v48 = result - 1; | |
837 if ( result - 1 <= a5 ) | |
838 { | |
839 v39 = v11 - 1; | |
840 do | |
841 { | |
842 v14 = v39; | |
843 v50 = v39; | |
844 if ( v39 <= a4 ) | |
845 { | |
846 result = (v39 - 63) << 9; | |
847 v49 = (v39 - 63) << 9; | |
848 do | |
849 { | |
850 if ( v13 >= 0 && result >= -32256 && v13 <= 127 && result <= 32768 ) | |
851 { | |
49 | 852 v15 = pOutLocTerrain->field_10; |
0 | 853 v55 = v15; |
49 | 854 pMapHeight = pOutLocTerrain->pHeightmap; |
855 v17 = (int)(&pMapHeight[v13 * v15] + v14); | |
0 | 856 v18 = -v13; |
857 v19 = (64 - v13) << 9; | |
858 v20 = 32 * *(char *)v17; | |
859 v21 = 32 * *(char *)(v17 + 1); | |
860 v22 = (v18 + 63) << 9; | |
861 v41 = v22; | |
49 | 862 v23 = (int)(&pMapHeight[v55 * (v48 + 1)] + v50); |
0 | 863 v24 = v22 - v19; |
864 v40 = 32 * *(char *)v23; | |
865 v42 = 32 * *(char *)(v23 + 1); | |
866 v25 = v49 - 512 - v49; | |
867 v26 = (double)-((v20 - v21) * v24); | |
868 v51 = v26; | |
869 v27 = (double)-(v25 * (v42 - v21)); | |
870 v53 = v27; | |
871 v28 = (double)(v25 * v24); | |
872 v56 = v28; | |
873 v29 = sqrt(v28 * v28 + v27 * v27 + v26 * v26); | |
874 if ( v29 != 0.0 ) | |
875 { | |
876 v30 = 1.0 / v29; | |
877 v51 = v51 * v30; | |
878 v53 = v53 * v30; | |
879 v56 = v30 * v56; | |
880 } | |
881 v31 = (v56 * v47 + v53 * v46 + v51 * v45) * 31.0; | |
882 if ( v31 < 0.0 ) | |
883 v31 = 0.0; | |
884 if ( v31 > 31.0 ) | |
885 v31 = 31.0; | |
49 | 886 v44 = 2 * (v50 + v48 * pOutLocTerrain2->field_10); |
887 pOutLocTerrain = pOutLocTerrain2; | |
888 *((char *)pOutLocTerrain2->ptr_C + v44 + 1) = (signed __int64)v31; | |
0 | 889 v32 = v49 - (v49 - 512); |
890 v33 = (double)-((v42 - v40) * (v19 - v41)); | |
891 v52 = v33; | |
892 v34 = (double)-(v32 * (v20 - v40)); | |
893 v54 = v34; | |
894 v35 = (double)(v32 * (v19 - v41)); | |
895 v57 = v35; | |
896 v36 = sqrt(v35 * v35 + v34 * v34 + v33 * v33); | |
897 if ( v36 != 0.0 ) | |
898 { | |
899 v37 = 1.0 / v36; | |
900 v52 = v52 * v37; | |
901 v54 = v54 * v37; | |
902 v57 = v37 * v57; | |
903 } | |
904 v38 = (v57 * v47 + v54 * v46 + v52 * v45) * 31.0; | |
905 if ( v38 < 0.0 ) | |
906 v38 = 0.0; | |
907 if ( v38 > 31.0 ) | |
908 v38 = 31.0; | |
909 v13 = v48; | |
49 | 910 *((char *)pOutLocTerrain2->ptr_C + v44) = (signed __int64)v38; |
0 | 911 v14 = v50; |
912 result = v49; | |
913 } | |
914 ++v14; | |
915 result += 512; | |
916 v50 = v14; | |
917 v49 = result; | |
918 } | |
919 while ( v14 <= a4 ); | |
920 } | |
921 ++v13; | |
922 v48 = v13; | |
923 } | |
924 while ( v13 <= a5 ); | |
925 } | |
926 return result; | |
927 } | |
928 | |
929 //----- (0047CB57) -------------------------------------------------------- | |
930 int OutdoorLocationTerrain::_47CB57(int a1, int a2, int a3) | |
931 { | |
932 signed int result; // eax@2 | |
933 unsigned __int16 *v5; // edx@3 | |
934 double v6; // st7@3 | |
935 char v7; // bl@3 | |
936 int v8; // eax@3 | |
937 int v9; // eax@4 | |
938 int v10; // eax@5 | |
939 double v11; // st6@7 | |
940 signed int v12; // edi@7 | |
941 int v13; // esi@9 | |
942 char *v14; // esi@10 | |
943 signed int v15; // ecx@10 | |
944 char v16[256]; // [sp+4h] [bp-124h]@9 | |
945 unsigned __int16 *v17; // [sp+104h] [bp-24h]@3 | |
946 unsigned int v18; // [sp+108h] [bp-20h]@3 | |
947 unsigned int v19; // [sp+10Ch] [bp-1Ch]@3 | |
948 unsigned int v20; // [sp+110h] [bp-18h]@3 | |
949 unsigned int v21; // [sp+114h] [bp-14h]@3 | |
950 float v22; // [sp+118h] [bp-10h]@3 | |
951 float v23; // [sp+11Ch] [bp-Ch]@3 | |
952 int i; // [sp+120h] [bp-8h]@3 | |
953 unsigned int v25; // [sp+124h] [bp-4h]@5 | |
954 signed int a2a; // [sp+134h] [bp+Ch]@3 | |
955 unsigned int a2b; // [sp+134h] [bp+Ch]@7 | |
956 float a3a; // [sp+138h] [bp+10h]@7 | |
957 int a3b; // [sp+138h] [bp+10h]@9 | |
958 | |
959 if ( pRenderer->pRenderD3D ) | |
960 { | |
961 result = 0; | |
962 } | |
963 else | |
964 { | |
965 v5 = PaletteManager::Get_Dark_or_Red_LUT(a2, 0, 1); | |
966 v6 = 0.0; | |
967 v7 = LOBYTE(pRenderer->uTargetBBits); | |
968 v19 = pRenderer->uTargetRMask; | |
969 v21 = pRenderer->uTargetGMask; | |
970 v22 = 0.0; | |
971 v20 = pRenderer->uTargetBMask; | |
972 v8 = 0; | |
973 v17 = v5; | |
974 v23 = 0.0; | |
975 v18 = pRenderer->uTargetBBits; | |
976 a2a = 0; | |
977 for ( i = 0; i < a3; ++i ) | |
978 { | |
979 v9 = *(char *)(v8 + a1); | |
980 if ( v9 ) | |
981 { | |
982 v10 = v5[v9]; | |
983 v6 = v6 + (double)((signed int)(v19 & v10) >> (LOBYTE(pRenderer->uTargetBBits) + LOBYTE(pRenderer->uTargetGBits))); | |
984 ++a2a; | |
985 v25 = v20 & v10; | |
986 v22 = (double)((signed int)(v21 & v10) >> SLOBYTE(pRenderer->uTargetBBits)) + v22; | |
987 v23 = (double)(signed int)(v20 & v10) + v23; | |
988 } | |
989 v8 = i + 1; | |
990 } | |
991 v11 = 1.0 / (double)a2a; | |
992 a3a = v11; | |
993 v25 = (signed __int64)(a3a * v22); | |
994 i = (signed __int64)(a3a * v23); | |
995 v12 = 0; | |
996 a2b = pRenderer->uTargetBBits + pRenderer->uTargetGBits; | |
997 while ( 1 ) | |
998 { | |
999 v13 = v17[v12]; | |
1000 a3b = abs((__int64)(signed __int64)(v11 * v6) - ((signed int)(v19 & v17[v12]) >> a2b)); | |
1001 BYTE3(a3b) = abs((signed)v25 - ((signed int)(v21 & v13) >> v7)) + a3b; | |
1002 v16[v12++] = abs((signed)i - (signed)(v20 & v13)) + BYTE3(a3b); | |
1003 if ( v12 >= 256 ) | |
1004 break; | |
1005 v7 = v18; | |
1006 } | |
1007 result = 0; | |
1008 v14 = (char *)&pPaletteManager->field_D1600[42][23][116]; | |
1009 v15 = 0; | |
1010 do | |
1011 { | |
1012 if ( (unsigned __int8)v16[v15] < (signed int)v14 ) | |
1013 { | |
1014 v14 = (char *)(unsigned __int8)v16[v15]; | |
1015 result = v15; | |
1016 } | |
1017 ++v15; | |
1018 } | |
1019 while ( v15 < 256 ); | |
1020 } | |
1021 return result; | |
1022 } | |
1023 // 47CB57: using guessed type char var_124[256]; | |
1024 | |
1025 //----- (0047CCE2) -------------------------------------------------------- | |
1026 bool OutdoorLocationTerrain::ZeroLandscape() | |
1027 { | |
1028 OutdoorLocationTerrain *v1; // esi@1 | |
1029 | |
1030 v1 = this; | |
1031 memset(this->pHeightmap, 0, 0x4000u); | |
1032 memset(v1->pTilemap, 90, 0x4000u); | |
1033 memset(v1->pAttributemap, 0, 0x4000u); | |
1034 memset(v1->ptr_C, 0, 0x8000u); | |
1035 v1->field_12 = 128; | |
1036 v1->field_10 = 128; | |
1037 v1->field_16 = 7; | |
1038 v1->field_14 = 7; | |
1039 v1->field_1C = 127; | |
1040 v1->field_18 = 127; | |
1041 return 1; | |
1042 } | |
1043 | |
1044 //----- (0047CD44) -------------------------------------------------------- | |
1045 bool OutdoorLocationTerrain::Initialize() | |
1046 { | |
1047 OutdoorLocationTerrain *v1; // esi@1 | |
1048 void *v2; // eax@1 | |
1049 bool result; // eax@2 | |
1050 void *v4; // eax@3 | |
1051 void *v5; // eax@4 | |
1052 void *v6; // eax@5 | |
1053 | |
1054 v1 = this; | |
49 | 1055 v2 = pAllocator->AllocNamedChunk(this->pHeightmap, 0x4000u, "HMAP");//êàðòà âûñîò |
0 | 1056 v1->pHeightmap = (unsigned __int8 *)v2; |
1057 if ( v2 | |
49 | 1058 && (v4 = pAllocator->AllocNamedChunk(v1->pTilemap, 0x4000u, "TMAP"),//êàðòà òàéëîâ |
0 | 1059 (v1->pTilemap = (unsigned __int8 *)v4) != 0) |
49 | 1060 && (v5 = pAllocator->AllocNamedChunk(v1->pAttributemap, 0x4000u, "AMAP"),//êàðòà àòðèáóòîâ |
0 | 1061 (v1->pAttributemap = (unsigned __int8 *)v5) != 0) ) |
1062 { | |
1063 v6 = pAllocator->AllocNamedChunk(v1->ptr_C, 0x8000u, "DMAP"); | |
1064 v1->ptr_C = v6; | |
1065 result = v6 != 0; | |
1066 } | |
1067 else | |
1068 { | |
1069 result = 0; | |
1070 } | |
1071 return result; | |
1072 } | |
1073 | |
1074 //----- (0047CDE2) -------------------------------------------------------- | |
1075 void OutdoorLocation::CreateDebugLocation() | |
1076 { | |
1077 OutdoorLocation *v1; // esi@1 | |
1078 void *v2; // eax@1 | |
1079 void *v3; // ST14_4@1 | |
1080 void *v4; // eax@1 | |
1081 void *v5; // ST14_4@1 | |
1082 void *v6; // eax@1 | |
1083 unsigned int v7; // eax@1 | |
1084 char v8; // zf@1 | |
1085 | |
1086 v1 = this; | |
1087 strcpy(this->pLevelFilename, "blank"); | |
1088 strcpy(v1->pLocationFileName, "i6.odm"); | |
1089 strcpy(v1->pLocationFileDescription, "MM6 Outdoor v1.00"); | |
1090 v1->uNumBModels = 0; | |
1091 v1->pTileTypes[0].uTileGroup = 0; | |
1092 v1->pTileTypes[1].uTileGroup = 5; | |
1093 v1->pTileTypes[2].uTileGroup = 6; | |
1094 v1->pTileTypes[3].uTileGroup = 10; | |
1095 v1->LoadTileGroupIds(); | |
1096 v1->_47F3EA(); | |
1097 pAllocator->FreeChunk(v1->pBModels); | |
1098 pAllocator->FreeChunk(v1->pSpawnPoints); | |
1099 v1->pBModels = 0; | |
1100 v1->pSpawnPoints = 0; | |
1101 v1->pTerrain.Initialize(); | |
1102 v1->pTerrain.ZeroLandscape(); | |
1103 v1->pTerrain._47C80A(0, 0, 128, 128); | |
1104 pAllocator->FreeChunk(v1->ptr_D4); | |
1105 v1->ptr_D4 = 0; | |
1106 v2 = pAllocator->AllocNamedChunk(0, 0x8000u, "CMAP"); | |
1107 v3 = v1->pOMAP; | |
1108 v1->ptr_D4 = v2; | |
1109 pAllocator->FreeChunk(v3); | |
1110 v1->pOMAP = 0; | |
1111 v4 = pAllocator->AllocNamedChunk(0, 0x10000u, "OMAP"); | |
1112 v1->pOMAP = (unsigned int *)v4; | |
1113 memset(v4, 0, 0x10000u); | |
1114 v5 = v1->pFaceIDLIST; | |
1115 v1->numFaceIDListElems = 0; | |
1116 pAllocator->FreeChunk(v5); | |
1117 v1->pFaceIDLIST = 0; | |
1118 v6 = pAllocator->AllocNamedChunk(0, 2u, "IDLIST"); | |
1119 v1->pFaceIDLIST = (unsigned __int16 *)v6; | |
1120 *(short *)v6 = 0; | |
1121 strcpy(v1->pSkyTextureName, pDefaultSkyTexture); | |
1122 v1->uSky_TextureID = pBitmaps_LOD->LoadTexture(v1->pSkyTextureName); | |
1123 strcpy(v1->pGroundTileset, byte_6BE124_cfg_textures_DefaultGroundTexture); | |
1124 v7 = pBitmaps_LOD->LoadTexture(v1->pGroundTileset); | |
1125 v8 = v1->uSky_TextureID == -1; | |
1126 v1->uMainTile_BitmapID = v7; | |
1127 if ( v8 ) | |
1128 Abortf("Invalid Sky Tex Handle"); | |
1129 if ( v1->uMainTile_BitmapID == -1 ) | |
1130 Abortf("Invalid Ground Tex Handle"); | |
1131 } | |
1132 | |
1133 | |
1134 | |
1135 //----- (0047CF9C) -------------------------------------------------------- | |
1136 void OutdoorLocation::Release() | |
1137 { | |
1138 //OutdoorLocation *v1; // esi@1 | |
1139 //signed int v2; // edi@1 | |
1140 //int v3; // ebx@2 | |
1141 //void *v4; // ST24_4@4 | |
1142 //char *v5; // ebx@4 | |
1143 //void **v6; // esi@4 | |
1144 | |
1145 //v1 = this; | |
1146 strcpy(pLevelFilename, "blank"); | |
1147 strcpy(pLocationFileName, "default.odm"); | |
1148 strcpy(pLocationFileDescription, "MM6 Outdoor v1.00"); | |
1149 strcpy(pSkyTextureName, "sky043"); | |
1150 strcpy(pGroundTileset, "hm005"); | |
1151 | |
1152 if (pBModels) | |
1153 { | |
1154 for (uint i = 0; i < uNumBModels; ++i) | |
1155 pBModels[i].Release(); | |
1156 | |
1157 pAllocator->FreeChunk(pBModels); | |
1158 pBModels = nullptr; | |
1159 uNumBModels = 0; | |
1160 } | |
1161 | |
1162 if (pSpawnPoints) | |
1163 { | |
1164 pAllocator->FreeChunk(pSpawnPoints); | |
1165 pSpawnPoints = nullptr; | |
1166 } | |
1167 uNumSpawnPoints = 0; | |
1168 | |
1169 pTerrain.Release(); | |
1170 | |
1171 if (ptr_D4) | |
1172 { | |
1173 pAllocator->FreeChunk(ptr_D4); | |
1174 ptr_D4 = nullptr; | |
1175 } | |
1176 if (pOMAP) | |
1177 { | |
1178 pAllocator->FreeChunk(pOMAP); | |
1179 pOMAP = nullptr; | |
1180 } | |
1181 if (pFaceIDLIST) | |
1182 { | |
1183 pAllocator->FreeChunk(pFaceIDLIST); | |
1184 pFaceIDLIST = nullptr; | |
1185 } | |
1186 if (pTerrainNormals) | |
1187 { | |
1188 pAllocator->FreeChunk(pTerrainNormals); | |
1189 pTerrainNormals = nullptr; | |
1190 } | |
1191 } | |
1192 | |
1193 //----- (0047D0A6) -------------------------------------------------------- | |
119 | 1194 bool OutdoorLocation::Load(const char *pFilename, ODMFace *File, size_t pNumItems, int thisa)//çàãðóçêà ëîêàöèè |
0 | 1195 { |
1196 //OutdoorLocation *pOutdoorLocation; // esi@1 | |
1197 /*bool result; // eax@9 | |
1198 bool v7; // ebx@9 | |
1199 size_t v8; // eax@10 | |
1200 void *v9; // eax@10 | |
1201 void *v10; // eax@10 | |
1202 void *v11; // eax@10 | |
1203 int v12; // ebx@11 | |
1204 BSPModel *v13; // eax@12 | |
1205 void *v14; // eax@12 | |
1206 BSPModel *v15; // ecx@12 | |
1207 void *v16; // eax@12 | |
1208 BSPModel *v17; // ecx@12 | |
1209 BSPModel *v18; // eax@12 | |
1210 __int16 v19; // ax@15 | |
1211 __int16 v20; // ax@16 | |
1212 int v21; // ecx@16 | |
1213 ODMFace *v22; // ebx@26 | |
1214 LayingItem *pItems; // ecx@27 | |
1215 unsigned int v24; // eax@28 | |
1216 //unsigned __int8 v25; // zf@28 | |
1217 //unsigned __int8 v26; // sf@28 | |
1218 ODMFace *v27; // eax@28 | |
1219 const char *i; // edx@29 | |
1220 unsigned __int16 v29; // ax@33 | |
1221 unsigned __int16 v30; // ax@37 | |
1222 int v31; // ecx@37 | |
1223 int v32; // eax@38 | |
1224 void *v33; // eax@38 | |
1225 TileDesc *v34; // eax@43 | |
1226 unsigned int v35; // eax@43 | |
1227 unsigned int v36; // edi@43 | |
1228 unsigned int v37; // edi@45*/ | |
1229 //size_t v38; // eax@50 | |
1230 FILE *v39; // eax@50 | |
1231 //unsigned int v40; // edi@56 | |
1232 //void *v41; // eax@56 | |
1233 //void *v42; // ebx@56 | |
1234 //const void *v43; // ebx@59 | |
1235 //const void *v44; // ebx@59 | |
1236 //unsigned int v45; // eax@59 | |
1237 //BSPModel *v46; // eax@59 | |
1238 //unsigned int v47; // ecx@59 | |
1239 //int v48; // ebx@60 | |
1240 //BSPModel *v49; // eax@61 | |
1241 //BSPModel *v50; // eax@61 | |
1242 //BSPModel *v51; // eax@61 | |
1243 //BSPModel *v52; // eax@61 | |
1244 //BSPModel *v53; // eax@61 | |
1245 //BSPModel *v54; // ecx@61 | |
1246 //BSPModel *v55; // ecx@61 | |
1247 //BSPModel *v56; // ecx@61 | |
1248 //void *v57; // ST24_4@61 | |
1249 //BSPModel *v58; // ecx@61 | |
1250 //void *v59; // ST18_4@61 | |
1251 //BSPModel *v60; // eax@61 | |
1252 //__int16 v61; // ax@64 | |
1253 unsigned __int16 v62; // ax@65 | |
1254 //ODMFace *v63; // ecx@65 | |
1255 //unsigned __int16 v64; // ax@80 | |
1256 //const char *v65; // ecx@80 | |
1257 //int v66; // eax@81 | |
1258 //void *v67; // eax@81 | |
1259 //int v68; // ecx@81 | |
1260 //void *v69; // eax@81 | |
1261 //unsigned int v70; // eax@81 | |
1262 //SpawnPointMM7 *v71; // eax@81 | |
1263 //unsigned int v72; // ecx@81 | |
1264 //size_t v73; // eax@81 | |
1265 //int v74; // edi@87 | |
1266 //void *v75; // edi@88 | |
1267 //unsigned int v76; // edx@94 | |
1268 //int v77; // ecx@94 | |
1269 //char *v78; // eax@95 | |
1270 //unsigned int v79; // edx@97 | |
1271 //unsigned int v80; // eax@99 | |
1272 //int v81; // eax@107 | |
1273 //void *v82; // edi@114 | |
1274 //size_t v83; // eax@120 | |
1275 //const void *v84; // edi@120 | |
1276 //const void *v85; // edi@120 | |
1277 //BSPModel *v86; // eax@124 | |
1278 //unsigned int v87; // eax@124 | |
1279 //BSPModel *v88; // eax@126 | |
1280 //BSPModel *v89; // eax@127 | |
1281 //ODMFace *v90; // eax@129 | |
1282 //const void *v91; // edi@138 | |
1283 //const void *v92; // edi@141 | |
1284 //const void *v93; // edi@141 | |
1285 //const void *v94; // edi@144 | |
1286 //const void *v95; // edi@144 | |
1287 //const char *v96; // edi@147 | |
1288 //unsigned int v97; // eax@147 | |
1289 //TileDesc *v98; // eax@147 | |
1290 //unsigned int v99; // eax@147 | |
1291 //int v100; // ecx@150 | |
1292 //unsigned int v101; // eax@157 | |
1293 int v102; // edi@159 | |
1294 //void *v103; // [sp-14h] [bp-B94h]@55 | |
1295 //void *v104; // [sp-10h] [bp-B90h]@59 | |
1296 //size_t v105; // [sp-Ch] [bp-B8Ch]@59 | |
1297 //char *v106; // [sp-8h] [bp-B88h]@59 | |
1298 int v107; // [sp-4h] [bp-B84h]@12 | |
1299 int v108; // [sp+0h] [bp-B80h]@10 | |
1300 char Src[968]; // [sp+10h] [bp-B70h]@110 | |
1301 char Dst[968]; // [sp+3D8h] [bp-7A8h]@50 | |
1302 char Str[256]; // [sp+7A0h] [bp-3E0h]@50 | |
1303 /*char DstBuf; // [sp+8A0h] [bp-2E0h]@10 | |
1304 __int32 Offset; // [sp+8A4h] [bp-2DCh]@10 | |
1305 __int32 v114; // [sp+8B0h] [bp-2D0h]@10 | |
1306 __int32 v115; // [sp+8BCh] [bp-2C4h]@10 | |
1307 __int32 v116; // [sp+8C8h] [bp-2B8h]@10 | |
1308 __int32 v117; // [sp+8D4h] [bp-2ACh]@10 | |
1309 __int32 v118; // [sp+8E0h] [bp-2A0h]@10 | |
1310 __int32 v119; // [sp+8ECh] [bp-294h]@10 | |
1311 __int32 v120; // [sp+8F8h] [bp-288h]@10 | |
1312 __int32 v121; // [sp+904h] [bp-27Ch]@10 | |
1313 __int32 v122; // [sp+910h] [bp-270h]@10 | |
1314 __int32 v123; // [sp+91Ch] [bp-264h]@10 | |
1315 __int32 v124; // [sp+928h] [bp-258h]@26 | |
1316 __int32 v125; // [sp+934h] [bp-24Ch]@35 | |
1317 __int32 v126; // [sp+940h] [bp-240h]@38 | |
1318 __int32 v127; // [sp+94Ch] [bp-234h]@38 | |
1319 __int32 v128; // [sp+958h] [bp-228h]@38 | |
1320 __int32 v129; // [sp+964h] [bp-21Ch]@38 | |
1321 __int32 v130; // [sp+970h] [bp-210h]@38 | |
1322 __int32 v131; // [sp+97Ch] [bp-204h]@38 | |
1323 __int32 v132; // [sp+988h] [bp-1F8h]@38 | |
1324 __int32 v133; // [sp+994h] [bp-1ECh]@38 | |
1325 __int32 v134; // [sp+9A0h] [bp-1E0h]@38 | |
1326 __int32 v135; // [sp+9ACh] [bp-1D4h]@38 | |
1327 __int32 v136; // [sp+9D0h] [bp-1B0h]@10*/ | |
1328 //char FileName[8]; // [sp+A20h] [bp-160h]@8 | |
1329 //char v138; // [sp+A28h] [bp-158h]@12 | |
1330 //int v139; // [sp+B1Ch] [bp-64h]@10 | |
1331 //char pContainer[32]; // [sp+B20h] [bp-60h]@1 | |
1332 //int *v141; // [sp+B40h] [bp-40h]@50 | |
1333 //__int64 v142; // [sp+B44h] [bp-3Ch]@55 | |
1334 //size_t pSource; // [sp+B4Ch] [bp-34h]@56 | |
1335 //int v144; // [sp+B50h] [bp-30h]@61 | |
1336 //int v145; // [sp+B54h] [bp-2Ch]@68 | |
1337 ODMHeader header; // [sp+B58h] [bp-28h]@50 | |
1338 //unsigned int pDestLen; // [sp+B68h] [bp-18h]@13 | |
1339 //FILE *ptr; // [sp+B6Ch] [bp-14h]@12 | |
1340 //void *v149; // [sp+B70h] [bp-10h]@19 | |
1341 char *Str2; // [sp+B74h] [bp-Ch]@12 | |
1342 //int v151; // [sp+B78h] [bp-8h]@59 | |
1343 //void *uSourceLen; // [sp+B7Ch] [bp-4h]@59 | |
1344 | |
1345 //pOutdoorLocation = this; | |
1346 //strcpy(pContainer, pFilename); | |
1347 | |
1348 if (bUnderwater) | |
1349 { | |
1350 pPaletteManager->pPalette_tintColor[0] = 0x10; | |
1351 pPaletteManager->pPalette_tintColor[1] = 0xC2; | |
1352 pPaletteManager->pPalette_tintColor[2] = 0x99; | |
1353 pPaletteManager->pPalette_mistColor[0] = 0x25; | |
1354 pPaletteManager->pPalette_mistColor[1] = 0x8F; | |
1355 pPaletteManager->pPalette_mistColor[2] = 0x5C; | |
1356 } | |
1357 else | |
1358 { | |
1359 pPaletteManager->pPalette_tintColor[0] = 0; | |
1360 pPaletteManager->pPalette_tintColor[1] = 0; | |
1361 pPaletteManager->pPalette_tintColor[2] = 0; | |
1362 if (pPaletteManager->pPalette_mistColor[0] != 0x80 || | |
1363 pPaletteManager->pPalette_mistColor[1] != 0x80 || | |
1364 pPaletteManager->pPalette_mistColor[2] != 0x80) | |
1365 { | |
1366 pPaletteManager->pPalette_mistColor[0] = 0x80; | |
1367 pPaletteManager->pPalette_mistColor[1] = 0x80; | |
1368 pPaletteManager->pPalette_mistColor[2] = 0x80; | |
1369 pPaletteManager->RecalculateAll(); | |
1370 } | |
1371 } | |
1372 | |
1373 _6807E0_num_decorations_with_sounds_6807B8 = 0; | |
1374 /*sprintf(FileName, "levels\\%s", pContainer); | |
1375 if ( GetFileAttributesA(FileName) != -1 ) | |
1376 { | |
1377 result = (bool)fopen(FileName, "rb"); | |
1378 v7 = result; | |
1379 File = (ODMFace *)result; | |
1380 if ( !result ) | |
1381 return result; | |
1382 *(int *)thisa = 1; | |
1383 v8 = strlen(pContainer); | |
1384 v108 = 2; | |
1385 *((char *)&v139 + v8) = 0; | |
1386 viewparams->uTextureID_LocationMap = pIcons_LOD->LoadTexture(pContainer, (enum TEXTURE_TYPE)v108); | |
1387 fread(&DstBuf, 0x180u, 1u, (FILE *)v7); | |
1388 fseek((FILE *)v7, Offset, 0); | |
1389 fread(this, 0xB0u, 1u, (FILE *)v7); | |
1390 LoadTileGroupIds(); | |
1391 _47F3EA(); | |
1392 strcpy(pGroundTileset, "grastyl"); | |
1393 fseek((FILE *)v7, v114, 0); | |
1394 fread(&uNumBModels, 4u, 1u, (FILE *)v7); | |
1395 fseek((FILE *)v7, v115, 0); | |
1396 fread(&uNumLayingItems, 4u, 1u, (FILE *)v7); | |
1397 fseek((FILE *)v7, v116, 0); | |
1398 fread(&uNumLevelDecorations, 4u, 1u, (FILE *)v7); | |
1399 fseek((FILE *)v7, v117, 0); | |
1400 fread(&uNumActors, 4u, 1u, (FILE *)v7); | |
1401 fseek((FILE *)v7, v118, 0); | |
1402 fread(&uNumChests, 4u, 1u, (FILE *)v7); | |
1403 pTerrain.Initialize(); | |
1404 fseek((FILE *)v7, v119, 0); | |
1405 fread(pTerrain.pHeightmap, 1u, 0x4000u, (FILE *)v7); | |
1406 fseek((FILE *)v7, v120, 0); | |
1407 fread(pTerrain.pTilemap, 1u, 0x4000u, (FILE *)v7); | |
1408 fseek((FILE *)v7, v121, 0); | |
1409 fread(pTerrain.pAttributemap, 1u, 0x4000u, (FILE *)v7); | |
1410 pTerrain._47C80A(0, 0, 128, 128); | |
1411 pAllocator->FreeChunk(ptr_D4); | |
1412 ptr_D4 = 0; | |
1413 v9 = pAllocator->AllocNamedChunk(0, 0x8000u, "CMAP"); | |
1414 v108 = (int)pOMAP; | |
1415 ptr_D4 = v9; | |
1416 pAllocator->FreeChunk((void *)v108); | |
1417 pOMAP = 0; | |
1418 v10 = pAllocator->AllocNamedChunk(0, 0x10000u, "OMAP"); | |
1419 v108 = 0; | |
1420 pOMAP = (unsigned int *)v10; | |
1421 fseek((FILE *)v7, v136, v108); | |
1422 fread(&uNumTerrainNormals, 4u, 1u, (FILE *)v7); | |
1423 fread(pTerrainSomeOtherData, 1u, 0x20000u, (FILE *)v7); | |
1424 fread(pTerrainNormalIndices, 1u, 0x10000u, (FILE *)v7); | |
1425 pTerrainNormals = (Vec3_float_ *)pAllocator->AllocNamedChunk(pTerrainNormals, 12 * uNumTerrainNormals, "TerNorm"); | |
1426 fread(pTerrainNormals, 1u, 12 * uNumTerrainNormals, (FILE *)v7); | |
1427 v11 = pAllocator->AllocNamedChunk(pBModels, 188 * uNumBModels, "BDdata"); | |
1428 v108 = 0; | |
1429 pBModels = (BSPModel *)v11; | |
1430 fseek((FILE *)v7, v122, v108); | |
1431 fread(pBModels, 0xBCu, uNumBModels, (FILE *)v7); | |
1432 fseek((FILE *)v7, v123, 0); | |
1433 pNumItems = 0; | |
1434 if ( (signed int)uNumBModels > 0 ) | |
1435 { | |
1436 v12 = 0; | |
1437 while ( 1 ) | |
1438 { | |
1439 pBModels[v12].pVertices.pVertices = 0; | |
1440 pBModels[v12].pFaces = 0; | |
1441 pBModels[v12].pFacesOrdering = 0; | |
1442 pBModels[v12].pNodes = 0; | |
1443 FileName[0] = 0; | |
1444 v108 = (int)&pBModels[v12]; | |
1445 sprintfex(FileName, "%s", v108); | |
1446 v13 = pBModels; | |
1447 v138 = 0; | |
1448 pBModels[v12].pVertices.pVertices = (Vec3_int_ *)pAllocator->AllocNamedChunk(v13[v12].pVertices.pVertices, 12 * v13[v12].pVertices.uNumVertices, | |
1449 FileName); | |
1450 pBModels[v12].pFaces = (ODMFace *)pAllocator->AllocNamedChunk(pBModels[v12].pFaces, 308 * pBModels[v12].uNumFaces, | |
1451 FileName); | |
1452 pBModels[v12].pFacesOrdering = (unsigned __int16 *)pAllocator->AllocNamedChunk(pBModels[v12].pFacesOrdering, | |
1453 2 * pBModels[v12].uNumFaces, FileName); | |
1454 v14 = pAllocator->AllocNamedChunk(pBModels[v12].pNodes, 8 * pBModels[v12].uNumNodes, FileName); | |
1455 v15 = pBModels; | |
1456 v108 = (int)File; | |
1457 v15[v12].pNodes = (BSPNode *)v14; | |
1458 fread(pBModels[v12].pVertices.pVertices, 0xCu, pBModels[v12].pVertices.uNumVertices, (FILE *)v108); | |
1459 fread(pBModels[v12].pFaces, 0x134u, pBModels[v12].uNumFaces, (FILE *)File); | |
1460 fread(pBModels[v12].pFacesOrdering, 2u, pBModels[v12].uNumFaces, (FILE *)File); | |
1461 fread(pBModels[v12].pNodes, 8u, pBModels[v12].uNumNodes, (FILE *)File); | |
1462 v16 = malloc(10 * pBModels[v12].uNumFaces); | |
1463 v107 = (int)File; | |
1464 v17 = pBModels; | |
1465 ptr = (FILE *)v16; | |
1466 fread(v16, 0xAu, v17[v12].uNumFaces, (FILE *)File); | |
1467 v18 = pBModels; | |
1468 Str2 = 0; | |
1469 if ( (signed int)v18[v12].uNumFaces > 0 ) | |
1470 break; | |
1471 LABEL_25: | |
1472 free(ptr); | |
1473 ++pNumItems; | |
1474 ++v12; | |
1475 if ( (signed int)pNumItems >= (signed int)uNumBModels ) | |
1476 goto LABEL_26; | |
1477 } | |
1478 pDestLen = 0; | |
1479 pFilename = (char *)ptr; | |
1480 while ( 1 ) | |
1481 { | |
1482 thisa = (int)((char *)v18[v12].pFaces + pDestLen); | |
1483 if ( !(*(char *)(thisa + 29) & 0x40) ) | |
1484 break; | |
1485 v19 = pTextureFrameTable->FindTextureByName(pFilename); | |
1486 *(short *)(thisa + 272) = v19; | |
1487 if ( !v19 ) | |
1488 { | |
1489 v20 = pBitmaps_LOD->LoadTexture(pFilename); | |
1490 v21 = thisa; | |
1491 *(char *)(v21 + 29) &= 0xBFu; | |
1492 LABEL_19: | |
1493 *(short *)(v21 + 272) = v20; | |
1494 v149 = (void *)(v20 != -1 ? &pBitmaps_LOD->pTextures[v20] : 0); | |
1495 auto pTex = (Texture *)v149; | |
1496 if (pTex) | |
1497 pTex->palette_id2 = pPaletteManager->LoadPalette(pTex->palette_id1); | |
1498 goto LABEL_20; | |
1499 } | |
1500 pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(unsigned __int16 *)((char *)&pBModels[v12].pFaces->uTextureID + pDestLen)); | |
1501 LABEL_20: | |
1502 if ( *(short *)(thisa + 292) ) | |
1503 { | |
1504 if ( ((ODMFace *)thisa)->HasEventHint() ) | |
1505 *(char *)(thisa + 30) |= 0x10u; | |
1506 else | |
1507 *(char *)(thisa + 30) &= 0xEFu; | |
1508 } | |
1509 ++Str2; | |
1510 v18 = pBModels; | |
1511 pDestLen += 308; | |
1512 pFilename += 10; | |
1513 if ( (signed int)Str2 >= (signed int)v18[v12].uNumFaces ) | |
1514 goto LABEL_25; | |
1515 } | |
1516 v20 = pBitmaps_LOD->LoadTexture(pFilename); | |
1517 v21 = thisa; | |
1518 goto LABEL_19; | |
1519 } | |
1520 LABEL_26: | |
1521 v22 = File; | |
1522 fseek((FILE *)File, v124, 0); | |
1523 fread(pLayingItems, 0x70u, uNumLayingItems, (FILE *)v22); | |
1524 if ( (signed int)uNumLayingItems > 0 ) | |
1525 { | |
1526 pItems = pLayingItems; | |
1527 pNumItems = uNumLayingItems; | |
1528 do | |
1529 { | |
1530 v24 = pItems->stru_24.uItemID; | |
1531 thisa = 0; | |
1532 v27 = (ODMFace *)(48 * v24); | |
1533 v25 = pObjectList->uNumObjects == 0; | |
1534 v26 = (pObjectList->uNumObjects & 0x80000000u) != 0; | |
1535 LOWORD(v27) = *(short *)((char *)&v27->pFacePlane.vNormal.x + (int)((char *)&pItemsTable + 24)); | |
1536 File = v27; | |
1537 pItems->uItemType = (unsigned __int16)v27; | |
1538 if ( v26 | v25 ) | |
1539 { | |
1540 LABEL_33: | |
1541 v29 = 0; | |
1542 } | |
1543 else | |
1544 { | |
1545 for ( i = (const char *)&pObjectList->pObjects->uObjectID; (short)v27 != *(short *)i; i = pFilename ) | |
1546 { | |
1547 ++thisa; | |
1548 pFilename = (char *)i + 56; | |
1549 if ( thisa >= (signed int)pObjectList->uNumObjects ) | |
1550 goto LABEL_33; | |
1551 LOWORD(v27) = (short)File; | |
1552 } | |
1553 v29 = thisa; | |
1554 } | |
1555 pItems->uObjectDescID = v29; | |
1556 ++pItems; | |
1557 --pNumItems; | |
1558 } | |
1559 while ( pNumItems ); | |
1560 } | |
1561 fseek((FILE *)v22, v125, 0); | |
1562 fread(pLevelDecorations, 0x20u, uNumLevelDecorations, (FILE *)v22); | |
1563 pNumItems = 0; | |
1564 if ( (signed int)uNumLevelDecorations > 0 ) | |
1565 { | |
1566 thisa = (int)pLevelDecorations; | |
1567 do | |
1568 { | |
1569 fread(FileName, 1u, 0x20u, (FILE *)v22); | |
1570 v30 = pDecorationList->GetDecorIdByName(FileName); | |
1571 v31 = thisa; | |
1572 ++pNumItems; | |
1573 thisa += 32; | |
1574 *(short *)v31 = v30; | |
1575 } | |
1576 while ( (signed int)pNumItems < (signed int)uNumLevelDecorations ); | |
1577 } | |
1578 fseek((FILE *)v22, v126, 0); | |
1579 fread(pActors, 0x344u, uNumActors, (FILE *)v22); | |
1580 fseek((FILE *)v22, v127, 0); | |
1581 fread(pChests, 0x14CCu, uNumChests, (FILE *)v22); | |
1582 fseek((FILE *)v22, v128, 0); | |
1583 fread(&field_DC, 4u, 1u, (FILE *)v22); | |
1584 pAllocator->FreeChunk(pFaceIDLIST); | |
1585 v32 = field_DC; | |
1586 pFaceIDLIST = 0; | |
1587 v33 = pAllocator->AllocNamedChunk(0, 2 * v32, "IDLIST"); | |
1588 v108 = (int)v22; | |
1589 pFaceIDLIST = (unsigned __int16 *)v33; | |
1590 fread(v33, 2u, field_DC, (FILE *)v108); | |
1591 fseek((FILE *)v22, v129, 0); | |
1592 fread(pOMAP, 4u, 0x4000u, (FILE *)v22); | |
1593 fseek((FILE *)v22, v130, 0); | |
1594 fread(&uNumSpawnPoints, 4u, 1u, (FILE *)v22); | |
1595 pSpawnPoints = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(pSpawnPoints, 24 * uNumSpawnPoints, "Spawn"); | |
1596 fseek((FILE *)v22, v131, 0); | |
1597 fread(pSpawnPoints, 0x18u, uNumSpawnPoints, (FILE *)v22); | |
1598 fseek((FILE *)v22, v132, 0); | |
1599 fread(&ddm, 0x28u, 1u, (FILE *)v22); | |
1600 fseek((FILE *)v22, v133, 0); | |
1601 fread(&stru_5E4C90, 1u, 0xC8u, (FILE *)v22); | |
1602 fseek((FILE *)v22, v134, 0); | |
1603 fread(&uLastVisitDay, 1u, 0x38u, (FILE *)v22); | |
1604 fseek((FILE *)v22, v135, 0); | |
1605 fread(&uLastVisitDay, 1u, 4u, (FILE *)v22); | |
1606 thisa = (int)pTileTypes; | |
1607 pTileTable->InitializeTileset(4); | |
1608 pTileTable->InitializeTileset(pTileTypes[0].uTileGroup); | |
1609 pTileTable->InitializeTileset(pTileTypes[1].uTileGroup); | |
1610 pTileTable->InitializeTileset(pTileTypes[2].uTileGroup); | |
1611 pTileTable->InitializeTileset(pTileTypes[3].uTileGroup); | |
1612 if ( this != (OutdoorLocation *)-96 && pSkyTextureName[0] ) | |
1613 { | |
1614 v108 = 0; | |
1615 v107 = (int)pSkyTextureName; | |
1616 } | |
1617 else | |
1618 { | |
1619 v108 = 0; | |
1620 v107 = (int)pDefaultSkyTexture; | |
1621 } | |
1622 uSky_TextureID = pBitmaps_LOD->LoadTexture((const char *)v107, (enum TEXTURE_TYPE)v108); | |
1623 strcpy(pGroundTileset, byte_6BE124_cfg_textures_DefaultGroundTexture); | |
1624 v34 = pTileTable->GetTileById(pTileTypes[0].uTileID); | |
1625 v35 = pBitmaps_LOD->LoadTexture(v34->pTileName); | |
1626 v36 = uSky_TextureID; | |
1627 uMainTile_BitmapID = v35; | |
1628 if ( v36 != -1 ) | |
1629 pBitmaps_LOD->pTextures[v36].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v36].palette_id1); | |
1630 | |
1631 v37 = uMainTile_BitmapID; | |
1632 if ( v37 != -1 ) | |
1633 pBitmaps_LOD->pTextures[v37].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v37].palette_id1); | |
1634 | |
1635 _47F0E2(); | |
1636 pGameLoadingUI_ProgressBar->Progress(); | |
1637 fclose((FILE *)v22); | |
1638 goto LABEL_150; | |
1639 }*/ | |
1640 | |
1641 assert(sizeof(BSPModel) == 188); | |
1642 | |
1643 if (!pGames_LOD->DoesContainerExist(pFilename)) | |
1644 Abortf("Unable to find %s in Games.LOD", pFilename); | |
1645 | |
119 | 1646 |
1647 char pMinimapTextureFilename[1024]; | |
1648 strcpy(pMinimapTextureFilename, pFilename); | |
1649 pMinimapTextureFilename[strlen(pMinimapTextureFilename) - 4] = 0; | |
1650 viewparams->uTextureID_LocationMap = pIcons_LOD->LoadTexture(pMinimapTextureFilename, TEXTURE_16BIT_PALETTE); | |
1651 | |
0 | 1652 //strcpy(FileName, pContainer); |
1653 strcpy(Str, pFilename); | |
1654 strcpy(Str + strlen(Str) - 4, ".odm"); | |
1655 //v141 = &v139; | |
1656 //v38 = strlen(pFilename); | |
1657 //strcpy((char *)&v139 + v38, ".odm"); | |
1658 v39 = pGames_LOD->FindContainer(Str, 1); | |
1659 //Str[strlen(Str) - 4] = 0; | |
1660 | |
1661 header.uCompressedSize = 0; | |
1662 header.uDecompressedSize = 0; | |
1663 //ptr = v39; | |
1664 header.uVersion = 91969; | |
1665 header.pMagic[0] = 'm'; | |
1666 header.pMagic[1] = 'v'; | |
1667 header.pMagic[2] = 'i'; | |
1668 header.pMagic[3] = 'i'; | |
1669 fread(&header, 0x10u, 1u, v39); | |
1670 if (header.uVersion != 91969 || | |
1671 header.pMagic[0] != 'm' || | |
1672 header.pMagic[1] != 'v' || | |
1673 header.pMagic[2] != 'i' || | |
1674 header.pMagic[3] != 'i') | |
1675 { | |
1676 MessageBoxW(nullptr, L"Can't load file!", | |
1677 L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:507", 0); | |
1678 } | |
1679 //v40 = header.uCompressedSize; | |
1680 //pSource = header.uDecompressedSize; | |
1681 //v41 = malloc(header.uDecompressedSize); | |
1682 auto pSrcMem = (unsigned char *)malloc(header.uDecompressedSize); | |
1683 auto pSrc = pSrcMem; | |
1684 //v42 = v41; | |
1685 //HIDWORD(v142) = (uint32)pSrc; | |
1686 if (header.uCompressedSize < header.uDecompressedSize) | |
1687 { | |
1688 auto pComressedSrc = (char *)malloc(header.uCompressedSize); | |
1689 fread(pComressedSrc, header.uCompressedSize, 1, v39); | |
1690 | |
1691 uint actualDecompressedSize = header.uDecompressedSize; | |
1692 zlib::MemUnzip(pSrc, &actualDecompressedSize, pComressedSrc, header.uCompressedSize); | |
1693 free(pComressedSrc); | |
1694 } | |
1695 else | |
1696 { | |
1697 fread(pSrc, header.uDecompressedSize, 1, v39); | |
1698 } | |
1699 | |
1700 memcpy(pLevelFilename, pSrc, 0x20); | |
1701 memcpy(pLocationFileName, pSrc + 0x20, 0x20); | |
1702 memcpy(pLocationFileDescription, pSrc + 0x40, 0x20); | |
67 | 1703 memcpy(pSkyTextureName, pSrc + 3 * 32, 32); |
0 | 1704 memcpy(pGroundTileset, pSrc + 0x80, 0x20); |
1705 memcpy(pTileTypes, pSrc + 0xA0, 0x10); | |
1706 pSrc += 0xB0; | |
1707 | |
1708 //v43 = (char *)pSrc + 176; | |
1709 LoadTileGroupIds(); | |
1710 _47F3EA(); | |
1711 strcpy(pGroundTileset, "grastyl"); | |
1712 pGameLoadingUI_ProgressBar->Progress(); | |
1713 pTerrain.Initialize(); | |
1714 //v108 = 16384; | |
1715 //v107 = (int)v43; | |
1716 //v106 = (char *)pTerrain.pHeightmap; | |
1717 memcpy(pTerrain.pHeightmap, pSrc, 0x4000); | |
1718 pSrc += 0x4000; | |
1719 | |
1720 //v43 = (char *)v43 + 16384; | |
1721 //v105 = 16384; | |
1722 //v104 = (void *)v43; | |
1723 //v103 = pTerrain.pTilemap; | |
1724 memcpy(pTerrain.pTilemap, pSrc, 0x4000); | |
1725 pSrc += 0x4000; | |
1726 | |
1727 //v43 = (char *)v43 + 16384; | |
1728 memcpy(pTerrain.pAttributemap, pSrc, 0x4000); | |
1729 pSrc += 0x4000; | |
1730 | |
1731 //v43 = (char *)v43 + 16384; | |
1732 //v108 = (int)ptr_D4; | |
1733 if (ptr_D4) | |
1734 { | |
1735 pAllocator->FreeChunk(ptr_D4); | |
1736 ptr_D4 = nullptr; | |
1737 } | |
1738 ptr_D4 = pAllocator->AllocNamedChunk(0, 0x8000u, "CMAP"); | |
1739 pTerrain._47C80A(0, 0, 128, 128); | |
1740 | |
1741 pGameLoadingUI_ProgressBar->Progress(); | |
1742 memcpy(&uNumTerrainNormals, pSrc, 4); | |
1743 //v43 = (char *)v43 + 4; | |
1744 memcpy(pTerrainSomeOtherData, pSrc + 4, 0x20000); | |
1745 pSrc += 4 + 0x20000; | |
1746 //v43 = (char *)v43 + 131072; | |
1747 memcpy(pTerrainNormalIndices, pSrc, 0x10000); | |
1748 pSrc += 0x10000; | |
1749 //v43 = (char *)v43 + 65536; | |
1750 | |
1751 //pFilename = (char *)(12 * uNumTerrainNormals); | |
1752 pTerrainNormals = (Vec3_float_ *)pAllocator->AllocNamedChunk(pTerrainNormals, 12 * uNumTerrainNormals, "TerNorm"); | |
1753 memcpy(pTerrainNormals, pSrc, 12 * uNumTerrainNormals); | |
1754 pSrc += 12 * uNumTerrainNormals; | |
1755 //v44 = (char *)v43 + (int)pFilename; | |
1756 //v44 = (char *)v44 + 4; | |
1757 //v45 = uNumBModels; | |
1758 //v108 = (int)"BDdata"; | |
1759 | |
1760 pGameLoadingUI_ProgressBar->Progress(); | |
1761 | |
1762 //v107 = 188 * v45; | |
1763 //v106 = (char *)pBModels; | |
1764 //v46 = (BSPModel *)pAllocator->AllocNamedChunk(v106, 188 * v45, "BDdata"); | |
1765 //v47 = uNumBModels; | |
1766 memcpy(&uNumBModels, pSrc, 4); | |
1767 pBModels = (BSPModel *)pAllocator->AllocNamedChunk(pBModels, 188 * uNumBModels, "BDdata"); | |
1768 //pFilename = (char *)(188 * v47); | |
1769 memcpy(pBModels, pSrc + 4, 188 * uNumBModels); | |
1770 pSrc += 4 + 188 * uNumBModels; | |
1771 | |
1772 pGameLoadingUI_ProgressBar->Progress(); | |
1773 | |
1774 //uSourceLen = (char *)v44 + (int)pFilename; | |
1775 //v151 = 0; | |
1776 for (uint i = 0; i < uNumBModels; ++i) | |
1777 { | |
1778 //v48 = 0; | |
80 | 1779 auto model = &pBModels[i]; |
0 | 1780 |
1781 model->pVertices.pVertices = nullptr; | |
1782 model->pFaces = nullptr; | |
1783 model->pFacesOrdering = nullptr; | |
1784 model->pNodes = nullptr; | |
1785 //FileName[0] = 0; | |
1786 //v108 = (int)&pBModels[i]; | |
1787 //sprintf(FileName, "%s", v108); | |
1788 //v49 = pBModels; | |
1789 //v138 = 0; | |
1790 //v50 = &pBModels[v48]; | |
1791 //v108 = (int)FileName; | |
1792 //v107 = 12 * v50->pVertices.uNumVertices; | |
1793 //v106 = (char *)v50->pVertices.pVertices; | |
1794 assert(sizeof(Vec3_int_) == 12); | |
1795 uint verticesSize = model->pVertices.uNumVertices * sizeof(Vec3_int_); | |
1796 model->pVertices.pVertices = (Vec3_int_ *)pAllocator->AllocNamedChunk(model->pVertices.pVertices, verticesSize, ""); | |
1797 memcpy(model->pVertices.pVertices, pSrc, verticesSize); | |
1798 pSrc += verticesSize; | |
1799 //v51 = &pBModels[v48]; | |
1800 //v108 = (int)FileName; | |
1801 //v107 = 308 * v51->uNumFaces; | |
1802 //v106 = (char *)v51->pFaces; | |
1803 assert(sizeof(ODMFace) == 308); | |
1804 uint facesSize = model->uNumFaces * sizeof(ODMFace); | |
1805 model->pFaces = (ODMFace *)pAllocator->AllocNamedChunk(model->pFaces, facesSize, ""); | |
1806 memcpy(model->pFaces, pSrc, facesSize); | |
1807 pSrc += facesSize; | |
1808 //v52 = &pBModels[v48]; | |
1809 //v108 = (int)FileName; | |
1810 //v107 = 2 * v52->uNumFaces; | |
1811 //v106 = (char *)v52->pFacesOrdering; | |
1812 uint facesOrderingSize = model->uNumFaces * sizeof(short); | |
1813 model->pFacesOrdering = (unsigned __int16 *)pAllocator->AllocNamedChunk(model->pFacesOrdering, facesOrderingSize, ""); | |
1814 memcpy(model->pFacesOrdering, pSrc, facesOrderingSize); | |
1815 pSrc += facesOrderingSize; | |
1816 //v53 = &pBModels[v48]; | |
1817 //v108 = (int)FileName; | |
1818 //v107 = 8 * v53->uNumNodes; | |
1819 //v106 = (char *)v53->pNodes; | |
1820 assert(sizeof(BSPNode) == 8); | |
1821 uint nodesSize = model->uNumNodes * sizeof(BSPNode); | |
1822 model->pNodes = (BSPNode *)pAllocator->AllocNamedChunk(model->pNodes, nodesSize, ""); | |
1823 memcpy(model->pNodes, pSrc, nodesSize); | |
1824 pSrc += nodesSize; | |
1825 //v54 = &pBModels[v48]; | |
1826 //v108 = 12 * v54->pVertices.uNumVertices; | |
1827 //pFilename = (char *)v108; | |
1828 //v107 = (int)uSourceLen; | |
1829 //v106 = (char *)v54->pVertices.pVertices; | |
1830 //memcpy(v106, uSourceLen, v108); | |
1831 //uSourceLen = (char *)uSourceLen + (int)pFilename; | |
1832 //v55 = &pBModels[v48]; | |
1833 //v105 = 308 * v55->uNumFaces; | |
1834 //v104 = uSourceLen; | |
1835 //v103 = v55->pFaces; | |
1836 //pFilename = (char *)v105; | |
1837 //memcpy(v103, uSourceLen, v105); | |
1838 //v56 = &pBModels[v48]; | |
1839 //uSourceLen = (char *)uSourceLen + (int)pFilename; | |
1840 //v57 = v56->pFacesOrdering; | |
1841 //pFilename = (char *)(2 * v56->uNumFaces); | |
1842 //memcpy(v57, uSourceLen, (size_t)pFilename); | |
1843 //v58 = &pBModels[v48]; | |
1844 //uSourceLen = (char *)uSourceLen + (int)pFilename; | |
1845 //v59 = v58->pNodes; | |
1846 //pFilename = (char *)(8 * v58->uNumNodes); | |
1847 //memcpy(v59, uSourceLen, (size_t)pFilename); | |
1848 //uSourceLen = (char *)uSourceLen + (int)pFilename; | |
1849 //ptr = (FILE *)malloc(10 * model->uNumFaces); | |
1850 auto textureFilenames = (const char *)malloc(10 * model->uNumFaces); | |
1851 //pFilename = (char *)(10 * pBModels[v48].uNumFaces); | |
1852 memcpy((char *)textureFilenames, pSrc, 10 * model->uNumFaces); | |
1853 pSrc += 10 * model->uNumFaces; | |
1854 //v144 = 0; | |
1855 //uSourceLen = (char *)uSourceLen + (int)pFilename; | |
1856 //v60 = pBModels; | |
1857 for (uint j = 0; j < model->uNumFaces; ++j) | |
1858 { | |
1859 auto texFilename = textureFilenames + j * 10; | |
1860 //v149 = 0; | |
1861 //Str2 = (char *)ptr; | |
1862 | |
80 | 1863 auto *face = &model->pFaces[j]; |
0 | 1864 //pFilename = (char *)v149 + (unsigned int)v60[v48].pFaces; |
1865 if (~face->uAttributes & 0x40) | |
1866 { | |
1867 v62 = pBitmaps_LOD->LoadTexture(texFilename); | |
1868 // v63 = (ODMFace *)pFilename; | |
1869 goto LABEL_68; | |
1870 } | |
1871 //v61 = pTextureFrameTable->FindTextureByName(texFilename); | |
1872 face->uTextureID = pTextureFrameTable->FindTextureByName(texFilename); | |
1873 if (!face->uTextureID) | |
1874 { | |
1875 v62 = pBitmaps_LOD->LoadTexture(texFilename); | |
1876 //v63 = (ODMFace *)pFilename; | |
1877 BYTE1(face->uAttributes) &= 0xBFu; | |
1878 LABEL_68: | |
1879 face->uTextureID = v62; | |
1880 //v145 = (signed __int16)v62 != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62] : 0; | |
1881 //v108 = ((signed __int16)v62 != -1 ? pBitmaps_LOD->pTextures[(signed __int16)v62].palette_id1 : 36); | |
1882 if ((signed __int16)v62 != -1) | |
1883 pBitmaps_LOD->pTextures[v62].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v62].palette_id1); | |
1884 goto LABEL_69; | |
1885 } | |
1886 pTextureFrameTable->LoadAnimationSequenceAndPalettes(face->uTextureID); | |
1887 LABEL_69: | |
1888 if (face->sCogTriggeredID) | |
1889 { | |
1890 if (face->HasEventHint()) | |
1891 BYTE2(face->uAttributes) |= 0x10u; | |
1892 else | |
1893 BYTE2(face->uAttributes) &= 0xEFu; | |
1894 } | |
1895 //++v144; | |
1896 //v60 = pBModels; | |
1897 //v149 = (char *)v149 + 308; | |
1898 //Str2 += 10; | |
1899 //if ( v144 >= (signed int)v60[v48].uNumFaces ) | |
1900 //goto LABEL_74; | |
1901 } | |
1902 | |
1903 //LABEL_74: | |
1904 free((void *)textureFilenames); | |
1905 // ++v151; | |
1906 // ++v48; | |
1907 // if ( v151 >= (signed int)uNumBModels ) | |
1908 // goto LABEL_75; | |
1909 } | |
1910 //LABEL_75: | |
1911 pGameLoadingUI_ProgressBar->Progress(); | |
1912 | |
1913 memcpy(&uNumLevelDecorations, pSrc, 4u); | |
1914 //uSourceLen = (char *)uSourceLen + 4; | |
1915 if (uNumLevelDecorations > 3000) | |
1916 MessageBoxW(nullptr, L"Can't load file!", | |
1917 L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:678", 0); | |
1918 | |
1919 assert(sizeof(LevelDecoration) == 32); | |
1920 //pFilename = (char *)(32 * uNumLevelDecorations); | |
1921 memcpy(pLevelDecorations, pSrc + 4, uNumLevelDecorations * sizeof(LevelDecoration)); | |
1922 pSrc += 4 + 32 * uNumLevelDecorations; | |
1923 | |
1924 pGameLoadingUI_ProgressBar->Progress(); | |
1925 | |
1926 //v151 = 0; | |
1927 //uSourceLen = (char *)uSourceLen + (int)pFilename; | |
1928 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
1929 { | |
1930 char name[256]; | |
1931 memcpy(name, pSrc, 32); | |
1932 pSrc += 32; | |
1933 | |
1934 pLevelDecorations[i].uDecorationDescID = pDecorationList->GetDecorIdByName(name); | |
1935 } | |
1936 | |
1937 pGameLoadingUI_ProgressBar->Progress(); | |
1938 | |
1939 memcpy(&numFaceIDListElems, pSrc, 4); | |
1940 | |
1941 //uSourceLen = (char *)uSourceLen + 4; | |
1942 //v108 = (int)pFaceIDLIST; | |
1943 if (pFaceIDLIST) | |
1944 { | |
1945 pAllocator->FreeChunk(pFaceIDLIST); | |
1946 pFaceIDLIST = nullptr; | |
1947 } | |
1948 //v66 = field_DC; | |
1949 //pFaceIDLIST = 0; | |
1950 //v67 = pAllocator->AllocNamedChunk(0, 2 * v66, "IDLIST"); | |
1951 uint faceIDListSize = 2 * numFaceIDListElems; | |
1952 pFaceIDLIST = (unsigned short *)pAllocator->AllocNamedChunk(0, faceIDListSize, "IDLIST"); | |
1953 //v68 = field_DC; | |
1954 //pFaceIDLIST = (unsigned __int16 *)v67; | |
1955 //pFilename = (char *)(2 * v68); | |
1956 memcpy(pFaceIDLIST, pSrc + 4, faceIDListSize); | |
1957 pSrc += 4 + faceIDListSize; | |
1958 | |
1959 //uSourceLen = (char *)uSourceLen + (int)pFilename; | |
1960 pGameLoadingUI_ProgressBar->Progress(); | |
1961 | |
1962 //v108 = (int)pOMAP; | |
1963 //pAllocator->FreeChunk((void *)v108); | |
1964 //pOMAP = 0; | |
1965 if (pOMAP) | |
1966 { | |
1967 pAllocator->FreeChunk(pOMAP); | |
1968 pOMAP = nullptr; | |
1969 } | |
1970 //v69 = pAllocator->AllocNamedChunk(0, 0x10000u, "OMAP"); | |
1971 pOMAP = (unsigned int *)pAllocator->AllocNamedChunk(0, 0x10000, "OMAP"); | |
1972 //v108 = 65536; | |
1973 //pOMAP = (unsigned int *)v69; | |
1974 memcpy(pOMAP, pSrc, 65536); | |
1975 pSrc += 65536; | |
1976 | |
1977 //uSourceLen = (char *)uSourceLen + 65536; | |
1978 pGameLoadingUI_ProgressBar->Progress(); | |
1979 | |
1980 memcpy(&uNumSpawnPoints, pSrc, 4); | |
1981 //uSourceLen = (char *)uSourceLen + 4; | |
1982 pGameLoadingUI_ProgressBar->Progress(); | |
1983 //v70 = uNumSpawnPoints; | |
1984 //v108 = (int)"Spawn"; | |
1985 //v107 = 24 * v70; | |
1986 //v106 = (char *)pSpawnPoints; | |
1987 assert(sizeof(SpawnPointMM7) == 24); | |
1988 uint spawnPointsSize = uNumSpawnPoints * sizeof(SpawnPointMM7); | |
1989 pSpawnPoints = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(pSpawnPoints, spawnPointsSize, "Spawn"); | |
1990 //v72 = uNumSpawnPoints; | |
1991 //pSpawnPoints = v71; | |
1992 memcpy(pSpawnPoints, pSrc + 4, spawnPointsSize); | |
1993 pSrc += 4 + spawnPointsSize; | |
1994 | |
1995 pGameLoadingUI_ProgressBar->Progress(); | |
1996 | |
1997 free(pSrcMem); | |
1998 | |
1999 //v108 = (int)".ddm"; | |
2000 //v73 = strlen(pContainer); | |
2001 strcpy(Str + strlen(Str) - 4, ".ddm"); | |
2002 //strcpy((char *)v141 + v73, (const char *)v108); | |
2003 v39 = pNew_LOD->FindContainer(Str, 1);// | |
2004 fread(&header, 0x10u, 1u, v39); | |
2005 Str2 = 0; | |
2006 if (header.uVersion != 91969 || | |
2007 header.pMagic[0] != 'm' || | |
2008 header.pMagic[1] != 'v' || | |
2009 header.pMagic[2] != 'i' || | |
2010 header.pMagic[3] != 'i' ) | |
2011 { | |
187 | 2012 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:746", 0); |
0 | 2013 Str2 = (char *)1; |
2014 } | |
2015 //v74 = 0; | |
2016 //pFilename = (char *)header.uCompressedSize; | |
2017 //v149 = 0; | |
2018 //pDestLen = header.uDecompressedSize; | |
2019 if ( !Str2 ) | |
2020 { | |
2021 pSrcMem = (unsigned char *)malloc(header.uDecompressedSize); | |
2022 pSrc = pSrcMem; | |
2023 //v149 = v75; | |
2024 if (header.uCompressedSize == header.uDecompressedSize) | |
2025 fread(pSrc, header.uDecompressedSize, 1u, v39); | |
2026 else if (header.uCompressedSize < header.uDecompressedSize) | |
2027 { | |
2028 auto compressedMem = malloc(header.uCompressedSize); | |
2029 fread(compressedMem, header.uCompressedSize, 1, v39); | |
2030 | |
2031 uint actualDecompressedSize = header.uDecompressedSize; | |
2032 zlib::MemUnzip(pSrc, &actualDecompressedSize, compressedMem, header.uCompressedSize); | |
2033 free(compressedMem); | |
2034 } | |
2035 else | |
2036 MessageBoxW(nullptr, L"Can't load file!", | |
2037 L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:765", 0); | |
2038 | |
2039 assert(sizeof(DDM_DLV_Header) == 0x28); | |
2040 memcpy(&ddm, pSrc, sizeof(DDM_DLV_Header)); | |
2041 pSrc += sizeof(DDM_DLV_Header); | |
2042 //v74 = (int)((char *)v75 + 40); | |
2043 } | |
2044 //v76 = uNumBModels; | |
2045 //v77 = actualNumFacesInLevel = 0; | |
2046 uint actualNumFacesInLevel = 0; | |
2047 for (uint i = 0; i < uNumBModels; ++i) | |
80 | 2048 actualNumFacesInLevel += pBModels[i].uNumFaces; |
0 | 2049 |
2050 //v79 = ddm.uNumFacesInBModels; | |
2051 if (ddm.uNumFacesInBModels) | |
2052 { | |
2053 if ( ddm.uNumBModels ) | |
2054 { | |
2055 //v80 = ddm.uNumDecorations; | |
2056 if (ddm.uNumDecorations) | |
2057 { | |
2058 if (ddm.uNumFacesInBModels != actualNumFacesInLevel || | |
2059 ddm.uNumBModels != uNumBModels || | |
2060 ddm.uNumDecorations != uNumLevelDecorations ) | |
2061 Str2 = (char *)1; | |
2062 } | |
2063 } | |
2064 } | |
2065 | |
2066 if ( BYTE1(dword_6BE364_game_settings_1) & 0x20 ) | |
2067 pNumItems = 29030400; | |
2068 if ( Str2 ) | |
2069 { | |
2070 memset(Dst, 0, 0x3C8u); | |
2071 memset(Src, 0, 0x3C8u); | |
2072 goto LABEL_112; | |
2073 } | |
2074 //v81 = ddm.uLastRepawnDay; | |
2075 if ((unsigned int)((char *)File - ddm.uLastRepawnDay) >= pNumItems || !ddm.uLastRepawnDay) | |
2076 { | |
2077 memcpy(Dst, pSrc, 0x3C8u); | |
2078 memcpy(Src, pSrc + 968, 0x3C8u); | |
2079 LABEL_112: | |
2080 free(pSrcMem); | |
2081 | |
2082 ddm.uLastRepawnDay = (int)File; | |
2083 if (Str2 == 0) | |
2084 ++ddm.uNumRespawns; | |
2085 v108 = 0; | |
2086 *(int *)thisa = 1; | |
2087 v39 = pGames_LOD->FindContainer(Str, 0); | |
2088 fread(&header, 0x10, 1u, v39); | |
2089 //pFilename = (char *)header.uCompressedSize; | |
2090 //pDestLen = header.uDecompressedSize; | |
2091 //v82 = malloc(header.uDecompressedSize); | |
2092 pSrcMem = (unsigned char *)malloc(header.uDecompressedSize); | |
2093 //v149 = v82; | |
2094 if (header.uCompressedSize == header.uDecompressedSize) | |
2095 fread(pSrcMem, header.uDecompressedSize, 1, v39); | |
2096 else if (header.uCompressedSize < header.uDecompressedSize) | |
2097 { | |
2098 auto compressedMem = malloc(header.uCompressedSize); | |
2099 fread(compressedMem, header.uCompressedSize, 1u, v39); | |
2100 | |
2101 uint actualDecompressedSize = header.uDecompressedSize; | |
2102 zlib::MemUnzip(pSrcMem, &actualDecompressedSize, compressedMem, header.uCompressedSize); | |
2103 free(compressedMem); | |
2104 } | |
2105 else | |
2106 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:857", 0); | |
2107 | |
2108 pSrc = pSrcMem + 40; | |
2109 goto LABEL_120; | |
2110 | |
2111 } | |
2112 *(int *)thisa = 0; | |
2113 LABEL_120: | |
2114 //v108 = (int)".odm"; | |
2115 //v83 = strlen(pContainer); | |
2116 //strcpy((char *)v141 + v83, (const char *)v108); | |
2117 memcpy(array_528, pSrc, 0x3C8); | |
2118 //v84 = (const void *)(v74 + 968); | |
2119 memcpy(array_8F0, pSrc + 0x3C8, 0x3C8); | |
2120 pSrc += 2 * 0x3C8; | |
2121 //v85 = (char *)v84 + 968; | |
2122 | |
2123 pGameLoadingUI_ProgressBar->Progress(); | |
2124 | |
2125 if ( *(int *)thisa ) | |
2126 { | |
2127 memcpy(array_528, Dst, 0x3C8u); | |
2128 memcpy(array_8F0, Src, 0x3C8u); | |
2129 } | |
2130 | |
2131 //v25 = uNumBModels == 0; | |
2132 //v26 = (uNumBModels & 0x80000000u) != 0; | |
2133 //v151 = 0; | |
2134 for (uint i = 0; i < uNumBModels; ++i) | |
2135 { | |
79 | 2136 auto model = pBModels[i]; |
0 | 2137 //pNumItems = 0; |
2138 //do | |
2139 //{ | |
2140 //v86 = pBModels; | |
2141 //thisa = 0; | |
2142 //v87 = (unsigned int)((char *)v86 + pNumItems); | |
79 | 2143 for (uint j = 0; j < model.uNumFaces; ++j) |
0 | 2144 { |
79 | 2145 auto face = model.pFaces[j]; |
0 | 2146 |
2147 //if ( *(int *)(v87 + 76) > 0 ) | |
2148 //{ | |
2149 //File = 0; | |
2150 //do | |
2151 //{ | |
2152 //v106 = (char *)&File->uAttributes + *(int *)(v87 + 84); | |
79 | 2153 memcpy(&face.uAttributes, pSrc, 4); |
0 | 2154 pSrc += 4; |
2155 //v88 = pBModels; | |
2156 //++File; | |
2157 //v85 = (char *)v85 + 4; | |
2158 //++thisa; | |
2159 //v87 = (unsigned int)((char *)v88 + pNumItems); | |
2160 //} | |
2161 //while ( thisa < *(int *)(v87 + 76) ); | |
2162 } | |
2163 | |
2164 //v89 = pBModels; | |
2165 //thisa = 0; | |
79 | 2166 for (uint j = 0; j < model.uNumFaces; ++j) |
0 | 2167 { |
79 | 2168 auto face = model.pFaces[j]; |
0 | 2169 //pFilename = 0; |
2170 //do | |
2171 //{ | |
2172 //v90 = (ODMFace *)&pFilename[*(unsigned int *)((char *)&v89->pFaces + pNumItems)]; | |
2173 //File = v90; | |
79 | 2174 if (face.sCogTriggeredID) |
0 | 2175 { |
79 | 2176 if (face.HasEventHint()) |
2177 BYTE2(face.uAttributes) |= 0x10u; | |
0 | 2178 else |
79 | 2179 BYTE2(face.uAttributes) &= 0xEFu; |
0 | 2180 } |
2181 //++thisa; | |
2182 //v89 = pBModels; | |
2183 //pFilename += 308; | |
2184 //} | |
2185 //while ( thisa < *(signed int *)((char *)&v89->uNumFaces + pNumItems) ); | |
2186 } | |
2187 //++v151; | |
2188 //pNumItems += 188; | |
2189 //} | |
2190 //while ( v151 < (signed int)uNumBModels ); | |
2191 } | |
2192 | |
2193 pGameLoadingUI_ProgressBar->Progress(); | |
2194 | |
2195 //v151 = 0; | |
2196 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
2197 { | |
2198 //thisa = (int)&pLevelDecorations[0].field_2; | |
2199 //do | |
2200 //{ | |
2201 memcpy(&pLevelDecorations[i].field_2, pSrc, 2); | |
2202 pSrc += 2; | |
2203 //thisa += 32; | |
2204 //v85 = (char *)v85 + 2; | |
2205 //++v151; | |
2206 //} | |
2207 //while ( v151 < (signed int)uNumLevelDecorations ); | |
2208 } | |
2209 | |
2210 pGameLoadingUI_ProgressBar->Progress(); | |
2211 | |
2212 memcpy(&uNumActors, pSrc, 4); | |
2213 //v91 = (char *)v85 + 4; | |
2214 if (uNumActors > 500) | |
2215 MessageBoxW(nullptr, L"Can't load file!", | |
2216 L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:939", 0); | |
2217 | |
2218 pGameLoadingUI_ProgressBar->Progress(); | |
2219 | |
2220 assert(sizeof(Actor) == 836); | |
2221 //pFilename = (char *)(836 * uNumActors); | |
2222 memcpy(pActors, pSrc + 4, uNumActors * sizeof(Actor)); | |
2223 pSrc += 4 + uNumActors * sizeof(Actor); | |
2224 //v92 = (char *)v91 + (int)pFilename; | |
2225 pGameLoadingUI_ProgressBar->Progress(); | |
2226 | |
2227 memcpy(&uNumLayingItems, pSrc, 4); | |
2228 //v93 = (char *)v92 + 4; | |
2229 if (uNumLayingItems > 1000) | |
2230 MessageBoxW(nullptr, L"Can't load file!", | |
2231 L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:954", 0); | |
2232 | |
2233 pGameLoadingUI_ProgressBar->Progress(); | |
2234 | |
2235 assert(sizeof(LayingItem) == 112); | |
2236 //pFilename = (char *)(112 * uNumLayingItems); | |
2237 memcpy(pLayingItems, pSrc + 4, uNumLayingItems * sizeof(LayingItem)); | |
2238 pSrc += 4 + uNumLayingItems * sizeof(LayingItem); | |
2239 | |
2240 //v94 = (char *)v93 + (int)pFilename; | |
2241 pGameLoadingUI_ProgressBar->Progress(); | |
2242 | |
2243 memcpy(&uNumChests, pSrc, 4); | |
2244 //v95 = (char *)v94 + 4; | |
2245 if (uNumChests > 20) | |
2246 MessageBoxW(nullptr, L"Can't load file!", | |
2247 L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:968", 0); | |
2248 | |
2249 pGameLoadingUI_ProgressBar->Progress(); | |
2250 | |
2251 assert(sizeof(Chest) == 5324); | |
2252 //pFilename = (char *)(5324 * uNumChests); | |
2253 memcpy(pChests, pSrc + 4 , uNumChests * sizeof(Chest)); | |
2254 pSrc += 4 + uNumChests * sizeof(Chest); | |
2255 //v96 = (char *)v95 + (int)pFilename; | |
2256 pGameLoadingUI_ProgressBar->Progress(); | |
2257 | |
2258 memcpy(&stru_5E4C90, pSrc, 0xC8); | |
2259 pSrc += 0xC8; | |
2260 | |
2261 pGameLoadingUI_ProgressBar->Progress(); | |
2262 memcpy(&uLastVisitDay, pSrc, 0x38u); | |
2263 | |
2264 free(pSrcMem); | |
2265 | |
2266 pTileTable->InitializeTileset(4); | |
2267 //thisa = (int)pTileTypes; | |
2268 //v108 = pTileTypes[0].uTileGroup; | |
2269 pTileTable->InitializeTileset(pTileTypes[0].uTileGroup); | |
2270 //v108 = pTileTypes[1].uTileGroup; | |
2271 pTileTable->InitializeTileset(pTileTypes[1].uTileGroup); | |
2272 //v108 = pTileTypes[2].uTileGroup; | |
2273 pTileTable->InitializeTileset(pTileTypes[2].uTileGroup); | |
2274 //v108 = pTileTypes[3].uTileGroup; | |
2275 pTileTable->InitializeTileset(pTileTypes[3].uTileGroup); | |
2276 strcpy(pGroundTileset, byte_6BE124_cfg_textures_DefaultGroundTexture); | |
2277 //v97 = pTileTypes[0].uTileID; | |
2278 //v108 = 0; | |
2279 auto v98 = pTileTable->GetTileById(pTileTypes[0].uTileID); | |
2280 //v99 = pBitmaps_LOD->LoadTexture(v98->pTileName, TEXTURE_DEFAULT); | |
2281 uMainTile_BitmapID = pBitmaps_LOD->LoadTexture(v98->pTileName, TEXTURE_DEFAULT); | |
2282 if (uMainTile_BitmapID != -1) | |
2283 pBitmaps_LOD->pTextures[uMainTile_BitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[uMainTile_BitmapID].palette_id1); | |
2284 | |
2285 _47F0E2(); | |
2286 | |
2287 LABEL_150: | |
2288 //v100 = HIDWORD(uLastVisitDay); | |
2289 //LODWORD(v142) = LODWORD(uLastVisitDay); | |
2290 //HIDWORD(v142) = v100; | |
2291 if (uLastVisitDay) | |
2292 { | |
2293 auto v108 = 28; | |
2294 if ( (signed int)((signed int)(signed __int64)((double)uLastVisitDay * 0.234375) / 60 / 60 / 0x18u) % 28 != pParty->uDaysPlayed ) | |
2295 { | |
2296 if ( rand() % 100 >= 20 ) | |
2297 v108 = dword_4EC268[rand() % dword_4EC2A8]; | |
2298 else | |
2299 v108 = dword_4EC28C[rand() % dword_4EC2AC]; | |
2300 sprintf(field_4F8, "plansky%d", v108); | |
2301 } | |
2302 } | |
2303 else | |
2304 { | |
2305 strcpy(field_4F8, "plansky3"); | |
2306 } | |
2307 //v101 = pBitmaps_LOD->LoadTexture(field_4F8); | |
2308 uSky_TextureID = pBitmaps_LOD->LoadTexture(field_4F8); | |
2309 if (uSky_TextureID != -1) | |
2310 pBitmaps_LOD->pTextures[uSky_TextureID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[uSky_TextureID].palette_id1); | |
2311 | |
2312 pPaletteManager->RecalculateAll(); | |
2313 pSoundList->LoadSound(53, 0); | |
2314 pSoundList->LoadSound(92, 0); | |
2315 pSoundList->LoadSound(57, 0); | |
2316 pSoundList->LoadSound(96, 0); | |
2317 pSoundList->LoadSound(64, 0); | |
2318 pSoundList->LoadSound(103, 0); | |
2319 v102 = thisa; | |
2320 thisa = 3; | |
2321 do | |
2322 { | |
2323 if ( *(short *)v102 ) | |
2324 { | |
2325 switch ( *(short *)v102 ) | |
2326 { | |
2327 case 1: | |
2328 pSoundList->LoadSound(58, 0); | |
2329 v108 = 0; | |
2330 v107 = 97; | |
2331 break; | |
2332 case 2: | |
2333 pSoundList->LoadSound(52, 0); | |
2334 v108 = 0; | |
2335 v107 = 91; | |
2336 break; | |
2337 case 3: | |
2338 pSoundList->LoadSound(51, 0); | |
2339 v108 = 0; | |
2340 v107 = 90; | |
2341 break; | |
2342 case 5: | |
2343 pSoundList->LoadSound(62, 0); | |
2344 v108 = 0; | |
2345 v107 = 101; | |
2346 break; | |
2347 case 6: | |
2348 pSoundList->LoadSound(49, 0); | |
2349 v108 = 0; | |
2350 v107 = 88; | |
2351 break; | |
2352 default: | |
2353 if ( *(short *)v102 != 7 ) | |
2354 goto LABEL_175; | |
2355 pSoundList->LoadSound(61, 0); | |
2356 v108 = 0; | |
2357 v107 = 100; | |
2358 break; | |
2359 } | |
2360 } | |
2361 else | |
2362 { | |
2363 pSoundList->LoadSound(54, 0); | |
2364 v108 = 0; | |
2365 v107 = 93; | |
2366 } | |
2367 pSoundList->LoadSound(v107, v108); | |
2368 LABEL_175: | |
2369 v102 += 4; | |
2370 --thisa; | |
2371 } | |
2372 while ( thisa ); | |
2373 return true; | |
2374 } | |
2375 | |
2376 //----- (0047ECC1) -------------------------------------------------------- | |
2377 int OutdoorLocation::_47ECC1(signed int a2) | |
2378 { | |
2379 signed int result; // eax@2 | |
2380 int v3; // eax@3 | |
2381 | |
2382 if ( a2 >= 90 ) | |
2383 { | |
2384 v3 = (a2 - 90) / 36; | |
2385 if ( v3 && v3 != 1 && v3 != 2 ) | |
2386 { | |
2387 if ( v3 == 3 ) | |
2388 result = this->pTileTypes[3].uTileID; | |
2389 else | |
2390 result = a2; | |
2391 } | |
2392 else | |
2393 { | |
2394 result = this->pTileTypes[v3].uTileID; | |
2395 } | |
2396 } | |
2397 else | |
2398 { | |
2399 result = 0; | |
2400 } | |
2401 return result; | |
2402 } | |
2403 | |
2404 //----- (0047ED08) -------------------------------------------------------- | |
67 | 2405 unsigned int OutdoorLocation::DoGetTileTexture(unsigned int uX, unsigned int uY) |
0 | 2406 { |
2407 int v3; // esi@5 | |
2408 unsigned int result; // eax@9 | |
2409 | |
67 | 2410 |
2411 /* v3 = *(&this->pTerrain.pTilemap[128 * uZ] + uX); | |
0 | 2412 if ( v3 < 198 ) |
2413 { | |
2414 if ( v3 >= 90 ) | |
2415 v3 = v3 + this->pTileTypes[(v3 - 90) / 36].uTileID - 36 * (v3 - 90) / 36 - 90; | |
2416 } | |
2417 else | |
2418 { | |
2419 v3 = v3 + this->pTileTypes[3].uTileID - 198; | |
2420 } | |
2421 result = pTileTable->pTiles[v3].uBitmapID; | |
2422 } | |
67 | 2423 return result;*/ |
185 | 2424 if ( uX < 0 || uX > 127 || uY < 0 || uY > 127) |
67 | 2425 return 0; |
2426 | |
2427 v3 = this->pTerrain.pTilemap[uY * 128 + uX]; | |
2428 if (v3 < 198) | |
2429 { | |
2430 if (v3 >= 90) | |
185 | 2431 v3 = v3 + this->pTileTypes[(v3 - 90) / 36].uTileID - 36 * ((v3 - 90) / 36) - 90; |
67 | 2432 } |
2433 else | |
2434 v3 = v3 + this->pTileTypes[3].uTileID - 198; | |
2435 | |
2436 return pTileTable->pTiles[v3].uBitmapID; | |
0 | 2437 } |
2438 | |
2439 //----- (0047ED83) -------------------------------------------------------- | |
2440 int OutdoorLocation::_47ED83(signed int a2, signed int a3) | |
2441 { | |
2442 int result; // eax@5 | |
2443 | |
2444 if ( a2 < 0 || a2 > 127 || a3 < 0 || a3 > 127 ) | |
2445 result = 0; | |
2446 else | |
2447 result = *(&this->pTerrain.pTilemap[128 * a3] + a2); | |
2448 return result; | |
2449 } | |
2450 | |
2451 //----- (0047EDB3) -------------------------------------------------------- | |
2452 int OutdoorLocation::ActuallyGetSomeOtherTileInfo(unsigned int uX, unsigned int uY) | |
2453 { | |
2454 int v3; // esi@5 | |
67 | 2455 //int result; // eax@7 |
0 | 2456 |
67 | 2457 /* if ( (uX & 0x80000000u) != 0 || (signed int)uX > 127 || (uY & 0x80000000u) != 0 || (signed int)uY > 127 ) |
0 | 2458 { |
2459 result = 0; | |
2460 } | |
2461 else | |
2462 { | |
2463 v3 = *(&this->pTerrain.pTilemap[128 * uY] + uX); | |
2464 if ( v3 >= 90 ) | |
2465 v3 = v3 + this->pTileTypes[(v3 - 90) / 36].uTileID - 36 * (v3 - 90) / 36 - 90; | |
2466 result = pTileTable->pTiles[v3].uAttributes; | |
2467 } | |
67 | 2468 return result;*/ |
185 | 2469 if (uX < 0 || uX > 127 || uY < 0 || uY > 127) |
179 | 2470 return 0; |
2471 else | |
2472 { | |
2473 v3 = this->pTerrain.pTilemap[uY * 128 + uX]; | |
2474 if ( v3 >= 90 ) | |
185 | 2475 v3 = v3 + this->pTileTypes[(v3 - 90) / 36].uTileID - 36 * ((v3 - 90) / 36) - 90; |
67 | 2476 return pTileTable->pTiles[v3].uAttributes; |
185 | 2477 } |
0 | 2478 } |
2479 | |
2480 //----- (0047EE16) -------------------------------------------------------- | |
2481 int OutdoorLocation::DoGetHeightOnTerrain(unsigned int uX, unsigned int uZ) | |
2482 { | |
2483 int result; // eax@5 | |
2484 | |
49 | 2485 if ( (signed int)uX < 0 || (signed int)uX > 127 || (signed int)uZ < 0 || (signed int)uZ > 127 ) |
0 | 2486 result = 0; |
2487 else | |
179 | 2488 result = 32 * *(&this->pTerrain.pHeightmap[uZ * 128 + uX]); |
0 | 2489 return result; |
2490 } | |
2491 | |
2492 //----- (0047EE49) -------------------------------------------------------- | |
2493 int OutdoorLocation::_47EE49(signed int a2, signed int a3, int a4) | |
2494 { | |
2495 signed int v4; // eax@5 | |
2496 signed int v5; // eax@7 | |
2497 int v6; // eax@8 | |
2498 signed int v8; // eax@9 | |
2499 int v9; // eax@12 | |
2500 int v10; // eax@13 | |
2501 int v11; // eax@14 | |
2502 int v12; // eax@16 | |
2503 int v13; // eax@17 | |
2504 int v14; // eax@18 | |
2505 int v15; // eax@19 | |
2506 int v16; // eax@20 | |
2507 int v17; // eax@21 | |
2508 int v18; // eax@28 | |
2509 int v19; // eax@29 | |
2510 int v20; // eax@30 | |
2511 | |
2512 if ( a2 < 0 || a2 > 127 || a3 < 0 || a3 > 127 ) | |
2513 v4 = 0; | |
2514 else | |
2515 v4 = *(&this->pTerrain.pTilemap[128 * a3] + a2); | |
2516 v5 = _47ECC1(v4); | |
2517 if ( !v5 ) | |
2518 { | |
2519 v6 = -(a4 != 0); | |
2520 LOBYTE(v6) = v6 & 0xD9; | |
2521 return v6 + 92; | |
2522 } | |
2523 v8 = pTileTable->pTiles[v5].uTerrainType; | |
2524 if ( v8 <= 6 ) | |
2525 { | |
2526 if ( v8 == 6 ) | |
2527 { | |
2528 v17 = -(a4 != 0); | |
2529 LOBYTE(v17) = v17 & 0xD9; | |
2530 return v17 + 88; | |
2531 } | |
2532 if ( v8 ) | |
2533 { | |
2534 v9 = v8 - 1; | |
2535 if ( !v9 ) | |
2536 { | |
2537 v15 = -(a4 != 0); | |
2538 LOBYTE(v15) = v15 & 0xD9; | |
2539 return v15 + 97; | |
2540 } | |
2541 v10 = v9 - 1; | |
2542 if ( !v10 ) | |
2543 { | |
2544 v14 = -(a4 != 0); | |
2545 LOBYTE(v14) = v14 & 0xD9; | |
2546 return v14 + 91; | |
2547 } | |
2548 v11 = v10 - 1; | |
2549 if ( !v11 ) | |
2550 { | |
2551 v13 = -(a4 != 0); | |
2552 LOBYTE(v13) = v13 & 0xD9; | |
2553 return v13 + 90; | |
2554 } | |
2555 if ( v11 == 2 ) | |
2556 { | |
2557 v12 = -(a4 != 0); | |
2558 LOBYTE(v12) = v12 & 0xD9; | |
2559 return v12 + 101; | |
2560 } | |
2561 LABEL_29: | |
2562 v19 = -(a4 != 0); | |
2563 LOBYTE(v19) = v19 & 0xD9; | |
2564 return v19 + 95; | |
2565 } | |
2566 goto LABEL_20; | |
2567 } | |
2568 if ( v8 != 7 ) | |
2569 { | |
2570 if ( v8 != 8 ) | |
2571 { | |
2572 if ( v8 > 9 && (v8 <= 17 || v8 > 21 && v8 <= 27) ) | |
2573 { | |
2574 v18 = -(a4 != 0); | |
2575 LOBYTE(v18) = v18 & 0xD9; | |
2576 return v18 + 96; | |
2577 } | |
2578 goto LABEL_29; | |
2579 } | |
2580 LABEL_20: | |
2581 v16 = -(a4 != 0); | |
2582 LOBYTE(v16) = v16 & 0xD9; | |
2583 return v16 + 93; | |
2584 } | |
2585 v20 = -(a4 != 0); | |
2586 LOBYTE(v20) = v20 & 0xD9; | |
2587 return v20 + 100; | |
2588 } | |
2589 | |
2590 //----- (0047EF60) -------------------------------------------------------- | |
2591 int OutdoorLocation::_47EF60(int a2, int a3, int a4) | |
2592 { | |
2593 int v4; // ecx@1 | |
2594 int v5; // edx@2 | |
2595 int v6; // edi@2 | |
2596 int v7; // esi@2 | |
2597 int v8; // eax@4 | |
2598 int v9; // ebx@4 | |
2599 int v10; // eax@5 | |
2600 int v11; // eax@7 | |
2601 int v12; // esi@12 | |
2602 char v13; // al@12 | |
2603 int v15; // [sp+4h] [bp-14h]@7 | |
2604 int v16; // [sp+8h] [bp-10h]@5 | |
2605 int v17; // [sp+Ch] [bp-Ch]@2 | |
2606 OutdoorLocation *v18; // [sp+10h] [bp-8h]@1 | |
2607 int v19; // [sp+14h] [bp-4h]@2 | |
2608 int i; // [sp+24h] [bp+Ch]@5 | |
2609 | |
2610 v18 = this; | |
2611 v4 = a3 - 10; | |
2612 if ( a3 - 10 < a3 + 10 ) | |
2613 { | |
2614 v5 = v4 - a3; | |
2615 v6 = 88 * (a3 - 30); | |
2616 v7 = a2; | |
2617 v19 = v4 - a3; | |
2618 v17 = a3 + 10 - v4; | |
2619 while ( 1 ) | |
2620 { | |
2621 v8 = abs(v5); | |
2622 v9 = v7 - 10; | |
2623 if ( v7 - 10 < v7 + 10 ) | |
2624 { | |
2625 v16 = v8 * v8; | |
2626 v10 = v9 - v7; | |
2627 for ( i = v9 - v7; ; v10 = i ) | |
2628 { | |
2629 v11 = abs(v10); | |
2630 v15 = v11 * v11 + v16; | |
2631 if ( v15 <= 100 && v9 >= 20 && v9 <= 107 && v6 >= 0 && v6 <= 7656 ) | |
2632 { | |
2633 v12 = (v6 + v9 - 20) >> 3; | |
2634 v13 = 1 << (8 - (v6 + v9 - 20) % 8 - 1); | |
2635 v18->array_8F0[v12] |= v13; | |
2636 if ( v15 <= 49 ) | |
2637 v18->array_528[v12] |= v13; | |
2638 v7 = a2; | |
2639 } | |
2640 ++v9; | |
2641 ++i; | |
2642 if ( v9 >= v7 + 10 ) | |
2643 break; | |
2644 } | |
2645 } | |
2646 v6 += 88; | |
2647 ++v19; | |
2648 --v17; | |
2649 if ( !v17 ) | |
2650 break; | |
2651 v5 = v19; | |
2652 } | |
2653 } | |
2654 return 1; | |
2655 } | |
2656 | |
2657 //----- (0047F04C) -------------------------------------------------------- | |
2658 bool OutdoorLocation::_47F04C(signed int a2, signed int a3) | |
2659 { | |
2660 bool result; // eax@5 | |
2661 | |
2662 if ( a2 < 0 || a2 >= 88 || a3 < 0 || a3 >= 88 ) | |
2663 result = 0; | |
2664 else | |
2665 result = (this->array_528[(a2 + 88 * a3) / 8] & (unsigned __int8)(1 << (7 - (a2 + 88 * a3) % 8))) != 0; | |
2666 return result; | |
2667 } | |
2668 | |
2669 //----- (0047F097) -------------------------------------------------------- | |
2670 bool OutdoorLocation::_47F097(signed int a2, signed int a3) | |
2671 { | |
2672 bool result; // eax@5 | |
2673 | |
2674 if ( a2 < 0 || a2 >= 88 || a3 < 0 || a3 >= 88 ) | |
2675 result = 0; | |
2676 else | |
2677 result = (this->array_8F0[(a2 + 88 * a3) / 8] & (unsigned __int8)(1 << (7 - (a2 + 88 * a3) % 8))) != 0; | |
2678 return result; | |
2679 } | |
2680 | |
2681 //----- (0047F0E2) -------------------------------------------------------- | |
2682 bool OutdoorLocation::_47F0E2() | |
2683 { | |
2684 signed int v1; // edi@1 | |
2685 OutdoorLocation *v2; // ebx@1 | |
2686 Texture *v3; // ebp@2 | |
2687 | |
2688 v1 = 0; | |
2689 v2 = this; | |
2690 if ( (signed int)pBitmaps_LOD->uNumLoadedFiles > 0 ) | |
2691 { | |
2692 v3 = pBitmaps_LOD->pTextures; | |
2693 do | |
2694 { | |
2695 if ( v1 != -1 ? (int)v3 : 0 ) | |
2696 v3->uDecompressedSize = v2->pTerrain._47CB57((int)v3->pLevelOfDetail0, | |
2697 v3->palette_id2, | |
2698 v3->uTextureWidth * v3->uTextureHeight); | |
2699 ++v1; | |
2700 ++v3; | |
2701 } | |
2702 while ( v1 < (signed int)pBitmaps_LOD->uNumLoadedFiles ); | |
2703 } | |
2704 return 1; | |
2705 } | |
2706 | |
2707 //----- (0047F138) -------------------------------------------------------- | |
2708 bool OutdoorLocation::PrepareDecorations() | |
2709 { | |
2710 signed int v1; // ebx@1 | |
2711 __int16 v4; // ax@5 | |
2712 int v5; // eax@7 | |
2713 __int16 v6; // ax@14 | |
2714 signed int v8; // [sp+Ch] [bp-4h]@1 | |
2715 | |
2716 v1 = 0; | |
2717 v8 = 0; | |
2718 if ( !_strcmpi(pCurrentMapName, "out09.odm") ) | |
2719 v8 = 1; | |
2720 | |
2721 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
2722 { | |
2723 auto decor = pLevelDecorations + i; | |
2724 | |
2725 pDecorationList->InitializeDecorationSprite(decor->uDecorationDescID); | |
2726 v4 = pDecorationList->pDecorations[decor->uDecorationDescID].uSoundID; | |
2727 if ( v4 && _6807E0_num_decorations_with_sounds_6807B8 < 9 ) | |
2728 { | |
2729 pSoundList->LoadSound(v4, 0); | |
2730 v5 = _6807E0_num_decorations_with_sounds_6807B8++; | |
2731 _6807B8_level_decorations_ids[v5] = i; | |
2732 } | |
2733 if ( v8 && decor->uCog == 20 ) | |
2734 LOBYTE(decor->field_2) |= 0x40u; | |
2735 if ( !decor->field_16_event_id ) | |
2736 { | |
2737 if ( decor->IsInteractive() ) | |
2738 { | |
2739 if ( v1 < 124 ) | |
2740 { | |
2741 v6 = v1 + 75; | |
2742 decor->_idx_in_stru123 = v6; | |
2743 if ( !stru_5E4C90._decor_events[v1++] ) | |
2744 LOBYTE(decor->field_2) |= 0x20u; | |
2745 } | |
2746 } | |
2747 } | |
2748 } | |
2749 | |
2750 pGameLoadingUI_ProgressBar->Progress(); | |
2751 return true; | |
2752 } | |
2753 // 6807E0: using guessed type int _6807E0_num_decorations_6807B8; | |
2754 | |
2755 //----- (0047F223) -------------------------------------------------------- | |
2756 int OutdoorLocation::_47F223_LooksLikeGenerateMonsterLoot() | |
2757 { | |
2758 signed int v1; // ebx@1 | |
2759 char *v2; // esi@2 | |
2760 int v3; // eax@7 | |
2761 OutdoorLocation *v5; // [sp+0h] [bp-4h]@1 | |
2762 | |
2763 v5 = this; | |
2764 v1 = 0; | |
2765 if ( (signed int)uNumLayingItems > 0 ) | |
2766 { | |
2767 v2 = (char *)&pLayingItems[0].uObjectDescID; | |
2768 do | |
2769 { | |
2770 if ( *(short *)v2 ) | |
2771 { | |
2772 if ( !(v2[24] & 8) && !(pObjectList->pObjects[*(short *)v2].uFlags & 0x10) ) | |
2773 *(int *)(v2 + 10) = GetTerrainHeightsAroundParty2(*(int *)(v2 + 2), *(int *)(v2 + 6), (int *)&v5, 0); | |
2774 v3 = *(int *)(v2 + 34); | |
2775 if ( v3 ) | |
2776 { | |
2777 if ( v3 != 220 && pItemsTable->pItems[v3].uEquipType == 14 && !*(int *)(v2 + 38) ) | |
2778 *(int *)(v2 + 38) = rand() % 15 + 5; | |
2779 pItemsTable->SetSpecialBonus((ItemGen *)(v2 + 34)); | |
2780 } | |
2781 } | |
2782 ++v1; | |
2783 v2 += 112; | |
2784 } | |
2785 while ( v1 < (signed int)uNumLayingItems ); | |
2786 } | |
2787 pGameLoadingUI_ProgressBar->Progress(); | |
2788 return 1; | |
2789 } | |
2790 | |
2791 //----- (0047F2D3) -------------------------------------------------------- | |
2792 bool OutdoorLocation::InitalizeActors(int a1) | |
2793 { | |
2794 int v2; // ebx@1 | |
82 | 2795 Actor *v3; // esi@2 |
0 | 2796 int v4; // eax@3 |
2797 __int16 v5; // ax@11 | |
2798 int v8; // [sp+348h] [bp-8h]@1 | |
2799 int v9; // [sp+34Ch] [bp-4h]@1 | |
2800 | |
2801 v2 = 0; | |
2802 v8 = 0; | |
2803 v9 = 0; | |
2804 if ( (signed int)uNumActors > 0 ) | |
2805 { | |
82 | 2806 v3 = pActors;//[0].uAttributes; |
2807 while ( v9 < (signed int)uNumActors ) | |
0 | 2808 { |
82 | 2809 v4 = v3->uAttributes; |
2810 if ( !(v4 & 0x100000) ) | |
2811 { | |
2812 if ( v8 != 1 ) | |
2813 { | |
2814 v3->uCurrentActionTime = v2; | |
2815 v3->uCurrentActionLength = v2; | |
2816 if ( v4 & 0x10000 ) | |
2817 v3->uAIState = (AIState) 19; | |
2818 v5 = v3->uAIState; | |
2819 if ( v5 != 11 && v5 != 19 && (v3->sCurrentHP == (short)v2 || v3->pMonsterInfo.uHP == v2) ) | |
2820 v3->uAIState = (AIState) 5; | |
2821 v3->vVelocity.x = v2; | |
2822 v3->vVelocity.y = v2; | |
2823 v3->vVelocity.z = v2; | |
2824 v3->UpdateAnimation(); | |
2825 v3->pMonsterInfo.uHostilityType = (MonsterInfo::HostilityRadius)0; | |
2826 v3->PrepareSprites(0); | |
2827 v2 = 0; | |
2828 } | |
2829 else | |
2830 { | |
2831 v3->uAIState = (AIState) 19; | |
2832 v3->uAttributes = v4 | 0x10000; | |
2833 } | |
2834 } | |
2835 else if ( a1 == v2 ) | |
2836 { | |
2837 v3->uAIState = (AIState) 19; | |
2838 v3->uAttributes = v4 | 0x10000; | |
2839 } | |
2840 else if ( v8 != v2 ) | |
2841 { | |
2842 v3->uCurrentActionTime = v2; | |
2843 v3->uCurrentActionLength = v2; | |
2844 if ( v4 & 0x10000 ) | |
2845 v3->uAIState = (AIState) 19; | |
2846 v5 = v3->uAIState; | |
2847 if ( v5 != 11 && v5 != 19 && (v3->sCurrentHP == (short)v2 || v3->pMonsterInfo.uHP == v2) ) | |
2848 v3->uAIState = (AIState) 5; | |
2849 v3->vVelocity.x = v2; | |
2850 v3->vVelocity.y = v2; | |
2851 v3->vVelocity.z = v2; | |
2852 v3->UpdateAnimation(); | |
2853 v3->pMonsterInfo.uHostilityType = (MonsterInfo::HostilityRadius)0; | |
2854 v3->PrepareSprites(0); | |
2855 v2 = 0; | |
2856 } | |
2857 else | |
2858 { | |
2859 v3->uAIState = (AIState) 19; | |
2860 v3->uAttributes = v4 | 0x10000; | |
2861 v8 = GetAlertStatus(); | |
2862 } | |
2863 ++v9; | |
2864 ++v3; | |
0 | 2865 } |
2866 } | |
2867 pGameLoadingUI_ProgressBar->Progress(); | |
2868 | |
2869 Actor thisa; | |
2870 thisa.pMonsterInfo.uID = 45; | |
2871 thisa.PrepareSprites(v2); | |
2872 return 1; | |
2873 } | |
2874 | |
2875 //----- (0047F3EA) -------------------------------------------------------- | |
2876 bool OutdoorLocation::_47F3EA() | |
2877 { | |
2878 OutdoorLocationTileType *v1; // esi@1 | |
2879 | |
2880 v1 = &this->pTileTypes[3]; | |
2881 this->pTileTypes[3].uTileID = pTileTable->method_487ED6(this->pTileTypes[3].uTileGroup, 1); | |
2882 pTileTable->InitializeTileset(v1->uTileGroup); | |
2883 return 1; | |
2884 } | |
2885 | |
2886 //----- (0047F420) -------------------------------------------------------- | |
2887 bool OutdoorLocation::LoadTileGroupIds() | |
2888 { | |
2889 for (uint i = 0; i < 3; ++i) | |
2890 pTileTypes[i].uTileID = pTileTable->method_487ED6(pTileTypes[i].uTileGroup, 1); | |
2891 | |
2892 return true; | |
2893 } | |
2894 | |
2895 //----- (0047B42C) -------------------------------------------------------- | |
142 | 2896 void OutdoorLocation::PrepareActorsDrawList() |
0 | 2897 { |
2898 unsigned int result; // eax@1 | |
142 | 2899 //Actor *v1; // edi@2 |
2900 //__int16 v2; // ax@3 | |
2901 int z; // esi@5 | |
0 | 2902 float v4; // ST48_4@8 |
142 | 2903 //double v5; // ST38_8@8 |
2904 //float v6; // ST48_4@10 | |
2905 //double v7; // ST30_8@10 | |
0 | 2906 unsigned int v8; // eax@11 |
2907 int v9; // edx@11 | |
2908 __int16 v10; // dx@11 | |
2909 unsigned int v11; // eax@13 | |
2910 signed int v12; // eax@16 | |
2911 __int16 v13; // cx@21 | |
2912 SpriteFrame *v14; // eax@24 | |
2913 SpriteFrame *v15; // ebx@25 | |
2914 //int *v16; // eax@25 | |
2915 int v17; // eax@35 | |
2916 int v18; // ST78_4@36 | |
2917 int v19; // eax@36 | |
2918 int v20; // ecx@38 | |
2919 int v21; // eax@38 | |
2920 int v22; // ecx@41 | |
2921 int v23; // ST5C_4@43 | |
2922 int v24; // esi@44 | |
2923 signed __int64 v25; // qtt@45 | |
2924 int v26; // ST54_4@45 | |
2925 int v27; // ecx@45 | |
2926 RenderBillboard *v28; // esi@45 | |
142 | 2927 //__int16 v29; // ax@46 |
0 | 2928 unsigned __int8 v30; // zf@46 |
2929 unsigned __int8 v31; // sf@46 | |
2930 signed __int16 v32; // ax@49 | |
2931 signed int v33; // ecx@50 | |
2932 int v34; // ecx@54 | |
2933 MonsterDesc *v35; // edx@54 | |
2934 int v36; // ecx@54 | |
142 | 2935 //unsigned __int8 v37; // zf@54 |
2936 //unsigned __int8 v38; // sf@54 | |
0 | 2937 unsigned int v39; // [sp-8h] [bp-68h]@23 |
2938 unsigned int v40; // [sp-4h] [bp-64h]@23 | |
2939 int v41; // [sp+24h] [bp-3Ch]@11 | |
2940 int v42; // [sp+28h] [bp-38h]@38 | |
2941 int v43; // [sp+28h] [bp-38h]@45 | |
2942 int v44; // [sp+2Ch] [bp-34h]@36 | |
2943 int v45; // [sp+2Ch] [bp-34h]@44 | |
2944 int v46; // [sp+2Ch] [bp-34h]@45 | |
2945 int v47; // [sp+30h] [bp-30h]@36 | |
2946 int v48; // [sp+30h] [bp-30h]@41 | |
2947 signed int v49; // [sp+34h] [bp-2Ch]@5 | |
2948 int v50; // [sp+34h] [bp-2Ch]@36 | |
2949 int v51; // [sp+34h] [bp-2Ch]@41 | |
2950 int v52; // [sp+34h] [bp-2Ch]@50 | |
2951 int v53; // [sp+38h] [bp-28h]@36 | |
142 | 2952 //int v54; // [sp+3Ch] [bp-24h]@2 |
0 | 2953 int y; // [sp+40h] [bp-20h]@5 |
2954 int x; // [sp+44h] [bp-1Ch]@5 | |
2955 int v57; // [sp+48h] [bp-18h]@45 | |
2956 int v58; // [sp+4Ch] [bp-14h]@45 | |
142 | 2957 //signed int v59; // [sp+50h] [bp-10h]@1 |
0 | 2958 int X; // [sp+54h] [bp-Ch]@36 |
142 | 2959 //__int16 v61; // [sp+58h] [bp-8h]@5 |
0 | 2960 signed __int16 v62; // [sp+5Ch] [bp-4h]@25 |
2961 | |
142 | 2962 //result = 0; |
2963 //v59 = 0; | |
2964 for (int i = 0; i < uNumActors; ++i) | |
0 | 2965 { |
142 | 2966 //v54 = 0; |
2967 //v1 = pActors;//[0].vPosition.z; | |
2968 //do | |
2969 //{ | |
2970 auto actor = pActors + i; | |
2971 //v2 = actor->uAIState; | |
2972 | |
2973 actor->uAttributes &= 0xFFFFFFF7u; | |
2974 if (actor->uAIState == Removed || actor->uAIState == Disabled) | |
2975 continue; | |
2976 | |
2977 z = actor->vPosition.z; | |
0 | 2978 v49 = 0; |
142 | 2979 x = actor->vPosition.x; |
2980 y = actor->vPosition.y; | |
2981 if (actor->uAIState == Summoned) | |
0 | 2982 { |
142 | 2983 if ((actor->uSummonerID & 7) != OBJECT_Actor || |
2984 pActors[actor->uSummonerID >> 3].pMonsterInfo.uSpecialAbilityDamageDiceSides != 1 ) | |
0 | 2985 { |
142 | 2986 z += floorf(actor->uActorHeight * 0.5f + 0.5f); |
0 | 2987 } |
2988 else | |
2989 { | |
2990 v49 = 1; | |
142 | 2991 pGame->pStru6Instance->_4A7F74(actor->vPosition.x, actor->vPosition.y, z); |
2992 v4 = (1.0 - (double)actor->uCurrentActionTime / (double)actor->uCurrentActionLength) * | |
2993 (double)(2 * actor->uActorHeight); | |
2994 z -= floorf(v4 + 0.5f); | |
2995 if ( z > actor->vPosition.z ) | |
2996 z = actor->vPosition.z; | |
0 | 2997 } |
2998 } | |
142 | 2999 v8 = stru_5C6E00->Atan2(actor->vPosition.x - pIndoorCamera->pos.x, |
3000 actor->vPosition.y - pIndoorCamera->pos.y); | |
3001 LOWORD(v9) = actor->uYawAngle; | |
0 | 3002 v41 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v9 - v8) >> 8) & 7; |
142 | 3003 v10 = actor->uCurrentActionAnimation; |
0 | 3004 if ( pParty->bTurnBasedModeOn ) |
3005 { | |
3006 if ( v10 != 1 ) | |
3007 { | |
3008 LABEL_17: | |
142 | 3009 v12 = actor->uCurrentActionTime; |
0 | 3010 goto LABEL_18; |
3011 } | |
3012 v11 = pMiscTimer->uTotalGameTimeElapsed; | |
3013 } | |
3014 else | |
3015 { | |
3016 if ( v10 != 1 ) | |
3017 goto LABEL_17; | |
3018 v11 = pEventTimer->uTotalGameTimeElapsed; | |
3019 } | |
142 | 3020 v12 = 32 * i + v11; |
0 | 3021 LABEL_18: |
142 | 3022 if ( (signed __int64)actor->pActorBuffs[5].uExpireTime > 0 || (signed __int64)actor->pActorBuffs[6].uExpireTime > 0 ) |
0 | 3023 v12 = 0; |
142 | 3024 v13 = actor->uAIState; |
0 | 3025 if ( v13 == 17 && !v49 ) |
3026 { | |
3027 v40 = v12; | |
3028 v39 = uSpriteID_Spell11; | |
3029 LABEL_24: | |
3030 v14 = pSpriteFrameTable->GetFrame(v39, v40); | |
3031 goto LABEL_25; | |
3032 } | |
3033 v40 = v12; | |
142 | 3034 v39 = actor->pSpriteIDs[v10]; |
0 | 3035 if ( v13 != 16 ) |
3036 goto LABEL_24; | |
3037 v14 = pSpriteFrameTable->GetFrameBy_x(v39, v12); | |
3038 LABEL_25: | |
3039 v62 = 0; | |
3040 v15 = v14; | |
3041 //v16 = (int *)v14->uFlags; | |
3042 if (v14->uFlags & 2) | |
3043 v62 = 2; | |
3044 if (v14->uFlags & 0x40000) | |
3045 v62 |= 0x40u; | |
3046 if (v14->uFlags & 0x20000) | |
3047 LOBYTE(v62) = v62 | 0x80; | |
3048 if ((256 << v41) & v14->uFlags) | |
3049 v62 |= 4u; | |
3050 if ( v15->uGlowRadius ) | |
3051 { | |
3052 //LOBYTE(v16) = byte_4E94D3; | |
142 | 3053 pMobileLightsStack->AddLight(x, y, z, 0, v15->uGlowRadius, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3); |
0 | 3054 } |
3055 v17 = (x - pIndoorCamera->pos.x) << 16; | |
3056 if ( pIndoorCamera->sRotationX ) | |
3057 { | |
3058 v18 = (y - pIndoorCamera->pos.y) << 16; | |
3059 v47 = ((unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) | |
3060 + ((unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | |
3061 v50 = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3062 v53 = (unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
142 | 3063 v44 = (z - pIndoorCamera->pos.z) << 16; |
0 | 3064 v19 = ((unsigned __int64)(v44 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16) |
3065 + ((unsigned __int64)(v47 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16); | |
3066 X = ((unsigned __int64)(v44 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16) | |
3067 + ((unsigned __int64)(v47 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16); | |
3068 if ( v19 < 262144 || v19 > pOutdoorCamera->shading_dist_mist << 16 ) | |
142 | 3069 continue; |
0 | 3070 v20 = v53 - v50; |
3071 v42 = v53 - v50; | |
3072 v21 = ((unsigned __int64)(v44 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) | |
3073 - ((unsigned __int64)(v47 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | |
3074 } | |
3075 else | |
3076 { | |
3077 v48 = (y - pIndoorCamera->pos.y) << 16; | |
3078 v51 = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | |
3079 v22 = (unsigned __int64)(v48 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3080 X = v22 + v51; | |
3081 if ( v22 + v51 < 262144 || v22 + v51 > pOutdoorCamera->shading_dist_mist << 16 ) | |
142 | 3082 continue; |
0 | 3083 v23 = (unsigned __int64)(((x - pIndoorCamera->pos.x) << 16) |
3084 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | |
3085 v20 = ((unsigned __int64)(v48 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v23; | |
3086 v42 = ((unsigned __int64)(v48 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v23; | |
142 | 3087 v21 = (z - pIndoorCamera->pos.z) << 16; |
0 | 3088 } |
3089 v45 = v21; | |
3090 v24 = abs(v20); | |
3091 if ( abs(X) >= v24 ) | |
3092 { | |
3093 LODWORD(v25) = 0; | |
3094 HIDWORD(v25) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
3095 v58 = v25 / X; | |
3096 v26 = v25 / X; | |
3097 LODWORD(v25) = 0; | |
3098 HIDWORD(v25) = SLOWORD(pOutdoorCamera->int_fov_rad); | |
3099 v57 = v25 / X; | |
3100 v27 = pViewport->uScreenCenterX | |
3101 - ((signed int)(((unsigned __int64)(v26 * (signed __int64)v42) >> 16) + 32768) >> 16); | |
3102 v43 = pViewport->uScreenCenterX | |
3103 - ((signed int)(((unsigned __int64)(v26 * (signed __int64)v42) >> 16) + 32768) >> 16); | |
3104 v46 = pViewport->uScreenCenterY - ((signed int)(((unsigned __int64)(v25 / X * v45) >> 16) + 32768) >> 16); | |
3105 result = uNumBillboardsToDraw; | |
3106 v28 = &pBillboardRenderList[uNumBillboardsToDraw]; | |
142 | 3107 if (uNumBillboardsToDraw >= 500) |
3108 return; | |
0 | 3109 ++uNumBillboardsToDraw; |
3110 ++uNumSpritesDrawnThisFrame; | |
142 | 3111 actor->uAttributes |= 8u; |
0 | 3112 v28->uHwSpriteID = v15->pHwSpriteIDs[v41]; |
3113 v28->uIndoorSectorID = 0; | |
142 | 3114 v28->uPalette = v15->uPaletteIndex; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
142
diff
changeset
|
3115 v28->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v15->scale * (signed __int64)v58) >> 16; |
142 | 3116 v30 = HIDWORD(actor->pActorBuffs[3].uExpireTime) == 0; |
3117 v31 = SHIDWORD(actor->pActorBuffs[3].uExpireTime) < 0; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
142
diff
changeset
|
3118 v28->_screenspace_y_scaler_packedfloat = (unsigned __int64)(v15->scale * (signed __int64)v57) >> 16; |
142 | 3119 if ( v31 || v31 | v30 && LODWORD(actor->pActorBuffs[3].uExpireTime) <= 0u ) |
0 | 3120 { |
142 | 3121 if ( (signed __int64)actor->pActorBuffs[10].uExpireTime > 0i64 ) |
0 | 3122 { |
142 | 3123 v52 = (unsigned __int64)(pGame->pStru6Instance->_4A806F(actor) |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
142
diff
changeset
|
3124 * (signed __int64)v28->_screenspace_y_scaler_packedfloat) >> 16; |
0 | 3125 LABEL_53: |
3126 LOWORD(v27) = v43; | |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
142
diff
changeset
|
3127 v28->_screenspace_y_scaler_packedfloat = v52; |
0 | 3128 } |
3129 } | |
3130 else | |
3131 { | |
142 | 3132 v32 = actor->pActorBuffs[3].uPower; |
0 | 3133 if ( v32 ) |
3134 { | |
142 | 3135 v33 = actor->pActorBuffs[3].uPower; |
144
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
142
diff
changeset
|
3136 v28->_screenspace_x_scaler_packedfloat = (unsigned __int64)(65536 / (unsigned __int16)v32 * (signed __int64)v28->_screenspace_x_scaler_packedfloat) >> 16; |
8ab4484c22e0
Billboard drawing's up (actors, decorations, misc sprites)
Nomad
parents:
142
diff
changeset
|
3137 v52 = (unsigned __int64)(65536 / v33 * (signed __int64)v28->_screenspace_y_scaler_packedfloat) >> 16; |
0 | 3138 goto LABEL_53; |
3139 } | |
3140 } | |
3141 v28->uScreenSpaceX = v27; | |
142 | 3142 v28->uScreenSpaceY = v46; |
0 | 3143 v28->some_x = x; |
3144 v28->some_y = y; | |
142 | 3145 v28->some_z = z; |
0 | 3146 HIWORD(v34) = HIWORD(X); |
3147 LOWORD(v34) = 0; | |
3148 v28->uPaletteSubindex = 0; | |
142 | 3149 v28->sZValue = v34 + (8 * i | OBJECT_Actor); |
3150 v28->field_14_actor_id = i; | |
0 | 3151 v35 = pMonsterList->pMonsters; |
142 | 3152 v36 = actor->pMonsterInfo.uID; |
0 | 3153 v28->field_1E = v62 | 0x200; |
3154 v28->pSpriteFrame = v15; | |
3155 v28->uTintColor = *((int *)&v35[v36] - 36); | |
142 | 3156 if (actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0) |
0 | 3157 v28->field_1E = v62 | 0x200; |
3158 } | |
142 | 3159 //LABEL_58: |
3160 //++v59; | |
3161 //v54 += 32; | |
3162 //result = v59; | |
3163 //++v1; | |
3164 //} | |
3165 //while ( v59 < (signed int)uNumActors ); | |
0 | 3166 } |
142 | 3167 //return result; |
0 | 3168 } |
3169 // 4E94D3: using guessed type char byte_4E94D3; | |
3170 // 5187E4: using guessed type int uNumSpritesDrawnThisFrame; | |
3171 | |
3172 //----- (0044C1E8) -------------------------------------------------------- | |
3173 bool ODMFace::HasEventHint() | |
3174 { | |
3175 signed int v1; // eax@1 | |
3176 Event *v2; // esi@2 | |
3177 bool result; // eax@5 | |
3178 signed int v4; // eax@6 | |
3179 | |
3180 v1 = 0; | |
3181 if ( (signed int)(uLevelEVT_NumEvents - 1) <= 0 ) | |
3182 goto LABEL_5; | |
3183 v2 = pLevelEVT_Events; | |
3184 while ( v2->uEventID != this->sCogTriggeredID ) | |
3185 { | |
3186 ++v1; | |
3187 ++v2; | |
3188 if ( v1 >= (signed int)(uLevelEVT_NumEvents - 1) ) | |
3189 goto LABEL_5; | |
3190 } | |
3191 v4 = v1; | |
3192 if ( pLevelEVT[pLevelEVT_Events[v4 + 1].uEventOffsetInEVT + 4] != 1 | |
3193 || pLevelEVT[pLevelEVT_Events[v4].uEventOffsetInEVT + 4] != 4 ) | |
3194 LABEL_5: | |
3195 result = 0; | |
3196 else | |
3197 result = 1; | |
3198 return result; | |
3199 } |