MCPcopy Create free account
hub / github.com/Panzerschrek/Chasm-Reverse / Loop

Method Loop

PanzerChasm/client/client.cpp:242–349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240}
241
242void 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 ) ];

Callers

nothing calls this directly

Calls 15

AngleToMessageAngleFunction · 0.85
ToSecondsMethod · 0.80
IsFinishedMethod · 0.80
SetHeadPositionMethod · 0.80
GetViewAngleZMethod · 0.80
GetViewAngleXMethod · 0.80
UpdateMapStateMethod · 0.80
SetPlayerStateMethod · 0.80
GetAccelerationMethod · 0.80
JumpPressedMethod · 0.80
GetOrSetIntMethod · 0.80
SendUnreliableMessageMethod · 0.80

Tested by

no test coverage detected