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