| 240 | } |
| 241 | |
| 242 | void Client::Loop( const InputState& input_state, const bool paused ) |
| 243 | { |
| 244 | const Time current_real_time= Time::CurrentTime(); |
| 245 | |
| 246 | // Calculate time, which we spend in pause. |
| 247 | // Subtract time, spended in pauses, from real time. |
| 248 | if( paused && !paused_ ) |
| 249 | { |
| 250 | paused_= paused; |
| 251 | pause_start_time_= current_real_time; |
| 252 | } |
| 253 | if( paused ) |
| 254 | return; |
| 255 | if( !paused && paused_ ) |
| 256 | { |
| 257 | paused_= paused; |
| 258 | accumulated_pauses_time_+= current_real_time - pause_start_time_; |
| 259 | pause_start_time_= Time::FromSeconds(0); |
| 260 | } |
| 261 | |
| 262 | const Time prev_tick_time= current_tick_time_; |
| 263 | current_tick_time_= current_real_time - accumulated_pauses_time_; |
| 264 | const float tick_dt_s= ( current_tick_time_ - prev_tick_time ).ToSeconds(); |
| 265 | |
| 266 | if( connection_info_ != nullptr ) |
| 267 | { |
| 268 | if( connection_info_->connection->Disconnected() ) |
| 269 | StopMap(); |
| 270 | else |
| 271 | connection_info_->messages_extractor.ProcessMessages( *this ); |
| 272 | } |
| 273 | |
| 274 | if( cutscene_player_ != nullptr ) |
| 275 | { |
| 276 | if( cutscene_player_->IsFinished() ) |
| 277 | { |
| 278 | cutscene_player_= nullptr; |
| 279 | |
| 280 | PC_ASSERT( current_map_data_ != nullptr ); |
| 281 | if( sound_engine_ != nullptr ) |
| 282 | sound_engine_->SetMap( current_map_data_ ); |
| 283 | map_drawer_->SetMap( current_map_data_ ); |
| 284 | minimap_drawer_->SetMap( current_map_data_ ); |
| 285 | } |
| 286 | else |
| 287 | return; |
| 288 | } |
| 289 | |
| 290 | { // Scale minimap. |
| 291 | const float log2_delta= 2.0f * tick_dt_s; |
| 292 | if( input_state.keyboard[ static_cast<unsigned int>( SystemEvent::KeyEvent::KeyCode::SquareBrackretLeft ) ] ) |
| 293 | minimap_scale_log2_-= log2_delta; |
| 294 | if( input_state.keyboard[ static_cast<unsigned int>( SystemEvent::KeyEvent::KeyCode::SquareBrackretRight ) ] ) |
| 295 | minimap_scale_log2_+= log2_delta; |
| 296 | minimap_scale_log2_= std::max( -2.0f, std::min( minimap_scale_log2_, 1.0f ) ); |
| 297 | } |
| 298 | |
| 299 | shoot_pressed_= input_state.mouse[ static_cast<unsigned int>( SystemEvent::MouseKeyEvent::Button::Left ) ]; |
nothing calls this directly
no test coverage detected