src/misc_cmd.cpp
changeset 8013 82001acdb8d0
parent 7802 246a94599679
child 8065 605375063266
equal deleted inserted replaced
8012:5faf4ff3b4d2 8013:82001acdb8d0
   292 	}
   292 	}
   293 
   293 
   294 	return CommandCost();
   294 	return CommandCost();
   295 }
   295 }
   296 
   296 
       
   297 /**
       
   298  * In case of an unsafe unpause, we want the
       
   299  * user to confirm that it might crash.
       
   300  * @param w         unused
       
   301  * @param confirmed whether the user confirms his/her action
       
   302  */
       
   303 static void AskUnsafeUnpauseCallback(Window *w, bool confirmed)
       
   304 {
       
   305 	DoCommandP(0, confirmed ? 0 : 1, 0, NULL, CMD_PAUSE);
       
   306 }
       
   307 
   297 /** Pause/Unpause the game (server-only).
   308 /** Pause/Unpause the game (server-only).
   298  * Increase or decrease the pause counter. If the counter is zero,
   309  * Increase or decrease the pause counter. If the counter is zero,
   299  * the game is unpaused. A counter is used instead of a boolean value
   310  * the game is unpaused. A counter is used instead of a boolean value
   300  * to have more control over the game when saving/loading, etc.
   311  * to have more control over the game when saving/loading, etc.
   301  * @param tile unused
   312  * @param tile unused
   305  */
   316  */
   306 CommandCost CmdPause(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   317 CommandCost CmdPause(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   307 {
   318 {
   308 	if (flags & DC_EXEC) {
   319 	if (flags & DC_EXEC) {
   309 		_pause_game += (p1 == 1) ? 1 : -1;
   320 		_pause_game += (p1 == 1) ? 1 : -1;
   310 		if (_pause_game == (byte)-1) _pause_game = 0;
   321 
       
   322 		switch (_pause_game) {
       
   323 			case (byte)-4:
       
   324 			case (byte)-1:
       
   325 				_pause_game = 0;
       
   326 				break;
       
   327 			case (byte)-3:
       
   328 				ShowQuery(
       
   329 					STR_NEWGRF_UNPAUSE_WARNING_TITLE,
       
   330 					STR_NEWGRF_UNPAUSE_WARNING,
       
   331 					NULL,
       
   332 					AskUnsafeUnpauseCallback
       
   333 				);
       
   334 				break;
       
   335 
       
   336 			default: break;
       
   337 		}
       
   338 
   311 		InvalidateWindow(WC_STATUS_BAR, 0);
   339 		InvalidateWindow(WC_STATUS_BAR, 0);
   312 		InvalidateWindow(WC_MAIN_TOOLBAR, 0);
   340 		InvalidateWindow(WC_MAIN_TOOLBAR, 0);
   313 	}
   341 	}
   314 	return CommandCost();
   342 	return CommandCost();
   315 }
   343 }