This is my first major piece of code (ignoring projects for any
classes) and as such is poorly written, doesn't have extremely
helpful comments, and most likely has a lot of unnecessary little
redundancies.   It also most likely has a lot of little tiny bugs.
If you find any, please email me the bug, along with whatever you
did to fix it.

Here's what you have to do to install this code.   First, in
your world directory create a guild directory and move the 
two indexes and the 30.guild into it. 

Next you have to go into spec_assign.c and remove all references
to the guild spec_proc.  There's a function in guild.c that takes
care of this.

In spec_procs.c remove everything between the end of void sort_spells(void)
and the beginning of SPECIAL(dump)

And, for those who like a little info on their guild masters.  do_show in act.wizard.c
needs to be changed to include the show_gm function.  do_show is pretty simple
so exact directions aren't given :)

Next, in shop.h there are some util's that they say could be used
by other files, (or something) move them into utils.h.  (or at the very
least END_OF :)

That was the easy part.   Now it's time to alter db.h and db.c.
in db.h add: #define GLD_PREFIX "world/guild"
             #define DB_BOOT_GLD 6

For clarity I'd put them with the other DB_BOOT and _PREFIX defines.

in db.c add: in the extern function prototypes add
  void assign_the_gms(void);
  void boot_the_guilds(FILE *gm_f, char *filename, int rec_count);

in the function boot_world add:
   after if !no_specials
    log("Loadin guild masters.");
    index_boot(DB_BOOT_GLD);

in the function boot_db:
  after log("Assigning function pointers");
   add log("  Guildmasters.");
       assign_the_gms();

In the function index_boot:
  In the first switch statement add:
    case DB_BOOT_GLD;
     prefix = GLD_PREFIX;
     break;

under if (!rec_count) {
change the if statement to
 if (mode == DB_BOOT_SHP || mode == DB_BOOT_GLD)

In the third switch statement add:
 case DB_BOOT_GLD;
  boot_the_guilds(db_file, buf2, rec_count);
  break;


Okay, adding the Oasis support is a slight bit harder :)  I'll outline
the basics, after that, I'll assume you'll know what to do :)

Add an entry into the Makefile

define a con state for gm editing, and add a statement
into nanny for gedit_parse

You need to define a substate for gedit, (like the one for redit, medit
etc.) and add an entry for gedit into the master command table

in olc.h  (big list coming)
add #define NUM_SKILLS	(however many skills you have.)

Add "stuct guild_master_data *guild;" to struct olc_data

Add "#define OLC_GUILD(d)	((d)->olc->guild)" to the
other olc_data manipulators.

Add "#define OLC_SAVE_GM	(next free numebr)" to the other
OLC_SAVE_FOO defines.

At the bottom, add in this:
/*. Submodes of GEDIT connectedness     . */
#define GEDIT_MAIN_MENU                 0
#define GEDIT_CONFIRM_SAVESTRING        1
#define GEDIT_NO_CASH                   2
#define GEDIT_NO_SKILL                  3
/*. Numerical responses . */
#define GEDIT_NUMERICAL_RESPONSE        5
#define GEDIT_CHARGE                    6
#define GEDIT_OPEN                      7
#define GEDIT_CLOSE                     8
#define GEDIT_TRAINER                   9
#define GEDIT_NO_TRAIN                  10
#define GEDIT_SELECT_SPELLS            11
#define GEDIT_SELECT_SKILLS            12

Okay, olc.c:

Add the following function prototypes:
void gedit_save_to_disk(struct descriptor_data *d);
void gedit_setup_existing(struct descriptor_data *d, int rgm_num);
void gedit_setup_new(struct descriptor_data *d);
void free_gm(struct guild_master_data *guild);
int real_gm(int vnum);

Increment the olc_scmd_info array by one, and add this entry last.
{"gm", CON_GEDIT}

inside of do_olc:

In the case where it returns if no vnum is given, add a case for
SCMD_OLC_GEDIT

In the switch that calls the saving functions, add:
    case SCMD_OLC_GEDIT:
      send_to_char("Saving all gms in zone.\r\n", ch);
      sprintf(buf, "OLC: %s saves gms for zone %d",
             GET_NAME(ch), zone_table[OLC_ZNUM(d)].number);
      mudlog(buf, CMP, LVL_BUILDER, TRUE);
      gedit_save_to_disk(d);
      break;

In the switch right before the act that sends the starting up
OLC message, add this case:
  case SCMD_OLC_GEDIT:
    real_num = real_gm(number);
    if (real_num >= 0)
      gedit_setup_existing(d, real_num);
    else
      gedit_setup_new(d);
    STATE(d) = CON_GEDIT;
    break;

Inside the save_info_msg array, add "Gms" to the entries, (don't forget
to increment it!)

Okay, inside cleanup_olc, add this block to the appropriate place:
    /*. Check for gm . */
    if (OLC_GUILD(d)) {              
     switch (cleanup_type) {
      case CLEANUP_ALL:
       free_gm(OLC_GUILD(d));
       break;
      case CLEANUP_STRUCTS:
       free(OLC_GUILD(d));
        break;
       default:
      }
    }

In zedit.c
 inside of zedit_new_zone, add this block to the appropriate
 place.

/*. Create Gld file . */
 sprintf(buf, "%s/%i.gld", GLD_PREFIX, vzone_num);
 if (!(fp = fopen(buf, "w"))) {
   mudlog("SYSERR: OLC: Can't write new GM file", BRF, LVL_IMPL, TRUE);
   return;
 }
 fprintf(fp, "$~\n");
 fclose(fp);

 In the same function, add this with the other calls:
 zedit_create_index(vzone_num, "gld");

In zedit create index, add this in the switch:
 case 'g':
   prefix = GLD_PREFIX;
   break;

That should be it for the olc, BTW, when making a .gld for an
already created area, you'll have to add an entry into the
index file manually, (but new zones created should have
an entry created automatically)


If you should have any major problems with this code email me and I'll
see if I can help :)  If you happen across a bug in it, it really just
a feature (okay, its really just a bug, but email it to me if you could.)
It isn't neccassary to credit me for this code, but appreciated.
 
Jason Goodwin
jgoodwin@expert.cc.purdue.edu

