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