Crossfire Server, Branch 1.12  R12190
commands.c
Go to the documentation of this file.
00001 /*
00002  * static char *rcsid_commands_c =
00003  *   "$Id: commands.c 11578 2009-02-23 22:02:27Z lalo $";
00004  */
00005 
00006 /*
00007     CrossFire, A Multiplayer game for X-windows
00008 
00009     Copyright (C) 2006 Mark Wedel & Crossfire Development Team
00010     Copyright (C) 1992 Frank Tore Johansen
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00025 
00026     The author can be reached via e-mail to crossfire-devel@real-time.com
00027 */
00028 
00034 #include <global.h>
00035 #include <commands.h>
00036 #ifndef __CEXTRACT__
00037 #include <sproto.h>
00038 #endif
00039 #include <ctype.h>
00040 
00041 /* Added times to all the commands.  However, this was quickly done,
00042  * and probably needs more refinements.  All socket and DM commands
00043  * take 0 time.
00044  */
00045 
00049 command_array_struct Commands[] = {
00050     { "language", command_language,      0.0 },
00051     { "save", command_save,              0.0 },
00052 
00053     { "sound", command_sound,            0.0 },
00054     { "party", command_party,            0.0 },
00055     { "party_rejoin", command_party_rejoin, 0.0 },
00056     { "gsay", command_gsay,              1.0 },
00057 #ifdef DEBUG_MALLOC_LEVEL
00058     { "verify", command_malloc_verify,   0.0 },
00059 #endif
00060     { "apply", command_apply,            1.0 },   /* should be variable */
00061     { "applymode", command_applymode,    1.0 },   /* should be variable */
00062     { "body", command_body,              0.0 },
00063     { "brace", command_brace,            0.0 },
00064     { "cast", command_cast,              0.2 },   /* Is this right? */
00065     { "disarm", command_disarm,          1.0 },
00066     { "dm", command_dm,                  0.0 },
00067     { "dmhide", command_dmhide,          0.0 }, /* Like dm, but don't tell a dm arrived, hide player */
00068     { "drop", command_drop,              1.0 },
00069     { "dropall", command_dropall,        1.0 },
00070     { "empty", command_empty,            1.0 },
00071     { "examine", command_examine,        0.5 },
00072     { "explore", command_explore,        0.0 },
00073     { "fix_me", command_fix_me,          0.0 },
00074     { "get", command_take,               1.0 },
00075     { "help", command_help,              0.0 },
00076     { "hiscore", command_hiscore,        0.0 },
00077     { "inventory", command_inventory,    0.0 },
00078     { "invoke", command_invoke,          1.0 },
00079     { "killpets", command_kill_pets,     0.0 },
00080     { "listen", command_listen,          0.0 },
00081     { "lock", command_lock_item,         0.0 },
00082     { "maps", command_maps,              0.0 },
00083     { "mapinfo", command_mapinfo,        0.0 },
00084     { "mark", command_mark,              0.0 },
00085     { "motd", command_motd,              0.0 },
00086     { "rules", command_rules,            0.0 },
00087     { "news", command_news,              0.0 },
00088     { "output-sync", command_output_sync, 0.0 },
00089     { "output-count", command_output_count, 0.0 },
00090     { "passwd", command_passwd,          0.0 },
00091     { "peaceful", command_peaceful,      0.0 },
00092     { "pickup", command_pickup,          1.0 },
00093     { "prepare", command_prepare,        1.0 },
00094     { "quit", command_quit,              0.0 },
00095     { "rename", command_rename_item,     0.0 },
00096     { "resistances", command_resistances, 0.0 },
00097     { "rotateshoottype", command_rotateshoottype, 0.0 },
00098     { "skills", command_skills,          0.0 },   /* shows player list of skills */
00099     { "use_skill", command_uskill,       1.0 },
00100     { "ready_skill", command_rskill,     1.0 },
00101     { "search", command_search,          1.0 },
00102     { "search-items", command_search_items, 0.0 },
00103     { "showpets", command_showpets,      1.0 },
00104     { "statistics", command_statistics,  0.0 },
00105     { "take", command_take,              1.0 },
00106     { "throw", command_throw,            1.0 },
00107     { "time", command_time,              0.0 },
00108     { "use", command_use,                1.0 },
00109     { "whereabouts", command_whereabouts, 0.0 },
00110     { "whereami", command_whereami,      0.0 },
00111     { "title", command_title,            0.0 },
00112     { "usekeys", command_usekeys,        0.0 },
00113     { "bowmode", command_bowmode,        0.0 },
00114     { "petmode", command_petmode,        0.0 },
00115     { "version", command_version,        0.0 },
00116     { "wimpy", command_wimpy,            0.0 },
00117     { "who", command_who,                0.0 },
00118     { "afk", command_afk,                0.0 },
00119 
00120     { "stay", command_stay,              1.0 }, /* 1.0 because it is used when using a
00121                                                *  skill on yourself */
00122     { "north", command_north,            1.0 },
00123     { "east", command_east,              1.0 },
00124     { "south", command_south,            1.0 },
00125     { "west", command_west,              1.0 },
00126     { "northeast", command_northeast,    1.0 },
00127     { "southeast", command_southeast,    1.0 },
00128     { "southwest", command_southwest,    1.0 },
00129     { "northwest", command_northwest,    1.0 },
00130     { "run", command_run,                1.0 },
00131     { "run_stop", command_run_stop,      0.0 },
00132     { "fire", command_fire,              1.0 },
00133     { "fire_stop", command_fire_stop,    0.0 }
00134 };
00135 
00137 const int CommandsSize = sizeof(Commands)/sizeof(command_array_struct);
00138 
00140 command_array_struct CommunicationCommands [] = {
00141     /* begin emotions */
00142     { "tell", command_tell,              0.1 },
00143     { "reply", command_reply,            0.0 },
00144     { "say", command_say,                0.1 },
00145     { "shout", command_shout,            0.1 },
00146     { "chat", command_chat,              0.1 },
00147     { "me", command_me,                  0.1 },
00148     { "nod", command_nod,                0.0 },
00149     { "dance", command_dance,            0.0 },
00150     { "kiss", command_kiss,              0.0 },
00151     { "bounce", command_bounce,          0.0 },
00152     { "smile", command_smile,            0.0 },
00153     { "cackle", command_cackle,          0.0 },
00154     { "laugh", command_laugh,            0.0 },
00155     { "giggle", command_giggle,          0.0 },
00156     { "shake", command_shake,            0.0 },
00157     { "puke", command_puke,              0.0 },
00158     { "growl", command_growl,            0.0 },
00159     { "scream", command_scream,          0.0 },
00160     { "sigh", command_sigh,              0.0 },
00161     { "sulk", command_sulk,              0.0 },
00162     { "hug", command_hug,                0.0 },
00163     { "cry", command_cry,                0.0 },
00164     { "poke", command_poke,              0.0 },
00165     { "accuse", command_accuse,          0.0 },
00166     { "grin", command_grin,              0.0 },
00167     { "bow", command_bow,                0.0 },
00168     { "clap", command_clap,              0.0 },
00169     { "blush", command_blush,            0.0 },
00170     { "burp", command_burp,              0.0 },
00171     { "chuckle", command_chuckle,        0.0 },
00172     { "cough", command_cough,            0.0 },
00173     { "flip", command_flip,              0.0 },
00174     { "frown", command_frown,            0.0 },
00175     { "gasp", command_gasp,              0.0 },
00176     { "glare", command_glare,            0.0 },
00177     { "groan", command_groan,            0.0 },
00178     { "hiccup", command_hiccup,          0.0 },
00179     { "lick", command_lick,              0.0 },
00180     { "pout", command_pout,              0.0 },
00181     { "shiver", command_shiver,          0.0 },
00182     { "shrug", command_shrug,            0.0 },
00183     { "slap", command_slap,              0.0 },
00184     { "smirk", command_smirk,            0.0 },
00185     { "snap", command_snap,              0.0 },
00186     { "sneeze", command_sneeze,          0.0 },
00187     { "snicker", command_snicker,        0.0 },
00188     { "sniff", command_sniff,            0.0 },
00189     { "snore", command_snore,            0.0 },
00190     { "spit", command_spit,              0.0 },
00191     { "strut", command_strut,            0.0 },
00192     { "thank", command_thank,            0.0 },
00193     { "twiddle", command_twiddle,        0.0 },
00194     { "wave", command_wave,              0.0 },
00195     { "whistle", command_whistle,        0.0 },
00196     { "wink", command_wink,              0.0 },
00197     { "yawn", command_yawn,              0.0 },
00198     { "beg", command_beg,                0.0 },
00199     { "bleed", command_bleed,            0.0 },
00200     { "cringe", command_cringe,          0.0 },
00201     { "think", command_think,            0.0 },
00202     { "cointoss", command_cointoss,      0.0 },
00203     { "orcknuckle", command_orcknuckle,  0.0 },
00204     { "printlos", command_printlos,      0.0 },
00205 };
00206 
00208 const int CommunicationCommandSize = sizeof(CommunicationCommands)/sizeof(command_array_struct);
00209 
00211 command_array_struct WizCommands [] = {
00212     { "abil", command_abil,                      0.0 },
00213     { "addexp", command_addexp,                  0.0 },
00214     { "archs", command_archs,                    0.0 },
00215     { "arrest", command_arrest,                  0.0 },
00216     { "banish", command_banish,                  0.0 },
00217     { "create", command_create,                  0.0 },
00218     { "debug", command_debug,                    0.0 },
00219     { "diff", command_diff,                      0.0 },
00220     { "dmtell", command_dmtell,                  0.0 },
00221     { "dump", command_dump,                      0.0 },
00222     { "dumpbelow", command_dumpbelow,            0.0 },
00223     { "dumpfriendlyobjects", command_dumpfriendlyobjects, 0.0 },
00224     { "dumpallarchetypes", command_dumpallarchetypes, 0.0 },
00225     { "dumpallmaps", command_dumpallmaps,        0.0 },
00226     { "dumpallobjects", command_dumpallobjects,  0.0 },
00227     { "dumpmap", command_dumpmap,                0.0 },
00228     { "follow", command_follow,                  0.0 },
00229     { "forget_spell", command_forget_spell,      0.0 },
00230     { "free", command_free,                      0.0 },
00231     { "freeze", command_freeze,                  0.0 },
00232     { "goto", command_goto,                      0.0 },
00233     { "hide", command_hide,                      0.0 },
00234     { "insert_into", command_insert_into,        0.0 },
00235     { "invisible", command_invisible,            0.0 },
00236     { "kick", (command_function)command_kick,    0.0 },
00237     { "learn_special_prayer", command_learn_special_prayer, 0.0 },
00238     { "learn_spell", command_learn_spell,        0.0 },
00239     { "malloc", command_malloc,                  0.0 },
00240     { "nodm", command_nowiz,                     0.0 },
00241     { "nowiz", command_nowiz,                    0.0 },
00242     { "patch", command_patch,                    0.0 },
00243     { "players", command_players,                0.0 },
00244     { "plugin", command_loadplugin,              0.0 },
00245     { "pluglist", command_listplugins,           0.0 },
00246     { "plugout", command_unloadplugin,           0.0 },
00247     { "remove", command_remove,                  0.0 },
00248     { "reset", command_reset,                    0.0 },
00249     { "set_god", command_setgod,                 0.0 },
00250     { "server_speed", command_speed,             0.0 },
00251     { "shutdown", command_shutdown,              0.0 },
00252     { "ssdumptable", command_ssdumptable,        0.0 },
00253     { "stack_clear", command_stack_clear,        0.0 },
00254     { "stack_list", command_stack_list,          0.0 },
00255     { "stack_pop", command_stack_pop,            0.0 },
00256     { "stack_push", command_stack_push,          0.0 },
00257     { "stats", command_stats,                    0.0 },
00258     { "strings", command_strings,                0.0 },
00259     { "style_info", command_style_map_info,      0.0 },        /* Costly command, so make it wiz only */
00260     { "summon", command_summon,                  0.0 },
00261     { "teleport", command_teleport,              0.0 },
00262     { "toggle_shout", command_toggle_shout,      0.0 },
00263     { "wizpass", command_wizpass,                0.0 },
00264     { "wizcast", command_wizcast,                0.0 },
00265     { "overlay_save", command_overlay_save,      0.0 },
00266     { "overlay_reset", command_overlay_reset,    0.0 },
00267 /*    { "possess", command_possess, 0.0 }, */
00268     { "mon_aggr", command_mon_aggr,              0.0 },
00269     { "loadtest", command_loadtest,              0.0 },
00270 };
00272 const int WizCommandsSize = sizeof(WizCommands)/sizeof(command_array_struct);
00273 
00286 static int compare_A(const void *a, const void *b) {
00287     return strcmp(((const command_array_struct *)a)->name, ((const command_array_struct *)b)->name);
00288 }
00289 
00293 void init_commands(void) {
00294     qsort(Commands, CommandsSize, sizeof(command_array_struct), compare_A);
00295     qsort(CommunicationCommands, CommunicationCommandSize, sizeof(command_array_struct), compare_A);
00296     qsort(WizCommands, WizCommandsSize, sizeof(command_array_struct), compare_A);
00297 }