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