Mercurial > mm7
annotate Game.cpp @ 1115:849b848ed871
wrong IsNotAlive() condition fix
author | Grumpy7 |
---|---|
date | Wed, 29 May 2013 03:19:12 +0200 |
parents | cf6cd674c398 |
children | 29a8defbad9e |
rev | line source |
---|---|
137 | 1 #include <assert.h> |
2 | |
1016 | 3 #include "Vis.h" |
4 | |
5 #include "LightmapBuilder.h" | |
6 #include "DecalBuilder.h" | |
7 #include "ParticleEngine.h" | |
8 #include "Mouse.h" | |
9 #include "Keyboard.h" | |
10 #include "CShow.h" | |
11 #include "GammaControl.h" | |
12 #include "stru6.h" | |
13 #include "stru9.h" | |
14 #include "stru10.h" | |
15 #include "stru11.h" | |
16 #include "stru12.h" | |
17 | |
0 | 18 #include "Game.h" |
19 #include "Party.h" | |
20 #include "IndoorCamera.h" | |
21 #include "Viewport.h" | |
22 #include "Time.h" | |
23 #include "Outdoor.h" | |
24 #include "Overlays.h" | |
25 #include "AudioPlayer.h" | |
26 #include "LOD.h" | |
27 #include "OSInfo.h" | |
28 #include "GUIWindow.h" | |
29 #include "TurnEngine.h" | |
30 #include "VideoPlayer.h" | |
31 #include "Bink_Smacker.h" | |
32 #include "Events.h" | |
33 #include "Arcomage.h" | |
189 | 34 #include "texts.h" |
791 | 35 #include "GUIFont.h" |
194 | 36 #include "Log.h" |
0 | 37 |
38 //#include "MM7.h" | |
39 | |
40 | |
41 | |
42 | |
43 | |
44 | |
45 Game *pGame; | |
46 | |
47 | |
48 | |
49 | |
50 | |
51 //----- (00435694) -------------------------------------------------------- | |
52 void Game::ToggleFlags2(unsigned int uFlag) | |
53 { | |
54 unsigned int v2; // eax@1 | |
55 | |
56 v2 = this->uFlags2; | |
57 if ( v2 & uFlag ) | |
58 this->uFlags2 = v2 & ~uFlag; | |
59 else | |
60 this->uFlags2 = uFlag | v2; | |
61 } | |
62 | |
63 //----- (0044103C) -------------------------------------------------------- | |
64 void Game::Draw() | |
65 { | |
142 | 66 //float v2; // ST24_4@11 |
0 | 67 //double v3; // ST28_8@11 |
68 int v4; // edi@26 | |
142 | 69 //int v5; // eax@35 |
0 | 70 |
71 uFlags2 &= 0xFFFFFFFDu; | |
72 if ( pParty->_497FC5_check_party_perception_against_level() ) | |
73 uFlags2 |= 2u; | |
74 pIndoorCamera->sRotationX = pParty->sRotationX; | |
75 pIndoorCamera->sRotationY = pParty->sRotationY; | |
120 | 76 //pIndoorCamera->pos.x = pParty->vPosition.x - ((__int64)pParty->y_rotation_granularity * stru_5C6E00->SinCos(pIndoorCamera->sRotationY)) / 2048.0;//12552 |
77 //pIndoorCamera->pos.y = pParty->vPosition.y - ((__int64)pParty->y_rotation_granularity * stru_5C6E00->SinCos(pIndoorCamera->sRotationY)) / 2048.0;//800 | |
78 pIndoorCamera->pos.x = pParty->vPosition.x - pParty->y_rotation_granularity * cosf(2 * 3.141592653589 * pIndoorCamera->sRotationY / 2048.0); | |
79 pIndoorCamera->pos.y = pParty->vPosition.y - pParty->y_rotation_granularity * sinf(2 * 3.141592653589 * pIndoorCamera->sRotationY / 2048.0); | |
66 | 80 pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel;//193, but real 353 |
0 | 81 pIndoorCamera->Initialize2(); |
82 pIndoorCameraD3D->CreateWorldMatrixAndSomeStuff(); | |
83 pIndoorCameraD3D->_4374E8_ProllyBuildFrustrum(); | |
84 | |
85 if ( pVideoPlayer->AnyMovieLoaded() ) | |
86 { | |
87 if ( pRenderer->pRenderD3D ) | |
88 goto LABEL_22; | |
89 pRenderer->BeginSceneD3D(); | |
90 pMouse->DrawCursorToTarget(); | |
91 } | |
92 else | |
93 { | |
1110 | 94 if ( pParty->vPosition.x != pParty->vPrevPosition.x || pParty->sRotationY != pParty->sPrevRotationY || pParty->vPosition.y != pParty->vPrevPosition.y |
95 || pParty->sRotationX != pParty->sPrevRotationX || pParty->vPosition.z != pParty->vPrevPosition.z || pParty->sEyelevel != pParty->sPrevEyelevel ) | |
0 | 96 pParty->uFlags |= 2u; |
847 | 97 pParty->vPrevPosition.x = pParty->vPosition.x; |
78 | 98 pParty->vPrevPosition.y = pParty->vPosition.y; |
847 | 99 pParty->vPrevPosition.z = pParty->vPosition.z; |
0 | 100 //v0 = &pRenderer; |
101 pParty->sPrevRotationY = pParty->sRotationY; | |
102 pParty->sPrevRotationX = pParty->sRotationX; | |
847 | 103 |
0 | 104 pParty->sPrevEyelevel = pParty->sEyelevel; |
105 pRenderer->BeginSceneD3D(); | |
106 | |
107 if ( !pRenderer->pRenderD3D ) | |
108 pMouse->DrawCursorToTarget(); | |
265 | 109 if ( !PauseGameDrawing() || viewparams->field_48 == 1 ) |
0 | 110 { |
111 if ( pRenderer->pRenderD3D ) | |
112 { | |
142 | 113 float v2 = (double)(((signed int)pMiscTimer->uTotalGameTimeElapsed >> 2) & 0x1F) * 0.032258064 * 6.0; |
0 | 114 //v3 = v2 + 6.7553994e15; |
115 //pRenderer->field_1036A8_bitmapid = LODWORD(v3); | |
265 | 116 pRenderer->hd_water_current_frame = floorf(v2 + 0.5f); |
0 | 117 } |
118 | |
119 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
120 pIndoor->Draw(); | |
121 else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
122 pOutdoor->Draw(); | |
137 | 123 else assert(false); |
0 | 124 |
125 if (pRenderer->pRenderD3D) | |
126 { | |
127 pDecalBuilder->DrawBloodsplats(); | |
569 | 128 pGame->pLightmapBuilder->DrawLightmaps(2); |
0 | 129 } |
130 } | |
131 } | |
132 pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); | |
133 LABEL_22: | |
791 | 134 |
135 //DEBUG: force redraw gui | |
136 viewparams->bRedrawGameUI = true; | |
137 | |
138 | |
0 | 139 pRenderer->BeginScene(); |
140 if (pRenderer->pRenderD3D) | |
141 pMouse->DrawCursorToTarget(); | |
142 | 142 if (pOtherOverlayList->bRedraw) |
143 viewparams->bRedrawGameUI = true; | |
0 | 144 v4 = viewparams->bRedrawGameUI; |
783 | 145 GameUI_Footer(); |
0 | 146 if (!viewparams->bRedrawGameUI) |
147 { | |
148 GameUI_DrawRightPanelItems(); | |
149 } | |
150 else | |
151 { | |
152 GameUI_DrawRightPanelFrames(); | |
783 | 153 GameUI_Footer_2(); |
0 | 154 viewparams->bRedrawGameUI = false; |
155 } | |
156 if (!pVideoPlayer->pSmackerMovie) | |
157 { | |
158 GameUI_DrawMinimap(488, 16, 625, 133, viewparams->uMinimapZoom, pParty->uFlags & 2); | |
159 if (v4) | |
160 { | |
265 | 161 if ( !PauseGameDrawing() && pRenderer->pRenderD3D) // clear game viewport with transparent color |
693 | 162 pRenderer->FillRectFast(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pViewport->uViewportBR_X - pViewport->uViewportTL_X, |
163 pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1, | |
142 | 164 pRenderer->uTargetGMask | pRenderer->uTargetBMask); |
0 | 165 viewparams->field_48 = 0; |
166 } | |
167 } | |
142 | 168 |
169 viewparams->bRedrawGameUI = pOtherOverlayList->bRedraw; | |
170 pOtherOverlayList->bRedraw = 0; | |
171 | |
0 | 172 GameUI_DrawPartySpells(); |
291 | 173 if (v4 || pParty->pHirelings[0].evt_C || pParty->pHirelings[1].evt_C ) |
994 | 174 GameUI_DrawHiredNPCs(); |
0 | 175 GameUI_DrawPortraits(v4); |
176 GameUI_DrawLifeManaBars(); | |
177 GameUI_DrawCharacterSelectionFrame(); | |
178 if ( sub_44100D() ) | |
994 | 179 GameUI_DrawRightPanel(); |
0 | 180 if ( !pVideoPlayer->AnyMovieLoaded() ) |
181 { | |
182 pStru6Instance->DrawPlayerBuffAnims(); | |
569 | 183 pOtherOverlayList->DrawTurnBasedIcon(v4); |
0 | 184 GameUI_DrawTorchlightAndWizardEye(); |
185 } | |
791 | 186 |
794 | 187 |
188 static bool render_framerate = false; | |
189 static float framerate = 0.0f; | |
190 static uint frames_this_second = 0; | |
191 static uint last_frame_time = GetTickCount(); | |
192 static uint framerate_time_elapsed = 0; | |
193 | |
194 auto frame_dt = GetTickCount() - last_frame_time; | |
195 last_frame_time = GetTickCount(); | |
196 | |
197 framerate_time_elapsed += frame_dt; | |
198 if (framerate_time_elapsed >= 1000) | |
199 { | |
200 framerate = frames_this_second * (1000.0f / framerate_time_elapsed); | |
201 | |
202 framerate_time_elapsed = 0; | |
203 frames_this_second = 0; | |
204 render_framerate = true; | |
205 } | |
206 | |
207 ++frames_this_second; | |
208 | |
209 | |
210 if (render_framerate) | |
211 { | |
212 sprintf(pTmpBuf, "FPS: % .4f", framerate); | |
949 | 213 pPrimaryWindow->DrawText(pFontArrus, 494, 0, TargetColor(0, 0, 0), pTmpBuf, 0, 0, 0); |
794 | 214 } |
215 | |
791 | 216 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) |
217 { | |
831 | 218 auto sector_id = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); |
219 sprintf(pTmpBuf, "Party Sector ID: %u/%u\n", sector_id, pIndoor->uNumSectors); | |
949 | 220 pPrimaryWindow->DrawText(pFontArrus, 16, 16, TargetColor(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF); |
791 | 221 } |
222 sprintf(pTmpBuf, "Party Position: % d % d % d", pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); | |
949 | 223 pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16, TargetColor(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF); |
791 | 224 |
225 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
226 { | |
227 uint uFaceID; | |
831 | 228 auto sector_id = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); |
229 auto floor_level = BLV_GetFloorLevel(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + 40, sector_id, &uFaceID); | |
791 | 230 sprintf(pTmpBuf, "BLV_GetFloorLevel: %d face_id %d\n", floor_level, uFaceID); |
231 } | |
232 else | |
233 { | |
234 int on_water, _a6; | |
235 auto floor_level = ODM_GetFloorLevel(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z, 0, &on_water, &_a6, false); | |
236 sprintf(pTmpBuf, "ODM_GetFloorLevel: %d on_water: %s a6 = %d\n", floor_level, on_water ? "true" : "false", _a6); | |
237 } | |
949 | 238 pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16 + 16, TargetColor(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF); |
791 | 239 |
0 | 240 GUI_UpdateWindows(); |
130 | 241 pParty->UpdatePlayersAndHirelingsEmotions(); |
937 | 242 |
434 | 243 _unused_5B5924_is_travel_ui_drawn = false; |
0 | 244 if (v4) |
791 | 245 pMouse->bRedraw = true; |
0 | 246 pMouse->_469EA4(); |
247 pMouse->DrawCursor(); | |
248 pMouse->_469E1C(); | |
249 pRenderer->EndScene(); | |
250 pRenderer->Present(); | |
569 | 251 pParty->uFlags &= ~2; |
0 | 252 } |
253 | |
254 //----- (0047A815) -------------------------------------------------------- | |
255 void Game::DrawParticles() | |
256 { | |
257 pParticleEngine->Draw(); | |
258 } | |
259 | |
260 //----- (00463149) -------------------------------------------------------- | |
261 void Game::Loop() | |
262 { | |
263 //signed int v0; // ebp@3 | |
264 //signed int v1; // esi@4 | |
265 //Render *v2; // edi@7 | |
266 //signed int v3; // esi@7 | |
267 signed int pNewNPCsCount; // ecx@58 | |
1063 | 268 NPCData *pNPC; // eax@59 |
0 | 269 Player *pPlayer; // esi@65 |
981 | 270 //OtherOverlay *pOtherOverlay; // esi@67 |
271 //signed int v8; // edi@67 | |
982 | 272 //int pPlayerNum; // edi@69 |
0 | 273 int *pHealth; // esi@71 |
982 | 274 //signed int v11; // esi@78 |
275 //int v12; // eax@83 | |
0 | 276 const char *pLocationName; // [sp-4h] [bp-68h]@74 |
277 bool bLoading; // [sp+10h] [bp-54h]@1 | |
982 | 278 //signed int bLoadinga; // [sp+10h] [bp-54h]@19 |
0 | 279 signed int v16; // [sp+14h] [bp-50h]@8 |
982 | 280 //int v17[4]; // [sp+18h] [bp-4Ch]@80 |
0 | 281 MSG Msg; // [sp+28h] [bp-3Ch]@20 |
282 char Source[64]; // [sp+44h] [bp-20h]@76 | |
283 | |
961 | 284 bLoading = uCurrentMenuID == MENU_LoadingProcInMainMenu; |
0 | 285 SetCurrentMenuID((MENU_STATE)-1); |
286 if (bLoading) | |
287 { | |
288 pParty->Reset(); | |
289 dword_6BE340 = 0; | |
982 | 290 uGameState = GAME_STATE_PLAYING; |
0 | 291 LoadGame(uLoadGameUI_SelectedSlot); |
292 } | |
293 | |
294 for (uint i = 1; i < 5; ++i) | |
295 for (uint j = 1; j < 6; ++j) | |
296 { | |
297 sprintf(pTmpBuf, "data\\lloyd%d%d.pcx", i, j); | |
298 remove(pTmpBuf); | |
299 } | |
300 | |
301 LoadPlayerPortraintsAndVoices(); | |
783 | 302 pIcons_LOD->_inlined_sub1(); |
328 | 303 pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); |
0 | 304 |
305 while ( 2 ) | |
306 { | |
307 v16 = 1; | |
783 | 308 pMessageQueue_50CBD0->Flush(); |
0 | 309 |
310 pPartyActionQueue->uNumActions = 0; | |
311 if (pParty->bTurnBasedModeOn) | |
312 { | |
313 pTurnEngine->End(false); | |
314 pParty->bTurnBasedModeOn = false; | |
315 } | |
316 DoPrepareWorld(bLoading, 1); | |
317 pEventTimer->Resume(); | |
318 dword_6BE364_game_settings_1 |= 0x80; | |
319 dword_6BE340 = 2; | |
320 // uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0; | |
151 | 321 pCurrentScreen = SCREEN_GAME; |
1038 | 322 |
0 | 323 if ( pRenderer->pRenderD3D ) |
324 pGame->pVisInstance->_4C1A02(); | |
982 | 325 |
326 bool game_finished = false; | |
0 | 327 do |
328 { | |
329 while ( PeekMessageA(&Msg, 0, 0, 0, PM_REMOVE) ) | |
330 { | |
331 if ( Msg.message == WM_QUIT ) | |
332 Game_DeinitializeAndTerminate(0); | |
333 TranslateMessage(&Msg); | |
334 DispatchMessageA(&Msg); | |
335 } | |
336 if (dword_6BE364_game_settings_1 & 0x0100 ) | |
337 { | |
338 WaitMessage(); | |
339 continue; | |
340 } | |
341 pGame->_44EEA7(); | |
342 GameUI_WritePointedObjectStatusString(); | |
343 ProcessInputActions(); | |
344 GameUI_MsgProc(); | |
345 if ( pArcomageGame->bGameInProgress ) | |
346 { | |
347 ArcomageGame::Loop(); | |
348 pRenderer->Present(); | |
349 continue; | |
350 } | |
351 if ( pVideoPlayer->pSmackerMovie && !SmackWait(pVideoPlayer->pSmackerMovie) ) | |
352 { | |
353 pRenderer->BeginScene(); | |
354 pMouse->DrawCursorToTarget(); | |
355 pVideoPlayer->SmackUpdatePalette(pVideoPlayer->hWindow); | |
356 pMouse->_469EA4(); | |
357 pRenderer->EndScene(); | |
358 } | |
982 | 359 else if ( pVideoPlayer->pBinkMovie && !BinkWait(pVideoPlayer->pBinkMovie) ) |
0 | 360 { |
361 pRenderer->BeginScene(); | |
362 pMouse->DrawCursorToTarget(); | |
363 pVideoPlayer->BinkUpdatePalette(pVideoPlayer->hWindow); | |
364 pMouse->_469EA4(); | |
365 pRenderer->EndScene(); | |
366 } | |
983 | 367 |
368 pEventTimer->Update(); | |
369 pMiscTimer->Update(); | |
370 | |
0 | 371 OnTimer(0); |
372 GameUI_StatusBar_UpdateTimedString(0); | |
373 if ( pMiscTimer->bPaused && !pEventTimer->bPaused ) | |
374 pMiscTimer->Resume(); | |
375 if ( pEventTimer->bTackGameTime && !pParty->bTurnBasedModeOn ) | |
376 pEventTimer->bTackGameTime = 0; | |
982 | 377 if ( !pEventTimer->bPaused && uGameState == GAME_STATE_PLAYING) |
0 | 378 { |
379 if ( !pEventTimer->bTackGameTime ) | |
380 _494035_timed_effects__water_walking_damage__etc(); | |
381 if ( dword_6BE364_game_settings_1 & 1 ) | |
382 { | |
383 dword_6BE364_game_settings_1 &= 0xFFFFFFFEu; | |
384 } | |
385 else | |
386 { | |
783 | 387 UpdateActorAI(); |
388 UpdateUserInput_and_MapSpecificStuff(); | |
0 | 389 } |
390 } | |
391 if ( v16 ) | |
392 { | |
393 v16 = 0; | |
394 viewparams->bRedrawGameUI = true; | |
395 } | |
378 | 396 pAudioPlayer->UpdateSounds(); |
978 | 397 if (uGameState == GAME_FINISHED) |
0 | 398 //goto LABEL_96; |
4 | 399 { |
982 | 400 game_finished = true; |
0 | 401 continue; |
4 | 402 } |
978 | 403 if (uGameState == GAME_STATE_2) |
0 | 404 { |
405 pAudioPlayer->StopChannels(-1, -1); | |
406 PrepareWorld(0); | |
982 | 407 uGameState = GAME_STATE_PLAYING; |
0 | 408 continue; |
409 } | |
978 | 410 if ( (signed int)uGameState <= GAME_STATE_2 ) |
0 | 411 //goto LABEL_85; |
4 | 412 { |
413 pGame->Draw(); | |
0 | 414 continue; |
4 | 415 } |
978 | 416 if ( (signed int)uGameState <= GAME_STATE_5 || uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU ) |
0 | 417 { |
418 //LABEL_96: | |
982 | 419 game_finished = true; |
0 | 420 continue; |
421 } | |
981 | 422 if ( uGameState != GAME_STATE_PARTY_DIED ) |
0 | 423 { |
978 | 424 if ( uGameState != GAME_STATE_FINAL_WINDOW ) |
0 | 425 { |
426 //LABEL_85: | |
427 pGame->Draw(); | |
428 } | |
981 | 429 else |
430 { | |
431 pRenderer->BeginScene(); | |
432 GUI_UpdateWindows(); | |
433 pRenderer->EndScene(); | |
434 //goto LABEL_89; | |
435 pRenderer->Present(); | |
436 } | |
0 | 437 continue; |
438 } | |
4 | 439 pAudioPlayer->StopChannels(-1, -1);//äàëåå â ñëó÷àå ñìåðòè ãðóïïû |
293 | 440 memset(&pParty->pHirelings[0], 0, 0x4Cu); |
0 | 441 memset(&pParty->pHirelings[1], 0, 0x4Cu); |
442 pNewNPCsCount = 0; | |
443 if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) | |
444 { | |
1063 | 445 pNPC = pNPCStats->pNewNPCData; |
0 | 446 do |
447 { | |
1063 | 448 if ( pNPC->field_24 ) |
449 pNPC->uFlags &= 0xFFFFFF7Fu; | |
0 | 450 ++pNewNPCsCount; |
1063 | 451 ++pNPC; |
0 | 452 } |
453 while ( pNewNPCsCount < (signed int)pNPCStats->uNumNewNPCs ); | |
454 } | |
455 pVideoPlayer->PlayDeathMovie(); | |
456 if ( pVideoPlayer->AnyMovieLoaded() ) | |
457 pVideoPlayer->Unload(); | |
458 SaveGame(0, 0); | |
459 ++pParty->uNumDeaths; | |
460 pPlayer = pParty->pPlayers; | |
461 do | |
462 { | |
463 pPlayer->SetVariable(VAR_Award, 85); | |
464 ++pPlayer; | |
465 } | |
466 while ( (signed int)pPlayer < (signed int)pParty->pHirelings ); | |
766 | 467 pParty->days_played_without_rest = 0; |
0 | 468 pParty->uTimePlayed += 0x276000ui64; |
569 | 469 LOWORD(pParty->uFlags) &= ~0x204; |
0 | 470 pParty->SetGold(0); |
981 | 471 pOtherOverlayList->Reset(); |
982 | 472 memset(pParty->pPartyBuffs, 0, 0x140u); |
981 | 473 |
0 | 474 if ( pParty->bTurnBasedModeOn == 1 ) |
475 { | |
476 pTurnEngine->End(1); | |
477 pParty->bTurnBasedModeOn = 0; | |
478 } | |
440 | 479 //pHealth = &pParty->pPlayers[0].sHealth;//193C |
480 //do | |
481 for(int i=0; i<4; ++i) | |
0 | 482 { |
440 | 483 memset(pParty->pPlayers[i].pConditions, 0, 0xA0u);//(pConditions, 0, 160) |
484 memset(pParty->pPlayers[i].pPlayerBuffs, 0, 0x180u);//(pPlayerBuffs[0], 0, 384) | |
485 //*pHealth = 1; | |
486 pParty->pPlayers[i].sHealth=1; | |
487 //pHealth += 1743; //6CF | |
0 | 488 uActiveCharacter = 1; |
489 } | |
440 | 490 // while ( (signed int)pHealth < (signed int)&pParty->field_871C[567] ); |
981 | 491 if (_449B57_test_bit(pParty->_quest_bits, PARTY_QUEST_FINISHED_EMERALD_ISLE)) |
0 | 492 { |
493 pParty->vPosition.x = -17331; // respawn in harmondale | |
494 pParty->vPosition.y = 12547; | |
495 pParty->vPosition.z = 465; | |
496 pParty->sRotationY = 0; | |
497 pLocationName = "out02.odm"; | |
498 } | |
499 else | |
500 { | |
501 pParty->vPosition.x = 12552; // respawn on emerald isle | |
502 pParty->vPosition.y = 1816; | |
503 pParty->vPosition.z = 0; | |
504 pParty->sRotationY = 512; | |
505 pLocationName = "out01.odm"; | |
506 } | |
507 strcpy(Source, pLocationName); | |
508 pParty->uFallStartY = pParty->vPosition.z; | |
509 pParty->sRotationX = 0; | |
510 pParty->uFallSpeed = 0; | |
511 pParty->field_6E4 = 0; | |
512 pParty->field_6E0 = 0; | |
1104 | 513 if ( _stricmp(Source, pCurrentMapName) ) |
0 | 514 { |
515 strcpy(pCurrentMapName, Source); | |
516 _5B65A8_npcdata_uflags_or_other = pParty->vPosition.x; | |
517 _5B65AC_npcdata_fame_or_other = pParty->vPosition.y; | |
518 _5B65B0_npcdata_rep_or_other = pParty->vPosition.z; | |
519 _5B65B4_npcdata_loword_house_or_other = pParty->sRotationY; | |
520 _5B65B8_npcdata_hiword_house_or_other = pParty->sRotationX; | |
521 dword_5B65C0 = 1; | |
522 PrepareWorld(1); | |
523 } | |
524 InitializeActors(); | |
982 | 525 |
526 | |
527 int num_conscious_players = 0; | |
528 int conscious_players_ids[4] = {-1, -1, -1, -1}; | |
529 for (int v11 = 0; v11 < 4; ++v11) | |
0 | 530 { |
982 | 531 if (pPlayers[v11 + 1]->CanAct()) |
532 conscious_players_ids[num_conscious_players++] = v11; | |
0 | 533 } |
982 | 534 if (num_conscious_players) |
0 | 535 { |
982 | 536 int idx = conscious_players_ids[rand() % num_conscious_players]; |
537 assert(idx >= 0); | |
538 pPlayers[idx + 1]->PlaySound(SPEECH_99, 0); | |
0 | 539 } |
982 | 540 |
0 | 541 ShowStatusBarString(pGlobalTXT_LocalizationStrings[524], 2u);// "Once again you've cheated death!.." "Âû ñíîâà îáõèòðèëè ñìåðòü! …" |
982 | 542 uGameState = GAME_STATE_PLAYING; |
0 | 543 } |
982 | 544 while (!game_finished); |
545 | |
0 | 546 dword_6BE340 = 0; |
547 pEventTimer->Pause(); | |
548 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); | |
978 | 549 if ( uGameState == GAME_STATE_3 ) |
0 | 550 { |
551 sub_491E3A(); | |
552 LoadPlayerPortraintsAndVoices(); | |
982 | 553 uGameState = GAME_STATE_PLAYING; |
0 | 554 pIcons_LOD->dword_11B84 = pIcons_LOD->uNumLoadedFiles; |
555 bLoading = true; | |
556 continue; | |
557 } | |
558 break; | |
559 } | |
151 | 560 pCurrentScreen = SCREEN_VIDEO; |
0 | 561 sub_491E3A(); |
562 } | |
563 | |
564 | |
565 //----- (0044F192) -------------------------------------------------------- | |
566 void Game::PrepareBloodsplats() | |
567 { | |
568 for (uint i = 0; i < uNumBloodsplats; ++i) | |
569 { | |
570 pBloodsplatContainer->AddBloodsplat( | |
571 pBloodsplats[i].x, | |
572 pBloodsplats[i].y, | |
573 pBloodsplats[i].z, | |
574 pBloodsplats[i].radius, | |
575 pBloodsplats[i].r, | |
576 pBloodsplats[i].g, | |
577 pBloodsplats[i].b); | |
578 } | |
579 } | |
580 | |
581 | |
582 //----- (0044F120) -------------------------------------------------------- | |
583 void Game::PushStationaryLights(int a2) | |
584 { | |
1094 | 585 Game__StationaryLight* pLight; |
586 | |
587 for( int i=0; i<uNumStationaryLights; ++i ) | |
588 { | |
589 pLight=&pStationaryLights[i]; | |
590 pStationaryLightsStack->AddLight( | |
591 pLight->vPosition.x, | |
592 pLight->vPosition.y, | |
593 pLight->vPosition.z, | |
594 pLight->flt_18, | |
595 pLight->vRGBColor.x, | |
596 pLight->vRGBColor.y, | |
597 pLight->vRGBColor.z, | |
598 byte_4E94D0); | |
599 } | |
0 | 600 } |
601 // 4E94D0: using guessed type char byte_4E94D0; | |
602 | |
603 //----- (0044F0FD) -------------------------------------------------------- | |
604 void Game::_44F0FD() | |
605 { | |
606 ToggleFlags(0x40u); | |
607 | |
608 if ( !(uFlags & 0x40) ) | |
609 { | |
610 uNumBloodsplats = 0; | |
611 field_E0C = 0; | |
612 } | |
613 } | |
614 | |
615 //----- (0044F0D8) -------------------------------------------------------- | |
616 void Game::ToggleFlags(uint uMask) | |
617 { | |
618 if (uFlags & uMask) | |
619 uFlags &= ~uMask; | |
620 else | |
621 uFlags |= uMask; | |
622 } | |
623 | |
624 | |
625 //----- (0044F07B) -------------------------------------------------------- | |
626 bool Game::_44F07B() | |
627 { | |
628 if (!pKeyboardInstance->IsKeyBeingHeld(VK_SHIFT) && | |
629 !pKeyboardInstance->IsKeyBeingHeld(VK_LSHIFT) && | |
630 !pKeyboardInstance->IsKeyBeingHeld(VK_LSHIFT) || | |
631 | |
632 (pKeyboardInstance->WasKeyPressed(VK_F11) == 0 && | |
633 pKeyboardInstance->WasKeyPressed(VK_F11))) | |
634 return true; | |
635 return false; | |
636 } | |
637 | |
638 //----- (0044EEA7) -------------------------------------------------------- | |
639 bool Game::_44EEA7() | |
640 { | |
641 //Game *v1; // esi@1 | |
194 | 642 //double v2; // st7@2 |
0 | 643 float depth; // ST00_4@9 |
194 | 644 //bool result; // eax@9 |
0 | 645 unsigned int v5; // eax@14 |
646 __int64 v6; // kr00_8@21 | |
647 unsigned int y; // [sp+4h] [bp-24h]@2 | |
648 unsigned int x; // [sp+8h] [bp-20h]@2 | |
194 | 649 Vis_SelectionFilter *v10; // [sp+10h] [bp-18h]@2 |
650 Vis_SelectionFilter *v11; // [sp+14h] [bp-14h]@2 | |
0 | 651 POINT a2; // [sp+20h] [bp-8h]@1 |
652 | |
653 //v1 = this; | |
654 ++qword_5C6DF0; | |
655 pParticleEngine->UpdateParticles(); | |
656 pMouseInstance->GetCursorPos(&a2); | |
194 | 657 |
658 x = a2.y; | |
659 y = a2.x; | |
0 | 660 if ( sub_4637E0_is_there_popup_onscreen() ) |
661 { | |
194 | 662 v11 = &vis_face_filter; |
663 v10 = &vis_sprite_filter_2; | |
871 | 664 depth = pGame->pIndoorCameraD3D->GetPickDepth(); |
0 | 665 } |
666 else | |
667 { | |
592 | 668 if ( uFlags2 & GAME_FLAGS_2_TARGETING_MODE ) |
0 | 669 { |
194 | 670 v11 = &vis_face_filter; |
671 v10 = &vis_sprite_filter_1; | |
0 | 672 } |
673 else | |
674 { | |
194 | 675 v11 = &vis_face_filter; |
676 v10 = &vis_sprite_filter_4; | |
0 | 677 } |
194 | 678 depth = 5120.0; |
0 | 679 } |
194 | 680 //depth = v2; |
0 | 681 |
323 | 682 PickMouse(depth, y, x, false, v10, v11); |
0 | 683 pLightmapBuilder->std__vector_000004_size = 0; |
684 pLightmapBuilder->std__vector_183808_size = 0; | |
685 pDecalBuilder->std__vector_pDecals_size = 0; | |
686 pDecalBuilder->field_308008 = 0; | |
194 | 687 if (!_44F07B()) |
688 return false; | |
689 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
638
diff
changeset
|
690 if ( uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS) |
794 | 691 pStru10Instance->bDoNotDrawPortalFrustum = false; |
0 | 692 if ( pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor) |
693 { | |
694 v5 = GetLevelFogColor(); | |
695 pRenderer->uFogColor = v5 & 0xFFFFFF; | |
696 } | |
697 if (uFlags & 0x0400) | |
698 uFlags2 |= 0x01; | |
699 if ( !pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor && pMobileLightsStack->uNumLightsActive ) | |
700 { | |
701 uFlags2 |= 0x01; | |
702 field_E10 = qword_5C6DF0; | |
703 } | |
704 v6 = qword_5C6DF0 - field_E10; | |
705 if ( qword_5C6DF0 - field_E10 == 1 ) | |
706 uFlags2 |= v6; | |
707 if (uNumStationaryLights_in_pStationaryLightsStack != pStationaryLightsStack->uNumLightsActive ) | |
708 { | |
709 uFlags2 |= 1u; | |
710 uNumStationaryLights_in_pStationaryLightsStack = pStationaryLightsStack->uNumLightsActive; | |
711 } | |
712 _44E904(); | |
194 | 713 return true; |
0 | 714 } |
715 | |
716 | |
717 //----- (0044EDE4) -------------------------------------------------------- | |
638 | 718 bool Game::AlterGamma_BLV(BLVFace *pFace, unsigned int *pColor) |
0 | 719 { |
638 | 720 if (uFlags2 & GAME_FLAGS_2_SATURATE_LIGHTMAPS && |
721 pFace->uAttributes & FACE_CAN_SATURATE_COLOR) | |
0 | 722 { |
723 *pColor = ReplaceHSV(*pColor, 1.0, fSaturation, -1.0); | |
724 return true; | |
725 } | |
726 else | |
727 return false; | |
728 } | |
729 | |
730 //----- (0044EE30) -------------------------------------------------------- | |
638 | 731 bool Game::AlterGamma_ODM(ODMFace *pFace, unsigned int *pColor) |
0 | 732 { |
638 | 733 if (uFlags2 & GAME_FLAGS_2_SATURATE_LIGHTMAPS && |
734 pFace->uAttributes & FACE_CAN_SATURATE_COLOR) | |
0 | 735 { |
638 | 736 *pColor = ReplaceHSV(*pColor, 1.0, fSaturation, -1.0); |
0 | 737 return true; |
738 } | |
739 else | |
740 return false; | |
741 } | |
742 | |
743 | |
744 //----- (004645FA) -------------------------------------------------------- | |
745 void Game::Deinitialize() | |
746 { | |
747 struct tagRECT Rect; // [sp+0h] [bp-10h]@6 | |
748 | |
1038 | 749 |
0 | 750 WriteWindowsRegistryInt("startinwindow", pRenderer->bWindowMode); |
751 if ( GetWindowRect(hWnd, &Rect) && pRenderer->bWindowMode ) | |
752 { | |
753 WriteWindowsRegistryInt("window X", Rect.left); | |
754 WriteWindowsRegistryInt("window Y", Rect.top); | |
755 } | |
756 WriteWindowsRegistryInt("valAlwaysRun", bAlwaysRun); | |
757 pItemsTable->Release(); | |
758 pNPCStats->Release(); | |
1038 | 759 |
0 | 760 if (pMouse) |
761 pMouse->Deactivate(); | |
762 | |
1093 | 763 delete pRenderer; |
0 | 764 pAudioPlayer->Release();//error |
765 pNew_LOD->FreeSubIndexAndIO(); | |
766 pGames_LOD->FreeSubIndexAndIO(); | |
767 ClipCursor(0); | |
768 Game::Destroy(); | |
769 } | |
770 | |
771 //----- (0044EE7C) -------------------------------------------------------- | |
772 bool Game::draw_debug_outlines() | |
773 { | |
774 if (uFlags & 0x04) | |
775 { | |
776 pLightmapBuilder->DrawDebugOutlines(-1); | |
777 pDecalBuilder->DrawDecalDebugOutlines(); | |
778 } | |
779 return true; | |
780 } | |
781 | |
782 //----- (0044EC23) -------------------------------------------------------- | |
783 int Game::_44EC23(stru148 *a2, int *a3, signed int a4) | |
784 { | |
785 double v4; // st7@4 | |
786 //double v5; // ST00_8@4 | |
787 signed int v6; // eax@5 | |
788 //double v7; // ST00_8@6 | |
789 signed int result; // eax@8 | |
790 //double v9; // ST00_8@9 | |
791 //double v10; // ST00_8@11 | |
792 float a2a; // [sp+14h] [bp+8h]@4 | |
793 float a3a; // [sp+18h] [bp+Ch]@4 | |
794 float a3b; // [sp+18h] [bp+Ch]@6 | |
795 float a4a; // [sp+1Ch] [bp+10h]@9 | |
796 float a4b; // [sp+1Ch] [bp+10h]@11 | |
797 | |
798 if ( this->uFlags2 & 2 && a2->field_59 == 5 && a2->pODMFace->uAttributes & 2 ) | |
799 { | |
800 v4 = (double)a4; | |
801 a2a = v4; | |
802 *a3 |= 2u; | |
803 a3a = (1.0 - this->fSaturation) * v4; | |
804 //v5 = a3a + 6.7553994e15; | |
805 //if ( SLODWORD(v5) >= 0 ) | |
806 if (floorf(a3a + 0.5f) >= 0 ) | |
807 { | |
808 a3b = (1.0 - this->fSaturation) * a2a; | |
809 //v7 = a3b + 6.7553994e15; | |
810 //v6 = LODWORD(v7); | |
811 v6 = floorf(a3b + 0.5f); | |
812 } | |
813 else | |
814 { | |
815 v6 = 0; | |
816 } | |
817 if ( a4 >= v6 ) | |
818 { | |
819 a4a = (1.0 - fSaturation) * a2a; | |
820 //v9 = a4a + 6.7553994e15; | |
821 //if ( SLODWORD(v9) >= 0 ) | |
822 if (floorf(a4a + 0.5f) >= 0) | |
823 { | |
824 a4b = (1.0 - fSaturation) * a2a; | |
825 //v10 = a4b + 6.7553994e15; | |
826 //result = LODWORD(v10); | |
827 result = floorf(a4b + 0.5f); | |
828 } | |
829 else | |
830 { | |
831 result = 0; | |
832 } | |
833 } | |
834 else | |
835 { | |
836 result = a4; | |
837 } | |
838 } | |
839 else | |
840 { | |
841 result = -1; | |
842 } | |
843 return result; | |
844 } | |
845 | |
846 | |
847 | |
848 //----- (00465C8B) -------------------------------------------------------- | |
849 Game *Game::Create() | |
850 { | |
851 return new Game; | |
852 } | |
853 | |
854 //----- (00465CF3) -------------------------------------------------------- | |
855 void Game::Destroy() | |
856 { | |
857 if (pGame) | |
858 delete pGame; | |
859 pGame = nullptr; | |
860 } | |
861 | |
862 //----- (0044ED0A) -------------------------------------------------------- | |
863 signed int Game::_44ED0A(BLVFace *a2, int *a3, signed int a4) | |
864 { | |
865 double v4; // st7@3 | |
866 //double v5; // ST00_8@3 | |
867 signed int v6; // eax@4 | |
868 //double v7; // ST00_8@5 | |
869 signed int result; // eax@7 | |
870 //double v9; // ST00_8@8 | |
871 //double v10; // ST00_8@10 | |
872 float v11; // [sp+14h] [bp+8h]@3 | |
873 float v12; // [sp+18h] [bp+Ch]@3 | |
874 float v13; // [sp+18h] [bp+Ch]@5 | |
875 float v14; // [sp+1Ch] [bp+10h]@8 | |
876 float v15; // [sp+1Ch] [bp+10h]@10 | |
877 | |
878 if ( this->uFlags2 & 2 && a2->uAttributes & 2 ) | |
879 { | |
880 v4 = (double)a4; | |
881 v11 = v4; | |
882 *a3 |= 2u; | |
883 v12 = (1.0 - this->fSaturation) * v4; | |
884 //v5 = v12 + 6.7553994e15; | |
885 if (floorf(v12 + 0.5f)/* SLODWORD(v5)*/ >= 0 ) | |
886 { | |
887 v13 = (1.0 - this->fSaturation) * v11; | |
888 //v7 = v13 + 6.7553994e15; | |
889 //v6 = LODWORD(v7); | |
890 v6 = floorf(v13 + 0.5f); | |
891 } | |
892 else | |
893 { | |
894 v6 = 0; | |
895 } | |
896 if ( a4 >= v6 ) | |
897 { | |
898 v14 = (1.0 - fSaturation) * v11; | |
899 //v9 = v14 + 6.7553994e15; | |
900 if (floorf(v14 + 0.5f)/* SLODWORD(v9)*/ >= 0 ) | |
901 { | |
902 v15 = (1.0 - fSaturation) * v11; | |
903 //v10 = v15 + 6.7553994e15; | |
904 //result = LODWORD(v10); | |
905 result = floorf(v15 + 0.5f); | |
906 } | |
907 else | |
908 { | |
909 result = 0; | |
910 } | |
911 } | |
912 else | |
913 { | |
914 result = a4; | |
915 } | |
916 } | |
917 else | |
918 { | |
919 result = -1; | |
920 } | |
921 return result; | |
922 } | |
923 | |
924 | |
925 //----- (0044E4B7) -------------------------------------------------------- | |
926 Game::Game() | |
927 { | |
928 uNumStationaryLights = 0; | |
929 uNumBloodsplats = 0; | |
930 field_E0C = 0; | |
931 field_E10 = 0; | |
932 uNumStationaryLights_in_pStationaryLightsStack = 0; | |
933 bGammaControlInitialized = false; | |
934 uFlags = 0; | |
935 uFlags2 = 0; | |
936 uSomeGammaStartTime = 0; | |
937 uSomeGammaDeltaTime = 0; | |
938 | |
939 pThreadWardInstance = new ThreadWard; | |
940 pParticleEngine = new ParticleEngine; | |
941 pMouse = pMouseInstance = new Mouse(pThreadWardInstance); | |
942 pLightmapBuilder = new LightmapBuilder; | |
943 pVisInstance = new Vis; | |
944 pStru6Instance = new stru6; | |
945 pIndoorCameraD3D = new IndoorCameraD3D; | |
946 pStru9Instance = new stru9; | |
947 pStru10Instance = new stru10; | |
948 pStru11Instance = new stru11; | |
949 pStru12Instance = new stru12(pStru11Instance); | |
950 pCShow = new CShow; | |
951 pKeyboardInstance = new Keyboard; | |
952 pGammaController = new GammaController; | |
953 | |
954 uFlags |= 0x0800; | |
955 uFlags2 |= 0x24; | |
956 | |
957 _44F0FD(); | |
958 | |
959 bWinNT4_0 = false; | |
960 if (pVersion->pVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && | |
961 pVersion->pVersionInfo.dwMajorVersion == 4) | |
962 bWinNT4_0 = true; | |
963 } | |
964 | |
965 //----- (0044E7F3) -------------------------------------------------------- | |
966 Game::~Game() | |
967 { | |
968 if (pGammaController) | |
969 delete pGammaController; | |
970 if (pKeyboardInstance) | |
971 delete pKeyboardInstance; | |
972 if (pCShow) | |
973 delete pCShow; | |
974 if (pStru12Instance) | |
975 delete pStru12Instance; | |
976 if (pStru11Instance) | |
977 delete pStru11Instance; | |
978 if (pStru10Instance) | |
979 delete pStru10Instance; | |
980 if (pStru9Instance) | |
981 delete pStru9Instance; | |
982 if (pIndoorCameraD3D) | |
983 delete pIndoorCameraD3D; | |
984 if (pStru6Instance) | |
985 delete pStru6Instance; | |
986 if (pVisInstance) | |
987 delete pVisInstance; | |
988 if (pLightmapBuilder) | |
989 delete pLightmapBuilder; | |
990 if (pMouseInstance) | |
991 delete pMouseInstance; | |
992 if (pParticleEngine) | |
993 delete pParticleEngine; | |
994 if (pThreadWardInstance) | |
995 delete pThreadWardInstance; | |
996 } | |
997 | |
998 //----- (0044E904) -------------------------------------------------------- | |
999 void Game::_44E904() | |
1000 { | |
1001 //Game *v1; // esi@1 | |
1002 unsigned __int64 v2; // qax@1 | |
1003 unsigned int v3; // ecx@1 | |
1004 int v4; // edi@1 | |
1005 unsigned __int8 v5; // cf@7 | |
1006 double v6; // st7@13 | |
1007 double v7; // st7@15 | |
1008 signed __int64 v8; // [sp+Ch] [bp-8h]@1 | |
1009 | |
1010 //v1 = this; | |
1011 v2 = pEventTimer->Time(); | |
1012 v4 = (v2 - uSomeGammaStartTime) >> 32; | |
1013 v3 = v2 - LODWORD(uSomeGammaStartTime); | |
1014 v8 = v2 - uSomeGammaStartTime; | |
1015 if ( v4 < 0 | |
1016 || SHIDWORD(v2) < ((unsigned int)v2 < LODWORD(uSomeGammaStartTime)) + HIDWORD(uSomeGammaStartTime) | v4 == 0 | |
1017 && v3 <= 0x80 ) | |
1018 { | |
1019 if ( v4 > 0 || v4 >= 0 ) | |
1020 goto LABEL_12; | |
1021 v3 = 0; | |
1022 v4 = 0; | |
1023 } | |
1024 else | |
1025 { | |
1026 if ( uSomeGammaDeltaTime ) | |
1027 { | |
1028 LODWORD(uSomeGammaDeltaTime) = 0; | |
1029 HIDWORD(uSomeGammaDeltaTime) = 0; | |
1030 } | |
1031 else | |
1032 { | |
1033 LODWORD(uSomeGammaDeltaTime) = v3; | |
1034 HIDWORD(uSomeGammaDeltaTime) = v4; | |
1035 } | |
1036 v5 = __CFADD__(v3, -128); | |
1037 v3 -= 128; | |
1038 v4 = v5 + v4 - 1; | |
1039 } | |
1040 uSomeGammaStartTime = v2; | |
1041 v8 = __PAIR__(v4, v3); | |
1042 LABEL_12: | |
1043 if ( uSomeGammaDeltaTime ) | |
1044 v6 = (double)(signed __int64)(uSomeGammaDeltaTime - __PAIR__(v4, v3)); | |
1045 else | |
1046 v6 = (double)v8; | |
1047 v7 = v6 * 0.0078125; | |
1048 if ( v7 < 0.0 || v7 <= 1.0 ) | |
1049 { | |
1050 if ( v7 < 0.0 ) | |
1051 v7 = 0.0; | |
1052 } | |
1053 else | |
1054 { | |
1055 v7 = 1.0; | |
1056 } | |
1057 if ( pRenderer->pRenderD3D ) | |
1058 fSaturation = v7; | |
1059 else | |
1060 fSaturation = (1.0 - 0.5) * v7 + 0.5; | |
1061 } | |
1062 | |
1063 //----- (0044EA17) -------------------------------------------------------- | |
1064 bool Game::InitializeGammaController() | |
1065 { | |
1066 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
1067 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
1068 pGammaController->InitializeFromSurface(pRenderer->pFrontBuffer4); | |
1069 | |
1070 bGammaControlInitialized = true; | |
1071 uSomeGammaStartTime = pEventTimer->Time(); | |
1072 return true; | |
1073 } | |
1074 | |
1075 //----- (0044EA5E) -------------------------------------------------------- | |
194 | 1076 bool Game::PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) |
0 | 1077 { |
227 | 1078 if (pCurrentScreen != SCREEN_GAME|| !pRenderer->pRenderD3D) |
194 | 1079 return false; |
0 | 1080 |
194 | 1081 if (!pVisInstance) |
0 | 1082 { |
194 | 1083 MessageBoxW(nullptr, L"The 'Vis' object pointer has not been instatiated, but CGame::Pick() is trying to call through it.", nullptr, 0); |
1084 return false; | |
1085 } | |
0 | 1086 |
692 | 1087 if (uMouseX >= (signed int)pViewport->uScreen_TL_X && |
1088 uMouseX <= (signed int)pViewport->uScreen_BR_X && | |
1089 uMouseY >= (signed int)pViewport->uScreen_TL_Y && | |
1090 uMouseY <= (signed int)pViewport->uScreen_BR_Y) | |
194 | 1091 { |
1092 pVisInstance->PickMouse(fPickDepth, uMouseX, uMouseY, sprite_filter, face_filter); | |
0 | 1093 |
194 | 1094 if (bOutline) |
1095 OutlineSelection(); | |
0 | 1096 } |
194 | 1097 |
1098 return true; | |
0 | 1099 } |
1100 // 4E28F8: using guessed type int pCurrentScreen; | |
1101 | |
1102 //----- (0044EB12) -------------------------------------------------------- | |
194 | 1103 bool Game::PickKeyboard(bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) |
0 | 1104 { |
271 | 1105 if (pCurrentScreen == SCREEN_GAME && pVisInstance && pRenderer->pRenderD3D) |
0 | 1106 { |
194 | 1107 bool r = pVisInstance->PickKeyboard(&pVisInstance->default_list, sprite_filter, face_filter); |
0 | 1108 |
1109 if (bOutline) | |
1110 OutlineSelection(); | |
1111 return r; | |
1112 } | |
1113 return false; | |
1114 } | |
123 | 1115 /* |
1116 Result::Code Game::PickKeyboard(bool bOutline, struct unnamed_F93E6C *a3, struct unnamed_F93E6C *a4) | |
1117 { | |
1118 if (dword_4E28F8_PartyCantJumpIfTrue) | |
1119 return Result::Generic; | |
1120 | |
1121 pVis->PickKeyboard(a3, a4); | |
1122 if (bOutline) | |
1123 Game_outline_selection((int)this); | |
1124 return Result::Success; | |
1125 } | |
1126 */ | |
0 | 1127 // 4E28F8: using guessed type int pCurrentScreen; |
1128 | |
1129 //----- (0044EB5A) -------------------------------------------------------- | |
1130 void Game::OutlineSelection() | |
1131 { | |
194 | 1132 if (!pVisInstance) |
1133 return; | |
1134 | |
1135 if (!pVisInstance->default_list.uNumPointers) | |
1136 return; | |
0 | 1137 |
194 | 1138 auto object_info = pVisInstance->default_list.object_pointers[0]; |
1139 if (object_info) | |
1140 switch (object_info->object_type) | |
0 | 1141 { |
194 | 1142 case VisObjectType_Sprite: |
0 | 1143 { |
194 | 1144 Log::Warning(L"Sprite outline currently unsupported"); |
1145 return; | |
0 | 1146 } |
1147 | |
194 | 1148 case VisObjectType_Face: |
1149 { | |
1150 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
0 | 1151 { |
194 | 1152 auto face = (ODMFace *)object_info->object; |
1153 if (face->uAttributes & FACE_OUTLINED) | |
1154 face->uAttributes &= ~FACE_OUTLINED; | |
0 | 1155 else |
194 | 1156 face->uAttributes |= FACE_OUTLINED; |
1157 } | |
1158 else if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
1159 { | |
1160 auto face = (BLVFace *)object_info->object; | |
1161 if (face->uAttributes & FACE_OUTLINED) | |
1162 face->uAttributes &= ~FACE_OUTLINED; | |
1163 else | |
1164 face->uAttributes |= FACE_OUTLINED; | |
0 | 1165 } |
194 | 1166 else assert(false); |
1167 } | |
323 | 1168 break; |
194 | 1169 |
1170 default: | |
1171 { | |
1172 MessageBoxW(nullptr, L"Undefined CObjectInfo type requested in CGame::outline_selection()", nullptr, 0); | |
1173 ExitProcess(0); | |
1174 } | |
0 | 1175 } |
1176 } |