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