1stMUD4.0/bin/
1stMUD4.0/doc/MPDocs/
1stMUD4.0/player/
1stMUD4.0/win32/
1stMUD4.0/win32/rom/
/**************************************************************************
*  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-2003 by Ryan Jennings              *
*            http://1stmud.dlmud.com/  <r-jenn@shaw.ca>                   *
***************************************************************************/

#include "merc.h"
#include "olc.h"
#include "lookup.h"
#include "recycle.h"
#include "globals.h"
#include "tables.h"
#include "recycle.h"
#include "tablesave.h"

CH_CMD(do_dedit)
{
	DEITY_DATA *pDeity;
	char arg[MSL];

	if (IS_NPC(ch))
		return;

	pDeity = deity_first;

	argument = one_argument(argument, arg);

	if (IS_NULLSTR(arg))
	{
		chprintln(ch, "Syntax: dedit create\n\r        dedit <deity name>");
		return;
	}

	if (!str_cmp(arg, "save"))
	{
		rw_deities(action_write);
		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;
	}
	else if (!(pDeity = deity_lookup(arg)) || IS_NULLSTR(pDeity->name))
	{
		chprintln(ch, "That deity does not exist.");
		return;
	}

	edit_start(ch, pDeity, ED_DEITY);
	return;
}

OLCED(dedit_show)
{
	DEITY_DATA *pDeity;

	EDIT_DEITY(ch, pDeity);

	chprintln(ch, draw_line(ch, 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(ch, NULL, 0));
	return TRUE;
}

OLCED(dedit_list)
{
	DEITY_DATA *i;
	bool found = FALSE;

	for (i = deity_first; i; i = i->next)
	{
		found = TRUE;
		chprintlnf(ch, "\t%-12s : %s", i->name, IS_STRSET(i->desc));
	}
	if (!found)
		chprintln(ch, "No deities.");
	return TRUE;
}

OLCED(dedit_create)
{
	DEITY_DATA *pDeity;
	char buf[MIL];

	if (!IS_NULLSTR(argument) && deity_lookup(argument) == NULL)
		sprintf(buf, argument);
	else
		sprintf(buf, "New Deity%d", maxDeity + 1);

	pDeity = new_deity();
	replace_string(pDeity->name, buf);
	LINK(pDeity, deity_first, deity_last, next, prev);
	edit_start(ch, pDeity, ED_DEITY);
	chprintln(ch, "Deity created.");
	return TRUE;
}

OLCED(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
	{
		UNLINK(pDeity, deity_first, deity_last, next, prev);
		free_deity(pDeity);
		pDeity = deity_first;
		ch->desc->pEdit = (void *) pDeity;

		chprintln(ch, "Deity deleted.");
	}

	return TRUE;
}