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 "tables.h"
#include "olc.h"
#include "lookup.h"
#include "recycle.h"
#include "interp.h"

OLCED(hedit_show)
{
	HELP_DATA *help;

	EDIT_HELP(ch, help);

	chprintlnf(ch,
			   "Keyword : [%s]\n\r" "Level   : [%d]\n\r" "Texto   :\n\r"
			   "%s-FIN-", help->keyword, help->level, help->text);

	return FALSE;
}

OLCED(hedit_level)
{
	HELP_DATA *help;
	int lev;

	EDIT_HELP(ch, help);

	if (IS_NULLSTR(argument) || !is_number(argument))
	{
		chprintln(ch, "Sintaxis : nivel [-1..MAX_LEVEL]");
		return FALSE;
	}

	lev = atoi(argument);

	if (lev < -1 || lev > MAX_LEVEL)
	{
		chprintf(ch, "HEdit : niveles entre -1 y %d solamente.\n\r", MAX_LEVEL);
		return FALSE;
	}

	help->level = lev;
	chprintln(ch, "Ok.");
	return TRUE;
}

OLCED(hedit_keyword)
{
	HELP_DATA *help;

	EDIT_HELP(ch, help);

	if (IS_NULLSTR(argument))
	{
		chprintln(ch, "Sintaxis : keyword [keywords]");
		return FALSE;
	}

	replace_string(help->keyword, argument);

	chprintln(ch, "Ok.");
	return TRUE;
}

OLCED(hedit_new)
{
	char arg[MIL], fullarg[MIL];
	HELP_DATA *help;

	if (IS_NULLSTR(argument))
	{
		chprintln(ch, "Sintaxis : new [nombre]");
		chprintln(ch, "           new [area] [nombre]");
		return FALSE;
	}

	strcpy(fullarg, argument);
	argument = one_argument(argument, arg);

	if (help_lookup(argument))
	{
		chprintln(ch, "HEdit : help ya existe.");
		return FALSE;
	}

	help = new_help();
	help->level = 0;
	help->keyword = str_dup(argument);
	help->text = str_dup("");

	add_help(help);

	edit_start(ch, help, ED_HELP);
	chprintln(ch, "Ok.");
	return FALSE;
}

OLCED(hedit_text)
{
	HELP_DATA *help;

	EDIT_HELP(ch, help);

	if (!IS_NULLSTR(argument))
	{
		chprintln(ch, "Sintaxis : texto");
		return FALSE;
	}

	string_append(ch, &help->text);

	return TRUE;
}

CH_CMD(do_hedit)
{
	HELP_DATA *pHelp;
	char arg[MIL];

	if (IS_NPC(ch))
		return;

	argument = one_argument(argument, arg);

	if (is_name(arg, "create new make"))
	{
		hedit_new(ch, argument);
		return;
	}

	strcat(arg, " ");
	strcat(arg, argument);

	if ((pHelp = help_lookup(arg)) == NULL)
	{
		chprintln(ch, "HEdit : Help inexistente.");
		return;
	}

	edit_start(ch, pHelp, ED_HELP);
	return;
}

OLCED(hedit_delete)
{
	HELP_DATA *pHelp;
	DESCRIPTOR_DATA *d;

	EDIT_HELP(ch, pHelp);

	for (d = descriptor_first; d; d = d->next)
		if (d->editor == ED_HELP && pHelp == (HELP_DATA *) d->pEdit)
			edit_done(d->character);

	UNLINK(pHelp, help_first, help_last, next, prev);

	free_help(pHelp);

	chprintln(ch, "Ok.");
	return TRUE;
}

OLCED(hedit_list)
{
	int cnt = 0;
	HELP_DATA *pHelp;
	BUFFER *buffer;

	EDIT_HELP(ch, pHelp);

	if (!str_cmp(argument, "all"))
	{
		buffer = new_buf();

		for (pHelp = help_first; pHelp; pHelp = pHelp->next)
		{
			bprintf(buffer, "%3d. %-14.14s%s", cnt, pHelp->keyword,
					cnt % 4 == 3 ? "\n\r" : " ");
			cnt++;
		}

		if (cnt % 4)
			bprintln(buffer, "");

		sendpage(ch, buf_string(buffer));
		return FALSE;
	}

	if (IS_NULLSTR(argument))
	{
		chprintln(ch, "Sintaxis : list all");
		return FALSE;
	}

	return FALSE;
}