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