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

📄 extern.h

📁 MudMaster 2000 的C++源码
💻 H
字号:
/************************************************************************************
	Copyright (c) 2000 Aaron O'Neil
	All rights reserved.

	Redistribution and use in source and binary forms, with or without
	modification, are permitted provided that the following conditions
	are met:

		1) Redistributions of source code must retain the above copyright notice, 
				this list of conditions and the following disclaimer.
		2) Redistributions in binary form must reproduce the above copyright notice, 
				this list of conditions and the following disclaimer in the documentation
				and/or other materials provided with the distribution.
		3) Redistributions in binary form must reproduce the above copyright notice on
				program startup. Additional credits for program modification are acceptable
				but original copyright and credits must be visible at startup.
		4) You may charge a reasonable copying fee for any distribution of Mud Master. 
				You may charge any fee you choose for support of Mud Master. You may not 
				charge a fee for Mud Master itself.

  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
	IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
	OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
	IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
	INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
	DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
	THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
	(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
	THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

**************************************************************************************/

#define MAX_INPUT_LEN	5000

class CScreen;
extern CScreen _screen;

class CMudWindow;
extern CMudWindow _terminal;

class CTextInput;
extern CTextInput	_tiUserInput;

class CScrollBack;
extern CScrollBack _scrollBack;

class CStatusBar;
extern CStatusBar _statusBar;

class CKeyboard;
extern CKeyboard _keyboard;

class CUndo;
extern CUndo _undo;

extern BOOL _bUsingModem;
class CModem;
extern CModem _modem;

class CSound;
extern CSound _sound;

extern SOCKET	_hActiveSocket;
extern CString	_strActiveSession;
extern BOOL		_bConnected;

extern SOCKET _hListenSocket;

class CAliasMap;
extern CAliasMap _aliases;
class CActions;
extern CActions _actions;
class CTabList;
extern CTabList _tabList;
class CMacros;
extern CMacros _macros;
class CUserLists;
extern CUserLists _lists;
class CEvents;
extern CEvents _events;
class CMudArray;
extern CMudArray _arrays;
class CGags;
extern CGags _gags;
class CHighlights;
extern CHighlights _highlights;
class CSubstitutes;
extern CSubstitutes _subs;
class CChat;
extern CChat _chat;
class CDll;
extern CDll _dlls;

extern CString		_strGlobalVars[10];
extern CStringMap _mapVars;

extern BOOL _bLogOpen;
class CLogFile;
extern CLogFile _logFile;

class CMsp;
extern CMsp _msp;

class CDebugStack;
extern CDebugStack _debugStack;

extern char *_pWalkBuf;

extern int _nListenPort;

// Creates a socket to listen for inbound calls.
extern void InitListenSocket();
extern void CloseListenSocket();

// Used for calling a user defined DLL.
#define DLL_RESULT_LEN		5001
extern char *_pszDLLResult;

// FALSE by default. Enabled by using "bootlog" as a command line parameter.
// Creates a file called BootLog.txt in the MM dir when enabled.
extern BOOL _bBootLog;
#define BOOTLOG "BootLog.txt"

// Structure to track the status of the changes thread.
struct CHANGESTHREADINFO;
extern CHANGESTHREADINFO _cti;

//////////////////////////////////////////////////////////////////////////////
// Event Related
//
	// This BOOL is set by the SetTimer callback proc when the amount
	// of time has elapsed.  The function dealing with the events
	// needs to set this back to FALSE after it has processed everything.
	extern BOOL _bCheckEvents;

	// Current time passed to the callback procedure.
	extern DWORD _dwTime;

	// Function that updates the two vars above. 
	extern void CheckTime();
//
//////////////////////////////////////////////////////////////////////////////

// This is set to FALSE when the program first starts.  When a 
// midi file is played the flag is set to TRUE.  The midi routine
// then knows that it has to close the previous file before it
// tries to play a new one.
extern BOOL _bMidiOpen;

// This is set to TRUE when a file is being read in.  Certain
// areas might be sensitive to the difference between reading
// a file and actually typing a command in.  One exmaple of this
// is the @PreTrans proc.  It needs to NOT translate when it is
// being read from a file, but translate at all other times.
extern BOOL _bReadingFile;

////////////////////////////////////////////////
// System Variables
//
	// Set in CMudWindow each time the screens foreground
	// color is changed.  Used for the system variable
	// $ForeColor.
	extern int _nForeColor;

	extern int _nBackColor;

	// Used the the list procedures.
	extern CString _strListItem;

	extern int _nLoopCount;

	// This is set in CMudWindow to point to the last line of text printed
	// before the action is checked.  It is used by the procs to figure
	// out text colors for specific parts of a string.
	extern CTextLine *_ptlLastText;

//
////////////////////////////////////////////////

// Struct for holding all the terms color values.  I apparently
// forgout about this struction.  All of the classes keep track of
// their own color values.  Currently the struction is used just
// when the options are loaded to hold the values until the
// object is created and displayed.
struct TERMCOLORS
{ 
	WORD wInput;		// Where the users typed text appears.
	WORD wStatusBar;	// Status bar colors.
};

extern TERMCOLORS _colors;

#define STATUS_BAR_ABOVE 0
#define STATUS_BAR_BELOW 1

struct CONFIGURATION
{
	CHAR	chCommand;		// Command character.
	CHAR	chSeparator;	// Character to separate commands on a line.
	CHAR	chEscape;		// Escape character for special codes.
	CHAR	chBlockStart;	// Character for starting a block statement.
	CHAR	chBlockEnd;		// Character for ending a block statement.
	int	nHistory;		// Number history lines to save.
	int	nScrollBack;	// Number of lines to remember in scroll back buffer.
	BOOL	bVarMessages;	// TRUE to print variable messages.
	BOOL	bAliasMessages;
	BOOL	bActionMessages;
	BOOL  bTabMessages;
	BOOL  bMacroMessages;
	BOOL	bListMessages;
	BOOL	bItemMessages;
	BOOL	bEventMessages;
	BOOL  bBarMessages;
	BOOL  bArrayMessages;
	BOOL	bGagMessages;
	BOOL	bHighMessages;
	BOOL	bSubMessages;
	BOOL	bEnableMessages;
	BOOL	bEcho;					// TRUE it echos text typed to the terminal.
	BOOL	bSpeedWalk;				// TRUE when speedwalking is on.
	int	nPace;					// Delay between executing speedwalk commands.
	BOOL	bPause;					// TRUE to pause each screenfull.
	BOOL	bDoEvents;				// TRUE to process events.
	BOOL	bStatusBar;				// TRUE to display the status bar.
	BOOL	bPreSub;					// TRUE to process subs before actions/gags.
	int	nStatusBarPos;			// Whether above or below in input line.
	BOOL  bCommandPrintOn;		// TRUE when CommandPrintOn() has been called.
	CString strIPAddress;		// IP Address of this machine.
	CString strHostName;			// Host name of this machine.
	BOOL  bDoNotDisturb;			// TRUE when chat requests should be ignored.
	BOOL  bAutoAccept;			// TRUE doesn't ask just accepts chat calls.
	BOOL  bShowInfo;				// When a command file is loaded, if TRUE does a /info.
	CString strDefaultFile;		// Default command file to load.
	BOOL  bMultipleActions;		// When TRUE will parse all actions.  When false, stops looking after first action match.
	int   nUndo;					// Number of undo lines to remember.
	BOOL	bAltGr;					// Treats the right alt key differently when TRUE.
	BOOL  bIgnoreAliases;		// TRUE to turn off alias processing.
	int	nDebugDepth;			// Depth of the stack to spam when an error is hit.
	BOOL	bDebugMessages;		// TRUE to show debug errors.  FALSE will show none.
	BOOL  bShowMismatches;		// TRUE to show mismatches errors in /if.
	BOOL  bDisplayVersionStuff;// TRUE to show status of version checking.
	BOOL	bPromptOverwrite;		// TRUE to prompt before overwriting a command file.
	BOOL	bCheckVersion;			// TRUE to do a version check on startup.
	BOOL	bEchoActions;			// TRUE to echo the text spammed when an action fires.

	// Paths
	CString strUploadPath;
	CString strDownloadPath;
	CString strScriptPath;
	CString strSoundPath;

	// Sounds
	int	nDefaultVolume;		// Default level to play sounds at. 0-100%
	BOOL	bMspOn;					// TRUE when processing MSP strings.
	BOOL  bUsePlaySound;			// TRUE to use the windows API PlaySound.

	// How MM runs.
	BOOL	bWinMessages;			// TRUE to process windows messages.

	// Version Info.  The string is still a define.
	int	nVersionMajor;			// Big functionality changes.
	int	nVersionMinor;			// New functionality.
	int	nVersionBuild;			// Bug fixes, spelling corrections.
	int	nVersionBeta;			// 0 if this isn't a beta version.
	CString strVersion;			// Created from the numbers above.
};

extern CONFIGURATION _config;

// Notification lists.
class CNotifications;
class CNotifyConnect;
class CNotifyDisconnect;
class CNotifyChatConnect;
class CNotifyChatDisconnect;
class CNotifyInput;
class CNotifyRaw;
extern CNotifyConnect			_notifyConnect;
extern CNotifyDisconnect		_notifyDisconnect;
extern CNotifyChatConnect		_notifyChatConnect;
extern CNotifyChatDisconnect	_notifyChatDisconnect;
extern CNotifyInput				_notifyInput;
extern CNotifyRaw					_notifyRaw;

// This is the function the DLL calls to send text to MM's interpreter.
extern "C" void DllCallback(const char *pszText);

// Declaration for user defined DLLs.
typedef VOID (*DLLADDRESSFUNC)(const char *);
typedef VOID (*MYPROC)(const char *pszParams, char *pszResult);
typedef VOID (*DLLCALLBACK)(DLLADDRESSFUNC);
typedef VOID (*CONNECTPROC)(SOCKET hSockt);
typedef VOID (*DISCONNECTPROC)(void);
typedef VOID (*CHATCONNECTPROC)(SOCKET hSocket, const char *pszChatName);
typedef VOID (*CHATDISCONNECTPROC)(SOCKET hSocket, const char *pszChatName);
typedef BOOL (*INPUTPROC)(const char *pszInput);
typedef BOOL (*RAWPROC)(char *pszBuf);

//////////////////////////////////////////////////////////////////
// Command related items.
//
typedef VOID (*COMMANDPROC)(CString &strLine);	// Declaration for a command function.

struct COMMANDLIST
{
	char *szCommand;
	COMMANDPROC proc;
	BOOL bWholeMatch;			// TRUE to require full text match for sensitive commands.
	char *szHelp;
};

// List of all client commands;
extern COMMANDLIST _commandList[];

// Hast table for quick lookups of commands in _commandList.
extern CHashTable _htCommands;

//
//////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////
// Function Declarations.
//

// Main.cpp
extern void CommandPrintOn();
extern void CommandPrintOff();
extern void PrintMessage(const char *pszMessage, BOOL bCR=TRUE, BOOL bNoAction=FALSE);
extern void PrintError();
extern void Connect(const char *pszName, const char *pszAddress, const char *pszPort);
extern void FindStatement(CString &strText, CString &strResult);
extern void SetFocusUserInput();
extern void HandleInput(CString &strLine);
extern void ProcessLine(CString &strLine);
extern void PretranslateString(CString &strLine);
extern void ReplaceVariables(CString &strLine, BOOL bQuoteStrings=FALSE);
extern void SendText(const char *pszText, BOOL bAppendCR=TRUE);
extern BOOL IsNumber(const char *pszText);
extern BOOL IsPartial(const char *pszLookFor, const char *pszText);
extern void WriteIniString(const char *pszSection, const char *pszEntry, const char *pszValue);
extern void WriteIniInt(const char *pszSection, const char *pszEntry, int nValue);
extern CString GetIniString(const char *pszSection, const char *pszEntry, const char *pszDefault);
extern int  GetIniInt(const char *pszSection, const char *pszEntry, int nDefault);
extern void GetIPAddress();
// Takes a windows defined error code and changes it to a string.
extern BOOL ErrorToString(DWORD dwError, CString &strError);

⌨️ 快捷键说明

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