From: Paul E. <pa...@up...> - 2008-05-19 11:50:15
|
Hi Coz, On Mon, 2008-05-19 at 02:15 -0400, Eduardo Alberto Hernández Muñoz wrote: > Hi, > > > static bool updated = false; > > - if( updated == true ) race_manager->startNew(); > > + if( updated == true ) > > + { > > + race_manager->startNew(); > > + updated = false; > > + } > > else updated = true; > > } > > > > which I think works. The 'Loading Race..' gui now appears each time a > > race or challenge is started. Should I commit this, or have I missed > > something? > > Well, there's a problem. I tested it, and it did worked quite well. > Every single time, I tried, out of about 20, it worked. > > However, I don't know why this works. If you place a std::cerr within > the if( updated == true ) brackets, but before the > race_manager->startNew(), you'll notice that there is no difference > before and after adding updated = false; in both cases it is only > printed once, and the variable is only used in that part of the code. Isn't it correct that the std::cerr is printed only once? The if(updated == true) is only entered once per race, no matter what. Without adding updated = false, subsequent calls (when starting a second, third race etc..) of StartRaceFeedback::update() will always have updated == true and so will call race_manager->startNew immediately, rather than on the next game loop. This is wrong because startNew eventually leads to the RaceGUI being pushed on to the stack, replacing the feedbackGUI. So when the screen is redrawn at the end of the game loop, StartRaceFeedback is no longer the current menu and so is not drawn. Cheers, Paul |