Hey everyone.
I am trying to set up a grid-based world system in a text-based game (MUD). The whole world would consist out of several locations, each location stored in it's own file.
What I want to have is that every location consist out of sector's using a 2 dimensional array, but the whole world consist of the collection of locations. Certain sector's in a location may be of different type and/or not accessable by players. I was able to create a single location so far without any problems, but as soon as I try to make a collection of locations, although it compiled fine, the game crashed when loading.
What I used was:
This worked fine when I used sector[x][y].sector_type, etc. but that would only allow me to create one location. So after that I decided to use a different way:Code:typedef struct sector_data SECTOR_DATA; #define MAX_X_GRID 100 #define MAX_Y_GRID 100 struct sector_data { char *description; int sector_type; } sector[MAX_X_GRID - 1][MAX_X_GRID - 1];
Using this method compiled fine but everytime the game loaded the world it crashed. Is normally used world[x].description or world[i].sector[x][y].sector_type.Code:typedef struct sector_data SECTOR_DATA; typedef struct world_data WORLD_DATA; #define MAX_X_GRID 100 #define MAX_Y_GRID 100 #define MAX_LOCATIONS 10 struct sector_data { int sector_type; }; struct world_data { char *description; /* rather than having each sector use it */ SECTOR_DATA *sector[MAX_X_GRID - 1][MAX_Y_GRID - 1]; } world[MAX_LOCATIONS - 1];
I am currently unsure what I have done wrong, yet even if there would be a better way. Any suggestions or help would be much appreciated.
Thank you.



LinkBack URL
About LinkBacks


