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

📄 commandsstoz.cpp

📁 MudMaster 2000 的C++源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
{
	CString strIP;
	FindStatement(strLine,strIP);
	ReplaceVariables(strIP);

	if (strIP.IsEmpty())
		return;

	_config.strIPAddress = strIP;

	CString strText;
	strText.Format("IP Address Changed: %s",(const char *)strIP);
	PrintMessage(strText);
}

void ShowMe(CString &strLine)
{
	CString strText;
	FindStatement(strLine,strText);
	ReplaceVariables(strText);
	CommandPrintOn();
	_terminal.Print(strText+"\n");
	CommandPrintOff();
}

void ShowMismatchErrors(CString &strLine)
{
	if (_config.bShowMismatches)
		_config.bShowMismatches = FALSE;
	else
		_config.bShowMismatches = TRUE;
	
	CString strText;
	strText.Format("/if Mismatch errors will %s shown.",
		(_config.bShowMismatches ? "be" : "not be"));
	PrintMessage(strText);
	WriteIniInt("Miscellaneous","Show Mismatches",_config.bShowMismatches);
}

void Snoop(CString &strLine)
{
	CString strName;
	FindStatement(strLine,strName);
	ReplaceVariables(strName);

	CHAT *pChat;
	int nIndex = atoi(strName);
	if (!nIndex)
		pChat = _chat.FindName(strName);
	else
		pChat = _chat.GetAt(nIndex-1);

	if (pChat == NULL)
	{
		PrintMessage("Chat name not found.");
		return;
	}
	else
		_chat.Snoop(pChat);
}

void SoundPath(CString &strLine)
{
	CString strPath;
	FindStatement(strLine,strPath);
	ReplaceVariables(strPath);

	if (!strPath.IsEmpty())
		if (strPath.Right(1) != "\\")
			strPath += "\\";
	_config.strSoundPath = strPath;
	WriteIniString("Paths","Sound",strPath);
	PrintMessage(CString("Sound path changed to: ")+strPath);
}

void SpeedWalk(CString &strLine)
{
	CString strParam1;
	FindStatement(strLine,strParam1);
	strParam1.MakeLower();
	if (strParam1.IsEmpty())
	{
		if (_config.bSpeedWalk)
			_config.bSpeedWalk = FALSE;
		else
			_config.bSpeedWalk = TRUE;
	}
	else
		if (!CString("on").Find(strParam1))
			_config.bSpeedWalk = TRUE;
		else
			if (!CString("off").Find(strParam1))
				_config.bSpeedWalk = FALSE;

	CString strTemp;
	strTemp.Format("Speed walking is %s.",
		(_config.bSpeedWalk ? "on" : "off"));
	PrintMessage(strTemp);
	WriteIniInt("Speed Walking","Enabled",_config.bSpeedWalk);
}

void StatusBar(CString &strLine)
{
	CString strPos;
	FindStatement(strLine,strPos);

	// If no position is given, just toggle it on or off.
	if (strPos.IsEmpty())
	{
		if (_config.bStatusBar)
		{
			_statusBar.HideBar();
			_config.bStatusBar = FALSE;
		}
		else
		{
			_statusBar.ShowBar(_config.nStatusBarPos);
			_config.bStatusBar = TRUE;
		}
		WriteIniInt("Status Bar","Visible",_config.bStatusBar);
		return;
	}

	int nNewPos;
	strPos.MakeLower();
	if (strPos.GetAt(0) == 'a')
		nNewPos = STATUS_BAR_ABOVE;
	else
		nNewPos = STATUS_BAR_BELOW;

	// If it is currently showing and the position is different
	// hide it.
	if (_config.bStatusBar && _config.nStatusBarPos != nNewPos)
	{
		_statusBar.HideBar();
		_config.nStatusBarPos = nNewPos;
	}

	// Display the bar.
	_statusBar.ShowBar(_config.nStatusBarPos);
	_config.bStatusBar = TRUE;

	WriteIniInt("Status Bar","Visible",_config.bStatusBar);
	WriteIniInt("Status Bar","Position",_config.nStatusBarPos);
}

void Substitute(CString &strLine)
{
	CString strParam1, strParam2, strGroup;
	CString strTemp;
	int nSubNum;

	FindStatement(strLine,strParam1);
	FindStatement(strLine,strParam2);
	FindStatement(strLine,strGroup);

	ReplaceVariables(strParam1);
	ReplaceVariables(strGroup);
	PretranslateString(strParam2);

	if (!strParam1.IsEmpty() && !strParam2.IsEmpty())
	{
		nSubNum = _subs.Add(strParam1,strParam2,strGroup);
		if (_config.bSubMessages)
			if (nSubNum)
			{
				strTemp.Format("Substitute added as #%d.",nSubNum);
				PrintMessage(strTemp);
			}
			else
				PrintMessage("Substitute not added.");
		return;
	}

	if (strParam1.IsEmpty() && strParam2.IsEmpty())
	{
		PrintMessage("Defined Subs:");
		CommandPrintOn();

		CString strTemp, strText;
		char *ptr;
		int nResult;
		int nLineCount = 1;
		int nNumLines = _terminal.GetWindowLines()-2;
		int nInc;
		SUB *pSub = _subs.GetFirst();
		while(pSub != NULL)
		{
			_subs.SubToTrigger(pSub,strTemp);
			ptr = strText.GetBuffer(strTemp.GetLength()+pSub->strSub.GetLength()+pSub->strGroup.GetLength()+80);
			nResult = sprintf(ptr,"%s%03d:%s%c{%s} {%s} {%s}\n",
				ANSI_F_BOLDWHITE,
				_subs.GetFindIndex()+1,
				ANSI_RESET,
				(pSub->bEnabled ? ' ' : '*'),
				(const char *)strTemp,
				(const char *)pSub->strSub,
				(const char *)pSub->strGroup);
			strText.ReleaseBuffer(nResult);
			_terminal.Print(strText);
			
			if (_config.bPause)
			{
				nInc = strText.GetLength() / 80 + 1;
				nLineCount += nInc;
				if (nLineCount >= nNumLines)
					if (PausePrompt())
						nLineCount = 0;
					else
						break;
			}

			pSub = _subs.GetNext();
		}
		CommandPrintOff();
		return;
	}

	if (strParam2.IsEmpty())
	{
		PrintMessage("Defined Sub:");
		CString strTemp, strText;
		SUB *pSub = _subs.FindExact(strParam1);
		if (pSub != NULL)
		{
			_subs.SubToTrigger(pSub,strTemp);
			char *ptr = strText.GetBuffer(strTemp.GetLength()+pSub->strSub.GetLength()+pSub->strGroup.GetLength()+80);
			int nResult = sprintf(ptr,"%c{%s} {%s} {%s}\n",
				(pSub->bEnabled ? ' ' : '*'),
				(const char *)strTemp,
				(const char *)pSub->strSub,
				(const char *)pSub->strGroup);
			strText.ReleaseBuffer(nResult);
			CommandPrintOn();
			_terminal.Print(strText);
			CommandPrintOff();
		}
	}
}

void TabAdd(CString &strLine)
{
	CString strParam1, strGroup;
	FindStatement(strLine,strParam1);
	FindStatement(strLine,strGroup);
	if (strParam1.IsEmpty())
		return;
	ReplaceVariables(strParam1);

	if (strParam1.Find(' ') != -1)
	{
		PrintMessage("You cannot have spaces in the tablist.");
		return;
	}

	if (_tabList.Add(strParam1,strGroup))
	{
		if (_config.bTabMessages)
		{
			CString strText;
			char *pBuf = strText.GetBuffer(strParam1.GetLength()+40);
			int nResult = sprintf(pBuf,"\"%s\" added to tab list.",
				(const char *)strParam1);
			strText.ReleaseBuffer(nResult);
			PrintMessage(strText);
		}
	}
}

void TabDelete(CString &strLine)
{
	CString strParam1;
	FindStatement(strLine,strParam1);
	if (strParam1.IsEmpty())
		return;
	ReplaceVariables(strParam1);

	BOOL bResult;
	int nIndex = atoi(strParam1);
	if (nIndex)
		bResult = _tabList.Remove(nIndex-1);
	else
		bResult = _tabList.Remove(strParam1);

	if (bResult && _config.bTabMessages)
		PrintMessage("Word removed from tab list.");
}

void TabList(CString &strLine)
{
	PrintMessage("Tab List:");
	CommandPrintOn();
	CString strText;
	char *pBuf;
	int nResult;
	int nLineCount = 1;
	int nNumLines = _terminal.GetWindowLines()-2;
	int nInc;
	TAB *pTab = _tabList.GetFirst();
	while(pTab != NULL)
	{
		pBuf = strText.GetBuffer(pTab->strText.GetLength()+pTab->strGroup.GetLength()+40);
		nResult = sprintf(pBuf,"%s%03d:%s {%s} {%s}\n",
			ANSI_F_BOLDWHITE,
			_tabList.GetFindIndex()+1,
			ANSI_RESET,
			(const char *)pTab->strText,
			(const char *)pTab->strGroup);
		strText.ReleaseBuffer(nResult);
		_terminal.Print(strText);

		if (_config.bPause)
		{
			nInc = strText.GetLength() / 80 + 1;
			nLineCount += nInc;
			if (nLineCount >= nNumLines)
				if (PausePrompt())
					nLineCount = 0;
				else
					break;
		}
		
		pTab = _tabList.GetNext();
	}
	CommandPrintOff();
}

void TextIn(CString &strLine)
{
	CString strFilename;
	FindStatement(strLine,strFilename);

	ReplaceVariables(strFilename);
	if (strFilename.IsEmpty())
		return;

	CStdioFileFixed file;
	if (!file.Open(strFilename,CFile::modeRead))
		return;

	//CommandPrintOn();

	CString strText;
	while(file.ReadString(strText))
	{
		_terminal.Print(strText+"\n");
		SendText(strText);
	}
	file.Close();

//	CommandPrintOff();
}

void UnAction(CString &strLine)
{
	CString strParam1;
	FindStatement(strLine,strParam1);
	if (strParam1.IsEmpty())
		return;
	ReplaceVariables(strParam1);

	BOOL bResult;
	ACTION *pAct;
	int nIndex = atoi(strParam1);
	if (nIndex)
		pAct = _actions.GetAt(nIndex-1);
	else
		pAct = _actions.FindExact(strParam1);

	if (pAct != NULL)
	{
		CString strTemp, strText;
		char *pBuf;
		int nResult;

		_actions.ActionToTrigger(pAct,strTemp);
		pBuf = strText.GetBuffer(strTemp.GetLength()+pAct->strAction.GetLength()+pAct->strGroup.GetLength()+40);
		nResult = sprintf(pBuf,"%caction {%s} {%s} {%s}",
			_config.chCommand,
			(const char *)strTemp,
			(const char *)pAct->strAction,
			(const char *)pAct->strGroup);
		strText.ReleaseBuffer(nResult);
		_undo.Add(strText);

		if (nIndex)
			bResult = _actions.Remove(nIndex-1);
		else
			bResult = _actions.Remove(strParam1);
	}
	else
		bResult = FALSE;

	if (bResult)
	{
		if (_config.bActionMessages)
			PrintMessage("Action removed.");
	}
	else
	{
		if (_config.bActionMessages)
			PrintMessage("Action not found.");
	}
}

void UnAlias(CString &strLine)
{
	CString strParam1;
	FindStatement(strLine,strParam1);
	if (strParam1.IsEmpty())
		return;
	ReplaceVariables(strParam1);

	BOOL bResult;
	ALIAS_MAP *pAlias;
	int nIndex = atoi(strParam1);
	if (nIndex)
		pAlias = _aliases.GetAt(nIndex-1);
	else
		pAlias = _aliases.FindExact(strParam1);

	if (pAlias != NULL)
	{
		CString strText;
		_aliases.MapToCommand(pAlias,strText);
		_undo.Add(strText);

		if (nIndex)
			bResult = _aliases.Remove(nIndex-1);
		else
			bResult = _aliases.Remove(strParam1);
	}
	else
		bResult = FALSE;
	
	if (bResult)
	{
		if (_config.bAliasMessages)
			PrintMessage("Alias removed.");
	}
	else
	{
		if (_config.bAliasMessages)
			PrintMessage("Alias not found.");
	}
}

void UnArray(CString &strLine)
{
	CString strArray;
	FindStatement(strLine,strArray);
	if (strArray.IsEmpty())
		return;
	ReplaceVariables(strArray);

	BOOL bResult;
	int nIndex = atoi(strArray);
	if (nIndex)
		bResult = _arrays.Remove(nIndex-1);
	else
		bResult = _arrays.Remove(strArray);

	if (_config.bArrayMessages)
		if (bResult)
			PrintMessage("Array removed.");
		else
			PrintMessage("Array not removed.");
}

void UnBarItem(CString &strLine)
{
	CString strParam1;
	FindStatement(strLine,strParam1);
	if (strParam1.IsEmpty())
		return;
	ReplaceVariables(strParam1);

	BOOL bResult;
	BAR_ITEM *pItem;
	int nIndex = atoi(strParam1);
	if (nIndex)
		pItem = _statusBar.GetAt(nIndex-1);
	else
		pItem = _statusBar.FindItem(strParam1);
	if (pItem != NULL)
	{
		char *pBuf;
		CString strText;
		int nResult;

		if (pItem->bSeparator)
		{
			pBuf = strText.GetBuffer(pItem->strItem.GetLength()+pItem->strGroup.GetLength()+40);
			nResult = sprintf(pBuf,"%cbarseparator {%s} {%d} {%s}",
				_config.chCommand,
				(const char *)pItem->strItem,
				pItem->nPos,
				(const char *)pItem->strGroup);
			strText.ReleaseBuffer(nResult);
		}
		else
		{
			pBuf = strText.GetBuffer(pItem->strItem.GetLength()+pItem->strText.GetLength()+pItem->strGroup.GetLength()+80);
			nResult = sprintf(pBuf,"%cbaritem {%s} {%s} {%d} {%d} {%d} {%d} {%s}",
				_config.chCommand,
				(const char *)pItem->strItem,
				(const char *)pItem->strText,
				pItem->nPos,
				pItem->nLen,
				pItem->nFore,
				pItem->nBack,
				pItem->strGroup);
			strText.ReleaseBuffer(nResult);
		}
		_undo.Add(strText);

		if (nIndex)
			bResult = _statusBar.Remove(nIndex-1);
		else
			bResult = _statusBar.Remove(strParam1);

⌨️ 快捷键说明

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