16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-19 13:29:18 +02:00

Merge branch 'tmj-dev' into milek-dev

This commit is contained in:
milek7
2018-09-20 22:00:02 +02:00
39 changed files with 2997 additions and 2171 deletions

View File

@@ -25,25 +25,25 @@ TMemCell::TMemCell( scene::node_data const &Nodedata ) : basic_node( Nodedata )
void TMemCell::UpdateValues( std::string const &szNewText, double const fNewValue1, double const fNewValue2, int const CheckMask )
{
if (CheckMask & update_memadd)
if (CheckMask & basic_event::flags::mode_add)
{ // dodawanie wartości
if( TestFlag( CheckMask, update_memstring ) )
if( TestFlag( CheckMask, basic_event::flags::text ) )
szText += szNewText;
if (TestFlag(CheckMask, update_memval1))
if (TestFlag(CheckMask, basic_event::flags::value_1))
fValue1 += fNewValue1;
if (TestFlag(CheckMask, update_memval2))
if (TestFlag(CheckMask, basic_event::flags::value_2))
fValue2 += fNewValue2;
}
else
{
if( TestFlag( CheckMask, update_memstring ) )
if( TestFlag( CheckMask, basic_event::flags::text ) )
szText = szNewText;
if (TestFlag(CheckMask, update_memval1))
if (TestFlag(CheckMask, basic_event::flags::value_1))
fValue1 = fNewValue1;
if (TestFlag(CheckMask, update_memval2))
if (TestFlag(CheckMask, basic_event::flags::value_2))
fValue2 = fNewValue2;
}
if (TestFlag(CheckMask, update_memstring))
if (TestFlag(CheckMask, basic_event::flags::text))
CommandCheck(); // jeśli zmieniony tekst, próbujemy rozpoznać komendę
}
@@ -110,15 +110,15 @@ bool TMemCell::Load(cParser *parser)
return true;
}
void TMemCell::PutCommand( TController *Mech, glm::dvec3 const *Loc )
void TMemCell::PutCommand( TController *Mech, glm::dvec3 const *Loc ) const
{ // wysłanie zawartości komórki do AI
if (Mech)
Mech->PutCommand(szText, fValue1, fValue2, Loc);
}
bool TMemCell::Compare( std::string const &szTestText, double const fTestValue1, double const fTestValue2, int const CheckMask ) {
bool TMemCell::Compare( std::string const &szTestText, double const fTestValue1, double const fTestValue2, int const CheckMask ) const {
// porównanie zawartości komórki pamięci z podanymi wartościami
if( TestFlag( CheckMask, conditional_memstring ) ) {
if( TestFlag( CheckMask, basic_event::flags::text ) ) {
// porównać teksty
auto range = szTestText.find( '*' );
if( range != std::string::npos ) {
@@ -135,8 +135,8 @@ bool TMemCell::Compare( std::string const &szTestText, double const fTestValue1,
}
}
// tekst zgodny, porównać resztę
return ( ( !TestFlag( CheckMask, conditional_memval1 ) || ( fValue1 == fTestValue1 ) )
&& ( !TestFlag( CheckMask, conditional_memval2 ) || ( fValue2 == fTestValue2 ) ) );
return ( ( !TestFlag( CheckMask, basic_event::flags::value_1 ) || ( fValue1 == fTestValue1 ) )
&& ( !TestFlag( CheckMask, basic_event::flags::value_2 ) || ( fValue2 == fTestValue2 ) ) );
};
bool TMemCell::IsVelocity() const
@@ -159,7 +159,7 @@ void TMemCell::StopCommandSent()
}
};
void TMemCell::AssignEvents(TEvent *e)
void TMemCell::AssignEvents(basic_event *e)
{ // powiązanie eventu
OnSent = e;
};
@@ -192,7 +192,7 @@ TMemCell::export_as_text_( std::ostream &Output ) const {
<< fValue1 << ' '
<< fValue2 << ' '
// associated track
<< ( asTrackName.empty() ? "none" : asTrackName ) << ' '
<< ( Track ? Track->name() : asTrackName.empty() ? "none" : asTrackName ) << ' '
// footer
<< "endmemcell"
<< "\n";
@@ -208,6 +208,13 @@ memory_table::InitCells() {
for( auto *cell : m_items ) {
// Ra: eventy komórek pamięci, wykonywane po wysłaniu komendy do zatrzymanego pojazdu
cell->AssignEvents( simulation::Events.FindEvent( cell->name() + ":sent" ) );
// bind specified path with the memory cell
if( false == cell->asTrackName.empty() ) {
cell->Track = simulation::Paths.find( cell->asTrackName );
if( cell->Track == nullptr ) {
ErrorLog( "Bad memcell: track \"" + cell->asTrackName + "\" referenced in memcell \"" + cell->name() + "\" doesn't exist" );
}
}
}
}