| 97 | } |
| 98 | |
| 99 | static void LoadAction( const Vfs::FileContent& file_content, CutsceneScript& script ) |
| 100 | { |
| 101 | const char* const action= std::strstr( reinterpret_cast<const char*>(file_content.data()), "#action" ); |
| 102 | const char* const action_end= std::strstr( action + std::strlen("#action"), "#end" ); |
| 103 | |
| 104 | std::istringstream stream( std::string( action + std::strlen("#action"), action_end ) ); |
| 105 | |
| 106 | while( !stream.eof() ) |
| 107 | { |
| 108 | char line[ 512u ]; |
| 109 | stream.getline( line, sizeof(line), '\n' ); |
| 110 | if( stream.eof() ) |
| 111 | break; |
| 112 | |
| 113 | if( line[0] == ';' ) // comment |
| 114 | continue; |
| 115 | |
| 116 | std::istringstream line_stream{ std::string( line ) }; |
| 117 | char line_start[ 64 ]; |
| 118 | line_stream >> line_start; |
| 119 | if( line_stream.fail() ) |
| 120 | continue; |
| 121 | |
| 122 | CutsceneScript::ActionCommand::Type command_type= CutsceneScript::ActionCommand::Type::None; |
| 123 | |
| 124 | if( std::strcmp( line_start, "delay" ) == 0 ) |
| 125 | command_type= CutsceneScript::ActionCommand::Type::Delay; |
| 126 | else if( std::strcmp( line_start, "say" ) == 0 ) |
| 127 | command_type= CutsceneScript::ActionCommand::Type::Say; |
| 128 | else if( std::strcmp( line_start, "voice" ) == 0 ) |
| 129 | command_type= CutsceneScript::ActionCommand::Type::Voice; |
| 130 | else if( std::strcmp( line_start, "setani" ) == 0 ) |
| 131 | command_type= CutsceneScript::ActionCommand::Type::Setani; |
| 132 | else if( std::strcmp( line_start, "wait_key" ) == 0 ) |
| 133 | command_type= CutsceneScript::ActionCommand::Type::WaitKey; |
| 134 | else if( std::strcmp( line_start, "movecamto" ) == 0 ) |
| 135 | command_type= CutsceneScript::ActionCommand::Type::MoveCamTo; |
| 136 | |
| 137 | if( command_type != CutsceneScript::ActionCommand::Type::None ) |
| 138 | { |
| 139 | script.commands.emplace_back(); |
| 140 | CutsceneScript::ActionCommand& command= script.commands.back(); |
| 141 | command.type= command_type; |
| 142 | |
| 143 | // Load params |
| 144 | for( unsigned int i= 0u; i < CutsceneScript::ActionCommand::c_max_params; i++ ) |
| 145 | { |
| 146 | std::string& out_param= command.params[i]; |
| 147 | |
| 148 | char text_line[512]; |
| 149 | line_stream >> text_line; |
| 150 | if (text_line[0] == '"' ) |
| 151 | { |
| 152 | if( std::strcmp( text_line, "\"\"" ) != 0 ) |
| 153 | { |
| 154 | // Read line in "" |
| 155 | const int len= std::strlen(text_line); |
| 156 | line_stream.getline( text_line + len, sizeof(text_line) - len, '\n' ); |
no outgoing calls
no test coverage detected