SmaugWizard/Backup/
SmaugWizard/Backup/L/
SmaugWizard/Boards/
SmaugWizard/Building/
SmaugWizard/Corpses/
SmaugWizard/Councils/
SmaugWizard/Deity/
SmaugWizard/Gods/
SmaugWizard/MudProgs/
SmaugWizard/Player/L/
SmaugWizard/Src/
SmaugWizard/Src/res/
/****************************************************************************
 * [S]imulated [M]edieval [A]dventure multi[U]ser [G]ame      |				*
 * -----------------------------------------------------------|   \\._.//	*
 * SmaugWiz (C) 1998 by Russ Pillsbury (Windows NT version)   |   (0...0)	*
 * -----------------------------------------------------------|    ).:.(	*
 * SMAUG (C) 1994, 1995, 1996 by Derek Snider                 |    {o o}	*
 * -----------------------------------------------------------|   / ' ' \	*
 * SMAUG code team: Thoric, Altrag, Blodkai, Narn, Haus,      |~'~.VxvxV.~'~*
 * Scryn, Swordbearer, Rennard, Tricops, and Gorog.           |				*
 * ------------------------------------------------------------------------ *
 * Merc 2.1 Diku Mud improvments copyright (C) 1992, 1993 by Michael        *
 * Chastain, Michael Quan, and Mitchell Tse.                                *
 * Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer,          *
 * Michael Seifert, Hans Henrik Staerfeldt, Tom Madsen, and Katja Nyboe.    *
 * ------------------------------------------------------------------------ *
 *			    Commands Interface file										*
 ****************************************************************************/

#ifndef	COMMANDS_H
#define	COMMANDS_H

// Structure for a command in the command lookup table.
class CCmdType {
public:
				CCmdType () { memset (this, 0, sizeof (CCmdType)); }
				~CCmdType () { delete m_pName; }
	CCmdType	*GetNext () { return m_pNext; }
	void		SetNext (CCmdType* n) { m_pNext = n; }

	char		*GetName () { return m_pName; }
	void		SetName (char* n);

	BOOL		Read (FILE *fp);
	void		Write (FILE* fp);

	friend class	CCommandTable;

private:
	CCmdType	*m_pNext;
	char		*m_pName;
public:
	DO_FUN		*do_fun;
	short		position;
	short		level;
	short		log;
	struct		timerset	userec;
};



class CCommandTable {
public:
				CCommandTable () { Empty (); }
				~CCommandTable () { RemoveAll (); }

	CCmdType	*GetCommand (int hash)
				{ ASSERT (hash >= 0 && hash < MAX_COMMANDS);
				  return m_ct [hash]; }
	CCmdType	*GetCommand (const char *name)
				{ return GetCommand (GetHash (name [0])); }
	int			GetHash (char k) { return LOWER (k) % MAX_COMMANDS; }
	void		Add (CCmdType *command);
	CCmdType *	Find (char *command);
	void		Unlink (CCmdType *command);

	void		Load ();
	void		Save ();
	void		Empty () { memset (this, 0, sizeof (CCommandTable)); }
	void		RemoveAll ();

private:
	CCmdType	*m_ct [MAX_COMMANDS];
};


#ifdef	SMAUGSERVER_CPP
	CCommandTable	CommandTable;
#endif

extern CCommandTable	CommandTable;

#endif