2541
|
1
|
|
2
|
|
3 #define _CRTDBG_MAP_ALLOC
|
|
4 #include <stdlib.h>
|
|
5 #include <crtdbg.h>
|
|
6
|
|
7 #define _CRT_SECURE_NO_WARNINGS
|
|
8
|
|
9 #include "Engine/Engine.h"
|
|
10
|
|
11 #include "Arcomage\Arcomage.h"
|
|
12
|
|
13 #include "Engine/Graphics/Vis.h"
|
|
14 #include "Engine/Graphics/Weather.h"
|
|
15 #include "Engine/Graphics/LightmapBuilder.h"
|
|
16 #include "Engine/Graphics/DecalBuilder.h"
|
|
17 #include "Engine/Graphics/ParticleEngine.h"
|
|
18 #include "IO/Mouse.h"
|
|
19 #include "IO/Keyboard.h"
|
|
20 #include "Engine/Graphics/GammaControl.h"
|
|
21 #include "stru6.h"
|
|
22 #include "Engine/Graphics/stru9.h"
|
|
23 #include "Engine/Graphics/stru10.h"
|
|
24
|
|
25 #include "Engine/Party.h"
|
|
26 #include "Engine/Graphics/Viewport.h"
|
|
27 #include "Engine/Timer.h"
|
|
28 #include "Engine/Graphics/Outdoor.h"
|
|
29 #include "Engine/Graphics/Overlays.h"
|
|
30 #include "Media/Audio/AudioPlayer.h"
|
|
31 #include "Engine/LOD.h"
|
|
32 #include "GUI/GUIWindow.h"
|
|
33 #include "Engine/TurnEngine/TurnEngine.h"
|
|
34 #include "Media/Video/Bink_Smacker.h"
|
|
35 #include "Engine/Events.h"
|
|
36 #include "Engine/OurMath.h"
|
|
37 #include "Engine/texts.h"
|
|
38 #include "GUI/GUIFont.h"
|
|
39 #include "Engine/Graphics/Lights.h"
|
|
40 #include "Engine/Spells/CastSpellInfo.h"
|
|
41 #include "Engine/Tables/FrameTableInc.h"
|
|
42 #include "Engine/Objects/Actor.h"
|
|
43 #include "GUI/GUIProgressBar.h"
|
|
44 #include "Engine/Objects/ObjectList.h"
|
|
45 #include "Engine/Graphics/Level/Decoration.h"
|
|
46 #include "Engine/Graphics/PaletteManager.h"
|
|
47 #include "GUI/UI/UIHouses.h"
|
|
48 #include "GUI/UI/UIShops.h"
|
|
49 #include "GUI/UI/UIPartyCreation.h"
|
|
50 #include "Engine/SaveLoad.h"
|
|
51 #include "Engine/Objects/SpriteObject.h"
|
|
52 #include "Engine/Graphics/Sprites.h"
|
|
53 #include "Engine/Registry.h"
|
|
54 #include "Engine/Objects/Chest.h"
|
|
55
|
|
56 #include "GUI/UI/UIGame.h"
|
|
57
|
|
58 #include "Engine/Graphics/DecorationList.h"
|
|
59 #include "Engine/Tables/IconFrameTable.h"
|
|
60 #include "Engine/Tables/PlayerFrameTable.h"
|
|
61 #include "Engine/MapsLongTimer.h"
|
|
62 #include "Engine/Tables/StorylineTextTable.h"
|
|
63 #include "Engine/Tables/FactionTable.h"
|
|
64 #include "Engine/stru123.h"
|
|
65 #include "Engine/LuaVM.h"
|
|
66 #include "Engine/Graphics/RenderD3D11.h"
|
|
67 #include "Engine/MMT.h"
|
|
68 #include "GUI/NewUI\MainMenu.h"
|
|
69
|
|
70 #include "Game/Game.h"
|
2543
|
71 #include "Game/MainMenu.h"
|
2541
|
72
|
|
73 #include <direct.h>
|
|
74
|
|
75
|
|
76
|
|
77
|
|
78 Engine *pEngine = nullptr;
|
|
79
|
|
80
|
|
81
|
|
82
|
|
83
|
|
84
|
|
85
|
|
86 //----- (00466C40) --------------------------------------------------------
|
|
87 const wchar_t *MENU_STATE_to_string(MENU_STATE m)
|
|
88 {
|
|
89 switch (m)
|
|
90 {
|
|
91 case -1: return L"-1";
|
|
92 case MENU_MAIN: return L"MENU_MAIN";
|
|
93 case MENU_NEWGAME: return L"MENU_NEWGAME";
|
|
94 case MENU_CREDITS: return L"MENU_CREDITS";
|
|
95 case MENU_SAVELOAD: return L"MENU_SAVELOAD";
|
|
96 case MENU_EXIT_GAME: return L"MENU_EXIT_GAME";
|
|
97 case MENU_5: return L"MENU_5";
|
|
98 case MENU_CREATEPARTY: return L"MENU_CREATEPARTY";
|
|
99 case MENU_NAMEPANELESC: return L"MENU_NAMEPANELESC";
|
|
100 case MENU_CREDITSPROC: return L"MENU_CREDITSPROC";
|
|
101 case MENU_LoadingProcInMainMenu: return L"MENU_LoadingProcInMainMenu";
|
|
102 case MENU_DebugBLVLevel: return L"MENU_DebugBLVLevel";
|
|
103 case MENU_CREDITSCLOSE: return L"MENU_CREDITSCLOSE";
|
|
104 case MENU_MMT_MAIN_MENU: return L"MENU_MMT_MAIN_MENU";
|
|
105 default: return L"unk";
|
|
106 };
|
|
107 };
|
|
108
|
|
109
|
|
110 void SetCurrentMenuID(MENU_STATE uMenu)
|
|
111 {
|
|
112 sCurrentMenuID = uMenu;
|
|
113 Log::Warning(L"CurrentMenu = %s \n", MENU_STATE_to_string(uMenu));
|
|
114 }
|
|
115
|
|
116 //----- (00466CA0) --------------------------------------------------------
|
|
117 MENU_STATE GetCurrentMenuID()
|
|
118 {
|
|
119 return sCurrentMenuID;
|
|
120 }
|
|
121
|
|
122
|
|
123
|
|
124 //----- (00464761) --------------------------------------------------------
|
|
125 void Engine_DeinitializeAndTerminate(int exitCode)
|
|
126 {
|
|
127 SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
|
|
128 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows();
|
|
129 pEngine->Deinitialize();
|
|
130 pRenderer->Release();
|
|
131 delete window;
|
|
132 //if ( !DestroyWindow(hWnd) )
|
|
133 // GetLastError();
|
|
134 exit(exitCode);
|
|
135 }
|
|
136
|
|
137
|
|
138
|
|
139
|
|
140
|
|
141
|
|
142
|
|
143
|
|
144
|
|
145
|
|
146
|
|
147 //----- (00435694) --------------------------------------------------------
|
|
148 void Engine::ToggleFlags2(unsigned int uFlag)
|
|
149 {
|
|
150 unsigned int v2; // eax@1
|
|
151
|
|
152 v2 = this->uFlags2;
|
|
153 if (v2 & uFlag)
|
|
154 this->uFlags2 = v2 & ~uFlag;
|
|
155 else
|
|
156 this->uFlags2 = uFlag | v2;
|
|
157 }
|
|
158
|
|
159 //----- (0044103C) --------------------------------------------------------
|
|
160 void Engine::Draw()
|
|
161 {
|
|
162 int v4; // edi@26
|
|
163
|
|
164 uFlags2 &= ~0x02;
|
|
165 if (pParty->_497FC5_check_party_perception_against_level())
|
|
166 uFlags2 |= 2;
|
|
167
|
2543
|
168 pIndoorCameraD3D->sRotationX = pParty->sRotationX;
|
|
169 pIndoorCameraD3D->sRotationY = pParty->sRotationY;
|
|
170 pIndoorCameraD3D->vPartyPos.x = pParty->vPosition.x - pParty->y_rotation_granularity * cosf(2 * pi_double * pParty->sRotationY / 2048.0);
|
|
171 pIndoorCameraD3D->vPartyPos.y = pParty->vPosition.y - pParty->y_rotation_granularity * sinf(2 * pi_double * pParty->sRotationY / 2048.0);
|
|
172 pIndoorCameraD3D->vPartyPos.z = pParty->vPosition.z + pParty->sEyelevel;//193, but real 353
|
2541
|
173
|
|
174 //pIndoorCamera->Initialize2();
|
|
175 pIndoorCameraD3D->CalculateRotations(pParty->sRotationX, pParty->sRotationY);
|
|
176 pIndoorCameraD3D->CreateWorldMatrixAndSomeStuff();
|
|
177 pIndoorCameraD3D->_4374E8_ProllyBuildFrustrum();
|
|
178
|
|
179 if (pMovie_Track)
|
|
180 {
|
|
181 /*if ( !pRenderer->pRenderD3D )
|
|
182 {
|
|
183 pRenderer->BeginSceneD3D();
|
|
184 pMouse->DrawCursorToTarget();
|
|
185 pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
|
|
186 }*/
|
|
187 }
|
|
188 else
|
|
189 {
|
|
190 if (pParty->vPosition.x != pParty->vPrevPosition.x || pParty->sRotationY != pParty->sPrevRotationY || pParty->vPosition.y != pParty->vPrevPosition.y
|
|
191 || pParty->sRotationX != pParty->sPrevRotationX || pParty->vPosition.z != pParty->vPrevPosition.z || pParty->sEyelevel != pParty->sPrevEyelevel)
|
|
192 pParty->uFlags |= 2u;
|
|
193 pParty->vPrevPosition.x = pParty->vPosition.x;
|
|
194 pParty->vPrevPosition.y = pParty->vPosition.y;
|
|
195 pParty->vPrevPosition.z = pParty->vPosition.z;
|
|
196 //v0 = &pRenderer;
|
|
197 pParty->sPrevRotationY = pParty->sRotationY;
|
|
198 pParty->sPrevRotationX = pParty->sRotationX;
|
|
199
|
|
200 pParty->sPrevEyelevel = pParty->sEyelevel;
|
|
201 pRenderer->BeginSceneD3D();
|
|
202
|
|
203 //if ( !pRenderer->pRenderD3D )
|
|
204 //pMouse->DrawCursorToTarget();
|
|
205 if (!PauseGameDrawing() || viewparams->field_48 == 1)
|
|
206 {
|
|
207 //if ( pRenderer->pRenderD3D )
|
|
208 {
|
|
209 float v2 = (double)(((signed int)pMiscTimer->uTotalGameTimeElapsed >> 2) & 0x1F) * 0.032258064 * 6.0;
|
|
210 //v3 = v2 + 6.7553994e15;
|
|
211 //pRenderer->field_1036A8_bitmapid = LODWORD(v3);
|
|
212 pRenderer->hd_water_current_frame = floorf(v2 + 0.5f);
|
|
213 }
|
|
214
|
|
215 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
216 pIndoor->Draw();
|
|
217 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
218 pOutdoor->Draw();
|
|
219 else
|
|
220 Error("Invalid level type: %u", uCurrentlyLoadedLevelType);
|
|
221
|
|
222 //if (pRenderer->pRenderD3D)
|
|
223 {
|
|
224 pDecalBuilder->DrawBloodsplats();
|
|
225 pEngine->pLightmapBuilder->DrawLightmapsType(2);
|
|
226 }
|
|
227 }
|
|
228 pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene();
|
|
229 }
|
|
230
|
|
231 //DEBUG: force redraw gui
|
|
232 viewparams->bRedrawGameUI = true;
|
|
233
|
|
234
|
|
235 pRenderer->BeginScene();
|
|
236 //if (pRenderer->pRenderD3D)
|
|
237 pMouse->DrawCursorToTarget();
|
|
238 if (pOtherOverlayList->bRedraw)
|
|
239 viewparams->bRedrawGameUI = true;
|
|
240 v4 = viewparams->bRedrawGameUI;
|
|
241 GameUI_Footer();
|
|
242 if (!viewparams->bRedrawGameUI)
|
|
243 GameUI_DrawRightPanelItems();
|
|
244 else
|
|
245 {
|
|
246 GameUI_DrawRightPanelFrames();
|
|
247 GameUI_Footer_2();
|
|
248 viewparams->bRedrawGameUI = false;
|
|
249 }
|
|
250 if (!pMovie_Track)//!pVideoPlayer->pSmackerMovie)
|
|
251 {
|
|
252 GameUI_DrawMinimap(488, 16, 625, 133, viewparams->uMinimapZoom, true);//redraw = pParty->uFlags & 2);
|
|
253 if (v4)
|
|
254 {
|
|
255 if (!PauseGameDrawing() /*&& pRenderer->pRenderD3D*/) // clear game viewport with transparent color
|
|
256 pRenderer->FillRectFast(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pViewport->uViewportBR_X - pViewport->uViewportTL_X,
|
|
257 pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1,
|
|
258 0x7FF);
|
|
259 viewparams->field_48 = 0;
|
|
260 }
|
|
261 }
|
|
262
|
|
263 viewparams->bRedrawGameUI = pOtherOverlayList->bRedraw;
|
|
264 pOtherOverlayList->bRedraw = 0;
|
|
265
|
|
266 GameUI_DrawPartySpells();
|
|
267 if (v4 || pParty->pHirelings[0].evt_C || pParty->pHirelings[1].evt_C)
|
|
268 GameUI_DrawHiredNPCs();
|
|
269 GameUI_DrawPortraits(v4);
|
|
270 GameUI_DrawLifeManaBars();
|
|
271 GameUI_DrawCharacterSelectionFrame();
|
|
272 if (_44100D_should_alter_right_panel())
|
|
273 GameUI_DrawRightPanel();
|
|
274 if (!pMovie_Track)
|
|
275 {
|
|
276 pStru6Instance->DrawPlayerBuffAnims();
|
|
277 pOtherOverlayList->DrawTurnBasedIcon(v4);
|
|
278 GameUI_DrawTorchlightAndWizardEye();
|
|
279 }
|
|
280
|
|
281
|
|
282 static bool render_framerate = false;
|
|
283 static float framerate = 0.0f;
|
|
284 static uint frames_this_second = 0;
|
|
285 static uint last_frame_time = GetTickCount();
|
|
286 static uint framerate_time_elapsed = 0;
|
|
287
|
|
288 if (current_screen_type == SCREEN_GAME && uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
289 pWeather->Draw();//Ritor1: my include
|
|
290
|
|
291 //while(GetTickCount() - last_frame_time < 33 );//FPS control
|
|
292 uint frame_dt = GetTickCount() - last_frame_time;
|
|
293 last_frame_time = GetTickCount();
|
|
294
|
|
295 framerate_time_elapsed += frame_dt;
|
|
296 if (framerate_time_elapsed >= 1000)
|
|
297 {
|
|
298 framerate = frames_this_second * (1000.0f / framerate_time_elapsed);
|
|
299
|
|
300 framerate_time_elapsed = 0;
|
|
301 frames_this_second = 0;
|
|
302 render_framerate = true;
|
|
303 }
|
|
304
|
|
305 ++frames_this_second;
|
|
306
|
|
307 if (debug_information)
|
|
308 {
|
|
309 if (render_framerate)
|
|
310 {
|
|
311 sprintf(pTmpBuf.data(), "FPS: % .4f", framerate);
|
|
312 pPrimaryWindow->DrawText(pFontArrus, 494, 0, Color16(0, 0, 0), pTmpBuf.data(), 0, 0, 0);
|
|
313 }
|
|
314
|
|
315 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
316 {
|
|
317 int sector_id = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
|
|
318 sprintf(pTmpBuf.data(), "Party Sector ID: %u/%u\n", sector_id, pIndoor->uNumSectors);
|
|
319 pPrimaryWindow->DrawText(pFontArrus, 16, 16, Color16(255, 255, 255), pTmpBuf.data(), 0, 0, Color16(255, 255, 255));
|
|
320 }
|
|
321 sprintf(pTmpBuf.data(), "Party Position: % d % d % d", pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
|
|
322 pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16, Color16(255, 255, 255), pTmpBuf.data(), 0, 0, Color16(255, 255, 255));
|
|
323
|
|
324 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
325 {
|
|
326 uint uFaceID;
|
|
327 int sector_id = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
|
|
328 int floor_level = BLV_GetFloorLevel(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + 40, sector_id, &uFaceID);
|
|
329 sprintf(pTmpBuf.data(), "BLV_GetFloorLevel: %d face_id %d\n", floor_level, uFaceID);
|
|
330 }
|
|
331 else
|
|
332 {
|
|
333 int on_water, _a6;
|
|
334 int floor_level = ODM_GetFloorLevel(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z, 0, &on_water, &_a6, false);
|
|
335 sprintf(pTmpBuf.data(), "ODM_GetFloorLevel: %d on_water: %s a6 = %d\n", floor_level, on_water ? "true" : "false", _a6);
|
|
336 }
|
|
337 pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16 + 16, Color16(255, 255, 255), pTmpBuf.data(), 0, 0, Color16(255, 255, 255));
|
|
338 }
|
|
339
|
|
340 GUI_UpdateWindows();
|
|
341 pParty->UpdatePlayersAndHirelingsEmotions();
|
|
342
|
|
343 _unused_5B5924_is_travel_ui_drawn = false;
|
|
344 if (v4)
|
|
345 pMouse->bRedraw = true;
|
|
346 pMouse->ReadCursorWithItem();
|
|
347 pMouse->DrawCursor();
|
|
348 pMouse->Activate();
|
|
349 pRenderer->EndScene();
|
|
350 pRenderer->Present();
|
|
351 pParty->uFlags &= ~2;
|
|
352 }
|
|
353
|
|
354 //----- (0047A815) --------------------------------------------------------
|
|
355 void Engine::DrawParticles()
|
|
356 {
|
|
357 pParticleEngine->Draw();
|
|
358 }
|
|
359
|
|
360
|
|
361 //----- (0044F192) --------------------------------------------------------
|
|
362 void Engine::PrepareBloodsplats()
|
|
363 {
|
|
364 for (uint i = 0; i < uNumBloodsplats; ++i)
|
|
365 {
|
|
366 pBloodsplatContainer->AddBloodsplat(pBloodsplats[i].x, pBloodsplats[i].y, pBloodsplats[i].z,
|
|
367 pBloodsplats[i].radius, pBloodsplats[i].r, pBloodsplats[i].g, pBloodsplats[i].b);
|
|
368 }
|
|
369 }
|
|
370
|
|
371
|
|
372 //----- (0044F120) --------------------------------------------------------
|
|
373 void Engine::PushStationaryLights(int a2)
|
|
374 {
|
|
375 Game__StationaryLight* pLight;
|
|
376
|
|
377 for (int i = 0; i < uNumStationaryLights; ++i)
|
|
378 {
|
|
379 pLight = &pStationaryLights[i];
|
|
380 pStationaryLightsStack->AddLight(pLight->vPosition.x, pLight->vPosition.y, pLight->vPosition.z,
|
|
381 pLight->flt_18, pLight->vRGBColor.x, pLight->vRGBColor.y, pLight->vRGBColor.z, _4E94D0_light_type);
|
|
382 }
|
|
383 }
|
|
384 // 4E94D0: using guessed type char _4E94D0_light_type;
|
|
385
|
|
386 //----- (0044F0FD) --------------------------------------------------------
|
|
387 void Engine::_44F0FD()
|
|
388 {
|
|
389 ToggleFlags(0x40u);
|
|
390
|
|
391 if (!(uFlags & 0x40))
|
|
392 {
|
|
393 uNumBloodsplats = 0;
|
|
394 field_E0C = 0;
|
|
395 }
|
|
396 }
|
|
397
|
|
398 //----- (0044F0D8) --------------------------------------------------------
|
|
399 void Engine::ToggleFlags(uint uMask)
|
|
400 {
|
|
401 if (uFlags & uMask)
|
|
402 uFlags &= ~uMask;
|
|
403 else
|
|
404 uFlags |= uMask;
|
|
405 }
|
|
406
|
|
407
|
|
408 //----- (0044F07B) --------------------------------------------------------
|
|
409 bool Engine::_44F07B()
|
|
410 {
|
|
411 if (!pKeyboardInstance->IsKeyBeingHeld(VK_SHIFT) && !pKeyboardInstance->IsKeyBeingHeld(VK_LSHIFT) &&
|
|
412 !pKeyboardInstance->IsKeyBeingHeld(VK_LSHIFT) || (pKeyboardInstance->WasKeyPressed(VK_F11) == 0 &&
|
|
413 pKeyboardInstance->WasKeyPressed(VK_F11)))
|
|
414 return true;
|
|
415 return false;
|
|
416 }
|
|
417
|
|
418 //----- (0044EEA7) --------------------------------------------------------
|
|
419 bool Engine::_44EEA7()
|
|
420 {
|
|
421 //Game *v1; // esi@1
|
|
422 //double v2; // st7@2
|
|
423 float depth; // ST00_4@9
|
|
424 //bool result; // eax@9
|
|
425 //unsigned int v5; // eax@14
|
|
426 __int64 v6; // kr00_8@21
|
|
427 //unsigned int y; // [sp+4h] [bp-24h]@2
|
|
428 //unsigned int x; // [sp+8h] [bp-20h]@2
|
|
429 Vis_SelectionFilter *v10; // [sp+10h] [bp-18h]@2
|
|
430 Vis_SelectionFilter *v11; // [sp+14h] [bp-14h]@2
|
|
431 POINT cursor; // [sp+20h] [bp-8h]@1
|
|
432
|
|
433 //v1 = this;
|
|
434 ++qword_5C6DF0;
|
|
435 pParticleEngine->UpdateParticles();
|
|
436 pMouseInstance->GetCursorPos(&cursor);
|
|
437
|
|
438 //x = cursor.y;
|
|
439 //y = cursor.x;
|
|
440 if (sub_4637E0_is_there_popup_onscreen())
|
|
441 {
|
|
442 v11 = &vis_face_filter;
|
|
443 v10 = &vis_sprite_filter_2;
|
2543
|
444 depth = pIndoorCameraD3D->GetPickDepth();
|
2541
|
445 }
|
|
446 else
|
|
447 {
|
|
448 if (uFlags2 & GAME_FLAGS_2_TARGETING_MODE)
|
|
449 {
|
|
450 v11 = &vis_face_filter;
|
|
451 v10 = &vis_sprite_filter_1;
|
|
452 }
|
|
453 else
|
|
454 {
|
|
455 v11 = &vis_face_filter;
|
|
456 v10 = &vis_sprite_filter_4;
|
|
457 }
|
|
458 depth = 5120.0;
|
|
459 }
|
|
460 //depth = v2;
|
|
461
|
|
462 PickMouse(depth, cursor.x, cursor.y, false, v10, v11);
|
|
463 pLightmapBuilder->std__vector_000004_size = 0;
|
|
464 pLightmapBuilder->std__vector_183808_size = 0;
|
|
465 pDecalBuilder->std__vector_pDecals_size = 0;
|
|
466 pDecalBuilder->field_308008 = 0;
|
|
467 if (!_44F07B())
|
|
468 return false;
|
|
469
|
|
470 if (uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS)
|
|
471 pStru10Instance->bDoNotDrawPortalFrustum = false;
|
|
472 if ( /*pRenderer->pRenderD3D &&*/ uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
473 pRenderer->uFogColor = GetLevelFogColor() & 0xFFFFFF;
|
|
474 if (uFlags & 0x0400)
|
|
475 uFlags2 |= 0x01;
|
|
476 /*if ( !pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor && pMobileLightsStack->uNumLightsActive )
|
|
477 {
|
|
478 uFlags2 |= 0x01;
|
|
479 field_E10 = qword_5C6DF0;
|
|
480 }*/
|
|
481 v6 = qword_5C6DF0 - field_E10;
|
|
482 if (qword_5C6DF0 - field_E10 == 1)
|
|
483 uFlags2 |= v6;
|
|
484 if (uNumStationaryLights_in_pStationaryLightsStack != pStationaryLightsStack->uNumLightsActive)
|
|
485 {
|
|
486 uFlags2 |= 1;
|
|
487 uNumStationaryLights_in_pStationaryLightsStack = pStationaryLightsStack->uNumLightsActive;
|
|
488 }
|
|
489 return true;
|
|
490 }
|
|
491
|
|
492
|
|
493 //----- (0044EDE4) --------------------------------------------------------
|
|
494 bool Engine::AlterGamma_BLV(BLVFace *pFace, signed int *pColor)
|
|
495 {
|
|
496 if (uFlags2 & GAME_FLAGS_2_SATURATE_LIGHTMAPS &&
|
|
497 pFace->uAttributes & FACE_CAN_SATURATE_COLOR)
|
|
498 {
|
|
499 *pColor = ReplaceHSV(*pColor, 1.0, fSaturation, -1.0);
|
|
500 return true;
|
|
501 }
|
|
502 else
|
|
503 return false;
|
|
504 }
|
|
505
|
|
506 //----- (0044EE30) --------------------------------------------------------
|
|
507 bool Engine::AlterGamma_ODM(ODMFace *pFace, signed int *pColor)
|
|
508 {
|
|
509 if (uFlags2 & GAME_FLAGS_2_SATURATE_LIGHTMAPS &&
|
|
510 pFace->uAttributes & FACE_CAN_SATURATE_COLOR)
|
|
511 {
|
|
512 *pColor = ReplaceHSV(*pColor, 1.0, fSaturation, -1.0);
|
|
513 return true;
|
|
514 }
|
|
515 else
|
|
516 return false;
|
|
517 }
|
|
518
|
|
519
|
|
520 //----- (004645FA) --------------------------------------------------------
|
|
521 void Engine::Deinitialize()
|
|
522 {
|
|
523 WriteWindowsRegistryInt("startinwindow", 1);//pRenderer->bWindowMode);
|
|
524 //if (pRenderer->bWindowMode)
|
|
525 {
|
|
526 WriteWindowsRegistryInt("window X", window->GetX());
|
|
527 WriteWindowsRegistryInt("window Y", window->GetY());
|
|
528 }
|
|
529 WriteWindowsRegistryInt("valAlwaysRun", bAlwaysRun);
|
|
530 pItemsTable->Release();
|
|
531 pNPCStats->Release();
|
|
532
|
|
533 if (pMouse)
|
|
534 pMouse->Deactivate();
|
|
535
|
|
536 delete pRenderer;
|
|
537 pAudioPlayer->Release();//error
|
|
538 pNew_LOD->FreeSubIndexAndIO();
|
|
539 pGames_LOD->FreeSubIndexAndIO();
|
|
540 ClipCursor(0);
|
|
541 Engine::Destroy();
|
|
542 delete pEventTimer;
|
|
543 }
|
|
544
|
|
545 //----- (0044EE7C) --------------------------------------------------------
|
|
546 bool Engine::draw_debug_outlines()
|
|
547 {
|
|
548 if (uFlags & 0x04)
|
|
549 {
|
|
550 pLightmapBuilder->DrawDebugOutlines(-1);
|
|
551 pDecalBuilder->DrawDecalDebugOutlines();
|
|
552 }
|
|
553 return true;
|
|
554 }
|
|
555
|
|
556 //----- (0044EC23) --------------------------------------------------------
|
|
557 int Engine::_44EC23(struct Polygon *a2, int *a3, signed int a4)
|
|
558 {
|
|
559 double v4; // st7@4
|
|
560 //double v5; // ST00_8@4
|
|
561 signed int v6; // eax@5
|
|
562 //double v7; // ST00_8@6
|
|
563 signed int result; // eax@8
|
|
564 //double v9; // ST00_8@9
|
|
565 //double v10; // ST00_8@11
|
|
566 float a2a; // [sp+14h] [bp+8h]@4
|
|
567 float a3a; // [sp+18h] [bp+Ch]@4
|
|
568 float a3b; // [sp+18h] [bp+Ch]@6
|
|
569 float a4a; // [sp+1Ch] [bp+10h]@9
|
|
570 float a4b; // [sp+1Ch] [bp+10h]@11
|
|
571
|
|
572 if (this->uFlags2 & 2 && a2->field_59 == 5 && a2->pODMFace->uAttributes & 2)
|
|
573 {
|
|
574 v4 = (double)a4;
|
|
575 a2a = v4;
|
|
576 *a3 |= 2u;
|
|
577 a3a = (1.0 - this->fSaturation) * v4;
|
|
578 //v5 = a3a + 6.7553994e15;
|
|
579 //if ( SLODWORD(v5) >= 0 )
|
|
580 if (floorf(a3a + 0.5f) >= 0)
|
|
581 {
|
|
582 a3b = (1.0 - this->fSaturation) * a2a;
|
|
583 //v7 = a3b + 6.7553994e15;
|
|
584 //v6 = LODWORD(v7);
|
|
585 v6 = floorf(a3b + 0.5f);
|
|
586 }
|
|
587 else
|
|
588 v6 = 0;
|
|
589 if (a4 >= v6)
|
|
590 {
|
|
591 a4a = (1.0 - fSaturation) * a2a;
|
|
592 //v9 = a4a + 6.7553994e15;
|
|
593 //if ( SLODWORD(v9) >= 0 )
|
|
594 if (floorf(a4a + 0.5f) >= 0)
|
|
595 {
|
|
596 a4b = (1.0 - fSaturation) * a2a;
|
|
597 //v10 = a4b + 6.7553994e15;
|
|
598 //result = LODWORD(v10);
|
|
599 result = floorf(a4b + 0.5f);
|
|
600 }
|
|
601 else
|
|
602 result = 0;
|
|
603 }
|
|
604 else
|
|
605 result = a4;
|
|
606 }
|
|
607 else
|
|
608 result = -1;
|
|
609 return result;
|
|
610 }
|
|
611
|
|
612
|
|
613
|
|
614 //----- (00465C8B) --------------------------------------------------------
|
|
615 Engine *Engine::Create()
|
|
616 {
|
|
617 return new Engine;
|
|
618 }
|
|
619
|
|
620 //----- (00465CF3) --------------------------------------------------------
|
|
621 void Engine::Destroy()
|
|
622 {
|
|
623 delete pEngine;
|
|
624 pEngine = nullptr;
|
|
625 }
|
|
626
|
|
627 //----- (0044ED0A) --------------------------------------------------------
|
|
628 signed int Engine::_44ED0A(BLVFace *a2, int *a3, signed int a4)
|
|
629 {
|
|
630 double v4; // st7@3
|
|
631 //double v5; // ST00_8@3
|
|
632 signed int v6; // eax@4
|
|
633 //double v7; // ST00_8@5
|
|
634 signed int result; // eax@7
|
|
635 //double v9; // ST00_8@8
|
|
636 //double v10; // ST00_8@10
|
|
637 float v11; // [sp+14h] [bp+8h]@3
|
|
638 float v12; // [sp+18h] [bp+Ch]@3
|
|
639 float v13; // [sp+18h] [bp+Ch]@5
|
|
640 float v14; // [sp+1Ch] [bp+10h]@8
|
|
641 float v15; // [sp+1Ch] [bp+10h]@10
|
|
642
|
|
643 if (this->uFlags2 & 2 && a2->uAttributes & 2)
|
|
644 {
|
|
645 v4 = (double)a4;
|
|
646 v11 = v4;
|
|
647 *a3 |= 2u;
|
|
648 v12 = (1.0 - this->fSaturation) * v4;
|
|
649 //v5 = v12 + 6.7553994e15;
|
|
650 if (floorf(v12 + 0.5f)/* SLODWORD(v5)*/ >= 0)
|
|
651 {
|
|
652 v13 = (1.0 - this->fSaturation) * v11;
|
|
653 //v7 = v13 + 6.7553994e15;
|
|
654 //v6 = LODWORD(v7);
|
|
655 v6 = floorf(v13 + 0.5f);
|
|
656 }
|
|
657 else
|
|
658 v6 = 0;
|
|
659 if (a4 >= v6)
|
|
660 {
|
|
661 v14 = (1.0 - fSaturation) * v11;
|
|
662 //v9 = v14 + 6.7553994e15;
|
|
663 if (floorf(v14 + 0.5f)/* SLODWORD(v9)*/ >= 0)
|
|
664 {
|
|
665 v15 = (1.0 - fSaturation) * v11;
|
|
666 //v10 = v15 + 6.7553994e15;
|
|
667 //result = LODWORD(v10);
|
|
668 result = floorf(v15 + 0.5f);
|
|
669 }
|
|
670 else
|
|
671 result = 0;
|
|
672 }
|
|
673 else
|
|
674 result = a4;
|
|
675 }
|
|
676 else
|
|
677 result = -1;
|
|
678 return result;
|
|
679 }
|
|
680
|
|
681
|
|
682 //----- (0044E4B7) --------------------------------------------------------
|
|
683 Engine::Engine()
|
|
684 {
|
|
685 uNumStationaryLights = 0;
|
|
686 uNumBloodsplats = 0;
|
|
687 field_E0C = 0;
|
|
688 field_E10 = 0;
|
|
689 uNumStationaryLights_in_pStationaryLightsStack = 0;
|
|
690 uFlags = 0;
|
|
691 uFlags2 = 0;
|
|
692
|
|
693 //pThreadWardInstance = new ThreadWard;
|
|
694 pThreadWardInstance = nullptr;
|
|
695 pParticleEngine = new ParticleEngine;
|
|
696 pMouse = pMouseInstance = new Mouse;
|
|
697 pLightmapBuilder = new LightmapBuilder;
|
|
698 pVisInstance = new Vis;
|
|
699 pStru6Instance = new stru6;
|
|
700 pIndoorCameraD3D = new IndoorCameraD3D;
|
|
701 pStru9Instance = new stru9;
|
|
702 pStru10Instance = new stru10;
|
|
703 //pStru11Instance = new stru11;
|
|
704 pStru11Instance = nullptr;
|
|
705 //pStru12Instance = new stru12(pStru11Instance);
|
|
706 pStru12Instance = nullptr;
|
|
707 //pCShow = new CShow;
|
|
708 pCShow = nullptr;
|
|
709 pKeyboardInstance = new Keyboard;
|
|
710 //pGammaController = new GammaController;
|
|
711
|
|
712 uFlags |= 0x0800;
|
|
713 uFlags2 |= 0x24;
|
|
714
|
|
715 _44F0FD();
|
|
716 }
|
|
717
|
|
718 //----- (0044E7F3) --------------------------------------------------------
|
|
719 Engine::~Engine()
|
|
720 {
|
|
721 //delete pGammaController;
|
|
722 delete pKeyboardInstance;
|
|
723 /*delete pCShow;
|
|
724 delete pStru12Instance;
|
|
725 delete pStru11Instance;*/
|
|
726 delete pStru10Instance;
|
|
727 delete pStru9Instance;
|
|
728 delete pIndoorCameraD3D;
|
|
729 delete pStru6Instance;
|
|
730 delete pVisInstance;
|
|
731 delete pLightmapBuilder;
|
|
732 delete pMouseInstance;
|
|
733 delete pParticleEngine;
|
|
734 //delete pThreadWardInstance;
|
|
735 }
|
|
736
|
|
737 //----- (0044EA5E) --------------------------------------------------------
|
|
738 bool Engine::PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter)
|
|
739 {
|
|
740 /*if (current_screen_type != SCREEN_GAME|| !pRenderer->pRenderD3D)
|
|
741 return false;*/
|
|
742
|
|
743 if (!pVisInstance)
|
|
744 {
|
|
745 MessageBoxW(nullptr, L"The 'Vis' object pointer has not been instatiated, but CGame::Pick() is trying to call through it.", nullptr, 0);
|
|
746 return false;
|
|
747 }
|
|
748
|
|
749 if (uMouseX >= (signed int)pViewport->uScreen_TL_X &&
|
|
750 uMouseX <= (signed int)pViewport->uScreen_BR_X &&
|
|
751 uMouseY >= (signed int)pViewport->uScreen_TL_Y &&
|
|
752 uMouseY <= (signed int)pViewport->uScreen_BR_Y)
|
|
753 {
|
|
754 pVisInstance->PickMouse(fPickDepth, uMouseX, uMouseY, sprite_filter, face_filter);
|
|
755
|
|
756 if (bOutline)
|
|
757 OutlineSelection();
|
|
758 }
|
|
759
|
|
760 return true;
|
|
761 }
|
|
762 // 4E28F8: using guessed type int current_screen_type;
|
|
763
|
|
764 //----- (0044EB12) --------------------------------------------------------
|
|
765 bool Engine::PickKeyboard(bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter)
|
|
766 {
|
|
767 if (current_screen_type == SCREEN_GAME && pVisInstance /*&& pRenderer->pRenderD3D*/)
|
|
768 {
|
|
769 bool r = pVisInstance->PickKeyboard(&pVisInstance->default_list, sprite_filter, face_filter);
|
|
770
|
|
771 if (bOutline)
|
|
772 OutlineSelection();
|
|
773 return r;
|
|
774 }
|
|
775 return false;
|
|
776 }
|
|
777 /*
|
|
778 Result::Code Game::PickKeyboard(bool bOutline, struct unnamed_F93E6C *a3, struct unnamed_F93E6C *a4)
|
|
779 {
|
|
780 if (dword_4E28F8_PartyCantJumpIfTrue)
|
|
781 return Result::Generic;
|
|
782
|
|
783 pVis->PickKeyboard(a3, a4);
|
|
784 if (bOutline)
|
|
785 Game_outline_selection((int)this);
|
|
786 return Result::Success;
|
|
787 }
|
|
788 */
|
|
789 // 4E28F8: using guessed type int current_screen_type;
|
|
790
|
|
791 //----- (0044EB5A) --------------------------------------------------------
|
|
792 void Engine::OutlineSelection()
|
|
793 {
|
|
794 if (!pVisInstance)
|
|
795 return;
|
|
796
|
|
797 if (!pVisInstance->default_list.uNumPointers)
|
|
798 return;
|
|
799
|
|
800 Vis_ObjectInfo* object_info = pVisInstance->default_list.object_pointers[0];
|
|
801 if (object_info)
|
|
802 switch (object_info->object_type)
|
|
803 {
|
|
804 case VisObjectType_Sprite:
|
|
805 {
|
|
806 Log::Warning(L"Sprite outline currently unsupported");
|
|
807 return;
|
|
808 }
|
|
809
|
|
810 case VisObjectType_Face:
|
|
811 {
|
|
812 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
813 {
|
|
814 ODMFace* face = (ODMFace *)object_info->object;
|
|
815 if (face->uAttributes & FACE_OUTLINED)
|
|
816 face->uAttributes &= ~FACE_OUTLINED;
|
|
817 else
|
|
818 face->uAttributes |= FACE_OUTLINED;
|
|
819 }
|
|
820 else if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
821 {
|
|
822 BLVFace* face = (BLVFace *)object_info->object;
|
|
823 if (face->uAttributes & FACE_OUTLINED)
|
|
824 face->uAttributes &= ~FACE_OUTLINED;
|
|
825 else
|
|
826 face->uAttributes |= FACE_OUTLINED;
|
|
827 }
|
|
828 else
|
|
829 Error("Invalid level type", uCurrentlyLoadedLevelType);
|
|
830 }
|
|
831 break;
|
|
832
|
|
833 default:
|
|
834 {
|
|
835 MessageBoxW(nullptr, L"Undefined CObjectInfo type requested in CGame::outline_selection()", nullptr, 0);
|
|
836 ExitProcess(0);
|
|
837 }
|
|
838 }
|
|
839 }
|
|
840
|
|
841
|
|
842
|
|
843
|
|
844
|
|
845 //----- (0042FBDD) --------------------------------------------------------
|
|
846 void sub_42FBDD()
|
|
847 {
|
|
848 pAudioPlayer->PlaySound(SOUND_StartMainChoice02, 0, 0, -1, 0, 0, 0, 0);
|
|
849 pRenderer->DrawTextureIndexedAlpha(pBtn_YES->uX, pBtn_YES->uY, pBtn_YES->pTextures[0]);
|
|
850 pRenderer->Present();
|
|
851 }
|
|
852
|
|
853 //----- (0042FC15) --------------------------------------------------------
|
|
854 void CloseWindowBackground()
|
|
855 {
|
|
856 pAudioPlayer->PlaySound(SOUND_StartMainChoice02, -2, 0, -1, 0, 0, 0, 0);
|
|
857 pRenderer->DrawTextureIndexedAlpha(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pBtn_ExitCancel->pTextures[0]);
|
|
858 pRenderer->Present();
|
|
859 }
|
|
860
|
|
861
|
|
862 //----- (0046BDC0) --------------------------------------------------------
|
|
863 void UpdateUserInput_and_MapSpecificStuff()
|
|
864 {
|
|
865 if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0080_SKIP_USER_INPUT_THIS_FRAME)
|
|
866 {
|
|
867 dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0080_SKIP_USER_INPUT_THIS_FRAME;
|
|
868 return;
|
|
869 }
|
|
870
|
|
871 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
872 BLV_UpdateUserInputAndOther();
|
|
873 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
874 ODM_UpdateUserInputAndOther();
|
|
875
|
|
876 area_of_effect__damage_evaluate();
|
|
877 }
|
|
878
|
|
879 //----- (004646F0) --------------------------------------------------------
|
|
880 void PrepareWorld(unsigned int _0_box_loading_1_fullscreen)
|
|
881 {
|
|
882 //if ( pRenderer->pRenderD3D )
|
|
883 pEngine->pVisInstance->_4C1A02();
|
|
884 pEventTimer->Pause();
|
|
885 pMiscTimer->Pause();
|
|
886 pParty->uFlags = 2;
|
|
887 CastSpellInfoHelpers::_427D48();
|
|
888 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows();
|
|
889 DoPrepareWorld(0, (_0_box_loading_1_fullscreen == 0) + 1);
|
|
890 pMiscTimer->Resume();
|
|
891 pEventTimer->Resume();
|
|
892 }
|
|
893
|
|
894 //----- (00464866) --------------------------------------------------------
|
|
895 void DoPrepareWorld(unsigned int bLoading, int _1_fullscreen_loading_2_box)
|
|
896 {
|
|
897 char *v3; // eax@1
|
|
898 unsigned int v5; // eax@3
|
|
899 char Str1[20]; // [sp+Ch] [bp-18h]@1
|
|
900 unsigned int v9; // [sp+20h] [bp-4h]@1
|
|
901
|
|
902 v9 = bLoading;
|
|
903 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows();
|
|
904 pDecalBuilder->Reset(0);
|
|
905 pGameLoadingUI_ProgressBar->Initialize(_1_fullscreen_loading_2_box == 1 ? GUIProgressBar::TYPE_Fullscreen :
|
|
906 GUIProgressBar::TYPE_Box);
|
|
907 strcpy(Str1, pCurrentMapName);
|
|
908 v3 = strtok(Str1, ".");
|
|
909 strcpy(Str1, v3);
|
|
910 Level_LoadEvtAndStr(Str1);
|
|
911 LoadLevel_InitializeLevelEvt();
|
|
912 strcpy(Str1, pCurrentMapName);
|
|
913 _strrev(Str1);
|
|
914 strtok(Str1, ".");
|
|
915 _strrev(Str1);
|
|
916
|
|
917 for (uint i = 0; i < 1000; ++i)
|
|
918 pSpriteObjects[i].uObjectDescID = 0;
|
|
919
|
|
920 v5 = pMapStats->GetMapInfo(pCurrentMapName);
|
|
921 bUnderwater = false;
|
|
922 uLevelMapStatsID = v5;
|
|
923 pEngine->uFlags2 &= 0xFFFFFFF7u;
|
|
924 if (!_stricmp(pCurrentMapName, "out15.odm"))
|
|
925 {
|
|
926 bUnderwater = true;
|
|
927 pEngine->uFlags2 |= GAME_FLAGS_2_ALTER_GRAVITY;
|
|
928 }
|
|
929 pParty->floor_face_pid = 0;
|
|
930 if (_stricmp(Str1, "blv"))
|
|
931 PrepareToLoadODM(v9, 0);
|
|
932 else
|
|
933 PrepareToLoadBLV(v9);
|
|
934 pAudioPlayer->SetMapEAX();
|
|
935 _461103_load_level_sub();
|
|
936 if (!_stricmp(pCurrentMapName, "d11.blv") || !_stricmp(pCurrentMapName, "d10.blv"))
|
|
937 {
|
|
938 //spawning grounds & walls of mist - no loot & exp from monsters
|
|
939
|
|
940 for (uint i = 0; i < uNumActors; ++i)
|
|
941 {
|
|
942 pActors[i].pMonsterInfo.uTreasureType = 0;
|
|
943 pActors[i].pMonsterInfo.uTreasureDiceRolls = 0;
|
|
944 pActors[i].pMonsterInfo.uExp = 0;
|
|
945 }
|
|
946 }
|
|
947 bDialogueUI_InitializeActor_NPC_ID = 0;
|
|
948 OnMapLoad();
|
|
949 pGameLoadingUI_ProgressBar->Progress();
|
|
950 memset(&pRenderer->pBillboardRenderListD3D, 0, sizeof(pRenderer->pBillboardRenderListD3D));
|
|
951 pGameLoadingUI_ProgressBar->Release();
|
|
952 _flushall();
|
|
953 }
|
|
954
|
|
955 void IntegrityTest()
|
|
956 {
|
|
957 static_assert(sizeof(MovieHeader) == 44, "Wrong type size");
|
|
958 static_assert(sizeof(SoundDesc_mm6) == 112, "Wrong type size");
|
|
959 static_assert(sizeof(SoundDesc) == 120, "Wrong type size");
|
|
960 static_assert(sizeof(OverlayDesc) == 8, "Wrong type size");
|
|
961 static_assert(sizeof(ChestDesc) == 36, "Wrong type size");
|
|
962 static_assert(sizeof(ObjectDesc_mm6) == 52, "Wrong type size");
|
|
963 static_assert(sizeof(ObjectDesc) == 56, "Wrong type size");
|
|
964 static_assert(sizeof(DecorationDesc) == 84, "Wrong type size");
|
|
965 static_assert(sizeof(IconFrame) == 32, "Wrong type size");
|
|
966 static_assert(sizeof(PlayerFrame) == 10, "Wrong type size");
|
|
967 static_assert(sizeof(TextureFrame) == 20, "Wrong type size");
|
|
968 static_assert(sizeof(SpriteFrame) == 60, "Wrong type size");
|
|
969 static_assert(sizeof(RenderVertexSoft) == 0x30, "Wrong type size");
|
|
970 static_assert(sizeof(RenderBillboard) == 0x34, "Wrong type size");
|
|
971 static_assert(sizeof(Texture) == 0x48, "Wrong type size");
|
|
972 //static_assert(sizeof(RGBTexture) == 0x28, "Wrong type size");
|
|
973 //static_assert(sizeof(LODFile_IconsBitmaps) == 0x11BB8 + 4, "Wrong type size"); // + virtual dtor ptr
|
|
974 static_assert(sizeof(AudioPlayer) == 0xC84, "Wrong type size");
|
|
975 static_assert(sizeof(SoundDesc) == 0x78, "Wrong type size");
|
|
976 static_assert(sizeof(stru339_spell_sound) == 0xAFD8, "Wrong type size");
|
|
977 //static_assert(sizeof(VideoPlayer) == 0x108 + 4, "Wrong type size");
|
|
978 static_assert(sizeof(MovieHeader) == 0x2C, "Wrong type size");
|
|
979 static_assert(sizeof(DecorationDesc) == 0x54, "Wrong type size");
|
|
980 static_assert(sizeof(ObjectDesc) == 0x38, "Wrong type size");
|
|
981 static_assert(sizeof(OverlayDesc) == 0x8, "Wrong type size");
|
|
982 static_assert(sizeof(ChestDesc) == 0x24, "Wrong type size");
|
|
983 static_assert(sizeof(TileDesc) == 0x1A, "Wrong type size");
|
|
984 static_assert(sizeof(MonsterDesc_mm6) == 148, "Wrong type size");
|
|
985 static_assert(sizeof(MonsterDesc) == 152, "Wrong type size");
|
|
986 static_assert(sizeof(Timer) == 0x28, "Wrong type size");
|
|
987 static_assert(sizeof(OtherOverlay) == 0x14, "Wrong type size");
|
|
988 static_assert(sizeof(ItemGen) == 0x24, "Wrong type size");
|
|
989 static_assert(sizeof(SpriteObject) == 0x70, "Wrong type size");
|
|
990 static_assert(sizeof(ItemDesc) == 0x30, "Wrong type size");
|
|
991 static_assert(sizeof(ItemsTable) == 0x117A0, "Wrong type size");
|
|
992 static_assert(sizeof(Chest) == 0x14CC, "Wrong type size");
|
|
993 static_assert(sizeof(MapInfo) == 0x44, "Wrong type size");
|
|
994 static_assert(sizeof(SpellInfo) == 0x24, "Wrong type size");
|
|
995 static_assert(sizeof(SpellData) == 0x14, "Wrong type size");
|
|
996 static_assert(sizeof(SpellBuff) == 0x10, "Wrong type size");
|
|
997 static_assert(sizeof(AIDirection) == 0x1C, "Wrong type size");
|
|
998 static_assert(sizeof(ActorJob) == 0xC, "Wrong type size");
|
|
999 static_assert(sizeof(Actor) == 0x344, "Wrong type size");
|
|
1000 static_assert(sizeof(LevelDecoration) == 0x20, "Wrong type size");
|
|
1001 static_assert(sizeof(KeyboardActionMapping) == 0x20C, "Wrong type size");
|
|
1002 static_assert(sizeof(UIAnimation) == 0xD, "Wrong type size");
|
|
1003 static_assert(sizeof(SpawnPointMM7) == 0x18, "Wrong type size");
|
|
1004 static_assert(sizeof(ODMFace) == 0x134, "Wrong type size");
|
|
1005 static_assert(sizeof(BSPNode) == 0x8, "Wrong type size");
|
|
1006 static_assert(sizeof(BSPModel) == 0xBC, "Wrong type size");
|
|
1007 static_assert(sizeof(OutdoorLocation) == 0x1C28C, "Wrong type size");
|
|
1008 static_assert(sizeof(BLVFace) == 0x60, "Wrong type size");
|
|
1009 static_assert(sizeof(BLVFaceExtra) == 0x24, "Wrong type size");
|
|
1010 static_assert(sizeof(BLVSector) == 0x74, "Wrong type size");
|
|
1011 static_assert(sizeof(BLVLightMM7) == 0x10, "Wrong type size");
|
|
1012 static_assert(sizeof(BLVDoor) == 0x50, "Wrong type size");
|
|
1013 static_assert(sizeof(IndoorLocation) == 0x690, "Wrong type size");
|
|
1014 //static_assert(sizeof(ODMRenderParams) == 0x74, "Wrong type size");
|
|
1015 static_assert(sizeof(Mouse) == 0x114, "Wrong type size");
|
|
1016 static_assert(sizeof(Particle_sw) == 0x68, "Wrong type size");
|
|
1017 static_assert(sizeof(Particle) == 0x68, "Wrong type size");
|
|
1018 static_assert(sizeof(ParticleEngine) == 0xE430, "Wrong type size");
|
|
1019 static_assert(sizeof(Lightmap) == 0xC1C, "Wrong type size");
|
|
1020 static_assert(sizeof(LightmapBuilder) == 0x3CBC38, "Wrong type size");
|
|
1021 static_assert(sizeof(Vis_SelectionList) == 0x2008, "Wrong type size");
|
|
1022 static_assert(sizeof(Vis) == 0x20D0, "Wrong type size");
|
|
1023 static_assert(sizeof(PlayerBuffAnim) == 0x10, "Wrong type size");
|
|
1024 static_assert(sizeof(ProjectileAnim) == 0x1C, "Wrong type size");
|
|
1025 static_assert(sizeof(stru6) == 0x5F8, "Wrong type size");
|
|
1026 static_assert(sizeof(IndoorCameraD3D_Vec3) == 0x10, "Wrong type size");
|
|
1027 static_assert(sizeof(IndoorCameraD3D_Vec4) == 0x18, "Wrong type size"); //should be 14 (10 vec3 + 4 vdtor) but 18 coz of his +4 from own vdtor, but it is odd since vdtor already present from vec3
|
|
1028 //static_assert(sizeof(IndoorCameraD3D) == 0x1A1384, "Wrong type size");
|
|
1029 static_assert(sizeof(StationaryLight) == 0xC, "Wrong type size");
|
|
1030 static_assert(sizeof(LightsStack_StationaryLight_) == 0x12C8, "Wrong type size");
|
|
1031 static_assert(sizeof(MobileLight) == 0x12, "Wrong type size");
|
|
1032 static_assert(sizeof(LightsStack_MobileLight_) == 0x1C28, "Wrong type size");
|
|
1033 static_assert(sizeof(Engine) == 0xE78, "Wrong type size");
|
|
1034 static_assert(sizeof(stru141_actor_collision_object) == 0xA8, "Wrong type size");
|
|
1035 static_assert(sizeof(ActionQueue) == 0x7C, "Wrong type size");
|
|
1036 static_assert(sizeof(NPCData) == 0x4C, "Wrong type size");
|
|
1037 static_assert(sizeof(NPCStats) == 0x17FFC, "Wrong type size");
|
|
1038 static_assert(sizeof(BspRenderer) == 0x53740, "Wrong type size");
|
|
1039 static_assert(sizeof(PaletteManager) == 0x267AF0, "Wrong type size");
|
|
1040 static_assert(sizeof(ViewingParams) == 0x26C, "Wrong type size");
|
|
1041 //static_assert(sizeof(IndoorCamera) == 0x50, "Wrong type size");
|
|
1042 static_assert(sizeof(Bloodsplat) == 0x28, "Wrong type size");
|
|
1043 static_assert(sizeof(BloodsplatContainer) == 0xA0C, "Wrong type size");
|
|
1044 static_assert(sizeof(TrailParticle) == 0x18, "Wrong type size");
|
|
1045 static_assert(sizeof(EventIndex) == 0xC, "Wrong type size");
|
|
1046 static_assert(sizeof(_2devent) == 0x34, "Wrong type size");
|
|
1047 static_assert(sizeof(MapsLongTimer) == 0x20, "Wrong type size");
|
|
1048 static_assert(sizeof(SavegameHeader) == 0x64, "Wrong type size");
|
|
1049 static_assert(sizeof(SavegameList) == 0x3138, "Wrong type size");
|
|
1050 static_assert(sizeof(StorylineText) == 0x160, "Wrong type size");
|
|
1051 static_assert(sizeof(FactionTable) == 0x1EF1, "Wrong type size");
|
|
1052 static_assert(sizeof(Decal) == 0xC20, "Wrong type size");
|
|
1053 static_assert(sizeof(DecalBuilder) == 0x30C038, "Wrong type size");
|
|
1054 static_assert(sizeof(MonsterInfo) == 0x58, "Wrong type size");
|
|
1055 static_assert(sizeof(MonsterStats) == 0x5BA0, "Wrong type size");
|
|
1056 static_assert(sizeof(RenderD3D) == 0x148, "Wrong type size");
|
|
1057 // static_assert(sizeof(Render) == 0x129844, "Wrong type size");
|
|
1058 static_assert(sizeof(Player) == 0x1B3C, "Wrong type size");
|
|
1059 static_assert(sizeof(PartyTimeStruct) == 0x678, "Wrong type size");
|
|
1060 static_assert(sizeof(Party) == 0x16238, "Wrong type size");
|
|
1061 static_assert(sizeof(GUIButton) == 0xBC, "Wrong type size");
|
|
1062 static_assert(sizeof(GUIWindow) == 0x54, "Wrong type size");
|
|
1063 //static_assert(sizeof(GUIProgressBar) == 0x1B8, "Wrong type size");
|
|
1064 static_assert(sizeof(GUIFont) == 0x1020, "Wrong type size");
|
|
1065 // static_assert(sizeof(stru262_TurnBased) == 0x40, "Wrong type size");
|
|
1066 //static_assert(sizeof(ArcomageGame) == 0xFB, "Wrong type size");
|
|
1067 static_assert(sizeof(CastSpellInfo) == 0x14, "Wrong type size");
|
|
1068 static_assert(sizeof(ArcomageCard) == 0x6C, "Wrong type size");
|
|
1069 static_assert(sizeof(stru320) == 0x3FC, "Wrong type size");
|
|
1070 static_assert(sizeof(TravelInfo) == 0x20, "Wrong type size");
|
|
1071 static_assert(sizeof(stru336) == 0x798, "Wrong type size");
|
|
1072 static_assert(sizeof(Vec3_short_) == 6, "Wrong type size");
|
|
1073 static_assert(sizeof(BLVFace) == 96, "Wrong type size");
|
|
1074 static_assert(sizeof(BLVFaceExtra) == 36, "Wrong type size");
|
|
1075 static_assert(sizeof(BLVSector) == 116, "Wrong type size");
|
|
1076 static_assert(sizeof(LevelDecoration) == 32, "Wrong type size");
|
|
1077 static_assert(sizeof(BLVLightMM7) == 16, "Wrong type size");
|
|
1078 static_assert(sizeof(BSPNode) == 8, "Wrong type size");
|
|
1079 static_assert(sizeof(SpawnPointMM7) == 24, "Wrong type size");
|
|
1080 static_assert(sizeof(DDM_DLV_Header) == 40, "Wrong type size");
|
|
1081 static_assert(sizeof(Actor) == 836, "Wrong type size");
|
|
1082 static_assert(sizeof(SpriteObject) == 112, "Wrong type size");
|
|
1083 static_assert(sizeof(Chest) == 5324, "Wrong type size");
|
|
1084 static_assert(sizeof(stru123) == 0xC8, "Wrong type size");
|
|
1085 static_assert(sizeof(BLVMapOutline) == 12, "Wrong type size");
|
|
1086 static_assert(sizeof(LODSprite) == 0x28, "Wrong type size");
|
|
1087 }
|
|
1088
|
|
1089
|
|
1090 //----- (004647AB) --------------------------------------------------------
|
|
1091 void FinalInitialization()
|
|
1092 {
|
|
1093 pViewport->SetScreen(viewparams->uSomeX, viewparams->uSomeY, viewparams->uSomeZ, viewparams->uSomeW);
|
|
1094 pViewport->SetFOV(flt_6BE3A0 * 65536.0f);
|
|
1095
|
|
1096 //pIndoorCamera = new IndoorCamera;
|
|
1097 //pIndoorCamera->Initialize(65, viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X + 1,
|
|
1098 // viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y + 1);
|
|
1099
|
|
1100 InitializeTurnBasedAnimations(&stru_50C198);
|
|
1101 pBitmaps_LOD->_inlined_sub1();
|
|
1102 pSprites_LOD->_inlined_sub1();
|
|
1103 pIcons_LOD->_inlined_sub1();
|
|
1104 }
|
|
1105 // 6BE3A0: using guessed type float flt_6BE3A0;
|
|
1106
|
|
1107
|
|
1108
|
|
1109 //----- (00464E17) --------------------------------------------------------
|
|
1110 bool __fastcall CheckMM7CD(char c)
|
|
1111 {
|
|
1112 char DstBuf[256] = { 0 };
|
|
1113 char strCommand[256] = { 0 }; // [sp+10Ch] [bp-118h]@1
|
|
1114 char Filename[20] = { 0 }; // [sp+20Ch] [bp-18h]@1
|
|
1115
|
|
1116 wchar_t pMagicPath[1024];
|
|
1117 swprintf(pMagicPath, wcslen(L"%C:\\anims\\magic7.vid"), L"%C:\\anims\\magic7.vid", c);
|
|
1118 if (GetFileAttributesW(pMagicPath) == -1)
|
|
1119 return false;
|
|
1120
|
|
1121 //Open CD audio
|
|
1122 wsprintfA(strCommand, "open %c: type cdaudio alias CD", c);
|
|
1123 if (!mciSendStringA(strCommand, DstBuf, 255, 0))
|
|
1124 {
|
|
1125 wsprintfA(strCommand, "info CD UPC wait");
|
|
1126 mciSendStringA(strCommand, DstBuf, 255, 0);
|
|
1127 wsprintfA(strCommand, "close CD");
|
|
1128 mciSendStringA(strCommand, DstBuf, 255, 0);
|
|
1129 }
|
|
1130
|
|
1131 memcpy(Filename, "X:\\anims\\magic7.vid", sizeof(Filename));
|
|
1132 *Filename = c;
|
|
1133
|
|
1134 FILE* f = fopen(Filename, "rb");
|
|
1135 if (!f)
|
|
1136 return false;
|
|
1137
|
|
1138 if (!fseek(f, 0, SEEK_END))
|
|
1139 {
|
|
1140 if (!fseek(f, -100, SEEK_CUR))
|
|
1141 fread(DstBuf, 1, 0x64u, f);
|
|
1142
|
|
1143 fclose(f);
|
|
1144 return true;
|
|
1145 }
|
|
1146 fclose(f);
|
|
1147 return false;
|
|
1148 }
|
|
1149
|
|
1150 //----- (00464F1B) --------------------------------------------------------
|
|
1151 signed int __stdcall InsertMM7CDDialogFunc(HWND hDlg, int a2, __int16 a3, int a4)
|
|
1152 {
|
|
1153 char v4; // zf@3
|
|
1154 int v6; // eax@10
|
|
1155 int v7; // eax@11
|
|
1156 int v8; // eax@12
|
|
1157 int v9; // eax@13
|
|
1158 BOOL(__stdcall *v10)(HWND, int, LPCSTR); // edi@15
|
|
1159 const CHAR *v11; // [sp-Ch] [bp-Ch]@15
|
|
1160 INT_PTR v12; // [sp-4h] [bp-4h]@5
|
|
1161
|
|
1162 if (a2 == 272)
|
|
1163 {
|
|
1164 hInsertCDWindow = hDlg;
|
|
1165 v6 = (GetUserDefaultLangID() & 0x3FF) - 7;
|
|
1166 if (v6)
|
|
1167 {
|
|
1168 v7 = v6 - 3;
|
|
1169 if (v7)
|
|
1170 {
|
|
1171 v8 = v7 - 2;
|
|
1172 if (v8)
|
|
1173 {
|
|
1174 v9 = v8 - 4;
|
|
1175 if (v9)
|
|
1176 {
|
|
1177 if (v9 != 5)
|
|
1178 return 0;
|
|
1179 SetWindowTextA(hDlg, "Wloz CD-ROM numer 2");
|
|
1180 v10 = SetDlgItemTextA;
|
|
1181 SetDlgItemTextA(hDlg, 1010, "Wloz CD-ROM numer 2 Might and Magic® VII.");
|
|
1182 v11 = "Odwolaj";
|
|
1183 }
|
|
1184 else
|
|
1185 {
|
|
1186 SetWindowTextA(hDlg, "Inserire il secondo CD");
|
|
1187 v10 = SetDlgItemTextA;
|
|
1188 SetDlgItemTextA(hDlg, 1010, "Inserire il secondo CD di Might and Magic® VII.");
|
|
1189 v11 = "Annulla";
|
|
1190 }
|
|
1191 }
|
|
1192 else
|
|
1193 {
|
|
1194 SetWindowTextA(hDlg, "Insérez le CD 2");
|
|
1195 v10 = SetDlgItemTextA;
|
|
1196 SetDlgItemTextA(hDlg, 1010, "Insérez Might & Magic® VII CD 2.");
|
|
1197 v11 = "Supprimer";
|
|
1198 }
|
|
1199 }
|
|
1200 else
|
|
1201 {
|
|
1202 SetWindowTextA(hDlg, "Por favor, inserte disco 2");
|
|
1203 v10 = SetDlgItemTextA;
|
|
1204 SetDlgItemTextA(hDlg, 1010, "Por favor, inserte disco 2 de Might & Magic® VII.");
|
|
1205 v11 = "Cancelar";
|
|
1206 }
|
|
1207 }
|
|
1208 else
|
|
1209 {
|
|
1210 SetWindowTextA(hDlg, "Bitte CD 2 einlegen");
|
|
1211 v10 = SetDlgItemTextA;
|
|
1212 SetDlgItemTextA(hDlg, 1010, "Bitte CD 2 von Might and Magic® VII einlegen.");
|
|
1213 v11 = "Abbrechen";
|
|
1214 }
|
|
1215 v10(hDlg, 2, v11);
|
|
1216 return 0;
|
|
1217 }
|
|
1218 if (a2 == 273)
|
|
1219 {
|
|
1220 if (a3 == 2)
|
|
1221 {
|
|
1222 v12 = 0;
|
|
1223 EndDialog(hDlg, v12);
|
|
1224 return 1;
|
|
1225 }
|
|
1226 v4 = a3 == 1;
|
|
1227 }
|
|
1228 else
|
|
1229 {
|
|
1230 v4 = a2 == 1025;
|
|
1231 }
|
|
1232 if (v4)
|
|
1233 {
|
|
1234 v12 = 1;
|
|
1235 EndDialog(hDlg, v12);
|
|
1236 return 1;
|
|
1237 }
|
|
1238 return 0;
|
|
1239 }
|
|
1240
|
|
1241 //----- (00465061) --------------------------------------------------------
|
|
1242 bool __fastcall FindMM7CD(HWND hWnd, char *pCDDrive)
|
|
1243 {
|
|
1244 char drive[4] = { 'X', ':', '\\', 0 };
|
|
1245
|
|
1246 bool bGotCDFromRegistry = false;
|
|
1247
|
|
1248 HKEY hSoftware = nullptr,
|
|
1249 hNWC = nullptr,
|
|
1250 hMM7 = nullptr,
|
|
1251 hVersion = nullptr;
|
|
1252 if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ | KEY_WOW64_32KEY, &hSoftware))
|
|
1253 {
|
|
1254 if (!RegOpenKeyExA(hSoftware, "New World Computing", 0, KEY_READ | KEY_WOW64_32KEY, &hNWC))
|
|
1255 {
|
|
1256 if (!RegOpenKeyExA(hNWC, "Might and Magic VII", 0, KEY_READ | KEY_WOW64_32KEY, &hMM7))
|
|
1257 {
|
|
1258 if (!RegOpenKeyExA(hMM7, "1.0", 0, KEY_READ | KEY_WOW64_32KEY, &hVersion))
|
|
1259 {
|
|
1260 DWORD cbData = 3;
|
|
1261 if (!RegQueryValueExA(hVersion, "CDDrive", 0, 0, (BYTE *)drive, &cbData))
|
|
1262 bGotCDFromRegistry = true;
|
|
1263 }
|
|
1264 RegCloseKey(hVersion);
|
|
1265 }
|
|
1266 RegCloseKey(hMM7);
|
|
1267 }
|
|
1268 RegCloseKey(hNWC);
|
|
1269 }
|
|
1270 RegCloseKey(hSoftware);
|
|
1271
|
|
1272 if (bGotCDFromRegistry)
|
|
1273 if (CheckMM7CD(*drive))
|
|
1274 {
|
|
1275 cMM7GameCDDriveLetter = *drive;
|
|
1276 return true;
|
|
1277 }
|
|
1278
|
|
1279 while (true)
|
|
1280 {
|
|
1281 for (uint i = 0; i < 26; ++i)
|
|
1282 {
|
|
1283 drive[0] = 'A' + i;
|
|
1284
|
|
1285 if (GetDriveTypeA(drive) == DRIVE_CDROM)
|
|
1286 if (CheckMM7CD(*drive))
|
|
1287 {
|
|
1288 cMM7GameCDDriveLetter = *drive;
|
|
1289 WriteWindowsRegistryString("CDDrive", drive);
|
|
1290 return true;
|
|
1291 }
|
|
1292 }
|
|
1293
|
|
1294 if (DialogBoxParamA(GetModuleHandleW(nullptr), "InsertCD", hWnd, (DLGPROC)InsertMM7CDDialogFunc, 0))
|
|
1295 continue;
|
|
1296 return false;
|
|
1297 }
|
|
1298 }
|
|
1299
|
|
1300 //----- (004651F4) --------------------------------------------------------
|
|
1301 bool MM7_Initialize(int game_width, int game_height)
|
|
1302 {
|
|
1303 wchar_t pCurrentDir[1024];
|
|
1304 _wgetcwd(pCurrentDir, 1024);
|
|
1305
|
|
1306 wchar_t pMM6IniFile[1024];
|
|
1307 wsprintfW(pMM6IniFile, L"%s\\mm6.ini", pCurrentDir);
|
|
1308
|
|
1309 bCanLoadFromCD = GetPrivateProfileIntW(L"settings", L"use_cd", 1, pMM6IniFile);
|
|
1310 if (bNoCD)
|
|
1311 bCanLoadFromCD = false;
|
|
1312 if (bCanLoadFromCD)
|
|
1313 {
|
|
1314 Log::Warning(L"Checking for CD...");
|
|
1315 if (!FindMM7CD(nullptr, &cMM7GameCDDriveLetter))
|
|
1316 return false;
|
|
1317 Log::Warning(L"...done.");
|
|
1318 }
|
|
1319
|
|
1320
|
|
1321 srand(GetTickCount());
|
|
1322
|
|
1323 pEventTimer = Timer::Create();
|
|
1324 pEventTimer->Initialize();
|
|
1325 window = OSWindow::Create(L"Might and Magic® Trilogy", game_width, game_height);//Create game window
|
|
1326
|
|
1327 bool use_d3d11 = false;
|
|
1328 if (use_d3d11)
|
|
1329 pRenderer = RenderD3D11::Create();
|
|
1330 else
|
|
1331 pRenderer = Render::Create();//Create DirectX
|
|
1332 if (!pRenderer)
|
|
1333 {
|
|
1334 Log::Warning(L"Render creation failed");
|
|
1335 return false;
|
|
1336 }
|
|
1337 else
|
|
1338 {
|
|
1339 //bool bWindowMode = ReadWindowsRegistryInt("startinwindow", false);
|
|
1340 //uint uDefaultDevice = ReadWindowsRegistryInt("D3D Device", 1);
|
|
1341
|
|
1342 if (!pRenderer->Initialize(window/*, bColoredLights, uLevelOfDetail, bTinting*/))
|
|
1343 {
|
|
1344 Log::Warning(L"Render failed to initialize");
|
|
1345 return false;
|
|
1346 }
|
|
1347 }
|
|
1348
|
|
1349 game_starting_year = 1168;
|
|
1350
|
|
1351 pParty = new Party;
|
|
1352 memset(&pParty->pHirelings, 0, sizeof(pParty->pHirelings));
|
|
1353 pParty->uWalkSpeed = GetPrivateProfileIntW(L"debug", L"walkspeed", 384, pMM6IniFile);
|
|
1354 pParty->uDefaultEyelevel = GetPrivateProfileIntW(L"party", L"eyelevel", 160, pMM6IniFile);
|
|
1355 pParty->sEyelevel = pParty->uDefaultEyelevel;
|
|
1356 pParty->uDefaultPartyHeight = GetPrivateProfileIntW(L"party", L"height", 192, pMM6IniFile);
|
|
1357 pParty->uPartyHeight = pParty->uDefaultPartyHeight;
|
|
1358
|
|
1359 MM6_Initialize(pMM6IniFile);
|
|
1360
|
|
1361 pKeyActionMap = new KeyboardActionMapping;
|
|
1362
|
|
1363 OnTimer(1);
|
|
1364 GameUI_StatusBar_UpdateTimedString(1);
|
|
1365 pEngine = Engine::Create();
|
|
1366 pMouse = pEngine->pMouseInstance;
|
|
1367
|
|
1368
|
|
1369 pIcons_LOD = new LODFile_IconsBitmaps;
|
|
1370 if (!pIcons_LOD->Load("data\\icons.lod", "icons"))
|
|
1371 {
|
|
1372 MessageBoxW(nullptr, L"Some files are missing\n\nPlease Reinstall.",
|
|
1373 L"Files Missing", MB_ICONEXCLAMATION);
|
|
1374 return false;
|
|
1375 }
|
|
1376 pIcons_LOD->dword_011BA4 = 0;
|
|
1377
|
|
1378 pEvents_LOD = new LODFile_IconsBitmaps;
|
|
1379 if (!pEvents_LOD->Load("data\\events.lod", "icons"))
|
|
1380 {
|
|
1381 MessageBoxW(nullptr, L"Some files are missing\n\nPlease Reinstall.",
|
|
1382 L"Files Missing", MB_ICONEXCLAMATION);
|
|
1383 return false;
|
|
1384 }
|
|
1385
|
|
1386 InitializeGameText();
|
|
1387
|
|
1388 pBitmaps_LOD = new LODFile_IconsBitmaps;
|
|
1389 if (!pBitmaps_LOD->Load("data\\bitmaps.lod", "bitmaps"))
|
|
1390 {
|
|
1391 MessageBoxA(nullptr, pGlobalTXT_LocalizationStrings[63],
|
|
1392 pGlobalTXT_LocalizationStrings[184], MB_ICONEXCLAMATION);
|
|
1393 return false;
|
|
1394 }
|
|
1395
|
|
1396 pSprites_LOD = new LODFile_Sprites;
|
|
1397 if (!pSprites_LOD->LoadSprites("data\\sprites.lod"))
|
|
1398 {
|
|
1399 MessageBoxA(nullptr,
|
|
1400 pGlobalTXT_LocalizationStrings[63],
|
|
1401 pGlobalTXT_LocalizationStrings[184], MB_ICONEXCLAMATION);
|
|
1402 return false;
|
|
1403 }
|
|
1404
|
|
1405
|
|
1406 #if 0
|
|
1407 if (_access("../MM_VI/data/icons.lod", 0) == 0)
|
|
1408 {
|
|
1409 pIcons_LOD_mm6 = new LODFile_IconsBitmaps;
|
|
1410 if (!pIcons_LOD_mm6->Load("../MM_VI/data/icons.lod", "icons"))
|
|
1411 {
|
|
1412 delete pIcons_LOD_mm6;
|
|
1413 pIcons_LOD_mm6 = nullptr;
|
|
1414 Log::Warning(L"Unable to load mm6:icons.lod");
|
|
1415 }
|
|
1416 }
|
|
1417 else
|
|
1418 Log::Warning(L"Unable to find mm6:icons.lod");
|
|
1419
|
|
1420 if (_access("../MM_VI/data/bitmaps.lod", 0) == 0)
|
|
1421 {
|
|
1422 pBitmaps_LOD_mm6 = new LODFile_IconsBitmaps;
|
|
1423 if (!pBitmaps_LOD_mm6->Load("../MM_VI/data/bitmaps.lod", "bitmaps"))
|
|
1424 {
|
|
1425 delete pBitmaps_LOD_mm6;
|
|
1426 pBitmaps_LOD_mm6 = nullptr;
|
|
1427 Log::Warning(L"Unable to load mm6:bitmaps.lod");
|
|
1428 }
|
|
1429 }
|
|
1430 else
|
|
1431 Log::Warning(L"Unable to find mm6:bitmaps.lod");
|
|
1432
|
|
1433 auto mm6_sprite_container_name = bUseLoResSprites ? "../MM_VI/data/spriteLO.lod"
|
|
1434 : "../MM_VI/data/sprites.lod";
|
|
1435 if (_access(mm6_sprite_container_name, 0) == 0)
|
|
1436 {
|
|
1437 pSprites_LOD_mm6 = new LODFile_Sprites;
|
|
1438 if (!pSprites_LOD_mm6->LoadSprites(mm6_sprite_container_name))
|
|
1439 {
|
|
1440 delete pSprites_LOD_mm6;
|
|
1441 pSprites_LOD_mm6 = nullptr;
|
|
1442 Log::Warning(L"Unable to load mm6:sprites.lod");
|
|
1443 }
|
|
1444 }
|
|
1445 else
|
|
1446 Log::Warning(L"Unable to find mm6:sprites.lod");
|
|
1447
|
|
1448
|
|
1449 if (_access("../mm8/data/icons.lod", 0) == 0)
|
|
1450 {
|
|
1451 pIcons_LOD_mm8 = new LODFile_IconsBitmaps;
|
|
1452 if (!pIcons_LOD_mm8->Load("../mm8/data/icons.lod", "icons"))
|
|
1453 {
|
|
1454 delete pIcons_LOD_mm8;
|
|
1455 pIcons_LOD_mm8 = nullptr;
|
|
1456 Log::Warning(L"Unable to load mm8:icons.lod");
|
|
1457 }
|
|
1458 }
|
|
1459 else
|
|
1460 Log::Warning(L"Unable to find mm8:icons.lod");
|
|
1461
|
|
1462
|
|
1463 if (_access("../mm8/data/bitmaps.lod", 0) == 0)
|
|
1464 {
|
|
1465 pBitmaps_LOD_mm8 = new LODFile_IconsBitmaps;
|
|
1466 if (!pBitmaps_LOD_mm8->Load("../mm8/data/bitmaps.lod", "bitmaps"))
|
|
1467 {
|
|
1468 delete pBitmaps_LOD_mm8;
|
|
1469 pBitmaps_LOD_mm8 = nullptr;
|
|
1470 Log::Warning(L"Unable to load mm8:bitmaps.lod");
|
|
1471 }
|
|
1472 }
|
|
1473 else
|
|
1474 Log::Warning(L"Unable to find mm8:bitmaps.lod");
|
|
1475
|
|
1476
|
|
1477 if (_access("../mm8/data/sprites.lod", 0) == 0)
|
|
1478 {
|
|
1479 pSprites_LOD_mm8 = new LODFile_Sprites;
|
|
1480 if (!pSprites_LOD_mm8->LoadSprites("../mm8/data/sprites.lod"))
|
|
1481 {
|
|
1482 delete pSprites_LOD_mm8;
|
|
1483 pSprites_LOD_mm8 = nullptr;
|
|
1484 Log::Warning(L"Unable to load mm8:sprites.lod");
|
|
1485 }
|
|
1486 }
|
|
1487 else
|
|
1488 Log::Warning(L"Unable to find mm8:sprites.lod");
|
|
1489 #endif
|
|
1490
|
|
1491 {
|
|
1492 void *sft_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dsft.bin", 1) : nullptr,
|
|
1493 *sft_mm8 = nullptr;
|
|
1494 void *sft_mm7 = pEvents_LOD->LoadRaw("dsft.bin", 1);
|
|
1495 pSpriteFrameTable = new SpriteFrameTable;
|
|
1496 pSpriteFrameTable->FromFile(sft_mm6, sft_mm7, sft_mm8);
|
|
1497 free(sft_mm6);
|
|
1498 free(sft_mm7);
|
|
1499 free(sft_mm8);
|
|
1500
|
|
1501 void *tft_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dtft.bin", 1) : nullptr,
|
|
1502 *tft_mm8 = nullptr;
|
|
1503 void *tft_mm7 = pEvents_LOD->LoadRaw("dtft.bin", 1);
|
|
1504 pTextureFrameTable = new TextureFrameTable;
|
|
1505 pTextureFrameTable->FromFile(tft_mm6, tft_mm7, tft_mm8);
|
|
1506 free(tft_mm6);
|
|
1507 free(tft_mm7);
|
|
1508 free(tft_mm8);
|
|
1509
|
|
1510 void *tiles_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dtile.bin", 1) : nullptr,
|
|
1511 *tiles_mm8 = nullptr;
|
|
1512 void *tiles_mm7 = pEvents_LOD->LoadRaw("dtile.bin", 1);
|
|
1513 pTileTable = new TileTable;
|
|
1514 pTileTable->FromFile(tiles_mm6, tiles_mm7, tiles_mm8);
|
|
1515 free(tiles_mm6);
|
|
1516 free(tiles_mm7);
|
|
1517 free(tiles_mm8);
|
|
1518
|
|
1519 void *pft_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dpft.bin", 1) : nullptr,
|
|
1520 *pft_mm8 = nullptr;
|
|
1521 void *pft_mm7 = pEvents_LOD->LoadRaw("dpft.bin", 1);
|
|
1522 pPlayerFrameTable = new PlayerFrameTable;
|
|
1523 pPlayerFrameTable->FromFile(pft_mm6, pft_mm7, pft_mm8);
|
|
1524 free(pft_mm6);
|
|
1525 free(pft_mm7);
|
|
1526 free(pft_mm8);
|
|
1527
|
|
1528 void *ift_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dift.bin", 1) : nullptr,
|
|
1529 *ift_mm8 = nullptr;
|
|
1530 void *ift_mm7 = pEvents_LOD->LoadRaw("dift.bin", 1);
|
|
1531 pIconsFrameTable = new IconFrameTable;
|
|
1532 pIconsFrameTable->FromFile(ift_mm6, ift_mm7, ift_mm8);
|
|
1533 free(ift_mm6);
|
|
1534 free(ift_mm7);
|
|
1535 free(ift_mm8);
|
|
1536
|
|
1537 void *decs_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("ddeclist.bin", 1) : nullptr,
|
|
1538 *decs_mm8 = nullptr;
|
|
1539 void *decs_mm7 = pEvents_LOD->LoadRaw("ddeclist.bin", 1);
|
|
1540 pDecorationList = new DecorationList;
|
|
1541 pDecorationList->FromFile(decs_mm6, decs_mm7, decs_mm8);
|
|
1542 free(decs_mm6);
|
|
1543 free(decs_mm7);
|
|
1544 free(decs_mm8);
|
|
1545
|
|
1546 void *objs_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dobjlist.bin", 1) : nullptr,
|
|
1547 *objs_mm8 = nullptr;
|
|
1548 void *objs_mm7 = pEvents_LOD->LoadRaw("dobjlist.bin", 1);
|
|
1549 pObjectList = new ObjectList;
|
|
1550 pObjectList->FromFile(objs_mm6, objs_mm7, objs_mm8);
|
|
1551 free(objs_mm6);
|
|
1552 free(objs_mm7);
|
|
1553 free(objs_mm8);
|
|
1554
|
|
1555 void *mons_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dmonlist.bin", 1) : nullptr,
|
|
1556 *mons_mm8 = nullptr;
|
|
1557 void *mons_mm7 = pEvents_LOD->LoadRaw("dmonlist.bin", 1);
|
|
1558 pMonsterList = new MonsterList;
|
|
1559 pMonsterList->FromFile(mons_mm6, mons_mm7, mons_mm8);
|
|
1560 free(mons_mm6);
|
|
1561 free(mons_mm7);
|
|
1562 free(mons_mm8);
|
|
1563
|
|
1564 void *chests_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dchest.bin", 1) : nullptr,
|
|
1565 *chests_mm8 = nullptr;
|
|
1566 void *chests_mm7 = pEvents_LOD->LoadRaw("dchest.bin", 1);
|
|
1567 pChestList = new ChestList;
|
|
1568 pChestList->FromFile(chests_mm6, chests_mm7, chests_mm8);
|
|
1569 free(chests_mm6);
|
|
1570 free(chests_mm7);
|
|
1571 free(chests_mm8);
|
|
1572
|
|
1573 void *overlays_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("doverlay.bin", 1) : nullptr,
|
|
1574 *overlays_mm8 = nullptr;
|
|
1575 void *overlays_mm7 = pEvents_LOD->LoadRaw("doverlay.bin", 1);
|
|
1576 pOverlayList = new OverlayList;
|
|
1577 pOverlayList->FromFile(overlays_mm6, overlays_mm7, overlays_mm8);
|
|
1578 free(overlays_mm6);
|
|
1579 free(overlays_mm7);
|
|
1580 free(overlays_mm8);
|
|
1581
|
|
1582 void *sounds_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dsounds.bin", 1) : nullptr,
|
|
1583 *sounds_mm8 = nullptr;
|
|
1584 void *sounds_mm7 = pEvents_LOD->LoadRaw("dsounds.bin", 1);
|
|
1585 pSoundList = new SoundList;
|
|
1586 pSoundList->FromFile(sounds_mm6, sounds_mm7, sounds_mm8);
|
|
1587 free(sounds_mm6);
|
|
1588 free(sounds_mm7);
|
|
1589 free(sounds_mm8);
|
|
1590 }
|
|
1591
|
|
1592
|
|
1593
|
|
1594
|
|
1595 if (dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_RUN_IN_WIDOW)
|
|
1596 {
|
|
1597 //window->SetWindowedMode(game_width, game_height);
|
|
1598 pRenderer->SwitchToWindow();
|
|
1599 }
|
|
1600 else
|
|
1601 {
|
|
1602 __debugbreak(); // Nomad
|
|
1603 window->SetFullscreenMode();
|
|
1604 pRenderer->InitializeFullscreen();
|
|
1605 }
|
|
1606
|
|
1607 uSoundVolumeMultiplier = min(9, ReadWindowsRegistryInt("soundflag", 9));
|
|
1608 uMusicVolimeMultiplier = min(9, ReadWindowsRegistryInt("musicflag", 9));
|
|
1609 uVoicesVolumeMultiplier = min(9, ReadWindowsRegistryInt("CharVoices", 9));
|
|
1610 bShowDamage = ReadWindowsRegistryInt("ShowDamage", 1) != 0;
|
|
1611
|
|
1612 uGammaPos = min(4, ReadWindowsRegistryInt("GammaPos", 4));
|
|
1613 //pEngine->pGammaController->Initialize(uGammaPos * 0.1 + 0.6);
|
|
1614
|
|
1615 if (ReadWindowsRegistryInt("Bloodsplats", 1))
|
|
1616 pEngine->uFlags2 |= GAME_FLAGS_2_DRAW_BLOODSPLATS;
|
|
1617 else
|
|
1618 pEngine->uFlags2 &= ~GAME_FLAGS_2_DRAW_BLOODSPLATS;
|
|
1619
|
|
1620 uTurnSpeed = ReadWindowsRegistryInt("TurnDelta", 3);
|
|
1621
|
|
1622 if (!bNoSound)
|
|
1623 pAudioPlayer->Initialize();
|
|
1624
|
|
1625 pMediaPlayer = new Media::MPlayer();
|
|
1626 pMediaPlayer->Initialize(window);
|
|
1627
|
|
1628 dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000;
|
|
1629
|
|
1630 switch (uTurnSpeed)
|
|
1631 {
|
|
1632 case 0: // undefined turn option
|
|
1633 __debugbreak(); // really shouldn't use this mode
|
|
1634 uTurnSpeed = 64; //(unsigned int)uCPUSpeed < 199/*MHz*/ ? 128 : 64; // adjust turn speed to estimated fps
|
|
1635 break;
|
|
1636
|
|
1637 case 1: // 16x
|
|
1638 Log::Warning(L"x16 Turn Speed"); // really shouldn't use this mode
|
|
1639 uTurnSpeed = 128;
|
|
1640 break;
|
|
1641
|
|
1642 case 2: // 32x
|
|
1643 Log::Warning(L"x32 Turn Speed"); // really shouldn't use this mode
|
|
1644 uTurnSpeed = 64;
|
|
1645 break;
|
|
1646
|
|
1647 case 3: // smooth
|
|
1648 uTurnSpeed = 0;
|
|
1649 break;
|
|
1650 }
|
|
1651
|
|
1652 return true;
|
|
1653 }
|
|
1654
|
|
1655 //----- (00465D0B) --------------------------------------------------------
|
|
1656 void SecondaryInitialization()
|
|
1657 {
|
|
1658 pMouse->Initialize(window);
|
|
1659
|
|
1660 pItemsTable = new ItemsTable;
|
|
1661 pItemsTable->Initialize();
|
|
1662
|
|
1663 //pBitmaps_LOD->can_load_hardware_sprites = 1;
|
|
1664 //pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
|
|
1665 pBitmaps_LOD->SetupPalettes(5, 6, 5);
|
|
1666 //pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
|
|
1667 pIcons_LOD->SetupPalettes(5, 6, 5);
|
|
1668 //pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
|
|
1669 pPaletteManager->SetColorChannelInfo(5, 6, 5);
|
|
1670
|
|
1671 pPaletteManager->SetMistColor(128, 128, 128);
|
|
1672 pPaletteManager->RecalculateAll();
|
|
1673 //pSprites_LOD->can_load_hardware_sprites = 1;
|
|
1674 pObjectList->InitializeSprites();
|
|
1675 pOverlayList->InitializeSprites();
|
|
1676
|
|
1677 if (!bNoSound)
|
|
1678 pSoundList->Initialize();
|
|
1679
|
|
1680
|
|
1681 for (uint i = 0; i < 4; ++i)
|
|
1682 {
|
|
1683 static const char *pUIAnimNames[4] =
|
|
1684 {
|
|
1685 "glow03", "glow05",
|
|
1686 "torchA", "wizeyeA"
|
|
1687 };
|
|
1688 static unsigned short _4E98D0[4][4] =
|
|
1689 {
|
|
1690 { 479, 0, 329, 0 },
|
|
1691 { 585, 0, 332, 0 },
|
|
1692 { 468, 0, 0, 0 },
|
|
1693 { 606, 0, 0, 0 }
|
|
1694 };
|
|
1695
|
|
1696 pUIAnims[i]->uIconID = pIconsFrameTable->FindIcon(pUIAnimNames[i]);
|
|
1697 pIconsFrameTable->InitializeAnimation(pUIAnims[i]->uIconID);
|
|
1698
|
|
1699 pUIAnims[i]->uAnimLength = 0;
|
|
1700 pUIAnims[i]->uAnimTime = 0;
|
|
1701 pUIAnims[i]->x = _4E98D0[i][0];
|
|
1702 pUIAnims[i]->y = _4E98D0[i][2];
|
|
1703 }
|
|
1704
|
|
1705 for (unsigned int i = 0; i < pObjectList->uNumObjects; ++i)
|
|
1706 {
|
|
1707 pObjectList->pObjects[i].uParticleTrailColor = pObjectList->pObjects[i].uParticleTrailColorB |
|
|
1708 ((unsigned int)pObjectList->pObjects[i].uParticleTrailColorG << 8) |
|
|
1709 ((unsigned int)pObjectList->pObjects[i].uParticleTrailColorR << 16);
|
|
1710 }
|
|
1711
|
|
1712 MainMenuUI_Create();
|
|
1713 pEngine->pStru6Instance->LoadAnimations();
|
|
1714
|
|
1715 for (uint i = 0; i < 7; ++i)
|
|
1716 {
|
|
1717 char container_name[64];
|
|
1718 sprintf(container_name, "HDWTR%03u", i);
|
|
1719 pRenderer->pHDWaterBitmapIDs[i] = pBitmaps_LOD->LoadTexture(container_name);
|
|
1720 }
|
|
1721
|
|
1722 pNPCStats = new NPCStats;
|
|
1723 memset(pNPCStats->pNPCData, 0, 0x94BCu);
|
|
1724 pNPCStats->Initialize();
|
|
1725
|
|
1726 Initialize_GlobalEVT();
|
|
1727 pBitmaps_LOD->_inlined_sub0();
|
|
1728 pSprites_LOD->_inlined_sub0();
|
|
1729 pPaletteManager->LockAll();
|
|
1730
|
|
1731 _mkdir("Saves");
|
|
1732 for (uint i = 0; i < 5; ++i)
|
|
1733 for (uint j = 0; j < 6; ++j)
|
|
1734 {
|
|
1735 sprintf(pTmpBuf.data(), "data\\lloyd%d%d.pcx", i, j);
|
|
1736 remove(pTmpBuf.data());
|
|
1737 }
|
|
1738
|
|
1739 Initialize_GamesLOD_NewLOD();
|
|
1740 _576E2C_current_minimap_zoom = 512;
|
|
1741 dword_576E28 = 9;
|
|
1742 }
|
|
1743
|
|
1744 int max_flight_height = 4000; //maximum altitude
|
|
1745 bool use_MMT = false;
|
|
1746 bool use_music_folder = true;
|
|
1747 bool for_refactoring = false;
|
|
1748
|
|
1749 //----- (00462C94) --------------------------------------------------------
|
|
1750 bool MM_Main(const wchar_t *pCmdLine)
|
|
1751 {
|
|
1752 IntegrityTest();
|
|
1753
|
|
1754 lua = new LuaVM;
|
|
1755 lua->Initialize();
|
|
1756
|
|
1757 bool bNoMargareth = false;
|
|
1758 if (pCmdLine && *pCmdLine)
|
|
1759 {
|
|
1760 //if (wcsstr(pCmdLine, L"-usedefs"))
|
|
1761 // bDebugResouces = 1;
|
|
1762 if (wcsstr(pCmdLine, L"-window"))
|
|
1763 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_RUN_IN_WIDOW;
|
|
1764
|
|
1765 if (wcsstr(pCmdLine, L"-nointro"))
|
|
1766 bNoIntro = true;//dword_6BE364_game_settings_1 |= 4;
|
|
1767 if (wcsstr(pCmdLine, L"-nologo"))
|
|
1768 bNoLogo = true;//dword_6BE364_game_settings_1 |= 8;
|
|
1769 if (wcsstr(pCmdLine, L"-nosound"))
|
|
1770 bNoSound = true; //dword_6BE364_game_settings_1 |= 0x10;
|
|
1771
|
|
1772 bWalkSound = ReadWindowsRegistryInt("WalkSound", 1) != 0;
|
|
1773 if (wcsstr(pCmdLine, L"-nowalksound"))
|
|
1774 bWalkSound = false;//dword_6BE364_game_settings_1 |= 0x20;
|
|
1775 if (wcsstr(pCmdLine, L"-novideo"))
|
|
1776 {
|
|
1777 dword_6BE364_game_settings_1 |= GAME_SETTINGS_NO_HOUSE_ANIM;
|
|
1778 bNoVideo = true;
|
|
1779 }
|
|
1780 if (wcsstr(pCmdLine, L"-nocd"))
|
|
1781 bNoCD = true;
|
|
1782 if (wcsstr(pCmdLine, L"-nomarg"))
|
|
1783 bNoMargareth = true;
|
|
1784 }
|
|
1785
|
|
1786 //_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF );//Ritor1: for memory test
|
|
1787
|
|
1788 if (!MM7_Initialize(640, 480))
|
|
1789 {
|
|
1790 Log::Warning(L"MM init: failed");
|
|
1791 pEngine->Deinitialize();
|
|
1792 return 1;
|
|
1793 }
|
|
1794
|
|
1795 pEventTimer->Pause();
|
|
1796
|
|
1797 SetUserInterface(PartyAlignment_Neutral, false);
|
|
1798
|
|
1799 ShowLogoVideo();
|
|
1800 //ShowIntroVideo_and_LoadingScreen();
|
|
1801 WriteWindowsRegistryInt("Ran once", 1);
|
|
1802 dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000;
|
|
1803 SecondaryInitialization();
|
|
1804 //pRenderer->SetRasterClipRect(0, 0, window->GetWidth() - 1, window->GetHeight() - 1);
|
|
1805 FinalInitialization();
|
|
1806
|
|
1807 //Ritor1: include
|
|
1808 if (use_MMT)
|
|
1809 MMT_MainMenu_Loop();
|
|
1810
|
|
1811 Log::Warning(L"MM: entering main loop");
|
|
1812 while (1)
|
|
1813 {
|
|
1814 //MainMenuWindow* main_menu_window = MainMenuWindow::Create();
|
|
1815 //window->AddControl(main_menu_window);
|
|
1816 MainMenu_Loop();
|
|
1817 uGameState = GAME_STATE_PLAYING;
|
|
1818 while (1)
|
|
1819 {
|
|
1820 if (uGameState == GAME_FINISHED || GetCurrentMenuID() == MENU_EXIT_GAME)
|
|
1821 {
|
|
1822 pEngine->Deinitialize();
|
|
1823 return true;
|
|
1824 }
|
|
1825
|
|
1826 if (GetCurrentMenuID() == MENU_NEWGAME)
|
|
1827 {
|
|
1828 if (use_music_folder)
|
|
1829 alSourceStop(mSourceID);
|
|
1830 else
|
|
1831 {
|
|
1832 if (pAudioPlayer->hAILRedbook)
|
|
1833 AIL_redbook_stop(pAudioPlayer->hAILRedbook);
|
|
1834 }
|
|
1835 pParty->Reset();
|
|
1836 pOtherOverlayList->Reset();
|
|
1837 strcpy(pCurrentMapName, pStartingMapName);
|
|
1838 pParty->CreateDefaultParty(0);
|
|
1839 PlayerCreationUI_Initialize();
|
|
1840 if (PlayerCreationUI_Loop())
|
|
1841 {
|
|
1842 DeleteCCharFont();
|
|
1843 break;
|
|
1844 }
|
|
1845 DeleteCCharFont();
|
|
1846 bFlashQuestBook = true;
|
|
1847 pMediaPlayer->PlayFullscreenMovie(MOVIE_Emerald, true);
|
|
1848 SaveNewGame();
|
|
1849 if (bNoMargareth)
|
|
1850 _449B7E_toggle_bit(pParty->_quest_bits, PARTY_QUEST_EMERALD_MARGARETH_OFF, 1);
|
|
1851 Game_Loop();
|
|
1852 if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU)
|
|
1853 {
|
|
1854 SetCurrentMenuID(MENU_NEWGAME);
|
|
1855 uGameState = GAME_STATE_PLAYING;
|
|
1856 continue;
|
|
1857 }
|
|
1858 else if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)
|
|
1859 break;
|
|
1860 assert(false && "Invalid game state");
|
|
1861 }
|
2543
|
1862 else if (GetCurrentMenuID() == MENU_CREDITS)
|
2541
|
1863 {
|
|
1864 if (use_music_folder)
|
|
1865 alSourceStop(mSourceID);
|
|
1866 else
|
|
1867 {
|
|
1868 if (pAudioPlayer->hAILRedbook)
|
|
1869 AIL_redbook_stop(pAudioPlayer->hAILRedbook);
|
|
1870 }
|
|
1871 MainMenuUI_Credits_Loop();
|
|
1872 break;
|
|
1873 }
|
2543
|
1874 else if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu)
|
2541
|
1875 {
|
|
1876 uGameState = GAME_STATE_PLAYING;
|
|
1877 Game_Loop();
|
|
1878 }
|
2543
|
1879 else if (GetCurrentMenuID() == MENU_DebugBLVLevel)
|
2541
|
1880 {
|
2543
|
1881 pMouse->ChangeActivation(0);
|
|
1882 pParty->Reset();
|
|
1883 pParty->CreateDefaultParty(1);
|
|
1884
|
|
1885 __debugbreak();
|
|
1886 /*extern void CreateDefaultBLVLevel();
|
|
1887 CreateDefaultBLVLevel();
|
|
1888
|
|
1889 OPENFILENAMEA ofn;
|
|
1890 if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) )
|
2541
|
1891 {
|
2543
|
1892 pMouse->ChangeActivation(1);
|
|
1893 break;
|
2541
|
1894 }
|
2543
|
1895 _chdir("..\\");
|
|
1896 strcpy(pCurrentMapName, ofn.lpstrFileTitle);*/
|
|
1897 pMouse->ChangeActivation(1);
|
|
1898 Game_Loop();
|
2541
|
1899 }
|
|
1900 if (uGameState == GAME_STATE_LOADING_GAME)
|
|
1901 {
|
|
1902 SetCurrentMenuID(MENU_5);
|
|
1903 uGameState = GAME_STATE_PLAYING;
|
|
1904 continue;
|
|
1905 }
|
|
1906 if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU)
|
|
1907 {
|
|
1908 SetCurrentMenuID(MENU_NEWGAME);
|
|
1909 uGameState = GAME_STATE_PLAYING;
|
|
1910 continue;
|
|
1911 }
|
|
1912 if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)// from the loaded game
|
|
1913 {
|
|
1914 pAudioPlayer->StopChannels(-1, -1);
|
|
1915 uGameState = GAME_STATE_PLAYING;
|
|
1916 break;
|
|
1917 }
|
|
1918 }
|
|
1919 if (!bNoSound)
|
|
1920 {
|
|
1921 if (use_music_folder)
|
|
1922 {
|
|
1923 PlayAudio(L"Music\\14.mp3");
|
|
1924 alSourcef(mSourceID, AL_GAIN, pSoundVolumeLevels[uMusicVolimeMultiplier]);
|
|
1925 }
|
|
1926 else if (pAudioPlayer->hAILRedbook)
|
|
1927 {
|
|
1928 pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f);
|
|
1929 AIL_redbook_stop(pAudioPlayer->hAILRedbook);
|
|
1930 unsigned int startms, end_ms;
|
|
1931 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &startms, &end_ms);
|
|
1932 AIL_redbook_play(pAudioPlayer->hAILRedbook, startms + 1, end_ms);
|
|
1933 }
|
|
1934 }
|
|
1935 }
|
|
1936 //lua_close(L);
|
|
1937 pEngine->Deinitialize();
|
|
1938 return 1;
|
|
1939 }
|
|
1940
|
|
1941
|
|
1942
|
|
1943 //----- (00466082) --------------------------------------------------------
|
|
1944 void MM6_Initialize(const wchar_t *pIniFilename)
|
|
1945 {
|
|
1946 size_t v2; // eax@31
|
|
1947 size_t v3; // ebx@32
|
|
1948 size_t v4; // edi@36
|
|
1949 char pDefaultGroundTexture[16]; // [sp+FCh] [bp-8Ch]@32
|
|
1950 unsigned int v9; // [sp+184h] [bp-4h]@28
|
|
1951
|
|
1952 //_getcwd(v5, 120);
|
|
1953 //sprintfex(pIniFilename, "%s\\mm6.ini", v5);
|
|
1954 viewparams = new ViewingParams;
|
|
1955 game_viewport_x = viewparams->uScreen_topL_X = GetPrivateProfileIntW(L"screen", L"vx1", 8, pIniFilename);
|
|
1956 game_viewport_y = viewparams->uScreen_topL_Y = GetPrivateProfileIntW(L"screen", L"vy1", 8, pIniFilename);
|
|
1957 game_viewport_z = viewparams->uScreen_BttmR_X = GetPrivateProfileIntW(L"screen", L"vx2", 468, pIniFilename);
|
|
1958 game_viewport_w = viewparams->uScreen_BttmR_Y = GetPrivateProfileIntW(L"screen", L"vy2", 351, pIniFilename);
|
|
1959 game_viewport_width = game_viewport_z - game_viewport_x;
|
|
1960 game_viewport_height = game_viewport_w - game_viewport_y + 1;
|
|
1961
|
|
1962
|
|
1963 pAudioPlayer = new AudioPlayer;
|
|
1964 pAudioPlayer->uMixerChannels = GetPrivateProfileIntW(L"settings", L"mixerchannels", 16, pIniFilename);
|
|
1965 if (pAudioPlayer->uMixerChannels > 16)
|
|
1966 pAudioPlayer->uMixerChannels = 16;
|
|
1967
|
|
1968
|
|
1969 if (GetPrivateProfileIntW(L"debug", L"nomonster", 0, pIniFilename))
|
|
1970 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_NO_ACTORS;
|
|
1971 if (ReadWindowsRegistryInt("startinwindow", 0))
|
|
1972 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_RUN_IN_WIDOW;
|
|
1973 if (GetPrivateProfileIntW(L"debug", L"showFR", 0, pIniFilename))
|
|
1974 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_0002_SHOW_FR;
|
|
1975 if (GetPrivateProfileIntW(L"debug", L"nodamage", 0, pIniFilename))
|
|
1976 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_NO_DAMAGE;
|
|
1977 if (GetPrivateProfileIntW(L"debug", L"nodecoration", 0, pIniFilename))
|
|
1978 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_NO_DECORATIONS;
|
|
1979
|
|
1980 wchar_t pStartingMapNameW[1024];
|
|
1981 GetPrivateProfileStringW(L"file", L"startmap", L"out01.odm", pStartingMapNameW, 0x20u, pIniFilename);
|
|
1982 sprintf(pStartingMapName, "%S", pStartingMapNameW);
|
|
1983
|
|
1984 v9 = 0;
|
|
1985 if (strlen(pStartingMapName))
|
|
1986 {
|
|
1987 do
|
|
1988 {
|
|
1989 if (pStartingMapName[v9] == ' ')
|
|
1990 pStartingMapName[v9] = 0;
|
|
1991 ++v9;
|
|
1992 v2 = strlen(pStartingMapName);
|
|
1993 } while (v9 < v2);
|
|
1994 }
|
|
1995
|
|
1996 pODMRenderParams = new ODMRenderParams;
|
|
1997 pODMRenderParams->outdoor_no_mist = GetPrivateProfileIntW(L"debug", L"noMist", 0, pIniFilename);
|
|
1998 pODMRenderParams->bNoSky = GetPrivateProfileIntW(L"outdoor", L"nosky", 0, pIniFilename);
|
|
1999 pODMRenderParams->bDoNotRenderDecorations = GetPrivateProfileIntW(L"render", L"nodecorations", 0, pIniFilename);
|
|
2000 pODMRenderParams->outdoor_no_wavy_water = GetPrivateProfileIntW(L"outdoor", L"nowavywater", 0, pIniFilename);
|
2543
|
2001 //outdoor_grid_band_1 = GetPrivateProfileIntW(L"outdoor", L"gridband1", 10, pIniFilename);
|
|
2002 //outdoor_grid_band_2 = GetPrivateProfileIntW(L"outdoor", L"gridband2", 15, pIniFilename);
|
|
2003 //outdoor_grid_band_3 = GetPrivateProfileIntW(L"outdoor", L"gridband3", 25, pIniFilename);
|
2541
|
2004 pODMRenderParams->terrain_gamma = GetPrivateProfileIntW(L"outdoor", L"ter_gamma", 0, pIniFilename);
|
|
2005 pODMRenderParams->building_gamme = GetPrivateProfileIntW(L"outdoor", L"bld_gamma", 0, pIniFilename);
|
|
2006 pODMRenderParams->shading_dist_shade = GetPrivateProfileIntW(L"shading", L"dist_shade", 2048, pIniFilename);
|
|
2007 pODMRenderParams->shading_dist_shademist = GetPrivateProfileIntW(L"shading", L"dist_shademist", 4096, pIniFilename);
|
|
2008
|
|
2009 pODMRenderParams->shading_dist_mist = GetPrivateProfileIntW(L"shading", L"dist_mist", 0x2000, pIniFilename);//drawing dist 0x2000
|
|
2010
|
|
2011 wchar_t pDefaultSkyTextureW[1024];
|
|
2012 GetPrivateProfileStringW(L"textures", L"sky", L"plansky1", pDefaultSkyTextureW, 0x10u, pIniFilename);
|
|
2013 sprintf(pDefaultSkyTexture.data(), "%S", pDefaultSkyTextureW);
|
|
2014
|
|
2015 wchar_t pDefaultGroundTextureW[1024];
|
|
2016 GetPrivateProfileStringW(L"textures", L"default", L"dirt", pDefaultGroundTextureW, 0x10u, pIniFilename);
|
|
2017 sprintf(pDefaultGroundTexture, "%S", pDefaultGroundTextureW);
|
|
2018
|
|
2019 wchar_t pFloat[1024];
|
|
2020 GetPrivateProfileStringW(L"debug", L"recmod1", L"1.0", pFloat, 0x10u, pIniFilename);
|
|
2021 swscanf(pFloat, L"%f", &flt_6BE3A4_debug_recmod1);
|
|
2022
|
|
2023 GetPrivateProfileStringW(L"debug", L"recmod2", L"1.0", pFloat, 0x10u, pIniFilename);
|
|
2024 swscanf(pFloat, L"%f", &flt_6BE3A8_debug_recmod2);
|
|
2025
|
|
2026 flt_6BE3AC_debug_recmod1_x_1_6 = flt_6BE3A4_debug_recmod1 * 1.666666666666667;
|
|
2027
|
|
2028 v3 = 0;
|
|
2029 if (strlen(pDefaultSkyTexture.data()))
|
|
2030 {
|
|
2031 do
|
|
2032 {
|
|
2033 if (pDefaultSkyTexture[v3] == ' ')
|
|
2034 pDefaultSkyTexture[v3] = 0;
|
|
2035 ++v3;
|
|
2036 } while (v3 < strlen(pDefaultSkyTexture.data()));
|
|
2037 }
|
|
2038 v4 = 0;
|
|
2039 if (strlen(pDefaultGroundTexture))
|
|
2040 {
|
|
2041 do
|
|
2042 {
|
|
2043 if (pDefaultGroundTexture[v4] == ' ')
|
|
2044 pDefaultGroundTexture[v4] = 0;
|
|
2045 ++v4;
|
|
2046 } while (v4 < strlen(pDefaultGroundTexture));
|
|
2047 }
|
|
2048
|
|
2049 MM7Initialization();
|
|
2050 }
|
|
2051
|
|
2052 //----- (004666D5) --------------------------------------------------------
|
|
2053 void MM7Initialization()
|
|
2054 {
|
|
2055 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
2056 {
|
|
2057 /*if (byte_6BE388_graphicsmode == 0)
|
|
2058 {
|
|
2059 outdoor_grid_band_1 = 10;
|
|
2060 outdoor_grid_band_2 = 15;
|
|
2061 outdoor_grid_band_3 = 20;
|
|
2062 pODMRenderParams->shading_dist_mist = 8192;
|
|
2063 pODMRenderParams->bNoSky = false;
|
|
2064 LOBYTE(viewparams->field_20) = 0;
|
|
2065 }*/
|
|
2066 pODMRenderParams->shading_dist_shade = 2048;
|
|
2067 pODMRenderParams->terrain_gamma = 0;
|
|
2068 pODMRenderParams->building_gamme = 0;
|
|
2069 pODMRenderParams->shading_dist_shademist = 4096;
|
|
2070 pODMRenderParams->outdoor_no_wavy_water = 0;
|
|
2071 //_47F4D3_initialize_terrain_bezier_stuff(outdoor_grid_band_1, outdoor_grid_band_2, outdoor_grid_band_3);
|
|
2072 {
|
2543
|
2073 pODMRenderParams->outdoor_grid_band_3 = 25;//outdoor_grid_band_3;
|
|
2074 pODMRenderParams->uPickDepth = 25 * 512;//outdoor_grid_band_3 * 512;
|
2541
|
2075 }
|
|
2076 }
|
|
2077 else
|
|
2078 LOBYTE(viewparams->field_20) = 0;
|
2543
|
2079
|
2541
|
2080 pParty->uFlags |= 2;
|
|
2081 viewparams->uSomeY = viewparams->uScreen_topL_Y;
|
|
2082 viewparams->uSomeX = viewparams->uScreen_topL_X;
|
|
2083 viewparams->uSomeZ = viewparams->uScreen_BttmR_X;
|
|
2084 viewparams->uSomeW = viewparams->uScreen_BttmR_Y;
|
|
2085
|
|
2086 pViewport->SetScreen(viewparams->uScreen_topL_X, viewparams->uScreen_topL_Y, viewparams->uScreen_BttmR_X, viewparams->uScreen_BttmR_Y);
|
|
2087 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
2088 pODMRenderParams->Initialize();
|
|
2089 }
|
|
2090
|
|
2091 //----- (004610AA) --------------------------------------------------------
|
|
2092 void __fastcall PrepareToLoadODM(unsigned int bLoading, ODMRenderParams *a2)
|
|
2093 {
|
|
2094 pGameLoadingUI_ProgressBar->Reset(27);
|
|
2095 pSoundList->_4A9D79(0);
|
|
2096 uCurrentlyLoadedLevelType = LEVEL_Outdoor;
|
|
2097 ODM_LoadAndInitialize(pCurrentMapName, a2);
|
|
2098 if (!bLoading)
|
|
2099 TeleportToStartingPoint(uLevel_StartingPointType);
|
|
2100 viewparams->_443365();
|
|
2101 PlayLevelMusic();
|
|
2102 }
|
2543
|
2103
|
2541
|
2104
|
|
2105 //----- (00464479) --------------------------------------------------------
|
|
2106 void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows()
|
|
2107 {
|
|
2108 int v0; // esi@9
|
|
2109
|
|
2110 if (pMouse)
|
|
2111 pMouse->SetCursorBitmap("MICON1");
|
|
2112
|
|
2113 pPaletteManager->ResetNonLocked();
|
|
2114 pBitmaps_LOD->ReleaseAll2();
|
|
2115 pSprites_LOD->DeleteSomeOtherSprites();
|
|
2116 pIcons_LOD->ReleaseAll2();
|
|
2117
|
|
2118 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
2119 pIndoor->Release();
|
|
2120 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
2121 pOutdoor->Release();
|
|
2122
|
|
2123 pAudioPlayer->StopChannels(-1, -1);
|
|
2124 pSoundList->_4A9D79(0);
|
|
2125 uCurrentlyLoadedLevelType = LEVEL_null;
|
|
2126 pSpriteFrameTable->ResetSomeSpriteFlags();
|
|
2127 v0 = uNumVisibleWindows;
|
|
2128 pParty->armageddon_timer = 0;
|
|
2129 while (v0 > 0)
|
|
2130 pWindowList[pVisibleWindowsIdxs[v0--] - 1].Release();
|
|
2131 }
|
|
2132
|
|
2133 //----- (00461103) --------------------------------------------------------
|
|
2134 void _461103_load_level_sub()
|
|
2135 {
|
|
2136 int v4; // edx@8
|
|
2137 signed int v6; // esi@14
|
|
2138 signed int v8; // ecx@16
|
|
2139 int v12; // esi@25
|
|
2140 int v13; // eax@26
|
|
2141 __int16 v14; // ax@41
|
|
2142 signed int v17; // [sp+14h] [bp-48h]@3
|
|
2143 signed int v18; // [sp+14h] [bp-48h]@23
|
|
2144 int v19; // [sp+18h] [bp-44h]@1
|
|
2145 signed int v20; // [sp+18h] [bp-44h]@14
|
|
2146 int v21[16]; // [sp+1Ch] [bp-40h]@17
|
|
2147
|
|
2148 GenerateItemsInChest();
|
|
2149 pGameLoadingUI_ProgressBar->Progress();
|
|
2150 pParty->uFlags |= 2;
|
|
2151 pParty->field_7B5_in_arena_quest = 0;
|
|
2152 dword_5C6DF8 = 1;
|
|
2153 pNPCStats->uNewlNPCBufPos = 0;
|
|
2154 v19 = pMapStats->GetMapInfo(pCurrentMapName);
|
|
2155
|
|
2156 //v15 = 0;
|
|
2157 for (uint i = 0; i < uNumActors; ++i)
|
|
2158 //if ( (signed int)uNumActors > 0 )
|
|
2159 {
|
|
2160 //Actor* pActor = &pActors[i];
|
|
2161 //v2 = (char *)&pActors[0].uNPC_ID;
|
|
2162 //do
|
|
2163 //{
|
|
2164 //v3 = pActors[i].pMonsterInfo.uID;
|
|
2165 v17 = 0;
|
|
2166 if (pActors[i].pMonsterInfo.uID >= 115 && pActors[i].pMonsterInfo.uID <= 186
|
|
2167 || pActors[i].pMonsterInfo.uID >= 232 && pActors[i].pMonsterInfo.uID <= 249)
|
|
2168 v17 = 1;
|
|
2169 //v1 = 0;
|
|
2170 v4 = (pActors[i].pMonsterInfo.uID - 1) % 3;
|
|
2171 if (2 == v4)
|
|
2172 {
|
|
2173 if (pActors[i].sNPC_ID && pActors[i].sNPC_ID < 5000)
|
|
2174 continue;
|
|
2175 }
|
|
2176 else
|
|
2177 {
|
|
2178 if (v4 != 1)
|
|
2179 {
|
|
2180 if (v4 == 0 && pActors[i].sNPC_ID == 0)
|
|
2181 pActors[i].sNPC_ID = 0;
|
|
2182 continue;
|
|
2183 }
|
|
2184 }
|
|
2185 if (pActors[i].sNPC_ID > 0 && pActors[i].sNPC_ID < 5000)
|
|
2186 continue;
|
|
2187 if (v17)
|
|
2188 {
|
|
2189 pNPCStats->InitializeAdditionalNPCs(&pNPCStats->pAdditionalNPC[pNPCStats->uNewlNPCBufPos], pActors[i].pMonsterInfo.uID, 0, v19);
|
|
2190 v14 = LOWORD(pNPCStats->uNewlNPCBufPos) + 5000;
|
|
2191 ++pNPCStats->uNewlNPCBufPos;
|
|
2192 pActors[i].sNPC_ID = v14;
|
|
2193 continue;
|
|
2194 }
|
|
2195 pActors[i].sNPC_ID = 0;
|
|
2196 //++v15;
|
|
2197 //v2 += 836;
|
|
2198 //}
|
|
2199 //while ( v15 < (signed int)uNumActors );
|
|
2200 }
|
|
2201
|
|
2202 pGameLoadingUI_ProgressBar->Progress();
|
|
2203
|
|
2204 //v5 = uNumActors;
|
|
2205 v6 = 0;
|
|
2206 v20 = 0;
|
|
2207 //v16 = v1;
|
|
2208
|
|
2209 for (uint i = 0; i < uNumActors; ++i)
|
|
2210 {
|
|
2211 //v7 = (char *)&pActors[0].pMonsterInfo;
|
|
2212 //do
|
|
2213 //{
|
|
2214 for (v8 = 0; v8 < v6; ++v8)
|
|
2215 {
|
|
2216 if (v21[v8] == pActors[i].pMonsterInfo.uID - 1)
|
|
2217 break;
|
|
2218 }
|
|
2219
|
|
2220 if (v8 == v6)
|
|
2221 {
|
|
2222 v21[v6++] = pActors[i].pMonsterInfo.uID - 1;
|
|
2223 v20 = v6;
|
|
2224 if (v6 == 16)
|
|
2225 break;
|
|
2226 }
|
|
2227 //++v16;
|
|
2228 //v7 += 836;
|
|
2229 //}
|
|
2230 //while ( v16 < (signed int)v5 );
|
|
2231 }
|
|
2232
|
|
2233 pGameLoadingUI_ProgressBar->Progress();
|
|
2234
|
|
2235 for (int _v0 = 0; _v0 < v6; ++_v0)
|
|
2236 {
|
|
2237 for (v18 = 4; v18; --v18)
|
|
2238 pSoundList->LoadSound(pMonsterList->pMonsters[v21[_v0]].pSoundSampleIDs[4 - v18], 0);
|
|
2239 v12 = 0;
|
|
2240 do
|
|
2241 v13 = pSoundList->LoadSound(v12++ + word_4EE088_sound_ids[pMonsterStats->pInfos[v21[_v0] + 1].uSpell1ID], 1);
|
|
2242 while (v13);
|
|
2243 }
|
|
2244 //v0 = pGameLoadingUI_ProgressBar;
|
|
2245 //v1 = 0;
|
|
2246
|
|
2247 pGameLoadingUI_ProgressBar->Progress();
|
|
2248
|
|
2249 if (dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_ACTORS)
|
|
2250 uNumActors = 0;
|
|
2251 if (dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_DECORATIONS)
|
|
2252 uNumLevelDecorations = 0;
|
|
2253 init_event_triggers();
|
|
2254
|
|
2255 pGameLoadingUI_ProgressBar->Progress();
|
|
2256
|
2543
|
2257 pIndoorCameraD3D->vPartyPos.x = 0;
|
|
2258 pIndoorCameraD3D->vPartyPos.y = 0;
|
|
2259 pIndoorCameraD3D->vPartyPos.z = 100;
|
|
2260 pIndoorCameraD3D->sRotationX = 0;
|
|
2261 pIndoorCameraD3D->sRotationY = 0;
|
2541
|
2262 viewparams->bRedrawGameUI = true;
|
|
2263 uLevel_StartingPointType = MapStartPoint_Party;
|
|
2264 pSprites_LOD->_461397();
|
|
2265 pPaletteManager->LockTestAll();
|
|
2266 if (pParty->pPickedItem.uItemID != 0)
|
|
2267 pMouse->SetCursorBitmapFromItemID(pParty->pPickedItem.uItemID);
|
|
2268 }
|
|
2269
|
|
2270 //----- (0042F3D6) --------------------------------------------------------
|
|
2271 void InitializeTurnBasedAnimations(void *_this)
|
|
2272 {
|
|
2273 for (unsigned int i = 0; i < pIconIDs_Turn.size(); ++i)
|
|
2274 {
|
|
2275 char icon_name[32];
|
|
2276 sprintf(icon_name, "turn%u", i);
|
|
2277 pIconIDs_Turn[i] = pIconsFrameTable->FindIcon(icon_name);
|
|
2278 pIconsFrameTable->InitializeAnimation(pIconIDs_Turn[i]);
|
|
2279 }
|
|
2280
|
|
2281 uIconID_TurnStop = pIconsFrameTable->FindIcon("turnstop");
|
|
2282 uIconID_TurnHour = pIconsFrameTable->FindIcon("turnhour");
|
|
2283 uIconID_TurnStart = pIconsFrameTable->FindIcon("turnstart");
|
|
2284 uIconID_CharacterFrame = pIconsFrameTable->FindIcon("aframe1");
|
|
2285 uSpriteID_Spell11 = pSpriteFrameTable->FastFindSprite("spell11");
|
|
2286
|
|
2287 pIconsFrameTable->InitializeAnimation(uIconID_TurnHour);
|
|
2288 pIconsFrameTable->InitializeAnimation(uIconID_TurnStop);
|
|
2289 pIconsFrameTable->InitializeAnimation(uIconID_TurnStart);
|
|
2290 pIconsFrameTable->InitializeAnimation(uIconID_CharacterFrame);
|
|
2291 }
|
|
2292
|
|
2293 //----- (0046BDA8) --------------------------------------------------------
|
|
2294 unsigned int GetGravityStrength()
|
|
2295 {
|
|
2296 int v0; // eax@1
|
|
2297
|
|
2298 v0 = ~LOBYTE(pEngine->uFlags2) & 8;
|
|
2299 LOBYTE(v0) = v0 | 2;
|
|
2300 return (unsigned int)v0 >> 1;
|
|
2301 }
|
|
2302
|
|
2303 //----- (00448B45) --------------------------------------------------------
|
|
2304 void GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide)
|
|
2305 {
|
|
2306 if (bForceHide || GameUI_Footer_TimeLeft && GetTickCount() >= GameUI_Footer_TimeLeft)
|
|
2307 GameUI_Footer_TimeLeft = 0;
|
|
2308 }
|
|
2309
|
|
2310 //----- (0044861E) --------------------------------------------------------
|
|
2311 void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename)
|
|
2312 {
|
|
2313 unsigned int texture; // eax@2
|
|
2314
|
|
2315 if (uFaceCog)
|
|
2316 {
|
|
2317 texture = pBitmaps_LOD->LoadTexture(pFilename);
|
|
2318 if (texture != -1 ? (int)&pBitmaps_LOD->pTextures[texture] : 0)
|
|
2319 {
|
|
2320 pBitmaps_LOD->pTextures[texture].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[texture].palette_id1);
|
|
2321
|
|
2322 if (uCurrentlyLoadedLevelType == 1)
|
|
2323 {
|
|
2324 if ((signed int)pIndoor->uNumFaceExtras > 1)
|
|
2325 {
|
|
2326 for (uint i = 1; i < (signed int)pIndoor->uNumFaceExtras; ++i)
|
|
2327 {
|
|
2328 if (pIndoor->pFaceExtras[i].sCogNumber == uFaceCog)
|
|
2329 {
|
|
2330 if (pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes & FACE_TEXTURE_FRAME)
|
|
2331 {
|
|
2332 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = pTextureFrameTable->FindTextureByName(pFilename);
|
|
2333 if (pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID)
|
|
2334 {
|
|
2335 pTextureFrameTable->LoadAnimationSequenceAndPalettes(pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID);
|
|
2336 }
|
|
2337 else
|
|
2338 {
|
|
2339 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = texture;
|
|
2340 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes &= 0xFFFFBFFF;
|
|
2341 }
|
|
2342 }
|
|
2343 else
|
|
2344 {
|
|
2345 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = texture;
|
|
2346 }
|
|
2347 }
|
|
2348 }
|
|
2349 }
|
|
2350 pParty->uFlags |= 2;
|
|
2351 }
|
|
2352 else
|
|
2353 {
|
|
2354 for (uint j = 0; j < (unsigned int)pOutdoor->uNumBModels; ++j)
|
|
2355 {
|
|
2356 for (uint i = 0; i < pOutdoor->pBModels[j].uNumFaces; ++i)
|
|
2357 {
|
|
2358 if (pOutdoor->pBModels[j].pFaces[i].sCogNumber == uFaceCog)
|
|
2359 {
|
|
2360 if (pOutdoor->pBModels[j].pFaces[i].uAttributes & FACE_TEXTURE_FRAME)
|
|
2361 {
|
|
2362 pOutdoor->pBModels[j].pFaces[i].uTextureID = pTextureFrameTable->FindTextureByName(pFilename);
|
|
2363 if (pOutdoor->pBModels[j].pFaces[i].uTextureID)
|
|
2364 pTextureFrameTable->LoadAnimationSequenceAndPalettes(pOutdoor->pBModels[j].pFaces[i].uTextureID);
|
|
2365 else
|
|
2366 {
|
|
2367 pOutdoor->pBModels[j].pFaces[i].uTextureID = texture;
|
|
2368 pOutdoor->pBModels[j].pFaces[i].uAttributes &= 0xFFFFBFFF;
|
|
2369 }
|
|
2370 }
|
|
2371 else
|
|
2372 pOutdoor->pBModels[j].pFaces[i].uTextureID = texture;
|
|
2373 }
|
|
2374 }
|
|
2375 }
|
|
2376 }
|
|
2377 pParty->uFlags |= 2;
|
|
2378 }
|
|
2379 }
|
|
2380 }
|
|
2381
|
|
2382 //----- (0044892E) --------------------------------------------------------
|
|
2383 void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on)
|
|
2384 {
|
|
2385 if (sCogNumber)
|
|
2386 {
|
|
2387 if (uCurrentlyLoadedLevelType == 1)
|
|
2388 {
|
|
2389 for (uint i = 1; i < (unsigned int)pIndoor->uNumFaceExtras; ++i)
|
|
2390 {
|
|
2391 if (pIndoor->pFaceExtras[i].sCogNumber == sCogNumber)
|
|
2392 {
|
|
2393 if (on)
|
|
2394 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes |= bit;
|
|
2395 else
|
|
2396 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes &= ~bit;
|
|
2397 }
|
|
2398 }
|
|
2399 pParty->uFlags |= 2;
|
|
2400 }
|
|
2401 else
|
|
2402 {
|
|
2403 for (uint j = 0; j < (unsigned int)pOutdoor->uNumBModels; ++j)
|
|
2404 {
|
|
2405 for (uint i = 0; i < (unsigned int)pOutdoor->pBModels[j].uNumFaces; ++i)
|
|
2406 {
|
|
2407 if (pOutdoor->pBModels[j].pFaces[i].sCogNumber == sCogNumber)
|
|
2408 {
|
|
2409 if (on)
|
|
2410 pOutdoor->pBModels[j].pFaces[i].uAttributes |= bit;
|
|
2411 else
|
|
2412 pOutdoor->pBModels[j].pFaces[i].uAttributes &= ~bit;
|
|
2413 }
|
|
2414 }
|
|
2415 }
|
|
2416 }
|
|
2417 pParty->uFlags |= 2;
|
|
2418 }
|
|
2419 }
|
|
2420
|
|
2421 //----- (0044882F) --------------------------------------------------------
|
|
2422 void __fastcall SetDecorationSprite(uint16_t uCog, bool bHide, const char *pFileName)
|
|
2423 {
|
|
2424 for (size_t i = 0; i < uNumLevelDecorations; i++)
|
|
2425 {
|
|
2426 if (pLevelDecorations[i].uCog == uCog)
|
|
2427 {
|
|
2428 if (pFileName && strcmp(pFileName, "0"))
|
|
2429 {
|
|
2430 pLevelDecorations[i].uDecorationDescID = pDecorationList->GetDecorIdByName(pFileName);
|
|
2431 pDecorationList->InitializeDecorationSprite(pLevelDecorations[i].uDecorationDescID);
|
|
2432 }
|
|
2433
|
|
2434 if (bHide)
|
|
2435 pLevelDecorations[i].uFlags &= ~LEVEL_DECORATION_INVISIBLE;
|
|
2436 else
|
|
2437 pLevelDecorations[i].uFlags |= LEVEL_DECORATION_INVISIBLE;
|
|
2438
|
|
2439 pParty->uFlags |= 2;
|
|
2440 }
|
|
2441 }
|
|
2442 }
|
|
2443
|
|
2444 //----- (004356FF) --------------------------------------------------------
|
|
2445 void back_to_game()
|
|
2446 {
|
|
2447 dword_507BF0_is_there_popup_onscreen = 0;
|
|
2448 dword_4E455C = 1;
|
|
2449
|
|
2450 extern int no_rightlick_in_inventory;
|
|
2451 no_rightlick_in_inventory = false;
|
|
2452
|
|
2453 if (pGUIWindow_ScrollWindow)
|
|
2454 free_book_subwindow();
|
|
2455 if (!current_screen_type && !pGUIWindow_Settings)
|
|
2456 pEventTimer->Resume();
|
|
2457 viewparams->bRedrawGameUI = 1;
|
|
2458 }
|
|
2459
|
|
2460 //----- (00494035) --------------------------------------------------------
|
|
2461 void _494035_timed_effects__water_walking_damage__etc()
|
|
2462 {
|
|
2463 signed __int64 v0; // qax@1
|
|
2464 unsigned int v4; // edi@1
|
|
2465 // signed int v12; // edi@29
|
|
2466 int v24; // ecx@60
|
|
2467 int v26; // ecx@64
|
|
2468 int v28; // ecx@68
|
|
2469 int v30; // ecx@72
|
|
2470 int v32; // ecx@76
|
|
2471 int v34; // ecx@80
|
|
2472 int v36; // ecx@84
|
|
2473 int v38; // ecx@88
|
|
2474 int v40; // ecx@92
|
|
2475 int v42; // ecx@96
|
|
2476 bool v43; // ebx@102
|
|
2477 bool v46; // edi@111
|
|
2478 // unsigned int v56; // [sp-8h] [bp-38h]@55
|
|
2479 // int v59; // [sp-4h] [bp-34h]@55
|
|
2480 // unsigned int v61; // [sp+14h] [bp-1Ch]@1
|
|
2481 signed int a2a; // [sp+18h] [bp-18h]@47
|
|
2482 signed int old_day; // [sp+1Ch] [bp-14h]@47
|
|
2483 signed int old_hour;
|
|
2484
|
|
2485 old_day = pParty->uDaysPlayed;
|
|
2486 old_hour = pParty->uCurrentHour;
|
|
2487 //auto prev_time = pEventTimer->uTimeElapsed;
|
|
2488 pParty->uTimePlayed += pEventTimer->uTimeElapsed;
|
|
2489 v0 = ((signed __int64)(pParty->uTimePlayed * 0.234375) / 60) / 60i64;
|
|
2490 v4 = (unsigned int)(((unsigned int)v0 / 24) / 7) >> 2;
|
|
2491 pParty->uCurrentTimeSecond = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) % 60;
|
|
2492 pParty->uCurrentMinute = ((signed __int64)(pParty->uTimePlayed * 0.234375) / 60) % 60;
|
|
2493 pParty->uCurrentHour = v0 % 24;
|
|
2494 pParty->uCurrentMonthWeek = ((unsigned int)v0 / 24) / 7 & 3;
|
|
2495 pParty->uDaysPlayed = (unsigned int)((unsigned int)v0 / 24) % 28;
|
|
2496 pParty->uCurrentMonth = v4 % 12;
|
|
2497 pParty->uCurrentYear = v4 / 0xC + game_starting_year;
|
|
2498 if (pParty->uCurrentHour >= 3 && (old_hour < 3 || pParty->uDaysPlayed > old_day)) // new day dawns
|
|
2499 {
|
|
2500 pParty->pHirelings[0].bHasUsedTheAbility = false;
|
|
2501 pParty->pHirelings[1].bHasUsedTheAbility = false;
|
|
2502
|
|
2503 for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i)
|
|
2504 pNPCStats->pNewNPCData[i].bHasUsedTheAbility = false;
|
|
2505
|
|
2506 ++pParty->days_played_without_rest;
|
|
2507 if (pParty->days_played_without_rest > 1)
|
|
2508 {
|
|
2509 for (uint i = 0; i < 4; ++i)
|
|
2510 pParty->pPlayers[i].SetCondWeakWithBlockCheck(0);
|
|
2511
|
|
2512 if (pParty->uNumFoodRations)
|
|
2513 Party::TakeFood(1);
|
|
2514 else
|
|
2515 for (uint i = 0; i < 4; ++i)
|
|
2516 pParty->pPlayers[i].sHealth = pParty->pPlayers[i].sHealth / (pParty->days_played_without_rest + 1) + 1;
|
|
2517
|
|
2518 if (pParty->days_played_without_rest > 3)
|
|
2519 for (uint i = 0; i < 4; ++i)
|
|
2520 {
|
|
2521 pParty->pPlayers[i].Zero();
|
|
2522 if (!pParty->pPlayers[i].IsPertified() && !pParty->pPlayers[i].IsEradicated()
|
|
2523 && !pParty->pPlayers[i].IsDead())
|
|
2524 {
|
|
2525 if (rand() % 100 < 5 * pParty->days_played_without_rest)
|
|
2526 pParty->pPlayers[i].SetCondDeadWithBlockCheck(0);
|
|
2527 if (rand() % 100 < 10 * pParty->days_played_without_rest)
|
|
2528 pParty->pPlayers[i].SetCondInsaneWithBlockCheck(0);
|
|
2529 }
|
|
2530 }
|
|
2531 }
|
|
2532 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor)
|
|
2533 pOutdoor->SetFog();
|
|
2534
|
|
2535 for (uint i = 0; i < 4; ++i)
|
|
2536 pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0;
|
|
2537 }
|
|
2538
|
|
2539 if (pParty->uFlags & 4 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed)//water damage
|
|
2540 {
|
|
2541 pParty->field_6FC = (signed __int64)pParty->uTimePlayed + 128;
|
|
2542 viewparams->bRedrawGameUI = true;
|
|
2543 for (uint pl = 1; pl <= 4; ++pl)
|
|
2544 {
|
|
2545 if (pPlayers[pl]->WearsItem(ITEM_RELIC_HARECS_LEATHER, EQUIP_ARMOUR)
|
|
2546 || pPlayers[pl]->HasEnchantedItemEquipped(71)
|
|
2547 || pPlayers[pl]->pPlayerBuffs[PLAYER_BUFF_WATER_WALK].uExpireTime > 0)
|
|
2548 pPlayers[pl]->PlayEmotion(CHARACTER_EXPRESSION_37, 0);
|
|
2549 else
|
|
2550 {
|
|
2551 if (!pPlayers[pl]->HasUnderwaterSuitEquipped())
|
|
2552 {
|
|
2553 pPlayers[pl]->ReceiveDamage((signed __int64)pPlayers[pl]->GetMaxHealth() * 0.1, DMGT_FIRE);
|
|
2554 if (pParty->uFlags & 4)
|
|
2555 {
|
|
2556 strcpy(GameUI_Footer_TimedString.data(), pGlobalTXT_LocalizationStrings[660]);// Âû òîíåòå!
|
|
2557 GameUI_Footer_TimeLeft = 128;
|
|
2558 }
|
|
2559 }
|
|
2560 else
|
|
2561 pPlayers[pl]->PlayEmotion(CHARACTER_EXPRESSION_37, 0);
|
|
2562 }
|
|
2563 }
|
|
2564 }
|
|
2565 if (pParty->uFlags & 0x200 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed) //lava damage
|
|
2566 {
|
|
2567 viewparams->bRedrawGameUI = true;
|
|
2568 pParty->field_6FC = (signed __int64)pParty->uTimePlayed + 128;
|
|
2569
|
|
2570 for (uint pl = 1; pl <= 4; pl++)
|
|
2571 {
|
|
2572 pPlayers[pl]->ReceiveDamage((signed __int64)pPlayers[pl]->GetMaxHealth() * 0.1, DMGT_FIRE);
|
|
2573 if (pParty->uFlags & 0x200)
|
|
2574 {
|
|
2575 strcpy(GameUI_Footer_TimedString.data(), pGlobalTXT_LocalizationStrings[661]); //Âû ãîðèòå!
|
|
2576 GameUI_Footer_TimeLeft = 128;
|
|
2577 }
|
|
2578 }
|
|
2579 }
|
|
2580 _493938_regenerate();
|
|
2581 uint party_condition_flag = 4;
|
|
2582 a2a = pEventTimer->uTimeElapsed;
|
|
2583 if (pParty->uFlags2 & PARTY_FLAGS_2_RUNNING)//çàìåäëåíèå âîññòàíîâëåíèÿ ïðè áåãå
|
|
2584 {
|
|
2585 a2a *= 0.5f;
|
|
2586 if (a2a < 1)
|
|
2587 a2a = 1;
|
|
2588 }
|
|
2589
|
|
2590 for (uint pl = 1; pl <= 4; pl++)
|
|
2591 {
|
|
2592 if (pPlayers[pl]->uTimeToRecovery)
|
|
2593 pPlayers[pl]->Recover(a2a);//âîññòàíîâëåíèå àêòèâíîñòè
|
|
2594 if (pPlayers[pl]->GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE) + pPlayers[pl]->sHealth + pPlayers[pl]->uEndurance >= 1
|
|
2595 || (signed __int64)pPlayers[pl]->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0)
|
|
2596 {
|
|
2597 if (pPlayers[pl]->sHealth < 1)
|
|
2598 pPlayers[pl]->SetCondition(Condition_Unconcious, 0);
|
|
2599 }
|
|
2600 else
|
|
2601 pPlayers[pl]->SetCondition(Condition_Dead, 0);
|
|
2602 if (pPlayers[pl]->field_E0)
|
|
2603 {
|
|
2604 v24 = pPlayers[pl]->field_E0 - pEventTimer->uTimeElapsed;
|
|
2605 if (v24 > 0)
|
|
2606 pPlayers[pl]->field_E0 = v24;
|
|
2607 else
|
|
2608 {
|
|
2609 pPlayers[pl]->field_E0 = 0;
|
|
2610 viewparams->bRedrawGameUI = true;
|
|
2611 }
|
|
2612 }
|
|
2613 if (pPlayers[pl]->field_E4)
|
|
2614 {
|
|
2615 v26 = pPlayers[pl]->field_E4 - pEventTimer->uTimeElapsed;
|
|
2616 if (v26 > 0)
|
|
2617 pPlayers[pl]->field_E4 = v26;
|
|
2618 else
|
|
2619 {
|
|
2620 pPlayers[pl]->field_E4 = 0;
|
|
2621 viewparams->bRedrawGameUI = true;
|
|
2622 }
|
|
2623 }
|
|
2624 if (pPlayers[pl]->field_E8)
|
|
2625 {
|
|
2626 v28 = pPlayers[pl]->field_E8 - pEventTimer->uTimeElapsed;
|
|
2627 if (v28 > 0)
|
|
2628 pPlayers[pl]->field_E8 = v28;
|
|
2629 else
|
|
2630 {
|
|
2631 pPlayers[pl]->field_E8 = 0;
|
|
2632 viewparams->bRedrawGameUI = true;
|
|
2633 }
|
|
2634 }
|
|
2635 if (pPlayers[pl]->field_EC)
|
|
2636 {
|
|
2637 v30 = pPlayers[pl]->field_EC - pEventTimer->uTimeElapsed;
|
|
2638 if (v30 > 0)
|
|
2639 pPlayers[pl]->field_EC = v30;
|
|
2640 else
|
|
2641 {
|
|
2642 pPlayers[pl]->field_EC = 0;
|
|
2643 viewparams->bRedrawGameUI = true;
|
|
2644 }
|
|
2645 }
|
|
2646 if (pPlayers[pl]->field_F0)
|
|
2647 {
|
|
2648 v32 = pPlayers[pl]->field_F0 - pEventTimer->uTimeElapsed;
|
|
2649 if (v32 > 0)
|
|
2650 pPlayers[pl]->field_F0 = v32;
|
|
2651 else
|
|
2652 {
|
|
2653 pPlayers[pl]->field_F0 = 0;
|
|
2654 viewparams->bRedrawGameUI = true;
|
|
2655 }
|
|
2656 }
|
|
2657 if (pPlayers[pl]->field_F4)
|
|
2658 {
|
|
2659 v34 = pPlayers[pl]->field_F4 - pEventTimer->uTimeElapsed;
|
|
2660 if (v34 > 0)
|
|
2661 pPlayers[pl]->field_F4 = v34;
|
|
2662 else
|
|
2663 {
|
|
2664 pPlayers[pl]->field_F4 = 0;
|
|
2665 viewparams->bRedrawGameUI = true;
|
|
2666 }
|
|
2667 }
|
|
2668 if (pPlayers[pl]->field_F8)
|
|
2669 {
|
|
2670 v36 = pPlayers[pl]->field_F8 - pEventTimer->uTimeElapsed;
|
|
2671 if (v36 > 0)
|
|
2672 pPlayers[pl]->field_F8 = v36;
|
|
2673 else
|
|
2674 {
|
|
2675 pPlayers[pl]->field_F8 = 0;
|
|
2676 viewparams->bRedrawGameUI = true;
|
|
2677 }
|
|
2678 }
|
|
2679 if (pPlayers[pl]->field_FC)
|
|
2680 {
|
|
2681 v38 = pPlayers[pl]->field_FC - pEventTimer->uTimeElapsed;
|
|
2682 if (v38 > 0)
|
|
2683 pPlayers[pl]->field_FC = v38;
|
|
2684 else
|
|
2685 {
|
|
2686 pPlayers[pl]->field_FC = 0;
|
|
2687 viewparams->bRedrawGameUI = true;
|
|
2688 }
|
|
2689 }
|
|
2690 if (pPlayers[pl]->field_100)
|
|
2691 {
|
|
2692 v40 = pPlayers[pl]->field_100 - pEventTimer->uTimeElapsed;
|
|
2693 if (v40 > 0)
|
|
2694 pPlayers[pl]->field_100 = v40;
|
|
2695 else
|
|
2696 {
|
|
2697 pPlayers[pl]->field_100 = 0;
|
|
2698 viewparams->bRedrawGameUI = true;
|
|
2699 }
|
|
2700 }
|
|
2701 if (pPlayers[pl]->field_104)
|
|
2702 {
|
|
2703 v42 = pPlayers[pl]->field_104 - pEventTimer->uTimeElapsed;
|
|
2704 if (v42 > 0)
|
|
2705 pPlayers[pl]->field_104 = v42;
|
|
2706 else
|
|
2707 {
|
|
2708 pPlayers[pl]->field_104 = 0;
|
|
2709 viewparams->bRedrawGameUI = true;
|
|
2710 }
|
|
2711 }
|
|
2712 if (pPlayers[pl]->pConditions[Condition_Sleep] | pPlayers[pl]->pConditions[Condition_Paralyzed]
|
|
2713 | pPlayers[pl]->pConditions[Condition_Unconcious] | pPlayers[pl]->pConditions[Condition_Dead]
|
|
2714 | pPlayers[pl]->pConditions[Condition_Pertified] | pPlayers[pl]->pConditions[Condition_Eradicated])
|
|
2715 --party_condition_flag;
|
|
2716 v43 = (signed __int64)pPlayers[pl]->pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime > 0; //ñïåøêà
|
|
2717
|
|
2718 for (uint k = 0; k < 24; ++k)
|
|
2719 pPlayers[pl]->pPlayerBuffs[k].IsBuffExpiredToTime(pParty->uTimePlayed);
|
|
2720
|
|
2721 if (v43 && (signed __int64)pPlayers[pl]->pPlayerBuffs[7].uExpireTime <= 0)
|
|
2722 pPlayers[pl]->SetCondition(Condition_Weak, 0);
|
|
2723 }
|
|
2724
|
|
2725 v46 = (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_HASTE].uExpireTime > 0;
|
|
2726
|
|
2727 for (uint i = 0; i < 20; ++i)
|
|
2728 {
|
|
2729 if (pParty->pPartyBuffs[i].IsBuffExpiredToTime(pParty->uTimePlayed) == 1)
|
|
2730 viewparams->bRedrawGameUI = true;
|
|
2731 }
|
|
2732
|
|
2733 if (v46 && (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_HASTE].uExpireTime <= 0)
|
|
2734 {
|
|
2735 for (uint i = 0; i < 4; ++i)
|
|
2736 pParty->pPlayers[i].SetCondition(1, 0);
|
|
2737 }
|
|
2738
|
|
2739 for (uint i = 0; i < 2; ++i)//Ïðîâåðêà â ñîçíàíèè ëè ïåðñ ñäåëàâøèé çàêë íà ïîë¸ò è õîæäåíèå ïî âîäå
|
|
2740 {
|
|
2741 SpellBuff* pBuf = &pParty->pPartyBuffs[Party_Spec_Motion_status_ids[i]];
|
|
2742 if (pBuf->uExpireTime == 0)
|
|
2743 continue;
|
|
2744
|
|
2745 if (!(pBuf->uFlags & 1))
|
|
2746 {
|
|
2747 if (!pPlayers[pBuf->uCaster]->CanAct())
|
|
2748 {
|
|
2749 pBuf->Reset();
|
|
2750 if (Party_Spec_Motion_status_ids[i] == PARTY_BUFF_FLY)
|
|
2751 pParty->bFlying = false;
|
|
2752 }
|
|
2753 }
|
|
2754 }
|
|
2755
|
|
2756 if (!party_condition_flag)
|
|
2757 {
|
|
2758 if (current_screen_type != SCREEN_REST)
|
|
2759 {
|
|
2760 for (uint pl = 1; pl <= 4; pl++)
|
|
2761 {
|
|
2762 if (pPlayers[pl]->pConditions[Condition_Sleep])
|
|
2763 {
|
|
2764 pPlayers[pl]->pConditions[Condition_Sleep] = 0;
|
|
2765 party_condition_flag = 1;
|
|
2766 break;
|
|
2767 }
|
|
2768 }
|
|
2769 if (!party_condition_flag || _5C35C0_force_party_death)
|
|
2770 uGameState = GAME_STATE_PARTY_DIED;
|
|
2771 }
|
|
2772 }
|
|
2773
|
|
2774 if (uActiveCharacter)//âûáîð ñëåäóþùåãî ïîñëå ïðîïóñêàþùåãî õîä
|
|
2775 {
|
|
2776 if (current_screen_type != SCREEN_REST)
|
|
2777 {
|
|
2778 if (pPlayers[uActiveCharacter]->pConditions[Condition_Sleep]
|
|
2779 || pPlayers[uActiveCharacter]->pConditions[Condition_Paralyzed]
|
|
2780 || pPlayers[uActiveCharacter]->pConditions[Condition_Unconcious]
|
|
2781 || pPlayers[uActiveCharacter]->pConditions[Condition_Dead]
|
|
2782 || pPlayers[uActiveCharacter]->pConditions[Condition_Pertified]
|
|
2783 || pPlayers[uActiveCharacter]->pConditions[Condition_Eradicated])
|
|
2784 {
|
|
2785 viewparams->bRedrawGameUI = true;
|
|
2786 uActiveCharacter = pParty->GetNextActiveCharacter();
|
|
2787 }
|
|
2788 }
|
|
2789 }
|
|
2790 }
|
|
2791
|
|
2792 //----- (00493938) --------------------------------------------------------
|
|
2793 void _493938_regenerate()
|
|
2794 {
|
|
2795 int current_time; // edi@1
|
|
2796 int last_reg_time; // qax@1
|
|
2797 int v4; // eax@2
|
|
2798 int v5; // edi@5
|
|
2799 long long *v6; // ecx@5
|
|
2800 char v7; // sf@5
|
|
2801 int *v8; // ecx@10
|
|
2802 int v9; // edi@15
|
|
2803 signed int v10; // eax@15
|
|
2804 // __int16 *v11; // edx@16
|
|
2805 // int v12; // eax@20
|
|
2806 int numberOfActorsAffected; // ebx@20
|
|
2807 unsigned int v14; // esi@21
|
|
2808 //unsigned int v15; // ecx@21
|
|
2809 //unsigned int v16; // eax@21
|
|
2810 // int v18; // eax@21
|
|
2811 signed int v19; // eax@21
|
|
2812 bool recovery_HP; // ebx@25
|
|
2813 // ITEM_EQUIP_TYPE v22; // edi@30
|
|
2814 signed int v25; // eax@33
|
|
2815 // int v26; // eax@35
|
|
2816 // int v27; // eax@36
|
|
2817 // int v28; // eax@37
|
|
2818 signed int v31; // ecx@53
|
|
2819 int actorsAffectedByImmolation[100]; // [sp+4h] [bp-22Ch]@20
|
|
2820 SpriteObject a1; // [sp+194h] [bp-9Ch]@15
|
|
2821 Vec3_int_ a3; // [sp+204h] [bp-2Ch]@15
|
|
2822 bool has_dragon_flag; // [sp+210h] [bp-20h]@22
|
|
2823 bool lich_jar_flag; // [sp+214h] [bp-1Ch]@25
|
|
2824 bool zombie_flag; // [sp+218h] [bp-18h]@25
|
|
2825 bool decrease_HP; // [sp+21Ch] [bp-14h]@25
|
|
2826 bool lich_flag; // [sp+220h] [bp-10h]@25
|
|
2827 int v49; // [sp+224h] [bp-Ch]@24
|
|
2828 bool recovery_SP; // [sp+228h] [bp-8h]@25
|
|
2829 bool redraw_flag; // [sp+22Ch] [bp-4h]@2
|
|
2830
|
|
2831 current_time = (signed int)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) / 60;
|
|
2832 last_reg_time = (signed int)(signed __int64)((double)pParty->uLastRegenerationTime * 0.234375) / 60;
|
|
2833 if (current_time >= (signed int)last_reg_time + 5)
|
|
2834 {
|
|
2835 redraw_flag = false;
|
|
2836 v4 = (current_time - last_reg_time) / 5;
|
|
2837 if (pParty->FlyActive())
|
|
2838 {
|
|
2839 if (pParty->bFlying)
|
|
2840 {
|
|
2841 if (!(pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags & 1))
|
|
2842 {
|
|
2843 v5 = v4 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uPower;
|
|
2844 //cursed_flag = pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].pConditions[Condition_Cursed];//cursed
|
|
2845 //v7 = cursed_flag < v5;
|
|
2846 //cursed_flag -= v5;
|
|
2847
|
|
2848 v6 = &pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].pConditions[Condition_Cursed];
|
|
2849
|
|
2850 if (*v6 < v5)
|
|
2851 {
|
|
2852 v6 = 0;
|
|
2853 pParty->uFlags &= 0xFFFFFFBFu;
|
|
2854 pParty->bFlying = false;
|
|
2855 redraw_flag = true;
|
|
2856 }
|
|
2857 }
|
|
2858 }
|
|
2859 }
|
|
2860
|
|
2861 if (pParty->WaterWalkActive())
|
|
2862 {
|
|
2863 if (pParty->uFlags & PARTY_FLAGS_1_STANDING_ON_WATER)
|
|
2864 {
|
|
2865 if (!(pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags & 1))
|
|
2866 { // taking on water
|
|
2867 v8 = (int *)&pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster - 1].pConditions[Condition_Cursed];//&AA1058_PartyQuickSpellSound[4].pSounds[6972 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster + 2000];
|
|
2868 v7 = *v8 < v4;
|
|
2869 *v8 -= v4;
|
|
2870 if (v7)
|
|
2871 {
|
|
2872 *v8 = 0;
|
|
2873 pParty->uFlags &= ~PARTY_FLAGS_1_STANDING_ON_WATER;
|
|
2874 redraw_flag = true;
|
|
2875 }
|
|
2876 }
|
|
2877 }
|
|
2878 }
|
|
2879
|
|
2880 if (pParty->ImmolationActive())//Æåðòâà
|
|
2881 {
|
|
2882 a3.z = 0;
|
|
2883 a3.y = 0;
|
|
2884 a3.x = 0;
|
|
2885 a1.stru_24.Reset();
|
|
2886 a1.spell_level = pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].uPower;
|
|
2887 a1.spell_skill = pParty->ImmolationSkillLevel();
|
|
2888 v10 = 0;
|
|
2889 a1.uType = 1070;
|
|
2890 a1.spell_id = SPELL_FIRE_IMMOLATION;
|
|
2891 v10 = 0;
|
|
2892 for (uint i = 0; i > pObjectList->uNumObjects; i++)
|
|
2893 {
|
|
2894 if (pObjectList->pObjects[i].uObjectID == stru_4E3ACC[8].uType)
|
|
2895 v10 = i;
|
|
2896 }
|
|
2897 a1.uObjectDescID = v10;
|
|
2898 a1.field_60_distance_related_prolly_lod = 0;
|
|
2899 a1.uAttributes = 0;
|
|
2900 a1.uSectorID = 0;
|
|
2901 a1.uSpriteFrameID = 0;
|
|
2902 a1.spell_caster_pid = PID(OBJECT_Player, pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].uCaster);
|
|
2903 a1.uFacing = 0;
|
|
2904 a1.uSoundID = 0;
|
|
2905 numberOfActorsAffected = pParty->_46A89E_immolation_effect(actorsAffectedByImmolation, 100, 307);
|
|
2906 for (v9 = 0; v9 < numberOfActorsAffected; ++v9)
|
|
2907 {
|
|
2908 v14 = actorsAffectedByImmolation[v9];
|
|
2909 a1.vPosition.x = pActors[v14].vPosition.x;
|
|
2910 a1.vPosition.y = pActors[v14].vPosition.y;
|
|
2911 a1.vPosition.z = pActors[v14].vPosition.z;
|
|
2912 a1.spell_target_pid = PID(OBJECT_Actor, v14);
|
|
2913 v19 = a1.Create(0, 0, 0, 0);
|
|
2914 Actor::DamageMonsterFromParty(PID(OBJECT_Item, v19), v14, &a3);
|
|
2915 }
|
|
2916 }
|
|
2917
|
|
2918 has_dragon_flag = false;
|
|
2919 if (PartyHasDragon())
|
|
2920 has_dragon_flag = true;
|
|
2921
|
|
2922 for (v49 = 0; v49 < 4; v49++)
|
|
2923 {
|
|
2924 recovery_HP = false;
|
|
2925 recovery_SP = false;
|
|
2926 decrease_HP = false;
|
|
2927 lich_flag = false;
|
|
2928 lich_jar_flag = false;
|
|
2929 zombie_flag = false;
|
|
2930
|
|
2931 for (int v22 = 0; (signed int)v22 < 16; v22++)
|
|
2932 {
|
|
2933 if (pParty->pPlayers[v49].HasItemEquipped((ITEM_EQUIP_TYPE)v22))
|
|
2934 {
|
|
2935 uint _idx = pParty->pPlayers[v49].pEquipment.pIndices[v22];
|
|
2936 if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID > 134)
|
|
2937 {
|
|
2938 if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_RELIC_ETHRICS_STAFF)
|
|
2939 decrease_HP = true;
|
|
2940 if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_ARTIFACT_HERMES_SANDALS)
|
|
2941 {
|
|
2942 recovery_HP = true;
|
|
2943 recovery_SP = true;
|
|
2944 }
|
|
2945 if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_ARTIFACT_MINDS_EYE)
|
|
2946 recovery_SP = true;
|
|
2947 if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_ARTIFACT_HEROS_BELT)
|
|
2948 recovery_HP = true;
|
|
2949 }
|
|
2950 else
|
|
2951 {
|
|
2952 v25 = pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uSpecEnchantmentType;
|
|
2953 if (v25 == 37 //of Regeneration("Regenerate 1hp/x while walking, etc")
|
|
2954 || v25 == 44 //of Life("HP (+10), Regen hpts")
|
|
2955 || v25 == 50 //of The Phoenix("Fire Res (+30), Regen hpts") &&
|
|
2956 || v25 == 54)// of The Troll("End (+15), Regen hpts")
|
|
2957 recovery_HP = true;
|
|
2958 if (v25 == 38 //of Mana("Regenerate 1sp/x while walking, etc")
|
|
2959 || v25 == 47 //of The Eclipse("SP (+10), Regen spts")
|
|
2960 || v25 == 55)//of The Unicorn("Luck (+15), Regen spts")
|
|
2961 recovery_SP = true;
|
|
2962 if (v25 == 66)// of Plenty("Regenerate 1 hp/x and 1 sp/x while walking, etc.")
|
|
2963 {
|
|
2964 recovery_HP = true;
|
|
2965 recovery_SP = true;
|
|
2966 }
|
|
2967 }
|
|
2968
|
|
2969 if (recovery_HP &&
|
|
2970 !pParty->pPlayers[v49].pConditions[Condition_Dead] &&
|
|
2971 !pParty->pPlayers[v49].pConditions[Condition_Eradicated])
|
|
2972 {
|
|
2973 if (pParty->pPlayers[v49].sHealth < pParty->pPlayers[v49].GetMaxHealth())
|
|
2974 ++pParty->pPlayers[v49].sHealth;
|
|
2975 if (pParty->pPlayers[v49].pConditions[Condition_Unconcious] && pParty->pPlayers[v49].sHealth > 0)
|
|
2976 pParty->pPlayers[v49].pConditions[Condition_Unconcious] = 0;
|
|
2977 redraw_flag = true;
|
|
2978 }
|
|
2979
|
|
2980 if (recovery_SP &&
|
|
2981 !pParty->pPlayers[v49].pConditions[Condition_Dead] &&
|
|
2982 !pParty->pPlayers[v49].pConditions[Condition_Eradicated])
|
|
2983 {
|
|
2984 if (pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana())
|
|
2985 ++pParty->pPlayers[v49].sMana;
|
|
2986 redraw_flag = true;
|
|
2987 }
|
|
2988
|
|
2989 if (decrease_HP &&
|
|
2990 !pParty->pPlayers[v49].pConditions[Condition_Dead] &&
|
|
2991 !pParty->pPlayers[v49].pConditions[Condition_Eradicated])
|
|
2992 {
|
|
2993 --pParty->pPlayers[v49].sHealth;
|
|
2994 if (!(pParty->pPlayers[v49].pConditions[Condition_Unconcious]) && pParty->pPlayers[v49].sHealth < 0)
|
|
2995 pParty->pPlayers[v49].pConditions[Condition_Unconcious] = pParty->uTimePlayed;
|
|
2996 if (pParty->pPlayers[v49].sHealth < 1)
|
|
2997 {
|
|
2998 if (pParty->pPlayers[v49].sHealth + pParty->pPlayers[v49].uEndurance + pParty->pPlayers[v49].GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE) >= 1
|
|
2999 || (signed __int64)pParty->pPlayers[v49].pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0)
|
|
3000 pParty->pPlayers[v49].pConditions[Condition_Unconcious] = pParty->uTimePlayed;
|
|
3001 else
|
|
3002 {
|
|
3003 if (!pParty->pPlayers[v49].pConditions[Condition_Dead])
|
|
3004 pParty->pPlayers[v49].pConditions[Condition_Dead] = pParty->uTimePlayed;
|
|
3005 }
|
|
3006 }
|
|
3007 redraw_flag = true;
|
|
3008 }
|
|
3009 }
|
|
3010 }
|
|
3011
|
|
3012 //regeneration
|
|
3013 if (pParty->pPlayers[v49].pPlayerBuffs[PLAYER_BUFF_REGENERATION].uExpireTime > 0
|
|
3014 && !pParty->pPlayers[v49].pConditions[Condition_Dead]
|
|
3015 && !pParty->pPlayers[v49].pConditions[Condition_Eradicated])
|
|
3016 {
|
|
3017 pParty->pPlayers[v49].sHealth += 5 * pParty->pPlayers[v49].pPlayerBuffs[PLAYER_BUFF_REGENERATION].uPower;
|
|
3018 if (pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth())
|
|
3019 pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].GetMaxHealth();
|
|
3020 if (pParty->pPlayers[v49].pConditions[Condition_Unconcious] && pParty->pPlayers[v49].sHealth > 0)
|
|
3021 pParty->pPlayers[v49].pConditions[Condition_Unconcious] = 0;
|
|
3022 redraw_flag = true;
|
|
3023 }
|
|
3024
|
|
3025 //for warlock
|
|
3026 if (has_dragon_flag && pParty->pPlayers[v49].classType == PLAYER_CLASS_WARLOCK)
|
|
3027 {
|
|
3028 if (pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana())
|
|
3029 ++pParty->pPlayers[v49].sMana;
|
|
3030 redraw_flag = true;
|
|
3031 }
|
|
3032
|
|
3033 //for lich
|
|
3034 if (pParty->pPlayers[v49].classType == PLAYER_CLASS_LICH)
|
|
3035 {
|
|
3036 for (v31 = 0; v31 < 126; ++v31)
|
|
3037 {
|
|
3038 if (pParty->pPlayers[v49].pInventoryItemList[v31].uItemID == ITEM_LICH_JAR_FULL)
|
|
3039 lich_jar_flag = true;
|
|
3040 }
|
|
3041 lich_flag = true;
|
|
3042 }
|
|
3043 if (lich_flag && !pParty->pPlayers[v49].pConditions[Condition_Dead]
|
|
3044 && !pParty->pPlayers[v49].pConditions[Condition_Eradicated])
|
|
3045 {
|
|
3046 if (pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth() / 2)
|
|
3047 pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].sHealth - 2;
|
|
3048 if (pParty->pPlayers[v49].sMana > pParty->pPlayers[v49].GetMaxMana() / 2)
|
|
3049 pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].sMana - 2;
|
|
3050 }
|
|
3051 if (lich_jar_flag)
|
|
3052 {
|
|
3053 if (pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana())
|
|
3054 ++pParty->pPlayers[v49].sMana;
|
|
3055 }
|
|
3056
|
|
3057 //for zombie
|
|
3058 if (pParty->pPlayers[v49].pConditions[Condition_Zombie])
|
|
3059 zombie_flag = true;
|
|
3060 if (zombie_flag && !pParty->pPlayers[v49].pConditions[Condition_Dead]
|
|
3061 && !pParty->pPlayers[v49].pConditions[Condition_Eradicated])
|
|
3062 {
|
|
3063 if (pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth() / 2)
|
|
3064 pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].sHealth - 1;
|
|
3065 if (pParty->pPlayers[v49].sMana > 0)
|
|
3066 pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].sMana - 1;
|
|
3067 }
|
|
3068 }
|
|
3069 pParty->uLastRegenerationTime = pParty->uTimePlayed;
|
|
3070 if (!viewparams->bRedrawGameUI)
|
|
3071 viewparams->bRedrawGameUI = redraw_flag;
|
|
3072 }
|
|
3073 }
|
|
3074
|
|
3075 //----- (00491E3A) --------------------------------------------------------
|
|
3076 void sub_491E3A()
|
|
3077 {
|
|
3078 signed int v1; // esi@3
|
|
3079 unsigned int v3; // eax@7
|
|
3080 unsigned int v4; // edx@8
|
|
3081 int v6; // edi@17
|
|
3082
|
|
3083 //__debugbreak();//Ritor1
|
|
3084 for (uint pl = 0; pl < 4; pl++)
|
|
3085 {
|
|
3086 if (SoundSetAction[24][0])
|
|
3087 {
|
|
3088 v3 = 0;
|
|
3089 for (v1 = 0; v1 < (signed int)pSoundList->sNumSounds; ++v1)
|
|
3090 {
|
|
3091 int ps = 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[pl].uVoiceID) + 4998;//6728
|
|
3092 if (pSoundList->pSL_Sounds[v1].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[pl].uVoiceID) + 4998)
|
|
3093 v3 = v1;
|
|
3094 }
|
|
3095 pSoundList->UnloadSound(v3, 1);
|
|
3096 for (v4 = 0; (signed int)v4 < (signed int)pSoundList->sNumSounds; ++v4)
|
|
3097 {
|
|
3098 if (pSoundList->pSL_Sounds[v4].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[pl].uVoiceID) + 4999)
|
|
3099 pSoundList->UnloadSound(v4, 1);
|
|
3100 }
|
|
3101 }
|
|
3102 }
|
|
3103 v6 = pIcons_LOD->uNumLoadedFiles - 1;
|
|
3104 if (v6 >= pIcons_LOD->pFacesLock)
|
|
3105 {
|
|
3106 do
|
|
3107 {
|
|
3108 pIcons_LOD->pTextures[v6].Release();
|
|
3109 if (pIcons_LOD->pHardwareTextures)
|
|
3110 {
|
|
3111 if (pIcons_LOD->pHardwareTextures[v6])
|
|
3112 {
|
|
3113 pIcons_LOD->pHardwareTextures[v6]->Release();
|
|
3114 pIcons_LOD->pHardwareTextures[v6] = 0;
|
|
3115 }
|
|
3116 }
|
|
3117 if (pIcons_LOD->pHardwareSurfaces)
|
|
3118 {
|
|
3119 if (pIcons_LOD->pHardwareSurfaces[v6])
|
|
3120 {
|
|
3121 pIcons_LOD->pHardwareSurfaces[v6]->Release();
|
|
3122 pIcons_LOD->pHardwareSurfaces[v6] = 0;
|
|
3123 }
|
|
3124 }
|
|
3125 --v6;
|
|
3126 } while (v6 >= pIcons_LOD->pFacesLock);
|
|
3127 }
|
|
3128 pIcons_LOD->uNumLoadedFiles = pIcons_LOD->pFacesLock;
|
|
3129 pIcons_LOD->pFacesLock = 0;
|
|
3130 }
|
|
3131 // 4ED498: using guessed type char byte_4ED498;
|
|
3132
|
|
3133 //----- (00494820) --------------------------------------------------------
|
|
3134 unsigned int __fastcall _494820_training_time(unsigned int a1)
|
|
3135 {
|
|
3136 signed int v1; // eax@1
|
|
3137
|
|
3138 v1 = 5;
|
|
3139 if (a1 % 24 >= 5)
|
|
3140 v1 = 29;
|
|
3141 return v1 - a1 % 24;
|
|
3142 }
|
|
3143
|
|
3144 //----- (00494836) --------------------------------------------------------
|
|
3145 int stru339_spell_sound::AddPartySpellSound(int uSoundID, int a6)
|
|
3146 {
|
|
3147 int v3; // esi@1
|
|
3148 int result; // eax@1
|
|
3149 //stru339_spell_sound *v5; // ebx@1
|
|
3150 //int *v6; // edi@2
|
|
3151 unsigned int v7; // eax@3
|
|
3152 int v8; // [sp+Ch] [bp-8h]@3
|
|
3153 int v9; // [sp+10h] [bp-4h]@2
|
|
3154 int a2a; // [sp+1Ch] [bp+8h]@1
|
|
3155 //return 0;
|
|
3156 v3 = 0;
|
|
3157 result = word_4EE088_sound_ids[uSoundID];
|
|
3158 //v5 = this;
|
|
3159 a2a = word_4EE088_sound_ids[uSoundID];
|
|
3160 if (word_4EE088_sound_ids[uSoundID])
|
|
3161 {
|
|
3162 //v6 = this->pSoundsOffsets;
|
|
3163 for (v9 = 0; v9 < 2; ++v9)
|
|
3164 {
|
|
3165 v7 = a2a++;
|
|
3166 result = pSoundList->LoadSound(v7, (char *)this + v3, 44744 - v3, &v8, a6);
|
|
3167 if (!result)
|
|
3168 break;
|
|
3169 a6 += 4;
|
|
3170 result = v8 + 256;
|
|
3171 this->pSoundsOffsets[v9] = v3;
|
|
3172 v3 += result;
|
|
3173 this->pSoundsSizes[v9] = v8 + 256;
|
|
3174 //++v6;
|
|
3175 }
|
|
3176 }
|
|
3177 return result;
|
|
3178 }
|
|
3179 // 4EE088: using guessed type __int16 word_4EE088_sound_ids[];
|
|
3180
|
|
3181 //----- (00443E31) --------------------------------------------------------
|
|
3182 void LoadLevel_InitializeLevelStr()
|
|
3183 {
|
|
3184
|
|
3185 // char Args[100];
|
|
3186 int string_num;
|
|
3187 int max_string_length;
|
|
3188 // int current_string_length;
|
|
3189 int prev_string_offset;
|
|
3190
|
|
3191 if (sizeof(pLevelStrOffsets) != 2000)
|
|
3192 Log::Warning(L"pLevelStrOffsets: deserialization warning");
|
|
3193 memset(pLevelStrOffsets.data(), 0, 2000);
|
|
3194
|
|
3195 max_string_length = 0;
|
|
3196 string_num = 1;
|
|
3197 prev_string_offset = 0;
|
|
3198 pLevelStrOffsets[0] = 0;
|
|
3199 for (uint i = 0; i < uLevelStrFileSize; ++i)
|
|
3200 {
|
|
3201 if (!pLevelStr[i])
|
|
3202 {
|
|
3203 pLevelStrOffsets[string_num] = i + 1;
|
|
3204 ++string_num;
|
|
3205 if (i - prev_string_offset > max_string_length)
|
|
3206 max_string_length = i - prev_string_offset;
|
|
3207 prev_string_offset = i;
|
|
3208 }
|
|
3209 }
|
|
3210
|
|
3211 uLevelStrNumStrings = string_num - 1;
|
|
3212 if (max_string_length > 800)
|
|
3213 Error("MAX_EVENT_TEXT_LENGTH needs to be increased to %lu", max_string_length + 1);
|
|
3214
|
|
3215 if (uLevelStrNumStrings > 0)
|
|
3216 {
|
|
3217 for (uint i = 0; i <uLevelStrNumStrings; ++i)
|
|
3218 {
|
|
3219 if (RemoveQuotes(&pLevelStr[pLevelStrOffsets[i]]) != &pLevelStr[pLevelStrOffsets[i]])
|
|
3220 ++pLevelStrOffsets[i];
|
|
3221 }
|
|
3222 }
|
|
3223 }
|
|
3224
|
|
3225 //----- (00443F95) --------------------------------------------------------
|
|
3226 void OnMapLeave()
|
|
3227 {
|
|
3228 _evt_raw *test_event;
|
|
3229 if (uLevelEVT_NumEvents > 0)
|
|
3230 {
|
|
3231 for (uint i = 0; i < uLevelEVT_NumEvents; ++i)
|
|
3232 {
|
|
3233 test_event = (_evt_raw*)&pLevelEVT[pLevelEVT_Index[i].uEventOffsetInEVT];
|
|
3234 if (test_event->_e_type == EVENT_OnMapLeave)
|
|
3235 {
|
|
3236 EventProcessor(pLevelEVT_Index[i].uEventID, 0, 1, pLevelEVT_Index[i].event_sequence_num);
|
|
3237 }
|
|
3238 }
|
|
3239 }
|
|
3240 }
|
|
3241
|
|
3242 //----- (00443FDC) --------------------------------------------------------
|
|
3243 void OnMapLoad()
|
|
3244 {
|
|
3245 int v6; // eax@9
|
|
3246 unsigned __int64 v8; // qax@26
|
|
3247 int hours; // ebx@26
|
|
3248 unsigned __int64 v18; // [sp+Ch] [bp-44h]@12
|
|
3249 unsigned int seconds; // [sp+14h] [bp-3Ch]@26
|
|
3250 unsigned __int64 v20; // [sp+1Ch] [bp-34h]@7
|
|
3251 unsigned int minutes; // [sp+2Ch] [bp-24h]@26
|
|
3252 unsigned int years; // [sp+34h] [bp-1Ch]@26
|
|
3253 unsigned int weeks; // [sp+38h] [bp-18h]@26
|
|
3254 int v26; // [sp+3Ch] [bp-14h]@15
|
|
3255 unsigned int days; // [sp+3Ch] [bp-14h]@26
|
|
3256 unsigned int months; // [sp+40h] [bp-10h]@26
|
|
3257
|
|
3258 for (uint i = 0; i < uLevelEVT_NumEvents; ++i)
|
|
3259 {
|
|
3260 EventIndex pEvent = pLevelEVT_Index[i];
|
|
3261
|
|
3262 _evt_raw* _evt = (_evt_raw *)(&pLevelEVT[pEvent.uEventOffsetInEVT]);
|
|
3263
|
|
3264 if (_evt->_e_type == EVENT_PlaySound)
|
|
3265 pSoundList->LoadSound(EVT_DWORD(_evt->v5), 0);
|
|
3266 else if (_evt->_e_type == EVENT_OnMapReload)
|
|
3267 EventProcessor(pEvent.uEventID, 0, 0, pEvent.event_sequence_num);
|
|
3268 else if (_evt->_e_type == EVENT_OnTimer || _evt->_e_type == EVENT_Initialize)
|
|
3269 {
|
|
3270 //v3 = &MapsLongTimersList[MapsLongTimers_count];
|
|
3271 v20 = pOutdoor->loc_time.uLastVisitDay;
|
|
3272 if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
|
|
3273 v20 = pIndoor->stru1.uLastVisitDay;
|
|
3274
|
|
3275 MapsLongTimersList[MapsLongTimers_count].timer_evt_type = _evt->_e_type;
|
|
3276 MapsLongTimersList[MapsLongTimers_count].timer_evt_ID = pEvent.uEventID;
|
|
3277 MapsLongTimersList[MapsLongTimers_count].timer_evt_seq_num = pEvent.event_sequence_num;
|
|
3278
|
|
3279 MapsLongTimersList[MapsLongTimers_count].YearsInterval = _evt->v5;
|
|
3280 MapsLongTimersList[MapsLongTimers_count].MonthsInterval = _evt->v6;
|
|
3281 MapsLongTimersList[MapsLongTimers_count].WeeksInterval = _evt->v7;
|
|
3282 MapsLongTimersList[MapsLongTimers_count].HoursInterval = _evt->v8;
|
|
3283 MapsLongTimersList[MapsLongTimers_count].MinutesInterval = _evt->v9;
|
|
3284 MapsLongTimersList[MapsLongTimers_count].SecondsInterval = _evt->v10;
|
|
3285
|
|
3286
|
|
3287 v6 = ((unsigned short)_evt->v12 << 8) + _evt->v11;
|
|
3288
|
|
3289 MapsLongTimersList[MapsLongTimers_count].time_left_to_fire = ((unsigned short)_evt->v12 << 8) + _evt->v11;
|
|
3290 MapsLongTimersList[MapsLongTimers_count].IntervalHalfMins = ((unsigned short)_evt->v12 << 8) + _evt->v11;
|
|
3291 if (MapsLongTimersList[MapsLongTimers_count].timer_evt_type == EVENT_Initialize && !(short)v6)
|
|
3292 {
|
|
3293 if (v20)
|
|
3294 v18 = pParty->uTimePlayed - v20;
|
|
3295 else
|
|
3296 v18 = 0;
|
|
3297 v26 = (signed int)(signed __int64)((double)(signed __int64)v18 * 0.234375) / 60 / 60 / 24;
|
|
3298
|
|
3299 if (v26 / 7 / 4 / 12 != 0 && MapsLongTimersList[MapsLongTimers_count].YearsInterval ||
|
|
3300 v26 / 7 / 4 != 0 && MapsLongTimersList[MapsLongTimers_count].MonthsInterval != 0 ||
|
|
3301 v26 / 7 != 0 && MapsLongTimersList[MapsLongTimers_count].WeeksInterval != 0 ||
|
|
3302 v26 != 0 || !v20)
|
|
3303 {
|
|
3304 ++MapsLongTimers_count;
|
|
3305 MapsLongTimersList[MapsLongTimers_count].NextStartTime = 0;
|
|
3306 continue;
|
|
3307 }
|
|
3308 }
|
|
3309 else
|
|
3310 {
|
|
3311 v8 = (__int64)((double)pParty->uTimePlayed * 0.234375);
|
|
3312 seconds = v8 % 60;
|
|
3313 minutes = (v8 / 60) % 60;
|
|
3314 hours = ((v8 / 60) / 60) % 24;
|
|
3315 days = (((v8 / 60) / 60) / 24) % 7;
|
|
3316 weeks = ((((v8 / 60) / 60) / 24) / 7) % 4;
|
|
3317 months = (((((v8 / 60) / 60) / 24) / 7) / 4) % 12;
|
|
3318 years = (((((v8 / 60) / 60) / 24) / 7) / 4) / 12;
|
|
3319
|
|
3320 if (MapsLongTimersList[MapsLongTimers_count].YearsInterval)
|
|
3321 ++years;
|
|
3322 else if (MapsLongTimersList[MapsLongTimers_count].MonthsInterval)
|
|
3323 ++months;
|
|
3324 else if (MapsLongTimersList[MapsLongTimers_count].WeeksInterval)
|
|
3325 ++weeks;
|
|
3326 else
|
|
3327 {
|
|
3328 ++days;
|
|
3329 hours = MapsLongTimersList[MapsLongTimers_count].HoursInterval;
|
|
3330 minutes = MapsLongTimersList[MapsLongTimers_count].MinutesInterval;
|
|
3331 seconds = MapsLongTimersList[MapsLongTimers_count].SecondsInterval;
|
|
3332 }
|
|
3333 MapsLongTimersList[MapsLongTimers_count].NextStartTime = (signed __int64)((double)((seconds
|
|
3334 + 60 * minutes
|
|
3335 + 3600 * hours
|
|
3336 + 86400 * days
|
|
3337 + 604800 * weeks
|
|
3338 + 2419200 * months
|
|
3339 + 29030400 * years) << 7)
|
|
3340 * 0.033333335);
|
|
3341
|
|
3342 ++MapsLongTimers_count;
|
|
3343 }
|
|
3344 }
|
|
3345 }
|
|
3346 }
|
|
3347
|
|
3348 //----- (00444360) --------------------------------------------------------
|
|
3349 void Level_LoadEvtAndStr(const char *pLevelName)
|
|
3350 {
|
|
3351 char pContainerName[120]; // [sp+8h] [bp-98h]@1
|
|
3352
|
|
3353 sprintf(pContainerName, "%s.evt", pLevelName);
|
|
3354 uLevelEVT_Size = LoadEventsToBuffer(pContainerName, pLevelEVT.data(), 9216);
|
|
3355
|
|
3356 sprintf(pContainerName, "%s.str", pLevelName);
|
|
3357 uLevelStrFileSize = LoadEventsToBuffer(pContainerName, pLevelStr.data(), 9216);
|
|
3358 if (uLevelStrFileSize)
|
|
3359 LoadLevel_InitializeLevelStr();
|
|
3360 }
|
|
3361
|
|
3362 //----- (004452BB) --------------------------------------------------------
|
|
3363 void sub_4452BB()
|
|
3364 {
|
|
3365 pGUIWindow2->Release();
|
|
3366 pGUIWindow2 = 0;
|
|
3367 activeLevelDecoration = _591094_decoration;
|
|
3368 EventProcessor(dword_5C3418, 0, 1, dword_5C341C);
|
|
3369 activeLevelDecoration = nullptr;
|
|
3370 pEventTimer->Resume();
|
|
3371 }
|
|
3372
|
|
3373 //----- (0044100D) --------------------------------------------------------
|
|
3374 bool _44100D_should_alter_right_panel()
|
|
3375 {
|
|
3376 return current_screen_type == SCREEN_NPC_DIALOGUE || current_screen_type == SCREEN_CHARACTERS ||
|
|
3377 current_screen_type == SCREEN_HOUSE || current_screen_type == SCREEN_E ||
|
|
3378 current_screen_type == SCREEN_CHANGE_LOCATION || current_screen_type == SCREEN_INPUT_BLV || current_screen_type == SCREEN_CASTING;
|
|
3379 }
|
|
3380
|
|
3381 //----- (0044987B) --------------------------------------------------------
|
|
3382 void Transition_StopSound_Autosave(const char *pMapName, MapStartPoint start_point)
|
|
3383 {
|
|
3384 pAudioPlayer->StopChannels(-1, -1);
|
|
3385 pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_None);
|
|
3386 if (_stricmp(pCurrentMapName, pMapName))
|
|
3387 SaveGame(1, 0);
|
|
3388
|
|
3389 uGameState = GAME_STATE_CHANGE_LOCATION;
|
|
3390 strcpy(pCurrentMapName, pMapName);
|
|
3391 uLevel_StartingPointType = start_point;
|
|
3392 }
|
|
3393 // 6BE35C: using guessed type int uLevel_StartingPointType;
|
|
3394
|
|
3395 //----- (004451A8) --------------------------------------------------------
|
|
3396 void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4)
|
|
3397 {
|
|
3398 if (!pGUIWindow2)
|
|
3399 {
|
|
3400 if (pParty->uFlags & 2)
|
|
3401 pEngine->Draw();
|
|
3402 pAudioPlayer->StopChannels(-1, -1);
|
|
3403 pMiscTimer->Pause();
|
|
3404 pEventTimer->Pause();
|
|
3405 dword_5C3418 = a1;
|
|
3406 dword_5C341C = a2;
|
|
3407 _591094_decoration = activeLevelDecoration;
|
|
3408 pGUIWindow2 = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_GreetingNPC, a4, 0);
|
|
3409 pGUIWindow2->CreateButton(61, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0);
|
|
3410 pGUIWindow2->CreateButton(177, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0);
|
|
3411 pGUIWindow2->CreateButton(292, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0);
|
|
3412 pGUIWindow2->CreateButton(407, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0);
|
|
3413 }
|
|
3414 }
|
|
3415
|
|
3416
|
|
3417
|
|
3418
|
|
3419 //----- (00448B67) --------------------------------------------------------
|
|
3420 void OnTimer(int)
|
|
3421 {
|
|
3422 if (pEventTimer->bPaused)
|
|
3423 return;
|
|
3424
|
|
3425 long long v13 = (signed __int64)(pParty->uTimePlayed - _5773B8_event_timer) / 128;
|
|
3426 if (!v13)
|
|
3427 return;
|
|
3428
|
|
3429 //uint _v2v3 = pParty->uTimePlayed;
|
|
3430 //v3 = HIDWORD(pParty->uTimePlayed);
|
|
3431 //v2 = LODWORD(pParty->uTimePlayed);
|
|
3432
|
|
3433 _5773B8_event_timer = pParty->uTimePlayed;
|
|
3434
|
|
3435 for (uint i = 0; i < MapsLongTimers_count; ++i)
|
|
3436 {
|
|
3437 //v4 = (char *)&array_5B5928_timers[0].field_C;
|
|
3438 MapsLongTimer* timer = &MapsLongTimersList[i];
|
|
3439 //while ( 1 )
|
|
3440 //{
|
|
3441 //v5 = *(short *)v4;
|
|
3442 if (timer->time_left_to_fire)
|
|
3443 {
|
|
3444 if (v13 < timer->time_left_to_fire)
|
|
3445 timer->time_left_to_fire -= v13;
|
|
3446 else
|
|
3447 {
|
|
3448 timer->time_left_to_fire = timer->IntervalHalfMins;
|
|
3449 EventProcessor(timer->timer_evt_ID, 0, 1, timer->timer_evt_seq_num);
|
|
3450 }
|
|
3451 }
|
|
3452 else
|
|
3453 {
|
|
3454 if (timer->NextStartTime < pParty->uTimePlayed)
|
|
3455 {
|
|
3456 uint next_trigger_time = 1 * 60 * 60 * 24; // 1 day
|
|
3457 if (timer->YearsInterval)
|
|
3458 next_trigger_time = 336 * 60 * 60 * 24; // 1 year
|
|
3459 else if (timer->MonthsInterval)
|
|
3460 next_trigger_time = 28 * 60 * 60 * 24; // 1 month
|
|
3461 else if (timer->WeeksInterval)
|
|
3462 next_trigger_time = 7 * 60 * 60 * 24; // 1 week
|
|
3463
|
|
3464 timer->NextStartTime += (next_trigger_time * 128) / 3.0f;
|
|
3465 if (timer->NextStartTime < pParty->uTimePlayed) // make sure in wont fire several times in a row if big time interval has lapsed
|
|
3466 timer->NextStartTime = pParty->uTimePlayed;
|
|
3467
|
|
3468 EventProcessor(timer->timer_evt_ID, 0, 1, timer->timer_evt_seq_num);
|
|
3469 }
|
|
3470 }
|
|
3471 }
|
|
3472 }
|
|
3473
|
|
3474
|
|
3475
|
|
3476
|
|
3477
|
|
3478
|
|
3479
|
|
3480 //----- (0044C28F) --------------------------------------------------------
|
|
3481 bool TeleportToNWCDungeon()
|
|
3482 {
|
|
3483 if (!_stricmp("nwc.blv", pCurrentMapName))
|
|
3484 return false;
|
|
3485
|
|
3486 _5B65A8_npcdata_uflags_or_other = 0;
|
|
3487 _5B65AC_npcdata_fame_or_other = 0;
|
|
3488 _5B65B0_npcdata_rep_or_other = 0;
|
|
3489 _5B65B4_npcdata_loword_house_or_other = 0;
|
|
3490 _5B65B8_npcdata_hiword_house_or_other = 0;
|
|
3491 dword_5B65BC = 0;
|
|
3492 dword_5B65C0 = 0;
|
|
3493
|
|
3494 pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen;
|
|
3495 Transition_StopSound_Autosave("nwc.blv", MapStartPoint_Party);
|
|
3496 current_screen_type = SCREEN_GAME;
|
|
3497 return true;
|
|
3498 }
|
|
3499
|
|
3500 //----- (00401000) --------------------------------------------------------
|
|
3501 void mm7__vector_constructor(void *a1, int objSize, int numObjs, int(*constructor)(int))
|
|
3502 {
|
|
3503 void *v4; // esi@2
|
|
3504
|
|
3505 if (numObjs > 0)
|
|
3506 {
|
|
3507 v4 = a1;
|
|
3508 for (int i = numObjs; i; --i)
|
|
3509 {
|
|
3510 constructor((int)v4);
|
|
3511 v4 = (char *)v4 + objSize;
|
|
3512 }
|
|
3513 }
|
|
3514 }
|
|
3515
|
|
3516
|
|
3517
|