Mail Archives: djgpp/1997/12/08/21:37:59
This is a multi-part message in MIME format.
------=_NextPart_000_01BD051D.239E2880
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Hi, I have attached two small files with this message that show my error.
I'm sure the error is self evident but I have to go to work soon and really
need this code to work! So, in an attempt to fix it, I'm asking for your
help.
When i compile this program with the line:
gxx test.cc -o test.exe
I get no errors.
When I run the program I get the following:
SEGSEGV under dos box in win95 (error occurs at the line: map[y][x].height
= seaLevel according to Rhide) in the function clear_map
Under Rhide I get the same thing
As this program is a cut down version of my actual game. I'll say that my
actual game gives the same result as above. Also, every now and again, the
program runs through and everything is ok.
Please help - without this I have no game!
Jamie Love
now on the web at http://www.geocities.com/SiliconValley/Horizon/4532
e-mail me at jamie DOT love AT clear DOT net DOT nz
------=_NextPart_000_01BD051D.239E2880
Content-Type: application/octet-stream; name="Game.h"
Content-Transfer-Encoding: quoted-printable
Content-Description: Game.h (H File)
Content-Disposition: attachment; filename="Game.h"
/************************************************************************=
******************
* |--\ |-\ |-- | |\ /| |--- ----- | | | / |--- |-\ =
|--- *
* | | | | | | | | \/ | | | | | | | / | | | | =
*
* | | | / |-- | | | | --- | | | | | /\ |-- | / =
--- *
* | | |\ | | - | | | | | | - | | |/ \ | |\ =
| *
* |--/ | \ |__ | | | | ___| | | | |___ | \ |___ | \ =
___| *
* =
*
* Written by =
Jamie Love 1997 -1998 *
* =
*
* game.h - data for the game =
*
=
*************************************************************************=
*****************/
#ifndef GAME_HEADER
#define GAME_HEADER
//the map data for every map square
struct mapStruct
{
int height; //height of the map =
piece
int colorIndex; //index into a =
colorArray for color and
//texture
};
//the parameters for a map
struct mapParams
{
int size; //size of the map
int lowestHeight;
int heighestHeight;
int seaLevel;
int landLevel; //landLevel - seaLevel =
=3D beach
int hillLevel;
int mountainLevel;
};
//array of different colors and textures - holds all textures and =
colors for all the
//different possible map squares
struct colorArray
{
int colors[100];
BITMAP *textures[100]; //allegro.h must be =
included beforehand
};
#endif
------=_NextPart_000_01BD051D.239E2880
Content-Type: application/octet-stream; name="Test.cc"
Content-Transfer-Encoding: quoted-printable
Content-Description: Test.cc (CC File)
Content-Disposition: attachment; filename="Test.cc"
#include <allegro.h>
#include <iostream.h>
#include "game.h" //for the structures
//internal functions
int setup_params(mapParams *params);
int clear_map(mapStruct **map, int size, int seaLevel);
char *generate_map(mapStruct **map, mapParams *params);
//structure to tie all map data together
//global map also defined here
struct MAP_STRUCT
{
mapStruct **map;
mapParams params;
colorArray colors;
} MAP;
int main(void)
{
//setup defaults
setup_params(&MAP.params);
//allocate memory for map
MAP.map =3D (mapStruct **) new =
mapStruct[MAP.params.size][MAP.params.size];
if(MAP.map =3D=3D NULL)
return 0;
//generate a map
if( generate_map( MAP.map, &MAP.params) =3D=3D NULL)
;
//free map memory
delete[] MAP.map;
return 1;
}
char *generate_map(mapStruct **map, mapParams *params)
{
//clear the map to sea level first
clear_map(map, params->size, params->seaLevel);
return NULL;
}
//clear the map to sea level first
int clear_map(mapStruct **map, int size, int seaLevel)
{
int x, y;
for(y =3D 0; y < size; y++)
for(x =3D 0; x < size; x++)
{
MAP.map[y][x].height =3D seaLevel;
cout << "done x =3D " << x << " y =3D " << y << endl;
}
return 1;
}
int setup_params(mapParams *params)
{
params->size =3D 100;
params->lowestHeight =3D -5;
params->heighestHeight =3D 15;
params->seaLevel =3D 0;
params->landLevel =3D 1;
params->hillLevel =3D 7;
params->mountainLevel =3D 13;
return 1;
}
------=_NextPart_000_01BD051D.239E2880--
- Raw text -