Mercurial > mm7
annotate Engine/Engine.cpp @ 2563:65c97624c047
Saving & loading works from both main menu and game
author | a.parshin |
---|---|
date | Tue, 19 May 2015 22:00:56 +0200 |
parents | b8a56afc6ba1 |
children | f9bdfe26d03d |
rev | line source |
---|---|
2541 | 1 #define _CRTDBG_MAP_ALLOC |
2553 | 2 #define _CRT_SECURE_NO_WARNINGS |
2541 | 3 #include <stdlib.h> |
4 #include <crtdbg.h> | |
2553 | 5 #include <direct.h> |
2541 | 6 |
7 #include "Engine/Engine.h" | |
2553 | 8 #include "Engine/Party.h" |
9 #include "Engine/Timer.h" | |
10 #include "Engine/LOD.h" | |
11 #include "Engine/Events.h" | |
12 #include "Engine/OurMath.h" | |
13 #include "Engine/texts.h" | |
14 #include "Engine/stru123.h" | |
15 #include "Engine/LuaVM.h" | |
16 #include "Engine/MMT.h" | |
17 #include "Engine/SaveLoad.h" | |
18 #include "Engine/Registry.h" | |
2541 | 19 #include "Engine/Graphics/Vis.h" |
20 #include "Engine/Graphics/Weather.h" | |
21 #include "Engine/Graphics/LightmapBuilder.h" | |
22 #include "Engine/Graphics/DecalBuilder.h" | |
23 #include "Engine/Graphics/ParticleEngine.h" | |
24 #include "Engine/Graphics/GammaControl.h" | |
25 #include "Engine/Graphics/stru9.h" | |
26 #include "Engine/Graphics/stru10.h" | |
27 #include "Engine/Graphics/Viewport.h" | |
28 #include "Engine/Graphics/Outdoor.h" | |
29 #include "Engine/Graphics/Overlays.h" | |
2553 | 30 #include "Engine/Graphics/Lights.h" |
31 #include "Engine/Graphics/Level/Decoration.h" | |
32 #include "Engine/Graphics/PaletteManager.h" | |
33 #include "Engine/Graphics/DecorationList.h" | |
34 #include "Engine/Graphics/RenderD3D11.h" | |
35 #include "Engine/Graphics/Sprites.h" | |
2541 | 36 #include "Engine/TurnEngine/TurnEngine.h" |
37 #include "Engine/Spells/CastSpellInfo.h" | |
38 #include "Engine/Tables/FrameTableInc.h" | |
39 #include "Engine/Objects/Actor.h" | |
2553 | 40 #include "Engine/Objects/ObjectList.h" |
41 #include "Engine/Objects/SpriteObject.h" | |
42 #include "Engine/Objects/Chest.h" | |
43 | |
44 #include "Arcomage\Arcomage.h" | |
45 | |
46 #include "IO/Mouse.h" | |
47 #include "IO/Keyboard.h" | |
48 | |
49 #include "GUI/GUIWindow.h" | |
2541 | 50 #include "GUI/GUIProgressBar.h" |
2553 | 51 #include "GUI/GUIFont.h" |
52 #include "GUI/UI/UIGame.h" | |
2541 | 53 #include "GUI/UI/UIHouses.h" |
54 #include "GUI/UI/UIShops.h" | |
55 #include "GUI/UI/UIPartyCreation.h" | |
2553 | 56 |
57 #include "GUI/NewUI/MainMenu.h" | |
58 | |
59 #include "Media/Audio/AudioPlayer.h" | |
60 #include "Media/Video/Bink_Smacker.h" | |
61 | |
2541 | 62 #include "Engine/Tables/IconFrameTable.h" |
63 #include "Engine/Tables/PlayerFrameTable.h" | |
64 #include "Engine/Tables/StorylineTextTable.h" | |
65 #include "Engine/Tables/FactionTable.h" | |
2553 | 66 #include "Engine/MapsLongTimer.h" |
2541 | 67 |
68 #include "Game/Game.h" | |
2543 | 69 #include "Game/MainMenu.h" |
2553 | 70 #include "Game/MainMenuLoad.h" |
71 #include "Game/CreateParty.h" | |
72 | |
73 #include "stru6.h" | |
2541 | 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); | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2555
diff
changeset
|
463 pLightmapBuilder->StationaryLightsCount = 0; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2555
diff
changeset
|
464 pLightmapBuilder->MobileLightsCount = 0; |
2541 | 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 { | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2555
diff
changeset
|
548 if (/*uFlags & 0x04*/ debug_lights) |
2541 | 549 { |
550 pLightmapBuilder->DrawDebugOutlines(-1); | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2555
diff
changeset
|
551 //pDecalBuilder->DrawDecalDebugOutlines(); |
2541 | 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"); | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2543
diff
changeset
|
1062 //static_assert(sizeof(GUIWindow) == 0x54, "Wrong type size"); |
2541 | 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"); | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2555
diff
changeset
|
1069 static_assert(sizeof(LightsData) == 0x3FC, "Wrong type size"); |
2541 | 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; | |
2551
4008b2f34be0
MainMenu rendering moved from event loop to respective window class
a.parshin
parents:
2544
diff
changeset
|
1746 bool use_music_folder = false; |
2541 | 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 { | |
2552
ac16f4a3a91e
Load from MainMenu logic separated from MainMenu window
a.parshin
parents:
2551
diff
changeset
|
1814 //MainMenuWindow *main_menu_window = MainMenuWindow::Create(); |
ac16f4a3a91e
Load from MainMenu logic separated from MainMenu window
a.parshin
parents:
2551
diff
changeset
|
1815 //window->AddControl(main_menu_window); |
2541 | 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 } | |
2553 | 1825 else if (GetCurrentMenuID() == MENU_SAVELOAD) |
2541 | 1826 { |
2553 | 1827 MainMenuLoad_Loop(); |
2563
65c97624c047
Saving & loading works from both main menu and game
a.parshin
parents:
2562
diff
changeset
|
1828 if (GetCurrentMenuID() == MENU_LoadingProcInMainMenu) |
65c97624c047
Saving & loading works from both main menu and game
a.parshin
parents:
2562
diff
changeset
|
1829 { |
65c97624c047
Saving & loading works from both main menu and game
a.parshin
parents:
2562
diff
changeset
|
1830 uGameState = GAME_STATE_PLAYING; |
65c97624c047
Saving & loading works from both main menu and game
a.parshin
parents:
2562
diff
changeset
|
1831 Game_Loop(); |
65c97624c047
Saving & loading works from both main menu and game
a.parshin
parents:
2562
diff
changeset
|
1832 } |
2553 | 1833 break; |
1834 } | |
1835 else if (GetCurrentMenuID() == MENU_NEWGAME) | |
1836 { | |
1837 if (!CreateParty_Loop()) | |
2541 | 1838 break; |
2553 | 1839 |
2541 | 1840 bFlashQuestBook = true; |
1841 pMediaPlayer->PlayFullscreenMovie(MOVIE_Emerald, true); | |
1842 SaveNewGame(); | |
1843 if (bNoMargareth) | |
1844 _449B7E_toggle_bit(pParty->_quest_bits, PARTY_QUEST_EMERALD_MARGARETH_OFF, 1); | |
1845 Game_Loop(); | |
1846 if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU) | |
1847 { | |
1848 SetCurrentMenuID(MENU_NEWGAME); | |
1849 uGameState = GAME_STATE_PLAYING; | |
1850 continue; | |
1851 } | |
1852 else if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU) | |
1853 break; | |
1854 assert(false && "Invalid game state"); | |
1855 } | |
2543 | 1856 else if (GetCurrentMenuID() == MENU_CREDITS) |
2541 | 1857 { |
1858 if (use_music_folder) | |
1859 alSourceStop(mSourceID); | |
1860 else | |
1861 { | |
1862 if (pAudioPlayer->hAILRedbook) | |
1863 AIL_redbook_stop(pAudioPlayer->hAILRedbook); | |
1864 } | |
1865 MainMenuUI_Credits_Loop(); | |
1866 break; | |
1867 } | |
2543 | 1868 else if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu) |
2541 | 1869 { |
1870 uGameState = GAME_STATE_PLAYING; | |
1871 Game_Loop(); | |
1872 } | |
2543 | 1873 else if (GetCurrentMenuID() == MENU_DebugBLVLevel) |
2541 | 1874 { |
2543 | 1875 pMouse->ChangeActivation(0); |
1876 pParty->Reset(); | |
1877 pParty->CreateDefaultParty(1); | |
1878 | |
1879 __debugbreak(); | |
1880 /*extern void CreateDefaultBLVLevel(); | |
1881 CreateDefaultBLVLevel(); | |
1882 | |
1883 OPENFILENAMEA ofn; | |
1884 if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) ) | |
2541 | 1885 { |
2543 | 1886 pMouse->ChangeActivation(1); |
1887 break; | |
2541 | 1888 } |
2543 | 1889 _chdir("..\\"); |
1890 strcpy(pCurrentMapName, ofn.lpstrFileTitle);*/ | |
1891 pMouse->ChangeActivation(1); | |
1892 Game_Loop(); | |
2541 | 1893 } |
1894 if (uGameState == GAME_STATE_LOADING_GAME) | |
1895 { | |
1896 SetCurrentMenuID(MENU_5); | |
1897 uGameState = GAME_STATE_PLAYING; | |
1898 continue; | |
1899 } | |
1900 if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU) | |
1901 { | |
1902 SetCurrentMenuID(MENU_NEWGAME); | |
1903 uGameState = GAME_STATE_PLAYING; | |
1904 continue; | |
1905 } | |
1906 if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)// from the loaded game | |
1907 { | |
1908 pAudioPlayer->StopChannels(-1, -1); | |
1909 uGameState = GAME_STATE_PLAYING; | |
1910 break; | |
1911 } | |
1912 } | |
1913 if (!bNoSound) | |
1914 { | |
1915 if (use_music_folder) | |
1916 { | |
1917 PlayAudio(L"Music\\14.mp3"); | |
1918 alSourcef(mSourceID, AL_GAIN, pSoundVolumeLevels[uMusicVolimeMultiplier]); | |
1919 } | |
1920 else if (pAudioPlayer->hAILRedbook) | |
1921 { | |
1922 pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); | |
1923 AIL_redbook_stop(pAudioPlayer->hAILRedbook); | |
1924 unsigned int startms, end_ms; | |
1925 AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &startms, &end_ms); | |
1926 AIL_redbook_play(pAudioPlayer->hAILRedbook, startms + 1, end_ms); | |
1927 } | |
1928 } | |
1929 } | |
1930 //lua_close(L); | |
1931 pEngine->Deinitialize(); | |
1932 return 1; | |
1933 } | |
1934 | |
1935 | |
1936 | |
1937 //----- (00466082) -------------------------------------------------------- | |
1938 void MM6_Initialize(const wchar_t *pIniFilename) | |
1939 { | |
1940 size_t v2; // eax@31 | |
1941 size_t v3; // ebx@32 | |
1942 size_t v4; // edi@36 | |
1943 char pDefaultGroundTexture[16]; // [sp+FCh] [bp-8Ch]@32 | |
1944 unsigned int v9; // [sp+184h] [bp-4h]@28 | |
1945 | |
1946 //_getcwd(v5, 120); | |
1947 //sprintfex(pIniFilename, "%s\\mm6.ini", v5); | |
1948 viewparams = new ViewingParams; | |
1949 game_viewport_x = viewparams->uScreen_topL_X = GetPrivateProfileIntW(L"screen", L"vx1", 8, pIniFilename); | |
1950 game_viewport_y = viewparams->uScreen_topL_Y = GetPrivateProfileIntW(L"screen", L"vy1", 8, pIniFilename); | |
1951 game_viewport_z = viewparams->uScreen_BttmR_X = GetPrivateProfileIntW(L"screen", L"vx2", 468, pIniFilename); | |
1952 game_viewport_w = viewparams->uScreen_BttmR_Y = GetPrivateProfileIntW(L"screen", L"vy2", 351, pIniFilename); | |
1953 game_viewport_width = game_viewport_z - game_viewport_x; | |
1954 game_viewport_height = game_viewport_w - game_viewport_y + 1; | |
1955 | |
1956 | |
1957 pAudioPlayer = new AudioPlayer; | |
1958 pAudioPlayer->uMixerChannels = GetPrivateProfileIntW(L"settings", L"mixerchannels", 16, pIniFilename); | |
1959 if (pAudioPlayer->uMixerChannels > 16) | |
1960 pAudioPlayer->uMixerChannels = 16; | |
1961 | |
1962 | |
1963 if (GetPrivateProfileIntW(L"debug", L"nomonster", 0, pIniFilename)) | |
1964 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_NO_ACTORS; | |
1965 if (ReadWindowsRegistryInt("startinwindow", 0)) | |
1966 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_RUN_IN_WIDOW; | |
1967 if (GetPrivateProfileIntW(L"debug", L"showFR", 0, pIniFilename)) | |
1968 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_0002_SHOW_FR; | |
1969 if (GetPrivateProfileIntW(L"debug", L"nodamage", 0, pIniFilename)) | |
1970 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_NO_DAMAGE; | |
1971 if (GetPrivateProfileIntW(L"debug", L"nodecoration", 0, pIniFilename)) | |
1972 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_NO_DECORATIONS; | |
1973 | |
1974 wchar_t pStartingMapNameW[1024]; | |
1975 GetPrivateProfileStringW(L"file", L"startmap", L"out01.odm", pStartingMapNameW, 0x20u, pIniFilename); | |
1976 sprintf(pStartingMapName, "%S", pStartingMapNameW); | |
1977 | |
1978 v9 = 0; | |
1979 if (strlen(pStartingMapName)) | |
1980 { | |
1981 do | |
1982 { | |
1983 if (pStartingMapName[v9] == ' ') | |
1984 pStartingMapName[v9] = 0; | |
1985 ++v9; | |
1986 v2 = strlen(pStartingMapName); | |
1987 } while (v9 < v2); | |
1988 } | |
1989 | |
1990 pODMRenderParams = new ODMRenderParams; | |
1991 pODMRenderParams->outdoor_no_mist = GetPrivateProfileIntW(L"debug", L"noMist", 0, pIniFilename); | |
1992 pODMRenderParams->bNoSky = GetPrivateProfileIntW(L"outdoor", L"nosky", 0, pIniFilename); | |
1993 pODMRenderParams->bDoNotRenderDecorations = GetPrivateProfileIntW(L"render", L"nodecorations", 0, pIniFilename); | |
1994 pODMRenderParams->outdoor_no_wavy_water = GetPrivateProfileIntW(L"outdoor", L"nowavywater", 0, pIniFilename); | |
2543 | 1995 //outdoor_grid_band_1 = GetPrivateProfileIntW(L"outdoor", L"gridband1", 10, pIniFilename); |
1996 //outdoor_grid_band_2 = GetPrivateProfileIntW(L"outdoor", L"gridband2", 15, pIniFilename); | |
1997 //outdoor_grid_band_3 = GetPrivateProfileIntW(L"outdoor", L"gridband3", 25, pIniFilename); | |
2541 | 1998 pODMRenderParams->terrain_gamma = GetPrivateProfileIntW(L"outdoor", L"ter_gamma", 0, pIniFilename); |
1999 pODMRenderParams->building_gamme = GetPrivateProfileIntW(L"outdoor", L"bld_gamma", 0, pIniFilename); | |
2000 pODMRenderParams->shading_dist_shade = GetPrivateProfileIntW(L"shading", L"dist_shade", 2048, pIniFilename); | |
2001 pODMRenderParams->shading_dist_shademist = GetPrivateProfileIntW(L"shading", L"dist_shademist", 4096, pIniFilename); | |
2002 | |
2003 pODMRenderParams->shading_dist_mist = GetPrivateProfileIntW(L"shading", L"dist_mist", 0x2000, pIniFilename);//drawing dist 0x2000 | |
2004 | |
2005 wchar_t pDefaultSkyTextureW[1024]; | |
2006 GetPrivateProfileStringW(L"textures", L"sky", L"plansky1", pDefaultSkyTextureW, 0x10u, pIniFilename); | |
2007 sprintf(pDefaultSkyTexture.data(), "%S", pDefaultSkyTextureW); | |
2008 | |
2009 wchar_t pDefaultGroundTextureW[1024]; | |
2010 GetPrivateProfileStringW(L"textures", L"default", L"dirt", pDefaultGroundTextureW, 0x10u, pIniFilename); | |
2011 sprintf(pDefaultGroundTexture, "%S", pDefaultGroundTextureW); | |
2012 | |
2013 wchar_t pFloat[1024]; | |
2014 GetPrivateProfileStringW(L"debug", L"recmod1", L"1.0", pFloat, 0x10u, pIniFilename); | |
2015 swscanf(pFloat, L"%f", &flt_6BE3A4_debug_recmod1); | |
2016 | |
2017 GetPrivateProfileStringW(L"debug", L"recmod2", L"1.0", pFloat, 0x10u, pIniFilename); | |
2018 swscanf(pFloat, L"%f", &flt_6BE3A8_debug_recmod2); | |
2019 | |
2020 flt_6BE3AC_debug_recmod1_x_1_6 = flt_6BE3A4_debug_recmod1 * 1.666666666666667; | |
2021 | |
2022 v3 = 0; | |
2023 if (strlen(pDefaultSkyTexture.data())) | |
2024 { | |
2025 do | |
2026 { | |
2027 if (pDefaultSkyTexture[v3] == ' ') | |
2028 pDefaultSkyTexture[v3] = 0; | |
2029 ++v3; | |
2030 } while (v3 < strlen(pDefaultSkyTexture.data())); | |
2031 } | |
2032 v4 = 0; | |
2033 if (strlen(pDefaultGroundTexture)) | |
2034 { | |
2035 do | |
2036 { | |
2037 if (pDefaultGroundTexture[v4] == ' ') | |
2038 pDefaultGroundTexture[v4] = 0; | |
2039 ++v4; | |
2040 } while (v4 < strlen(pDefaultGroundTexture)); | |
2041 } | |
2042 | |
2043 MM7Initialization(); | |
2044 } | |
2045 | |
2046 //----- (004666D5) -------------------------------------------------------- | |
2047 void MM7Initialization() | |
2048 { | |
2049 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
2050 { | |
2051 /*if (byte_6BE388_graphicsmode == 0) | |
2052 { | |
2053 outdoor_grid_band_1 = 10; | |
2054 outdoor_grid_band_2 = 15; | |
2055 outdoor_grid_band_3 = 20; | |
2056 pODMRenderParams->shading_dist_mist = 8192; | |
2057 pODMRenderParams->bNoSky = false; | |
2058 LOBYTE(viewparams->field_20) = 0; | |
2059 }*/ | |
2060 pODMRenderParams->shading_dist_shade = 2048; | |
2061 pODMRenderParams->terrain_gamma = 0; | |
2062 pODMRenderParams->building_gamme = 0; | |
2063 pODMRenderParams->shading_dist_shademist = 4096; | |
2064 pODMRenderParams->outdoor_no_wavy_water = 0; | |
2065 //_47F4D3_initialize_terrain_bezier_stuff(outdoor_grid_band_1, outdoor_grid_band_2, outdoor_grid_band_3); | |
2066 { | |
2543 | 2067 pODMRenderParams->outdoor_grid_band_3 = 25;//outdoor_grid_band_3; |
2068 pODMRenderParams->uPickDepth = 25 * 512;//outdoor_grid_band_3 * 512; | |
2541 | 2069 } |
2070 } | |
2071 else | |
2072 LOBYTE(viewparams->field_20) = 0; | |
2543 | 2073 |
2541 | 2074 pParty->uFlags |= 2; |
2075 viewparams->uSomeY = viewparams->uScreen_topL_Y; | |
2076 viewparams->uSomeX = viewparams->uScreen_topL_X; | |
2077 viewparams->uSomeZ = viewparams->uScreen_BttmR_X; | |
2078 viewparams->uSomeW = viewparams->uScreen_BttmR_Y; | |
2079 | |
2080 pViewport->SetScreen(viewparams->uScreen_topL_X, viewparams->uScreen_topL_Y, viewparams->uScreen_BttmR_X, viewparams->uScreen_BttmR_Y); | |
2081 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
2082 pODMRenderParams->Initialize(); | |
2083 } | |
2084 | |
2085 //----- (004610AA) -------------------------------------------------------- | |
2086 void __fastcall PrepareToLoadODM(unsigned int bLoading, ODMRenderParams *a2) | |
2087 { | |
2088 pGameLoadingUI_ProgressBar->Reset(27); | |
2089 pSoundList->_4A9D79(0); | |
2090 uCurrentlyLoadedLevelType = LEVEL_Outdoor; | |
2091 ODM_LoadAndInitialize(pCurrentMapName, a2); | |
2092 if (!bLoading) | |
2093 TeleportToStartingPoint(uLevel_StartingPointType); | |
2094 viewparams->_443365(); | |
2095 PlayLevelMusic(); | |
2096 } | |
2543 | 2097 |
2541 | 2098 |
2099 //----- (00464479) -------------------------------------------------------- | |
2100 void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows() | |
2101 { | |
2102 if (pMouse) | |
2103 pMouse->SetCursorBitmap("MICON1"); | |
2104 | |
2105 pPaletteManager->ResetNonLocked(); | |
2106 pBitmaps_LOD->ReleaseAll2(); | |
2107 pSprites_LOD->DeleteSomeOtherSprites(); | |
2108 pIcons_LOD->ReleaseAll2(); | |
2109 | |
2110 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
2111 pIndoor->Release(); | |
2112 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
2113 pOutdoor->Release(); | |
2114 | |
2115 pAudioPlayer->StopChannels(-1, -1); | |
2116 pSoundList->_4A9D79(0); | |
2117 uCurrentlyLoadedLevelType = LEVEL_null; | |
2118 pSpriteFrameTable->ResetSomeSpriteFlags(); | |
2119 pParty->armageddon_timer = 0; | |
2555
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2554
diff
changeset
|
2120 |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2554
diff
changeset
|
2121 while (uNumVisibleWindows > 0) |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2543
diff
changeset
|
2122 { |
2555
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2554
diff
changeset
|
2123 pWindowList[pVisibleWindowsIdxs[uNumVisibleWindows] - 1]->Release(); |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2554
diff
changeset
|
2124 delete pWindowList[pVisibleWindowsIdxs[uNumVisibleWindows] - 1]; |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2554
diff
changeset
|
2125 pWindowList[pVisibleWindowsIdxs[uNumVisibleWindows] - 1] = nullptr; |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2554
diff
changeset
|
2126 |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2554
diff
changeset
|
2127 uNumVisibleWindows--; |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2543
diff
changeset
|
2128 } |
2541 | 2129 } |
2130 | |
2131 //----- (00461103) -------------------------------------------------------- | |
2132 void _461103_load_level_sub() | |
2133 { | |
2134 int v4; // edx@8 | |
2135 signed int v6; // esi@14 | |
2136 signed int v8; // ecx@16 | |
2137 int v12; // esi@25 | |
2138 int v13; // eax@26 | |
2139 __int16 v14; // ax@41 | |
2140 signed int v17; // [sp+14h] [bp-48h]@3 | |
2141 signed int v18; // [sp+14h] [bp-48h]@23 | |
2142 int v19; // [sp+18h] [bp-44h]@1 | |
2143 signed int v20; // [sp+18h] [bp-44h]@14 | |
2144 int v21[16]; // [sp+1Ch] [bp-40h]@17 | |
2145 | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2555
diff
changeset
|
2146 if(no_actors) |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2555
diff
changeset
|
2147 uNumActors = 0; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2555
diff
changeset
|
2148 |
2541 | 2149 GenerateItemsInChest(); |
2150 pGameLoadingUI_ProgressBar->Progress(); | |
2151 pParty->uFlags |= 2; | |
2152 pParty->field_7B5_in_arena_quest = 0; | |
2153 dword_5C6DF8 = 1; | |
2154 pNPCStats->uNewlNPCBufPos = 0; | |
2155 v19 = pMapStats->GetMapInfo(pCurrentMapName); | |
2156 | |
2157 //v15 = 0; | |
2158 for (uint i = 0; i < uNumActors; ++i) | |
2159 //if ( (signed int)uNumActors > 0 ) | |
2160 { | |
2161 //Actor* pActor = &pActors[i]; | |
2162 //v2 = (char *)&pActors[0].uNPC_ID; | |
2163 //do | |
2164 //{ | |
2165 //v3 = pActors[i].pMonsterInfo.uID; | |
2166 v17 = 0; | |
2167 if (pActors[i].pMonsterInfo.uID >= 115 && pActors[i].pMonsterInfo.uID <= 186 | |
2168 || pActors[i].pMonsterInfo.uID >= 232 && pActors[i].pMonsterInfo.uID <= 249) | |
2169 v17 = 1; | |
2170 //v1 = 0; | |
2171 v4 = (pActors[i].pMonsterInfo.uID - 1) % 3; | |
2172 if (2 == v4) | |
2173 { | |
2174 if (pActors[i].sNPC_ID && pActors[i].sNPC_ID < 5000) | |
2175 continue; | |
2176 } | |
2177 else | |
2178 { | |
2179 if (v4 != 1) | |
2180 { | |
2181 if (v4 == 0 && pActors[i].sNPC_ID == 0) | |
2182 pActors[i].sNPC_ID = 0; | |
2183 continue; | |
2184 } | |
2185 } | |
2186 if (pActors[i].sNPC_ID > 0 && pActors[i].sNPC_ID < 5000) | |
2187 continue; | |
2188 if (v17) | |
2189 { | |
2190 pNPCStats->InitializeAdditionalNPCs(&pNPCStats->pAdditionalNPC[pNPCStats->uNewlNPCBufPos], pActors[i].pMonsterInfo.uID, 0, v19); | |
2191 v14 = LOWORD(pNPCStats->uNewlNPCBufPos) + 5000; | |
2192 ++pNPCStats->uNewlNPCBufPos; | |
2193 pActors[i].sNPC_ID = v14; | |
2194 continue; | |
2195 } | |
2196 pActors[i].sNPC_ID = 0; | |
2197 //++v15; | |
2198 //v2 += 836; | |
2199 //} | |
2200 //while ( v15 < (signed int)uNumActors ); | |
2201 } | |
2202 | |
2203 pGameLoadingUI_ProgressBar->Progress(); | |
2204 | |
2205 //v5 = uNumActors; | |
2206 v6 = 0; | |
2207 v20 = 0; | |
2208 //v16 = v1; | |
2209 | |
2210 for (uint i = 0; i < uNumActors; ++i) | |
2211 { | |
2212 //v7 = (char *)&pActors[0].pMonsterInfo; | |
2213 //do | |
2214 //{ | |
2215 for (v8 = 0; v8 < v6; ++v8) | |
2216 { | |
2217 if (v21[v8] == pActors[i].pMonsterInfo.uID - 1) | |
2218 break; | |
2219 } | |
2220 | |
2221 if (v8 == v6) | |
2222 { | |
2223 v21[v6++] = pActors[i].pMonsterInfo.uID - 1; | |
2224 v20 = v6; | |
2225 if (v6 == 16) | |
2226 break; | |
2227 } | |
2228 //++v16; | |
2229 //v7 += 836; | |
2230 //} | |
2231 //while ( v16 < (signed int)v5 ); | |
2232 } | |
2233 | |
2234 pGameLoadingUI_ProgressBar->Progress(); | |
2235 | |
2236 for (int _v0 = 0; _v0 < v6; ++_v0) | |
2237 { | |
2238 for (v18 = 4; v18; --v18) | |
2239 pSoundList->LoadSound(pMonsterList->pMonsters[v21[_v0]].pSoundSampleIDs[4 - v18], 0); | |
2240 v12 = 0; | |
2241 do | |
2242 v13 = pSoundList->LoadSound(v12++ + word_4EE088_sound_ids[pMonsterStats->pInfos[v21[_v0] + 1].uSpell1ID], 1); | |
2243 while (v13); | |
2244 } | |
2245 //v0 = pGameLoadingUI_ProgressBar; | |
2246 //v1 = 0; | |
2247 | |
2248 pGameLoadingUI_ProgressBar->Progress(); | |
2249 | |
2250 if (dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_ACTORS) | |
2251 uNumActors = 0; | |
2252 if (dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_DECORATIONS) | |
2253 uNumLevelDecorations = 0; | |
2254 init_event_triggers(); | |
2255 | |
2256 pGameLoadingUI_ProgressBar->Progress(); | |
2257 | |
2543 | 2258 pIndoorCameraD3D->vPartyPos.x = 0; |
2259 pIndoorCameraD3D->vPartyPos.y = 0; | |
2260 pIndoorCameraD3D->vPartyPos.z = 100; | |
2261 pIndoorCameraD3D->sRotationX = 0; | |
2262 pIndoorCameraD3D->sRotationY = 0; | |
2541 | 2263 viewparams->bRedrawGameUI = true; |
2264 uLevel_StartingPointType = MapStartPoint_Party; | |
2265 pSprites_LOD->_461397(); | |
2266 pPaletteManager->LockTestAll(); | |
2267 if (pParty->pPickedItem.uItemID != 0) | |
2268 pMouse->SetCursorBitmapFromItemID(pParty->pPickedItem.uItemID); | |
2269 } | |
2270 | |
2271 //----- (0042F3D6) -------------------------------------------------------- | |
2272 void InitializeTurnBasedAnimations(void *_this) | |
2273 { | |
2274 for (unsigned int i = 0; i < pIconIDs_Turn.size(); ++i) | |
2275 { | |
2276 char icon_name[32]; | |
2277 sprintf(icon_name, "turn%u", i); | |
2278 pIconIDs_Turn[i] = pIconsFrameTable->FindIcon(icon_name); | |
2279 pIconsFrameTable->InitializeAnimation(pIconIDs_Turn[i]); | |
2280 } | |
2281 | |
2282 uIconID_TurnStop = pIconsFrameTable->FindIcon("turnstop"); | |
2283 uIconID_TurnHour = pIconsFrameTable->FindIcon("turnhour"); | |
2284 uIconID_TurnStart = pIconsFrameTable->FindIcon("turnstart"); | |
2285 uIconID_CharacterFrame = pIconsFrameTable->FindIcon("aframe1"); | |
2286 uSpriteID_Spell11 = pSpriteFrameTable->FastFindSprite("spell11"); | |
2287 | |
2288 pIconsFrameTable->InitializeAnimation(uIconID_TurnHour); | |
2289 pIconsFrameTable->InitializeAnimation(uIconID_TurnStop); | |
2290 pIconsFrameTable->InitializeAnimation(uIconID_TurnStart); | |
2291 pIconsFrameTable->InitializeAnimation(uIconID_CharacterFrame); | |
2292 } | |
2293 | |
2294 //----- (0046BDA8) -------------------------------------------------------- | |
2295 unsigned int GetGravityStrength() | |
2296 { | |
2297 int v0; // eax@1 | |
2298 | |
2299 v0 = ~LOBYTE(pEngine->uFlags2) & 8; | |
2300 LOBYTE(v0) = v0 | 2; | |
2301 return (unsigned int)v0 >> 1; | |
2302 } | |
2303 | |
2304 //----- (00448B45) -------------------------------------------------------- | |
2305 void GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide) | |
2306 { | |
2307 if (bForceHide || GameUI_Footer_TimeLeft && GetTickCount() >= GameUI_Footer_TimeLeft) | |
2308 GameUI_Footer_TimeLeft = 0; | |
2309 } | |
2310 | |
2311 //----- (0044861E) -------------------------------------------------------- | |
2312 void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename) | |
2313 { | |
2314 unsigned int texture; // eax@2 | |
2315 | |
2316 if (uFaceCog) | |
2317 { | |
2318 texture = pBitmaps_LOD->LoadTexture(pFilename); | |
2319 if (texture != -1 ? (int)&pBitmaps_LOD->pTextures[texture] : 0) | |
2320 { | |
2321 pBitmaps_LOD->pTextures[texture].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[texture].palette_id1); | |
2322 | |
2323 if (uCurrentlyLoadedLevelType == 1) | |
2324 { | |
2325 if ((signed int)pIndoor->uNumFaceExtras > 1) | |
2326 { | |
2327 for (uint i = 1; i < (signed int)pIndoor->uNumFaceExtras; ++i) | |
2328 { | |
2329 if (pIndoor->pFaceExtras[i].sCogNumber == uFaceCog) | |
2330 { | |
2331 if (pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes & FACE_TEXTURE_FRAME) | |
2332 { | |
2333 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = pTextureFrameTable->FindTextureByName(pFilename); | |
2334 if (pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID) | |
2335 { | |
2336 pTextureFrameTable->LoadAnimationSequenceAndPalettes(pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID); | |
2337 } | |
2338 else | |
2339 { | |
2340 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = texture; | |
2341 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes &= 0xFFFFBFFF; | |
2342 } | |
2343 } | |
2344 else | |
2345 { | |
2346 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = texture; | |
2347 } | |
2348 } | |
2349 } | |
2350 } | |
2351 pParty->uFlags |= 2; | |
2352 } | |
2353 else | |
2354 { | |
2355 for (uint j = 0; j < (unsigned int)pOutdoor->uNumBModels; ++j) | |
2356 { | |
2357 for (uint i = 0; i < pOutdoor->pBModels[j].uNumFaces; ++i) | |
2358 { | |
2359 if (pOutdoor->pBModels[j].pFaces[i].sCogNumber == uFaceCog) | |
2360 { | |
2361 if (pOutdoor->pBModels[j].pFaces[i].uAttributes & FACE_TEXTURE_FRAME) | |
2362 { | |
2363 pOutdoor->pBModels[j].pFaces[i].uTextureID = pTextureFrameTable->FindTextureByName(pFilename); | |
2364 if (pOutdoor->pBModels[j].pFaces[i].uTextureID) | |
2365 pTextureFrameTable->LoadAnimationSequenceAndPalettes(pOutdoor->pBModels[j].pFaces[i].uTextureID); | |
2366 else | |
2367 { | |
2368 pOutdoor->pBModels[j].pFaces[i].uTextureID = texture; | |
2369 pOutdoor->pBModels[j].pFaces[i].uAttributes &= 0xFFFFBFFF; | |
2370 } | |
2371 } | |
2372 else | |
2373 pOutdoor->pBModels[j].pFaces[i].uTextureID = texture; | |
2374 } | |
2375 } | |
2376 } | |
2377 } | |
2378 pParty->uFlags |= 2; | |
2379 } | |
2380 } | |
2381 } | |
2382 | |
2383 //----- (0044892E) -------------------------------------------------------- | |
2384 void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on) | |
2385 { | |
2386 if (sCogNumber) | |
2387 { | |
2388 if (uCurrentlyLoadedLevelType == 1) | |
2389 { | |
2390 for (uint i = 1; i < (unsigned int)pIndoor->uNumFaceExtras; ++i) | |
2391 { | |
2392 if (pIndoor->pFaceExtras[i].sCogNumber == sCogNumber) | |
2393 { | |
2394 if (on) | |
2395 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes |= bit; | |
2396 else | |
2397 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes &= ~bit; | |
2398 } | |
2399 } | |
2400 pParty->uFlags |= 2; | |
2401 } | |
2402 else | |
2403 { | |
2404 for (uint j = 0; j < (unsigned int)pOutdoor->uNumBModels; ++j) | |
2405 { | |
2406 for (uint i = 0; i < (unsigned int)pOutdoor->pBModels[j].uNumFaces; ++i) | |
2407 { | |
2408 if (pOutdoor->pBModels[j].pFaces[i].sCogNumber == sCogNumber) | |
2409 { | |
2410 if (on) | |
2411 pOutdoor->pBModels[j].pFaces[i].uAttributes |= bit; | |
2412 else | |
2413 pOutdoor->pBModels[j].pFaces[i].uAttributes &= ~bit; | |
2414 } | |
2415 } | |
2416 } | |
2417 } | |
2418 pParty->uFlags |= 2; | |
2419 } | |
2420 } | |
2421 | |
2422 //----- (0044882F) -------------------------------------------------------- | |
2423 void __fastcall SetDecorationSprite(uint16_t uCog, bool bHide, const char *pFileName) | |
2424 { | |
2425 for (size_t i = 0; i < uNumLevelDecorations; i++) | |
2426 { | |
2427 if (pLevelDecorations[i].uCog == uCog) | |
2428 { | |
2429 if (pFileName && strcmp(pFileName, "0")) | |
2430 { | |
2431 pLevelDecorations[i].uDecorationDescID = pDecorationList->GetDecorIdByName(pFileName); | |
2432 pDecorationList->InitializeDecorationSprite(pLevelDecorations[i].uDecorationDescID); | |
2433 } | |
2434 | |
2435 if (bHide) | |
2436 pLevelDecorations[i].uFlags &= ~LEVEL_DECORATION_INVISIBLE; | |
2437 else | |
2438 pLevelDecorations[i].uFlags |= LEVEL_DECORATION_INVISIBLE; | |
2439 | |
2440 pParty->uFlags |= 2; | |
2441 } | |
2442 } | |
2443 } | |
2444 | |
2445 //----- (004356FF) -------------------------------------------------------- | |
2446 void back_to_game() | |
2447 { | |
2448 dword_507BF0_is_there_popup_onscreen = 0; | |
2449 dword_4E455C = 1; | |
2450 | |
2451 extern int no_rightlick_in_inventory; | |
2452 no_rightlick_in_inventory = false; | |
2453 | |
2454 if (pGUIWindow_ScrollWindow) | |
2455 free_book_subwindow(); | |
2554 | 2456 if (!current_screen_type && !pGUIWindow_CastTargetedSpell) |
2541 | 2457 pEventTimer->Resume(); |
2458 viewparams->bRedrawGameUI = 1; | |
2459 } | |
2460 | |
2461 //----- (00494035) -------------------------------------------------------- | |
2462 void _494035_timed_effects__water_walking_damage__etc() | |
2463 { | |
2464 signed __int64 v0; // qax@1 | |
2465 unsigned int v4; // edi@1 | |
2466 // signed int v12; // edi@29 | |
2467 int v24; // ecx@60 | |
2468 int v26; // ecx@64 | |
2469 int v28; // ecx@68 | |
2470 int v30; // ecx@72 | |
2471 int v32; // ecx@76 | |
2472 int v34; // ecx@80 | |
2473 int v36; // ecx@84 | |
2474 int v38; // ecx@88 | |
2475 int v40; // ecx@92 | |
2476 int v42; // ecx@96 | |
2477 bool v43; // ebx@102 | |
2478 bool v46; // edi@111 | |
2479 // unsigned int v56; // [sp-8h] [bp-38h]@55 | |
2480 // int v59; // [sp-4h] [bp-34h]@55 | |
2481 // unsigned int v61; // [sp+14h] [bp-1Ch]@1 | |
2482 signed int a2a; // [sp+18h] [bp-18h]@47 | |
2483 signed int old_day; // [sp+1Ch] [bp-14h]@47 | |
2484 signed int old_hour; | |
2485 | |
2486 old_day = pParty->uDaysPlayed; | |
2487 old_hour = pParty->uCurrentHour; | |
2488 //auto prev_time = pEventTimer->uTimeElapsed; | |
2489 pParty->uTimePlayed += pEventTimer->uTimeElapsed; | |
2490 v0 = ((signed __int64)(pParty->uTimePlayed * 0.234375) / 60) / 60i64; | |
2491 v4 = (unsigned int)(((unsigned int)v0 / 24) / 7) >> 2; | |
2492 pParty->uCurrentTimeSecond = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) % 60; | |
2493 pParty->uCurrentMinute = ((signed __int64)(pParty->uTimePlayed * 0.234375) / 60) % 60; | |
2494 pParty->uCurrentHour = v0 % 24; | |
2495 pParty->uCurrentMonthWeek = ((unsigned int)v0 / 24) / 7 & 3; | |
2496 pParty->uDaysPlayed = (unsigned int)((unsigned int)v0 / 24) % 28; | |
2497 pParty->uCurrentMonth = v4 % 12; | |
2498 pParty->uCurrentYear = v4 / 0xC + game_starting_year; | |
2499 if (pParty->uCurrentHour >= 3 && (old_hour < 3 || pParty->uDaysPlayed > old_day)) // new day dawns | |
2500 { | |
2501 pParty->pHirelings[0].bHasUsedTheAbility = false; | |
2502 pParty->pHirelings[1].bHasUsedTheAbility = false; | |
2503 | |
2504 for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i) | |
2505 pNPCStats->pNewNPCData[i].bHasUsedTheAbility = false; | |
2506 | |
2507 ++pParty->days_played_without_rest; | |
2508 if (pParty->days_played_without_rest > 1) | |
2509 { | |
2510 for (uint i = 0; i < 4; ++i) | |
2511 pParty->pPlayers[i].SetCondWeakWithBlockCheck(0); | |
2512 | |
2513 if (pParty->uNumFoodRations) | |
2514 Party::TakeFood(1); | |
2515 else | |
2516 for (uint i = 0; i < 4; ++i) | |
2517 pParty->pPlayers[i].sHealth = pParty->pPlayers[i].sHealth / (pParty->days_played_without_rest + 1) + 1; | |
2518 | |
2519 if (pParty->days_played_without_rest > 3) | |
2520 for (uint i = 0; i < 4; ++i) | |
2521 { | |
2522 pParty->pPlayers[i].Zero(); | |
2523 if (!pParty->pPlayers[i].IsPertified() && !pParty->pPlayers[i].IsEradicated() | |
2524 && !pParty->pPlayers[i].IsDead()) | |
2525 { | |
2526 if (rand() % 100 < 5 * pParty->days_played_without_rest) | |
2527 pParty->pPlayers[i].SetCondDeadWithBlockCheck(0); | |
2528 if (rand() % 100 < 10 * pParty->days_played_without_rest) | |
2529 pParty->pPlayers[i].SetCondInsaneWithBlockCheck(0); | |
2530 } | |
2531 } | |
2532 } | |
2533 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
2534 pOutdoor->SetFog(); | |
2535 | |
2536 for (uint i = 0; i < 4; ++i) | |
2537 pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0; | |
2538 } | |
2539 | |
2540 if (pParty->uFlags & 4 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed)//water damage | |
2541 { | |
2542 pParty->field_6FC = (signed __int64)pParty->uTimePlayed + 128; | |
2543 viewparams->bRedrawGameUI = true; | |
2544 for (uint pl = 1; pl <= 4; ++pl) | |
2545 { | |
2546 if (pPlayers[pl]->WearsItem(ITEM_RELIC_HARECS_LEATHER, EQUIP_ARMOUR) | |
2547 || pPlayers[pl]->HasEnchantedItemEquipped(71) | |
2548 || pPlayers[pl]->pPlayerBuffs[PLAYER_BUFF_WATER_WALK].uExpireTime > 0) | |
2549 pPlayers[pl]->PlayEmotion(CHARACTER_EXPRESSION_37, 0); | |
2550 else | |
2551 { | |
2552 if (!pPlayers[pl]->HasUnderwaterSuitEquipped()) | |
2553 { | |
2554 pPlayers[pl]->ReceiveDamage((signed __int64)pPlayers[pl]->GetMaxHealth() * 0.1, DMGT_FIRE); | |
2555 if (pParty->uFlags & 4) | |
2556 { | |
2557 strcpy(GameUI_Footer_TimedString.data(), pGlobalTXT_LocalizationStrings[660]);// Âû òîíåòå! | |
2558 GameUI_Footer_TimeLeft = 128; | |
2559 } | |
2560 } | |
2561 else | |
2562 pPlayers[pl]->PlayEmotion(CHARACTER_EXPRESSION_37, 0); | |
2563 } | |
2564 } | |
2565 } | |
2566 if (pParty->uFlags & 0x200 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed) //lava damage | |
2567 { | |
2568 viewparams->bRedrawGameUI = true; | |
2569 pParty->field_6FC = (signed __int64)pParty->uTimePlayed + 128; | |
2570 | |
2571 for (uint pl = 1; pl <= 4; pl++) | |
2572 { | |
2573 pPlayers[pl]->ReceiveDamage((signed __int64)pPlayers[pl]->GetMaxHealth() * 0.1, DMGT_FIRE); | |
2574 if (pParty->uFlags & 0x200) | |
2575 { | |
2576 strcpy(GameUI_Footer_TimedString.data(), pGlobalTXT_LocalizationStrings[661]); //Âû ãîðèòå! | |
2577 GameUI_Footer_TimeLeft = 128; | |
2578 } | |
2579 } | |
2580 } | |
2581 _493938_regenerate(); | |
2582 uint party_condition_flag = 4; | |
2583 a2a = pEventTimer->uTimeElapsed; | |
2584 if (pParty->uFlags2 & PARTY_FLAGS_2_RUNNING)//çàìåäëåíèå âîññòàíîâëåíèÿ ïðè áåãå | |
2585 { | |
2586 a2a *= 0.5f; | |
2587 if (a2a < 1) | |
2588 a2a = 1; | |
2589 } | |
2590 | |
2591 for (uint pl = 1; pl <= 4; pl++) | |
2592 { | |
2593 if (pPlayers[pl]->uTimeToRecovery) | |
2594 pPlayers[pl]->Recover(a2a);//âîññòàíîâëåíèå àêòèâíîñòè | |
2595 if (pPlayers[pl]->GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE) + pPlayers[pl]->sHealth + pPlayers[pl]->uEndurance >= 1 | |
2596 || (signed __int64)pPlayers[pl]->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0) | |
2597 { | |
2598 if (pPlayers[pl]->sHealth < 1) | |
2599 pPlayers[pl]->SetCondition(Condition_Unconcious, 0); | |
2600 } | |
2601 else | |
2602 pPlayers[pl]->SetCondition(Condition_Dead, 0); | |
2603 if (pPlayers[pl]->field_E0) | |
2604 { | |
2605 v24 = pPlayers[pl]->field_E0 - pEventTimer->uTimeElapsed; | |
2606 if (v24 > 0) | |
2607 pPlayers[pl]->field_E0 = v24; | |
2608 else | |
2609 { | |
2610 pPlayers[pl]->field_E0 = 0; | |
2611 viewparams->bRedrawGameUI = true; | |
2612 } | |
2613 } | |
2614 if (pPlayers[pl]->field_E4) | |
2615 { | |
2616 v26 = pPlayers[pl]->field_E4 - pEventTimer->uTimeElapsed; | |
2617 if (v26 > 0) | |
2618 pPlayers[pl]->field_E4 = v26; | |
2619 else | |
2620 { | |
2621 pPlayers[pl]->field_E4 = 0; | |
2622 viewparams->bRedrawGameUI = true; | |
2623 } | |
2624 } | |
2625 if (pPlayers[pl]->field_E8) | |
2626 { | |
2627 v28 = pPlayers[pl]->field_E8 - pEventTimer->uTimeElapsed; | |
2628 if (v28 > 0) | |
2629 pPlayers[pl]->field_E8 = v28; | |
2630 else | |
2631 { | |
2632 pPlayers[pl]->field_E8 = 0; | |
2633 viewparams->bRedrawGameUI = true; | |
2634 } | |
2635 } | |
2636 if (pPlayers[pl]->field_EC) | |
2637 { | |
2638 v30 = pPlayers[pl]->field_EC - pEventTimer->uTimeElapsed; | |
2639 if (v30 > 0) | |
2640 pPlayers[pl]->field_EC = v30; | |
2641 else | |
2642 { | |
2643 pPlayers[pl]->field_EC = 0; | |
2644 viewparams->bRedrawGameUI = true; | |
2645 } | |
2646 } | |
2647 if (pPlayers[pl]->field_F0) | |
2648 { | |
2649 v32 = pPlayers[pl]->field_F0 - pEventTimer->uTimeElapsed; | |
2650 if (v32 > 0) | |
2651 pPlayers[pl]->field_F0 = v32; | |
2652 else | |
2653 { | |
2654 pPlayers[pl]->field_F0 = 0; | |
2655 viewparams->bRedrawGameUI = true; | |
2656 } | |
2657 } | |
2658 if (pPlayers[pl]->field_F4) | |
2659 { | |
2660 v34 = pPlayers[pl]->field_F4 - pEventTimer->uTimeElapsed; | |
2661 if (v34 > 0) | |
2662 pPlayers[pl]->field_F4 = v34; | |
2663 else | |
2664 { | |
2665 pPlayers[pl]->field_F4 = 0; | |
2666 viewparams->bRedrawGameUI = true; | |
2667 } | |
2668 } | |
2669 if (pPlayers[pl]->field_F8) | |
2670 { | |
2671 v36 = pPlayers[pl]->field_F8 - pEventTimer->uTimeElapsed; | |
2672 if (v36 > 0) | |
2673 pPlayers[pl]->field_F8 = v36; | |
2674 else | |
2675 { | |
2676 pPlayers[pl]->field_F8 = 0; | |
2677 viewparams->bRedrawGameUI = true; | |
2678 } | |
2679 } | |
2680 if (pPlayers[pl]->field_FC) | |
2681 { | |
2682 v38 = pPlayers[pl]->field_FC - pEventTimer->uTimeElapsed; | |
2683 if (v38 > 0) | |
2684 pPlayers[pl]->field_FC = v38; | |
2685 else | |
2686 { | |
2687 pPlayers[pl]->field_FC = 0; | |
2688 viewparams->bRedrawGameUI = true; | |
2689 } | |
2690 } | |
2691 if (pPlayers[pl]->field_100) | |
2692 { | |
2693 v40 = pPlayers[pl]->field_100 - pEventTimer->uTimeElapsed; | |
2694 if (v40 > 0) | |
2695 pPlayers[pl]->field_100 = v40; | |
2696 else | |
2697 { | |
2698 pPlayers[pl]->field_100 = 0; | |
2699 viewparams->bRedrawGameUI = true; | |
2700 } | |
2701 } | |
2702 if (pPlayers[pl]->field_104) | |
2703 { | |
2704 v42 = pPlayers[pl]->field_104 - pEventTimer->uTimeElapsed; | |
2705 if (v42 > 0) | |
2706 pPlayers[pl]->field_104 = v42; | |
2707 else | |
2708 { | |
2709 pPlayers[pl]->field_104 = 0; | |
2710 viewparams->bRedrawGameUI = true; | |
2711 } | |
2712 } | |
2713 if (pPlayers[pl]->pConditions[Condition_Sleep] | pPlayers[pl]->pConditions[Condition_Paralyzed] | |
2714 | pPlayers[pl]->pConditions[Condition_Unconcious] | pPlayers[pl]->pConditions[Condition_Dead] | |
2715 | pPlayers[pl]->pConditions[Condition_Pertified] | pPlayers[pl]->pConditions[Condition_Eradicated]) | |
2716 --party_condition_flag; | |
2717 v43 = (signed __int64)pPlayers[pl]->pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime > 0; //ñïåøêà | |
2718 | |
2719 for (uint k = 0; k < 24; ++k) | |
2720 pPlayers[pl]->pPlayerBuffs[k].IsBuffExpiredToTime(pParty->uTimePlayed); | |
2721 | |
2722 if (v43 && (signed __int64)pPlayers[pl]->pPlayerBuffs[7].uExpireTime <= 0) | |
2723 pPlayers[pl]->SetCondition(Condition_Weak, 0); | |
2724 } | |
2725 | |
2726 v46 = (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_HASTE].uExpireTime > 0; | |
2727 | |
2728 for (uint i = 0; i < 20; ++i) | |
2729 { | |
2730 if (pParty->pPartyBuffs[i].IsBuffExpiredToTime(pParty->uTimePlayed) == 1) | |
2731 viewparams->bRedrawGameUI = true; | |
2732 } | |
2733 | |
2734 if (v46 && (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_HASTE].uExpireTime <= 0) | |
2735 { | |
2736 for (uint i = 0; i < 4; ++i) | |
2737 pParty->pPlayers[i].SetCondition(1, 0); | |
2738 } | |
2739 | |
2740 for (uint i = 0; i < 2; ++i)//Ïðîâåðêà â ñîçíàíèè ëè ïåðñ ñäåëàâøèé çàêë íà ïîë¸ò è õîæäåíèå ïî âîäå | |
2741 { | |
2742 SpellBuff* pBuf = &pParty->pPartyBuffs[Party_Spec_Motion_status_ids[i]]; | |
2743 if (pBuf->uExpireTime == 0) | |
2744 continue; | |
2745 | |
2746 if (!(pBuf->uFlags & 1)) | |
2747 { | |
2748 if (!pPlayers[pBuf->uCaster]->CanAct()) | |
2749 { | |
2750 pBuf->Reset(); | |
2751 if (Party_Spec_Motion_status_ids[i] == PARTY_BUFF_FLY) | |
2752 pParty->bFlying = false; | |
2753 } | |
2754 } | |
2755 } | |
2756 | |
2757 if (!party_condition_flag) | |
2758 { | |
2759 if (current_screen_type != SCREEN_REST) | |
2760 { | |
2761 for (uint pl = 1; pl <= 4; pl++) | |
2762 { | |
2763 if (pPlayers[pl]->pConditions[Condition_Sleep]) | |
2764 { | |
2765 pPlayers[pl]->pConditions[Condition_Sleep] = 0; | |
2766 party_condition_flag = 1; | |
2767 break; | |
2768 } | |
2769 } | |
2770 if (!party_condition_flag || _5C35C0_force_party_death) | |
2771 uGameState = GAME_STATE_PARTY_DIED; | |
2772 } | |
2773 } | |
2774 | |
2775 if (uActiveCharacter)//âûáîð ñëåäóþùåãî ïîñëå ïðîïóñêàþùåãî õîä | |
2776 { | |
2777 if (current_screen_type != SCREEN_REST) | |
2778 { | |
2779 if (pPlayers[uActiveCharacter]->pConditions[Condition_Sleep] | |
2780 || pPlayers[uActiveCharacter]->pConditions[Condition_Paralyzed] | |
2781 || pPlayers[uActiveCharacter]->pConditions[Condition_Unconcious] | |
2782 || pPlayers[uActiveCharacter]->pConditions[Condition_Dead] | |
2783 || pPlayers[uActiveCharacter]->pConditions[Condition_Pertified] | |
2784 || pPlayers[uActiveCharacter]->pConditions[Condition_Eradicated]) | |
2785 { | |
2786 viewparams->bRedrawGameUI = true; | |
2787 uActiveCharacter = pParty->GetNextActiveCharacter(); | |
2788 } | |
2789 } | |
2790 } | |
2791 } | |
2792 | |
2793 //----- (00493938) -------------------------------------------------------- | |
2794 void _493938_regenerate() | |
2795 { | |
2796 int current_time; // edi@1 | |
2797 int last_reg_time; // qax@1 | |
2798 int v4; // eax@2 | |
2799 int v5; // edi@5 | |
2800 long long *v6; // ecx@5 | |
2801 char v7; // sf@5 | |
2802 int *v8; // ecx@10 | |
2803 int v9; // edi@15 | |
2804 signed int v10; // eax@15 | |
2805 // __int16 *v11; // edx@16 | |
2806 // int v12; // eax@20 | |
2807 int numberOfActorsAffected; // ebx@20 | |
2808 unsigned int v14; // esi@21 | |
2809 //unsigned int v15; // ecx@21 | |
2810 //unsigned int v16; // eax@21 | |
2811 // int v18; // eax@21 | |
2812 signed int v19; // eax@21 | |
2813 bool recovery_HP; // ebx@25 | |
2814 // ITEM_EQUIP_TYPE v22; // edi@30 | |
2815 signed int v25; // eax@33 | |
2816 // int v26; // eax@35 | |
2817 // int v27; // eax@36 | |
2818 // int v28; // eax@37 | |
2819 signed int v31; // ecx@53 | |
2820 int actorsAffectedByImmolation[100]; // [sp+4h] [bp-22Ch]@20 | |
2821 SpriteObject a1; // [sp+194h] [bp-9Ch]@15 | |
2822 Vec3_int_ a3; // [sp+204h] [bp-2Ch]@15 | |
2823 bool has_dragon_flag; // [sp+210h] [bp-20h]@22 | |
2824 bool lich_jar_flag; // [sp+214h] [bp-1Ch]@25 | |
2825 bool zombie_flag; // [sp+218h] [bp-18h]@25 | |
2826 bool decrease_HP; // [sp+21Ch] [bp-14h]@25 | |
2827 bool lich_flag; // [sp+220h] [bp-10h]@25 | |
2828 int v49; // [sp+224h] [bp-Ch]@24 | |
2829 bool recovery_SP; // [sp+228h] [bp-8h]@25 | |
2830 bool redraw_flag; // [sp+22Ch] [bp-4h]@2 | |
2831 | |
2832 current_time = (signed int)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) / 60; | |
2833 last_reg_time = (signed int)(signed __int64)((double)pParty->uLastRegenerationTime * 0.234375) / 60; | |
2834 if (current_time >= (signed int)last_reg_time + 5) | |
2835 { | |
2836 redraw_flag = false; | |
2837 v4 = (current_time - last_reg_time) / 5; | |
2838 if (pParty->FlyActive()) | |
2839 { | |
2840 if (pParty->bFlying) | |
2841 { | |
2842 if (!(pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags & 1)) | |
2843 { | |
2844 v5 = v4 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uPower; | |
2845 //cursed_flag = pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].pConditions[Condition_Cursed];//cursed | |
2846 //v7 = cursed_flag < v5; | |
2847 //cursed_flag -= v5; | |
2848 | |
2849 v6 = &pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].pConditions[Condition_Cursed]; | |
2850 | |
2851 if (*v6 < v5) | |
2852 { | |
2853 v6 = 0; | |
2854 pParty->uFlags &= 0xFFFFFFBFu; | |
2855 pParty->bFlying = false; | |
2856 redraw_flag = true; | |
2857 } | |
2858 } | |
2859 } | |
2860 } | |
2861 | |
2862 if (pParty->WaterWalkActive()) | |
2863 { | |
2864 if (pParty->uFlags & PARTY_FLAGS_1_STANDING_ON_WATER) | |
2865 { | |
2866 if (!(pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags & 1)) | |
2867 { // taking on water | |
2868 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]; | |
2869 v7 = *v8 < v4; | |
2870 *v8 -= v4; | |
2871 if (v7) | |
2872 { | |
2873 *v8 = 0; | |
2874 pParty->uFlags &= ~PARTY_FLAGS_1_STANDING_ON_WATER; | |
2875 redraw_flag = true; | |
2876 } | |
2877 } | |
2878 } | |
2879 } | |
2880 | |
2881 if (pParty->ImmolationActive())//Æåðòâà | |
2882 { | |
2883 a3.z = 0; | |
2884 a3.y = 0; | |
2885 a3.x = 0; | |
2886 a1.stru_24.Reset(); | |
2887 a1.spell_level = pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].uPower; | |
2888 a1.spell_skill = pParty->ImmolationSkillLevel(); | |
2889 v10 = 0; | |
2890 a1.uType = 1070; | |
2891 a1.spell_id = SPELL_FIRE_IMMOLATION; | |
2892 v10 = 0; | |
2893 for (uint i = 0; i > pObjectList->uNumObjects; i++) | |
2894 { | |
2895 if (pObjectList->pObjects[i].uObjectID == stru_4E3ACC[8].uType) | |
2896 v10 = i; | |
2897 } | |
2898 a1.uObjectDescID = v10; | |
2899 a1.field_60_distance_related_prolly_lod = 0; | |
2900 a1.uAttributes = 0; | |
2901 a1.uSectorID = 0; | |
2902 a1.uSpriteFrameID = 0; | |
2903 a1.spell_caster_pid = PID(OBJECT_Player, pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].uCaster); | |
2904 a1.uFacing = 0; | |
2905 a1.uSoundID = 0; | |
2906 numberOfActorsAffected = pParty->_46A89E_immolation_effect(actorsAffectedByImmolation, 100, 307); | |
2907 for (v9 = 0; v9 < numberOfActorsAffected; ++v9) | |
2908 { | |
2909 v14 = actorsAffectedByImmolation[v9]; | |
2910 a1.vPosition.x = pActors[v14].vPosition.x; | |
2911 a1.vPosition.y = pActors[v14].vPosition.y; | |
2912 a1.vPosition.z = pActors[v14].vPosition.z; | |
2913 a1.spell_target_pid = PID(OBJECT_Actor, v14); | |
2914 v19 = a1.Create(0, 0, 0, 0); | |
2915 Actor::DamageMonsterFromParty(PID(OBJECT_Item, v19), v14, &a3); | |
2916 } | |
2917 } | |
2918 | |
2919 has_dragon_flag = false; | |
2920 if (PartyHasDragon()) | |
2921 has_dragon_flag = true; | |
2922 | |
2923 for (v49 = 0; v49 < 4; v49++) | |
2924 { | |
2925 recovery_HP = false; | |
2926 recovery_SP = false; | |
2927 decrease_HP = false; | |
2928 lich_flag = false; | |
2929 lich_jar_flag = false; | |
2930 zombie_flag = false; | |
2931 | |
2932 for (int v22 = 0; (signed int)v22 < 16; v22++) | |
2933 { | |
2934 if (pParty->pPlayers[v49].HasItemEquipped((ITEM_EQUIP_TYPE)v22)) | |
2935 { | |
2936 uint _idx = pParty->pPlayers[v49].pEquipment.pIndices[v22]; | |
2937 if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID > 134) | |
2938 { | |
2939 if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_RELIC_ETHRICS_STAFF) | |
2940 decrease_HP = true; | |
2941 if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_ARTIFACT_HERMES_SANDALS) | |
2942 { | |
2943 recovery_HP = true; | |
2944 recovery_SP = true; | |
2945 } | |
2946 if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_ARTIFACT_MINDS_EYE) | |
2947 recovery_SP = true; | |
2948 if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_ARTIFACT_HEROS_BELT) | |
2949 recovery_HP = true; | |
2950 } | |
2951 else | |
2952 { | |
2953 v25 = pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uSpecEnchantmentType; | |
2954 if (v25 == 37 //of Regeneration("Regenerate 1hp/x while walking, etc") | |
2955 || v25 == 44 //of Life("HP (+10), Regen hpts") | |
2956 || v25 == 50 //of The Phoenix("Fire Res (+30), Regen hpts") && | |
2957 || v25 == 54)// of The Troll("End (+15), Regen hpts") | |
2958 recovery_HP = true; | |
2959 if (v25 == 38 //of Mana("Regenerate 1sp/x while walking, etc") | |
2960 || v25 == 47 //of The Eclipse("SP (+10), Regen spts") | |
2961 || v25 == 55)//of The Unicorn("Luck (+15), Regen spts") | |
2962 recovery_SP = true; | |
2963 if (v25 == 66)// of Plenty("Regenerate 1 hp/x and 1 sp/x while walking, etc.") | |
2964 { | |
2965 recovery_HP = true; | |
2966 recovery_SP = true; | |
2967 } | |
2968 } | |
2969 | |
2970 if (recovery_HP && | |
2971 !pParty->pPlayers[v49].pConditions[Condition_Dead] && | |
2972 !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) | |
2973 { | |
2974 if (pParty->pPlayers[v49].sHealth < pParty->pPlayers[v49].GetMaxHealth()) | |
2975 ++pParty->pPlayers[v49].sHealth; | |
2976 if (pParty->pPlayers[v49].pConditions[Condition_Unconcious] && pParty->pPlayers[v49].sHealth > 0) | |
2977 pParty->pPlayers[v49].pConditions[Condition_Unconcious] = 0; | |
2978 redraw_flag = true; | |
2979 } | |
2980 | |
2981 if (recovery_SP && | |
2982 !pParty->pPlayers[v49].pConditions[Condition_Dead] && | |
2983 !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) | |
2984 { | |
2985 if (pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana()) | |
2986 ++pParty->pPlayers[v49].sMana; | |
2987 redraw_flag = true; | |
2988 } | |
2989 | |
2990 if (decrease_HP && | |
2991 !pParty->pPlayers[v49].pConditions[Condition_Dead] && | |
2992 !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) | |
2993 { | |
2994 --pParty->pPlayers[v49].sHealth; | |
2995 if (!(pParty->pPlayers[v49].pConditions[Condition_Unconcious]) && pParty->pPlayers[v49].sHealth < 0) | |
2996 pParty->pPlayers[v49].pConditions[Condition_Unconcious] = pParty->uTimePlayed; | |
2997 if (pParty->pPlayers[v49].sHealth < 1) | |
2998 { | |
2999 if (pParty->pPlayers[v49].sHealth + pParty->pPlayers[v49].uEndurance + pParty->pPlayers[v49].GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE) >= 1 | |
3000 || (signed __int64)pParty->pPlayers[v49].pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0) | |
3001 pParty->pPlayers[v49].pConditions[Condition_Unconcious] = pParty->uTimePlayed; | |
3002 else | |
3003 { | |
3004 if (!pParty->pPlayers[v49].pConditions[Condition_Dead]) | |
3005 pParty->pPlayers[v49].pConditions[Condition_Dead] = pParty->uTimePlayed; | |
3006 } | |
3007 } | |
3008 redraw_flag = true; | |
3009 } | |
3010 } | |
3011 } | |
3012 | |
3013 //regeneration | |
3014 if (pParty->pPlayers[v49].pPlayerBuffs[PLAYER_BUFF_REGENERATION].uExpireTime > 0 | |
3015 && !pParty->pPlayers[v49].pConditions[Condition_Dead] | |
3016 && !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) | |
3017 { | |
3018 pParty->pPlayers[v49].sHealth += 5 * pParty->pPlayers[v49].pPlayerBuffs[PLAYER_BUFF_REGENERATION].uPower; | |
3019 if (pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth()) | |
3020 pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].GetMaxHealth(); | |
3021 if (pParty->pPlayers[v49].pConditions[Condition_Unconcious] && pParty->pPlayers[v49].sHealth > 0) | |
3022 pParty->pPlayers[v49].pConditions[Condition_Unconcious] = 0; | |
3023 redraw_flag = true; | |
3024 } | |
3025 | |
3026 //for warlock | |
3027 if (has_dragon_flag && pParty->pPlayers[v49].classType == PLAYER_CLASS_WARLOCK) | |
3028 { | |
3029 if (pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana()) | |
3030 ++pParty->pPlayers[v49].sMana; | |
3031 redraw_flag = true; | |
3032 } | |
3033 | |
3034 //for lich | |
3035 if (pParty->pPlayers[v49].classType == PLAYER_CLASS_LICH) | |
3036 { | |
3037 for (v31 = 0; v31 < 126; ++v31) | |
3038 { | |
3039 if (pParty->pPlayers[v49].pInventoryItemList[v31].uItemID == ITEM_LICH_JAR_FULL) | |
3040 lich_jar_flag = true; | |
3041 } | |
3042 lich_flag = true; | |
3043 } | |
3044 if (lich_flag && !pParty->pPlayers[v49].pConditions[Condition_Dead] | |
3045 && !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) | |
3046 { | |
3047 if (pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth() / 2) | |
3048 pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].sHealth - 2; | |
3049 if (pParty->pPlayers[v49].sMana > pParty->pPlayers[v49].GetMaxMana() / 2) | |
3050 pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].sMana - 2; | |
3051 } | |
3052 if (lich_jar_flag) | |
3053 { | |
3054 if (pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana()) | |
3055 ++pParty->pPlayers[v49].sMana; | |
3056 } | |
3057 | |
3058 //for zombie | |
3059 if (pParty->pPlayers[v49].pConditions[Condition_Zombie]) | |
3060 zombie_flag = true; | |
3061 if (zombie_flag && !pParty->pPlayers[v49].pConditions[Condition_Dead] | |
3062 && !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) | |
3063 { | |
3064 if (pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth() / 2) | |
3065 pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].sHealth - 1; | |
3066 if (pParty->pPlayers[v49].sMana > 0) | |
3067 pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].sMana - 1; | |
3068 } | |
3069 } | |
3070 pParty->uLastRegenerationTime = pParty->uTimePlayed; | |
3071 if (!viewparams->bRedrawGameUI) | |
3072 viewparams->bRedrawGameUI = redraw_flag; | |
3073 } | |
3074 } | |
3075 | |
3076 //----- (00491E3A) -------------------------------------------------------- | |
3077 void sub_491E3A() | |
3078 { | |
3079 signed int v1; // esi@3 | |
3080 unsigned int v3; // eax@7 | |
3081 unsigned int v4; // edx@8 | |
3082 int v6; // edi@17 | |
3083 | |
3084 //__debugbreak();//Ritor1 | |
3085 for (uint pl = 0; pl < 4; pl++) | |
3086 { | |
3087 if (SoundSetAction[24][0]) | |
3088 { | |
3089 v3 = 0; | |
3090 for (v1 = 0; v1 < (signed int)pSoundList->sNumSounds; ++v1) | |
3091 { | |
3092 int ps = 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[pl].uVoiceID) + 4998;//6728 | |
3093 if (pSoundList->pSL_Sounds[v1].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[pl].uVoiceID) + 4998) | |
3094 v3 = v1; | |
3095 } | |
3096 pSoundList->UnloadSound(v3, 1); | |
3097 for (v4 = 0; (signed int)v4 < (signed int)pSoundList->sNumSounds; ++v4) | |
3098 { | |
3099 if (pSoundList->pSL_Sounds[v4].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[pl].uVoiceID) + 4999) | |
3100 pSoundList->UnloadSound(v4, 1); | |
3101 } | |
3102 } | |
3103 } | |
3104 v6 = pIcons_LOD->uNumLoadedFiles - 1; | |
3105 if (v6 >= pIcons_LOD->pFacesLock) | |
3106 { | |
3107 do | |
3108 { | |
3109 pIcons_LOD->pTextures[v6].Release(); | |
3110 if (pIcons_LOD->pHardwareTextures) | |
3111 { | |
3112 if (pIcons_LOD->pHardwareTextures[v6]) | |
3113 { | |
3114 pIcons_LOD->pHardwareTextures[v6]->Release(); | |
3115 pIcons_LOD->pHardwareTextures[v6] = 0; | |
3116 } | |
3117 } | |
3118 if (pIcons_LOD->pHardwareSurfaces) | |
3119 { | |
3120 if (pIcons_LOD->pHardwareSurfaces[v6]) | |
3121 { | |
3122 pIcons_LOD->pHardwareSurfaces[v6]->Release(); | |
3123 pIcons_LOD->pHardwareSurfaces[v6] = 0; | |
3124 } | |
3125 } | |
3126 --v6; | |
3127 } while (v6 >= pIcons_LOD->pFacesLock); | |
3128 } | |
3129 pIcons_LOD->uNumLoadedFiles = pIcons_LOD->pFacesLock; | |
3130 pIcons_LOD->pFacesLock = 0; | |
3131 } | |
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 | |
3180 //----- (00443E31) -------------------------------------------------------- | |
3181 void LoadLevel_InitializeLevelStr() | |
3182 { | |
3183 | |
3184 // char Args[100]; | |
3185 int string_num; | |
3186 int max_string_length; | |
3187 // int current_string_length; | |
3188 int prev_string_offset; | |
3189 | |
3190 if (sizeof(pLevelStrOffsets) != 2000) | |
3191 Log::Warning(L"pLevelStrOffsets: deserialization warning"); | |
3192 memset(pLevelStrOffsets.data(), 0, 2000); | |
3193 | |
3194 max_string_length = 0; | |
3195 string_num = 1; | |
3196 prev_string_offset = 0; | |
3197 pLevelStrOffsets[0] = 0; | |
3198 for (uint i = 0; i < uLevelStrFileSize; ++i) | |
3199 { | |
3200 if (!pLevelStr[i]) | |
3201 { | |
3202 pLevelStrOffsets[string_num] = i + 1; | |
3203 ++string_num; | |
3204 if (i - prev_string_offset > max_string_length) | |
3205 max_string_length = i - prev_string_offset; | |
3206 prev_string_offset = i; | |
3207 } | |
3208 } | |
3209 | |
3210 uLevelStrNumStrings = string_num - 1; | |
3211 if (max_string_length > 800) | |
3212 Error("MAX_EVENT_TEXT_LENGTH needs to be increased to %lu", max_string_length + 1); | |
3213 | |
3214 if (uLevelStrNumStrings > 0) | |
3215 { | |
3216 for (uint i = 0; i <uLevelStrNumStrings; ++i) | |
3217 { | |
3218 if (RemoveQuotes(&pLevelStr[pLevelStrOffsets[i]]) != &pLevelStr[pLevelStrOffsets[i]]) | |
3219 ++pLevelStrOffsets[i]; | |
3220 } | |
3221 } | |
3222 } | |
3223 | |
3224 //----- (00443F95) -------------------------------------------------------- | |
2551
4008b2f34be0
MainMenu rendering moved from event loop to respective window class
a.parshin
parents:
2544
diff
changeset
|
3225 void OnMapLeave() |
2541 | 3226 { |
3227 _evt_raw *test_event; | |
3228 if (uLevelEVT_NumEvents > 0) | |
3229 { | |
3230 for (uint i = 0; i < uLevelEVT_NumEvents; ++i) | |
3231 { | |
3232 test_event = (_evt_raw*)&pLevelEVT[pLevelEVT_Index[i].uEventOffsetInEVT]; | |
3233 if (test_event->_e_type == EVENT_OnMapLeave) | |
3234 { | |
3235 EventProcessor(pLevelEVT_Index[i].uEventID, 0, 1, pLevelEVT_Index[i].event_sequence_num); | |
3236 } | |
3237 } | |
3238 } | |
3239 } | |
3240 | |
3241 //----- (00443FDC) -------------------------------------------------------- | |
3242 void OnMapLoad() | |
3243 { | |
3244 int v6; // eax@9 | |
3245 unsigned __int64 v8; // qax@26 | |
3246 int hours; // ebx@26 | |
3247 unsigned __int64 v18; // [sp+Ch] [bp-44h]@12 | |
3248 unsigned int seconds; // [sp+14h] [bp-3Ch]@26 | |
3249 unsigned __int64 v20; // [sp+1Ch] [bp-34h]@7 | |
3250 unsigned int minutes; // [sp+2Ch] [bp-24h]@26 | |
3251 unsigned int years; // [sp+34h] [bp-1Ch]@26 | |
3252 unsigned int weeks; // [sp+38h] [bp-18h]@26 | |
3253 int v26; // [sp+3Ch] [bp-14h]@15 | |
3254 unsigned int days; // [sp+3Ch] [bp-14h]@26 | |
3255 unsigned int months; // [sp+40h] [bp-10h]@26 | |
3256 | |
3257 for (uint i = 0; i < uLevelEVT_NumEvents; ++i) | |
3258 { | |
3259 EventIndex pEvent = pLevelEVT_Index[i]; | |
3260 | |
3261 _evt_raw* _evt = (_evt_raw *)(&pLevelEVT[pEvent.uEventOffsetInEVT]); | |
3262 | |
3263 if (_evt->_e_type == EVENT_PlaySound) | |
3264 pSoundList->LoadSound(EVT_DWORD(_evt->v5), 0); | |
3265 else if (_evt->_e_type == EVENT_OnMapReload) | |
3266 EventProcessor(pEvent.uEventID, 0, 0, pEvent.event_sequence_num); | |
3267 else if (_evt->_e_type == EVENT_OnTimer || _evt->_e_type == EVENT_Initialize) | |
3268 { | |
3269 //v3 = &MapsLongTimersList[MapsLongTimers_count]; | |
3270 v20 = pOutdoor->loc_time.uLastVisitDay; | |
3271 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
3272 v20 = pIndoor->stru1.uLastVisitDay; | |
3273 | |
3274 MapsLongTimersList[MapsLongTimers_count].timer_evt_type = _evt->_e_type; | |
3275 MapsLongTimersList[MapsLongTimers_count].timer_evt_ID = pEvent.uEventID; | |
3276 MapsLongTimersList[MapsLongTimers_count].timer_evt_seq_num = pEvent.event_sequence_num; | |
3277 | |
3278 MapsLongTimersList[MapsLongTimers_count].YearsInterval = _evt->v5; | |
3279 MapsLongTimersList[MapsLongTimers_count].MonthsInterval = _evt->v6; | |
3280 MapsLongTimersList[MapsLongTimers_count].WeeksInterval = _evt->v7; | |
3281 MapsLongTimersList[MapsLongTimers_count].HoursInterval = _evt->v8; | |
3282 MapsLongTimersList[MapsLongTimers_count].MinutesInterval = _evt->v9; | |
3283 MapsLongTimersList[MapsLongTimers_count].SecondsInterval = _evt->v10; | |
3284 | |
3285 | |
3286 v6 = ((unsigned short)_evt->v12 << 8) + _evt->v11; | |
3287 | |
3288 MapsLongTimersList[MapsLongTimers_count].time_left_to_fire = ((unsigned short)_evt->v12 << 8) + _evt->v11; | |
3289 MapsLongTimersList[MapsLongTimers_count].IntervalHalfMins = ((unsigned short)_evt->v12 << 8) + _evt->v11; | |
3290 if (MapsLongTimersList[MapsLongTimers_count].timer_evt_type == EVENT_Initialize && !(short)v6) | |
3291 { | |
3292 if (v20) | |
3293 v18 = pParty->uTimePlayed - v20; | |
3294 else | |
3295 v18 = 0; | |
3296 v26 = (signed int)(signed __int64)((double)(signed __int64)v18 * 0.234375) / 60 / 60 / 24; | |
3297 | |
3298 if (v26 / 7 / 4 / 12 != 0 && MapsLongTimersList[MapsLongTimers_count].YearsInterval || | |
3299 v26 / 7 / 4 != 0 && MapsLongTimersList[MapsLongTimers_count].MonthsInterval != 0 || | |
3300 v26 / 7 != 0 && MapsLongTimersList[MapsLongTimers_count].WeeksInterval != 0 || | |
3301 v26 != 0 || !v20) | |
3302 { | |
3303 ++MapsLongTimers_count; | |
3304 MapsLongTimersList[MapsLongTimers_count].NextStartTime = 0; | |
3305 continue; | |
3306 } | |
3307 } | |
3308 else | |
3309 { | |
3310 v8 = (__int64)((double)pParty->uTimePlayed * 0.234375); | |
3311 seconds = v8 % 60; | |
3312 minutes = (v8 / 60) % 60; | |
3313 hours = ((v8 / 60) / 60) % 24; | |
3314 days = (((v8 / 60) / 60) / 24) % 7; | |
3315 weeks = ((((v8 / 60) / 60) / 24) / 7) % 4; | |
3316 months = (((((v8 / 60) / 60) / 24) / 7) / 4) % 12; | |
3317 years = (((((v8 / 60) / 60) / 24) / 7) / 4) / 12; | |
3318 | |
3319 if (MapsLongTimersList[MapsLongTimers_count].YearsInterval) | |
3320 ++years; | |
3321 else if (MapsLongTimersList[MapsLongTimers_count].MonthsInterval) | |
3322 ++months; | |
3323 else if (MapsLongTimersList[MapsLongTimers_count].WeeksInterval) | |
3324 ++weeks; | |
3325 else | |
3326 { | |
3327 ++days; | |
3328 hours = MapsLongTimersList[MapsLongTimers_count].HoursInterval; | |
3329 minutes = MapsLongTimersList[MapsLongTimers_count].MinutesInterval; | |
3330 seconds = MapsLongTimersList[MapsLongTimers_count].SecondsInterval; | |
3331 } | |
3332 MapsLongTimersList[MapsLongTimers_count].NextStartTime = (signed __int64)((double)((seconds | |
3333 + 60 * minutes | |
3334 + 3600 * hours | |
3335 + 86400 * days | |
3336 + 604800 * weeks | |
3337 + 2419200 * months | |
3338 + 29030400 * years) << 7) | |
3339 * 0.033333335); | |
3340 | |
3341 ++MapsLongTimers_count; | |
3342 } | |
3343 } | |
3344 } | |
3345 } | |
3346 | |
3347 //----- (00444360) -------------------------------------------------------- | |
3348 void Level_LoadEvtAndStr(const char *pLevelName) | |
3349 { | |
3350 char pContainerName[120]; // [sp+8h] [bp-98h]@1 | |
3351 | |
3352 sprintf(pContainerName, "%s.evt", pLevelName); | |
3353 uLevelEVT_Size = LoadEventsToBuffer(pContainerName, pLevelEVT.data(), 9216); | |
3354 | |
3355 sprintf(pContainerName, "%s.str", pLevelName); | |
3356 uLevelStrFileSize = LoadEventsToBuffer(pContainerName, pLevelStr.data(), 9216); | |
3357 if (uLevelStrFileSize) | |
3358 LoadLevel_InitializeLevelStr(); | |
3359 } | |
3360 | |
3361 //----- (004452BB) -------------------------------------------------------- | |
3362 void sub_4452BB() | |
3363 { | |
3364 pGUIWindow2->Release(); | |
3365 pGUIWindow2 = 0; | |
3366 activeLevelDecoration = _591094_decoration; | |
3367 EventProcessor(dword_5C3418, 0, 1, dword_5C341C); | |
3368 activeLevelDecoration = nullptr; | |
3369 pEventTimer->Resume(); | |
3370 } | |
3371 | |
3372 //----- (0044100D) -------------------------------------------------------- | |
3373 bool _44100D_should_alter_right_panel() | |
3374 { | |
3375 return current_screen_type == SCREEN_NPC_DIALOGUE || current_screen_type == SCREEN_CHARACTERS || | |
3376 current_screen_type == SCREEN_HOUSE || current_screen_type == SCREEN_E || | |
3377 current_screen_type == SCREEN_CHANGE_LOCATION || current_screen_type == SCREEN_INPUT_BLV || current_screen_type == SCREEN_CASTING; | |
3378 } | |
3379 | |
3380 //----- (0044987B) -------------------------------------------------------- | |
3381 void Transition_StopSound_Autosave(const char *pMapName, MapStartPoint start_point) | |
3382 { | |
3383 pAudioPlayer->StopChannels(-1, -1); | |
3384 pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_None); | |
3385 if (_stricmp(pCurrentMapName, pMapName)) | |
3386 SaveGame(1, 0); | |
3387 | |
3388 uGameState = GAME_STATE_CHANGE_LOCATION; | |
3389 strcpy(pCurrentMapName, pMapName); | |
3390 uLevel_StartingPointType = start_point; | |
3391 } | |
3392 | |
3393 //----- (004451A8) -------------------------------------------------------- | |
3394 void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4) | |
3395 { | |
3396 if (!pGUIWindow2) | |
3397 { | |
3398 if (pParty->uFlags & 2) | |
3399 pEngine->Draw(); | |
3400 pAudioPlayer->StopChannels(-1, -1); | |
3401 pMiscTimer->Pause(); | |
3402 pEventTimer->Pause(); | |
3403 dword_5C3418 = a1; | |
3404 dword_5C341C = a2; | |
3405 _591094_decoration = activeLevelDecoration; | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2543
diff
changeset
|
3406 pGUIWindow2 = new GUIWindow_GenericDialogue(0, 0, window->GetWidth(), window->GetHeight(), a4, 0); |
2541 | 3407 pGUIWindow2->CreateButton(61, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); |
3408 pGUIWindow2->CreateButton(177, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); | |
3409 pGUIWindow2->CreateButton(292, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); | |
3410 pGUIWindow2->CreateButton(407, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); | |
3411 } | |
3412 } | |
3413 | |
3414 | |
3415 | |
3416 | |
3417 //----- (00448B67) -------------------------------------------------------- | |
3418 void OnTimer(int) | |
3419 { | |
3420 if (pEventTimer->bPaused) | |
3421 return; | |
3422 | |
3423 long long v13 = (signed __int64)(pParty->uTimePlayed - _5773B8_event_timer) / 128; | |
3424 if (!v13) | |
3425 return; | |
3426 | |
3427 //uint _v2v3 = pParty->uTimePlayed; | |
3428 //v3 = HIDWORD(pParty->uTimePlayed); | |
3429 //v2 = LODWORD(pParty->uTimePlayed); | |
3430 | |
3431 _5773B8_event_timer = pParty->uTimePlayed; | |
3432 | |
3433 for (uint i = 0; i < MapsLongTimers_count; ++i) | |
3434 { | |
3435 //v4 = (char *)&array_5B5928_timers[0].field_C; | |
3436 MapsLongTimer* timer = &MapsLongTimersList[i]; | |
3437 //while ( 1 ) | |
3438 //{ | |
3439 //v5 = *(short *)v4; | |
3440 if (timer->time_left_to_fire) | |
3441 { | |
3442 if (v13 < timer->time_left_to_fire) | |
3443 timer->time_left_to_fire -= v13; | |
3444 else | |
3445 { | |
3446 timer->time_left_to_fire = timer->IntervalHalfMins; | |
3447 EventProcessor(timer->timer_evt_ID, 0, 1, timer->timer_evt_seq_num); | |
3448 } | |
3449 } | |
3450 else | |
3451 { | |
3452 if (timer->NextStartTime < pParty->uTimePlayed) | |
3453 { | |
3454 uint next_trigger_time = 1 * 60 * 60 * 24; // 1 day | |
3455 if (timer->YearsInterval) | |
3456 next_trigger_time = 336 * 60 * 60 * 24; // 1 year | |
3457 else if (timer->MonthsInterval) | |
3458 next_trigger_time = 28 * 60 * 60 * 24; // 1 month | |
3459 else if (timer->WeeksInterval) | |
3460 next_trigger_time = 7 * 60 * 60 * 24; // 1 week | |
3461 | |
3462 timer->NextStartTime += (next_trigger_time * 128) / 3.0f; | |
3463 if (timer->NextStartTime < pParty->uTimePlayed) // make sure in wont fire several times in a row if big time interval has lapsed | |
3464 timer->NextStartTime = pParty->uTimePlayed; | |
3465 | |
3466 EventProcessor(timer->timer_evt_ID, 0, 1, timer->timer_evt_seq_num); | |
3467 } | |
3468 } | |
3469 } | |
3470 } | |
3471 | |
3472 | |
3473 | |
3474 | |
3475 | |
3476 | |
3477 | |
3478 //----- (0044C28F) -------------------------------------------------------- | |
3479 bool TeleportToNWCDungeon() | |
3480 { | |
3481 if (!_stricmp("nwc.blv", pCurrentMapName)) | |
3482 return false; | |
3483 | |
3484 _5B65A8_npcdata_uflags_or_other = 0; | |
3485 _5B65AC_npcdata_fame_or_other = 0; | |
3486 _5B65B0_npcdata_rep_or_other = 0; | |
3487 _5B65B4_npcdata_loword_house_or_other = 0; | |
3488 _5B65B8_npcdata_hiword_house_or_other = 0; | |
3489 dword_5B65BC = 0; | |
3490 dword_5B65C0 = 0; | |
3491 | |
3492 pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; | |
3493 Transition_StopSound_Autosave("nwc.blv", MapStartPoint_Party); | |
3494 current_screen_type = SCREEN_GAME; | |
3495 return true; | |
3496 } | |
3497 | |
3498 //----- (00401000) -------------------------------------------------------- | |
3499 void mm7__vector_constructor(void *a1, int objSize, int numObjs, int(*constructor)(int)) | |
3500 { | |
3501 void *v4; // esi@2 | |
3502 | |
3503 if (numObjs > 0) | |
3504 { | |
3505 v4 = a1; | |
3506 for (int i = numObjs; i; --i) | |
3507 { | |
3508 constructor((int)v4); | |
3509 v4 = (char *)v4 + objSize; | |
3510 } | |
3511 } | |
3512 } | |
3513 | |
3514 | |
3515 |