MCPcopy Create free account
hub / github.com/TurningWheel/Barony / pauseGame

Function pauseGame

src/game.cpp:5368–5500  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5366-------------------------------------------------------------------------------*/
5367
5368void 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");

Callers 14

actWinningPortalFunction · 0.85
actMidGamePortalMethod · 0.85
gameLogicFunction · 0.85
handleEventsFunction · 0.85
mainFunction · 0.85
doNewGameFunction · 0.85
doMidgameFunction · 0.85
changeLevelFunction · 0.85
net.cppFile · 0.85

Calls 7

playSoundFunction · 0.85
sendPacketSafeFunction · 0.85
isLocalPlayerMethod · 0.80
buttonCloseSubwindowFunction · 0.70
binaryMethod · 0.45
isDisabledMethod · 0.45

Tested by

no test coverage detected