⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tintin.h

📁 Windows上的MUD客户端程序
💻 H
📖 第 1 页 / 共 2 页
字号:
/*----------------------------------------------------------------------------
                        _                              _ _       
        /\             | |                            | (_)      
       /  \   _ __   __| |_ __ ___  _ __ ___   ___  __| |_  __ _ 
      / /\ \ | '_ \ / _` | '__/ _ \| '_ ` _ \ / _ \/ _` | |/ _` |
     / ____ \| | | | (_| | | | (_) | | | | | |  __/ (_| | | (_| |
    /_/    \_\_| |_|\__,_|_|  \___/|_| |_| |_|\___|\__,_|_|\__,_|

    The contents of this file are subject to the Andromedia Public
	License Version 1.0 (the "License"); you may not use this file
	except in compliance with the License. You may obtain a copy of
	the License at http://www.andromedia.com/APL/

    Software distributed under the License is distributed on an
	"AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
	implied. See the License for the specific language governing
	rights and limitations under the License.

    The Original Code is Pueblo client code, released November 4, 1998.

    The Initial Developer of the Original Code is Andromedia Incorporated.
	Portions created by Andromedia are Copyright (C) 1998 Andromedia
	Incorporated.  All Rights Reserved.

	Andromedia Incorporated                         415.365.6700
	818 Mission Street - 2nd Floor                  415.365.6701 fax
	San Francisco, CA 94103

    Contributor(s):
	--------------------------------------------------------------------------
	   Chaco team:  Dan Greening, Glenn Crocker, Jim Doubek,
	                Coyote Lussier, Pritham Shetty.

					Wrote and designed original codebase.

------------------------------------------------------------------------------

	TinTin class definitions.  Originally modified from TinTin++,
	(T)he K(I)cki(N) (T)ickin D(I)kumud Clie(N)t, originally coded by
	Peter Unold 1992.

----------------------------------------------------------------------------*/

// $Header: /home/cvs/chaco/modules/client/msw/ChWorld/TinTin.h,v 2.34 1996/05/01 18:48:52 coyote Exp $

#if !defined( TINTIN_H )
#define TINTIN_H


#include "TinTinSettings.h"


/*----------------------------------------------------------------------------
	Constants
----------------------------------------------------------------------------*/

#define TINTIN_VERSION			"1.6"

#define DEF_TINTIN_CHAR			'#'			// TinTin escape char
#define DEF_VERBATIM_CHAR		'\\'		/* If an input starts with this
												char, it will be sent 'as is'
												to the MUD */
#define DEF_TICK_SIZE			75
#define DEF_TICK_KEY			"TinTin"

#define DEF_OPEN				'{'			// Char that starts an argument
#define DEF_CLOSE				'}'			// Char that ends an argument
#define TINTIN_DEF_GAG_STRING	"."

#define TINTIN_HELP_PREFIX		"TinTin"

#define MAX_PATH_LENGTH			200			// Maximum path length
#define MAX_RECURSE				100			// Maximum recursion depth


/*----------------------------------------------------------------------------
	Types
----------------------------------------------------------------------------*/

											/* If you change this enumeration,
												you must also change the
												TinTin::m_pstrCommands array
												to correspond with the indices
												in this enumeration */

typedef enum { ttUnknown = -1, ttAction = 0, ttAlert, ttAlias, ttAll,
				ttAntisubstitute, ttBell, ttBoss, ttChar, ttCr, ttEcho,
				ttEnd, ttGag, ttHelp, ttHighlight, ttHistory, ttIf,
				ttIgnore, ttInfo, ttKillall, ttLog, ttLoop, ttMap, ttMath,
				ttMark, ttMbox, ttMessage, ttName, ttNop, ttPath,
				ttPathdir, ttPlaySound, ttPresub, ttRandom, ttRedraw,
				ttRetab, ttReturn, ttRead, ttSavepath, ttSession, ttShowme,
				ttSpeedwalk, ttSplit, ttSubstitute, ttTextin,
				ttTick, ttTickkey, ttTickoff, ttTickon, ttTickset, ttTicksize,
				ttTolower, ttTogglesub, ttToupper, ttUnaction, ttUnalias,
				ttUnantisubstitute, ttUnhighlight, ttUnsubstitute,
				ttUngag, ttUnpath, ttUnvariable, ttVariable, ttVersion,
				ttWizlist, ttWrite, ttWritesession, ttZap, ttVerbatim,
				ttEnhancements, ttExpressions } TTCommand;

typedef int		VarLenType[10];
typedef string	VarType[10];


typedef enum { opInvalid = -1, opOpenParen = 0, opCloseParen, opBooleanNot,
				opLowercase, opMult, opDiv, opAdd, opSubtract, opCompGreater,
				opCompGreaterEqual, opCompLess, opCompLessEqual, opCompEqual,
				opCompNotEqual, opBoolAnd, opBoolOr, opInt, opString,
				opMaximum } TTOperator;


/*----------------------------------------------------------------------------
	Utility functions
----------------------------------------------------------------------------*/

CH_EXTERN_FUNC( bool )
Match( const char* pstrRegex, const char* pstrTest );


/*----------------------------------------------------------------------------
	MathOp class
----------------------------------------------------------------------------*/

class MathOps
{
	public:
		MathOps() : m_iNext( 0 ),
					m_op( opInvalid ),
					m_iValue( 0 ),
					m_pstrValue( 0 )
			{
			}

		~MathOps()
			{
				if (m_pstrValue)
				{
					delete m_pstrValue;
				}
			}

		inline int GetNext() const { return m_iNext; }
		inline TTOperator GetOp() const { return m_op; }
		inline int GetInt() const
						{
							ASSERT( IsInt() );

							return m_iValue;
						}
		inline int& GetInt()
						{
							ASSERT( IsInt() );

							return m_iValue;
						}
		inline string* GetString() const
						{
							ASSERT( 0 != m_pstrValue );
							ASSERT( IsString() );

							return m_pstrValue;
						}

		inline bool IsInt() const
						{
							return (GetOp() == opInt);
						}
		inline bool IsString() const
						{
							return (GetOp() == opString);
						}
		inline bool IsValue() const
						{
							return (IsInt() || IsString());
						}

		inline void SetNext( int iNext ) { m_iNext = iNext; }
		inline void SetOp( TTOperator op ) { m_op = op; }
		inline void Set( int iValue ) { m_iValue = iValue; }
		inline void Set( const string& strValue )
						{
							if (m_pstrValue)
							{
								*m_pstrValue = strValue;
							}
							else
							{
								m_pstrValue = new string( strValue );
							}
						}

		inline void Set( const string* pstrValue )
						{
							Set( *pstrValue );
						}

		inline void Reset()
						{
							if (m_pstrValue)
							{
								delete m_pstrValue;
								m_pstrValue = 0;
							}
						}

	protected:
		int			m_iNext;
		TTOperator	m_op;
		int			m_iValue;
		string*		m_pstrValue;
};


/*----------------------------------------------------------------------------
	TinTin class
----------------------------------------------------------------------------*/

class ChWorldMainInfo;

class TinTin
{
	public:
		TinTin( ChWorldMainInfo* pMainInfo );
		~TinTin();

		inline void ReadInitFile( const string& strFile )
						{
							DoRead( strFile, false );
						}

		inline void Message( const string& strMessage,
								bool boolPreformatted = false ) const
						{
							if (IsMessages())
							{
								Display( strMessage, boolPreformatted );
							}
						}
		inline void ActMessage( const string& strMessage )
						{
							if (IsMessages())
							{
								Display( strMessage, false );
							}
							CheckActions( strMessage );
						}
		inline void ErrMessage( const string& strMessage ) const
						{
							Display( strMessage, false );
						}

		inline bool IsIgnore() { return GetSettings()->IsIgnore(); }
		inline bool IsActionsDefined()
						{
							return (0 != GetListActions()->GetTop());
						}

		virtual void SendToWorld( const string& strOutput );
		virtual void Display( const string& strOutput,
								bool boolPreformatted ) const;
		void Reset();

		void ParseInput( const string& strInput );

		void CheckActions( const string& strLine );
		void CheckInsertPath( const string& strCommand );

		void OnSecondTick( time_t timeCurr );

	protected:
		inline ChWorldMainInfo* GetMainInfo() const { return m_pMainInfo; }
		inline TinTinSettings* GetSettings() const
						{
							return m_pActiveSettings;
						}

		inline TinTinList* GetListAliases() const
						{
							return GetSettings()->GetListAliases();
						}
		inline TinTinList* GetListActions() const
						{
							return GetSettings()->GetListActions();
						}
		inline TinTinList* GetListVars() const

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -