Mercurial > mm7
annotate Game.cpp @ 1080:9456f2ed5ff9
getskillbonus continue cleaning
author | Gloval |
---|---|
date | Sat, 25 May 2013 23:50:56 +0400 |
parents | bcebd491e8fa |
children | c59ac5ea63f5 c40d40027b77 |
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 { | |
78 | 94 if ( pParty->vPosition.x != pParty->vPrevPosition.x | pParty->sRotationY != pParty->sPrevRotationY | pParty->vPosition.y != pParty->vPrevPosition.y |
101 | 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; | |
513 if ( _strcmpi(Source, pCurrentMapName) ) | |
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 { | |
585 signed int v3; // ebx@1 | |
586 char *v4; // esi@2 | |
587 | |
588 auto v2 = this; | |
589 v3 = 0; | |
590 if ( (signed int)this->uNumStationaryLights > 0 ) | |
591 { | |
592 v4 = (char *)&this->pStationaryLights[0].vRGBColor.y; | |
593 do | |
594 { | |
595 pStationaryLightsStack->AddLight( | |
596 (signed __int64)*((float *)v4 - 4), | |
597 (signed __int64)*((float *)v4 - 3), | |
598 (signed __int64)*((float *)v4 - 2), | |
599 (signed __int64)*((float *)v4 + 2), | |
600 (signed __int64)*((float *)v4 - 1), | |
601 (signed __int64)*(float *)v4, | |
602 (signed __int64)*((float *)v4 + 1), | |
603 byte_4E94D0); | |
604 ++v3; | |
605 v4 += 28; | |
606 } | |
607 while ( v3 < (signed int)v2->uNumStationaryLights ); | |
608 } | |
609 } | |
610 // 4E94D0: using guessed type char byte_4E94D0; | |
611 | |
612 //----- (0044F0FD) -------------------------------------------------------- | |
613 void Game::_44F0FD() | |
614 { | |
615 ToggleFlags(0x40u); | |
616 | |
617 if ( !(uFlags & 0x40) ) | |
618 { | |
619 uNumBloodsplats = 0; | |
620 field_E0C = 0; | |
621 } | |
622 } | |
623 | |
624 //----- (0044F0D8) -------------------------------------------------------- | |
625 void Game::ToggleFlags(uint uMask) | |
626 { | |
627 if (uFlags & uMask) | |
628 uFlags &= ~uMask; | |
629 else | |
630 uFlags |= uMask; | |
631 } | |
632 | |
633 | |
634 //----- (0044F07B) -------------------------------------------------------- | |
635 bool Game::_44F07B() | |
636 { | |
637 if (!pKeyboardInstance->IsKeyBeingHeld(VK_SHIFT) && | |
638 !pKeyboardInstance->IsKeyBeingHeld(VK_LSHIFT) && | |
639 !pKeyboardInstance->IsKeyBeingHeld(VK_LSHIFT) || | |
640 | |
641 (pKeyboardInstance->WasKeyPressed(VK_F11) == 0 && | |
642 pKeyboardInstance->WasKeyPressed(VK_F11))) | |
643 return true; | |
644 return false; | |
645 } | |
646 | |
647 //----- (0044EEA7) -------------------------------------------------------- | |
648 bool Game::_44EEA7() | |
649 { | |
650 //Game *v1; // esi@1 | |
194 | 651 //double v2; // st7@2 |
0 | 652 float depth; // ST00_4@9 |
194 | 653 //bool result; // eax@9 |
0 | 654 unsigned int v5; // eax@14 |
655 __int64 v6; // kr00_8@21 | |
656 unsigned int y; // [sp+4h] [bp-24h]@2 | |
657 unsigned int x; // [sp+8h] [bp-20h]@2 | |
194 | 658 Vis_SelectionFilter *v10; // [sp+10h] [bp-18h]@2 |
659 Vis_SelectionFilter *v11; // [sp+14h] [bp-14h]@2 | |
0 | 660 POINT a2; // [sp+20h] [bp-8h]@1 |
661 | |
662 //v1 = this; | |
663 ++qword_5C6DF0; | |
664 pParticleEngine->UpdateParticles(); | |
665 pMouseInstance->GetCursorPos(&a2); | |
194 | 666 |
667 x = a2.y; | |
668 y = a2.x; | |
0 | 669 if ( sub_4637E0_is_there_popup_onscreen() ) |
670 { | |
194 | 671 v11 = &vis_face_filter; |
672 v10 = &vis_sprite_filter_2; | |
871 | 673 depth = pGame->pIndoorCameraD3D->GetPickDepth(); |
0 | 674 } |
675 else | |
676 { | |
592 | 677 if ( uFlags2 & GAME_FLAGS_2_TARGETING_MODE ) |
0 | 678 { |
194 | 679 v11 = &vis_face_filter; |
680 v10 = &vis_sprite_filter_1; | |
0 | 681 } |
682 else | |
683 { | |
194 | 684 v11 = &vis_face_filter; |
685 v10 = &vis_sprite_filter_4; | |
0 | 686 } |
194 | 687 depth = 5120.0; |
0 | 688 } |
194 | 689 //depth = v2; |
0 | 690 |
323 | 691 PickMouse(depth, y, x, false, v10, v11); |
0 | 692 pLightmapBuilder->std__vector_000004_size = 0; |
693 pLightmapBuilder->std__vector_183808_size = 0; | |
694 pDecalBuilder->std__vector_pDecals_size = 0; | |
695 pDecalBuilder->field_308008 = 0; | |
194 | 696 if (!_44F07B()) |
697 return false; | |
698 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
638
diff
changeset
|
699 if ( uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS) |
794 | 700 pStru10Instance->bDoNotDrawPortalFrustum = false; |
0 | 701 if ( pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor) |
702 { | |
703 v5 = GetLevelFogColor(); | |
704 pRenderer->uFogColor = v5 & 0xFFFFFF; | |
705 } | |
706 if (uFlags & 0x0400) | |
707 uFlags2 |= 0x01; | |
708 if ( !pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor && pMobileLightsStack->uNumLightsActive ) | |
709 { | |
710 uFlags2 |= 0x01; | |
711 field_E10 = qword_5C6DF0; | |
712 } | |
713 v6 = qword_5C6DF0 - field_E10; | |
714 if ( qword_5C6DF0 - field_E10 == 1 ) | |
715 uFlags2 |= v6; | |
716 if (uNumStationaryLights_in_pStationaryLightsStack != pStationaryLightsStack->uNumLightsActive ) | |
717 { | |
718 uFlags2 |= 1u; | |
719 uNumStationaryLights_in_pStationaryLightsStack = pStationaryLightsStack->uNumLightsActive; | |
720 } | |
721 _44E904(); | |
194 | 722 return true; |
0 | 723 } |
724 | |
725 | |
726 //----- (0044EDE4) -------------------------------------------------------- | |
638 | 727 bool Game::AlterGamma_BLV(BLVFace *pFace, unsigned int *pColor) |
0 | 728 { |
638 | 729 if (uFlags2 & GAME_FLAGS_2_SATURATE_LIGHTMAPS && |
730 pFace->uAttributes & FACE_CAN_SATURATE_COLOR) | |
0 | 731 { |
732 *pColor = ReplaceHSV(*pColor, 1.0, fSaturation, -1.0); | |
733 return true; | |
734 } | |
735 else | |
736 return false; | |
737 } | |
738 | |
739 //----- (0044EE30) -------------------------------------------------------- | |
638 | 740 bool Game::AlterGamma_ODM(ODMFace *pFace, unsigned int *pColor) |
0 | 741 { |
638 | 742 if (uFlags2 & GAME_FLAGS_2_SATURATE_LIGHTMAPS && |
743 pFace->uAttributes & FACE_CAN_SATURATE_COLOR) | |
0 | 744 { |
638 | 745 *pColor = ReplaceHSV(*pColor, 1.0, fSaturation, -1.0); |
0 | 746 return true; |
747 } | |
748 else | |
749 return false; | |
750 } | |
751 | |
752 | |
753 //----- (004645FA) -------------------------------------------------------- | |
754 void Game::Deinitialize() | |
755 { | |
756 struct tagRECT Rect; // [sp+0h] [bp-10h]@6 | |
757 | |
1038 | 758 |
0 | 759 WriteWindowsRegistryInt("startinwindow", pRenderer->bWindowMode); |
760 if ( GetWindowRect(hWnd, &Rect) && pRenderer->bWindowMode ) | |
761 { | |
762 WriteWindowsRegistryInt("window X", Rect.left); | |
763 WriteWindowsRegistryInt("window Y", Rect.top); | |
764 } | |
765 WriteWindowsRegistryInt("valAlwaysRun", bAlwaysRun); | |
766 pItemsTable->Release(); | |
767 pNPCStats->Release(); | |
1038 | 768 |
0 | 769 if (pMouse) |
770 pMouse->Deactivate(); | |
771 | |
772 pAudioPlayer->Release();//error | |
773 pNew_LOD->FreeSubIndexAndIO(); | |
774 pGames_LOD->FreeSubIndexAndIO(); | |
775 ClipCursor(0); | |
776 Game::Destroy(); | |
777 } | |
778 | |
779 //----- (0044EE7C) -------------------------------------------------------- | |
780 bool Game::draw_debug_outlines() | |
781 { | |
782 if (uFlags & 0x04) | |
783 { | |
784 pLightmapBuilder->DrawDebugOutlines(-1); | |
785 pDecalBuilder->DrawDecalDebugOutlines(); | |
786 } | |
787 return true; | |
788 } | |
789 | |
790 //----- (0044EC23) -------------------------------------------------------- | |
791 int Game::_44EC23(stru148 *a2, int *a3, signed int a4) | |
792 { | |
793 double v4; // st7@4 | |
794 //double v5; // ST00_8@4 | |
795 signed int v6; // eax@5 | |
796 //double v7; // ST00_8@6 | |
797 signed int result; // eax@8 | |
798 //double v9; // ST00_8@9 | |
799 //double v10; // ST00_8@11 | |
800 float a2a; // [sp+14h] [bp+8h]@4 | |
801 float a3a; // [sp+18h] [bp+Ch]@4 | |
802 float a3b; // [sp+18h] [bp+Ch]@6 | |
803 float a4a; // [sp+1Ch] [bp+10h]@9 | |
804 float a4b; // [sp+1Ch] [bp+10h]@11 | |
805 | |
806 if ( this->uFlags2 & 2 && a2->field_59 == 5 && a2->pODMFace->uAttributes & 2 ) | |
807 { | |
808 v4 = (double)a4; | |
809 a2a = v4; | |
810 *a3 |= 2u; | |
811 a3a = (1.0 - this->fSaturation) * v4; | |
812 //v5 = a3a + 6.7553994e15; | |
813 //if ( SLODWORD(v5) >= 0 ) | |
814 if (floorf(a3a + 0.5f) >= 0 ) | |
815 { | |
816 a3b = (1.0 - this->fSaturation) * a2a; | |
817 //v7 = a3b + 6.7553994e15; | |
818 //v6 = LODWORD(v7); | |
819 v6 = floorf(a3b + 0.5f); | |
820 } | |
821 else | |
822 { | |
823 v6 = 0; | |
824 } | |
825 if ( a4 >= v6 ) | |
826 { | |
827 a4a = (1.0 - fSaturation) * a2a; | |
828 //v9 = a4a + 6.7553994e15; | |
829 //if ( SLODWORD(v9) >= 0 ) | |
830 if (floorf(a4a + 0.5f) >= 0) | |
831 { | |
832 a4b = (1.0 - fSaturation) * a2a; | |
833 //v10 = a4b + 6.7553994e15; | |
834 //result = LODWORD(v10); | |
835 result = floorf(a4b + 0.5f); | |
836 } | |
837 else | |
838 { | |
839 result = 0; | |
840 } | |
841 } | |
842 else | |
843 { | |
844 result = a4; | |
845 } | |
846 } | |
847 else | |
848 { | |
849 result = -1; | |
850 } | |
851 return result; | |
852 } | |
853 | |
854 | |
855 | |
856 //----- (00465C8B) -------------------------------------------------------- | |
857 Game *Game::Create() | |
858 { | |
859 return new Game; | |
860 } | |
861 | |
862 //----- (00465CF3) -------------------------------------------------------- | |
863 void Game::Destroy() | |
864 { | |
865 if (pGame) | |
866 delete pGame; | |
867 pGame = nullptr; | |
868 } | |
869 | |
870 //----- (0044ED0A) -------------------------------------------------------- | |
871 signed int Game::_44ED0A(BLVFace *a2, int *a3, signed int a4) | |
872 { | |
873 double v4; // st7@3 | |
874 //double v5; // ST00_8@3 | |
875 signed int v6; // eax@4 | |
876 //double v7; // ST00_8@5 | |
877 signed int result; // eax@7 | |
878 //double v9; // ST00_8@8 | |
879 //double v10; // ST00_8@10 | |
880 float v11; // [sp+14h] [bp+8h]@3 | |
881 float v12; // [sp+18h] [bp+Ch]@3 | |
882 float v13; // [sp+18h] [bp+Ch]@5 | |
883 float v14; // [sp+1Ch] [bp+10h]@8 | |
884 float v15; // [sp+1Ch] [bp+10h]@10 | |
885 | |
886 if ( this->uFlags2 & 2 && a2->uAttributes & 2 ) | |
887 { | |
888 v4 = (double)a4; | |
889 v11 = v4; | |
890 *a3 |= 2u; | |
891 v12 = (1.0 - this->fSaturation) * v4; | |
892 //v5 = v12 + 6.7553994e15; | |
893 if (floorf(v12 + 0.5f)/* SLODWORD(v5)*/ >= 0 ) | |
894 { | |
895 v13 = (1.0 - this->fSaturation) * v11; | |
896 //v7 = v13 + 6.7553994e15; | |
897 //v6 = LODWORD(v7); | |
898 v6 = floorf(v13 + 0.5f); | |
899 } | |
900 else | |
901 { | |
902 v6 = 0; | |
903 } | |
904 if ( a4 >= v6 ) | |
905 { | |
906 v14 = (1.0 - fSaturation) * v11; | |
907 //v9 = v14 + 6.7553994e15; | |
908 if (floorf(v14 + 0.5f)/* SLODWORD(v9)*/ >= 0 ) | |
909 { | |
910 v15 = (1.0 - fSaturation) * v11; | |
911 //v10 = v15 + 6.7553994e15; | |
912 //result = LODWORD(v10); | |
913 result = floorf(v15 + 0.5f); | |
914 } | |
915 else | |
916 { | |
917 result = 0; | |
918 } | |
919 } | |
920 else | |
921 { | |
922 result = a4; | |
923 } | |
924 } | |
925 else | |
926 { | |
927 result = -1; | |
928 } | |
929 return result; | |
930 } | |
931 | |
932 | |
933 //----- (0044E4B7) -------------------------------------------------------- | |
934 Game::Game() | |
935 { | |
936 uNumStationaryLights = 0; | |
937 uNumBloodsplats = 0; | |
938 field_E0C = 0; | |
939 field_E10 = 0; | |
940 uNumStationaryLights_in_pStationaryLightsStack = 0; | |
941 bGammaControlInitialized = false; | |
942 uFlags = 0; | |
943 uFlags2 = 0; | |
944 uSomeGammaStartTime = 0; | |
945 uSomeGammaDeltaTime = 0; | |
946 | |
947 pThreadWardInstance = new ThreadWard; | |
948 pParticleEngine = new ParticleEngine; | |
949 pMouse = pMouseInstance = new Mouse(pThreadWardInstance); | |
950 pLightmapBuilder = new LightmapBuilder; | |
951 pVisInstance = new Vis; | |
952 pStru6Instance = new stru6; | |
953 pIndoorCameraD3D = new IndoorCameraD3D; | |
954 pStru9Instance = new stru9; | |
955 pStru10Instance = new stru10; | |
956 pStru11Instance = new stru11; | |
957 pStru12Instance = new stru12(pStru11Instance); | |
958 pCShow = new CShow; | |
959 pKeyboardInstance = new Keyboard; | |
960 pGammaController = new GammaController; | |
961 | |
962 uFlags |= 0x0800; | |
963 uFlags2 |= 0x24; | |
964 | |
965 _44F0FD(); | |
966 | |
967 bWinNT4_0 = false; | |
968 if (pVersion->pVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && | |
969 pVersion->pVersionInfo.dwMajorVersion == 4) | |
970 bWinNT4_0 = true; | |
971 } | |
972 | |
973 //----- (0044E7F3) -------------------------------------------------------- | |
974 Game::~Game() | |
975 { | |
976 if (pGammaController) | |
977 delete pGammaController; | |
978 if (pKeyboardInstance) | |
979 delete pKeyboardInstance; | |
980 if (pCShow) | |
981 delete pCShow; | |
982 if (pStru12Instance) | |
983 delete pStru12Instance; | |
984 if (pStru11Instance) | |
985 delete pStru11Instance; | |
986 if (pStru10Instance) | |
987 delete pStru10Instance; | |
988 if (pStru9Instance) | |
989 delete pStru9Instance; | |
990 if (pIndoorCameraD3D) | |
991 delete pIndoorCameraD3D; | |
992 if (pStru6Instance) | |
993 delete pStru6Instance; | |
994 if (pVisInstance) | |
995 delete pVisInstance; | |
996 if (pLightmapBuilder) | |
997 delete pLightmapBuilder; | |
998 if (pMouseInstance) | |
999 delete pMouseInstance; | |
1000 if (pParticleEngine) | |
1001 delete pParticleEngine; | |
1002 if (pThreadWardInstance) | |
1003 delete pThreadWardInstance; | |
1004 } | |
1005 | |
1006 //----- (0044E904) -------------------------------------------------------- | |
1007 void Game::_44E904() | |
1008 { | |
1009 //Game *v1; // esi@1 | |
1010 unsigned __int64 v2; // qax@1 | |
1011 unsigned int v3; // ecx@1 | |
1012 int v4; // edi@1 | |
1013 unsigned __int8 v5; // cf@7 | |
1014 double v6; // st7@13 | |
1015 double v7; // st7@15 | |
1016 signed __int64 v8; // [sp+Ch] [bp-8h]@1 | |
1017 | |
1018 //v1 = this; | |
1019 v2 = pEventTimer->Time(); | |
1020 v4 = (v2 - uSomeGammaStartTime) >> 32; | |
1021 v3 = v2 - LODWORD(uSomeGammaStartTime); | |
1022 v8 = v2 - uSomeGammaStartTime; | |
1023 if ( v4 < 0 | |
1024 || SHIDWORD(v2) < ((unsigned int)v2 < LODWORD(uSomeGammaStartTime)) + HIDWORD(uSomeGammaStartTime) | v4 == 0 | |
1025 && v3 <= 0x80 ) | |
1026 { | |
1027 if ( v4 > 0 || v4 >= 0 ) | |
1028 goto LABEL_12; | |
1029 v3 = 0; | |
1030 v4 = 0; | |
1031 } | |
1032 else | |
1033 { | |
1034 if ( uSomeGammaDeltaTime ) | |
1035 { | |
1036 LODWORD(uSomeGammaDeltaTime) = 0; | |
1037 HIDWORD(uSomeGammaDeltaTime) = 0; | |
1038 } | |
1039 else | |
1040 { | |
1041 LODWORD(uSomeGammaDeltaTime) = v3; | |
1042 HIDWORD(uSomeGammaDeltaTime) = v4; | |
1043 } | |
1044 v5 = __CFADD__(v3, -128); | |
1045 v3 -= 128; | |
1046 v4 = v5 + v4 - 1; | |
1047 } | |
1048 uSomeGammaStartTime = v2; | |
1049 v8 = __PAIR__(v4, v3); | |
1050 LABEL_12: | |
1051 if ( uSomeGammaDeltaTime ) | |
1052 v6 = (double)(signed __int64)(uSomeGammaDeltaTime - __PAIR__(v4, v3)); | |
1053 else | |
1054 v6 = (double)v8; | |
1055 v7 = v6 * 0.0078125; | |
1056 if ( v7 < 0.0 || v7 <= 1.0 ) | |
1057 { | |
1058 if ( v7 < 0.0 ) | |
1059 v7 = 0.0; | |
1060 } | |
1061 else | |
1062 { | |
1063 v7 = 1.0; | |
1064 } | |
1065 if ( pRenderer->pRenderD3D ) | |
1066 fSaturation = v7; | |
1067 else | |
1068 fSaturation = (1.0 - 0.5) * v7 + 0.5; | |
1069 } | |
1070 | |
1071 //----- (0044EA17) -------------------------------------------------------- | |
1072 bool Game::InitializeGammaController() | |
1073 { | |
1074 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
1075 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
1076 pGammaController->InitializeFromSurface(pRenderer->pFrontBuffer4); | |
1077 | |
1078 bGammaControlInitialized = true; | |
1079 uSomeGammaStartTime = pEventTimer->Time(); | |
1080 return true; | |
1081 } | |
1082 | |
1083 //----- (0044EA5E) -------------------------------------------------------- | |
194 | 1084 bool Game::PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) |
0 | 1085 { |
227 | 1086 if (pCurrentScreen != SCREEN_GAME|| !pRenderer->pRenderD3D) |
194 | 1087 return false; |
0 | 1088 |
194 | 1089 if (!pVisInstance) |
0 | 1090 { |
194 | 1091 MessageBoxW(nullptr, L"The 'Vis' object pointer has not been instatiated, but CGame::Pick() is trying to call through it.", nullptr, 0); |
1092 return false; | |
1093 } | |
0 | 1094 |
692 | 1095 if (uMouseX >= (signed int)pViewport->uScreen_TL_X && |
1096 uMouseX <= (signed int)pViewport->uScreen_BR_X && | |
1097 uMouseY >= (signed int)pViewport->uScreen_TL_Y && | |
1098 uMouseY <= (signed int)pViewport->uScreen_BR_Y) | |
194 | 1099 { |
1100 pVisInstance->PickMouse(fPickDepth, uMouseX, uMouseY, sprite_filter, face_filter); | |
0 | 1101 |
194 | 1102 if (bOutline) |
1103 OutlineSelection(); | |
0 | 1104 } |
194 | 1105 |
1106 return true; | |
0 | 1107 } |
1108 // 4E28F8: using guessed type int pCurrentScreen; | |
1109 | |
1110 //----- (0044EB12) -------------------------------------------------------- | |
194 | 1111 bool Game::PickKeyboard(bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) |
0 | 1112 { |
271 | 1113 if (pCurrentScreen == SCREEN_GAME && pVisInstance && pRenderer->pRenderD3D) |
0 | 1114 { |
194 | 1115 bool r = pVisInstance->PickKeyboard(&pVisInstance->default_list, sprite_filter, face_filter); |
0 | 1116 |
1117 if (bOutline) | |
1118 OutlineSelection(); | |
1119 return r; | |
1120 } | |
1121 return false; | |
1122 } | |
123 | 1123 /* |
1124 Result::Code Game::PickKeyboard(bool bOutline, struct unnamed_F93E6C *a3, struct unnamed_F93E6C *a4) | |
1125 { | |
1126 if (dword_4E28F8_PartyCantJumpIfTrue) | |
1127 return Result::Generic; | |
1128 | |
1129 pVis->PickKeyboard(a3, a4); | |
1130 if (bOutline) | |
1131 Game_outline_selection((int)this); | |
1132 return Result::Success; | |
1133 } | |
1134 */ | |
0 | 1135 // 4E28F8: using guessed type int pCurrentScreen; |
1136 | |
1137 //----- (0044EB5A) -------------------------------------------------------- | |
1138 void Game::OutlineSelection() | |
1139 { | |
194 | 1140 if (!pVisInstance) |
1141 return; | |
1142 | |
1143 if (!pVisInstance->default_list.uNumPointers) | |
1144 return; | |
0 | 1145 |
194 | 1146 auto object_info = pVisInstance->default_list.object_pointers[0]; |
1147 if (object_info) | |
1148 switch (object_info->object_type) | |
0 | 1149 { |
194 | 1150 case VisObjectType_Sprite: |
0 | 1151 { |
194 | 1152 Log::Warning(L"Sprite outline currently unsupported"); |
1153 return; | |
0 | 1154 } |
1155 | |
194 | 1156 case VisObjectType_Face: |
1157 { | |
1158 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
0 | 1159 { |
194 | 1160 auto face = (ODMFace *)object_info->object; |
1161 if (face->uAttributes & FACE_OUTLINED) | |
1162 face->uAttributes &= ~FACE_OUTLINED; | |
0 | 1163 else |
194 | 1164 face->uAttributes |= FACE_OUTLINED; |
1165 } | |
1166 else if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
1167 { | |
1168 auto face = (BLVFace *)object_info->object; | |
1169 if (face->uAttributes & FACE_OUTLINED) | |
1170 face->uAttributes &= ~FACE_OUTLINED; | |
1171 else | |
1172 face->uAttributes |= FACE_OUTLINED; | |
0 | 1173 } |
194 | 1174 else assert(false); |
1175 } | |
323 | 1176 break; |
194 | 1177 |
1178 default: | |
1179 { | |
1180 MessageBoxW(nullptr, L"Undefined CObjectInfo type requested in CGame::outline_selection()", nullptr, 0); | |
1181 ExitProcess(0); | |
1182 } | |
0 | 1183 } |
1184 } |