Parameter: state - 1 = success, 0 = failure, -1 = abort
| 1890 | |
| 1891 | // Parameter: state - 1 = success, 0 = failure, -1 = abort |
| 1892 | void EndLevel(int state) { |
| 1893 | tLevelNode *lvl = &Current_mission.levels[Current_mission.cur_level - 1]; |
| 1894 | |
| 1895 | // Tells all the clients to end the level |
| 1896 | if ((Game_mode & GM_MULTI) && Netgame.local_role == LR_SERVER) { |
| 1897 | MultiSendLevelEnded(state, Multi_next_level); |
| 1898 | CallGameDLL(EVT_CLIENT_GAMELEVELEND, &DLLInfo); |
| 1899 | CallMultiDLL(MT_EVT_GAME_OVER); |
| 1900 | } |
| 1901 | |
| 1902 | if (!(Game_mode & GM_MULTI)) { |
| 1903 | |
| 1904 | // report the information to the pilot's mission data |
| 1905 | CurrentPilotUpdateMissionStatus(); |
| 1906 | // Sound_system.StopAllSounds(); -- moved to below because bug was reported that sounds were |
| 1907 | // playing in performance screen |
| 1908 | |
| 1909 | // save our shields (in case this call is due to starting a new level |
| 1910 | // in InitPlayerNewLevel, we'll determine if we should restore them |
| 1911 | // this function ALWAYS gets called right before InitPlayerNewLevel from StartLevel |
| 1912 | Player_shields_saved_from_last_level = Objects[Players[Player_num].objnum].shields; |
| 1913 | Player_energy_saved_from_last_level = Players[Player_num].energy; |
| 1914 | } else { |
| 1915 | // Stop all player sounds |
| 1916 | for (int i = 0; i < MAX_PLAYERS; i++) { |
| 1917 | if (NetPlayers[i].flags & NPF_CONNECTED) { |
| 1918 | PlayerStopSounds(i); |
| 1919 | Players[i].flags &= ~(PLAYER_FLAGS_THRUSTED | PLAYER_FLAGS_AFTERBURN_ON); |
| 1920 | } |
| 1921 | } |
| 1922 | } |
| 1923 | |
| 1924 | // clear screen now. |
| 1925 | if (!Dedicated_server) { |
| 1926 | StartFrame(); |
| 1927 | rend_ClearScreen(GR_BLACK); |
| 1928 | EndFrame(); |
| 1929 | rend_Flip(); |
| 1930 | Sound_system.StopAllSounds(); |
| 1931 | } |
| 1932 | |
| 1933 | // Sequencing here. |
| 1934 | // if this level has an endmovie |
| 1935 | if ((state == 1) && (lvl->flags & LVLFLAG_ENDMOVIE) && !(Game_mode & GM_MULTI)) { |
| 1936 | DoMissionMovie(lvl->endmovie); |
| 1937 | } |
| 1938 | |
| 1939 | // display postlevel results. |
| 1940 | if ((state != -1) && (GetFunctionMode() != EDITOR_GAME_MODE)) |
| 1941 | PostLevelResults(state == 1); |
| 1942 | |
| 1943 | // check for dead players |
| 1944 | if (Game_mode & GM_MULTI) { |
| 1945 | // in multiplayer check all players |
| 1946 | for (int i = 0; i < MAX_PLAYERS; i++) { |
| 1947 | if ((NetPlayers[i].flags & NPF_CONNECTED) && (NetPlayers[i].sequence >= NETSEQ_PLAYING)) { |
| 1948 | // check to see if player is dying |
| 1949 | if ((Players[i].flags & PLAYER_FLAGS_DYING) || (Players[i].flags & PLAYER_FLAGS_DEAD)) { |
no test coverage detected