ILAB OLC Beta 1.1
Jason Dinkel
May. 15 1995
COMM.C
This file contains modifications needed to stock Envy 1.0 comm.c.
Only the lines commented with /* OLC */ need to be added. The surrounding
code is for getting ones bearings.
This file contains modifications needed to comm.c.
---- FUNCTION: game_loop_mac_msdos
DESC: We must assign the three new entries in the descriptor structure
before the structure is saved in a new variable.
dcon.pEdit = NULL; /* OLC */
dcon.pString = NULL; /* OLC */
dcon.editor = 0; /* OLC */
dcon.next = descriptor_list;
descriptor_list = &dcon;
DESC: In the process input loop we must check for what editor a player
is using. This code does that. Make sure you get all of the
parentheses pasted over the olc section.
read_from_buffer( d );
if ( d->incomm[0] != '\0' )
{
d->fcommand = TRUE;
stop_idling( d->character );
/* OLC */
if ( d->showstr_point )
show_string( d, d->incomm );
else
if ( d->pString )
string_add( d->character, d->incomm );
else
if ( d->connected == CON_PLAYING )
{
if ( !run_olc_editor( d ) )
interpret( d->character, d->incomm );
}
else
nanny( d, d->incomm );
d->incomm[0] = '\0';
}
---- FUNCTION: game_loop_unix
DESC: Same as above, but for the unix game loop.
read_from_buffer( d );
if ( d->incomm[0] != '\0' )
{
d->fcommand = TRUE;
stop_idling( d->character );
/* OLC */
if ( d->showstr_point )
show_string( d, d->incomm );
else
if ( d->pString )
string_add( d->character, d->incomm );
else
if ( d->connected == CON_PLAYING )
{
if ( !run_olc_editor( d ) )
interpret( d->character, d->incomm );
}
else
nanny( d, d->incomm );
d->incomm[0] = '\0';
}
---- FUNCTION: new_descriptor
DESC: Same as for mac_dos but for unix we use a different function to
assign the new descriptor structure values.
dnew->pEdit = NULL; /* OLC */
dnew->pString = NULL; /* OLC */
dnew->editor = 0; /* OLC */
dnew->outsize = 2000;
dnew->outbuf = alloc_mem( dnew->outsize );
---- FUNCTION: process_output
DESC: This ensures that a player gets the correct prompt based on the
editor they are using.
/*
* Bust a prompt.
*/
if ( fPrompt && !merc_down && d->connected == CON_PLAYING ) /* OLC */
if ( d->showstr_point )
write_to_buffer( d,
"[Please type (c)ontinue, (r)efresh, (b)ack, (h)elp, (q)uit, or RETURN]: ",
0 );
else
if ( d->pString )
write_to_buffer( d, "> ", 2 );
else
{
CHAR_DATA *ch;
---- FUNCTION: bust_a_prompt
DESC: These are just nice additions to the prompt so that a builder can
keep track of what editor they are using and what vnum they are
editing. You may want to add them to your help files.
case 'c' : /* OLC */
i = olc_ed_name( ch );
break;
case 'C' : /* OLC */
i = olc_ed_vnum( ch );
break;
---- FUNCTION: check_parse_name
DESC: Walker found that a player can log in as "none" and change areas.
This needs to be changed so that this cannot occur.
if ( is_name( name, "all auto immortal self someone none" ) )
return FALSE;
---- It will probably be necessary to use Zavod's pager fix.
I'll include it here for your convenience. This is the
version that Mike Nikkel revised and fixed the help messages.
---- FUNCTION: write_to_buffer
DESC: This function needs one change at the end for the pager to work.
replace this:
strcpy( d->outbuf + d->outtop, txt );
with this:
strncpy( d->outbuf + d->outtop, txt, length ); /* OLC */
---- FUNCTION: show_string
DESC: This function replaced the current show_string.
/* OLC, new pager for editing long descriptions. */
/* ========================================================================= */
/* - The heart of the pager. Thanks to N'Atas-Ha, ThePrincedom for porting */
/* this SillyMud code for MERC 2.0 and laying down the groundwork. */
/* - Thanks to Blackstar, hopper.cs.uiowa.edu 4000 for which the improvements*/
/* to the pager was modeled from. - Kahn */
/* - Safer, allows very large pagelen now, and allows to page while switched */
/* Zavod of jcowan.reslife.okstate.edu 4000. */
/* ========================================================================= */
void show_string( DESCRIPTOR_DATA *d, char *input )
{
char *start, *end;
char arg[MAX_INPUT_LENGTH];
int lines = 0, pagelen;
/* Set the page length */
/* ------------------- */
pagelen = d->original ? d->original->pcdata->pagelen
: d->character->pcdata->pagelen;
/* Check for the command entered */
/* ----------------------------- */
one_argument( input, arg );
switch( UPPER( *arg ) )
{
/* Show the next page */
case '\0':
case 'C': lines = 0;
break;
/* Scroll back a page */
case 'B': lines = -2 * pagelen;
break;
/* Help for show page */
case 'H': write_to_buffer( d, "B - Scroll back one page.\n\r", 0 );
write_to_buffer( d, "C - Continue scrolling.\n\r", 0 );
write_to_buffer( d, "H - This help menu.\n\r", 0 );
write_to_buffer( d, "R - Refresh the current page.\n\r",
0 );
write_to_buffer( d, "Enter - Continue Scrolling.\n\r", 0 );
return;
/* refresh the current page */
case 'R': lines = -1 - pagelen;
break;
/* stop viewing */
default: free_string( d->showstr_head );
d->showstr_head = NULL;
d->showstr_point = NULL;
return;
}
/* do any backing up necessary to find the starting point */
/* ------------------------------------------------------ */
if ( lines < 0 )
{
for( start= d->showstr_point; start > d->showstr_head && lines < 0;
start-- )
if ( *start == '\r' )
lines++;
}
else
start = d->showstr_point;
/* Find the ending point based on the page length */
/* ---------------------------------------------- */
lines = 0;
for ( end= start; *end && lines < pagelen; end++ )
if ( *end == '\r' )
lines++;
d->showstr_point = end;
if ( end - start )
write_to_buffer( d, start, end - start );
/* See if this is the end (or near the end) of the string */
/* ------------------------------------------------------ */
for ( ; isspace( *end ); end++ );
if ( !*end )
{
free_string( d->showstr_head );
d->showstr_head = NULL;
d->showstr_point = NULL;
}
return;
}
END OF FILE COMM.C