| 325 | } |
| 326 | |
| 327 | bool Server::Load( const SaveLoadBuffer& buffer, unsigned int& buffer_pos ) |
| 328 | { |
| 329 | DisconnectAllClients(); |
| 330 | |
| 331 | Log::Info( "Loading save for server " ); |
| 332 | |
| 333 | const auto show_progress= |
| 334 | [&]( const float progress ) |
| 335 | { |
| 336 | if( draw_loading_callback_ != nullptr ) |
| 337 | draw_loading_callback_( progress, "Server" ); |
| 338 | }; |
| 339 | |
| 340 | show_progress( 0.0f ); |
| 341 | |
| 342 | LoadStream load_stream( buffer, buffer_pos, server_accumulated_time_ ); |
| 343 | |
| 344 | unsigned int game_rules; |
| 345 | load_stream.ReadUInt32( game_rules ); |
| 346 | |
| 347 | unsigned int map_number; |
| 348 | load_stream.ReadUInt32( map_number ); |
| 349 | |
| 350 | unsigned int difficulty; |
| 351 | load_stream.ReadUInt32( difficulty ); |
| 352 | |
| 353 | Log::Info( "Changing server map to ", map_number ); |
| 354 | |
| 355 | const MapDataConstPtr map_data= map_loader_->LoadMap( map_number ); |
| 356 | if( map_data == nullptr ) |
| 357 | { |
| 358 | Log::Warning( "Can not load map ", map_number ); |
| 359 | return false; |
| 360 | } |
| 361 | |
| 362 | show_progress( 0.5f ); |
| 363 | |
| 364 | game_rules_= static_cast<GameRules>( game_rules ); |
| 365 | map_changed_from_previous_map_= false; |
| 366 | current_map_data_= map_data; |
| 367 | map_.reset( |
| 368 | new Map( |
| 369 | static_cast<DifficultyType>(difficulty), |
| 370 | GameRules::SinglePlayer, |
| 371 | map_data, |
| 372 | load_stream, |
| 373 | game_resources_, |
| 374 | map_end_callback_ ) ); |
| 375 | |
| 376 | map_end_triggered_= false; |
| 377 | join_first_client_with_existing_player_= true; |
| 378 | |
| 379 | show_progress( 1.0f ); |
| 380 | |
| 381 | buffer_pos= load_stream.GetBufferPos(); |
| 382 | |
| 383 | return true; |
| 384 | } |
nothing calls this directly
no test coverage detected