Mercurial > mm7
annotate Engine/Graphics/Outdoor.cpp @ 2575:a76d408c5132 tip
DrawTranslucent -> DrawTextureGrayShade
Removed old texture drawing stuff
author | a.parshin |
---|---|
date | Wed, 09 Mar 2016 01:39:52 +0200 |
parents | dd36326a9994 |
children |
rev | line source |
---|---|
2496 | 1 #define _CRTDBG_MAP_ALLOC |
2545 | 2 #define _CRT_SECURE_NO_WARNINGS |
2496 | 3 #include <stdlib.h> |
4 #include <crtdbg.h> | |
5 | |
2541 | 6 #include "Engine/Engine.h" |
2545 | 7 #include "Engine/Party.h" |
8 #include "Engine/Objects/SpriteObject.h" | |
9 #include "Engine/LOD.h" | |
10 #include "Engine/OurMath.h" | |
11 #include "Engine/Objects/ObjectList.h" | |
12 #include "Engine/Objects/Actor.h" | |
13 #include "Engine/Objects/Chest.h" | |
14 #include "Engine/stru123.h" | |
15 #include "Engine/Timer.h" | |
16 #include "Engine/TurnEngine/TurnEngine.h" | |
17 #include "Engine/Events.h" | |
18 #include "Engine/ZlibWrapper.h" | |
19 #include "Engine/MMT.h" | |
2567 | 20 #include "Engine/stru6.h" |
21 | |
2496 | 22 #include "Weather.h" |
23 #include "Sprites.h" | |
24 #include "LightmapBuilder.h" | |
25 #include "Outdoor.h" | |
26 #include "PaletteManager.h" | |
27 #include "DecorationList.h" | |
28 #include "Viewport.h" | |
29 #include "ParticleEngine.h" | |
30 #include "Lights.h" | |
2545 | 31 #include "Level/Decoration.h" |
2496 | 32 |
2502 | 33 #include "GUI/GUIWindow.h" |
2545 | 34 #include "GUI/GUIProgressBar.h" |
35 #include "GUI/UI/UITransition.h" | |
2574 | 36 #include "GUI/UI/UIRest.h" |
2545 | 37 |
38 #include "Media/Audio/AudioPlayer.h" | |
39 | |
40 MapStartPoint uLevel_StartingPointType; | |
2496 | 41 |
42 OutdoorLocation *pOutdoor = new OutdoorLocation; | |
43 ODMRenderParams *pODMRenderParams; | |
44 | |
45 | |
46 stru149 stru_8019C8; | |
47 std::array<struct Polygon, 2000 + 18000> array_77EC08; | |
48 | |
49 | |
50 struct FogProbabilityTableEntry | |
51 { | |
52 unsigned char small_fog_chance; | |
53 unsigned char average_fog_chance; | |
54 unsigned char dense_fog_chance; | |
55 unsigned char __unused; | |
56 } fog_probability_table[15] = | |
57 { | |
58 { 20, 10, 5, 0}, // MAP_EMERALD_ISLE | |
59 { 20, 10, 5, 0}, // MAP_HARMONDALE | |
60 { 20, 10, 5, 0}, // MAP_STEADWICK | |
61 { 20, 10, 5, 0}, // MAP_PIERPONT | |
62 { 20, 10, 5, 0}, // MAP_DEYJA | |
63 { 10, 5, 0, 0}, // MAP_BRAKADA_DESERT | |
64 { 0, 0, 0, 0}, // MAP_CELESTIA | |
65 { 0, 0, 0, 0}, // MAP_THE_PIT | |
66 { 20, 30, 50, 0}, // MAP_EVENMORN_ISLE | |
67 { 30, 20, 10, 0}, // MAP_MOUNT_NIGHON | |
68 { 10, 5, 0, 0}, // MAP_BARROW_DOWNS | |
69 { 20, 10, 5, 0}, // MAP_LAND_OF_GIANTS | |
70 { 20, 10, 5, 0}, // MAP_TATALIA | |
71 { 20, 10, 5, 0}, // MAP_AVLEE | |
72 { 0, 100, 0, 0} // MAP_SHOALS | |
73 }; | |
74 | |
75 //for future sky textures? | |
76 std::array<int, 9> dword_4EC268={{3,3,3,3,3,3,3,3,3}}; // weak | |
77 std::array<int, 7> dword_4EC28C={{3,3,3,3,3,3,3}}; // weak | |
78 int dword_4EC2A8=9; // weak | |
79 int dword_4EC2AC=7; // weak | |
80 | |
81 | |
82 | |
83 //----- (0047A59E) -------------------------------------------------------- | |
84 void OutdoorLocation::ExecDraw(unsigned int bRedraw) | |
85 { | |
86 | |
2543 | 87 pIndoorCameraD3D->debug_flags = 0; |
2496 | 88 if (viewparams->draw_d3d_outlines) |
2543 | 89 pIndoorCameraD3D->debug_flags |= ODM_RENDER_DRAW_D3D_OUTLINES; |
2496 | 90 |
91 if (bRedraw || true/*pRenderer->pRenderD3D*/) | |
92 { | |
93 //pODMRenderParams->RotationToInts(); | |
94 sub_481ED9_MessWithODMRenderParams(); | |
95 } | |
96 | |
97 pODMRenderParams->uMapGridCellX = WorldPosToGridCellX(pParty->vPosition.x); | |
98 pODMRenderParams->uMapGridCellZ = WorldPosToGridCellZ(pParty->vPosition.y); | |
99 assert(pODMRenderParams->uMapGridCellX <= 127 && pODMRenderParams->uMapGridCellZ <= 127); | |
100 | |
101 if (bRedraw) | |
102 { | |
103 sub_487DA9(); | |
104 } | |
105 if ( pParty->uCurrentMinute != pOutdoor->uLastSunlightUpdateMinute ) | |
106 pOutdoor->UpdateSunlightVectors(); | |
107 pOutdoor->UpdateFog(); | |
2543 | 108 //pIndoorCameraD3D->sr_Reset_list_0037C(); |
2496 | 109 |
110 //if (pRenderer->pRenderD3D) // d3d - redraw always | |
111 { | |
112 pRenderer->DrawOutdoorSkyD3D(); | |
113 pRenderer->DrawBuildingsD3D(); | |
114 pRenderer->RenderTerrainD3D(); | |
115 //pRenderer->DrawBezierTerrain(); | |
116 } | |
117 /*else | |
118 { | |
119 if (!bRedraw) | |
120 pRenderer->OnOutdoorRedrawSW(); | |
121 else | |
122 { | |
123 pRenderer->DrawBuildingsSW(); | |
124 pRenderer->DrawBezierTerrain(); | |
125 sr_sub_486F92_MessWithEdgesAndSpans(); | |
126 pODMRenderParams->ApplyLightmapsSW(); | |
127 } | |
128 }*/ | |
129 | |
130 | |
131 pMobileLightsStack->uNumLightsActive = 0; | |
132 pStationaryLightsStack->uNumLightsActive = 0; | |
133 /*if ( !pRenderer->pRenderD3D ) | |
134 { | |
135 pRenderer->ExecOutdoorDrawSW(); | |
2543 | 136 pIndoorCameraD3D->sr_438240_draw_lits(); |
2496 | 137 }*/ |
2541 | 138 pEngine->PushStationaryLights(-1); |
139 pEngine->PrepareBloodsplats(); | |
2496 | 140 if (bRedraw) |
141 pOutdoor->UpdateDiscoveredArea(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y), 1); | |
2541 | 142 pEngine->uFlags2 &= 0xFFFFFFFEu;//~0x00000001 |
2496 | 143 if (/*pRenderer->pRenderD3D*/true && pRenderer->bUsingSpecular) |
2541 | 144 pEngine->pLightmapBuilder->uFlags |= 1; |
2496 | 145 else |
2541 | 146 pEngine->pLightmapBuilder->uFlags &= 0xFFFFFFFEu;//~0x00000001 |
2496 | 147 |
148 uNumDecorationsDrawnThisFrame = 0; | |
149 uNumSpritesDrawnThisFrame = 0; | |
150 uNumBillboardsToDraw = 0; | |
151 | |
152 PrepareActorsDrawList(); | |
153 if (!pODMRenderParams->bDoNotRenderDecorations) | |
154 pRenderer->PrepareDecorationsRenderList_ODM(); | |
155 | |
156 pRenderer->DrawSpriteObjects_ODM(); | |
157 pRenderer->TransformBillboardsAndSetPalettesODM(); | |
158 } | |
159 | |
160 | |
161 //----- (00441CFF) -------------------------------------------------------- | |
162 void OutdoorLocation::Draw() | |
163 { | |
164 bool redrawWorld = true; | |
2541 | 165 if ( !(pParty->uFlags & 2) && !(pEngine->uFlags2 & 1) ) |
2496 | 166 redrawWorld = false; |
167 pOutdoor->ExecDraw(redrawWorld); | |
168 | |
2541 | 169 pEngine->DrawParticles(); |
2496 | 170 //pWeather->Draw();//если раскомментировать скорость снега быстрее |
171 trail_particle_generator.UpdateParticles(); | |
172 } | |
173 | |
174 //----- (00488E23) -------------------------------------------------------- | |
175 double OutdoorLocation::GetFogDensityByTime() | |
176 { | |
177 if ( pParty->uCurrentHour < 5 )//ночь | |
178 { | |
179 pWeather->bNight = true; | |
180 return 60.0 * 0.016666668; | |
181 } | |
182 else if ( pParty->uCurrentHour >= 5 && pParty->uCurrentHour < 6 )//рассвет | |
183 { | |
184 pWeather->bNight = false; | |
185 return (60.0 - (double)(60 * pParty->uCurrentHour + pParty->uCurrentMinute - 300)) * 0.016666668; | |
186 } | |
187 else if ( pParty->uCurrentHour >= 6 && pParty->uCurrentHour < 20 )//день | |
188 { | |
189 pWeather->bNight = false; | |
190 return 0.0; | |
191 } | |
192 else if ( pParty->uCurrentHour >= 20 && pParty->uCurrentHour < 21 )//сумерки | |
193 { | |
194 pWeather->bNight = false; | |
195 return ((double)(pParty->uCurrentHour - 20) * 60.0 + (double)(signed int)pParty->uCurrentMinute) * 0.016666668; | |
196 } | |
197 else//ночь | |
198 { | |
199 pWeather->bNight = true; | |
200 return 60.0 * 0.016666668; | |
201 } | |
202 } | |
203 | |
204 //----- (00488EB1) -------------------------------------------------------- | |
205 int OutdoorLocation::GetSomeOtherTileInfo(int sX, int sY) | |
206 { | |
207 //OutdoorLocation *v3; // esi@1 | |
208 unsigned int v4; // edi@1 | |
209 unsigned int v5; // eax@1 | |
210 // int result; // eax@5 | |
211 | |
212 /* v3 = this; | |
213 v4 = WorldPosToGridCellZ(sY); | |
214 v5 = WorldPosToGridCellX(sX); | |
215 if ( (v5 & 0x80000000u) != 0 || (signed int)v5 > 127 || (v4 & 0x80000000u) != 0 || (signed int)v4 > 127 ) | |
216 result = 0; | |
217 else | |
218 result = ActuallyGetSomeOtherTileInfo(v5, v4); | |
219 return result;*/ | |
220 v4 = WorldPosToGridCellZ(sY); | |
221 v5 = WorldPosToGridCellX(sX); | |
222 if ( v5 < 0 || v5 > 127 || v4 < 0 || v4 > 127 ) | |
223 return 0; | |
224 return ActuallyGetSomeOtherTileInfo(v5, v4); | |
225 } | |
226 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); | |
227 // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); | |
228 | |
229 //----- (00488EEF) -------------------------------------------------------- | |
230 unsigned int OutdoorLocation::GetTileTexture(signed int sX, signed int sY) | |
231 { | |
232 //OutdoorLocation *v3; // esi@1 | |
233 signed int v4; // edi@1 | |
234 signed int v5; // eax@1 | |
235 // unsigned int result; // eax@5 | |
236 | |
237 /*v3 = this; | |
238 v4 = WorldPosToGridCellZ(sZ); | |
239 v5 = WorldPosToGridCellX(sX); | |
240 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 ) | |
241 result = -1; | |
242 else | |
243 result = DoGetTileTexture(v5, v4); | |
244 return result;*/ | |
245 v4 = WorldPosToGridCellZ(sY); | |
246 v5 = WorldPosToGridCellX(sX); | |
247 if ( v5 < 0 || v5 > 127 || v4 < 0 || v4 > 127 ) | |
248 return -1; | |
249 return DoGetTileTexture(v5, v4); | |
250 } | |
251 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); | |
252 // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); | |
253 | |
254 //----- (00488F2E) -------------------------------------------------------- | |
255 int OutdoorLocation::GetHeightOnTerrain(int sX, int sZ) | |
256 /* Функция предоставляет возможность перемещать камеру таким образом, чтобы она имитировала ходьбу по ландшафту. | |
257 То есть нам надо менять высоту камеры (координату Y) в зависимости от того, в каком месте ландшафта мы находимся. | |
258 Для этого мы сначала должны определить по координатам X и Z камеры квадрат ландшафта в котором мы находимся. | |
259 Все это делает функция Terrain::getHeight; в своих параметрах она получает координаты X и Z камеры и возвращает высоту, | |
260 на которой должна быть расположена камера, чтобы она оказалась над ландшафтом.*/ | |
261 { | |
262 int result; // eax@5 | |
263 | |
264 if ( sX < 0 || sX > 127 || sZ < 0 || sZ > 127 ) | |
265 result = 0; | |
266 else | |
267 result = DoGetHeightOnTerrain(sX, sZ); | |
268 return result; | |
269 } | |
270 | |
271 //----- (00488F5C) -------------------------------------------------------- | |
272 bool OutdoorLocation::Initialize(const char *pFilename, int File, size_t uRespawnInterval, int *thisa) | |
273 { | |
274 OutdoorLocation *v5; // esi@1 | |
275 bool result; // eax@2 | |
276 | |
277 v5 = this; | |
278 if ( pFilename ) | |
279 { | |
280 Release(); | |
281 pBitmaps_LOD->ReleaseAll2(); | |
282 pSprites_LOD->DeleteSomeOtherSprites(); | |
283 pSpriteFrameTable->ResetSomeSpriteFlags(); | |
284 pIcons_LOD->ReleaseAll2(); | |
285 | |
286 if ( !Load(pFilename, (ODMFace *)File, uRespawnInterval, thisa) ) | |
287 { | |
288 MessageBoxA(0, "Error!", "Couldn't Load Map!", 0); | |
289 CreateDebugLocation(); | |
290 } | |
291 ::day_attrib = v5->loc_time.day_attrib; | |
292 ::day_fogrange_1 = v5->loc_time.day_fogrange_1; | |
293 ::day_fogrange_2 = v5->loc_time.day_fogrange_2; | |
294 if ( Is_out15odm_underwater() ) | |
295 SetUnderwaterFog(); | |
296 _6BE134_odm_main_tile_group = v5->pTileTypes[0].tileset; | |
297 result = 1; | |
298 } | |
299 else | |
300 { | |
301 result = 0; | |
302 } | |
303 return result; | |
304 } | |
305 | |
306 | |
307 | |
308 char foot_travel_destinations[15][4] = | |
309 { | |
310 // north south east west from | |
311 {MAP_INVALID, MAP_INVALID, MAP_INVALID, MAP_INVALID}, // MAP_EMERALD_ISLE | |
312 {MAP_PIERPONT, MAP_BARROW_DOWNS, MAP_PIERPONT, MAP_STEADWICK}, // MAP_HARMONDALE | |
313 {MAP_DEYJA, MAP_BRAKADA_DESERT, MAP_HARMONDALE, MAP_TATALIA}, // MAP_STEADWICK | |
314 {MAP_AVLEE, MAP_HARMONDALE, MAP_INVALID, MAP_DEYJA}, // MAP_PIERPONT | |
315 {MAP_PIERPONT, MAP_STEADWICK, MAP_PIERPONT, MAP_STEADWICK}, // MAP_DEYJA | |
316 {MAP_STEADWICK, MAP_INVALID, MAP_BARROW_DOWNS, MAP_INVALID}, // MAP_BRAKADA_DESERT | |
317 {MAP_INVALID, MAP_INVALID, MAP_INVALID, MAP_INVALID}, // MAP_CELESTIA | |
318 {MAP_INVALID, MAP_INVALID, MAP_INVALID, MAP_INVALID}, // MAP_THE_PIT | |
319 {MAP_INVALID, MAP_INVALID, MAP_INVALID, MAP_INVALID}, // MAP_EVENMORN_ISLE | |
320 {MAP_INVALID, MAP_INVALID, MAP_INVALID, MAP_INVALID}, // MAP_MOUNT_NIGHON | |
321 {MAP_HARMONDALE, MAP_BRAKADA_DESERT, MAP_HARMONDALE, MAP_BRAKADA_DESERT}, // MAP_BARROW_DOWNS | |
322 {MAP_INVALID, MAP_INVALID, MAP_INVALID, MAP_INVALID}, // MAP_LAND_OF_GIANTS | |
323 {MAP_INVALID, MAP_INVALID, MAP_STEADWICK, MAP_INVALID}, // MAP_TATALIA | |
324 {MAP_INVALID, MAP_PIERPONT, MAP_PIERPONT, MAP_INVALID}, // MAP_AVLEE | |
325 {MAP_INVALID, MAP_INVALID, MAP_INVALID, MAP_INVALID} // MAP_SHOALS | |
326 }; | |
327 unsigned char foot_travel_times[15][4] = | |
328 { | |
329 // north south east west from | |
330 {0, 0, 0, 0}, // MAP_EMERALD_ISLE | |
331 {5, 5, 7, 5}, // MAP_HARMONDALE | |
332 {5, 5, 5, 5}, // MAP_STEADWICK | |
333 {5, 5, 0, 5}, // MAP_PIERPONT | |
334 {7, 5, 5, 4}, // MAP_DEYJA | |
335 {5, 0, 5, 0}, // MAP_BRAKADA_DESERT | |
336 {0, 0, 0, 0}, // MAP_CELESTIA | |
337 {0, 0, 0, 0}, // MAP_THE_PIT | |
338 {0, 0, 0, 0}, // MAP_EVENMORN_ISLE | |
339 {0, 0, 0, 0}, // MAP_MOUNT_NIGHON | |
340 {5, 7, 7, 5}, // MAP_BARROW_DOWNS | |
341 {0, 0, 0, 0}, // MAP_LAND_OF_GIANTS | |
342 {0, 0, 5, 0}, // MAP_TATALIA | |
343 {0, 7, 5, 0}, // MAP_AVLEE | |
344 {0, 0, 0, 0}, // MAP_SHOALS | |
345 }; | |
346 | |
347 | |
348 MapStartPoint foot_travel_arrival_points[15][4] = | |
349 { | |
350 // north south east west from | |
351 {MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party}, // MAP_EMERALD_ISLE | |
352 {MapStartPoint_South, MapStartPoint_North, MapStartPoint_South, MapStartPoint_East}, // MAP_HARMONDALE | |
353 {MapStartPoint_South, MapStartPoint_North, MapStartPoint_West, MapStartPoint_East}, // MAP_STEADWICK | |
354 {MapStartPoint_East, MapStartPoint_North, MapStartPoint_Party, MapStartPoint_East}, // MAP_PIERPONT | |
355 {MapStartPoint_West, MapStartPoint_North, MapStartPoint_West, MapStartPoint_North}, // MAP_DEYJA | |
356 {MapStartPoint_South, MapStartPoint_Party, MapStartPoint_West, MapStartPoint_Party}, // MAP_BRAKADA_DESERT | |
357 {MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party}, // MAP_CELESTIA | |
358 {MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party}, // MAP_THE_PIT | |
359 {MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party}, // MAP_EVENMORN_ISLE | |
360 {MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party}, // MAP_MOUNT_NIGHON | |
361 {MapStartPoint_South, MapStartPoint_East, MapStartPoint_South, MapStartPoint_East}, // MAP_BARROW_DOWNS | |
362 {MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party}, // MAP_LAND_OF_GIANTS | |
363 {MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_West, MapStartPoint_Party}, // MAP_TATALIA | |
364 {MapStartPoint_Party, MapStartPoint_North, MapStartPoint_North, MapStartPoint_Party}, // MAP_AVLEE | |
365 {MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party, MapStartPoint_Party}, // MAP_SHOALS | |
366 }; | |
367 | |
368 | |
369 //----- (0048902E) -------------------------------------------------------- | |
370 bool OutdoorLocation::GetTravelDestination(signed int sPartyX, signed int sPartyZ, char *pOut, signed int a5) | |
371 { | |
372 char *mapNumberAsStr; // eax@3 | |
373 int mapNumberAsInt; // eax@3 | |
374 signed int direction; // esi@7 | |
375 signed int destinationMap; // eax@23 | |
376 char Str[140]; // [sp+8h] [bp-78h]@3 | |
377 | |
378 strcpy(Str, this->pLevelFilename);//настоящая локация | |
379 _strlwr(Str); | |
380 mapNumberAsStr = strtok(Str, "out"); | |
381 mapNumberAsStr[2] = 0; | |
382 mapNumberAsInt = atoi(mapNumberAsStr); | |
383 if ( a5 < 10 || strlen(this->pLevelFilename) != 9 || mapNumberAsInt < 1 || mapNumberAsInt > 15 ) //длина .odm и количество локаций | |
384 return 0; | |
385 if ( sPartyX < -22528 )//граница карты | |
386 direction = 4; | |
387 else if ( sPartyX > 22528 ) | |
388 direction = 3; | |
389 else if ( sPartyZ < -22528 ) | |
390 direction = 2; | |
391 else if ( sPartyZ > 22528 ) | |
392 direction = 1; | |
393 else | |
394 return false; | |
395 | |
396 if ( mapNumberAsInt == MAP_AVLEE && direction == 4) // to Shoals | |
397 { | |
398 if ( pPlayers[1]->HasUnderwaterSuitEquipped() && | |
399 pPlayers[2]->HasUnderwaterSuitEquipped() && | |
400 pPlayers[3]->HasUnderwaterSuitEquipped() && | |
401 pPlayers[4]->HasUnderwaterSuitEquipped()) | |
402 { | |
403 uDefaultTravelTime_ByFoot = 1; | |
404 strcpy(pOut, "out15.odm"); | |
405 uLevel_StartingPointType = MapStartPoint_East; | |
406 LOWORD(pParty->uFlags) &= 0xFD7Bu; | |
407 return true; | |
408 } | |
409 } | |
410 else if ( mapNumberAsInt == MAP_SHOALS && direction == 3 ) //from Shoals | |
411 { | |
412 uDefaultTravelTime_ByFoot = 1; | |
413 strcpy(pOut, "out14.odm");//Авли | |
414 uLevel_StartingPointType = MapStartPoint_West; | |
415 LOWORD(pParty->uFlags) &= 0xFD7Bu; | |
416 return true; | |
417 } | |
418 destinationMap = foot_travel_destinations[mapNumberAsInt - 1][direction - 1]; | |
419 if (destinationMap == MAP_INVALID) | |
420 return false; | |
421 | |
422 assert(destinationMap <= MAP_SHOALS); | |
423 | |
424 uDefaultTravelTime_ByFoot = foot_travel_times[mapNumberAsInt - 1][direction - 1]; | |
425 uLevel_StartingPointType = foot_travel_arrival_points[mapNumberAsInt - 1][direction - 1]; | |
426 sprintf(pOut, "out%02d.odm", destinationMap); //локация направления | |
427 return true; | |
428 } | |
429 // 6BD07C: using guessed type int uDefaultTravelTime_ByFoot; | |
430 // 6BE35C: using guessed type int uLevel_StartingPointType; | |
431 | |
432 //----- (0048917E) -------------------------------------------------------- | |
433 void OutdoorLocation::MessWithLUN() | |
434 { | |
435 this->pSpriteIDs_LUN[0] = -1; | |
436 this->pSpriteIDs_LUN[1] = 0; | |
437 this->pSpriteIDs_LUN[2] = pSpriteFrameTable->FastFindSprite("LUN1-4"); | |
438 this->pSpriteIDs_LUN[3] = 0; | |
439 this->pSpriteIDs_LUN[4] = pSpriteFrameTable->FastFindSprite("LUN1-2"); | |
440 this->pSpriteIDs_LUN[5] = 0; | |
441 this->pSpriteIDs_LUN[6] = pSpriteFrameTable->FastFindSprite("LUN3-4"); | |
442 this->pSpriteIDs_LUN[7] = 0; | |
443 this->uSpriteID_LUNFULL = pSpriteFrameTable->FastFindSprite("LUNFULL"); | |
444 this->uSpriteID_LUN1_2_cp = pSpriteFrameTable->FastFindSprite("LUN1-2"); | |
445 this->uSpriteID_LUN1_4_cp = pSpriteFrameTable->FastFindSprite("LUN1-4"); | |
446 this->uSpriteID_LUN3_4_cp = pSpriteFrameTable->FastFindSprite("LUN3-4"); | |
447 this->field_D60 = -1; | |
448 this->field_CF0 = 4; | |
449 this->field_CF8 = 4; | |
450 this->field_D00 = 4; | |
451 this->field_CE8 = 0; | |
452 this->field_D3C = (int)this->pSpriteIDs_LUN; | |
453 this->field_D40 = 0; | |
454 this->field_D44 = 0; | |
455 this->field_D48 = 0; | |
456 this->field_D4C = 131072; | |
457 this->field_D5C = 0; | |
458 this->field_D64 = 0; | |
459 this->field_D28 = -1; | |
460 this->field_D08 = 0; | |
461 this->field_D0C = 0; | |
462 this->field_D10 = 0; | |
463 this->field_D24 = 0; | |
464 this->field_D2C = 0; | |
465 this->uSpriteID_LUN_SUN = pSpriteFrameTable->FastFindSprite("LUN-SUN"); | |
466 this->field_D14 = -131072; | |
467 for ( uint i = 0; i < 8; i++ ) | |
468 pSpriteFrameTable->InitializeSprite(this->pSpriteIDs_LUN[i]);//v2 += 2; | |
469 pSpriteFrameTable->InitializeSprite(this->uSpriteID_LUN_SUN); | |
470 } | |
471 | |
472 //----- (004892E6) -------------------------------------------------------- | |
473 void OutdoorLocation::UpdateSunlightVectors() | |
474 { | |
475 unsigned int v3; // edi@3 | |
476 double v8; // st7@4 | |
477 | |
478 if ( pParty->uCurrentHour >= 5 && pParty->uCurrentHour < 21 ) | |
479 { | |
480 v3 = pParty->uCurrentMinute + 60 * (pParty->uCurrentHour - 5); | |
481 this->inv_sunlight_y = 0; | |
482 this->inv_sunlight_x = stru_5C6E00->Cos((v3 * stru_5C6E00->uIntegerPi) / 960); | |
483 this->inv_sunlight_z = stru_5C6E00->Sin((v3 * stru_5C6E00->uIntegerPi) / 960); | |
484 this->vSunlight.x = -this->inv_sunlight_x; | |
485 this->vSunlight.y = -this->inv_sunlight_y; | |
486 this->vSunlight.z = -this->inv_sunlight_z; | |
487 if ( v3 >= 480 ) | |
488 v8 = 960 - v3; | |
489 else | |
490 v8 = v3; | |
491 this->max_terrain_dimming_level = (int)(20.0 - v8 / 480.0 * 20.0); | |
492 this->uLastSunlightUpdateMinute = pParty->uCurrentMinute; | |
493 } | |
494 } | |
495 | |
496 //----- (004893C1) -------------------------------------------------------- | |
497 void OutdoorLocation::UpdateFog() | |
498 { | |
499 fFogDensity = GetFogDensityByTime(); | |
500 } | |
501 | |
502 //----- (004893CF) -------------------------------------------------------- | |
503 int OutdoorLocation::GetNumFoodRequiredToRestInCurrentPos(int x, signed int y, int z) | |
504 { | |
505 int v7; // eax@4 | |
506 int is_on_water; // [sp+8h] [bp-8h]@2 | |
507 int bmodel_standing_on_pid; // [sp+Ch] [bp-4h]@2 | |
508 | |
509 is_on_water = 0; | |
510 bmodel_standing_on_pid = 0; | |
511 ODM_GetFloorLevel(x, y, z, pParty->uDefaultPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0); | |
512 if ( pParty->uFlags & 8 || bmodel_standing_on_pid || is_on_water )//на bmodel,и или на воде | |
513 return 2; | |
514 v7 = _47ED83(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y) - 1); | |
515 switch ( pTileTable->pTiles[GetTileIdByTileMapId(v7)].tileset ) | |
516 { | |
517 case Tileset_Grass://на траве | |
518 return 1; | |
519 case Tileset_Snow://на снегу | |
520 return 3; | |
521 case Tilset_Desert://на песке | |
522 return 5; | |
2534 | 523 case Tileset_CooledLava: |
2496 | 524 case Tileset_Dirt:// на грязи |
525 return 4; | |
526 case Tileset_Water:// on water(на воде) | |
527 return 3;//еденицы еды | |
528 default: | |
529 return 2; | |
530 } | |
531 } | |
532 | |
533 //----- (00489487) -------------------------------------------------------- | |
534 void OutdoorLocation::SetFog() | |
535 { | |
536 strcpy(pOutdoor->pLevelFilename, pCurrentMapName); | |
537 | |
538 MAP_TYPE map_id = pMapStats->GetMapInfo(pCurrentMapName); | |
539 if (map_id == MAP_INVALID || map_id == MAP_CELESTIA || map_id == MAP_THE_PIT || map_id > MAP_SHOALS) | |
540 return; | |
541 | |
542 uint chance = rand() % 100; | |
543 | |
544 if (chance < fog_probability_table[map_id - 1].small_fog_chance) | |
545 { | |
546 ::day_fogrange_1 = 4096; | |
547 ::day_fogrange_2 = 8192; | |
548 ::day_attrib |= DAY_ATTRIB_FOG; | |
549 } | |
550 else if (chance < fog_probability_table[map_id - 1].small_fog_chance + | |
551 fog_probability_table[map_id - 1].average_fog_chance) | |
552 { | |
553 ::day_fogrange_2 = 4096; | |
554 ::day_fogrange_1 = 0; | |
555 ::day_attrib |= DAY_ATTRIB_FOG; | |
556 } | |
557 else if (fog_probability_table[map_id - 1].dense_fog_chance && | |
558 chance < fog_probability_table[map_id - 1].small_fog_chance + | |
559 fog_probability_table[map_id - 1].average_fog_chance + | |
560 fog_probability_table[map_id - 1].dense_fog_chance) | |
561 { | |
562 ::day_fogrange_2 = 2048; | |
563 ::day_fogrange_1 = 0; | |
564 ::day_attrib |= DAY_ATTRIB_FOG; | |
565 } | |
566 else | |
567 ::day_attrib &= ~DAY_ATTRIB_FOG; | |
568 | |
569 if ( Is_out15odm_underwater() ) | |
570 SetUnderwaterFog(); | |
571 pOutdoor->loc_time.day_fogrange_1 = ::day_fogrange_1; | |
572 pOutdoor->loc_time.day_fogrange_2 = ::day_fogrange_2; | |
573 pOutdoor->loc_time.day_attrib = ::day_attrib; | |
574 } | |
575 | |
576 //----- (00482170) -------------------------------------------------------- | |
577 bool ODMFace::IsBackfaceNotCulled(RenderVertexSoft *a2, struct Polygon *polygon) | |
578 { | |
579 unsigned int numOfVertices; // edx@1 | |
580 RenderVertexSoft *currVertex; // ecx@2 | |
581 double v7; // st7@5 | |
582 double v8; // st6@5 | |
583 double v9; // st5@5 | |
584 float v18; // [sp+8h] [bp-38h]@5 | |
585 float v19; // [sp+10h] [bp-30h]@5 | |
586 float v20; // [sp+14h] [bp-2Ch]@5 | |
587 float v21; // [sp+18h] [bp-28h]@5 | |
588 float v22; // [sp+1Ch] [bp-24h]@5 | |
589 float v23; // [sp+24h] [bp-1Ch]@5 | |
590 float v24; // [sp+28h] [bp-18h]@5 | |
591 float v25; // [sp+30h] [bp-10h]@5 | |
592 float v26; // [sp+34h] [bp-Ch]@5 | |
593 float v27; // [sp+38h] [bp-8h]@5 | |
594 float v28; // [sp+3Ch] [bp-4h]@5 | |
595 float a3a; // [sp+48h] [bp+8h]@5 | |
596 float a3b; // [sp+48h] [bp+8h]@17 | |
597 float a3c; // [sp+48h] [bp+8h]@17 | |
598 float a3d; // [sp+48h] [bp+8h]@17 | |
599 float a3e; // [sp+48h] [bp+8h]@17 | |
600 | |
601 numOfVertices = polygon->uNumVertices; | |
602 if ( numOfVertices < 3 ) | |
603 return false; | |
604 currVertex = &a2[numOfVertices - 1]; | |
605 if ( a2->vWorldPosition.z == a2[1].vWorldPosition.z && a2[1].vWorldPosition.z == currVertex->vWorldPosition.z ) | |
606 polygon->flags |= 0x10u; | |
607 | |
608 v28 = a2[1].vWorldPosition.x - a2->vWorldPosition.x; | |
609 v27 = a2[1].vWorldPosition.y - a2->vWorldPosition.y; | |
610 a3a = a2[1].vWorldPosition.z - a2->vWorldPosition.z; | |
611 | |
612 | |
613 for (int i = 0; i < numOfVertices; i++) | |
614 { | |
615 v7 = currVertex->vWorldPosition.x - a2->vWorldPosition.x; | |
616 v8 = currVertex->vWorldPosition.y - a2->vWorldPosition.y; | |
617 v9 = currVertex->vWorldPosition.z - a2->vWorldPosition.z; | |
618 v26 = v27 * v9 - v8 * a3a; | |
619 v24 = v7 * a3a - v9 * v28; | |
620 v25 = v8 * v28 - v7 * v27; | |
621 if ( v24 != 0.0 || v25 != 0.0 || v26 != 0.0 ) | |
622 break; | |
623 currVertex--; | |
624 } | |
625 | |
2543 | 626 if ( ((double)pIndoorCameraD3D->vPartyPos.x - a2->vWorldPosition.x) * v26 |
627 + ((double)pIndoorCameraD3D->vPartyPos.z - a2->vWorldPosition.z) * v25 | |
628 + ((double)pIndoorCameraD3D->vPartyPos.y - a2->vWorldPosition.y) * v24 > 0.0 ) | |
2496 | 629 { |
630 | |
631 v19 = a2[1].vWorldViewPosition.x - a2->vWorldViewPosition.x; | |
632 v18 = a2[1].vWorldViewPosition.y - a2->vWorldViewPosition.y; | |
633 v20 = a2[1].vWorldViewPosition.z - a2->vWorldViewPosition.z; | |
634 v21 = currVertex->vWorldViewPosition.x - a2->vWorldViewPosition.x; | |
635 v22 = currVertex->vWorldViewPosition.y - a2->vWorldViewPosition.y; | |
636 v23 = currVertex->vWorldViewPosition.z - a2->vWorldViewPosition.z; | |
637 | |
638 a3b = v23 * v18 - v22 * v20; | |
639 polygon->v_18.x = bankersRounding(a3b); | |
640 a3c = v21 * v20 - v23 * v19; | |
641 polygon->v_18.y = bankersRounding(a3c); | |
642 a3d = v22 * v19 - v21 * v18; | |
643 polygon->v_18.z = bankersRounding(a3d); | |
644 polygon->_normalize_v_18(); | |
645 a3e = -((double)polygon->v_18.x * a2->vWorldViewPosition.x) | |
646 - (double)polygon->v_18.y * a2->vWorldViewPosition.y | |
647 - (double)polygon->v_18.z * a2->vWorldViewPosition.z; | |
648 polygon->field_24 = bankersRounding(a3e); | |
649 return true; | |
650 } | |
651 else | |
652 return false; | |
653 } | |
654 | |
655 //----- (0047C7A9) -------------------------------------------------------- | |
656 void OutdoorLocationTerrain::_47C7A9() | |
657 { | |
658 this->field_10 = 0; | |
659 this->field_12 = 0; | |
660 this->field_16 = 0; | |
661 this->field_14 = 0; | |
662 this->field_1C = 0; | |
663 this->field_18 = 0; | |
664 } | |
665 | |
666 //----- (0047C7C2) -------------------------------------------------------- | |
667 void OutdoorLocationTerrain::Release()//очистить локацию | |
668 { | |
669 free(this->pHeightmap); | |
670 pHeightmap = nullptr; | |
671 free(pTilemap); | |
672 pTilemap = nullptr; | |
673 free(pAttributemap); | |
674 pAttributemap = nullptr; | |
675 free(pDmap); | |
676 pDmap = nullptr; | |
677 | |
678 _47C7A9(); | |
679 } | |
680 | |
681 //----- (0047C80A) -------------------------------------------------------- | |
682 void OutdoorLocationTerrain::FillDMap( int X, int Y, int W, int Z ) | |
683 { | |
684 double v6; // st7@1 | |
685 double v7; // st7@2 | |
686 double v8; // st7@2 | |
687 int result; // eax@3 | |
688 int v10; // eax@4 | |
689 int v11; // ecx@5 | |
690 int v12; // ecx@6 | |
691 int v13; // edi@7 | |
692 int v14; // edx@9 | |
693 // int v15; // eax@15 | |
694 unsigned __int8 *pMapHeight; // ebx@15 | |
695 int v17; // eax@15 | |
696 int v18; // ecx@15 | |
697 int v19; // esi@15 | |
698 int v20; // edi@15 | |
699 int v21; // edx@15 | |
700 int v22; // ecx@15 | |
701 int v23; // ebx@15 | |
702 int v24; // ecx@15 | |
703 int v25; // ST28_4@15 | |
704 double v26; // st7@15 | |
705 double v27; // st6@15 | |
706 double v28; // st5@15 | |
707 double v29; // st7@15 | |
708 double v30; // st7@16 | |
709 double v31; // st7@17 | |
710 int v32; // eax@21 | |
711 double v33; // st7@21 | |
712 double v34; // st6@21 | |
713 double v35; // st5@21 | |
714 double v36; // st7@21 | |
715 double v37; // st7@22 | |
716 double v38; // st7@23 | |
717 int v39; // [sp+14h] [bp-34h]@8 | |
718 int v40; // [sp+18h] [bp-30h]@15 | |
719 int v41; // [sp+1Ch] [bp-2Ch]@15 | |
720 int v42; // [sp+20h] [bp-28h]@15 | |
721 int v44; // [sp+28h] [bp-20h]@21 | |
722 float v45; // [sp+2Ch] [bp-1Ch]@1 | |
723 float v46; // [sp+30h] [bp-18h]@1 | |
724 float v47; // [sp+34h] [bp-14h]@1 | |
725 //int v48; // [sp+38h] [bp-10h]@7 | |
726 int v49; // [sp+3Ch] [bp-Ch]@10 | |
727 int v50; // [sp+40h] [bp-8h]@9 | |
728 float v51; // [sp+44h] [bp-4h]@15 | |
729 float v52; // [sp+44h] [bp-4h]@21 | |
730 float v53; // [sp+50h] [bp+8h]@15 | |
731 float v54; // [sp+50h] [bp+8h]@21 | |
732 // int v55; // [sp+54h] [bp+Ch]@15 | |
733 float v56; // [sp+54h] [bp+Ch]@15 | |
734 float v57; // [sp+54h] [bp+Ch]@21 | |
735 | |
736 v46 = -64.0; | |
737 v47 = -64.0; | |
738 v45 = 64.0; | |
739 v6 = sqrt(12288.0); | |
740 if ( v6 != 0.0 ) | |
741 { | |
742 v7 = 1.0 / v6; | |
743 v45 = 64.0 * v7; | |
744 v8 = v7 * -64.0; | |
745 v46 = v8; | |
746 v47 = v8; | |
747 } | |
748 result = Y; | |
749 if ( Y > Z ) | |
750 { | |
751 v10 = Z ^ Y; | |
752 Z ^= Y ^ Z; | |
753 result = Z ^ v10; | |
754 } | |
755 v11 = X; | |
756 if ( X > W ) | |
757 { | |
758 v12 = W ^ X; | |
759 W ^= X ^ W; | |
760 v11 = W ^ v12; | |
761 } | |
762 //v48 = result - 1; | |
763 if ( result - 1 <= Z ) | |
764 { | |
765 v39 = v11 - 1; | |
766 for ( v13 = result - 1; v13 <= Z; v13++ ) | |
767 { | |
768 v50 = v39; | |
769 if ( v39 <= W ) | |
770 { | |
771 result = (v39 - 63) << 9; | |
772 v49 = (v39 - 63) << 9; | |
773 for ( v14 = v39; v14 <= W; v14++ ) | |
774 { | |
775 if ( v13 >= 0 && result >= -32256 && v13 <= 127 && result <= 32768 ) | |
776 { | |
777 //v15 = pOutLocTerrain->field_10; | |
778 //v55 = pOutLocTerrain->field_10; | |
779 pMapHeight = this->pHeightmap; | |
780 v17 = (int)(&pMapHeight[v13 * this->field_10] + v14); | |
781 v18 = -v13; | |
782 v19 = (64 - v13) << 9; | |
783 v20 = 32 * *(char *)v17; | |
784 v21 = 32 * *(char *)(v17 + 1); | |
785 | |
786 v22 = (v18 + 63) << 9; | |
787 v41 = v22; | |
788 v23 = (int)(&pMapHeight[this->field_10 * (v13 + 1)] + v14); | |
789 v24 = v22 - v19; | |
790 v40 = 32 * *(char *)v23; | |
791 v42 = 32 * *(char *)(v23 + 1); | |
792 | |
793 v25 = v49 - 512 - v49; | |
794 v26 = (double)-((v20 - v21) * v24); | |
795 v51 = v26; | |
796 v27 = (double)-(v25 * (v42 - v21)); | |
797 v53 = v27; | |
798 v28 = (double)(v25 * v24); | |
799 v56 = v28; | |
800 v29 = sqrt(v28 * v28 + v27 * v27 + v26 * v26); | |
801 if ( v29 != 0.0 ) | |
802 { | |
803 v30 = 1.0 / v29; | |
804 v51 = v51 * v30; | |
805 v53 = v53 * v30; | |
806 v56 = v30 * v56; | |
807 } | |
808 v31 = (v56 * v47 + v53 * v46 + v51 * v45) * 31.0; | |
809 if ( v31 < 0.0 ) | |
810 v31 = 0.0; | |
811 if ( v31 > 31.0 ) | |
812 v31 = 31.0; | |
813 v44 = 2 * (v14 + v13 * this->field_10); | |
814 //pOutLocTerrain = pOutLocTerrain2; | |
815 *((char *)this->pDmap + v44 + 1) = (signed __int64)v31; | |
816 | |
817 v32 = v49 - (v49 - 512); | |
818 v33 = (double)-((v42 - v40) * (v19 - v41)); | |
819 v52 = v33; | |
820 v34 = (double)-(v32 * (v20 - v40)); | |
821 v54 = v34; | |
822 v35 = (double)(v32 * (v19 - v41)); | |
823 v57 = v35; | |
824 v36 = sqrt(v35 * v35 + v34 * v34 + v33 * v33); | |
825 if ( v36 != 0.0 ) | |
826 { | |
827 v37 = 1.0 / v36; | |
828 v52 = v52 * v37; | |
829 v54 = v54 * v37; | |
830 v57 = v37 * v57; | |
831 } | |
832 v38 = (v57 * v47 + v54 * v46 + v52 * v45) * 31.0; | |
833 if ( v38 < 0.0 ) | |
834 v38 = 0.0; | |
835 if ( v38 > 31.0 ) | |
836 v38 = 31.0; | |
837 //v13 = v48; | |
838 *((char *)this->pDmap + v44) = (signed __int64)v38; | |
839 //v14 = v50; | |
840 result = v49; | |
841 } | |
842 //++v14; | |
843 result += 512; | |
844 //v50 = v14; | |
845 v49 = result; | |
846 } | |
847 } | |
848 //++v13; | |
849 //v48 = v13; | |
850 } | |
851 //while ( v13 <= Z ); | |
852 } | |
853 } | |
854 | |
855 //----- (0047CB57) -------------------------------------------------------- | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2567
diff
changeset
|
856 int OutdoorLocationTerrain::_47CB57(unsigned char *pixels_8bit, int a2, int num_pixels) |
2496 | 857 { |
858 signed int result; // eax@2 | |
859 // unsigned __int16 *v5; // edx@3 | |
860 // double v6; // st7@3 | |
861 // int v8; // eax@3 | |
862 // int v9; // eax@4 | |
863 // int v10; // eax@5 | |
864 // double v11; // st6@7 | |
865 // signed int v12; // edi@7 | |
866 // int v13; // esi@9 | |
867 // char *v14; // esi@10 | |
868 // signed int v15; // ecx@10 | |
869 // char v16[256]; // [sp+4h] [bp-124h]@9 | |
870 // unsigned __int16 *v17; // [sp+104h] [bp-24h]@3 | |
871 // float v22; // [sp+118h] [bp-10h]@3 | |
872 // float v23; // [sp+11Ch] [bp-Ch]@3 | |
873 // int i; // [sp+120h] [bp-8h]@3 | |
874 // unsigned int v25; // [sp+124h] [bp-4h]@5 | |
875 // signed int a2a; // [sp+134h] [bp+Ch]@3 | |
876 // unsigned int a2b; // [sp+134h] [bp+Ch]@7 | |
877 // float a3a; // [sp+138h] [bp+10h]@7 | |
878 // int a3b; // [sp+138h] [bp+10h]@9 | |
879 | |
880 int num_r_bits = 5; | |
881 int num_g_bits = 6; | |
882 int num_b_bits = 5; | |
883 | |
884 int r_mask = 0xF800; | |
885 int g_mask = 0x7E0; | |
886 int b_mask = 0x1F; | |
887 | |
888 //if ( pRenderer->pRenderD3D ) | |
889 result = 0; | |
890 /*else | |
891 { | |
892 __debugbreak(); | |
893 v5 = PaletteManager::Get_Dark_or_Red_LUT(a2, 0, 1); | |
894 v6 = 0.0; | |
895 v22 = 0.0; | |
896 v8 = 0; | |
897 v17 = v5; | |
898 v23 = 0.0; | |
899 a2a = 0; | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2567
diff
changeset
|
900 for ( i = 0; i < num_pixels; ++i ) |
2496 | 901 { |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2567
diff
changeset
|
902 v9 = *(char *)(v8 + pixels_8bit); |
2496 | 903 if ( v9 ) |
904 { | |
905 v10 = v5[v9]; | |
906 v6 = v6 + (double)((signed int)(r_mask & v10) >> (num_b_bits + num_g_bits)); | |
907 ++a2a; | |
908 v25 = b_mask & v10; | |
909 v22 = (double)((signed int)(g_mask & v10) >> num_b_bits) + v22; | |
910 v23 = (double)(signed int)(b_mask & v10) + v23; | |
911 } | |
912 v8 = i + 1; | |
913 } | |
914 v11 = 1.0 / (double)a2a; | |
915 a3a = v11; | |
916 v25 = (signed __int64)(a3a * v22); | |
917 i = (signed __int64)(a3a * v23); | |
918 v12 = 0; | |
919 a2b = num_b_bits + num_g_bits; | |
920 while ( 1 ) | |
921 { | |
922 v13 = v17[v12]; | |
923 a3b = abs((__int64)(signed __int64)(v11 * v6) - ((signed int)(r_mask & v17[v12]) >> a2b)); | |
924 BYTE3(a3b) = abs((signed)v25 - ((signed int)(g_mask & v13) >> num_b_bits)) + a3b; | |
925 v16[v12++] = abs((signed)i - (signed)(b_mask & v13)) + BYTE3(a3b); | |
926 if ( v12 >= 256 ) | |
927 break; | |
928 } | |
929 result = 0; | |
930 v14 = (char *)&pPaletteManager->field_D1600[42][23][116]; | |
931 v15 = 0; | |
932 do | |
933 { | |
934 if ( (unsigned __int8)v16[v15] < (signed int)v14 ) | |
935 { | |
936 v14 = (char *)(unsigned __int8)v16[v15]; | |
937 result = v15; | |
938 } | |
939 ++v15; | |
940 } | |
941 while ( v15 < 256 ); | |
942 }*/ | |
943 return result; | |
944 } | |
945 | |
946 //----- (0047CCE2) -------------------------------------------------------- | |
947 bool OutdoorLocationTerrain::ZeroLandscape() | |
948 { | |
949 memset(this->pHeightmap, 0, 0x4000u); | |
950 memset(this->pTilemap, 90, 0x4000u); | |
951 memset(this->pAttributemap, 0, 0x4000u); | |
952 memset(this->pDmap, 0, 0x8000u); | |
953 this->field_12 = 128; | |
954 this->field_10 = 128; | |
955 this->field_16 = 7; | |
956 this->field_14 = 7; | |
957 this->field_1C = 127; | |
958 this->field_18 = 127; | |
959 return true; | |
960 } | |
961 | |
962 //----- (0047CD44) -------------------------------------------------------- | |
963 bool OutdoorLocationTerrain::Initialize() | |
964 { | |
2534 | 965 pHeightmap = (unsigned __int8 *)malloc(0x4000);//height map |
966 pTilemap = (unsigned __int8 *)malloc(0x4000);//tile map | |
967 pAttributemap = (unsigned __int8 *)malloc(0x4000);//карта атрибутов | |
968 pDmap = (struct DMap *)malloc(0x8000); | |
2496 | 969 if (pHeightmap && pTilemap && pAttributemap && pDmap ) |
970 return true; | |
971 else | |
972 return false; | |
973 } | |
974 | |
975 //----- (0047CDE2) -------------------------------------------------------- | |
976 void OutdoorLocation::CreateDebugLocation() | |
977 { | |
978 //OutdoorLocation *v1; // esi@1 | |
979 void *v2; // eax@1 | |
980 void *v3; // ST14_4@1 | |
981 void *v4; // eax@1 | |
982 void *v5; // ST14_4@1 | |
983 void *v6; // eax@1 | |
984 //unsigned int v7; // eax@1 | |
985 //char v8; // zf@1 | |
986 | |
987 //v1 = this; | |
988 strcpy(this->pLevelFilename, "blank"); | |
989 strcpy(this->pLocationFileName, "i6.odm"); | |
990 strcpy(this->pLocationFileDescription, "MM6 Outdoor v1.00"); | |
991 this->uNumBModels = 0; | |
992 this->pTileTypes[0].tileset = Tileset_Grass; | |
993 this->pTileTypes[1].tileset = Tileset_Water; | |
2534 | 994 this->pTileTypes[2].tileset = Tileset_Badlands; |
2496 | 995 this->pTileTypes[3].tileset = Tileset_RoadGrassCobble; |
996 this->LoadTileGroupIds(); | |
997 this->LoadRoadTileset(); | |
998 free(this->pBModels); | |
999 free(this->pSpawnPoints); | |
1000 this->pBModels = 0; | |
1001 this->pSpawnPoints = 0; | |
1002 this->pTerrain.Initialize(); | |
1003 this->pTerrain.ZeroLandscape(); | |
1004 this->pTerrain.FillDMap(0, 0, 128, 128); | |
1005 free(this->pCmap); | |
1006 this->pCmap = 0; | |
1007 v2 = malloc(0x8000u); | |
1008 v3 = this->pOMAP; | |
1009 this->pCmap = v2; | |
1010 free(v3); | |
1011 this->pOMAP = 0; | |
1012 v4 = malloc(0x10000u); | |
1013 this->pOMAP = (unsigned int *)v4; | |
1014 memset(v4, 0, 0x10000u); | |
1015 v5 = this->pFaceIDLIST; | |
1016 this->numFaceIDListElems = 0; | |
1017 free(v5); | |
1018 this->pFaceIDLIST = 0; | |
1019 v6 = malloc(2); | |
1020 this->pFaceIDLIST = (unsigned __int16 *)v6; | |
1021 *(short *)v6 = 0; | |
1022 strcpy(this->pSkyTextureName, pDefaultSkyTexture.data()); | |
1023 this->sSky_TextureID = pBitmaps_LOD->LoadTexture(this->pSkyTextureName); | |
1024 strcpy(this->pGroundTileset, byte_6BE124_cfg_textures_DefaultGroundTexture.data()); | |
1025 //v7 = pBitmaps_LOD->LoadTexture(this->pGroundTileset); | |
1026 this->sMainTile_BitmapID = pBitmaps_LOD->LoadTexture(this->pGroundTileset); | |
1027 | |
1028 if ( this->sSky_TextureID == -1 ) | |
1029 Error("Invalid Sky Tex Handle"); | |
1030 | |
1031 if ( this->sMainTile_BitmapID == -1 ) | |
1032 Error("Invalid Ground Tex Handle"); | |
1033 } | |
1034 | |
1035 //----- (0047CF9C) -------------------------------------------------------- | |
1036 void OutdoorLocation::Release() | |
1037 { | |
1038 strcpy(pLevelFilename, "blank"); | |
1039 strcpy(pLocationFileName, "default.odm"); | |
1040 strcpy(pLocationFileDescription, "MM6 Outdoor v1.00"); | |
1041 strcpy(pSkyTextureName, "sky043"); | |
1042 strcpy(pGroundTileset, "hm005"); | |
1043 | |
1044 if (pBModels) | |
1045 { | |
1046 for (uint i = 0; i < uNumBModels; ++i) | |
1047 pBModels[i].Release(); | |
1048 | |
1049 free(pBModels); | |
1050 pBModels = nullptr; | |
1051 uNumBModels = 0; | |
1052 } | |
1053 | |
1054 free(pSpawnPoints); | |
1055 pSpawnPoints = nullptr; | |
1056 uNumSpawnPoints = 0; | |
1057 | |
1058 pTerrain.Release(); | |
1059 | |
1060 free(pCmap); | |
1061 pCmap = nullptr; | |
1062 free(pOMAP); | |
1063 pOMAP = nullptr; | |
1064 free(pFaceIDLIST); | |
1065 pFaceIDLIST = nullptr; | |
1066 free(pTerrainNormals); | |
1067 pTerrainNormals = nullptr; | |
1068 } | |
1069 | |
1070 //----- (0047D0A6) -------------------------------------------------------- | |
1071 bool OutdoorLocation::Load(const char *pFilename, ODMFace *File, size_t pNumItems, int *thisa)//загрузка локации | |
1072 { | |
2534 | 1073 FILE *pFile; // eax@50 |
2496 | 1074 unsigned __int16 v62; // ax@65 |
1075 int v108; // [sp+0h] [bp-B80h]@10 | |
1076 char Src[968]; // [sp+10h] [bp-B70h]@110 | |
1077 char Dst[968]; // [sp+3D8h] [bp-7A8h]@50 | |
1078 char Str[256]; // [sp+7A0h] [bp-3E0h]@50 | |
1079 ODMHeader header; // [sp+B58h] [bp-28h]@50 | |
1080 char *Str2; // [sp+B74h] [bp-Ch]@12 | |
1081 | |
1082 //pOutdoorLocation = this; | |
1083 //strcpy(pContainer, pFilename); | |
1084 | |
1085 if (bUnderwater) | |
1086 { | |
1087 pPaletteManager->pPalette_tintColor[0] = 0x10; | |
1088 pPaletteManager->pPalette_tintColor[1] = 0xC2; | |
1089 pPaletteManager->pPalette_tintColor[2] = 0x99; | |
1090 pPaletteManager->SetMistColor(37, 143, 92); | |
1091 } | |
1092 else | |
1093 { | |
1094 pPaletteManager->pPalette_tintColor[0] = 0; | |
1095 pPaletteManager->pPalette_tintColor[1] = 0; | |
1096 pPaletteManager->pPalette_tintColor[2] = 0; | |
1097 if (pPaletteManager->pPalette_mistColor[0] != 0x80 || | |
1098 pPaletteManager->pPalette_mistColor[1] != 0x80 || | |
1099 pPaletteManager->pPalette_mistColor[2] != 0x80) | |
1100 { | |
1101 pPaletteManager->SetMistColor(128, 128, 128); | |
1102 pPaletteManager->RecalculateAll(); | |
1103 } | |
1104 } | |
1105 | |
1106 _6807E0_num_decorations_with_sounds_6807B8 = 0; | |
1107 /*sprintf(FileName, "levels\\%s", pContainer); | |
1108 if ( GetFileAttributesA(FileName) != -1 ) | |
1109 { | |
1110 result = (bool)fopen(FileName, "rb"); | |
1111 v7 = result; | |
1112 File = (ODMFace *)result; | |
1113 if ( !result ) | |
1114 return result; | |
1115 *(int *)thisa = 1; | |
1116 v8 = strlen(pContainer); | |
1117 v108 = 2; | |
1118 *((char *)&v139 + v8) = 0; | |
1119 viewparams->uTextureID_LocationMap = pIcons_LOD->LoadTexture(pContainer, (enum TEXTURE_TYPE)v108); | |
1120 fread(&DstBuf, 0x180u, 1u, (FILE *)v7); | |
1121 fseek((FILE *)v7, Offset, 0); | |
1122 fread(this, 0xB0u, 1u, (FILE *)v7); | |
1123 LoadTileGroupIds(); | |
1124 LoadRoadTileset(); | |
1125 strcpy(pGroundTileset, "grastyl"); | |
1126 fseek((FILE *)v7, v114, 0); | |
1127 fread(&uNumBModels, 4u, 1u, (FILE *)v7); | |
1128 fseek((FILE *)v7, v115, 0); | |
1129 fread(&uNumSpriteObjects, 4u, 1u, (FILE *)v7); | |
1130 fseek((FILE *)v7, v116, 0); | |
1131 fread(&uNumLevelDecorations, 4u, 1u, (FILE *)v7); | |
1132 fseek((FILE *)v7, v117, 0); | |
1133 fread(&uNumActors, 4u, 1u, (FILE *)v7); | |
1134 fseek((FILE *)v7, v118, 0); | |
1135 fread(&uNumChests, 4u, 1u, (FILE *)v7); | |
1136 pTerrain.Initialize(); | |
1137 fseek((FILE *)v7, v119, 0); | |
1138 fread(pTerrain.pHeightmap, 1u, 0x4000u, (FILE *)v7); | |
1139 fseek((FILE *)v7, v120, 0); | |
1140 fread(pTerrain.pTilemap, 1u, 0x4000u, (FILE *)v7); | |
1141 fseek((FILE *)v7, v121, 0); | |
1142 fread(pTerrain.pAttributemap, 1u, 0x4000u, (FILE *)v7); | |
1143 pTerrain._47C80A(0, 0, 128, 128); | |
1144 free(ptr_D4); | |
1145 ptr_D4 = 0; | |
1146 v9 = malloc(0, 0x8000u, "CMAP"); | |
1147 v108 = (int)pOMAP; | |
1148 ptr_D4 = v9; | |
1149 free((void *)v108); | |
1150 pOMAP = 0; | |
1151 v10 = malloc(0, 0x10000u, "OMAP"); | |
1152 v108 = 0; | |
1153 pOMAP = (unsigned int *)v10; | |
1154 fseek((FILE *)v7, v136, v108); | |
1155 fread(&uNumTerrainNormals, 4u, 1u, (FILE *)v7); | |
1156 fread(pTerrainSomeOtherData, 1u, 0x20000u, (FILE *)v7); | |
1157 fread(pTerrainNormalIndices, 1u, 0x10000u, (FILE *)v7); | |
1158 pTerrainNormals = (Vec3_float_ *)malloc(pTerrainNormals, 12 * uNumTerrainNormals, "TerNorm"); | |
1159 fread(pTerrainNormals, 1u, 12 * uNumTerrainNormals, (FILE *)v7); | |
1160 v11 = malloc(pBModels, 188 * uNumBModels, "BDdata"); | |
1161 v108 = 0; | |
1162 pBModels = (BSPModel *)v11; | |
1163 fseek((FILE *)v7, v122, v108); | |
1164 fread(pBModels, 0xBCu, uNumBModels, (FILE *)v7); | |
1165 fseek((FILE *)v7, v123, 0); | |
1166 pNumItems = 0; | |
1167 if ( (signed int)uNumBModels > 0 ) | |
1168 { | |
1169 v12 = 0; | |
1170 while ( 1 ) | |
1171 { | |
1172 pBModels[v12].pVertices.pVertices = 0; | |
1173 pBModels[v12].pFaces = 0; | |
1174 pBModels[v12].pFacesOrdering = 0; | |
1175 pBModels[v12].pNodes = 0; | |
1176 FileName[0] = 0; | |
1177 v108 = (int)&pBModels[v12]; | |
1178 sprintfex(FileName, "%s", v108); | |
1179 v13 = pBModels; | |
1180 v138 = 0; | |
1181 pBModels[v12].pVertices.pVertices = (Vec3_int_ *)malloc(v13[v12].pVertices.pVertices, 12 * v13[v12].pVertices.uNumVertices, | |
1182 FileName); | |
1183 pBModels[v12].pFaces = (ODMFace *)malloc(pBModels[v12].pFaces, 308 * pBModels[v12].uNumFaces, | |
1184 FileName); | |
1185 pBModels[v12].pFacesOrdering = (unsigned __int16 *)malloc(pBModels[v12].pFacesOrdering, | |
1186 2 * pBModels[v12].uNumFaces, FileName); | |
1187 v14 = malloc(pBModels[v12].pNodes, 8 * pBModels[v12].uNumNodes, FileName); | |
1188 v15 = pBModels; | |
1189 v108 = (int)File; | |
1190 v15[v12].pNodes = (BSPNode *)v14; | |
1191 fread(pBModels[v12].pVertices.pVertices, 0xCu, pBModels[v12].pVertices.uNumVertices, (FILE *)v108); | |
1192 fread(pBModels[v12].pFaces, 0x134u, pBModels[v12].uNumFaces, (FILE *)File); | |
1193 fread(pBModels[v12].pFacesOrdering, 2u, pBModels[v12].uNumFaces, (FILE *)File); | |
1194 fread(pBModels[v12].pNodes, 8u, pBModels[v12].uNumNodes, (FILE *)File); | |
1195 v16 = malloc(10 * pBModels[v12].uNumFaces); | |
1196 v107 = (int)File; | |
1197 v17 = pBModels; | |
1198 ptr = (FILE *)v16; | |
1199 fread(v16, 0xAu, v17[v12].uNumFaces, (FILE *)File); | |
1200 v18 = pBModels; | |
1201 Str2 = 0; | |
1202 if ( (signed int)v18[v12].uNumFaces > 0 ) | |
1203 break; | |
1204 LABEL_25: | |
1205 free(ptr); | |
1206 ++pNumItems; | |
1207 ++v12; | |
1208 if ( (signed int)pNumItems >= (signed int)uNumBModels ) | |
1209 goto LABEL_26; | |
1210 } | |
1211 pDestLen = 0; | |
1212 pFilename = (char *)ptr; | |
1213 while ( 1 ) | |
1214 { | |
1215 thisa = (int)((char *)v18[v12].pFaces + pDestLen); | |
1216 if ( !(*(char *)(thisa + 29) & 0x40) ) | |
1217 break; | |
1218 v19 = pTextureFrameTable->FindTextureByName(pFilename); | |
1219 *(short *)(thisa + 272) = v19; | |
1220 if ( !v19 ) | |
1221 { | |
1222 v20 = pBitmaps_LOD->LoadTexture(pFilename); | |
1223 v21 = thisa; | |
1224 *(char *)(v21 + 29) &= 0xBFu; | |
1225 LABEL_19: | |
1226 *(short *)(v21 + 272) = v20; | |
1227 v149 = (void *)(v20 != -1 ? &pBitmaps_LOD->pTextures[v20] : 0); | |
2574 | 1228 auto pTex = (Texture_MM7 *)v149; |
2496 | 1229 if (pTex) |
1230 pTex->palette_id2 = pPaletteManager->LoadPalette(pTex->palette_id1); | |
1231 goto LABEL_20; | |
1232 } | |
1233 pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(unsigned __int16 *)((char *)&pBModels[v12].pFaces->uTextureID + pDestLen)); | |
1234 LABEL_20: | |
1235 if ( *(short *)(thisa + 292) ) | |
1236 { | |
1237 if ( ((ODMFace *)thisa)->HasEventHint() ) | |
1238 *(char *)(thisa + 30) |= 0x10u; | |
1239 else | |
1240 *(char *)(thisa + 30) &= 0xEFu; | |
1241 } | |
1242 ++Str2; | |
1243 v18 = pBModels; | |
1244 pDestLen += 308; | |
1245 pFilename += 10; | |
1246 if ( (signed int)Str2 >= (signed int)v18[v12].uNumFaces ) | |
1247 goto LABEL_25; | |
1248 } | |
1249 v20 = pBitmaps_LOD->LoadTexture(pFilename); | |
1250 v21 = thisa; | |
1251 goto LABEL_19; | |
1252 } | |
1253 LABEL_26: | |
1254 v22 = File; | |
1255 fseek((FILE *)File, v124, 0); | |
1256 fread(pSpriteObjects, 0x70u, uNumSpriteObjects, (FILE *)v22); | |
1257 if ( (signed int)uNumSpriteObjects > 0 ) | |
1258 { | |
1259 pItems = pSpriteObjects; | |
1260 pNumItems = uNumSpriteObjects; | |
1261 do | |
1262 { | |
1263 v24 = pItems->stru_24.uItemID; | |
1264 thisa = 0; | |
1265 v27 = (ODMFace *)(48 * v24); | |
1266 v25 = pObjectList->uNumObjects == 0; | |
1267 v26 = (pObjectList->uNumObjects & 0x80000000u) != 0; | |
1268 LOWORD(v27) = *(short *)((char *)&v27->pFacePlane.vNormal.x + (int)((char *)&pItemsTable + 24)); | |
1269 File = v27; | |
1270 pItems->uItemType = (unsigned __int16)v27; | |
1271 if ( v26 | v25 ) | |
1272 { | |
1273 LABEL_33: | |
1274 v29 = 0; | |
1275 } | |
1276 else | |
1277 { | |
1278 for ( i = (const char *)&pObjectList->pObjects->uObjectID; (short)v27 != *(short *)i; i = pFilename ) | |
1279 { | |
1280 ++thisa; | |
1281 pFilename = (char *)i + 56; | |
1282 if ( thisa >= (signed int)pObjectList->uNumObjects ) | |
1283 goto LABEL_33; | |
1284 LOWORD(v27) = (short)File; | |
1285 } | |
1286 v29 = thisa; | |
1287 } | |
1288 pItems->uObjectDescID = v29; | |
1289 ++pItems; | |
1290 --pNumItems; | |
1291 } | |
1292 while ( pNumItems ); | |
1293 } | |
1294 fseek((FILE *)v22, v125, 0); | |
1295 fread(pLevelDecorations, 0x20u, uNumLevelDecorations, (FILE *)v22); | |
1296 pNumItems = 0; | |
1297 if ( (signed int)uNumLevelDecorations > 0 ) | |
1298 { | |
1299 thisa = (int)pLevelDecorations; | |
1300 do | |
1301 { | |
1302 fread(FileName, 1u, 0x20u, (FILE *)v22); | |
1303 v30 = pDecorationList->GetDecorIdByName(FileName); | |
1304 v31 = thisa; | |
1305 ++pNumItems; | |
1306 thisa += 32; | |
1307 *(short *)v31 = v30; | |
1308 } | |
1309 while ( (signed int)pNumItems < (signed int)uNumLevelDecorations ); | |
1310 } | |
1311 fseek((FILE *)v22, v126, 0); | |
1312 fread(pActors, 0x344u, uNumActors, (FILE *)v22); | |
1313 fseek((FILE *)v22, v127, 0); | |
1314 fread(pChests, 0x14CCu, uNumChests, (FILE *)v22); | |
1315 fseek((FILE *)v22, v128, 0); | |
1316 fread(&field_DC, 4u, 1u, (FILE *)v22); | |
1317 free(pFaceIDLIST); | |
1318 v32 = field_DC; | |
1319 pFaceIDLIST = 0; | |
1320 v33 = malloc(0, 2 * v32, "IDLIST"); | |
1321 v108 = (int)v22; | |
1322 pFaceIDLIST = (unsigned __int16 *)v33; | |
1323 fread(v33, 2u, field_DC, (FILE *)v108); | |
1324 fseek((FILE *)v22, v129, 0); | |
1325 fread(pOMAP, 4u, 0x4000u, (FILE *)v22); | |
1326 fseek((FILE *)v22, v130, 0); | |
1327 fread(&uNumSpawnPoints, 4u, 1u, (FILE *)v22); | |
1328 pSpawnPoints = (SpawnPointMM7 *)malloc(pSpawnPoints, 24 * uNumSpawnPoints, "Spawn"); | |
1329 fseek((FILE *)v22, v131, 0); | |
1330 fread(pSpawnPoints, 0x18u, uNumSpawnPoints, (FILE *)v22); | |
1331 fseek((FILE *)v22, v132, 0); | |
1332 fread(&ddm, 0x28u, 1u, (FILE *)v22); | |
1333 fseek((FILE *)v22, v133, 0); | |
1334 fread(&stru_5E4C90, 1u, 0xC8u, (FILE *)v22); | |
1335 fseek((FILE *)v22, v134, 0); | |
1336 fread(&uLastVisitDay, 1u, 0x38u, (FILE *)v22); | |
1337 fseek((FILE *)v22, v135, 0); | |
1338 fread(&uLastVisitDay, 1u, 4u, (FILE *)v22); | |
1339 thisa = (int)pTileTypes; | |
1340 pTileTable->InitializeTileset(4); | |
1341 pTileTable->InitializeTileset(pTileTypes[0].uTileGroup); | |
1342 pTileTable->InitializeTileset(pTileTypes[1].uTileGroup); | |
1343 pTileTable->InitializeTileset(pTileTypes[2].uTileGroup); | |
1344 pTileTable->InitializeTileset(pTileTypes[3].uTileGroup); | |
1345 if ( this != (OutdoorLocation *)-96 && pSkyTextureName[0] ) | |
1346 { | |
1347 v108 = 0; | |
1348 v107 = (int)pSkyTextureName; | |
1349 } | |
1350 else | |
1351 { | |
1352 v108 = 0; | |
1353 v107 = (int)pDefaultSkyTexture; | |
1354 } | |
1355 sSky_TextureID = pBitmaps_LOD->LoadTexture((const char *)v107, (enum TEXTURE_TYPE)v108); | |
1356 strcpy(pGroundTileset, byte_6BE124_cfg_textures_DefaultGroundTexture); | |
1357 v34 = pTileTable->GetTileById(pTileTypes[0].uTileID); | |
1358 v35 = pBitmaps_LOD->LoadTexture(v34->pTileName); | |
1359 v36 = sSky_TextureID; | |
1360 sMainTile_BitmapID = v35; | |
1361 if ( v36 != -1 ) | |
1362 pBitmaps_LOD->pTextures[v36].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v36].palette_id1); | |
1363 | |
1364 v37 = sMainTile_BitmapID; | |
1365 if ( v37 != -1 ) | |
1366 pBitmaps_LOD->pTextures[v37].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v37].palette_id1); | |
1367 | |
1368 _47F0E2(); | |
1369 pGameLoadingUI_ProgressBar->Progress(); | |
1370 fclose((FILE *)v22); | |
1371 goto LABEL_150; | |
1372 }*/ | |
1373 | |
1374 assert(sizeof(BSPModel) == 188); | |
1375 | |
1376 if (!pGames_LOD->DoesContainerExist(pFilename)) | |
1377 Error("Unable to find %s in Games.LOD", pFilename); | |
1378 | |
1379 | |
1380 char pMinimapTextureFilename[1024]; | |
1381 strcpy(pMinimapTextureFilename, pFilename); | |
1382 pMinimapTextureFilename[strlen(pMinimapTextureFilename) - 4] = 0; | |
1383 viewparams->uTextureID_LocationMap = pIcons_LOD->LoadTexture(pMinimapTextureFilename, TEXTURE_16BIT_PALETTE); | |
1384 | |
1385 //strcpy(FileName, pContainer); | |
1386 strcpy(Str, pFilename); | |
1387 strcpy(Str + strlen(Str) - 4, ".odm"); | |
1388 //v141 = &v139; | |
1389 //v38 = strlen(pFilename); | |
1390 //strcpy((char *)&v139 + v38, ".odm"); | |
2534 | 1391 pFile = pGames_LOD->FindContainer(Str, true); |
2496 | 1392 //Str[strlen(Str) - 4] = 0; |
1393 | |
1394 header.uCompressedSize = 0; | |
1395 header.uDecompressedSize = 0; | |
1396 //ptr = v39; | |
1397 header.uVersion = 91969; | |
1398 header.pMagic[0] = 'm'; | |
1399 header.pMagic[1] = 'v'; | |
1400 header.pMagic[2] = 'i'; | |
1401 header.pMagic[3] = 'i'; | |
2534 | 1402 fread(&header, 0x10, 1, pFile); |
2496 | 1403 if (header.uVersion != 91969 || |
1404 header.pMagic[0] != 'm' || | |
1405 header.pMagic[1] != 'v' || | |
1406 header.pMagic[2] != 'i' || | |
1407 header.pMagic[3] != 'i') | |
1408 { | |
1409 MessageBoxW(nullptr, L"Can't load file!", | |
1410 L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:507", 0); | |
1411 } | |
1412 //v40 = header.uCompressedSize; | |
1413 //pSource = header.uDecompressedSize; | |
1414 //v41 = malloc(header.uDecompressedSize); | |
1415 uchar* pSrcMem = (unsigned char *)malloc(header.uDecompressedSize); | |
1416 uchar* pSrc = pSrcMem; | |
1417 //v42 = v41; | |
1418 //HIDWORD(v142) = (uint32)pSrc; | |
1419 if (header.uCompressedSize < header.uDecompressedSize) | |
1420 { | |
1421 char* pComressedSrc = (char *)malloc(header.uCompressedSize); | |
2534 | 1422 fread(pComressedSrc, header.uCompressedSize, 1, pFile); |
2496 | 1423 |
1424 uint actualDecompressedSize = header.uDecompressedSize; | |
1425 zlib::MemUnzip(pSrc, &actualDecompressedSize, pComressedSrc, header.uCompressedSize); | |
1426 free(pComressedSrc); | |
1427 } | |
1428 else | |
1429 { | |
2534 | 1430 fread(pSrc, header.uDecompressedSize, 1, pFile); |
2496 | 1431 } |
1432 | |
1433 memcpy(pLevelFilename, pSrc, 0x20); | |
1434 memcpy(pLocationFileName, pSrc + 0x20, 0x20); | |
1435 memcpy(pLocationFileDescription, pSrc + 0x40, 0x20); | |
1436 memcpy(pSkyTextureName, pSrc + 3 * 32, 32); | |
1437 memcpy(pGroundTileset, pSrc + 0x80, 0x20); | |
1438 memcpy(pTileTypes, pSrc + 0xA0, 0x10); | |
1439 pSrc += 0xB0; | |
1440 | |
1441 //v43 = (char *)pSrc + 176; | |
1442 LoadTileGroupIds(); | |
1443 LoadRoadTileset(); | |
1444 strcpy(pGroundTileset, "grastyl"); | |
2534 | 1445 |
1446 pGameLoadingUI_ProgressBar->Progress(); //прогресс загрузки | |
1447 | |
1448 //*******************Terrain**************************// | |
2496 | 1449 pTerrain.Initialize(); |
2534 | 1450 memcpy(pTerrain.pHeightmap, pSrc, 0x4000); //карта высот |
2496 | 1451 pSrc += 0x4000; |
1452 | |
2534 | 1453 memcpy(pTerrain.pTilemap, pSrc, 0x4000); //карта тайлов |
2496 | 1454 pSrc += 0x4000; |
1455 | |
2534 | 1456 memcpy(pTerrain.pAttributemap, pSrc, 0x4000); // карта аттрибутов |
2496 | 1457 pSrc += 0x4000; |
1458 | |
1459 //v43 = (char *)v43 + 16384; | |
1460 //v108 = (int)ptr_D4; | |
1461 free(pCmap); | |
1462 pCmap = malloc(0x8000); | |
2534 | 1463 pTerrain.FillDMap(0, 0, 128, 128); // |
1464 | |
1465 pGameLoadingUI_ProgressBar->Progress(); //прогресс загрузки | |
1466 | |
1467 memcpy(&uNumTerrainNormals, pSrc, 4); // количество нормалей | |
2496 | 1468 memcpy(pTerrainSomeOtherData.data(), pSrc + 4, 0x20000); |
1469 pSrc += 4 + 0x20000; | |
1470 //v43 = (char *)v43 + 131072; | |
2534 | 1471 memcpy(pTerrainNormalIndices.data(), pSrc, 0x10000); //индексы нормалей |
2496 | 1472 pSrc += 0x10000; |
1473 //v43 = (char *)v43 + 65536; | |
1474 | |
1475 //pFilename = (char *)(12 * uNumTerrainNormals); | |
2534 | 1476 pTerrainNormals = (Vec3_float_ *)malloc(sizeof(Vec3_float_) * uNumTerrainNormals);//карта нормалей |
2496 | 1477 memcpy(pTerrainNormals, pSrc, 12 * uNumTerrainNormals); |
1478 pSrc += 12 * uNumTerrainNormals; | |
1479 //v44 = (char *)v43 + (int)pFilename; | |
1480 //v44 = (char *)v44 + 4; | |
1481 //v45 = uNumBModels; | |
1482 //v108 = (int)"BDdata"; | |
1483 | |
2534 | 1484 pGameLoadingUI_ProgressBar->Progress(); //прогресс загрузки |
1485 | |
1486 //************BModels************************// | |
2496 | 1487 //v107 = 188 * v45; |
1488 //v106 = (char *)pBModels; | |
1489 //v46 = (BSPModel *)malloc(v106, 188 * v45, "BDdata"); | |
1490 //v47 = uNumBModels; | |
2534 | 1491 memcpy(&uNumBModels, pSrc, 4); //количество BModel'ей |
2496 | 1492 pBModels = (BSPModel *)malloc(188 * uNumBModels); |
2534 | 1493 memcpy(pBModels, pSrc + 4, 188 * uNumBModels); //BModel'и |
2496 | 1494 pSrc += 4 + 188 * uNumBModels; |
1495 | |
2534 | 1496 pGameLoadingUI_ProgressBar->Progress(); //прогресс загрузки |
2496 | 1497 |
1498 //uSourceLen = (char *)v44 + (int)pFilename; | |
1499 //v151 = 0; | |
1500 for (uint i = 0; i < uNumBModels; ++i) | |
1501 { | |
1502 //v48 = 0; | |
1503 //BSPModel* model = &pBModels[i]; | |
1504 | |
1505 pBModels[i].pVertices.pVertices = nullptr; | |
1506 pBModels[i].pFaces = nullptr; | |
1507 pBModels[i].pFacesOrdering = nullptr; | |
1508 pBModels[i].pNodes = nullptr; | |
1509 //FileName[0] = 0; | |
1510 //v108 = (int)&pBModels[i]; | |
1511 //sprintf(FileName, "%s", v108); | |
1512 //v49 = pBModels; | |
1513 //v138 = 0; | |
1514 //v50 = &pBModels[v48]; | |
1515 //v108 = (int)FileName; | |
1516 //v107 = 12 * v50->pVertices.uNumVertices; | |
1517 //v106 = (char *)v50->pVertices.pVertices; | |
1518 assert(sizeof(Vec3_int_) == 12); | |
1519 uint verticesSize = pBModels[i].pVertices.uNumVertices * sizeof(Vec3_int_); | |
1520 pBModels[i].pVertices.pVertices = (Vec3_int_ *)malloc(verticesSize); | |
1521 memcpy(pBModels[i].pVertices.pVertices, pSrc, verticesSize); | |
1522 pSrc += verticesSize; | |
1523 //v51 = &pBModels[v48]; | |
1524 //v108 = (int)FileName; | |
1525 //v107 = 308 * v51->uNumFaces; | |
1526 //v106 = (char *)v51->pFaces; | |
1527 assert(sizeof(ODMFace) == 308); | |
1528 uint facesSize = pBModels[i].uNumFaces * sizeof(ODMFace); | |
1529 pBModels[i].pFaces = (ODMFace *)malloc(facesSize); | |
1530 memcpy(pBModels[i].pFaces, pSrc, facesSize); | |
1531 pSrc += facesSize; | |
1532 //v52 = &pBModels[v48]; | |
1533 //v108 = (int)FileName; | |
1534 //v107 = 2 * v52->uNumFaces; | |
1535 //v106 = (char *)v52->pFacesOrdering; | |
1536 uint facesOrderingSize = pBModels[i].uNumFaces * sizeof(short); | |
1537 pBModels[i].pFacesOrdering = (unsigned __int16 *)malloc(facesOrderingSize); | |
1538 memcpy(pBModels[i].pFacesOrdering, pSrc, facesOrderingSize); | |
1539 pSrc += facesOrderingSize; | |
1540 //v53 = &pBModels[v48]; | |
1541 //v108 = (int)FileName; | |
1542 //v107 = 8 * v53->uNumNodes; | |
1543 //v106 = (char *)v53->pNodes; | |
1544 assert(sizeof(BSPNode) == 8); | |
1545 uint nodesSize = pBModels[i].uNumNodes * sizeof(BSPNode); | |
1546 pBModels[i].pNodes = (BSPNode *)malloc(nodesSize); | |
1547 memcpy(pBModels[i].pNodes, pSrc, nodesSize); | |
1548 pSrc += nodesSize; | |
1549 //v54 = &pBModels[v48]; | |
1550 //v108 = 12 * v54->pVertices.uNumVertices; | |
1551 //pFilename = (char *)v108; | |
1552 //v107 = (int)uSourceLen; | |
1553 //v106 = (char *)v54->pVertices.pVertices; | |
1554 //memcpy(v106, uSourceLen, v108); | |
1555 //uSourceLen = (char *)uSourceLen + (int)pFilename; | |
1556 //v55 = &pBModels[v48]; | |
1557 //v105 = 308 * v55->uNumFaces; | |
1558 //v104 = uSourceLen; | |
1559 //v103 = v55->pFaces; | |
1560 //pFilename = (char *)v105; | |
1561 //memcpy(v103, uSourceLen, v105); | |
1562 //v56 = &pBModels[v48]; | |
1563 //uSourceLen = (char *)uSourceLen + (int)pFilename; | |
1564 //v57 = v56->pFacesOrdering; | |
1565 //pFilename = (char *)(2 * v56->uNumFaces); | |
1566 //memcpy(v57, uSourceLen, (size_t)pFilename); | |
1567 //v58 = &pBModels[v48]; | |
1568 //uSourceLen = (char *)uSourceLen + (int)pFilename; | |
1569 //v59 = v58->pNodes; | |
1570 //pFilename = (char *)(8 * v58->uNumNodes); | |
1571 //memcpy(v59, uSourceLen, (size_t)pFilename); | |
1572 //uSourceLen = (char *)uSourceLen + (int)pFilename; | |
1573 //ptr = (FILE *)malloc(10 * model->uNumFaces); | |
1574 const char* textureFilenames = (const char *)malloc(10 * pBModels[i].uNumFaces); | |
1575 //pFilename = (char *)(10 * pBModels[v48].uNumFaces); | |
1576 memcpy((char *)textureFilenames, pSrc, 10 * pBModels[i].uNumFaces); | |
1577 pSrc += 10 * pBModels[i].uNumFaces; | |
1578 //v144 = 0; | |
1579 //uSourceLen = (char *)uSourceLen + (int)pFilename; | |
1580 //v60 = pBModels; | |
1581 for (uint j = 0; j < pBModels[i].uNumFaces; ++j) | |
1582 { | |
1583 const char* texFilename = &textureFilenames[j * 10]; | |
1584 //v149 = 0; | |
1585 //Str2 = (char *)ptr; | |
1586 | |
1587 //ODMFace* face = &pBModels[i].pFaces[j]; | |
1588 //pFilename = (char *)v149 + (unsigned int)v60[v48].pFaces; | |
1589 if ( !(pBModels[i].pFaces[j].uAttributes & FACE_DONT_CACHE_TEXTURE)) | |
1590 { | |
1591 v62 = pBitmaps_LOD->LoadTexture(texFilename); | |
1592 // v63 = (ODMFace *)pFilename; | |
1593 pBModels[i].pFaces[j].uTextureID = v62; | |
1594 //v145 = (signed __int16)v62 != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62] : 0; | |
1595 //v108 = ((signed __int16)v62 != -1 ? pBitmaps_LOD->pTextures[(signed __int16)v62].palette_id1 : 36); | |
1596 if ((signed __int16)v62 != -1) | |
1597 pBitmaps_LOD->pTextures[v62].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v62].palette_id1); | |
1598 //goto LABEL_69; | |
1599 //goto LABEL_68; | |
1600 } | |
1601 else | |
1602 { | |
1603 //v61 = pTextureFrameTable->FindTextureByName(texFilename); | |
1604 pBModels[i].pFaces[j].uTextureID = pTextureFrameTable->FindTextureByName(texFilename); | |
1605 if (!pBModels[i].pFaces[j].uTextureID) | |
1606 { | |
1607 v62 = pBitmaps_LOD->LoadTexture(texFilename); | |
1608 //v63 = (ODMFace *)pFilename; | |
1609 pBModels[i].pFaces[j].uAttributes &= ~FACE_DONT_CACHE_TEXTURE; | |
1610 //LABEL_68: | |
1611 pBModels[i].pFaces[j].uTextureID = v62; | |
1612 //v145 = (signed __int16)v62 != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62] : 0; | |
1613 //v108 = ((signed __int16)v62 != -1 ? pBitmaps_LOD->pTextures[(signed __int16)v62].palette_id1 : 36); | |
1614 if ((signed __int16)v62 != -1) | |
1615 pBitmaps_LOD->pTextures[v62].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v62].palette_id1); | |
1616 //goto LABEL_69; | |
1617 } | |
1618 else | |
1619 pTextureFrameTable->LoadAnimationSequenceAndPalettes(pBModels[i].pFaces[j].uTextureID); | |
1620 } | |
1621 //LABEL_69: | |
1622 if (pBModels[i].pFaces[j].sCogTriggeredID) | |
1623 { | |
1624 if (pBModels[i].pFaces[j].HasEventHint()) | |
1625 pBModels[i].pFaces[j].uAttributes |= FACE_HAS_EVENT; | |
1626 else | |
1627 pBModels[i].pFaces[j].uAttributes &= ~FACE_HAS_EVENT; | |
1628 } | |
1629 //++v144; | |
1630 //v60 = pBModels; | |
1631 //v149 = (char *)v149 + 308; | |
1632 //Str2 += 10; | |
1633 //if ( v144 >= (signed int)v60[v48].uNumFaces ) | |
1634 //goto LABEL_74; | |
1635 } | |
1636 | |
1637 //LABEL_74: | |
1638 free((void *)textureFilenames); | |
1639 // ++v151; | |
1640 // ++v48; | |
1641 // if ( v151 >= (signed int)uNumBModels ) | |
1642 // goto LABEL_75; | |
1643 } | |
1644 //LABEL_75: | |
2534 | 1645 pGameLoadingUI_ProgressBar->Progress(); //прогресс загрузки |
1646 | |
1647 //******************Decorations**********************// | |
2496 | 1648 memcpy(&uNumLevelDecorations, pSrc, 4); |
1649 //uSourceLen = (char *)uSourceLen + 4; | |
1650 if (uNumLevelDecorations > 3000) | |
1651 MessageBoxW(nullptr, L"Can't load file!", | |
1652 L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:678", 0); | |
1653 | |
1654 assert(sizeof(LevelDecoration) == 32); | |
1655 //pFilename = (char *)(32 * uNumLevelDecorations); | |
1656 memcpy(pLevelDecorations.data(), pSrc + 4, uNumLevelDecorations * sizeof(LevelDecoration)); | |
1657 pSrc += 4 + sizeof(LevelDecoration) * uNumLevelDecorations; | |
1658 | |
1659 pGameLoadingUI_ProgressBar->Progress(); | |
1660 | |
1661 //v151 = 0; | |
1662 //uSourceLen = (char *)uSourceLen + (int)pFilename; | |
1663 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
1664 { | |
1665 char name[256]; | |
1666 memcpy(name, pSrc, sizeof(LevelDecoration)); | |
1667 pSrc += sizeof(LevelDecoration); | |
1668 | |
1669 pLevelDecorations[i].uDecorationDescID = pDecorationList->GetDecorIdByName(name); | |
1670 } | |
1671 | |
2534 | 1672 pGameLoadingUI_ProgressBar->Progress(); //прогресс загрузки |
2496 | 1673 |
1674 memcpy(&numFaceIDListElems, pSrc, 4); | |
1675 | |
1676 //uSourceLen = (char *)uSourceLen + 4; | |
1677 //v108 = (int)pFaceIDLIST; | |
1678 free(pFaceIDLIST); | |
1679 pFaceIDLIST = nullptr; | |
1680 //v66 = field_DC; | |
1681 //pFaceIDLIST = 0; | |
1682 //v67 = malloc(0, 2 * v66, "IDLIST"); | |
1683 uint faceIDListSize = 2 * numFaceIDListElems; | |
1684 pFaceIDLIST = (unsigned short *)malloc(faceIDListSize); | |
1685 //v68 = field_DC; | |
1686 //pFaceIDLIST = (unsigned __int16 *)v67; | |
1687 //pFilename = (char *)(2 * v68); | |
1688 memcpy(pFaceIDLIST, pSrc + 4, faceIDListSize); | |
1689 pSrc += 4 + faceIDListSize; | |
1690 | |
1691 //uSourceLen = (char *)uSourceLen + (int)pFilename; | |
2534 | 1692 pGameLoadingUI_ProgressBar->Progress(); //прогресс загрузки |
2496 | 1693 |
1694 //v108 = (int)pOMAP; | |
1695 //free((void *)v108); | |
1696 //pOMAP = 0; | |
1697 free(pOMAP); | |
1698 //v69 = malloc(0, 0x10000u, "OMAP"); | |
1699 pOMAP = (unsigned int *)malloc(0x10000); | |
1700 //v108 = 65536; | |
1701 //pOMAP = (unsigned int *)v69; | |
1702 memcpy(pOMAP, pSrc, 65536); | |
1703 pSrc += 65536; | |
1704 | |
1705 //uSourceLen = (char *)uSourceLen + 65536; | |
1706 pGameLoadingUI_ProgressBar->Progress(); | |
1707 | |
1708 memcpy(&uNumSpawnPoints, pSrc, 4); | |
1709 //uSourceLen = (char *)uSourceLen + 4; | |
2534 | 1710 pGameLoadingUI_ProgressBar->Progress(); //прогресс загрузки |
2496 | 1711 //v70 = uNumSpawnPoints; |
1712 //v108 = (int)"Spawn"; | |
1713 //v107 = 24 * v70; | |
1714 //v106 = (char *)pSpawnPoints; | |
1715 assert(sizeof(SpawnPointMM7) == 24); | |
1716 uint spawnPointsSize = uNumSpawnPoints * sizeof(SpawnPointMM7); | |
1717 pSpawnPoints = (SpawnPointMM7 *)malloc(spawnPointsSize); | |
1718 //v72 = uNumSpawnPoints; | |
1719 //pSpawnPoints = v71; | |
1720 memcpy(pSpawnPoints, pSrc + 4, spawnPointsSize); | |
1721 pSrc += 4 + spawnPointsSize; | |
1722 | |
2534 | 1723 pGameLoadingUI_ProgressBar->Progress(); //прогресс загрузки |
1724 | |
1725 //****************.ddm file*********************// | |
2496 | 1726 free(pSrcMem); |
1727 strcpy(Str + strlen(Str) - 4, ".ddm"); | |
2534 | 1728 pFile = pNew_LOD->FindContainer(Str, 1); |
1729 fread(&header, 0x10, 1, pFile); | |
2496 | 1730 Str2 = 0; |
1731 if (header.uVersion != 91969 || | |
1732 header.pMagic[0] != 'm' || | |
1733 header.pMagic[1] != 'v' || | |
1734 header.pMagic[2] != 'i' || | |
1735 header.pMagic[3] != 'i' ) | |
1736 { | |
1737 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:746", 0); | |
1738 Str2 = (char *)1; | |
1739 } | |
1740 //v74 = 0; | |
1741 //pFilename = (char *)header.uCompressedSize; | |
1742 //v149 = 0; | |
1743 //pDestLen = header.uDecompressedSize; | |
1744 if ( !Str2 ) | |
1745 { | |
1746 pSrcMem = (unsigned char *)malloc(header.uDecompressedSize); | |
1747 pSrc = pSrcMem; | |
1748 //v149 = v75; | |
1749 if (header.uCompressedSize == header.uDecompressedSize) | |
2534 | 1750 fread(pSrc, header.uDecompressedSize, 1, pFile); |
2496 | 1751 else if (header.uCompressedSize < header.uDecompressedSize) |
1752 { | |
1753 void* compressedMem = malloc(header.uCompressedSize); | |
2534 | 1754 fread(compressedMem, header.uCompressedSize, 1, pFile); |
2496 | 1755 |
1756 uint actualDecompressedSize = header.uDecompressedSize; | |
1757 zlib::MemUnzip(pSrc, &actualDecompressedSize, compressedMem, header.uCompressedSize); | |
1758 free(compressedMem); | |
1759 } | |
1760 else | |
2534 | 1761 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:765", 0); |
2496 | 1762 |
1763 assert(sizeof(DDM_DLV_Header) == 0x28); | |
1764 memcpy(&ddm, pSrc, sizeof(DDM_DLV_Header)); | |
1765 pSrc += sizeof(DDM_DLV_Header); | |
1766 //v74 = (int)((char *)v75 + 40); | |
1767 } | |
1768 uint actualNumFacesInLevel = 0; | |
1769 for (uint i = 0; i < uNumBModels; ++i) | |
1770 actualNumFacesInLevel += pBModels[i].uNumFaces; | |
1771 | |
1772 if (ddm.uNumFacesInBModels) | |
1773 { | |
1774 if ( ddm.uNumBModels ) | |
1775 { | |
1776 if (ddm.uNumDecorations) | |
1777 { | |
1778 if (ddm.uNumFacesInBModels != actualNumFacesInLevel || | |
1779 ddm.uNumBModels != uNumBModels || | |
1780 ddm.uNumDecorations != uNumLevelDecorations ) | |
1781 Str2 = (char *)1; | |
1782 } | |
1783 } | |
1784 } | |
1785 | |
1786 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_2000) | |
1787 pNumItems = 0x1BAF800; | |
1788 | |
1789 if (Str2 || ((unsigned int)((char *)File - ddm.uLastRepawnDay) >= pNumItems || !ddm.uLastRepawnDay)) | |
1790 { | |
1791 | |
1792 if (Str2) | |
1793 { | |
2534 | 1794 memset(Dst, 0, 0x3C8); |
1795 memset(Src, 0, 0x3C8); | |
2496 | 1796 } |
1797 if ((unsigned int)((char *)File - ddm.uLastRepawnDay) >= pNumItems || !ddm.uLastRepawnDay) | |
1798 { | |
2534 | 1799 memcpy(Dst, pSrc, 968); |
1800 memcpy(Src, pSrc + 968, 968); | |
2496 | 1801 } |
1802 free(pSrcMem); | |
1803 | |
1804 ddm.uLastRepawnDay = (int)File; | |
1805 if (Str2 == 0) | |
1806 ++ddm.uNumRespawns; | |
1807 v108 = 0; | |
1808 *thisa = 1; | |
2534 | 1809 pFile = pGames_LOD->FindContainer(Str, 0); |
1810 fread(&header, 0x10, 1, pFile); | |
2496 | 1811 //pFilename = (char *)header.uCompressedSize; |
1812 //pDestLen = header.uDecompressedSize; | |
1813 //v82 = malloc(header.uDecompressedSize); | |
1814 pSrcMem = (unsigned char *)malloc(header.uDecompressedSize); | |
1815 //v149 = v82; | |
1816 if (header.uCompressedSize == header.uDecompressedSize) | |
2534 | 1817 fread(pSrcMem, header.uDecompressedSize, 1, pFile); |
2496 | 1818 else if (header.uCompressedSize < header.uDecompressedSize) |
1819 { | |
1820 void* compressedMem = malloc(header.uCompressedSize); | |
2534 | 1821 fread(compressedMem, header.uCompressedSize, 1, pFile); |
2496 | 1822 |
1823 uint actualDecompressedSize = header.uDecompressedSize; | |
1824 zlib::MemUnzip(pSrcMem, &actualDecompressedSize, compressedMem, header.uCompressedSize); | |
1825 free(compressedMem); | |
1826 } | |
1827 else | |
1828 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:857", 0); | |
1829 | |
1830 pSrc = pSrcMem + 40; | |
1831 } | |
1832 else | |
1833 *thisa = 0; | |
2534 | 1834 memcpy(uFullyRevealedCellOnMap, pSrc, 968); |
1835 memcpy(uPartiallyRevealedCellOnMap, pSrc + 968, 968); | |
1836 pSrc += 2 * 968; | |
1837 | |
1838 pGameLoadingUI_ProgressBar->Progress(); //прогресс загрузки | |
2496 | 1839 |
1840 if ( *thisa ) | |
1841 { | |
2534 | 1842 memcpy(uFullyRevealedCellOnMap, Dst, 968); |
1843 memcpy(uPartiallyRevealedCellOnMap, Src, 968); | |
2496 | 1844 } |
1845 | |
1846 for (uint i = 0; i < uNumBModels; ++i) | |
1847 { | |
1848 BSPModel model = pBModels[i]; | |
1849 for (uint j = 0; j < model.uNumFaces; ++j) | |
1850 { | |
1851 ODMFace face = model.pFaces[j]; | |
1852 memcpy(&face.uAttributes, pSrc, 4); | |
1853 pSrc += 4; | |
1854 } | |
1855 | |
1856 for (uint j = 0; j < model.uNumFaces; ++j) | |
1857 { | |
1858 ODMFace face = model.pFaces[j]; | |
1859 if (face.sCogTriggeredID) | |
1860 { | |
1861 if (face.HasEventHint()) | |
1862 face.uAttributes |= FACE_HAS_EVENT_HINT; | |
1863 else | |
1864 face.uAttributes &= ~FACE_HAS_EVENT_HINT;//~0x00001000 | |
1865 } | |
1866 } | |
1867 } | |
1868 | |
2534 | 1869 pGameLoadingUI_ProgressBar->Progress(); //прогресс загрузки |
2496 | 1870 |
1871 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
1872 { | |
1873 memcpy(&pLevelDecorations[i].uFlags, pSrc, 2); | |
1874 pSrc += 2; | |
1875 } | |
1876 | |
2534 | 1877 pGameLoadingUI_ProgressBar->Progress(); //прогресс загрузки |
2496 | 1878 |
1879 memcpy(&uNumActors, pSrc, 4); | |
1880 if (uNumActors > 500) | |
2534 | 1881 MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:939", 0); |
1882 | |
1883 pGameLoadingUI_ProgressBar->Progress(); //прогресс загрузки | |
2496 | 1884 |
1885 assert(sizeof(Actor) == 836); | |
1886 //pFilename = (char *)(836 * uNumActors); | |
1887 memcpy(pActors.data(), pSrc + 4, uNumActors * sizeof(Actor)); | |
1888 pSrc += 4 + uNumActors * sizeof(Actor); | |
1889 //v92 = (char *)v91 + (int)pFilename; | |
2534 | 1890 pGameLoadingUI_ProgressBar->Progress(); //прогресс загрузки |
2496 | 1891 |
1892 memcpy(&uNumSpriteObjects, pSrc, 4); | |
1893 assert(uNumSpriteObjects <= 1000 && "Too many objects"); | |
1894 assert(sizeof(SpriteObject) == 112); | |
1895 | |
2534 | 1896 pGameLoadingUI_ProgressBar->Progress(); //прогресс загрузки |
2496 | 1897 |
1898 //pFilename = (char *)(112 * uNumSpriteObjects); | |
1899 memcpy(pSpriteObjects.data(), pSrc + 4, uNumSpriteObjects * sizeof(SpriteObject)); | |
1900 pSrc += 4 + uNumSpriteObjects * sizeof(SpriteObject); | |
1901 | |
1902 //v94 = (char *)v93 + (int)pFilename; | |
2534 | 1903 pGameLoadingUI_ProgressBar->Progress(); //прогресс загрузки |
2496 | 1904 |
1905 memcpy(&uNumChests, pSrc, 4); | |
1906 //v95 = (char *)v94 + 4; | |
1907 if (uNumChests > 20) | |
1908 MessageBoxW(nullptr, L"Can't load file!", | |
1909 L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:968", 0); | |
1910 | |
2534 | 1911 pGameLoadingUI_ProgressBar->Progress(); //прогресс загрузки |
2496 | 1912 |
1913 assert(sizeof(Chest) == 5324); | |
1914 //pFilename = (char *)(5324 * uNumChests); | |
1915 memcpy(pChests.data(), pSrc + 4 , uNumChests * sizeof(Chest)); | |
1916 pSrc += 4 + uNumChests * sizeof(Chest); | |
1917 //v96 = (char *)v95 + (int)pFilename; | |
2534 | 1918 pGameLoadingUI_ProgressBar->Progress(); //прогресс загрузки |
2496 | 1919 |
1920 memcpy(&stru_5E4C90_MapPersistVars, pSrc, 0xC8); | |
1921 pSrc += 0xC8; | |
1922 | |
2534 | 1923 pGameLoadingUI_ProgressBar->Progress(); //прогресс загрузки |
2496 | 1924 memcpy(&loc_time, pSrc, 0x38u); |
1925 | |
1926 free(pSrcMem); | |
1927 | |
1928 pTileTable->InitializeTileset(Tileset_Dirt); | |
1929 pTileTable->InitializeTileset(Tileset_Snow); | |
1930 pTileTable->InitializeTileset(pTileTypes[0].tileset); | |
1931 pTileTable->InitializeTileset(pTileTypes[1].tileset); | |
1932 pTileTable->InitializeTileset(pTileTypes[2].tileset); | |
1933 pTileTable->InitializeTileset(pTileTypes[3].tileset); | |
1934 strcpy(pGroundTileset, byte_6BE124_cfg_textures_DefaultGroundTexture.data()); | |
1935 TileDesc* v98 = pTileTable->GetTileById(pTileTypes[0].uTileID); | |
1936 sMainTile_BitmapID = pBitmaps_LOD->LoadTexture(v98->pTileName, TEXTURE_DEFAULT); | |
1937 if (sMainTile_BitmapID != -1) | |
1938 pBitmaps_LOD->pTextures[sMainTile_BitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[sMainTile_BitmapID].palette_id1); | |
1939 | |
1940 _47F0E2(); | |
1941 | |
1942 //LABEL_150: | |
1943 if ( pWeather->bRenderSnow ) //Ritor1: it's include for snow | |
1944 strcpy(loc_time.sky_texture_name, "sky19"); | |
1945 else if (loc_time.uLastVisitDay) | |
1946 { | |
1947 if ( (signed int)((signed int)(signed __int64)((double)loc_time.uLastVisitDay * 0.234375) / 60 / 60 / 24) % 28 != pParty->uDaysPlayed ) | |
1948 { | |
1949 if ( rand() % 100 >= 20 ) | |
1950 v108 = dword_4EC268[rand() % dword_4EC2A8]; | |
1951 else | |
1952 v108 = dword_4EC28C[rand() % dword_4EC2AC]; | |
1953 sprintf(loc_time.sky_texture_name, "plansky%d", v108); | |
1954 } | |
1955 } | |
1956 else | |
1957 strcpy(loc_time.sky_texture_name, "plansky3"); | |
1958 | |
2534 | 1959 //New_SKY_NIGHT_ID = pBitmaps_LOD->LoadTexture("SKY13"); |
1960 //if (New_SKY_NIGHT_ID != -1) | |
1961 // pBitmaps_LOD->pTextures[New_SKY_NIGHT_ID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[New_SKY_NIGHT_ID].palette_id1); | |
1962 | |
2496 | 1963 //v101 = pBitmaps_LOD->LoadTexture(field_4F8); |
1964 sSky_TextureID = pBitmaps_LOD->LoadTexture(loc_time.sky_texture_name); | |
1965 if (sSky_TextureID != -1) | |
1966 pBitmaps_LOD->pTextures[sSky_TextureID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[sSky_TextureID].palette_id1); | |
1967 | |
1968 pPaletteManager->RecalculateAll(); | |
2534 | 1969 pSoundList->LoadSound(SOUND_RunDirt, 0); //For Dirt tyle(для звука хождения по грязи) |
1970 pSoundList->LoadSound(SOUND_WalkDirt, 0); //для бега | |
1971 pSoundList->LoadSound(SOUND_RunRoad, 0); //для звука хождения по дороге | |
1972 pSoundList->LoadSound(SOUND_WalkRoad, 0); | |
1973 pSoundList->LoadSound(SOUND_RunWood, 0); //для звука хождения по дереву | |
1974 pSoundList->LoadSound(SOUND_WalkWood, 0); | |
2496 | 1975 for (int i=0; i < 3;++i) |
1976 { | |
1977 switch ( pTileTypes[i].tileset ) | |
1978 { | |
1979 case Tileset_Grass: | |
2534 | 1980 pSoundList->LoadSound(SOUND_RunGrass, 0); //для звука хождения по траве |
1981 pSoundList->LoadSound(SOUND_WalkGrass, 0); | |
2496 | 1982 break; |
1983 case Tileset_Snow: | |
2534 | 1984 pSoundList->LoadSound(SOUND_RunSnow, 0); //по снегу |
1985 pSoundList->LoadSound(SOUND_WalkSnow, 0); | |
2496 | 1986 break; |
1987 case Tilset_Desert: | |
2534 | 1988 pSoundList->LoadSound(SOUND_RunDesert, 0); //по пустыне |
1989 pSoundList->LoadSound(SOUND_WalkDesert, 0); | |
2496 | 1990 break; |
2534 | 1991 case Tileset_CooledLava: |
1992 pSoundList->LoadSound(SOUND_RunCooledLava, 0);//по лаве | |
1993 pSoundList->LoadSound(SOUND_WalkCooledLava, 0); | |
2496 | 1994 break; |
1995 case Tileset_Water: | |
2534 | 1996 pSoundList->LoadSound(SOUND_RunWater, 0); //по воде |
1997 pSoundList->LoadSound(SOUND_WalkWater, 0); | |
2496 | 1998 break; |
2534 | 1999 case Tileset_Badlands: |
2000 pSoundList->LoadSound(SOUND_RunBadlands, 0); //для звука ходьбы по бесплодным землям | |
2001 pSoundList->LoadSound(SOUND_WalkBadlands, 0); | |
2496 | 2002 break; |
2003 case Tileset_Swamp: | |
2534 | 2004 pSoundList->LoadSound(SOUND_RunSwamp, 0); //по болоту |
2005 pSoundList->LoadSound(SOUND_WalkSwamp, 0); | |
2496 | 2006 break; |
2007 } | |
2008 } | |
2009 return true; | |
2010 } | |
2011 | |
2012 //----- (0047ECC1) -------------------------------------------------------- | |
2013 int OutdoorLocation::GetTileIdByTileMapId(signed int a2) | |
2014 { | |
2015 signed int result; // eax@2 | |
2016 int v3; // eax@3 | |
2017 | |
2018 if ( a2 >= 90 ) | |
2019 { | |
2020 v3 = (a2 - 90) / 36; | |
2021 if ( v3 && v3 != 1 && v3 != 2 ) | |
2022 { | |
2534 | 2023 if ( v3 == Tileset_CooledLava ) |
2496 | 2024 result = this->pTileTypes[3].uTileID; |
2025 else | |
2026 result = a2; | |
2027 } | |
2028 else | |
2029 result = this->pTileTypes[v3].uTileID; | |
2030 } | |
2031 else | |
2032 result = 0; | |
2033 return result; | |
2034 } | |
2035 | |
2036 //----- (0047ED08) -------------------------------------------------------- | |
2037 unsigned int OutdoorLocation::DoGetTileTexture(signed int sX, signed int sY) | |
2038 { | |
2039 int v3; // esi@5 | |
2040 // unsigned int result; // eax@9 | |
2041 | |
2042 assert(sX < 128 && sY < 128); | |
2043 | |
2044 v3 = this->pTerrain.pTilemap[sY * 128 + sX]; | |
2045 if (v3 < 198) // < Tileset_3 | |
2046 { | |
2047 if (v3 >= 90) | |
2048 v3 = v3 + this->pTileTypes[(v3 - 90) / 36].uTileID - 36 * ((v3 - 90) / 36) - 90; | |
2049 } | |
2050 else | |
2051 v3 = v3 + this->pTileTypes[3].uTileID - 198; | |
2052 | |
2053 #pragma region "New: seasons change" | |
2054 | |
2055 if (change_seasons) | |
2056 switch (pParty->uCurrentMonth) | |
2057 { | |
2058 case 11: case 0: case 1: // winter | |
2059 if (v3 >= 90) // Tileset_Grass begins at TileID = 90 | |
2060 { | |
2061 if (v3 <= 95) // some grastyl entries | |
2062 v3 = 348; | |
2063 else if (v3 <= 113) // rest of grastyl & all grdrt* | |
2064 v3 = 348 + (v3 - 96); | |
2065 } | |
2066 /*switch (v3) | |
2067 { | |
2068 case 102: v3 = 354; break; // grdrtNE -> SNdrtne | |
2069 case 104: v3 = 356; break; // grdrtNW -> SNdrtnw | |
2070 case 108: v3 = 360; break; // grdrtN -> SNdrtn | |
2071 }*/ | |
2072 break; | |
2073 | |
2074 case 2: case 3: case 4: // spring | |
2075 case 8: case 9: case 10: // autumn | |
2076 if (v3 >= 90 && v3 <= 113) // just convert all Tileset_Grass to dirt | |
2077 v3 = 1; | |
2078 break; | |
2079 | |
2080 case 5: case 6: case 7: // summer | |
2081 //all tiles are green grass by default | |
2082 break; | |
2083 | |
2084 default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12); | |
2085 } | |
2086 #pragma endregion | |
2087 | |
2088 return pTileTable->pTiles[v3].uBitmapID; | |
2089 } | |
2090 | |
2091 //----- (0047ED83) -------------------------------------------------------- | |
2092 int OutdoorLocation::_47ED83(signed int a2, signed int a3) | |
2093 { | |
2094 assert(a2 < 128 && a3 < 128); | |
2095 | |
2096 return *(&this->pTerrain.pTilemap[128 * a3] + a2); | |
2097 } | |
2098 | |
2099 //----- (0047EDB3) -------------------------------------------------------- | |
2100 int OutdoorLocation::ActuallyGetSomeOtherTileInfo(signed int sX, signed int sY) | |
2101 { | |
2102 assert(sX < 128 && sY < 128); | |
2103 int v3; // esi@5 | |
2104 | |
2105 v3 = this->pTerrain.pTilemap[sY * 128 + sX]; | |
2106 if ( v3 >= 90 ) | |
2107 v3 = v3 + this->pTileTypes[(v3 - 90) / 36].uTileID - 36 * ((v3 - 90) / 36) - 90; | |
2108 return pTileTable->pTiles[v3].uAttributes; | |
2109 } | |
2110 | |
2111 //----- (0047EE16) -------------------------------------------------------- | |
2112 int OutdoorLocation::DoGetHeightOnTerrain(signed int sX, signed int sZ) | |
2113 { | |
2114 assert(sX < 128 && sZ < 128); | |
2115 | |
2116 return 32 * pTerrain.pHeightmap[sZ * 128 + sX]; | |
2117 } | |
2118 | |
2119 //----- (0047EE49) -------------------------------------------------------- | |
2120 int OutdoorLocation::GetSoundIdByPosition( signed int X_pos, signed int Y_pos, int running ) | |
2121 { | |
2122 signed int v4; // eax@5 | |
2123 signed int v5; // eax@7 | |
2124 // int v6; // eax@8 | |
2125 signed int v8; // eax@9 | |
2126 int modif=0; | |
2127 | |
2128 if ( X_pos < 0 || X_pos > 127 || Y_pos < 0 || Y_pos > 127 ) | |
2129 v4 = 0; | |
2130 else | |
2131 v4 = this->pTerrain.pTilemap[128 * Y_pos + X_pos]; | |
2132 v5 = GetTileIdByTileMapId(v4); | |
2133 if (running) | |
2134 modif=-39; | |
2135 if ( !v5 ) | |
2136 return 92+modif; | |
2137 | |
2138 switch (pTileTable->pTiles[v5].tileset) | |
2139 { | |
2140 case 0: return 93+ modif; | |
2141 case 1: return 97+ modif; | |
2142 case 2: return 91+ modif; | |
2143 case 3: return 90+ modif; | |
2144 case 4: return 101+ modif; | |
2145 case 5: return 95+ modif; | |
2146 case 6: return 88+ modif; | |
2147 case 7: return 100+ modif; | |
2148 case 8: return 93+ modif; | |
2149 default: | |
2150 v8=pTileTable->pTiles[v5].tileset; | |
2151 if ( (v8 > 9 && v8 <= 17) || (v8 > 21 && v8 <= 27) ) | |
2152 return 96+ modif; | |
2153 else | |
2154 return 95+ modif; | |
2155 } | |
2156 | |
2157 } | |
2158 | |
2159 //----- (0047EF60) -------------------------------------------------------- | |
2160 int OutdoorLocation::UpdateDiscoveredArea(int X_grid_pos, int Y_grid_poa, int a4) | |
2161 { | |
2162 for (int i = -10; i < 10; i++) | |
2163 { | |
2164 int currYpos = Y_grid_poa + i - 20; | |
2165 for (int j = -10; j < 10; j++) | |
2166 { | |
2167 int currXpos = X_grid_pos + j - 20; | |
2168 int distanceSquared = i * i + j * j; | |
2169 if ( distanceSquared <= 100 && currYpos >= 0 && currYpos <= 87 && currXpos >= 0 && currXpos <= 87 ) | |
2170 { | |
2171 unsigned char v13 = 1 << (7 - currXpos % 8); | |
2172 this->uPartiallyRevealedCellOnMap[currYpos][currXpos / 8] |= v13; | |
2173 if ( distanceSquared <= 49 ) | |
2174 this->uFullyRevealedCellOnMap[currYpos][currXpos / 8] |= v13; | |
2175 } | |
2176 } | |
2177 } | |
2178 return 1; | |
2179 } | |
2180 | |
2181 | |
2182 //----- (0047F04C) -------------------------------------------------------- | |
2183 bool OutdoorLocation::IsMapCellFullyRevealed(signed int x_pos, signed int y_pos) | |
2184 { | |
2185 if ( x_pos < 0 || x_pos >= 88 || y_pos < 0 || y_pos >= 88 ) | |
2186 return false; | |
2187 else | |
2188 return (uFullyRevealedCellOnMap[y_pos][x_pos/8] & (1 << (7 - (x_pos) % 8))) != 0; | |
2189 } | |
2190 | |
2191 //----- (0047F097) -------------------------------------------------------- | |
2192 bool OutdoorLocation::IsMapCellPartiallyRevealed(signed int x_pos, signed int y_pos) | |
2193 { | |
2194 if ( x_pos < 0 || x_pos >= 88 || y_pos < 0 || y_pos >= 88 ) | |
2195 return false; | |
2196 else | |
2197 return (uPartiallyRevealedCellOnMap[y_pos][x_pos/8] & (1 << (7 - (x_pos) % 8))) != 0; | |
2198 } | |
2199 | |
2200 //----- (0047F0E2) -------------------------------------------------------- | |
2201 bool OutdoorLocation::_47F0E2() | |
2202 { | |
2203 for ( uint i = 0; i < (signed int)pBitmaps_LOD->uNumLoadedFiles; ++i ) | |
2204 { | |
2205 //if ( i != -1 ? (int)&pBitmaps_LOD->pTextures[i] : 0 ) | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2567
diff
changeset
|
2206 pBitmaps_LOD->pTextures[i].uDecompressedSize = this->pTerrain._47CB57(pBitmaps_LOD->pTextures[i].paletted_pixels, |
2496 | 2207 pBitmaps_LOD->pTextures[i].palette_id2, |
2208 pBitmaps_LOD->pTextures[i].uTextureWidth * pBitmaps_LOD->pTextures[i].uTextureHeight); | |
2209 } | |
2210 return 1; | |
2211 } | |
2212 | |
2213 //----- (0047F138) -------------------------------------------------------- | |
2214 bool OutdoorLocation::PrepareDecorations() | |
2215 { | |
2216 signed int v1; // ebx@1 | |
2217 signed int v8; // [sp+Ch] [bp-4h]@1 | |
2218 | |
2219 v1 = 0; | |
2220 v8 = 0; | |
2221 if ( !_stricmp(pCurrentMapName, "out09.odm") ) | |
2222 v8 = 1; | |
2223 | |
2224 for (uint i = 0; i < uNumLevelDecorations; ++i) | |
2225 { | |
2226 LevelDecoration* decor = &pLevelDecorations[i]; | |
2227 | |
2228 pDecorationList->InitializeDecorationSprite(decor->uDecorationDescID); | |
2229 if ( pDecorationList->pDecorations[decor->uDecorationDescID].uSoundID && _6807E0_num_decorations_with_sounds_6807B8 < 9 ) | |
2230 { | |
2231 pSoundList->LoadSound(pDecorationList->pDecorations[decor->uDecorationDescID].uSoundID, 0); | |
2232 _6807B8_level_decorations_ids[_6807E0_num_decorations_with_sounds_6807B8++] = i; | |
2233 } | |
2234 if ( v8 && decor->uCog == 20 ) | |
2235 decor->uFlags |= LEVEL_DECORATION_OBELISK_CHEST; | |
2236 if ( !decor->uEventID ) | |
2237 { | |
2238 if ( decor->IsInteractive() ) | |
2239 { | |
2240 if ( v1 < 124 ) | |
2241 { | |
2242 decor->_idx_in_stru123 = v1 + 75; | |
2243 if ( !stru_5E4C90_MapPersistVars._decor_events[v1++] ) | |
2244 decor->uFlags |= LEVEL_DECORATION_INVISIBLE; | |
2245 } | |
2246 } | |
2247 } | |
2248 } | |
2249 | |
2250 pGameLoadingUI_ProgressBar->Progress(); | |
2251 return true; | |
2252 } | |
2253 // 6807E0: using guessed type int _6807E0_num_decorations_6807B8; | |
2254 | |
2255 //----- (0047F223) -------------------------------------------------------- | |
2256 void OutdoorLocation::ArrangeSpriteObjects() | |
2257 { | |
2258 OutdoorLocation *v5; // [sp+0h] [bp-4h]@1 | |
2259 | |
2260 v5 = this; | |
2261 if ( (signed int)uNumSpriteObjects > 0 ) | |
2262 { | |
2263 for ( int i = 0; i < (signed int)uNumSpriteObjects; ++i ) | |
2264 { | |
2265 if ( pSpriteObjects[i].uObjectDescID ) | |
2266 { | |
2267 if ( !(pSpriteObjects[i].uAttributes & 8) && !(pObjectList->pObjects[pSpriteObjects[i].uObjectDescID].uFlags & 0x10) ) | |
2268 pSpriteObjects[i].vPosition.z = GetTerrainHeightsAroundParty2(pSpriteObjects[i].vPosition.x, pSpriteObjects[i].vPosition.y, (int *)&v5, 0); | |
2566 | 2269 if (pSpriteObjects[i].containing_item.uItemID) |
2496 | 2270 { |
2566 | 2271 if (pSpriteObjects[i].containing_item.uItemID != 220 |
2272 && pItemsTable->pItems[pSpriteObjects[i].containing_item.uItemID].uEquipType == EQUIP_POTION | |
2273 && !pSpriteObjects[i].containing_item.uEnchantmentType) | |
2274 pSpriteObjects[i].containing_item.uEnchantmentType = rand() % 15 + 5; | |
2275 pItemsTable->SetSpecialBonus(&pSpriteObjects[i].containing_item); | |
2496 | 2276 } |
2277 } | |
2278 } | |
2279 } | |
2280 pGameLoadingUI_ProgressBar->Progress(); | |
2281 } | |
2282 | |
2283 //----- (0047F2D3) -------------------------------------------------------- | |
2284 bool OutdoorLocation::InitalizeActors(int a1) | |
2285 { | |
2286 int alert_status; // [sp+348h] [bp-8h]@1 | |
2287 // int v9; // [sp+34Ch] [bp-4h]@1 | |
2288 | |
2289 alert_status = 0; | |
2290 for( int i = 0; i < uNumActors; ++i ) | |
2291 { | |
2292 if ( !(pActors[i].uAttributes & ACTOR_UNKNOW7) ) | |
2293 { | |
2294 if ( alert_status != 1 ) | |
2295 { | |
2296 pActors[i].uCurrentActionTime = 0; | |
2297 pActors[i].uCurrentActionLength = 0; | |
2298 if ( pActors[i].uAttributes & ACTOR_UNKNOW11 ) | |
2299 pActors[i].uAIState = AIState::Disabled; | |
2300 if ( pActors[i].uAIState != AIState::Removed && pActors[i].uAIState != AIState::Disabled && | |
2301 (pActors[i].sCurrentHP == 0 || pActors[i].pMonsterInfo.uHP == 0) ) | |
2302 pActors[i].uAIState = AIState::Dead; | |
2303 pActors[i].vVelocity.x = 0; | |
2304 pActors[i].vVelocity.y = 0; | |
2305 pActors[i].vVelocity.z = 0; | |
2306 pActors[i].UpdateAnimation(); | |
2307 pActors[i].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
2308 pActors[i].PrepareSprites(0); | |
2309 } | |
2310 else | |
2311 { | |
2312 pActors[i].uAIState = AIState::Disabled; | |
2313 pActors[i].uAttributes |= ACTOR_UNKNOW11; | |
2314 } | |
2315 } | |
2316 else if ( a1 == 0 ) | |
2317 { | |
2318 pActors[i].uAIState = AIState::Disabled; | |
2319 pActors[i].uAttributes |= ACTOR_UNKNOW11; | |
2320 } | |
2321 else if ( alert_status != 0 ) | |
2322 { | |
2323 pActors[i].uCurrentActionTime = 0; | |
2324 pActors[i].uCurrentActionLength = 0; | |
2325 if ( pActors[i].uAttributes & ACTOR_UNKNOW11 ) | |
2326 pActors[i].uAIState = AIState::Disabled; | |
2327 if ( pActors[i].uAIState != AIState::Removed && pActors[i].uAIState != AIState::Disabled && | |
2328 (pActors[i].sCurrentHP == 0 || pActors[i].pMonsterInfo.uHP == 0) ) | |
2329 pActors[i].uAIState = AIState::Dead; | |
2330 pActors[i].vVelocity.x = 0; | |
2331 pActors[i].vVelocity.y = 0; | |
2332 pActors[i].vVelocity.z = 0; | |
2333 pActors[i].UpdateAnimation(); | |
2334 pActors[i].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; | |
2335 pActors[i].PrepareSprites(0); | |
2336 } | |
2337 else | |
2338 { | |
2339 pActors[i].uAIState = AIState::Disabled; | |
2340 pActors[i].uAttributes |= ACTOR_UNKNOW11; | |
2341 alert_status = GetAlertStatus(); | |
2342 } | |
2343 } | |
2344 | |
2345 pGameLoadingUI_ProgressBar->Progress(); | |
2346 //no use for this | |
2347 // Actor thisa; | |
2348 // thisa.pMonsterInfo.uID = 45; | |
2349 // thisa.PrepareSprites(0); | |
2350 return 1; | |
2351 } | |
2352 | |
2353 //----- (0047F3EA) -------------------------------------------------------- | |
2354 bool OutdoorLocation::LoadRoadTileset() | |
2355 { | |
2356 pTileTypes[3].uTileID = pTileTable->GetTileForTerrainType(pTileTypes[3].tileset, 1); | |
2357 pTileTable->InitializeTileset(pTileTypes[3].tileset); | |
2358 return 1; | |
2359 } | |
2360 | |
2361 //----- (0047F420) -------------------------------------------------------- | |
2362 bool OutdoorLocation::LoadTileGroupIds() | |
2363 { | |
2364 for (uint i = 0; i < 3; ++i) | |
2365 pTileTypes[i].uTileID = pTileTable->GetTileForTerrainType(pTileTypes[i].tileset, 1); | |
2366 | |
2367 return true; | |
2368 } | |
2369 | |
2370 //----- (0047B42C) -------------------------------------------------------- | |
2371 void OutdoorLocation::PrepareActorsDrawList() | |
2372 { | |
2373 unsigned int result; // eax@1 | |
2374 int z; // esi@5 | |
2375 float v4; // ST48_4@8 | |
2376 unsigned int v8; // eax@11 | |
2377 int v9; // edx@11 | |
2378 signed int v12; // eax@16 | |
2379 SpriteFrame *v14; // eax@24 | |
2380 SpriteFrame *v15; // ebx@25 | |
2381 int v17; // eax@35 | |
2382 int v18; // ST78_4@36 | |
2383 int v19; // eax@36 | |
2384 int v20; // ecx@38 | |
2385 int v21; // eax@38 | |
2386 int v22; // ecx@41 | |
2387 int v23; // ST5C_4@43 | |
2388 int v24; // esi@44 | |
2389 signed __int64 v25; // qtt@45 | |
2390 int v26; // ST54_4@45 | |
2391 int v27; // ecx@45 | |
2392 int v34; // ecx@54 | |
2393 int v41; // [sp+24h] [bp-3Ch]@11 | |
2394 int v42; // [sp+28h] [bp-38h]@38 | |
2395 int v43; // [sp+28h] [bp-38h]@45 | |
2396 int v44; // [sp+2Ch] [bp-34h]@36 | |
2397 int v45; // [sp+2Ch] [bp-34h]@44 | |
2398 int v46; // [sp+2Ch] [bp-34h]@45 | |
2399 int v47; // [sp+30h] [bp-30h]@36 | |
2400 int v48; // [sp+30h] [bp-30h]@41 | |
2401 signed int v49; // [sp+34h] [bp-2Ch]@5 | |
2402 int v50; // [sp+34h] [bp-2Ch]@36 | |
2403 int v51; // [sp+34h] [bp-2Ch]@41 | |
2404 int v53; // [sp+38h] [bp-28h]@36 | |
2405 int y; // [sp+40h] [bp-20h]@5 | |
2406 int x; // [sp+44h] [bp-1Ch]@5 | |
2407 int v57; // [sp+48h] [bp-18h]@45 | |
2408 int v58; // [sp+4Ch] [bp-14h]@45 | |
2409 int X; // [sp+54h] [bp-Ch]@36 | |
2410 signed __int16 v62; // [sp+5Ch] [bp-4h]@25 | |
2411 | |
2412 //result = 0; | |
2413 //v59 = 0; | |
2414 for (int i = 0; i < uNumActors; ++i) | |
2415 { | |
2416 //v54 = 0; | |
2417 //v1 = pActors;//[0].vPosition.z; | |
2418 //do | |
2419 //{ | |
2420 //Actor* actor = &pActors[i]; | |
2421 //v2 = actor->uAIState; | |
2422 | |
2423 pActors[i].uAttributes &= 0xFFFFFFF7;//~0x8 | |
2424 if (pActors[i].uAIState == Removed || pActors[i].uAIState == Disabled) | |
2425 continue; | |
2426 | |
2427 z = pActors[i].vPosition.z; | |
2428 v49 = 0; | |
2429 x = pActors[i].vPosition.x; | |
2430 y = pActors[i].vPosition.y; | |
2431 if (pActors[i].uAIState == Summoned) | |
2432 { | |
2433 if (PID_TYPE(pActors[i].uSummonerID) != OBJECT_Actor || | |
2434 pActors[PID_ID(pActors[i].uSummonerID)].pMonsterInfo.uSpecialAbilityDamageDiceSides != 1 ) | |
2435 { | |
2436 z += floorf(pActors[i].uActorHeight * 0.5f + 0.5f); | |
2437 } | |
2438 else | |
2439 { | |
2440 v49 = 1; | |
2541 | 2441 pEngine->pStru6Instance->_4A7F74(pActors[i].vPosition.x, pActors[i].vPosition.y, z); |
2496 | 2442 v4 = (1.0 - (double)pActors[i].uCurrentActionTime / (double)pActors[i].uCurrentActionLength) * |
2443 (double)(2 * pActors[i].uActorHeight); | |
2444 z -= floorf(v4 + 0.5f); | |
2445 if ( z > pActors[i].vPosition.z ) | |
2446 z = pActors[i].vPosition.z; | |
2447 } | |
2448 } | |
2543 | 2449 v8 = stru_5C6E00->Atan2(pActors[i].vPosition.x - pIndoorCameraD3D->vPartyPos.x, |
2450 pActors[i].vPosition.y - pIndoorCameraD3D->vPartyPos.y); | |
2496 | 2451 LOWORD(v9) = pActors[i].uYawAngle; |
2452 v41 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v9 - v8) >> 8) & 7; | |
2453 if ( pParty->bTurnBasedModeOn ) | |
2454 { | |
2455 v12 = pActors[i].uCurrentActionTime; | |
2456 if ( pActors[i].uCurrentActionAnimation == 1 ) | |
2457 v12 = 32 * i + pMiscTimer->uTotalGameTimeElapsed; | |
2458 } | |
2459 else | |
2460 { | |
2461 v12 = pActors[i].uCurrentActionTime; | |
2462 if ( pActors[i].uCurrentActionAnimation == 1 ) | |
2463 v12 = 32 * i + pEventTimer->uTotalGameTimeElapsed; | |
2464 } | |
2465 if ( (signed __int64)pActors[i].pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0 || (signed __int64)pActors[i].pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0 ) | |
2466 v12 = 0; | |
2467 if ( pActors[i].uAIState == 17 && !v49 ) | |
2468 v14 = pSpriteFrameTable->GetFrame(uSpriteID_Spell11, v12); | |
2469 else if ( pActors[i].uAIState == 16 ) | |
2470 v14 = pSpriteFrameTable->GetFrameBy_x(pActors[i].pSpriteIDs[pActors[i].uCurrentActionAnimation], v12); | |
2471 else | |
2472 v14 = pSpriteFrameTable->GetFrame(pActors[i].pSpriteIDs[pActors[i].uCurrentActionAnimation], v12); | |
2473 v62 = 0; | |
2474 v15 = v14; | |
2475 //v16 = (int *)v14->uFlags; | |
2476 if (v14->uFlags & 2) | |
2477 v62 = 2; | |
2478 if (v14->uFlags & 0x40000) | |
2479 v62 |= 0x40; | |
2480 if (v14->uFlags & 0x20000) | |
2481 LOBYTE(v62) = v62 | 0x80; | |
2482 if ((256 << v41) & v14->uFlags) | |
2483 v62 |= 4; | |
2484 if ( v15->uGlowRadius ) | |
2485 { | |
2486 //LOBYTE(v16) = _4E94D3_light_type; | |
2487 pMobileLightsStack->AddLight(x, y, z, 0, v15->uGlowRadius, 0xFFu, 0xFFu, 0xFFu, _4E94D3_light_type); | |
2488 } | |
2543 | 2489 v17 = (x - pIndoorCameraD3D->vPartyPos.x) << 16; |
2490 if (pIndoorCameraD3D->sRotationX) | |
2496 | 2491 { |
2543 | 2492 v18 = (y - pIndoorCameraD3D->vPartyPos.y) << 16; |
2493 v47 = (fixpoint_mul(v17, pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v18, pIndoorCameraD3D->int_sine_y)); | |
2494 v50 = fixpoint_mul(v17, pIndoorCameraD3D->int_sine_y); | |
2495 v53 = fixpoint_mul(v18, pIndoorCameraD3D->int_cosine_y); | |
2496 v44 = (z - pIndoorCameraD3D->vPartyPos.z) << 16; | |
2497 v19 = (fixpoint_mul(v44, pIndoorCameraD3D->int_sine_x) + fixpoint_mul(v47, pIndoorCameraD3D->int_cosine_x)); | |
2498 X = fixpoint_mul(v44, pIndoorCameraD3D->int_sine_x) + fixpoint_mul(v47, pIndoorCameraD3D->int_cosine_x); | |
2496 | 2499 if ( v19 < 262144 || v19 > pODMRenderParams->shading_dist_mist << 16 ) |
2500 continue; | |
2501 v20 = v53 - v50; | |
2502 v42 = v53 - v50; | |
2543 | 2503 v21 = (fixpoint_mul(v44, pIndoorCameraD3D->int_cosine_x) - fixpoint_mul(v47, pIndoorCameraD3D->int_sine_x)); |
2496 | 2504 } |
2505 else | |
2506 { | |
2543 | 2507 v48 = (y - pIndoorCameraD3D->vPartyPos.y) << 16; |
2508 v51 = fixpoint_mul(v17, pIndoorCameraD3D->int_cosine_y); | |
2509 v22 = fixpoint_mul(v48, pIndoorCameraD3D->int_sine_y); | |
2496 | 2510 X = v22 + v51; |
2511 if ( v22 + v51 < 262144 || v22 + v51 > pODMRenderParams->shading_dist_mist << 16 ) | |
2512 continue; | |
2543 | 2513 v23 = fixpoint_mul(((x - pIndoorCameraD3D->vPartyPos.x) << 16), pIndoorCameraD3D->int_sine_y); |
2514 v20 = fixpoint_mul(v48, pIndoorCameraD3D->int_cosine_y) - v23; | |
2515 v42 = fixpoint_mul(v48, pIndoorCameraD3D->int_cosine_y) - v23; | |
2516 v21 = (z - pIndoorCameraD3D->vPartyPos.z) << 16; | |
2496 | 2517 } |
2518 v45 = v21; | |
2519 v24 = abs(v20); | |
2520 if ( abs(X) >= v24 ) | |
2521 { | |
2522 LODWORD(v25) = 0; | |
2523 HIDWORD(v25) = SLOWORD(pODMRenderParams->int_fov_rad); | |
2524 v58 = v25 / X; | |
2525 v26 = v25 / X; | |
2526 LODWORD(v25) = 0; | |
2527 HIDWORD(v25) = SLOWORD(pODMRenderParams->int_fov_rad); | |
2528 v57 = v25 / X; | |
2529 v27 = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v26, v42) + 0x8000) >> 16); | |
2530 v43 = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v26, v42) + 0x8000) >> 16); | |
2531 v46 = pViewport->uScreenCenterY - ((signed int)(fixpoint_mul(v25 / X, v45) + 0x8000) >> 16); | |
2532 result = uNumBillboardsToDraw; | |
2533 //v28 = &pBillboardRenderList[uNumBillboardsToDraw]; | |
2534 if (uNumBillboardsToDraw >= 500) | |
2535 return; | |
2536 ++uNumBillboardsToDraw; | |
2537 ++uNumSpritesDrawnThisFrame; | |
2538 pActors[i].uAttributes |= ACTOR_UNKNOW2; | |
2539 pBillboardRenderList[uNumBillboardsToDraw - 1].HwSpriteID = v15->pHwSpriteIDs[v41]; | |
2540 pBillboardRenderList[uNumBillboardsToDraw - 1].uIndoorSectorID = 0; | |
2541 pBillboardRenderList[uNumBillboardsToDraw - 1].uPalette = v15->uPaletteIndex; | |
2542 pBillboardRenderList[uNumBillboardsToDraw - 1]._screenspace_x_scaler_packedfloat = fixpoint_mul(v15->scale, v58); | |
2543 pBillboardRenderList[uNumBillboardsToDraw - 1]._screenspace_y_scaler_packedfloat = fixpoint_mul(v15->scale, v57); | |
2544 if ( pActors[i].pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime <= 0 ) | |
2545 { | |
2546 if ( pActors[i].pActorBuffs[ACTOR_BUFF_MASS_DISTORTION].uExpireTime > 0 ) | |
2547 { | |
2541 | 2548 pBillboardRenderList[uNumBillboardsToDraw - 1]._screenspace_y_scaler_packedfloat = fixpoint_mul(pEngine->pStru6Instance->_4A806F(&pActors[i]), |
2496 | 2549 pBillboardRenderList[uNumBillboardsToDraw - 1]._screenspace_y_scaler_packedfloat); |
2550 LOWORD(v27) = v43; | |
2551 } | |
2552 } | |
2553 else | |
2554 { | |
2555 if ( pActors[i].pActorBuffs[ACTOR_BUFF_SHRINK].uPower ) | |
2556 { | |
2557 pBillboardRenderList[uNumBillboardsToDraw - 1]._screenspace_y_scaler_packedfloat = fixpoint_mul(65536 / pActors[i].pActorBuffs[ACTOR_BUFF_SHRINK].uPower, | |
2558 pBillboardRenderList[uNumBillboardsToDraw - 1]._screenspace_y_scaler_packedfloat); | |
2559 LOWORD(v27) = v43; | |
2560 } | |
2561 } | |
2562 pBillboardRenderList[uNumBillboardsToDraw - 1].uScreenSpaceX = v27; | |
2563 pBillboardRenderList[uNumBillboardsToDraw - 1].uScreenSpaceY = v46; | |
2564 pBillboardRenderList[uNumBillboardsToDraw - 1].world_x = x; | |
2565 pBillboardRenderList[uNumBillboardsToDraw - 1].world_y = y; | |
2566 pBillboardRenderList[uNumBillboardsToDraw - 1].world_z = z; | |
2567 HIWORD(v34) = HIWORD(X); | |
2568 LOWORD(v34) = 0; | |
2569 pBillboardRenderList[uNumBillboardsToDraw - 1].dimming_level = 0; | |
2570 pBillboardRenderList[uNumBillboardsToDraw - 1].sZValue = v34 + PID(OBJECT_Actor, i); | |
2571 pBillboardRenderList[uNumBillboardsToDraw - 1].field_14_actor_id = i; | |
2572 //v35 = pMonsterList->pMonsters; | |
2573 //v36 = pActors[i].pMonsterInfo.uID; | |
2574 pBillboardRenderList[uNumBillboardsToDraw - 1].field_1E = v62 | 0x200; | |
2575 pBillboardRenderList[uNumBillboardsToDraw - 1].pSpriteFrame = v15; | |
2576 pBillboardRenderList[uNumBillboardsToDraw - 1].sTintColor = pMonsterList->pMonsters[pActors[i].pMonsterInfo.uID - 1].sTintColor;//*((int *)&v35[v36] - 36); | |
2577 if (pActors[i].pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) | |
2578 pBillboardRenderList[uNumBillboardsToDraw - 1].field_1E = v62 | 0x200; | |
2579 } | |
2580 //LABEL_58: | |
2581 //++v59; | |
2582 //v54 += 32; | |
2583 //result = v59; | |
2584 //++v1; | |
2585 //} | |
2586 //while ( v59 < (signed int)uNumActors ); | |
2587 } | |
2588 //return result; | |
2589 } | |
2590 | |
2591 //----- (0044C1E8) -------------------------------------------------------- | |
2592 bool ODMFace::HasEventHint() | |
2593 { | |
2594 signed int event_index; // eax@1 | |
2595 _evt_raw* start_evt; | |
2596 _evt_raw* end_evt; | |
2597 | |
2598 event_index = 0; | |
2599 if ( (uLevelEVT_NumEvents - 1) <= 0 ) | |
2600 return false; | |
2601 while ( pLevelEVT_Index[event_index].uEventID != this->sCogTriggeredID ) | |
2602 { | |
2603 ++event_index; | |
2604 if ( event_index >= (signed int)(uLevelEVT_NumEvents - 1) ) | |
2605 return false; | |
2606 } | |
2607 end_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index+1].uEventOffsetInEVT]; | |
2608 start_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index].uEventOffsetInEVT]; | |
2609 if ( (end_evt->_e_type != EVENT_Exit) || (start_evt->_e_type!= EVENT_MouseOver) ) | |
2610 return false; | |
2611 else | |
2612 return true; | |
2613 } | |
2614 //----- (0046D49E) -------------------------------------------------------- | |
2615 int ODM_GetFloorLevel(int X, signed int Y, int Z, int __unused, int *pIsOnWater, int *bmodel_pid, int bWaterWalk) | |
2616 { | |
2617 BSPModel *pBModel; // esi@4 | |
2618 ODMFace *pFace; // ecx@11 | |
2619 // int v14; // edx@20 | |
2620 signed int v18; // edx@26 | |
2621 int v19; // eax@28 | |
2622 // int v20; // edx@30 | |
2623 // int v21; // ST1C_4@30 | |
2624 signed int v22; // edx@30 | |
2625 signed __int64 v23; // qtt@30 | |
2626 int v24; // eax@36 | |
2627 signed int v25; // ecx@38 | |
2628 // int result; // eax@42 | |
2629 signed int current_floor_level; // ecx@43 | |
2630 // int v28; // edi@44 | |
2631 signed int v29; // edx@44 | |
2632 // int v30; // esi@45 | |
2633 // int v31; // eax@45 | |
2634 // int v33; // ecx@59 | |
2635 // int v36; // [sp+14h] [bp-2Ch]@24 | |
2636 // int v38; // [sp+1Ch] [bp-24h]@2 | |
2637 int v39; // [sp+20h] [bp-20h]@9 | |
2638 signed int pBModelNum; // [sp+28h] [bp-18h]@1 | |
2639 int pFaceNum; // [sp+2Ch] [bp-14h]@8 | |
2640 bool current_vertices_Y; // [sp+30h] [bp-10h]@22 | |
2641 bool next_vertices_Y; // [sp+34h] [bp-Ch]@24 | |
2642 signed int v46; // [sp+3Ch] [bp-4h]@1 | |
2643 signed int number_hits; // [sp+58h] [bp+18h]@22 | |
2644 signed int next_floor_level; // [sp+58h] [bp+18h]@43 | |
2645 | |
2646 v46 = 1; | |
2647 current_BModel_id[0] = -1; | |
2648 current_Face_id[0] = -1; | |
2649 odm_floor_level[0] = GetTerrainHeightsAroundParty2(X, Y, pIsOnWater, bWaterWalk); | |
2650 | |
2651 for ( pBModelNum = 0; pBModelNum < pOutdoor->uNumBModels; ++pBModelNum ) | |
2652 { | |
2653 pBModel = &pOutdoor->pBModels[pBModelNum]; | |
2654 if ( X <= pBModel->sMaxX && X >= pBModel->sMinX && | |
2655 Y <= pBModel->sMaxY && Y >= pBModel->sMinY ) | |
2656 { | |
2657 if ( pBModel->uNumFaces > 0 ) | |
2658 { | |
2659 v39 = 0; | |
2660 for ( pFaceNum = 0; pFaceNum < pBModel->uNumFaces; ++pFaceNum ) | |
2661 { | |
2662 pFace = &pBModel->pFaces[pFaceNum]; | |
2663 if ( pFace->Ethereal() ) | |
2664 continue; | |
2665 if ( (pFace->uPolygonType == POLYGON_Floor || pFace->uPolygonType == POLYGON_InBetweenFloorAndWall) | |
2666 && X <= pFace->pBoundingBox.x2 && X >= pFace->pBoundingBox.x1 | |
2667 && Y <= pFace->pBoundingBox.y2 && Y >= pFace->pBoundingBox.y1 ) | |
2668 { | |
2669 for ( uint i = 0; i < pFace->uNumVertices; ++i) | |
2670 { | |
2671 odm_floor_face_vert_coord_X[2 * i] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].x; | |
2672 odm_floor_face_vert_coord_Y[2 * i] = pFace->pYInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i]].y; | |
2673 odm_floor_face_vert_coord_X[2 * i + 1] = pFace->pXInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].x; | |
2674 odm_floor_face_vert_coord_Y[2 * i + 1] = pFace->pYInterceptDisplacements[i] + pBModel->pVertices.pVertices[pFace->pVertexIDs[i + 1]].y; | |
2675 } | |
2676 odm_floor_face_vert_coord_X[2 * pFace->uNumVertices] = odm_floor_face_vert_coord_X[0]; | |
2677 odm_floor_face_vert_coord_Y[2 * pFace->uNumVertices] = odm_floor_face_vert_coord_Y[0]; | |
2678 | |
2679 current_vertices_Y = odm_floor_face_vert_coord_Y[0] >= Y; | |
2680 number_hits = 0; | |
2681 if ( 2 * pFace->uNumVertices > 0 ) | |
2682 { | |
2683 for ( int i = 0; i < 2 * pFace->uNumVertices; ++i ) | |
2684 { | |
2685 if ( number_hits >= 2 ) | |
2686 break; | |
2687 //v36 = odm_floor_face_vert_coord_Y[i + 1]; | |
2688 next_vertices_Y = odm_floor_face_vert_coord_Y[i + 1] >= Y; | |
2689 if ( current_vertices_Y != next_vertices_Y )//проверка по Y | |
2690 { | |
2691 v18 = odm_floor_face_vert_coord_X[i + 1] >= X ? 0 : 2; | |
2692 v19 = v18 | (odm_floor_face_vert_coord_X[i] < X); | |
2693 if ( v19 != 3 ) | |
2694 { | |
2695 if ( !v19 ) | |
2696 ++number_hits; | |
2697 else | |
2698 { | |
2699 LODWORD(v23) = (Y - odm_floor_face_vert_coord_Y[i]) << 16; | |
2700 HIDWORD(v23) = (Y - odm_floor_face_vert_coord_Y[i]) >> 16; | |
2701 v22 = ((((odm_floor_face_vert_coord_X[i + 1] - odm_floor_face_vert_coord_X[i]) * v23 / (odm_floor_face_vert_coord_Y[i + 1] | |
2702 - odm_floor_face_vert_coord_Y[i])) >> 16) + odm_floor_face_vert_coord_X[i]); | |
2703 if ( v22 >= X) | |
2704 ++number_hits; | |
2705 } | |
2706 } | |
2707 } | |
2708 current_vertices_Y = next_vertices_Y; | |
2709 } | |
2710 if ( number_hits == 1 ) | |
2711 { | |
2712 if ( v46 >= 20 ) | |
2713 break; | |
2714 if ( pFace->uPolygonType == POLYGON_Floor ) | |
2715 v24 = pBModel->pVertices.pVertices[pFace->pVertexIDs[0]].z; | |
2716 else | |
2717 { | |
2718 int a = fixpoint_mul(pFace->zCalc1, X); | |
2719 int b = fixpoint_mul(pFace->zCalc2, Y); | |
2720 int c = ((signed __int64)pFace->zCalc3 >> 16); | |
2721 v24 = a + b + c; | |
2722 } | |
2723 v25 = v46++; | |
2724 odm_floor_level[v25] = v24; | |
2725 current_BModel_id[v25] = pBModelNum; | |
2726 current_Face_id[v25] = pFaceNum; | |
2727 } | |
2728 } | |
2729 } | |
2730 | |
2731 } | |
2732 } | |
2733 } | |
2734 } | |
2735 if ( v46 == 1 ) | |
2736 { | |
2737 *bmodel_pid = 0; | |
2738 return odm_floor_level[0]; | |
2739 } | |
2740 current_floor_level = 0; | |
2741 v29 = 0; | |
2742 if ( v46 <= 1 ) | |
2743 *bmodel_pid = 0; | |
2744 else | |
2745 { | |
2746 current_floor_level = odm_floor_level[0]; | |
2747 for ( uint i = 1; i < v46; ++i ) | |
2748 { | |
2749 next_floor_level = odm_floor_level[i]; | |
2750 if ( current_floor_level <= Z + 5 ) | |
2751 { | |
2752 if ( next_floor_level > current_floor_level && next_floor_level <= Z + 5 ) | |
2753 { | |
2754 current_floor_level = next_floor_level; | |
2755 v29 = i; | |
2756 } | |
2757 } | |
2758 else if ( next_floor_level < current_floor_level ) | |
2759 { | |
2760 current_floor_level = next_floor_level; | |
2761 v29 = i; | |
2762 } | |
2763 } | |
2764 if ( !v29 ) | |
2765 *bmodel_pid = 0; | |
2766 else | |
2767 *bmodel_pid = current_Face_id[v29] | (current_BModel_id[v29] << 6); | |
2768 } | |
2769 if ( v29 ) | |
2770 { | |
2771 *pIsOnWater = false; | |
2772 if ( pOutdoor->pBModels[current_BModel_id[v29]].pFaces[current_Face_id[v29]].Fluid()) | |
2773 *pIsOnWater = true; | |
2774 } | |
2775 if ( odm_floor_level[v29] >= odm_floor_level[0] ) | |
2776 odm_floor_level[0] = odm_floor_level[v29]; | |
2777 return odm_floor_level[0]; | |
2778 } | |
2779 | |
2780 //not sure if right- or left-handed coordinate space assumed, so this could be normal of inverse normal | |
2781 // for a right-handed system, that would be an inverse normal | |
2782 //----- (0046DCC8) -------------------------------------------------------- | |
2783 void ODM_GetTerrainNormalAt(int pos_x, int pos_z, Vec3_int_ *out) | |
2784 { | |
2785 uint grid_x = WorldPosToGridCellX(pos_x); | |
2786 uint grid_z = WorldPosToGridCellZ(pos_z) - 1; | |
2787 | |
2788 int grid_pos_x1 = GridCellToWorldPosX(grid_x); | |
2789 int grid_pos_x2 = GridCellToWorldPosX(grid_x + 1); | |
2790 int grid_pos_z1 = GridCellToWorldPosZ(grid_z); | |
2791 int grid_pos_z2 = GridCellToWorldPosZ(grid_z + 1); | |
2792 | |
2793 int x1z1_y = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z); | |
2794 int x2z1_y = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z); | |
2795 int x2z2_y = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z + 1); | |
2796 int x1z2_y = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z + 1); | |
2797 | |
2798 float side1_dx, side1_dy, side1_dz, | |
2799 side2_dx, side2_dy, side2_dz; | |
2800 | |
2801 int dx = abs(pos_x - grid_pos_x1), | |
2802 dz = abs(grid_pos_z1 - pos_z); | |
2803 if (dz >= dx) | |
2804 { | |
2805 side2_dx = (double)(grid_pos_x2 - grid_pos_x1); | |
2806 side2_dz = 0.0;//(double)(grid_pos_z2 - grid_pos_z2); // bug? z2 - z2 | |
2807 side2_dy = (double)(x2z2_y - x1z2_y); | |
2808 | |
2809 side1_dx = 0.0;//(double)(grid_pos_x1 - grid_pos_x1); | |
2810 side1_dz = (double)(grid_pos_z1 - grid_pos_z2); // z1 - z2 yes | |
2811 side1_dy = (double)(x1z1_y - x1z2_y); | |
2812 //Log::Warning(L"%S %S %u\n", __FILE__, __FUNCTION__, __LINE__); | |
2813 /* |\ | |
2814 side1 | \ | |
2815 |____\ | |
2816 side 2 */ | |
2817 } | |
2818 else | |
2819 { | |
2820 side2_dx = (double)(grid_pos_x1 - grid_pos_x2); | |
2821 side2_dz = 0.0;//(double)(grid_pos_z1 - grid_pos_z1); | |
2822 side2_dy = (double)(x1z1_y - x2z1_y); | |
2823 | |
2824 side1_dx = 0.0;//(double)(grid_pos_x2 - grid_pos_x1); | |
2825 side1_dz = (double)(grid_pos_z2 - grid_pos_z1); | |
2826 side1_dy = (double)(x2z2_y - x2z1_y); | |
2827 /* side 2 | |
2828 _____ | |
2829 \ | | |
2830 \ | side 1 | |
2831 \| */ | |
2832 } | |
2833 | |
2834 float nx = side1_dy * side2_dz - side1_dz * side2_dy; | |
2835 float ny = side1_dx * side2_dy - side1_dy * side2_dx; | |
2836 float nz = side1_dz * side2_dx - side1_dx * side2_dz; | |
2837 | |
2838 float mag = sqrt(nx * nx + ny * ny + nz * nz); | |
2839 if (fabsf(mag) < 1e-6f) | |
2840 { | |
2841 out->y = 0; | |
2842 out->x = 0; | |
2843 out->z = 65536; | |
2844 } | |
2845 else | |
2846 { | |
2847 float invmag = 1.0 / mag; | |
2848 out->x = invmag * nx * 65536.0; | |
2849 out->y = invmag * ny * 65536.0; | |
2850 out->z = invmag * nz * 65536.0; | |
2851 } | |
2852 } | |
2853 //----- (0046BE0A) -------------------------------------------------------- | |
2854 void ODM_UpdateUserInputAndOther() | |
2855 { | |
2856 bool v0; // eax@5 | |
2857 char pOut[32]; // [sp+8h] [bp-20h]@5 | |
2858 | |
2859 UpdateObjects(); | |
2860 ODM_ProcessPartyActions(); | |
2861 if ( pParty->vPosition.x < -22528 | |
2862 || pParty->vPosition.x > 22528 | |
2863 || pParty->vPosition.y < -22528 | |
2864 || pParty->vPosition.y > 22528 ) | |
2865 { | |
2866 strcpy(pOutdoor->pLevelFilename, pCurrentMapName); | |
2867 v0 = pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pOut, 32); | |
2868 if ( !bUnderwater && (pParty->uFlags & (PARTY_FLAGS_1_STANDING_ON_WATER | PARTY_FLAGS_1_FALLING | 0x04) || pParty->uFlags & 0x0200 || pParty->bFlying) || !v0 ) | |
2869 { | |
2870 if ( pParty->vPosition.x < -22528 ) | |
2871 pParty->vPosition.x = -22528; | |
2872 if ( pParty->vPosition.x > 22528 ) | |
2873 pParty->vPosition.x = 22528; | |
2874 if ( pParty->vPosition.y < -22528 ) | |
2875 pParty->vPosition.y = -22528; | |
2876 if ( pParty->vPosition.y > 22528 ) | |
2877 pParty->vPosition.y = 22528; | |
2878 } | |
2879 else | |
2880 { | |
2881 pAudioPlayer->StopChannels(-1, -1); | |
2545 | 2882 pDialogueWindow = new GUIWindow_Travel();//TravelUI_Load(); |
2496 | 2883 } |
2884 } | |
2885 UpdateActors_ODM(); | |
2886 check_event_triggers(); | |
2887 } | |
2888 //----- (0041F54A) -------------------------------------------------------- | |
2889 void OutdoorLocation::LoadActualSkyFrame() | |
2890 { | |
2574 | 2891 if (rest_ui_sky_frame_current) |
2892 { | |
2893 rest_ui_sky_frame_current->Release(); | |
2894 rest_ui_sky_frame_current = nullptr; | |
2895 } | |
2896 if (rest_ui_hourglass_frame_current) | |
2897 { | |
2898 rest_ui_hourglass_frame_current->Release(); | |
2899 rest_ui_hourglass_frame_current = nullptr; | |
2900 } | |
2901 | |
2902 wchar_t name[1024]; | |
2903 swprintf(name, L"TERRA%03d", pParty->uCurrentMinute / 6 + 10 * pParty->uCurrentHour); | |
2904 | |
2496 | 2905 sprintf(pTmpBuf.data(), "TERRA%03d", pParty->uCurrentMinute / 6 + 10 * pParty->uCurrentHour); |
2574 | 2906 rest_ui_sky_frame_current = assets->GetImage_16BitColorKey(name, 0x7FF); |
2496 | 2907 } |
2908 | |
2909 | |
2910 //----- (004626BA) -------------------------------------------------------- | |
2911 OutdoorLocation::OutdoorLocation() | |
2912 { | |
2913 subconstuctor(); | |
2914 uLastSunlightUpdateMinute = 0; | |
2915 | |
2916 uNumBModels = 0; | |
2917 pBModels = nullptr; | |
2918 } | |
2919 | |
2920 //----- (004626CD) -------------------------------------------------------- | |
2921 void OutdoorLocation::subconstuctor() | |
2922 { | |
2923 //OutdoorLocationTerrain::OutdoorLocationTerrain(&this->pTerrain); | |
2924 field_F0 = 0; | |
2925 field_F4 = 0x40000000u; | |
2926 //DLVHeader::DLVHeader(&v1->ddm); | |
2927 pSpawnPoints = 0; | |
2928 pBModels = 0; | |
2929 pCmap = 0; | |
2930 pFaceIDLIST = 0; | |
2931 pOMAP = 0; | |
2932 } | |
2933 | |
2934 //----- (00481E55) -------------------------------------------------------- | |
2935 void ODM_Project(unsigned int uNumVertices) | |
2936 { | |
2937 for ( uint i = 0; i < uNumVertices; i++ ) | |
2938 { | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2545
diff
changeset
|
2939 memcpy(&VertexRenderList[i], &array_507D30[i], sizeof(VertexRenderList[i])); |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2545
diff
changeset
|
2940 VertexRenderList[i].vWorldViewProjX = (double)pViewport->uScreenCenterX |
2496 | 2941 - ((double)pODMRenderParams->int_fov_rad * array_507D30[i]._rhw) * array_507D30[i].vWorldViewPosition.y; |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2545
diff
changeset
|
2942 VertexRenderList[i].vWorldViewProjY = (double)pViewport->uScreenCenterY |
2496 | 2943 - ((double)pODMRenderParams->int_fov_rad * array_507D30[i]._rhw) * array_507D30[i].vWorldViewPosition.z; |
2944 } | |
2945 } | |
2946 //----- (00485F64) -------------------------------------------------------- | |
2947 void ODMRenderParams::Initialize() | |
2948 { | |
2949 int v1; // eax@1 | |
2950 int v2; // eax@2 | |
2951 signed __int64 v3; // qtt@4 | |
2952 int v4; // eax@4 | |
2953 | |
2954 this->uCameraFovInDegrees = 75; | |
2955 v1 = stru_5C6E00->uPiMask & 0xD5; | |
2956 if ( v1 >= (signed int)stru_5C6E00->uIntegerHalfPi ) | |
2957 v2 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v1]; | |
2958 else | |
2959 v2 = stru_5C6E00->pTanTable[v1]; | |
2960 LODWORD(v3) = (viewparams->uSomeZ - viewparams->uSomeX) << 31; | |
2961 HIDWORD(v3) = (viewparams->uSomeZ - viewparams->uSomeX) << 15 >> 16; | |
2962 v4 = (signed int)(v3 / v2) >> 16; | |
2963 this->int_fov_rad = v4; | |
2964 this->field_4C = 360000; | |
2965 this->int_fov_rad_inv = 65536 / v4; | |
2966 this->field_50 = 115; | |
2967 //sr_6BE060[1] = 1; | |
2968 //RotationToInts(); | |
2969 } | |
2970 //----- (00473893) -------------------------------------------------------- | |
2971 void ODM_ProcessPartyActions() | |
2972 { | |
2973 int v1; // edi@1 | |
2974 int v2; // ebx@1 | |
2975 int floor_level; // eax@14 | |
2976 ODMFace *face; // ecx@45 | |
2977 int v34; // esi@143 | |
2978 int v35; // esi@147 | |
2979 int v36; // eax@155 | |
2980 int v40; // esi@162 | |
2981 bool v42; // eax@180 | |
2982 signed int v43; // ecx@184 | |
2983 signed int v44; // edx@184 | |
2984 int v45; // ecx@200 | |
2985 BSPModel *pModel; // eax@203 | |
2986 bool pModel_; | |
2987 ODMFace *pODMFace; // esi@203 | |
2988 int v48; // eax@203 | |
2989 int v54; // eax@215 | |
2990 int v55; // eax@217 | |
2991 unsigned int v66; // esi@263 | |
2992 signed int v68; // ecx@263 | |
2993 int v69; // eax@263 | |
2994 bool v77; // edx@297 | |
2995 bool v78; // ecx@303 | |
2996 int v79; // ecx@314 | |
2997 __int16 v80; // dx@317 | |
2998 int pTerrainHeight; // eax@321 | |
2999 int v87; // [sp-20h] [bp-B4h]@248 | |
3000 int v97; // [sp+Ch] [bp-88h]@180 | |
3001 Vec3_int_ v98; | |
3002 bool not_high_fall; // [sp+1Ch] [bp-78h]@33 | |
3003 int v102; // [sp+20h] [bp-74h]@1 | |
3004 int trigger_id; // [sp+24h] [bp-70h]@1 | |
3005 bool bFeatherFall; // [sp+28h] [bp-6Ch]@4 | |
3006 int bonus; | |
3007 int on_ground; // [sp+2Ch] [bp-68h]@24 | |
3008 bool bWaterWalk; // [sp+30h] [bp-64h]@1 | |
3009 int ceiling_height; // [sp+3Ch] [bp-58h]@28 | |
3010 int v110; // [sp+40h] [bp-54h]@180 | |
3011 int v111; // [sp+44h] [bp-50h]@14 | |
3012 bool hovering; // [sp+48h] [bp-4Ch]@1 | |
3013 int v113; // [sp+4Ch] [bp-48h]@1 | |
3014 bool party_running_flag; // [sp+50h] [bp-44h]@1 | |
3015 int _walk_speed; // [sp+54h] [bp-40h]@48 | |
3016 int pX; // [sp+58h] [bp-3Ch]@1 | |
3017 int pY; // [sp+5Ch] [bp-38h]@1 | |
2534 | 3018 int party_new_Z; // [sp+74h] [bp-20h]@1 |
2496 | 3019 int v118; // [sp+60h] [bp-34h]@1 |
3020 int _angle_x; // [sp+68h] [bp-2Ch]@48 | |
3021 unsigned int v122; // [sp+70h] [bp-24h]@180 | |
2534 | 3022 |
2496 | 3023 bool party_walking_flag; // [sp+78h] [bp-1Ch]@1 |
3024 int _angle_y; // [sp+7Ch] [bp-18h]@48 | |
3025 int v128; // [sp+88h] [bp-Ch]@1 | |
3026 int v129; // [sp+8Ch] [bp-8h]@92 | |
3027 | |
3028 v1 = 0; | |
3029 trigger_id = 0; | |
3030 v2 = 0; | |
3031 //*(float *)&v128 = 0.0; | |
3032 int fall_speed = pParty->uFallSpeed; | |
3033 v128 = 0; | |
3034 v129 = 0; | |
2534 | 3035 |
2496 | 3036 pX = pParty->vPosition.x; |
3037 pY = pParty->vPosition.y; | |
2534 | 3038 party_new_Z = pParty->vPosition.z; |
3039 | |
2496 | 3040 v113 = pParty->field_6F0; |
3041 hovering = false; | |
3042 bool partyAtHighSlope = IsTerrainSlopeTooHigh(pParty->vPosition.x, pParty->vPosition.y); | |
3043 party_running_flag = false; | |
3044 party_walking_flag = false; | |
3045 v102 = 0; | |
3046 pModel_ = false; | |
3047 bWaterWalk = false; | |
2534 | 3048 //************************************ |
3049 //Проверка падение пера | |
3050 if (!pParty->FeatherFallActive()) | |
2496 | 3051 { |
3052 bFeatherFall = false; | |
3053 for (int i = 0; i < 4; ++i) | |
3054 if (pParty->pPlayers[i].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT)) // seems like flying boots | |
3055 { | |
3056 bFeatherFall = true; | |
3057 break; | |
3058 } | |
3059 } | |
3060 else | |
3061 bFeatherFall = true; | |
2534 | 3062 //************************************ |
3063 //Проверка хождения по воде | |
2496 | 3064 pParty->uFlags &= ~PARTY_FLAGS_1_STANDING_ON_WATER; |
2534 | 3065 if (pParty->WaterWalkActive()) |
2496 | 3066 { |
3067 //LOBYTE(pParty->uFlags) &= 0x7Fu; | |
3068 bWaterWalk = true; | |
2508 | 3069 *(short *)&stru_5E4C90_MapPersistVars._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 119] |= 1; |
2496 | 3070 if (!(pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags & 1) && |
3071 pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster - 1].sMana <= 0 ) | |
3072 bWaterWalk = false; | |
3073 } | |
2534 | 3074 //************************************* |
3075 //определение уровня пола | |
3076 int bmodel_standing_on_pid; //данные 3D model'и | |
3077 int is_on_water = false; //на воду | |
3078 floor_level = ODM_GetFloorLevel(pX, pY, party_new_Z, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, bWaterWalk); | |
3079 int is_not_on_bmodel = bmodel_standing_on_pid == 0; //не на 3D model | |
3080 | |
3081 v111 = floor_level; //??? | |
3082 //************************************ | |
3083 //определение высоты падения | |
3084 if ( bFeatherFall ) //падение пера | |
2496 | 3085 pParty->uFallStartY = floor_level; |
3086 else | |
3087 floor_level = pParty->uFallStartY; | |
2534 | 3088 //************************************* |
3089 //падение на 3D Model | |
3090 if ( floor_level - party_new_Z > 512 && !bFeatherFall && party_new_Z <= v111 + 1 ) | |
2496 | 3091 { |
3092 if (pParty->uFlags & PARTY_FLAGS_1_LANDING) | |
3093 pParty->uFlags &= ~PARTY_FLAGS_1_LANDING; | |
3094 else for (int i = 0; i < 4; ++i) // receive falling damage | |
3095 { | |
3096 if ( !pParty->pPlayers[i].HasEnchantedItemEquipped(72) && !pParty->pPlayers[i].WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) | |
3097 { | |
3098 pParty->pPlayers[i].ReceiveDamage( | |
2534 | 3099 (signed int)((pParty->uFallStartY - party_new_Z) * (unsigned __int64)(pParty->pPlayers[i].GetMaxHealth() / 10)) / 256, DMGT_PHISYCAL); |
2496 | 3100 bonus = 20 - pParty->pPlayers[i].GetParameterBonus(pParty->pPlayers[i].GetActualEndurance()); |
3101 pParty->pPlayers[i].SetRecoveryTime((signed __int64)((double)bonus * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); | |
3102 } | |
3103 } | |
3104 } | |
2534 | 3105 //********************************* |
3106 //определение высоты потолка | |
2496 | 3107 ceiling_height = -1; |
2534 | 3108 if ( pParty->bFlying ) //в полёте |
3109 ceiling_height = GetCeilingHeight(pX, pY, party_new_Z + pParty->uPartyHeight, (int)&v102);//высота потолка | |
2496 | 3110 //v107 = bmodel_standing_on_pid == 0; |
2534 | 3111 on_ground = v111 + 1; //на земле |
3112 //************************************** | |
3113 | |
3114 if ( party_new_Z <= on_ground )//полёт: посадка | |
2496 | 3115 { |
3116 ceiling_height = -1; | |
3117 pParty->bFlying = false; | |
3118 } | |
3119 else | |
3120 hovering = true; | |
2534 | 3121 not_high_fall = party_new_Z - v111 <= 32; |
3122 //**************************************** | |
3123 //timer update(обновить таймер звука ходьбы) | |
3124 if ( bWalkSound && pParty->walk_sound_timer) | |
2496 | 3125 { |
3126 if (pParty->walk_sound_timer >= pEventTimer->uTimeElapsed) | |
3127 pParty->walk_sound_timer -= pEventTimer->uTimeElapsed; | |
3128 else | |
3129 pParty->walk_sound_timer = 0; | |
3130 } | |
2534 | 3131 //**************************************** |
3132 // конец действия полёта | |
3133 if (!bUnderwater && pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime <= 0)//не под водой и время закла полёта закончилось | |
2496 | 3134 pParty->bFlying = false; |
2534 | 3135 //***************************************** |
3136 // установить на чём стоит группа | |
3137 if (!hovering)//не в воздухе | |
2496 | 3138 { |
3139 if ( pParty->floor_face_pid != PID(OBJECT_BModel, bmodel_standing_on_pid) ) | |
3140 { | |
3141 if (bmodel_standing_on_pid) | |
3142 { | |
2534 | 3143 int BModel_id = bmodel_standing_on_pid >> 6; |
3144 if ( BModel_id < pOutdoor->uNumBModels ) | |
2496 | 3145 { |
2534 | 3146 face = pOutdoor->pBModels[BModel_id].pFaces; |
3147 int face_id = bmodel_standing_on_pid & 0x3F; | |
2496 | 3148 /*if ( *(char *)(v7->pFacePlane.vNormal.x + 308 * v6 + 31) & 4 ) |
3149 { | |
3150 pParty->field_6F4_packedid = PID(OBJECT_BModel,v108); | |
3151 v103 = *(short *)(v7->pFacePlane.vNormal.x + 308 * v6 + 292); | |
3152 }*/ | |
2534 | 3153 if ( face[face_id].uAttributes & FACE_PRESSURE_PLATE ) |
2496 | 3154 { |
3155 pParty->floor_face_pid = PID(OBJECT_BModel, bmodel_standing_on_pid); | |
2534 | 3156 trigger_id = face[face_id].sCogTriggeredID; //EVT, панель имеет событие |
2496 | 3157 } |
3158 } | |
3159 } | |
3160 } | |
2534 | 3161 pParty->floor_face_pid = PID(OBJECT_BModel, bmodel_standing_on_pid);//6 - на земле |
2496 | 3162 } |
2534 | 3163 //*********************************************** |
2496 | 3164 _walk_speed = pParty->uWalkSpeed; |
3165 _angle_y = pParty->sRotationY; | |
3166 _angle_x = pParty->sRotationX; | |
3167 //v126 = pEventTimer->dt_in_some_format; | |
3168 /*v119 = (Player **)((unsigned __int64)(pEventTimer->dt_in_some_format | |
3169 * (signed __int64)((signed int)(pParty->field_20_prolly_turn_speed | |
3170 * stru_5C6E00->uIntegerPi) | |
3171 / 180)) >> 16);*/ | |
3172 __int64 dturn = (unsigned __int64)(pEventTimer->dt_in_some_format * (signed __int64)((signed int)(pParty->y_rotation_speed * stru_5C6E00->uIntegerPi) / 180)) >> 16; | |
3173 while (pPartyActionQueue->uNumActions) | |
3174 { | |
3175 switch (pPartyActionQueue->Next()) | |
3176 { | |
3177 case PARTY_FlyUp://полёт вверх | |
3178 { | |
3179 if (!pParty->FlyActive() && !bUnderwater) | |
3180 break; | |
3181 | |
3182 pParty->bFlying = false; | |
3183 if (bUnderwater || | |
3184 pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags & 1 || | |
3185 pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].sMana > 0 ) | |
3186 { | |
3187 extern int max_flight_height; | |
3188 if ( pParty->vPosition.z < max_flight_height || hovering ) | |
3189 { | |
2534 | 3190 party_new_Z += 30; |
2496 | 3191 v113 += 30; |
3192 pParty->bFlying = true; | |
2534 | 3193 if ( party_new_Z > max_flight_height ) |
2496 | 3194 { |
2534 | 3195 party_new_Z = max_flight_height; |
2496 | 3196 v113 = max_flight_height; |
3197 } | |
3198 v1 = 0; | |
3199 v2 = 0; | |
3200 fall_speed = 0; | |
3201 *(float *)&v128 = 0.0; | |
2534 | 3202 if ( v102 && party_new_Z < ceiling_height && (signed int)(pParty->uPartyHeight + party_new_Z) >= ceiling_height )//столкновение с потолком |
2496 | 3203 { |
3204 pParty->field_6E0 = 0; | |
3205 pParty->field_6E4 = 0; | |
3206 pPartyActionQueue->uNumActions = 0; | |
3207 pParty->uFlags |= PARTY_FLAGS_1_LANDING; | |
3208 pParty->vPosition.z = ceiling_height - pParty->uPartyHeight - 31; | |
2534 | 3209 pParty->field_6F0 = party_new_Z; |
2496 | 3210 pParty->bFlying = false; |
2534 | 3211 party_new_Z = ceiling_height - pParty->uPartyHeight - 31; |
2496 | 3212 v113 = pParty->field_6F0; |
3213 } | |
3214 pParty->uFallSpeed = 0; | |
3215 pModel_ = true; | |
3216 } | |
3217 } | |
3218 } | |
3219 break; | |
3220 | |
3221 case PARTY_FlyDown://полёт вниз | |
3222 if (pParty->FlyActive() || bUnderwater) | |
3223 { | |
3224 pParty->bFlying = false; | |
3225 if ( bUnderwater | |
3226 || pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags & 1 | |
3227 || pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].sMana > 0 )//*(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster + 10] > 0 ) | |
3228 { | |
2534 | 3229 party_new_Z -= 30; |
2496 | 3230 v113 -= 30; |
3231 pParty->uFallSpeed = 0; | |
3232 fall_speed = 0; | |
3233 pParty->bFlying = true; | |
3234 pModel_ = true; | |
2534 | 3235 if ( party_new_Z <= v111 ) |
2496 | 3236 { |
3237 pParty->bFlying = false; | |
3238 pPartyActionQueue->uNumActions = 0; | |
3239 } | |
3240 } | |
3241 } | |
3242 break; | |
3243 | |
2534 | 3244 case PARTY_TurnLeft://поворот влево |
2496 | 3245 if (uTurnSpeed) |
3246 _angle_y += uTurnSpeed; //descrete turn | |
3247 else | |
3248 _angle_y += dturn * fTurnSpeedMultiplier; // time-based smooth turn | |
3249 | |
3250 _angle_y &= stru_5C6E00->uDoublePiMask; | |
3251 break; | |
3252 | |
2534 | 3253 case PARTY_TurnRight://поворот вправо |
2496 | 3254 if (uTurnSpeed) |
3255 _angle_y -= uTurnSpeed; | |
3256 else | |
3257 _angle_y -= dturn * fTurnSpeedMultiplier; | |
3258 | |
3259 _angle_y &= stru_5C6E00->uDoublePiMask; | |
3260 break; | |
3261 | |
2534 | 3262 case PARTY_FastTurnLeft://быстрый поворот влево |
2496 | 3263 if (uTurnSpeed) |
3264 _angle_y += uTurnSpeed; | |
3265 else | |
3266 _angle_y += 2.0f * fTurnSpeedMultiplier * (double)dturn; | |
3267 | |
3268 _angle_y &= stru_5C6E00->uDoublePiMask; | |
3269 break; | |
3270 | |
2534 | 3271 case PARTY_FastTurnRight://быстрый поворот вправо |
2496 | 3272 if (!uTurnSpeed) |
3273 _angle_y -= 2.0f * fTurnSpeedMultiplier * (double)dturn; | |
3274 else | |
3275 _angle_y -= uTurnSpeed; | |
3276 | |
3277 _angle_y &= stru_5C6E00->uDoublePiMask; | |
3278 break; | |
3279 | |
3280 case PARTY_StrafeLeft://хождение боком в влево | |
3281 { | |
3282 *(float *)&v128 = pParty->uWalkSpeed; | |
3283 | |
2534 | 3284 float sin_y = sinf(2 * pi_double * _angle_y / 2048.0); |
2496 | 3285 int dx = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; |
3286 v2 -= 3 * dx / 4; | |
3287 | |
2534 | 3288 float cos_y = cosf(2 * pi_double * _angle_y / 2048.0); |
2496 | 3289 int dy = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; |
3290 v1 += 3 * dy / 4; | |
3291 | |
3292 v128 = v1; | |
3293 party_walking_flag = true; | |
3294 } | |
3295 break; | |
3296 | |
3297 case PARTY_StrafeRight://хождение боком в вправо | |
3298 { | |
3299 *(float *)&v128 = pParty->uWalkSpeed; | |
3300 | |
2534 | 3301 float sin_y = sinf(2 * pi_double * _angle_y / 2048.0); |
2496 | 3302 int dx = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; |
3303 v2 += 3 * dx / 4; | |
3304 | |
2534 | 3305 float cos_y = cosf(2 * pi_double * _angle_y / 2048.0); |
2496 | 3306 int dy = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; |
3307 v1 -= 3 * dy / 4; | |
3308 | |
3309 v128 = v1; | |
3310 party_walking_flag = true; | |
3311 } | |
3312 break; | |
3313 | |
3314 case PARTY_WalkForward:// идти вперёд | |
3315 { | |
3316 *(float *)&v128 = _walk_speed; | |
3317 | |
2534 | 3318 float sin_y = sinf(2 * pi_double * _angle_y / 2048.0), |
3319 cos_y = cosf(2 * pi_double * _angle_y / 2048.0); | |
2496 | 3320 |
3321 int dx = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; | |
3322 int dy = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; | |
3323 | |
3324 if ( new_speed ) | |
3325 { | |
3326 v2 += dx * 12; | |
3327 v1 += dy * 12; | |
3328 } | |
3329 else | |
3330 { | |
3331 v2 += dx; | |
3332 v1 += dy; | |
3333 } | |
3334 | |
3335 v128 = v1; | |
3336 party_walking_flag = true; | |
3337 } | |
3338 break; | |
3339 | |
3340 case PARTY_RunForward://бежать вперёд | |
3341 { | |
3342 *(float *)&v128 = _walk_speed; | |
3343 | |
2534 | 3344 float sin_y = sinf(2 * pi_double * _angle_y / 2048.0); |
3345 float cos_y = cosf(2 * pi_double * _angle_y / 2048.0); | |
2496 | 3346 |
3347 int dx = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; | |
3348 int dy = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; | |
3349 | |
3350 if (pParty->bFlying)//лететь вперёд | |
3351 { | |
3352 v2 += 4 * dx; | |
3353 v1 += 4 * dy; | |
3354 | |
3355 v128 = v1; | |
3356 } | |
3357 else if (partyAtHighSlope && !bmodel_standing_on_pid)//сбегание со склона | |
3358 { | |
3359 v2 += dx; | |
3360 v1 += dy; | |
3361 | |
3362 v128 = v1; | |
3363 party_walking_flag = true; | |
3364 } | |
3365 else | |
3366 { | |
3367 /*v2 += (unsigned __int64)(stru_5C6E00->Cos(_angle_y) | |
3368 * (signed __int64)(signed int)(2 * (unsigned __int64)(signed __int64)((double)_walk_speed * fWalkSpeedMultiplier))) >> 16; | |
3369 v1 += (unsigned __int64)((signed int)stru_5C6E00->Sin(_angle_y) | |
3370 * (signed __int64)(signed int)(2 * (unsigned __int64)(signed __int64)((double)_walk_speed * fWalkSpeedMultiplier))) >> 16;*/ | |
3371 | |
3372 v2 += 2 * dx; | |
3373 v1 += 2 * dy; | |
3374 | |
3375 v128 = v1; | |
3376 party_running_flag = true; | |
3377 } | |
3378 } | |
3379 break; | |
3380 | |
3381 | |
3382 case PARTY_WalkBackward://идти назад | |
3383 { | |
3384 *(float *)&v128 = _walk_speed; | |
3385 | |
3386 float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0), | |
3387 cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0); | |
3388 | |
3389 int dx = cos_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier; | |
3390 v2 -= dx; | |
3391 | |
3392 int dy = sin_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier; | |
3393 v1 -= dy; | |
3394 | |
3395 v128 = v1; | |
3396 party_walking_flag = true; | |
3397 } | |
3398 break; | |
3399 | |
3400 | |
3401 case PARTY_RunBackward://бежать назад | |
3402 { | |
3403 float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0), | |
3404 cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0); | |
3405 | |
3406 int dx = cos_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier; | |
3407 int dy = sin_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier; | |
3408 | |
3409 if (pParty->bFlying) | |
3410 { | |
3411 v2 -= 4 * dx; | |
3412 v1 -= 4 * dy; | |
3413 v128 = v1; | |
3414 } | |
3415 else | |
3416 { | |
3417 v2 -= dx; | |
3418 v1 -= dy; | |
3419 | |
3420 v128 = v1; | |
3421 party_walking_flag = true; | |
3422 } | |
3423 } | |
3424 break; | |
3425 | |
3426 case PARTY_CenterView://смотреть прямо | |
3427 _angle_x = 0; | |
3428 break; | |
3429 | |
3430 case PARTY_LookUp://смотреть вверх | |
3431 _angle_x += (signed __int64)(flt_6BE150_look_up_down_dangle * 25.0); | |
3432 if ( _angle_x > 128 ) | |
3433 _angle_x = 128; | |
3434 if (uActiveCharacter) | |
3435 pPlayers[uActiveCharacter]->PlaySound(SPEECH_63, 0); | |
3436 break; | |
3437 | |
3438 case PARTY_LookDown://смотреть вниз | |
3439 _angle_x += (signed __int64)(flt_6BE150_look_up_down_dangle * -25.0); | |
3440 if ( _angle_x < -128 ) | |
3441 _angle_x = -128; | |
3442 if (uActiveCharacter) | |
3443 pPlayers[uActiveCharacter]->PlaySound(SPEECH_64, 0); | |
3444 break; | |
3445 | |
3446 case PARTY_Jump://прыжок | |
3447 if ( (!partyAtHighSlope || bmodel_standing_on_pid) && !hovering && pParty->field_24 && !(pParty->uFlags & 4) && !(pParty->uFlags & 0x200) ) | |
3448 { | |
3449 //v126 = pParty->field_24 << 6; | |
3450 hovering = true; | |
3451 fall_speed = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)fall_speed); | |
3452 } | |
3453 break; | |
3454 | |
3455 case PARTY_Land://приземление(клавиша Home) | |
3456 if (pParty->bFlying) | |
3457 { | |
3458 pParty->uFlags |= PARTY_FLAGS_1_LANDING; | |
3459 pParty->uFallSpeed = 0; | |
3460 } | |
3461 pParty->bFlying = false; | |
3462 pPartyActionQueue->uNumActions = 0; | |
3463 break; | |
3464 | |
3465 default: | |
3466 assert(false); | |
3467 | |
3468 | |
3469 } | |
3470 } | |
3471 | |
3472 pParty->sRotationY = _angle_y; | |
3473 pParty->sRotationX = _angle_x; | |
3474 //------------------------------------------- | |
3475 if ( pParty->bFlying ) | |
3476 { | |
3477 v129 = fixpoint_mul(4, stru_5C6E00->Cos(GetTickCount())); | |
2534 | 3478 party_new_Z = v113 + v129; |
2496 | 3479 if ( pModel_ ) |
2534 | 3480 party_new_Z = v113; |
2496 | 3481 if (pParty->FlyActive()) |
3482 stru_5E4C90_MapPersistVars._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] &= 0xFE; | |
2534 | 3483 pParty->uFallStartY = party_new_Z; |
2496 | 3484 } |
2534 | 3485 else if ( party_new_Z < v111 ) |
2496 | 3486 { |
3487 if ( is_on_water && fall_speed ) | |
3488 SpriteObject::sub_42F960_create_object(pX, pY, v111); | |
3489 fall_speed = 0; | |
2534 | 3490 party_new_Z = v111; |
2496 | 3491 pParty->uFallStartY = v111; |
2534 | 3492 v113 = party_new_Z; |
2496 | 3493 if (pParty->FlyActive()) |
3494 stru_5E4C90_MapPersistVars._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] |= 1; | |
3495 } | |
3496 else | |
3497 { | |
2534 | 3498 v113 = party_new_Z; |
2496 | 3499 if (pParty->FlyActive()) |
3500 stru_5E4C90_MapPersistVars._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] |= 1; | |
3501 } | |
3502 //------------------------------------------ | |
3503 if (hovering && !pParty->bFlying)//расчёт скорости падения | |
3504 { | |
3505 //v33 = -(pEventTimer->uTimeElapsed * GetGravityStrength()); | |
3506 v34 = fall_speed + (-(pEventTimer->uTimeElapsed * GetGravityStrength()) << 1); | |
3507 fall_speed += (-(pEventTimer->uTimeElapsed * GetGravityStrength()) << 1 ); //y(t) = 2*gt | |
3508 } | |
3509 else if (!partyAtHighSlope) | |
3510 v34 = fall_speed; | |
3511 else if (!hovering) | |
3512 { | |
3513 if ( !bmodel_standing_on_pid ) | |
3514 { | |
3515 // rolling down the hill | |
3516 // how it's done: you get a little bit pushed in the air along terrain normal, getting in the air | |
3517 // and falling to the gravity, gradually sliding downwards. nice trick | |
2534 | 3518 party_new_Z = v111; |
2496 | 3519 ODM_GetTerrainNormalAt(pX, pY, &v98); |
3520 v35 = fall_speed + (8 * -(pEventTimer->uTimeElapsed * GetGravityStrength())); | |
3521 v129 = abs(v2 * v98.x + v1 * v98.y + v35 * v98.z) >> 16; | |
3522 v2 += fixpoint_mul(v129, v98.x); | |
3523 v1 += fixpoint_mul(v129, v98.y); | |
3524 v34 = v35 + fixpoint_mul(v129, v98.z); | |
3525 v128 = v1; | |
3526 fall_speed = v34; | |
3527 } | |
3528 } | |
3529 else | |
3530 v34 = fall_speed; | |
3531 | |
3532 if ( hovering )//блок для крика падения | |
3533 { | |
3534 if ( !bUnderwater && v34 <= 0) | |
3535 { | |
3536 if ( v34 < -500 && !pParty->bFlying && pParty->vPosition.z - v111 > 1000 && !pParty->FeatherFallActive()) | |
3537 { // falling scream | |
3538 for (int i = 0; i < 4; ++i) | |
3539 { | |
3540 if (!pParty->pPlayers[i].HasEnchantedItemEquipped(72) | |
3541 && !pParty->pPlayers[i].WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) | |
3542 && pParty->pPlayers[i].CanAct()) | |
3543 pParty->pPlayers[i].PlaySound(SPEECH_Falling_scream, 0);//крик падения | |
3544 } | |
3545 } | |
3546 } | |
3547 } | |
3548 else | |
2534 | 3549 pParty->uFallStartY = party_new_Z; |
2496 | 3550 |
3551 if ( v2 * v2 + v1 * v1 < 400 && !partyAtHighSlope ) | |
3552 { | |
3553 *(float *)&v128 = 0.0; | |
3554 v2 = 0; | |
3555 } | |
3556 //--(столкновения)------------------------------------------------------------------- | |
3557 stru_721530.field_84 = -1; | |
3558 stru_721530.field_70 = 0; | |
3559 stru_721530.prolly_normal_d = pParty->field_14_radius; | |
3560 stru_721530.field_8_radius = pParty->field_14_radius / 2; | |
3561 stru_721530.field_0 = 1; | |
3562 stru_721530.height = pParty->uPartyHeight - 32; | |
3563 for ( uint i = 0; i < 100; i++ ) | |
3564 { | |
3565 stru_721530.position.x = pX; | |
3566 stru_721530.position.y = pY; | |
2534 | 3567 stru_721530.position.z = stru_721530.height + party_new_Z + 1; |
2496 | 3568 |
3569 stru_721530.normal.x = pX; | |
3570 stru_721530.normal.y = pY; | |
2534 | 3571 stru_721530.normal.z = stru_721530.prolly_normal_d + party_new_Z + 1; |
2496 | 3572 |
3573 stru_721530.velocity.x = v2; | |
3574 stru_721530.velocity.y = v128; | |
3575 stru_721530.velocity.z = fall_speed; | |
3576 | |
3577 stru_721530.uSectorID = 0; | |
3578 v36 = 0; | |
3579 if ( pParty->bTurnBasedModeOn == true && pTurnEngine->turn_stage == TE_MOVEMENT ) | |
3580 v36 = 13312; | |
3581 if ( stru_721530._47050A(v36) ) | |
3582 break; | |
3583 _46E889_collide_against_bmodels(1); | |
3584 //v37 = WorldPosToGridCellZ(pParty->vPosition.y); | |
3585 //v38 = WorldPosToGridCellX(pParty->vPosition.x); | |
3586 _46E26D_collide_against_sprites(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y)); | |
3587 _46ED8A_collide_against_sprite_objects(4); | |
3588 for ( uint actor_id = 0; actor_id < (signed int)uNumActors; ++actor_id ) | |
3589 Actor::_46DF1A_collide_against_actor(actor_id, 0); | |
3590 if ( stru_721530.field_7C >= stru_721530.field_6C ) | |
3591 { | |
3592 _angle_x = stru_721530.normal2.x; | |
3593 _angle_y = stru_721530.normal2.y; | |
3594 v40 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; | |
3595 } | |
3596 else | |
3597 { | |
3598 _angle_x = pX + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x); | |
3599 _angle_y = pY + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y); | |
3600 //pModel = (BSPModel *)fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); | |
2534 | 3601 v40 = fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z) + party_new_Z; |
2496 | 3602 } |
3603 v122 = v40; | |
3604 ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0); | |
3605 v129 = ODM_GetFloorLevel(_angle_x, pY, v40, pParty->uPartyHeight, &is_on_water, &v97, 0); | |
3606 int v119 = ODM_GetFloorLevel(pX, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &v110, 0); | |
3607 bool v42_ = (BSPModel *)IsTerrainSlopeTooHigh(_angle_x, pY); | |
3608 v42 = IsTerrainSlopeTooHigh(pX, _angle_y); | |
3609 is_not_on_bmodel = false; | |
3610 //v118 = v42; | |
3611 if ( !v97 && !v110 && !bmodel_standing_on_pid ) | |
3612 is_not_on_bmodel = true; | |
3613 v43 = 1; | |
3614 v44 = 1; | |
3615 if ( bUnderwater || !is_not_on_bmodel ) | |
3616 { | |
3617 pX = _angle_x; | |
3618 if ( v43 ) | |
3619 pY = _angle_y; | |
3620 } | |
3621 else | |
3622 { | |
2534 | 3623 if ( v42_ && v129 > party_new_Z ) |
2496 | 3624 v44 = 0; |
2534 | 3625 if ( v42 && v119 > party_new_Z ) |
2496 | 3626 v43 = 0; |
3627 if ( v44 ) | |
3628 { | |
3629 pX = _angle_x; | |
3630 if ( v43 ) | |
3631 pY = _angle_y; | |
3632 } | |
3633 else if ( v43 ) | |
3634 pY = _angle_y; | |
3635 else | |
3636 { | |
3637 int new_ = ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0); | |
2534 | 3638 if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && new_ <= party_new_Z ) |
2496 | 3639 { |
3640 v43 = 1; | |
3641 pX = _angle_x; | |
3642 if ( v43 ) | |
3643 pY = _angle_y; | |
3644 } | |
3645 } | |
3646 } | |
3647 if ( stru_721530.field_7C >= stru_721530.field_6C ) | |
3648 { | |
3649 if ( !is_not_on_bmodel ) | |
3650 { | |
3651 pX = stru_721530.normal2.x; | |
3652 pY = stru_721530.normal2.y; | |
3653 } | |
2534 | 3654 party_new_Z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; |
2496 | 3655 break; |
3656 } | |
3657 stru_721530.field_70 += stru_721530.field_7C; | |
3658 pX = _angle_x; | |
3659 pY = _angle_y; | |
3660 v45 = stru_721530.uFaceID; | |
2534 | 3661 party_new_Z = v40; |
2496 | 3662 |
3663 if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor) | |
3664 { | |
3665 if (pParty->Invisible()) | |
3666 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); | |
3667 viewparams->bRedrawGameUI = true; | |
3668 } | |
3669 | |
3670 if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) | |
3671 { | |
3672 v129 = stru_5C6E00->Atan2(_angle_x - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x, | |
3673 _angle_y - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y); | |
3674 v2 = fixpoint_mul(stru_5C6E00->Cos(v129), integer_sqrt(v2 * v2 + v128 * v128)); | |
3675 v122 = fixpoint_mul(stru_5C6E00->Sin(v129), integer_sqrt(v2 * v2 + v128 * v128)); | |
3676 v128 = fixpoint_mul(stru_5C6E00->Sin(v129), integer_sqrt(v2 * v2 + v128 * v128)); | |
3677 } | |
3678 | |
3679 if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) | |
3680 { | |
3681 pParty->bFlying = false; | |
3682 pModel = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; | |
3683 pODMFace = &pModel->pFaces[((signed int)stru_721530.uFaceID >> 3) & 0x3F]; | |
3684 v48 = pODMFace->pBoundingBox.z2 - pODMFace->pBoundingBox.z1; | |
3685 v129 = v48 <= 32; | |
3686 v119 = pODMFace->pFacePlane.vNormal.z < 46378; | |
3687 if ( bUnderwater == 1 ) | |
3688 v119 = 0; | |
3689 if ( pODMFace->uPolygonType == POLYGON_Floor ) | |
3690 { | |
3691 if ( fall_speed < 0 ) | |
3692 fall_speed = 0; | |
2534 | 3693 party_new_Z = pModel->pVertices.pVertices[pODMFace->pVertexIDs[0]].z + 1; |
2496 | 3694 if ( v2 * v2 + v128 * v128 < 400 ) |
3695 { | |
3696 v2 = 0; | |
3697 *(float *)&v128 = 0.0; | |
3698 } | |
3699 if ( pParty->floor_face_pid != v45 && pODMFace->Pressure_Plate() ) | |
3700 { | |
3701 pParty->floor_face_pid = v45; | |
3702 trigger_id = pODMFace->sCogTriggeredID; | |
3703 } | |
3704 } | |
3705 if ( !v129 && (pODMFace->uPolygonType != POLYGON_InBetweenFloorAndWall || v119) )// упёрся в столб | |
3706 { | |
3707 v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + fall_speed * pODMFace->pFacePlane.vNormal.z | |
3708 + v2 * pODMFace->pFacePlane.vNormal.x) >> 16; | |
3709 if ((stru_721530.speed >> 3) > v118 ) | |
3710 v118 = stru_721530.speed >> 3; | |
3711 v2 += fixpoint_mul(v118, pODMFace->pFacePlane.vNormal.x); | |
3712 v128 += fixpoint_mul(v118, pODMFace->pFacePlane.vNormal.y); | |
3713 v54 = 0; | |
3714 if ( !v119 ) | |
3715 v54 = fixpoint_mul(v118, pODMFace->pFacePlane.vNormal.z); | |
3716 pParty->uFallSpeed += v54; | |
3717 v55 = stru_721530.prolly_normal_d - ((signed int)(pODMFace->pFacePlane.dist + v122 * pODMFace->pFacePlane.vNormal.z | |
3718 + _angle_y * pODMFace->pFacePlane.vNormal.y + _angle_x * pODMFace->pFacePlane.vNormal.x) >> 16); | |
3719 if ( v55 > 0 ) | |
3720 { | |
3721 pX = _angle_x + fixpoint_mul(pODMFace->pFacePlane.vNormal.x, v55); | |
3722 pY = _angle_y + fixpoint_mul(pODMFace->pFacePlane.vNormal.y, v55); | |
3723 if ( !v119 ) | |
2534 | 3724 party_new_Z = v122 + fixpoint_mul(pODMFace->pFacePlane.vNormal.z, v55); |
2496 | 3725 } |
3726 if ( pParty->floor_face_pid != stru_721530.uFaceID && pODMFace->Pressure_Plate() ) | |
3727 { | |
3728 pParty->floor_face_pid = stru_721530.uFaceID; | |
3729 trigger_id = pODMFace->sCogTriggeredID; // | |
3730 } | |
3731 } | |
3732 if ( pODMFace->uPolygonType == POLYGON_InBetweenFloorAndWall ) | |
3733 { | |
3734 v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y | |
3735 + fall_speed * pODMFace->pFacePlane.vNormal.z + v2 * pODMFace->pFacePlane.vNormal.x) >> 16; | |
3736 if ((stru_721530.speed >> 3) > v118 ) | |
3737 v118 = stru_721530.speed >> 3; | |
3738 v2 += fixpoint_mul(v118, pODMFace->pFacePlane.vNormal.x); | |
3739 v128 += fixpoint_mul(v118, pODMFace->pFacePlane.vNormal.y); | |
3740 fall_speed += fixpoint_mul(v118, pODMFace->pFacePlane.vNormal.z); | |
3741 if ( v2 * v2 + v128 * v128 >= 400 ) | |
3742 { | |
3743 if ( pParty->floor_face_pid != stru_721530.uFaceID && pODMFace->Pressure_Plate() ) | |
3744 { | |
3745 pParty->floor_face_pid = stru_721530.uFaceID; | |
3746 trigger_id = pODMFace->sCogTriggeredID; // | |
3747 } | |
3748 } | |
3749 else | |
3750 { | |
3751 v2 = 0; | |
3752 fall_speed = 0; | |
3753 *(float *)&v128 = 0.0; | |
3754 } | |
3755 } | |
3756 } | |
3757 v2 = fixpoint_mul(58500, v2); | |
3758 v128 = fixpoint_mul(58500, v128); | |
3759 v122 = fixpoint_mul(58500, v122); | |
3760 fall_speed = fixpoint_mul(58500, fall_speed); | |
3761 } | |
3762 | |
3763 //Воспроизведение звуков ходьбы/бега------------------------ | |
3764 uint pX_ = abs(pParty->vPosition.x - pX); | |
3765 uint pY_ = abs(pParty->vPosition.y - pY); | |
2534 | 3766 uint pZ_ = abs(pParty->vPosition.z - party_new_Z); |
2496 | 3767 if ( bWalkSound && pParty->walk_sound_timer <= 0 ) |
3768 { | |
3769 pAudioPlayer->_4AA258(804);//stop sound | |
3770 if ( party_running_flag && (!hovering || not_high_fall) ) | |
3771 { | |
3772 if ( integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) >= 16 ) | |
3773 { | |
3774 if ( !is_not_on_bmodel && pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].Visible() ) | |
2534 | 3775 pAudioPlayer->PlaySound(SOUND_RunWood, 804, 1, -1, 0, 0, 0, 0);//бег на 3D Modelи |
2496 | 3776 else |
3777 { | |
3778 v87 = pOutdoor->GetSoundIdByPosition(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y) - 1, 1); | |
3779 pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0);//бег по земле 56 | |
3780 } | |
3781 pParty->walk_sound_timer = 96;//таймер для бега | |
3782 } | |
3783 } | |
3784 else if( party_walking_flag && (!hovering || not_high_fall) ) | |
3785 { | |
3786 if ( integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) >= 8 ) | |
3787 { | |
3788 if ( !is_not_on_bmodel && pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].Visible() ) | |
2534 | 3789 pAudioPlayer->PlaySound(SOUND_WalkWood, 804, 1, -1, 0, 0, 0, 0);// хождение на 3D Modelи |
2496 | 3790 else |
3791 { | |
3792 v87 = pOutdoor->GetSoundIdByPosition(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y) - 1, 0); | |
3793 pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0);// хождение по земле | |
3794 } | |
3795 pParty->walk_sound_timer = 144;//таймер для ходьбы | |
3796 } | |
3797 } | |
3798 } | |
3799 if ( integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) < 8 )//отключить звук ходьбы при остановке | |
3800 pAudioPlayer->_4AA258(804); | |
3801 //------------------------------------------------------------------------ | |
3802 if ( !hovering || !not_high_fall )// или не высокое падение | |
3803 pParty->uFlags &= ~PARTY_FLAGS_1_FALLING; | |
3804 else | |
3805 pParty->uFlags |= PARTY_FLAGS_1_FALLING; | |
3806 int pMap_X = WorldPosToGridCellX(pParty->vPosition.x); | |
3807 int pMap_Y = WorldPosToGridCellZ(pParty->vPosition.y) - 1; | |
3808 unsigned int v114_a = WorldPosToGridCellX(pX); | |
3809 v66 = WorldPosToGridCellZ(pY) - 1; | |
3810 unsigned int v122_a = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(pMap_X, pMap_Y) / 2) & 1; | |
3811 v122 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v114_a, pMap_Y) / 2) & 1; | |
3812 v69 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(pMap_X, v66) / 2) & 1; | |
3813 | |
3814 //-(обновление координат группы)--------------------------------------- | |
3815 v68 = 0; | |
3816 if ( v114_a == pMap_X && v66 == pMap_Y && v122 && v69 ) | |
3817 v68 = 1; | |
3818 if ( !is_not_on_bmodel ) // на bmodel,и | |
3819 v68 = 1; | |
3820 if ( v68 ) | |
3821 { | |
3822 pParty->vPosition.x = pX; | |
3823 pParty->vPosition.y = pY; | |
2534 | 3824 pParty->vPosition.z = party_new_Z; |
2496 | 3825 pParty->field_6F0 = v113; |
3826 pParty->uFallSpeed = fall_speed; | |
2534 | 3827 if ( party_new_Z > 8160 ) //ограничение высоты |
2496 | 3828 { |
2534 | 3829 party_new_Z = 8160; |
2496 | 3830 pParty->uFallStartY = 8160; |
3831 pParty->vPosition.z = 8160; | |
3832 } | |
3833 | |
3834 if ( !trigger_id //падение на землю | |
3835 || (EventProcessor(trigger_id, 0, 1), | |
3836 pParty->vPosition.x == pX) | |
3837 && pParty->vPosition.y == pY | |
2534 | 3838 && pParty->vPosition.z == party_new_Z ) |
2496 | 3839 { |
3840 if ( pParty->vPosition.z < v111 ) | |
3841 { | |
3842 pParty->uFallSpeed = 0; | |
3843 //v73 = v105; | |
3844 pParty->vPosition.z = on_ground; | |
2534 | 3845 if ( pParty->uFallStartY - party_new_Z > 512 && !bFeatherFall |
3846 && party_new_Z <= on_ground && !bUnderwater )//Fall to the ground(падение на землю с высоты) | |
2496 | 3847 { |
3848 if ( pParty->uFlags & PARTY_FLAGS_1_LANDING ) | |
3849 pParty->uFlags &= ~PARTY_FLAGS_1_LANDING; | |
3850 else | |
3851 { | |
3852 for ( uint i = 1; i <= 4; ++i ) | |
3853 { | |
2534 | 3854 pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - party_new_Z) * (unsigned __int64)(signed __int64)((double)pPlayers[i]->GetMaxHealth() * 0.1)) / 256, |
2496 | 3855 DMGT_PHISYCAL); |
3856 v110 = 20 - pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualEndurance()); | |
3857 pPlayers[i]->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); | |
3858 } | |
3859 //v73 = pParty->vPosition.z; | |
3860 } | |
3861 } | |
2534 | 3862 pParty->uFallStartY = party_new_Z; |
2496 | 3863 } |
3864 if ( v102 && pParty->vPosition.z < ceiling_height ) | |
3865 { | |
3866 if ( (signed int)(pParty->uPartyHeight + pParty->vPosition.z) >= ceiling_height ) | |
3867 { | |
3868 pParty->vPosition.z = ceiling_height - pParty->uPartyHeight - 1; | |
3869 pParty->field_6F0 = ceiling_height - pParty->uPartyHeight - 1; | |
3870 } | |
3871 } | |
3872 pParty->uFlags &= ~0x204; | |
3873 } | |
3874 return; | |
3875 } | |
3876 //----------------------------------------------------------------- | |
3877 //v76 = pParty->bFlying; | |
3878 if ( pParty->bFlying || !not_high_fall || bWaterWalk || !v122_a )// полёт или высокое падение или хождение по воде или | |
3879 v77 = 1; | |
3880 else | |
3881 v77 = v122 != 0; | |
3882 bool party_drowning_flag = false; | |
3883 if ( !pParty->bFlying && not_high_fall && !bWaterWalk ) //не полёт и не высокое падение и не хождение по воде | |
3884 { | |
3885 if ( v122_a ) | |
3886 v78 = v69 != 0; | |
3887 else | |
3888 { | |
3889 party_drowning_flag = true;//утопление | |
3890 v78 = true; | |
3891 } | |
3892 } | |
3893 else | |
3894 v78 = true; | |
3895 | |
3896 if ( v77 ) | |
3897 pParty->vPosition.x = pX; | |
3898 if ( v78 ) | |
3899 pParty->vPosition.y = pY; | |
3900 | |
3901 if ( v78 || v77) | |
3902 { | |
3903 if ( bWaterWalk ) | |
3904 { | |
3905 pParty->uFlags &= ~PARTY_FLAGS_1_STANDING_ON_WATER; | |
3906 //v79 = 20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 6180178; | |
3907 //*(short *)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 119] |= 1u; | |
3908 v79 = (int)&stru_5E4C90_MapPersistVars._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 119]; | |
3909 *(short *)v79 |= 1; | |
3910 if ( !v122 || !v69 ) | |
3911 { | |
3912 if ( !pParty->bFlying ) | |
3913 { | |
3914 v80 = *(short *)v79; | |
3915 pParty->uFlags |= PARTY_FLAGS_1_STANDING_ON_WATER; | |
3916 *(short *)v79 = v80 & 0xFFFE; | |
3917 } | |
3918 } | |
3919 } | |
3920 } | |
3921 else if ( bWalkSound && pParty->walk_sound_timer <= 0 ) | |
3922 { | |
3923 pAudioPlayer->_4AA258(804); | |
3924 pParty->walk_sound_timer = 64; | |
3925 } | |
3926 | |
3927 //v81 = pZ; | |
3928 //v82 = pZ; | |
2534 | 3929 pParty->vPosition.z = party_new_Z; |
3930 if ( party_new_Z > 8160 )//опять ограничение высоты | |
2496 | 3931 { |
3932 //v82 = 8160; | |
3933 pParty->uFallStartY = 8160; | |
3934 pParty->vPosition.z = 8160; | |
3935 } | |
3936 LOWORD(pParty->uFlags) &= 0xFDFBu; | |
3937 pParty->uFallSpeed = fall_speed; | |
3938 pParty->field_6F0 = v113; | |
3939 if ( party_drowning_flag )//группа тонет | |
3940 { | |
3941 pTerrainHeight = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.y, &v110, 1); | |
3942 if ( pParty->vPosition.z <= pTerrainHeight + 1 )//положение группы всегда +1 | |
3943 pParty->uFlags |= PARTY_FLAGS_1_WATER_DAMAGE; | |
3944 } | |
3945 | |
3946 if ( !trigger_id//падение на воду | |
3947 || (EventProcessor(trigger_id, 0, 1), | |
3948 pParty->vPosition.x == pX) | |
3949 && pParty->vPosition.y == pY | |
2534 | 3950 && pParty->vPosition.z == party_new_Z ) |
2496 | 3951 { |
3952 if ( pParty->vPosition.z < v111 ) | |
3953 { | |
3954 //v82 = on_ground; | |
3955 pParty->uFallSpeed = 0; | |
3956 pParty->vPosition.z = on_ground; | |
2534 | 3957 if ( pParty->uFallStartY - party_new_Z > 512 |
3958 && !bFeatherFall && party_new_Z <= on_ground && !bUnderwater )//Fall to the water(падение на воду с высоты) | |
2496 | 3959 { |
3960 if ( pParty->uFlags & PARTY_FLAGS_1_LANDING ) | |
3961 pParty->uFlags &= ~PARTY_FLAGS_1_LANDING; | |
3962 else | |
3963 { | |
3964 for ( uint i = 1; i <= 4; ++i ) | |
3965 { | |
3966 v110 = pPlayers[i]->GetMaxHealth(); | |
2534 | 3967 pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - party_new_Z) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256, |
2496 | 3968 DMGT_PHISYCAL); |
3969 v110 = 20 - pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualEndurance()); | |
3970 pPlayers[i]->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); | |
3971 } | |
3972 //v82 = pParty->vPosition.z; | |
3973 } | |
3974 } | |
2534 | 3975 pParty->uFallStartY = party_new_Z; |
2496 | 3976 } |
3977 if ( v102 && pParty->vPosition.z < ceiling_height && (signed int)(pParty->uPartyHeight + pParty->vPosition.z) >= ceiling_height ) | |
3978 { | |
3979 pParty->vPosition.z = pParty->vPosition.z + pParty->uPartyHeight - ceiling_height + 1; | |
3980 pParty->field_6F0 = pParty->vPosition.z + pParty->uPartyHeight - ceiling_height + 1; | |
3981 } | |
3982 } | |
3983 } | |
3984 | |
3985 //----- (0046D8E3) -------------------------------------------------------- | |
3986 int GetCeilingHeight(int Party_X, signed int Party_Y, int Party_ZHeight, int pFaceID) | |
3987 { | |
3988 signed int v13; // eax@25 | |
3989 int v14; // edx@27 | |
3990 int v16; // ST18_4@29 | |
3991 signed int v17; // edx@29 | |
3992 signed __int64 v18; // qtt@29 | |
3993 int v19; // eax@35 | |
3994 signed int v20; // ecx@37 | |
3995 signed int v22; // ebx@42 | |
3996 // int v24; // edx@44 | |
3997 // int v25; // eax@44 | |
3998 int v27; // [sp+10h] [bp-34h]@21 | |
3999 bool v34; // [sp+30h] [bp-14h]@21 | |
4000 bool v35; // [sp+34h] [bp-10h]@23 | |
4001 signed int v37; // [sp+38h] [bp-Ch]@21 | |
4002 signed int v38; // [sp+38h] [bp-Ch]@42 | |
4003 signed int v39; // [sp+3Ch] [bp-8h]@1 | |
4004 | |
4005 dword_720ED0[0] = -1; | |
4006 dword_720E80[0] = -1; | |
4007 v39 = 1; | |
4008 ceiling_height_level[0] = 10000;//нет потолка | |
4009 for ( uint i = 0; i < (signed int)pOutdoor->uNumBModels; ++i ) | |
4010 { | |
4011 if ( Party_X <= pOutdoor->pBModels[i].sMaxX && Party_X >= pOutdoor->pBModels[i].sMinX | |
4012 && Party_Y <= pOutdoor->pBModels[i].sMaxY && Party_Y >= pOutdoor->pBModels[i].sMinY ) | |
4013 { | |
4014 for ( uint j = 0; j < pOutdoor->pBModels[i].uNumFaces; ++j ) | |
4015 { | |
4016 if ( (pOutdoor->pBModels[i].pFaces[j].uPolygonType == POLYGON_Ceiling | |
4017 || pOutdoor->pBModels[i].pFaces[j].uPolygonType == POLYGON_InBetweenCeilingAndWall) | |
4018 && !pOutdoor->pBModels[i].pFaces[j].Ethereal() | |
4019 && Party_X <= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.x2 && Party_X >= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.x1 | |
4020 && Party_Y <= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.y2 && Party_Y >= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.y1 ) | |
4021 { | |
4022 for ( uint v = 0; v < pOutdoor->pBModels[i].pFaces[j].uNumVertices; v++ ) | |
4023 { | |
4024 word_720DB0_xs[2 * v] = pOutdoor->pBModels[i].pFaces[j].pXInterceptDisplacements[v] + LOWORD(pOutdoor->pBModels[i].pVertices.pVertices[pOutdoor->pBModels[i].pFaces[j].pVertexIDs[v]].x); | |
4025 word_720CE0_ys[2 * v] = pOutdoor->pBModels[i].pFaces[j].pXInterceptDisplacements[v] + LOWORD(pOutdoor->pBModels[i].pVertices.pVertices[pOutdoor->pBModels[i].pFaces[j].pVertexIDs[v]].y); | |
4026 word_720DB0_xs[2 * v + 1] = pOutdoor->pBModels[i].pFaces[j].pXInterceptDisplacements[v] + LOWORD(pOutdoor->pBModels[i].pVertices.pVertices[pOutdoor->pBModels[i].pFaces[j].pVertexIDs[v + 1]].x); | |
4027 word_720CE0_ys[2 * v + 1] = pOutdoor->pBModels[i].pFaces[j].pXInterceptDisplacements[v] + LOWORD(pOutdoor->pBModels[i].pVertices.pVertices[pOutdoor->pBModels[i].pFaces[j].pVertexIDs[v + 1]].y); | |
4028 } | |
4029 v27 = 2 * pOutdoor->pBModels[i].pFaces[j].uNumVertices; | |
4030 word_720DB0_xs[2 * pOutdoor->pBModels[i].pFaces[j].uNumVertices] = word_720DB0_xs[0]; | |
4031 word_720CE0_ys[2 * pOutdoor->pBModels[i].pFaces[j].uNumVertices] = word_720CE0_ys[0]; | |
4032 v34 = word_720CE0_ys[0] >= Party_Y; | |
4033 v37 = 0; | |
4034 for ( uint v = 0; v < v27; ++v ) | |
4035 { | |
4036 if ( v37 >= 2 ) | |
4037 break; | |
4038 v35 = word_720CE0_ys[v + 1] >= Party_Y; | |
4039 if ( v34 != v35 ) | |
4040 { | |
4041 v13 = word_720DB0_xs[v + 1] >= Party_X ? 0 : 2; | |
4042 v14 = v13 | (word_720DB0_xs[v] < Party_X); | |
4043 if ( v14 != 3 ) | |
4044 { | |
4045 if ( !v14 || ( v16 = word_720CE0_ys[v + 1] - word_720CE0_ys[v], | |
4046 v17 = Party_Y - word_720CE0_ys[v], | |
4047 LODWORD(v18) = v17 << 16, | |
4048 HIDWORD(v18) = v17 >> 16, | |
4049 (signed int)(((unsigned __int64)(((signed int)word_720DB0_xs[v + 1] | |
4050 - (signed int)word_720DB0_xs[v]) * v18 / v16) >> 16) + word_720DB0_xs[v]) >= Party_X) ) | |
4051 ++v37; | |
4052 } | |
4053 } | |
4054 v34 = v35; | |
4055 } | |
4056 if ( v37 == 1 ) | |
4057 { | |
4058 if ( v39 >= 20 ) | |
4059 break; | |
4060 if ( pOutdoor->pBModels[i].pFaces[j].uPolygonType == POLYGON_Ceiling ) | |
4061 v19 = pOutdoor->pBModels[i].pVertices.pVertices[pOutdoor->pBModels[i].pFaces[j].pVertexIDs[0]].z; | |
4062 else | |
4063 v19 = fixpoint_mul(pOutdoor->pBModels[i].pFaces[j].zCalc1, Party_X) + fixpoint_mul(pOutdoor->pBModels[i].pFaces[j].zCalc2, Party_Y) | |
4064 + HIWORD(pOutdoor->pBModels[i].pFaces[j].zCalc3); | |
4065 v20 = v39++; | |
4066 ceiling_height_level[v20] = v19; | |
4067 dword_720ED0[v20] = i; | |
4068 dword_720E80[v20] = j; | |
4069 } | |
4070 } | |
4071 } | |
4072 } | |
4073 } | |
4074 if ( !v39 ) | |
4075 { | |
4076 pFaceID = 0; | |
4077 return ceiling_height_level[0]; | |
4078 } | |
4079 v22 = 0; | |
4080 for ( v38 = 0; v38 < v39; ++v38 ) | |
4081 { | |
4082 if ( ceiling_height_level[v38] == ceiling_height_level[0] ) | |
4083 v22 = v38; | |
4084 else if ( ceiling_height_level[v38] < ceiling_height_level[0] && ceiling_height_level[0] > Party_ZHeight + 15 ) | |
4085 v22 = v38; | |
4086 else if ( ceiling_height_level[v38] > ceiling_height_level[0] && ceiling_height_level[v38] <= Party_ZHeight + 15 ) | |
4087 v22 = v38; | |
4088 } | |
4089 if ( v22 ) | |
4090 { | |
4091 *(int *)pFaceID = dword_720E80[v22] | (dword_720ED0[v22] << 6); | |
4092 return ceiling_height_level[v22];//если есть преграда | |
4093 } | |
4094 pFaceID = 0; | |
4095 return ceiling_height_level[v22];// нет никакой преграды | |
4096 } | |
4097 | |
4098 | |
4099 //----- (00464839) -------------------------------------------------------- | |
4100 char Is_out15odm_underwater() | |
4101 { | |
4102 return _stricmp(pCurrentMapName, "out15.odm") == 0; | |
4103 } | |
4104 | |
4105 //----- (00464851) -------------------------------------------------------- | |
4106 void SetUnderwaterFog() | |
4107 { | |
4108 day_fogrange_1 = 50; | |
4109 day_fogrange_2 = 5000; | |
4110 } | |
4111 | |
4112 //----- (00487DA9) -------------------------------------------------------- | |
4113 void sub_487DA9() | |
4114 { | |
4115 for (int i = 0; i < 20000; ++i) | |
4116 array_77EC08[i].field_108 = 0; | |
4117 } | |
4118 | |
4119 //----- (004706C6) -------------------------------------------------------- | |
4120 void UpdateActors_ODM() | |
4121 { | |
4122 int v3; // ebx@6 | |
4123 int v5; // eax@10 | |
4124 //int v6; // ecx@10 | |
4125 signed int v8; // ebx@17 | |
4126 // unsigned __int8 v10; // sf@17 | |
4127 // unsigned __int16 v11; // ax@21 | |
4128 __int16 v20; // ax@42 | |
4129 int v25; // eax@45 | |
4130 signed int v26; // ecx@50 | |
4131 int v28; // eax@54 | |
4132 signed int v29; // ebx@57 | |
4133 signed int v30; // eax@57 | |
4134 int v31; // edi@57 | |
4135 signed int i; // ebx@57 | |
4136 unsigned int v33; // ecx@58 | |
4137 int v35; // edi@64 | |
4138 int v36; // eax@64 | |
4139 unsigned int v39; // edi@71 | |
4140 ODMFace *face; // edi@75 | |
4141 int v46; // ecx@82 | |
4142 signed int v47; // ebx@85 | |
4143 int v48; // edi@85 | |
4144 // int v55; // eax@107 | |
4145 // unsigned int v56; // edi@107 | |
4146 // int v57; // ST10_4@107 | |
4147 unsigned int v58; // edi@107 | |
4148 unsigned int v59; // ebx@107 | |
4149 // signed int v60; // eax@107 | |
4150 int v61; // eax@124 | |
4151 Vec3_int_ v62; // [sp+Ch] [bp-44h]@42 | |
4152 int v63; // [sp+18h] [bp-38h]@64 | |
4153 int v64; // [sp+1Ch] [bp-34h]@64 | |
4154 bool v67; // [sp+28h] [bp-28h]@10 | |
4155 unsigned int v69; // [sp+30h] [bp-20h]@6 | |
4156 unsigned int v70; // [sp+34h] [bp-1Ch]@10 | |
4157 int v71; // [sp+38h] [bp-18h]@62 | |
4158 int uIsAboveFloor; // [sp+3Ch] [bp-14h]@10 | |
4159 int v72b; | |
4160 int uIsFlying; // [sp+44h] [bp-Ch]@8 | |
4161 unsigned int v75; // [sp+48h] [bp-8h]@1 | |
4162 int uIsOnWater; // [sp+4Ch] [bp-4h]@10 | |
4163 | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2545
diff
changeset
|
4164 if(no_actors) |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2545
diff
changeset
|
4165 uNumActors = 0; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2545
diff
changeset
|
4166 |
2496 | 4167 for (v75 = 0; v75 < uNumActors; ++v75) |
4168 { | |
4169 if (pActors[v75].uAIState == Removed | |
4170 || pActors[v75].uAIState == Disabled | |
4171 || pActors[v75].uAIState == Summoned | |
4172 || !pActors[v75].uMovementSpeed) | |
4173 continue; | |
4174 v3 = 0; | |
4175 v69 = 0; | |
4176 if (MonsterStats::BelongsToSupertype(pActors[v75].pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL)) | |
4177 v3 = 1; | |
4178 pActors[v75].uSectorID = 0; | |
4179 uIsFlying = pActors[v75].pMonsterInfo.uFlying; | |
4180 if (!pActors[v75].CanAct()) | |
4181 uIsFlying = 0; | |
4182 v70 = IsTerrainSlopeTooHigh(pActors[v75].vPosition.x, pActors[v75].vPosition.y); | |
4183 v5 = ODM_GetFloorLevel(pActors[v75].vPosition.x, pActors[v75].vPosition.y, pActors[v75].vPosition.z, | |
4184 pActors[v75].uActorHeight, &uIsOnWater, (int *)&v69, v3); | |
4185 //v6 = pActors[v75].vPosition.z; | |
4186 uIsAboveFloor = 0; | |
4187 v67 = v69 == 0; | |
4188 if (pActors[v75].vPosition.z > v5 + 1) | |
4189 uIsAboveFloor = 1; | |
4190 if (pActors[v75].uAIState == Dead && uIsOnWater && !uIsAboveFloor) | |
4191 { | |
4192 pActors[v75].uAIState = Removed; | |
4193 continue; | |
4194 } | |
4195 if (pActors[v75].uCurrentActionAnimation == ANIM_Walking) | |
4196 { | |
4197 v8 = pActors[v75].uMovementSpeed; | |
4198 if ((signed __int64)pActors[v75].pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0) | |
4199 v8 = (signed __int64)((double)v8 * 0.5); | |
4200 if (pActors[v75].uAIState == Fleeing || pActors[v75].uAIState == Pursuing) | |
4201 v8 *= 2; | |
4202 if (pParty->bTurnBasedModeOn == true && pTurnEngine->turn_stage == TE_WAIT) | |
4203 v8 *= flt_6BE3AC_debug_recmod1_x_1_6; | |
4204 if (v8 > 1000) | |
4205 v8 = 1000; | |
4206 | |
4207 pActors[v75].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(pActors[v75].uYawAngle), v8); | |
4208 pActors[v75].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(pActors[v75].uYawAngle), v8); | |
4209 if (uIsFlying) | |
4210 { | |
4211 pActors[v75].vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pActors[v75].uPitchAngle), v8); | |
4212 } | |
4213 //v7 = v68; | |
4214 } | |
4215 else | |
4216 { | |
4217 pActors[v75].vVelocity.x = fixpoint_mul(55000, pActors[v75].vVelocity.x); | |
4218 pActors[v75].vVelocity.y = fixpoint_mul(55000, pActors[v75].vVelocity.y); | |
4219 if (uIsFlying) | |
4220 pActors[v75].vVelocity.z = fixpoint_mul(55000, pActors[v75].vVelocity.z); | |
4221 } | |
4222 if (pActors[v75].vPosition.z < v5) | |
4223 { | |
4224 pActors[v75].vPosition.z = v5; | |
4225 pActors[v75].vVelocity.z = uIsFlying != 0 ? 0x14 : 0; | |
4226 } | |
4227 //v17 = 0; | |
4228 if (!uIsAboveFloor || uIsFlying) | |
4229 { | |
4230 if (v70 && !uIsAboveFloor && v67) | |
4231 { | |
4232 pActors[v75].vPosition.z = v5; | |
4233 ODM_GetTerrainNormalAt(pActors[v75].vPosition.x, pActors[v75].vPosition.y, &v62); | |
4234 v20 = GetGravityStrength(); | |
4235 //v21 = v62.y; | |
4236 //v22 = v62.z; | |
4237 //v23 = v62.y * v0->vVelocity.y; | |
4238 pActors[v75].vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20; | |
4239 int v73 = abs(v62.x * pActors[v75].vVelocity.x + v62.z * pActors[v75].vVelocity.z + v62.y * pActors[v75].vVelocity.y) >> 16; | |
4240 //v72b = v21; | |
4241 pActors[v75].vVelocity.x += fixpoint_mul(v73, v62.x); | |
4242 pActors[v75].vVelocity.y += fixpoint_mul(v73, v62.y); | |
4243 pActors[v75].vVelocity.z += fixpoint_mul(v73, v62.z); | |
4244 //v17 = 0; | |
4245 } | |
4246 } | |
4247 else | |
4248 { | |
4249 pActors[v75].vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); | |
4250 } | |
4251 if (pParty->armageddon_timer != 0 && pActors[v75].CanAct()) | |
4252 { | |
4253 pActors[v75].vVelocity.x += rand() % 100 - 50; | |
4254 pActors[v75].vVelocity.y += rand() % 100 - 50; | |
4255 pActors[v75].vVelocity.z += rand() % 100 - 20; | |
4256 v25 = rand(); | |
4257 pActors[v75].uAIState = Stunned; | |
4258 pActors[v75].uYawAngle += v25 % 32 - 16; | |
4259 pActors[v75].UpdateAnimation(); | |
4260 } | |
4261 if (pActors[v75].vVelocity.x * pActors[v75].vVelocity.x + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y < 400 && v70 == 0) | |
4262 { | |
4263 pActors[v75].vVelocity.y = 0; | |
4264 pActors[v75].vVelocity.x = 0; | |
4265 } | |
4266 stru_721530.field_0 = 1; | |
4267 if (!uIsFlying) | |
4268 v26 = 40; | |
4269 else | |
4270 v26 = pActors[v75].uActorRadius; | |
4271 | |
4272 stru_721530.field_84 = -1; | |
4273 stru_721530.field_8_radius = v26; | |
4274 stru_721530.prolly_normal_d = v26; | |
4275 stru_721530.height = pActors[v75].uActorHeight; | |
4276 stru_721530.field_70 = 0; | |
4277 | |
4278 for (v69 = 0; v69 < 100; ++v69) | |
4279 { | |
4280 stru_721530.position.x = pActors[v75].vPosition.x; | |
4281 stru_721530.normal.x = stru_721530.position.x; | |
4282 stru_721530.position.y = pActors[v75].vPosition.y; | |
4283 stru_721530.normal.y = stru_721530.position.y; | |
4284 v28 = pActors[v75].vPosition.z; | |
4285 stru_721530.normal.z = v28 + v26 + 1; | |
4286 stru_721530.position.z = v28 - v26 + stru_721530.height - 1; | |
4287 if (stru_721530.position.z < stru_721530.normal.z) | |
4288 stru_721530.position.z = v28 + v26 + 1; | |
4289 stru_721530.velocity.x = pActors[v75].vVelocity.x; | |
4290 stru_721530.uSectorID = 0; | |
4291 stru_721530.velocity.y = pActors[v75].vVelocity.y; | |
4292 stru_721530.velocity.z = pActors[v75].vVelocity.z; | |
4293 if (stru_721530._47050A(0)) | |
4294 break; | |
4295 _46E889_collide_against_bmodels(1); | |
4296 v29 = WorldPosToGridCellZ(pActors[v75].vPosition.y); | |
4297 v30 = WorldPosToGridCellX(pActors[v75].vPosition.x); | |
4298 _46E26D_collide_against_sprites(v30, v29); | |
4299 _46EF01_collision_chech_player(0); | |
4300 _46ED8A_collide_against_sprite_objects(PID(OBJECT_Actor, v75)); | |
4301 v31 = 0; | |
4302 for (i = 0; v31 < ai_arrays_size; ++v31) | |
4303 { | |
4304 v33 = ai_near_actors_ids[v31]; | |
4305 if (v33 != v75 && Actor::_46DF1A_collide_against_actor(v33, 40)) | |
4306 ++i; | |
4307 } | |
4308 v71 = i > 1; | |
4309 if (stru_721530.field_7C < stru_721530.field_6C) | |
4310 v70 = fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); | |
4311 //v34 = 0; | |
4312 v35 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; | |
4313 v36 = ODM_GetFloorLevel(stru_721530.normal2.x, stru_721530.normal2.y, | |
4314 stru_721530.normal2.z - stru_721530.prolly_normal_d - 1, | |
4315 pActors[v75].uActorHeight, (int *)&v63, &v64, 0); | |
4316 if (uIsOnWater) | |
4317 { | |
4318 if (v35 < v36 + 60) | |
4319 { | |
4320 if (pActors[v75].uAIState == Dead || pActors[v75].uAIState == Dying || pActors[v75].uAIState == Removed | |
4321 || pActors[v75].uAIState == Disabled) | |
4322 { | |
4323 if (v64) | |
4324 v61 = v36 + 30; | |
4325 else | |
4326 v61 = v5 + 60; | |
4327 SpriteObject::sub_42F960_create_object(pActors[v75].vPosition.x, pActors[v75].vPosition.y, v61); | |
4328 pActors[v75].uAIState = Removed; | |
4329 return; | |
4330 } | |
4331 } | |
4332 } | |
4333 if (stru_721530.field_7C >= stru_721530.field_6C) | |
4334 { | |
4335 pActors[v75].vPosition.x = LOWORD(stru_721530.normal2.x); | |
4336 pActors[v75].vPosition.y = LOWORD(stru_721530.normal2.y); | |
4337 pActors[v75].vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1; | |
4338 break; | |
4339 } | |
4340 //v72b = fixpoint_mul(stru_721530.field_7C, stru_721530.field_58.x); | |
4341 pActors[v75].vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x); | |
4342 //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; | |
4343 pActors[v75].vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y); | |
4344 //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; | |
4345 pActors[v75].vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); | |
4346 stru_721530.field_70 += stru_721530.field_7C; | |
4347 v39 = PID_ID(stru_721530.uFaceID); | |
4348 switch (PID_TYPE(stru_721530.uFaceID)) | |
4349 { | |
4350 case OBJECT_Actor: | |
4351 if (pTurnEngine->turn_stage != TE_ATTACK && pTurnEngine->turn_stage != TE_MOVEMENT || pParty->bTurnBasedModeOn != TE_WAIT) | |
4352 { | |
4353 //if(pParty->bTurnBasedModeOn == 1) | |
4354 //v34 = 0; | |
4355 if (pActors[v75].pMonsterInfo.uHostilityType) | |
4356 { | |
4357 if (v71 == 0) | |
4358 Actor::AI_Flee(v75, stru_721530.uFaceID, 0, (AIDirection *)0); | |
4359 else | |
4360 Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0); | |
4361 } | |
4362 else if (v71) | |
4363 Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0); | |
4364 else if (pActors[v39].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly) | |
4365 Actor::AI_Flee(v75, stru_721530.uFaceID, 0, (AIDirection *)0); | |
4366 else | |
4367 Actor::AI_FaceObject(v75, stru_721530.uFaceID, 0, (AIDirection *)0); | |
4368 } | |
4369 break; | |
4370 case OBJECT_Player: | |
4371 if (!pActors[v75].GetActorsRelation(0)) | |
4372 { | |
4373 Actor::AI_FaceObject(v75, stru_721530.uFaceID, 0, (AIDirection *)0); | |
4374 break; | |
4375 } | |
4376 //v52 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) == 0; | |
4377 //v53 = SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) < 0; | |
4378 pActors[v75].vVelocity.y = 0; | |
4379 pActors[v75].vVelocity.x = 0; | |
4380 //if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0) ) | |
4381 if ((signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime < 0) | |
4382 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); | |
4383 viewparams->bRedrawGameUI = 1; | |
4384 break; | |
4385 case OBJECT_Decoration: | |
4386 v47 = integer_sqrt(pActors[v75].vVelocity.x * pActors[v75].vVelocity.x + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y); | |
4387 v48 = stru_5C6E00->Atan2(pActors[v75].vPosition.x - pLevelDecorations[v39].vPosition.x, | |
4388 pActors[v75].vPosition.y - pLevelDecorations[v39].vPosition.y); | |
4389 //v49 = v48; | |
4390 pActors[v75].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v48), v47); | |
4391 pActors[v75].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v48), v47); | |
4392 break; | |
4393 case OBJECT_BModel: | |
4394 face = &pOutdoor->pBModels[stru_721530.uFaceID >> 9].pFaces[v39 & 0x3F]; | |
4395 if (!face->Ethereal()) | |
4396 { | |
4397 if (face->uPolygonType == 3) | |
4398 { | |
4399 pActors[v75].vVelocity.z = 0; | |
4400 pActors[v75].vPosition.z = LOWORD(pOutdoor->pBModels[stru_721530.uFaceID >> 9].pVertices.pVertices[face->pVertexIDs[0]].z) + 1; | |
4401 if (pActors[v75].vVelocity.x * pActors[v75].vVelocity.x | |
4402 + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y < 400) | |
4403 { | |
4404 pActors[v75].vVelocity.y = 0; | |
4405 pActors[v75].vVelocity.x = 0; | |
4406 } | |
4407 } | |
4408 else | |
4409 { | |
4410 v72b = abs(face->pFacePlane.vNormal.y * pActors[v75].vVelocity.y + face->pFacePlane.vNormal.z * pActors[v75].vVelocity.z | |
4411 + face->pFacePlane.vNormal.x * pActors[v75].vVelocity.x) >> 16; | |
4412 if ((stru_721530.speed >> 3) > v72b) | |
4413 v72b = stru_721530.speed >> 3; | |
4414 | |
4415 pActors[v75].vVelocity.x += fixpoint_mul(v72b, face->pFacePlane.vNormal.x); | |
4416 pActors[v75].vVelocity.y += fixpoint_mul(v72b, face->pFacePlane.vNormal.y); | |
4417 pActors[v75].vVelocity.z += fixpoint_mul(v72b, face->pFacePlane.vNormal.z); | |
4418 if (face->uPolygonType != 4) | |
4419 { | |
4420 v46 = stru_721530.prolly_normal_d | |
4421 - ((face->pFacePlane.dist | |
4422 + face->pFacePlane.vNormal.x * pActors[v75].vPosition.x | |
4423 + face->pFacePlane.vNormal.y * pActors[v75].vPosition.y | |
4424 + face->pFacePlane.vNormal.z * pActors[v75].vPosition.z) >> 16); | |
4425 if (v46 > 0) | |
4426 { | |
4427 pActors[v75].vPosition.x += fixpoint_mul(v46, face->pFacePlane.vNormal.x); | |
4428 pActors[v75].vPosition.y += fixpoint_mul(v46, face->pFacePlane.vNormal.y); | |
4429 pActors[v75].vPosition.z += fixpoint_mul(v46, face->pFacePlane.vNormal.z); | |
4430 } | |
4431 pActors[v75].uYawAngle = stru_5C6E00->Atan2(pActors[v75].vVelocity.x, pActors[v75].vVelocity.y); | |
4432 } | |
4433 } | |
4434 } | |
4435 break; | |
4436 } | |
4437 | |
4438 pActors[v75].vVelocity.x = fixpoint_mul(58500, pActors[v75].vVelocity.x); | |
4439 pActors[v75].vVelocity.y = fixpoint_mul(58500, pActors[v75].vVelocity.y); | |
4440 pActors[v75].vVelocity.z = fixpoint_mul(58500, pActors[v75].vVelocity.z); | |
4441 | |
4442 v26 = stru_721530.prolly_normal_d; | |
4443 } | |
4444 | |
4445 v58 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(pActors[v75].vPosition.x), WorldPosToGridCellZ(pActors[v75].vPosition.y) - 1) >> 1) & 1; | |
4446 v59 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(pActors[v75].vPosition.x), WorldPosToGridCellZ(pActors[v75].vPosition.y) - 1) >> 1) & 1; | |
4447 if (WorldPosToGridCellX(pActors[v75].vPosition.x) == WorldPosToGridCellX(pActors[v75].vPosition.x) | |
4448 && WorldPosToGridCellZ(pActors[v75].vPosition.y) == WorldPosToGridCellZ(pActors[v75].vPosition.y) | |
4449 && v58 || v67 != 0) | |
4450 { | |
4451 if (MonsterStats::BelongsToSupertype(pActors[v75].pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL)) | |
4452 { | |
4453 v58 = v58 == 0; | |
4454 v59 = v59 == 0; | |
4455 } | |
4456 if (!uIsFlying && v58 && !v59) | |
4457 { | |
4458 pActors[v75].vPosition.x = pActors[v75].vPosition.x; | |
4459 pActors[v75].vPosition.y = pActors[v75].vPosition.y; | |
4460 if (pActors[v75].CanAct()) | |
4461 { | |
4462 pActors[v75].uYawAngle -= 32; | |
4463 pActors[v75].uCurrentActionTime = 0; | |
4464 pActors[v75].uCurrentActionLength = 128; | |
4465 pActors[v75].uAIState = Fleeing; | |
4466 } | |
4467 } | |
4468 } | |
4469 } | |
4470 } | |
4471 | |
4472 //----- (0047A384) -------------------------------------------------------- | |
4473 void ODM_LoadAndInitialize(const char *pLevelFilename, ODMRenderParams *thisa) | |
4474 { | |
4475 int v2; // ebx@3 | |
4476 unsigned int v3; // eax@3 | |
4477 MapInfo *v4; // edi@4 | |
4478 //int v5; // eax@8 | |
4479 //SpawnPointMM7 *v6; // edx@14 | |
4480 size_t v7; // eax@19 | |
4481 //char *v8; // eax@19 | |
4482 //char *v9; // eax@21 | |
4483 char Source[120]; // [sp+Ch] [bp-84h]@19 | |
4484 const char *pFilename; // [sp+84h] [bp-Ch]@1 | |
4485 //unsigned int v12; // [sp+88h] [bp-8h]@12 | |
4486 //int v13; // [sp+8Ch] [bp-4h]@11 | |
4487 int v; | |
4488 | |
4489 pFilename = pLevelFilename; | |
4490 //thisa->AllocSoftwareDrawBuffers(); | |
4491 pODMRenderParams->Initialize(); | |
4492 pWeather->bRenderSnow = false; | |
4493 pRenderer->ClearZBuffer(0, 479); | |
4494 //thisa = (ODMRenderParams *)1; | |
4495 GetAlertStatus(); | |
4496 if (_A750D8_player_speech_timer) | |
4497 _A750D8_player_speech_timer = 0; | |
4498 v2 = pMapStats->GetMapInfo(pCurrentMapName); | |
4499 v3 = 0; | |
4500 if (v2) | |
4501 { | |
4502 v4 = &pMapStats->pInfos[v2]; | |
4503 v3 = v4->uRespawnIntervalDays; | |
4504 } | |
4505 else | |
4506 v4 = (MapInfo *)1; | |
4507 day_attrib &= ~DAY_ATTRIB_FOG; | |
4508 dword_6BE13C_uCurrentlyLoadedLocationID = v2; | |
4509 pOutdoor->Initialize( | |
4510 pFilename, | |
4511 (unsigned int)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) / 0x3C / 0x3C / 0x18 + 1, | |
4512 v3, | |
4513 &v); | |
4514 if (!(dword_6BE364_game_settings_1 & GAME_SETTINGS_2000)) | |
4515 { | |
4516 Actor::InitializeActors(); | |
4517 SpriteObject::InitializeSpriteObjects(); | |
4518 } | |
4519 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_2000; | |
4520 //v5 = 0; | |
4521 if (!v2) | |
4522 v = 0; | |
4523 if (v == 1) | |
4524 { | |
4525 //v13 = 0; | |
4526 for (uint i = 0; i < pOutdoor->uNumSpawnPoints; ++i) | |
4527 { | |
4528 SpawnPointMM7* spawn = pOutdoor->pSpawnPoints + i; | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2567
diff
changeset
|
4529 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2567
diff
changeset
|
4530 if (spawn->IsMonsterSpawn()) |
2496 | 4531 SpawnEncounter(v4, spawn, 0, 0, 0); |
4532 else | |
4533 v4->SpawnRandomTreasure(spawn); | |
4534 } | |
4535 RespawnGlobalDecorations(); | |
4536 } | |
4537 pOutdoor->PrepareDecorations(); | |
4538 pOutdoor->ArrangeSpriteObjects(); | |
4539 pOutdoor->InitalizeActors(v2); | |
4540 pOutdoor->MessWithLUN(); | |
4541 v7 = strlen("levels\\"); | |
4542 strcpy(Source, &pFilename[v7]); | |
4543 strcpy(pOutdoor->pLevelFilename, Source); | |
4544 pWeather->Initialize(); | |
2543 | 4545 pIndoorCameraD3D->sRotationY = pParty->sRotationY; |
4546 pIndoorCameraD3D->sRotationX = pParty->sRotationX; | |
2496 | 4547 //pODMRenderParams->RotationToInts(); |
4548 pOutdoor->UpdateSunlightVectors(); | |
4549 | |
4550 float fov_rad; | |
4551 float fov_rad_inv; | |
4552 //----- (0042394D) -------------------------------------------------------- | |
4553 //void IndoorCamera::Initialize(int degFov, unsigned int uViewportWidth, unsigned int uViewportHeight) | |
4554 { | |
4555 //pIndoorCamera->Initialize(65, viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X + 1, | |
4556 // viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y + 1); | |
4557 | |
4558 int uViewportWidth = viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X + 1; | |
4559 | |
4560 extern float _calc_fov(int viewport_width, int angle_degree); | |
4561 fov_rad = _calc_fov(uViewportWidth, 65); | |
4562 fov_rad_inv = 65536.0 / fov_rad; | |
4563 } | |
4564 pODMRenderParams->int_fov_rad = (signed __int64)fov_rad; | |
4565 pODMRenderParams->int_fov_rad_inv = (signed __int64)fov_rad_inv; | |
4566 | |
4567 for (int i = 0; i < 20000; ++i) | |
4568 { | |
4569 array_77EC08[i].ptr_38 = &stru_8019C8; | |
4570 | |
4571 array_77EC08[i].ptr_48 = nullptr; | |
4572 } | |
4573 | |
4574 MM7Initialization(); | |
4575 } | |
4576 | |
4577 //----- (0047C370) -------------------------------------------------------- | |
4578 unsigned int GetLevelFogColor() | |
4579 { | |
4580 signed __int64 v1; // qax@5 | |
4581 int v2; // eax@6 | |
4582 | |
4583 if (bUnderwater) | |
4584 return 0xFF258F5C; | |
4585 | |
4586 if (day_attrib & DAY_ATTRIB_FOG) | |
4587 { | |
4588 if (pWeather->bNight) // night-time fog | |
4589 { | |
4590 if (for_refactoring) | |
4591 { | |
4592 MessageBoxA(nullptr, "Nomad: decompilation can be inaccurate, please send savegame to Nomad", "", 0); | |
4593 __debugbreak(); | |
4594 } | |
4595 v2 = -(pWeather->bNight != 1); | |
4596 return (v2 & 0xE0E0E1) - 0xE0E0E1; | |
4597 } | |
4598 else | |
4599 { | |
4600 v1 = (signed __int64)((1.0 - pOutdoor->fFogDensity) * 200.0 + pOutdoor->fFogDensity * 31.0); | |
4601 return v1 | (((unsigned int)v1 | (((unsigned int)v1 | 0xFFFFFF00) << 8)) << 8); | |
4602 } | |
4603 } | |
4604 | |
4605 return 0; | |
4606 } | |
4607 | |
4608 //----- (0047C3D7) -------------------------------------------------------- | |
4609 int __fastcall sub_47C3D7_get_fog_specular(int a1, int a2, float a3) | |
4610 { | |
4611 int v3; // ecx@1 | |
4612 signed int v7; // ecx@11 | |
4613 | |
4614 v3 = pWeather->bNight; | |
4615 if (bUnderwater == 1) | |
4616 v3 = 0; | |
4617 if (pParty->armageddon_timer || !(day_attrib & DAY_ATTRIB_FOG) && !bUnderwater) | |
4618 return 0xFF000000; | |
4619 if (v3) | |
4620 { | |
4621 if (a3 < (double)day_fogrange_1) | |
4622 { | |
4623 v7 = 0; | |
4624 if (a3 == 0.0) | |
4625 v7 = 216; | |
4626 if (a2) | |
4627 v7 = 248; | |
4628 return (-1 - v7) << 24; | |
4629 } | |
4630 else | |
4631 { | |
4632 if (a3 > (double)day_fogrange_2) | |
4633 { | |
4634 v7 = 216; | |
4635 if (a3 == 0.0) | |
4636 v7 = 216; | |
4637 if (a2) | |
4638 v7 = 248; | |
4639 return (-1 - v7) << 24; | |
4640 } | |
4641 v7 = (signed __int64)((a3 - (double)day_fogrange_1) / ((double)day_fogrange_2 - (double)day_fogrange_1) * 216.0); | |
4642 } | |
4643 } | |
4644 else | |
4645 { | |
4646 if (a3 < (double)day_fogrange_1) | |
4647 { | |
4648 v7 = 0; | |
4649 if (a3 == 0.0) | |
4650 v7 = 216; | |
4651 if (a2) | |
4652 v7 = 248; | |
4653 return (-1 - v7) << 24; | |
4654 } | |
4655 else | |
4656 { | |
4657 if (a3 > (double)day_fogrange_2) | |
4658 { | |
4659 v7 = 216; | |
4660 if (a3 == 0.0) | |
4661 v7 = 216; | |
4662 if (a2) | |
4663 v7 = 248; | |
4664 return (-1 - v7) << 24; | |
4665 } | |
4666 else | |
4667 v7 = floorf(((a3 - (double)day_fogrange_1) * 216.0 / ((double)day_fogrange_2 - (double)day_fogrange_1)) + 0.5f); | |
4668 } | |
4669 } | |
4670 if (v7 > 216) | |
4671 v7 = 216; | |
4672 else | |
4673 { | |
4674 if (a3 == 0.0) | |
4675 v7 = 216; | |
4676 } | |
4677 if (a2) | |
4678 v7 = 248; | |
4679 return (-1 - v7) << 24; | |
4680 } | |
4681 | |
4682 | |
4683 //----- (0047F44B) -------------------------------------------------------- | |
4684 unsigned int WorldPosToGridCellX(int sWorldPosX) | |
4685 { | |
4686 return (sWorldPosX >> 9) + 64; // sar is in original exe, resulting -880 / 512 = -1 | |
4687 // and -880 sar 9 = -2 | |
4688 } | |
4689 | |
4690 //----- (0047F458) -------------------------------------------------------- | |
4691 unsigned int WorldPosToGridCellZ(int sWorldPosZ) | |
4692 { | |
4693 return 64 - (sWorldPosZ >> 9); // sar is in original exe, resulting -880 / 512 = -1 | |
4694 // and -880 sar 9 = -2 | |
4695 } | |
4696 | |
4697 //----- (0047F469) -------------------------------------------------------- | |
4698 int GridCellToWorldPosX(int a1) | |
4699 { | |
4700 return (a1 - 64) << 9; | |
4701 } | |
4702 | |
4703 //----- (0047F476) -------------------------------------------------------- | |
4704 int GridCellToWorldPosZ(int a1) | |
4705 { | |
4706 return (64 - a1) << 9; | |
4707 } | |
4708 | |
4709 | |
4710 | |
4711 //----- (00481ED9) -------------------------------------------------------- | |
4712 void sub_481ED9_MessWithODMRenderParams() | |
4713 { | |
4714 stru_8019C8._48616B_frustum_odm(65536, 0, 0, 0, 65536, 0); | |
4715 pODMRenderParams->uNumPolygons = 0; | |
4716 //pODMRenderParams->uNumEdges = 0; | |
4717 //pODMRenderParams->uNumSpans = 0; | |
4718 //pODMRenderParams->uNumSurfs = 0; | |
4719 pODMRenderParams->uNumBillboards = 0; | |
4720 pODMRenderParams->field_44 = 0; | |
4721 } | |
4722 | |
4723 //----- (004823F4) -------------------------------------------------------- | |
4724 bool IsTerrainSlopeTooHigh(int pos_x, int pos_z) | |
4725 { | |
4726 //unsigned int v2; // ebx@1 | |
4727 //unsigned int v3; // edi@1 | |
4728 //int v4; // eax@1 | |
4729 //int v6; // esi@5 | |
4730 //int v7; // ecx@6 | |
4731 //int v8; // edx@6 | |
4732 //int v9; // eax@6 | |
4733 //int y_min; // esi@10 | |
4734 //int v11; // [sp+14h] [bp-8h]@1 | |
4735 //int v12; // [sp+18h] [bp-4h]@1 | |
4736 | |
4737 //v12 = a1; | |
4738 //v11 = a2; | |
4739 unsigned int grid_x = WorldPosToGridCellX(pos_x); | |
4740 unsigned int grid_z = WorldPosToGridCellZ(pos_z) - 1; | |
4741 | |
4742 int party_grid_x1 = GridCellToWorldPosX(grid_x); | |
4743 //dword_76D56C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(grid_x + 1); | |
4744 //dword_76D570_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(grid_x + 1); | |
4745 //dword_76D574_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(grid_x); | |
4746 int party_grid_z1 = GridCellToWorldPosZ(grid_z); | |
4747 //dword_76D55C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(grid_z); | |
4748 //dword_76D560_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(grid_z + 1); | |
4749 //dword_76D564_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(grid_z + 1); | |
4750 int party_x1z1_y = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z); | |
4751 int party_x2z1_y = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z); | |
4752 int party_x2z2_y = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z + 1); | |
4753 int party_x1z2_y = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z + 1); | |
4754 //dword_76D554_terrain_cell_world_pos_around_party_y = v4; | |
4755 if (party_x1z1_y == party_x2z1_y && | |
4756 party_x2z1_y == party_x2z2_y && | |
4757 party_x2z2_y == party_x1z2_y) | |
4758 return false; | |
4759 | |
4760 int dx = abs(pos_x - party_grid_x1), | |
4761 dz = abs(party_grid_z1 - pos_z); | |
4762 | |
4763 int y1, y2, y3; | |
4764 if (dz >= dx) | |
4765 { | |
4766 y1 = party_x1z2_y; // lower-left triangle | |
4767 y2 = party_x2z2_y; // y3 | \ | |
4768 y3 = party_x1z1_y; // | \ | |
4769 /* | \ | |
4770 |______ \ | |
4771 y1 y2 */ | |
4772 } | |
4773 else | |
4774 { | |
4775 y1 = party_x2z1_y; // upper-right | |
4776 y2 = party_x1z1_y; // y2_______ y1 | |
4777 y3 = party_x2z2_y; // \ | | |
4778 /* \ | | |
4779 \ | | |
4780 y3 */ | |
4781 } | |
4782 | |
4783 int y_min = min(y1, min(y2, y3));// не верно при подъёме на склон | |
4784 int y_max = max(y1, max(y2, y3)); | |
4785 return (y_max - y_min) > 512; | |
4786 } | |
4787 | |
4788 //----- (0048257A) -------------------------------------------------------- | |
4789 int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *pIsOnWater, int bFloatAboveWater) | |
4790 { | |
4791 // int result; // eax@9 | |
4792 int v8; // ebx@11 | |
4793 int v9; // eax@11 | |
4794 int v10; // ecx@11 | |
4795 int v13; // [sp+10h] [bp-8h]@11 | |
4796 signed int v14; // [sp+14h] [bp-4h]@3 | |
4797 int v15; // [sp+24h] [bp+Ch]@11 | |
4798 | |
4799 unsigned int grid_x = WorldPosToGridCellX(a1); | |
4800 unsigned int grid_z = WorldPosToGridCellZ(a2) - 1; | |
4801 | |
4802 int grid_x1 = GridCellToWorldPosX(grid_x), | |
4803 grid_x2 = GridCellToWorldPosX(grid_x + 1); | |
4804 int grid_z1 = GridCellToWorldPosZ(grid_z), | |
4805 grid_z2 = GridCellToWorldPosZ(grid_z + 1); | |
4806 | |
4807 int y_x1z1 = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z), | |
4808 y_x2z1 = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z), | |
4809 y_x2z2 = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z + 1), | |
4810 y_x1z2 = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z + 1); | |
4811 //v4 = WorldPosToGridCellX(a1); | |
4812 //v5 = WorldPosToGridCellZ(v12) - 1; | |
4813 //dword_76D538_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4); | |
4814 //dword_76D53C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1); | |
4815 //dword_76D540_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1); | |
4816 //dword_76D544_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4); | |
4817 //dword_76D528_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5); | |
4818 //dword_76D52C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5); | |
4819 //dword_76D530_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1); | |
4820 //dword_76D534_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1); | |
4821 //dword_76D518_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5); | |
4822 //dword_76D51C_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5); | |
4823 //dword_76D520_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5 + 1); | |
4824 //dword_76D524_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5 + 1); | |
4825 *pIsOnWater = false; | |
4826 if (pOutdoor->ActuallyGetSomeOtherTileInfo(grid_x, grid_z) & 2) | |
4827 *pIsOnWater = true; | |
4828 v14 = 0; | |
4829 if (!bFloatAboveWater && *pIsOnWater) | |
4830 v14 = -60; | |
4831 if (y_x1z1 != y_x2z1 || | |
4832 y_x2z1 != y_x2z2 || | |
4833 y_x2z2 != y_x1z2) | |
4834 { | |
4835 if (abs(grid_z1 - a2) >= abs(a1 - grid_x1)) | |
4836 { | |
4837 v8 = y_x1z2; | |
4838 v9 = y_x2z2; | |
4839 v10 = y_x1z1; | |
4840 v15 = a1 - grid_x1; | |
4841 v13 = a2 - grid_z2; | |
4842 } | |
4843 else | |
4844 { | |
4845 v8 = y_x2z1; | |
4846 v9 = y_x1z1; | |
4847 v10 = y_x2z2; | |
4848 v15 = grid_x2 - a1; | |
4849 v13 = grid_z1 - a2; | |
4850 } | |
4851 return v14 + v8 + fixpoint_mul(v13, (v10 - v8) * 128) + fixpoint_mul(v15, (v9 - v8) * 128); | |
4852 } | |
4853 else | |
4854 return y_x1z1; | |
4855 } |