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

Method Map

PanzerChasm/server/map.cpp:83–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83Map::Map(
84 const DifficultyType difficulty,
85 const GameRules game_rules,
86 const MapDataConstPtr& map_data,
87 const GameResourcesConstPtr& game_resources,
88 const Time map_start_time,
89 MapEndCallback map_end_callback )
90 : difficulty_(difficulty)
91 , game_rules_(game_rules)
92 , map_data_(map_data)
93 , game_resources_(game_resources)
94 , map_end_callback_( std::move( map_end_callback ) )
95 , random_generator_( std::make_shared<LongRand>() )
96 , collision_index_( map_data )
97{
98 PC_ASSERT( map_data_ != nullptr );
99 PC_ASSERT( game_resources_ != nullptr );
100
101 unsigned int difficulty_mask= static_cast<unsigned int>( difficulty_ );
102 if( game_rules == GameRules::Deathmatch )
103 difficulty_mask|= 8u;
104
105 std::memset( wind_field_, 0, sizeof(wind_field_) );
106 std::memset( death_field_, 0, sizeof(death_field_) );
107
108 procedures_.resize( map_data_->procedures.size() );
109 for( unsigned int p= 0u; p < procedures_.size(); p++ )
110 {
111 if( map_data_->procedures[p].locked )
112 procedures_[p].locked= true;
113 }
114
115 dynamic_walls_.resize( map_data_->dynamic_walls.size() );
116 for( unsigned int w= 0u; w < dynamic_walls_.size(); w++ )
117 {
118 dynamic_walls_[w].texture_id= map_data_->dynamic_walls[w].texture_id;
119 }
120
121 static_models_.resize( map_data_->static_models.size() );
122 for( unsigned int m= 0u; m < static_models_.size(); m++ )
123 {
124 const MapData::StaticModel& in_model= map_data_->static_models[m];
125 StaticModel& out_model= static_models_[m];
126
127 if( ( in_model.difficulty_flags & difficulty_mask ) == 0u )
128 out_model.model_id= 255; // Disable model for current difficulty. TODO - maybe tihs is not enough.
129 else
130 out_model.model_id= in_model.model_id;
131
132 const MapData::ModelDescription* const model_description=
133 out_model.model_id < map_data_->models_description.size()
134 ? &map_data_->models_description[ out_model.model_id] : nullptr;
135
136 out_model.health= model_description == nullptr ? 0 : model_description->break_limit;
137
138 out_model.pos= m_Vec3( in_model.pos, 0.0f );
139 out_model.angle= in_model.angle;
140 out_model.baze_z= 0.0f;

Callers

nothing calls this directly

Calls 2

BuildStateMessageMethod · 0.45

Tested by

no test coverage detected