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