Mercurial > mm7
annotate Game.cpp @ 1391:cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
stru148 -> struct Polygon
author | Nomad |
---|---|
date | Thu, 18 Jul 2013 14:42:54 +0200 |
parents | 1803172dffd9 |
children | 8ea496564034 |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1110
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1110
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1110
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1110
diff
changeset
|
4 |
137 | 5 #include <assert.h> |
6 | |
1016 | 7 #include "Vis.h" |
8 | |
9 #include "LightmapBuilder.h" | |
10 #include "DecalBuilder.h" | |
11 #include "ParticleEngine.h" | |
12 #include "Mouse.h" | |
13 #include "Keyboard.h" | |
14 #include "CShow.h" | |
15 #include "GammaControl.h" | |
16 #include "stru6.h" | |
17 #include "stru9.h" | |
18 #include "stru10.h" | |
19 | |
0 | 20 #include "Game.h" |
21 #include "Party.h" | |
22 #include "IndoorCamera.h" | |
23 #include "Viewport.h" | |
24 #include "Time.h" | |
25 #include "Outdoor.h" | |
1277 | 26 #include "Outdoor_stuff.h" |
0 | 27 #include "Overlays.h" |
28 #include "AudioPlayer.h" | |
29 #include "LOD.h" | |
30 #include "OSInfo.h" | |
31 #include "GUIWindow.h" | |
32 #include "TurnEngine.h" | |
33 #include "VideoPlayer.h" | |
34 #include "Bink_Smacker.h" | |
35 #include "Events.h" | |
36 #include "Arcomage.h" | |
189 | 37 #include "texts.h" |
791 | 38 #include "GUIFont.h" |
194 | 39 #include "Log.h" |
1262 | 40 #include "Lights.h" |
41 #include "mm7_data.h" | |
0 | 42 |
43 //#include "MM7.h" | |
44 | |
45 | |
46 | |
47 | |
48 | |
49 | |
50 Game *pGame; | |
51 | |
52 | |
53 | |
54 | |
55 | |
56 //----- (00435694) -------------------------------------------------------- | |
57 void Game::ToggleFlags2(unsigned int uFlag) | |
58 { | |
59 unsigned int v2; // eax@1 | |
60 | |
61 v2 = this->uFlags2; | |
62 if ( v2 & uFlag ) | |
63 this->uFlags2 = v2 & ~uFlag; | |
64 else | |
65 this->uFlags2 = uFlag | v2; | |
66 } | |
67 | |
68 //----- (0044103C) -------------------------------------------------------- | |
69 void Game::Draw() | |
70 { | |
142 | 71 //float v2; // ST24_4@11 |
0 | 72 //double v3; // ST28_8@11 |
73 int v4; // edi@26 | |
142 | 74 //int v5; // eax@35 |
0 | 75 |
76 uFlags2 &= 0xFFFFFFFDu; | |
77 if ( pParty->_497FC5_check_party_perception_against_level() ) | |
78 uFlags2 |= 2u; | |
79 pIndoorCamera->sRotationX = pParty->sRotationX; | |
80 pIndoorCamera->sRotationY = pParty->sRotationY; | |
120 | 81 //pIndoorCamera->pos.x = pParty->vPosition.x - ((__int64)pParty->y_rotation_granularity * stru_5C6E00->SinCos(pIndoorCamera->sRotationY)) / 2048.0;//12552 |
82 //pIndoorCamera->pos.y = pParty->vPosition.y - ((__int64)pParty->y_rotation_granularity * stru_5C6E00->SinCos(pIndoorCamera->sRotationY)) / 2048.0;//800 | |
83 pIndoorCamera->pos.x = pParty->vPosition.x - pParty->y_rotation_granularity * cosf(2 * 3.141592653589 * pIndoorCamera->sRotationY / 2048.0); | |
84 pIndoorCamera->pos.y = pParty->vPosition.y - pParty->y_rotation_granularity * sinf(2 * 3.141592653589 * pIndoorCamera->sRotationY / 2048.0); | |
66 | 85 pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel;//193, but real 353 |
0 | 86 pIndoorCamera->Initialize2(); |
87 pIndoorCameraD3D->CreateWorldMatrixAndSomeStuff(); | |
88 pIndoorCameraD3D->_4374E8_ProllyBuildFrustrum(); | |
89 | |
90 if ( pVideoPlayer->AnyMovieLoaded() ) | |
91 { | |
92 if ( pRenderer->pRenderD3D ) | |
93 goto LABEL_22; | |
94 pRenderer->BeginSceneD3D(); | |
95 pMouse->DrawCursorToTarget(); | |
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(); | |
137 | 128 else assert(false); |
0 | 129 |
130 if (pRenderer->pRenderD3D) | |
131 { | |
132 pDecalBuilder->DrawBloodsplats(); | |
569 | 133 pGame->pLightmapBuilder->DrawLightmaps(2); |
0 | 134 } |
135 } | |
136 } | |
137 pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); | |
138 LABEL_22: | |
791 | 139 |
140 //DEBUG: force redraw gui | |
141 viewparams->bRedrawGameUI = true; | |
142 | |
143 | |
0 | 144 pRenderer->BeginScene(); |
145 if (pRenderer->pRenderD3D) | |
146 pMouse->DrawCursorToTarget(); | |
142 | 147 if (pOtherOverlayList->bRedraw) |
148 viewparams->bRedrawGameUI = true; | |
0 | 149 v4 = viewparams->bRedrawGameUI; |
783 | 150 GameUI_Footer(); |
0 | 151 if (!viewparams->bRedrawGameUI) |
152 { | |
153 GameUI_DrawRightPanelItems(); | |
154 } | |
155 else | |
156 { | |
157 GameUI_DrawRightPanelFrames(); | |
783 | 158 GameUI_Footer_2(); |
0 | 159 viewparams->bRedrawGameUI = false; |
160 } | |
161 if (!pVideoPlayer->pSmackerMovie) | |
162 { | |
163 GameUI_DrawMinimap(488, 16, 625, 133, viewparams->uMinimapZoom, pParty->uFlags & 2); | |
164 if (v4) | |
165 { | |
265 | 166 if ( !PauseGameDrawing() && pRenderer->pRenderD3D) // clear game viewport with transparent color |
693 | 167 pRenderer->FillRectFast(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pViewport->uViewportBR_X - pViewport->uViewportTL_X, |
168 pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1, | |
142 | 169 pRenderer->uTargetGMask | pRenderer->uTargetBMask); |
0 | 170 viewparams->field_48 = 0; |
171 } | |
172 } | |
142 | 173 |
174 viewparams->bRedrawGameUI = pOtherOverlayList->bRedraw; | |
175 pOtherOverlayList->bRedraw = 0; | |
176 | |
0 | 177 GameUI_DrawPartySpells(); |
291 | 178 if (v4 || pParty->pHirelings[0].evt_C || pParty->pHirelings[1].evt_C ) |
994 | 179 GameUI_DrawHiredNPCs(); |
0 | 180 GameUI_DrawPortraits(v4); |
181 GameUI_DrawLifeManaBars(); | |
182 GameUI_DrawCharacterSelectionFrame(); | |
183 if ( sub_44100D() ) | |
994 | 184 GameUI_DrawRightPanel(); |
0 | 185 if ( !pVideoPlayer->AnyMovieLoaded() ) |
186 { | |
187 pStru6Instance->DrawPlayerBuffAnims(); | |
569 | 188 pOtherOverlayList->DrawTurnBasedIcon(v4); |
0 | 189 GameUI_DrawTorchlightAndWizardEye(); |
190 } | |
791 | 191 |
794 | 192 |
193 static bool render_framerate = false; | |
194 static float framerate = 0.0f; | |
195 static uint frames_this_second = 0; | |
196 static uint last_frame_time = GetTickCount(); | |
197 static uint framerate_time_elapsed = 0; | |
198 | |
199 auto frame_dt = GetTickCount() - last_frame_time; | |
200 last_frame_time = GetTickCount(); | |
201 | |
202 framerate_time_elapsed += frame_dt; | |
203 if (framerate_time_elapsed >= 1000) | |
204 { | |
205 framerate = frames_this_second * (1000.0f / framerate_time_elapsed); | |
206 | |
207 framerate_time_elapsed = 0; | |
208 frames_this_second = 0; | |
209 render_framerate = true; | |
210 } | |
211 | |
212 ++frames_this_second; | |
213 | |
214 | |
215 if (render_framerate) | |
216 { | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
217 sprintf(pTmpBuf.data(), "FPS: % .4f", framerate); |
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
218 pPrimaryWindow->DrawText(pFontArrus, 494, 0, TargetColor(0, 0, 0), pTmpBuf.data(), 0, 0, 0); |
794 | 219 } |
220 | |
791 | 221 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) |
222 { | |
831 | 223 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
|
224 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
|
225 pPrimaryWindow->DrawText(pFontArrus, 16, 16, TargetColor(255, 255, 255), pTmpBuf.data(), 0, 0, 0xFFFFFFFF); |
791 | 226 } |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
227 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
|
228 pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16, TargetColor(255, 255, 255), pTmpBuf.data(), 0, 0, 0xFFFFFFFF); |
791 | 229 |
230 if (uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
231 { | |
232 uint uFaceID; | |
831 | 233 auto sector_id = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); |
234 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
|
235 sprintf(pTmpBuf.data(), "BLV_GetFloorLevel: %d face_id %d\n", floor_level, uFaceID); |
791 | 236 } |
237 else | |
238 { | |
239 int on_water, _a6; | |
240 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
|
241 sprintf(pTmpBuf.data(), "ODM_GetFloorLevel: %d on_water: %s a6 = %d\n", floor_level, on_water ? "true" : "false", _a6); |
791 | 242 } |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
243 pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16 + 16, TargetColor(255, 255, 255), pTmpBuf.data(), 0, 0, 0xFFFFFFFF); |
791 | 244 |
0 | 245 GUI_UpdateWindows(); |
130 | 246 pParty->UpdatePlayersAndHirelingsEmotions(); |
937 | 247 |
434 | 248 _unused_5B5924_is_travel_ui_drawn = false; |
0 | 249 if (v4) |
791 | 250 pMouse->bRedraw = true; |
0 | 251 pMouse->_469EA4(); |
252 pMouse->DrawCursor(); | |
253 pMouse->_469E1C(); | |
254 pRenderer->EndScene(); | |
255 pRenderer->Present(); | |
569 | 256 pParty->uFlags &= ~2; |
0 | 257 } |
258 | |
259 //----- (0047A815) -------------------------------------------------------- | |
260 void Game::DrawParticles() | |
261 { | |
262 pParticleEngine->Draw(); | |
263 } | |
264 | |
265 //----- (00463149) -------------------------------------------------------- | |
266 void Game::Loop() | |
267 { | |
268 //signed int v0; // ebp@3 | |
269 //signed int v1; // esi@4 | |
270 //Render *v2; // edi@7 | |
271 //signed int v3; // esi@7 | |
272 signed int pNewNPCsCount; // ecx@58 | |
1063 | 273 NPCData *pNPC; // eax@59 |
0 | 274 Player *pPlayer; // esi@65 |
981 | 275 //OtherOverlay *pOtherOverlay; // esi@67 |
276 //signed int v8; // edi@67 | |
982 | 277 //int pPlayerNum; // edi@69 |
0 | 278 int *pHealth; // esi@71 |
982 | 279 //signed int v11; // esi@78 |
280 //int v12; // eax@83 | |
0 | 281 const char *pLocationName; // [sp-4h] [bp-68h]@74 |
282 bool bLoading; // [sp+10h] [bp-54h]@1 | |
982 | 283 //signed int bLoadinga; // [sp+10h] [bp-54h]@19 |
0 | 284 signed int v16; // [sp+14h] [bp-50h]@8 |
982 | 285 //int v17[4]; // [sp+18h] [bp-4Ch]@80 |
0 | 286 MSG Msg; // [sp+28h] [bp-3Ch]@20 |
287 char Source[64]; // [sp+44h] [bp-20h]@76 | |
288 | |
961 | 289 bLoading = uCurrentMenuID == MENU_LoadingProcInMainMenu; |
0 | 290 SetCurrentMenuID((MENU_STATE)-1); |
291 if (bLoading) | |
292 { | |
293 pParty->Reset(); | |
294 dword_6BE340 = 0; | |
982 | 295 uGameState = GAME_STATE_PLAYING; |
0 | 296 LoadGame(uLoadGameUI_SelectedSlot); |
297 } | |
298 | |
299 for (uint i = 1; i < 5; ++i) | |
300 for (uint j = 1; j < 6; ++j) | |
301 { | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
302 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
|
303 remove(pTmpBuf.data()); |
0 | 304 } |
305 | |
306 LoadPlayerPortraintsAndVoices(); | |
783 | 307 pIcons_LOD->_inlined_sub1(); |
328 | 308 pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); |
0 | 309 |
310 while ( 2 ) | |
311 { | |
312 v16 = 1; | |
783 | 313 pMessageQueue_50CBD0->Flush(); |
0 | 314 |
315 pPartyActionQueue->uNumActions = 0; | |
316 if (pParty->bTurnBasedModeOn) | |
317 { | |
318 pTurnEngine->End(false); | |
319 pParty->bTurnBasedModeOn = false; | |
320 } | |
321 DoPrepareWorld(bLoading, 1); | |
322 pEventTimer->Resume(); | |
323 dword_6BE364_game_settings_1 |= 0x80; | |
324 dword_6BE340 = 2; | |
325 // uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0; | |
151 | 326 pCurrentScreen = SCREEN_GAME; |
1038 | 327 |
0 | 328 if ( pRenderer->pRenderD3D ) |
329 pGame->pVisInstance->_4C1A02(); | |
982 | 330 |
331 bool game_finished = false; | |
0 | 332 do |
333 { | |
334 while ( PeekMessageA(&Msg, 0, 0, 0, PM_REMOVE) ) | |
335 { | |
336 if ( Msg.message == WM_QUIT ) | |
337 Game_DeinitializeAndTerminate(0); | |
338 TranslateMessage(&Msg); | |
339 DispatchMessageA(&Msg); | |
340 } | |
341 if (dword_6BE364_game_settings_1 & 0x0100 ) | |
342 { | |
343 WaitMessage(); | |
344 continue; | |
345 } | |
346 pGame->_44EEA7(); | |
347 GameUI_WritePointedObjectStatusString(); | |
348 ProcessInputActions(); | |
349 GameUI_MsgProc(); | |
350 if ( pArcomageGame->bGameInProgress ) | |
351 { | |
352 ArcomageGame::Loop(); | |
353 pRenderer->Present(); | |
354 continue; | |
355 } | |
356 if ( pVideoPlayer->pSmackerMovie && !SmackWait(pVideoPlayer->pSmackerMovie) ) | |
357 { | |
358 pRenderer->BeginScene(); | |
359 pMouse->DrawCursorToTarget(); | |
360 pVideoPlayer->SmackUpdatePalette(pVideoPlayer->hWindow); | |
361 pMouse->_469EA4(); | |
362 pRenderer->EndScene(); | |
363 } | |
982 | 364 else if ( pVideoPlayer->pBinkMovie && !BinkWait(pVideoPlayer->pBinkMovie) ) |
0 | 365 { |
366 pRenderer->BeginScene(); | |
367 pMouse->DrawCursorToTarget(); | |
368 pVideoPlayer->BinkUpdatePalette(pVideoPlayer->hWindow); | |
369 pMouse->_469EA4(); | |
370 pRenderer->EndScene(); | |
371 } | |
983 | 372 |
373 pEventTimer->Update(); | |
374 pMiscTimer->Update(); | |
375 | |
0 | 376 OnTimer(0); |
377 GameUI_StatusBar_UpdateTimedString(0); | |
378 if ( pMiscTimer->bPaused && !pEventTimer->bPaused ) | |
379 pMiscTimer->Resume(); | |
380 if ( pEventTimer->bTackGameTime && !pParty->bTurnBasedModeOn ) | |
381 pEventTimer->bTackGameTime = 0; | |
982 | 382 if ( !pEventTimer->bPaused && uGameState == GAME_STATE_PLAYING) |
0 | 383 { |
384 if ( !pEventTimer->bTackGameTime ) | |
385 _494035_timed_effects__water_walking_damage__etc(); | |
386 if ( dword_6BE364_game_settings_1 & 1 ) | |
387 { | |
388 dword_6BE364_game_settings_1 &= 0xFFFFFFFEu; | |
389 } | |
390 else | |
391 { | |
783 | 392 UpdateActorAI(); |
393 UpdateUserInput_and_MapSpecificStuff(); | |
0 | 394 } |
395 } | |
396 if ( v16 ) | |
397 { | |
398 v16 = 0; | |
399 viewparams->bRedrawGameUI = true; | |
400 } | |
378 | 401 pAudioPlayer->UpdateSounds(); |
978 | 402 if (uGameState == GAME_FINISHED) |
0 | 403 //goto LABEL_96; |
4 | 404 { |
982 | 405 game_finished = true; |
0 | 406 continue; |
4 | 407 } |
978 | 408 if (uGameState == GAME_STATE_2) |
0 | 409 { |
410 pAudioPlayer->StopChannels(-1, -1); | |
411 PrepareWorld(0); | |
982 | 412 uGameState = GAME_STATE_PLAYING; |
0 | 413 continue; |
414 } | |
978 | 415 if ( (signed int)uGameState <= GAME_STATE_2 ) |
0 | 416 //goto LABEL_85; |
4 | 417 { |
418 pGame->Draw(); | |
0 | 419 continue; |
4 | 420 } |
978 | 421 if ( (signed int)uGameState <= GAME_STATE_5 || uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU ) |
0 | 422 { |
423 //LABEL_96: | |
982 | 424 game_finished = true; |
0 | 425 continue; |
426 } | |
981 | 427 if ( uGameState != GAME_STATE_PARTY_DIED ) |
0 | 428 { |
978 | 429 if ( uGameState != GAME_STATE_FINAL_WINDOW ) |
0 | 430 { |
431 //LABEL_85: | |
432 pGame->Draw(); | |
433 } | |
981 | 434 else |
435 { | |
436 pRenderer->BeginScene(); | |
437 GUI_UpdateWindows(); | |
438 pRenderer->EndScene(); | |
439 //goto LABEL_89; | |
440 pRenderer->Present(); | |
441 } | |
0 | 442 continue; |
443 } | |
4 | 444 pAudioPlayer->StopChannels(-1, -1);//äàëåå â ñëó÷àå ñìåðòè ãðóïïû |
293 | 445 memset(&pParty->pHirelings[0], 0, 0x4Cu); |
0 | 446 memset(&pParty->pHirelings[1], 0, 0x4Cu); |
447 pNewNPCsCount = 0; | |
448 if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) | |
449 { | |
1063 | 450 pNPC = pNPCStats->pNewNPCData; |
0 | 451 do |
452 { | |
1063 | 453 if ( pNPC->field_24 ) |
454 pNPC->uFlags &= 0xFFFFFF7Fu; | |
0 | 455 ++pNewNPCsCount; |
1063 | 456 ++pNPC; |
0 | 457 } |
458 while ( pNewNPCsCount < (signed int)pNPCStats->uNumNewNPCs ); | |
459 } | |
460 pVideoPlayer->PlayDeathMovie(); | |
461 if ( pVideoPlayer->AnyMovieLoaded() ) | |
462 pVideoPlayer->Unload(); | |
463 SaveGame(0, 0); | |
464 ++pParty->uNumDeaths; | |
465 pPlayer = pParty->pPlayers; | |
466 do | |
467 { | |
468 pPlayer->SetVariable(VAR_Award, 85); | |
469 ++pPlayer; | |
470 } | |
471 while ( (signed int)pPlayer < (signed int)pParty->pHirelings ); | |
766 | 472 pParty->days_played_without_rest = 0; |
0 | 473 pParty->uTimePlayed += 0x276000ui64; |
569 | 474 LOWORD(pParty->uFlags) &= ~0x204; |
0 | 475 pParty->SetGold(0); |
981 | 476 pOtherOverlayList->Reset(); |
982 | 477 memset(pParty->pPartyBuffs, 0, 0x140u); |
981 | 478 |
0 | 479 if ( pParty->bTurnBasedModeOn == 1 ) |
480 { | |
481 pTurnEngine->End(1); | |
482 pParty->bTurnBasedModeOn = 0; | |
483 } | |
440 | 484 //pHealth = &pParty->pPlayers[0].sHealth;//193C |
485 //do | |
486 for(int i=0; i<4; ++i) | |
0 | 487 { |
440 | 488 memset(pParty->pPlayers[i].pConditions, 0, 0xA0u);//(pConditions, 0, 160) |
489 memset(pParty->pPlayers[i].pPlayerBuffs, 0, 0x180u);//(pPlayerBuffs[0], 0, 384) | |
490 //*pHealth = 1; | |
491 pParty->pPlayers[i].sHealth=1; | |
492 //pHealth += 1743; //6CF | |
0 | 493 uActiveCharacter = 1; |
494 } | |
440 | 495 // while ( (signed int)pHealth < (signed int)&pParty->field_871C[567] ); |
981 | 496 if (_449B57_test_bit(pParty->_quest_bits, PARTY_QUEST_FINISHED_EMERALD_ISLE)) |
0 | 497 { |
498 pParty->vPosition.x = -17331; // respawn in harmondale | |
499 pParty->vPosition.y = 12547; | |
500 pParty->vPosition.z = 465; | |
501 pParty->sRotationY = 0; | |
502 pLocationName = "out02.odm"; | |
503 } | |
504 else | |
505 { | |
506 pParty->vPosition.x = 12552; // respawn on emerald isle | |
507 pParty->vPosition.y = 1816; | |
508 pParty->vPosition.z = 0; | |
509 pParty->sRotationY = 512; | |
510 pLocationName = "out01.odm"; | |
511 } | |
512 strcpy(Source, pLocationName); | |
513 pParty->uFallStartY = pParty->vPosition.z; | |
514 pParty->sRotationX = 0; | |
515 pParty->uFallSpeed = 0; | |
516 pParty->field_6E4 = 0; | |
517 pParty->field_6E0 = 0; | |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
518 if ( _stricmp(Source, pCurrentMapName.data()) ) |
0 | 519 { |
1205
8c02e6f74b29
arrays to std::arrays phase 2 - mm7_data.h converted
Grumpy7
parents:
1165
diff
changeset
|
520 strcpy(pCurrentMapName.data(), Source); |
0 | 521 _5B65A8_npcdata_uflags_or_other = pParty->vPosition.x; |
522 _5B65AC_npcdata_fame_or_other = pParty->vPosition.y; | |
523 _5B65B0_npcdata_rep_or_other = pParty->vPosition.z; | |
524 _5B65B4_npcdata_loword_house_or_other = pParty->sRotationY; | |
525 _5B65B8_npcdata_hiword_house_or_other = pParty->sRotationX; | |
526 dword_5B65C0 = 1; | |
527 PrepareWorld(1); | |
528 } | |
529 InitializeActors(); | |
982 | 530 |
531 | |
532 int num_conscious_players = 0; | |
533 int conscious_players_ids[4] = {-1, -1, -1, -1}; | |
534 for (int v11 = 0; v11 < 4; ++v11) | |
0 | 535 { |
982 | 536 if (pPlayers[v11 + 1]->CanAct()) |
537 conscious_players_ids[num_conscious_players++] = v11; | |
0 | 538 } |
982 | 539 if (num_conscious_players) |
0 | 540 { |
982 | 541 int idx = conscious_players_ids[rand() % num_conscious_players]; |
542 assert(idx >= 0); | |
543 pPlayers[idx + 1]->PlaySound(SPEECH_99, 0); | |
0 | 544 } |
982 | 545 |
0 | 546 ShowStatusBarString(pGlobalTXT_LocalizationStrings[524], 2u);// "Once again you've cheated death!.." "Âû ñíîâà îáõèòðèëè ñìåðòü! …" |
982 | 547 uGameState = GAME_STATE_PLAYING; |
0 | 548 } |
982 | 549 while (!game_finished); |
550 | |
0 | 551 dword_6BE340 = 0; |
552 pEventTimer->Pause(); | |
553 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); | |
1214
0d6c7ff3cddd
simplified stru193_math constructor and class definition
Grumpy7
parents:
1205
diff
changeset
|
554 if ( uGameState == GAME_STATE_LOADING_GAME ) |
0 | 555 { |
556 sub_491E3A(); | |
557 LoadPlayerPortraintsAndVoices(); | |
982 | 558 uGameState = GAME_STATE_PLAYING; |
0 | 559 pIcons_LOD->dword_11B84 = pIcons_LOD->uNumLoadedFiles; |
560 bLoading = true; | |
561 continue; | |
562 } | |
563 break; | |
564 } | |
151 | 565 pCurrentScreen = SCREEN_VIDEO; |
0 | 566 sub_491E3A(); |
567 } | |
568 | |
569 | |
570 //----- (0044F192) -------------------------------------------------------- | |
571 void Game::PrepareBloodsplats() | |
572 { | |
573 for (uint i = 0; i < uNumBloodsplats; ++i) | |
574 { | |
575 pBloodsplatContainer->AddBloodsplat( | |
576 pBloodsplats[i].x, | |
577 pBloodsplats[i].y, | |
578 pBloodsplats[i].z, | |
579 pBloodsplats[i].radius, | |
580 pBloodsplats[i].r, | |
581 pBloodsplats[i].g, | |
582 pBloodsplats[i].b); | |
583 } | |
584 } | |
585 | |
586 | |
587 //----- (0044F120) -------------------------------------------------------- | |
588 void Game::PushStationaryLights(int a2) | |
589 { | |
1094 | 590 Game__StationaryLight* pLight; |
591 | |
592 for( int i=0; i<uNumStationaryLights; ++i ) | |
593 { | |
594 pLight=&pStationaryLights[i]; | |
595 pStationaryLightsStack->AddLight( | |
596 pLight->vPosition.x, | |
597 pLight->vPosition.y, | |
598 pLight->vPosition.z, | |
599 pLight->flt_18, | |
600 pLight->vRGBColor.x, | |
601 pLight->vRGBColor.y, | |
602 pLight->vRGBColor.z, | |
603 byte_4E94D0); | |
604 } | |
0 | 605 } |
606 // 4E94D0: using guessed type char byte_4E94D0; | |
607 | |
608 //----- (0044F0FD) -------------------------------------------------------- | |
609 void Game::_44F0FD() | |
610 { | |
611 ToggleFlags(0x40u); | |
612 | |
613 if ( !(uFlags & 0x40) ) | |
614 { | |
615 uNumBloodsplats = 0; | |
616 field_E0C = 0; | |
617 } | |
618 } | |
619 | |
620 //----- (0044F0D8) -------------------------------------------------------- | |
621 void Game::ToggleFlags(uint uMask) | |
622 { | |
623 if (uFlags & uMask) | |
624 uFlags &= ~uMask; | |
625 else | |
626 uFlags |= uMask; | |
627 } | |
628 | |
629 | |
630 //----- (0044F07B) -------------------------------------------------------- | |
631 bool Game::_44F07B() | |
632 { | |
633 if (!pKeyboardInstance->IsKeyBeingHeld(VK_SHIFT) && | |
634 !pKeyboardInstance->IsKeyBeingHeld(VK_LSHIFT) && | |
635 !pKeyboardInstance->IsKeyBeingHeld(VK_LSHIFT) || | |
636 | |
637 (pKeyboardInstance->WasKeyPressed(VK_F11) == 0 && | |
638 pKeyboardInstance->WasKeyPressed(VK_F11))) | |
639 return true; | |
640 return false; | |
641 } | |
642 | |
643 //----- (0044EEA7) -------------------------------------------------------- | |
644 bool Game::_44EEA7() | |
645 { | |
646 //Game *v1; // esi@1 | |
194 | 647 //double v2; // st7@2 |
0 | 648 float depth; // ST00_4@9 |
194 | 649 //bool result; // eax@9 |
0 | 650 unsigned int v5; // eax@14 |
651 __int64 v6; // kr00_8@21 | |
652 unsigned int y; // [sp+4h] [bp-24h]@2 | |
653 unsigned int x; // [sp+8h] [bp-20h]@2 | |
194 | 654 Vis_SelectionFilter *v10; // [sp+10h] [bp-18h]@2 |
655 Vis_SelectionFilter *v11; // [sp+14h] [bp-14h]@2 | |
0 | 656 POINT a2; // [sp+20h] [bp-8h]@1 |
657 | |
658 //v1 = this; | |
659 ++qword_5C6DF0; | |
660 pParticleEngine->UpdateParticles(); | |
661 pMouseInstance->GetCursorPos(&a2); | |
194 | 662 |
663 x = a2.y; | |
664 y = a2.x; | |
0 | 665 if ( sub_4637E0_is_there_popup_onscreen() ) |
666 { | |
194 | 667 v11 = &vis_face_filter; |
668 v10 = &vis_sprite_filter_2; | |
871 | 669 depth = pGame->pIndoorCameraD3D->GetPickDepth(); |
0 | 670 } |
671 else | |
672 { | |
592 | 673 if ( uFlags2 & GAME_FLAGS_2_TARGETING_MODE ) |
0 | 674 { |
194 | 675 v11 = &vis_face_filter; |
676 v10 = &vis_sprite_filter_1; | |
0 | 677 } |
678 else | |
679 { | |
194 | 680 v11 = &vis_face_filter; |
681 v10 = &vis_sprite_filter_4; | |
0 | 682 } |
194 | 683 depth = 5120.0; |
0 | 684 } |
194 | 685 //depth = v2; |
0 | 686 |
323 | 687 PickMouse(depth, y, x, false, v10, v11); |
0 | 688 pLightmapBuilder->std__vector_000004_size = 0; |
689 pLightmapBuilder->std__vector_183808_size = 0; | |
690 pDecalBuilder->std__vector_pDecals_size = 0; | |
691 pDecalBuilder->field_308008 = 0; | |
194 | 692 if (!_44F07B()) |
693 return false; | |
694 | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
638
diff
changeset
|
695 if ( uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS) |
794 | 696 pStru10Instance->bDoNotDrawPortalFrustum = false; |
0 | 697 if ( pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor) |
698 { | |
699 v5 = GetLevelFogColor(); | |
700 pRenderer->uFogColor = v5 & 0xFFFFFF; | |
701 } | |
702 if (uFlags & 0x0400) | |
703 uFlags2 |= 0x01; | |
704 if ( !pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor && pMobileLightsStack->uNumLightsActive ) | |
705 { | |
706 uFlags2 |= 0x01; | |
707 field_E10 = qword_5C6DF0; | |
708 } | |
709 v6 = qword_5C6DF0 - field_E10; | |
710 if ( qword_5C6DF0 - field_E10 == 1 ) | |
711 uFlags2 |= v6; | |
712 if (uNumStationaryLights_in_pStationaryLightsStack != pStationaryLightsStack->uNumLightsActive ) | |
713 { | |
714 uFlags2 |= 1u; | |
715 uNumStationaryLights_in_pStationaryLightsStack = pStationaryLightsStack->uNumLightsActive; | |
716 } | |
717 _44E904(); | |
194 | 718 return true; |
0 | 719 } |
720 | |
721 | |
722 //----- (0044EDE4) -------------------------------------------------------- | |
638 | 723 bool Game::AlterGamma_BLV(BLVFace *pFace, unsigned int *pColor) |
0 | 724 { |
638 | 725 if (uFlags2 & GAME_FLAGS_2_SATURATE_LIGHTMAPS && |
726 pFace->uAttributes & FACE_CAN_SATURATE_COLOR) | |
0 | 727 { |
728 *pColor = ReplaceHSV(*pColor, 1.0, fSaturation, -1.0); | |
729 return true; | |
730 } | |
731 else | |
732 return false; | |
733 } | |
734 | |
735 //----- (0044EE30) -------------------------------------------------------- | |
638 | 736 bool Game::AlterGamma_ODM(ODMFace *pFace, unsigned int *pColor) |
0 | 737 { |
638 | 738 if (uFlags2 & GAME_FLAGS_2_SATURATE_LIGHTMAPS && |
739 pFace->uAttributes & FACE_CAN_SATURATE_COLOR) | |
0 | 740 { |
638 | 741 *pColor = ReplaceHSV(*pColor, 1.0, fSaturation, -1.0); |
0 | 742 return true; |
743 } | |
744 else | |
745 return false; | |
746 } | |
747 | |
748 | |
749 //----- (004645FA) -------------------------------------------------------- | |
750 void Game::Deinitialize() | |
751 { | |
752 struct tagRECT Rect; // [sp+0h] [bp-10h]@6 | |
753 | |
1038 | 754 |
0 | 755 WriteWindowsRegistryInt("startinwindow", pRenderer->bWindowMode); |
756 if ( GetWindowRect(hWnd, &Rect) && pRenderer->bWindowMode ) | |
757 { | |
758 WriteWindowsRegistryInt("window X", Rect.left); | |
759 WriteWindowsRegistryInt("window Y", Rect.top); | |
760 } | |
761 WriteWindowsRegistryInt("valAlwaysRun", bAlwaysRun); | |
762 pItemsTable->Release(); | |
763 pNPCStats->Release(); | |
1038 | 764 |
0 | 765 if (pMouse) |
766 pMouse->Deactivate(); | |
767 | |
1093 | 768 delete pRenderer; |
0 | 769 pAudioPlayer->Release();//error |
770 pNew_LOD->FreeSubIndexAndIO(); | |
771 pGames_LOD->FreeSubIndexAndIO(); | |
772 ClipCursor(0); | |
773 Game::Destroy(); | |
774 } | |
775 | |
776 //----- (0044EE7C) -------------------------------------------------------- | |
777 bool Game::draw_debug_outlines() | |
778 { | |
779 if (uFlags & 0x04) | |
780 { | |
781 pLightmapBuilder->DrawDebugOutlines(-1); | |
782 pDecalBuilder->DrawDecalDebugOutlines(); | |
783 } | |
784 return true; | |
785 } | |
786 | |
787 //----- (0044EC23) -------------------------------------------------------- | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1277
diff
changeset
|
788 int Game::_44EC23(struct Polygon *a2, int *a3, signed int a4) |
0 | 789 { |
790 double v4; // st7@4 | |
791 //double v5; // ST00_8@4 | |
792 signed int v6; // eax@5 | |
793 //double v7; // ST00_8@6 | |
794 signed int result; // eax@8 | |
795 //double v9; // ST00_8@9 | |
796 //double v10; // ST00_8@11 | |
797 float a2a; // [sp+14h] [bp+8h]@4 | |
798 float a3a; // [sp+18h] [bp+Ch]@4 | |
799 float a3b; // [sp+18h] [bp+Ch]@6 | |
800 float a4a; // [sp+1Ch] [bp+10h]@9 | |
801 float a4b; // [sp+1Ch] [bp+10h]@11 | |
802 | |
803 if ( this->uFlags2 & 2 && a2->field_59 == 5 && a2->pODMFace->uAttributes & 2 ) | |
804 { | |
805 v4 = (double)a4; | |
806 a2a = v4; | |
807 *a3 |= 2u; | |
808 a3a = (1.0 - this->fSaturation) * v4; | |
809 //v5 = a3a + 6.7553994e15; | |
810 //if ( SLODWORD(v5) >= 0 ) | |
811 if (floorf(a3a + 0.5f) >= 0 ) | |
812 { | |
813 a3b = (1.0 - this->fSaturation) * a2a; | |
814 //v7 = a3b + 6.7553994e15; | |
815 //v6 = LODWORD(v7); | |
816 v6 = floorf(a3b + 0.5f); | |
817 } | |
818 else | |
819 { | |
820 v6 = 0; | |
821 } | |
822 if ( a4 >= v6 ) | |
823 { | |
824 a4a = (1.0 - fSaturation) * a2a; | |
825 //v9 = a4a + 6.7553994e15; | |
826 //if ( SLODWORD(v9) >= 0 ) | |
827 if (floorf(a4a + 0.5f) >= 0) | |
828 { | |
829 a4b = (1.0 - fSaturation) * a2a; | |
830 //v10 = a4b + 6.7553994e15; | |
831 //result = LODWORD(v10); | |
832 result = floorf(a4b + 0.5f); | |
833 } | |
834 else | |
835 { | |
836 result = 0; | |
837 } | |
838 } | |
839 else | |
840 { | |
841 result = a4; | |
842 } | |
843 } | |
844 else | |
845 { | |
846 result = -1; | |
847 } | |
848 return result; | |
849 } | |
850 | |
851 | |
852 | |
853 //----- (00465C8B) -------------------------------------------------------- | |
854 Game *Game::Create() | |
855 { | |
856 return new Game; | |
857 } | |
858 | |
859 //----- (00465CF3) -------------------------------------------------------- | |
860 void Game::Destroy() | |
861 { | |
862 if (pGame) | |
863 delete pGame; | |
864 pGame = nullptr; | |
865 } | |
866 | |
867 //----- (0044ED0A) -------------------------------------------------------- | |
868 signed int Game::_44ED0A(BLVFace *a2, int *a3, signed int a4) | |
869 { | |
870 double v4; // st7@3 | |
871 //double v5; // ST00_8@3 | |
872 signed int v6; // eax@4 | |
873 //double v7; // ST00_8@5 | |
874 signed int result; // eax@7 | |
875 //double v9; // ST00_8@8 | |
876 //double v10; // ST00_8@10 | |
877 float v11; // [sp+14h] [bp+8h]@3 | |
878 float v12; // [sp+18h] [bp+Ch]@3 | |
879 float v13; // [sp+18h] [bp+Ch]@5 | |
880 float v14; // [sp+1Ch] [bp+10h]@8 | |
881 float v15; // [sp+1Ch] [bp+10h]@10 | |
882 | |
883 if ( this->uFlags2 & 2 && a2->uAttributes & 2 ) | |
884 { | |
885 v4 = (double)a4; | |
886 v11 = v4; | |
887 *a3 |= 2u; | |
888 v12 = (1.0 - this->fSaturation) * v4; | |
889 //v5 = v12 + 6.7553994e15; | |
890 if (floorf(v12 + 0.5f)/* SLODWORD(v5)*/ >= 0 ) | |
891 { | |
892 v13 = (1.0 - this->fSaturation) * v11; | |
893 //v7 = v13 + 6.7553994e15; | |
894 //v6 = LODWORD(v7); | |
895 v6 = floorf(v13 + 0.5f); | |
896 } | |
897 else | |
898 { | |
899 v6 = 0; | |
900 } | |
901 if ( a4 >= v6 ) | |
902 { | |
903 v14 = (1.0 - fSaturation) * v11; | |
904 //v9 = v14 + 6.7553994e15; | |
905 if (floorf(v14 + 0.5f)/* SLODWORD(v9)*/ >= 0 ) | |
906 { | |
907 v15 = (1.0 - fSaturation) * v11; | |
908 //v10 = v15 + 6.7553994e15; | |
909 //result = LODWORD(v10); | |
910 result = floorf(v15 + 0.5f); | |
911 } | |
912 else | |
913 { | |
914 result = 0; | |
915 } | |
916 } | |
917 else | |
918 { | |
919 result = a4; | |
920 } | |
921 } | |
922 else | |
923 { | |
924 result = -1; | |
925 } | |
926 return result; | |
927 } | |
928 | |
929 | |
930 //----- (0044E4B7) -------------------------------------------------------- | |
931 Game::Game() | |
932 { | |
933 uNumStationaryLights = 0; | |
934 uNumBloodsplats = 0; | |
935 field_E0C = 0; | |
936 field_E10 = 0; | |
937 uNumStationaryLights_in_pStationaryLightsStack = 0; | |
938 bGammaControlInitialized = false; | |
939 uFlags = 0; | |
940 uFlags2 = 0; | |
941 uSomeGammaStartTime = 0; | |
942 uSomeGammaDeltaTime = 0; | |
943 | |
944 pThreadWardInstance = new ThreadWard; | |
945 pParticleEngine = new ParticleEngine; | |
946 pMouse = pMouseInstance = new Mouse(pThreadWardInstance); | |
947 pLightmapBuilder = new LightmapBuilder; | |
948 pVisInstance = new Vis; | |
949 pStru6Instance = new stru6; | |
950 pIndoorCameraD3D = new IndoorCameraD3D; | |
951 pStru9Instance = new stru9; | |
952 pStru10Instance = new stru10; | |
1391
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1277
diff
changeset
|
953 //pStru11Instance = new stru11; |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1277
diff
changeset
|
954 pStru11Instance = nullptr; |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1277
diff
changeset
|
955 //pStru12Instance = new stru12(pStru11Instance); |
cc9a3a24d61d
Moved stru11, stru12 and some SW Rendering stuff to the archives.
Nomad
parents:
1277
diff
changeset
|
956 pStru12Instance = nullptr; |
0 | 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 } |