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