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