Jump to content

  • Log In with Google      Sign In   
  • Create Account

[C++] suddenly shutdown on some computers


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Nazzrim   Members   -  Reputation: 136

Like
0Likes
Like

Posted 09 May 2012 - 03:35 PM

Hey everyone.

At first: Please excuse my poor English skills :-(.

But let me tell you about my problem:

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.

I want to create a framework, which grows with my knowledge, where I can implement my ideas and learn out of it.

I have chosen C++ because I already have some Skills in it and want to improve them.

This is my working state:

- I am using Windows 7 64bit Professional

- game-state-machine with actual 2 states (menu & "game"-mode)

- button, timer, tileMap, animation, player, bitmapFont & log classes

- menu state shows a background, with a barely animated cloud and a button, which switches to gameState

- 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.

All this works fine on the computer I coded it on.

Now the actual problem:

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.

On the source computer it isn't possible to start the game, direct ".exe doesn't work anymore..." (- hope I translated this one right -).

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.

So I set up my log and logged every step happening (See code & log below).

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.

(This is the most important problem)

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.)

Edit: Talked to my friend again, he used windows, too, but I am still interested in cross platform sources.


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


If new Game button is clicked nxtState is set to STATE_HOME_FARM, changeState is called every gameloop before rendering.

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");
}
}


This is the constructor of my HomeFarm class.

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");


This is the constructor of my ExitButton class

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");


And finally this is my log.txt created if I run the game on my notebook and try to start a Game.

start change
delete act
done
detected home farm
create hero
create exit button
set vars
load img
set clip
set initial clip
done

Nazzrim


Edited by Nazzrim, 10 May 2012 - 02:13 AM.


Sponsor:

#2 Slavik81   Members   -  Reputation: 360

Like
0Likes
Like

Posted 10 May 2012 - 02:09 AM

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, 10 May 2012 - 02:12 AM.


#3 Nazzrim   Members   -  Reputation: 136

Like
0Likes
Like

Posted 10 May 2012 - 02:15 AM

Right after start up before the gameloop starts working state is initialized to MainMenu state.
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)
{


#4 rip-off   Moderators   -  Reputation: 8217

Like
0Likes
Like

Posted 10 May 2012 - 04:03 AM

So I set up my log and logged every step happening (See code & log below).


How does your log work? Does it flush each time it is called?

I placed the compiled .exe and all necessary .dll's

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.

#5 Nazzrim   Members   -  Reputation: 136

Like
0Likes
Like

Posted 10 May 2012 - 04:49 AM

Yes it flushes every time:
void Log::log (std:: string message)
{
logger << message << std::endl;
logger.flush();
}

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. ;-)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS