mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 03:09:18 +02:00
maintenance: removed deprecated code from memcells, tracks, events
This commit is contained in:
83
MemCell.cpp
83
MemCell.cpp
@@ -28,37 +28,20 @@ http://mozilla.org/MPL/2.0/.
|
||||
TMemCell::TMemCell(vector3 *p)
|
||||
{
|
||||
fValue1 = fValue2 = 0;
|
||||
#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY
|
||||
szText = new char[256]; // musi być dla automatycznie tworzonych komórek dla odcinków izolowanych
|
||||
#endif
|
||||
vPosition =
|
||||
p ? *p : vector3(0, 0, 0); // ustawienie współrzędnych, bo do TGroundNode nie ma dostępu
|
||||
bCommand = false; // komenda wysłana
|
||||
OnSent = NULL;
|
||||
}
|
||||
#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY
|
||||
TMemCell::~TMemCell()
|
||||
{
|
||||
SafeDeleteArray(szText);
|
||||
}
|
||||
#endif
|
||||
void TMemCell::Init()
|
||||
{
|
||||
}
|
||||
#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY
|
||||
void TMemCell::UpdateValues(char const *szNewText, double const fNewValue1, double const fNewValue2, int const CheckMask)
|
||||
#else
|
||||
void TMemCell::UpdateValues( std::string const &szNewText, double const fNewValue1, double const fNewValue2, int const CheckMask )
|
||||
#endif
|
||||
{
|
||||
if (CheckMask & update_memadd)
|
||||
{ // dodawanie wartości
|
||||
if( TestFlag( CheckMask, update_memstring ) )
|
||||
#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY
|
||||
strcat( szText, szNewText );
|
||||
#else
|
||||
szText += szNewText;
|
||||
#endif
|
||||
if (TestFlag(CheckMask, update_memval1))
|
||||
fValue1 += fNewValue1;
|
||||
if (TestFlag(CheckMask, update_memval2))
|
||||
@@ -67,11 +50,7 @@ void TMemCell::UpdateValues( std::string const &szNewText, double const fNewValu
|
||||
else
|
||||
{
|
||||
if( TestFlag( CheckMask, update_memstring ) )
|
||||
#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY
|
||||
strcpy( szText, szNewText );
|
||||
#else
|
||||
szText = szNewText;
|
||||
#endif
|
||||
if (TestFlag(CheckMask, update_memval1))
|
||||
fValue1 = fNewValue1;
|
||||
if (TestFlag(CheckMask, update_memval2))
|
||||
@@ -83,56 +62,32 @@ void TMemCell::UpdateValues( std::string const &szNewText, double const fNewValu
|
||||
|
||||
TCommandType TMemCell::CommandCheck()
|
||||
{ // rozpoznanie komendy
|
||||
#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY
|
||||
if (strcmp(szText, "SetVelocity") == 0) // najpopularniejsze
|
||||
#else
|
||||
if( szText == "SetVelocity" ) // najpopularniejsze
|
||||
#endif
|
||||
{
|
||||
eCommand = cm_SetVelocity;
|
||||
bCommand = false; // ta komenda nie jest wysyłana
|
||||
}
|
||||
#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY
|
||||
else if( strcmp( szText, "ShuntVelocity" ) == 0 ) // w tarczach manewrowych
|
||||
#else
|
||||
else if( szText == "ShuntVelocity" ) // w tarczach manewrowych
|
||||
#endif
|
||||
{
|
||||
eCommand = cm_ShuntVelocity;
|
||||
bCommand = false; // ta komenda nie jest wysyłana
|
||||
}
|
||||
#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY
|
||||
else if( strcmp( szText, "Change_direction" ) == 0 ) // zdarza się
|
||||
#else
|
||||
else if( szText == "Change_direction" ) // zdarza się
|
||||
#endif
|
||||
{
|
||||
eCommand = cm_ChangeDirection;
|
||||
bCommand = true; // do wysłania
|
||||
}
|
||||
#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY
|
||||
else if( strcmp( szText, "OutsideStation" ) == 0 ) // zdarza się
|
||||
#else
|
||||
else if( szText == "OutsideStation" ) // zdarza się
|
||||
#endif
|
||||
{
|
||||
eCommand = cm_OutsideStation;
|
||||
bCommand = false; // tego nie powinno być w komórce
|
||||
}
|
||||
#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY
|
||||
else if( strncmp( szText, "PassengerStopPoint:", 19 ) == 0 ) // porównanie początków
|
||||
#else
|
||||
else if( szText.compare( 0, 19, "PassengerStopPoint:" ) == 0 ) // porównanie początków
|
||||
#endif
|
||||
{
|
||||
eCommand = cm_PassengerStopPoint;
|
||||
bCommand = false; // tego nie powinno być w komórce
|
||||
}
|
||||
#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY
|
||||
else if( strcmp( szText, "SetProximityVelocity" ) == 0 ) // nie powinno tego być
|
||||
#else
|
||||
else if( szText == "SetProximityVelocity" ) // nie powinno tego być
|
||||
#endif
|
||||
{
|
||||
eCommand = cm_SetProximityVelocity;
|
||||
bCommand = false; // ta komenda nie jest wysyłana
|
||||
@@ -149,14 +104,7 @@ bool TMemCell::Load(cParser *parser)
|
||||
{
|
||||
std::string token;
|
||||
parser->getTokens(1, false); // case sensitive
|
||||
#ifdef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY
|
||||
*parser >> token;
|
||||
SafeDeleteArray(szText);
|
||||
szText = new char[256]; // musi być bufor do łączenia tekstów
|
||||
strcpy(szText, token.c_str());
|
||||
#else
|
||||
*parser >> szText;
|
||||
#endif
|
||||
parser->getTokens( 2, false );
|
||||
*parser
|
||||
>> fValue1
|
||||
@@ -179,32 +127,6 @@ void TMemCell::PutCommand(TController *Mech, vector3 *Loc)
|
||||
Mech->PutCommand(szText, fValue1, fValue2, Loc);
|
||||
}
|
||||
|
||||
bool TMemCell::Compare(char const *szTestText, double const fTestValue1, double const fTestValue2, int const CheckMask)
|
||||
{ // porównanie zawartości komórki pamięci z podanymi wartościami
|
||||
if (TestFlag(CheckMask, conditional_memstring))
|
||||
{ // porównać teksty
|
||||
std::string
|
||||
match( szTestText );
|
||||
auto range = match.find( '*' );
|
||||
if( range != std::string::npos ) {
|
||||
// compare string parts
|
||||
if( 0 != szText.compare( 0, range, match, 0, range ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// compare full strings
|
||||
if( szText != match ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// tekst zgodny, porównać resztę
|
||||
return ((!TestFlag(CheckMask, conditional_memval1) || (fValue1 == fTestValue1)) &&
|
||||
(!TestFlag(CheckMask, conditional_memval2) || (fValue2 == fTestValue2)));
|
||||
};
|
||||
|
||||
#ifndef EU07_USE_OLD_TMEMCELL_TEXT_ARRAY
|
||||
bool TMemCell::Compare( std::string const &szTestText, double const fTestValue1, double const fTestValue2, int const CheckMask ) {
|
||||
// porównanie zawartości komórki pamięci z podanymi wartościami
|
||||
if( TestFlag( CheckMask, conditional_memstring ) ) {
|
||||
@@ -224,10 +146,9 @@ 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, conditional_memval1 ) || ( fValue1 == fTestValue1 ) )
|
||||
&& ( !TestFlag( CheckMask, conditional_memval2 ) || ( fValue2 == fTestValue2 ) ) );
|
||||
};
|
||||
#endif
|
||||
|
||||
bool TMemCell::Render()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user