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