Mercurial > mm7
annotate Game.cpp @ 961:5a12082c803d
UIMSG and WINDOW_Type(continue)
author | Ritor1 |
---|---|
date | Mon, 06 May 2013 17:33:40 +0600 |
parents | c0d0656aa662 |
children | 9334a8c59c8d |
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 | |
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 | |
961 | 273 bLoading = uCurrentMenuID == MENU_LoadingProcInMainMenu; |
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; | |
871 | 674 depth = pGame->pIndoorCameraD3D->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("valAlwaysRun", bAlwaysRun); | |
770 pItemsTable->Release(); | |
771 pNPCStats->Release(); | |
772 if (pAsyncKeyboard) | |
773 pAsyncKeyboard->Release(); | |
774 if (pAsyncMouse) | |
775 pAsyncMouse->Release(); | |
776 if (pMouse) | |
777 pMouse->Deactivate(); | |
778 | |
779 pAudioPlayer->Release();//error | |
780 pNew_LOD->FreeSubIndexAndIO(); | |
781 pGames_LOD->FreeSubIndexAndIO(); | |
782 ClipCursor(0); | |
783 Game::Destroy(); | |
784 } | |
785 | |
786 //----- (0044EE7C) -------------------------------------------------------- | |
787 bool Game::draw_debug_outlines() | |
788 { | |
789 if (uFlags & 0x04) | |
790 { | |
791 pLightmapBuilder->DrawDebugOutlines(-1); | |
792 pDecalBuilder->DrawDecalDebugOutlines(); | |
793 } | |
794 return true; | |
795 } | |
796 | |
797 //----- (0044EC23) -------------------------------------------------------- | |
798 int Game::_44EC23(stru148 *a2, int *a3, signed int a4) | |
799 { | |
800 double v4; // st7@4 | |
801 //double v5; // ST00_8@4 | |
802 signed int v6; // eax@5 | |
803 //double v7; // ST00_8@6 | |
804 signed int result; // eax@8 | |
805 //double v9; // ST00_8@9 | |
806 //double v10; // ST00_8@11 | |
807 float a2a; // [sp+14h] [bp+8h]@4 | |
808 float a3a; // [sp+18h] [bp+Ch]@4 | |
809 float a3b; // [sp+18h] [bp+Ch]@6 | |
810 float a4a; // [sp+1Ch] [bp+10h]@9 | |
811 float a4b; // [sp+1Ch] [bp+10h]@11 | |
812 | |
813 if ( this->uFlags2 & 2 && a2->field_59 == 5 && a2->pODMFace->uAttributes & 2 ) | |
814 { | |
815 v4 = (double)a4; | |
816 a2a = v4; | |
817 *a3 |= 2u; | |
818 a3a = (1.0 - this->fSaturation) * v4; | |
819 //v5 = a3a + 6.7553994e15; | |
820 //if ( SLODWORD(v5) >= 0 ) | |
821 if (floorf(a3a + 0.5f) >= 0 ) | |
822 { | |
823 a3b = (1.0 - this->fSaturation) * a2a; | |
824 //v7 = a3b + 6.7553994e15; | |
825 //v6 = LODWORD(v7); | |
826 v6 = floorf(a3b + 0.5f); | |
827 } | |
828 else | |
829 { | |
830 v6 = 0; | |
831 } | |
832 if ( a4 >= v6 ) | |
833 { | |
834 a4a = (1.0 - fSaturation) * a2a; | |
835 //v9 = a4a + 6.7553994e15; | |
836 //if ( SLODWORD(v9) >= 0 ) | |
837 if (floorf(a4a + 0.5f) >= 0) | |
838 { | |
839 a4b = (1.0 - fSaturation) * a2a; | |
840 //v10 = a4b + 6.7553994e15; | |
841 //result = LODWORD(v10); | |
842 result = floorf(a4b + 0.5f); | |
843 } | |
844 else | |
845 { | |
846 result = 0; | |
847 } | |
848 } | |
849 else | |
850 { | |
851 result = a4; | |
852 } | |
853 } | |
854 else | |
855 { | |
856 result = -1; | |
857 } | |
858 return result; | |
859 } | |
860 | |
861 | |
862 | |
863 //----- (00465C8B) -------------------------------------------------------- | |
864 Game *Game::Create() | |
865 { | |
866 return new Game; | |
867 } | |
868 | |
869 //----- (00465CF3) -------------------------------------------------------- | |
870 void Game::Destroy() | |
871 { | |
872 if (pGame) | |
873 delete pGame; | |
874 pGame = nullptr; | |
875 } | |
876 | |
877 //----- (0044ED0A) -------------------------------------------------------- | |
878 signed int Game::_44ED0A(BLVFace *a2, int *a3, signed int a4) | |
879 { | |
880 double v4; // st7@3 | |
881 //double v5; // ST00_8@3 | |
882 signed int v6; // eax@4 | |
883 //double v7; // ST00_8@5 | |
884 signed int result; // eax@7 | |
885 //double v9; // ST00_8@8 | |
886 //double v10; // ST00_8@10 | |
887 float v11; // [sp+14h] [bp+8h]@3 | |
888 float v12; // [sp+18h] [bp+Ch]@3 | |
889 float v13; // [sp+18h] [bp+Ch]@5 | |
890 float v14; // [sp+1Ch] [bp+10h]@8 | |
891 float v15; // [sp+1Ch] [bp+10h]@10 | |
892 | |
893 if ( this->uFlags2 & 2 && a2->uAttributes & 2 ) | |
894 { | |
895 v4 = (double)a4; | |
896 v11 = v4; | |
897 *a3 |= 2u; | |
898 v12 = (1.0 - this->fSaturation) * v4; | |
899 //v5 = v12 + 6.7553994e15; | |
900 if (floorf(v12 + 0.5f)/* SLODWORD(v5)*/ >= 0 ) | |
901 { | |
902 v13 = (1.0 - this->fSaturation) * v11; | |
903 //v7 = v13 + 6.7553994e15; | |
904 //v6 = LODWORD(v7); | |
905 v6 = floorf(v13 + 0.5f); | |
906 } | |
907 else | |
908 { | |
909 v6 = 0; | |
910 } | |
911 if ( a4 >= v6 ) | |
912 { | |
913 v14 = (1.0 - fSaturation) * v11; | |
914 //v9 = v14 + 6.7553994e15; | |
915 if (floorf(v14 + 0.5f)/* SLODWORD(v9)*/ >= 0 ) | |
916 { | |
917 v15 = (1.0 - fSaturation) * v11; | |
918 //v10 = v15 + 6.7553994e15; | |
919 //result = LODWORD(v10); | |
920 result = floorf(v15 + 0.5f); | |
921 } | |
922 else | |
923 { | |
924 result = 0; | |
925 } | |
926 } | |
927 else | |
928 { | |
929 result = a4; | |
930 } | |
931 } | |
932 else | |
933 { | |
934 result = -1; | |
935 } | |
936 return result; | |
937 } | |
938 | |
939 | |
940 //----- (0044E4B7) -------------------------------------------------------- | |
941 Game::Game() | |
942 { | |
943 uNumStationaryLights = 0; | |
944 uNumBloodsplats = 0; | |
945 field_E0C = 0; | |
946 field_E10 = 0; | |
947 uNumStationaryLights_in_pStationaryLightsStack = 0; | |
948 bGammaControlInitialized = false; | |
949 uFlags = 0; | |
950 uFlags2 = 0; | |
951 uSomeGammaStartTime = 0; | |
952 uSomeGammaDeltaTime = 0; | |
953 | |
954 pThreadWardInstance = new ThreadWard; | |
955 pParticleEngine = new ParticleEngine; | |
956 pMouse = pMouseInstance = new Mouse(pThreadWardInstance); | |
957 pLightmapBuilder = new LightmapBuilder; | |
958 pVisInstance = new Vis; | |
959 pStru6Instance = new stru6; | |
960 pIndoorCameraD3D = new IndoorCameraD3D; | |
961 pStru9Instance = new stru9; | |
962 pStru10Instance = new stru10; | |
963 pStru11Instance = new stru11; | |
964 pStru12Instance = new stru12(pStru11Instance); | |
965 pCShow = new CShow; | |
966 pKeyboardInstance = new Keyboard; | |
967 pGammaController = new GammaController; | |
968 | |
969 uFlags |= 0x0800; | |
970 uFlags2 |= 0x24; | |
971 | |
972 _44F0FD(); | |
973 | |
974 bWinNT4_0 = false; | |
975 if (pVersion->pVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && | |
976 pVersion->pVersionInfo.dwMajorVersion == 4) | |
977 bWinNT4_0 = true; | |
978 } | |
979 | |
980 //----- (0044E7F3) -------------------------------------------------------- | |
981 Game::~Game() | |
982 { | |
983 if (pGammaController) | |
984 delete pGammaController; | |
985 if (pKeyboardInstance) | |
986 delete pKeyboardInstance; | |
987 if (pCShow) | |
988 delete pCShow; | |
989 if (pStru12Instance) | |
990 delete pStru12Instance; | |
991 if (pStru11Instance) | |
992 delete pStru11Instance; | |
993 if (pStru10Instance) | |
994 delete pStru10Instance; | |
995 if (pStru9Instance) | |
996 delete pStru9Instance; | |
997 if (pIndoorCameraD3D) | |
998 delete pIndoorCameraD3D; | |
999 if (pStru6Instance) | |
1000 delete pStru6Instance; | |
1001 if (pVisInstance) | |
1002 delete pVisInstance; | |
1003 if (pLightmapBuilder) | |
1004 delete pLightmapBuilder; | |
1005 if (pMouseInstance) | |
1006 delete pMouseInstance; | |
1007 if (pParticleEngine) | |
1008 delete pParticleEngine; | |
1009 if (pThreadWardInstance) | |
1010 delete pThreadWardInstance; | |
1011 } | |
1012 | |
1013 //----- (0044E904) -------------------------------------------------------- | |
1014 void Game::_44E904() | |
1015 { | |
1016 //Game *v1; // esi@1 | |
1017 unsigned __int64 v2; // qax@1 | |
1018 unsigned int v3; // ecx@1 | |
1019 int v4; // edi@1 | |
1020 unsigned __int8 v5; // cf@7 | |
1021 double v6; // st7@13 | |
1022 double v7; // st7@15 | |
1023 signed __int64 v8; // [sp+Ch] [bp-8h]@1 | |
1024 | |
1025 //v1 = this; | |
1026 v2 = pEventTimer->Time(); | |
1027 v4 = (v2 - uSomeGammaStartTime) >> 32; | |
1028 v3 = v2 - LODWORD(uSomeGammaStartTime); | |
1029 v8 = v2 - uSomeGammaStartTime; | |
1030 if ( v4 < 0 | |
1031 || SHIDWORD(v2) < ((unsigned int)v2 < LODWORD(uSomeGammaStartTime)) + HIDWORD(uSomeGammaStartTime) | v4 == 0 | |
1032 && v3 <= 0x80 ) | |
1033 { | |
1034 if ( v4 > 0 || v4 >= 0 ) | |
1035 goto LABEL_12; | |
1036 v3 = 0; | |
1037 v4 = 0; | |
1038 } | |
1039 else | |
1040 { | |
1041 if ( uSomeGammaDeltaTime ) | |
1042 { | |
1043 LODWORD(uSomeGammaDeltaTime) = 0; | |
1044 HIDWORD(uSomeGammaDeltaTime) = 0; | |
1045 } | |
1046 else | |
1047 { | |
1048 LODWORD(uSomeGammaDeltaTime) = v3; | |
1049 HIDWORD(uSomeGammaDeltaTime) = v4; | |
1050 } | |
1051 v5 = __CFADD__(v3, -128); | |
1052 v3 -= 128; | |
1053 v4 = v5 + v4 - 1; | |
1054 } | |
1055 uSomeGammaStartTime = v2; | |
1056 v8 = __PAIR__(v4, v3); | |
1057 LABEL_12: | |
1058 if ( uSomeGammaDeltaTime ) | |
1059 v6 = (double)(signed __int64)(uSomeGammaDeltaTime - __PAIR__(v4, v3)); | |
1060 else | |
1061 v6 = (double)v8; | |
1062 v7 = v6 * 0.0078125; | |
1063 if ( v7 < 0.0 || v7 <= 1.0 ) | |
1064 { | |
1065 if ( v7 < 0.0 ) | |
1066 v7 = 0.0; | |
1067 } | |
1068 else | |
1069 { | |
1070 v7 = 1.0; | |
1071 } | |
1072 if ( pRenderer->pRenderD3D ) | |
1073 fSaturation = v7; | |
1074 else | |
1075 fSaturation = (1.0 - 0.5) * v7 + 0.5; | |
1076 } | |
1077 | |
1078 //----- (0044EA17) -------------------------------------------------------- | |
1079 bool Game::InitializeGammaController() | |
1080 { | |
1081 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
1082 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
1083 pGammaController->InitializeFromSurface(pRenderer->pFrontBuffer4); | |
1084 | |
1085 bGammaControlInitialized = true; | |
1086 uSomeGammaStartTime = pEventTimer->Time(); | |
1087 return true; | |
1088 } | |
1089 | |
1090 //----- (0044EA5E) -------------------------------------------------------- | |
194 | 1091 bool Game::PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) |
0 | 1092 { |
227 | 1093 if (pCurrentScreen != SCREEN_GAME|| !pRenderer->pRenderD3D) |
194 | 1094 return false; |
0 | 1095 |
194 | 1096 if (!pVisInstance) |
0 | 1097 { |
194 | 1098 MessageBoxW(nullptr, L"The 'Vis' object pointer has not been instatiated, but CGame::Pick() is trying to call through it.", nullptr, 0); |
1099 return false; | |
1100 } | |
0 | 1101 |
692 | 1102 if (uMouseX >= (signed int)pViewport->uScreen_TL_X && |
1103 uMouseX <= (signed int)pViewport->uScreen_BR_X && | |
1104 uMouseY >= (signed int)pViewport->uScreen_TL_Y && | |
1105 uMouseY <= (signed int)pViewport->uScreen_BR_Y) | |
194 | 1106 { |
1107 pVisInstance->PickMouse(fPickDepth, uMouseX, uMouseY, sprite_filter, face_filter); | |
0 | 1108 |
194 | 1109 if (bOutline) |
1110 OutlineSelection(); | |
0 | 1111 } |
194 | 1112 |
1113 return true; | |
0 | 1114 } |
1115 // 4E28F8: using guessed type int pCurrentScreen; | |
1116 | |
1117 //----- (0044EB12) -------------------------------------------------------- | |
194 | 1118 bool Game::PickKeyboard(bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) |
0 | 1119 { |
271 | 1120 if (pCurrentScreen == SCREEN_GAME && pVisInstance && pRenderer->pRenderD3D) |
0 | 1121 { |
194 | 1122 bool r = pVisInstance->PickKeyboard(&pVisInstance->default_list, sprite_filter, face_filter); |
0 | 1123 |
1124 if (bOutline) | |
1125 OutlineSelection(); | |
1126 return r; | |
1127 } | |
1128 return false; | |
1129 } | |
123 | 1130 /* |
1131 Result::Code Game::PickKeyboard(bool bOutline, struct unnamed_F93E6C *a3, struct unnamed_F93E6C *a4) | |
1132 { | |
1133 if (dword_4E28F8_PartyCantJumpIfTrue) | |
1134 return Result::Generic; | |
1135 | |
1136 pVis->PickKeyboard(a3, a4); | |
1137 if (bOutline) | |
1138 Game_outline_selection((int)this); | |
1139 return Result::Success; | |
1140 } | |
1141 */ | |
0 | 1142 // 4E28F8: using guessed type int pCurrentScreen; |
1143 | |
1144 //----- (0044EB5A) -------------------------------------------------------- | |
1145 void Game::OutlineSelection() | |
1146 { | |
194 | 1147 if (!pVisInstance) |
1148 return; | |
1149 | |
1150 if (!pVisInstance->default_list.uNumPointers) | |
1151 return; | |
0 | 1152 |
194 | 1153 auto object_info = pVisInstance->default_list.object_pointers[0]; |
1154 if (object_info) | |
1155 switch (object_info->object_type) | |
0 | 1156 { |
194 | 1157 case VisObjectType_Sprite: |
0 | 1158 { |
194 | 1159 Log::Warning(L"Sprite outline currently unsupported"); |
1160 return; | |
0 | 1161 } |
1162 | |
194 | 1163 case VisObjectType_Face: |
1164 { | |
1165 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
0 | 1166 { |
194 | 1167 auto face = (ODMFace *)object_info->object; |
1168 if (face->uAttributes & FACE_OUTLINED) | |
1169 face->uAttributes &= ~FACE_OUTLINED; | |
0 | 1170 else |
194 | 1171 face->uAttributes |= FACE_OUTLINED; |
1172 } | |
1173 else if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
1174 { | |
1175 auto face = (BLVFace *)object_info->object; | |
1176 if (face->uAttributes & FACE_OUTLINED) | |
1177 face->uAttributes &= ~FACE_OUTLINED; | |
1178 else | |
1179 face->uAttributes |= FACE_OUTLINED; | |
0 | 1180 } |
194 | 1181 else assert(false); |
1182 } | |
323 | 1183 break; |
194 | 1184 |
1185 default: | |
1186 { | |
1187 MessageBoxW(nullptr, L"Undefined CObjectInfo type requested in CGame::outline_selection()", nullptr, 0); | |
1188 ExitProcess(0); | |
1189 } | |
0 | 1190 } |
1191 } |