I’ve been working on a 3D game for a while now, and just ran into something that cost me a couple of hours to get working.
It is not working right, and I don’t know why it is doing what it does - it does, however, do something very much like what it should do.
What I am doing is expanding the script language in the cube game engine. The cube game engine is written in C++ and uses macros to allow the script execution loop to access C++ functions.
I’ve got a function called “starttimer” that gets called by a script command of the same name. To get the current value of the timer, I have a function named “CheckTimer” that returns the current value in seconds (integer.)
starttimer does not work - unless there is a call to puts shortly thereafter. At first it didn’t work at all, and in the course of trying to find the problem I had the script report on certain variables just after calling starttimer - and of a sudden it worked just fine. I then took out the reporting stuff and it quit again.
After much poking around, I found that the script echo command (which I used to print out some of the variables) uses puts to print the same data to standard out that get shown on screen (OpenGL screen, that is.)
It is sufficient to have a call to puts("") in the starttimer function in the C++ program - if I do that everything works just fine.
I don’t know why, and it is driving me batty. It disturbs my sense of logic to have to output nothing on standard out to get a non-related function to work.
I know that this is not really the best place for this kind of question, but maybe someone could be kind enough to point me in the direction of an active C++ message board where there might be someone more knowledgeable about.
This using g++ 3.3 under Linux if it matters.
Also, I should make clear that I am modifying someone else’s code - I did not create the cube engine, I am just using it (as allowed by its license) as the base of some things I want to do.