Mercurial > mm7
annotate Engine/Engine.cpp @ 2572:d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
author | a.parshin |
---|---|
date | Sat, 05 Mar 2016 01:51:54 +0200 |
parents | d433439699be |
children | dd36326a9994 |
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; |
2568 | 465 pDecalBuilder->DecalsCount = 0; |
466 pDecalBuilder->curent_decal_id = 0; | |
2541 | 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); | |
2568 | 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 | |
2566 | 900 |
901 //v9 = bLoading; | |
2541 | 902 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); |
903 pDecalBuilder->Reset(0); | |
904 pGameLoadingUI_ProgressBar->Initialize(_1_fullscreen_loading_2_box == 1 ? GUIProgressBar::TYPE_Fullscreen : | |
905 GUIProgressBar::TYPE_Box); | |
906 strcpy(Str1, pCurrentMapName); | |
907 v3 = strtok(Str1, "."); | |
908 strcpy(Str1, v3); | |
909 Level_LoadEvtAndStr(Str1); | |
910 LoadLevel_InitializeLevelEvt(); | |
911 strcpy(Str1, pCurrentMapName); | |
912 _strrev(Str1); | |
913 strtok(Str1, "."); | |
914 _strrev(Str1); | |
915 | |
916 for (uint i = 0; i < 1000; ++i) | |
917 pSpriteObjects[i].uObjectDescID = 0; | |
918 | |
919 v5 = pMapStats->GetMapInfo(pCurrentMapName); | |
920 bUnderwater = false; | |
921 uLevelMapStatsID = v5; | |
922 pEngine->uFlags2 &= 0xFFFFFFF7u; | |
923 if (!_stricmp(pCurrentMapName, "out15.odm")) | |
924 { | |
925 bUnderwater = true; | |
926 pEngine->uFlags2 |= GAME_FLAGS_2_ALTER_GRAVITY; | |
927 } | |
928 pParty->floor_face_pid = 0; | |
929 if (_stricmp(Str1, "blv")) | |
2566 | 930 PrepareToLoadODM(bLoading, 0); |
2541 | 931 else |
2566 | 932 PrepareToLoadBLV(bLoading); |
2541 | 933 pAudioPlayer->SetMapEAX(); |
934 _461103_load_level_sub(); | |
935 if (!_stricmp(pCurrentMapName, "d11.blv") || !_stricmp(pCurrentMapName, "d10.blv")) | |
936 { | |
937 //spawning grounds & walls of mist - no loot & exp from monsters | |
938 | |
939 for (uint i = 0; i < uNumActors; ++i) | |
940 { | |
941 pActors[i].pMonsterInfo.uTreasureType = 0; | |
942 pActors[i].pMonsterInfo.uTreasureDiceRolls = 0; | |
943 pActors[i].pMonsterInfo.uExp = 0; | |
944 } | |
945 } | |
946 bDialogueUI_InitializeActor_NPC_ID = 0; | |
947 OnMapLoad(); | |
948 pGameLoadingUI_ProgressBar->Progress(); | |
949 memset(&pRenderer->pBillboardRenderListD3D, 0, sizeof(pRenderer->pBillboardRenderListD3D)); | |
950 pGameLoadingUI_ProgressBar->Release(); | |
951 _flushall(); | |
952 } | |
953 | |
954 void IntegrityTest() | |
955 { | |
956 static_assert(sizeof(MovieHeader) == 44, "Wrong type size"); | |
957 static_assert(sizeof(SoundDesc_mm6) == 112, "Wrong type size"); | |
958 static_assert(sizeof(SoundDesc) == 120, "Wrong type size"); | |
959 static_assert(sizeof(OverlayDesc) == 8, "Wrong type size"); | |
960 static_assert(sizeof(ChestDesc) == 36, "Wrong type size"); | |
961 static_assert(sizeof(ObjectDesc_mm6) == 52, "Wrong type size"); | |
962 static_assert(sizeof(ObjectDesc) == 56, "Wrong type size"); | |
963 static_assert(sizeof(DecorationDesc) == 84, "Wrong type size"); | |
964 static_assert(sizeof(IconFrame) == 32, "Wrong type size"); | |
965 static_assert(sizeof(PlayerFrame) == 10, "Wrong type size"); | |
966 static_assert(sizeof(TextureFrame) == 20, "Wrong type size"); | |
967 static_assert(sizeof(SpriteFrame) == 60, "Wrong type size"); | |
968 static_assert(sizeof(RenderVertexSoft) == 0x30, "Wrong type size"); | |
969 static_assert(sizeof(RenderBillboard) == 0x34, "Wrong type size"); | |
970 static_assert(sizeof(Texture) == 0x48, "Wrong type size"); | |
971 //static_assert(sizeof(RGBTexture) == 0x28, "Wrong type size"); | |
972 //static_assert(sizeof(LODFile_IconsBitmaps) == 0x11BB8 + 4, "Wrong type size"); // + virtual dtor ptr | |
973 static_assert(sizeof(AudioPlayer) == 0xC84, "Wrong type size"); | |
974 static_assert(sizeof(SoundDesc) == 0x78, "Wrong type size"); | |
975 static_assert(sizeof(stru339_spell_sound) == 0xAFD8, "Wrong type size"); | |
976 //static_assert(sizeof(VideoPlayer) == 0x108 + 4, "Wrong type size"); | |
977 static_assert(sizeof(MovieHeader) == 0x2C, "Wrong type size"); | |
978 static_assert(sizeof(DecorationDesc) == 0x54, "Wrong type size"); | |
979 static_assert(sizeof(ObjectDesc) == 0x38, "Wrong type size"); | |
980 static_assert(sizeof(OverlayDesc) == 0x8, "Wrong type size"); | |
981 static_assert(sizeof(ChestDesc) == 0x24, "Wrong type size"); | |
982 static_assert(sizeof(TileDesc) == 0x1A, "Wrong type size"); | |
983 static_assert(sizeof(MonsterDesc_mm6) == 148, "Wrong type size"); | |
984 static_assert(sizeof(MonsterDesc) == 152, "Wrong type size"); | |
985 static_assert(sizeof(Timer) == 0x28, "Wrong type size"); | |
986 static_assert(sizeof(OtherOverlay) == 0x14, "Wrong type size"); | |
987 static_assert(sizeof(ItemGen) == 0x24, "Wrong type size"); | |
988 static_assert(sizeof(SpriteObject) == 0x70, "Wrong type size"); | |
989 static_assert(sizeof(ItemDesc) == 0x30, "Wrong type size"); | |
990 static_assert(sizeof(ItemsTable) == 0x117A0, "Wrong type size"); | |
991 static_assert(sizeof(Chest) == 0x14CC, "Wrong type size"); | |
992 static_assert(sizeof(MapInfo) == 0x44, "Wrong type size"); | |
993 static_assert(sizeof(SpellInfo) == 0x24, "Wrong type size"); | |
994 static_assert(sizeof(SpellData) == 0x14, "Wrong type size"); | |
995 static_assert(sizeof(SpellBuff) == 0x10, "Wrong type size"); | |
996 static_assert(sizeof(AIDirection) == 0x1C, "Wrong type size"); | |
997 static_assert(sizeof(ActorJob) == 0xC, "Wrong type size"); | |
998 static_assert(sizeof(Actor) == 0x344, "Wrong type size"); | |
999 static_assert(sizeof(LevelDecoration) == 0x20, "Wrong type size"); | |
1000 static_assert(sizeof(KeyboardActionMapping) == 0x20C, "Wrong type size"); | |
1001 static_assert(sizeof(UIAnimation) == 0xD, "Wrong type size"); | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1002 //static_assert(sizeof(SpawnPointMM7) == 0x18, "Wrong type size"); |
2541 | 1003 static_assert(sizeof(ODMFace) == 0x134, "Wrong type size"); |
1004 static_assert(sizeof(BSPNode) == 0x8, "Wrong type size"); | |
1005 static_assert(sizeof(BSPModel) == 0xBC, "Wrong type size"); | |
1006 static_assert(sizeof(OutdoorLocation) == 0x1C28C, "Wrong type size"); | |
1007 static_assert(sizeof(BLVFace) == 0x60, "Wrong type size"); | |
1008 static_assert(sizeof(BLVFaceExtra) == 0x24, "Wrong type size"); | |
1009 static_assert(sizeof(BLVSector) == 0x74, "Wrong type size"); | |
1010 static_assert(sizeof(BLVLightMM7) == 0x10, "Wrong type size"); | |
1011 static_assert(sizeof(BLVDoor) == 0x50, "Wrong type size"); | |
1012 static_assert(sizeof(IndoorLocation) == 0x690, "Wrong type size"); | |
1013 //static_assert(sizeof(ODMRenderParams) == 0x74, "Wrong type size"); | |
1014 static_assert(sizeof(Mouse) == 0x114, "Wrong type size"); | |
1015 static_assert(sizeof(Particle_sw) == 0x68, "Wrong type size"); | |
1016 static_assert(sizeof(Particle) == 0x68, "Wrong type size"); | |
1017 static_assert(sizeof(ParticleEngine) == 0xE430, "Wrong type size"); | |
1018 static_assert(sizeof(Lightmap) == 0xC1C, "Wrong type size"); | |
1019 static_assert(sizeof(LightmapBuilder) == 0x3CBC38, "Wrong type size"); | |
1020 static_assert(sizeof(Vis_SelectionList) == 0x2008, "Wrong type size"); | |
1021 static_assert(sizeof(Vis) == 0x20D0, "Wrong type size"); | |
1022 static_assert(sizeof(PlayerBuffAnim) == 0x10, "Wrong type size"); | |
1023 static_assert(sizeof(ProjectileAnim) == 0x1C, "Wrong type size"); | |
1024 static_assert(sizeof(stru6) == 0x5F8, "Wrong type size"); | |
1025 static_assert(sizeof(IndoorCameraD3D_Vec3) == 0x10, "Wrong type size"); | |
1026 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 | |
1027 //static_assert(sizeof(IndoorCameraD3D) == 0x1A1384, "Wrong type size"); | |
1028 static_assert(sizeof(StationaryLight) == 0xC, "Wrong type size"); | |
1029 static_assert(sizeof(LightsStack_StationaryLight_) == 0x12C8, "Wrong type size"); | |
1030 static_assert(sizeof(MobileLight) == 0x12, "Wrong type size"); | |
1031 static_assert(sizeof(LightsStack_MobileLight_) == 0x1C28, "Wrong type size"); | |
1032 static_assert(sizeof(Engine) == 0xE78, "Wrong type size"); | |
1033 static_assert(sizeof(stru141_actor_collision_object) == 0xA8, "Wrong type size"); | |
1034 static_assert(sizeof(ActionQueue) == 0x7C, "Wrong type size"); | |
1035 static_assert(sizeof(NPCData) == 0x4C, "Wrong type size"); | |
1036 static_assert(sizeof(NPCStats) == 0x17FFC, "Wrong type size"); | |
1037 static_assert(sizeof(BspRenderer) == 0x53740, "Wrong type size"); | |
1038 static_assert(sizeof(PaletteManager) == 0x267AF0, "Wrong type size"); | |
1039 static_assert(sizeof(ViewingParams) == 0x26C, "Wrong type size"); | |
1040 //static_assert(sizeof(IndoorCamera) == 0x50, "Wrong type size"); | |
1041 static_assert(sizeof(Bloodsplat) == 0x28, "Wrong type size"); | |
1042 static_assert(sizeof(BloodsplatContainer) == 0xA0C, "Wrong type size"); | |
1043 static_assert(sizeof(TrailParticle) == 0x18, "Wrong type size"); | |
1044 static_assert(sizeof(EventIndex) == 0xC, "Wrong type size"); | |
1045 static_assert(sizeof(_2devent) == 0x34, "Wrong type size"); | |
1046 static_assert(sizeof(MapsLongTimer) == 0x20, "Wrong type size"); | |
1047 static_assert(sizeof(SavegameHeader) == 0x64, "Wrong type size"); | |
1048 static_assert(sizeof(SavegameList) == 0x3138, "Wrong type size"); | |
1049 static_assert(sizeof(StorylineText) == 0x160, "Wrong type size"); | |
1050 static_assert(sizeof(FactionTable) == 0x1EF1, "Wrong type size"); | |
1051 static_assert(sizeof(Decal) == 0xC20, "Wrong type size"); | |
1052 static_assert(sizeof(DecalBuilder) == 0x30C038, "Wrong type size"); | |
1053 static_assert(sizeof(MonsterInfo) == 0x58, "Wrong type size"); | |
1054 static_assert(sizeof(MonsterStats) == 0x5BA0, "Wrong type size"); | |
1055 static_assert(sizeof(RenderD3D) == 0x148, "Wrong type size"); | |
1056 // static_assert(sizeof(Render) == 0x129844, "Wrong type size"); | |
1057 static_assert(sizeof(Player) == 0x1B3C, "Wrong type size"); | |
1058 static_assert(sizeof(PartyTimeStruct) == 0x678, "Wrong type size"); | |
1059 static_assert(sizeof(Party) == 0x16238, "Wrong type size"); | |
1060 static_assert(sizeof(GUIButton) == 0xBC, "Wrong type size"); | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2543
diff
changeset
|
1061 //static_assert(sizeof(GUIWindow) == 0x54, "Wrong type size"); |
2541 | 1062 //static_assert(sizeof(GUIProgressBar) == 0x1B8, "Wrong type size"); |
1063 static_assert(sizeof(GUIFont) == 0x1020, "Wrong type size"); | |
1064 // static_assert(sizeof(stru262_TurnBased) == 0x40, "Wrong type size"); | |
1065 //static_assert(sizeof(ArcomageGame) == 0xFB, "Wrong type size"); | |
1066 static_assert(sizeof(CastSpellInfo) == 0x14, "Wrong type size"); | |
1067 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
|
1068 static_assert(sizeof(LightsData) == 0x3FC, "Wrong type size"); |
2541 | 1069 static_assert(sizeof(TravelInfo) == 0x20, "Wrong type size"); |
1070 static_assert(sizeof(stru336) == 0x798, "Wrong type size"); | |
1071 static_assert(sizeof(Vec3_short_) == 6, "Wrong type size"); | |
1072 static_assert(sizeof(BLVFace) == 96, "Wrong type size"); | |
1073 static_assert(sizeof(BLVFaceExtra) == 36, "Wrong type size"); | |
1074 static_assert(sizeof(BLVSector) == 116, "Wrong type size"); | |
1075 static_assert(sizeof(LevelDecoration) == 32, "Wrong type size"); | |
1076 static_assert(sizeof(BLVLightMM7) == 16, "Wrong type size"); | |
1077 static_assert(sizeof(BSPNode) == 8, "Wrong type size"); | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1078 //static_assert(sizeof(SpawnPointMM7) == 24, "Wrong type size"); |
2541 | 1079 static_assert(sizeof(DDM_DLV_Header) == 40, "Wrong type size"); |
1080 static_assert(sizeof(Actor) == 836, "Wrong type size"); | |
1081 static_assert(sizeof(SpriteObject) == 112, "Wrong type size"); | |
1082 static_assert(sizeof(Chest) == 5324, "Wrong type size"); | |
1083 static_assert(sizeof(stru123) == 0xC8, "Wrong type size"); | |
1084 static_assert(sizeof(BLVMapOutline) == 12, "Wrong type size"); | |
1085 static_assert(sizeof(LODSprite) == 0x28, "Wrong type size"); | |
1086 } | |
1087 | |
1088 | |
1089 //----- (004647AB) -------------------------------------------------------- | |
1090 void FinalInitialization() | |
1091 { | |
1092 pViewport->SetScreen(viewparams->uSomeX, viewparams->uSomeY, viewparams->uSomeZ, viewparams->uSomeW); | |
1093 pViewport->SetFOV(flt_6BE3A0 * 65536.0f); | |
1094 | |
1095 //pIndoorCamera = new IndoorCamera; | |
1096 //pIndoorCamera->Initialize(65, viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X + 1, | |
1097 // viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y + 1); | |
1098 | |
1099 InitializeTurnBasedAnimations(&stru_50C198); | |
1100 pBitmaps_LOD->_inlined_sub1(); | |
1101 pSprites_LOD->_inlined_sub1(); | |
1102 pIcons_LOD->_inlined_sub1(); | |
1103 } | |
1104 // 6BE3A0: using guessed type float flt_6BE3A0; | |
1105 | |
1106 | |
1107 | |
1108 //----- (00464E17) -------------------------------------------------------- | |
1109 bool __fastcall CheckMM7CD(char c) | |
1110 { | |
1111 char DstBuf[256] = { 0 }; | |
1112 char strCommand[256] = { 0 }; // [sp+10Ch] [bp-118h]@1 | |
1113 char Filename[20] = { 0 }; // [sp+20Ch] [bp-18h]@1 | |
1114 | |
1115 wchar_t pMagicPath[1024]; | |
1116 swprintf(pMagicPath, wcslen(L"%C:\\anims\\magic7.vid"), L"%C:\\anims\\magic7.vid", c); | |
1117 if (GetFileAttributesW(pMagicPath) == -1) | |
1118 return false; | |
1119 | |
1120 //Open CD audio | |
1121 wsprintfA(strCommand, "open %c: type cdaudio alias CD", c); | |
1122 if (!mciSendStringA(strCommand, DstBuf, 255, 0)) | |
1123 { | |
1124 wsprintfA(strCommand, "info CD UPC wait"); | |
1125 mciSendStringA(strCommand, DstBuf, 255, 0); | |
1126 wsprintfA(strCommand, "close CD"); | |
1127 mciSendStringA(strCommand, DstBuf, 255, 0); | |
1128 } | |
1129 | |
1130 memcpy(Filename, "X:\\anims\\magic7.vid", sizeof(Filename)); | |
1131 *Filename = c; | |
1132 | |
1133 FILE* f = fopen(Filename, "rb"); | |
1134 if (!f) | |
1135 return false; | |
1136 | |
1137 if (!fseek(f, 0, SEEK_END)) | |
1138 { | |
1139 if (!fseek(f, -100, SEEK_CUR)) | |
1140 fread(DstBuf, 1, 0x64u, f); | |
1141 | |
1142 fclose(f); | |
1143 return true; | |
1144 } | |
1145 fclose(f); | |
1146 return false; | |
1147 } | |
1148 | |
1149 //----- (00464F1B) -------------------------------------------------------- | |
1150 signed int __stdcall InsertMM7CDDialogFunc(HWND hDlg, int a2, __int16 a3, int a4) | |
1151 { | |
1152 char v4; // zf@3 | |
1153 int v6; // eax@10 | |
1154 int v7; // eax@11 | |
1155 int v8; // eax@12 | |
1156 int v9; // eax@13 | |
1157 BOOL(__stdcall *v10)(HWND, int, LPCSTR); // edi@15 | |
1158 const CHAR *v11; // [sp-Ch] [bp-Ch]@15 | |
1159 INT_PTR v12; // [sp-4h] [bp-4h]@5 | |
1160 | |
1161 if (a2 == 272) | |
1162 { | |
1163 hInsertCDWindow = hDlg; | |
1164 v6 = (GetUserDefaultLangID() & 0x3FF) - 7; | |
1165 if (v6) | |
1166 { | |
1167 v7 = v6 - 3; | |
1168 if (v7) | |
1169 { | |
1170 v8 = v7 - 2; | |
1171 if (v8) | |
1172 { | |
1173 v9 = v8 - 4; | |
1174 if (v9) | |
1175 { | |
1176 if (v9 != 5) | |
1177 return 0; | |
1178 SetWindowTextA(hDlg, "Wloz CD-ROM numer 2"); | |
1179 v10 = SetDlgItemTextA; | |
1180 SetDlgItemTextA(hDlg, 1010, "Wloz CD-ROM numer 2 Might and Magic® VII."); | |
1181 v11 = "Odwolaj"; | |
1182 } | |
1183 else | |
1184 { | |
1185 SetWindowTextA(hDlg, "Inserire il secondo CD"); | |
1186 v10 = SetDlgItemTextA; | |
1187 SetDlgItemTextA(hDlg, 1010, "Inserire il secondo CD di Might and Magic® VII."); | |
1188 v11 = "Annulla"; | |
1189 } | |
1190 } | |
1191 else | |
1192 { | |
1193 SetWindowTextA(hDlg, "Insérez le CD 2"); | |
1194 v10 = SetDlgItemTextA; | |
1195 SetDlgItemTextA(hDlg, 1010, "Insérez Might & Magic® VII CD 2."); | |
1196 v11 = "Supprimer"; | |
1197 } | |
1198 } | |
1199 else | |
1200 { | |
1201 SetWindowTextA(hDlg, "Por favor, inserte disco 2"); | |
1202 v10 = SetDlgItemTextA; | |
1203 SetDlgItemTextA(hDlg, 1010, "Por favor, inserte disco 2 de Might & Magic® VII."); | |
1204 v11 = "Cancelar"; | |
1205 } | |
1206 } | |
1207 else | |
1208 { | |
1209 SetWindowTextA(hDlg, "Bitte CD 2 einlegen"); | |
1210 v10 = SetDlgItemTextA; | |
1211 SetDlgItemTextA(hDlg, 1010, "Bitte CD 2 von Might and Magic® VII einlegen."); | |
1212 v11 = "Abbrechen"; | |
1213 } | |
1214 v10(hDlg, 2, v11); | |
1215 return 0; | |
1216 } | |
1217 if (a2 == 273) | |
1218 { | |
1219 if (a3 == 2) | |
1220 { | |
1221 v12 = 0; | |
1222 EndDialog(hDlg, v12); | |
1223 return 1; | |
1224 } | |
1225 v4 = a3 == 1; | |
1226 } | |
1227 else | |
1228 { | |
1229 v4 = a2 == 1025; | |
1230 } | |
1231 if (v4) | |
1232 { | |
1233 v12 = 1; | |
1234 EndDialog(hDlg, v12); | |
1235 return 1; | |
1236 } | |
1237 return 0; | |
1238 } | |
1239 | |
1240 //----- (00465061) -------------------------------------------------------- | |
1241 bool __fastcall FindMM7CD(HWND hWnd, char *pCDDrive) | |
1242 { | |
1243 char drive[4] = { 'X', ':', '\\', 0 }; | |
1244 | |
1245 bool bGotCDFromRegistry = false; | |
1246 | |
1247 HKEY hSoftware = nullptr, | |
1248 hNWC = nullptr, | |
1249 hMM7 = nullptr, | |
1250 hVersion = nullptr; | |
1251 if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ | KEY_WOW64_32KEY, &hSoftware)) | |
1252 { | |
1253 if (!RegOpenKeyExA(hSoftware, "New World Computing", 0, KEY_READ | KEY_WOW64_32KEY, &hNWC)) | |
1254 { | |
1255 if (!RegOpenKeyExA(hNWC, "Might and Magic VII", 0, KEY_READ | KEY_WOW64_32KEY, &hMM7)) | |
1256 { | |
1257 if (!RegOpenKeyExA(hMM7, "1.0", 0, KEY_READ | KEY_WOW64_32KEY, &hVersion)) | |
1258 { | |
1259 DWORD cbData = 3; | |
1260 if (!RegQueryValueExA(hVersion, "CDDrive", 0, 0, (BYTE *)drive, &cbData)) | |
1261 bGotCDFromRegistry = true; | |
1262 } | |
1263 RegCloseKey(hVersion); | |
1264 } | |
1265 RegCloseKey(hMM7); | |
1266 } | |
1267 RegCloseKey(hNWC); | |
1268 } | |
1269 RegCloseKey(hSoftware); | |
1270 | |
1271 if (bGotCDFromRegistry) | |
1272 if (CheckMM7CD(*drive)) | |
1273 { | |
1274 cMM7GameCDDriveLetter = *drive; | |
1275 return true; | |
1276 } | |
1277 | |
1278 while (true) | |
1279 { | |
1280 for (uint i = 0; i < 26; ++i) | |
1281 { | |
1282 drive[0] = 'A' + i; | |
1283 | |
1284 if (GetDriveTypeA(drive) == DRIVE_CDROM) | |
1285 if (CheckMM7CD(*drive)) | |
1286 { | |
1287 cMM7GameCDDriveLetter = *drive; | |
1288 WriteWindowsRegistryString("CDDrive", drive); | |
1289 return true; | |
1290 } | |
1291 } | |
1292 | |
1293 if (DialogBoxParamA(GetModuleHandleW(nullptr), "InsertCD", hWnd, (DLGPROC)InsertMM7CDDialogFunc, 0)) | |
1294 continue; | |
1295 return false; | |
1296 } | |
1297 } | |
1298 | |
1299 //----- (004651F4) -------------------------------------------------------- | |
1300 bool MM7_Initialize(int game_width, int game_height) | |
1301 { | |
1302 wchar_t pCurrentDir[1024]; | |
1303 _wgetcwd(pCurrentDir, 1024); | |
1304 | |
1305 wchar_t pMM6IniFile[1024]; | |
1306 wsprintfW(pMM6IniFile, L"%s\\mm6.ini", pCurrentDir); | |
1307 | |
1308 bCanLoadFromCD = GetPrivateProfileIntW(L"settings", L"use_cd", 1, pMM6IniFile); | |
1309 if (bNoCD) | |
1310 bCanLoadFromCD = false; | |
1311 if (bCanLoadFromCD) | |
1312 { | |
1313 Log::Warning(L"Checking for CD..."); | |
1314 if (!FindMM7CD(nullptr, &cMM7GameCDDriveLetter)) | |
1315 return false; | |
1316 Log::Warning(L"...done."); | |
1317 } | |
1318 | |
1319 | |
1320 srand(GetTickCount()); | |
1321 | |
1322 pEventTimer = Timer::Create(); | |
1323 pEventTimer->Initialize(); | |
1324 window = OSWindow::Create(L"Might and Magic® Trilogy", game_width, game_height);//Create game window | |
1325 | |
1326 bool use_d3d11 = false; | |
1327 if (use_d3d11) | |
1328 pRenderer = RenderD3D11::Create(); | |
1329 else | |
1330 pRenderer = Render::Create();//Create DirectX | |
1331 if (!pRenderer) | |
1332 { | |
1333 Log::Warning(L"Render creation failed"); | |
1334 return false; | |
1335 } | |
1336 else | |
1337 { | |
1338 //bool bWindowMode = ReadWindowsRegistryInt("startinwindow", false); | |
1339 //uint uDefaultDevice = ReadWindowsRegistryInt("D3D Device", 1); | |
1340 | |
1341 if (!pRenderer->Initialize(window/*, bColoredLights, uLevelOfDetail, bTinting*/)) | |
1342 { | |
1343 Log::Warning(L"Render failed to initialize"); | |
1344 return false; | |
1345 } | |
1346 } | |
1347 | |
1348 game_starting_year = 1168; | |
1349 | |
1350 pParty = new Party; | |
1351 memset(&pParty->pHirelings, 0, sizeof(pParty->pHirelings)); | |
1352 pParty->uWalkSpeed = GetPrivateProfileIntW(L"debug", L"walkspeed", 384, pMM6IniFile); | |
1353 pParty->uDefaultEyelevel = GetPrivateProfileIntW(L"party", L"eyelevel", 160, pMM6IniFile); | |
1354 pParty->sEyelevel = pParty->uDefaultEyelevel; | |
1355 pParty->uDefaultPartyHeight = GetPrivateProfileIntW(L"party", L"height", 192, pMM6IniFile); | |
1356 pParty->uPartyHeight = pParty->uDefaultPartyHeight; | |
1357 | |
1358 MM6_Initialize(pMM6IniFile); | |
1359 | |
1360 pKeyActionMap = new KeyboardActionMapping; | |
1361 | |
1362 OnTimer(1); | |
1363 GameUI_StatusBar_UpdateTimedString(1); | |
1364 pEngine = Engine::Create(); | |
1365 pMouse = pEngine->pMouseInstance; | |
1366 | |
1367 | |
1368 pIcons_LOD = new LODFile_IconsBitmaps; | |
1369 if (!pIcons_LOD->Load("data\\icons.lod", "icons")) | |
1370 { | |
1371 MessageBoxW(nullptr, L"Some files are missing\n\nPlease Reinstall.", | |
1372 L"Files Missing", MB_ICONEXCLAMATION); | |
1373 return false; | |
1374 } | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1375 pIcons_LOD->_011BA4_debug_paletted_pixels_uncompressed = false; |
2541 | 1376 |
1377 pEvents_LOD = new LODFile_IconsBitmaps; | |
1378 if (!pEvents_LOD->Load("data\\events.lod", "icons")) | |
1379 { | |
1380 MessageBoxW(nullptr, L"Some files are missing\n\nPlease Reinstall.", | |
1381 L"Files Missing", MB_ICONEXCLAMATION); | |
1382 return false; | |
1383 } | |
1384 | |
1385 InitializeGameText(); | |
1386 | |
1387 pBitmaps_LOD = new LODFile_IconsBitmaps; | |
1388 if (!pBitmaps_LOD->Load("data\\bitmaps.lod", "bitmaps")) | |
1389 { | |
1390 MessageBoxA(nullptr, pGlobalTXT_LocalizationStrings[63], | |
1391 pGlobalTXT_LocalizationStrings[184], MB_ICONEXCLAMATION); | |
1392 return false; | |
1393 } | |
1394 | |
1395 pSprites_LOD = new LODFile_Sprites; | |
1396 if (!pSprites_LOD->LoadSprites("data\\sprites.lod")) | |
1397 { | |
1398 MessageBoxA(nullptr, | |
1399 pGlobalTXT_LocalizationStrings[63], | |
1400 pGlobalTXT_LocalizationStrings[184], MB_ICONEXCLAMATION); | |
1401 return false; | |
1402 } | |
1403 | |
1404 | |
1405 #if 0 | |
1406 if (_access("../MM_VI/data/icons.lod", 0) == 0) | |
1407 { | |
1408 pIcons_LOD_mm6 = new LODFile_IconsBitmaps; | |
1409 if (!pIcons_LOD_mm6->Load("../MM_VI/data/icons.lod", "icons")) | |
1410 { | |
1411 delete pIcons_LOD_mm6; | |
1412 pIcons_LOD_mm6 = nullptr; | |
1413 Log::Warning(L"Unable to load mm6:icons.lod"); | |
1414 } | |
1415 } | |
1416 else | |
1417 Log::Warning(L"Unable to find mm6:icons.lod"); | |
1418 | |
1419 if (_access("../MM_VI/data/bitmaps.lod", 0) == 0) | |
1420 { | |
1421 pBitmaps_LOD_mm6 = new LODFile_IconsBitmaps; | |
1422 if (!pBitmaps_LOD_mm6->Load("../MM_VI/data/bitmaps.lod", "bitmaps")) | |
1423 { | |
1424 delete pBitmaps_LOD_mm6; | |
1425 pBitmaps_LOD_mm6 = nullptr; | |
1426 Log::Warning(L"Unable to load mm6:bitmaps.lod"); | |
1427 } | |
1428 } | |
1429 else | |
1430 Log::Warning(L"Unable to find mm6:bitmaps.lod"); | |
1431 | |
1432 auto mm6_sprite_container_name = bUseLoResSprites ? "../MM_VI/data/spriteLO.lod" | |
1433 : "../MM_VI/data/sprites.lod"; | |
1434 if (_access(mm6_sprite_container_name, 0) == 0) | |
1435 { | |
1436 pSprites_LOD_mm6 = new LODFile_Sprites; | |
1437 if (!pSprites_LOD_mm6->LoadSprites(mm6_sprite_container_name)) | |
1438 { | |
1439 delete pSprites_LOD_mm6; | |
1440 pSprites_LOD_mm6 = nullptr; | |
1441 Log::Warning(L"Unable to load mm6:sprites.lod"); | |
1442 } | |
1443 } | |
1444 else | |
1445 Log::Warning(L"Unable to find mm6:sprites.lod"); | |
1446 | |
1447 | |
1448 if (_access("../mm8/data/icons.lod", 0) == 0) | |
1449 { | |
1450 pIcons_LOD_mm8 = new LODFile_IconsBitmaps; | |
1451 if (!pIcons_LOD_mm8->Load("../mm8/data/icons.lod", "icons")) | |
1452 { | |
1453 delete pIcons_LOD_mm8; | |
1454 pIcons_LOD_mm8 = nullptr; | |
1455 Log::Warning(L"Unable to load mm8:icons.lod"); | |
1456 } | |
1457 } | |
1458 else | |
1459 Log::Warning(L"Unable to find mm8:icons.lod"); | |
1460 | |
1461 | |
1462 if (_access("../mm8/data/bitmaps.lod", 0) == 0) | |
1463 { | |
1464 pBitmaps_LOD_mm8 = new LODFile_IconsBitmaps; | |
1465 if (!pBitmaps_LOD_mm8->Load("../mm8/data/bitmaps.lod", "bitmaps")) | |
1466 { | |
1467 delete pBitmaps_LOD_mm8; | |
1468 pBitmaps_LOD_mm8 = nullptr; | |
1469 Log::Warning(L"Unable to load mm8:bitmaps.lod"); | |
1470 } | |
1471 } | |
1472 else | |
1473 Log::Warning(L"Unable to find mm8:bitmaps.lod"); | |
1474 | |
1475 | |
1476 if (_access("../mm8/data/sprites.lod", 0) == 0) | |
1477 { | |
1478 pSprites_LOD_mm8 = new LODFile_Sprites; | |
1479 if (!pSprites_LOD_mm8->LoadSprites("../mm8/data/sprites.lod")) | |
1480 { | |
1481 delete pSprites_LOD_mm8; | |
1482 pSprites_LOD_mm8 = nullptr; | |
1483 Log::Warning(L"Unable to load mm8:sprites.lod"); | |
1484 } | |
1485 } | |
1486 else | |
1487 Log::Warning(L"Unable to find mm8:sprites.lod"); | |
1488 #endif | |
1489 | |
1490 { | |
1491 void *sft_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dsft.bin", 1) : nullptr, | |
1492 *sft_mm8 = nullptr; | |
1493 void *sft_mm7 = pEvents_LOD->LoadRaw("dsft.bin", 1); | |
1494 pSpriteFrameTable = new SpriteFrameTable; | |
1495 pSpriteFrameTable->FromFile(sft_mm6, sft_mm7, sft_mm8); | |
1496 free(sft_mm6); | |
1497 free(sft_mm7); | |
1498 free(sft_mm8); | |
1499 | |
1500 void *tft_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dtft.bin", 1) : nullptr, | |
1501 *tft_mm8 = nullptr; | |
1502 void *tft_mm7 = pEvents_LOD->LoadRaw("dtft.bin", 1); | |
1503 pTextureFrameTable = new TextureFrameTable; | |
1504 pTextureFrameTable->FromFile(tft_mm6, tft_mm7, tft_mm8); | |
1505 free(tft_mm6); | |
1506 free(tft_mm7); | |
1507 free(tft_mm8); | |
1508 | |
1509 void *tiles_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dtile.bin", 1) : nullptr, | |
1510 *tiles_mm8 = nullptr; | |
1511 void *tiles_mm7 = pEvents_LOD->LoadRaw("dtile.bin", 1); | |
1512 pTileTable = new TileTable; | |
1513 pTileTable->FromFile(tiles_mm6, tiles_mm7, tiles_mm8); | |
1514 free(tiles_mm6); | |
1515 free(tiles_mm7); | |
1516 free(tiles_mm8); | |
1517 | |
1518 void *pft_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dpft.bin", 1) : nullptr, | |
1519 *pft_mm8 = nullptr; | |
1520 void *pft_mm7 = pEvents_LOD->LoadRaw("dpft.bin", 1); | |
1521 pPlayerFrameTable = new PlayerFrameTable; | |
1522 pPlayerFrameTable->FromFile(pft_mm6, pft_mm7, pft_mm8); | |
1523 free(pft_mm6); | |
1524 free(pft_mm7); | |
1525 free(pft_mm8); | |
1526 | |
1527 void *ift_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dift.bin", 1) : nullptr, | |
1528 *ift_mm8 = nullptr; | |
1529 void *ift_mm7 = pEvents_LOD->LoadRaw("dift.bin", 1); | |
1530 pIconsFrameTable = new IconFrameTable; | |
1531 pIconsFrameTable->FromFile(ift_mm6, ift_mm7, ift_mm8); | |
1532 free(ift_mm6); | |
1533 free(ift_mm7); | |
1534 free(ift_mm8); | |
1535 | |
1536 void *decs_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("ddeclist.bin", 1) : nullptr, | |
1537 *decs_mm8 = nullptr; | |
1538 void *decs_mm7 = pEvents_LOD->LoadRaw("ddeclist.bin", 1); | |
1539 pDecorationList = new DecorationList; | |
1540 pDecorationList->FromFile(decs_mm6, decs_mm7, decs_mm8); | |
1541 free(decs_mm6); | |
1542 free(decs_mm7); | |
1543 free(decs_mm8); | |
1544 | |
1545 void *objs_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dobjlist.bin", 1) : nullptr, | |
1546 *objs_mm8 = nullptr; | |
1547 void *objs_mm7 = pEvents_LOD->LoadRaw("dobjlist.bin", 1); | |
1548 pObjectList = new ObjectList; | |
1549 pObjectList->FromFile(objs_mm6, objs_mm7, objs_mm8); | |
1550 free(objs_mm6); | |
1551 free(objs_mm7); | |
1552 free(objs_mm8); | |
1553 | |
1554 void *mons_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dmonlist.bin", 1) : nullptr, | |
1555 *mons_mm8 = nullptr; | |
1556 void *mons_mm7 = pEvents_LOD->LoadRaw("dmonlist.bin", 1); | |
1557 pMonsterList = new MonsterList; | |
1558 pMonsterList->FromFile(mons_mm6, mons_mm7, mons_mm8); | |
1559 free(mons_mm6); | |
1560 free(mons_mm7); | |
1561 free(mons_mm8); | |
1562 | |
1563 void *chests_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dchest.bin", 1) : nullptr, | |
1564 *chests_mm8 = nullptr; | |
1565 void *chests_mm7 = pEvents_LOD->LoadRaw("dchest.bin", 1); | |
1566 pChestList = new ChestList; | |
1567 pChestList->FromFile(chests_mm6, chests_mm7, chests_mm8); | |
1568 free(chests_mm6); | |
1569 free(chests_mm7); | |
1570 free(chests_mm8); | |
1571 | |
1572 void *overlays_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("doverlay.bin", 1) : nullptr, | |
1573 *overlays_mm8 = nullptr; | |
1574 void *overlays_mm7 = pEvents_LOD->LoadRaw("doverlay.bin", 1); | |
1575 pOverlayList = new OverlayList; | |
1576 pOverlayList->FromFile(overlays_mm6, overlays_mm7, overlays_mm8); | |
1577 free(overlays_mm6); | |
1578 free(overlays_mm7); | |
1579 free(overlays_mm8); | |
1580 | |
1581 void *sounds_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dsounds.bin", 1) : nullptr, | |
1582 *sounds_mm8 = nullptr; | |
1583 void *sounds_mm7 = pEvents_LOD->LoadRaw("dsounds.bin", 1); | |
1584 pSoundList = new SoundList; | |
1585 pSoundList->FromFile(sounds_mm6, sounds_mm7, sounds_mm8); | |
1586 free(sounds_mm6); | |
1587 free(sounds_mm7); | |
1588 free(sounds_mm8); | |
1589 } | |
1590 | |
1591 | |
1592 | |
1593 | |
1594 if (dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_RUN_IN_WIDOW) | |
1595 { | |
1596 //window->SetWindowedMode(game_width, game_height); | |
1597 pRenderer->SwitchToWindow(); | |
1598 } | |
1599 else | |
1600 { | |
1601 __debugbreak(); // Nomad | |
1602 window->SetFullscreenMode(); | |
1603 pRenderer->InitializeFullscreen(); | |
1604 } | |
1605 | |
1606 uSoundVolumeMultiplier = min(9, ReadWindowsRegistryInt("soundflag", 9)); | |
1607 uMusicVolimeMultiplier = min(9, ReadWindowsRegistryInt("musicflag", 9)); | |
1608 uVoicesVolumeMultiplier = min(9, ReadWindowsRegistryInt("CharVoices", 9)); | |
1609 bShowDamage = ReadWindowsRegistryInt("ShowDamage", 1) != 0; | |
1610 | |
1611 uGammaPos = min(4, ReadWindowsRegistryInt("GammaPos", 4)); | |
1612 //pEngine->pGammaController->Initialize(uGammaPos * 0.1 + 0.6); | |
1613 | |
1614 if (ReadWindowsRegistryInt("Bloodsplats", 1)) | |
1615 pEngine->uFlags2 |= GAME_FLAGS_2_DRAW_BLOODSPLATS; | |
1616 else | |
1617 pEngine->uFlags2 &= ~GAME_FLAGS_2_DRAW_BLOODSPLATS; | |
1618 | |
1619 uTurnSpeed = ReadWindowsRegistryInt("TurnDelta", 3); | |
1620 | |
1621 if (!bNoSound) | |
1622 pAudioPlayer->Initialize(); | |
1623 | |
1624 pMediaPlayer = new Media::MPlayer(); | |
1625 pMediaPlayer->Initialize(window); | |
1626 | |
1627 dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000; | |
1628 | |
1629 switch (uTurnSpeed) | |
1630 { | |
1631 case 0: // undefined turn option | |
1632 __debugbreak(); // really shouldn't use this mode | |
1633 uTurnSpeed = 64; //(unsigned int)uCPUSpeed < 199/*MHz*/ ? 128 : 64; // adjust turn speed to estimated fps | |
1634 break; | |
1635 | |
1636 case 1: // 16x | |
1637 Log::Warning(L"x16 Turn Speed"); // really shouldn't use this mode | |
1638 uTurnSpeed = 128; | |
1639 break; | |
1640 | |
1641 case 2: // 32x | |
1642 Log::Warning(L"x32 Turn Speed"); // really shouldn't use this mode | |
1643 uTurnSpeed = 64; | |
1644 break; | |
1645 | |
1646 case 3: // smooth | |
1647 uTurnSpeed = 0; | |
1648 break; | |
1649 } | |
1650 | |
1651 return true; | |
1652 } | |
1653 | |
1654 //----- (00465D0B) -------------------------------------------------------- | |
1655 void SecondaryInitialization() | |
1656 { | |
1657 pMouse->Initialize(window); | |
1658 | |
1659 pItemsTable = new ItemsTable; | |
1660 pItemsTable->Initialize(); | |
1661 | |
1662 //pBitmaps_LOD->can_load_hardware_sprites = 1; | |
1663 //pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
1664 pBitmaps_LOD->SetupPalettes(5, 6, 5); | |
1665 //pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
1666 pIcons_LOD->SetupPalettes(5, 6, 5); | |
1667 //pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); | |
1668 pPaletteManager->SetColorChannelInfo(5, 6, 5); | |
1669 | |
1670 pPaletteManager->SetMistColor(128, 128, 128); | |
1671 pPaletteManager->RecalculateAll(); | |
1672 //pSprites_LOD->can_load_hardware_sprites = 1; | |
1673 pObjectList->InitializeSprites(); | |
1674 pOverlayList->InitializeSprites(); | |
1675 | |
1676 if (!bNoSound) | |
1677 pSoundList->Initialize(); | |
1678 | |
1679 | |
1680 for (uint i = 0; i < 4; ++i) | |
1681 { | |
1682 static const char *pUIAnimNames[4] = | |
1683 { | |
1684 "glow03", "glow05", | |
1685 "torchA", "wizeyeA" | |
1686 }; | |
1687 static unsigned short _4E98D0[4][4] = | |
1688 { | |
1689 { 479, 0, 329, 0 }, | |
1690 { 585, 0, 332, 0 }, | |
1691 { 468, 0, 0, 0 }, | |
1692 { 606, 0, 0, 0 } | |
1693 }; | |
1694 | |
1695 pUIAnims[i]->uIconID = pIconsFrameTable->FindIcon(pUIAnimNames[i]); | |
1696 pIconsFrameTable->InitializeAnimation(pUIAnims[i]->uIconID); | |
1697 | |
1698 pUIAnims[i]->uAnimLength = 0; | |
1699 pUIAnims[i]->uAnimTime = 0; | |
1700 pUIAnims[i]->x = _4E98D0[i][0]; | |
1701 pUIAnims[i]->y = _4E98D0[i][2]; | |
1702 } | |
1703 | |
1704 for (unsigned int i = 0; i < pObjectList->uNumObjects; ++i) | |
1705 { | |
1706 pObjectList->pObjects[i].uParticleTrailColor = pObjectList->pObjects[i].uParticleTrailColorB | | |
1707 ((unsigned int)pObjectList->pObjects[i].uParticleTrailColorG << 8) | | |
1708 ((unsigned int)pObjectList->pObjects[i].uParticleTrailColorR << 16); | |
1709 } | |
1710 | |
1711 MainMenuUI_Create(); | |
1712 pEngine->pStru6Instance->LoadAnimations(); | |
1713 | |
1714 for (uint i = 0; i < 7; ++i) | |
1715 { | |
1716 char container_name[64]; | |
1717 sprintf(container_name, "HDWTR%03u", i); | |
1718 pRenderer->pHDWaterBitmapIDs[i] = pBitmaps_LOD->LoadTexture(container_name); | |
1719 } | |
1720 | |
1721 pNPCStats = new NPCStats; | |
1722 memset(pNPCStats->pNPCData, 0, 0x94BCu); | |
1723 pNPCStats->Initialize(); | |
1724 | |
1725 Initialize_GlobalEVT(); | |
1726 pBitmaps_LOD->_inlined_sub0(); | |
1727 pSprites_LOD->_inlined_sub0(); | |
1728 pPaletteManager->LockAll(); | |
1729 | |
1730 _mkdir("Saves"); | |
1731 for (uint i = 0; i < 5; ++i) | |
1732 for (uint j = 0; j < 6; ++j) | |
1733 { | |
1734 sprintf(pTmpBuf.data(), "data\\lloyd%d%d.pcx", i, j); | |
1735 remove(pTmpBuf.data()); | |
1736 } | |
1737 | |
1738 Initialize_GamesLOD_NewLOD(); | |
1739 _576E2C_current_minimap_zoom = 512; | |
1740 dword_576E28 = 9; | |
1741 } | |
1742 | |
1743 int max_flight_height = 4000; //maximum altitude | |
1744 bool use_MMT = false; | |
2551
4008b2f34be0
MainMenu rendering moved from event loop to respective window class
a.parshin
parents:
2544
diff
changeset
|
1745 bool use_music_folder = false; |
2541 | 1746 bool for_refactoring = false; |
2566 | 1747 bool all_spells = true; |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1748 bool bNoMargareth = false; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1749 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1750 void ParseCommandLine(const wchar_t *cmd) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1751 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1752 //if (wcsstr(pCmdLine, L"-usedefs")) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1753 // bDebugResouces = 1; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1754 if (wcsstr(cmd, L"-window")) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1755 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_RUN_IN_WIDOW; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1756 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1757 if (wcsstr(cmd, L"-nointro")) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1758 bNoIntro = true;//dword_6BE364_game_settings_1 |= 4; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1759 if (wcsstr(cmd, L"-nologo")) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1760 bNoLogo = true;//dword_6BE364_game_settings_1 |= 8; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1761 if (wcsstr(cmd, L"-nosound")) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1762 bNoSound = true; //dword_6BE364_game_settings_1 |= 0x10; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1763 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1764 bWalkSound = ReadWindowsRegistryInt("WalkSound", 1) != 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1765 if (wcsstr(cmd, L"-nowalksound")) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1766 bWalkSound = false;//dword_6BE364_game_settings_1 |= 0x20; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1767 if (wcsstr(cmd, L"-novideo")) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1768 { |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1769 dword_6BE364_game_settings_1 |= GAME_SETTINGS_NO_HOUSE_ANIM; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1770 bNoVideo = true; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1771 } |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1772 if (wcsstr(cmd, L"-nocd")) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1773 bNoCD = true; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1774 if (wcsstr(cmd, L"-nomarg")) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1775 bNoMargareth = true; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1776 } |
2541 | 1777 |
1778 //----- (00462C94) -------------------------------------------------------- | |
1779 bool MM_Main(const wchar_t *pCmdLine) | |
1780 { | |
1781 IntegrityTest(); | |
1782 | |
1783 lua = new LuaVM; | |
1784 lua->Initialize(); | |
1785 | |
1786 if (pCmdLine && *pCmdLine) | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1787 ParseCommandLine(pCmdLine); |
2541 | 1788 |
1789 if (!MM7_Initialize(640, 480)) | |
1790 { | |
1791 Log::Warning(L"MM init: failed"); | |
1792 pEngine->Deinitialize(); | |
1793 return 1; | |
1794 } | |
1795 | |
1796 pEventTimer->Pause(); | |
1797 | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1798 GUIWindow::InitializeGUI(); |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1799 |
2564 | 1800 |
2541 | 1801 ShowLogoVideo(); |
1802 //ShowIntroVideo_and_LoadingScreen(); | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1803 |
2541 | 1804 dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000; |
1805 | |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1806 //if (use_MMT) |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1807 // MMT_MainMenu_Loop(); |
2541 | 1808 |
1809 Log::Warning(L"MM: entering main loop"); | |
1810 while (1) | |
1811 { | |
2552
ac16f4a3a91e
Load from MainMenu logic separated from MainMenu window
a.parshin
parents:
2551
diff
changeset
|
1812 //MainMenuWindow *main_menu_window = MainMenuWindow::Create(); |
ac16f4a3a91e
Load from MainMenu logic separated from MainMenu window
a.parshin
parents:
2551
diff
changeset
|
1813 //window->AddControl(main_menu_window); |
2541 | 1814 MainMenu_Loop(); |
1815 uGameState = GAME_STATE_PLAYING; | |
1816 while (1) | |
1817 { | |
1818 if (uGameState == GAME_FINISHED || GetCurrentMenuID() == MENU_EXIT_GAME) | |
1819 { | |
1820 pEngine->Deinitialize(); | |
1821 return true; | |
1822 } | |
2553 | 1823 else if (GetCurrentMenuID() == MENU_SAVELOAD) |
2541 | 1824 { |
2553 | 1825 MainMenuLoad_Loop(); |
2563
65c97624c047
Saving & loading works from both main menu and game
a.parshin
parents:
2562
diff
changeset
|
1826 if (GetCurrentMenuID() == MENU_LoadingProcInMainMenu) |
65c97624c047
Saving & loading works from both main menu and game
a.parshin
parents:
2562
diff
changeset
|
1827 { |
65c97624c047
Saving & loading works from both main menu and game
a.parshin
parents:
2562
diff
changeset
|
1828 uGameState = GAME_STATE_PLAYING; |
65c97624c047
Saving & loading works from both main menu and game
a.parshin
parents:
2562
diff
changeset
|
1829 Game_Loop(); |
65c97624c047
Saving & loading works from both main menu and game
a.parshin
parents:
2562
diff
changeset
|
1830 } |
2553 | 1831 break; |
1832 } | |
1833 else if (GetCurrentMenuID() == MENU_NEWGAME) | |
1834 { | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2564
diff
changeset
|
1835 pOtherOverlayList->Reset(); |
2553 | 1836 if (!CreateParty_Loop()) |
2541 | 1837 break; |
2553 | 1838 |
2572
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1839 |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1840 pParty->pPickedItem.uItemID = 0; |
d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
a.parshin
parents:
2569
diff
changeset
|
1841 |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2564
diff
changeset
|
1842 strcpy(pCurrentMapName, pStartingMapName); |
2541 | 1843 bFlashQuestBook = true; |
1844 pMediaPlayer->PlayFullscreenMovie(MOVIE_Emerald, true); | |
1845 SaveNewGame(); | |
1846 if (bNoMargareth) | |
1847 _449B7E_toggle_bit(pParty->_quest_bits, PARTY_QUEST_EMERALD_MARGARETH_OFF, 1); | |
1848 Game_Loop(); | |
1849 if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU) | |
1850 { | |
1851 SetCurrentMenuID(MENU_NEWGAME); | |
1852 uGameState = GAME_STATE_PLAYING; | |
1853 continue; | |
1854 } | |
1855 else if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU) | |
1856 break; | |
1857 assert(false && "Invalid game state"); | |
1858 } | |
2543 | 1859 else if (GetCurrentMenuID() == MENU_CREDITS) |
2541 | 1860 { |
1861 if (use_music_folder) | |
1862 alSourceStop(mSourceID); | |
1863 else | |
1864 { | |
1865 if (pAudioPlayer->hAILRedbook) | |
1866 AIL_redbook_stop(pAudioPlayer->hAILRedbook); | |
1867 } | |
1868 MainMenuUI_Credits_Loop(); | |
1869 break; | |
1870 } | |
2543 | 1871 else if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu) |
2541 | 1872 { |
1873 uGameState = GAME_STATE_PLAYING; | |
1874 Game_Loop(); | |
1875 } | |
2543 | 1876 else if (GetCurrentMenuID() == MENU_DebugBLVLevel) |
2541 | 1877 { |
2543 | 1878 pMouse->ChangeActivation(0); |
1879 pParty->Reset(); | |
2565
117c219bf913
Party, items and stuff are abstracted from savegame file representation
a.parshin
parents:
2564
diff
changeset
|
1880 pParty->CreateDefaultParty(true); |
2543 | 1881 |
1882 __debugbreak(); | |
1883 /*extern void CreateDefaultBLVLevel(); | |
1884 CreateDefaultBLVLevel(); | |
1885 | |
1886 OPENFILENAMEA ofn; | |
1887 if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) ) | |
2541 | 1888 { |
2543 | 1889 pMouse->ChangeActivation(1); |
1890 break; | |
2541 | 1891 } |
2543 | 1892 _chdir("..\\"); |
1893 strcpy(pCurrentMapName, ofn.lpstrFileTitle);*/ | |
1894 pMouse->ChangeActivation(1); | |
1895 Game_Loop(); | |
2541 | 1896 } |
1897 if (uGameState == GAME_STATE_LOADING_GAME) | |
1898 { | |
1899 SetCurrentMenuID(MENU_5); | |
1900 uGameState = GAME_STATE_PLAYING; | |
1901 continue; | |
1902 } | |
1903 if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU) | |
1904 { | |
1905 SetCurrentMenuID(MENU_NEWGAME); | |
1906 uGameState = GAME_STATE_PLAYING; | |
1907 continue; | |
1908 } | |
1909 if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)// from the loaded game | |
1910 { | |
1911 pAudioPlayer->StopChannels(-1, -1); | |
1912 uGameState = GAME_STATE_PLAYING; | |
1913 break; | |
1914 } | |
1915 } | |
1916 } | |
1917 //lua_close(L); | |
1918 pEngine->Deinitialize(); | |
1919 return 1; | |
1920 } | |
1921 | |
1922 | |
1923 | |
1924 //----- (00466082) -------------------------------------------------------- | |
1925 void MM6_Initialize(const wchar_t *pIniFilename) | |
1926 { | |
1927 size_t v2; // eax@31 | |
1928 size_t v3; // ebx@32 | |
1929 size_t v4; // edi@36 | |
1930 char pDefaultGroundTexture[16]; // [sp+FCh] [bp-8Ch]@32 | |
1931 unsigned int v9; // [sp+184h] [bp-4h]@28 | |
1932 | |
1933 //_getcwd(v5, 120); | |
1934 //sprintfex(pIniFilename, "%s\\mm6.ini", v5); | |
1935 viewparams = new ViewingParams; | |
1936 game_viewport_x = viewparams->uScreen_topL_X = GetPrivateProfileIntW(L"screen", L"vx1", 8, pIniFilename); | |
1937 game_viewport_y = viewparams->uScreen_topL_Y = GetPrivateProfileIntW(L"screen", L"vy1", 8, pIniFilename); | |
1938 game_viewport_z = viewparams->uScreen_BttmR_X = GetPrivateProfileIntW(L"screen", L"vx2", 468, pIniFilename); | |
1939 game_viewport_w = viewparams->uScreen_BttmR_Y = GetPrivateProfileIntW(L"screen", L"vy2", 351, pIniFilename); | |
1940 game_viewport_width = game_viewport_z - game_viewport_x; | |
1941 game_viewport_height = game_viewport_w - game_viewport_y + 1; | |
1942 | |
1943 | |
1944 pAudioPlayer = new AudioPlayer; | |
1945 pAudioPlayer->uMixerChannels = GetPrivateProfileIntW(L"settings", L"mixerchannels", 16, pIniFilename); | |
1946 if (pAudioPlayer->uMixerChannels > 16) | |
1947 pAudioPlayer->uMixerChannels = 16; | |
1948 | |
1949 | |
1950 if (GetPrivateProfileIntW(L"debug", L"nomonster", 0, pIniFilename)) | |
1951 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_NO_ACTORS; | |
1952 if (ReadWindowsRegistryInt("startinwindow", 0)) | |
1953 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_RUN_IN_WIDOW; | |
1954 if (GetPrivateProfileIntW(L"debug", L"showFR", 0, pIniFilename)) | |
1955 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_0002_SHOW_FR; | |
1956 if (GetPrivateProfileIntW(L"debug", L"nodamage", 0, pIniFilename)) | |
1957 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_NO_DAMAGE; | |
1958 if (GetPrivateProfileIntW(L"debug", L"nodecoration", 0, pIniFilename)) | |
1959 dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_NO_DECORATIONS; | |
1960 | |
1961 wchar_t pStartingMapNameW[1024]; | |
1962 GetPrivateProfileStringW(L"file", L"startmap", L"out01.odm", pStartingMapNameW, 0x20u, pIniFilename); | |
1963 sprintf(pStartingMapName, "%S", pStartingMapNameW); | |
1964 | |
1965 v9 = 0; | |
1966 if (strlen(pStartingMapName)) | |
1967 { | |
1968 do | |
1969 { | |
1970 if (pStartingMapName[v9] == ' ') | |
1971 pStartingMapName[v9] = 0; | |
1972 ++v9; | |
1973 v2 = strlen(pStartingMapName); | |
1974 } while (v9 < v2); | |
1975 } | |
1976 | |
1977 pODMRenderParams = new ODMRenderParams; | |
1978 pODMRenderParams->outdoor_no_mist = GetPrivateProfileIntW(L"debug", L"noMist", 0, pIniFilename); | |
1979 pODMRenderParams->bNoSky = GetPrivateProfileIntW(L"outdoor", L"nosky", 0, pIniFilename); | |
1980 pODMRenderParams->bDoNotRenderDecorations = GetPrivateProfileIntW(L"render", L"nodecorations", 0, pIniFilename); | |
1981 pODMRenderParams->outdoor_no_wavy_water = GetPrivateProfileIntW(L"outdoor", L"nowavywater", 0, pIniFilename); | |
2543 | 1982 //outdoor_grid_band_1 = GetPrivateProfileIntW(L"outdoor", L"gridband1", 10, pIniFilename); |
1983 //outdoor_grid_band_2 = GetPrivateProfileIntW(L"outdoor", L"gridband2", 15, pIniFilename); | |
1984 //outdoor_grid_band_3 = GetPrivateProfileIntW(L"outdoor", L"gridband3", 25, pIniFilename); | |
2541 | 1985 pODMRenderParams->terrain_gamma = GetPrivateProfileIntW(L"outdoor", L"ter_gamma", 0, pIniFilename); |
1986 pODMRenderParams->building_gamme = GetPrivateProfileIntW(L"outdoor", L"bld_gamma", 0, pIniFilename); | |
1987 pODMRenderParams->shading_dist_shade = GetPrivateProfileIntW(L"shading", L"dist_shade", 2048, pIniFilename); | |
1988 pODMRenderParams->shading_dist_shademist = GetPrivateProfileIntW(L"shading", L"dist_shademist", 4096, pIniFilename); | |
1989 | |
1990 pODMRenderParams->shading_dist_mist = GetPrivateProfileIntW(L"shading", L"dist_mist", 0x2000, pIniFilename);//drawing dist 0x2000 | |
1991 | |
1992 wchar_t pDefaultSkyTextureW[1024]; | |
1993 GetPrivateProfileStringW(L"textures", L"sky", L"plansky1", pDefaultSkyTextureW, 0x10u, pIniFilename); | |
1994 sprintf(pDefaultSkyTexture.data(), "%S", pDefaultSkyTextureW); | |
1995 | |
1996 wchar_t pDefaultGroundTextureW[1024]; | |
1997 GetPrivateProfileStringW(L"textures", L"default", L"dirt", pDefaultGroundTextureW, 0x10u, pIniFilename); | |
1998 sprintf(pDefaultGroundTexture, "%S", pDefaultGroundTextureW); | |
1999 | |
2000 wchar_t pFloat[1024]; | |
2001 GetPrivateProfileStringW(L"debug", L"recmod1", L"1.0", pFloat, 0x10u, pIniFilename); | |
2002 swscanf(pFloat, L"%f", &flt_6BE3A4_debug_recmod1); | |
2003 | |
2004 GetPrivateProfileStringW(L"debug", L"recmod2", L"1.0", pFloat, 0x10u, pIniFilename); | |
2005 swscanf(pFloat, L"%f", &flt_6BE3A8_debug_recmod2); | |
2006 | |
2007 flt_6BE3AC_debug_recmod1_x_1_6 = flt_6BE3A4_debug_recmod1 * 1.666666666666667; | |
2008 | |
2009 v3 = 0; | |
2010 if (strlen(pDefaultSkyTexture.data())) | |
2011 { | |
2012 do | |
2013 { | |
2014 if (pDefaultSkyTexture[v3] == ' ') | |
2015 pDefaultSkyTexture[v3] = 0; | |
2016 ++v3; | |
2017 } while (v3 < strlen(pDefaultSkyTexture.data())); | |
2018 } | |
2019 v4 = 0; | |
2020 if (strlen(pDefaultGroundTexture)) | |
2021 { | |
2022 do | |
2023 { | |
2024 if (pDefaultGroundTexture[v4] == ' ') | |
2025 pDefaultGroundTexture[v4] = 0; | |
2026 ++v4; | |
2027 } while (v4 < strlen(pDefaultGroundTexture)); | |
2028 } | |
2029 | |
2030 MM7Initialization(); | |
2031 } | |
2032 | |
2033 //----- (004666D5) -------------------------------------------------------- | |
2034 void MM7Initialization() | |
2035 { | |
2036 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
2037 { | |
2038 /*if (byte_6BE388_graphicsmode == 0) | |
2039 { | |
2040 outdoor_grid_band_1 = 10; | |
2041 outdoor_grid_band_2 = 15; | |
2042 outdoor_grid_band_3 = 20; | |
2043 pODMRenderParams->shading_dist_mist = 8192; | |
2044 pODMRenderParams->bNoSky = false; | |
2045 LOBYTE(viewparams->field_20) = 0; | |
2046 }*/ | |
2047 pODMRenderParams->shading_dist_shade = 2048; | |
2048 pODMRenderParams->terrain_gamma = 0; | |
2049 pODMRenderParams->building_gamme = 0; | |
2050 pODMRenderParams->shading_dist_shademist = 4096; | |
2051 pODMRenderParams->outdoor_no_wavy_water = 0; | |
2052 //_47F4D3_initialize_terrain_bezier_stuff(outdoor_grid_band_1, outdoor_grid_band_2, outdoor_grid_band_3); | |
2053 { | |
2543 | 2054 pODMRenderParams->outdoor_grid_band_3 = 25;//outdoor_grid_band_3; |
2055 pODMRenderParams->uPickDepth = 25 * 512;//outdoor_grid_band_3 * 512; | |
2541 | 2056 } |
2057 } | |
2058 else | |
2059 LOBYTE(viewparams->field_20) = 0; | |
2543 | 2060 |
2541 | 2061 pParty->uFlags |= 2; |
2062 viewparams->uSomeY = viewparams->uScreen_topL_Y; | |
2063 viewparams->uSomeX = viewparams->uScreen_topL_X; | |
2064 viewparams->uSomeZ = viewparams->uScreen_BttmR_X; | |
2065 viewparams->uSomeW = viewparams->uScreen_BttmR_Y; | |
2066 | |
2067 pViewport->SetScreen(viewparams->uScreen_topL_X, viewparams->uScreen_topL_Y, viewparams->uScreen_BttmR_X, viewparams->uScreen_BttmR_Y); | |
2068 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
2069 pODMRenderParams->Initialize(); | |
2070 } | |
2071 | |
2072 //----- (004610AA) -------------------------------------------------------- | |
2073 void __fastcall PrepareToLoadODM(unsigned int bLoading, ODMRenderParams *a2) | |
2074 { | |
2075 pGameLoadingUI_ProgressBar->Reset(27); | |
2076 pSoundList->_4A9D79(0); | |
2077 uCurrentlyLoadedLevelType = LEVEL_Outdoor; | |
2078 ODM_LoadAndInitialize(pCurrentMapName, a2); | |
2079 if (!bLoading) | |
2080 TeleportToStartingPoint(uLevel_StartingPointType); | |
2081 viewparams->_443365(); | |
2082 PlayLevelMusic(); | |
2083 } | |
2543 | 2084 |
2541 | 2085 |
2086 //----- (00464479) -------------------------------------------------------- | |
2087 void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows() | |
2088 { | |
2089 if (pMouse) | |
2090 pMouse->SetCursorBitmap("MICON1"); | |
2091 | |
2092 pPaletteManager->ResetNonLocked(); | |
2093 pBitmaps_LOD->ReleaseAll2(); | |
2094 pSprites_LOD->DeleteSomeOtherSprites(); | |
2095 pIcons_LOD->ReleaseAll2(); | |
2096 | |
2097 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
2098 pIndoor->Release(); | |
2099 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
2100 pOutdoor->Release(); | |
2101 | |
2102 pAudioPlayer->StopChannels(-1, -1); | |
2103 pSoundList->_4A9D79(0); | |
2104 uCurrentlyLoadedLevelType = LEVEL_null; | |
2105 pSpriteFrameTable->ResetSomeSpriteFlags(); | |
2106 pParty->armageddon_timer = 0; | |
2555
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2554
diff
changeset
|
2107 |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2554
diff
changeset
|
2108 while (uNumVisibleWindows > 0) |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2543
diff
changeset
|
2109 { |
2555
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2554
diff
changeset
|
2110 pWindowList[pVisibleWindowsIdxs[uNumVisibleWindows] - 1]->Release(); |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2554
diff
changeset
|
2111 delete pWindowList[pVisibleWindowsIdxs[uNumVisibleWindows] - 1]; |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2554
diff
changeset
|
2112 pWindowList[pVisibleWindowsIdxs[uNumVisibleWindows] - 1] = nullptr; |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2554
diff
changeset
|
2113 |
67d837007a4c
ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows & d3d deinit crashes fixed
a.parshin
parents:
2554
diff
changeset
|
2114 uNumVisibleWindows--; |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2543
diff
changeset
|
2115 } |
2541 | 2116 } |
2117 | |
2118 //----- (00461103) -------------------------------------------------------- | |
2119 void _461103_load_level_sub() | |
2120 { | |
2121 int v4; // edx@8 | |
2122 signed int v6; // esi@14 | |
2123 signed int v8; // ecx@16 | |
2124 int v12; // esi@25 | |
2125 int v13; // eax@26 | |
2126 __int16 v14; // ax@41 | |
2127 signed int v17; // [sp+14h] [bp-48h]@3 | |
2128 signed int v18; // [sp+14h] [bp-48h]@23 | |
2129 int v19; // [sp+18h] [bp-44h]@1 | |
2130 signed int v20; // [sp+18h] [bp-44h]@14 | |
2131 int v21[16]; // [sp+1Ch] [bp-40h]@17 | |
2132 | |
2562
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2555
diff
changeset
|
2133 if(no_actors) |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2555
diff
changeset
|
2134 uNumActors = 0; |
b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
Ritor1
parents:
2555
diff
changeset
|
2135 |
2541 | 2136 GenerateItemsInChest(); |
2137 pGameLoadingUI_ProgressBar->Progress(); | |
2138 pParty->uFlags |= 2; | |
2139 pParty->field_7B5_in_arena_quest = 0; | |
2140 dword_5C6DF8 = 1; | |
2141 pNPCStats->uNewlNPCBufPos = 0; | |
2142 v19 = pMapStats->GetMapInfo(pCurrentMapName); | |
2143 | |
2144 //v15 = 0; | |
2145 for (uint i = 0; i < uNumActors; ++i) | |
2146 //if ( (signed int)uNumActors > 0 ) | |
2147 { | |
2148 //Actor* pActor = &pActors[i]; | |
2149 //v2 = (char *)&pActors[0].uNPC_ID; | |
2150 //do | |
2151 //{ | |
2152 //v3 = pActors[i].pMonsterInfo.uID; | |
2153 v17 = 0; | |
2154 if (pActors[i].pMonsterInfo.uID >= 115 && pActors[i].pMonsterInfo.uID <= 186 | |
2155 || pActors[i].pMonsterInfo.uID >= 232 && pActors[i].pMonsterInfo.uID <= 249) | |
2156 v17 = 1; | |
2157 //v1 = 0; | |
2158 v4 = (pActors[i].pMonsterInfo.uID - 1) % 3; | |
2159 if (2 == v4) | |
2160 { | |
2161 if (pActors[i].sNPC_ID && pActors[i].sNPC_ID < 5000) | |
2162 continue; | |
2163 } | |
2164 else | |
2165 { | |
2166 if (v4 != 1) | |
2167 { | |
2168 if (v4 == 0 && pActors[i].sNPC_ID == 0) | |
2169 pActors[i].sNPC_ID = 0; | |
2170 continue; | |
2171 } | |
2172 } | |
2173 if (pActors[i].sNPC_ID > 0 && pActors[i].sNPC_ID < 5000) | |
2174 continue; | |
2175 if (v17) | |
2176 { | |
2177 pNPCStats->InitializeAdditionalNPCs(&pNPCStats->pAdditionalNPC[pNPCStats->uNewlNPCBufPos], pActors[i].pMonsterInfo.uID, 0, v19); | |
2178 v14 = LOWORD(pNPCStats->uNewlNPCBufPos) + 5000; | |
2179 ++pNPCStats->uNewlNPCBufPos; | |
2180 pActors[i].sNPC_ID = v14; | |
2181 continue; | |
2182 } | |
2183 pActors[i].sNPC_ID = 0; | |
2184 //++v15; | |
2185 //v2 += 836; | |
2186 //} | |
2187 //while ( v15 < (signed int)uNumActors ); | |
2188 } | |
2189 | |
2190 pGameLoadingUI_ProgressBar->Progress(); | |
2191 | |
2192 //v5 = uNumActors; | |
2193 v6 = 0; | |
2194 v20 = 0; | |
2195 //v16 = v1; | |
2196 | |
2197 for (uint i = 0; i < uNumActors; ++i) | |
2198 { | |
2199 //v7 = (char *)&pActors[0].pMonsterInfo; | |
2200 //do | |
2201 //{ | |
2202 for (v8 = 0; v8 < v6; ++v8) | |
2203 { | |
2204 if (v21[v8] == pActors[i].pMonsterInfo.uID - 1) | |
2205 break; | |
2206 } | |
2207 | |
2208 if (v8 == v6) | |
2209 { | |
2210 v21[v6++] = pActors[i].pMonsterInfo.uID - 1; | |
2211 v20 = v6; | |
2212 if (v6 == 16) | |
2213 break; | |
2214 } | |
2215 //++v16; | |
2216 //v7 += 836; | |
2217 //} | |
2218 //while ( v16 < (signed int)v5 ); | |
2219 } | |
2220 | |
2221 pGameLoadingUI_ProgressBar->Progress(); | |
2222 | |
2223 for (int _v0 = 0; _v0 < v6; ++_v0) | |
2224 { | |
2225 for (v18 = 4; v18; --v18) | |
2226 pSoundList->LoadSound(pMonsterList->pMonsters[v21[_v0]].pSoundSampleIDs[4 - v18], 0); | |
2227 v12 = 0; | |
2228 do | |
2229 v13 = pSoundList->LoadSound(v12++ + word_4EE088_sound_ids[pMonsterStats->pInfos[v21[_v0] + 1].uSpell1ID], 1); | |
2230 while (v13); | |
2231 } | |
2232 //v0 = pGameLoadingUI_ProgressBar; | |
2233 //v1 = 0; | |
2234 | |
2235 pGameLoadingUI_ProgressBar->Progress(); | |
2236 | |
2237 if (dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_ACTORS) | |
2238 uNumActors = 0; | |
2239 if (dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_DECORATIONS) | |
2240 uNumLevelDecorations = 0; | |
2241 init_event_triggers(); | |
2242 | |
2243 pGameLoadingUI_ProgressBar->Progress(); | |
2244 | |
2543 | 2245 pIndoorCameraD3D->vPartyPos.x = 0; |
2246 pIndoorCameraD3D->vPartyPos.y = 0; | |
2247 pIndoorCameraD3D->vPartyPos.z = 100; | |
2248 pIndoorCameraD3D->sRotationX = 0; | |
2249 pIndoorCameraD3D->sRotationY = 0; | |
2541 | 2250 viewparams->bRedrawGameUI = true; |
2251 uLevel_StartingPointType = MapStartPoint_Party; | |
2252 pSprites_LOD->_461397(); | |
2253 pPaletteManager->LockTestAll(); | |
2254 if (pParty->pPickedItem.uItemID != 0) | |
2255 pMouse->SetCursorBitmapFromItemID(pParty->pPickedItem.uItemID); | |
2256 } | |
2257 | |
2258 //----- (0042F3D6) -------------------------------------------------------- | |
2259 void InitializeTurnBasedAnimations(void *_this) | |
2260 { | |
2261 for (unsigned int i = 0; i < pIconIDs_Turn.size(); ++i) | |
2262 { | |
2263 char icon_name[32]; | |
2264 sprintf(icon_name, "turn%u", i); | |
2265 pIconIDs_Turn[i] = pIconsFrameTable->FindIcon(icon_name); | |
2266 pIconsFrameTable->InitializeAnimation(pIconIDs_Turn[i]); | |
2267 } | |
2268 | |
2269 uIconID_TurnStop = pIconsFrameTable->FindIcon("turnstop"); | |
2270 uIconID_TurnHour = pIconsFrameTable->FindIcon("turnhour"); | |
2271 uIconID_TurnStart = pIconsFrameTable->FindIcon("turnstart"); | |
2272 uIconID_CharacterFrame = pIconsFrameTable->FindIcon("aframe1"); | |
2273 uSpriteID_Spell11 = pSpriteFrameTable->FastFindSprite("spell11"); | |
2274 | |
2275 pIconsFrameTable->InitializeAnimation(uIconID_TurnHour); | |
2276 pIconsFrameTable->InitializeAnimation(uIconID_TurnStop); | |
2277 pIconsFrameTable->InitializeAnimation(uIconID_TurnStart); | |
2278 pIconsFrameTable->InitializeAnimation(uIconID_CharacterFrame); | |
2279 } | |
2280 | |
2281 //----- (0046BDA8) -------------------------------------------------------- | |
2282 unsigned int GetGravityStrength() | |
2283 { | |
2284 int v0; // eax@1 | |
2285 | |
2286 v0 = ~LOBYTE(pEngine->uFlags2) & 8; | |
2287 LOBYTE(v0) = v0 | 2; | |
2288 return (unsigned int)v0 >> 1; | |
2289 } | |
2290 | |
2291 //----- (00448B45) -------------------------------------------------------- | |
2292 void GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide) | |
2293 { | |
2294 if (bForceHide || GameUI_Footer_TimeLeft && GetTickCount() >= GameUI_Footer_TimeLeft) | |
2295 GameUI_Footer_TimeLeft = 0; | |
2296 } | |
2297 | |
2298 //----- (0044861E) -------------------------------------------------------- | |
2299 void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename) | |
2300 { | |
2301 unsigned int texture; // eax@2 | |
2302 | |
2303 if (uFaceCog) | |
2304 { | |
2305 texture = pBitmaps_LOD->LoadTexture(pFilename); | |
2306 if (texture != -1 ? (int)&pBitmaps_LOD->pTextures[texture] : 0) | |
2307 { | |
2308 pBitmaps_LOD->pTextures[texture].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[texture].palette_id1); | |
2309 | |
2310 if (uCurrentlyLoadedLevelType == 1) | |
2311 { | |
2312 if ((signed int)pIndoor->uNumFaceExtras > 1) | |
2313 { | |
2314 for (uint i = 1; i < (signed int)pIndoor->uNumFaceExtras; ++i) | |
2315 { | |
2316 if (pIndoor->pFaceExtras[i].sCogNumber == uFaceCog) | |
2317 { | |
2318 if (pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes & FACE_TEXTURE_FRAME) | |
2319 { | |
2320 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = pTextureFrameTable->FindTextureByName(pFilename); | |
2321 if (pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID) | |
2322 { | |
2323 pTextureFrameTable->LoadAnimationSequenceAndPalettes(pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID); | |
2324 } | |
2325 else | |
2326 { | |
2327 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = texture; | |
2328 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes &= 0xFFFFBFFF; | |
2329 } | |
2330 } | |
2331 else | |
2332 { | |
2333 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = texture; | |
2334 } | |
2335 } | |
2336 } | |
2337 } | |
2338 pParty->uFlags |= 2; | |
2339 } | |
2340 else | |
2341 { | |
2342 for (uint j = 0; j < (unsigned int)pOutdoor->uNumBModels; ++j) | |
2343 { | |
2344 for (uint i = 0; i < pOutdoor->pBModels[j].uNumFaces; ++i) | |
2345 { | |
2346 if (pOutdoor->pBModels[j].pFaces[i].sCogNumber == uFaceCog) | |
2347 { | |
2348 if (pOutdoor->pBModels[j].pFaces[i].uAttributes & FACE_TEXTURE_FRAME) | |
2349 { | |
2350 pOutdoor->pBModels[j].pFaces[i].uTextureID = pTextureFrameTable->FindTextureByName(pFilename); | |
2351 if (pOutdoor->pBModels[j].pFaces[i].uTextureID) | |
2352 pTextureFrameTable->LoadAnimationSequenceAndPalettes(pOutdoor->pBModels[j].pFaces[i].uTextureID); | |
2353 else | |
2354 { | |
2355 pOutdoor->pBModels[j].pFaces[i].uTextureID = texture; | |
2356 pOutdoor->pBModels[j].pFaces[i].uAttributes &= 0xFFFFBFFF; | |
2357 } | |
2358 } | |
2359 else | |
2360 pOutdoor->pBModels[j].pFaces[i].uTextureID = texture; | |
2361 } | |
2362 } | |
2363 } | |
2364 } | |
2365 pParty->uFlags |= 2; | |
2366 } | |
2367 } | |
2368 } | |
2369 | |
2370 //----- (0044892E) -------------------------------------------------------- | |
2371 void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on) | |
2372 { | |
2373 if (sCogNumber) | |
2374 { | |
2375 if (uCurrentlyLoadedLevelType == 1) | |
2376 { | |
2377 for (uint i = 1; i < (unsigned int)pIndoor->uNumFaceExtras; ++i) | |
2378 { | |
2379 if (pIndoor->pFaceExtras[i].sCogNumber == sCogNumber) | |
2380 { | |
2381 if (on) | |
2382 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes |= bit; | |
2383 else | |
2384 pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes &= ~bit; | |
2385 } | |
2386 } | |
2387 pParty->uFlags |= 2; | |
2388 } | |
2389 else | |
2390 { | |
2391 for (uint j = 0; j < (unsigned int)pOutdoor->uNumBModels; ++j) | |
2392 { | |
2393 for (uint i = 0; i < (unsigned int)pOutdoor->pBModels[j].uNumFaces; ++i) | |
2394 { | |
2395 if (pOutdoor->pBModels[j].pFaces[i].sCogNumber == sCogNumber) | |
2396 { | |
2397 if (on) | |
2398 pOutdoor->pBModels[j].pFaces[i].uAttributes |= bit; | |
2399 else | |
2400 pOutdoor->pBModels[j].pFaces[i].uAttributes &= ~bit; | |
2401 } | |
2402 } | |
2403 } | |
2404 } | |
2405 pParty->uFlags |= 2; | |
2406 } | |
2407 } | |
2408 | |
2409 //----- (0044882F) -------------------------------------------------------- | |
2410 void __fastcall SetDecorationSprite(uint16_t uCog, bool bHide, const char *pFileName) | |
2411 { | |
2412 for (size_t i = 0; i < uNumLevelDecorations; i++) | |
2413 { | |
2414 if (pLevelDecorations[i].uCog == uCog) | |
2415 { | |
2416 if (pFileName && strcmp(pFileName, "0")) | |
2417 { | |
2418 pLevelDecorations[i].uDecorationDescID = pDecorationList->GetDecorIdByName(pFileName); | |
2419 pDecorationList->InitializeDecorationSprite(pLevelDecorations[i].uDecorationDescID); | |
2420 } | |
2421 | |
2422 if (bHide) | |
2423 pLevelDecorations[i].uFlags &= ~LEVEL_DECORATION_INVISIBLE; | |
2424 else | |
2425 pLevelDecorations[i].uFlags |= LEVEL_DECORATION_INVISIBLE; | |
2426 | |
2427 pParty->uFlags |= 2; | |
2428 } | |
2429 } | |
2430 } | |
2431 | |
2432 //----- (004356FF) -------------------------------------------------------- | |
2433 void back_to_game() | |
2434 { | |
2435 dword_507BF0_is_there_popup_onscreen = 0; | |
2436 dword_4E455C = 1; | |
2437 | |
2438 extern int no_rightlick_in_inventory; | |
2439 no_rightlick_in_inventory = false; | |
2440 | |
2441 if (pGUIWindow_ScrollWindow) | |
2442 free_book_subwindow(); | |
2554 | 2443 if (!current_screen_type && !pGUIWindow_CastTargetedSpell) |
2541 | 2444 pEventTimer->Resume(); |
2445 viewparams->bRedrawGameUI = 1; | |
2446 } | |
2447 | |
2448 //----- (00494035) -------------------------------------------------------- | |
2449 void _494035_timed_effects__water_walking_damage__etc() | |
2450 { | |
2451 signed __int64 v0; // qax@1 | |
2452 unsigned int v4; // edi@1 | |
2453 // signed int v12; // edi@29 | |
2454 int v24; // ecx@60 | |
2455 int v26; // ecx@64 | |
2456 int v28; // ecx@68 | |
2457 int v30; // ecx@72 | |
2458 int v32; // ecx@76 | |
2459 int v34; // ecx@80 | |
2460 int v36; // ecx@84 | |
2461 int v38; // ecx@88 | |
2462 int v40; // ecx@92 | |
2463 int v42; // ecx@96 | |
2464 bool v43; // ebx@102 | |
2465 bool v46; // edi@111 | |
2466 // unsigned int v56; // [sp-8h] [bp-38h]@55 | |
2467 // int v59; // [sp-4h] [bp-34h]@55 | |
2468 // unsigned int v61; // [sp+14h] [bp-1Ch]@1 | |
2469 signed int a2a; // [sp+18h] [bp-18h]@47 | |
2470 signed int old_day; // [sp+1Ch] [bp-14h]@47 | |
2471 signed int old_hour; | |
2472 | |
2473 old_day = pParty->uDaysPlayed; | |
2474 old_hour = pParty->uCurrentHour; | |
2475 //auto prev_time = pEventTimer->uTimeElapsed; | |
2476 pParty->uTimePlayed += pEventTimer->uTimeElapsed; | |
2477 v0 = ((signed __int64)(pParty->uTimePlayed * 0.234375) / 60) / 60i64; | |
2478 v4 = (unsigned int)(((unsigned int)v0 / 24) / 7) >> 2; | |
2479 pParty->uCurrentTimeSecond = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) % 60; | |
2480 pParty->uCurrentMinute = ((signed __int64)(pParty->uTimePlayed * 0.234375) / 60) % 60; | |
2481 pParty->uCurrentHour = v0 % 24; | |
2482 pParty->uCurrentMonthWeek = ((unsigned int)v0 / 24) / 7 & 3; | |
2483 pParty->uDaysPlayed = (unsigned int)((unsigned int)v0 / 24) % 28; | |
2484 pParty->uCurrentMonth = v4 % 12; | |
2485 pParty->uCurrentYear = v4 / 0xC + game_starting_year; | |
2486 if (pParty->uCurrentHour >= 3 && (old_hour < 3 || pParty->uDaysPlayed > old_day)) // new day dawns | |
2487 { | |
2488 pParty->pHirelings[0].bHasUsedTheAbility = false; | |
2489 pParty->pHirelings[1].bHasUsedTheAbility = false; | |
2490 | |
2491 for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i) | |
2492 pNPCStats->pNewNPCData[i].bHasUsedTheAbility = false; | |
2493 | |
2494 ++pParty->days_played_without_rest; | |
2495 if (pParty->days_played_without_rest > 1) | |
2496 { | |
2497 for (uint i = 0; i < 4; ++i) | |
2498 pParty->pPlayers[i].SetCondWeakWithBlockCheck(0); | |
2499 | |
2500 if (pParty->uNumFoodRations) | |
2501 Party::TakeFood(1); | |
2502 else | |
2503 for (uint i = 0; i < 4; ++i) | |
2504 pParty->pPlayers[i].sHealth = pParty->pPlayers[i].sHealth / (pParty->days_played_without_rest + 1) + 1; | |
2505 | |
2506 if (pParty->days_played_without_rest > 3) | |
2507 for (uint i = 0; i < 4; ++i) | |
2508 { | |
2509 pParty->pPlayers[i].Zero(); | |
2510 if (!pParty->pPlayers[i].IsPertified() && !pParty->pPlayers[i].IsEradicated() | |
2511 && !pParty->pPlayers[i].IsDead()) | |
2512 { | |
2513 if (rand() % 100 < 5 * pParty->days_played_without_rest) | |
2514 pParty->pPlayers[i].SetCondDeadWithBlockCheck(0); | |
2515 if (rand() % 100 < 10 * pParty->days_played_without_rest) | |
2516 pParty->pPlayers[i].SetCondInsaneWithBlockCheck(0); | |
2517 } | |
2518 } | |
2519 } | |
2520 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
2521 pOutdoor->SetFog(); | |
2522 | |
2523 for (uint i = 0; i < 4; ++i) | |
2524 pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0; | |
2525 } | |
2526 | |
2527 if (pParty->uFlags & 4 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed)//water damage | |
2528 { | |
2529 pParty->field_6FC = (signed __int64)pParty->uTimePlayed + 128; | |
2530 viewparams->bRedrawGameUI = true; | |
2531 for (uint pl = 1; pl <= 4; ++pl) | |
2532 { | |
2533 if (pPlayers[pl]->WearsItem(ITEM_RELIC_HARECS_LEATHER, EQUIP_ARMOUR) | |
2534 || pPlayers[pl]->HasEnchantedItemEquipped(71) | |
2535 || pPlayers[pl]->pPlayerBuffs[PLAYER_BUFF_WATER_WALK].uExpireTime > 0) | |
2536 pPlayers[pl]->PlayEmotion(CHARACTER_EXPRESSION_37, 0); | |
2537 else | |
2538 { | |
2539 if (!pPlayers[pl]->HasUnderwaterSuitEquipped()) | |
2540 { | |
2541 pPlayers[pl]->ReceiveDamage((signed __int64)pPlayers[pl]->GetMaxHealth() * 0.1, DMGT_FIRE); | |
2542 if (pParty->uFlags & 4) | |
2543 { | |
2544 strcpy(GameUI_Footer_TimedString.data(), pGlobalTXT_LocalizationStrings[660]);// Âû òîíåòå! | |
2545 GameUI_Footer_TimeLeft = 128; | |
2546 } | |
2547 } | |
2548 else | |
2549 pPlayers[pl]->PlayEmotion(CHARACTER_EXPRESSION_37, 0); | |
2550 } | |
2551 } | |
2552 } | |
2553 if (pParty->uFlags & 0x200 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed) //lava damage | |
2554 { | |
2555 viewparams->bRedrawGameUI = true; | |
2556 pParty->field_6FC = (signed __int64)pParty->uTimePlayed + 128; | |
2557 | |
2558 for (uint pl = 1; pl <= 4; pl++) | |
2559 { | |
2560 pPlayers[pl]->ReceiveDamage((signed __int64)pPlayers[pl]->GetMaxHealth() * 0.1, DMGT_FIRE); | |
2561 if (pParty->uFlags & 0x200) | |
2562 { | |
2563 strcpy(GameUI_Footer_TimedString.data(), pGlobalTXT_LocalizationStrings[661]); //Âû ãîðèòå! | |
2564 GameUI_Footer_TimeLeft = 128; | |
2565 } | |
2566 } | |
2567 } | |
2568 _493938_regenerate(); | |
2569 uint party_condition_flag = 4; | |
2570 a2a = pEventTimer->uTimeElapsed; | |
2571 if (pParty->uFlags2 & PARTY_FLAGS_2_RUNNING)//çàìåäëåíèå âîññòàíîâëåíèÿ ïðè áåãå | |
2572 { | |
2573 a2a *= 0.5f; | |
2574 if (a2a < 1) | |
2575 a2a = 1; | |
2576 } | |
2577 | |
2578 for (uint pl = 1; pl <= 4; pl++) | |
2579 { | |
2580 if (pPlayers[pl]->uTimeToRecovery) | |
2581 pPlayers[pl]->Recover(a2a);//âîññòàíîâëåíèå àêòèâíîñòè | |
2582 if (pPlayers[pl]->GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE) + pPlayers[pl]->sHealth + pPlayers[pl]->uEndurance >= 1 | |
2583 || (signed __int64)pPlayers[pl]->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0) | |
2584 { | |
2585 if (pPlayers[pl]->sHealth < 1) | |
2586 pPlayers[pl]->SetCondition(Condition_Unconcious, 0); | |
2587 } | |
2588 else | |
2589 pPlayers[pl]->SetCondition(Condition_Dead, 0); | |
2590 if (pPlayers[pl]->field_E0) | |
2591 { | |
2592 v24 = pPlayers[pl]->field_E0 - pEventTimer->uTimeElapsed; | |
2593 if (v24 > 0) | |
2594 pPlayers[pl]->field_E0 = v24; | |
2595 else | |
2596 { | |
2597 pPlayers[pl]->field_E0 = 0; | |
2598 viewparams->bRedrawGameUI = true; | |
2599 } | |
2600 } | |
2601 if (pPlayers[pl]->field_E4) | |
2602 { | |
2603 v26 = pPlayers[pl]->field_E4 - pEventTimer->uTimeElapsed; | |
2604 if (v26 > 0) | |
2605 pPlayers[pl]->field_E4 = v26; | |
2606 else | |
2607 { | |
2608 pPlayers[pl]->field_E4 = 0; | |
2609 viewparams->bRedrawGameUI = true; | |
2610 } | |
2611 } | |
2612 if (pPlayers[pl]->field_E8) | |
2613 { | |
2614 v28 = pPlayers[pl]->field_E8 - pEventTimer->uTimeElapsed; | |
2615 if (v28 > 0) | |
2616 pPlayers[pl]->field_E8 = v28; | |
2617 else | |
2618 { | |
2619 pPlayers[pl]->field_E8 = 0; | |
2620 viewparams->bRedrawGameUI = true; | |
2621 } | |
2622 } | |
2623 if (pPlayers[pl]->field_EC) | |
2624 { | |
2625 v30 = pPlayers[pl]->field_EC - pEventTimer->uTimeElapsed; | |
2626 if (v30 > 0) | |
2627 pPlayers[pl]->field_EC = v30; | |
2628 else | |
2629 { | |
2630 pPlayers[pl]->field_EC = 0; | |
2631 viewparams->bRedrawGameUI = true; | |
2632 } | |
2633 } | |
2634 if (pPlayers[pl]->field_F0) | |
2635 { | |
2636 v32 = pPlayers[pl]->field_F0 - pEventTimer->uTimeElapsed; | |
2637 if (v32 > 0) | |
2638 pPlayers[pl]->field_F0 = v32; | |
2639 else | |
2640 { | |
2641 pPlayers[pl]->field_F0 = 0; | |
2642 viewparams->bRedrawGameUI = true; | |
2643 } | |
2644 } | |
2645 if (pPlayers[pl]->field_F4) | |
2646 { | |
2647 v34 = pPlayers[pl]->field_F4 - pEventTimer->uTimeElapsed; | |
2648 if (v34 > 0) | |
2649 pPlayers[pl]->field_F4 = v34; | |
2650 else | |
2651 { | |
2652 pPlayers[pl]->field_F4 = 0; | |
2653 viewparams->bRedrawGameUI = true; | |
2654 } | |
2655 } | |
2656 if (pPlayers[pl]->field_F8) | |
2657 { | |
2658 v36 = pPlayers[pl]->field_F8 - pEventTimer->uTimeElapsed; | |
2659 if (v36 > 0) | |
2660 pPlayers[pl]->field_F8 = v36; | |
2661 else | |
2662 { | |
2663 pPlayers[pl]->field_F8 = 0; | |
2664 viewparams->bRedrawGameUI = true; | |
2665 } | |
2666 } | |
2667 if (pPlayers[pl]->field_FC) | |
2668 { | |
2669 v38 = pPlayers[pl]->field_FC - pEventTimer->uTimeElapsed; | |
2670 if (v38 > 0) | |
2671 pPlayers[pl]->field_FC = v38; | |
2672 else | |
2673 { | |
2674 pPlayers[pl]->field_FC = 0; | |
2675 viewparams->bRedrawGameUI = true; | |
2676 } | |
2677 } | |
2678 if (pPlayers[pl]->field_100) | |
2679 { | |
2680 v40 = pPlayers[pl]->field_100 - pEventTimer->uTimeElapsed; | |
2681 if (v40 > 0) | |
2682 pPlayers[pl]->field_100 = v40; | |
2683 else | |
2684 { | |
2685 pPlayers[pl]->field_100 = 0; | |
2686 viewparams->bRedrawGameUI = true; | |
2687 } | |
2688 } | |
2689 if (pPlayers[pl]->field_104) | |
2690 { | |
2691 v42 = pPlayers[pl]->field_104 - pEventTimer->uTimeElapsed; | |
2692 if (v42 > 0) | |
2693 pPlayers[pl]->field_104 = v42; | |
2694 else | |
2695 { | |
2696 pPlayers[pl]->field_104 = 0; | |
2697 viewparams->bRedrawGameUI = true; | |
2698 } | |
2699 } | |
2700 if (pPlayers[pl]->pConditions[Condition_Sleep] | pPlayers[pl]->pConditions[Condition_Paralyzed] | |
2701 | pPlayers[pl]->pConditions[Condition_Unconcious] | pPlayers[pl]->pConditions[Condition_Dead] | |
2702 | pPlayers[pl]->pConditions[Condition_Pertified] | pPlayers[pl]->pConditions[Condition_Eradicated]) | |
2703 --party_condition_flag; | |
2704 v43 = (signed __int64)pPlayers[pl]->pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime > 0; //ñïåøêà | |
2705 | |
2706 for (uint k = 0; k < 24; ++k) | |
2707 pPlayers[pl]->pPlayerBuffs[k].IsBuffExpiredToTime(pParty->uTimePlayed); | |
2708 | |
2709 if (v43 && (signed __int64)pPlayers[pl]->pPlayerBuffs[7].uExpireTime <= 0) | |
2710 pPlayers[pl]->SetCondition(Condition_Weak, 0); | |
2711 } | |
2712 | |
2713 v46 = (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_HASTE].uExpireTime > 0; | |
2714 | |
2715 for (uint i = 0; i < 20; ++i) | |
2716 { | |
2717 if (pParty->pPartyBuffs[i].IsBuffExpiredToTime(pParty->uTimePlayed) == 1) | |
2718 viewparams->bRedrawGameUI = true; | |
2719 } | |
2720 | |
2721 if (v46 && (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_HASTE].uExpireTime <= 0) | |
2722 { | |
2723 for (uint i = 0; i < 4; ++i) | |
2724 pParty->pPlayers[i].SetCondition(1, 0); | |
2725 } | |
2726 | |
2727 for (uint i = 0; i < 2; ++i)//Ïðîâåðêà â ñîçíàíèè ëè ïåðñ ñäåëàâøèé çàêë íà ïîë¸ò è õîæäåíèå ïî âîäå | |
2728 { | |
2729 SpellBuff* pBuf = &pParty->pPartyBuffs[Party_Spec_Motion_status_ids[i]]; | |
2730 if (pBuf->uExpireTime == 0) | |
2731 continue; | |
2732 | |
2733 if (!(pBuf->uFlags & 1)) | |
2734 { | |
2735 if (!pPlayers[pBuf->uCaster]->CanAct()) | |
2736 { | |
2737 pBuf->Reset(); | |
2738 if (Party_Spec_Motion_status_ids[i] == PARTY_BUFF_FLY) | |
2739 pParty->bFlying = false; | |
2740 } | |
2741 } | |
2742 } | |
2743 | |
2744 if (!party_condition_flag) | |
2745 { | |
2746 if (current_screen_type != SCREEN_REST) | |
2747 { | |
2748 for (uint pl = 1; pl <= 4; pl++) | |
2749 { | |
2750 if (pPlayers[pl]->pConditions[Condition_Sleep]) | |
2751 { | |
2752 pPlayers[pl]->pConditions[Condition_Sleep] = 0; | |
2753 party_condition_flag = 1; | |
2754 break; | |
2755 } | |
2756 } | |
2757 if (!party_condition_flag || _5C35C0_force_party_death) | |
2758 uGameState = GAME_STATE_PARTY_DIED; | |
2759 } | |
2760 } | |
2761 | |
2762 if (uActiveCharacter)//âûáîð ñëåäóþùåãî ïîñëå ïðîïóñêàþùåãî õîä | |
2763 { | |
2764 if (current_screen_type != SCREEN_REST) | |
2765 { | |
2766 if (pPlayers[uActiveCharacter]->pConditions[Condition_Sleep] | |
2767 || pPlayers[uActiveCharacter]->pConditions[Condition_Paralyzed] | |
2768 || pPlayers[uActiveCharacter]->pConditions[Condition_Unconcious] | |
2769 || pPlayers[uActiveCharacter]->pConditions[Condition_Dead] | |
2770 || pPlayers[uActiveCharacter]->pConditions[Condition_Pertified] | |
2771 || pPlayers[uActiveCharacter]->pConditions[Condition_Eradicated]) | |
2772 { | |
2773 viewparams->bRedrawGameUI = true; | |
2774 uActiveCharacter = pParty->GetNextActiveCharacter(); | |
2775 } | |
2776 } | |
2777 } | |
2778 } | |
2779 | |
2780 //----- (00493938) -------------------------------------------------------- | |
2781 void _493938_regenerate() | |
2782 { | |
2783 int current_time; // edi@1 | |
2784 int last_reg_time; // qax@1 | |
2785 int v4; // eax@2 | |
2786 int v5; // edi@5 | |
2787 long long *v6; // ecx@5 | |
2788 char v7; // sf@5 | |
2789 int *v8; // ecx@10 | |
2790 int v9; // edi@15 | |
2791 signed int v10; // eax@15 | |
2792 // __int16 *v11; // edx@16 | |
2793 // int v12; // eax@20 | |
2794 int numberOfActorsAffected; // ebx@20 | |
2795 unsigned int v14; // esi@21 | |
2796 //unsigned int v15; // ecx@21 | |
2797 //unsigned int v16; // eax@21 | |
2798 // int v18; // eax@21 | |
2799 signed int v19; // eax@21 | |
2800 bool recovery_HP; // ebx@25 | |
2801 // ITEM_EQUIP_TYPE v22; // edi@30 | |
2802 signed int v25; // eax@33 | |
2803 // int v26; // eax@35 | |
2804 // int v27; // eax@36 | |
2805 // int v28; // eax@37 | |
2806 signed int v31; // ecx@53 | |
2807 int actorsAffectedByImmolation[100]; // [sp+4h] [bp-22Ch]@20 | |
2808 SpriteObject a1; // [sp+194h] [bp-9Ch]@15 | |
2809 Vec3_int_ a3; // [sp+204h] [bp-2Ch]@15 | |
2810 bool has_dragon_flag; // [sp+210h] [bp-20h]@22 | |
2811 bool lich_jar_flag; // [sp+214h] [bp-1Ch]@25 | |
2812 bool zombie_flag; // [sp+218h] [bp-18h]@25 | |
2813 bool decrease_HP; // [sp+21Ch] [bp-14h]@25 | |
2814 bool lich_flag; // [sp+220h] [bp-10h]@25 | |
2815 int v49; // [sp+224h] [bp-Ch]@24 | |
2816 bool recovery_SP; // [sp+228h] [bp-8h]@25 | |
2817 bool redraw_flag; // [sp+22Ch] [bp-4h]@2 | |
2818 | |
2819 current_time = (signed int)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) / 60; | |
2820 last_reg_time = (signed int)(signed __int64)((double)pParty->uLastRegenerationTime * 0.234375) / 60; | |
2821 if (current_time >= (signed int)last_reg_time + 5) | |
2822 { | |
2823 redraw_flag = false; | |
2824 v4 = (current_time - last_reg_time) / 5; | |
2825 if (pParty->FlyActive()) | |
2826 { | |
2827 if (pParty->bFlying) | |
2828 { | |
2829 if (!(pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags & 1)) | |
2830 { | |
2831 v5 = v4 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uPower; | |
2832 //cursed_flag = pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].pConditions[Condition_Cursed];//cursed | |
2833 //v7 = cursed_flag < v5; | |
2834 //cursed_flag -= v5; | |
2835 | |
2836 v6 = &pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].pConditions[Condition_Cursed]; | |
2837 | |
2838 if (*v6 < v5) | |
2839 { | |
2840 v6 = 0; | |
2841 pParty->uFlags &= 0xFFFFFFBFu; | |
2842 pParty->bFlying = false; | |
2843 redraw_flag = true; | |
2844 } | |
2845 } | |
2846 } | |
2847 } | |
2848 | |
2849 if (pParty->WaterWalkActive()) | |
2850 { | |
2851 if (pParty->uFlags & PARTY_FLAGS_1_STANDING_ON_WATER) | |
2852 { | |
2853 if (!(pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags & 1)) | |
2854 { // taking on water | |
2855 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]; | |
2856 v7 = *v8 < v4; | |
2857 *v8 -= v4; | |
2858 if (v7) | |
2859 { | |
2860 *v8 = 0; | |
2861 pParty->uFlags &= ~PARTY_FLAGS_1_STANDING_ON_WATER; | |
2862 redraw_flag = true; | |
2863 } | |
2864 } | |
2865 } | |
2866 } | |
2867 | |
2868 if (pParty->ImmolationActive())//Æåðòâà | |
2869 { | |
2870 a3.z = 0; | |
2871 a3.y = 0; | |
2872 a3.x = 0; | |
2566 | 2873 a1.containing_item.Reset(); |
2541 | 2874 a1.spell_level = pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].uPower; |
2875 a1.spell_skill = pParty->ImmolationSkillLevel(); | |
2876 v10 = 0; | |
2566 | 2877 a1.uType = SPRITE_SPELL_FIRE_IMMOLATION; |
2541 | 2878 a1.spell_id = SPELL_FIRE_IMMOLATION; |
2879 v10 = 0; | |
2880 for (uint i = 0; i > pObjectList->uNumObjects; i++) | |
2881 { | |
2566 | 2882 if (pObjectList->pObjects[i].uObjectID == spell_sprite_mapping[8].uSpriteType) |
2541 | 2883 v10 = i; |
2884 } | |
2885 a1.uObjectDescID = v10; | |
2886 a1.field_60_distance_related_prolly_lod = 0; | |
2887 a1.uAttributes = 0; | |
2888 a1.uSectorID = 0; | |
2889 a1.uSpriteFrameID = 0; | |
2890 a1.spell_caster_pid = PID(OBJECT_Player, pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].uCaster); | |
2891 a1.uFacing = 0; | |
2892 a1.uSoundID = 0; | |
2893 numberOfActorsAffected = pParty->_46A89E_immolation_effect(actorsAffectedByImmolation, 100, 307); | |
2894 for (v9 = 0; v9 < numberOfActorsAffected; ++v9) | |
2895 { | |
2896 v14 = actorsAffectedByImmolation[v9]; | |
2897 a1.vPosition.x = pActors[v14].vPosition.x; | |
2898 a1.vPosition.y = pActors[v14].vPosition.y; | |
2899 a1.vPosition.z = pActors[v14].vPosition.z; | |
2900 a1.spell_target_pid = PID(OBJECT_Actor, v14); | |
2901 v19 = a1.Create(0, 0, 0, 0); | |
2902 Actor::DamageMonsterFromParty(PID(OBJECT_Item, v19), v14, &a3); | |
2903 } | |
2904 } | |
2905 | |
2906 has_dragon_flag = false; | |
2907 if (PartyHasDragon()) | |
2908 has_dragon_flag = true; | |
2909 | |
2910 for (v49 = 0; v49 < 4; v49++) | |
2911 { | |
2912 recovery_HP = false; | |
2913 recovery_SP = false; | |
2914 decrease_HP = false; | |
2915 lich_flag = false; | |
2916 lich_jar_flag = false; | |
2917 zombie_flag = false; | |
2918 | |
2919 for (int v22 = 0; (signed int)v22 < 16; v22++) | |
2920 { | |
2921 if (pParty->pPlayers[v49].HasItemEquipped((ITEM_EQUIP_TYPE)v22)) | |
2922 { | |
2923 uint _idx = pParty->pPlayers[v49].pEquipment.pIndices[v22]; | |
2924 if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID > 134) | |
2925 { | |
2926 if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_RELIC_ETHRICS_STAFF) | |
2927 decrease_HP = true; | |
2928 if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_ARTIFACT_HERMES_SANDALS) | |
2929 { | |
2930 recovery_HP = true; | |
2931 recovery_SP = true; | |
2932 } | |
2933 if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_ARTIFACT_MINDS_EYE) | |
2934 recovery_SP = true; | |
2935 if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_ARTIFACT_HEROS_BELT) | |
2936 recovery_HP = true; | |
2937 } | |
2938 else | |
2939 { | |
2567 | 2940 v25 = pParty->pPlayers[v49].pInventoryItemList[_idx - 1].special_enchantment; |
2541 | 2941 if (v25 == 37 //of Regeneration("Regenerate 1hp/x while walking, etc") |
2942 || v25 == 44 //of Life("HP (+10), Regen hpts") | |
2943 || v25 == 50 //of The Phoenix("Fire Res (+30), Regen hpts") && | |
2944 || v25 == 54)// of The Troll("End (+15), Regen hpts") | |
2945 recovery_HP = true; | |
2946 if (v25 == 38 //of Mana("Regenerate 1sp/x while walking, etc") | |
2947 || v25 == 47 //of The Eclipse("SP (+10), Regen spts") | |
2948 || v25 == 55)//of The Unicorn("Luck (+15), Regen spts") | |
2949 recovery_SP = true; | |
2950 if (v25 == 66)// of Plenty("Regenerate 1 hp/x and 1 sp/x while walking, etc.") | |
2951 { | |
2952 recovery_HP = true; | |
2953 recovery_SP = true; | |
2954 } | |
2955 } | |
2956 | |
2957 if (recovery_HP && | |
2958 !pParty->pPlayers[v49].pConditions[Condition_Dead] && | |
2959 !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) | |
2960 { | |
2961 if (pParty->pPlayers[v49].sHealth < pParty->pPlayers[v49].GetMaxHealth()) | |
2962 ++pParty->pPlayers[v49].sHealth; | |
2963 if (pParty->pPlayers[v49].pConditions[Condition_Unconcious] && pParty->pPlayers[v49].sHealth > 0) | |
2964 pParty->pPlayers[v49].pConditions[Condition_Unconcious] = 0; | |
2965 redraw_flag = true; | |
2966 } | |
2967 | |
2968 if (recovery_SP && | |
2969 !pParty->pPlayers[v49].pConditions[Condition_Dead] && | |
2970 !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) | |
2971 { | |
2972 if (pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana()) | |
2973 ++pParty->pPlayers[v49].sMana; | |
2974 redraw_flag = true; | |
2975 } | |
2976 | |
2977 if (decrease_HP && | |
2978 !pParty->pPlayers[v49].pConditions[Condition_Dead] && | |
2979 !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) | |
2980 { | |
2981 --pParty->pPlayers[v49].sHealth; | |
2982 if (!(pParty->pPlayers[v49].pConditions[Condition_Unconcious]) && pParty->pPlayers[v49].sHealth < 0) | |
2983 pParty->pPlayers[v49].pConditions[Condition_Unconcious] = pParty->uTimePlayed; | |
2984 if (pParty->pPlayers[v49].sHealth < 1) | |
2985 { | |
2986 if (pParty->pPlayers[v49].sHealth + pParty->pPlayers[v49].uEndurance + pParty->pPlayers[v49].GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE) >= 1 | |
2987 || (signed __int64)pParty->pPlayers[v49].pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0) | |
2988 pParty->pPlayers[v49].pConditions[Condition_Unconcious] = pParty->uTimePlayed; | |
2989 else | |
2990 { | |
2991 if (!pParty->pPlayers[v49].pConditions[Condition_Dead]) | |
2992 pParty->pPlayers[v49].pConditions[Condition_Dead] = pParty->uTimePlayed; | |
2993 } | |
2994 } | |
2995 redraw_flag = true; | |
2996 } | |
2997 } | |
2998 } | |
2999 | |
3000 //regeneration | |
3001 if (pParty->pPlayers[v49].pPlayerBuffs[PLAYER_BUFF_REGENERATION].uExpireTime > 0 | |
3002 && !pParty->pPlayers[v49].pConditions[Condition_Dead] | |
3003 && !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) | |
3004 { | |
3005 pParty->pPlayers[v49].sHealth += 5 * pParty->pPlayers[v49].pPlayerBuffs[PLAYER_BUFF_REGENERATION].uPower; | |
3006 if (pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth()) | |
3007 pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].GetMaxHealth(); | |
3008 if (pParty->pPlayers[v49].pConditions[Condition_Unconcious] && pParty->pPlayers[v49].sHealth > 0) | |
3009 pParty->pPlayers[v49].pConditions[Condition_Unconcious] = 0; | |
3010 redraw_flag = true; | |
3011 } | |
3012 | |
3013 //for warlock | |
3014 if (has_dragon_flag && pParty->pPlayers[v49].classType == PLAYER_CLASS_WARLOCK) | |
3015 { | |
3016 if (pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana()) | |
3017 ++pParty->pPlayers[v49].sMana; | |
3018 redraw_flag = true; | |
3019 } | |
3020 | |
3021 //for lich | |
3022 if (pParty->pPlayers[v49].classType == PLAYER_CLASS_LICH) | |
3023 { | |
3024 for (v31 = 0; v31 < 126; ++v31) | |
3025 { | |
3026 if (pParty->pPlayers[v49].pInventoryItemList[v31].uItemID == ITEM_LICH_JAR_FULL) | |
3027 lich_jar_flag = true; | |
3028 } | |
3029 lich_flag = true; | |
3030 } | |
3031 if (lich_flag && !pParty->pPlayers[v49].pConditions[Condition_Dead] | |
3032 && !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) | |
3033 { | |
3034 if (pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth() / 2) | |
3035 pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].sHealth - 2; | |
3036 if (pParty->pPlayers[v49].sMana > pParty->pPlayers[v49].GetMaxMana() / 2) | |
3037 pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].sMana - 2; | |
3038 } | |
3039 if (lich_jar_flag) | |
3040 { | |
3041 if (pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana()) | |
3042 ++pParty->pPlayers[v49].sMana; | |
3043 } | |
3044 | |
3045 //for zombie | |
3046 if (pParty->pPlayers[v49].pConditions[Condition_Zombie]) | |
3047 zombie_flag = true; | |
3048 if (zombie_flag && !pParty->pPlayers[v49].pConditions[Condition_Dead] | |
3049 && !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) | |
3050 { | |
3051 if (pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth() / 2) | |
3052 pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].sHealth - 1; | |
3053 if (pParty->pPlayers[v49].sMana > 0) | |
3054 pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].sMana - 1; | |
3055 } | |
3056 } | |
3057 pParty->uLastRegenerationTime = pParty->uTimePlayed; | |
3058 if (!viewparams->bRedrawGameUI) | |
3059 viewparams->bRedrawGameUI = redraw_flag; | |
3060 } | |
3061 } | |
3062 | |
3063 //----- (00491E3A) -------------------------------------------------------- | |
3064 void sub_491E3A() | |
3065 { | |
3066 signed int v1; // esi@3 | |
3067 unsigned int v3; // eax@7 | |
3068 unsigned int v4; // edx@8 | |
3069 int v6; // edi@17 | |
3070 | |
3071 //__debugbreak();//Ritor1 | |
3072 for (uint pl = 0; pl < 4; pl++) | |
3073 { | |
3074 if (SoundSetAction[24][0]) | |
3075 { | |
3076 v3 = 0; | |
3077 for (v1 = 0; v1 < (signed int)pSoundList->sNumSounds; ++v1) | |
3078 { | |
3079 int ps = 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[pl].uVoiceID) + 4998;//6728 | |
3080 if (pSoundList->pSL_Sounds[v1].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[pl].uVoiceID) + 4998) | |
3081 v3 = v1; | |
3082 } | |
3083 pSoundList->UnloadSound(v3, 1); | |
3084 for (v4 = 0; (signed int)v4 < (signed int)pSoundList->sNumSounds; ++v4) | |
3085 { | |
3086 if (pSoundList->pSL_Sounds[v4].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[pl].uVoiceID) + 4999) | |
3087 pSoundList->UnloadSound(v4, 1); | |
3088 } | |
3089 } | |
3090 } | |
3091 v6 = pIcons_LOD->uNumLoadedFiles - 1; | |
3092 if (v6 >= pIcons_LOD->pFacesLock) | |
3093 { | |
3094 do | |
3095 { | |
3096 pIcons_LOD->pTextures[v6].Release(); | |
3097 if (pIcons_LOD->pHardwareTextures) | |
3098 { | |
3099 if (pIcons_LOD->pHardwareTextures[v6]) | |
3100 { | |
3101 pIcons_LOD->pHardwareTextures[v6]->Release(); | |
3102 pIcons_LOD->pHardwareTextures[v6] = 0; | |
3103 } | |
3104 } | |
3105 if (pIcons_LOD->pHardwareSurfaces) | |
3106 { | |
3107 if (pIcons_LOD->pHardwareSurfaces[v6]) | |
3108 { | |
3109 pIcons_LOD->pHardwareSurfaces[v6]->Release(); | |
3110 pIcons_LOD->pHardwareSurfaces[v6] = 0; | |
3111 } | |
3112 } | |
3113 --v6; | |
3114 } while (v6 >= pIcons_LOD->pFacesLock); | |
3115 } | |
3116 pIcons_LOD->uNumLoadedFiles = pIcons_LOD->pFacesLock; | |
3117 pIcons_LOD->pFacesLock = 0; | |
3118 } | |
3119 | |
3120 //----- (00494820) -------------------------------------------------------- | |
3121 unsigned int __fastcall _494820_training_time(unsigned int a1) | |
3122 { | |
3123 signed int v1; // eax@1 | |
3124 | |
3125 v1 = 5; | |
3126 if (a1 % 24 >= 5) | |
3127 v1 = 29; | |
3128 return v1 - a1 % 24; | |
3129 } | |
3130 | |
3131 //----- (00494836) -------------------------------------------------------- | |
3132 int stru339_spell_sound::AddPartySpellSound(int uSoundID, int a6) | |
3133 { | |
3134 int v3; // esi@1 | |
3135 int result; // eax@1 | |
3136 //stru339_spell_sound *v5; // ebx@1 | |
3137 //int *v6; // edi@2 | |
3138 unsigned int v7; // eax@3 | |
3139 int v8; // [sp+Ch] [bp-8h]@3 | |
3140 int v9; // [sp+10h] [bp-4h]@2 | |
3141 int a2a; // [sp+1Ch] [bp+8h]@1 | |
3142 //return 0; | |
3143 v3 = 0; | |
3144 result = word_4EE088_sound_ids[uSoundID]; | |
3145 //v5 = this; | |
3146 a2a = word_4EE088_sound_ids[uSoundID]; | |
3147 if (word_4EE088_sound_ids[uSoundID]) | |
3148 { | |
3149 //v6 = this->pSoundsOffsets; | |
3150 for (v9 = 0; v9 < 2; ++v9) | |
3151 { | |
3152 v7 = a2a++; | |
3153 result = pSoundList->LoadSound(v7, (char *)this + v3, 44744 - v3, &v8, a6); | |
3154 if (!result) | |
3155 break; | |
3156 a6 += 4; | |
3157 result = v8 + 256; | |
3158 this->pSoundsOffsets[v9] = v3; | |
3159 v3 += result; | |
3160 this->pSoundsSizes[v9] = v8 + 256; | |
3161 //++v6; | |
3162 } | |
3163 } | |
3164 return result; | |
3165 } | |
3166 | |
3167 //----- (00443E31) -------------------------------------------------------- | |
3168 void LoadLevel_InitializeLevelStr() | |
3169 { | |
3170 | |
3171 // char Args[100]; | |
3172 int string_num; | |
3173 int max_string_length; | |
3174 // int current_string_length; | |
3175 int prev_string_offset; | |
3176 | |
3177 if (sizeof(pLevelStrOffsets) != 2000) | |
3178 Log::Warning(L"pLevelStrOffsets: deserialization warning"); | |
3179 memset(pLevelStrOffsets.data(), 0, 2000); | |
3180 | |
3181 max_string_length = 0; | |
3182 string_num = 1; | |
3183 prev_string_offset = 0; | |
3184 pLevelStrOffsets[0] = 0; | |
3185 for (uint i = 0; i < uLevelStrFileSize; ++i) | |
3186 { | |
3187 if (!pLevelStr[i]) | |
3188 { | |
3189 pLevelStrOffsets[string_num] = i + 1; | |
3190 ++string_num; | |
3191 if (i - prev_string_offset > max_string_length) | |
3192 max_string_length = i - prev_string_offset; | |
3193 prev_string_offset = i; | |
3194 } | |
3195 } | |
3196 | |
3197 uLevelStrNumStrings = string_num - 1; | |
3198 if (max_string_length > 800) | |
3199 Error("MAX_EVENT_TEXT_LENGTH needs to be increased to %lu", max_string_length + 1); | |
3200 | |
3201 if (uLevelStrNumStrings > 0) | |
3202 { | |
3203 for (uint i = 0; i <uLevelStrNumStrings; ++i) | |
3204 { | |
3205 if (RemoveQuotes(&pLevelStr[pLevelStrOffsets[i]]) != &pLevelStr[pLevelStrOffsets[i]]) | |
3206 ++pLevelStrOffsets[i]; | |
3207 } | |
3208 } | |
3209 } | |
3210 | |
3211 //----- (00443F95) -------------------------------------------------------- | |
2551
4008b2f34be0
MainMenu rendering moved from event loop to respective window class
a.parshin
parents:
2544
diff
changeset
|
3212 void OnMapLeave() |
2541 | 3213 { |
3214 _evt_raw *test_event; | |
3215 if (uLevelEVT_NumEvents > 0) | |
3216 { | |
3217 for (uint i = 0; i < uLevelEVT_NumEvents; ++i) | |
3218 { | |
3219 test_event = (_evt_raw*)&pLevelEVT[pLevelEVT_Index[i].uEventOffsetInEVT]; | |
3220 if (test_event->_e_type == EVENT_OnMapLeave) | |
3221 { | |
3222 EventProcessor(pLevelEVT_Index[i].uEventID, 0, 1, pLevelEVT_Index[i].event_sequence_num); | |
3223 } | |
3224 } | |
3225 } | |
3226 } | |
3227 | |
3228 //----- (00443FDC) -------------------------------------------------------- | |
3229 void OnMapLoad() | |
3230 { | |
3231 int v6; // eax@9 | |
3232 unsigned __int64 v8; // qax@26 | |
3233 int hours; // ebx@26 | |
3234 unsigned __int64 v18; // [sp+Ch] [bp-44h]@12 | |
3235 unsigned int seconds; // [sp+14h] [bp-3Ch]@26 | |
3236 unsigned __int64 v20; // [sp+1Ch] [bp-34h]@7 | |
3237 unsigned int minutes; // [sp+2Ch] [bp-24h]@26 | |
3238 unsigned int years; // [sp+34h] [bp-1Ch]@26 | |
3239 unsigned int weeks; // [sp+38h] [bp-18h]@26 | |
3240 int v26; // [sp+3Ch] [bp-14h]@15 | |
3241 unsigned int days; // [sp+3Ch] [bp-14h]@26 | |
3242 unsigned int months; // [sp+40h] [bp-10h]@26 | |
3243 | |
3244 for (uint i = 0; i < uLevelEVT_NumEvents; ++i) | |
3245 { | |
3246 EventIndex pEvent = pLevelEVT_Index[i]; | |
3247 | |
3248 _evt_raw* _evt = (_evt_raw *)(&pLevelEVT[pEvent.uEventOffsetInEVT]); | |
3249 | |
3250 if (_evt->_e_type == EVENT_PlaySound) | |
3251 pSoundList->LoadSound(EVT_DWORD(_evt->v5), 0); | |
3252 else if (_evt->_e_type == EVENT_OnMapReload) | |
3253 EventProcessor(pEvent.uEventID, 0, 0, pEvent.event_sequence_num); | |
3254 else if (_evt->_e_type == EVENT_OnTimer || _evt->_e_type == EVENT_Initialize) | |
3255 { | |
3256 //v3 = &MapsLongTimersList[MapsLongTimers_count]; | |
3257 v20 = pOutdoor->loc_time.uLastVisitDay; | |
3258 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
3259 v20 = pIndoor->stru1.uLastVisitDay; | |
3260 | |
3261 MapsLongTimersList[MapsLongTimers_count].timer_evt_type = _evt->_e_type; | |
3262 MapsLongTimersList[MapsLongTimers_count].timer_evt_ID = pEvent.uEventID; | |
3263 MapsLongTimersList[MapsLongTimers_count].timer_evt_seq_num = pEvent.event_sequence_num; | |
3264 | |
3265 MapsLongTimersList[MapsLongTimers_count].YearsInterval = _evt->v5; | |
3266 MapsLongTimersList[MapsLongTimers_count].MonthsInterval = _evt->v6; | |
3267 MapsLongTimersList[MapsLongTimers_count].WeeksInterval = _evt->v7; | |
3268 MapsLongTimersList[MapsLongTimers_count].HoursInterval = _evt->v8; | |
3269 MapsLongTimersList[MapsLongTimers_count].MinutesInterval = _evt->v9; | |
3270 MapsLongTimersList[MapsLongTimers_count].SecondsInterval = _evt->v10; | |
3271 | |
3272 | |
3273 v6 = ((unsigned short)_evt->v12 << 8) + _evt->v11; | |
3274 | |
3275 MapsLongTimersList[MapsLongTimers_count].time_left_to_fire = ((unsigned short)_evt->v12 << 8) + _evt->v11; | |
3276 MapsLongTimersList[MapsLongTimers_count].IntervalHalfMins = ((unsigned short)_evt->v12 << 8) + _evt->v11; | |
3277 if (MapsLongTimersList[MapsLongTimers_count].timer_evt_type == EVENT_Initialize && !(short)v6) | |
3278 { | |
3279 if (v20) | |
3280 v18 = pParty->uTimePlayed - v20; | |
3281 else | |
3282 v18 = 0; | |
3283 v26 = (signed int)(signed __int64)((double)(signed __int64)v18 * 0.234375) / 60 / 60 / 24; | |
3284 | |
3285 if (v26 / 7 / 4 / 12 != 0 && MapsLongTimersList[MapsLongTimers_count].YearsInterval || | |
3286 v26 / 7 / 4 != 0 && MapsLongTimersList[MapsLongTimers_count].MonthsInterval != 0 || | |
3287 v26 / 7 != 0 && MapsLongTimersList[MapsLongTimers_count].WeeksInterval != 0 || | |
3288 v26 != 0 || !v20) | |
3289 { | |
3290 ++MapsLongTimers_count; | |
3291 MapsLongTimersList[MapsLongTimers_count].NextStartTime = 0; | |
3292 continue; | |
3293 } | |
3294 } | |
3295 else | |
3296 { | |
3297 v8 = (__int64)((double)pParty->uTimePlayed * 0.234375); | |
3298 seconds = v8 % 60; | |
3299 minutes = (v8 / 60) % 60; | |
3300 hours = ((v8 / 60) / 60) % 24; | |
3301 days = (((v8 / 60) / 60) / 24) % 7; | |
3302 weeks = ((((v8 / 60) / 60) / 24) / 7) % 4; | |
3303 months = (((((v8 / 60) / 60) / 24) / 7) / 4) % 12; | |
3304 years = (((((v8 / 60) / 60) / 24) / 7) / 4) / 12; | |
3305 | |
3306 if (MapsLongTimersList[MapsLongTimers_count].YearsInterval) | |
3307 ++years; | |
3308 else if (MapsLongTimersList[MapsLongTimers_count].MonthsInterval) | |
3309 ++months; | |
3310 else if (MapsLongTimersList[MapsLongTimers_count].WeeksInterval) | |
3311 ++weeks; | |
3312 else | |
3313 { | |
3314 ++days; | |
3315 hours = MapsLongTimersList[MapsLongTimers_count].HoursInterval; | |
3316 minutes = MapsLongTimersList[MapsLongTimers_count].MinutesInterval; | |
3317 seconds = MapsLongTimersList[MapsLongTimers_count].SecondsInterval; | |
3318 } | |
3319 MapsLongTimersList[MapsLongTimers_count].NextStartTime = (signed __int64)((double)((seconds | |
3320 + 60 * minutes | |
3321 + 3600 * hours | |
3322 + 86400 * days | |
3323 + 604800 * weeks | |
3324 + 2419200 * months | |
3325 + 29030400 * years) << 7) | |
3326 * 0.033333335); | |
3327 | |
3328 ++MapsLongTimers_count; | |
3329 } | |
3330 } | |
3331 } | |
3332 } | |
3333 | |
3334 //----- (00444360) -------------------------------------------------------- | |
3335 void Level_LoadEvtAndStr(const char *pLevelName) | |
3336 { | |
3337 char pContainerName[120]; // [sp+8h] [bp-98h]@1 | |
3338 | |
3339 sprintf(pContainerName, "%s.evt", pLevelName); | |
3340 uLevelEVT_Size = LoadEventsToBuffer(pContainerName, pLevelEVT.data(), 9216); | |
3341 | |
3342 sprintf(pContainerName, "%s.str", pLevelName); | |
3343 uLevelStrFileSize = LoadEventsToBuffer(pContainerName, pLevelStr.data(), 9216); | |
3344 if (uLevelStrFileSize) | |
3345 LoadLevel_InitializeLevelStr(); | |
3346 } | |
3347 | |
3348 //----- (004452BB) -------------------------------------------------------- | |
3349 void sub_4452BB() | |
3350 { | |
3351 pGUIWindow2->Release(); | |
3352 pGUIWindow2 = 0; | |
3353 activeLevelDecoration = _591094_decoration; | |
3354 EventProcessor(dword_5C3418, 0, 1, dword_5C341C); | |
3355 activeLevelDecoration = nullptr; | |
3356 pEventTimer->Resume(); | |
3357 } | |
3358 | |
3359 //----- (0044100D) -------------------------------------------------------- | |
3360 bool _44100D_should_alter_right_panel() | |
3361 { | |
3362 return current_screen_type == SCREEN_NPC_DIALOGUE || current_screen_type == SCREEN_CHARACTERS || | |
3363 current_screen_type == SCREEN_HOUSE || current_screen_type == SCREEN_E || | |
3364 current_screen_type == SCREEN_CHANGE_LOCATION || current_screen_type == SCREEN_INPUT_BLV || current_screen_type == SCREEN_CASTING; | |
3365 } | |
3366 | |
3367 //----- (0044987B) -------------------------------------------------------- | |
3368 void Transition_StopSound_Autosave(const char *pMapName, MapStartPoint start_point) | |
3369 { | |
3370 pAudioPlayer->StopChannels(-1, -1); | |
3371 pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_None); | |
3372 if (_stricmp(pCurrentMapName, pMapName)) | |
3373 SaveGame(1, 0); | |
3374 | |
3375 uGameState = GAME_STATE_CHANGE_LOCATION; | |
3376 strcpy(pCurrentMapName, pMapName); | |
3377 uLevel_StartingPointType = start_point; | |
3378 } | |
3379 | |
3380 //----- (004451A8) -------------------------------------------------------- | |
3381 void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4) | |
3382 { | |
3383 if (!pGUIWindow2) | |
3384 { | |
3385 if (pParty->uFlags & 2) | |
3386 pEngine->Draw(); | |
3387 pAudioPlayer->StopChannels(-1, -1); | |
3388 pMiscTimer->Pause(); | |
3389 pEventTimer->Pause(); | |
3390 dword_5C3418 = a1; | |
3391 dword_5C341C = a2; | |
3392 _591094_decoration = activeLevelDecoration; | |
2544
c674d547cc7c
GUIWindow switch logic refactored into behaviour classes
a.parshin
parents:
2543
diff
changeset
|
3393 pGUIWindow2 = new GUIWindow_GenericDialogue(0, 0, window->GetWidth(), window->GetHeight(), a4, 0); |
2541 | 3394 pGUIWindow2->CreateButton(61, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); |
3395 pGUIWindow2->CreateButton(177, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); | |
3396 pGUIWindow2->CreateButton(292, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); | |
3397 pGUIWindow2->CreateButton(407, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); | |
3398 } | |
3399 } | |
3400 | |
3401 | |
3402 | |
3403 | |
3404 //----- (00448B67) -------------------------------------------------------- | |
3405 void OnTimer(int) | |
3406 { | |
3407 if (pEventTimer->bPaused) | |
3408 return; | |
3409 | |
3410 long long v13 = (signed __int64)(pParty->uTimePlayed - _5773B8_event_timer) / 128; | |
3411 if (!v13) | |
3412 return; | |
3413 | |
3414 //uint _v2v3 = pParty->uTimePlayed; | |
3415 //v3 = HIDWORD(pParty->uTimePlayed); | |
3416 //v2 = LODWORD(pParty->uTimePlayed); | |
3417 | |
3418 _5773B8_event_timer = pParty->uTimePlayed; | |
3419 | |
3420 for (uint i = 0; i < MapsLongTimers_count; ++i) | |
3421 { | |
3422 //v4 = (char *)&array_5B5928_timers[0].field_C; | |
3423 MapsLongTimer* timer = &MapsLongTimersList[i]; | |
3424 //while ( 1 ) | |
3425 //{ | |
3426 //v5 = *(short *)v4; | |
3427 if (timer->time_left_to_fire) | |
3428 { | |
3429 if (v13 < timer->time_left_to_fire) | |
3430 timer->time_left_to_fire -= v13; | |
3431 else | |
3432 { | |
3433 timer->time_left_to_fire = timer->IntervalHalfMins; | |
3434 EventProcessor(timer->timer_evt_ID, 0, 1, timer->timer_evt_seq_num); | |
3435 } | |
3436 } | |
3437 else | |
3438 { | |
3439 if (timer->NextStartTime < pParty->uTimePlayed) | |
3440 { | |
3441 uint next_trigger_time = 1 * 60 * 60 * 24; // 1 day | |
3442 if (timer->YearsInterval) | |
3443 next_trigger_time = 336 * 60 * 60 * 24; // 1 year | |
3444 else if (timer->MonthsInterval) | |
3445 next_trigger_time = 28 * 60 * 60 * 24; // 1 month | |
3446 else if (timer->WeeksInterval) | |
3447 next_trigger_time = 7 * 60 * 60 * 24; // 1 week | |
3448 | |
3449 timer->NextStartTime += (next_trigger_time * 128) / 3.0f; | |
3450 if (timer->NextStartTime < pParty->uTimePlayed) // make sure in wont fire several times in a row if big time interval has lapsed | |
3451 timer->NextStartTime = pParty->uTimePlayed; | |
3452 | |
3453 EventProcessor(timer->timer_evt_ID, 0, 1, timer->timer_evt_seq_num); | |
3454 } | |
3455 } | |
3456 } | |
3457 } | |
3458 | |
3459 | |
3460 | |
3461 | |
3462 | |
3463 | |
3464 | |
3465 //----- (0044C28F) -------------------------------------------------------- | |
3466 bool TeleportToNWCDungeon() | |
3467 { | |
3468 if (!_stricmp("nwc.blv", pCurrentMapName)) | |
3469 return false; | |
3470 | |
3471 _5B65A8_npcdata_uflags_or_other = 0; | |
3472 _5B65AC_npcdata_fame_or_other = 0; | |
3473 _5B65B0_npcdata_rep_or_other = 0; | |
3474 _5B65B4_npcdata_loword_house_or_other = 0; | |
3475 _5B65B8_npcdata_hiword_house_or_other = 0; | |
3476 dword_5B65BC = 0; | |
3477 dword_5B65C0 = 0; | |
3478 | |
3479 pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; | |
3480 Transition_StopSound_Autosave("nwc.blv", MapStartPoint_Party); | |
3481 current_screen_type = SCREEN_GAME; | |
3482 return true; | |
3483 } | |
3484 | |
3485 //----- (00401000) -------------------------------------------------------- | |
3486 void mm7__vector_constructor(void *a1, int objSize, int numObjs, int(*constructor)(int)) | |
3487 { | |
3488 void *v4; // esi@2 | |
3489 | |
3490 if (numObjs > 0) | |
3491 { | |
3492 v4 = a1; | |
3493 for (int i = numObjs; i; --i) | |
3494 { | |
3495 constructor((int)v4); | |
3496 v4 = (char *)v4 + objSize; | |
3497 } | |
3498 } | |
3499 } | |
3500 | |
3501 | |
3502 |