Sign in to follow this  

[C++] suddenly shutdown on some computers

This topic is 2042 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone.
[left]At first: Please excuse my poor English skills :-(.[/left]
[left]But let me tell you about my problem:[/left]
[left]I wanted to lean how to use SDL. So, at first I read some articles and tutorials. Then I started to code a "game", less a game, more object of my personal study.[/left]
[left]I want to create a framework, which grows with my knowledge, where I can implement my ideas and learn out of it.[/left]
[left]I have chosen C++ because I already have some Skills in it and want to improve them.[/left]
[left]This is my working state:[/left]
[left]- I am using Windows 7 64bit Professional[/left]
[left]- game-state-machine with actual 2 states (menu & "game"-mode)[/left]
[left]- button, timer, tileMap, animation, player, bitmapFont & log classes[/left]
[left]- menu state shows a background, with a barely animated cloud and a button, which switches to gameState[/left]
[left]- game-mode has a tileMap based background with a level read in by a file, A test of the bitmapFont, and a moveable "hero" with a camara following him (2D if there are any uncertainties) and an exit button.[/left]
[left]All this works fine on the computer I coded it on.[/left]
[left]Now the actual problem:[/left]
[left]I placed the compiled .exe and all necessary .dll's and images in my DropBox because I wanted to test it on my notebook and I direct linked the folder with a fellow student.[/left]
[left]On the source computer it isn't possible to start the game, direct ".exe doesn't work anymore..." (- hope I translated this one right -).[/left]
[left]On my Notebook (also Windows 7 64bit Professional / no seperate SDL installation) the game starts correct and enters the main Menu, but if click on the new Game button the game closes without any error message.[/left]
[left]So I set up my log and logged every step happening (See code & log below).[/left]
[left]This way I pointed out that the program exits without a reason (visible for me) after the end of the constructor of the exit button in game state.[/left]
[left](This is the most important problem)[/left]
[left]On the computer of my friend (he actually tested with ArchLinux) it works fine in some cases or it isn't startable. (Also interesting, but it's more important for me to get a working version on my notebook, but I am interested in articles/tutorials about using SDL cross platform, because reading windows and linux tutorials and then point out the differences isn't fun, I think.)[/left]
[left][i]Edit: Talked to my friend again, he used windows, too, but I am still interested in cross platform sources.[/i][/left]

[left]I am thankful for every help and advice you can provide me. :-)[/left]

[left]If new Game button is clicked nxtState is set to STATE_HOME_FARM, changeState is called every gameloop before rendering.[/left]
[left][CODE]
void changeState()
{
if (nxtState != STATE_NO_CHANGE)
{
log->log("start change");
if (nxtState != STATE_EXIT)
{
log->log("delete act");
delete workingState;
log->log("done");
}
switch (nxtState)
{
case STATE_HOME_FARM:
log->log("detected home farm");
workingState = new HomeFarm();
log->log("createt state");
break;
}
log->log("set vars");
actState = nxtState;
nxtState = STATE_NO_CHANGE;
log->log("done");
}
}
[/CODE][/left]

[left]This is the constructor of my HomeFarm class.[/left]
[left][CODE]
actWid = LEVEL_WIDTH;
actHig = LEVEL_HEIGHT;
log->log("create hero");
hero = new Farmer;
log->log("create exit button");
exitButton = new ExitButton(SCREEN_WIDTH/2, SCREEN_HEIGHT-200 , 200, 100, "Buttons/test_button_exit.png");
log->log("create font");
[/CODE][/left]

[left]This is the constructor of my ExitButton class[/left]
[left][CODE]
log->log("set vars");
CLIP_MOUSEOVER = 0;
CLIP_MOUSEOUT = 1;
CLIP_MOUSEDOWN = 2;
CLIP_MOUSEUP = 3;
button.x = x;
button.y = y;
button.w = width;
button.h = height;
log->log("load img");
img = loadImg(filename);
log->log("set clip");
setClips();
log->log("set initial clip");
state = &clip[CLIP_MOUSEOUT];
log->log("done");
[/CODE][/left]

[left]And finally this is my log.txt created if I run the game on my notebook and try to start a Game.[/left]
[CODE]
start change
delete act
done
detected home farm
create hero
create exit button
set vars
load img
set clip
set initial clip
done
[/CODE]

[left]Nazzrim[/left] Edited by Nazzrim

Share this post


Link to post
Share on other sites
What's workingState initialized to? Make sure it's either NULL or a valid state if you're going to be deleting it on the first state change. Edited by Slavik81

Share this post


Link to post
Share on other sites
Right after start up before the gameloop starts working state is initialized to MainMenu state.
[CODE]
int main (int argc, char* args[])
{
if (init() == false)
{
log->log ("Error on initialisation...");
return 1;
}
actState = STATE_MAIN_MENU;
workingState = new MainMenu();
while (actState != STATE_EXIT)
{
[/CODE]

Share this post


Link to post
Share on other sites
[quote]
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)]So I set up my log and logged every step happening (See code & log below).[/background][/left][/size][/font][/color]
[/quote]
How does your log work? Does it flush each time it is called?

[quote]
I placed the compiled .exe and all necessary .dll's
[/quote]
How are you building the executable? In release mode? Which DLLs are you including? The "application is not working" message usually means some required DLL is not working.

Share this post


Link to post
Share on other sites
Yes it flushes every time:
[CODE]
void Log::log (std:: string message)
{
logger << message << std::endl;
logger.flush();
}
[/CODE]

I am not completely sure what the difference between release/debug mode (- maybe someone got sources :S? -).
So I use Notepad++ for coding, and mingw32 via cmd for compiling.
I have a bunch of header files for my classes and .ccp files for the actual classes.
I am compiling it using the command "g++ 'all.ccps' -lSDL -lSDLmain -lSDL_image.
This are my includes DLLs:
libgcc_s_dw2-1.dll
libstdc++-6.dll

libpng15-15.dll
SDL.dll
SDL_image.dll
zlib.dll

The first two are there, because my notebook complains if they are not *shame*
The rest are SDL and related DLLs.

I must concede that my DLL skills tend towards zero, but I really like to improve them. ;-)

Share this post


Link to post
Share on other sites

This topic is 2042 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this