Mercurial > mm7
annotate Game.cpp @ 816:cfc65feef029
* Player Recovery Times
* Player Attack fixes
* Debug log to timers
author | Nomad |
---|---|
date | Tue, 26 Mar 2013 12:40:27 +0200 |
parents | 9a3121bbc1d0 |
children | 9c3f28b31b4a |
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 "stru279.h" | |
13 #include "AudioPlayer.h" | |
14 #include "LOD.h" | |
15 #include "OSInfo.h" | |
16 #include "GUIWindow.h" | |
17 #include "Party.h" | |
18 #include "TurnEngine.h" | |
19 #include "VideoPlayer.h" | |
20 #include "Bink_Smacker.h" | |
21 #include "Events.h" | |
22 #include "Arcomage.h" | |
189 | 23 #include "texts.h" |
194 | 24 #include "Actor.h" |
791 | 25 #include "GUIFont.h" |
194 | 26 #include "Log.h" |
0 | 27 |
28 //#include "MM7.h" | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 Game *pGame; | |
36 | |
37 | |
38 | |
39 | |
40 | |
41 //----- (00435694) -------------------------------------------------------- | |
42 void Game::ToggleFlags2(unsigned int uFlag) | |
43 { | |
44 unsigned int v2; // eax@1 | |
45 | |
46 v2 = this->uFlags2; | |
47 if ( v2 & uFlag ) | |
48 this->uFlags2 = v2 & ~uFlag; | |
49 else | |
50 this->uFlags2 = uFlag | v2; | |
51 } | |
52 | |
53 //----- (0044103C) -------------------------------------------------------- | |
54 void Game::Draw() | |
55 { | |
142 | 56 //float v2; // ST24_4@11 |
0 | 57 //double v3; // ST28_8@11 |
58 int v4; // edi@26 | |
142 | 59 //int v5; // eax@35 |
0 | 60 |
61 uFlags2 &= 0xFFFFFFFDu; | |
62 if ( pParty->_497FC5_check_party_perception_against_level() ) | |
63 uFlags2 |= 2u; | |
64 pIndoorCamera->sRotationX = pParty->sRotationX; | |
65 pIndoorCamera->sRotationY = pParty->sRotationY; | |
120 | 66 //pIndoorCamera->pos.x = pParty->vPosition.x - ((__int64)pParty->y_rotation_granularity * stru_5C6E00->SinCos(pIndoorCamera->sRotationY)) / 2048.0;//12552 |
67 //pIndoorCamera->pos.y = pParty->vPosition.y - ((__int64)pParty->y_rotation_granularity * stru_5C6E00->SinCos(pIndoorCamera->sRotationY)) / 2048.0;//800 | |
68 pIndoorCamera->pos.x = pParty->vPosition.x - pParty->y_rotation_granularity * cosf(2 * 3.141592653589 * pIndoorCamera->sRotationY / 2048.0); | |
69 pIndoorCamera->pos.y = pParty->vPosition.y - pParty->y_rotation_granularity * sinf(2 * 3.141592653589 * pIndoorCamera->sRotationY / 2048.0); | |
66 | 70 pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel;//193, but real 353 |
0 | 71 pIndoorCamera->Initialize2(); |
72 pIndoorCameraD3D->CreateWorldMatrixAndSomeStuff(); | |
73 pIndoorCameraD3D->_4374E8_ProllyBuildFrustrum(); | |
74 | |
75 if ( pVideoPlayer->AnyMovieLoaded() ) | |
76 { | |
77 if ( pRenderer->pRenderD3D ) | |
78 goto LABEL_22; | |
79 pRenderer->BeginSceneD3D(); | |
80 pMouse->DrawCursorToTarget(); | |
81 } | |
82 else | |
83 { | |
78 | 84 if ( pParty->vPosition.x != pParty->vPrevPosition.x | pParty->sRotationY != pParty->sPrevRotationY | pParty->vPosition.y != pParty->vPrevPosition.y |
101 | 85 | pParty->sRotationX != pParty->sPrevRotationX | pParty->vPosition.z != pParty->vPrevPosition.z | pParty->sEyelevel != pParty->sPrevEyelevel ) |
0 | 86 pParty->uFlags |= 2u; |
78 | 87 pParty->vPrevPosition = pParty->vPosition; |
88 pParty->vPrevPosition.y = pParty->vPosition.y; | |
0 | 89 //v0 = &pRenderer; |
90 pParty->sPrevRotationY = pParty->sRotationY; | |
78 | 91 pParty->vPrevPosition.z = pParty->vPosition.z; |
0 | 92 pParty->sPrevRotationX = pParty->sRotationX; |
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); | |
202 pPrimaryWindow->DrawText(pFontArrus, 494, 0, GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0), pTmpBuf, 0, 0, 0); | |
203 } | |
204 | |
791 | 205 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) |
206 { | |
207 sprintf(pTmpBuf, "Party Sector ID: %u/%u\n", pBLVRenderParams->uPartySectorID, pIndoor->uNumSectors); | |
208 pPrimaryWindow->DrawText(pFontArrus, 16, 16, GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF); | |
209 } | |
210 sprintf(pTmpBuf, "Party Position: % d % d % d", pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
211 pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16, GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF); | |
212 | |
213 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
214 { | |
215 uint uFaceID; | |
216 auto floor_level = BLV_GetFloorLevel(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z, pBLVRenderParams->uPartySectorID, &uFaceID); | |
217 sprintf(pTmpBuf, "BLV_GetFloorLevel: %d face_id %d\n", floor_level, uFaceID); | |
218 } | |
219 else | |
220 { | |
221 int on_water, _a6; | |
222 auto floor_level = ODM_GetFloorLevel(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z, 0, &on_water, &_a6, false); | |
223 sprintf(pTmpBuf, "ODM_GetFloorLevel: %d on_water: %s a6 = %d\n", floor_level, on_water ? "true" : "false", _a6); | |
224 } | |
225 pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16 + 16, GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF); | |
226 | |
0 | 227 GUI_UpdateWindows(); |
130 | 228 pParty->UpdatePlayersAndHirelingsEmotions(); |
0 | 229 ++stru_51076C.field_8; |
434 | 230 _unused_5B5924_is_travel_ui_drawn = false; |
0 | 231 if (v4) |
791 | 232 pMouse->bRedraw = true; |
0 | 233 pMouse->_469EA4(); |
234 pMouse->DrawCursor(); | |
235 pMouse->_469E1C(); | |
236 pRenderer->EndScene(); | |
237 pRenderer->Present(); | |
569 | 238 pParty->uFlags &= ~2; |
0 | 239 } |
240 | |
241 //----- (0047A815) -------------------------------------------------------- | |
242 void Game::DrawParticles() | |
243 { | |
244 pParticleEngine->Draw(); | |
245 } | |
246 | |
247 //----- (00463149) -------------------------------------------------------- | |
248 void Game::Loop() | |
249 { | |
250 //signed int v0; // ebp@3 | |
251 //signed int v1; // esi@4 | |
252 //Render *v2; // edi@7 | |
253 //signed int v3; // esi@7 | |
254 signed int pNewNPCsCount; // ecx@58 | |
255 char *pFlags; // eax@59 | |
256 Player *pPlayer; // esi@65 | |
257 OtherOverlay *pOtherOverlay; // esi@67 | |
258 signed int v8; // edi@67 | |
259 int pPlayerNum; // edi@69 | |
260 int *pHealth; // esi@71 | |
261 signed int v11; // esi@78 | |
262 int v12; // eax@83 | |
263 const char *pLocationName; // [sp-4h] [bp-68h]@74 | |
264 bool bLoading; // [sp+10h] [bp-54h]@1 | |
265 signed int bLoadinga; // [sp+10h] [bp-54h]@19 | |
266 signed int v16; // [sp+14h] [bp-50h]@8 | |
267 int v17[4]; // [sp+18h] [bp-4Ch]@80 | |
268 MSG Msg; // [sp+28h] [bp-3Ch]@20 | |
269 char Source[64]; // [sp+44h] [bp-20h]@76 | |
270 | |
165 | 271 bLoading = uCurrentMenuID == MENU_LOADINGPROC; |
0 | 272 SetCurrentMenuID((MENU_STATE)-1); |
273 if (bLoading) | |
274 { | |
275 pParty->Reset(); | |
276 dword_6BE340 = 0; | |
277 uGameState = 0; | |
278 LoadGame(uLoadGameUI_SelectedSlot); | |
279 } | |
280 | |
281 for (uint i = 1; i < 5; ++i) | |
282 for (uint j = 1; j < 6; ++j) | |
283 { | |
284 sprintf(pTmpBuf, "data\\lloyd%d%d.pcx", i, j); | |
285 remove(pTmpBuf); | |
286 } | |
287 | |
288 LoadPlayerPortraintsAndVoices(); | |
783 | 289 pIcons_LOD->_inlined_sub1(); |
328 | 290 pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); |
0 | 291 |
292 while ( 2 ) | |
293 { | |
294 v16 = 1; | |
783 | 295 pMessageQueue_50CBD0->Flush(); |
0 | 296 |
297 pPartyActionQueue->uNumActions = 0; | |
298 if (pParty->bTurnBasedModeOn) | |
299 { | |
300 pTurnEngine->End(false); | |
301 pParty->bTurnBasedModeOn = false; | |
302 } | |
303 DoPrepareWorld(bLoading, 1); | |
304 pEventTimer->Resume(); | |
305 dword_6BE364_game_settings_1 |= 0x80; | |
306 dword_6BE340 = 2; | |
307 // uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0; | |
151 | 308 pCurrentScreen = SCREEN_GAME; |
0 | 309 if (pAsyncMouse) |
310 pAsyncMouse->Resume(); | |
311 if (pGame->pKeyboardInstance->bUsingAsynKeyboard && pAsyncKeyboard ) | |
312 pAsyncKeyboard->Resume(); | |
313 if ( pRenderer->pRenderD3D ) | |
314 pGame->pVisInstance->_4C1A02(); | |
315 bLoadinga = 0; | |
316 do | |
317 { | |
318 while ( PeekMessageA(&Msg, 0, 0, 0, PM_REMOVE) ) | |
319 { | |
320 if ( Msg.message == WM_QUIT ) | |
321 Game_DeinitializeAndTerminate(0); | |
322 TranslateMessage(&Msg); | |
323 DispatchMessageA(&Msg); | |
324 } | |
325 if (dword_6BE364_game_settings_1 & 0x0100 ) | |
326 { | |
327 WaitMessage(); | |
328 continue; | |
329 } | |
330 pGame->_44EEA7(); | |
331 GameUI_WritePointedObjectStatusString(); | |
332 ProcessInputActions(); | |
333 GameUI_MsgProc(); | |
334 if ( pArcomageGame->bGameInProgress ) | |
335 { | |
336 ArcomageGame::Loop(); | |
337 pRenderer->Present(); | |
338 continue; | |
339 } | |
340 if (pAsyncMouse) | |
341 pAsyncMouse->_46B736_consume_click_lists(1); | |
342 if ( pVideoPlayer->pSmackerMovie && !SmackWait(pVideoPlayer->pSmackerMovie) ) | |
343 { | |
344 pRenderer->BeginScene(); | |
345 pMouse->DrawCursorToTarget(); | |
346 pVideoPlayer->SmackUpdatePalette(pVideoPlayer->hWindow); | |
347 pMouse->_469EA4(); | |
348 pRenderer->EndScene(); | |
349 } | |
350 if ( pVideoPlayer->pBinkMovie && !BinkWait(pVideoPlayer->pBinkMovie) ) | |
351 { | |
352 pRenderer->BeginScene(); | |
353 pMouse->DrawCursorToTarget(); | |
354 pVideoPlayer->BinkUpdatePalette(pVideoPlayer->hWindow); | |
355 pMouse->_469EA4(); | |
356 pRenderer->EndScene(); | |
357 } | |
816 | 358 |
359 static int gtc_old = GetTickCount(); | |
360 int gtc = GetTickCount(); | |
361 auto evt_old = pEventTimer->uStartTime, | |
362 msc_old = pMiscTimer->uStartTime; | |
0 | 363 pEventTimer->Update(); |
364 pMiscTimer->Update(); | |
816 | 365 Log::Warning(L"Evt/Msc/GTC dt: %u/%u/%u", pEventTimer->uTimeElapsed, pMiscTimer->uTimeElapsed, gtc - gtc_old); |
366 gtc_old = gtc; | |
367 | |
0 | 368 OnTimer(0); |
369 GameUI_StatusBar_UpdateTimedString(0); | |
370 if ( pMiscTimer->bPaused && !pEventTimer->bPaused ) | |
371 pMiscTimer->Resume(); | |
372 if ( pEventTimer->bTackGameTime && !pParty->bTurnBasedModeOn ) | |
373 pEventTimer->bTackGameTime = 0; | |
374 if ( !pEventTimer->bPaused && !uGameState ) | |
375 { | |
376 if ( !pEventTimer->bTackGameTime ) | |
377 _494035_timed_effects__water_walking_damage__etc(); | |
378 if ( dword_6BE364_game_settings_1 & 1 ) | |
379 { | |
380 dword_6BE364_game_settings_1 &= 0xFFFFFFFEu; | |
381 } | |
382 else | |
383 { | |
783 | 384 UpdateActorAI(); |
385 UpdateUserInput_and_MapSpecificStuff(); | |
0 | 386 } |
387 } | |
388 if ( v16 ) | |
389 { | |
390 v16 = 0; | |
391 viewparams->bRedrawGameUI = true; | |
392 } | |
378 | 393 pAudioPlayer->UpdateSounds(); |
0 | 394 if (uGameState == 1) |
395 //goto LABEL_96; | |
4 | 396 { |
397 bLoadinga = 1; | |
0 | 398 continue; |
4 | 399 } |
0 | 400 if (uGameState == 2) |
401 { | |
402 pAudioPlayer->StopChannels(-1, -1); | |
403 PrepareWorld(0); | |
404 uGameState = 0; | |
405 continue; | |
406 } | |
407 if ( (signed int)uGameState <= 2 ) | |
408 //goto LABEL_85; | |
4 | 409 { |
410 pGame->Draw(); | |
0 | 411 continue; |
4 | 412 } |
0 | 413 if ( (signed int)uGameState <= 5 || uGameState == 7 ) |
414 { | |
415 //LABEL_96: | |
416 bLoadinga = 1; | |
417 continue; | |
418 } | |
419 if ( uGameState != 8 ) | |
420 { | |
421 if ( uGameState != 9 ) | |
422 { | |
423 //LABEL_85: | |
424 pGame->Draw(); | |
425 continue; | |
426 } | |
427 pRenderer->BeginScene(); | |
428 GUI_UpdateWindows(); | |
429 pRenderer->EndScene(); | |
430 //goto LABEL_89; | |
4 | 431 pRenderer->Present(); |
0 | 432 continue; |
433 } | |
4 | 434 pAudioPlayer->StopChannels(-1, -1);//äàëåå â ñëó÷àå ñìåðòè ãðóïïû |
293 | 435 memset(&pParty->pHirelings[0], 0, 0x4Cu); |
0 | 436 memset(&pParty->pHirelings[1], 0, 0x4Cu); |
437 pNewNPCsCount = 0; | |
438 if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) | |
439 { | |
440 pFlags = (char *)&pNPCStats->pNewNPCData[0].uFlags; | |
441 do | |
442 { | |
443 if ( *((int *)pFlags + 6) ) | |
444 *pFlags &= 0x7Fu; | |
445 ++pNewNPCsCount; | |
446 pFlags += 76; | |
447 } | |
448 while ( pNewNPCsCount < (signed int)pNPCStats->uNumNewNPCs ); | |
449 } | |
450 pVideoPlayer->PlayDeathMovie(); | |
451 if ( pVideoPlayer->AnyMovieLoaded() ) | |
452 pVideoPlayer->Unload(); | |
453 SaveGame(0, 0); | |
454 ++pParty->uNumDeaths; | |
455 pPlayer = pParty->pPlayers; | |
456 do | |
457 { | |
458 pPlayer->SetVariable(VAR_Award, 85); | |
459 ++pPlayer; | |
460 } | |
461 while ( (signed int)pPlayer < (signed int)pParty->pHirelings ); | |
766 | 462 pParty->days_played_without_rest = 0; |
0 | 463 pParty->uTimePlayed += 0x276000ui64; |
569 | 464 LOWORD(pParty->uFlags) &= ~0x204; |
0 | 465 pParty->SetGold(0); |
466 pOtherOverlay = pOtherOverlayList->pOverlays; | |
467 v8 = 50; | |
468 do | |
469 { | |
470 pOtherOverlay->Reset(); | |
471 ++pOtherOverlay; | |
472 --v8; | |
473 } | |
474 while ( v8 ); | |
475 memset(pParty->pPartyBuffs, 0, 0x140u); | |
476 pPlayerNum = 1; | |
477 if ( pParty->bTurnBasedModeOn == 1 ) | |
478 { | |
479 pTurnEngine->End(1); | |
480 pParty->bTurnBasedModeOn = 0; | |
481 } | |
440 | 482 //pHealth = &pParty->pPlayers[0].sHealth;//193C |
483 //do | |
484 for(int i=0; i<4; ++i) | |
0 | 485 { |
440 | 486 memset(pParty->pPlayers[i].pConditions, 0, 0xA0u);//(pConditions, 0, 160) |
487 memset(pParty->pPlayers[i].pPlayerBuffs, 0, 0x180u);//(pPlayerBuffs[0], 0, 384) | |
488 //*pHealth = 1; | |
489 pParty->pPlayers[i].sHealth=1; | |
490 //pHealth += 1743; //6CF | |
0 | 491 uActiveCharacter = 1; |
492 } | |
440 | 493 // while ( (signed int)pHealth < (signed int)&pParty->field_871C[567] ); |
484 | 494 if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 136) ) |
0 | 495 { |
496 pParty->vPosition.x = -17331; // respawn in harmondale | |
497 pParty->vPosition.y = 12547; | |
498 pParty->vPosition.z = 465; | |
499 pParty->sRotationY = 0; | |
500 pLocationName = "out02.odm"; | |
501 } | |
502 else | |
503 { | |
504 pParty->vPosition.x = 12552; // respawn on emerald isle | |
505 pParty->vPosition.y = 1816; | |
506 pParty->vPosition.z = 0; | |
507 pParty->sRotationY = 512; | |
508 pLocationName = "out01.odm"; | |
509 } | |
510 strcpy(Source, pLocationName); | |
511 pParty->uFallStartY = pParty->vPosition.z; | |
512 pParty->sRotationX = 0; | |
513 pParty->uFallSpeed = 0; | |
514 pParty->field_6E4 = 0; | |
515 pParty->field_6E0 = 0; | |
516 if ( _strcmpi(Source, pCurrentMapName) ) | |
517 { | |
518 strcpy(pCurrentMapName, Source); | |
519 _5B65A8_npcdata_uflags_or_other = pParty->vPosition.x; | |
520 _5B65AC_npcdata_fame_or_other = pParty->vPosition.y; | |
521 _5B65B0_npcdata_rep_or_other = pParty->vPosition.z; | |
522 _5B65B4_npcdata_loword_house_or_other = pParty->sRotationY; | |
523 _5B65B8_npcdata_hiword_house_or_other = pParty->sRotationX; | |
524 dword_5B65C0 = 1; | |
525 PrepareWorld(1); | |
526 } | |
527 InitializeActors(); | |
528 v11 = 0; | |
529 do | |
530 { | |
531 if ( pPlayers[pPlayerNum]->CanAct() ) | |
532 v17[v11++] = pPlayerNum; | |
533 ++pPlayerNum; | |
534 } | |
535 while ( pPlayerNum <= 4 ); | |
536 if ( v11 ) | |
537 { | |
538 v12 = rand(); | |
187 | 539 pPlayers[v17[v12 % v11]]->PlaySound(SPEECH_99, 0); |
0 | 540 } |
541 ShowStatusBarString(pGlobalTXT_LocalizationStrings[524], 2u);// "Once again you've cheated death!.." "Âû ñíîâà îáõèòðèëè ñìåðòü! …" | |
542 uGameState = 0; | |
543 } | |
544 while ( !bLoadinga ); | |
545 dword_6BE340 = 0; | |
546 pEventTimer->Pause(); | |
547 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); | |
548 if ( uGameState == 3 ) | |
549 { | |
550 sub_491E3A(); | |
551 LoadPlayerPortraintsAndVoices(); | |
552 uGameState = 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; | |
672 depth = 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("debug flags", stru_51076C.registry_debug_flags); | |
768 WriteWindowsRegistryInt("valAlwaysRun", bAlwaysRun); | |
769 pItemsTable->Release(); | |
770 pNPCStats->Release(); | |
771 if (pAsyncKeyboard) | |
772 pAsyncKeyboard->Release(); | |
773 if (pAsyncMouse) | |
774 pAsyncMouse->Release(); | |
775 if (pMouse) | |
776 pMouse->Deactivate(); | |
777 | |
778 pAudioPlayer->Release();//error | |
779 pNew_LOD->FreeSubIndexAndIO(); | |
780 pGames_LOD->FreeSubIndexAndIO(); | |
781 ClipCursor(0); | |
782 Game::Destroy(); | |
783 } | |
784 | |
785 //----- (0044EE7C) -------------------------------------------------------- | |
786 bool Game::draw_debug_outlines() | |
787 { | |
788 if (uFlags & 0x04) | |
789 { | |
790 pLightmapBuilder->DrawDebugOutlines(-1); | |
791 pDecalBuilder->DrawDecalDebugOutlines(); | |
792 } | |
793 return true; | |
794 } | |
795 | |
796 //----- (0044EC23) -------------------------------------------------------- | |
797 int Game::_44EC23(stru148 *a2, int *a3, signed int a4) | |
798 { | |
799 double v4; // st7@4 | |
800 //double v5; // ST00_8@4 | |
801 signed int v6; // eax@5 | |
802 //double v7; // ST00_8@6 | |
803 signed int result; // eax@8 | |
804 //double v9; // ST00_8@9 | |
805 //double v10; // ST00_8@11 | |
806 float a2a; // [sp+14h] [bp+8h]@4 | |
807 float a3a; // [sp+18h] [bp+Ch]@4 | |
808 float a3b; // [sp+18h] [bp+Ch]@6 | |
809 float a4a; // [sp+1Ch] [bp+10h]@9 | |
810 float a4b; // [sp+1Ch] [bp+10h]@11 | |
811 | |
812 if ( this->uFlags2 & 2 && a2->field_59 == 5 && a2->pODMFace->uAttributes & 2 ) | |
813 { | |
814 v4 = (double)a4; | |
815 a2a = v4; | |
816 *a3 |= 2u; | |
817 a3a = (1.0 - this->fSaturation) * v4; | |
818 //v5 = a3a + 6.7553994e15; | |
819 //if ( SLODWORD(v5) >= 0 ) | |
820 if (floorf(a3a + 0.5f) >= 0 ) | |
821 { | |
822 a3b = (1.0 - this->fSaturation) * a2a; | |
823 //v7 = a3b + 6.7553994e15; | |
824 //v6 = LODWORD(v7); | |
825 v6 = floorf(a3b + 0.5f); | |
826 } | |
827 else | |
828 { | |
829 v6 = 0; | |
830 } | |
831 if ( a4 >= v6 ) | |
832 { | |
833 a4a = (1.0 - fSaturation) * a2a; | |
834 //v9 = a4a + 6.7553994e15; | |
835 //if ( SLODWORD(v9) >= 0 ) | |
836 if (floorf(a4a + 0.5f) >= 0) | |
837 { | |
838 a4b = (1.0 - fSaturation) * a2a; | |
839 //v10 = a4b + 6.7553994e15; | |
840 //result = LODWORD(v10); | |
841 result = floorf(a4b + 0.5f); | |
842 } | |
843 else | |
844 { | |
845 result = 0; | |
846 } | |
847 } | |
848 else | |
849 { | |
850 result = a4; | |
851 } | |
852 } | |
853 else | |
854 { | |
855 result = -1; | |
856 } | |
857 return result; | |
858 } | |
859 | |
860 | |
861 | |
862 //----- (00465C8B) -------------------------------------------------------- | |
863 Game *Game::Create() | |
864 { | |
865 return new Game; | |
866 } | |
867 | |
868 //----- (00465CF3) -------------------------------------------------------- | |
869 void Game::Destroy() | |
870 { | |
871 if (pGame) | |
872 delete pGame; | |
873 pGame = nullptr; | |
874 } | |
875 | |
876 //----- (0044ED0A) -------------------------------------------------------- | |
877 signed int Game::_44ED0A(BLVFace *a2, int *a3, signed int a4) | |
878 { | |
879 double v4; // st7@3 | |
880 //double v5; // ST00_8@3 | |
881 signed int v6; // eax@4 | |
882 //double v7; // ST00_8@5 | |
883 signed int result; // eax@7 | |
884 //double v9; // ST00_8@8 | |
885 //double v10; // ST00_8@10 | |
886 float v11; // [sp+14h] [bp+8h]@3 | |
887 float v12; // [sp+18h] [bp+Ch]@3 | |
888 float v13; // [sp+18h] [bp+Ch]@5 | |
889 float v14; // [sp+1Ch] [bp+10h]@8 | |
890 float v15; // [sp+1Ch] [bp+10h]@10 | |
891 | |
892 if ( this->uFlags2 & 2 && a2->uAttributes & 2 ) | |
893 { | |
894 v4 = (double)a4; | |
895 v11 = v4; | |
896 *a3 |= 2u; | |
897 v12 = (1.0 - this->fSaturation) * v4; | |
898 //v5 = v12 + 6.7553994e15; | |
899 if (floorf(v12 + 0.5f)/* SLODWORD(v5)*/ >= 0 ) | |
900 { | |
901 v13 = (1.0 - this->fSaturation) * v11; | |
902 //v7 = v13 + 6.7553994e15; | |
903 //v6 = LODWORD(v7); | |
904 v6 = floorf(v13 + 0.5f); | |
905 } | |
906 else | |
907 { | |
908 v6 = 0; | |
909 } | |
910 if ( a4 >= v6 ) | |
911 { | |
912 v14 = (1.0 - fSaturation) * v11; | |
913 //v9 = v14 + 6.7553994e15; | |
914 if (floorf(v14 + 0.5f)/* SLODWORD(v9)*/ >= 0 ) | |
915 { | |
916 v15 = (1.0 - fSaturation) * v11; | |
917 //v10 = v15 + 6.7553994e15; | |
918 //result = LODWORD(v10); | |
919 result = floorf(v15 + 0.5f); | |
920 } | |
921 else | |
922 { | |
923 result = 0; | |
924 } | |
925 } | |
926 else | |
927 { | |
928 result = a4; | |
929 } | |
930 } | |
931 else | |
932 { | |
933 result = -1; | |
934 } | |
935 return result; | |
936 } | |
937 | |
938 | |
939 //----- (0044E4B7) -------------------------------------------------------- | |
940 Game::Game() | |
941 { | |
942 uNumStationaryLights = 0; | |
943 uNumBloodsplats = 0; | |
944 field_E0C = 0; | |
945 field_E10 = 0; | |
946 uNumStationaryLights_in_pStationaryLightsStack = 0; | |
947 bGammaControlInitialized = false; | |
948 uFlags = 0; | |
949 uFlags2 = 0; | |
950 uSomeGammaStartTime = 0; | |
951 uSomeGammaDeltaTime = 0; | |
952 | |
953 pThreadWardInstance = new ThreadWard; | |
954 pParticleEngine = new ParticleEngine; | |
955 pMouse = pMouseInstance = new Mouse(pThreadWardInstance); | |
956 pLightmapBuilder = new LightmapBuilder; | |
957 pVisInstance = new Vis; | |
958 pStru6Instance = new stru6; | |
959 pIndoorCameraD3D = new IndoorCameraD3D; | |
960 pStru9Instance = new stru9; | |
961 pStru10Instance = new stru10; | |
962 pStru11Instance = new stru11; | |
963 pStru12Instance = new stru12(pStru11Instance); | |
964 pCShow = new CShow; | |
965 pKeyboardInstance = new Keyboard; | |
966 pGammaController = new GammaController; | |
967 | |
968 uFlags |= 0x0800; | |
969 uFlags2 |= 0x24; | |
970 | |
971 _44F0FD(); | |
972 | |
973 bWinNT4_0 = false; | |
974 if (pVersion->pVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && | |
975 pVersion->pVersionInfo.dwMajorVersion == 4) | |
976 bWinNT4_0 = true; | |
977 } | |
978 | |
979 //----- (0044E7F3) -------------------------------------------------------- | |
980 Game::~Game() | |
981 { | |
982 if (pGammaController) | |
983 delete pGammaController; | |
984 if (pKeyboardInstance) | |
985 delete pKeyboardInstance; | |
986 if (pCShow) | |
987 delete pCShow; | |
988 if (pStru12Instance) | |
989 delete pStru12Instance; | |
990 if (pStru11Instance) | |
991 delete pStru11Instance; | |
992 if (pStru10Instance) | |
993 delete pStru10Instance; | |
994 if (pStru9Instance) | |
995 delete pStru9Instance; | |
996 if (pIndoorCameraD3D) | |
997 delete pIndoorCameraD3D; | |
998 if (pStru6Instance) | |
999 delete pStru6Instance; | |
1000 if (pVisInstance) | |
1001 delete pVisInstance; | |
1002 if (pLightmapBuilder) | |
1003 delete pLightmapBuilder; | |
1004 if (pMouseInstance) | |
1005 delete pMouseInstance; | |
1006 if (pParticleEngine) | |
1007 delete pParticleEngine; | |
1008 if (pThreadWardInstance) | |
1009 delete pThreadWardInstance; | |
1010 } | |
1011 | |
1012 //----- (0044E904) -------------------------------------------------------- | |
1013 void Game::_44E904() | |
1014 { | |
1015 //Game *v1; // esi@1 | |
1016 unsigned __int64 v2; // qax@1 | |
1017 unsigned int v3; // ecx@1 | |
1018 int v4; // edi@1 | |
1019 unsigned __int8 v5; // cf@7 | |
1020 double v6; // st7@13 | |
1021 double v7; // st7@15 | |
1022 signed __int64 v8; // [sp+Ch] [bp-8h]@1 | |
1023 | |
1024 //v1 = this; | |
1025 v2 = pEventTimer->Time(); | |
1026 v4 = (v2 - uSomeGammaStartTime) >> 32; | |
1027 v3 = v2 - LODWORD(uSomeGammaStartTime); | |
1028 v8 = v2 - uSomeGammaStartTime; | |
1029 if ( v4 < 0 | |
1030 || SHIDWORD(v2) < ((unsigned int)v2 < LODWORD(uSomeGammaStartTime)) + HIDWORD(uSomeGammaStartTime) | v4 == 0 | |
1031 && v3 <= 0x80 ) | |
1032 { | |
1033 if ( v4 > 0 || v4 >= 0 ) | |
1034 goto LABEL_12; | |
1035 v3 = 0; | |
1036 v4 = 0; | |
1037 } | |
1038 else | |
1039 { | |
1040 if ( uSomeGammaDeltaTime ) | |
1041 { | |
1042 LODWORD(uSomeGammaDeltaTime) = 0; | |
1043 HIDWORD(uSomeGammaDeltaTime) = 0; | |
1044 } | |
1045 else | |
1046 { | |
1047 LODWORD(uSomeGammaDeltaTime) = v3; | |
1048 HIDWORD(uSomeGammaDeltaTime) = v4; | |
1049 } | |
1050 v5 = __CFADD__(v3, -128); | |
1051 v3 -= 128; | |
1052 v4 = v5 + v4 - 1; | |
1053 } | |
1054 uSomeGammaStartTime = v2; | |
1055 v8 = __PAIR__(v4, v3); | |
1056 LABEL_12: | |
1057 if ( uSomeGammaDeltaTime ) | |
1058 v6 = (double)(signed __int64)(uSomeGammaDeltaTime - __PAIR__(v4, v3)); | |
1059 else | |
1060 v6 = (double)v8; | |
1061 v7 = v6 * 0.0078125; | |
1062 if ( v7 < 0.0 || v7 <= 1.0 ) | |
1063 { | |
1064 if ( v7 < 0.0 ) | |
1065 v7 = 0.0; | |
1066 } | |
1067 else | |
1068 { | |
1069 v7 = 1.0; | |
1070 } | |
1071 if ( pRenderer->pRenderD3D ) | |
1072 fSaturation = v7; | |
1073 else | |
1074 fSaturation = (1.0 - 0.5) * v7 + 0.5; | |
1075 } | |
1076 | |
1077 //----- (0044EA17) -------------------------------------------------------- | |
1078 bool Game::InitializeGammaController() | |
1079 { | |
1080 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
1081 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
1082 pGammaController->InitializeFromSurface(pRenderer->pFrontBuffer4); | |
1083 | |
1084 bGammaControlInitialized = true; | |
1085 uSomeGammaStartTime = pEventTimer->Time(); | |
1086 return true; | |
1087 } | |
1088 | |
1089 //----- (0044EA5E) -------------------------------------------------------- | |
194 | 1090 bool Game::PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) |
0 | 1091 { |
227 | 1092 if (pCurrentScreen != SCREEN_GAME|| !pRenderer->pRenderD3D) |
194 | 1093 return false; |
0 | 1094 |
194 | 1095 if (!pVisInstance) |
0 | 1096 { |
194 | 1097 MessageBoxW(nullptr, L"The 'Vis' object pointer has not been instatiated, but CGame::Pick() is trying to call through it.", nullptr, 0); |
1098 return false; | |
1099 } | |
0 | 1100 |
692 | 1101 if (uMouseX >= (signed int)pViewport->uScreen_TL_X && |
1102 uMouseX <= (signed int)pViewport->uScreen_BR_X && | |
1103 uMouseY >= (signed int)pViewport->uScreen_TL_Y && | |
1104 uMouseY <= (signed int)pViewport->uScreen_BR_Y) | |
194 | 1105 { |
1106 pVisInstance->PickMouse(fPickDepth, uMouseX, uMouseY, sprite_filter, face_filter); | |
0 | 1107 |
194 | 1108 if (bOutline) |
1109 OutlineSelection(); | |
0 | 1110 } |
194 | 1111 |
1112 return true; | |
0 | 1113 } |
1114 // 4E28F8: using guessed type int pCurrentScreen; | |
1115 | |
1116 //----- (0044EB12) -------------------------------------------------------- | |
194 | 1117 bool Game::PickKeyboard(bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) |
0 | 1118 { |
271 | 1119 if (pCurrentScreen == SCREEN_GAME && pVisInstance && pRenderer->pRenderD3D) |
0 | 1120 { |
194 | 1121 bool r = pVisInstance->PickKeyboard(&pVisInstance->default_list, sprite_filter, face_filter); |
0 | 1122 |
1123 if (bOutline) | |
1124 OutlineSelection(); | |
1125 return r; | |
1126 } | |
1127 return false; | |
1128 } | |
123 | 1129 /* |
1130 Result::Code Game::PickKeyboard(bool bOutline, struct unnamed_F93E6C *a3, struct unnamed_F93E6C *a4) | |
1131 { | |
1132 if (dword_4E28F8_PartyCantJumpIfTrue) | |
1133 return Result::Generic; | |
1134 | |
1135 pVis->PickKeyboard(a3, a4); | |
1136 if (bOutline) | |
1137 Game_outline_selection((int)this); | |
1138 return Result::Success; | |
1139 } | |
1140 */ | |
0 | 1141 // 4E28F8: using guessed type int pCurrentScreen; |
1142 | |
1143 //----- (0044EB5A) -------------------------------------------------------- | |
1144 void Game::OutlineSelection() | |
1145 { | |
194 | 1146 if (!pVisInstance) |
1147 return; | |
1148 | |
1149 if (!pVisInstance->default_list.uNumPointers) | |
1150 return; | |
0 | 1151 |
194 | 1152 auto object_info = pVisInstance->default_list.object_pointers[0]; |
1153 if (object_info) | |
1154 switch (object_info->object_type) | |
0 | 1155 { |
194 | 1156 case VisObjectType_Sprite: |
0 | 1157 { |
194 | 1158 Log::Warning(L"Sprite outline currently unsupported"); |
1159 return; | |
0 | 1160 } |
1161 | |
194 | 1162 case VisObjectType_Face: |
1163 { | |
1164 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
0 | 1165 { |
194 | 1166 auto face = (ODMFace *)object_info->object; |
1167 if (face->uAttributes & FACE_OUTLINED) | |
1168 face->uAttributes &= ~FACE_OUTLINED; | |
0 | 1169 else |
194 | 1170 face->uAttributes |= FACE_OUTLINED; |
1171 } | |
1172 else if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
1173 { | |
1174 auto face = (BLVFace *)object_info->object; | |
1175 if (face->uAttributes & FACE_OUTLINED) | |
1176 face->uAttributes &= ~FACE_OUTLINED; | |
1177 else | |
1178 face->uAttributes |= FACE_OUTLINED; | |
0 | 1179 } |
194 | 1180 else assert(false); |
1181 } | |
323 | 1182 break; |
194 | 1183 |
1184 default: | |
1185 { | |
1186 MessageBoxW(nullptr, L"Undefined CObjectInfo type requested in CGame::outline_selection()", nullptr, 0); | |
1187 ExitProcess(0); | |
1188 } | |
0 | 1189 } |
1190 } |