[CODE] Coordinate World Map Problems

From: Tristan Haynes (natsirt86@yahoo.com)
Date: 05/12/03

I'm creating a world map based on X Y coordinates that will allow players to move between zones and link zones without extra rooms. Its kinda like the whole Final Fantasy thing, with areas linked by the large world map. So far i've been pretty successful but now I've run into a major problem. I load the information on each coordinate from a world.map file. It then loads it into a structure, so each coordinate can store its own information, like sector, name, etc. When i autorun the game it loads up fine, but when I try to reboot it goes crazy. It starts using up a large percentage of the CPU, and I can't kill it from inside the shell. So it lags the entire server. When I comment out a certain section of the code it works perfectly and doesnt have this problem. The function is below. void load_world_map()
  int x, y, size, coord, coord_num = 0;
  FILE *mapfile;
//  int file_coord = 0, file_sector = 0;
  // determine actual coordinate numbers
  for (x = 1; x <= MAP_HEIGHT; x++) {
 for (y = 1; y <= MAP_WIDTH; y++) {
   world_map_num[x][y] = coord_num++;
  // create the coordinate data structure
  CREATE(map_proto, struct world_map, coord_num);
  size = sizeof(struct world_map) * coord_num;
  log("   %d coords, %d bytes.", coord_num, size);   // open world map file, if problem then shutdown
  if (!(mapfile = fopen("../lib/world.map", "r"))) {
   log("SYSERR: cannot open world map file");
  }/***** PROBLEM CODE HERE *****/  // load the map coord data from file to structure
  fscanf(mapfile, "%d %d\n", &file_coord, &file_sector);
  for (coord = 0; coord < coord_num; coord++) {
 map_proto[file_coord].sector_type = file_sector; if (coord > coord_num)
   break; fscanf(mapfile, "%d %d\n", &file_coord, &file_sector);
  } /***** PROBLEM CODE HERE *****/
} If anyone could help me with this it would be greatly appreciated so I can continue my work.

Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.

   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |

This archive was generated by hypermail 2b30 : 06/26/03 PDT