Mercurial > mm7
annotate Game.cpp @ 1490:db0dfdb9871e
Fix indentation.
author | yoctozepto |
---|---|
date | Thu, 29 Aug 2013 22:36:48 +0200 |
parents | 7ef4b64f6329 |
children | a109bb203e28 |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1110
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1110
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1110
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1110
diff
changeset
|
4 |
137 | 5 #include <assert.h> |
6 | |
1016 | 7 #include "Vis.h" |
8 | |
9 #include "LightmapBuilder.h" | |
10 #include "DecalBuilder.h" | |
11 #include "ParticleEngine.h" | |
12 #include "Mouse.h" | |
13 #include "Keyboard.h" | |
14 #include "CShow.h" | |
15 #include "GammaControl.h" | |
16 #include "stru6.h" | |
17 #include "stru9.h" | |
18 #include "stru10.h" | |
19 | |
0 | 20 #include "Game.h" |
21 #include "Party.h" | |
22 #include "IndoorCamera.h" | |
23 #include "Viewport.h" | |
24 #include "Time.h" | |
25 #include "Outdoor.h" | |
1277 | 26 #include "Outdoor_stuff.h" |
0 | 27 #include "Overlays.h" |
28 #include "AudioPlayer.h" | |
29 #include "LOD.h" | |
30 #include "OSInfo.h" | |
31 #include "GUIWindow.h" | |
32 #include "TurnEngine.h" | |
33 #include "VideoPlayer.h" | |
34 #include "Bink_Smacker.h" | |
35 #include "Events.h" | |
36 #include "Arcomage.h" | |
189 | 37 #include "texts.h" |
791 | 38 #include "GUIFont.h" |
194 | 39 #include "Log.h" |
1262 | 40 #include "Lights.h" |
41 #include "mm7_data.h" | |
0 | 42 |
43 //#include "MM7.h" | |
44 | |
45 | |
46 | |
47 | |
48 | |
49 | |
50 Game *pGame; | |
51 | |
52 | |
53 | |
54 | |
55 | |
56 //----- (00435694) -------------------------------------------------------- | |
57 void Game::ToggleFlags2(unsigned int uFlag) | |
58 { | |
59 unsigned int v2; // eax@1 | |
60 | |
61 v2 = this->uFlags2; | |
62 if ( v2 & uFlag ) | |
63 this->uFlags2 = v2 & ~uFlag; | |
64 else | |
65 this->uFlags2 = uFlag | v2; | |
66 } | |
67 | |
68 //----- (0044103C) -------------------------------------------------------- | |
69 void Game::Draw() | |
70 { | |
142 | 71 //float v2; // ST24_4@11 |
0 | 72 //double v3; // ST28_8@11 |
73 int v4; // edi@26 | |
142 | 74 //int v5; // eax@35 |
0 | 75 |
76 uFlags2 &= 0xFFFFFFFDu; | |
77 if ( pParty->_497FC5_check_party_perception_against_level() ) | |
78 uFlags2 |= 2u; | |
79 pIndoorCamera->sRotationX = pParty->sRotationX; | |
80 pIndoorCamera->sRotationY = pParty->sRotationY; | |
120 | 81 //pIndoorCamera->pos.x = pParty->vPosition.x - ((__int64)pParty->y_rotation_granularity * stru_5C6E00->SinCos(pIndoorCamera->sRotationY)) / 2048.0;//12552 |
82 //pIndoorCamera->pos.y = pParty->vPosition.y - ((__int64)pParty->y_rotation_granularity * stru_5C6E00->SinCos(pIndoorCamera->sRotationY)) / 2048.0;//800 | |
83 pIndoorCamera->pos.x = pParty->vPosition.x - pParty->y_rotation_granularity * cosf(2 * 3.141592653589 * pIndoorCamera->sRotationY / 2048.0); | |
84 pIndoorCamera->pos.y = pParty->vPosition.y - pParty->y_rotation_granularity * sinf(2 * 3.141592653589 * pIndoorCamera->sRotationY / 2048.0); | |
66 | 85 pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel;//193, but real 353 |
0 | 86 pIndoorCamera->Initialize2(); |
87 pIndoorCameraD3D->CreateWorldMatrixAndSomeStuff(); | |
88 pIndoorCameraD3D->_4374E8_ProllyBuildFrustrum(); | |
89 | |
90 if ( pVideoPlayer->AnyMovieLoaded() ) | |
91 { | |
1421 | 92 if ( !pRenderer->pRenderD3D ) |
93 { | |
94 pRenderer->BeginSceneD3D(); | |
95 pMouse->DrawCursorToTarget(); | |
96 pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); | |
97 } | |
0 | 98 } |
99 else | |
100 { | |
1110 | 101 if ( pParty->vPosition.x != pParty->vPrevPosition.x || pParty->sRotationY != pParty->sPrevRotationY || pParty->vPosition.y != pParty->vPrevPosition.y |
102 || pParty->sRotationX != pParty->sPrevRotationX || pParty->vPosition.z != pParty->vPrevPosition.z || pParty->sEyelevel != pParty->sPrevEyelevel ) | |
0 | 103 pParty->uFlags |= 2u; |
847 | 104 pParty->vPrevPosition.x = pParty->vPosition.x; |
78 | 105 pParty->vPrevPosition.y = pParty->vPosition.y; |
847 | 106 pParty->vPrevPosition.z = pParty->vPosition.z; |
0 | 107 //v0 = &pRenderer; |
108 pParty->sPrevRotationY = pParty->sRotationY; | |
109 pParty->sPrevRotationX = pParty->sRotationX; | |
847 | 110 |
0 | 111 pParty->sPrevEyelevel = pParty->sEyelevel; |
112 pRenderer->BeginSceneD3D(); | |
113 | |
114 if ( !pRenderer->pRenderD3D ) | |
115 pMouse->DrawCursorToTarget(); | |
265 | 116 if ( !PauseGameDrawing() || viewparams->field_48 == 1 ) |
0 | 117 { |
118 if ( pRenderer->pRenderD3D ) | |
119 { | |
142 | 120 float v2 = (double)(((signed int)pMiscTimer->uTotalGameTimeElapsed >> 2) & 0x1F) * 0.032258064 * 6.0; |
0 | 121 //v3 = v2 + 6.7553994e15; |
122 //pRenderer->field_1036A8_bitmapid = LODWORD(v3); | |
265 | 123 pRenderer->hd_water_current_frame = floorf(v2 + 0.5f); |
0 | 124 } |
125 | |
126 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
127 pIndoor->Draw(); | |
128 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
129 pOutdoor->Draw(); | |
137 | 130 else assert(false); |
0 | 131 |
132 if (pRenderer->pRenderD3D) | |
133 { | |
134 pDecalBuilder->DrawBloodsplats(); | |
1394 | 135 pGame->pLightmapBuilder->DrawLightmapsType(2); |
0 | 136 } |
137 } | |
1421 | 138 pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); |
0 | 139 } |
791 | 140 |
141 //DEBUG: force redraw gui | |
142 viewparams->bRedrawGameUI = true; | |
143 | |
144 | |
0 | 145 pRenderer->BeginScene(); |
146 if (pRenderer->pRenderD3D) | |
147 pMouse->DrawCursorToTarget(); | |
142 | 148 if (pOtherOverlayList->bRedraw) |
149 viewparams->bRedrawGameUI = true; | |
0 | 150 v4 = viewparams->bRedrawGameUI; |
783 | 151 GameUI_Footer(); |
0 | 152 if (!viewparams->bRedrawGameUI) |
153 { | |
154 GameUI_DrawRightPanelItems(); | |
155 } | |
156 else | |
157 { | |
158 GameUI_DrawRightPanelFrames(); | |
783 | 159 GameUI_Footer_2(); |
0 | 160 viewparams->bRedrawGameUI = false; |
161 } | |
162 if (!pVideoPlayer->pSmackerMovie) | |
163 { | |
164 GameUI_DrawMinimap(488, 16, 625, 133, viewparams->uMinimapZoom, pParty->uFlags & 2); | |
165 if (v4) | |
166 { | |
265 | 167 if ( !PauseGameDrawing() && pRenderer->pRenderD3D) // clear game viewport with transparent color |
693 | 168 pRenderer->FillRectFast(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pViewport->uViewportBR_X - pViewport->uViewportTL_X, |
169 pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1, | |
142 | 170 pRenderer->uTargetGMask | pRenderer->uTargetBMask); |
0 | 171 viewparams->field_48 = 0; |
172 } | |
173 } | |
142 | 174 |
175 viewparams->bRedrawGameUI = pOtherOverlayList->bRedraw; | |
176 pOtherOverlayList->bRedraw = 0; | |
177 | |
0 | 178 GameUI_DrawPartySpells(); |
291 | 179 if (v4 || pParty->pHirelings[0].evt_C || pParty->pHirelings[1].evt_C ) |
994 | 180 GameUI_DrawHiredNPCs(); |
0 | 181 GameUI_DrawPortraits(v4); |
182 GameUI_DrawLifeManaBars(); | |
183 GameUI_DrawCharacterSelectionFrame(); | |
184 if ( sub_44100D() ) | |
994 | 185 GameUI_DrawRightPanel(); |
0 | 186 if ( !pVideoPlayer->AnyMovieLoaded() ) |
187 { | |
188 pStru6Instance->DrawPlayerBuffAnims(); | |
569 | 189 pOtherOverlayList->DrawTurnBasedIcon(v4); |
0 | 190 GameUI_DrawTorchlightAndWizardEye(); |
191 } | |
791 | 192 |
794 | 193 |
194 static bool render_framerate = false; | |
195 static float framerate = 0.0f; | |
196 static uint frames_this_second = 0; | |
197 static uint last_frame_time = GetTickCount(); | |
198 static uint framerate_time_elapsed = 0; | |
199 | |
200 auto frame_dt = GetTickCount() - last_frame_time; | |
201 last_frame_time = GetTickCount(); | |
202 | |
203 framerate_time_elapsed += frame_dt; | |
204 if (framerate_time_elapsed >= 1000) | |
205 { | |
206 framerate = frames_this_second * (1000.0f / framerate_time_elapsed); | |
207 | |
208 framerate_time_elapsed = 0; | |
209 frames_this_second = 0; | |
210 render_framerate = true; | |
211 } | |
212 | |
213 ++frames_this_second; | |
214 | |
215 | |
216 if (render_framerate) | |
217 { | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
218 sprintf(pTmpBuf.data(), "FPS: % .4f", framerate); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
219 pPrimaryWindow->DrawText(pFontArrus, 494, 0, TargetColor(0, 0, 0), pTmpBuf.data(), 0, 0, 0); |
794 | 220 } |
221 | |
791 | 222 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) |
223 { | |
831 | 224 auto sector_id = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
225 sprintf(pTmpBuf.data(), "Party Sector ID: %u/%u\n", sector_id, pIndoor->uNumSectors); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
226 pPrimaryWindow->DrawText(pFontArrus, 16, 16, TargetColor(255, 255, 255), pTmpBuf.data(), 0, 0, 0xFFFFFFFF); |
791 | 227 } |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
228 sprintf(pTmpBuf.data(), "Party Position: % d % d % d", pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
229 pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16, TargetColor(255, 255, 255), pTmpBuf.data(), 0, 0, 0xFFFFFFFF); |
791 | 230 |
231 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
232 { | |
233 uint uFaceID; | |
831 | 234 auto sector_id = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); |
235 auto floor_level = BLV_GetFloorLevel(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + 40, sector_id, &uFaceID); | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
236 sprintf(pTmpBuf.data(), "BLV_GetFloorLevel: %d face_id %d\n", floor_level, uFaceID); |
791 | 237 } |
238 else | |
239 { | |
240 int on_water, _a6; | |
241 auto floor_level = ODM_GetFloorLevel(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z, 0, &on_water, &_a6, false); | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
242 sprintf(pTmpBuf.data(), "ODM_GetFloorLevel: %d on_water: %s a6 = %d\n", floor_level, on_water ? "true" : "false", _a6); |
791 | 243 } |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
244 pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16 + 16, TargetColor(255, 255, 255), pTmpBuf.data(), 0, 0, 0xFFFFFFFF); |
791 | 245 |
0 | 246 GUI_UpdateWindows(); |
130 | 247 pParty->UpdatePlayersAndHirelingsEmotions(); |
937 | 248 |
434 | 249 _unused_5B5924_is_travel_ui_drawn = false; |
0 | 250 if (v4) |
791 | 251 pMouse->bRedraw = true; |
0 | 252 pMouse->_469EA4(); |
253 pMouse->DrawCursor(); | |
254 pMouse->_469E1C(); | |
255 pRenderer->EndScene(); | |
256 pRenderer->Present(); | |
569 | 257 pParty->uFlags &= ~2; |
0 | 258 } |
259 | |
260 //----- (0047A815) -------------------------------------------------------- | |
261 void Game::DrawParticles() | |
262 { | |
263 pParticleEngine->Draw(); | |
264 } | |
265 | |
266 //----- (00463149) -------------------------------------------------------- | |
267 void Game::Loop() | |
268 { | |
269 //signed int v0; // ebp@3 | |
270 //signed int v1; // esi@4 | |
271 //Render *v2; // edi@7 | |
272 //signed int v3; // esi@7 | |
273 signed int pNewNPCsCount; // ecx@58 | |
1063 | 274 NPCData *pNPC; // eax@59 |
0 | 275 Player *pPlayer; // esi@65 |
981 | 276 //OtherOverlay *pOtherOverlay; // esi@67 |
277 //signed int v8; // edi@67 | |
982 | 278 //int pPlayerNum; // edi@69 |
0 | 279 int *pHealth; // esi@71 |
982 | 280 //signed int v11; // esi@78 |
281 //int v12; // eax@83 | |
0 | 282 const char *pLocationName; // [sp-4h] [bp-68h]@74 |
283 bool bLoading; // [sp+10h] [bp-54h]@1 | |
982 | 284 //signed int bLoadinga; // [sp+10h] [bp-54h]@19 |
0 | 285 signed int v16; // [sp+14h] [bp-50h]@8 |
982 | 286 //int v17[4]; // [sp+18h] [bp-4Ch]@80 |
0 | 287 MSG Msg; // [sp+28h] [bp-3Ch]@20 |
288 char Source[64]; // [sp+44h] [bp-20h]@76 | |
289 | |
961 | 290 bLoading = uCurrentMenuID == MENU_LoadingProcInMainMenu; |
0 | 291 SetCurrentMenuID((MENU_STATE)-1); |
292 if (bLoading) | |
293 { | |
294 pParty->Reset(); | |
295 dword_6BE340 = 0; | |
982 | 296 uGameState = GAME_STATE_PLAYING; |
0 | 297 LoadGame(uLoadGameUI_SelectedSlot); |
298 } | |
299 | |
300 for (uint i = 1; i < 5; ++i) | |
301 for (uint j = 1; j < 6; ++j) | |
302 { | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
303 sprintf(pTmpBuf.data(), "data\\lloyd%d%d.pcx", i, j); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
304 remove(pTmpBuf.data()); |
0 | 305 } |
306 | |
307 LoadPlayerPortraintsAndVoices(); | |
783 | 308 pIcons_LOD->_inlined_sub1(); |
328 | 309 pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); |
0 | 310 |
311 while ( 2 ) | |
312 { | |
313 v16 = 1; | |
783 | 314 pMessageQueue_50CBD0->Flush(); |
0 | 315 |
316 pPartyActionQueue->uNumActions = 0; | |
317 if (pParty->bTurnBasedModeOn) | |
318 { | |
319 pTurnEngine->End(false); | |
320 pParty->bTurnBasedModeOn = false; | |
321 } | |
322 DoPrepareWorld(bLoading, 1); | |
323 pEventTimer->Resume(); | |
324 dword_6BE364_game_settings_1 |= 0x80; | |
325 dword_6BE340 = 2; | |
326 // uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0; | |
151 | 327 pCurrentScreen = SCREEN_GAME; |
1038 | 328 |
0 | 329 if ( pRenderer->pRenderD3D ) |
330 pGame->pVisInstance->_4C1A02(); | |
982 | 331 |
332 bool game_finished = false; | |
0 | 333 do |
334 { | |
335 while ( PeekMessageA(&Msg, 0, 0, 0, PM_REMOVE) ) | |
336 { | |
337 if ( Msg.message == WM_QUIT ) | |
338 Game_DeinitializeAndTerminate(0); | |
339 TranslateMessage(&Msg); | |
340 DispatchMessageA(&Msg); | |
341 } | |
342 if (dword_6BE364_game_settings_1 & 0x0100 ) | |
343 { | |
344 WaitMessage(); | |
345 continue; | |
346 } | |
347 pGame->_44EEA7(); | |
348 GameUI_WritePointedObjectStatusString(); | |
349 ProcessInputActions(); | |
350 GameUI_MsgProc(); | |
351 if ( pArcomageGame->bGameInProgress ) | |
352 { | |
353 ArcomageGame::Loop(); | |
354 pRenderer->Present(); | |
355 continue; | |
356 } | |
357 if ( pVideoPlayer->pSmackerMovie && !SmackWait(pVideoPlayer->pSmackerMovie) ) | |
358 { | |
359 pRenderer->BeginScene(); | |
360 pMouse->DrawCursorToTarget(); | |
361 pVideoPlayer->SmackUpdatePalette(pVideoPlayer->hWindow); | |
362 pMouse->_469EA4(); | |
363 pRenderer->EndScene(); | |
364 } | |
982 | 365 else if ( pVideoPlayer->pBinkMovie && !BinkWait(pVideoPlayer->pBinkMovie) ) |
0 | 366 { |
367 pRenderer->BeginScene(); | |
368 pMouse->DrawCursorToTarget(); | |
369 pVideoPlayer->BinkUpdatePalette(pVideoPlayer->hWindow); | |
370 pMouse->_469EA4(); | |
371 pRenderer->EndScene(); | |
372 } | |
983 | 373 |
374 pEventTimer->Update(); | |
375 pMiscTimer->Update(); | |
376 | |
0 | 377 OnTimer(0); |
378 GameUI_StatusBar_UpdateTimedString(0); | |
379 if ( pMiscTimer->bPaused && !pEventTimer->bPaused ) | |
380 pMiscTimer->Resume(); | |
381 if ( pEventTimer->bTackGameTime && !pParty->bTurnBasedModeOn ) | |
382 pEventTimer->bTackGameTime = 0; | |
982 | 383 if ( !pEventTimer->bPaused && uGameState == GAME_STATE_PLAYING) |
0 | 384 { |
385 if ( !pEventTimer->bTackGameTime ) | |
386 _494035_timed_effects__water_walking_damage__etc(); | |
387 if ( dword_6BE364_game_settings_1 & 1 ) | |
388 { | |
389 dword_6BE364_game_settings_1 &= 0xFFFFFFFEu; | |
390 } | |
391 else | |
392 { | |
783 | 393 UpdateActorAI(); |
394 UpdateUserInput_and_MapSpecificStuff(); | |
0 | 395 } |
396 } | |
397 if ( v16 ) | |
398 { | |
399 v16 = 0; | |
400 viewparams->bRedrawGameUI = true; | |
401 } | |
378 | 402 pAudioPlayer->UpdateSounds(); |
978 | 403 if (uGameState == GAME_FINISHED) |
0 | 404 //goto LABEL_96; |
4 | 405 { |
982 | 406 game_finished = true; |
0 | 407 continue; |
4 | 408 } |
978 | 409 if (uGameState == GAME_STATE_2) |
0 | 410 { |
411 pAudioPlayer->StopChannels(-1, -1); | |
412 PrepareWorld(0); | |
982 | 413 uGameState = GAME_STATE_PLAYING; |
0 | 414 continue; |
415 } | |
978 | 416 if ( (signed int)uGameState <= GAME_STATE_2 ) |
0 | 417 //goto LABEL_85; |
4 | 418 { |
419 pGame->Draw(); | |
0 | 420 continue; |
4 | 421 } |
978 | 422 if ( (signed int)uGameState <= GAME_STATE_5 || uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU ) |
0 | 423 { |
424 //LABEL_96: | |
982 | 425 game_finished = true; |
0 | 426 continue; |
427 } | |
981 | 428 if ( uGameState != GAME_STATE_PARTY_DIED ) |
0 | 429 { |
978 | 430 if ( uGameState != GAME_STATE_FINAL_WINDOW ) |
0 | 431 { |
432 //LABEL_85: | |
433 pGame->Draw(); | |
434 } | |
981 | 435 else |
436 { | |
437 pRenderer->BeginScene(); | |
438 GUI_UpdateWindows(); | |
439 pRenderer->EndScene(); | |
440 //goto LABEL_89; | |
441 pRenderer->Present(); | |
442 } | |
0 | 443 continue; |
444 } | |
4 | 445 pAudioPlayer->StopChannels(-1, -1);//äàëåå â ñëó÷àå ñìåðòè ãðóïïû |
293 | 446 memset(&pParty->pHirelings[0], 0, 0x4Cu); |
0 | 447 memset(&pParty->pHirelings[1], 0, 0x4Cu); |
448 pNewNPCsCount = 0; | |
449 if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) | |
450 { | |
1063 | 451 pNPC = pNPCStats->pNewNPCData; |
0 | 452 do |
453 { | |
1063 | 454 if ( pNPC->field_24 ) |
455 pNPC->uFlags &= 0xFFFFFF7Fu; | |
0 | 456 ++pNewNPCsCount; |
1063 | 457 ++pNPC; |
0 | 458 } |
459 while ( pNewNPCsCount < (signed int)pNPCStats->uNumNewNPCs ); | |
460 } | |
461 pVideoPlayer->PlayDeathMovie(); | |
462 if ( pVideoPlayer->AnyMovieLoaded() ) | |
463 pVideoPlayer->Unload(); | |
464 SaveGame(0, 0); | |
465 ++pParty->uNumDeaths; | |
466 pPlayer = pParty->pPlayers; | |
467 do | |
468 { | |
469 pPlayer->SetVariable(VAR_Award, 85); | |
470 ++pPlayer; | |
471 } | |
472 while ( (signed int)pPlayer < (signed int)pParty->pHirelings ); | |
766 | 473 pParty->days_played_without_rest = 0; |
0 | 474 pParty->uTimePlayed += 0x276000ui64; |
569 | 475 LOWORD(pParty->uFlags) &= ~0x204; |
0 | 476 pParty->SetGold(0); |
981 | 477 pOtherOverlayList->Reset(); |
982 | 478 memset(pParty->pPartyBuffs, 0, 0x140u); |
981 | 479 |
0 | 480 if ( pParty->bTurnBasedModeOn == 1 ) |
481 { | |
1448 | 482 pTurnEngine->End(true); |
0 | 483 pParty->bTurnBasedModeOn = 0; |
484 } | |
440 | 485 //pHealth = &pParty->pPlayers[0].sHealth;//193C |
486 //do | |
487 for(int i=0; i<4; ++i) | |
0 | 488 { |
440 | 489 memset(pParty->pPlayers[i].pConditions, 0, 0xA0u);//(pConditions, 0, 160) |
490 memset(pParty->pPlayers[i].pPlayerBuffs, 0, 0x180u);//(pPlayerBuffs[0], 0, 384) | |
491 //*pHealth = 1; | |
492 pParty->pPlayers[i].sHealth=1; | |
493 //pHealth += 1743; //6CF | |
0 | 494 uActiveCharacter = 1; |
495 } | |
440 | 496 // while ( (signed int)pHealth < (signed int)&pParty->field_871C[567] ); |
981 | 497 if (_449B57_test_bit(pParty->_quest_bits, PARTY_QUEST_FINISHED_EMERALD_ISLE)) |
0 | 498 { |
499 pParty->vPosition.x = -17331; // respawn in harmondale | |
500 pParty->vPosition.y = 12547; | |
501 pParty->vPosition.z = 465; | |
502 pParty->sRotationY = 0; | |
503 pLocationName = "out02.odm"; | |
504 } | |
505 else | |
506 { | |
507 pParty->vPosition.x = 12552; // respawn on emerald isle | |
508 pParty->vPosition.y = 1816; | |
509 pParty->vPosition.z = 0; | |
510 pParty->sRotationY = 512; | |
511 pLocationName = "out01.odm"; | |
512 } | |
513 strcpy(Source, pLocationName); | |
514 pParty->uFallStartY = pParty->vPosition.z; | |
515 pParty->sRotationX = 0; | |
516 pParty->uFallSpeed = 0; | |
517 pParty->field_6E4 = 0; | |
518 pParty->field_6E0 = 0; | |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1449
diff
changeset
|
519 if ( _stricmp(Source, pCurrentMapName) ) |
0 | 520 { |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1449
diff
changeset
|
521 strcpy(pCurrentMapName, Source); |
0 | 522 _5B65A8_npcdata_uflags_or_other = pParty->vPosition.x; |
523 _5B65AC_npcdata_fame_or_other = pParty->vPosition.y; | |
524 _5B65B0_npcdata_rep_or_other = pParty->vPosition.z; | |
525 _5B65B4_npcdata_loword_house_or_other = pParty->sRotationY; | |
526 _5B65B8_npcdata_hiword_house_or_other = pParty->sRotationX; | |
527 dword_5B65C0 = 1; | |
528 PrepareWorld(1); | |
529 } | |
530 InitializeActors(); | |
982 | 531 |
532 | |
533 int num_conscious_players = 0; | |
534 int conscious_players_ids[4] = {-1, -1, -1, -1}; | |
535 for (int v11 = 0; v11 < 4; ++v11) | |
0 | 536 { |
982 | 537 if (pPlayers[v11 + 1]->CanAct()) |
538 conscious_players_ids[num_conscious_players++] = v11; | |
0 | 539 } |
982 | 540 if (num_conscious_players) |
0 | 541 { |
982 | 542 int idx = conscious_players_ids[rand() % num_conscious_players]; |
543 assert(idx >= 0); | |
544 pPlayers[idx + 1]->PlaySound(SPEECH_99, 0); | |
0 | 545 } |
982 | 546 |
0 | 547 ShowStatusBarString(pGlobalTXT_LocalizationStrings[524], 2u);// "Once again you've cheated death!.." "Âû ñíîâà îáõèòðèëè ñìåðòü! …" |
982 | 548 uGameState = GAME_STATE_PLAYING; |
0 | 549 } |
982 | 550 while (!game_finished); |
551 | |
0 | 552 dword_6BE340 = 0; |
553 pEventTimer->Pause(); | |
554 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); | |
1214
0d6c7ff3cddd
simplified stru193_math constructor and class definition
Grumpy7
parents:
1205
diff
changeset
|
555 if ( uGameState == GAME_STATE_LOADING_GAME ) |
0 | 556 { |
557 sub_491E3A(); | |
558 LoadPlayerPortraintsAndVoices(); | |
982 | 559 uGameState = GAME_STATE_PLAYING; |
0 | 560 pIcons_LOD->dword_11B84 = pIcons_LOD->uNumLoadedFiles; |
561 bLoading = true; | |
562 continue; | |
563 } | |
564 break; | |
565 } | |
151 | 566 pCurrentScreen = SCREEN_VIDEO; |
0 | 567 sub_491E3A(); |
568 } | |
569 | |
570 | |
571 //----- (0044F192) -------------------------------------------------------- | |
572 void Game::PrepareBloodsplats() | |
573 { | |
574 for (uint i = 0; i < uNumBloodsplats; ++i) | |
575 { | |
576 pBloodsplatContainer->AddBloodsplat( | |
577 pBloodsplats[i].x, | |
578 pBloodsplats[i].y, | |
579 pBloodsplats[i].z, | |
580 pBloodsplats[i].radius, | |
581 pBloodsplats[i].r, | |
582 pBloodsplats[i].g, | |
583 pBloodsplats[i].b); | |
584 } | |
585 } | |
586 | |
587 | |
588 //----- (0044F120) -------------------------------------------------------- | |
589 void Game::PushStationaryLights(int a2) | |
590 { | |
1094 | 591 Game__StationaryLight* pLight; |
592 | |
593 for( int i=0; i<uNumStationaryLights; ++i ) | |
594 { | |
595 pLight=&pStationaryLights[i]; | |
596 pStationaryLightsStack->AddLight( | |
597 pLight->vPosition.x, | |
598 pLight->vPosition.y, | |
599 pLight->vPosition.z, | |
600 pLight->flt_18, | |
601 pLight->vRGBColor.x, | |
602 pLight->vRGBColor.y, | |
603 pLight->vRGBColor.z, | |
604 byte_4E94D0); | |
605 } | |
0 | 606 } |
607 // 4E94D0: using guessed type char byte_4E94D0; | |
608 | |
609 //----- (0044F0FD) -------------------------------------------------------- | |
610 void Game::_44F0FD() | |
611 { | |
612 ToggleFlags(0x40u); | |
613 | |
614 if ( !(uFlags & 0x40) ) | |
615 { | |
616 uNumBloodsplats = 0; | |
617 field_E0C = 0; | |
618 } | |
619 } | |
620 | |
621 //----- (0044F0D8) -------------------------------------------------------- | |
622 void Game::ToggleFlags(uint uMask) | |
623 { | |
624 if (uFlags & uMask) | |
625 uFlags &= ~uMask; | |
626 else | |
627 uFlags |= uMask; | |
628 } | |
629 | |
630 | |
631 //----- (0044F07B) -------------------------------------------------------- | |
632 bool Game::_44F07B() | |
633 { | |
634 if (!pKeyboardInstance->IsKeyBeingHeld(VK_SHIFT) && | |
635 !pKeyboardInstance->IsKeyBeingHeld(VK_LSHIFT) && | |
636 !pKeyboardInstance->IsKeyBeingHeld(VK_LSHIFT) || | |
637 | |
638 (pKeyboardInstance->WasKeyPressed(VK_F11) == 0 && | |
639 pKeyboardInstance->WasKeyPressed(VK_F11))) | |
640 return true; | |
641 return false; | |
642 } | |
643 | |
644 //----- (0044EEA7) -------------------------------------------------------- | |
645 bool Game::_44EEA7() | |
646 { | |
647 //Game *v1; // esi@1 | |
194 | 648 //double v2; // st7@2 |
0 | 649 float depth; // ST00_4@9 |
194 | 650 //bool result; // eax@9 |
0 | 651 unsigned int v5; // eax@14 |
652 __int64 v6; // kr00_8@21 | |
653 unsigned int y; // [sp+4h] [bp-24h]@2 | |
654 unsigned int x; // [sp+8h] [bp-20h]@2 | |
194 | 655 Vis_SelectionFilter *v10; // [sp+10h] [bp-18h]@2 |
656 Vis_SelectionFilter *v11; // [sp+14h] [bp-14h]@2 | |
0 | 657 POINT a2; // [sp+20h] [bp-8h]@1 |
658 | |
659 //v1 = this; | |
660 ++qword_5C6DF0; | |
661 pParticleEngine->UpdateParticles(); | |
662 pMouseInstance->GetCursorPos(&a2); | |
194 | 663 |
664 x = a2.y; | |
665 y = a2.x; | |
0 | 666 if ( sub_4637E0_is_there_popup_onscreen() ) |
667 { | |
194 | 668 v11 = &vis_face_filter; |
669 v10 = &vis_sprite_filter_2; | |
871 | 670 depth = pGame->pIndoorCameraD3D->GetPickDepth(); |
0 | 671 } |
672 else | |
673 { | |
592 | 674 if ( uFlags2 & GAME_FLAGS_2_TARGETING_MODE ) |
0 | 675 { |
194 | 676 v11 = &vis_face_filter; |
677 v10 = &vis_sprite_filter_1; | |
0 | 678 } |
679 else | |
680 { | |
194 | 681 v11 = &vis_face_filter; |
682 v10 = &vis_sprite_filter_4; | |
0 | 683 } |
194 | 684 depth = 5120.0; |
0 | 685 } |
194 | 686 //depth = v2; |
0 | 687 |
323 | 688 PickMouse(depth, y, x, false, v10, v11); |
0 | 689 pLightmapBuilder->std__vector_000004_size = 0; |
690 pLightmapBuilder->std__vector_183808_size = 0; | |
691 pDecalBuilder->std__vector_pDecals_size = 0; | |
692 pDecalBuilder->field_308008 = 0; | |
194 | 693 if (!_44F07B()) |
694 return false; | |
695 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
638
diff
changeset
|
696 if ( uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS) |
794 | 697 pStru10Instance->bDoNotDrawPortalFrustum = false; |
0 | 698 if ( pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor) |
699 { | |
700 v5 = GetLevelFogColor(); | |
701 pRenderer->uFogColor = v5 & 0xFFFFFF; | |
702 } | |
703 if (uFlags & 0x0400) | |
704 uFlags2 |= 0x01; | |
705 if ( !pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor && pMobileLightsStack->uNumLightsActive ) | |
706 { | |
707 uFlags2 |= 0x01; | |
708 field_E10 = qword_5C6DF0; | |
709 } | |
710 v6 = qword_5C6DF0 - field_E10; | |
711 if ( qword_5C6DF0 - field_E10 == 1 ) | |
712 uFlags2 |= v6; | |
713 if (uNumStationaryLights_in_pStationaryLightsStack != pStationaryLightsStack->uNumLightsActive ) | |
714 { | |
715 uFlags2 |= 1u; | |
716 uNumStationaryLights_in_pStationaryLightsStack = pStationaryLightsStack->uNumLightsActive; | |
717 } | |
718 _44E904(); | |
194 | 719 return true; |
0 | 720 } |
721 | |
722 | |
723 //----- (0044EDE4) -------------------------------------------------------- | |
638 | 724 bool Game::AlterGamma_BLV(BLVFace *pFace, unsigned int *pColor) |
0 | 725 { |
638 | 726 if (uFlags2 & GAME_FLAGS_2_SATURATE_LIGHTMAPS && |
727 pFace->uAttributes & FACE_CAN_SATURATE_COLOR) | |
0 | 728 { |
729 *pColor = ReplaceHSV(*pColor, 1.0, fSaturation, -1.0); | |
730 return true; | |
731 } | |
732 else | |
733 return false; | |
734 } | |
735 | |
736 //----- (0044EE30) -------------------------------------------------------- | |
638 | 737 bool Game::AlterGamma_ODM(ODMFace *pFace, unsigned int *pColor) |
0 | 738 { |
638 | 739 if (uFlags2 & GAME_FLAGS_2_SATURATE_LIGHTMAPS && |
740 pFace->uAttributes & FACE_CAN_SATURATE_COLOR) | |
0 | 741 { |
638 | 742 *pColor = ReplaceHSV(*pColor, 1.0, fSaturation, -1.0); |
0 | 743 return true; |
744 } | |
745 else | |
746 return false; | |
747 } | |
748 | |
749 | |
750 //----- (004645FA) -------------------------------------------------------- | |
751 void Game::Deinitialize() | |
752 { | |
753 struct tagRECT Rect; // [sp+0h] [bp-10h]@6 | |
754 | |
1038 | 755 |
0 | 756 WriteWindowsRegistryInt("startinwindow", pRenderer->bWindowMode); |
757 if ( GetWindowRect(hWnd, &Rect) && pRenderer->bWindowMode ) | |
758 { | |
759 WriteWindowsRegistryInt("window X", Rect.left); | |
760 WriteWindowsRegistryInt("window Y", Rect.top); | |
761 } | |
762 WriteWindowsRegistryInt("valAlwaysRun", bAlwaysRun); | |
763 pItemsTable->Release(); | |
764 pNPCStats->Release(); | |
1038 | 765 |
0 | 766 if (pMouse) |
767 pMouse->Deactivate(); | |
768 | |
1093 | 769 delete pRenderer; |
0 | 770 pAudioPlayer->Release();//error |
771 pNew_LOD->FreeSubIndexAndIO(); | |
772 pGames_LOD->FreeSubIndexAndIO(); | |
773 ClipCursor(0); | |
774 Game::Destroy(); | |
775 } | |
776 | |
777 //----- (0044EE7C) -------------------------------------------------------- | |
778 bool Game::draw_debug_outlines() | |
779 { | |
780 if (uFlags & 0x04) | |
781 { | |
782 pLightmapBuilder->DrawDebugOutlines(-1); | |
783 pDecalBuilder->DrawDecalDebugOutlines(); | |
784 } | |
785 return true; | |
786 } | |
787 | |
788 //----- (0044EC23) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1277
diff
changeset
|
789 int Game::_44EC23(struct Polygon *a2, int *a3, signed int a4) |
0 | 790 { |
791 double v4; // st7@4 | |
792 //double v5; // ST00_8@4 | |
793 signed int v6; // eax@5 | |
794 //double v7; // ST00_8@6 | |
795 signed int result; // eax@8 | |
796 //double v9; // ST00_8@9 | |
797 //double v10; // ST00_8@11 | |
798 float a2a; // [sp+14h] [bp+8h]@4 | |
799 float a3a; // [sp+18h] [bp+Ch]@4 | |
800 float a3b; // [sp+18h] [bp+Ch]@6 | |
801 float a4a; // [sp+1Ch] [bp+10h]@9 | |
802 float a4b; // [sp+1Ch] [bp+10h]@11 | |
803 | |
804 if ( this->uFlags2 & 2 && a2->field_59 == 5 && a2->pODMFace->uAttributes & 2 ) | |
805 { | |
806 v4 = (double)a4; | |
807 a2a = v4; | |
808 *a3 |= 2u; | |
809 a3a = (1.0 - this->fSaturation) * v4; | |
810 //v5 = a3a + 6.7553994e15; | |
811 //if ( SLODWORD(v5) >= 0 ) | |
812 if (floorf(a3a + 0.5f) >= 0 ) | |
813 { | |
814 a3b = (1.0 - this->fSaturation) * a2a; | |
815 //v7 = a3b + 6.7553994e15; | |
816 //v6 = LODWORD(v7); | |
817 v6 = floorf(a3b + 0.5f); | |
818 } | |
819 else | |
820 { | |
821 v6 = 0; | |
822 } | |
823 if ( a4 >= v6 ) | |
824 { | |
825 a4a = (1.0 - fSaturation) * a2a; | |
826 //v9 = a4a + 6.7553994e15; | |
827 //if ( SLODWORD(v9) >= 0 ) | |
828 if (floorf(a4a + 0.5f) >= 0) | |
829 { | |
830 a4b = (1.0 - fSaturation) * a2a; | |
831 //v10 = a4b + 6.7553994e15; | |
832 //result = LODWORD(v10); | |
833 result = floorf(a4b + 0.5f); | |
834 } | |
835 else | |
836 { | |
837 result = 0; | |
838 } | |
839 } | |
840 else | |
841 { | |
842 result = a4; | |
843 } | |
844 } | |
845 else | |
846 { | |
847 result = -1; | |
848 } | |
849 return result; | |
850 } | |
851 | |
852 | |
853 | |
854 //----- (00465C8B) -------------------------------------------------------- | |
855 Game *Game::Create() | |
856 { | |
857 return new Game; | |
858 } | |
859 | |
860 //----- (00465CF3) -------------------------------------------------------- | |
861 void Game::Destroy() | |
862 { | |
863 if (pGame) | |
864 delete pGame; | |
865 pGame = nullptr; | |
866 } | |
867 | |
868 //----- (0044ED0A) -------------------------------------------------------- | |
869 signed int Game::_44ED0A(BLVFace *a2, int *a3, signed int a4) | |
870 { | |
871 double v4; // st7@3 | |
872 //double v5; // ST00_8@3 | |
873 signed int v6; // eax@4 | |
874 //double v7; // ST00_8@5 | |
875 signed int result; // eax@7 | |
876 //double v9; // ST00_8@8 | |
877 //double v10; // ST00_8@10 | |
878 float v11; // [sp+14h] [bp+8h]@3 | |
879 float v12; // [sp+18h] [bp+Ch]@3 | |
880 float v13; // [sp+18h] [bp+Ch]@5 | |
881 float v14; // [sp+1Ch] [bp+10h]@8 | |
882 float v15; // [sp+1Ch] [bp+10h]@10 | |
883 | |
884 if ( this->uFlags2 & 2 && a2->uAttributes & 2 ) | |
885 { | |
886 v4 = (double)a4; | |
887 v11 = v4; | |
888 *a3 |= 2u; | |
889 v12 = (1.0 - this->fSaturation) * v4; | |
890 //v5 = v12 + 6.7553994e15; | |
891 if (floorf(v12 + 0.5f)/* SLODWORD(v5)*/ >= 0 ) | |
892 { | |
893 v13 = (1.0 - this->fSaturation) * v11; | |
894 //v7 = v13 + 6.7553994e15; | |
895 //v6 = LODWORD(v7); | |
896 v6 = floorf(v13 + 0.5f); | |
897 } | |
898 else | |
899 { | |
900 v6 = 0; | |
901 } | |
902 if ( a4 >= v6 ) | |
903 { | |
904 v14 = (1.0 - fSaturation) * v11; | |
905 //v9 = v14 + 6.7553994e15; | |
906 if (floorf(v14 + 0.5f)/* SLODWORD(v9)*/ >= 0 ) | |
907 { | |
908 v15 = (1.0 - fSaturation) * v11; | |
909 //v10 = v15 + 6.7553994e15; | |
910 //result = LODWORD(v10); | |
911 result = floorf(v15 + 0.5f); | |
912 } | |
913 else | |
914 { | |
915 result = 0; | |
916 } | |
917 } | |
918 else | |
919 { | |
920 result = a4; | |
921 } | |
922 } | |
923 else | |
924 { | |
925 result = -1; | |
926 } | |
927 return result; | |
928 } | |
929 | |
930 | |
931 //----- (0044E4B7) -------------------------------------------------------- | |
932 Game::Game() | |
933 { | |
934 uNumStationaryLights = 0; | |
935 uNumBloodsplats = 0; | |
936 field_E0C = 0; | |
937 field_E10 = 0; | |
938 uNumStationaryLights_in_pStationaryLightsStack = 0; | |
939 bGammaControlInitialized = false; | |
940 uFlags = 0; | |
941 uFlags2 = 0; | |
942 uSomeGammaStartTime = 0; | |
943 uSomeGammaDeltaTime = 0; | |
944 | |
1397 | 945 //pThreadWardInstance = new ThreadWard; |
946 pThreadWardInstance = nullptr; | |
0 | 947 pParticleEngine = new ParticleEngine; |
948 pMouse = pMouseInstance = new Mouse(pThreadWardInstance); | |
949 pLightmapBuilder = new LightmapBuilder; | |
950 pVisInstance = new Vis; | |
951 pStru6Instance = new stru6; | |
952 pIndoorCameraD3D = new IndoorCameraD3D; | |
953 pStru9Instance = new stru9; | |
954 pStru10Instance = new stru10; | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1277
diff
changeset
|
955 //pStru11Instance = new stru11; |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1277
diff
changeset
|
956 pStru11Instance = nullptr; |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1277
diff
changeset
|
957 //pStru12Instance = new stru12(pStru11Instance); |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1277
diff
changeset
|
958 pStru12Instance = nullptr; |
1397 | 959 //pCShow = new CShow; |
960 pCShow = nullptr; | |
0 | 961 pKeyboardInstance = new Keyboard; |
962 pGammaController = new GammaController; | |
963 | |
964 uFlags |= 0x0800; | |
965 uFlags2 |= 0x24; | |
966 | |
967 _44F0FD(); | |
968 | |
969 bWinNT4_0 = false; | |
970 if (pVersion->pVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && | |
971 pVersion->pVersionInfo.dwMajorVersion == 4) | |
972 bWinNT4_0 = true; | |
973 } | |
974 | |
975 //----- (0044E7F3) -------------------------------------------------------- | |
976 Game::~Game() | |
977 { | |
978 if (pGammaController) | |
979 delete pGammaController; | |
980 if (pKeyboardInstance) | |
981 delete pKeyboardInstance; | |
1397 | 982 /*if (pCShow) |
0 | 983 delete pCShow; |
984 if (pStru12Instance) | |
985 delete pStru12Instance; | |
986 if (pStru11Instance) | |
1397 | 987 delete pStru11Instance;*/ |
0 | 988 if (pStru10Instance) |
989 delete pStru10Instance; | |
990 if (pStru9Instance) | |
991 delete pStru9Instance; | |
992 if (pIndoorCameraD3D) | |
993 delete pIndoorCameraD3D; | |
994 if (pStru6Instance) | |
995 delete pStru6Instance; | |
996 if (pVisInstance) | |
997 delete pVisInstance; | |
998 if (pLightmapBuilder) | |
999 delete pLightmapBuilder; | |
1000 if (pMouseInstance) | |
1001 delete pMouseInstance; | |
1002 if (pParticleEngine) | |
1003 delete pParticleEngine; | |
1397 | 1004 //if (pThreadWardInstance) |
1005 // delete pThreadWardInstance; | |
0 | 1006 } |
1007 | |
1008 //----- (0044E904) -------------------------------------------------------- | |
1009 void Game::_44E904() | |
1010 { | |
1011 //Game *v1; // esi@1 | |
1012 unsigned __int64 v2; // qax@1 | |
1013 unsigned int v3; // ecx@1 | |
1014 int v4; // edi@1 | |
1015 unsigned __int8 v5; // cf@7 | |
1016 double v6; // st7@13 | |
1017 double v7; // st7@15 | |
1018 signed __int64 v8; // [sp+Ch] [bp-8h]@1 | |
1019 | |
1020 //v1 = this; | |
1021 v2 = pEventTimer->Time(); | |
1022 v4 = (v2 - uSomeGammaStartTime) >> 32; | |
1023 v3 = v2 - LODWORD(uSomeGammaStartTime); | |
1024 v8 = v2 - uSomeGammaStartTime; | |
1025 if ( v4 < 0 | |
1026 || SHIDWORD(v2) < ((unsigned int)v2 < LODWORD(uSomeGammaStartTime)) + HIDWORD(uSomeGammaStartTime) | v4 == 0 | |
1027 && v3 <= 0x80 ) | |
1028 { | |
1421 | 1029 if ( v4 < 0 ) |
1030 { | |
1031 v3 = 0; | |
1032 v4 = 0; | |
1033 uSomeGammaStartTime = v2; | |
1034 v8 = __PAIR__(v4, v3); | |
1035 } | |
0 | 1036 } |
1037 else | |
1038 { | |
1039 if ( uSomeGammaDeltaTime ) | |
1040 { | |
1041 LODWORD(uSomeGammaDeltaTime) = 0; | |
1042 HIDWORD(uSomeGammaDeltaTime) = 0; | |
1043 } | |
1044 else | |
1045 { | |
1046 LODWORD(uSomeGammaDeltaTime) = v3; | |
1047 HIDWORD(uSomeGammaDeltaTime) = v4; | |
1048 } | |
1049 v5 = __CFADD__(v3, -128); | |
1050 v3 -= 128; | |
1051 v4 = v5 + v4 - 1; | |
1421 | 1052 uSomeGammaStartTime = v2; |
1053 v8 = __PAIR__(v4, v3); | |
0 | 1054 } |
1055 if ( uSomeGammaDeltaTime ) | |
1056 v6 = (double)(signed __int64)(uSomeGammaDeltaTime - __PAIR__(v4, v3)); | |
1057 else | |
1058 v6 = (double)v8; | |
1059 v7 = v6 * 0.0078125; | |
1060 if ( v7 < 0.0 || v7 <= 1.0 ) | |
1061 { | |
1062 if ( v7 < 0.0 ) | |
1063 v7 = 0.0; | |
1064 } | |
1065 else | |
1066 { | |
1067 v7 = 1.0; | |
1068 } | |
1069 if ( pRenderer->pRenderD3D ) | |
1070 fSaturation = v7; | |
1071 else | |
1072 fSaturation = (1.0 - 0.5) * v7 + 0.5; | |
1073 } | |
1074 | |
1075 //----- (0044EA17) -------------------------------------------------------- | |
1076 bool Game::InitializeGammaController() | |
1077 { | |
1078 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
1079 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
1080 pGammaController->InitializeFromSurface(pRenderer->pFrontBuffer4); | |
1081 | |
1082 bGammaControlInitialized = true; | |
1083 uSomeGammaStartTime = pEventTimer->Time(); | |
1084 return true; | |
1085 } | |
1086 | |
1087 //----- (0044EA5E) -------------------------------------------------------- | |
194 | 1088 bool Game::PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) |
0 | 1089 { |
227 | 1090 if (pCurrentScreen != SCREEN_GAME|| !pRenderer->pRenderD3D) |
194 | 1091 return false; |
0 | 1092 |
194 | 1093 if (!pVisInstance) |
0 | 1094 { |
194 | 1095 MessageBoxW(nullptr, L"The 'Vis' object pointer has not been instatiated, but CGame::Pick() is trying to call through it.", nullptr, 0); |
1096 return false; | |
1097 } | |
0 | 1098 |
692 | 1099 if (uMouseX >= (signed int)pViewport->uScreen_TL_X && |
1100 uMouseX <= (signed int)pViewport->uScreen_BR_X && | |
1101 uMouseY >= (signed int)pViewport->uScreen_TL_Y && | |
1102 uMouseY <= (signed int)pViewport->uScreen_BR_Y) | |
194 | 1103 { |
1104 pVisInstance->PickMouse(fPickDepth, uMouseX, uMouseY, sprite_filter, face_filter); | |
0 | 1105 |
194 | 1106 if (bOutline) |
1107 OutlineSelection(); | |
0 | 1108 } |
194 | 1109 |
1110 return true; | |
0 | 1111 } |
1112 // 4E28F8: using guessed type int pCurrentScreen; | |
1113 | |
1114 //----- (0044EB12) -------------------------------------------------------- | |
194 | 1115 bool Game::PickKeyboard(bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) |
0 | 1116 { |
271 | 1117 if (pCurrentScreen == SCREEN_GAME && pVisInstance && pRenderer->pRenderD3D) |
0 | 1118 { |
194 | 1119 bool r = pVisInstance->PickKeyboard(&pVisInstance->default_list, sprite_filter, face_filter); |
0 | 1120 |
1121 if (bOutline) | |
1122 OutlineSelection(); | |
1123 return r; | |
1124 } | |
1125 return false; | |
1126 } | |
123 | 1127 /* |
1128 Result::Code Game::PickKeyboard(bool bOutline, struct unnamed_F93E6C *a3, struct unnamed_F93E6C *a4) | |
1129 { | |
1130 if (dword_4E28F8_PartyCantJumpIfTrue) | |
1131 return Result::Generic; | |
1132 | |
1133 pVis->PickKeyboard(a3, a4); | |
1134 if (bOutline) | |
1135 Game_outline_selection((int)this); | |
1136 return Result::Success; | |
1137 } | |
1138 */ | |
0 | 1139 // 4E28F8: using guessed type int pCurrentScreen; |
1140 | |
1141 //----- (0044EB5A) -------------------------------------------------------- | |
1142 void Game::OutlineSelection() | |
1143 { | |
194 | 1144 if (!pVisInstance) |
1145 return; | |
1146 | |
1147 if (!pVisInstance->default_list.uNumPointers) | |
1148 return; | |
0 | 1149 |
194 | 1150 auto object_info = pVisInstance->default_list.object_pointers[0]; |
1151 if (object_info) | |
1152 switch (object_info->object_type) | |
0 | 1153 { |
194 | 1154 case VisObjectType_Sprite: |
0 | 1155 { |
194 | 1156 Log::Warning(L"Sprite outline currently unsupported"); |
1157 return; | |
0 | 1158 } |
1159 | |
194 | 1160 case VisObjectType_Face: |
1161 { | |
1162 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
0 | 1163 { |
194 | 1164 auto face = (ODMFace *)object_info->object; |
1165 if (face->uAttributes & FACE_OUTLINED) | |
1166 face->uAttributes &= ~FACE_OUTLINED; | |
0 | 1167 else |
194 | 1168 face->uAttributes |= FACE_OUTLINED; |
1169 } | |
1170 else if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
1171 { | |
1172 auto face = (BLVFace *)object_info->object; | |
1173 if (face->uAttributes & FACE_OUTLINED) | |
1174 face->uAttributes &= ~FACE_OUTLINED; | |
1175 else | |
1176 face->uAttributes |= FACE_OUTLINED; | |
0 | 1177 } |
194 | 1178 else assert(false); |
1179 } | |
323 | 1180 break; |
194 | 1181 |
1182 default: | |
1183 { | |
1184 MessageBoxW(nullptr, L"Undefined CObjectInfo type requested in CGame::outline_selection()", nullptr, 0); | |
1185 ExitProcess(0); | |
1186 } | |
0 | 1187 } |
1188 } |