src/command.h File Reference

#include "copyright.h"
#include "config.h"
#include "db.h"

Include dependency graph for command.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  cmdentry
struct  addedentry

Defines

#define CMD_NO_ARG(name)   extern void name(dbref, dbref, int)
#define CMD_ONE_ARG(name)   extern void name(dbref, dbref, int, char *)
#define CMD_ONE_ARG_CMDARG(name)   extern void name(dbref, dbref, int, char *, char *[], int)
#define CMD_TWO_ARG(name)   extern void name(dbref, dbref, int, char *, char *)
#define CMD_TWO_ARG_CMDARG(name)   extern void name(dbref, dbref, int, char *, char *, char*[], int)
#define CMD_TWO_ARG_ARGV(name)   extern void name(dbref, dbref, int, char *, char *[], int)
#define CMD_TWO_ARG_ARGV_CMDARG(name)   extern void name(dbref, dbref, int, char *, char *[], int, char*[], int)
#define CS_NO_ARGS   0x0000
#define CS_ONE_ARG   0x0001
#define CS_TWO_ARG   0x0002
#define CS_NARG_MASK   0x0003
#define CS_ARGV   0x0004
#define CS_INTERP   0x0010
#define CS_NOINTERP   0x0020
#define CS_CAUSE   0x0040
#define CS_UNPARSE   0x0080
#define CS_CMDARG   0x0100
#define CS_STRIP   0x0200
#define CS_STRIP_AROUND   0x0400
#define CS_ADDED   0X0800
#define CS_NO_MACRO   0x1000
#define CS_LEADIN   0x2000
#define CA_PUBLIC   0x00000000
#define CA_GOD   0x00000001
#define CA_WIZARD   0x00000002
#define CA_BUILDER   0x00000004
#define CA_IMMORTAL   0x00000008
#define CA_ROBOT   0x00000010
#define CA_ANNOUNCE   0x00000020
#define CA_ADMIN   0x00000800
#define CA_NO_HAVEN   0x00001000
#define CA_NO_ROBOT   0x00002000
#define CA_NO_SLAVE   0x00004000
#define CA_NO_SUSPECT   0x00008000
#define CA_NO_GUEST   0x00010000
#define CA_NO_IC   0x00020000
#define CA_GBL_BUILD   0x01000000
#define CA_GBL_INTERP   0x02000000
#define CA_DISABLED   0x04000000
#define CA_NO_DECOMP   0x08000000
#define CA_LOCATION   0x10000000
#define CA_CONTENTS   0x20000000
#define CA_PLAYER   0x40000000
#define CF_DARK   0x80000000

Typedefs

typedef cmdentry CMDENT
typedef addedentry ADDENT

Functions

 CMD_TWO_ARG (do_cemit)
 CMD_TWO_ARG (do_chboot)
 CMD_TWO_ARG (do_editchannel)
 CMD_ONE_ARG (do_checkchannel)
 CMD_ONE_ARG (do_createchannel)
 CMD_ONE_ARG (do_destroychannel)
 CMD_TWO_ARG (do_edituser)
 CMD_NO_ARG (do_chanlist)
 CMD_ONE_ARG (do_chanstatus)
 CMD_TWO_ARG (do_chopen)
 CMD_ONE_ARG (do_channelwho)
 CMD_TWO_ARG (do_addcom)
 CMD_ONE_ARG (do_allcom)
 CMD_NO_ARG (do_comlist)
 CMD_TWO_ARG (do_comtitle)
 CMD_NO_ARG (do_clearcom)
 CMD_ONE_ARG (do_delcom)
 CMD_TWO_ARG (do_tapcom)
 CMD_TWO_ARG (do_mail)
 CMD_TWO_ARG (do_malias)
 CMD_ONE_ARG (do_prepend)
 CMD_ONE_ARG (do_postpend)
 CMD_TWO_ARG (do_admin)
 CMD_TWO_ARG (do_alias)
 CMD_TWO_ARG (do_attribute)
 CMD_ONE_ARG (do_boot)
 CMD_TWO_ARG (do_chown)
 CMD_TWO_ARG (do_chownall)
 CMD_TWO_ARG (do_chzone)
 CMD_TWO_ARG (do_clone)
 CMD_NO_ARG (do_comment)
 CMD_TWO_ARG_ARGV (do_cpattr)
 CMD_TWO_ARG (do_create)
 CMD_ONE_ARG (do_cut)
 CMD_NO_ARG (do_dbck)
 CMD_TWO_ARG (do_decomp)
 CMD_ONE_ARG (do_destroy)
 CMD_TWO_ARG_ARGV (do_dig)
 CMD_ONE_ARG (do_doing)
 CMD_TWO_ARG_CMDARG (do_dolist)
 CMD_ONE_ARG (do_drop)
 CMD_NO_ARG (do_dump)
 CMD_TWO_ARG_ARGV (do_edit)
 CMD_ONE_ARG (do_enter)
 CMD_ONE_ARG (do_entrances)
 CMD_ONE_ARG (do_examine)
 CMD_ONE_ARG (do_find)
 CMD_TWO_ARG (do_fixdb)
 CMD_TWO_ARG_CMDARG (do_force)
 CMD_ONE_ARG_CMDARG (do_force_prefixed)
 CMD_TWO_ARG (do_function)
 CMD_ONE_ARG (do_get)
 CMD_TWO_ARG (do_give)
 CMD_ONE_ARG (do_global)
 CMD_ONE_ARG (do_halt)
 CMD_ONE_ARG (do_help)
 CMD_ONE_ARG (do_history)
 CMD_NO_ARG (do_multis)
 CMD_NO_ARG (do_inventory)
 CMD_TWO_ARG (do_prog)
 CMD_ONE_ARG (do_quitprog)
 CMD_TWO_ARG (do_kill)
 CMD_ONE_ARG (do_last)
 CMD_NO_ARG (do_leave)
 CMD_TWO_ARG (do_link)
 CMD_ONE_ARG (do_list)
 CMD_ONE_ARG (do_list_file)
 CMD_TWO_ARG (do_lock)
 CMD_ONE_ARG (do_look)
 CMD_ONE_ARG (do_motd)
 CMD_ONE_ARG (do_move)
 CMD_TWO_ARG_ARGV (do_mvattr)
 CMD_TWO_ARG (do_mudwho)
 CMD_TWO_ARG (do_name)
 CMD_TWO_ARG (do_newpassword)
 CMD_TWO_ARG (do_notify)
 CMD_TWO_ARG_ARGV (do_open)
 CMD_TWO_ARG (do_page)
 CMD_TWO_ARG (do_parent)
 CMD_TWO_ARG (do_password)
 CMD_TWO_ARG (do_pcreate)
 CMD_TWO_ARG (do_pemit)
 CMD_ONE_ARG (do_poor)
 CMD_TWO_ARG (do_power)
 CMD_ONE_ARG (do_ps)
 CMD_ONE_ARG (do_queue)
 CMD_TWO_ARG (do_quota)
 CMD_NO_ARG (do_readcache)
 CMD_NO_ARG (do_restart)
 CMD_ONE_ARG (do_say)
 CMD_NO_ARG (do_score)
 CMD_ONE_ARG (do_search)
 CMD_TWO_ARG (do_set)
 CMD_TWO_ARG (do_setattr)
 CMD_TWO_ARG (do_setvattr)
 CMD_ONE_ARG (do_shutdown)
 CMD_ONE_ARG (do_stats)
 CMD_ONE_ARG (do_sweep)
 CMD_TWO_ARG_ARGV_CMDARG (do_switch)
 CMD_TWO_ARG (do_teleport)
 CMD_ONE_ARG (do_think)
 CMD_ONE_ARG (do_timewarp)
 CMD_TWO_ARG (do_toad)
 CMD_TWO_ARG_ARGV (do_trigger)
 CMD_ONE_ARG (do_unlock)
 CMD_ONE_ARG (do_unlink)
 CMD_ONE_ARG (do_use)
 CMD_NO_ARG (do_version)
 CMD_TWO_ARG_ARGV (do_verb)
 CMD_TWO_ARG_CMDARG (do_wait)
 CMD_ONE_ARG (do_wipe)
 CMD_NO_ARG (do_dbclean)
 CMD_TWO_ARG (do_addcommand)
 CMD_TWO_ARG (do_delcommand)
 CMD_ONE_ARG (do_listcommands)
 CMD_TWO_ARG (do_show)
 CMD_ONE_ARG (do_charclear)
 CMD_NO_ARG (do_show_stat)
int check_access (dbref, int)
void process_command (dbref, dbref, int, char *, char *[], int)


Define Documentation

#define CA_ADMIN   0x00000800

Definition at line 222 of file command.h.

Referenced by check_access().

#define CA_ANNOUNCE   0x00000020

Definition at line 221 of file command.h.

Referenced by check_access().

#define CA_BUILDER   0x00000004

Definition at line 218 of file command.h.

Referenced by check_access().

#define CA_CONTENTS   0x20000000

Definition at line 236 of file command.h.

Referenced by process_cmdent().

#define CA_DISABLED   0x04000000

Definition at line 233 of file command.h.

Referenced by check_access(), and fun_config().

#define CA_GBL_BUILD   0x01000000

Definition at line 231 of file command.h.

Referenced by process_cmdent().

#define CA_GBL_INTERP   0x02000000

Definition at line 232 of file command.h.

Referenced by process_cmdent().

#define CA_GOD   0x00000001

Definition at line 216 of file command.h.

Referenced by check_access(), convert_flags(), decode_flags(), display_flagtab(), display_powertab(), flag_description(), has_flag(), has_power(), and power_description().

#define CA_IMMORTAL   0x00000008

Definition at line 219 of file command.h.

Referenced by check_access().

#define CA_LOCATION   0x10000000

Definition at line 235 of file command.h.

Referenced by process_cmdent().

#define CA_NO_DECOMP   0x08000000

Definition at line 234 of file command.h.

Referenced by decompile_flags(), decompile_powers(), and do_decomp().

#define CA_NO_GUEST   0x00010000

Definition at line 227 of file command.h.

Referenced by check_access(), and init_cmdtab().

#define CA_NO_HAVEN   0x00001000

Definition at line 223 of file command.h.

Referenced by check_access().

#define CA_NO_IC   0x00020000

Definition at line 228 of file command.h.

Referenced by check_access().

#define CA_NO_ROBOT   0x00002000

Definition at line 224 of file command.h.

Referenced by check_access().

#define CA_NO_SLAVE   0x00004000

Definition at line 225 of file command.h.

Referenced by check_access(), and init_cmdtab().

#define CA_NO_SUSPECT   0x00008000

Definition at line 226 of file command.h.

Referenced by check_access().

#define CA_PLAYER   0x40000000

Definition at line 237 of file command.h.

Referenced by process_cmdent().

#define CA_PUBLIC   0x00000000

Definition at line 215 of file command.h.

Referenced by flag_description().

#define CA_ROBOT   0x00000010

Definition at line 220 of file command.h.

Referenced by check_access().

#define CA_WIZARD   0x00000002

Definition at line 217 of file command.h.

Referenced by check_access(), convert_flags(), decode_flags(), display_flagtab(), display_powertab(), flag_description(), has_flag(), has_power(), init_cmdtab(), and power_description().

#define CF_DARK   0x80000000

Definition at line 238 of file command.h.

Referenced by list_cmdaccess(), list_cmdswitches(), and list_cmdtable().

#define CMD_NO_ARG ( name   )     extern void name(dbref, dbref, int)

Definition at line 15 of file command.h.

#define CMD_ONE_ARG ( name   )     extern void name(dbref, dbref, int, char *)

Definition at line 17 of file command.h.

#define CMD_ONE_ARG_CMDARG ( name   )     extern void name(dbref, dbref, int, char *, char *[], int)

Definition at line 19 of file command.h.

#define CMD_TWO_ARG ( name   )     extern void name(dbref, dbref, int, char *, char *)

Definition at line 21 of file command.h.

#define CMD_TWO_ARG_ARGV ( name   )     extern void name(dbref, dbref, int, char *, char *[], int)

Definition at line 25 of file command.h.

#define CMD_TWO_ARG_ARGV_CMDARG ( name   )     extern void name(dbref, dbref, int, char *, char *[], int, char*[], int)

Definition at line 27 of file command.h.

#define CMD_TWO_ARG_CMDARG ( name   )     extern void name(dbref, dbref, int, char *, char *, char*[], int)

Definition at line 23 of file command.h.

#define CS_ADDED   0X0800

Definition at line 209 of file command.h.

Referenced by do_addcommand(), do_delcommand(), do_listcommands(), and process_cmdent().

#define CS_ARGV   0x0004

Definition at line 201 of file command.h.

Referenced by process_cmdent().

#define CS_CAUSE   0x0040

Definition at line 204 of file command.h.

#define CS_CMDARG   0x0100

Definition at line 206 of file command.h.

Referenced by process_cmdent().

#define CS_INTERP   0x0010

Definition at line 202 of file command.h.

Referenced by process_cmdent().

#define CS_LEADIN   0x2000

Definition at line 211 of file command.h.

Referenced by process_cmdent().

#define CS_NARG_MASK   0x0003

Definition at line 200 of file command.h.

Referenced by process_cmdent().

#define CS_NO_ARGS   0x0000

Definition at line 197 of file command.h.

Referenced by process_cmdent().

#define CS_NO_MACRO   0x1000

Definition at line 210 of file command.h.

Referenced by process_command().

#define CS_NOINTERP   0x0020

Definition at line 203 of file command.h.

Referenced by process_cmdent().

#define CS_ONE_ARG   0x0001

Definition at line 198 of file command.h.

Referenced by process_cmdent().

#define CS_STRIP   0x0200

Definition at line 207 of file command.h.

Referenced by process_cmdent().

#define CS_STRIP_AROUND   0x0400

Definition at line 208 of file command.h.

Referenced by process_cmdent().

#define CS_TWO_ARG   0x0002

Definition at line 199 of file command.h.

Referenced by init_cmdtab(), and process_cmdent().

#define CS_UNPARSE   0x0080

Definition at line 205 of file command.h.

Referenced by process_cmdent().


Typedef Documentation

typedef struct addedentry ADDENT

Definition at line 187 of file command.h.

typedef struct cmdentry CMDENT

Definition at line 177 of file command.h.


Function Documentation

int check_access ( dbref  ,
int   
)

Definition at line 805 of file command.c.

00808 {
00809         int succ, fail;
00810 
00811         if(mask & CA_DISABLED)
00812                 return 0;
00813         if(God(player) || mudstate.initializing)
00814                 return 1;
00815 
00816         succ = fail = 0;
00817         if(mask & CA_GOD)
00818                 fail++;
00819         if(mask & CA_WIZARD) {
00820                 if(Wizard(player))
00821                         succ++;
00822                 else
00823                         fail++;
00824         }
00825         if((succ == 0) && (mask & CA_ADMIN)) {
00826                 if(WizRoy(player))
00827                         succ++;
00828                 else
00829                         fail++;
00830         }
00831         if((succ == 0) && (mask & CA_ANNOUNCE)) {
00832                 if(Announce(player))
00833                         succ++;
00834                 else
00835                         fail++;
00836         }
00837         if((succ == 0) && (mask & CA_IMMORTAL)) {
00838                 if(Immortal(player))
00839                         succ++;
00840                 else
00841                         fail++;
00842         }
00843         if((succ == 0) && (mask & CA_BUILDER)) {
00844                 if(Builder(player))
00845                         succ++;
00846                 else
00847                         fail++;
00848         }
00849         if((succ == 0) && (mask & CA_ROBOT)) {
00850                 if(Robot(player))
00851                         succ++;
00852                 else
00853                         fail++;
00854         }
00855         if(succ > 0)
00856                 fail = 0;
00857         if(fail > 0)
00858                 return 0;
00859 
00860         /*
00861          * Check for forbidden flags. 
00862          */
00863 
00864         if(!Wizard(player) && (((mask & CA_NO_HAVEN) && Player_haven(player))
00865                                                    || ((mask & CA_NO_ROBOT) && Robot(player)) ||
00866                                                    ((mask & CA_NO_SLAVE) && Slave(player)) ||
00867                                                    ((mask & CA_NO_SUSPECT) && Suspect(player)) ||
00868                                                    ((mask & CA_NO_GUEST) && Guest(player)) ||
00869                                                    (!mudconf.btech_ooc_comsys && (mask & CA_NO_IC)
00870                                                         && In_IC_Loc(player)) || ((mask & CA_NO_IC)
00871                                                                                                           && Gagged(player))
00872            ))
00873                 return 0;
00874         return 1;
00875 }

CMD_NO_ARG ( do_show_stat   ) 

CMD_NO_ARG ( do_dbclean   ) 

CMD_NO_ARG ( do_version   ) 

CMD_NO_ARG ( do_score   ) 

CMD_NO_ARG ( do_restart   ) 

CMD_NO_ARG ( do_readcache   ) 

CMD_NO_ARG ( do_leave   ) 

CMD_NO_ARG ( do_inventory   ) 

CMD_NO_ARG ( do_multis   ) 

CMD_NO_ARG ( do_dump   ) 

CMD_NO_ARG ( do_dbck   ) 

CMD_NO_ARG ( do_comment   ) 

CMD_NO_ARG ( do_clearcom   ) 

CMD_NO_ARG ( do_comlist   ) 

CMD_NO_ARG ( do_chanlist   ) 

CMD_ONE_ARG ( do_charclear   ) 

CMD_ONE_ARG ( do_listcommands   ) 

CMD_ONE_ARG ( do_wipe   ) 

CMD_ONE_ARG ( do_use   ) 

CMD_ONE_ARG ( do_unlink   ) 

CMD_ONE_ARG ( do_unlock   ) 

CMD_ONE_ARG ( do_timewarp   ) 

CMD_ONE_ARG ( do_think   ) 

CMD_ONE_ARG ( do_sweep   ) 

CMD_ONE_ARG ( do_stats   ) 

CMD_ONE_ARG ( do_shutdown   ) 

CMD_ONE_ARG ( do_search   ) 

CMD_ONE_ARG ( do_say   ) 

CMD_ONE_ARG ( do_queue   ) 

CMD_ONE_ARG ( do_ps   ) 

CMD_ONE_ARG ( do_poor   ) 

CMD_ONE_ARG ( do_move   ) 

CMD_ONE_ARG ( do_motd   ) 

CMD_ONE_ARG ( do_look   ) 

CMD_ONE_ARG ( do_list_file   ) 

CMD_ONE_ARG ( do_list   ) 

CMD_ONE_ARG ( do_last   ) 

CMD_ONE_ARG ( do_quitprog   ) 

CMD_ONE_ARG ( do_history   ) 

CMD_ONE_ARG ( do_help   ) 

CMD_ONE_ARG ( do_halt   ) 

CMD_ONE_ARG ( do_global   ) 

CMD_ONE_ARG ( do_get   ) 

CMD_ONE_ARG ( do_find   ) 

CMD_ONE_ARG ( do_examine   ) 

CMD_ONE_ARG ( do_entrances   ) 

CMD_ONE_ARG ( do_enter   ) 

CMD_ONE_ARG ( do_drop   ) 

CMD_ONE_ARG ( do_doing   ) 

CMD_ONE_ARG ( do_destroy   ) 

CMD_ONE_ARG ( do_cut   ) 

CMD_ONE_ARG ( do_boot   ) 

CMD_ONE_ARG ( do_postpend   ) 

CMD_ONE_ARG ( do_prepend   ) 

CMD_ONE_ARG ( do_delcom   ) 

CMD_ONE_ARG ( do_allcom   ) 

CMD_ONE_ARG ( do_channelwho   ) 

CMD_ONE_ARG ( do_chanstatus   ) 

CMD_ONE_ARG ( do_destroychannel   ) 

CMD_ONE_ARG ( do_createchannel   ) 

CMD_ONE_ARG ( do_checkchannel   ) 

CMD_ONE_ARG_CMDARG ( do_force_prefixed   ) 

CMD_TWO_ARG ( do_show   ) 

CMD_TWO_ARG ( do_delcommand   ) 

CMD_TWO_ARG ( do_addcommand   ) 

CMD_TWO_ARG ( do_toad   ) 

CMD_TWO_ARG ( do_teleport   ) 

CMD_TWO_ARG ( do_setvattr   ) 

CMD_TWO_ARG ( do_setattr   ) 

CMD_TWO_ARG ( do_set   ) 

CMD_TWO_ARG ( do_quota   ) 

CMD_TWO_ARG ( do_power   ) 

CMD_TWO_ARG ( do_pemit   ) 

CMD_TWO_ARG ( do_pcreate   ) 

CMD_TWO_ARG ( do_password   ) 

CMD_TWO_ARG ( do_parent   ) 

CMD_TWO_ARG ( do_page   ) 

CMD_TWO_ARG ( do_notify   ) 

CMD_TWO_ARG ( do_newpassword   ) 

CMD_TWO_ARG ( do_name   ) 

CMD_TWO_ARG ( do_mudwho   ) 

CMD_TWO_ARG ( do_lock   ) 

CMD_TWO_ARG ( do_link   ) 

CMD_TWO_ARG ( do_kill   ) 

CMD_TWO_ARG ( do_prog   ) 

CMD_TWO_ARG ( do_give   ) 

CMD_TWO_ARG ( do_function   ) 

CMD_TWO_ARG ( do_fixdb   ) 

CMD_TWO_ARG ( do_decomp   ) 

CMD_TWO_ARG ( do_create   ) 

CMD_TWO_ARG ( do_clone   ) 

CMD_TWO_ARG ( do_chzone   ) 

CMD_TWO_ARG ( do_chownall   ) 

CMD_TWO_ARG ( do_chown   ) 

CMD_TWO_ARG ( do_attribute   ) 

CMD_TWO_ARG ( do_alias   ) 

CMD_TWO_ARG ( do_admin   ) 

CMD_TWO_ARG ( do_malias   ) 

CMD_TWO_ARG ( do_mail   ) 

CMD_TWO_ARG ( do_tapcom   ) 

CMD_TWO_ARG ( do_comtitle   ) 

CMD_TWO_ARG ( do_addcom   ) 

CMD_TWO_ARG ( do_chopen   ) 

CMD_TWO_ARG ( do_edituser   ) 

CMD_TWO_ARG ( do_editchannel   ) 

CMD_TWO_ARG ( do_chboot   ) 

CMD_TWO_ARG ( do_cemit   ) 

CMD_TWO_ARG_ARGV ( do_verb   ) 

CMD_TWO_ARG_ARGV ( do_trigger   ) 

CMD_TWO_ARG_ARGV ( do_open   ) 

CMD_TWO_ARG_ARGV ( do_mvattr   ) 

CMD_TWO_ARG_ARGV ( do_edit   ) 

CMD_TWO_ARG_ARGV ( do_dig   ) 

CMD_TWO_ARG_ARGV ( do_cpattr   ) 

CMD_TWO_ARG_ARGV_CMDARG ( do_switch   ) 

CMD_TWO_ARG_CMDARG ( do_wait   ) 

CMD_TWO_ARG_CMDARG ( do_force   ) 

CMD_TWO_ARG_CMDARG ( do_dolist   ) 

void process_command ( dbref  ,
dbref  ,
int  ,
char *  ,
char *  [],
int   
)

Definition at line 1207 of file command.c.

References A_EALIAS, A_LALIAS, alloc_lbuf, AMATCH_CMD, atr_match(), atr_pget(), cmdentry::callseq, check_access(), statedata::command_htab, Contents, CS_NO_MACRO, statedata::debug_cmd, do_comsystem(), do_enter_internal(), do_leave(), do_macro(), do_move(), DOLIST, ENDLOG, EV_FCHECK, EV_STRIP, EV_TOP, exec(), Fixed, confdata::fixed_home_msg, free_lbuf, statedata::func_invk_ctr, statedata::func_nest_lev, Going, Good_obj, goto_cmdp, Halted, HandledCommand(), Has_contents, Has_location, hashfind(), confdata::have_comsys, confdata::have_macros, confdata::have_specials, confdata::have_zones, init_match_check_keys(), last_match_result(), LBUF_SIZE, list_check(), Location, statedata::lock_nest_lev, LOG_ALLCOMMANDS, LOG_BADCOMMANDS, LOG_BUGS, log_error(), log_name_and_loc(), LOG_SUSPECTCMDS, log_text(), confdata::master_room, match_exit_with_parents(), match_master_exit(), confdata::match_mine, confdata::match_mine_pl, match_zone_exit(), matches_exit_from_list(), move_exit(), mudconf, mudstate, Name(), No_Command, NOTHING, notify, notify_printf(), statedata::ntfy_nest_lev, Owner, cmdentry::perms, prefix_cmds, process_cmdent(), send_channel(), Slave, confdata::space_compress, STARTLOG, string_compare(), StringCopy, strnlen(), Suspect, ToLower, TYPE_EXIT, TYPE_PLAYER, TYPE_ROOM, Typeof, Verbose, WizRoy, and Zone.

Referenced by do_command(), and do_top().

01209 {
01210         char *p, *q, *arg, *lcbuf, *slashp, *cmdsave, *bp, *str;
01211         int succ, aflags, i;
01212         dbref exit, aowner;
01213         CMDENT *cmdp;
01214         char *macroout;
01215         int macerr;
01216         int eins = 1, null = 0;
01217         int length;
01218 
01219         /*
01220          * Robustify player 
01221          */
01222 
01223         cmdsave = mudstate.debug_cmd;
01224         mudstate.debug_cmd = (char *) "< process_command >";
01225 
01226         if(!command) {
01227                 abort();
01228         }
01229 
01230         if(!Good_obj(player)) {
01231         log_error(LOG_BUGS, "CMD", "PLYR", "Bad player in process_command: %d", player);
01232                 mudstate.debug_cmd = cmdsave;
01233                 goto exit;
01234         }
01235 
01236         //    if(isPlayer(player)) choke_player(player);
01237 
01238         /*
01239          * Make sure player isn't going or halted 
01240          */
01241 
01242         if(Going(player) || (Halted(player) &&
01243                                                  !((Typeof(player) == TYPE_PLAYER) && interactive))) {
01244                 notify_printf(Owner(player),
01245                                           "Attempt to execute command by halted object #%d",
01246                                           player);
01247                 mudstate.debug_cmd = cmdsave;
01248                 goto exit;
01249         }
01250 
01251         if(Suspect(player)) {
01252                 STARTLOG(LOG_SUSPECTCMDS | LOG_ALLCOMMANDS, "CMD", "SUS") {
01253                         log_name_and_loc(player);
01254                         lcbuf = alloc_lbuf("process_command.LOG.allcmds");
01255                         sprintf(lcbuf, " entered: '%s'", command);
01256                         log_text(lcbuf);
01257                         free_lbuf(lcbuf);
01258                         ENDLOG;
01259                 }
01260                 send_channel("SuspectsLog", "%s (#%d) (in #%d) entered: %s", Name(player),
01261                                                          player, Location(player), command);
01262         } else {
01263                 STARTLOG(LOG_ALLCOMMANDS, "CMD", "ALL") {
01264                         log_name_and_loc(player);
01265                         lcbuf = alloc_lbuf("process_command.LOG.allcmds");
01266                         sprintf(lcbuf, " entered: '%s'", command);
01267                         log_text(lcbuf);
01268                         free_lbuf(lcbuf);
01269                         ENDLOG;
01270                 }
01271         }
01272 
01273         /*
01274          * Reset recursion limits 
01275          */
01276         mudstate.func_nest_lev = 0;
01277         mudstate.func_invk_ctr = 0;
01278         mudstate.ntfy_nest_lev = 0;
01279         mudstate.lock_nest_lev = 0;
01280 
01281         if(Verbose(player))
01282                 notify_printf(Owner(player), "%s] %s", Name(player), command);
01283 
01284         /*
01285          * Eat leading whitespace, and space-compress if configured 
01286          */
01287 
01288         while (*command && isspace(*command))
01289                 command++;
01290         mudstate.debug_cmd = command;
01291 
01292         /*
01293          * Can we fix the @npemit thing? 
01294          */
01295         if(mudconf.space_compress && strncmp(command, "@npemit", 7)) {
01296                 p = q = command;
01297                 while (*p) {
01298                         while (*p && !isspace(*p))
01299                                 *q++ = *p++;
01300                         while (*p && isspace(*p))
01301                                 p++;
01302                         if(*p)
01303                                 *q++ = ' ';
01304                 }
01305                 *q = '\0';
01306         }
01307 
01308         /*
01309          * Now comes the fun stuff.  First check for single-letter leadins.
01310          * We check these before checking HOME because
01311          * they are among the most frequently executed commands, 
01312          * and they can never be the HOME command. 
01313          */
01314 
01315         i = command[0] & 0xff;
01316         if((prefix_cmds[i] != NULL) && command[0]) {
01317                 process_cmdent(prefix_cmds[i], NULL, player, cause,
01318                                            interactive, command, command, args, nargs);
01319                 mudstate.debug_cmd = cmdsave;
01320                 goto exit;
01321         }
01322         if(mudconf.have_macros && (command[0] == '.') && interactive) {
01323                 macerr = do_macro(player, command, &macroout);
01324                 if(!macerr)
01325                         goto exit;
01326                 if(macerr == 1) {
01327                         StringCopy(command, macroout);
01328                         free_lbuf(macroout);
01329                 }
01330         } else
01331                 macerr = 0;
01332         if(mudconf.have_comsys && !Slave(player))
01333                 if(!do_comsystem(player, command))
01334                         goto exit;
01335 
01336         /* Handle mecha stuff.. */
01337         if(mudconf.have_specials && !Slave(player))
01338                 if(HandledCommand(player, Location(player), command))
01339                         goto exit;
01340         /*
01341          * Check for the HOME command 
01342          */
01343 
01344         if(string_compare(command, "home") == 0) {
01345                 if(((Fixed(player)) || (Fixed(Owner(player)))) && !(WizRoy(player))) {
01346                         notify(player, mudconf.fixed_home_msg);
01347                         goto exit;
01348                 }
01349                 do_move(player, cause, 0, "home");
01350                 mudstate.debug_cmd = cmdsave;
01351                 goto exit;
01352         }
01353 
01354         /*
01355          * Only check for exits if we may use the goto command 
01356          */
01357         if(check_access(player, goto_cmdp->perms)) {
01358                 /*
01359                  * Check for an exit name 
01360                  */
01361                 init_match_check_keys(player, command, TYPE_EXIT);
01362                 match_exit_with_parents();
01363                 exit = last_match_result();
01364                 if(exit != NOTHING) {
01365                         move_exit(player, exit, 0, "You can't go that way.", 0);
01366                         mudstate.debug_cmd = cmdsave;
01367                         goto exit;
01368                 }
01369                 /*
01370                  * Check for an exit in the master room 
01371                  */
01372 
01373                 init_match_check_keys(player, command, TYPE_EXIT);
01374                 match_master_exit();
01375                 exit = last_match_result();
01376                 if(exit != NOTHING) {
01377                         move_exit(player, exit, 1, NULL, 0);
01378                         mudstate.debug_cmd = cmdsave;
01379                         goto exit;
01380                 }
01381         }
01382         /*
01383          * Set up a lowercase command and an arg pointer for the hashed
01384          * command check.  Since some types of argument
01385          * processing destroy the arguments, make a copy so that
01386          * we keep the original command line intact.  Store the
01387          * edible copy in lcbuf after the lowercased command. 
01388          */
01389         /*
01390          * Removed copy of the rest of the command, since it's ok do allow
01391          * it to be trashed.  -dcm 
01392          */
01393 
01394         lcbuf = alloc_lbuf("process_commands.LCbuf");
01395         for(p = command, q = lcbuf; *p && !isspace(*p); p++, q++)
01396                 *q = ToLower(*p);               /*
01397                                                                  * Make lowercase command 
01398                                                                  */
01399         *q++ = '\0';                            /*
01400                                                                  * Terminate command 
01401                                                                  */
01402         while (*p && isspace(*p))
01403                 p++;                                    /*
01404                                                                  * Skip spaces before arg 
01405                                                                  */
01406         arg = p;                                        /*
01407                                                                  * Remember where arg starts 
01408                                                                  */
01409 
01410         /*
01411          * Strip off any command switches and save them 
01412          */
01413 
01414         slashp = (char *) index(lcbuf, '/');
01415         if(slashp)
01416                 *slashp++ = '\0';
01417 
01418         /*
01419          * Check for a builtin command (or an alias of a builtin command) 
01420          */
01421 
01422         cmdp = (CMDENT *) hashfind(lcbuf, &mudstate.command_htab);
01423         if(cmdp != NULL) {
01424                 if((cmdp->callseq & CS_NO_MACRO) && macerr == 1)
01425                         notify(player,
01426                                    "This command is unavailable as macro. Please use an attribute instead.");
01427                 else
01428                         process_cmdent(cmdp, slashp, player, cause, interactive, arg,
01429                                                    command, args, nargs);
01430                 free_lbuf(lcbuf);
01431                 mudstate.debug_cmd = cmdsave;
01432                 goto exit;
01433         }
01434         /*
01435          * Check for enter and leave aliases, user-defined commands on the *
01436          * * * * * * player, other objects where the player is, on objects in
01437          * * the  * *  * *  * player's inventory, and on the room that holds * 
01438          * the * player. * We * *  * evaluate the command line here to allow * 
01439          * chains  * of * $-commands to * * * work. 
01440          */
01441 
01442         bp = lcbuf;
01443         str = command;
01444         exec(lcbuf, &bp, 0, player, cause,
01445                  EV_EVAL | EV_FCHECK | EV_STRIP | EV_TOP, &str, args, nargs);
01446         length = strnlen(lcbuf, LBUF_SIZE-1);
01447         lcbuf[length] = '\0';
01448         succ = 0;
01449 
01450         /*
01451          * Idea for enter/leave aliases from R'nice@TinyTIM 
01452          */
01453 
01454         if(Has_location(player) && Good_obj(Location(player))) {
01455 
01456                 /* Check for a leave alias */
01457                 p = atr_pget(Location(player), A_LALIAS, &aowner, &aflags);
01458                 if(p && *p) {
01459                         if(matches_exit_from_list(lcbuf, p)) {
01460                                 free_lbuf(lcbuf);
01461                                 free_lbuf(p);
01462                                 do_leave(player, player, 0);
01463                                 goto exit;
01464                         }
01465                 }
01466                 free_lbuf(p);
01467 
01468                 /*
01469                  * Check for enter aliases 
01470                  */
01471 
01472                 DOLIST(exit, Contents(Location(player))) {
01473                         p = atr_pget(exit, A_EALIAS, &aowner, &aflags);
01474                         if(p && *p) {
01475                                 if(matches_exit_from_list(lcbuf, p)) {
01476                                         free_lbuf(lcbuf);
01477                                         free_lbuf(p);
01478                                         do_enter_internal(player, exit, 0);
01479                                         goto exit;
01480                                 }
01481                         }
01482                         free_lbuf(p);
01483                 }
01484         }
01485         /*
01486          * Check for $-command matches on me 
01487          */
01488 
01489         if(mudconf.match_mine && (!(No_Command(player)))) {
01490                 if(((Typeof(player) != TYPE_PLAYER) || mudconf.match_mine_pl) &&
01491                    (atr_match(player, player, AMATCH_CMD, lcbuf, 1) > 0)) {
01492                         succ++;
01493                 }
01494         }
01495         /*
01496          * Check for $-command matches on nearby things and on my room 
01497          */
01498 
01499         if(Has_location(player)) {
01500                 succ +=
01501                         list_check(Contents(Location(player)), player, AMATCH_CMD,
01502                                            lcbuf, 1);
01503 
01504                 if(!(No_Command(Location(player))))
01505                         if(atr_match(Location(player), player, AMATCH_CMD, lcbuf, 1) > 0) {
01506                                 succ++;
01507                         }
01508         }
01509 
01510         /*
01511          * Check for $-command matches in my inventory 
01512          */
01513 
01514         if(Has_contents(player))
01515                 succ += list_check(Contents(player), player, AMATCH_CMD, lcbuf, 1);
01516 
01517         /*
01518          * now do check on zones 
01519          */
01520 
01521         if((!succ) && mudconf.have_zones && (Zone(Location(player)) != NOTHING)) {
01522                 if(Typeof(Zone(Location(player))) == TYPE_ROOM) {
01523 
01524                         /*
01525                          * zone of player's location is a parent room 
01526                          */
01527                         if(Location(player) != Zone(player)) {
01528 
01529                                 /*
01530                                  * check parent room exits 
01531                                  */
01532                                 init_match_check_keys(player, command, TYPE_EXIT);
01533                                 match_zone_exit();
01534                                 exit = last_match_result();
01535                                 if(exit != NOTHING) {
01536                                         move_exit(player, exit, 1, NULL, 0);
01537                                         mudstate.debug_cmd = cmdsave;
01538                                         goto exit;
01539                                 }
01540                                 succ += list_check(Contents(Zone(Location(player))), player,
01541                                                                    AMATCH_CMD, lcbuf, 1);
01542                         }                                       /*
01543                                                                  * * end of parent room checks  
01544                                                                  */
01545                 } else
01546                         /*
01547                          * try matching commands on area zone object 
01548                          */
01549 
01550                 if((!succ) && mudconf.have_zones &&
01551                            (Zone(Location(player)) != NOTHING) &&
01552                            (!(No_Command(Zone(Location(player))))))
01553                         succ += atr_match(Zone(Location(player)), player, AMATCH_CMD,
01554                                                           lcbuf, 1);
01555         }
01556         /*
01557          * * end of matching on zone of player's * *
01558          * * * * * location  
01559          */
01560         /*
01561          * if nothing matched with parent room/zone object, try matching
01562          * zone commands on the player's personal zone  
01563          */
01564         if((!succ) && mudconf.have_zones && (Zone(player) != NOTHING) &&
01565            (!(No_Command(Zone(player)))) &&
01566            (Zone(Location(player)) != Zone(player))) {
01567                 succ += atr_match(Zone(player), player, AMATCH_CMD, lcbuf, 1);
01568 
01569         }
01570         /*
01571          * If we didn't find anything, try in the master room 
01572          */
01573 
01574         if(!succ) {
01575                 if(Good_obj(mudconf.master_room) && Has_contents(mudconf.master_room)) {
01576                         succ +=
01577                                 list_check(Contents(mudconf.master_room), player,
01578                                                    AMATCH_CMD, lcbuf, 0);
01579                         if(!(No_Command(mudconf.master_room)))
01580                                 if(atr_match(mudconf.master_room, player, AMATCH_CMD,
01581                                                          lcbuf, 0) > 0) {
01582                                         succ++;
01583                                 }
01584                 }
01585         }
01586         free_lbuf(lcbuf);
01587 
01588         /*
01589          * If we still didn't find anything, tell how to get help. 
01590          */
01591 
01592         if(!succ) {
01593                 notify(player, "Huh?  (Type \"help\" for help.)");
01594                 STARTLOG(LOG_BADCOMMANDS, "CMD", "BAD") {
01595                         log_name_and_loc(player);
01596                         lcbuf = alloc_lbuf("process_commands.LOG.badcmd");
01597                         snprintf(lcbuf, LBUF_SIZE, " entered: '%s'", command);
01598                         log_text(lcbuf);
01599                         free_lbuf(lcbuf);
01600                         ENDLOG;
01601                 }
01602         }
01603         mudstate.debug_cmd = cmdsave;
01604 
01605   exit:
01606         //    if(isPlayer(player)) release_player(player);
01607         return;
01608 }


Generated on Mon May 28 04:25:27 2007 for BattletechMUX by  doxygen 1.4.7