Mercurial > mm7
annotate Game.cpp @ 982:08fd1436ef35
enums & lod
author | Nomad |
---|---|
date | Sat, 11 May 2013 13:19:55 +0200 |
parents | a6ef7125f6e4 |
children | 1462a5f12b65 |
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 } | |
816 | 361 |
0 | 362 OnTimer(0); |
363 GameUI_StatusBar_UpdateTimedString(0); | |
364 if ( pMiscTimer->bPaused && !pEventTimer->bPaused ) | |
365 pMiscTimer->Resume(); | |
366 if ( pEventTimer->bTackGameTime && !pParty->bTurnBasedModeOn ) | |
367 pEventTimer->bTackGameTime = 0; | |
982 | 368 if ( !pEventTimer->bPaused && uGameState == GAME_STATE_PLAYING) |
0 | 369 { |
370 if ( !pEventTimer->bTackGameTime ) | |
371 _494035_timed_effects__water_walking_damage__etc(); | |
372 if ( dword_6BE364_game_settings_1 & 1 ) | |
373 { | |
374 dword_6BE364_game_settings_1 &= 0xFFFFFFFEu; | |
375 } | |
376 else | |
377 { | |
783 | 378 UpdateActorAI(); |
379 UpdateUserInput_and_MapSpecificStuff(); | |
0 | 380 } |
381 } | |
382 if ( v16 ) | |
383 { | |
384 v16 = 0; | |
385 viewparams->bRedrawGameUI = true; | |
386 } | |
378 | 387 pAudioPlayer->UpdateSounds(); |
978 | 388 if (uGameState == GAME_FINISHED) |
0 | 389 //goto LABEL_96; |
4 | 390 { |
982 | 391 game_finished = true; |
0 | 392 continue; |
4 | 393 } |
978 | 394 if (uGameState == GAME_STATE_2) |
0 | 395 { |
396 pAudioPlayer->StopChannels(-1, -1); | |
397 PrepareWorld(0); | |
982 | 398 uGameState = GAME_STATE_PLAYING; |
0 | 399 continue; |
400 } | |
978 | 401 if ( (signed int)uGameState <= GAME_STATE_2 ) |
0 | 402 //goto LABEL_85; |
4 | 403 { |
404 pGame->Draw(); | |
0 | 405 continue; |
4 | 406 } |
978 | 407 if ( (signed int)uGameState <= GAME_STATE_5 || uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU ) |
0 | 408 { |
409 //LABEL_96: | |
982 | 410 game_finished = true; |
0 | 411 continue; |
412 } | |
981 | 413 if ( uGameState != GAME_STATE_PARTY_DIED ) |
0 | 414 { |
978 | 415 if ( uGameState != GAME_STATE_FINAL_WINDOW ) |
0 | 416 { |
417 //LABEL_85: | |
418 pGame->Draw(); | |
419 } | |
981 | 420 else |
421 { | |
422 pRenderer->BeginScene(); | |
423 GUI_UpdateWindows(); | |
424 pRenderer->EndScene(); | |
425 //goto LABEL_89; | |
426 pRenderer->Present(); | |
427 } | |
0 | 428 continue; |
429 } | |
4 | 430 pAudioPlayer->StopChannels(-1, -1);//äàëåå â ñëó÷àå ñìåðòè ãðóïïû |
293 | 431 memset(&pParty->pHirelings[0], 0, 0x4Cu); |
0 | 432 memset(&pParty->pHirelings[1], 0, 0x4Cu); |
433 pNewNPCsCount = 0; | |
434 if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) | |
435 { | |
436 pFlags = (char *)&pNPCStats->pNewNPCData[0].uFlags; | |
437 do | |
438 { | |
439 if ( *((int *)pFlags + 6) ) | |
440 *pFlags &= 0x7Fu; | |
441 ++pNewNPCsCount; | |
442 pFlags += 76; | |
443 } | |
444 while ( pNewNPCsCount < (signed int)pNPCStats->uNumNewNPCs ); | |
445 } | |
446 pVideoPlayer->PlayDeathMovie(); | |
447 if ( pVideoPlayer->AnyMovieLoaded() ) | |
448 pVideoPlayer->Unload(); | |
449 SaveGame(0, 0); | |
450 ++pParty->uNumDeaths; | |
451 pPlayer = pParty->pPlayers; | |
452 do | |
453 { | |
454 pPlayer->SetVariable(VAR_Award, 85); | |
455 ++pPlayer; | |
456 } | |
457 while ( (signed int)pPlayer < (signed int)pParty->pHirelings ); | |
766 | 458 pParty->days_played_without_rest = 0; |
0 | 459 pParty->uTimePlayed += 0x276000ui64; |
569 | 460 LOWORD(pParty->uFlags) &= ~0x204; |
0 | 461 pParty->SetGold(0); |
981 | 462 pOtherOverlayList->Reset(); |
982 | 463 memset(pParty->pPartyBuffs, 0, 0x140u); |
981 | 464 |
0 | 465 if ( pParty->bTurnBasedModeOn == 1 ) |
466 { | |
467 pTurnEngine->End(1); | |
468 pParty->bTurnBasedModeOn = 0; | |
469 } | |
440 | 470 //pHealth = &pParty->pPlayers[0].sHealth;//193C |
471 //do | |
472 for(int i=0; i<4; ++i) | |
0 | 473 { |
440 | 474 memset(pParty->pPlayers[i].pConditions, 0, 0xA0u);//(pConditions, 0, 160) |
475 memset(pParty->pPlayers[i].pPlayerBuffs, 0, 0x180u);//(pPlayerBuffs[0], 0, 384) | |
476 //*pHealth = 1; | |
477 pParty->pPlayers[i].sHealth=1; | |
478 //pHealth += 1743; //6CF | |
0 | 479 uActiveCharacter = 1; |
480 } | |
440 | 481 // while ( (signed int)pHealth < (signed int)&pParty->field_871C[567] ); |
981 | 482 if (_449B57_test_bit(pParty->_quest_bits, PARTY_QUEST_FINISHED_EMERALD_ISLE)) |
0 | 483 { |
484 pParty->vPosition.x = -17331; // respawn in harmondale | |
485 pParty->vPosition.y = 12547; | |
486 pParty->vPosition.z = 465; | |
487 pParty->sRotationY = 0; | |
488 pLocationName = "out02.odm"; | |
489 } | |
490 else | |
491 { | |
492 pParty->vPosition.x = 12552; // respawn on emerald isle | |
493 pParty->vPosition.y = 1816; | |
494 pParty->vPosition.z = 0; | |
495 pParty->sRotationY = 512; | |
496 pLocationName = "out01.odm"; | |
497 } | |
498 strcpy(Source, pLocationName); | |
499 pParty->uFallStartY = pParty->vPosition.z; | |
500 pParty->sRotationX = 0; | |
501 pParty->uFallSpeed = 0; | |
502 pParty->field_6E4 = 0; | |
503 pParty->field_6E0 = 0; | |
504 if ( _strcmpi(Source, pCurrentMapName) ) | |
505 { | |
506 strcpy(pCurrentMapName, Source); | |
507 _5B65A8_npcdata_uflags_or_other = pParty->vPosition.x; | |
508 _5B65AC_npcdata_fame_or_other = pParty->vPosition.y; | |
509 _5B65B0_npcdata_rep_or_other = pParty->vPosition.z; | |
510 _5B65B4_npcdata_loword_house_or_other = pParty->sRotationY; | |
511 _5B65B8_npcdata_hiword_house_or_other = pParty->sRotationX; | |
512 dword_5B65C0 = 1; | |
513 PrepareWorld(1); | |
514 } | |
515 InitializeActors(); | |
982 | 516 |
517 | |
518 int num_conscious_players = 0; | |
519 int conscious_players_ids[4] = {-1, -1, -1, -1}; | |
520 for (int v11 = 0; v11 < 4; ++v11) | |
0 | 521 { |
982 | 522 if (pPlayers[v11 + 1]->CanAct()) |
523 conscious_players_ids[num_conscious_players++] = v11; | |
0 | 524 } |
982 | 525 if (num_conscious_players) |
0 | 526 { |
982 | 527 int idx = conscious_players_ids[rand() % num_conscious_players]; |
528 assert(idx >= 0); | |
529 pPlayers[idx + 1]->PlaySound(SPEECH_99, 0); | |
0 | 530 } |
982 | 531 |
0 | 532 ShowStatusBarString(pGlobalTXT_LocalizationStrings[524], 2u);// "Once again you've cheated death!.." "Âû ñíîâà îáõèòðèëè ñìåðòü! …" |
982 | 533 uGameState = GAME_STATE_PLAYING; |
0 | 534 } |
982 | 535 while (!game_finished); |
536 | |
0 | 537 dword_6BE340 = 0; |
538 pEventTimer->Pause(); | |
539 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); | |
978 | 540 if ( uGameState == GAME_STATE_3 ) |
0 | 541 { |
542 sub_491E3A(); | |
543 LoadPlayerPortraintsAndVoices(); | |
982 | 544 uGameState = GAME_STATE_PLAYING; |
0 | 545 pIcons_LOD->dword_11B84 = pIcons_LOD->uNumLoadedFiles; |
546 bLoading = true; | |
547 continue; | |
548 } | |
549 break; | |
550 } | |
151 | 551 pCurrentScreen = SCREEN_VIDEO; |
0 | 552 sub_491E3A(); |
553 } | |
554 | |
555 | |
556 //----- (0044F192) -------------------------------------------------------- | |
557 void Game::PrepareBloodsplats() | |
558 { | |
559 for (uint i = 0; i < uNumBloodsplats; ++i) | |
560 { | |
561 pBloodsplatContainer->AddBloodsplat( | |
562 pBloodsplats[i].x, | |
563 pBloodsplats[i].y, | |
564 pBloodsplats[i].z, | |
565 pBloodsplats[i].radius, | |
566 pBloodsplats[i].r, | |
567 pBloodsplats[i].g, | |
568 pBloodsplats[i].b); | |
569 } | |
570 } | |
571 | |
572 | |
573 //----- (0044F120) -------------------------------------------------------- | |
574 void Game::PushStationaryLights(int a2) | |
575 { | |
576 signed int v3; // ebx@1 | |
577 char *v4; // esi@2 | |
578 | |
579 auto v2 = this; | |
580 v3 = 0; | |
581 if ( (signed int)this->uNumStationaryLights > 0 ) | |
582 { | |
583 v4 = (char *)&this->pStationaryLights[0].vRGBColor.y; | |
584 do | |
585 { | |
586 pStationaryLightsStack->AddLight( | |
587 (signed __int64)*((float *)v4 - 4), | |
588 (signed __int64)*((float *)v4 - 3), | |
589 (signed __int64)*((float *)v4 - 2), | |
590 (signed __int64)*((float *)v4 + 2), | |
591 (signed __int64)*((float *)v4 - 1), | |
592 (signed __int64)*(float *)v4, | |
593 (signed __int64)*((float *)v4 + 1), | |
594 byte_4E94D0); | |
595 ++v3; | |
596 v4 += 28; | |
597 } | |
598 while ( v3 < (signed int)v2->uNumStationaryLights ); | |
599 } | |
600 } | |
601 // 4E94D0: using guessed type char byte_4E94D0; | |
602 | |
603 //----- (0044F0FD) -------------------------------------------------------- | |
604 void Game::_44F0FD() | |
605 { | |
606 ToggleFlags(0x40u); | |
607 | |
608 if ( !(uFlags & 0x40) ) | |
609 { | |
610 uNumBloodsplats = 0; | |
611 field_E0C = 0; | |
612 } | |
613 } | |
614 | |
615 //----- (0044F0D8) -------------------------------------------------------- | |
616 void Game::ToggleFlags(uint uMask) | |
617 { | |
618 if (uFlags & uMask) | |
619 uFlags &= ~uMask; | |
620 else | |
621 uFlags |= uMask; | |
622 } | |
623 | |
624 | |
625 //----- (0044F07B) -------------------------------------------------------- | |
626 bool Game::_44F07B() | |
627 { | |
628 if (!pKeyboardInstance->IsKeyBeingHeld(VK_SHIFT) && | |
629 !pKeyboardInstance->IsKeyBeingHeld(VK_LSHIFT) && | |
630 !pKeyboardInstance->IsKeyBeingHeld(VK_LSHIFT) || | |
631 | |
632 (pKeyboardInstance->WasKeyPressed(VK_F11) == 0 && | |
633 pKeyboardInstance->WasKeyPressed(VK_F11))) | |
634 return true; | |
635 return false; | |
636 } | |
637 | |
638 //----- (0044EEA7) -------------------------------------------------------- | |
639 bool Game::_44EEA7() | |
640 { | |
641 //Game *v1; // esi@1 | |
194 | 642 //double v2; // st7@2 |
0 | 643 float depth; // ST00_4@9 |
194 | 644 //bool result; // eax@9 |
0 | 645 unsigned int v5; // eax@14 |
646 __int64 v6; // kr00_8@21 | |
647 unsigned int y; // [sp+4h] [bp-24h]@2 | |
648 unsigned int x; // [sp+8h] [bp-20h]@2 | |
194 | 649 Vis_SelectionFilter *v10; // [sp+10h] [bp-18h]@2 |
650 Vis_SelectionFilter *v11; // [sp+14h] [bp-14h]@2 | |
0 | 651 POINT a2; // [sp+20h] [bp-8h]@1 |
652 | |
653 //v1 = this; | |
654 ++qword_5C6DF0; | |
655 pParticleEngine->UpdateParticles(); | |
656 pMouseInstance->GetCursorPos(&a2); | |
194 | 657 |
658 x = a2.y; | |
659 y = a2.x; | |
0 | 660 if ( sub_4637E0_is_there_popup_onscreen() ) |
661 { | |
194 | 662 v11 = &vis_face_filter; |
663 v10 = &vis_sprite_filter_2; | |
871 | 664 depth = pGame->pIndoorCameraD3D->GetPickDepth(); |
0 | 665 } |
666 else | |
667 { | |
592 | 668 if ( uFlags2 & GAME_FLAGS_2_TARGETING_MODE ) |
0 | 669 { |
194 | 670 v11 = &vis_face_filter; |
671 v10 = &vis_sprite_filter_1; | |
0 | 672 } |
673 else | |
674 { | |
194 | 675 v11 = &vis_face_filter; |
676 v10 = &vis_sprite_filter_4; | |
0 | 677 } |
194 | 678 depth = 5120.0; |
0 | 679 } |
194 | 680 //depth = v2; |
0 | 681 |
323 | 682 PickMouse(depth, y, x, false, v10, v11); |
0 | 683 pLightmapBuilder->std__vector_000004_size = 0; |
684 pLightmapBuilder->std__vector_183808_size = 0; | |
685 pDecalBuilder->std__vector_pDecals_size = 0; | |
686 pDecalBuilder->field_308008 = 0; | |
194 | 687 if (!_44F07B()) |
688 return false; | |
689 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
638
diff
changeset
|
690 if ( uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS) |
794 | 691 pStru10Instance->bDoNotDrawPortalFrustum = false; |
0 | 692 if ( pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor) |
693 { | |
694 v5 = GetLevelFogColor(); | |
695 pRenderer->uFogColor = v5 & 0xFFFFFF; | |
696 } | |
697 if (uFlags & 0x0400) | |
698 uFlags2 |= 0x01; | |
699 if ( !pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor && pMobileLightsStack->uNumLightsActive ) | |
700 { | |
701 uFlags2 |= 0x01; | |
702 field_E10 = qword_5C6DF0; | |
703 } | |
704 v6 = qword_5C6DF0 - field_E10; | |
705 if ( qword_5C6DF0 - field_E10 == 1 ) | |
706 uFlags2 |= v6; | |
707 if (uNumStationaryLights_in_pStationaryLightsStack != pStationaryLightsStack->uNumLightsActive ) | |
708 { | |
709 uFlags2 |= 1u; | |
710 uNumStationaryLights_in_pStationaryLightsStack = pStationaryLightsStack->uNumLightsActive; | |
711 } | |
712 _44E904(); | |
194 | 713 return true; |
0 | 714 } |
715 | |
716 | |
717 //----- (0044EDE4) -------------------------------------------------------- | |
638 | 718 bool Game::AlterGamma_BLV(BLVFace *pFace, unsigned int *pColor) |
0 | 719 { |
638 | 720 if (uFlags2 & GAME_FLAGS_2_SATURATE_LIGHTMAPS && |
721 pFace->uAttributes & FACE_CAN_SATURATE_COLOR) | |
0 | 722 { |
723 *pColor = ReplaceHSV(*pColor, 1.0, fSaturation, -1.0); | |
724 return true; | |
725 } | |
726 else | |
727 return false; | |
728 } | |
729 | |
730 //----- (0044EE30) -------------------------------------------------------- | |
638 | 731 bool Game::AlterGamma_ODM(ODMFace *pFace, unsigned int *pColor) |
0 | 732 { |
638 | 733 if (uFlags2 & GAME_FLAGS_2_SATURATE_LIGHTMAPS && |
734 pFace->uAttributes & FACE_CAN_SATURATE_COLOR) | |
0 | 735 { |
638 | 736 *pColor = ReplaceHSV(*pColor, 1.0, fSaturation, -1.0); |
0 | 737 return true; |
738 } | |
739 else | |
740 return false; | |
741 } | |
742 | |
743 | |
744 //----- (004645FA) -------------------------------------------------------- | |
745 void Game::Deinitialize() | |
746 { | |
747 struct tagRECT Rect; // [sp+0h] [bp-10h]@6 | |
748 | |
749 if (pAsyncMouse) | |
750 pAsyncMouse->Suspend(); | |
751 if (pGame->pKeyboardInstance->bUsingAsynKeyboard && pAsyncKeyboard) | |
752 pAsyncKeyboard->Suspend(); | |
753 WriteWindowsRegistryInt("startinwindow", pRenderer->bWindowMode); | |
754 if ( GetWindowRect(hWnd, &Rect) && pRenderer->bWindowMode ) | |
755 { | |
756 WriteWindowsRegistryInt("window X", Rect.left); | |
757 WriteWindowsRegistryInt("window Y", Rect.top); | |
758 } | |
759 WriteWindowsRegistryInt("valAlwaysRun", bAlwaysRun); | |
760 pItemsTable->Release(); | |
761 pNPCStats->Release(); | |
762 if (pAsyncKeyboard) | |
763 pAsyncKeyboard->Release(); | |
764 if (pAsyncMouse) | |
765 pAsyncMouse->Release(); | |
766 if (pMouse) | |
767 pMouse->Deactivate(); | |
768 | |
769 pAudioPlayer->Release();//error | |
770 pNew_LOD->FreeSubIndexAndIO(); | |
771 pGames_LOD->FreeSubIndexAndIO(); | |
772 ClipCursor(0); | |
773 Game::Destroy(); | |
774 } | |
775 | |
776 //----- (0044EE7C) -------------------------------------------------------- | |
777 bool Game::draw_debug_outlines() | |
778 { | |
779 if (uFlags & 0x04) | |
780 { | |
781 pLightmapBuilder->DrawDebugOutlines(-1); | |
782 pDecalBuilder->DrawDecalDebugOutlines(); | |
783 } | |
784 return true; | |
785 } | |
786 | |
787 //----- (0044EC23) -------------------------------------------------------- | |
788 int Game::_44EC23(stru148 *a2, int *a3, signed int a4) | |
789 { | |
790 double v4; // st7@4 | |
791 //double v5; // ST00_8@4 | |
792 signed int v6; // eax@5 | |
793 //double v7; // ST00_8@6 | |
794 signed int result; // eax@8 | |
795 //double v9; // ST00_8@9 | |
796 //double v10; // ST00_8@11 | |
797 float a2a; // [sp+14h] [bp+8h]@4 | |
798 float a3a; // [sp+18h] [bp+Ch]@4 | |
799 float a3b; // [sp+18h] [bp+Ch]@6 | |
800 float a4a; // [sp+1Ch] [bp+10h]@9 | |
801 float a4b; // [sp+1Ch] [bp+10h]@11 | |
802 | |
803 if ( this->uFlags2 & 2 && a2->field_59 == 5 && a2->pODMFace->uAttributes & 2 ) | |
804 { | |
805 v4 = (double)a4; | |
806 a2a = v4; | |
807 *a3 |= 2u; | |
808 a3a = (1.0 - this->fSaturation) * v4; | |
809 //v5 = a3a + 6.7553994e15; | |
810 //if ( SLODWORD(v5) >= 0 ) | |
811 if (floorf(a3a + 0.5f) >= 0 ) | |
812 { | |
813 a3b = (1.0 - this->fSaturation) * a2a; | |
814 //v7 = a3b + 6.7553994e15; | |
815 //v6 = LODWORD(v7); | |
816 v6 = floorf(a3b + 0.5f); | |
817 } | |
818 else | |
819 { | |
820 v6 = 0; | |
821 } | |
822 if ( a4 >= v6 ) | |
823 { | |
824 a4a = (1.0 - fSaturation) * a2a; | |
825 //v9 = a4a + 6.7553994e15; | |
826 //if ( SLODWORD(v9) >= 0 ) | |
827 if (floorf(a4a + 0.5f) >= 0) | |
828 { | |
829 a4b = (1.0 - fSaturation) * a2a; | |
830 //v10 = a4b + 6.7553994e15; | |
831 //result = LODWORD(v10); | |
832 result = floorf(a4b + 0.5f); | |
833 } | |
834 else | |
835 { | |
836 result = 0; | |
837 } | |
838 } | |
839 else | |
840 { | |
841 result = a4; | |
842 } | |
843 } | |
844 else | |
845 { | |
846 result = -1; | |
847 } | |
848 return result; | |
849 } | |
850 | |
851 | |
852 | |
853 //----- (00465C8B) -------------------------------------------------------- | |
854 Game *Game::Create() | |
855 { | |
856 return new Game; | |
857 } | |
858 | |
859 //----- (00465CF3) -------------------------------------------------------- | |
860 void Game::Destroy() | |
861 { | |
862 if (pGame) | |
863 delete pGame; | |
864 pGame = nullptr; | |
865 } | |
866 | |
867 //----- (0044ED0A) -------------------------------------------------------- | |
868 signed int Game::_44ED0A(BLVFace *a2, int *a3, signed int a4) | |
869 { | |
870 double v4; // st7@3 | |
871 //double v5; // ST00_8@3 | |
872 signed int v6; // eax@4 | |
873 //double v7; // ST00_8@5 | |
874 signed int result; // eax@7 | |
875 //double v9; // ST00_8@8 | |
876 //double v10; // ST00_8@10 | |
877 float v11; // [sp+14h] [bp+8h]@3 | |
878 float v12; // [sp+18h] [bp+Ch]@3 | |
879 float v13; // [sp+18h] [bp+Ch]@5 | |
880 float v14; // [sp+1Ch] [bp+10h]@8 | |
881 float v15; // [sp+1Ch] [bp+10h]@10 | |
882 | |
883 if ( this->uFlags2 & 2 && a2->uAttributes & 2 ) | |
884 { | |
885 v4 = (double)a4; | |
886 v11 = v4; | |
887 *a3 |= 2u; | |
888 v12 = (1.0 - this->fSaturation) * v4; | |
889 //v5 = v12 + 6.7553994e15; | |
890 if (floorf(v12 + 0.5f)/* SLODWORD(v5)*/ >= 0 ) | |
891 { | |
892 v13 = (1.0 - this->fSaturation) * v11; | |
893 //v7 = v13 + 6.7553994e15; | |
894 //v6 = LODWORD(v7); | |
895 v6 = floorf(v13 + 0.5f); | |
896 } | |
897 else | |
898 { | |
899 v6 = 0; | |
900 } | |
901 if ( a4 >= v6 ) | |
902 { | |
903 v14 = (1.0 - fSaturation) * v11; | |
904 //v9 = v14 + 6.7553994e15; | |
905 if (floorf(v14 + 0.5f)/* SLODWORD(v9)*/ >= 0 ) | |
906 { | |
907 v15 = (1.0 - fSaturation) * v11; | |
908 //v10 = v15 + 6.7553994e15; | |
909 //result = LODWORD(v10); | |
910 result = floorf(v15 + 0.5f); | |
911 } | |
912 else | |
913 { | |
914 result = 0; | |
915 } | |
916 } | |
917 else | |
918 { | |
919 result = a4; | |
920 } | |
921 } | |
922 else | |
923 { | |
924 result = -1; | |
925 } | |
926 return result; | |
927 } | |
928 | |
929 | |
930 //----- (0044E4B7) -------------------------------------------------------- | |
931 Game::Game() | |
932 { | |
933 uNumStationaryLights = 0; | |
934 uNumBloodsplats = 0; | |
935 field_E0C = 0; | |
936 field_E10 = 0; | |
937 uNumStationaryLights_in_pStationaryLightsStack = 0; | |
938 bGammaControlInitialized = false; | |
939 uFlags = 0; | |
940 uFlags2 = 0; | |
941 uSomeGammaStartTime = 0; | |
942 uSomeGammaDeltaTime = 0; | |
943 | |
944 pThreadWardInstance = new ThreadWard; | |
945 pParticleEngine = new ParticleEngine; | |
946 pMouse = pMouseInstance = new Mouse(pThreadWardInstance); | |
947 pLightmapBuilder = new LightmapBuilder; | |
948 pVisInstance = new Vis; | |
949 pStru6Instance = new stru6; | |
950 pIndoorCameraD3D = new IndoorCameraD3D; | |
951 pStru9Instance = new stru9; | |
952 pStru10Instance = new stru10; | |
953 pStru11Instance = new stru11; | |
954 pStru12Instance = new stru12(pStru11Instance); | |
955 pCShow = new CShow; | |
956 pKeyboardInstance = new Keyboard; | |
957 pGammaController = new GammaController; | |
958 | |
959 uFlags |= 0x0800; | |
960 uFlags2 |= 0x24; | |
961 | |
962 _44F0FD(); | |
963 | |
964 bWinNT4_0 = false; | |
965 if (pVersion->pVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && | |
966 pVersion->pVersionInfo.dwMajorVersion == 4) | |
967 bWinNT4_0 = true; | |
968 } | |
969 | |
970 //----- (0044E7F3) -------------------------------------------------------- | |
971 Game::~Game() | |
972 { | |
973 if (pGammaController) | |
974 delete pGammaController; | |
975 if (pKeyboardInstance) | |
976 delete pKeyboardInstance; | |
977 if (pCShow) | |
978 delete pCShow; | |
979 if (pStru12Instance) | |
980 delete pStru12Instance; | |
981 if (pStru11Instance) | |
982 delete pStru11Instance; | |
983 if (pStru10Instance) | |
984 delete pStru10Instance; | |
985 if (pStru9Instance) | |
986 delete pStru9Instance; | |
987 if (pIndoorCameraD3D) | |
988 delete pIndoorCameraD3D; | |
989 if (pStru6Instance) | |
990 delete pStru6Instance; | |
991 if (pVisInstance) | |
992 delete pVisInstance; | |
993 if (pLightmapBuilder) | |
994 delete pLightmapBuilder; | |
995 if (pMouseInstance) | |
996 delete pMouseInstance; | |
997 if (pParticleEngine) | |
998 delete pParticleEngine; | |
999 if (pThreadWardInstance) | |
1000 delete pThreadWardInstance; | |
1001 } | |
1002 | |
1003 //----- (0044E904) -------------------------------------------------------- | |
1004 void Game::_44E904() | |
1005 { | |
1006 //Game *v1; // esi@1 | |
1007 unsigned __int64 v2; // qax@1 | |
1008 unsigned int v3; // ecx@1 | |
1009 int v4; // edi@1 | |
1010 unsigned __int8 v5; // cf@7 | |
1011 double v6; // st7@13 | |
1012 double v7; // st7@15 | |
1013 signed __int64 v8; // [sp+Ch] [bp-8h]@1 | |
1014 | |
1015 //v1 = this; | |
1016 v2 = pEventTimer->Time(); | |
1017 v4 = (v2 - uSomeGammaStartTime) >> 32; | |
1018 v3 = v2 - LODWORD(uSomeGammaStartTime); | |
1019 v8 = v2 - uSomeGammaStartTime; | |
1020 if ( v4 < 0 | |
1021 || SHIDWORD(v2) < ((unsigned int)v2 < LODWORD(uSomeGammaStartTime)) + HIDWORD(uSomeGammaStartTime) | v4 == 0 | |
1022 && v3 <= 0x80 ) | |
1023 { | |
1024 if ( v4 > 0 || v4 >= 0 ) | |
1025 goto LABEL_12; | |
1026 v3 = 0; | |
1027 v4 = 0; | |
1028 } | |
1029 else | |
1030 { | |
1031 if ( uSomeGammaDeltaTime ) | |
1032 { | |
1033 LODWORD(uSomeGammaDeltaTime) = 0; | |
1034 HIDWORD(uSomeGammaDeltaTime) = 0; | |
1035 } | |
1036 else | |
1037 { | |
1038 LODWORD(uSomeGammaDeltaTime) = v3; | |
1039 HIDWORD(uSomeGammaDeltaTime) = v4; | |
1040 } | |
1041 v5 = __CFADD__(v3, -128); | |
1042 v3 -= 128; | |
1043 v4 = v5 + v4 - 1; | |
1044 } | |
1045 uSomeGammaStartTime = v2; | |
1046 v8 = __PAIR__(v4, v3); | |
1047 LABEL_12: | |
1048 if ( uSomeGammaDeltaTime ) | |
1049 v6 = (double)(signed __int64)(uSomeGammaDeltaTime - __PAIR__(v4, v3)); | |
1050 else | |
1051 v6 = (double)v8; | |
1052 v7 = v6 * 0.0078125; | |
1053 if ( v7 < 0.0 || v7 <= 1.0 ) | |
1054 { | |
1055 if ( v7 < 0.0 ) | |
1056 v7 = 0.0; | |
1057 } | |
1058 else | |
1059 { | |
1060 v7 = 1.0; | |
1061 } | |
1062 if ( pRenderer->pRenderD3D ) | |
1063 fSaturation = v7; | |
1064 else | |
1065 fSaturation = (1.0 - 0.5) * v7 + 0.5; | |
1066 } | |
1067 | |
1068 //----- (0044EA17) -------------------------------------------------------- | |
1069 bool Game::InitializeGammaController() | |
1070 { | |
1071 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
1072 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
1073 pGammaController->InitializeFromSurface(pRenderer->pFrontBuffer4); | |
1074 | |
1075 bGammaControlInitialized = true; | |
1076 uSomeGammaStartTime = pEventTimer->Time(); | |
1077 return true; | |
1078 } | |
1079 | |
1080 //----- (0044EA5E) -------------------------------------------------------- | |
194 | 1081 bool Game::PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) |
0 | 1082 { |
227 | 1083 if (pCurrentScreen != SCREEN_GAME|| !pRenderer->pRenderD3D) |
194 | 1084 return false; |
0 | 1085 |
194 | 1086 if (!pVisInstance) |
0 | 1087 { |
194 | 1088 MessageBoxW(nullptr, L"The 'Vis' object pointer has not been instatiated, but CGame::Pick() is trying to call through it.", nullptr, 0); |
1089 return false; | |
1090 } | |
0 | 1091 |
692 | 1092 if (uMouseX >= (signed int)pViewport->uScreen_TL_X && |
1093 uMouseX <= (signed int)pViewport->uScreen_BR_X && | |
1094 uMouseY >= (signed int)pViewport->uScreen_TL_Y && | |
1095 uMouseY <= (signed int)pViewport->uScreen_BR_Y) | |
194 | 1096 { |
1097 pVisInstance->PickMouse(fPickDepth, uMouseX, uMouseY, sprite_filter, face_filter); | |
0 | 1098 |
194 | 1099 if (bOutline) |
1100 OutlineSelection(); | |
0 | 1101 } |
194 | 1102 |
1103 return true; | |
0 | 1104 } |
1105 // 4E28F8: using guessed type int pCurrentScreen; | |
1106 | |
1107 //----- (0044EB12) -------------------------------------------------------- | |
194 | 1108 bool Game::PickKeyboard(bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) |
0 | 1109 { |
271 | 1110 if (pCurrentScreen == SCREEN_GAME && pVisInstance && pRenderer->pRenderD3D) |
0 | 1111 { |
194 | 1112 bool r = pVisInstance->PickKeyboard(&pVisInstance->default_list, sprite_filter, face_filter); |
0 | 1113 |
1114 if (bOutline) | |
1115 OutlineSelection(); | |
1116 return r; | |
1117 } | |
1118 return false; | |
1119 } | |
123 | 1120 /* |
1121 Result::Code Game::PickKeyboard(bool bOutline, struct unnamed_F93E6C *a3, struct unnamed_F93E6C *a4) | |
1122 { | |
1123 if (dword_4E28F8_PartyCantJumpIfTrue) | |
1124 return Result::Generic; | |
1125 | |
1126 pVis->PickKeyboard(a3, a4); | |
1127 if (bOutline) | |
1128 Game_outline_selection((int)this); | |
1129 return Result::Success; | |
1130 } | |
1131 */ | |
0 | 1132 // 4E28F8: using guessed type int pCurrentScreen; |
1133 | |
1134 //----- (0044EB5A) -------------------------------------------------------- | |
1135 void Game::OutlineSelection() | |
1136 { | |
194 | 1137 if (!pVisInstance) |
1138 return; | |
1139 | |
1140 if (!pVisInstance->default_list.uNumPointers) | |
1141 return; | |
0 | 1142 |
194 | 1143 auto object_info = pVisInstance->default_list.object_pointers[0]; |
1144 if (object_info) | |
1145 switch (object_info->object_type) | |
0 | 1146 { |
194 | 1147 case VisObjectType_Sprite: |
0 | 1148 { |
194 | 1149 Log::Warning(L"Sprite outline currently unsupported"); |
1150 return; | |
0 | 1151 } |
1152 | |
194 | 1153 case VisObjectType_Face: |
1154 { | |
1155 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
0 | 1156 { |
194 | 1157 auto face = (ODMFace *)object_info->object; |
1158 if (face->uAttributes & FACE_OUTLINED) | |
1159 face->uAttributes &= ~FACE_OUTLINED; | |
0 | 1160 else |
194 | 1161 face->uAttributes |= FACE_OUTLINED; |
1162 } | |
1163 else if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
1164 { | |
1165 auto face = (BLVFace *)object_info->object; | |
1166 if (face->uAttributes & FACE_OUTLINED) | |
1167 face->uAttributes &= ~FACE_OUTLINED; | |
1168 else | |
1169 face->uAttributes |= FACE_OUTLINED; | |
0 | 1170 } |
194 | 1171 else assert(false); |
1172 } | |
323 | 1173 break; |
194 | 1174 |
1175 default: | |
1176 { | |
1177 MessageBoxW(nullptr, L"Undefined CObjectInfo type requested in CGame::outline_selection()", nullptr, 0); | |
1178 ExitProcess(0); | |
1179 } | |
0 | 1180 } |
1181 } |