Hello all,

I'm currently coding a simulation for a theoretical game called Angels and Mortals. As a simulation, it plays itself out without user input, and depending on different starting conditions, the results will be different.

So far, my backend is nearly complete, and will eventually feed into an OpenGL frontend where I'll be able to see the "game board" to see what's going on. Right now, output is to the console :P

The backend is what's causing me the problem so far. My game "pieces" are coded as class objects, and represented in a doubly-linked list. The problem is, I seem to have developed an access violation, but I have no idea why - this exact line was working previously and didn't throw up any seg faults as it does now. Essentially - I have no idea what's going wrong, and I'm pretty confused as to how to fix this.

Here's the line in question that my debugger ( CodeBlocks ) tells me is causing the problem :

Code:
angels = angels->next;
To put that into context, here's the relevant class :

Code:
class Angel
{
      private:
              int xcoord, ycoord;
      public:
             void create(int, int);
             void move();
             void setcoords(int, int);
             void editcoords(int, int);
             int readxc();
             int readyc();
             Angel *next;
             Angel *prev;
             ~Angel();
};
And the object angels is just an object of class Angel.


To aid in further contexting, here's the loop in which I supposedly get a seg fault :

Code:
         if(mortals->next != NULL) // ... check that there are actually mortals in play.
         {
                   while(angels->next != NULL)
                   {

                         angels->move();

                         if(angels->readxc() == 0) angels->editcoords(1,0); // fix coord == 0
                         if(angels->readyc() == 0) angels->editcoords(0,1); // fix coord == 0
                         if(angels->readxc() > BOARD_X) angels->editcoords(-1,0);
                         if(angels->readyc() > BOARD_Y) angels->editcoords(0,-1);


                         gotoxy(angels->readxc(), angels->readyc()); // go to new coords

                         cout << "O";

                         angels = angels->next; // next node

                    }

            }


For those who are either very brave or very kind, or have too much time on their hands, here's a pastebin of the entire application :

Main .cpp - http://pastebin.com/m58bfdeb0 - culprit on line 184
Angel.h - http://pastebin.com/m166973f4
Mortal.h - http://pastebin.com/m50f40c64
Settings.h - http://pastebin.com/m768f6067


My coding environment is Dev-CPP on Windows Vista.

Thanks for any help,
Quentin