dirs.c

MudOSa4DGD/mudlib/dgd/sfun/dirs.c · 1.6 KB

From the archive MudOSa4DGD-30.06.98.tar.gz

Download the archive   « Back to the archive contents

/*
 * dirs.c
 *
 * SFUN: Direction functions
 * Supported directions: north, northeast, east, southeast, south,
 * 			 southwest, west, northwest, up, down
 *
 * (C) Frank Schmidt, Jesus@NorseMUD
 *
 */


/* get direction opposite of <dir> */
static string get_opposite_dir(string dir) {
  switch (dir) {
  case "north":     return "south";
  case "south":     return "north";
  case "west":      return "east";
  case "east":      return "west";
  case "down":      return "up";
  case "up":        return "down";
  case "northeast": return "southwest";
  case "northwest": return "southeast";
  case "southeast": return "northwest";
  case "southwest": return "northeast";
  }
  /* couldn't find direction */
  return 0;
}


/* get direction command abbreviation (for exits) */
static string get_dir_abbrev(string dir) {
  switch (dir) {
  case "north":  return "n";
  case "south":  return "s";
  case "west":  return "w";
  case "east":  return "e";
  case "down":  return "d";
  case "up":  return "u";
  case "northeast": return "ne";
  case "northwest": return "nw";
  case "southeast": return "se";
  case "southwest": return "sw";
  }
  /* couldn't find abbreviation, return 0 */
  return 0;
}


/* get direction expansion from abbreviation */
static string get_dir_expansion(string dir) {
  switch (dir) {
  case "n":  return "north";
  case "s":  return "south";
  case "w":  return "west";
  case "e":  return "east";
  case "d":  return "down";
  case "u":  return "up";
  case "ne": return "northeast";
  case "nw": return "northwest";
  case "se": return "southeast";
  case "sw": return "southwest";
  }
  /* couldn't find expansion, return 0 */
  return 0;
}

Site Stats

Snippets: 1791
Codebases: 571