allegro issues

This is a discussion on allegro issues within the C++ Programming forums, part of the General Programming Boards category; First off I wasn't sure if I should put this in game programming but i did put it in my ...

  1. #1
    Or working on it anyways mramazing's Avatar
    Join Date
    Dec 2005
    Location
    Lehi, UT
    Posts
    121

    allegro issues

    First off I wasn't sure if I should put this in game programming but i did put it in my last thread "linux problems". None the less here it is:

    I was coding the rest of "parser" for the program i was working on above and I get this error

    Terminate called after throwing instance of 'std::ios_base::failure'
    what(): basic_ios::clear
    Shutting down allegro due to signal #6

    I am using fedora 10 using code::blocks and the latest allegro (linker `allegro-config --libs`)

    if you think the file being used will help I can post it.

    Here is the code:
    Code:
    #include <allegro.h>
    #include "standard_tcg.h"
    #include "card.h"
    #include "buttons.h"
    #include <iostream>
    #include <cstdlib>
    #include <fstream>
    #include <cstring>
    using namespace std;
    
    Card::Card(char id[7])
    {
        Name[0] = '\0';
    
        char set[4];
        char card[5];
        char fname[255];
    
        // parse the id into a set and card number
        for(int i = 0; i < 3; i++)
        {
            set[i] = id[i];
        }
        set[3] = '\0';
    
        for(int i = 0; i < 4; i++)
        {
            card[i] = id[i+3];
        }
        card[4] = '\0';
    
        strcpy(fname, "card_data//set");
        strcat(fname, set);
        strcat(fname, ".tcg");
        strcpy(filename, fname);
    
        ifstream IFP (fname);
    
        if(IFP == NULL)
            allegro_message("could not open: %s", fname);
    
        char comp_card[5];
        char send_buffer[512];
        char check;
        int  Icheck;
    
        int index = 0;
    
        while(!IFP.eof())
        {
            if(check == '[')
            {
                //get the id
                for(int i = 0; i < 4; i++)
                {
                    IFP >> check;
                    comp_card[i] = check;
                }
                comp_card[4] = '\0';
    
                if(strcmp(card, comp_card) != 0)
                    allegro_message("comp_card: %s\nCard   : %s", comp_card, card);
    
                if(strcmp(card, comp_card) == 0)
                {
                    IFP >> noskipws >> check;
                    // get card name
                    while(check != '#')
                    {
                        IFP >> check;
                        send_buffer[index] = check;
                        index++;
                    }
                    send_buffer[index-1] = '\0';
                    strcpy(Name, send_buffer);
                    index = 0;
    
                    // get HP
                    while(check != '>')
                        IFP >> check;
    
                    IFP >> Icheck;
                    health = Icheck;
    
                    // get type 1
                    while(check != '>')
                        IFP >> check;
    
                    IFP >> Icheck;
                    type1 = Icheck;
    
                    // get type 2
                    while(check != '>')
                        IFP >> check;
    
                    IFP >> Icheck;
                    type2 = Icheck;
    
                    // Get ability type 1
                    while(check != '>')
                        IFP >> check;
    
                    IFP >> Icheck;
                    ab_type_1 = Icheck;
    
                    // get ability type 2
                    while(check != '>')
                        IFP >> check;
    
                    IFP >> Icheck;
                    ab_type_2 = Icheck;
    
                    // get ability cost 1
                    while(check != '>')
                        IFP >> check;
    
                    IFP >> Icheck;
                    ab_cost_1 = Icheck;
    
                    // get ability cost 2
                    while(check != '>')
                        IFP >> check;
    
                    IFP >> Icheck;
                    ab_cost_2 = Icheck;
    
                    // get ability dmg 1
                    while(check != '>')
                        IFP >> check;
    
                    IFP >> Icheck;
                    ab_dmg_1 = Icheck;
    
                    // get ability dmg 2
                    while(check != '>')
                        IFP >> check;
    
                    IFP >> Icheck;
                    ab_dmg_2 = Icheck;
    
                    // get ability desc 1;
                    IFP >> check; // because it will be # right now
                    while(check != '#')
                    {
                        IFP >> check;
                        send_buffer[index] = check;
                        index++;
                    }
                    send_buffer[index-1] = '\0';
                    strcpy(ability_1, send_buffer);
                    index = 0;
    
                    // get ability desc 2
                    while(check != '#')
                    {
                        IFP >> check;
                        send_buffer[index] = check;
                        index++;
                    }
                    send_buffer[index-1] = '\0';
                    strcpy(ability_2, send_buffer);
                    index = 0;
    
                    // get retreat type 1
                    while(check != '>')
                        IFP >> check;
    
                    IFP >> Icheck;
                    rt_cost_type_1 = Icheck;
    
                    // get retreat type 2
                    while(check != '>')
                        IFP >> check;
    
                    IFP >> Icheck;
                    rt_cost_type_2 = Icheck;
    
                    // get retreat cost 1
                    while(check != '>')
                        IFP >> check;
    
                    IFP >> Icheck;
                    rt_cost_1 = Icheck;
    
                    // get retreat cost 2
                    while(check != '>')
                        IFP >> check;
    
                    IFP >> Icheck;
                    rt_cost_2 = Icheck;
    
                    // get weakness
                    while(check != '>')
                        IFP >> check;
    
                    IFP >> Icheck;
                    weakness = Icheck;
    
                    // get resistance
                    while(check != '>')
                        IFP >> check;
    
                    IFP >> Icheck;
                    resistance = Icheck;
    
                    // get resistance strength
                    while(check != '>')
                        IFP >> check;
    
                    IFP >> Icheck;
                    strength_res = Icheck;
    
                    // get evolve
                    while(check != '>')
                        IFP >> check;
    
                    IFP >> Icheck;
                    evolve = Icheck;
    
                    // move the iterator over one
                    IFP >> check;
    
                    // get evolve name
                    if(evolve == 1)
                    {
                        while(check != '#')
                        {
                            IFP >> check;
                            send_buffer[index] = check;
                            index++;
                        }
                        send_buffer[index-1] = '\0';
                        strcpy(ev_name, send_buffer);
                    }
                    else
                        ev_name[0] = '\0';
                }
            }
            IFP >> check;
        }
        IFP.close();
    }
    
    int Card::Print_Card(BITMAP *bmp, int x, int y)
    {
        if(Name[0] != '\0')
        {
            textprintf_ex(bmp, font, x, y+10, WHITE, -1,"%s", Name);
            textprintf_ex(bmp, font, x, y+20, WHITE, -1,"%d", health);
            textprintf_ex(bmp, font, x, y+30, WHITE, -1,"%d", type1);
            textprintf_ex(bmp, font, x, y+40, WHITE, -1,"%d", type2);
            textprintf_ex(bmp, font, x, y+50, WHITE, -1,"%d", ab_type_1);
            textprintf_ex(bmp, font, x, y+60, WHITE, -1,"%d", ab_type_2);
            textprintf_ex(bmp, font, x, y+70, WHITE, -1,"%d", ab_cost_1);
            textprintf_ex(bmp, font, x, y+80, WHITE, -1,"%d", ab_cost_2);
            textprintf_ex(bmp, font, x, y+90, WHITE, -1,"%d", ab_dmg_1);
            textprintf_ex(bmp, font, x, y+100, WHITE, -1,"%d", ab_dmg_2);
            textprintf_ex(bmp, font, x, y+110, WHITE, -1,"%s", ability_1);
            textprintf_ex(bmp, font, x, y+120, WHITE, -1,"%s", ability_2);
            textprintf_ex(bmp, font, x, y+130, WHITE, -1,"%s", filename);
        }
        else
            textprintf_ex(bmp, font, x, y+10, WHITE, -1, "No info was read");
        return 0;
    }
    -- Will you show me how to c++?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,765
    What makes you think that what you've posted has anything to do with the problem?

    Run the code in the debugger, and get a stack trace.
    Then relevant snippets of code along the stack.

    Ideally, a small and COMPLETE program which demonstrates the problem.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Allegro in C for a newb
    By Ideius in forum C Programming
    Replies: 5
    Last Post: 12-29-2005, 04:36 PM
  2. Allegro, OpenGL.. or even DirectX?
    By Zeusbwr in forum C++ Programming
    Replies: 1
    Last Post: 11-14-2004, 08:16 AM
  3. Game Programming FAQ
    By TechWins in forum Game Programming
    Replies: 5
    Last Post: 09-29-2004, 03:00 AM
  4. double buffering for allegro
    By Leeman_s in forum C++ Programming
    Replies: 6
    Last Post: 09-12-2002, 03:45 PM
  5. Special Allegro Information
    By TechWins in forum Game Programming
    Replies: 12
    Last Post: 08-21-2002, 12:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21