/* * The main entry point for executing commands. * Can be recursively called from 'at', 'order', 'force'. */ void interpret( CHAR_DATA *ch, char *argument ) { /* BUG with aliases: they can call themselves, which is * a Bad Thing. When an alias calls interp, we'll add * a '~' char as the first char. Checking for this will * tell us if we need to check aliases again. -S- */ bool alias_call; char command[MAX_INPUT_LENGTH]; char logline[MAX_INPUT_LENGTH]; int cmd; int trust; bool found; alias_call = FALSE; if ( ch->position == POS_WRITING ) /* if player is writing, pass argument straight to write_interpret */ { write_interpret( ch, argument ); return; } if ( ch->position == POS_BUILDING ) { if (argument[0]==':') argument++; else { build_interpret(ch,argument); return; } } /* * Strip leading spaces. */ while ( isspace(*argument) ) argument++; if ( argument[0] == '\0' ) return; if ( argument[0] == '~' ) { argument++; alias_call = TRUE; } /* * No hiding. */ REMOVE_BIT( ch->affected_by, AFF_HIDE ); /* * Implement freeze command. */ if ( !IS_NPC(ch) && IS_SET(ch->act, PLR_FREEZE) ) { send_to_char( "@@a@@fYou're totally frozen!@@N\n\r", ch ); return; } if ( ch->stunTimer > 0 ) { send_to_char( "You are too@@aSTUNNED@@N to act!\n\r", ch ); return; } /* * Grab the command word. * Special parsing so ' can be a command, * also no spaces needed after punctuation. */ strcpy( logline, argument ); if ( !isalpha(argument[0]) && !isdigit(argument[0]) ) { command[0] = argument[0]; command[1] = '\0'; argument++; while ( isspace(*argument) ) argument++; } else { argument = one_argument( argument, command ); } /* * Look for command in command table. */ found = FALSE; trust = get_trust( ch ); for ( cmd = 0; cmd_table[cmd].name[0] != '\0'; cmd++ ) { /* Stephen Mod: if level == CLAN_ONLY then for clan member only. == BOSS_ONLY have to be leader. == -3 vamp == -4 wolf */ if ( cmd_table[cmd].level == CLAN_ONLY && !IS_NPC( ch ) && ch->pcdata->clan == 0 ) continue; if ( cmd_table[cmd].level == BOSS_ONLY && !IS_NPC( ch ) && !IS_SET( ch->pcdata->pflags, PFLAG_CLAN_BOSS ) ) continue; if ( cmd_table[cmd].level == VAMP_ONLY && !IS_NPC( ch ) && !IS_VAMP( ch ) && ( ch->level != L_GOD ) ) continue; if ( cmd_table[cmd].level == WOLF_ONLY && !IS_NPC( ch ) && !IS_WOLF( ch ) && ( ch->level != L_GOD ) ) continue; if ( command[0] == cmd_table[cmd].name[0] && !str_prefix( command, cmd_table[cmd].name ) && ( cmd_table[cmd].level <= trust || MP_Commands( ch ) ) ) { found = TRUE; break; } } /* * Log and snoop. */ if ( cmd_table[cmd].log == LOG_NEVER ) strcpy( logline, "XXXXXXXX XXXXXXXX XXXXXXXX@@N"); if ( ( !IS_NPC(ch) && IS_SET(ch->act, PLR_LOG) ) || fLogAll || cmd_table[cmd].log == LOG_ALWAYS ) { sprintf( log_buf, "Log %s: %s", ch->name, logline ); log_string( log_buf ); if ( IS_SET( ch->act, PLR_LOG ) ) monitor_chan( log_buf, MONITOR_BAD ); else if ( cmd_table[cmd].level > LEVEL_HERO ) monitor_chan( log_buf, MONITOR_GEN_IMM ); else monitor_chan( log_buf, MONITOR_GEN_MORT ); } if ( ch->desc != NULL && ch->desc->snoop_by != NULL ) /* -S- Mod */ { char snp[MAX_STRING_LENGTH]; sprintf( snp, "[Snoop:%s] %s\n\r", ch->name, logline ); write_to_buffer( ch->desc->snoop_by, snp, 0 ); } if ( !found && !IS_NPC( ch ) && (!alias_call) ) { int cnt; char foo[MAX_STRING_LENGTH]; /* Check aliases -S- */ for ( cnt = 0; cnt < MAX_ALIASES; cnt++ ) { if ( !str_cmp( ch->pcdata->alias_name[cnt], command ) && str_cmp( ch->pcdata->alias_name[cnt], "<none>@@N") ) { found = TRUE; sprintf( foo, "~%s %s", ch->pcdata->alias[cnt], argument ); interpret( ch, foo ); return; } } } if ( !found ) { /* * Look for command in socials table. */ if ( !check_social( ch, command, argument ) #ifdef IMC && !imc_command_hook( ch, command, argument ) #endif ) send_to_char( "Huh?\n\r", ch ); return; } /* * Character not in position for command? */ if ( ch->position < cmd_table[cmd].position ) { switch( ch->position ) { case POS_DEAD: send_to_char( "Lie still; you are @@dDEAD@@N.\n\r", ch ); break; case POS_MORTAL: case POS_INCAP: send_to_char( "You are @@Rhurt@@N far too bad for that.\n\r", ch ); break; case POS_STUNNED: send_to_char( "You are too @@estunned@@N to do that.\n\r", ch ); break; case POS_SLEEPING: send_to_char( "Oh, go back to @@Wsleep!@@N\n\r", ch ); break; case POS_RESTING: send_to_char( "Naaaaaah... You feel too @@brelaxed@@N...\n\r", ch); break; case POS_FIGHTING: send_to_char( "Not until you @@Rstop@@N fighting!\n\r", ch); break; } return; } /* * Dispatch the command. */ if ( !IS_NPC( ch ) && ( ( ch->stance == STANCE_AMBUSH ) || ( ch->stance == STANCE_AC_BEST ) ) && ( ( str_prefix( command, "kill" ) ) && ( str_prefix( command, "murder" ) ) && ( str_prefix( command, "backstab" ) ) && ( str_prefix( command, "bs" ) ) && ( str_prefix( command, "whisper" ) ) && ( str_prefix( command, "stake" ) ) && ( str_prefix( command, "steal" ) ) ) ) { send_to_char( "You step out of the shadows.\n\r", ch ); ch->stance = STANCE_WARRIOR; ch->stance_ac_mod = 0; ch->stance_dr_mod = 0; ch->stance_hr_mod = 0; act( "$n steps out of the Shadows!", ch, NULL, NULL, TO_ROOM ); } comlog(ch, cmd, argument); (*cmd_table[cmd].do_fun) ( ch, argument ); tail_chain( ); return; }
/* * The main entry point for executing commands. * Can be recursively called from 'at', 'order', 'force'. */ void interpret(CHAR_DATA * ch, char *argument) { char command[MAX_INPUT_LENGTH]; char logline[MAX_INPUT_LENGTH]; int cmd; int trust; bool found; /* * Strip leading spaces. */ while(isspace(*argument)) { argument++; } if(argument[0] == '\0') { return; } /* * No hiding. */ REMOVE_BIT(ch->affected_by, AFF_HIDE); /* * Implement freeze command. */ if(!IS_NPC(ch) && IS_SET(ch->act, PLR_FREEZE)) { send_to_char("You're totally frozen!\r\n", ch); return; } /* * Grab the command word. * Special parsing so ' can be a command, * also no spaces needed after punctuation. */ strcpy(logline, argument); if(!isalpha(argument[0]) && !isdigit(argument[0])) { command[0] = argument[0]; command[1] = '\0'; argument++; while(isspace(*argument)) { argument++; } } else { argument = one_argument(argument, command); } /* * Look for command in command table. */ found = FALSE; trust = get_trust(ch); for(cmd = 0; cmd_table[cmd].name[0] != '\0'; cmd++) { if(command[0] == cmd_table[cmd].name[0] && !str_prefix(command, cmd_table[cmd].name) && (cmd_table[cmd].level <= trust || MP_Commands(ch))) { found = TRUE; break; } } /* * Log and snoop. */ if(cmd_table[cmd].log == LOG_NEVER) { strcpy(logline, "XXXXXXXX XXXXXXXX XXXXXXXX"); } if((!IS_NPC(ch) && IS_SET(ch->act, PLR_LOG)) || fLogAll || cmd_table[cmd].log == LOG_ALWAYS) { sprintf(log_buf, "Log %s: %s", ch->name, logline); log_string(log_buf); } if(ch->desc != NULL && ch->desc->snoop_by != NULL) { write_to_buffer(ch->desc->snoop_by, "% ", 2); write_to_buffer(ch->desc->snoop_by, logline, 0); write_to_buffer(ch->desc->snoop_by, "\r\n", 2); } if(!found) { /* * Look for command in socials table. */ if(!check_social(ch, command, argument) #ifdef IMC && !imc_command_hook(ch, command, argument) #endif ) { send_to_char("Huh?\r\n", ch); } return; } /* * Character not in position for command? */ if(ch->position < cmd_table[cmd].position) { switch(ch->position) { case POS_DEAD: send_to_char("Lie still; you are DEAD.\r\n", ch); break; case POS_MORTAL: case POS_INCAP: send_to_char("You are hurt far too bad for that.\r\n", ch); break; case POS_STUNNED: send_to_char("You are too stunned to do that.\r\n", ch); break; case POS_SLEEPING: send_to_char("In your dreams, or what?\r\n", ch); break; case POS_RESTING: send_to_char("Nah... You feel too relaxed...\r\n", ch); break; case POS_FIGHTING: send_to_char("No way! You are still fighting!\r\n", ch); break; } return; } /* * Dispatch the command. */ (*cmd_table[cmd].do_fun)(ch, argument); tail_chain(); return; }