more than 8 multiple events

This commit is contained in:
milek7
2018-02-15 18:41:41 +01:00
parent 303a1d8fb4
commit 910b0b1dd6
2 changed files with 22 additions and 24 deletions

View File

@@ -548,18 +548,12 @@ void TEvent::Load(cParser *parser, Math3D::vector3 const &org)
if( token != "else" ) {
if( token.substr( 0, 5 ) != "none_" ) {
// eventy rozpoczynające się od "none_" są ignorowane
if( paramidx < 8 ) {
Params[ paramidx ].asText = new char[ token.size() + 1 ];
strcpy( Params[ paramidx ].asText, token.c_str() );
if( ti ) {
// oflagowanie dla eventów "else"
iFlags |= conditional_else << paramidx;
}
++paramidx;
}
else {
ErrorLog( "Bad event: multi-event \"" + asName + "\" with more than 8 events; discarding link to event \"" + token + "\"" );
}
ext_params.push_back(std::make_pair(TParam(), 0));
ext_params[ paramidx ].first.asText = new char[ token.size() + 1 ];
strcpy( ext_params[ paramidx ].first.asText, token.c_str() );
// oflagowanie dla eventów "else"
ext_params[paramidx].second = (int)ti;
++paramidx;
}
else {
WriteLog( "Multi-event \"" + asName + "\" ignored link to event \"" + token + "\"" );
@@ -1123,12 +1117,12 @@ event_manager::CheckQuery() {
|| ( m_workevent->iFlags & conditional_anyelse ) ) {
// warunek spelniony albo było użyte else
WriteLog("Type: Multi-event");
for (i = 0; i < 8; ++i) {
for (i = 0; i < m_workevent->ext_params.size(); ++i) {
// dodawane do kolejki w kolejności zapisania
if( m_workevent->Params[ i ].asEvent ) {
if( bCondition != ( ( ( m_workevent->iFlags & ( conditional_else << i ) ) != 0 ) ) ) {
if( m_workevent->Params[ i ].asEvent != m_workevent )
AddToQuery( m_workevent->Params[ i ].asEvent, m_workevent->Activator ); // normalnie dodać
if( m_workevent->ext_params[ i ].first.asEvent ) {
if( bCondition != (bool)m_workevent->ext_params[i].second ) {
if( m_workevent->ext_params[ i ].first.asEvent != m_workevent )
AddToQuery( m_workevent->ext_params[ i ].first.asEvent, m_workevent->Activator ); // normalnie dodać
else {
// jeśli ma być rekurencja to musi mieć sensowny okres powtarzania
if( m_workevent->fDelay >= 5.0 ) {
@@ -1520,12 +1514,12 @@ event_manager::InitEvents() {
event->iFlags &= ~( conditional_memstring | conditional_memval1 | conditional_memval2 );
}
}
for( int i = 0; i < 8; ++i ) {
if( event->Params[ i ].asText != nullptr ) {
cellastext = event->Params[ i ].asText;
SafeDeleteArray( event->Params[ i ].asText );
event->Params[ i ].asEvent = FindEvent( cellastext );
if( event->Params[ i ].asEvent == nullptr ) {
for( int i = 0; i < event->ext_params.size(); ++i ) {
if( event->ext_params[ i ].first.asText != nullptr ) {
cellastext = event->ext_params[ i ].first.asText;
SafeDeleteArray( event->ext_params[ i ].first.asText );
event->ext_params[ i ].first.asEvent = FindEvent( cellastext );
if( event->ext_params[ i ].first.asEvent == nullptr ) {
// Ra: tylko w logu informacja o braku
ErrorLog( "Bad event: multi-event \"" + event->asName + "\" cannot find event \"" + cellastext + "\"" );
}

View File

@@ -53,7 +53,6 @@ const int update_only = 0x00000FF; // wartość graniczna
const int conditional_memstring = 0x0000100; // porównanie tekstu
const int conditional_memval1 = 0x0000200; // porównanie pierwszej wartości liczbowej
const int conditional_memval2 = 0x0000400; // porównanie drugiej wartości
const int conditional_else = 0x0010000; // flaga odwrócenia warunku (przesuwana bitowo)
const int conditional_anyelse = 0x0FF0000; // do sprawdzania, czy są odwrócone warunki
const int conditional_trackoccupied = 0x1000000; // jeśli tor zajęty
const int conditional_trackfree = 0x2000000; // jeśli tor wolny
@@ -97,6 +96,11 @@ class TEvent // zmienne: ev*
double fDelay = 0.0;
TDynamicObject *Activator = nullptr;
TParam Params[13]; // McZapkie-070502 //Ra: zamienić to na union/struct
// this is already mess, so one more hack won't make it much worse...
// stores TParam union and magic flag (eg. else flag)
std::vector<std::pair<TParam, int>> ext_params;
unsigned int iFlags = 0; // zamiast Params[8] z flagami warunku
std::string asNodeName; // McZapkie-100302 - dodalem zeby zapamietac nazwe toru
TEvent *evJoined = nullptr; // kolejny event z tą samą nazwą - od wersji 378