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