comparison Game.cpp @ 982:08fd1436ef35

enums & lod
author Nomad
date Sat, 11 May 2013 13:19:55 +0200
parents a6ef7125f6e4
children 1462a5f12b65
comparison
equal deleted inserted replaced
981:a6ef7125f6e4 982:08fd1436ef35
256 signed int pNewNPCsCount; // ecx@58 256 signed int pNewNPCsCount; // ecx@58
257 char *pFlags; // eax@59 257 char *pFlags; // eax@59
258 Player *pPlayer; // esi@65 258 Player *pPlayer; // esi@65
259 //OtherOverlay *pOtherOverlay; // esi@67 259 //OtherOverlay *pOtherOverlay; // esi@67
260 //signed int v8; // edi@67 260 //signed int v8; // edi@67
261 int pPlayerNum; // edi@69 261 //int pPlayerNum; // edi@69
262 int *pHealth; // esi@71 262 int *pHealth; // esi@71
263 signed int v11; // esi@78 263 //signed int v11; // esi@78
264 int v12; // eax@83 264 //int v12; // eax@83
265 const char *pLocationName; // [sp-4h] [bp-68h]@74 265 const char *pLocationName; // [sp-4h] [bp-68h]@74
266 bool bLoading; // [sp+10h] [bp-54h]@1 266 bool bLoading; // [sp+10h] [bp-54h]@1
267 signed int bLoadinga; // [sp+10h] [bp-54h]@19 267 //signed int bLoadinga; // [sp+10h] [bp-54h]@19
268 signed int v16; // [sp+14h] [bp-50h]@8 268 signed int v16; // [sp+14h] [bp-50h]@8
269 int v17[4]; // [sp+18h] [bp-4Ch]@80 269 //int v17[4]; // [sp+18h] [bp-4Ch]@80
270 MSG Msg; // [sp+28h] [bp-3Ch]@20 270 MSG Msg; // [sp+28h] [bp-3Ch]@20
271 char Source[64]; // [sp+44h] [bp-20h]@76 271 char Source[64]; // [sp+44h] [bp-20h]@76
272 272
273 bLoading = uCurrentMenuID == MENU_LoadingProcInMainMenu; 273 bLoading = uCurrentMenuID == MENU_LoadingProcInMainMenu;
274 SetCurrentMenuID((MENU_STATE)-1); 274 SetCurrentMenuID((MENU_STATE)-1);
275 if (bLoading) 275 if (bLoading)
276 { 276 {
277 pParty->Reset(); 277 pParty->Reset();
278 dword_6BE340 = 0; 278 dword_6BE340 = 0;
279 uGameState = GAME_STATE_0; 279 uGameState = GAME_STATE_PLAYING;
280 LoadGame(uLoadGameUI_SelectedSlot); 280 LoadGame(uLoadGameUI_SelectedSlot);
281 } 281 }
282 282
283 for (uint i = 1; i < 5; ++i) 283 for (uint i = 1; i < 5; ++i)
284 for (uint j = 1; j < 6; ++j) 284 for (uint j = 1; j < 6; ++j)
312 pAsyncMouse->Resume(); 312 pAsyncMouse->Resume();
313 if (pGame->pKeyboardInstance->bUsingAsynKeyboard && pAsyncKeyboard ) 313 if (pGame->pKeyboardInstance->bUsingAsynKeyboard && pAsyncKeyboard )
314 pAsyncKeyboard->Resume(); 314 pAsyncKeyboard->Resume();
315 if ( pRenderer->pRenderD3D ) 315 if ( pRenderer->pRenderD3D )
316 pGame->pVisInstance->_4C1A02(); 316 pGame->pVisInstance->_4C1A02();
317 bLoadinga = 0; 317
318 bool game_finished = false;
318 do 319 do
319 { 320 {
320 while ( PeekMessageA(&Msg, 0, 0, 0, PM_REMOVE) ) 321 while ( PeekMessageA(&Msg, 0, 0, 0, PM_REMOVE) )
321 { 322 {
322 if ( Msg.message == WM_QUIT ) 323 if ( Msg.message == WM_QUIT )
347 pMouse->DrawCursorToTarget(); 348 pMouse->DrawCursorToTarget();
348 pVideoPlayer->SmackUpdatePalette(pVideoPlayer->hWindow); 349 pVideoPlayer->SmackUpdatePalette(pVideoPlayer->hWindow);
349 pMouse->_469EA4(); 350 pMouse->_469EA4();
350 pRenderer->EndScene(); 351 pRenderer->EndScene();
351 } 352 }
352 if ( pVideoPlayer->pBinkMovie && !BinkWait(pVideoPlayer->pBinkMovie) ) 353 else if ( pVideoPlayer->pBinkMovie && !BinkWait(pVideoPlayer->pBinkMovie) )
353 { 354 {
354 pRenderer->BeginScene(); 355 pRenderer->BeginScene();
355 pMouse->DrawCursorToTarget(); 356 pMouse->DrawCursorToTarget();
356 pVideoPlayer->BinkUpdatePalette(pVideoPlayer->hWindow); 357 pVideoPlayer->BinkUpdatePalette(pVideoPlayer->hWindow);
357 pMouse->_469EA4(); 358 pMouse->_469EA4();
358 pRenderer->EndScene(); 359 pRenderer->EndScene();
359 } 360 }
360
361 static int gtc_old = GetTickCount();
362 int gtc = GetTickCount();
363 auto evt_old = pEventTimer->uStartTime,
364 msc_old = pMiscTimer->uStartTime;
365 pEventTimer->Update();
366 pMiscTimer->Update();
367 Log::Warning(L"Evt/Msc/GTC dt: %u/%u/%u", pEventTimer->uTimeElapsed, pMiscTimer->uTimeElapsed, gtc - gtc_old);
368 gtc_old = gtc;
369 361
370 OnTimer(0); 362 OnTimer(0);
371 GameUI_StatusBar_UpdateTimedString(0); 363 GameUI_StatusBar_UpdateTimedString(0);
372 if ( pMiscTimer->bPaused && !pEventTimer->bPaused ) 364 if ( pMiscTimer->bPaused && !pEventTimer->bPaused )
373 pMiscTimer->Resume(); 365 pMiscTimer->Resume();
374 if ( pEventTimer->bTackGameTime && !pParty->bTurnBasedModeOn ) 366 if ( pEventTimer->bTackGameTime && !pParty->bTurnBasedModeOn )
375 pEventTimer->bTackGameTime = 0; 367 pEventTimer->bTackGameTime = 0;
376 if ( !pEventTimer->bPaused && uGameState == GAME_STATE_0) 368 if ( !pEventTimer->bPaused && uGameState == GAME_STATE_PLAYING)
377 { 369 {
378 if ( !pEventTimer->bTackGameTime ) 370 if ( !pEventTimer->bTackGameTime )
379 _494035_timed_effects__water_walking_damage__etc(); 371 _494035_timed_effects__water_walking_damage__etc();
380 if ( dword_6BE364_game_settings_1 & 1 ) 372 if ( dword_6BE364_game_settings_1 & 1 )
381 { 373 {
394 } 386 }
395 pAudioPlayer->UpdateSounds(); 387 pAudioPlayer->UpdateSounds();
396 if (uGameState == GAME_FINISHED) 388 if (uGameState == GAME_FINISHED)
397 //goto LABEL_96; 389 //goto LABEL_96;
398 { 390 {
399 bLoadinga = 1; 391 game_finished = true;
400 continue; 392 continue;
401 } 393 }
402 if (uGameState == GAME_STATE_2) 394 if (uGameState == GAME_STATE_2)
403 { 395 {
404 pAudioPlayer->StopChannels(-1, -1); 396 pAudioPlayer->StopChannels(-1, -1);
405 PrepareWorld(0); 397 PrepareWorld(0);
406 uGameState = GAME_STATE_0; 398 uGameState = GAME_STATE_PLAYING;
407 continue; 399 continue;
408 } 400 }
409 if ( (signed int)uGameState <= GAME_STATE_2 ) 401 if ( (signed int)uGameState <= GAME_STATE_2 )
410 //goto LABEL_85; 402 //goto LABEL_85;
411 { 403 {
413 continue; 405 continue;
414 } 406 }
415 if ( (signed int)uGameState <= GAME_STATE_5 || uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU ) 407 if ( (signed int)uGameState <= GAME_STATE_5 || uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU )
416 { 408 {
417 //LABEL_96: 409 //LABEL_96:
418 bLoadinga = 1; 410 game_finished = true;
419 continue; 411 continue;
420 } 412 }
421 if ( uGameState != GAME_STATE_PARTY_DIED ) 413 if ( uGameState != GAME_STATE_PARTY_DIED )
422 { 414 {
423 if ( uGameState != GAME_STATE_FINAL_WINDOW ) 415 if ( uGameState != GAME_STATE_FINAL_WINDOW )
465 while ( (signed int)pPlayer < (signed int)pParty->pHirelings ); 457 while ( (signed int)pPlayer < (signed int)pParty->pHirelings );
466 pParty->days_played_without_rest = 0; 458 pParty->days_played_without_rest = 0;
467 pParty->uTimePlayed += 0x276000ui64; 459 pParty->uTimePlayed += 0x276000ui64;
468 LOWORD(pParty->uFlags) &= ~0x204; 460 LOWORD(pParty->uFlags) &= ~0x204;
469 pParty->SetGold(0); 461 pParty->SetGold(0);
470
471 pOtherOverlayList->Reset(); 462 pOtherOverlayList->Reset();
472
473 memset(pParty->pPartyBuffs, 0, 0x140u); 463 memset(pParty->pPartyBuffs, 0, 0x140u);
474 pPlayerNum = 1; 464
475 if ( pParty->bTurnBasedModeOn == 1 ) 465 if ( pParty->bTurnBasedModeOn == 1 )
476 { 466 {
477 pTurnEngine->End(1); 467 pTurnEngine->End(1);
478 pParty->bTurnBasedModeOn = 0; 468 pParty->bTurnBasedModeOn = 0;
479 } 469 }
521 _5B65B8_npcdata_hiword_house_or_other = pParty->sRotationX; 511 _5B65B8_npcdata_hiword_house_or_other = pParty->sRotationX;
522 dword_5B65C0 = 1; 512 dword_5B65C0 = 1;
523 PrepareWorld(1); 513 PrepareWorld(1);
524 } 514 }
525 InitializeActors(); 515 InitializeActors();
526 v11 = 0; 516
527 do 517
528 { 518 int num_conscious_players = 0;
529 if ( pPlayers[pPlayerNum]->CanAct() ) 519 int conscious_players_ids[4] = {-1, -1, -1, -1};
530 v17[v11++] = pPlayerNum; 520 for (int v11 = 0; v11 < 4; ++v11)
531 ++pPlayerNum; 521 {
532 } 522 if (pPlayers[v11 + 1]->CanAct())
533 while ( pPlayerNum <= 4 ); 523 conscious_players_ids[num_conscious_players++] = v11;
534 if ( v11 ) 524 }
535 { 525 if (num_conscious_players)
536 v12 = rand(); 526 {
537 pPlayers[v17[v12 % v11]]->PlaySound(SPEECH_99, 0); 527 int idx = conscious_players_ids[rand() % num_conscious_players];
538 } 528 assert(idx >= 0);
529 pPlayers[idx + 1]->PlaySound(SPEECH_99, 0);
530 }
531
539 ShowStatusBarString(pGlobalTXT_LocalizationStrings[524], 2u);// "Once again you've cheated death!.." "Вы снова обхитрили смерть! …" 532 ShowStatusBarString(pGlobalTXT_LocalizationStrings[524], 2u);// "Once again you've cheated death!.." "Вы снова обхитрили смерть! …"
540 uGameState = GAME_STATE_0; 533 uGameState = GAME_STATE_PLAYING;
541 } 534 }
542 while ( !bLoadinga ); 535 while (!game_finished);
536
543 dword_6BE340 = 0; 537 dword_6BE340 = 0;
544 pEventTimer->Pause(); 538 pEventTimer->Pause();
545 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); 539 ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows();
546 if ( uGameState == GAME_STATE_3 ) 540 if ( uGameState == GAME_STATE_3 )
547 { 541 {
548 sub_491E3A(); 542 sub_491E3A();
549 LoadPlayerPortraintsAndVoices(); 543 LoadPlayerPortraintsAndVoices();
550 uGameState = GAME_STATE_0; 544 uGameState = GAME_STATE_PLAYING;
551 pIcons_LOD->dword_11B84 = pIcons_LOD->uNumLoadedFiles; 545 pIcons_LOD->dword_11B84 = pIcons_LOD->uNumLoadedFiles;
552 bLoading = true; 546 bLoading = true;
553 continue; 547 continue;
554 } 548 }
555 break; 549 break;