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