comparison Outdoor.cpp @ 0:8b8875f5b359

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