for (const char *ptr = 0; *ptr != '\0'; ptr++)
That totally was not gonna crash. At least I caught it before I was done writing the line =P
for (const char *ptr = 0; *ptr != '\0'; ptr++)
That totally was not gonna crash. At least I caught it before I was done writing the line =P
Loading save game progress from one game to another, Mass Effect style:
My save system saves the dialogue and quests into the file SaveSlot.sav and loads both structs, by calling the save and load functions respectively.
I naively thought that just using the existing load function was enough. My characters didn't speak most of the time and when they did, they were saying the same things from the first game. I tried changing their IDs, but no dice.
Out of desperation, I made a new loading function which its only difference was that it only loaded the quest data and not the dialogue. It finally worked - the characters were saying their lines from the second game.
Moral of the story is that the best solution is often the simplest.
Just when I think I've written all the dumbest bugs possible, and I'll never top myself, along comes Friday.
void some_func() {
GLuint loc = glGetUniformLocation( program, "mvp" );
SDL_assert( loc != -1 );
// more code here...
}
Either it returns an unsigned int, or it doesn't. Hm....
I have the feeling that one needs more context to understand.
But yes, don't underestimate how far you can go screwing up in dumb ways.
Posted Today, 06:54 AM
I have the feeling that one needs more context to understand.
Oh right, for some reason I thought that was GLint =S (that said, I think OpenGL returns 0 on error when it'd return an identifier, if anybody wonders)
Oh right, for some reason I thought that was GLint =S (that said, I think OpenGL returns 0 on error when it'd return an identifier, if anybody wonders)
Not in this case, glGetUniformLocation returns -1 if the uniform is not available.
But you probably shouldn't assert on that, as it might just have been optimized away...
...next time I'll just look up the reference to make sure. (I guess there was a reason why I thought it said GLint at a glance)
Also:
// Play echoes
uint16_t faint = depth * (settings.audiovideo ? 0x30 : 0x40);
while (vol > faint) {
play_sfx_ex(id, x, y, vol - faint, delay, flags);
delay += 3300;
}
Although I will say: I'm surprised that often just resulted in a temporary hang and not the instantaneous lock up you'd expect from an infinite loop. Wondering if the compiler optimized it in some weird way?
But you probably shouldn't assert on that, as it might just have been optimized away...
When I'm testing algorithms, this is exactly the thing I don't want (because I've screwed up the shader)
Just when I think I've written all the dumbest bugs possible, and I'll never top myself, along comes Friday.
void some_func() { GLuint loc = glGetUniformLocation( program, "mvp" ); SDL_assert( loc != -1 ); // more code here... }
Either it returns an unsigned int, or it doesn't. Hm....
Ah, more context. So I accidentally wrote
// in shader
mat4 mvp;
void main() {
// shader code
}
But what I really wanted was:
// in shader
uniform mat4 mvp;
void main() {
// shader code
}
By leaving off the "uniform" it was never getting set, which I would have caught if the return value was -1, which it never was, because unsigned int. I hate programming some times...