void do_game() { char buf[MAX_INPUT_LENGTH]; if(num_in_arena() == 1) { ppl_in_arena = 0; ppl_challenged = 0; find_game_winner(); } else if(time_left_in_game == 0) { do_end_game(); } else if(num_in_arena() == 0) { ppl_in_arena = 0; ppl_challenged = 0; silent_end(); } else if(time_left_in_game % 5) { sprintf(buf, "With %d hours left in the game there are %d players left.", time_left_in_game, num_in_arena()); sportschan(buf); } else if(time_left_in_game == 1) { sprintf(buf, "With 1 hour left in the game there are %d players left.", num_in_arena()); sportschan(buf); } else if(time_left_in_game <= 4) { sprintf(buf, "With %d hours left in the game there are %d players left.", time_left_in_game, num_in_arena()); sportschan(buf); } time_left_in_game--; }
//called to go to the next level (if there is one) //if secret_flag is true, advance to secret level, else next normal one // Return true if game over. int AdvanceLevel(int secret_flag) { Fuelcen_control_center_destroyed = 0; #ifdef EDITOR if (PLAYING_BUILTIN_MISSION) return 0; //not a real level #endif #ifdef NETWORK if (Game_mode & GM_MULTI) { int result; result = multi_endlevel(&secret_flag); // Wait for other players to reach this point if (result) // failed to sync return (Current_level_num == Last_level); } #endif if (Current_level_num == Last_level) { //player has finished the game! Function_mode = FMODE_MENU; if ((Newdemo_state == ND_STATE_RECORDING) || (Newdemo_state == ND_STATE_PAUSED)) newdemo_stop_recording(); #ifndef SHAREWARE songs_play_song( SONG_ENDGAME, 0 ); #endif do_end_game(); return 1; } else { Next_level_num = Current_level_num+1; //assume go to next normal level if (secret_flag) { //go to secret level instead int i; for (i=0;i<-Last_secret_level;i++) if (Secret_level_table[i]==Current_level_num) { Next_level_num = -(i+1); break; } Assert(i<-Last_secret_level); //couldn't find which secret level } if (Current_level_num < 0) { //on secret level, where to go? Assert(!secret_flag); //shouldn't be going to secret level Assert(Current_level_num<=-1 && Current_level_num>=Last_secret_level); Next_level_num = Secret_level_table[(-Current_level_num)-1]+1; } StartNewLevel(Next_level_num); } return 0; }