C++ Help!!!

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.

Well… I’m pretty sure you’d have more luck here. They’ve got a forum and an irc channel and everything.

Thanks, nonoda.

The problem, though isn’t in one of the existing functions. It also seems to be more of a strange wrinkle in C++ rather than a problem with the game itself. That’s why I was looking for an answer elsewhere - I’ve managed to produce some odd behavior in C++ rather than in the game and I’m looking for someone to talk to about it rather than the game.

Ah. Well, I’m rather a light user of C++… if you’re willing to wait a while, posting a base case on comp.lang.c++ would be what I would try. Perhaps some sort of directory service might help too. If the code is short enough, many people right here can help.

Try here:

Ask in the general programming section.