/************************************************************************** * 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 <stdio.h> #include <string.h> #include <stdlib.h> #include "merc.h" #include "olc.h" #include "lookup.h" #include "recycle.h" #include "globals.h" #include "tables.h" #define DEDIT(fun) bool fun(CHAR_DATA *ch, const char *argument) DEITY_DATA *get_deity_data(int deity) { if (deity > -1 && deity < maxDeity) return &deity_table[deity]; return &deity_table[0]; } void dedit(CHAR_DATA * ch, char *argument) { if (get_trust(ch) < MAX_LEVEL - 5) { chprintln(ch, "Insuffecient security to modify deity data"); edit_done(ch); return; } if (!str_cmp(argument, "done")) { edit_done(ch); return; } if (emptystring(argument)) { dedit_show(ch, argument); return; } if (!process_olc_command(ch, argument, deity_olc_comm_table)) interpret(ch, argument); return; } CH_CMD(do_dedit) { DEITY_DATA *pDeity; int value; char arg[MSL]; if (IS_NPC(ch)) return; pDeity = &deity_table[0]; argument = one_argument(argument, arg); if (IS_NULLSTR(arg)) { chprintln(ch, "Syntax: dedit create\n\r dedit #/deity name"); return; } if (is_number(arg)) value = atoi(arg); else value = deity_lookup(arg); if (value > -1) { pDeity = get_deity_data(value); if (!pDeity || IS_NULLSTR(pDeity->name)) { chprintln(ch, "That deity does not exist."); return; } } else if (!str_cmp(arg, "save")) { save_deities(); chprintln(ch, "Deity database saved."); return; } else if (!str_cmp(arg, "create")) { if (ch->pcdata->security < 9) { chprintln(ch, "dEdit : Insuffecient security to create new deities."); return; } dedit_create(ch, argument); return; } edit_start(ch, pDeity, ED_DEITY); return; } DEDIT(dedit_show) { DEITY_DATA *pDeity; EDIT_DEITY(ch, pDeity); chprintln(ch, draw_line(NULL, 0)); chprintlnf(ch, "Name : %s", pDeity->name); chprintlnf(ch, "Desc : %s", pDeity->desc); chprintlnf(ch, "Skill : %s", IS_STRSET(pDeity->skillname)); chprintln(ch, draw_line(NULL, 0)); return TRUE; } DEDIT(dedit_list) { int i; bool found = FALSE; for (i = 0; i < maxDeity; i++) { found = TRUE; chprintlnf(ch, "\t%-12s : %s", deity_table[i].name, IS_STRSET(deity_table[i].desc)); } if (!found) chprintln(ch, "No deities."); return TRUE; } DEDIT(dedit_create) { int j, i = maxDeity; DEITY_DATA *pDeity; struct deity_type *new_table; char buf[MIL]; if (!IS_NULLSTR(argument) && deity_lookup(argument) == -1) sprintf(buf, argument); else sprintf(buf, "New Deity%d", maxDeity + 1); maxDeity++; alloc_mem(new_table, struct deity_type, maxDeity); if (!new_table) { chprintln(ch, "Memory Allocation Failed!!! Unable to create deity."); return FALSE; } for (j = 0; j < i; j++) new_table[j] = deity_table[j]; free_mem(deity_table); deity_table = new_table; deity_table[i].name = str_dup(buf); deity_table[i].desc = &str_empty[0]; deity_table[i].skillname = &str_empty[0]; pDeity = &deity_table[i]; edit_start(ch, pDeity, ED_DEITY); chprintln(ch, "Deity created."); return TRUE; } DEDIT(dedit_delete) { DEITY_DATA *pDeity; EDIT_DEITY(ch, pDeity); if (str_cmp(argument, "confirm")) { chprintln (ch, "Typing 'delete confirm' will permanetely remove this command!"); return FALSE; } else { int i, j = 0, c; struct deity_type *new_table; alloc_mem(new_table, struct deity_type, maxDeity); if (!new_table) { chprintln(ch, "Memory Allocation error!!! Unable to delete liquid."); return FALSE; } c = deity_lookup(pDeity->name); for (i = 0; i < maxDeity; i++) if (i != c) new_table[j++] = deity_table[i]; free_mem(deity_table); deity_table = new_table; maxDeity--; pDeity = &deity_table[0]; ch->desc->pEdit = (void *) pDeity; chprintln(ch, "Deity deleted."); } return TRUE; }