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