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