2496
|
1 #define _CRTDBG_MAP_ALLOC
|
|
2 #include <stdlib.h>
|
|
3 #include <crtdbg.h>
|
|
4
|
|
5 #define _CRT_SECURE_NO_WARNINGS
|
2499
|
6 #include "../ErrorHandling.h"
|
2496
|
7
|
|
8 #include "stru6.h"
|
|
9 #include "Weather.h"
|
|
10 #include "Sprites.h"
|
|
11 #include "LightmapBuilder.h"
|
|
12 #include "Outdoor.h"
|
2499
|
13 #include "../Party.h"
|
|
14 #include "../Objects/SpriteObject.h"
|
|
15 #include "../LOD.h"
|
2496
|
16 #include "PaletteManager.h"
|
2502
|
17 #include "GUI/GUIProgressBar.h"
|
|
18 #include "Media/Audio/AudioPlayer.h"
|
2496
|
19 #include "DecorationList.h"
|
2499
|
20 #include "../OurMath.h"
|
|
21 #include "../Objects/ObjectList.h"
|
|
22 #include "../Game.h"
|
|
23 #include "../Objects/Actor.h"
|
|
24 #include "../Objects/Chest.h"
|
|
25 #include "../stru123.h"
|
|
26 #include "../Timer.h"
|
2496
|
27 #include "Viewport.h"
|
2499
|
28 #include "../Events.h"
|
2496
|
29 #include "ParticleEngine.h"
|
2499
|
30 #include "../TurnEngine/TurnEngine.h"
|
|
31
|
|
32 #include "../MM7.h"
|
2496
|
33 #include "Lights.h"
|
|
34
|
2502
|
35 #include "GUI/GUIWindow.h"
|
2499
|
36 #include "Level/Decoration.h"
|
|
37 #include "../ZlibWrapper.h"
|
|
38 #include "../MMT.h"
|
2496
|
39
|
|
40 MapStartPoint uLevel_StartingPointType; // weak
|
|
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
|
|
87 pGame->pIndoorCameraD3D->debug_flags = 0;
|
|
88 if (viewparams->draw_d3d_outlines)
|
|
89 pGame->pIndoorCameraD3D->debug_flags |= ODM_RENDER_DRAW_D3D_OUTLINES;
|
|
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();
|
|
108 //pGame->pIndoorCameraD3D->sr_Reset_list_0037C();
|
|
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();
|
|
136 pGame->pIndoorCameraD3D->sr_438240_draw_lits();
|
|
137 }*/
|
|
138 pGame->PushStationaryLights(-1);
|
|
139 pGame->PrepareBloodsplats();
|
|
140 if (bRedraw)
|
|
141 pOutdoor->UpdateDiscoveredArea(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y), 1);
|
2508
|
142 pGame->uFlags2 &= 0xFFFFFFFEu;//~0x00000001
|
2496
|
143 if (/*pRenderer->pRenderD3D*/true && pRenderer->bUsingSpecular)
|
|
144 pGame->pLightmapBuilder->uFlags |= 1;
|
|
145 else
|
2508
|
146 pGame->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;
|
|
165 if ( !(pParty->uFlags & 2) && !(pGame->uFlags2 & 1) )
|
|
166 redrawWorld = false;
|
|
167 pOutdoor->ExecDraw(redrawWorld);
|
|
168
|
|
169 pGame->DrawParticles();
|
|
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
|
|
626 if ( ((double)pGame->pIndoorCameraD3D->vPartyPos.x - a2->vWorldPosition.x) * v26
|
|
627 + ((double)pGame->pIndoorCameraD3D->vPartyPos.z - a2->vWorldPosition.z) * v25
|
|
628 + ((double)pGame->pIndoorCameraD3D->vPartyPos.y - a2->vWorldPosition.y) * v24 > 0.0 )
|
|
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) --------------------------------------------------------
|
|
856 int OutdoorLocationTerrain::_47CB57(int a1, int a2, int a3)
|
|
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;
|
|
900 for ( i = 0; i < a3; ++i )
|
|
901 {
|
|
902 v9 = *(char *)(v8 + a1);
|
|
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);
|
|
1228 auto pTex = (Texture *)v149;
|
|
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 )
|
|
2206 pBitmaps_LOD->pTextures[i].uDecompressedSize = this->pTerrain._47CB57((int)pBitmaps_LOD->pTextures[i].pLevelOfDetail0_prolly_alpha_mask,
|
|
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);
|
|
2269 if ( pSpriteObjects[i].stru_24.uItemID )
|
|
2270 {
|
|
2271 if ( pSpriteObjects[i].stru_24.uItemID != 220
|
|
2272 && pItemsTable->pItems[pSpriteObjects[i].stru_24.uItemID].uEquipType == EQUIP_POTION
|
|
2273 && !pSpriteObjects[i].stru_24.uEnchantmentType )
|
|
2274 pSpriteObjects[i].stru_24.uEnchantmentType = rand() % 15 + 5;
|
|
2275 pItemsTable->SetSpecialBonus(&pSpriteObjects[i].stru_24);
|
|
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;
|
|
2441 pGame->pStru6Instance->_4A7F74(pActors[i].vPosition.x, pActors[i].vPosition.y, z);
|
|
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 }
|
|
2449 v8 = stru_5C6E00->Atan2(pActors[i].vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x,
|
|
2450 pActors[i].vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y);
|
|
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 }
|
|
2489 v17 = (x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16;
|
|
2490 if (pGame->pIndoorCameraD3D->sRotationX)
|
|
2491 {
|
|
2492 v18 = (y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16;
|
|
2493 v47 = (fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v18, pGame->pIndoorCameraD3D->int_sine_y));
|
|
2494 v50 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_sine_y);
|
|
2495 v53 = fixpoint_mul(v18, pGame->pIndoorCameraD3D->int_cosine_y);
|
|
2496 v44 = (z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16;
|
|
2497 v19 = (fixpoint_mul(v44, pGame->pIndoorCameraD3D->int_sine_x) + fixpoint_mul(v47, pGame->pIndoorCameraD3D->int_cosine_x));
|
|
2498 X = fixpoint_mul(v44, pGame->pIndoorCameraD3D->int_sine_x) + fixpoint_mul(v47, pGame->pIndoorCameraD3D->int_cosine_x);
|
|
2499 if ( v19 < 262144 || v19 > pODMRenderParams->shading_dist_mist << 16 )
|
|
2500 continue;
|
|
2501 v20 = v53 - v50;
|
|
2502 v42 = v53 - v50;
|
|
2503 v21 = (fixpoint_mul(v44, pGame->pIndoorCameraD3D->int_cosine_x) - fixpoint_mul(v47, pGame->pIndoorCameraD3D->int_sine_x));
|
|
2504 }
|
|
2505 else
|
|
2506 {
|
|
2507 v48 = (y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16;
|
|
2508 v51 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y);
|
|
2509 v22 = fixpoint_mul(v48, pGame->pIndoorCameraD3D->int_sine_y);
|
|
2510 X = v22 + v51;
|
|
2511 if ( v22 + v51 < 262144 || v22 + v51 > pODMRenderParams->shading_dist_mist << 16 )
|
|
2512 continue;
|
|
2513 v23 = fixpoint_mul(((x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16), pGame->pIndoorCameraD3D->int_sine_y);
|
|
2514 v20 = fixpoint_mul(v48, pGame->pIndoorCameraD3D->int_cosine_y) - v23;
|
|
2515 v42 = fixpoint_mul(v48, pGame->pIndoorCameraD3D->int_cosine_y) - v23;
|
|
2516 v21 = (z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16;
|
|
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 {
|
|
2548 pBillboardRenderList[uNumBillboardsToDraw - 1]._screenspace_y_scaler_packedfloat = fixpoint_mul(pGame->pStru6Instance->_4A806F(&pActors[i]),
|
|
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);
|
|
2882 TravelUI_Load();
|
|
2883 }
|
|
2884 }
|
|
2885 UpdateActors_ODM();
|
|
2886 check_event_triggers();
|
|
2887 }
|
|
2888 //----- (0041F54A) --------------------------------------------------------
|
|
2889 void OutdoorLocation::LoadActualSkyFrame()
|
|
2890 {
|
|
2891 if ( pTexture_RestUI_CurrentSkyFrame )
|
|
2892 pTexture_RestUI_CurrentSkyFrame->Release();
|
|
2893 if ( pTexture_RestUI_CurrentHourglassFrame )
|
|
2894 pTexture_RestUI_CurrentHourglassFrame->Release();
|
|
2895 pIcons_LOD->SyncLoadedFilesCount();
|
|
2896 sprintf(pTmpBuf.data(), "TERRA%03d", pParty->uCurrentMinute / 6 + 10 * pParty->uCurrentHour);
|
|
2897 pTexture_RestUI_CurrentSkyFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE);
|
|
2898 }
|
|
2899
|
|
2900
|
|
2901 //----- (004626BA) --------------------------------------------------------
|
|
2902 OutdoorLocation::OutdoorLocation()
|
|
2903 {
|
|
2904 subconstuctor();
|
|
2905 uLastSunlightUpdateMinute = 0;
|
|
2906
|
|
2907 uNumBModels = 0;
|
|
2908 pBModels = nullptr;
|
|
2909 }
|
|
2910
|
|
2911 //----- (004626CD) --------------------------------------------------------
|
|
2912 void OutdoorLocation::subconstuctor()
|
|
2913 {
|
|
2914 //OutdoorLocationTerrain::OutdoorLocationTerrain(&this->pTerrain);
|
|
2915 field_F0 = 0;
|
|
2916 field_F4 = 0x40000000u;
|
|
2917 //DLVHeader::DLVHeader(&v1->ddm);
|
|
2918 pSpawnPoints = 0;
|
|
2919 pBModels = 0;
|
|
2920 pCmap = 0;
|
|
2921 pFaceIDLIST = 0;
|
|
2922 pOMAP = 0;
|
|
2923 }
|
|
2924
|
|
2925 //----- (00481E55) --------------------------------------------------------
|
|
2926 void ODM_Project(unsigned int uNumVertices)
|
|
2927 {
|
|
2928 for ( uint i = 0; i < uNumVertices; i++ )
|
|
2929 {
|
|
2930 memcpy(&array_50AC10[i], &array_507D30[i], sizeof(array_50AC10[i]));
|
|
2931 array_50AC10[i].vWorldViewProjX = (double)pViewport->uScreenCenterX
|
|
2932 - ((double)pODMRenderParams->int_fov_rad * array_507D30[i]._rhw) * array_507D30[i].vWorldViewPosition.y;
|
|
2933 array_50AC10[i].vWorldViewProjY = (double)pViewport->uScreenCenterY
|
|
2934 - ((double)pODMRenderParams->int_fov_rad * array_507D30[i]._rhw) * array_507D30[i].vWorldViewPosition.z;
|
|
2935 }
|
|
2936 }
|
|
2937 //----- (00485F64) --------------------------------------------------------
|
|
2938 void ODMRenderParams::Initialize()
|
|
2939 {
|
|
2940 int v1; // eax@1
|
|
2941 int v2; // eax@2
|
|
2942 signed __int64 v3; // qtt@4
|
|
2943 int v4; // eax@4
|
|
2944
|
|
2945 this->uCameraFovInDegrees = 75;
|
|
2946 v1 = stru_5C6E00->uPiMask & 0xD5;
|
|
2947 if ( v1 >= (signed int)stru_5C6E00->uIntegerHalfPi )
|
|
2948 v2 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v1];
|
|
2949 else
|
|
2950 v2 = stru_5C6E00->pTanTable[v1];
|
|
2951 LODWORD(v3) = (viewparams->uSomeZ - viewparams->uSomeX) << 31;
|
|
2952 HIDWORD(v3) = (viewparams->uSomeZ - viewparams->uSomeX) << 15 >> 16;
|
|
2953 v4 = (signed int)(v3 / v2) >> 16;
|
|
2954 this->int_fov_rad = v4;
|
|
2955 this->field_4C = 360000;
|
|
2956 this->int_fov_rad_inv = 65536 / v4;
|
|
2957 this->field_50 = 115;
|
|
2958 //sr_6BE060[1] = 1;
|
|
2959 //RotationToInts();
|
|
2960 }
|
|
2961 //----- (00473893) --------------------------------------------------------
|
|
2962 void ODM_ProcessPartyActions()
|
|
2963 {
|
|
2964 int v1; // edi@1
|
|
2965 int v2; // ebx@1
|
|
2966 int floor_level; // eax@14
|
|
2967 ODMFace *face; // ecx@45
|
|
2968 int v34; // esi@143
|
|
2969 int v35; // esi@147
|
|
2970 int v36; // eax@155
|
|
2971 int v40; // esi@162
|
|
2972 bool v42; // eax@180
|
|
2973 signed int v43; // ecx@184
|
|
2974 signed int v44; // edx@184
|
|
2975 int v45; // ecx@200
|
|
2976 BSPModel *pModel; // eax@203
|
|
2977 bool pModel_;
|
|
2978 ODMFace *pODMFace; // esi@203
|
|
2979 int v48; // eax@203
|
|
2980 int v54; // eax@215
|
|
2981 int v55; // eax@217
|
|
2982 unsigned int v66; // esi@263
|
|
2983 signed int v68; // ecx@263
|
|
2984 int v69; // eax@263
|
|
2985 bool v77; // edx@297
|
|
2986 bool v78; // ecx@303
|
|
2987 int v79; // ecx@314
|
|
2988 __int16 v80; // dx@317
|
|
2989 int pTerrainHeight; // eax@321
|
|
2990 int v87; // [sp-20h] [bp-B4h]@248
|
|
2991 int v97; // [sp+Ch] [bp-88h]@180
|
|
2992 Vec3_int_ v98;
|
|
2993 bool not_high_fall; // [sp+1Ch] [bp-78h]@33
|
|
2994 int v102; // [sp+20h] [bp-74h]@1
|
|
2995 int trigger_id; // [sp+24h] [bp-70h]@1
|
|
2996 bool bFeatherFall; // [sp+28h] [bp-6Ch]@4
|
|
2997 int bonus;
|
|
2998 int on_ground; // [sp+2Ch] [bp-68h]@24
|
|
2999 bool bWaterWalk; // [sp+30h] [bp-64h]@1
|
|
3000 int ceiling_height; // [sp+3Ch] [bp-58h]@28
|
|
3001 int v110; // [sp+40h] [bp-54h]@180
|
|
3002 int v111; // [sp+44h] [bp-50h]@14
|
|
3003 bool hovering; // [sp+48h] [bp-4Ch]@1
|
|
3004 int v113; // [sp+4Ch] [bp-48h]@1
|
|
3005 bool party_running_flag; // [sp+50h] [bp-44h]@1
|
|
3006 int _walk_speed; // [sp+54h] [bp-40h]@48
|
|
3007 int pX; // [sp+58h] [bp-3Ch]@1
|
|
3008 int pY; // [sp+5Ch] [bp-38h]@1
|
2534
|
3009 int party_new_Z; // [sp+74h] [bp-20h]@1
|
2496
|
3010 int v118; // [sp+60h] [bp-34h]@1
|
|
3011 int _angle_x; // [sp+68h] [bp-2Ch]@48
|
|
3012 unsigned int v122; // [sp+70h] [bp-24h]@180
|
2534
|
3013
|
2496
|
3014 bool party_walking_flag; // [sp+78h] [bp-1Ch]@1
|
|
3015 int _angle_y; // [sp+7Ch] [bp-18h]@48
|
|
3016 int v128; // [sp+88h] [bp-Ch]@1
|
|
3017 int v129; // [sp+8Ch] [bp-8h]@92
|
|
3018
|
|
3019 v1 = 0;
|
|
3020 trigger_id = 0;
|
|
3021 v2 = 0;
|
|
3022 //*(float *)&v128 = 0.0;
|
|
3023 int fall_speed = pParty->uFallSpeed;
|
|
3024 v128 = 0;
|
|
3025 v129 = 0;
|
2534
|
3026
|
2496
|
3027 pX = pParty->vPosition.x;
|
|
3028 pY = pParty->vPosition.y;
|
2534
|
3029 party_new_Z = pParty->vPosition.z;
|
|
3030
|
2496
|
3031 v113 = pParty->field_6F0;
|
|
3032 hovering = false;
|
|
3033 bool partyAtHighSlope = IsTerrainSlopeTooHigh(pParty->vPosition.x, pParty->vPosition.y);
|
|
3034 party_running_flag = false;
|
|
3035 party_walking_flag = false;
|
|
3036 v102 = 0;
|
|
3037 pModel_ = false;
|
|
3038 bWaterWalk = false;
|
2534
|
3039 //************************************
|
|
3040 //Проверка падение пера
|
|
3041 if (!pParty->FeatherFallActive())
|
2496
|
3042 {
|
|
3043 bFeatherFall = false;
|
|
3044 for (int i = 0; i < 4; ++i)
|
|
3045 if (pParty->pPlayers[i].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT)) // seems like flying boots
|
|
3046 {
|
|
3047 bFeatherFall = true;
|
|
3048 break;
|
|
3049 }
|
|
3050 }
|
|
3051 else
|
|
3052 bFeatherFall = true;
|
2534
|
3053 //************************************
|
|
3054 //Проверка хождения по воде
|
2496
|
3055 pParty->uFlags &= ~PARTY_FLAGS_1_STANDING_ON_WATER;
|
2534
|
3056 if (pParty->WaterWalkActive())
|
2496
|
3057 {
|
|
3058 //LOBYTE(pParty->uFlags) &= 0x7Fu;
|
|
3059 bWaterWalk = true;
|
2508
|
3060 *(short *)&stru_5E4C90_MapPersistVars._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 119] |= 1;
|
2496
|
3061 if (!(pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags & 1) &&
|
|
3062 pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster - 1].sMana <= 0 )
|
|
3063 bWaterWalk = false;
|
|
3064 }
|
2534
|
3065 //*************************************
|
|
3066 //определение уровня пола
|
|
3067 int bmodel_standing_on_pid; //данные 3D model'и
|
|
3068 int is_on_water = false; //на воду
|
|
3069 floor_level = ODM_GetFloorLevel(pX, pY, party_new_Z, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, bWaterWalk);
|
|
3070 int is_not_on_bmodel = bmodel_standing_on_pid == 0; //не на 3D model
|
|
3071
|
|
3072 v111 = floor_level; //???
|
|
3073 //************************************
|
|
3074 //определение высоты падения
|
|
3075 if ( bFeatherFall ) //падение пера
|
2496
|
3076 pParty->uFallStartY = floor_level;
|
|
3077 else
|
|
3078 floor_level = pParty->uFallStartY;
|
2534
|
3079 //*************************************
|
|
3080 //падение на 3D Model
|
|
3081 if ( floor_level - party_new_Z > 512 && !bFeatherFall && party_new_Z <= v111 + 1 )
|
2496
|
3082 {
|
|
3083 if (pParty->uFlags & PARTY_FLAGS_1_LANDING)
|
|
3084 pParty->uFlags &= ~PARTY_FLAGS_1_LANDING;
|
|
3085 else for (int i = 0; i < 4; ++i) // receive falling damage
|
|
3086 {
|
|
3087 if ( !pParty->pPlayers[i].HasEnchantedItemEquipped(72) && !pParty->pPlayers[i].WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) )
|
|
3088 {
|
|
3089 pParty->pPlayers[i].ReceiveDamage(
|
2534
|
3090 (signed int)((pParty->uFallStartY - party_new_Z) * (unsigned __int64)(pParty->pPlayers[i].GetMaxHealth() / 10)) / 256, DMGT_PHISYCAL);
|
2496
|
3091 bonus = 20 - pParty->pPlayers[i].GetParameterBonus(pParty->pPlayers[i].GetActualEndurance());
|
|
3092 pParty->pPlayers[i].SetRecoveryTime((signed __int64)((double)bonus * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
|
|
3093 }
|
|
3094 }
|
|
3095 }
|
2534
|
3096 //*********************************
|
|
3097 //определение высоты потолка
|
2496
|
3098 ceiling_height = -1;
|
2534
|
3099 if ( pParty->bFlying ) //в полёте
|
|
3100 ceiling_height = GetCeilingHeight(pX, pY, party_new_Z + pParty->uPartyHeight, (int)&v102);//высота потолка
|
2496
|
3101 //v107 = bmodel_standing_on_pid == 0;
|
2534
|
3102 on_ground = v111 + 1; //на земле
|
|
3103 //**************************************
|
|
3104
|
|
3105 if ( party_new_Z <= on_ground )//полёт: посадка
|
2496
|
3106 {
|
|
3107 ceiling_height = -1;
|
|
3108 pParty->bFlying = false;
|
|
3109 }
|
|
3110 else
|
|
3111 hovering = true;
|
2534
|
3112 not_high_fall = party_new_Z - v111 <= 32;
|
|
3113 //****************************************
|
|
3114 //timer update(обновить таймер звука ходьбы)
|
|
3115 if ( bWalkSound && pParty->walk_sound_timer)
|
2496
|
3116 {
|
|
3117 if (pParty->walk_sound_timer >= pEventTimer->uTimeElapsed)
|
|
3118 pParty->walk_sound_timer -= pEventTimer->uTimeElapsed;
|
|
3119 else
|
|
3120 pParty->walk_sound_timer = 0;
|
|
3121 }
|
2534
|
3122 //****************************************
|
|
3123 // конец действия полёта
|
|
3124 if (!bUnderwater && pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime <= 0)//не под водой и время закла полёта закончилось
|
2496
|
3125 pParty->bFlying = false;
|
2534
|
3126 //*****************************************
|
|
3127 // установить на чём стоит группа
|
|
3128 if (!hovering)//не в воздухе
|
2496
|
3129 {
|
|
3130 if ( pParty->floor_face_pid != PID(OBJECT_BModel, bmodel_standing_on_pid) )
|
|
3131 {
|
|
3132 if (bmodel_standing_on_pid)
|
|
3133 {
|
2534
|
3134 int BModel_id = bmodel_standing_on_pid >> 6;
|
|
3135 if ( BModel_id < pOutdoor->uNumBModels )
|
2496
|
3136 {
|
2534
|
3137 face = pOutdoor->pBModels[BModel_id].pFaces;
|
|
3138 int face_id = bmodel_standing_on_pid & 0x3F;
|
2496
|
3139 /*if ( *(char *)(v7->pFacePlane.vNormal.x + 308 * v6 + 31) & 4 )
|
|
3140 {
|
|
3141 pParty->field_6F4_packedid = PID(OBJECT_BModel,v108);
|
|
3142 v103 = *(short *)(v7->pFacePlane.vNormal.x + 308 * v6 + 292);
|
|
3143 }*/
|
2534
|
3144 if ( face[face_id].uAttributes & FACE_PRESSURE_PLATE )
|
2496
|
3145 {
|
|
3146 pParty->floor_face_pid = PID(OBJECT_BModel, bmodel_standing_on_pid);
|
2534
|
3147 trigger_id = face[face_id].sCogTriggeredID; //EVT, панель имеет событие
|
2496
|
3148 }
|
|
3149 }
|
|
3150 }
|
|
3151 }
|
2534
|
3152 pParty->floor_face_pid = PID(OBJECT_BModel, bmodel_standing_on_pid);//6 - на земле
|
2496
|
3153 }
|
2534
|
3154 //***********************************************
|
2496
|
3155 _walk_speed = pParty->uWalkSpeed;
|
|
3156 _angle_y = pParty->sRotationY;
|
|
3157 _angle_x = pParty->sRotationX;
|
|
3158 //v126 = pEventTimer->dt_in_some_format;
|
|
3159 /*v119 = (Player **)((unsigned __int64)(pEventTimer->dt_in_some_format
|
|
3160 * (signed __int64)((signed int)(pParty->field_20_prolly_turn_speed
|
|
3161 * stru_5C6E00->uIntegerPi)
|
|
3162 / 180)) >> 16);*/
|
|
3163 __int64 dturn = (unsigned __int64)(pEventTimer->dt_in_some_format * (signed __int64)((signed int)(pParty->y_rotation_speed * stru_5C6E00->uIntegerPi) / 180)) >> 16;
|
|
3164 while (pPartyActionQueue->uNumActions)
|
|
3165 {
|
|
3166 switch (pPartyActionQueue->Next())
|
|
3167 {
|
|
3168 case PARTY_FlyUp://полёт вверх
|
|
3169 {
|
|
3170 if (!pParty->FlyActive() && !bUnderwater)
|
|
3171 break;
|
|
3172
|
|
3173 pParty->bFlying = false;
|
|
3174 if (bUnderwater ||
|
|
3175 pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags & 1 ||
|
|
3176 pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].sMana > 0 )
|
|
3177 {
|
|
3178 extern int max_flight_height;
|
|
3179 if ( pParty->vPosition.z < max_flight_height || hovering )
|
|
3180 {
|
2534
|
3181 party_new_Z += 30;
|
2496
|
3182 v113 += 30;
|
|
3183 pParty->bFlying = true;
|
2534
|
3184 if ( party_new_Z > max_flight_height )
|
2496
|
3185 {
|
2534
|
3186 party_new_Z = max_flight_height;
|
2496
|
3187 v113 = max_flight_height;
|
|
3188 }
|
|
3189 v1 = 0;
|
|
3190 v2 = 0;
|
|
3191 fall_speed = 0;
|
|
3192 *(float *)&v128 = 0.0;
|
2534
|
3193 if ( v102 && party_new_Z < ceiling_height && (signed int)(pParty->uPartyHeight + party_new_Z) >= ceiling_height )//столкновение с потолком
|
2496
|
3194 {
|
|
3195 pParty->field_6E0 = 0;
|
|
3196 pParty->field_6E4 = 0;
|
|
3197 pPartyActionQueue->uNumActions = 0;
|
|
3198 pParty->uFlags |= PARTY_FLAGS_1_LANDING;
|
|
3199 pParty->vPosition.z = ceiling_height - pParty->uPartyHeight - 31;
|
2534
|
3200 pParty->field_6F0 = party_new_Z;
|
2496
|
3201 pParty->bFlying = false;
|
2534
|
3202 party_new_Z = ceiling_height - pParty->uPartyHeight - 31;
|
2496
|
3203 v113 = pParty->field_6F0;
|
|
3204 }
|
|
3205 pParty->uFallSpeed = 0;
|
|
3206 pModel_ = true;
|
|
3207 }
|
|
3208 }
|
|
3209 }
|
|
3210 break;
|
|
3211
|
|
3212 case PARTY_FlyDown://полёт вниз
|
|
3213 if (pParty->FlyActive() || bUnderwater)
|
|
3214 {
|
|
3215 pParty->bFlying = false;
|
|
3216 if ( bUnderwater
|
|
3217 || pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags & 1
|
|
3218 || pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].sMana > 0 )//*(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster + 10] > 0 )
|
|
3219 {
|
2534
|
3220 party_new_Z -= 30;
|
2496
|
3221 v113 -= 30;
|
|
3222 pParty->uFallSpeed = 0;
|
|
3223 fall_speed = 0;
|
|
3224 pParty->bFlying = true;
|
|
3225 pModel_ = true;
|
2534
|
3226 if ( party_new_Z <= v111 )
|
2496
|
3227 {
|
|
3228 pParty->bFlying = false;
|
|
3229 pPartyActionQueue->uNumActions = 0;
|
|
3230 }
|
|
3231 }
|
|
3232 }
|
|
3233 break;
|
|
3234
|
2534
|
3235 case PARTY_TurnLeft://поворот влево
|
2496
|
3236 if (uTurnSpeed)
|
|
3237 _angle_y += uTurnSpeed; //descrete turn
|
|
3238 else
|
|
3239 _angle_y += dturn * fTurnSpeedMultiplier; // time-based smooth turn
|
|
3240
|
|
3241 _angle_y &= stru_5C6E00->uDoublePiMask;
|
|
3242 break;
|
|
3243
|
2534
|
3244 case PARTY_TurnRight://поворот вправо
|
2496
|
3245 if (uTurnSpeed)
|
|
3246 _angle_y -= uTurnSpeed;
|
|
3247 else
|
|
3248 _angle_y -= dturn * fTurnSpeedMultiplier;
|
|
3249
|
|
3250 _angle_y &= stru_5C6E00->uDoublePiMask;
|
|
3251 break;
|
|
3252
|
2534
|
3253 case PARTY_FastTurnLeft://быстрый поворот влево
|
2496
|
3254 if (uTurnSpeed)
|
|
3255 _angle_y += uTurnSpeed;
|
|
3256 else
|
|
3257 _angle_y += 2.0f * fTurnSpeedMultiplier * (double)dturn;
|
|
3258
|
|
3259 _angle_y &= stru_5C6E00->uDoublePiMask;
|
|
3260 break;
|
|
3261
|
2534
|
3262 case PARTY_FastTurnRight://быстрый поворот вправо
|
2496
|
3263 if (!uTurnSpeed)
|
|
3264 _angle_y -= 2.0f * fTurnSpeedMultiplier * (double)dturn;
|
|
3265 else
|
|
3266 _angle_y -= uTurnSpeed;
|
|
3267
|
|
3268 _angle_y &= stru_5C6E00->uDoublePiMask;
|
|
3269 break;
|
|
3270
|
|
3271 case PARTY_StrafeLeft://хождение боком в влево
|
|
3272 {
|
|
3273 *(float *)&v128 = pParty->uWalkSpeed;
|
|
3274
|
2534
|
3275 float sin_y = sinf(2 * pi_double * _angle_y / 2048.0);
|
2496
|
3276 int dx = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier;
|
|
3277 v2 -= 3 * dx / 4;
|
|
3278
|
2534
|
3279 float cos_y = cosf(2 * pi_double * _angle_y / 2048.0);
|
2496
|
3280 int dy = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier;
|
|
3281 v1 += 3 * dy / 4;
|
|
3282
|
|
3283 v128 = v1;
|
|
3284 party_walking_flag = true;
|
|
3285 }
|
|
3286 break;
|
|
3287
|
|
3288 case PARTY_StrafeRight://хождение боком в вправо
|
|
3289 {
|
|
3290 *(float *)&v128 = pParty->uWalkSpeed;
|
|
3291
|
2534
|
3292 float sin_y = sinf(2 * pi_double * _angle_y / 2048.0);
|
2496
|
3293 int dx = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier;
|
|
3294 v2 += 3 * dx / 4;
|
|
3295
|
2534
|
3296 float cos_y = cosf(2 * pi_double * _angle_y / 2048.0);
|
2496
|
3297 int dy = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier;
|
|
3298 v1 -= 3 * dy / 4;
|
|
3299
|
|
3300 v128 = v1;
|
|
3301 party_walking_flag = true;
|
|
3302 }
|
|
3303 break;
|
|
3304
|
|
3305 case PARTY_WalkForward:// идти вперёд
|
|
3306 {
|
|
3307 *(float *)&v128 = _walk_speed;
|
|
3308
|
2534
|
3309 float sin_y = sinf(2 * pi_double * _angle_y / 2048.0),
|
|
3310 cos_y = cosf(2 * pi_double * _angle_y / 2048.0);
|
2496
|
3311
|
|
3312 int dx = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier;
|
|
3313 int dy = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier;
|
|
3314
|
|
3315 if ( new_speed )
|
|
3316 {
|
|
3317 v2 += dx * 12;
|
|
3318 v1 += dy * 12;
|
|
3319 }
|
|
3320 else
|
|
3321 {
|
|
3322 v2 += dx;
|
|
3323 v1 += dy;
|
|
3324 }
|
|
3325
|
|
3326 v128 = v1;
|
|
3327 party_walking_flag = true;
|
|
3328 }
|
|
3329 break;
|
|
3330
|
|
3331 case PARTY_RunForward://бежать вперёд
|
|
3332 {
|
|
3333 *(float *)&v128 = _walk_speed;
|
|
3334
|
2534
|
3335 float sin_y = sinf(2 * pi_double * _angle_y / 2048.0);
|
|
3336 float cos_y = cosf(2 * pi_double * _angle_y / 2048.0);
|
2496
|
3337
|
|
3338 int dx = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier;
|
|
3339 int dy = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier;
|
|
3340
|
|
3341 if (pParty->bFlying)//лететь вперёд
|
|
3342 {
|
|
3343 v2 += 4 * dx;
|
|
3344 v1 += 4 * dy;
|
|
3345
|
|
3346 v128 = v1;
|
|
3347 }
|
|
3348 else if (partyAtHighSlope && !bmodel_standing_on_pid)//сбегание со склона
|
|
3349 {
|
|
3350 v2 += dx;
|
|
3351 v1 += dy;
|
|
3352
|
|
3353 v128 = v1;
|
|
3354 party_walking_flag = true;
|
|
3355 }
|
|
3356 else
|
|
3357 {
|
|
3358 /*v2 += (unsigned __int64)(stru_5C6E00->Cos(_angle_y)
|
|
3359 * (signed __int64)(signed int)(2 * (unsigned __int64)(signed __int64)((double)_walk_speed * fWalkSpeedMultiplier))) >> 16;
|
|
3360 v1 += (unsigned __int64)((signed int)stru_5C6E00->Sin(_angle_y)
|
|
3361 * (signed __int64)(signed int)(2 * (unsigned __int64)(signed __int64)((double)_walk_speed * fWalkSpeedMultiplier))) >> 16;*/
|
|
3362
|
|
3363 v2 += 2 * dx;
|
|
3364 v1 += 2 * dy;
|
|
3365
|
|
3366 v128 = v1;
|
|
3367 party_running_flag = true;
|
|
3368 }
|
|
3369 }
|
|
3370 break;
|
|
3371
|
|
3372
|
|
3373 case PARTY_WalkBackward://идти назад
|
|
3374 {
|
|
3375 *(float *)&v128 = _walk_speed;
|
|
3376
|
|
3377 float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0),
|
|
3378 cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0);
|
|
3379
|
|
3380 int dx = cos_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier;
|
|
3381 v2 -= dx;
|
|
3382
|
|
3383 int dy = sin_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier;
|
|
3384 v1 -= dy;
|
|
3385
|
|
3386 v128 = v1;
|
|
3387 party_walking_flag = true;
|
|
3388 }
|
|
3389 break;
|
|
3390
|
|
3391
|
|
3392 case PARTY_RunBackward://бежать назад
|
|
3393 {
|
|
3394 float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0),
|
|
3395 cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0);
|
|
3396
|
|
3397 int dx = cos_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier;
|
|
3398 int dy = sin_y * pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier;
|
|
3399
|
|
3400 if (pParty->bFlying)
|
|
3401 {
|
|
3402 v2 -= 4 * dx;
|
|
3403 v1 -= 4 * dy;
|
|
3404 v128 = v1;
|
|
3405 }
|
|
3406 else
|
|
3407 {
|
|
3408 v2 -= dx;
|
|
3409 v1 -= dy;
|
|
3410
|
|
3411 v128 = v1;
|
|
3412 party_walking_flag = true;
|
|
3413 }
|
|
3414 }
|
|
3415 break;
|
|
3416
|
|
3417 case PARTY_CenterView://смотреть прямо
|
|
3418 _angle_x = 0;
|
|
3419 break;
|
|
3420
|
|
3421 case PARTY_LookUp://смотреть вверх
|
|
3422 _angle_x += (signed __int64)(flt_6BE150_look_up_down_dangle * 25.0);
|
|
3423 if ( _angle_x > 128 )
|
|
3424 _angle_x = 128;
|
|
3425 if (uActiveCharacter)
|
|
3426 pPlayers[uActiveCharacter]->PlaySound(SPEECH_63, 0);
|
|
3427 break;
|
|
3428
|
|
3429 case PARTY_LookDown://смотреть вниз
|
|
3430 _angle_x += (signed __int64)(flt_6BE150_look_up_down_dangle * -25.0);
|
|
3431 if ( _angle_x < -128 )
|
|
3432 _angle_x = -128;
|
|
3433 if (uActiveCharacter)
|
|
3434 pPlayers[uActiveCharacter]->PlaySound(SPEECH_64, 0);
|
|
3435 break;
|
|
3436
|
|
3437 case PARTY_Jump://прыжок
|
|
3438 if ( (!partyAtHighSlope || bmodel_standing_on_pid) && !hovering && pParty->field_24 && !(pParty->uFlags & 4) && !(pParty->uFlags & 0x200) )
|
|
3439 {
|
|
3440 //v126 = pParty->field_24 << 6;
|
|
3441 hovering = true;
|
|
3442 fall_speed = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)fall_speed);
|
|
3443 }
|
|
3444 break;
|
|
3445
|
|
3446 case PARTY_Land://приземление(клавиша Home)
|
|
3447 if (pParty->bFlying)
|
|
3448 {
|
|
3449 pParty->uFlags |= PARTY_FLAGS_1_LANDING;
|
|
3450 pParty->uFallSpeed = 0;
|
|
3451 }
|
|
3452 pParty->bFlying = false;
|
|
3453 pPartyActionQueue->uNumActions = 0;
|
|
3454 break;
|
|
3455
|
|
3456 default:
|
|
3457 assert(false);
|
|
3458
|
|
3459
|
|
3460 }
|
|
3461 }
|
|
3462
|
|
3463 pParty->sRotationY = _angle_y;
|
|
3464 pParty->sRotationX = _angle_x;
|
|
3465 //-------------------------------------------
|
|
3466 if ( pParty->bFlying )
|
|
3467 {
|
|
3468 v129 = fixpoint_mul(4, stru_5C6E00->Cos(GetTickCount()));
|
2534
|
3469 party_new_Z = v113 + v129;
|
2496
|
3470 if ( pModel_ )
|
2534
|
3471 party_new_Z = v113;
|
2496
|
3472 if (pParty->FlyActive())
|
|
3473 stru_5E4C90_MapPersistVars._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] &= 0xFE;
|
2534
|
3474 pParty->uFallStartY = party_new_Z;
|
2496
|
3475 }
|
2534
|
3476 else if ( party_new_Z < v111 )
|
2496
|
3477 {
|
|
3478 if ( is_on_water && fall_speed )
|
|
3479 SpriteObject::sub_42F960_create_object(pX, pY, v111);
|
|
3480 fall_speed = 0;
|
2534
|
3481 party_new_Z = v111;
|
2496
|
3482 pParty->uFallStartY = v111;
|
2534
|
3483 v113 = party_new_Z;
|
2496
|
3484 if (pParty->FlyActive())
|
|
3485 stru_5E4C90_MapPersistVars._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] |= 1;
|
|
3486 }
|
|
3487 else
|
|
3488 {
|
2534
|
3489 v113 = party_new_Z;
|
2496
|
3490 if (pParty->FlyActive())
|
|
3491 stru_5E4C90_MapPersistVars._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] |= 1;
|
|
3492 }
|
|
3493 //------------------------------------------
|
|
3494 if (hovering && !pParty->bFlying)//расчёт скорости падения
|
|
3495 {
|
|
3496 //v33 = -(pEventTimer->uTimeElapsed * GetGravityStrength());
|
|
3497 v34 = fall_speed + (-(pEventTimer->uTimeElapsed * GetGravityStrength()) << 1);
|
|
3498 fall_speed += (-(pEventTimer->uTimeElapsed * GetGravityStrength()) << 1 ); //y(t) = 2*gt
|
|
3499 }
|
|
3500 else if (!partyAtHighSlope)
|
|
3501 v34 = fall_speed;
|
|
3502 else if (!hovering)
|
|
3503 {
|
|
3504 if ( !bmodel_standing_on_pid )
|
|
3505 {
|
|
3506 // rolling down the hill
|
|
3507 // how it's done: you get a little bit pushed in the air along terrain normal, getting in the air
|
|
3508 // and falling to the gravity, gradually sliding downwards. nice trick
|
2534
|
3509 party_new_Z = v111;
|
2496
|
3510 ODM_GetTerrainNormalAt(pX, pY, &v98);
|
|
3511 v35 = fall_speed + (8 * -(pEventTimer->uTimeElapsed * GetGravityStrength()));
|
|
3512 v129 = abs(v2 * v98.x + v1 * v98.y + v35 * v98.z) >> 16;
|
|
3513 v2 += fixpoint_mul(v129, v98.x);
|
|
3514 v1 += fixpoint_mul(v129, v98.y);
|
|
3515 v34 = v35 + fixpoint_mul(v129, v98.z);
|
|
3516 v128 = v1;
|
|
3517 fall_speed = v34;
|
|
3518 }
|
|
3519 }
|
|
3520 else
|
|
3521 v34 = fall_speed;
|
|
3522
|
|
3523 if ( hovering )//блок для крика падения
|
|
3524 {
|
|
3525 if ( !bUnderwater && v34 <= 0)
|
|
3526 {
|
|
3527 if ( v34 < -500 && !pParty->bFlying && pParty->vPosition.z - v111 > 1000 && !pParty->FeatherFallActive())
|
|
3528 { // falling scream
|
|
3529 for (int i = 0; i < 4; ++i)
|
|
3530 {
|
|
3531 if (!pParty->pPlayers[i].HasEnchantedItemEquipped(72)
|
|
3532 && !pParty->pPlayers[i].WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS)
|
|
3533 && pParty->pPlayers[i].CanAct())
|
|
3534 pParty->pPlayers[i].PlaySound(SPEECH_Falling_scream, 0);//крик падения
|
|
3535 }
|
|
3536 }
|
|
3537 }
|
|
3538 }
|
|
3539 else
|
2534
|
3540 pParty->uFallStartY = party_new_Z;
|
2496
|
3541
|
|
3542 if ( v2 * v2 + v1 * v1 < 400 && !partyAtHighSlope )
|
|
3543 {
|
|
3544 *(float *)&v128 = 0.0;
|
|
3545 v2 = 0;
|
|
3546 }
|
|
3547 //--(столкновения)-------------------------------------------------------------------
|
|
3548 stru_721530.field_84 = -1;
|
|
3549 stru_721530.field_70 = 0;
|
|
3550 stru_721530.prolly_normal_d = pParty->field_14_radius;
|
|
3551 stru_721530.field_8_radius = pParty->field_14_radius / 2;
|
|
3552 stru_721530.field_0 = 1;
|
|
3553 stru_721530.height = pParty->uPartyHeight - 32;
|
|
3554 for ( uint i = 0; i < 100; i++ )
|
|
3555 {
|
|
3556 stru_721530.position.x = pX;
|
|
3557 stru_721530.position.y = pY;
|
2534
|
3558 stru_721530.position.z = stru_721530.height + party_new_Z + 1;
|
2496
|
3559
|
|
3560 stru_721530.normal.x = pX;
|
|
3561 stru_721530.normal.y = pY;
|
2534
|
3562 stru_721530.normal.z = stru_721530.prolly_normal_d + party_new_Z + 1;
|
2496
|
3563
|
|
3564 stru_721530.velocity.x = v2;
|
|
3565 stru_721530.velocity.y = v128;
|
|
3566 stru_721530.velocity.z = fall_speed;
|
|
3567
|
|
3568 stru_721530.uSectorID = 0;
|
|
3569 v36 = 0;
|
|
3570 if ( pParty->bTurnBasedModeOn == true && pTurnEngine->turn_stage == TE_MOVEMENT )
|
|
3571 v36 = 13312;
|
|
3572 if ( stru_721530._47050A(v36) )
|
|
3573 break;
|
|
3574 _46E889_collide_against_bmodels(1);
|
|
3575 //v37 = WorldPosToGridCellZ(pParty->vPosition.y);
|
|
3576 //v38 = WorldPosToGridCellX(pParty->vPosition.x);
|
|
3577 _46E26D_collide_against_sprites(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y));
|
|
3578 _46ED8A_collide_against_sprite_objects(4);
|
|
3579 for ( uint actor_id = 0; actor_id < (signed int)uNumActors; ++actor_id )
|
|
3580 Actor::_46DF1A_collide_against_actor(actor_id, 0);
|
|
3581 if ( stru_721530.field_7C >= stru_721530.field_6C )
|
|
3582 {
|
|
3583 _angle_x = stru_721530.normal2.x;
|
|
3584 _angle_y = stru_721530.normal2.y;
|
|
3585 v40 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
|
|
3586 }
|
|
3587 else
|
|
3588 {
|
|
3589 _angle_x = pX + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x);
|
|
3590 _angle_y = pY + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y);
|
|
3591 //pModel = (BSPModel *)fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
|
2534
|
3592 v40 = fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z) + party_new_Z;
|
2496
|
3593 }
|
|
3594 v122 = v40;
|
|
3595 ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0);
|
|
3596 v129 = ODM_GetFloorLevel(_angle_x, pY, v40, pParty->uPartyHeight, &is_on_water, &v97, 0);
|
|
3597 int v119 = ODM_GetFloorLevel(pX, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &v110, 0);
|
|
3598 bool v42_ = (BSPModel *)IsTerrainSlopeTooHigh(_angle_x, pY);
|
|
3599 v42 = IsTerrainSlopeTooHigh(pX, _angle_y);
|
|
3600 is_not_on_bmodel = false;
|
|
3601 //v118 = v42;
|
|
3602 if ( !v97 && !v110 && !bmodel_standing_on_pid )
|
|
3603 is_not_on_bmodel = true;
|
|
3604 v43 = 1;
|
|
3605 v44 = 1;
|
|
3606 if ( bUnderwater || !is_not_on_bmodel )
|
|
3607 {
|
|
3608 pX = _angle_x;
|
|
3609 if ( v43 )
|
|
3610 pY = _angle_y;
|
|
3611 }
|
|
3612 else
|
|
3613 {
|
2534
|
3614 if ( v42_ && v129 > party_new_Z )
|
2496
|
3615 v44 = 0;
|
2534
|
3616 if ( v42 && v119 > party_new_Z )
|
2496
|
3617 v43 = 0;
|
|
3618 if ( v44 )
|
|
3619 {
|
|
3620 pX = _angle_x;
|
|
3621 if ( v43 )
|
|
3622 pY = _angle_y;
|
|
3623 }
|
|
3624 else if ( v43 )
|
|
3625 pY = _angle_y;
|
|
3626 else
|
|
3627 {
|
|
3628 int new_ = ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0);
|
2534
|
3629 if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && new_ <= party_new_Z )
|
2496
|
3630 {
|
|
3631 v43 = 1;
|
|
3632 pX = _angle_x;
|
|
3633 if ( v43 )
|
|
3634 pY = _angle_y;
|
|
3635 }
|
|
3636 }
|
|
3637 }
|
|
3638 if ( stru_721530.field_7C >= stru_721530.field_6C )
|
|
3639 {
|
|
3640 if ( !is_not_on_bmodel )
|
|
3641 {
|
|
3642 pX = stru_721530.normal2.x;
|
|
3643 pY = stru_721530.normal2.y;
|
|
3644 }
|
2534
|
3645 party_new_Z = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
|
2496
|
3646 break;
|
|
3647 }
|
|
3648 stru_721530.field_70 += stru_721530.field_7C;
|
|
3649 pX = _angle_x;
|
|
3650 pY = _angle_y;
|
|
3651 v45 = stru_721530.uFaceID;
|
2534
|
3652 party_new_Z = v40;
|
2496
|
3653
|
|
3654 if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor)
|
|
3655 {
|
|
3656 if (pParty->Invisible())
|
|
3657 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
|
|
3658 viewparams->bRedrawGameUI = true;
|
|
3659 }
|
|
3660
|
|
3661 if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)
|
|
3662 {
|
|
3663 v129 = stru_5C6E00->Atan2(_angle_x - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x,
|
|
3664 _angle_y - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y);
|
|
3665 v2 = fixpoint_mul(stru_5C6E00->Cos(v129), integer_sqrt(v2 * v2 + v128 * v128));
|
|
3666 v122 = fixpoint_mul(stru_5C6E00->Sin(v129), integer_sqrt(v2 * v2 + v128 * v128));
|
|
3667 v128 = fixpoint_mul(stru_5C6E00->Sin(v129), integer_sqrt(v2 * v2 + v128 * v128));
|
|
3668 }
|
|
3669
|
|
3670 if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)
|
|
3671 {
|
|
3672 pParty->bFlying = false;
|
|
3673 pModel = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9];
|
|
3674 pODMFace = &pModel->pFaces[((signed int)stru_721530.uFaceID >> 3) & 0x3F];
|
|
3675 v48 = pODMFace->pBoundingBox.z2 - pODMFace->pBoundingBox.z1;
|
|
3676 v129 = v48 <= 32;
|
|
3677 v119 = pODMFace->pFacePlane.vNormal.z < 46378;
|
|
3678 if ( bUnderwater == 1 )
|
|
3679 v119 = 0;
|
|
3680 if ( pODMFace->uPolygonType == POLYGON_Floor )
|
|
3681 {
|
|
3682 if ( fall_speed < 0 )
|
|
3683 fall_speed = 0;
|
2534
|
3684 party_new_Z = pModel->pVertices.pVertices[pODMFace->pVertexIDs[0]].z + 1;
|
2496
|
3685 if ( v2 * v2 + v128 * v128 < 400 )
|
|
3686 {
|
|
3687 v2 = 0;
|
|
3688 *(float *)&v128 = 0.0;
|
|
3689 }
|
|
3690 if ( pParty->floor_face_pid != v45 && pODMFace->Pressure_Plate() )
|
|
3691 {
|
|
3692 pParty->floor_face_pid = v45;
|
|
3693 trigger_id = pODMFace->sCogTriggeredID;
|
|
3694 }
|
|
3695 }
|
|
3696 if ( !v129 && (pODMFace->uPolygonType != POLYGON_InBetweenFloorAndWall || v119) )// упёрся в столб
|
|
3697 {
|
|
3698 v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + fall_speed * pODMFace->pFacePlane.vNormal.z
|
|
3699 + v2 * pODMFace->pFacePlane.vNormal.x) >> 16;
|
|
3700 if ((stru_721530.speed >> 3) > v118 )
|
|
3701 v118 = stru_721530.speed >> 3;
|
|
3702 v2 += fixpoint_mul(v118, pODMFace->pFacePlane.vNormal.x);
|
|
3703 v128 += fixpoint_mul(v118, pODMFace->pFacePlane.vNormal.y);
|
|
3704 v54 = 0;
|
|
3705 if ( !v119 )
|
|
3706 v54 = fixpoint_mul(v118, pODMFace->pFacePlane.vNormal.z);
|
|
3707 pParty->uFallSpeed += v54;
|
|
3708 v55 = stru_721530.prolly_normal_d - ((signed int)(pODMFace->pFacePlane.dist + v122 * pODMFace->pFacePlane.vNormal.z
|
|
3709 + _angle_y * pODMFace->pFacePlane.vNormal.y + _angle_x * pODMFace->pFacePlane.vNormal.x) >> 16);
|
|
3710 if ( v55 > 0 )
|
|
3711 {
|
|
3712 pX = _angle_x + fixpoint_mul(pODMFace->pFacePlane.vNormal.x, v55);
|
|
3713 pY = _angle_y + fixpoint_mul(pODMFace->pFacePlane.vNormal.y, v55);
|
|
3714 if ( !v119 )
|
2534
|
3715 party_new_Z = v122 + fixpoint_mul(pODMFace->pFacePlane.vNormal.z, v55);
|
2496
|
3716 }
|
|
3717 if ( pParty->floor_face_pid != stru_721530.uFaceID && pODMFace->Pressure_Plate() )
|
|
3718 {
|
|
3719 pParty->floor_face_pid = stru_721530.uFaceID;
|
|
3720 trigger_id = pODMFace->sCogTriggeredID; //
|
|
3721 }
|
|
3722 }
|
|
3723 if ( pODMFace->uPolygonType == POLYGON_InBetweenFloorAndWall )
|
|
3724 {
|
|
3725 v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y
|
|
3726 + fall_speed * pODMFace->pFacePlane.vNormal.z + v2 * pODMFace->pFacePlane.vNormal.x) >> 16;
|
|
3727 if ((stru_721530.speed >> 3) > v118 )
|
|
3728 v118 = stru_721530.speed >> 3;
|
|
3729 v2 += fixpoint_mul(v118, pODMFace->pFacePlane.vNormal.x);
|
|
3730 v128 += fixpoint_mul(v118, pODMFace->pFacePlane.vNormal.y);
|
|
3731 fall_speed += fixpoint_mul(v118, pODMFace->pFacePlane.vNormal.z);
|
|
3732 if ( v2 * v2 + v128 * v128 >= 400 )
|
|
3733 {
|
|
3734 if ( pParty->floor_face_pid != stru_721530.uFaceID && pODMFace->Pressure_Plate() )
|
|
3735 {
|
|
3736 pParty->floor_face_pid = stru_721530.uFaceID;
|
|
3737 trigger_id = pODMFace->sCogTriggeredID; //
|
|
3738 }
|
|
3739 }
|
|
3740 else
|
|
3741 {
|
|
3742 v2 = 0;
|
|
3743 fall_speed = 0;
|
|
3744 *(float *)&v128 = 0.0;
|
|
3745 }
|
|
3746 }
|
|
3747 }
|
|
3748 v2 = fixpoint_mul(58500, v2);
|
|
3749 v128 = fixpoint_mul(58500, v128);
|
|
3750 v122 = fixpoint_mul(58500, v122);
|
|
3751 fall_speed = fixpoint_mul(58500, fall_speed);
|
|
3752 }
|
|
3753
|
|
3754 //Воспроизведение звуков ходьбы/бега------------------------
|
|
3755 uint pX_ = abs(pParty->vPosition.x - pX);
|
|
3756 uint pY_ = abs(pParty->vPosition.y - pY);
|
2534
|
3757 uint pZ_ = abs(pParty->vPosition.z - party_new_Z);
|
2496
|
3758 if ( bWalkSound && pParty->walk_sound_timer <= 0 )
|
|
3759 {
|
|
3760 pAudioPlayer->_4AA258(804);//stop sound
|
|
3761 if ( party_running_flag && (!hovering || not_high_fall) )
|
|
3762 {
|
|
3763 if ( integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) >= 16 )
|
|
3764 {
|
|
3765 if ( !is_not_on_bmodel && pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].Visible() )
|
2534
|
3766 pAudioPlayer->PlaySound(SOUND_RunWood, 804, 1, -1, 0, 0, 0, 0);//бег на 3D Modelи
|
2496
|
3767 else
|
|
3768 {
|
|
3769 v87 = pOutdoor->GetSoundIdByPosition(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y) - 1, 1);
|
|
3770 pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0);//бег по земле 56
|
|
3771 }
|
|
3772 pParty->walk_sound_timer = 96;//таймер для бега
|
|
3773 }
|
|
3774 }
|
|
3775 else if( party_walking_flag && (!hovering || not_high_fall) )
|
|
3776 {
|
|
3777 if ( integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) >= 8 )
|
|
3778 {
|
|
3779 if ( !is_not_on_bmodel && pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].Visible() )
|
2534
|
3780 pAudioPlayer->PlaySound(SOUND_WalkWood, 804, 1, -1, 0, 0, 0, 0);// хождение на 3D Modelи
|
2496
|
3781 else
|
|
3782 {
|
|
3783 v87 = pOutdoor->GetSoundIdByPosition(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y) - 1, 0);
|
|
3784 pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0);// хождение по земле
|
|
3785 }
|
|
3786 pParty->walk_sound_timer = 144;//таймер для ходьбы
|
|
3787 }
|
|
3788 }
|
|
3789 }
|
|
3790 if ( integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) < 8 )//отключить звук ходьбы при остановке
|
|
3791 pAudioPlayer->_4AA258(804);
|
|
3792 //------------------------------------------------------------------------
|
|
3793 if ( !hovering || !not_high_fall )// или не высокое падение
|
|
3794 pParty->uFlags &= ~PARTY_FLAGS_1_FALLING;
|
|
3795 else
|
|
3796 pParty->uFlags |= PARTY_FLAGS_1_FALLING;
|
|
3797 int pMap_X = WorldPosToGridCellX(pParty->vPosition.x);
|
|
3798 int pMap_Y = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
|
|
3799 unsigned int v114_a = WorldPosToGridCellX(pX);
|
|
3800 v66 = WorldPosToGridCellZ(pY) - 1;
|
|
3801 unsigned int v122_a = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(pMap_X, pMap_Y) / 2) & 1;
|
|
3802 v122 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v114_a, pMap_Y) / 2) & 1;
|
|
3803 v69 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(pMap_X, v66) / 2) & 1;
|
|
3804
|
|
3805 //-(обновление координат группы)---------------------------------------
|
|
3806 v68 = 0;
|
|
3807 if ( v114_a == pMap_X && v66 == pMap_Y && v122 && v69 )
|
|
3808 v68 = 1;
|
|
3809 if ( !is_not_on_bmodel ) // на bmodel,и
|
|
3810 v68 = 1;
|
|
3811 if ( v68 )
|
|
3812 {
|
|
3813 pParty->vPosition.x = pX;
|
|
3814 pParty->vPosition.y = pY;
|
2534
|
3815 pParty->vPosition.z = party_new_Z;
|
2496
|
3816 pParty->field_6F0 = v113;
|
|
3817 pParty->uFallSpeed = fall_speed;
|
2534
|
3818 if ( party_new_Z > 8160 ) //ограничение высоты
|
2496
|
3819 {
|
2534
|
3820 party_new_Z = 8160;
|
2496
|
3821 pParty->uFallStartY = 8160;
|
|
3822 pParty->vPosition.z = 8160;
|
|
3823 }
|
|
3824
|
|
3825 if ( !trigger_id //падение на землю
|
|
3826 || (EventProcessor(trigger_id, 0, 1),
|
|
3827 pParty->vPosition.x == pX)
|
|
3828 && pParty->vPosition.y == pY
|
2534
|
3829 && pParty->vPosition.z == party_new_Z )
|
2496
|
3830 {
|
|
3831 if ( pParty->vPosition.z < v111 )
|
|
3832 {
|
|
3833 pParty->uFallSpeed = 0;
|
|
3834 //v73 = v105;
|
|
3835 pParty->vPosition.z = on_ground;
|
2534
|
3836 if ( pParty->uFallStartY - party_new_Z > 512 && !bFeatherFall
|
|
3837 && party_new_Z <= on_ground && !bUnderwater )//Fall to the ground(падение на землю с высоты)
|
2496
|
3838 {
|
|
3839 if ( pParty->uFlags & PARTY_FLAGS_1_LANDING )
|
|
3840 pParty->uFlags &= ~PARTY_FLAGS_1_LANDING;
|
|
3841 else
|
|
3842 {
|
|
3843 for ( uint i = 1; i <= 4; ++i )
|
|
3844 {
|
2534
|
3845 pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - party_new_Z) * (unsigned __int64)(signed __int64)((double)pPlayers[i]->GetMaxHealth() * 0.1)) / 256,
|
2496
|
3846 DMGT_PHISYCAL);
|
|
3847 v110 = 20 - pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualEndurance());
|
|
3848 pPlayers[i]->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
|
|
3849 }
|
|
3850 //v73 = pParty->vPosition.z;
|
|
3851 }
|
|
3852 }
|
2534
|
3853 pParty->uFallStartY = party_new_Z;
|
2496
|
3854 }
|
|
3855 if ( v102 && pParty->vPosition.z < ceiling_height )
|
|
3856 {
|
|
3857 if ( (signed int)(pParty->uPartyHeight + pParty->vPosition.z) >= ceiling_height )
|
|
3858 {
|
|
3859 pParty->vPosition.z = ceiling_height - pParty->uPartyHeight - 1;
|
|
3860 pParty->field_6F0 = ceiling_height - pParty->uPartyHeight - 1;
|
|
3861 }
|
|
3862 }
|
|
3863 pParty->uFlags &= ~0x204;
|
|
3864 }
|
|
3865 return;
|
|
3866 }
|
|
3867 //-----------------------------------------------------------------
|
|
3868 //v76 = pParty->bFlying;
|
|
3869 if ( pParty->bFlying || !not_high_fall || bWaterWalk || !v122_a )// полёт или высокое падение или хождение по воде или
|
|
3870 v77 = 1;
|
|
3871 else
|
|
3872 v77 = v122 != 0;
|
|
3873 bool party_drowning_flag = false;
|
|
3874 if ( !pParty->bFlying && not_high_fall && !bWaterWalk ) //не полёт и не высокое падение и не хождение по воде
|
|
3875 {
|
|
3876 if ( v122_a )
|
|
3877 v78 = v69 != 0;
|
|
3878 else
|
|
3879 {
|
|
3880 party_drowning_flag = true;//утопление
|
|
3881 v78 = true;
|
|
3882 }
|
|
3883 }
|
|
3884 else
|
|
3885 v78 = true;
|
|
3886
|
|
3887 if ( v77 )
|
|
3888 pParty->vPosition.x = pX;
|
|
3889 if ( v78 )
|
|
3890 pParty->vPosition.y = pY;
|
|
3891
|
|
3892 if ( v78 || v77)
|
|
3893 {
|
|
3894 if ( bWaterWalk )
|
|
3895 {
|
|
3896 pParty->uFlags &= ~PARTY_FLAGS_1_STANDING_ON_WATER;
|
|
3897 //v79 = 20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 6180178;
|
|
3898 //*(short *)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 119] |= 1u;
|
|
3899 v79 = (int)&stru_5E4C90_MapPersistVars._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 119];
|
|
3900 *(short *)v79 |= 1;
|
|
3901 if ( !v122 || !v69 )
|
|
3902 {
|
|
3903 if ( !pParty->bFlying )
|
|
3904 {
|
|
3905 v80 = *(short *)v79;
|
|
3906 pParty->uFlags |= PARTY_FLAGS_1_STANDING_ON_WATER;
|
|
3907 *(short *)v79 = v80 & 0xFFFE;
|
|
3908 }
|
|
3909 }
|
|
3910 }
|
|
3911 }
|
|
3912 else if ( bWalkSound && pParty->walk_sound_timer <= 0 )
|
|
3913 {
|
|
3914 pAudioPlayer->_4AA258(804);
|
|
3915 pParty->walk_sound_timer = 64;
|
|
3916 }
|
|
3917
|
|
3918 //v81 = pZ;
|
|
3919 //v82 = pZ;
|
2534
|
3920 pParty->vPosition.z = party_new_Z;
|
|
3921 if ( party_new_Z > 8160 )//опять ограничение высоты
|
2496
|
3922 {
|
|
3923 //v82 = 8160;
|
|
3924 pParty->uFallStartY = 8160;
|
|
3925 pParty->vPosition.z = 8160;
|
|
3926 }
|
|
3927 LOWORD(pParty->uFlags) &= 0xFDFBu;
|
|
3928 pParty->uFallSpeed = fall_speed;
|
|
3929 pParty->field_6F0 = v113;
|
|
3930 if ( party_drowning_flag )//группа тонет
|
|
3931 {
|
|
3932 pTerrainHeight = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.y, &v110, 1);
|
|
3933 if ( pParty->vPosition.z <= pTerrainHeight + 1 )//положение группы всегда +1
|
|
3934 pParty->uFlags |= PARTY_FLAGS_1_WATER_DAMAGE;
|
|
3935 }
|
|
3936
|
|
3937 if ( !trigger_id//падение на воду
|
|
3938 || (EventProcessor(trigger_id, 0, 1),
|
|
3939 pParty->vPosition.x == pX)
|
|
3940 && pParty->vPosition.y == pY
|
2534
|
3941 && pParty->vPosition.z == party_new_Z )
|
2496
|
3942 {
|
|
3943 if ( pParty->vPosition.z < v111 )
|
|
3944 {
|
|
3945 //v82 = on_ground;
|
|
3946 pParty->uFallSpeed = 0;
|
|
3947 pParty->vPosition.z = on_ground;
|
2534
|
3948 if ( pParty->uFallStartY - party_new_Z > 512
|
|
3949 && !bFeatherFall && party_new_Z <= on_ground && !bUnderwater )//Fall to the water(падение на воду с высоты)
|
2496
|
3950 {
|
|
3951 if ( pParty->uFlags & PARTY_FLAGS_1_LANDING )
|
|
3952 pParty->uFlags &= ~PARTY_FLAGS_1_LANDING;
|
|
3953 else
|
|
3954 {
|
|
3955 for ( uint i = 1; i <= 4; ++i )
|
|
3956 {
|
|
3957 v110 = pPlayers[i]->GetMaxHealth();
|
2534
|
3958 pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - party_new_Z) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
|
2496
|
3959 DMGT_PHISYCAL);
|
|
3960 v110 = 20 - pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualEndurance());
|
|
3961 pPlayers[i]->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
|
|
3962 }
|
|
3963 //v82 = pParty->vPosition.z;
|
|
3964 }
|
|
3965 }
|
2534
|
3966 pParty->uFallStartY = party_new_Z;
|
2496
|
3967 }
|
|
3968 if ( v102 && pParty->vPosition.z < ceiling_height && (signed int)(pParty->uPartyHeight + pParty->vPosition.z) >= ceiling_height )
|
|
3969 {
|
|
3970 pParty->vPosition.z = pParty->vPosition.z + pParty->uPartyHeight - ceiling_height + 1;
|
|
3971 pParty->field_6F0 = pParty->vPosition.z + pParty->uPartyHeight - ceiling_height + 1;
|
|
3972 }
|
|
3973 }
|
|
3974 }
|
|
3975
|
|
3976 //----- (0046D8E3) --------------------------------------------------------
|
|
3977 int GetCeilingHeight(int Party_X, signed int Party_Y, int Party_ZHeight, int pFaceID)
|
|
3978 {
|
|
3979 signed int v13; // eax@25
|
|
3980 int v14; // edx@27
|
|
3981 int v16; // ST18_4@29
|
|
3982 signed int v17; // edx@29
|
|
3983 signed __int64 v18; // qtt@29
|
|
3984 int v19; // eax@35
|
|
3985 signed int v20; // ecx@37
|
|
3986 signed int v22; // ebx@42
|
|
3987 // int v24; // edx@44
|
|
3988 // int v25; // eax@44
|
|
3989 int v27; // [sp+10h] [bp-34h]@21
|
|
3990 bool v34; // [sp+30h] [bp-14h]@21
|
|
3991 bool v35; // [sp+34h] [bp-10h]@23
|
|
3992 signed int v37; // [sp+38h] [bp-Ch]@21
|
|
3993 signed int v38; // [sp+38h] [bp-Ch]@42
|
|
3994 signed int v39; // [sp+3Ch] [bp-8h]@1
|
|
3995
|
|
3996 dword_720ED0[0] = -1;
|
|
3997 dword_720E80[0] = -1;
|
|
3998 v39 = 1;
|
|
3999 ceiling_height_level[0] = 10000;//нет потолка
|
|
4000 for ( uint i = 0; i < (signed int)pOutdoor->uNumBModels; ++i )
|
|
4001 {
|
|
4002 if ( Party_X <= pOutdoor->pBModels[i].sMaxX && Party_X >= pOutdoor->pBModels[i].sMinX
|
|
4003 && Party_Y <= pOutdoor->pBModels[i].sMaxY && Party_Y >= pOutdoor->pBModels[i].sMinY )
|
|
4004 {
|
|
4005 for ( uint j = 0; j < pOutdoor->pBModels[i].uNumFaces; ++j )
|
|
4006 {
|
|
4007 if ( (pOutdoor->pBModels[i].pFaces[j].uPolygonType == POLYGON_Ceiling
|
|
4008 || pOutdoor->pBModels[i].pFaces[j].uPolygonType == POLYGON_InBetweenCeilingAndWall)
|
|
4009 && !pOutdoor->pBModels[i].pFaces[j].Ethereal()
|
|
4010 && Party_X <= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.x2 && Party_X >= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.x1
|
|
4011 && Party_Y <= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.y2 && Party_Y >= pOutdoor->pBModels[i].pFaces[j].pBoundingBox.y1 )
|
|
4012 {
|
|
4013 for ( uint v = 0; v < pOutdoor->pBModels[i].pFaces[j].uNumVertices; v++ )
|
|
4014 {
|
|
4015 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);
|
|
4016 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);
|
|
4017 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);
|
|
4018 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);
|
|
4019 }
|
|
4020 v27 = 2 * pOutdoor->pBModels[i].pFaces[j].uNumVertices;
|
|
4021 word_720DB0_xs[2 * pOutdoor->pBModels[i].pFaces[j].uNumVertices] = word_720DB0_xs[0];
|
|
4022 word_720CE0_ys[2 * pOutdoor->pBModels[i].pFaces[j].uNumVertices] = word_720CE0_ys[0];
|
|
4023 v34 = word_720CE0_ys[0] >= Party_Y;
|
|
4024 v37 = 0;
|
|
4025 for ( uint v = 0; v < v27; ++v )
|
|
4026 {
|
|
4027 if ( v37 >= 2 )
|
|
4028 break;
|
|
4029 v35 = word_720CE0_ys[v + 1] >= Party_Y;
|
|
4030 if ( v34 != v35 )
|
|
4031 {
|
|
4032 v13 = word_720DB0_xs[v + 1] >= Party_X ? 0 : 2;
|
|
4033 v14 = v13 | (word_720DB0_xs[v] < Party_X);
|
|
4034 if ( v14 != 3 )
|
|
4035 {
|
|
4036 if ( !v14 || ( v16 = word_720CE0_ys[v + 1] - word_720CE0_ys[v],
|
|
4037 v17 = Party_Y - word_720CE0_ys[v],
|
|
4038 LODWORD(v18) = v17 << 16,
|
|
4039 HIDWORD(v18) = v17 >> 16,
|
|
4040 (signed int)(((unsigned __int64)(((signed int)word_720DB0_xs[v + 1]
|
|
4041 - (signed int)word_720DB0_xs[v]) * v18 / v16) >> 16) + word_720DB0_xs[v]) >= Party_X) )
|
|
4042 ++v37;
|
|
4043 }
|
|
4044 }
|
|
4045 v34 = v35;
|
|
4046 }
|
|
4047 if ( v37 == 1 )
|
|
4048 {
|
|
4049 if ( v39 >= 20 )
|
|
4050 break;
|
|
4051 if ( pOutdoor->pBModels[i].pFaces[j].uPolygonType == POLYGON_Ceiling )
|
|
4052 v19 = pOutdoor->pBModels[i].pVertices.pVertices[pOutdoor->pBModels[i].pFaces[j].pVertexIDs[0]].z;
|
|
4053 else
|
|
4054 v19 = fixpoint_mul(pOutdoor->pBModels[i].pFaces[j].zCalc1, Party_X) + fixpoint_mul(pOutdoor->pBModels[i].pFaces[j].zCalc2, Party_Y)
|
|
4055 + HIWORD(pOutdoor->pBModels[i].pFaces[j].zCalc3);
|
|
4056 v20 = v39++;
|
|
4057 ceiling_height_level[v20] = v19;
|
|
4058 dword_720ED0[v20] = i;
|
|
4059 dword_720E80[v20] = j;
|
|
4060 }
|
|
4061 }
|
|
4062 }
|
|
4063 }
|
|
4064 }
|
|
4065 if ( !v39 )
|
|
4066 {
|
|
4067 pFaceID = 0;
|
|
4068 return ceiling_height_level[0];
|
|
4069 }
|
|
4070 v22 = 0;
|
|
4071 for ( v38 = 0; v38 < v39; ++v38 )
|
|
4072 {
|
|
4073 if ( ceiling_height_level[v38] == ceiling_height_level[0] )
|
|
4074 v22 = v38;
|
|
4075 else if ( ceiling_height_level[v38] < ceiling_height_level[0] && ceiling_height_level[0] > Party_ZHeight + 15 )
|
|
4076 v22 = v38;
|
|
4077 else if ( ceiling_height_level[v38] > ceiling_height_level[0] && ceiling_height_level[v38] <= Party_ZHeight + 15 )
|
|
4078 v22 = v38;
|
|
4079 }
|
|
4080 if ( v22 )
|
|
4081 {
|
|
4082 *(int *)pFaceID = dword_720E80[v22] | (dword_720ED0[v22] << 6);
|
|
4083 return ceiling_height_level[v22];//если есть преграда
|
|
4084 }
|
|
4085 pFaceID = 0;
|
|
4086 return ceiling_height_level[v22];// нет никакой преграды
|
|
4087 }
|
|
4088
|
|
4089
|
|
4090 //----- (00464839) --------------------------------------------------------
|
|
4091 char Is_out15odm_underwater()
|
|
4092 {
|
|
4093 return _stricmp(pCurrentMapName, "out15.odm") == 0;
|
|
4094 }
|
|
4095
|
|
4096 //----- (00464851) --------------------------------------------------------
|
|
4097 void SetUnderwaterFog()
|
|
4098 {
|
|
4099 day_fogrange_1 = 50;
|
|
4100 day_fogrange_2 = 5000;
|
|
4101 }
|
|
4102
|
|
4103 //----- (00487DA9) --------------------------------------------------------
|
|
4104 void sub_487DA9()
|
|
4105 {
|
|
4106 for (int i = 0; i < 20000; ++i)
|
|
4107 array_77EC08[i].field_108 = 0;
|
|
4108 }
|
|
4109
|
|
4110 //----- (004706C6) --------------------------------------------------------
|
|
4111 void UpdateActors_ODM()
|
|
4112 {
|
|
4113 int v3; // ebx@6
|
|
4114 int v5; // eax@10
|
|
4115 //int v6; // ecx@10
|
|
4116 signed int v8; // ebx@17
|
|
4117 // unsigned __int8 v10; // sf@17
|
|
4118 // unsigned __int16 v11; // ax@21
|
|
4119 __int16 v20; // ax@42
|
|
4120 int v25; // eax@45
|
|
4121 signed int v26; // ecx@50
|
|
4122 int v28; // eax@54
|
|
4123 signed int v29; // ebx@57
|
|
4124 signed int v30; // eax@57
|
|
4125 int v31; // edi@57
|
|
4126 signed int i; // ebx@57
|
|
4127 unsigned int v33; // ecx@58
|
|
4128 int v35; // edi@64
|
|
4129 int v36; // eax@64
|
|
4130 unsigned int v39; // edi@71
|
|
4131 ODMFace *face; // edi@75
|
|
4132 int v46; // ecx@82
|
|
4133 signed int v47; // ebx@85
|
|
4134 int v48; // edi@85
|
|
4135 // int v55; // eax@107
|
|
4136 // unsigned int v56; // edi@107
|
|
4137 // int v57; // ST10_4@107
|
|
4138 unsigned int v58; // edi@107
|
|
4139 unsigned int v59; // ebx@107
|
|
4140 // signed int v60; // eax@107
|
|
4141 int v61; // eax@124
|
|
4142 Vec3_int_ v62; // [sp+Ch] [bp-44h]@42
|
|
4143 int v63; // [sp+18h] [bp-38h]@64
|
|
4144 int v64; // [sp+1Ch] [bp-34h]@64
|
|
4145 bool v67; // [sp+28h] [bp-28h]@10
|
|
4146 unsigned int v69; // [sp+30h] [bp-20h]@6
|
|
4147 unsigned int v70; // [sp+34h] [bp-1Ch]@10
|
|
4148 int v71; // [sp+38h] [bp-18h]@62
|
|
4149 int uIsAboveFloor; // [sp+3Ch] [bp-14h]@10
|
|
4150 int v72b;
|
|
4151 int uIsFlying; // [sp+44h] [bp-Ch]@8
|
|
4152 unsigned int v75; // [sp+48h] [bp-8h]@1
|
|
4153 int uIsOnWater; // [sp+4Ch] [bp-4h]@10
|
|
4154
|
|
4155 for (v75 = 0; v75 < uNumActors; ++v75)
|
|
4156 {
|
|
4157 if (pActors[v75].uAIState == Removed
|
|
4158 || pActors[v75].uAIState == Disabled
|
|
4159 || pActors[v75].uAIState == Summoned
|
|
4160 || !pActors[v75].uMovementSpeed)
|
|
4161 continue;
|
|
4162 v3 = 0;
|
|
4163 v69 = 0;
|
|
4164 if (MonsterStats::BelongsToSupertype(pActors[v75].pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL))
|
|
4165 v3 = 1;
|
|
4166 pActors[v75].uSectorID = 0;
|
|
4167 uIsFlying = pActors[v75].pMonsterInfo.uFlying;
|
|
4168 if (!pActors[v75].CanAct())
|
|
4169 uIsFlying = 0;
|
|
4170 v70 = IsTerrainSlopeTooHigh(pActors[v75].vPosition.x, pActors[v75].vPosition.y);
|
|
4171 v5 = ODM_GetFloorLevel(pActors[v75].vPosition.x, pActors[v75].vPosition.y, pActors[v75].vPosition.z,
|
|
4172 pActors[v75].uActorHeight, &uIsOnWater, (int *)&v69, v3);
|
|
4173 //v6 = pActors[v75].vPosition.z;
|
|
4174 uIsAboveFloor = 0;
|
|
4175 v67 = v69 == 0;
|
|
4176 if (pActors[v75].vPosition.z > v5 + 1)
|
|
4177 uIsAboveFloor = 1;
|
|
4178 if (pActors[v75].uAIState == Dead && uIsOnWater && !uIsAboveFloor)
|
|
4179 {
|
|
4180 pActors[v75].uAIState = Removed;
|
|
4181 continue;
|
|
4182 }
|
|
4183 if (pActors[v75].uCurrentActionAnimation == ANIM_Walking)
|
|
4184 {
|
|
4185 v8 = pActors[v75].uMovementSpeed;
|
|
4186 if ((signed __int64)pActors[v75].pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0)
|
|
4187 v8 = (signed __int64)((double)v8 * 0.5);
|
|
4188 if (pActors[v75].uAIState == Fleeing || pActors[v75].uAIState == Pursuing)
|
|
4189 v8 *= 2;
|
|
4190 if (pParty->bTurnBasedModeOn == true && pTurnEngine->turn_stage == TE_WAIT)
|
|
4191 v8 *= flt_6BE3AC_debug_recmod1_x_1_6;
|
|
4192 if (v8 > 1000)
|
|
4193 v8 = 1000;
|
|
4194
|
|
4195 pActors[v75].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(pActors[v75].uYawAngle), v8);
|
|
4196 pActors[v75].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(pActors[v75].uYawAngle), v8);
|
|
4197 if (uIsFlying)
|
|
4198 {
|
|
4199 pActors[v75].vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pActors[v75].uPitchAngle), v8);
|
|
4200 }
|
|
4201 //v7 = v68;
|
|
4202 }
|
|
4203 else
|
|
4204 {
|
|
4205 pActors[v75].vVelocity.x = fixpoint_mul(55000, pActors[v75].vVelocity.x);
|
|
4206 pActors[v75].vVelocity.y = fixpoint_mul(55000, pActors[v75].vVelocity.y);
|
|
4207 if (uIsFlying)
|
|
4208 pActors[v75].vVelocity.z = fixpoint_mul(55000, pActors[v75].vVelocity.z);
|
|
4209 }
|
|
4210 if (pActors[v75].vPosition.z < v5)
|
|
4211 {
|
|
4212 pActors[v75].vPosition.z = v5;
|
|
4213 pActors[v75].vVelocity.z = uIsFlying != 0 ? 0x14 : 0;
|
|
4214 }
|
|
4215 //v17 = 0;
|
|
4216 if (!uIsAboveFloor || uIsFlying)
|
|
4217 {
|
|
4218 if (v70 && !uIsAboveFloor && v67)
|
|
4219 {
|
|
4220 pActors[v75].vPosition.z = v5;
|
|
4221 ODM_GetTerrainNormalAt(pActors[v75].vPosition.x, pActors[v75].vPosition.y, &v62);
|
|
4222 v20 = GetGravityStrength();
|
|
4223 //v21 = v62.y;
|
|
4224 //v22 = v62.z;
|
|
4225 //v23 = v62.y * v0->vVelocity.y;
|
|
4226 pActors[v75].vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20;
|
|
4227 int v73 = abs(v62.x * pActors[v75].vVelocity.x + v62.z * pActors[v75].vVelocity.z + v62.y * pActors[v75].vVelocity.y) >> 16;
|
|
4228 //v72b = v21;
|
|
4229 pActors[v75].vVelocity.x += fixpoint_mul(v73, v62.x);
|
|
4230 pActors[v75].vVelocity.y += fixpoint_mul(v73, v62.y);
|
|
4231 pActors[v75].vVelocity.z += fixpoint_mul(v73, v62.z);
|
|
4232 //v17 = 0;
|
|
4233 }
|
|
4234 }
|
|
4235 else
|
|
4236 {
|
|
4237 pActors[v75].vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength();
|
|
4238 }
|
|
4239 if (pParty->armageddon_timer != 0 && pActors[v75].CanAct())
|
|
4240 {
|
|
4241 pActors[v75].vVelocity.x += rand() % 100 - 50;
|
|
4242 pActors[v75].vVelocity.y += rand() % 100 - 50;
|
|
4243 pActors[v75].vVelocity.z += rand() % 100 - 20;
|
|
4244 v25 = rand();
|
|
4245 pActors[v75].uAIState = Stunned;
|
|
4246 pActors[v75].uYawAngle += v25 % 32 - 16;
|
|
4247 pActors[v75].UpdateAnimation();
|
|
4248 }
|
|
4249 if (pActors[v75].vVelocity.x * pActors[v75].vVelocity.x + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y < 400 && v70 == 0)
|
|
4250 {
|
|
4251 pActors[v75].vVelocity.y = 0;
|
|
4252 pActors[v75].vVelocity.x = 0;
|
|
4253 }
|
|
4254 stru_721530.field_0 = 1;
|
|
4255 if (!uIsFlying)
|
|
4256 v26 = 40;
|
|
4257 else
|
|
4258 v26 = pActors[v75].uActorRadius;
|
|
4259
|
|
4260 stru_721530.field_84 = -1;
|
|
4261 stru_721530.field_8_radius = v26;
|
|
4262 stru_721530.prolly_normal_d = v26;
|
|
4263 stru_721530.height = pActors[v75].uActorHeight;
|
|
4264 stru_721530.field_70 = 0;
|
|
4265
|
|
4266 for (v69 = 0; v69 < 100; ++v69)
|
|
4267 {
|
|
4268 stru_721530.position.x = pActors[v75].vPosition.x;
|
|
4269 stru_721530.normal.x = stru_721530.position.x;
|
|
4270 stru_721530.position.y = pActors[v75].vPosition.y;
|
|
4271 stru_721530.normal.y = stru_721530.position.y;
|
|
4272 v28 = pActors[v75].vPosition.z;
|
|
4273 stru_721530.normal.z = v28 + v26 + 1;
|
|
4274 stru_721530.position.z = v28 - v26 + stru_721530.height - 1;
|
|
4275 if (stru_721530.position.z < stru_721530.normal.z)
|
|
4276 stru_721530.position.z = v28 + v26 + 1;
|
|
4277 stru_721530.velocity.x = pActors[v75].vVelocity.x;
|
|
4278 stru_721530.uSectorID = 0;
|
|
4279 stru_721530.velocity.y = pActors[v75].vVelocity.y;
|
|
4280 stru_721530.velocity.z = pActors[v75].vVelocity.z;
|
|
4281 if (stru_721530._47050A(0))
|
|
4282 break;
|
|
4283 _46E889_collide_against_bmodels(1);
|
|
4284 v29 = WorldPosToGridCellZ(pActors[v75].vPosition.y);
|
|
4285 v30 = WorldPosToGridCellX(pActors[v75].vPosition.x);
|
|
4286 _46E26D_collide_against_sprites(v30, v29);
|
|
4287 _46EF01_collision_chech_player(0);
|
|
4288 _46ED8A_collide_against_sprite_objects(PID(OBJECT_Actor, v75));
|
|
4289 v31 = 0;
|
|
4290 for (i = 0; v31 < ai_arrays_size; ++v31)
|
|
4291 {
|
|
4292 v33 = ai_near_actors_ids[v31];
|
|
4293 if (v33 != v75 && Actor::_46DF1A_collide_against_actor(v33, 40))
|
|
4294 ++i;
|
|
4295 }
|
|
4296 v71 = i > 1;
|
|
4297 if (stru_721530.field_7C < stru_721530.field_6C)
|
|
4298 v70 = fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
|
|
4299 //v34 = 0;
|
|
4300 v35 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1;
|
|
4301 v36 = ODM_GetFloorLevel(stru_721530.normal2.x, stru_721530.normal2.y,
|
|
4302 stru_721530.normal2.z - stru_721530.prolly_normal_d - 1,
|
|
4303 pActors[v75].uActorHeight, (int *)&v63, &v64, 0);
|
|
4304 if (uIsOnWater)
|
|
4305 {
|
|
4306 if (v35 < v36 + 60)
|
|
4307 {
|
|
4308 if (pActors[v75].uAIState == Dead || pActors[v75].uAIState == Dying || pActors[v75].uAIState == Removed
|
|
4309 || pActors[v75].uAIState == Disabled)
|
|
4310 {
|
|
4311 if (v64)
|
|
4312 v61 = v36 + 30;
|
|
4313 else
|
|
4314 v61 = v5 + 60;
|
|
4315 SpriteObject::sub_42F960_create_object(pActors[v75].vPosition.x, pActors[v75].vPosition.y, v61);
|
|
4316 pActors[v75].uAIState = Removed;
|
|
4317 return;
|
|
4318 }
|
|
4319 }
|
|
4320 }
|
|
4321 if (stru_721530.field_7C >= stru_721530.field_6C)
|
|
4322 {
|
|
4323 pActors[v75].vPosition.x = LOWORD(stru_721530.normal2.x);
|
|
4324 pActors[v75].vPosition.y = LOWORD(stru_721530.normal2.y);
|
|
4325 pActors[v75].vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1;
|
|
4326 break;
|
|
4327 }
|
|
4328 //v72b = fixpoint_mul(stru_721530.field_7C, stru_721530.field_58.x);
|
|
4329 pActors[v75].vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x);
|
|
4330 //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16;
|
|
4331 pActors[v75].vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y);
|
|
4332 //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16;
|
|
4333 pActors[v75].vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z);
|
|
4334 stru_721530.field_70 += stru_721530.field_7C;
|
|
4335 v39 = PID_ID(stru_721530.uFaceID);
|
|
4336 switch (PID_TYPE(stru_721530.uFaceID))
|
|
4337 {
|
|
4338 case OBJECT_Actor:
|
|
4339 if (pTurnEngine->turn_stage != TE_ATTACK && pTurnEngine->turn_stage != TE_MOVEMENT || pParty->bTurnBasedModeOn != TE_WAIT)
|
|
4340 {
|
|
4341 //if(pParty->bTurnBasedModeOn == 1)
|
|
4342 //v34 = 0;
|
|
4343 if (pActors[v75].pMonsterInfo.uHostilityType)
|
|
4344 {
|
|
4345 if (v71 == 0)
|
|
4346 Actor::AI_Flee(v75, stru_721530.uFaceID, 0, (AIDirection *)0);
|
|
4347 else
|
|
4348 Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0);
|
|
4349 }
|
|
4350 else if (v71)
|
|
4351 Actor::AI_StandOrBored(v75, 4, 0, (AIDirection *)0);
|
|
4352 else if (pActors[v39].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly)
|
|
4353 Actor::AI_Flee(v75, stru_721530.uFaceID, 0, (AIDirection *)0);
|
|
4354 else
|
|
4355 Actor::AI_FaceObject(v75, stru_721530.uFaceID, 0, (AIDirection *)0);
|
|
4356 }
|
|
4357 break;
|
|
4358 case OBJECT_Player:
|
|
4359 if (!pActors[v75].GetActorsRelation(0))
|
|
4360 {
|
|
4361 Actor::AI_FaceObject(v75, stru_721530.uFaceID, 0, (AIDirection *)0);
|
|
4362 break;
|
|
4363 }
|
|
4364 //v52 = HIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) == 0;
|
|
4365 //v53 = SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) < 0;
|
|
4366 pActors[v75].vVelocity.y = 0;
|
|
4367 pActors[v75].vVelocity.x = 0;
|
|
4368 //if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0) )
|
|
4369 if ((signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime < 0)
|
|
4370 pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset();
|
|
4371 viewparams->bRedrawGameUI = 1;
|
|
4372 break;
|
|
4373 case OBJECT_Decoration:
|
|
4374 v47 = integer_sqrt(pActors[v75].vVelocity.x * pActors[v75].vVelocity.x + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y);
|
|
4375 v48 = stru_5C6E00->Atan2(pActors[v75].vPosition.x - pLevelDecorations[v39].vPosition.x,
|
|
4376 pActors[v75].vPosition.y - pLevelDecorations[v39].vPosition.y);
|
|
4377 //v49 = v48;
|
|
4378 pActors[v75].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v48), v47);
|
|
4379 pActors[v75].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v48), v47);
|
|
4380 break;
|
|
4381 case OBJECT_BModel:
|
|
4382 face = &pOutdoor->pBModels[stru_721530.uFaceID >> 9].pFaces[v39 & 0x3F];
|
|
4383 if (!face->Ethereal())
|
|
4384 {
|
|
4385 if (face->uPolygonType == 3)
|
|
4386 {
|
|
4387 pActors[v75].vVelocity.z = 0;
|
|
4388 pActors[v75].vPosition.z = LOWORD(pOutdoor->pBModels[stru_721530.uFaceID >> 9].pVertices.pVertices[face->pVertexIDs[0]].z) + 1;
|
|
4389 if (pActors[v75].vVelocity.x * pActors[v75].vVelocity.x
|
|
4390 + pActors[v75].vVelocity.y * pActors[v75].vVelocity.y < 400)
|
|
4391 {
|
|
4392 pActors[v75].vVelocity.y = 0;
|
|
4393 pActors[v75].vVelocity.x = 0;
|
|
4394 }
|
|
4395 }
|
|
4396 else
|
|
4397 {
|
|
4398 v72b = abs(face->pFacePlane.vNormal.y * pActors[v75].vVelocity.y + face->pFacePlane.vNormal.z * pActors[v75].vVelocity.z
|
|
4399 + face->pFacePlane.vNormal.x * pActors[v75].vVelocity.x) >> 16;
|
|
4400 if ((stru_721530.speed >> 3) > v72b)
|
|
4401 v72b = stru_721530.speed >> 3;
|
|
4402
|
|
4403 pActors[v75].vVelocity.x += fixpoint_mul(v72b, face->pFacePlane.vNormal.x);
|
|
4404 pActors[v75].vVelocity.y += fixpoint_mul(v72b, face->pFacePlane.vNormal.y);
|
|
4405 pActors[v75].vVelocity.z += fixpoint_mul(v72b, face->pFacePlane.vNormal.z);
|
|
4406 if (face->uPolygonType != 4)
|
|
4407 {
|
|
4408 v46 = stru_721530.prolly_normal_d
|
|
4409 - ((face->pFacePlane.dist
|
|
4410 + face->pFacePlane.vNormal.x * pActors[v75].vPosition.x
|
|
4411 + face->pFacePlane.vNormal.y * pActors[v75].vPosition.y
|
|
4412 + face->pFacePlane.vNormal.z * pActors[v75].vPosition.z) >> 16);
|
|
4413 if (v46 > 0)
|
|
4414 {
|
|
4415 pActors[v75].vPosition.x += fixpoint_mul(v46, face->pFacePlane.vNormal.x);
|
|
4416 pActors[v75].vPosition.y += fixpoint_mul(v46, face->pFacePlane.vNormal.y);
|
|
4417 pActors[v75].vPosition.z += fixpoint_mul(v46, face->pFacePlane.vNormal.z);
|
|
4418 }
|
|
4419 pActors[v75].uYawAngle = stru_5C6E00->Atan2(pActors[v75].vVelocity.x, pActors[v75].vVelocity.y);
|
|
4420 }
|
|
4421 }
|
|
4422 }
|
|
4423 break;
|
|
4424 }
|
|
4425
|
|
4426 pActors[v75].vVelocity.x = fixpoint_mul(58500, pActors[v75].vVelocity.x);
|
|
4427 pActors[v75].vVelocity.y = fixpoint_mul(58500, pActors[v75].vVelocity.y);
|
|
4428 pActors[v75].vVelocity.z = fixpoint_mul(58500, pActors[v75].vVelocity.z);
|
|
4429
|
|
4430 v26 = stru_721530.prolly_normal_d;
|
|
4431 }
|
|
4432
|
|
4433 v58 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(pActors[v75].vPosition.x), WorldPosToGridCellZ(pActors[v75].vPosition.y) - 1) >> 1) & 1;
|
|
4434 v59 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(WorldPosToGridCellX(pActors[v75].vPosition.x), WorldPosToGridCellZ(pActors[v75].vPosition.y) - 1) >> 1) & 1;
|
|
4435 if (WorldPosToGridCellX(pActors[v75].vPosition.x) == WorldPosToGridCellX(pActors[v75].vPosition.x)
|
|
4436 && WorldPosToGridCellZ(pActors[v75].vPosition.y) == WorldPosToGridCellZ(pActors[v75].vPosition.y)
|
|
4437 && v58 || v67 != 0)
|
|
4438 {
|
|
4439 if (MonsterStats::BelongsToSupertype(pActors[v75].pMonsterInfo.uID, MONSTER_SUPERTYPE_WATER_ELEMENTAL))
|
|
4440 {
|
|
4441 v58 = v58 == 0;
|
|
4442 v59 = v59 == 0;
|
|
4443 }
|
|
4444 if (!uIsFlying && v58 && !v59)
|
|
4445 {
|
|
4446 pActors[v75].vPosition.x = pActors[v75].vPosition.x;
|
|
4447 pActors[v75].vPosition.y = pActors[v75].vPosition.y;
|
|
4448 if (pActors[v75].CanAct())
|
|
4449 {
|
|
4450 pActors[v75].uYawAngle -= 32;
|
|
4451 pActors[v75].uCurrentActionTime = 0;
|
|
4452 pActors[v75].uCurrentActionLength = 128;
|
|
4453 pActors[v75].uAIState = Fleeing;
|
|
4454 }
|
|
4455 }
|
|
4456 }
|
|
4457 }
|
|
4458 }
|
|
4459
|
|
4460 //----- (0047A384) --------------------------------------------------------
|
|
4461 void ODM_LoadAndInitialize(const char *pLevelFilename, ODMRenderParams *thisa)
|
|
4462 {
|
|
4463 int v2; // ebx@3
|
|
4464 unsigned int v3; // eax@3
|
|
4465 MapInfo *v4; // edi@4
|
|
4466 //int v5; // eax@8
|
|
4467 //SpawnPointMM7 *v6; // edx@14
|
|
4468 size_t v7; // eax@19
|
|
4469 //char *v8; // eax@19
|
|
4470 //char *v9; // eax@21
|
|
4471 char Source[120]; // [sp+Ch] [bp-84h]@19
|
|
4472 const char *pFilename; // [sp+84h] [bp-Ch]@1
|
|
4473 //unsigned int v12; // [sp+88h] [bp-8h]@12
|
|
4474 //int v13; // [sp+8Ch] [bp-4h]@11
|
|
4475 int v;
|
|
4476
|
|
4477 pFilename = pLevelFilename;
|
|
4478 //thisa->AllocSoftwareDrawBuffers();
|
|
4479 pODMRenderParams->Initialize();
|
|
4480 pWeather->bRenderSnow = false;
|
|
4481 pRenderer->ClearZBuffer(0, 479);
|
|
4482 //thisa = (ODMRenderParams *)1;
|
|
4483 GetAlertStatus();
|
|
4484 if (_A750D8_player_speech_timer)
|
|
4485 _A750D8_player_speech_timer = 0;
|
|
4486 v2 = pMapStats->GetMapInfo(pCurrentMapName);
|
|
4487 v3 = 0;
|
|
4488 if (v2)
|
|
4489 {
|
|
4490 v4 = &pMapStats->pInfos[v2];
|
|
4491 v3 = v4->uRespawnIntervalDays;
|
|
4492 }
|
|
4493 else
|
|
4494 v4 = (MapInfo *)1;
|
|
4495 day_attrib &= ~DAY_ATTRIB_FOG;
|
|
4496 dword_6BE13C_uCurrentlyLoadedLocationID = v2;
|
|
4497 pOutdoor->Initialize(
|
|
4498 pFilename,
|
|
4499 (unsigned int)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) / 0x3C / 0x3C / 0x18 + 1,
|
|
4500 v3,
|
|
4501 &v);
|
|
4502 if (!(dword_6BE364_game_settings_1 & GAME_SETTINGS_2000))
|
|
4503 {
|
|
4504 Actor::InitializeActors();
|
|
4505 SpriteObject::InitializeSpriteObjects();
|
|
4506 }
|
|
4507 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_2000;
|
|
4508 //v5 = 0;
|
|
4509 if (!v2)
|
|
4510 v = 0;
|
|
4511 if (v == 1)
|
|
4512 {
|
|
4513 //v13 = 0;
|
|
4514 for (uint i = 0; i < pOutdoor->uNumSpawnPoints; ++i)
|
|
4515 {
|
|
4516 //v12 = 0;
|
|
4517 //while ( 1 )
|
|
4518 //{
|
|
4519 SpawnPointMM7* spawn = pOutdoor->pSpawnPoints + i;
|
|
4520 //v6 = &pOutdoor->pSpawnPoints[v12 / 0x18];
|
|
4521 if (spawn->uKind == 3)
|
|
4522 SpawnEncounter(v4, spawn, 0, 0, 0);
|
|
4523 else
|
|
4524 v4->SpawnRandomTreasure(spawn);
|
|
4525 //++v13;
|
|
4526 //v12 += 24;
|
|
4527 //if ( v13 >= (signed int)pOutdoor->uNumSpawnPoints )
|
|
4528 // break;
|
|
4529 //v5 = 0;
|
|
4530 //}
|
|
4531 }
|
|
4532 RespawnGlobalDecorations();
|
|
4533 }
|
|
4534 pOutdoor->PrepareDecorations();
|
|
4535 pOutdoor->ArrangeSpriteObjects();
|
|
4536 pOutdoor->InitalizeActors(v2);
|
|
4537 pOutdoor->MessWithLUN();
|
|
4538 v7 = strlen("levels\\");
|
|
4539 strcpy(Source, &pFilename[v7]);
|
|
4540 strcpy(pOutdoor->pLevelFilename, Source);
|
|
4541 pWeather->Initialize();
|
|
4542 pGame->pIndoorCameraD3D->sRotationY = pParty->sRotationY;
|
|
4543 pGame->pIndoorCameraD3D->sRotationX = pParty->sRotationX;
|
|
4544 //pODMRenderParams->RotationToInts();
|
|
4545 pOutdoor->UpdateSunlightVectors();
|
|
4546
|
|
4547 float fov_rad;
|
|
4548 float fov_rad_inv;
|
|
4549 //----- (0042394D) --------------------------------------------------------
|
|
4550 //void IndoorCamera::Initialize(int degFov, unsigned int uViewportWidth, unsigned int uViewportHeight)
|
|
4551 {
|
|
4552 //pIndoorCamera->Initialize(65, viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X + 1,
|
|
4553 // viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y + 1);
|
|
4554
|
|
4555 int uViewportWidth = viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X + 1;
|
|
4556
|
|
4557 extern float _calc_fov(int viewport_width, int angle_degree);
|
|
4558 fov_rad = _calc_fov(uViewportWidth, 65);
|
|
4559 fov_rad_inv = 65536.0 / fov_rad;
|
|
4560 }
|
|
4561 pODMRenderParams->int_fov_rad = (signed __int64)fov_rad;
|
|
4562 pODMRenderParams->int_fov_rad_inv = (signed __int64)fov_rad_inv;
|
|
4563
|
|
4564 for (int i = 0; i < 20000; ++i)
|
|
4565 {
|
|
4566 array_77EC08[i].ptr_38 = &stru_8019C8;
|
|
4567
|
|
4568 array_77EC08[i].ptr_48 = nullptr;
|
|
4569 }
|
|
4570
|
|
4571 MM7Initialization();
|
|
4572 }
|
|
4573
|
|
4574 //----- (0047C370) --------------------------------------------------------
|
|
4575 unsigned int GetLevelFogColor()
|
|
4576 {
|
|
4577 signed __int64 v1; // qax@5
|
|
4578 int v2; // eax@6
|
|
4579
|
|
4580 if (bUnderwater)
|
|
4581 return 0xFF258F5C;
|
|
4582
|
|
4583 if (day_attrib & DAY_ATTRIB_FOG)
|
|
4584 {
|
|
4585 if (pWeather->bNight) // night-time fog
|
|
4586 {
|
|
4587 if (for_refactoring)
|
|
4588 {
|
|
4589 MessageBoxA(nullptr, "Nomad: decompilation can be inaccurate, please send savegame to Nomad", "", 0);
|
|
4590 __debugbreak();
|
|
4591 }
|
|
4592 v2 = -(pWeather->bNight != 1);
|
|
4593 return (v2 & 0xE0E0E1) - 0xE0E0E1;
|
|
4594 }
|
|
4595 else
|
|
4596 {
|
|
4597 v1 = (signed __int64)((1.0 - pOutdoor->fFogDensity) * 200.0 + pOutdoor->fFogDensity * 31.0);
|
|
4598 return v1 | (((unsigned int)v1 | (((unsigned int)v1 | 0xFFFFFF00) << 8)) << 8);
|
|
4599 }
|
|
4600 }
|
|
4601
|
|
4602 return 0;
|
|
4603 }
|
|
4604
|
|
4605 //----- (0047C3D7) --------------------------------------------------------
|
|
4606 int __fastcall sub_47C3D7_get_fog_specular(int a1, int a2, float a3)
|
|
4607 {
|
|
4608 int v3; // ecx@1
|
|
4609 signed int v7; // ecx@11
|
|
4610
|
|
4611 v3 = pWeather->bNight;
|
|
4612 if (bUnderwater == 1)
|
|
4613 v3 = 0;
|
|
4614 if (pParty->armageddon_timer || !(day_attrib & DAY_ATTRIB_FOG) && !bUnderwater)
|
|
4615 return 0xFF000000;
|
|
4616 if (v3)
|
|
4617 {
|
|
4618 if (a3 < (double)day_fogrange_1)
|
|
4619 {
|
|
4620 v7 = 0;
|
|
4621 if (a3 == 0.0)
|
|
4622 v7 = 216;
|
|
4623 if (a2)
|
|
4624 v7 = 248;
|
|
4625 return (-1 - v7) << 24;
|
|
4626 }
|
|
4627 else
|
|
4628 {
|
|
4629 if (a3 > (double)day_fogrange_2)
|
|
4630 {
|
|
4631 v7 = 216;
|
|
4632 if (a3 == 0.0)
|
|
4633 v7 = 216;
|
|
4634 if (a2)
|
|
4635 v7 = 248;
|
|
4636 return (-1 - v7) << 24;
|
|
4637 }
|
|
4638 v7 = (signed __int64)((a3 - (double)day_fogrange_1) / ((double)day_fogrange_2 - (double)day_fogrange_1) * 216.0);
|
|
4639 }
|
|
4640 }
|
|
4641 else
|
|
4642 {
|
|
4643 if (a3 < (double)day_fogrange_1)
|
|
4644 {
|
|
4645 v7 = 0;
|
|
4646 if (a3 == 0.0)
|
|
4647 v7 = 216;
|
|
4648 if (a2)
|
|
4649 v7 = 248;
|
|
4650 return (-1 - v7) << 24;
|
|
4651 }
|
|
4652 else
|
|
4653 {
|
|
4654 if (a3 > (double)day_fogrange_2)
|
|
4655 {
|
|
4656 v7 = 216;
|
|
4657 if (a3 == 0.0)
|
|
4658 v7 = 216;
|
|
4659 if (a2)
|
|
4660 v7 = 248;
|
|
4661 return (-1 - v7) << 24;
|
|
4662 }
|
|
4663 else
|
|
4664 v7 = floorf(((a3 - (double)day_fogrange_1) * 216.0 / ((double)day_fogrange_2 - (double)day_fogrange_1)) + 0.5f);
|
|
4665 }
|
|
4666 }
|
|
4667 if (v7 > 216)
|
|
4668 v7 = 216;
|
|
4669 else
|
|
4670 {
|
|
4671 if (a3 == 0.0)
|
|
4672 v7 = 216;
|
|
4673 }
|
|
4674 if (a2)
|
|
4675 v7 = 248;
|
|
4676 return (-1 - v7) << 24;
|
|
4677 }
|
|
4678
|
|
4679
|
|
4680 //----- (0047F44B) --------------------------------------------------------
|
|
4681 unsigned int WorldPosToGridCellX(int sWorldPosX)
|
|
4682 {
|
|
4683 return (sWorldPosX >> 9) + 64; // sar is in original exe, resulting -880 / 512 = -1
|
|
4684 // and -880 sar 9 = -2
|
|
4685 }
|
|
4686
|
|
4687 //----- (0047F458) --------------------------------------------------------
|
|
4688 unsigned int WorldPosToGridCellZ(int sWorldPosZ)
|
|
4689 {
|
|
4690 return 64 - (sWorldPosZ >> 9); // sar is in original exe, resulting -880 / 512 = -1
|
|
4691 // and -880 sar 9 = -2
|
|
4692 }
|
|
4693
|
|
4694 //----- (0047F469) --------------------------------------------------------
|
|
4695 int GridCellToWorldPosX(int a1)
|
|
4696 {
|
|
4697 return (a1 - 64) << 9;
|
|
4698 }
|
|
4699
|
|
4700 //----- (0047F476) --------------------------------------------------------
|
|
4701 int GridCellToWorldPosZ(int a1)
|
|
4702 {
|
|
4703 return (64 - a1) << 9;
|
|
4704 }
|
|
4705
|
|
4706
|
|
4707
|
|
4708 //----- (00481ED9) --------------------------------------------------------
|
|
4709 void sub_481ED9_MessWithODMRenderParams()
|
|
4710 {
|
|
4711 stru_8019C8._48616B_frustum_odm(65536, 0, 0, 0, 65536, 0);
|
|
4712 pODMRenderParams->uNumPolygons = 0;
|
|
4713 //pODMRenderParams->uNumEdges = 0;
|
|
4714 //pODMRenderParams->uNumSpans = 0;
|
|
4715 //pODMRenderParams->uNumSurfs = 0;
|
|
4716 pODMRenderParams->uNumBillboards = 0;
|
|
4717 pODMRenderParams->field_44 = 0;
|
|
4718 }
|
|
4719
|
|
4720 //----- (004823F4) --------------------------------------------------------
|
|
4721 bool IsTerrainSlopeTooHigh(int pos_x, int pos_z)
|
|
4722 {
|
|
4723 //unsigned int v2; // ebx@1
|
|
4724 //unsigned int v3; // edi@1
|
|
4725 //int v4; // eax@1
|
|
4726 //int v6; // esi@5
|
|
4727 //int v7; // ecx@6
|
|
4728 //int v8; // edx@6
|
|
4729 //int v9; // eax@6
|
|
4730 //int y_min; // esi@10
|
|
4731 //int v11; // [sp+14h] [bp-8h]@1
|
|
4732 //int v12; // [sp+18h] [bp-4h]@1
|
|
4733
|
|
4734 //v12 = a1;
|
|
4735 //v11 = a2;
|
|
4736 unsigned int grid_x = WorldPosToGridCellX(pos_x);
|
|
4737 unsigned int grid_z = WorldPosToGridCellZ(pos_z) - 1;
|
|
4738
|
|
4739 int party_grid_x1 = GridCellToWorldPosX(grid_x);
|
|
4740 //dword_76D56C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(grid_x + 1);
|
|
4741 //dword_76D570_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(grid_x + 1);
|
|
4742 //dword_76D574_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(grid_x);
|
|
4743 int party_grid_z1 = GridCellToWorldPosZ(grid_z);
|
|
4744 //dword_76D55C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(grid_z);
|
|
4745 //dword_76D560_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(grid_z + 1);
|
|
4746 //dword_76D564_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(grid_z + 1);
|
|
4747 int party_x1z1_y = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z);
|
|
4748 int party_x2z1_y = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z);
|
|
4749 int party_x2z2_y = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z + 1);
|
|
4750 int party_x1z2_y = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z + 1);
|
|
4751 //dword_76D554_terrain_cell_world_pos_around_party_y = v4;
|
|
4752 if (party_x1z1_y == party_x2z1_y &&
|
|
4753 party_x2z1_y == party_x2z2_y &&
|
|
4754 party_x2z2_y == party_x1z2_y)
|
|
4755 return false;
|
|
4756
|
|
4757 int dx = abs(pos_x - party_grid_x1),
|
|
4758 dz = abs(party_grid_z1 - pos_z);
|
|
4759
|
|
4760 int y1, y2, y3;
|
|
4761 if (dz >= dx)
|
|
4762 {
|
|
4763 y1 = party_x1z2_y; // lower-left triangle
|
|
4764 y2 = party_x2z2_y; // y3 | \
|
|
4765 y3 = party_x1z1_y; // | \
|
|
4766 /* | \
|
|
4767 |______ \
|
|
4768 y1 y2 */
|
|
4769 }
|
|
4770 else
|
|
4771 {
|
|
4772 y1 = party_x2z1_y; // upper-right
|
|
4773 y2 = party_x1z1_y; // y2_______ y1
|
|
4774 y3 = party_x2z2_y; // \ |
|
|
4775 /* \ |
|
|
4776 \ |
|
|
4777 y3 */
|
|
4778 }
|
|
4779
|
|
4780 int y_min = min(y1, min(y2, y3));// не верно при подъёме на склон
|
|
4781 int y_max = max(y1, max(y2, y3));
|
|
4782 return (y_max - y_min) > 512;
|
|
4783 }
|
|
4784
|
|
4785 //----- (0048257A) --------------------------------------------------------
|
|
4786 int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *pIsOnWater, int bFloatAboveWater)
|
|
4787 {
|
|
4788 // int result; // eax@9
|
|
4789 int v8; // ebx@11
|
|
4790 int v9; // eax@11
|
|
4791 int v10; // ecx@11
|
|
4792 int v13; // [sp+10h] [bp-8h]@11
|
|
4793 signed int v14; // [sp+14h] [bp-4h]@3
|
|
4794 int v15; // [sp+24h] [bp+Ch]@11
|
|
4795
|
|
4796 unsigned int grid_x = WorldPosToGridCellX(a1);
|
|
4797 unsigned int grid_z = WorldPosToGridCellZ(a2) - 1;
|
|
4798
|
|
4799 int grid_x1 = GridCellToWorldPosX(grid_x),
|
|
4800 grid_x2 = GridCellToWorldPosX(grid_x + 1);
|
|
4801 int grid_z1 = GridCellToWorldPosZ(grid_z),
|
|
4802 grid_z2 = GridCellToWorldPosZ(grid_z + 1);
|
|
4803
|
|
4804 int y_x1z1 = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z),
|
|
4805 y_x2z1 = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z),
|
|
4806 y_x2z2 = pOutdoor->DoGetHeightOnTerrain(grid_x + 1, grid_z + 1),
|
|
4807 y_x1z2 = pOutdoor->DoGetHeightOnTerrain(grid_x, grid_z + 1);
|
|
4808 //v4 = WorldPosToGridCellX(a1);
|
|
4809 //v5 = WorldPosToGridCellZ(v12) - 1;
|
|
4810 //dword_76D538_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4);
|
|
4811 //dword_76D53C_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1);
|
|
4812 //dword_76D540_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4 + 1);
|
|
4813 //dword_76D544_terrain_cell_world_pos_around_party_x = GridCellToWorldPosX(v4);
|
|
4814 //dword_76D528_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5);
|
|
4815 //dword_76D52C_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5);
|
|
4816 //dword_76D530_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1);
|
|
4817 //dword_76D534_terrain_cell_world_pos_around_party_z = GridCellToWorldPosZ(v5 + 1);
|
|
4818 //dword_76D518_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5);
|
|
4819 //dword_76D51C_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5);
|
|
4820 //dword_76D520_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4 + 1, v5 + 1);
|
|
4821 //dword_76D524_terrain_cell_world_pos_around_party_y = pOutdoor->DoGetHeightOnTerrain(v4, v5 + 1);
|
|
4822 *pIsOnWater = false;
|
|
4823 if (pOutdoor->ActuallyGetSomeOtherTileInfo(grid_x, grid_z) & 2)
|
|
4824 *pIsOnWater = true;
|
|
4825 v14 = 0;
|
|
4826 if (!bFloatAboveWater && *pIsOnWater)
|
|
4827 v14 = -60;
|
|
4828 if (y_x1z1 != y_x2z1 ||
|
|
4829 y_x2z1 != y_x2z2 ||
|
|
4830 y_x2z2 != y_x1z2)
|
|
4831 {
|
|
4832 if (abs(grid_z1 - a2) >= abs(a1 - grid_x1))
|
|
4833 {
|
|
4834 v8 = y_x1z2;
|
|
4835 v9 = y_x2z2;
|
|
4836 v10 = y_x1z1;
|
|
4837 v15 = a1 - grid_x1;
|
|
4838 v13 = a2 - grid_z2;
|
|
4839 }
|
|
4840 else
|
|
4841 {
|
|
4842 v8 = y_x2z1;
|
|
4843 v9 = y_x1z1;
|
|
4844 v10 = y_x2z2;
|
|
4845 v15 = grid_x2 - a1;
|
|
4846 v13 = grid_z1 - a2;
|
|
4847 }
|
|
4848 return v14 + v8 + fixpoint_mul(v13, (v10 - v8) * 128) + fixpoint_mul(v15, (v9 - v8) * 128);
|
|
4849 }
|
|
4850 else
|
|
4851 return y_x1z1;
|
|
4852 }
|