?? wsckcomm.c
字號:
#ifdef RACES
strcpy( buf, "Select a race [" );
for ( iRace = 0; iRace < MAX_RACE; iRace++ )
{
if ( iRace > 0 )
strcat( buf, " " );
strcat( buf, race_table[iRace].who_name );
}
strcat( buf, "]: " );
write_to_buffer( d, buf, 0 );
d->connected = CON_GET_NEW_RACE;
break;
case CON_GET_NEW_RACE:
for ( iRace = 0; iRace < MAX_RACE; iRace++ )
{
if ( !str_cmp( argument, race_table[iRace].who_name ) )
{
ch->race = iRace;
break;
}
}
if ( iRace == MAX_RACE )
{
write_to_buffer( d,
"That's not a race.\n\rWhat IS your race? ", 0 );
return;
}
#endif
strcpy( buf, "Select a class [" );
for ( iClass = 0; iClass < MAX_CLASS; iClass++ )
{
if ( iClass > 0 )
strcat( buf, " " );
strcat( buf, class_table[iClass].who_name );
}
strcat( buf, "]: " );
write_to_buffer( d, buf, 0 );
d->connected = CON_GET_NEW_CLASS;
break;
case CON_GET_NEW_CLASS:
for ( iClass = 0; iClass < MAX_CLASS; iClass++ )
{
if ( !str_cmp( argument, class_table[iClass].who_name ) )
{
ch->class = iClass;
break;
}
}
if ( iClass == MAX_CLASS )
{
write_to_buffer( d,
"That's not a class.\n\rWhat IS your class? ", 0 );
return;
}
sprintf( log_buf, "%s@%s new player.", ch->name, d->host );
log_string( log_buf );
write_to_buffer( d, "\n\r", 2 );
ch->pcdata->pagelen = 20;
ch->prompt = "<%hhp %mm %vmv> ";
do_help( ch, "motd" );
d->connected = CON_READ_MOTD;
break;
case CON_READ_MOTD:
ch->next = char_list;
char_list = ch;
d->connected = CON_PLAYING;
send_to_char(
"\n\rWelcome to Merc Diku Mud. May your visit here be ... Mercenary.\n\r",
ch );
if ( ch->level == 0 )
{
OBJ_DATA *obj;
switch ( class_table[ch->class].attr_prime )
{
case APPLY_STR: ch->pcdata->perm_str = 16; break;
case APPLY_INT: ch->pcdata->perm_int = 16; break;
case APPLY_WIS: ch->pcdata->perm_wis = 16; break;
case APPLY_DEX: ch->pcdata->perm_dex = 16; break;
case APPLY_CON: ch->pcdata->perm_con = 16; break;
}
#ifdef RACES
ch->pcdata->perm_str += race_table[ch->race].mod_str;
ch->pcdata->perm_int += race_table[ch->race].mod_int;
ch->pcdata->perm_wis += race_table[ch->race].mod_wis;
ch->pcdata->perm_dex += race_table[ch->race].mod_dex;
ch->pcdata->perm_con += race_table[ch->race].mod_con;
#endif
ch->level = 1;
ch->exp = 1000;
ch->hit = ch->max_hit;
ch->mana = ch->max_mana;
ch->move = ch->max_move;
#ifdef RACES
ch->affected_by = race_table[ch->race].bitvector;
#else
ch->affected_by = 0;
#endif
sprintf( buf, "the %s",
title_table [ch->class] [ch->level]
[ch->sex == SEX_FEMALE ? 1 : 0] );
set_title( ch, buf );
obj = create_object( get_obj_index(OBJ_VNUM_SCHOOL_BANNER), 0 );
obj_to_char( obj, ch );
equip_char( ch, obj, WEAR_LIGHT );
obj = create_object( get_obj_index(OBJ_VNUM_SCHOOL_VEST), 0 );
obj_to_char( obj, ch );
equip_char( ch, obj, WEAR_BODY );
obj = create_object( get_obj_index(OBJ_VNUM_SCHOOL_SHIELD), 0 );
obj_to_char( obj, ch );
equip_char( ch, obj, WEAR_SHIELD );
obj = create_object( get_obj_index(class_table[ch->class].weapon),
0 );
obj_to_char( obj, ch );
equip_char( ch, obj, WEAR_WIELD );
char_to_room( ch, get_room_index( ROOM_VNUM_SCHOOL ) );
}
else if ( ch->in_room != NULL )
{
char_to_room( ch, ch->in_room );
}
else if ( IS_IMMORTAL(ch) )
{
char_to_room( ch, get_room_index( ROOM_VNUM_CHAT ) );
}
else
{
#ifdef RACES
char_to_room( ch, get_room_index( race_table[ch->race].city_temple ) );
#else
char_to_room( ch, get_room_index( ROOM_VNUM_TEMPLE ) );
#endif
}
act( "$n has entered the game.", ch, NULL, NULL, TO_ROOM );
do_look( ch, "auto" );
/* check for new notes */
notes = 0;
for ( pnote = note_list; pnote != NULL; pnote = pnote->next )
if ( is_note_to( ch, pnote ) && str_cmp( ch->name, pnote->sender )
&& pnote->date_stamp > ch->last_note )
notes++;
if ( notes == 1 )
send_to_char( "\n\rYou have one new note waiting.\n\r", ch );
else
if ( notes > 1 )
{
sprintf( buf, "\n\rYou have %d new notes waiting.\n\r",
notes );
send_to_char( buf, ch );
}
break;
}
return;
}
/*
* Parse a name for acceptability.
*/
bool check_parse_name( char *name )
{
/*
* Reserved words.
*/
if ( is_name( name, "all auto immortal self someone" ) )
return FALSE;
/*
* Length restrictions.
*/
if ( strlen(name) < 3 )
return FALSE;
#if defined(MSDOS)
if ( strlen(name) > 8 )
return FALSE;
#endif
#if defined(macintosh) || defined(unix)
if ( strlen(name) > 12 )
return FALSE;
#endif
/*
* Alphanumerics only.
* Lock out IllIll twits.
*/
{
char *pc;
bool fIll;
fIll = TRUE;
for ( pc = name; *pc != '\0'; pc++ )
{
if ( !isalpha(*pc) )
return FALSE;
if ( LOWER(*pc) != 'i' && LOWER(*pc) != 'l' )
fIll = FALSE;
}
if ( fIll )
return FALSE;
}
/*
* Prevent players from naming themselves after mobs.
*/
{
extern MOB_INDEX_DATA *mob_index_hash[MAX_KEY_HASH];
MOB_INDEX_DATA *pMobIndex;
int iHash;
for ( iHash = 0; iHash < MAX_KEY_HASH; iHash++ )
{
for ( pMobIndex = mob_index_hash[iHash];
pMobIndex != NULL;
pMobIndex = pMobIndex->next )
{
if ( is_name( name, pMobIndex->player_name ) )
return FALSE;
}
}
}
return TRUE;
}
/*
* Look for link-dead player to reconnect.
*/
bool check_reconnect( DESCRIPTOR_DATA *d, char *name, bool fConn )
{
CHAR_DATA *ch;
OBJ_DATA *obj;
for ( ch = char_list; ch != NULL; ch = ch->next )
{
if ( !IS_NPC(ch)
&& ( !fConn || ch->desc == NULL )
&& !str_cmp( d->character->name, ch->name ) )
{
if ( fConn == FALSE )
{
free_string( d->character->pcdata->pwd );
d->character->pcdata->pwd = str_dup( ch->pcdata->pwd );
}
else
{
free_char( d->character );
d->character = ch;
ch->desc = d;
ch->timer = 0;
send_to_char( "Reconnecting.\n\r", ch );
act( "$n has reconnected.", ch, NULL, NULL, TO_ROOM );
sprintf( log_buf, "%s@%s reconnected.", ch->name, d->host );
log_string( log_buf );
d->connected = CON_PLAYING;
/*
* Contributed by Gene Choi
*/
if ( ( obj = get_eq_char( ch, WEAR_LIGHT ) ) != NULL
&& obj->item_type == ITEM_LIGHT
&& obj->value[2] != 0
&& ch->in_room != NULL )
++ch->in_room->light;
}
return TRUE;
}
}
return FALSE;
}
/*
* Check if already playing.
*/
bool check_playing( DESCRIPTOR_DATA *d, char *name )
{
DESCRIPTOR_DATA *dold;
for ( dold = descriptor_list; dold; dold = dold->next )
{
if ( dold != d
&& dold->character != NULL
&& dold->connected != CON_GET_NAME
&& dold->connected != CON_GET_OLD_PASSWORD
&& !str_cmp( name, dold->original
? dold->original->name : dold->character->name ) )
{
write_to_buffer( d, "Already playing.\n\rName: ", 0 );
d->connected = CON_GET_NAME;
if ( d->character != NULL )
{
free_char( d->character );
d->character = NULL;
}
return TRUE;
}
}
return FALSE;
}
void stop_idling( CHAR_DATA *ch )
{
if ( ch == NULL
|| ch->desc == NULL
|| ch->desc->connected != CON_PLAYING
|| ch->was_in_room == NULL
|| ch->in_room != get_room_index( ROOM_VNUM_LIMBO ) )
return;
ch->timer = 0;
char_from_room( ch );
char_to_room( ch, ch->was_in_room );
ch->was_in_room = NULL;
act( "$n has returned from the void.", ch, NULL, NULL, TO_ROOM );
return;
}
/*
* Low level output function.
*/
bool process_output( DESCRIPTOR_DATA *d, bool fPrompt )
{
extern bool merc_down;
/*
* Bust a prompt.
*/
if ( fPrompt && !merc_down && d->connected == CON_PLAYING )
if ( d->showstr_point )
write_to_buffer( d,
"[Please type (c)ontinue, (r)efresh, (b)ack, (h)elp, (q)uit, or RETURN]: ",
0 );
else
{
CHAR_DATA *ch;
ch = d->original ? d->original : d->character;
if ( IS_SET(ch->act, PLR_BLANK) )
write_to_buffer( d, "\n\r", 2 );
if ( IS_SET(ch->act, PLR_PROMPT) )
// bust_a_prompt( ch );
bust_a_prompt( d );
if ( IS_SET(ch->act, PLR_TELNET_GA) )
write_to_buffer( d, go_ahead_str, 0 );
}
/*
* Short-circuit if nothing to write.
*/
if ( d->outtop == 0 )
return TRUE;
/*
* Snoop-o-rama.
*/
if ( d->snoop_by != NULL )
{
write_to_buffer( d->snoop_by, "% ", 2 );
write_to_buffer( d->snoop_by, d->outbuf, d->outtop );
}
#if 0
/*
* OS-dependent output.
*/
if ( !write_to_descriptor( d->descriptor, d->outbuf, d->outtop ) )
{
d->outtop = 0;
return FALSE;
}
else
{
d->outtop = 0;
return TRUE;
}
#endif
// Wake up Winsock, if necessary
if (!BlastedTrumpet(d->descriptor))
{
if ( d->character != NULL )
save_char_obj( d->character );
d->outtop = 0;
close_socket( d );
return FALSE;
}
return TRUE;
}
/*
* Bust a prompt (player settable prompt)
* coded by Morgenes for Aldara Mud
*/
//void bust_a_prompt( CHAR_DATA *ch )
void bust_a_prompt( DESCRIPTOR_DATA *d )
{
char buf[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
const char *str;
const char *i;
char *point;
CHAR_DATA *ch;
CHAR_DATA *victim;
ch = d->character;
if( ch->prompt == NULL || ch->prompt[0] == '\0' )
{
send_to_char( "\n\r\n\r", ch );
return;
}
point = buf;
// str = ch->prompt;
str = d->original != NULL ? d->original->prompt : /* VERY VERY NEW */
d->character->prompt;
while( *str != '\0' )
{
if( *str != '%' )
{
*point++ = *str++;
continue;
}
++str;
switch( *str )
{
default :
i = " "; break;
case 'h' :
sprintf( buf2, "%d", ch->hit );
i = buf2; break;
case 'H' :
sprintf( buf2, "%d", ch->max_hit );
i = buf2; break;
case 'm' :
sprintf( buf2, "%d", ch->mana );
i = buf2; break;
case 'M' :
sprintf( buf2, "%d", ch->max_mana );
i = buf2; break;
case 'v' :
sprintf( buf2, "%d", ch->move );
i = buf2; break;
case 'V' :
sprintf( buf2, "%d", ch->max_move );
i = buf2; break;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -