Curtis L. Olson writes:

 > You bastards!  Writing property names to char arrays that are too short for
 > the data you are putting in it. :-(  Fixed ...

 >     for (index = 0; index < MAX_ENGINES; index++) {
 > !     char name[32];
 >       sprintf(name, "/controls/engines/engine[%d]/throttle", index);
 >       fgTie(name, this, index,
 > --- 276,280 ----
 >   
 >     for (index = 0; index < MAX_ENGINES; index++) {
 > !     char name[MAX_NAME_LEN];
 >       sprintf(name, "/controls/engines/engine[%d]/throttle", index);
 >       fgTie(name, this, index,

etc.

Note that there is no need to code things this way.  Here's a cleaner
alternative, avoiding sprintf altogether:

   for (index = 0; index < MAX_ENGINES; index++) {

     SGPropertyNode * node =
       fgGetNode("/controls/engines/engine", index, true);

     node->tie("throttle", 
               SGRawValueMethodsIndexed(this, index,
                                        &FGControls::get_throttle, 
                                        &FGControls::set_throttle));

     node->tie("mixture", 
               SGRawValueMethodsIndexed(this, index,
                                        &FGControls::get_mixture, 
                                        &FGControls::set_mixture));

     // and so on ...
   }


All the best,


David

-- 
David Megginson, [EMAIL PROTECTED], http://www.megginson.com/

_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to