Crossfire Server  1.75.0
commands.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2022 the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
19 #include "global.h"
20 
21 #include <ctype.h>
22 #include <stdlib.h>
23 #include <string.h>
24 
25 #include "commands.h"
26 #include "sproto.h"
27 #include "assert.h"
28 
29 #include <map>
30 
36  char *extra;
37  float time;
38  uint8_t type;
39 };
40 
44 static std::map<std::string, std::vector<registered_command *> > registered_commands;
45 
59  if (type > COMMAND_TYPE_WIZARD) {
60  type = COMMAND_TYPE_NORMAL;
61  }
62  auto existing = registered_commands.find(name);
63  if (existing != registered_commands.end()) {
64  assert(!existing->second.empty());
65  if (existing->second.back()->type != type) {
66  return 0;
67  }
68  }
69 
73  add->type = type;
74  add->func_std = func_std;
75  add->func_extra = func_extra;
76  add->extra = extra ? strdup(extra) : nullptr;
77  add->time = time;
78  registered_commands[name].push_back(add);
79  return add->registration;
80 }
81 
82 static void command_partial_commands(object *op, const char *params) {
83  if (strcmp(params, "1") == 0 || strcmp(params, "on") == 0) {
84  op->contr->partial_commands = 1;
85  }
86  if (strcmp(params, "0") == 0 || strcmp(params, "off") == 0) {
87  op->contr->partial_commands = 0;
88  }
89  draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_INFO, "Partial commands %s.", op->contr->partial_commands ? "enabled" : "disabled");
90 }
91 
101 command_registration command_register(const char *name, uint8_t type, command_function func, float time) {
102  return do_register(name, type, func, nullptr, nullptr, time);
103 }
104 
108 void commands_init(void) {
109 #define RN(name, func, time) command_register(name, COMMAND_TYPE_NORMAL, func, time)
110 #define RC(name, func, time) command_register(name, COMMAND_TYPE_COMMUNICATION, func, time)
111 #define RW(name, func, time) command_register(name, COMMAND_TYPE_WIZARD, func, time)
112 
113  /* Normal game commands. */
114  RN("afk", command_afk, 0.0);
115  RN("apply", command_apply, 1.0); /* should be variable */
116  RN("applymode", command_applymode, 1.0); /* should be variable */
117  RN("body", command_body, 0.0);
118  RN("bowmode", command_bowmode, 0.0);
119  RN("brace", command_brace, 0.0);
120  RN("cast", command_cast, 0.2); /* Is this right? */
121  RN("delete", command_delete, 0.0);
122  RN("disarm", command_disarm, 1.0);
123  RN("dm", command_dm, 0.0);
124  RN("dmhide", command_dmhide, 0.0); /* Like dm, but don't tell a dm arrived, hide player */
125  RN("drop", command_drop, 1.0);
126  RN("dropall", command_dropall, 1.0);
127  RN("empty", command_empty, 1.0);
128  RN("examine", command_examine, 0.5);
129  RN("fix_me", command_fix_me, 0.0);
130  RN("follow", command_follow, 0.0);
131  RN("forget_spell", command_forget_spell, 0.0);
132  RN("get", command_take, 1.0);
133  RN("help", command_help, 0.0);
134  RN("hiscore", command_hiscore, 0.0);
135  RN("inventory", command_inventory, 0.0);
136  RN("invoke", command_invoke, 1.0);
137  RN("killpets", command_kill_pets, 0.0);
138  RN("language", command_language, 0.0);
139  RN("listen", command_listen, 0.0);
140  RN("lock", command_lock_item, 0.0);
141  RN("maps", command_maps, 0.0);
142  RN("mapinfo", command_mapinfo, 0.0);
143  RN("mark", command_mark, 0.0);
144  RN("motd", command_motd, 0.0);
145  RN("news", command_news, 0.0);
146  RN("partial_commands", command_partial_commands, 0.0);
147  RN("party", command_party, 0.0);
148  RN("party_rejoin", command_party_rejoin, 0.0);
149  RN("passwd", command_passwd, 0.0);
150  RN("peaceful", command_peaceful, 0.0);
151  RN("petmode", command_petmode, 0.0);
152  RN("pickup", command_pickup, 1.0);
153  RN("prepare", command_cast, 1.0);
154  RN("printlos", command_printlos, 0.0);
155  RN("quit", command_quit, 0.0);
156  RN("ready_skill", command_rskill, 1.0);
157  RN("rename", command_rename_item, 0.0);
158  RN("resistances", command_resistances, 0.0);
159  RN("rotateshoottype", command_rotateshoottype, 0.0);
160  RN("rules", command_rules, 0.0);
161  RN("save", command_save, 0.0);
162  RN("shoottype", command_shoottype, 0.0);
163  RN("skills", command_skills, 0.0); /* shows player list of skills */
164  RN("use_skill", command_uskill, 1.0);
165  RN("search", command_search, 1.0);
166  RN("search-items", command_search_items, 0.0);
167  RN("showpets", command_showpets, 1.0);
168  RN("sound", command_sound, 0.0);
169  RN("statistics", command_statistics, 0.0);
170  RN("take", command_take, 1.0);
171  RN("throw", command_throw, 1.0);
172  RN("time", command_time, 0.0);
173  RN("title", command_title, 0.0);
174  RN("use", command_use, 1.0);
175  RN("usekeys", command_usekeys, 0.0);
176  RN("whereabouts", command_whereabouts, 0.0);
177  RN("whereami", command_whereami, 0.0);
178  RN("unarmed_skill", command_unarmed_skill, 0.0);
179 #ifdef DEBUG_MALLOC_LEVEL
180  RN("verify", command_malloc_verify, 0.0);
181 #endif
182  RN("version", command_version, 0.0);
183  RN("wimpy", command_wimpy, 0.0);
184  RN("who", command_who, 0.0);
185  /*
186  * directional commands
187  */
188  RN("stay", command_stay, 1.0); /* 1.0 because it is used when using a
189  * skill on yourself */
190  RN("north", command_north, 1.0);
191  RN("east", command_east, 1.0);
192  RN("south", command_south, 1.0);
193  RN("west", command_west, 1.0);
194  RN("northeast", command_northeast, 1.0);
195  RN("southeast", command_southeast, 1.0);
196  RN("southwest", command_southwest, 1.0);
197  RN("northwest", command_northwest, 1.0);
198  RN("run", command_run, 1.0);
199  RN("run_stop", command_run_stop, 0.0);
200  RN("fire", command_fire, 1.0);
201  RN("fire_stop", command_fire_stop, 0.0);
202  RN("face", command_face, 0.0);
203  RN("quest", command_quest, 0.0);
204  RN("knowledge", command_knowledge, 0.0);
205 
206  /* Chat/shout related commands. */
207  RC("tell", command_tell, 0.1);
208  RC("reply", command_reply, 0.0);
209  RC("say", command_say, 0.1);
210  RC("gsay", command_gsay, 1.0);
211  RC("shout", command_shout, 0.1);
212  RC("chat", command_chat, 0.1);
213  RC("me", command_me, 0.1);
214  RC("cointoss", command_cointoss, 0.0);
215  RC("orcknuckle", command_orcknuckle, 0.0);
216  /*
217  * begin emotions
218  */
219  RC("nod", command_nod, 0.0);
220  RC("dance", command_dance, 0.0);
221  RC("kiss", command_kiss, 0.0);
222  RC("bounce", command_bounce, 0.0);
223  RC("smile", command_smile, 0.0);
224  RC("cackle", command_cackle, 0.0);
225  RC("laugh", command_laugh, 0.0);
226  RC("giggle", command_giggle, 0.0);
227  RC("shake", command_shake, 0.0);
228  RC("puke", command_puke, 0.0);
229  RC("growl", command_growl, 0.0);
230  RC("scream", command_scream, 0.0);
231  RC("sigh", command_sigh, 0.0);
232  RC("sulk", command_sulk, 0.0);
233  RC("hug", command_hug, 0.0);
234  RC("cry", command_cry, 0.0);
235  RC("poke", command_poke, 0.0);
236  RC("accuse", command_accuse, 0.0);
237  RC("grin", command_grin, 0.0);
238  RC("bow", command_bow, 0.0);
239  RC("clap", command_clap, 0.0);
240  RC("blush", command_blush, 0.0);
241  RC("burp", command_burp, 0.0);
242  RC("chuckle", command_chuckle, 0.0);
243  RC("cough", command_cough, 0.0);
244  RC("flip", command_flip, 0.0);
245  RC("frown", command_frown, 0.0);
246  RC("gasp", command_gasp, 0.0);
247  RC("glare", command_glare, 0.0);
248  RC("groan", command_groan, 0.0);
249  RC("hiccup", command_hiccup, 0.0);
250  RC("lick", command_lick, 0.0);
251  RC("pout", command_pout, 0.0);
252  RC("shiver", command_shiver, 0.0);
253  RC("shrug", command_shrug, 0.0);
254  RC("slap", command_slap, 0.0);
255  RC("smirk", command_smirk, 0.0);
256  RC("snap", command_snap, 0.0);
257  RC("sneeze", command_sneeze, 0.0);
258  RC("snicker", command_snicker, 0.0);
259  RC("sniff", command_sniff, 0.0);
260  RC("snore", command_snore, 0.0);
261  RC("spit", command_spit, 0.0);
262  RC("strut", command_strut, 0.0);
263  RC("thank", command_thank, 0.0);
264  RC("twiddle", command_twiddle, 0.0);
265  RC("wave", command_wave, 0.0);
266  RC("whistle", command_whistle, 0.0);
267  RC("wink", command_wink, 0.0);
268  RC("yawn", command_yawn, 0.0);
269  RC("beg", command_beg, 0.0);
270  RC("bleed", command_bleed, 0.0);
271  RC("cringe", command_cringe, 0.0);
272  RC("think", command_think, 0.0);
273 
275  RW("abil", command_abil, 0.0);
276  RW("accountpasswd", command_accountpasswd, 0.0);
277  RW("addexp", command_addexp, 0.0);
278  RW("arrest", command_arrest, 0.0);
279  RW("banish", command_banish, 0.0);
280  RW("create", command_create, 0.0);
281  RW("debug", command_debug, 0.0);
282  RW("diff", command_diff, 0.0);
283  RW("dmtell", command_dmtell, 0.0);
284  RW("dump", command_dump, 0.0);
285  RW("dumpabove", command_dumpabove, 0.0);
286  RW("dumpbelow", command_dumpbelow, 0.0);
287  RW("dumpfriendlyobjects", command_dumpfriendlyobjects, 0.0);
288  RW("dumpallarchetypes", command_dumpallarchetypes, 0.0);
289  RW("dumpallmaps", command_dumpallmaps, 0.0);
290  RW("dumpallobjects", command_dumpallobjects, 0.0);
291  RW("dumpmap", command_dumpmap, 0.0);
292  RW("free", command_free, 0.0);
293  RW("freeze", command_freeze, 0.0);
294  RW("goto", command_goto, 0.0);
295  RW("hide", command_hide, 0.0);
296  RW("insert_into", command_insert_into, 0.0);
297  RW("invisible", command_invisible, 0.0);
298  RW("kick", command_kick, 0.0);
299  RW("learn_special_prayer", command_learn_special_prayer, 0.0);
300  RW("learn_spell", command_learn_spell, 0.0);
301  RW("malloc", command_malloc, 0.0);
302  RW("nodm", command_nowiz, 0.0);
303  RW("nowiz", command_nowiz, 0.0);
304  RW("patch", command_patch, 0.0);
305  RW("players", command_players, 0.0);
306  RW("plugin", command_loadplugin, 0.0);
307  RW("pluglist", command_listplugins, 0.0);
308  RW("plugout", command_unloadplugin, 0.0);
309  RW("purge_quest_state", command_purge_quest, 0.0);
310  RW("purge_quests", command_purge_quest_definitions, 0.0);
311  RW("recollect", command_recollect, 0.0);
312  RW("remove", command_remove, 0.0);
313  RW("reset", command_reset, 0.0);
314  RW("set_god", command_setgod, 0.0);
315  RW("settings", command_settings, 0.0);
316  RW("server_speed", command_speed, 0.0);
317  RW("shutdown", command_shutdown, 0.0);
318  RW("ssdumptable", command_ssdumptable, 0.0);
319  RW("stack_clear", command_stack_clear, 0.0);
320  RW("stack_list", command_stack_list, 0.0);
321  RW("stack_pop", command_stack_pop, 0.0);
322  RW("stack_push", command_stack_push, 0.0);
323  RW("stats", command_stats, 0.0);
324  RW("strings", command_strings, 0.0);
325  RW("style_info", command_style_map_info, 0.0); /* Costly command, so make it wiz only */
326  RW("summon", command_summon, 0.0);
327  RW("swap", command_swap, 0.0);
328  RW("teleport", command_teleport, 0.0);
329  RW("toggle_shout", command_toggle_shout, 0.0);
330  RW("wizpass", command_wizpass, 0.0);
331  RW("wizcast", command_wizcast, 0.0);
332  RW("overlay_save", command_overlay_save, 0.0);
333  RW("overlay_reset", command_overlay_reset, 0.0);
334  /* RW("possess", command_possess, 0.0); */
335  RW("mon_aggr", command_mon_aggr, 0.0);
336  RW("loadtest", command_loadtest, 0.0);
337 
338 #undef RN
339 #undef RC
340 #undef RW
341 }
342 
347  for (auto cmd = registered_commands.begin(); cmd != registered_commands.end(); cmd++) {
348  for (auto h = cmd->second.begin(); h != cmd->second.end(); h++) {
349  free((*h)->extra);
350  delete *h;
351  }
352  cmd->second.clear();
353  }
354  registered_commands.clear();
355 
356  next_registration = 1;
357 }
358 
369 static void show_commands(object *op, uint8_t type, const char *legend) {
370  char line[HUGE_BUF];
371 
373 
374  line[0] = '\0';
375  std::for_each(registered_commands.begin(), registered_commands.end(), [&type, &line] (auto cmd) {
376  if (cmd.second.back()->type == type) {
377  strcat(line, cmd.first.c_str());
378  strcat(line, " ");
379  }
380  });
382 }
383 
390 void command_list(object *pl, bool is_dm) {
391  show_commands(pl, COMMAND_TYPE_NORMAL, " Commands:");
393  show_commands(pl, COMMAND_TYPE_COMMUNICATION, " Communication commands:");
394  if (is_dm) {
396  show_commands(pl, COMMAND_TYPE_WIZARD, " Wiz commands:");
397  }
398 }
399 
407 static registered_command *command_find(const char *name, object *pl) {
408  auto existing = registered_commands.find(name);
409  if (existing != registered_commands.end()) {
410  if (!QUERY_FLAG(pl, FLAG_WIZ) && existing->second.back()->type == COMMAND_TYPE_WIZARD) {
412  "'%s' is not a valid command.", name);
413  return nullptr;
414  }
415  return existing->second.back();
416  }
417 
418  if (pl->contr->partial_commands) {
419  size_t len = strlen(name);
420  registered_command *candidate = nullptr;
421  std::string matches;
422  bool multiple = false;
423  for (auto command : registered_commands) {
424  if ((command.second.back()->type != COMMAND_TYPE_WIZARD || QUERY_FLAG(pl, FLAG_WIZ)) && command.first.length() >= len && command.first.compare(0, len, name) == 0) {
425  if (candidate) {
426  matches += ", " + command.first;
427  multiple = true;
428  } else {
429  candidate = command.second.back();
430  matches = command.first;
431  }
432  }
433  }
434  if (multiple) {
436  "'%s' is ambiguous and may be %s.", name, matches.c_str());
437  return nullptr;
438  }
439  if (candidate) {
440  return candidate;
441  }
442  }
444  "'%s' is not a valid command.", name);
445  return nullptr;
446 }
447 
456 void command_execute(object *pl, char *command) {
457  registered_command *csp;
458  char *cp, *low;
459 
460  pl->contr->has_hit = 0;
461 
462  /*
463  * remove trailing spaces from commant
464  */
465  cp = command+strlen(command)-1;
466  while ((cp >= command) && (*cp == ' ')) {
467  *cp = '\0';
468  cp--;
469  }
470  cp = strchr(command, ' ');
471  if (cp) {
472  *(cp++) = '\0';
473  while (*cp == ' ')
474  cp++;
475  } else {
476  cp = strchr(command, '\0');
477  }
478 
479  if (strlen(command) == 0) {
480  return;
481  }
482 
483  for (low = command; *low; low++)
484  *low = tolower(*low);
485 
486  csp = command_find(command, pl);
487 
488  if (csp == nullptr) {
489  return;
490  }
491 
492  pl->speed_left -= csp->time;
493 
494  /* A character time can never exceed his speed (which in many cases,
495  * if wearing armor, is less than one.) Thus, in most cases, if
496  * the command takes 1.0, the player's speed will be less than zero.
497  * it is only really an issue if time goes below -1
498  * Due to various reasons that are too long to go into here, we will
499  * actually still execute player even if his time is less than 0,
500  * but greater than -1. This is to improve the performance of the
501  * new client/server. In theory, it shouldn't make much difference.
502  */
503 
504  if (csp->time && pl->speed_left < -2.0) {
505  LOG(llevDebug, "execute_newclient_command: Player issued command that takes more time than he has left.\n");
506  }
507  if (csp->extra) {
508  csp->func_extra(pl, cp, csp->extra);
509  } else {
510  csp->func_std(pl, cp);
511  }
512 }
513 
526 command_registration command_register_extra(const char *name, const char *extra, uint8_t type, command_function_extra func, float time) {
527  assert(extra);
528  return do_register(name, type, nullptr, func, extra, time);
529 }
530 
536  for (auto cmd = registered_commands.begin(); cmd != registered_commands.end(); cmd++) {
537  for (auto h = cmd->second.begin(); h != cmd->second.end(); h++) {
538  if ((*h)->registration == command) {
539  free((*h)->extra);
540  delete (*h);
541  cmd->second.erase(h);
542  if (cmd->second.empty()) {
543  registered_commands.erase(cmd);
544  }
545  return;
546  }
547  }
548  }
549 }
static registered_command * command_find(const char *name, object *pl)
Find a command by its name.
Definition: commands.cpp:407
void command_speed(object *op, const char *params)
Changes the server speed.
Definition: c_wiz.cpp:1732
void command_smile(object *op, const char *params)
&#39;smile&#39; command.
Definition: c_chat.cpp:766
void command_bounce(object *op, const char *params)
&#39;bounce&#39; command.
Definition: c_chat.cpp:755
void command_arrest(object *op, const char *params)
Wizard jails player.
Definition: c_wiz.cpp:821
void command_hiscore(object *op, const char *params)
Player is asking for the hiscore.
Definition: c_misc.cpp:879
#define COMMAND_TYPE_WIZARD
Wizard-only commands.
Definition: commands.h:39
void command_east(object *op, const char *params)
&#39;east&#39; command.
Definition: c_move.cpp:57
#define RC(name, func, time)
void command_yawn(object *op, const char *params)
&#39;yawn&#39; command.
Definition: c_chat.cpp:1261
void command_diff(object *op, const char *params)
Get a diff of specified items.
Definition: c_wiz.cpp:2622
void command_quit(object *op, const char *params)
Tell players to use the &#39;delete&#39; command.
Definition: c_misc.cpp:1871
void command_bow(object *op, const char *params)
&#39;bow&#39; command.
Definition: c_chat.cpp:931
void command_skills(object *op, const char *params)
Player is asking for her skills.
Definition: c_wiz.cpp:1365
void command_list(object *pl, bool is_dm)
Display the list of commands to a player.
Definition: commands.cpp:390
void command_pout(object *op, const char *params)
&#39;pout&#39; command.
Definition: c_chat.cpp:1074
void command_motd(object *op, const char *params)
Display the message of the day.
Definition: c_misc.cpp:215
void command_strut(object *op, const char *params)
&#39;strut&#39; command.
Definition: c_chat.cpp:1195
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.cpp:58
void command_flip(object *op, const char *params)
&#39;flip&#39; command.
Definition: c_chat.cpp:997
void command_cast(object *op, const char *params)
&#39;cast&#39; command, prepares a spell for laster casting.
Definition: c_range.cpp:50
void command_overlay_save(object *op, const char *params)
Saves the op&#39;s map as an overlay - objects are persisted.
Definition: c_wiz.cpp:568
void command_title(object *op, const char *params)
Player wishes to change her title.
Definition: c_misc.cpp:2045
command_registration command_register_extra(const char *name, const char *extra, uint8_t type, command_function_extra func, float time)
Register a player-issued command with an extra parameter.
Definition: commands.cpp:526
void command_face(object *op, const char *params)
Player wants to face a given direction.
Definition: c_new.cpp:111
void command_dm(object *op, const char *params)
Actual command to perhaps become dm.
Definition: c_wiz.cpp:2214
void command_dump(object *op, const char *params)
Dumps the difference between an object and its archetype.
Definition: c_wiz.cpp:1377
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
void command_snicker(object *op, const char *params)
&#39;snicker&#39; command.
Definition: c_chat.cpp:1151
void command_stay(object *op, const char *params)
&#39;stay&#39; command.
Definition: c_move.cpp:145
Represents one command.
Definition: commands.cpp:32
void command_smirk(object *op, const char *params)
&#39;smirk&#39; command.
Definition: c_chat.cpp:1118
void command_grin(object *op, const char *params)
&#39;grin&#39; command.
Definition: c_chat.cpp:920
void command_invisible(object *op, const char *params)
Wizard wants to become invisible.
Definition: c_wiz.cpp:2226
void command_nod(object *op, const char *params)
&#39;nod&#39; command.
Definition: c_chat.cpp:722
void command_freeze(object *op, const char *params)
Freezes a player for a specified tick count, 100 by default.
Definition: c_wiz.cpp:745
void command_body(object *op, const char *params)
This command dumps the body information for object *op.
Definition: c_misc.cpp:173
void command_examine(object *op, const char *params)
&#39;examine&#39; command.
Definition: c_object.cpp:1441
void command_stack_pop(object *op, const char *params)
Pop the stack top.
Definition: c_wiz.cpp:2534
void command_sniff(object *op, const char *params)
&#39;sniff&#39; command.
Definition: c_chat.cpp:1162
void command_loadplugin(object *op, const char *params)
Loads the given plugin.
Definition: c_wiz.cpp:2458
void command_dumpallarchetypes(object *op, const char *params)
Various archetypes-related statistics.
Definition: c_misc.cpp:1003
#define HUGE_BUF
Used for messages - some can be quite long.
Definition: define.h:37
void command_use(object *op, const char *params)
Try to use an item on another.
Definition: c_object.cpp:2703
void command_style_map_info(object *op, const char *params)
Displays information about styles loaded for random maps.
Definition: c_wiz.cpp:2763
void(* command_function)(object *op, const char *params)
One command function.
Definition: commands.h:17
void command_malloc(object *op, const char *params)
Display memory information.
Definition: c_misc.cpp:794
#define RN(name, func, time)
void command_scream(object *op, const char *params)
&#39;scream&#39; command.
Definition: c_chat.cpp:843
void command_learn_special_prayer(object *op, const char *params)
Wizard wants to learn a god-given spell.
Definition: c_wiz.cpp:2402
void command_whereabouts(object *op, const char *params)
&#39;whereabouts&#39; command.
Definition: c_misc.cpp:482
void command_chuckle(object *op, const char *params)
&#39;chuckle&#39; command.
Definition: c_chat.cpp:975
void command_reset(object *op, const char *params)
Resets a map.
Definition: c_wiz.cpp:1885
void command_glare(object *op, const char *params)
&#39;glare&#39; command.
Definition: c_chat.cpp:1030
void command_summon(object *op, const char *params)
Summons player near DM.
Definition: c_wiz.cpp:866
void command_create(object *op, const char *params)
Wizard wants to create an object.
Definition: c_wiz.cpp:999
void command_version(object *op, const char *params)
Server version.
Definition: c_misc.cpp:1074
void command_cringe(object *op, const char *params)
&#39;cringe&#39; command.
Definition: c_chat.cpp:1294
void command_gasp(object *op, const char *params)
&#39;gasp&#39; command.
Definition: c_chat.cpp:1019
void command_passwd(object *pl, const char *params)
Player is asking to change password.
Definition: c_misc.cpp:2234
void command_settings(object *op, const char *ignored)
Wizard wants to know some server settings, so display.
Definition: c_wiz.cpp:2914
static void command_partial_commands(object *op, const char *params)
Definition: commands.cpp:82
void command_insert_into(object *op, const char *params)
Puts an object into another.
Definition: c_wiz.cpp:2686
void command_wimpy(object *op, const char *params)
Player wants to change how soon she&#39;ll flee.
Definition: c_misc.cpp:2140
void command_wave(object *op, const char *params)
&#39;wave&#39; command.
Definition: c_chat.cpp:1228
void command_abil(object *op, const char *params)
Changes an object&#39;s statistics.
Definition: c_wiz.cpp:1819
void command_fire_stop(object *op, const char *params)
Player wants to stop firing.
Definition: c_new.cpp:98
void command_spit(object *op, const char *params)
&#39;spit&#39; command.
Definition: c_chat.cpp:1184
void command_search(object *op, const char *params)
&#39;search&#39; command.
Definition: c_object.cpp:212
void command_dumpabove(object *op, const char *params)
Player wants to dump object above her.
Definition: c_wiz.cpp:2902
void commands_clear()
Clear all registered commands.
Definition: commands.cpp:346
void command_dance(object *op, const char *params)
&#39;dance&#39; command.
Definition: c_chat.cpp:733
Global type definitions and header inclusions.
void command_language(object *op, const char *params)
This is the &#39;language&#39; command.
Definition: c_misc.cpp:130
struct player * contr
Pointer to the player which control this object.
Definition: object.h:284
void command_quest(object *op, const char *params)
Command handler for &#39;quest&#39;.
Definition: quest.cpp:744
static command_registration next_registration
Next identifier for a command registration.
Definition: commands.cpp:42
void command_swap(object *op, const char *params)
Mark a map as ready for swapping.
Definition: c_wiz.cpp:907
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Sends message to player(s).
Definition: main.cpp:308
void command_party(object *op, const char *params)
&#39;party&#39; command, subdivided in different sub commands.
Definition: c_party.cpp:97
void command_stats(object *op, const char *params)
Displays the statistics of a player.
Definition: c_wiz.cpp:1762
void command_players(object *op, const char *params)
Display all known players.
Definition: c_misc.cpp:1225
void command_think(object *op, const char *params)
&#39;think&#39; command.
Definition: c_chat.cpp:1305
void command_stack_list(object *op, const char *params)
Displays stack contents.
Definition: c_wiz.cpp:2565
void command_fire(object *op, const char *params)
Player wants to start firing.
Definition: c_new.cpp:77
void command_remove(object *op, const char *params)
Remove an object from its position.
Definition: c_wiz.cpp:1565
void command_slap(object *op, const char *params)
&#39;slap&#39; command.
Definition: c_chat.cpp:1107
void command_reply(object *op, const char *params)
Reply to last person who told you something [mids 01/14/2002].
Definition: c_chat.cpp:336
void command_gsay(object *op, const char *params)
&#39;gsay&#39; command, talks to party.
Definition: c_party.cpp:75
void command_unarmed_skill(object *op, const char *params)
Player wants to change prefered unarmed skill.
Definition: c_misc.cpp:1379
void command_peaceful(object *op, const char *params)
Player toggles her peaceful status.
Definition: c_misc.cpp:2122
void command_clap(object *op, const char *params)
&#39;clap&#39; command.
Definition: c_chat.cpp:942
void command_say(object *op, const char *params)
&#39;say&#39; command.
Definition: c_chat.cpp:34
void command_strings(object *op, const char *params)
Various string-related statistics.
Definition: c_misc.cpp:845
void command_brace(object *op, const char *params)
Player toggles her braced status.
Definition: c_misc.cpp:2170
void command_whistle(object *op, const char *params)
&#39;whistle&#39; command.
Definition: c_chat.cpp:1239
void command_cough(object *op, const char *params)
&#39;cough&#39; command.
Definition: c_chat.cpp:986
void command_invoke(object *op, const char *params)
&#39;invoke&#39; command, fires a spell immediately.
Definition: c_range.cpp:38
void command_fix_me(object *op, const char *params)
Wrapper to fix a player.
Definition: c_misc.cpp:1211
void command_dmtell(object *op, const char *params)
Private communication, by a DM (can&#39;t be ignored by player).
Definition: c_chat.cpp:320
void command_twiddle(object *op, const char *params)
&#39;twiddle&#39; command.
Definition: c_chat.cpp:1217
#define MSG_TYPE_COMMAND
Responses to commands, eg, who.
Definition: newclient.h:420
void command_shiver(object *op, const char *params)
&#39;shiver&#39; command.
Definition: c_chat.cpp:1085
void command_bowmode(object *op, const char *params)
Player wants to change the bowmode, how arrows are fired.
Definition: c_misc.cpp:1316
void command_goto(object *op, const char *params)
Wizard teleports to a map.
Definition: c_wiz.cpp:724
void command_addexp(object *op, const char *params)
This adds exp to a player.
Definition: c_wiz.cpp:1676
void command_wizpass(object *op, const char *params)
Wizard toggling wall-crossing.
Definition: c_misc.cpp:915
void command_tell(object *op, const char *params)
Private communication.
Definition: c_chat.cpp:308
static std::map< std::string, std::vector< registered_command * > > registered_commands
All registered commands, key is the name, vector is all registered handlers in registration order (la...
Definition: commands.cpp:44
#define MSG_TYPE_COMMAND_ERROR
Bad syntax/can&#39;t use command.
Definition: newclient.h:550
void command_search_items(object *op, const char *params)
&#39;search-items&#39; command.
Definition: c_object.cpp:2429
void command_sneeze(object *op, const char *params)
&#39;sneeze&#39; command.
Definition: c_chat.cpp:1140
void command_setgod(object *op, const char *params)
Sets the god for some objects.
Definition: c_wiz.cpp:418
void command_laugh(object *op, const char *params)
&#39;laugh&#39; command.
Definition: c_chat.cpp:788
void command_hug(object *op, const char *params)
&#39;hug&#39; command.
Definition: c_chat.cpp:876
#define QUERY_FLAG(xyz, p)
Definition: define.h:386
void command_run(object *op, const char *params)
Player wants to start running.
Definition: c_new.cpp:41
void command_shake(object *op, const char *params)
&#39;shake&#39; command.
Definition: c_chat.cpp:810
uint64_t command_registration
Identifier when registering a command.
Definition: commands.h:32
void command_rotateshoottype(object *op, const char *params)
&#39;rotateshoottype&#39; command, switch range attack.
Definition: c_range.cpp:343
void(* command_function_extra)(object *op, const char *params, const char *extra)
One command function, with a custom parameter specified at registration time.
Definition: commands.h:29
void command_rskill(object *pl, const char *params)
&#39;ready_skill&#39; command.
Definition: c_object.cpp:161
void command_throw(object *op, const char *params)
&#39;throw&#39; command.
Definition: c_object.cpp:239
void command_applymode(object *op, const char *params)
Players wants to change the apply mode, ie how to handle applying an item when no body slot available...
Definition: c_misc.cpp:1275
void command_chat(object *op, const char *params)
&#39;chat&#39; command.
Definition: c_chat.cpp:221
void command_northeast(object *op, const char *params)
&#39;northeast&#39; command.
Definition: c_move.cpp:79
void command_stack_push(object *op, const char *params)
Push specified item on stack.
Definition: c_wiz.cpp:2547
void commands_init(void)
Init standard commands.
Definition: commands.cpp:108
void command_apply(object *op, const char *params)
&#39;apply&#39; command.
Definition: c_object.cpp:251
void command_cointoss(object *op, const char *params)
&#39;cointoss&#39; command.
Definition: c_chat.cpp:64
void command_dumpallmaps(object *op, const char *params)
Various map-related statistics.
Definition: c_misc.cpp:1045
void command_shout(object *op, const char *params)
&#39;shout&#39; command.
Definition: c_chat.cpp:210
void command_knowledge(object *pl, const char *params)
Handle the &#39;knowledge&#39; for a player.
Definition: knowledge.cpp:1213
void command_wizcast(object *op, const char *params)
Wizard toggling "cast everywhere" ability.
Definition: c_misc.cpp:945
void command_showpets(object *op, const char *params)
Players wants to know her pets.
Definition: c_misc.cpp:1479
uint8_t type
Command type, one of COMMAND_TYPE_xxx.
Definition: commands.cpp:38
void command_learn_spell(object *op, const char *params)
Wizard wants to learn a regular spell.
Definition: c_wiz.cpp:2390
static void show_commands(object *op, uint8_t type, const char *legend)
Helper function to display commands.
Definition: commands.cpp:369
command_function func_std
Command function.
Definition: commands.cpp:34
void command_blush(object *op, const char *params)
&#39;blush&#39; command.
Definition: c_chat.cpp:953
void command_inventory(object *op, const char *params)
Shows the inventory or some item.
Definition: c_wiz.cpp:1335
command_function_extra func_extra
Command function if extra argument.
Definition: commands.cpp:35
void command_party_rejoin(object *op, const char *params)
Handles the &#39;party_rejoin&#39; command.
Definition: c_party.cpp:307
void command_lock_item(object *op, const char *params)
Alternate way to lock/unlock items (command line).
Definition: c_object.cpp:2660
void command_teleport(object *op, const char *params)
Teleport next to target player.
Definition: c_wiz.cpp:933
Defines and structures related to commands the player can send.
void command_west(object *op, const char *params)
&#39;west&#39; command.
Definition: c_move.cpp:134
void command_snap(object *op, const char *params)
&#39;snap&#39; command.
Definition: c_chat.cpp:1129
void command_delete(object *op, const char *params)
Player wants to totally delete her character.
Definition: c_misc.cpp:1887
void command_debug(object *op, const char *params)
Player wants to see/change the debug level.
Definition: c_misc.cpp:891
void command_snore(object *op, const char *params)
&#39;snore&#39; command.
Definition: c_chat.cpp:1173
void command_lick(object *op, const char *params)
&#39;lick&#39; command.
Definition: c_chat.cpp:1063
void command_resistances(object *op, const char *params)
Players wants to know her resistances.
Definition: c_misc.cpp:1595
void command_follow(object *op, const char *params)
Follow a player, or stop following a player.
Definition: c_wiz.cpp:2809
void command_thank(object *op, const char *params)
&#39;thank&#39; command.
Definition: c_chat.cpp:1206
void command_dumpfriendlyobjects(object *op, const char *params)
Various friendly object-related statistics.
Definition: c_misc.cpp:989
void command_listen(object *op, const char *params)
Change the player&#39;s listen level.
Definition: c_misc.cpp:1088
#define FLAG_WIZ
Object has special privilegies.
Definition: define.h:218
void command_accountpasswd(object *op, const char *params)
Definition: c_wiz.cpp:1638
void command_kill_pets(object *op, const char *params)
Player wants to get rid of pets.
Definition: c_misc.cpp:2194
void command_forget_spell(object *op, const char *params)
Command for players to forget a spell.
Definition: c_wiz.cpp:2415
void command_unloadplugin(object *op, const char *params)
Unloads the given plugin.
Definition: c_wiz.cpp:2490
void command_purge_quest(object *op, const char *param)
Definition: c_wiz.cpp:2853
void command_sigh(object *op, const char *params)
&#39;sigh&#39; command.
Definition: c_chat.cpp:854
float speed_left
How much speed is left to spend this round.
Definition: object.h:338
void command_north(object *op, const char *params)
&#39;north&#39; command.
Definition: c_move.cpp:68
void command_poke(object *op, const char *params)
&#39;poke&#39; command.
Definition: c_chat.cpp:898
void command_help(object *op, const char *params)
Player is asking for some help.
Definition: c_misc.cpp:1770
void command_shoottype(object *op, const char *params)
&#39;shoottype&#39; command, set range attack.
Definition: c_range.cpp:369
void command_maps(object *op, const char *params)
&#39;maps&#39; command.
Definition: c_misc.cpp:833
void command_free(object *op, const char *params)
Totally free an object.
Definition: c_wiz.cpp:1612
void command_cry(object *op, const char *params)
&#39;cry&#39; command.
Definition: c_chat.cpp:887
void command_dropall(object *op, const char *params)
Command to drop all items that have not been locked.
Definition: c_object.cpp:1182
void command_cackle(object *op, const char *params)
&#39;cackle&#39; command.
Definition: c_chat.cpp:777
void command_ssdumptable(object *op, const char *params)
Various string-related statistics.
Definition: c_misc.cpp:1017
void command_empty(object *op, const char *params)
&#39;empty&#39; command.
Definition: c_object.cpp:1402
void command_sulk(object *op, const char *params)
&#39;sulk&#39; command.
Definition: c_chat.cpp:865
void command_banish(object *op, const char *params)
Add player&#39;s IP to ban_file and kick them off the server.
Definition: c_wiz.cpp:502
void command_run_stop(object *op, const char *params)
Player wants to stop running.
Definition: c_new.cpp:64
void command_growl(object *op, const char *params)
&#39;growl&#39; command.
Definition: c_chat.cpp:832
void command_dmhide(object *op, const char *params)
A players wants to become DM and hide.
Definition: c_wiz.cpp:2519
void command_southeast(object *op, const char *params)
&#39;southeast&#39; command.
Definition: c_move.cpp:112
void command_giggle(object *op, const char *params)
&#39;giggle&#39; command.
Definition: c_chat.cpp:799
command_registration command_register(const char *name, uint8_t type, command_function func, float time)
Register a player-issued command.
Definition: commands.cpp:101
void command_burp(object *op, const char *params)
&#39;burp&#39; command.
Definition: c_chat.cpp:964
void command_mapinfo(object *op, const char *params)
&#39;mapinfo&#39; command.
Definition: c_misc.cpp:807
void command_time(object *op, const char *params)
Players asks for the time.
Definition: c_misc.cpp:866
void command_take(object *op, const char *params)
This takes (picks up) an item.
Definition: c_object.cpp:797
void command_south(object *op, const char *params)
&#39;south&#39; command.
Definition: c_move.cpp:101
void command_rename_item(object *op, const char *params)
Changing the custom name of an item.
Definition: c_object.cpp:2474
Only for debugging purposes.
Definition: logger.h:13
void command_groan(object *op, const char *params)
&#39;groan&#39; command.
Definition: c_chat.cpp:1041
void command_mon_aggr(object *op, const char *params)
When DM is possessing a monster, flip aggression on and off, to allow better motion.
Definition: c_wiz.cpp:1405
void command_save(object *op, const char *params)
Player wants to get saved.
Definition: c_misc.cpp:2096
char * extra
Extra argument, if not NULL then func_extra is used, else func_std.
Definition: commands.cpp:36
void command_stack_clear(object *op, const char *params)
Empty DM item stack.
Definition: c_wiz.cpp:2596
void command_northwest(object *op, const char *params)
&#39;northwest&#39; command.
Definition: c_move.cpp:90
void command_unregister(command_registration command)
Unregister a previously registered command.
Definition: commands.cpp:535
void command_kiss(object *op, const char *params)
&#39;kiss&#39; command.
Definition: c_chat.cpp:744
void command_listplugins(object *op, const char *params)
Lists all plugins currently loaded with their IDs and full names.
Definition: c_wiz.cpp:2443
void command_dumpbelow(object *op, const char *params)
Player wants to dump object below her.
Definition: c_wiz.cpp:2887
void command_shutdown(object *op, const char *params)
Totally shutdowns the server.
Definition: c_wiz.cpp:658
void command_overlay_reset(object *op, const char *params)
Removes the overlay for op&#39;s current map.
Definition: c_wiz.cpp:589
#define MSG_TYPE_COMMAND_INFO
Generic info: resistances, etc.
Definition: newclient.h:547
void command_disarm(object *op, const char *params)
&#39;disarm&#39; command.
Definition: c_object.cpp:224
void command_bleed(object *op, const char *params)
&#39;bleed&#39; command.
Definition: c_chat.cpp:1283
void command_orcknuckle(object *op, const char *params)
Plays the "orcknucke" game.
Definition: c_chat.cpp:108
void command_nowiz(object *op, const char *params)
Steps down from wizard mode.
Definition: c_wiz.cpp:2080
void command_printlos(object *op, const char *params)
Various LOS-related statistics.
Definition: c_misc.cpp:1059
void command_mark(object *op, const char *params)
&#39;mark&#39; command, to mark an item for some effects (enchant armor, ...).
Definition: c_object.cpp:1519
void command_hide(object *op, const char *params)
Wizard &#39;hide&#39; command.
Definition: c_wiz.cpp:389
command_registration registration
Identifier for unregistration.
Definition: commands.cpp:33
void command_hiccup(object *op, const char *params)
&#39;hiccup&#39; command.
Definition: c_chat.cpp:1052
static int matches(const char *exp, const char *text)
Does the text match the expression?
Definition: dialog.cpp:81
void command_frown(object *op, const char *params)
&#39;frown&#39; command.
Definition: c_chat.cpp:1008
#define NDI_UNIQUE
Print immediately, don&#39;t buffer.
Definition: newclient.h:270
void command_rules(object *op, const char *params)
Display the server rules.
Definition: c_misc.cpp:228
uint32_t partial_commands
If 1, then first letters of a command are enough if no ambiguity in name.
Definition: player.h:152
void command_pickup(object *op, const char *params)
&#39;pickup&#39; command.
Definition: c_object.cpp:2311
void command_execute(object *pl, char *command)
Handle a player-issued command.
Definition: commands.cpp:456
uint32_t has_hit
If set, weapon_sp instead of speed will count.
Definition: player.h:146
void command_sound(object *op, const char *params)
Player wants to change sound status.
Definition: c_misc.cpp:1908
void command_loadtest(object *op, const char *params)
This command will stress server.
Definition: c_wiz.cpp:306
void command_recollect(object *op, const char *params)
Definition: c_wiz.cpp:1531
void command_patch(object *op, const char *params)
Wizard wants to altar an object.
Definition: c_wiz.cpp:1493
void command_dumpallobjects(object *op, const char *params)
Various object-related statistics.
Definition: c_misc.cpp:975
void command_southwest(object *op, const char *params)
&#39;southwest&#39; command.
Definition: c_move.cpp:123
void command_afk(object *op, const char *params)
Toggles the afk status of a player.
Definition: c_misc.cpp:773
void command_whereami(object *op, const char *params)
&#39;whereami&#39; command.
Definition: c_misc.cpp:820
void command_news(object *op, const char *params)
Display the server news.
Definition: c_misc.cpp:241
void command_accuse(object *op, const char *params)
&#39;accuse&#39; command.
Definition: c_chat.cpp:909
void command_usekeys(object *op, const char *params)
Player wants to change how keys are used.
Definition: c_misc.cpp:1554
void command_shrug(object *op, const char *params)
&#39;shrug&#39; command.
Definition: c_chat.cpp:1096
#define COMMAND_TYPE_NORMAL
Standard commands.
Definition: commands.h:35
void command_toggle_shout(object *op, const char *params)
A simple toggle for the no_shout field.
Definition: c_wiz.cpp:615
void command_uskill(object *pl, const char *params)
&#39;use_skill&#39; command.
Definition: c_object.cpp:144
void command_dumpmap(object *op, const char *params)
Various map-related statistics.
Definition: c_misc.cpp:1031
float time
How long it takes to execute this command.
Definition: commands.cpp:37
#define tolower(C)
Simple macro to convert a letter to lowercase.
Definition: c_new.cpp:30
void command_beg(object *op, const char *params)
&#39;beg&#39; command.
Definition: c_chat.cpp:1272
void command_purge_quest_definitions(object *op, const char *param)
Definition: c_wiz.cpp:2859
void command_petmode(object *op, const char *params)
Player wants to change how her pets behave.
Definition: c_misc.cpp:1435
#define COMMAND_TYPE_COMMUNICATION
Communication commands.
Definition: commands.h:37
void command_me(object *op, const char *params)
&#39;me&#39; command.
Definition: c_chat.cpp:47
static command_registration do_register(const char *name, uint8_t type, command_function func_std, command_function_extra func_extra, const char *extra, float time)
Register a player-issued command.
Definition: commands.cpp:58
void command_statistics(object *pl, const char *params)
Prints out some useful information for the character.
Definition: c_misc.cpp:1119
void command_kick(object *op, const char *params)
Kicks a player from the server.
Definition: c_wiz.cpp:556
void command_who(object *op, const char *params)
&#39;who&#39; command.
Definition: c_misc.cpp:621
void command_drop(object *op, const char *params)
&#39;drop&#39; command.
Definition: c_object.cpp:1306
void command_puke(object *op, const char *params)
&#39;puke&#39; command.
Definition: c_chat.cpp:821
#define RW(name, func, time)
void command_wink(object *op, const char *params)
&#39;wink&#39; command.
Definition: c_chat.cpp:1250