C++ project issues

kyzen

Golden Member
Oct 4, 2005
1,557
0
0
www.chrispiekarz.com
I'm working on a game for my final project in my entry level c++ class. I've run into two issues that are totally kicking my ass at the moment:

1 - I can debug my program from within Visual Studio 2008 just fine. I hit F5, the program compiles, it runs, and everything works perfectly. However, when I try to run the program from the exe in the debug folder of my project, it fires up, lets me scroll around the main menu, but as soon as I try to start a new game, it locks up.

2 - I figured maybe it had something to do with the way the debug executable was built, so instead I tried building a release version... and I get an error saying the entry point is undefined. I can switch back to a debug build and it works.

I'm totally lost here at this point. Any help with either of the above issues would be spectacular. My (sloppy) code can be found at http://www.chrispiekarz.com/files/csc160project.zip if anybody wants to poke around it. Note that it is a little under 10 megs at this point, but it includes all my image files, the compiled debug version (that crashes), the SDL libraries that I'm using, and my Visual Studio 2008 solution files.

Though the 2 issues listed above are my primary concern, I'm definitely interested in hearing any other feedback about the project - it's lightyears from being perfect, but it's my first large-scale application in C++, my first time doing any sort of graphics work, and my first attempt at any sort of game, so I know there's a lot for me to learn from it.


Edit: Oh and forgive the crappy art, I'm working on replacing some crap I produced in MS Paint with some free tile/sprite sets I've found online :)
 

chronodekar

Senior member
Nov 2, 2008
721
1
0
kyzen! Good to see your project progressing.

I've not unzipped your project yet, (downloading.. saving ... etc). But I had a similar issue with one of my projects like this too.

The debug would work, but for some mysterious reason, the release wouldn't. I don't exactly remember how I solved it, but I do remember that the solution lay somewhere in the project properties window.

It was a big project having at least 3 sub-projects and what was happening was that in the release configuration one of the projects was not getting built. It was a matter of checking the corresponding box.

Another similar issue a friend of mine had was that he made a dll. The debug worked fine, but for some reason the default release setting was trying to create a .exe ! We had to change that back to dll (in release) to get it to work.

You might want to warn those with slow net connections that your code is some <10MB in size.

 

kyzen

Golden Member
Oct 4, 2005
1,557
0
0
www.chrispiekarz.com
Fixed #2 - missed a project setting.

Still puzzled by #1 - both my debug and release builds crash when run from the exe, but work when run from the VS9 IDE.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
I can't help directly without seeing source, however this isn't an unusual thing. What's happening is that most likely you are stomping a memory location that you aren't allowed to write. In the debugger the executable code is not loaded into the same place in memory as when it is loaded by running it from the command line. As such it often happens that an error that doesn't cause a visible issue running from the debugger will cause a crash when run from the command line. Look for a bad pointer, overwriting the stack, that kind of thing.
 

kyzen

Golden Member
Oct 4, 2005
1,557
0
0
www.chrispiekarz.com
Well now it's time for my foot-in-mouth moment: I forgot to copy a couple of resource files (namely my map definitions files - I had the images :p) over to my debug/release folders.

Go me!
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Glad you found it. However, those should have failed gracefully. You'll save yourself a lot of time if you write the error handling at initial implementation. Instrumentation is your friend as well. Sorry for the minilecture ;).
 

kyzen

Golden Member
Oct 4, 2005
1,557
0
0
www.chrispiekarz.com
Yeah, error handling is just one more thing I'd like to get done... the project is due Friday, so I'm in a rush to make it semi-playable by then. I'll probably add some code to check that the file is open before I try reading from it, but I don't know if I'll have the time to do much more than gracefully fail the program at that point.

To be honest, at this point I'm dissatisfied with the entire architecture of the project, and if I decide to truly complete the game on my own time after the class, I'll probably be scrapping everything that's done and starting over.


 

chronodekar

Senior member
Nov 2, 2008
721
1
0
I've been in similar situations. If you don't have time to implement error-handling everywhere, at LEAST do so where it is necessary.

I'm assuming that for your project demonstration you'll be running some kind of fixed demo. In such a case, for the first 5 - 10mins of your demo, try to ensure that error-handling is implemented for all the functions that you call. (You can't be calling ALL of them yet, correct?)

I'm sure you want to avoid a Bill Gates moment, right? (Win98 crashed in his face during one of the first public demonstrations)

Good to hear that you fixed up those issues.


Speaking of which, did you know that in Visual Studio you can run pre-build scripts? I've got a project, where before compiling, I copy some folders to my debug directory. If you use those scripts, you won't have to worry about such issues.
 

kyzen

Golden Member
Oct 4, 2005
1,557
0
0
www.chrispiekarz.com
The scripts would be handy, I'll need to look those up.

And actually, yeah, every function I've written so far I use :)

I'm taking a pretty ugly approach to the project at this point, and coding functionality as I need it... it's resulted in some really messy code organization, and some backtracking to eliminate redundancies or fix bugs I find/create. With the project due in 2 days I'm just in a rush to get it done.

Though I'm personally not pleased with how the code looks now, I doubt it will effect my grade, as this is really a very low level class, and as far as I know, everybody else is doing a console based application. I'm hoping the teacher can excuse some of my gaffes given the scope of the project, and the fact that we'll have had about 21 days total to work on it (assuming people worked over thanksgiving break).