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

Method DoProcedureImmediateCommands

PanzerChasm/server/map.cpp:2196–2357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2194}
2195
2196void Map::DoProcedureImmediateCommands( const MapData::Procedure& procedure, const Time current_time )
2197{
2198 // Do immediate commands
2199 for( const MapData::Procedure::ActionCommand& command : procedure.action_commands )
2200 {
2201 // TODO - replace with switch-case
2202 using Command= MapData::Procedure::ActionCommandId;
2203 if( command.id == Command::Lock )
2204 {
2205 const unsigned short proc_number= static_cast<unsigned short>( command.args[0] );
2206 PC_ASSERT( proc_number < procedures_.size() );
2207
2208 procedures_[ proc_number ].locked= true;
2209 }
2210 else if( command.id == Command::Unlock )
2211 {
2212 const unsigned short proc_number= static_cast<unsigned short>( command.args[0] );
2213 PC_ASSERT( proc_number < procedures_.size() );
2214
2215 procedures_[ proc_number ].locked= false;
2216 }
2217 else if( command.id == Command::PlayAnimation )
2218 {
2219 const unsigned int model_id = AnimationNumberToModelNumber( static_cast<unsigned int>(command.args[0]) );
2220 for( StaticModel& model : static_models_ )
2221 {
2222 if( model.model_id == model_id )
2223 {
2224 model.animation_state= StaticModel::AnimationState::Animation;
2225 model.animation_start_time= current_time;
2226 model.animation_start_frame= 0u;
2227 }
2228 }
2229 }
2230 else if( command.id == Command::StopAnimation )
2231 {
2232 const unsigned int model_id = AnimationNumberToModelNumber( static_cast<unsigned int>(command.args[0]) );
2233 for( StaticModel& model : static_models_ )
2234 {
2235 if( model.model_id == model_id )
2236 {
2237 model.animation_state= StaticModel::AnimationState::SingleFrame;
2238 }
2239 }
2240 }
2241 else if( command.id == Command::Change )
2242 {
2243 const unsigned int x= static_cast<unsigned int>( command.args[0] );
2244 const unsigned int y= static_cast<unsigned int>( command.args[1] );
2245 const unsigned int id= static_cast<unsigned int>( command.args[2] );
2246 if( x < MapData::c_map_size && y < MapData::c_map_size )
2247 {
2248 const MapData::IndexElement& index_element= map_data_->map_index[ x + y * MapData::c_map_size ];
2249 if( index_element.type == MapData::IndexElement::StaticModel )
2250 {
2251 PC_ASSERT( index_element.index < static_models_.size() );
2252
2253 StaticModel& model = static_models_[ index_element.index ];

Callers

nothing calls this directly

Calls 4

ACodeEnum · 0.85
CoordToMessageCoordFunction · 0.85

Tested by

no test coverage detected