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