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

📄 commandsatof.cpp

📁 MudMaster 2000 的C++源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
				nResult = sprintf(pBuf,"%s%03d:%s%c{Pos:%2d} {Len:%2d} {%s} {%s} {Fore:%d} {Back:%d} {%s}\n",
					ANSI_F_BOLDWHITE,
					_statusBar.GetFindIndex()+1,
					ANSI_RESET,
					(pItem->bEnabled ? ' ' : '*'),
					pItem->nPos,
					pItem->nLen,
					(const char *)pItem->strItem,
					(const char *)pItem->strText,
					pItem->nFore,
					pItem->nBack,
					(const char *)pItem->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;
			}
			
			pItem = _statusBar.GetNext();
		}
		CommandPrintOff();
		return;
	}

	ReplaceVariables(strItem);
	PretranslateString(strText);
	ReplaceVariables(strPos);
	ReplaceVariables(strLen);
	ReplaceVariables(strFore);
	ReplaceVariables(strBack);

	if (strItem.IsEmpty() || strText.IsEmpty())
		return;

	int nPos = atoi(strPos);
	int nLen = atoi(strLen);

	if (nPos < 1 || nPos > 80 || nLen < 1 || nLen > 80)
		return;

	nItemNum = _statusBar.AddBarItem(strItem,strText,nPos,nLen,atoi(strFore),atoi(strBack),strGroup);
	if (nItemNum && _config.bStatusBar)
		_statusBar.Redraw();
	if (_config.bBarMessages)
		if (nItemNum)
		{
			strTemp.Format("Bar item added as #%d.",nItemNum);
			PrintMessage(strTemp);
		}
		else
			PrintMessage("Bar item not added.");
}

void BarItemBack(CString &strLine)
{
	CString strParam1, strColor;
	FindStatement(strLine,strParam1);
	FindStatement(strLine,strColor);
	if (strParam1.IsEmpty())
		return;

	ReplaceVariables(strParam1);
	ReplaceVariables(strColor);

	BAR_ITEM *pItem;
	int nIndex = atoi(strParam1);
	if (nIndex)
		pItem = _statusBar.GetAt(nIndex-1);
	else
		pItem = _statusBar.FindItem(strParam1);
	
	if (pItem != NULL)
	{
		_tiUserInput.HideCursor();
		_statusBar.SetBarItemBack(pItem,atoi(strColor));
		_tiUserInput.SetFocus();
		_tiUserInput.ShowCursor();
	}
}

void BarItemFore(CString &strLine)
{
	CString strParam1, strColor;
	FindStatement(strLine,strParam1);
	FindStatement(strLine,strColor);
	if (strParam1.IsEmpty())
		return;

	ReplaceVariables(strParam1);
	ReplaceVariables(strColor);

	BAR_ITEM *pItem;
	int nIndex = atoi(strParam1);
	if (nIndex)
		pItem = _statusBar.GetAt(nIndex-1);
	else
		pItem = _statusBar.FindItem(strParam1);
	
	if (pItem != NULL)
	{
		_tiUserInput.HideCursor();
		_statusBar.SetBarItemFore(pItem,atoi(strColor));
		_tiUserInput.SetFocus();
		_tiUserInput.ShowCursor();
	}
}

void BarItemShift(CString &strLine)
{
	CString strStart, strEnd, strNum;
	FindStatement(strLine,strStart);
	FindStatement(strLine,strEnd);
	FindStatement(strLine,strNum);

	ReplaceVariables(strStart);
	ReplaceVariables(strEnd);
	ReplaceVariables(strNum);

	_statusBar.ShiftItems(atoi(strStart)-1,atoi(strEnd)-1,atoi(strNum));
	_statusBar.Redraw();
}

void BarSeparator(CString &strLine)
{
	CString strItem, strPos, strGroup;
	CString strTemp;
	int nItemNum;

	FindStatement(strLine,strItem);
	FindStatement(strLine,strPos);
	FindStatement(strLine,strGroup);

	ReplaceVariables(strItem);
	ReplaceVariables(strPos);

	if (strItem.IsEmpty() || strPos.IsEmpty())
		return;

	int nPos = atoi(strPos);
	if (nPos < 1 || nPos > 80)
		return;

	nItemNum = _statusBar.AddSeparator(strItem,nPos,strGroup);
	if (_config.bBarMessages)
		if (nItemNum)
		{
			strTemp.Format("Separator added as #%d.",nItemNum);
			PrintMessage(strTemp);
			if (_config.bStatusBar)
				_statusBar.Redraw();
		}
		else
			PrintMessage("Spearator Not Added");
}

void Bell(CString &strLine)
{
	MessageBeep(0xFFFFFFFF);
}

void CacheSize(CString &strLine)
{
	long lSize = atol(strLine);
	if (lSize < 0)
		lSize = 0;
	_sound.SetCacheSize(lSize);
	WriteIniInt("Sounds","Cache",lSize);
}

void Call(CString &strLine)
{
	if (_chat.GetChatName().IsEmpty())
	{
		PrintMessage("You need to set your chat name first.");
		return;
	}

	CString strAddress;
	CString strPort;
	FindStatement(strLine,strAddress);
	FindStatement(strLine,strPort);

	ReplaceVariables(strAddress);
	ReplaceVariables(strPort);
	strPort.TrimRight();
	strAddress.TrimRight();
	strAddress.TrimLeft();

	int nPort = atoi(strPort);
	if (!nPort)
		nPort = 4050;
	if (_chat.FindAddress(strAddress,nPort) == NULL)
	{
		int nResult = _chat.Connect(strAddress,nPort);
		switch(nResult)
		{
			case CHAT_ACCEPT_SUCCESS :
				PrintMessage("Chat connected.");
				break;

			case CHAT_ACCEPT_FAILED :
				PrintMessage("Chat connection failed.");
				break;
		}
	}
	else
	{
		CString strText;
		strText.Format("You are already connected with: %s:%d",
			(const char *)strAddress,nPort);
		PrintMessage(strText);
	}
}

void CallDLL(CString &strLine)
{
	CString strLib;
	CString strFunction;
	CString strParams;
	FindStatement(strLine,strLib);
	FindStatement(strLine,strFunction);
	FindStatement(strLine,strParams);

	ReplaceVariables(strLib);
	ReplaceVariables(strFunction);
	ReplaceVariables(strParams);

	DLL *pDll = _dlls.FindExact(strLib);
	if (pDll == NULL)
	{
		PrintMessage("DLL not found.");
		return;
	}

	// Make it a 0 length string so the proc called can just leave
	// it blank if it wants to.
	*_pszDLLResult = '\x0';
	MYPROC proc = (MYPROC)GetProcAddress(pDll->hDLL,strFunction);
	if (proc == NULL)
	{
		PrintMessage("Procedure not found.");
		return;
	}

	(proc)((const char *)strParams,_pszDLLResult);

	if (strlen(_pszDLLResult))
	{
		CString strTemp(_pszDLLResult);
		_debugStack.Push(0,STACK_TYPE_DLL_RETURN);
		HandleInput(strTemp);
		_debugStack.Pop();
	}
}

void Char(CString &strLine)
{
	CString strChar;
	FindStatement(strLine,strChar);

	if (!strChar.IsEmpty())
		_config.chCommand = strChar.GetAt(0);
	CString strText;
	strText.Format("Command character is: %c",_config.chCommand);
	PrintMessage(strText);
}

void Chat(CString &strLine)
{
	CString strName;
	FindStatement(strLine,strName);

	ReplaceVariables(strName);
	ReplaceVariables(strLine);

	if (strName.IsEmpty())
	{
		PrintMessage("Chat Connections:\n");
		CommandPrintOn();
		_terminal.Print("     Name                 Address         Port  Group           Flags\n");
		_terminal.Print("     ==================== =============== ===== =============== =======\n");

		CString strText;
		CString strFlags;
		CString strName;
		char *pBuf;
		int nNamePad;
		int nResult;
		int nLineCount = 1;
		int nNumLines = _terminal.GetWindowLines()-2;
		int nInc;
		CHAT *pChat = _chat.GetFirst();
		while(pChat != NULL)
		{
			if (pChat->nDndId == 0)
			{
				strFlags.Format("%c%c%c%c%c%c%c",
					(pChat->bCommands ? 'A' : ' '),
					(pChat->bTransfers ? 'T' : ' '),
					(pChat->bPrivate ? 'P' : ' '),
					(pChat->bIgnore ? 'I' : ' '),
					(pChat->bServe ? 'S' : ' '),
					(pChat->strAddress != pChat->strSockAddress ? 'F' : ' '),
					(pChat->bSnooped ? 'N' : (pChat->bAllowSnoop ? 'n' : ' ')));

				// Color the name to reflect the status of a transfer.
				switch(pChat->nTransferType)
				{
					case CHAT_TRANSFER_NONE :
						strName = (pChat->strName.GetLength() > 20 ? pChat->strName.Left(20) : pChat->strName);
						break;

					case CHAT_TRANSFER_SEND :
						strName.Format("\x1b[1;32m%s\x1b[0;37m",(pChat->strName.GetLength() > 20 ? (const char *)pChat->strName.Left(20) : (const char *)pChat->strName));
						break;

					case CHAT_TRANSFER_RECEIVE :
						strName.Format("\x1b[1;34m%s\x1b[0;37m",(pChat->strName.GetLength() > 20 ? (const char *)pChat->strName.Left(20) : (const char *)pChat->strName));
						break;
				}

				// Figure out the padding of the name.
				nNamePad = 20 - pChat->strName.GetLength();
				if (nNamePad > 0)
					strName += CString(' ',nNamePad);

				pBuf = strText.GetBuffer(strName.GetLength()+pChat->strAddress.GetLength()+pChat->strGroup.GetLength()+strFlags.GetLength()+80);
				nResult = sprintf(pBuf,"%s%03d:%s %s %-15s %-5d %-15s %s\n",
					ANSI_F_BOLDWHITE,
					_chat.GetFindIndex()+1,
					ANSI_RESET,
					(const char *)strName,
					(const char *)pChat->strAddress,
					pChat->nPort,
					(const char *)pChat->strGroup,
					(const char *)strFlags);
				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;
				}
			}

			pChat = _chat.GetNext();
		}

		_terminal.Print("\nFlags: A - Allow Commands, F - Firewall, I - Ignore, n - Allow Snooping,\n"
			               "       N - Being Snooped, P - Private, S - Serving, T - Allows File Transfers\n");

		CommandPrintOff();
		return;
	}

	if (strLine.IsEmpty())
		return;

	BOOL bResult;
	int nIndex = atoi(strName);
	if (!nIndex)
		bResult = _chat.SendChatToPerson(strName,strLine);
	else
		bResult = _chat.SendChatToPerson(nIndex-1,strLine);

	if (!bResult)
		PrintMessage("Chat name not found.");
}

void ChatAll(CString &strLine)
{
	if (_chat.GetCount() < 1)
	{
		PrintMessage("You don't have any chat connections.");
		return;
	}
	ReplaceVariables(strLine);

	if (strLine.IsEmpty())
		return;

	_chat.SendChatToEverybody(strLine);
}

void ChatBack(CString &strLine)
{
	CString strBack;
	FindStatement(strLine,strBack);
	if (strBack.IsEmpty())
		return;

	ReplaceVariables(strBack);
	int nBack = atoi(strBack);
	_chat.SetBack(nBack);
	WriteIniInt("Chat","Back Color",nBack);
}

void ChatCommands(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;
	}

	if (pChat->bCommands)
	{
		CString strText;
		strText.Format("No longer accepting commands from %s.",(const char *)pChat->strName);
		PrintMessage(strText);
		pChat->bCommands = FALSE;
		strText.Format("\n<CHAT> %s is no longer accepting commands from you.\n",
			(const char *)_chat.GetChatName());
		_chat.SendMessage(pChat,strText);
	}
	else
	{
		CString strText;
		strText.Format("Now accepting commands from %s.",(const char *)pChat->strName);
		PrintMessage(strText);
		pChat->bCommands = TRUE;
		strText.Format("\n<CHAT> %s is now accepting commands from you.\n",
			(const char *)_chat.GetChatName());
		_chat.SendMessage(pChat,strText);
	}
}

void ChatFore(CString &strLine)
{
	CString strFore;
	FindStatement(strLine,strFore);
	if (strFore.IsEmpty())
		return;

	ReplaceVariables(strFore);
	int nFore = atoi(strFore);
	_chat.SetFore(nFore);
	WriteIniInt("Chat","Fore Color",nFore);
}

void ChatGroupRemove(CString &strLine)
{
	CString strGroup;
	CString strName;
	FindStatement(strLine,strName);
	FindStatement(strLine,strGroup);

	ReplaceVariables(strName);
	ReplaceVariables(strGroup);

	if (strName.IsEmpty() || strGroup.IsEmpty())
		return;

	BOOL bResult;
	int nIndex = atoi(strName);
	if (!nIndex)
		bResult = _chat.RemoveGroup(strName);
	else
		bResult = _chat.RemoveGroup(nIndex-1);

	if (!bResult)
		PrintMessage("Chat name not found.");
	else
		PrintMessage("Chat group removed.");
}

void ChatGroupSet(CString &strLine)
{
	CString strGroup;
	CString strName;
	FindStatement(strLine,strName);
	FindStatement(strLine,strGroup);

	ReplaceVariables(strName);

⌨️ 快捷键说明

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