Open Surge Forum

A fun 2D retro platformer inspired by Sonic games and a game creation system

You are not logged in.

Announcement

Our community has moved to Discord! https://discord.gg/w8JqM7m

#1 2009-03-03 03:19:55

Celdecea
Member
From: Southern Oregon
Registered: 2009-02-23
Posts: 147

Suggestion: avoid access vio when editing brick files (with patch)

Thanks to the excellent tutorial found here I have been working on level graphics and my first level.  When editing the brick files (themes/*.brk) I was getting an access violation.  It was because I misspelled the image file name.

Right now there doesn't seem to be a clean exit from the load_sprite() function (looking at revision 13, line 329 of src/sprite.c) for when a call to image_load() returns a null object.  I wrote a little check which may be added after the call to image_load() which prevents the subsequent code from doing their random read stuff.

The code looks like this:

    if (sheet == NULL)
    {
        logfile_message("load_sprite(): Failed to load the image file for the sprite.");
        allegro_message("An image file error occured while loading a sprite.");
        exit(2);
    }

An SVN patch file written against revision 13 is located here.

Down the road I suspect there will be something better implemented, but this could be clean enough to hold over a few revisions.

Have a nice day

Last edited by Celdecea (2009-03-03 10:46:29)

Offline

#2 2009-03-03 16:01:09

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,300
Website

Re: Suggestion: avoid access vio when editing brick files (with patch)

Thanks for both patches. smile

If the user misspells an image filepath, the program must not continue. However, a fatal error message is certainly better than a crash. smile

Offline

Board footer

Powered by FluxBB  hosted by tuxfamily.org