/******************************************************************************

The J.O.P.E howto

You should add the jope.c file to your Makefile and then edit the function
jope_show() so it will only use flags that you have define on your mud.
(I use a series of PLR_BRIEF1234 flags that I doubt you use).

Then you should remove the pthread_mutex_lock/unlock calls unless you use
Dystopia 1.2, since these calls are only needed for that specific code.

Now simply read the comments below, and add what it tells you to.

Recompile the entire code, and you should be set.

* How does it work ?
--------------------

Simply said, you type 'pfile <name of player>' and you'll get thrown into
a pfile-edit mode, where you can use a series of commands to alter the pfile,
and when your done, you simply type 'done'.

To get a list of valid J.O.P.E commands, you can type '?'

The jope_table[] decides what the minimum level is needed to use a
certain J.O.P.E command, and this is also where you add new commands if/when
you make them (it works like the interpret table in interp.c)

A final warning : When the pfile is loaded, the player is not put into a room,
                  so it's not wise to try and move the player in any way, so
                  don't recall, shadowstep, activate transporters, etc with
                  that char. (The level 12 command 'action' allows you to do
                  anything with the pfile loaded, including the above commands).

Enjoy the code,

Brian Graversen, aka Jobo, coder for the godwars mud Dystopia

*******************************************************************************/

/*
 * Add the following declares to merc.h
 ******************************************************************************
bool jope_load_char             args (( CHAR_DATA *ch, char *arg ));
void jope_free_char             args (( CHAR_DATA *ch ));
void jope_interp                args (( CHAR_DATA *ch, char *argument ));

extern  const   struct  jope_type       jope_table      [];

struct jope_type
{
  char * const        name;
  DO_FUN *            do_fun;
  sh_int              level;
};

struct bit_type
{ 
  char *const         name;
  int                 bit_value;
};

/*
 * The connection status while in pfile editing mode. (put it with the others)
 */
#define CON_PFILE             20

/*
 * Add the following list of DO_FUNS to merc.h (you only need to add do_pfile() to interp.c)
 */
DECLARE_DO_FUN( do_pfile        );
DECLARE_DO_FUN( jope_done       );
DECLARE_DO_FUN( jope_exp        );
DECLARE_DO_FUN( jope_show       );
DECLARE_DO_FUN( jope_list       );
DECLARE_DO_FUN( jope_spells     );
DECLARE_DO_FUN( jope_stances    );
DECLARE_DO_FUN( jope_weapons    );
DECLARE_DO_FUN( jope_action     );
DECLARE_DO_FUN( jope_inventory  );
DECLARE_DO_FUN( jope_drop       );
DECLARE_DO_FUN( jope_equipment  );
DECLARE_DO_FUN( jope_get        );
DECLARE_DO_FUN( jope_look       );
DECLARE_DO_FUN( jope_remove     );
DECLARE_DO_FUN( jope_wear       );
DECLARE_DO_FUN( jope_newbits    );
DECLARE_DO_FUN( jope_act        );
DECLARE_DO_FUN( jope_qps        );
DECLARE_DO_FUN( jope_primal     );
DECLARE_DO_FUN( jope_level      );
DECLARE_DO_FUN( jope_trust      );
DECLARE_DO_FUN( jope_hit        );
DECLARE_DO_FUN( jope_move       );
DECLARE_DO_FUN( jope_mana       );
DECLARE_DO_FUN( jope_pkill      );
DECLARE_DO_FUN( jope_pdeath     );
DECLARE_DO_FUN( jope_mkill      );
DECLARE_DO_FUN( jope_mdeath     );


in the pc_data structure add :
  CHAR_DATA *         pfile;

*******************************************************************************/

/*
 * changes to comm.c
 *****************************************************************************

Add this to the switch() in game_loop_unix()

                   case CON_PFILE:
                        jope_interp( d->character, d->incomm );
                        break;

Change this in process_output() to get the prompt for pfile edit mode as well.

from :  if ( fPrompt && !merc_down && d->connected == CON_PLAYING)
to:     if ( fPrompt && !merc_down && (d->connected == CON_PLAYING
                                    || d->connected == CON_PFILE))

Put this somewhere smart in close_socket() and close_socket2()

    if (dclose->connected == CON_PFILE) jope_done(dclose->character, "");

*******************************************************************************/