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

Function LoadSetupData

PanzerChasm/client/cutscene_script.cpp:11–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9{
10
11static void LoadSetupData( const Vfs::FileContent& file_content, CutsceneScript& script )
12{
13 const char* const setup= std::strstr( reinterpret_cast<const char*>(file_content.data()), "#setup" );
14 const char* const setup_end= std::strstr( setup + std::strlen("#setup"), "#" );
15
16 std::istringstream stream( std::string( setup + std::strlen("#setup"), setup_end ) );
17
18 while( !stream.eof() )
19 {
20 char line[ 512u ];
21 stream.getline( line, sizeof(line), '\n' );
22 if( stream.eof() )
23 break;
24
25 if( std::strncmp( line, "camera:", std::strlen( "camera:" ) ) == 0 )
26 {
27 std::istringstream line_stream( std::string( line + std::strlen( "camera:" ) ) );
28 line_stream >> script.camera_params.pos.x;
29 line_stream >> script.camera_params.pos.y;
30 line_stream >> script.camera_params.pos.z;
31 line_stream >> script.camera_params.angle;
32
33 script.camera_params.pos/= 64.0f;
34 script.camera_params.angle*= Constants::to_rad;
35 }
36 else if( std::strncmp( line, "ambient:", std::strlen( "ambient:" ) ) == 0 )
37 script.ambient_sound_number= std::atoi( line + std::strlen( "ambient:" ) );
38 else if( std::strncmp( line, "room:", std::strlen( "room:" ) ) == 0 )
39 script.room_number= std::atoi( line + std::strlen( "room:" ) );
40 else if( std::strncmp( line, "character", std::strlen( "character" ) ) == 0 )
41 {
42 const unsigned int character_number= std::atoi( line + std::strlen( "character" ) );
43 if( character_number >= script.characters.size() )
44 script.characters.resize( character_number + 1u );
45
46 CutsceneScript::Character& character= script.characters[character_number];
47 std::memset( character.model_file_name, 0, sizeof( character.model_file_name ) );
48 std::memset( character.idle_animation_file_name, 0, sizeof( character.idle_animation_file_name ) );
49 std::memset( character.animations_file_name, 0, sizeof( character.animations_file_name ) );
50
51 while( !stream.eof() )
52 {
53 char character_line[ 512u ];
54 stream.getline( character_line, sizeof(character_line), '\n' );
55 if( stream.eof() )
56 break;
57
58 std::istringstream line_stream{ std::string( character_line ) };
59 char line_start[ 64 ];
60 line_stream >> line_start;
61
62 if( std::strcmp( line_start, "model" ) == 0 )
63 {
64 line_stream >> character.model_file_name;
65 }
66 else if( std::strcmp( line_start, "position" ) == 0 )
67 {
68 line_stream >> character.pos.x;

Callers 1

LoadCutsceneScriptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected