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

Method LoadWalls

PanzerChasm/map_loader.cpp:273–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271}
272
273void MapLoader::LoadWalls(
274 const Vfs::FileContent& map_file,
275 MapData& map_data,
276 const DynamicWallsMask& dynamic_walls_mask,
277 const unsigned char* walls_lightmap_data )
278{
279 const unsigned int c_walls_offset= 0x18001u;
280
281 for( unsigned int y= 0u; y < MapData::c_map_size; y++ )
282 for( unsigned int x= 0u; x < MapData::c_map_size; x++ )
283 {
284 const bool is_dynamic= dynamic_walls_mask[ x + y * MapData::c_map_size ];
285 MapData::IndexElement& index_element= map_data.map_index[ x + y * MapData::c_map_size ];
286
287 const MapWall& map_wall=
288 *reinterpret_cast<const MapWall*>( map_file.data() + c_walls_offset + sizeof(MapWall) * ( y + x * MapData::c_map_size ) );
289
290 if( map_wall.texture_id == 0u )
291 {
292 // Trash
293 continue;
294 }
295 if( map_wall.texture_id >= 128u )
296 {
297 const unsigned int c_first_item= 131u;
298 const unsigned int c_first_model= 163u;
299
300 if( map_wall.texture_id == 250u )
301 {
302 // Many walls have thist texture id. I don`t know, what is that. Lights, maybe?
303 }
304 else if( map_wall.texture_id >= c_first_model + 64u )
305 {
306 // Presumably, levels have no more, then 64 models.
307 }
308 else if( map_wall.texture_id >= c_first_model )
309 {
310 // Presumably, this is mask of difficulty.
311 // bit 0 - easy, 1 - normal, 2 - hard, 3 - deathmatch
312 const unsigned int difficulty_levels_mask= map_wall.vert_coord[1][0] & 7u;
313 PC_UNUSED( difficulty_levels_mask );
314
315 map_data.static_models.emplace_back();
316 MapData::StaticModel& model= map_data.static_models.back();
317 model.pos.x= float(map_wall.vert_coord[0][0]) * g_map_coords_scale;
318 model.pos.y= float(map_wall.vert_coord[0][1]) * g_map_coords_scale;
319 model.angle= float(map_wall.unknown & 7u) / 8.0f * Constants::two_pi + Constants::pi;
320 model.model_id= map_wall.texture_id - c_first_model;
321 model.difficulty_flags= map_wall.vert_coord[1][0];
322 model.is_dynamic= is_dynamic;
323
324 index_element.type= MapData::IndexElement::StaticModel;
325 index_element.index= map_data.static_models.size() - 1u;
326 }
327 else if( map_wall.texture_id >= c_first_item )
328 {
329 map_data.items.emplace_back();
330 MapData::Item& item= map_data.items.back();

Callers

nothing calls this directly

Calls 1

ConvertMapLightFunction · 0.85

Tested by

no test coverage detected