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