Mercurial > mm7
annotate Game.cpp @ 1318:0ec2f944fccc
Слияние
author | Ritor1 |
---|---|
date | Wed, 26 Jun 2013 14:22:02 +0600 |
parents | 1803172dffd9 |
children | cc9a3a24d61d 5a5d0c713d47 |
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" | |
1277 | 28 #include "Outdoor_stuff.h" |
0 | 29 #include "Overlays.h" |
30 #include "AudioPlayer.h" | |
31 #include "LOD.h" | |
32 #include "OSInfo.h" | |
33 #include "GUIWindow.h" | |
34 #include "TurnEngine.h" | |
35 #include "VideoPlayer.h" | |
36 #include "Bink_Smacker.h" | |
37 #include "Events.h" | |
38 #include "Arcomage.h" | |
189 | 39 #include "texts.h" |
791 | 40 #include "GUIFont.h" |
194 | 41 #include "Log.h" |
1262 | 42 #include "Lights.h" |
43 #include "mm7_data.h" | |
0 | 44 |
45 //#include "MM7.h" | |
46 | |
47 | |
48 | |
49 | |
50 | |
51 | |
52 Game *pGame; | |
53 | |
54 | |
55 | |
56 | |
57 | |
58 //----- (00435694) -------------------------------------------------------- | |
59 void Game::ToggleFlags2(unsigned int uFlag) | |
60 { | |
61 unsigned int v2; // eax@1 | |
62 | |
63 v2 = this->uFlags2; | |
64 if ( v2 & uFlag ) | |
65 this->uFlags2 = v2 & ~uFlag; | |
66 else | |
67 this->uFlags2 = uFlag | v2; | |
68 } | |
69 | |
70 //----- (0044103C) -------------------------------------------------------- | |
71 void Game::Draw() | |
72 { | |
142 | 73 //float v2; // ST24_4@11 |
0 | 74 //double v3; // ST28_8@11 |
75 int v4; // edi@26 | |
142 | 76 //int v5; // eax@35 |
0 | 77 |
78 uFlags2 &= 0xFFFFFFFDu; | |
79 if ( pParty->_497FC5_check_party_perception_against_level() ) | |
80 uFlags2 |= 2u; | |
81 pIndoorCamera->sRotationX = pParty->sRotationX; | |
82 pIndoorCamera->sRotationY = pParty->sRotationY; | |
120 | 83 //pIndoorCamera->pos.x = pParty->vPosition.x - ((__int64)pParty->y_rotation_granularity * stru_5C6E00->SinCos(pIndoorCamera->sRotationY)) / 2048.0;//12552 |
84 //pIndoorCamera->pos.y = pParty->vPosition.y - ((__int64)pParty->y_rotation_granularity * stru_5C6E00->SinCos(pIndoorCamera->sRotationY)) / 2048.0;//800 | |
85 pIndoorCamera->pos.x = pParty->vPosition.x - pParty->y_rotation_granularity * cosf(2 * 3.141592653589 * pIndoorCamera->sRotationY / 2048.0); | |
86 pIndoorCamera->pos.y = pParty->vPosition.y - pParty->y_rotation_granularity * sinf(2 * 3.141592653589 * pIndoorCamera->sRotationY / 2048.0); | |
66 | 87 pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel;//193, but real 353 |
0 | 88 pIndoorCamera->Initialize2(); |
89 pIndoorCameraD3D->CreateWorldMatrixAndSomeStuff(); | |
90 pIndoorCameraD3D->_4374E8_ProllyBuildFrustrum(); | |
91 | |
92 if ( pVideoPlayer->AnyMovieLoaded() ) | |
93 { | |
94 if ( pRenderer->pRenderD3D ) | |
95 goto LABEL_22; | |
96 pRenderer->BeginSceneD3D(); | |
97 pMouse->DrawCursorToTarget(); | |
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(); | |
569 | 135 pGame->pLightmapBuilder->DrawLightmaps(2); |
0 | 136 } |
137 } | |
138 } | |
139 pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); | |
140 LABEL_22: | |
791 | 141 |
142 //DEBUG: force redraw gui | |
143 viewparams->bRedrawGameUI = true; | |
144 | |
145 | |
0 | 146 pRenderer->BeginScene(); |
147 if (pRenderer->pRenderD3D) | |
148 pMouse->DrawCursorToTarget(); | |
142 | 149 if (pOtherOverlayList->bRedraw) |
150 viewparams->bRedrawGameUI = true; | |
0 | 151 v4 = viewparams->bRedrawGameUI; |
783 | 152 GameUI_Footer(); |
0 | 153 if (!viewparams->bRedrawGameUI) |
154 { | |
155 GameUI_DrawRightPanelItems(); | |
156 } | |
157 else | |
158 { | |
159 GameUI_DrawRightPanelFrames(); | |
783 | 160 GameUI_Footer_2(); |
0 | 161 viewparams->bRedrawGameUI = false; |
162 } | |
163 if (!pVideoPlayer->pSmackerMovie) | |
164 { | |
165 GameUI_DrawMinimap(488, 16, 625, 133, viewparams->uMinimapZoom, pParty->uFlags & 2); | |
166 if (v4) | |
167 { | |
265 | 168 if ( !PauseGameDrawing() && pRenderer->pRenderD3D) // clear game viewport with transparent color |
693 | 169 pRenderer->FillRectFast(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pViewport->uViewportBR_X - pViewport->uViewportTL_X, |
170 pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1, | |
142 | 171 pRenderer->uTargetGMask | pRenderer->uTargetBMask); |
0 | 172 viewparams->field_48 = 0; |
173 } | |
174 } | |
142 | 175 |
176 viewparams->bRedrawGameUI = pOtherOverlayList->bRedraw; | |
177 pOtherOverlayList->bRedraw = 0; | |
178 | |
0 | 179 GameUI_DrawPartySpells(); |
291 | 180 if (v4 || pParty->pHirelings[0].evt_C || pParty->pHirelings[1].evt_C ) |
994 | 181 GameUI_DrawHiredNPCs(); |
0 | 182 GameUI_DrawPortraits(v4); |
183 GameUI_DrawLifeManaBars(); | |
184 GameUI_DrawCharacterSelectionFrame(); | |
185 if ( sub_44100D() ) | |
994 | 186 GameUI_DrawRightPanel(); |
0 | 187 if ( !pVideoPlayer->AnyMovieLoaded() ) |
188 { | |
189 pStru6Instance->DrawPlayerBuffAnims(); | |
569 | 190 pOtherOverlayList->DrawTurnBasedIcon(v4); |
0 | 191 GameUI_DrawTorchlightAndWizardEye(); |
192 } | |
791 | 193 |
794 | 194 |
195 static bool render_framerate = false; | |
196 static float framerate = 0.0f; | |
197 static uint frames_this_second = 0; | |
198 static uint last_frame_time = GetTickCount(); | |
199 static uint framerate_time_elapsed = 0; | |
200 | |
201 auto frame_dt = GetTickCount() - last_frame_time; | |
202 last_frame_time = GetTickCount(); | |
203 | |
204 framerate_time_elapsed += frame_dt; | |
205 if (framerate_time_elapsed >= 1000) | |
206 { | |
207 framerate = frames_this_second * (1000.0f / framerate_time_elapsed); | |
208 | |
209 framerate_time_elapsed = 0; | |
210 frames_this_second = 0; | |
211 render_framerate = true; | |
212 } | |
213 | |
214 ++frames_this_second; | |
215 | |
216 | |
217 if (render_framerate) | |
218 { | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
219 sprintf(pTmpBuf.data(), "FPS: % .4f", framerate); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
220 pPrimaryWindow->DrawText(pFontArrus, 494, 0, TargetColor(0, 0, 0), pTmpBuf.data(), 0, 0, 0); |
794 | 221 } |
222 | |
791 | 223 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) |
224 { | |
831 | 225 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
|
226 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
|
227 pPrimaryWindow->DrawText(pFontArrus, 16, 16, TargetColor(255, 255, 255), pTmpBuf.data(), 0, 0, 0xFFFFFFFF); |
791 | 228 } |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
229 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
|
230 pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16, TargetColor(255, 255, 255), pTmpBuf.data(), 0, 0, 0xFFFFFFFF); |
791 | 231 |
232 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
233 { | |
234 uint uFaceID; | |
831 | 235 auto sector_id = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); |
236 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
|
237 sprintf(pTmpBuf.data(), "BLV_GetFloorLevel: %d face_id %d\n", floor_level, uFaceID); |
791 | 238 } |
239 else | |
240 { | |
241 int on_water, _a6; | |
242 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
|
243 sprintf(pTmpBuf.data(), "ODM_GetFloorLevel: %d on_water: %s a6 = %d\n", floor_level, on_water ? "true" : "false", _a6); |
791 | 244 } |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
245 pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16 + 16, TargetColor(255, 255, 255), pTmpBuf.data(), 0, 0, 0xFFFFFFFF); |
791 | 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 { | |
483 pTurnEngine->End(1); | |
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; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
520 if ( _stricmp(Source, pCurrentMapName.data()) ) |
0 | 521 { |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
522 strcpy(pCurrentMapName.data(), 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]; |
544 assert(idx >= 0); | |
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) -------------------------------------------------------- | |
790 int Game::_44EC23(stru148 *a2, int *a3, signed int a4) | |
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 | |
946 pThreadWardInstance = new ThreadWard; | |
947 pParticleEngine = new ParticleEngine; | |
948 pMouse = pMouseInstance = new Mouse(pThreadWardInstance); | |
949 pLightmapBuilder = new LightmapBuilder; | |
950 pVisInstance = new Vis; | |
951 pStru6Instance = new stru6; | |
952 pIndoorCameraD3D = new IndoorCameraD3D; | |
953 pStru9Instance = new stru9; | |
954 pStru10Instance = new stru10; | |
955 pStru11Instance = new stru11; | |
956 pStru12Instance = new stru12(pStru11Instance); | |
957 pCShow = new CShow; | |
958 pKeyboardInstance = new Keyboard; | |
959 pGammaController = new GammaController; | |
960 | |
961 uFlags |= 0x0800; | |
962 uFlags2 |= 0x24; | |
963 | |
964 _44F0FD(); | |
965 | |
966 bWinNT4_0 = false; | |
967 if (pVersion->pVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && | |
968 pVersion->pVersionInfo.dwMajorVersion == 4) | |
969 bWinNT4_0 = true; | |
970 } | |
971 | |
972 //----- (0044E7F3) -------------------------------------------------------- | |
973 Game::~Game() | |
974 { | |
975 if (pGammaController) | |
976 delete pGammaController; | |
977 if (pKeyboardInstance) | |
978 delete pKeyboardInstance; | |
979 if (pCShow) | |
980 delete pCShow; | |
981 if (pStru12Instance) | |
982 delete pStru12Instance; | |
983 if (pStru11Instance) | |
984 delete pStru11Instance; | |
985 if (pStru10Instance) | |
986 delete pStru10Instance; | |
987 if (pStru9Instance) | |
988 delete pStru9Instance; | |
989 if (pIndoorCameraD3D) | |
990 delete pIndoorCameraD3D; | |
991 if (pStru6Instance) | |
992 delete pStru6Instance; | |
993 if (pVisInstance) | |
994 delete pVisInstance; | |
995 if (pLightmapBuilder) | |
996 delete pLightmapBuilder; | |
997 if (pMouseInstance) | |
998 delete pMouseInstance; | |
999 if (pParticleEngine) | |
1000 delete pParticleEngine; | |
1001 if (pThreadWardInstance) | |
1002 delete pThreadWardInstance; | |
1003 } | |
1004 | |
1005 //----- (0044E904) -------------------------------------------------------- | |
1006 void Game::_44E904() | |
1007 { | |
1008 //Game *v1; // esi@1 | |
1009 unsigned __int64 v2; // qax@1 | |
1010 unsigned int v3; // ecx@1 | |
1011 int v4; // edi@1 | |
1012 unsigned __int8 v5; // cf@7 | |
1013 double v6; // st7@13 | |
1014 double v7; // st7@15 | |
1015 signed __int64 v8; // [sp+Ch] [bp-8h]@1 | |
1016 | |
1017 //v1 = this; | |
1018 v2 = pEventTimer->Time(); | |
1019 v4 = (v2 - uSomeGammaStartTime) >> 32; | |
1020 v3 = v2 - LODWORD(uSomeGammaStartTime); | |
1021 v8 = v2 - uSomeGammaStartTime; | |
1022 if ( v4 < 0 | |
1023 || SHIDWORD(v2) < ((unsigned int)v2 < LODWORD(uSomeGammaStartTime)) + HIDWORD(uSomeGammaStartTime) | v4 == 0 | |
1024 && v3 <= 0x80 ) | |
1025 { | |
1026 if ( v4 > 0 || v4 >= 0 ) | |
1027 goto LABEL_12; | |
1028 v3 = 0; | |
1029 v4 = 0; | |
1030 } | |
1031 else | |
1032 { | |
1033 if ( uSomeGammaDeltaTime ) | |
1034 { | |
1035 LODWORD(uSomeGammaDeltaTime) = 0; | |
1036 HIDWORD(uSomeGammaDeltaTime) = 0; | |
1037 } | |
1038 else | |
1039 { | |
1040 LODWORD(uSomeGammaDeltaTime) = v3; | |
1041 HIDWORD(uSomeGammaDeltaTime) = v4; | |
1042 } | |
1043 v5 = __CFADD__(v3, -128); | |
1044 v3 -= 128; | |
1045 v4 = v5 + v4 - 1; | |
1046 } | |
1047 uSomeGammaStartTime = v2; | |
1048 v8 = __PAIR__(v4, v3); | |
1049 LABEL_12: | |
1050 if ( uSomeGammaDeltaTime ) | |
1051 v6 = (double)(signed __int64)(uSomeGammaDeltaTime - __PAIR__(v4, v3)); | |
1052 else | |
1053 v6 = (double)v8; | |
1054 v7 = v6 * 0.0078125; | |
1055 if ( v7 < 0.0 || v7 <= 1.0 ) | |
1056 { | |
1057 if ( v7 < 0.0 ) | |
1058 v7 = 0.0; | |
1059 } | |
1060 else | |
1061 { | |
1062 v7 = 1.0; | |
1063 } | |
1064 if ( pRenderer->pRenderD3D ) | |
1065 fSaturation = v7; | |
1066 else | |
1067 fSaturation = (1.0 - 0.5) * v7 + 0.5; | |
1068 } | |
1069 | |
1070 //----- (0044EA17) -------------------------------------------------------- | |
1071 bool Game::InitializeGammaController() | |
1072 { | |
1073 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || | |
1074 pVersion->pVersionInfo.dwMajorVersion != 4 ) | |
1075 pGammaController->InitializeFromSurface(pRenderer->pFrontBuffer4); | |
1076 | |
1077 bGammaControlInitialized = true; | |
1078 uSomeGammaStartTime = pEventTimer->Time(); | |
1079 return true; | |
1080 } | |
1081 | |
1082 //----- (0044EA5E) -------------------------------------------------------- | |
194 | 1083 bool Game::PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) |
0 | 1084 { |
227 | 1085 if (pCurrentScreen != SCREEN_GAME|| !pRenderer->pRenderD3D) |
194 | 1086 return false; |
0 | 1087 |
194 | 1088 if (!pVisInstance) |
0 | 1089 { |
194 | 1090 MessageBoxW(nullptr, L"The 'Vis' object pointer has not been instatiated, but CGame::Pick() is trying to call through it.", nullptr, 0); |
1091 return false; | |
1092 } | |
0 | 1093 |
692 | 1094 if (uMouseX >= (signed int)pViewport->uScreen_TL_X && |
1095 uMouseX <= (signed int)pViewport->uScreen_BR_X && | |
1096 uMouseY >= (signed int)pViewport->uScreen_TL_Y && | |
1097 uMouseY <= (signed int)pViewport->uScreen_BR_Y) | |
194 | 1098 { |
1099 pVisInstance->PickMouse(fPickDepth, uMouseX, uMouseY, sprite_filter, face_filter); | |
0 | 1100 |
194 | 1101 if (bOutline) |
1102 OutlineSelection(); | |
0 | 1103 } |
194 | 1104 |
1105 return true; | |
0 | 1106 } |
1107 // 4E28F8: using guessed type int pCurrentScreen; | |
1108 | |
1109 //----- (0044EB12) -------------------------------------------------------- | |
194 | 1110 bool Game::PickKeyboard(bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) |
0 | 1111 { |
271 | 1112 if (pCurrentScreen == SCREEN_GAME && pVisInstance && pRenderer->pRenderD3D) |
0 | 1113 { |
194 | 1114 bool r = pVisInstance->PickKeyboard(&pVisInstance->default_list, sprite_filter, face_filter); |
0 | 1115 |
1116 if (bOutline) | |
1117 OutlineSelection(); | |
1118 return r; | |
1119 } | |
1120 return false; | |
1121 } | |
123 | 1122 /* |
1123 Result::Code Game::PickKeyboard(bool bOutline, struct unnamed_F93E6C *a3, struct unnamed_F93E6C *a4) | |
1124 { | |
1125 if (dword_4E28F8_PartyCantJumpIfTrue) | |
1126 return Result::Generic; | |
1127 | |
1128 pVis->PickKeyboard(a3, a4); | |
1129 if (bOutline) | |
1130 Game_outline_selection((int)this); | |
1131 return Result::Success; | |
1132 } | |
1133 */ | |
0 | 1134 // 4E28F8: using guessed type int pCurrentScreen; |
1135 | |
1136 //----- (0044EB5A) -------------------------------------------------------- | |
1137 void Game::OutlineSelection() | |
1138 { | |
194 | 1139 if (!pVisInstance) |
1140 return; | |
1141 | |
1142 if (!pVisInstance->default_list.uNumPointers) | |
1143 return; | |
0 | 1144 |
194 | 1145 auto object_info = pVisInstance->default_list.object_pointers[0]; |
1146 if (object_info) | |
1147 switch (object_info->object_type) | |
0 | 1148 { |
194 | 1149 case VisObjectType_Sprite: |
0 | 1150 { |
194 | 1151 Log::Warning(L"Sprite outline currently unsupported"); |
1152 return; | |
0 | 1153 } |
1154 | |
194 | 1155 case VisObjectType_Face: |
1156 { | |
1157 if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
0 | 1158 { |
194 | 1159 auto face = (ODMFace *)object_info->object; |
1160 if (face->uAttributes & FACE_OUTLINED) | |
1161 face->uAttributes &= ~FACE_OUTLINED; | |
0 | 1162 else |
194 | 1163 face->uAttributes |= FACE_OUTLINED; |
1164 } | |
1165 else if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
1166 { | |
1167 auto face = (BLVFace *)object_info->object; | |
1168 if (face->uAttributes & FACE_OUTLINED) | |
1169 face->uAttributes &= ~FACE_OUTLINED; | |
1170 else | |
1171 face->uAttributes |= FACE_OUTLINED; | |
0 | 1172 } |
194 | 1173 else assert(false); |
1174 } | |
323 | 1175 break; |
194 | 1176 |
1177 default: | |
1178 { | |
1179 MessageBoxW(nullptr, L"Undefined CObjectInfo type requested in CGame::outline_selection()", nullptr, 0); | |
1180 ExitProcess(0); | |
1181 } | |
0 | 1182 } |
1183 } |