/* ***********************************************************************
*  file:  makerooms.c                                                    *
*  Usage: making xnumber of rooms in a row.                              *
*  Written by Arthur Sheffield -do not need any credit- I just love      *
*                               circle code. :)                          *
**************************************************************************/
/*
  This is a simple little file that you use to make more then one room
in a row.  You put this file in you util dir and do a make makrooms,
its that simple.  However, sence you may have dif room layouts and flags 
it would be a good idea to edit part of this file.  In my mud there is
two rows of room flags, example: after the room desciption my files go:
zone_number flags # # # or as in this file %d 1048576 1 0 1
and then the next line goes 0 0 0 0 0 
which is just extra stuff I have added, you will need to edit those two
lines to match your room layouts.
To use this file after you have finished editing it,
just type;
makerooms <file_name> <zone#> <starting_room#> <ending_room#> <dir>
thats it... it will then make a file of what you called it and make all
the rooms in order and connected from the start to the end! 
Im not very good a making help files, can you tell by that last few lines!
If you make this file better please email me at:
risemud@kilnar.com
and tell me so I can update my file. :)
The web site for my mud is www.kilnar.com/~risemud
feel free to drop by and take a look, Still have lots of work to do.
but love to talk about coding. Maybe will see you on the mud, Im the 
creator Sheri, hope to see you there. :)
Also, you may have to edit the first line, to show where your sysdep.h 
file is kept.
NOTE: this file does not put the $ at the end of the file, because
I use it to make the rooms then add them to the .wld file im using.
Last by not least, feel free to delete all this help stuff. 
*/

#include "../src/sysdep.h"

#include <signal.h>

void write_roomlist(FILE * out, int zone, int start, int end, char *dir)
{
  int i, j, first, last;

  first = start;
  last = end;

 for (i = start, j = end; i <= j; i++)
 {
  fprintf(out, "#%d\n", i);
  fprintf(out, "New Room~\n");
  fprintf(out, "   This is a new room.\n");
  fprintf(out, "~\n");
  fprintf(out, "%d 1048576 1 0 1\n", zone);
  fprintf(out, "0 0 0 0 0\n");

  switch (*dir)
   {
    case 'n':
    case 'N':
    if (last != i) {
     fprintf(out, "D0\n");
     fprintf(out, "~\n");
     fprintf(out, "~\n");
     fprintf(out, "0 0 %d\n", i+1);
    }
    if (first != i) {
     fprintf(out, "D2\n");
     fprintf(out, "~\n");
     fprintf(out, "~\n");
     fprintf(out, "0 0 %d\n", i-1);
    }
     fprintf(out, "S\n");
     break;
    case 'e':
    case 'E':
    if (last != i) {
     fprintf(out, "D1\n");
     fprintf(out, "~\n");
     fprintf(out, "~\n");
     fprintf(out, "0 0 %d\n", i+1);
    }
    if (first != i) {
     fprintf(out, "D3\n");
     fprintf(out, "~\n");
     fprintf(out, "~\n");
     fprintf(out, "0 0 %d\n", i-1);
    }
     fprintf(out, "S\n");
     break;
    case 's':
    case 'S':
    if (first != i) {
     fprintf(out, "D0\n");
     fprintf(out, "~\n");
     fprintf(out, "~\n");
     fprintf(out, "0 0 %d\n", i-1);
    }
    if (last != i) {
     fprintf(out, "D2\n");
     fprintf(out, "~\n");
     fprintf(out, "~\n");
     fprintf(out, "0 0 %d\n", i+1);
    }
     fprintf(out, "S\n");
     break;
    case 'w':
    case 'W':
    if (first != i) {
     fprintf(out, "D1\n");
     fprintf(out, "~\n");
     fprintf(out, "~\n");
     fprintf(out, "0 0 %d\n", i-1);
    }
    if (last != i) {
     fprintf(out, "D3\n");
     fprintf(out, "~\n");
     fprintf(out, "~\n");
     fprintf(out, "0 0 %d\n", i+1);
    }
     fprintf(out, "S\n");
     break;
    case 'u':
    case 'U':
    if (last != i) {
     fprintf(out, "D4\n");
     fprintf(out, "~\n");
     fprintf(out, "~\n");
     fprintf(out, "0 0 %d\n", i+1);
    }
    if (first != i) {
     fprintf(out, "D5\n");
     fprintf(out, "~\n");
     fprintf(out, "~\n");
     fprintf(out, "0 0 %d\n", i-1);
    }
     fprintf(out, "S\n");
     break;
    case 'd':
    case 'D':
    if (first != i) {
     fprintf(out, "D4\n");
     fprintf(out, "~\n");
     fprintf(out, "~\n");
     fprintf(out, "0 0 %d\n", i-1);
    }
    if (last != i) {
     fprintf(out, "D5\n");
     fprintf(out, "~\n");
     fprintf(out, "~\n");
     fprintf(out, "0 0 %d\n", i+1);
    }
     fprintf(out, "S\n");
     break;
   }
  }
}

int main(int argc, char **argv)
{
  int zone, start, end;
  char *dir;
  FILE *fl;

  if (argc != 6) {
    printf("Format: %s file zone start end dir\n",
	   argv[0]);
    exit(0);
  }
  zone = atoi(argv[2]);
  start = atoi(argv[3]);
  end = atoi(argv[4]);
  dir = argv[5];
  fl = fopen(argv[1], "w");
  write_roomlist(fl, zone, start, end, dir);
  fclose(fl);
  return 0;
}
