Re: [CODE] [QUESTION] Virtual Map

From: Daniel Koepke (dkoepke@CALIFORNIA.COM)
Date: 05/20/98


On Wed, 20 May 1998, Christoffer Lundberg wrote:

->act.informative.c:872: storage size of `vmap1' isn't constant
->act.informative.c:889: array subscript is not an integer
->act.informative.c:900: warning: too few arguments for format

->  extern int vmap1[(int)GET_Y(ch)][(int)GET_X(ch)];

This is wrong.  You want, "extern int vmap1[28][45];"

->  extern char symbol[];
->  extern char field_desc;
->  extern char forest_desc;
->  extern char hill_desc;
->  extern char mountain_desc;
->  extern char water_desc;
->  extern char flight_desc;
->  extern char desert_desc;
->  extern char road_desc;
->  extern char city_desc;
->  extern char village_desc;

Unless you want one (and only one) character for the _desc, you
probably want these to be char * pointers.

->  sprintf(buf, "&c%s&n\r\n\r\n", vmap_terrain_name[vmap1]);

I doubt this is correct -- vmap1 is a two-dimensional int array (int
**), and hence can't be used like this for an index.

->  sprintf(buf, "%s%s%s%s%s%s\r\n", buf, symbol[vmap1[(int)y+2][(int)x-2]],
->symbol[vmap1[(int)y+2][(int)x-1]],

You don't need all of these '(int)' casts everywhere.  y and x are
already integers -- there's no need to cast an integer to an integer.
Also, symbol[] isn't right either.  It's only a char array, so
"symbol[x];" is only a character, not a string (%c rather than %s).

->  sprintf(buf, "%s%s%s%s%s%s%s\r\n", buf,
->symbol[vmap1[(int)y-2][(int)x-2]], symbol[vmap1[(int)y-2][(int)x-1]],
->          symbol[vmap1[(int)y-2][(int)x]],
->symbol[vmap1[(int)y-2][(int)x+1]], symbol[vmap1[(int)y-2][(int)x+2]]);

I suspect this is about line 900.  Note your format calls for seven
string variables.  Ignoring the fact that symbol[] is a character, not
a string (as I said above), you only have six arguments here.  I think
the extra format code is a typo.

->  if (vmap1[y][x] == 0)
->    sprintf(buf, "%s%s\r\n", buf, field_desc);

Oh, dear God...

  const char * map_descs[] = {
    "This is a description for a field, put your stuff here.\r\n",
    "This is a description for something else, put your stuff\r\n"
    "here and note that multiple lines is just fine.\r\n",
    .
    .
    .
  };

And, then, instead of the messy 'if ()' block (and even the
sprintf()),

  strcat(buf, map_descs[vmap1[y][x]]);

->See anything errant in there?

Ohhh... just a _few_ things...

-dak : I'm being critical today.


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST