From e71d997c8208f0b0e874324b5baccc4d61664ad2 Mon Sep 17 00:00:00 2001 From: mfranz Date: Mon, 22 Jan 2007 00:10:39 +0000 Subject: [PATCH] Maik JUSTUS: connect fix --- src/FDM/YASim/Hitch.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/FDM/YASim/Hitch.cpp b/src/FDM/YASim/Hitch.cpp index 0b21d1889..3d4a2facf 100755 --- a/src/FDM/YASim/Hitch.cpp +++ b/src/FDM/YASim/Hitch.cpp @@ -60,7 +60,6 @@ Hitch::Hitch(const char *name) _mp_open_last_state=false; _timeLagCorrectedDist=0; - //tie the properties _node->tie("tow/length",SGRawValuePointer(&_towLength)); _node->tie("tow/elastic-constant",SGRawValuePointer(&_towElasticConstant)); _node->tie("tow/weight-per-m-kg-m",SGRawValuePointer(&_towWeightPerM)); @@ -288,14 +287,19 @@ void Hitch::findBestAIObject(bool doit,bool running_as_autoconnect) static bool lastState=false; if(!_state) return; - if (!doit) + if (!running_as_autoconnect) { - lastState=false; - return; + //if this function is binded to an input, it will be called every frame as long as the key is pressed. + //therefore wait for a key-release before running it again. + if (!doit) + { + lastState=false; + return; + } + if(lastState) + return; + lastState=true; } - if(lastState) - return; - lastState=true; double gpos[3]; _state->posLocalToGlobal(_pos,gpos); double bestdist=_towLength*_towLength;//squared!