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