Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Crashing allegro40.dll

This thread is locked; no one can reply to it. rss feed Print
Crashing allegro40.dll
MageMog
Member #2,668
August 2002
avatar

okay... so I'm not sure that's the name of
the dll file that's crashing, but it's the
one that looks like it that you need
to run allegro w/ mingw.

I only seem to have problems w/ my RPG
project which I am moving over from
Djgpp to Mingw.

I made a seperate program and it can
plot stuff to the screen and play sounds and
-seemingly- everything that my other
program did w/o crashing the allegro40.dll
file. It even doesn't properly close down
all of the declared bitmaps and samples
w/o crashing.

can sombody help?

I doubt anyone will look at this, but here it
is anyhow

The game files:
geocities.com/magemog/resurrection.zip
The source code:
geocities.com/magemog/ressource.zip

pls pls pls... I can't move on with my project
without help...

--BTW...
I get the feeling that I'm not much help to
the community b/c I only ask questions and
don't have the knowledge to answer most
of the posts, and suggestions here either?

----------------------------------
Um... sounds vaguely familiar...

Evert
Member #794
November 2000
avatar

Before taking a look at your source code, can I run it without any extra datafiles?

Some other things you can do yourself: try static linking and try linking against the debug version of the library to narrow down the problem. IMHO, the problem is unlikely to lie with Allegro itself, unless you use an unstable version (which I assume you're not, since all 4.0.x versions are stable releases).

Plucky
Member #1,346
May 2001
avatar

The following is going to be critical. I'll try not to be harsh, but if you have a thin skin, then don't read my comments.

I looked at your source and almost regretted it. It is very, very difficult to debug because of two very bad practices:

1) Using #include to insert code snippets. You should read up somewhere as to how to handle large projects (basically programming style). Generally programs are split up in a manageable manner with functions and multiple files filled with functions. Instead you have multiple files of code snippets that are inserted with #include. Split out code and especially reusable code into functions. Group similar functions into files. Etc. Code doesn't have to be all in one file. #include was designed for header files, which shouldn't have any code within them .

2) You don't indent. To make matters worse, you have many nested if's and do-while's. This makes following your code next to impossible.

As for the bugs, it's not the Allegro library; they're all caused by your code. The following bugs prevent the program from being compiling/linking with MingW or cause crashes as you described (I may have forgotten some):

  • allegro_init() should be called before install_sound()

  • Check the docs for Windows equivalent sound and MIDI cards. They aren't the same for DOS.

  • Don't redeclare 'font'. allegro.h already declares it as extern. By declaring 'FONT *font;', the compiler will ignore the default one in allegro. And since you didn't load a font into 'font'...

  • Don't use abort(). This purposefully causes an error.

  • random() is not portable. use rand() and srand().

Some warnings that could cause major problems:

  • When you define and initialize map[], it still needs the 'int' type definition.

Some things you should/shouldn't be doing:

  • In your situation, you shouldn't be explicitly calling allegro_exit() nor exit(). First, exit() will call allegro_exit() on its own, and second, there shouldn't be a need to call exit() in the first place if you organize your program properly (in this case.)

  • Destroying all bitmaps at the end of the program, not just a few of them. Or you'll get memory leaks.

  • You're reloading the intro menu bitmap over and over without destroying the previous ones. More memory leaks. Better is to load it once, and then reuse it. Basically your do-while loops need to be reorganized.

  • As I just said, reorganize your do-while loops.

  • [edit] There's a bug with how you handle the escape key. When the player presses escape during the game, the game could restart multiple times before the player even lets go of the key! Similarly, the game would exit to the menu screen, and in the fraction of time, the game could quit because the player has yet to release the escape key. One solution is to store the state of the key so the action only occurs on key release. ie If KEY_ESC is no longer true, and the previous state of the key is 'pressed', then you can act on the key. [/edit]

Unfortunately there are more problems. I strongly recommend reading up on programming style and practice. Read other people's code, like those in Allegro source and projects found on this site. Most of the bugs and programming problems here are as a result of bad style and practice.

On a positive note, your demo looks pretty good.

Blade Nick
Member #1,597
October 2001
avatar

Yeah that's right I always get a similar error too. But I figured it out just recently the, the order does matter! So make sure to go through the way you initalize everything and also try to indent things a little more. As non indneted code with billions of nesteded if's and for's does get really hard to read and mannage if you can't tell what is what and where is where. Also commenting is really usefull do it lots and lots more as it will help you to understand and every one else to aswell.

Bad Website Of Mine
We, will survive.

MageMog
Member #2,668
August 2002
avatar

Thanks plucky, that was very thorough responce : )

SWWEEEEEEEEEEEEEEEEEETT
sweet sweet sweet sweet sweet sweet sweet
my game works now HAHAHAHAHAHAHA!!!!

ya ya ya!!!

thanks...

don't worry about my retarded programming
style, I'm taking formal classes now and
my code looks much nicer : )
;D;D;D;D;D;D

----------------------------------
Um... sounds vaguely familiar...

Go to: