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