| 5366 | -------------------------------------------------------------------------------*/ |
| 5367 | |
| 5368 | void pauseGame(int mode /* 0 == toggle, 1 == force unpause, 2 == force pause */, int ignoreplayer /* ignored */) |
| 5369 | { |
| 5370 | int c; |
| 5371 | |
| 5372 | if ( intro ) |
| 5373 | { |
| 5374 | return; |
| 5375 | } |
| 5376 | if ( mode == 1 && !gamePaused ) |
| 5377 | { |
| 5378 | return; |
| 5379 | } |
| 5380 | if ( mode == 2 && gamePaused ) |
| 5381 | { |
| 5382 | return; |
| 5383 | } |
| 5384 | if ( MainMenu::isCutsceneActive() ) |
| 5385 | { |
| 5386 | return; |
| 5387 | } |
| 5388 | |
| 5389 | if ( (!gamePaused && mode != 1) || mode == 2 ) |
| 5390 | { |
| 5391 | playSound(500, 96); |
| 5392 | gamePaused = true; |
| 5393 | bool noOneUsingKeyboard = true; |
| 5394 | for (int c = 0; c < 4; ++c) |
| 5395 | { |
| 5396 | if (inputs.bPlayerUsingKeyboardControl(c) && MainMenu::isPlayerSignedIn(c) && players[c]->isLocalPlayer()) { |
| 5397 | noOneUsingKeyboard = false; |
| 5398 | } |
| 5399 | auto& input = Input::inputs[c]; |
| 5400 | if (input.binary("Pause Game") || (inputs.bPlayerUsingKeyboardControl(c) && keystatus[SDLK_ESCAPE] && !input.isDisabled())) { |
| 5401 | MainMenu::pause_menu_owner = c; |
| 5402 | break; |
| 5403 | } |
| 5404 | } |
| 5405 | if (noOneUsingKeyboard && keystatus[SDLK_ESCAPE]) { |
| 5406 | MainMenu::pause_menu_owner = clientnum; |
| 5407 | } |
| 5408 | if ( SDL_GetRelativeMouseMode() ) |
| 5409 | { |
| 5410 | SDL_SetRelativeMouseMode(SDL_FALSE); |
| 5411 | } |
| 5412 | if (keystatus[SDLK_ESCAPE]) { |
| 5413 | keystatus[SDLK_ESCAPE] = 0; |
| 5414 | } |
| 5415 | return; // doesn't disable the game in multiplayer anymore |
| 5416 | if ( multiplayer == SERVER ) |
| 5417 | { |
| 5418 | for ( c = 1; c < MAXPLAYERS; c++ ) |
| 5419 | { |
| 5420 | if ( client_disconnected[c] || ignoreplayer == c ) |
| 5421 | { |
| 5422 | continue; |
| 5423 | } |
| 5424 | if (net_packet && net_packet->data) { |
| 5425 | strcpy((char*)net_packet->data, "PAUS"); |
no test coverage detected