/************************************************************************** * Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, * * Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. * * * * Merc Diku Mud improvements copyright (C) 1992, 1993 by Michael * * Chastain, Michael Quan, and Mitchell Tse. * * * * In order to use any part of this Merc Diku Mud, you must comply with * * both the original Diku license in 'license.doc' as well the Merc * * license in 'license.txt'. In particular, you may not remove either of * * these copyright notices. * * * * Much time and thought has gone into this software and you are * * benefiting. We hope that you share your changes too. What goes * * around, comes around. * *************************************************************************** * ROM 2.4 is copyright 1993-1998 Russ Taylor * * ROM has been brought to you by the ROM consortium * * Russ Taylor (rtaylor@hypercube.org) * * Gabrielle Taylor (gtaylor@hypercube.org) * * Brian Moore (zump@rom.org) * * By using this code, you have agreed to follow the terms of the * * ROM license, in the file Rom24/doc/rom.license * *************************************************************************** * 1stMUD ROM Derivative (c) 2001-2002 by Ryan Jennings * * http://1stmud.dlmud.com/ <r-jenn@shaw.ca> * ***************************************************************************/ #include <sys/types.h> #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include "merc.h" #include "interp.h" #include "olc.h" #include "tables.h" #include "recycle.h" const char *do_fun_name args((DO_FUN * fun)); DO_FUN *do_fun_lookup args((const char *name)); #define CMDEDIT(fun) bool fun (CHAR_DATA *ch, const char *argument) CH_CMD(do_cmdcheck) { CMD_DATA *i; DO_FUN *fun; bool found = FALSE; if (IS_NULLSTR(argument)) chprintln(ch, "Syntax: cmdcheck null|missing|<do_fun_name>"); else if (!str_prefix(argument, "null")) { chprintln(ch, "NULL commands:"); for (i = cmd_first; i; i = i->next) { if (i->do_fun == do_null) { found = TRUE; chprintlnf(ch, "%s", i->name); } } if (!found) chprintln(ch, "None."); } else if (!str_prefix(argument, "missing")) { CMD_DATA *cmd; int j; int pos = 0; bool any = FALSE; chprintln(ch, "Functions missing command entries:"); for (j = 0; dofun_table[j].fun != NULL; i++) { found = FALSE; for (cmd = cmd_first; cmd; cmd = cmd->next) { if (dofun_table[j].fun == cmd->do_fun) { found = TRUE; break; } } if (!found) { any = TRUE; chprintf(ch, "%15s ", dofun_table[j].name); if (++pos % 4 == 0) chprintln(ch, ""); } } if (pos % 4 != 0) chprintln(ch, ""); if (!any) chprintln(ch, "None."); } else if ((fun = do_fun_lookup(argument)) != NULL) { chprintlnf(ch, "%s commands:", argument); for (i = cmd_first; i; i = i->next) { if (i->do_fun == fun) { found = TRUE; chprintlnf(ch, "%s", i->name); } } if (!found) chprintln(ch, "None."); } return; } CMDEDIT(cmdedit_show) { CMD_DATA *pCmd; EDIT_CMD(ch, pCmd); chprintln(ch, draw_line(NULL, 0)); chprintlnf(ch, "Name : %s", pCmd->name); chprintlnf(ch, "DoFun : %s", do_fun_name(pCmd->do_fun)); chprintlnf(ch, "Position : %s", flag_string(position_flags, pCmd->position)); chprintlnf(ch, "Level : %d", pCmd->level); chprintlnf(ch, "Log : %s", flag_string(log_flags, pCmd->log)); chprintlnf(ch, "fShow : %s", !pCmd->show ? "FALSE" : "TRUE"); chprintln(ch, draw_line(NULL, 0)); return TRUE; } CMDEDIT(cmdedit_create) { CMD_DATA *pCmd; char buf[MIL]; if (!IS_NULLSTR(argument) && command_lookup(argument) == NULL) sprintf(buf, argument); else sprintf(buf, "New Command%d", maxCommands + 1); pCmd = new_command(); replace_string(pCmd->name, buf); add_command(pCmd); LINK(pCmd, cmd_first, cmd_last, next, prev); edit_start(ch, pCmd, ED_CMD); chprintln(ch, "Command created."); return TRUE; } CMDEDIT(cmdedit_dofun) { CMD_DATA *pCmd; DO_FUN *fun; EDIT_CMD(ch, pCmd); if (IS_NULLSTR(argument)) { chprintln(ch, "Syntax: dofun <function>"); return FALSE; } if (is_name(argument, "none clear reset")) { pCmd->do_fun = do_null; chprintln(ch, "Function entry reset."); return TRUE; } if ((fun = do_fun_lookup(argument)) == do_null) { chprintln (ch, "That is not a valid function (probably not coded in yet)"); return FALSE; } pCmd->do_fun = fun; chprintlnf(ch, "%s now points to the %s function.", pCmd->name, argument); return TRUE; } CMDEDIT(cmdedit_delete) { CMD_DATA *pCmd; EDIT_CMD(ch, pCmd); if (str_cmp(argument, "confirm")) { chprintln (ch, "Typing 'delete confirm' again will permanetely remove this command!"); return FALSE; } else { UNLINK(pCmd, cmd_first, cmd_last, next, prev); free_command(pCmd); pCmd = cmd_first; edit_start(ch, pCmd, ED_CMD); chprintln(ch, "Command deleted."); } return TRUE; } CMDEDIT(cmdedit_rearrange) { CMD_DATA *pCmd, *iCmd, *tmp; bool found = FALSE; EDIT_CMD(ch, pCmd); if (IS_NULLSTR(argument)) { chprintln(ch, "Syntax: cmdedit rearrange <command to place before>"); return FALSE; } if ((iCmd = command_lookup(argument)) == NULL) { chprintln(ch, "That is not a command."); return FALSE; } if (iCmd == pCmd) { chprintln(ch, "Can't rearrange the same command."); return FALSE; } for (tmp = cmd_first; tmp; tmp = tmp->next) { if (tmp == pCmd) { found = TRUE; continue; } if (tmp == iCmd) { if (found) { chprintlnf(ch, "Error: command %s is already above %s.", pCmd->name, iCmd->name); return FALSE; } else break; } } UNLINK(pCmd, cmd_first, cmd_last, next, prev); INSERT(pCmd, iCmd, cmd_first, next, prev); for (tmp = cmd_first; tmp; tmp = tmp->next) unlink_command(tmp); for (tmp = cmd_first; tmp; tmp = tmp->next) add_command(tmp); chprintln(ch, "Command moved."); return TRUE; } CMDEDIT(cmdedit_name) { bool relocate; CMD_DATA *pCmd; char arg1[MIL]; EDIT_CMD(ch, pCmd); one_argument(argument, arg1); if (IS_NULLSTR(arg1)) { chprintln(ch, "Cannot clear name field!"); return FALSE; } if (arg1[0] != pCmd->name[0]) { unlink_command(pCmd); relocate = TRUE; } else relocate = FALSE; replace_string(pCmd->name, arg1); if (relocate) add_command(pCmd); chprintln(ch, "Name set."); return TRUE; }