コード例 #1
0
ファイル: console.cpp プロジェクト: VoiDeD/metamod-source
void SMConVarAccessor::Unregister(ConCommandBase *pCommand)
{
#if SOURCE_ENGINE >= SE_ORANGEBOX
	icvar->UnregisterConCommand(pCommand);
#else
	ConCommandBase *pCur = NULL;
	ConCommandBase *pPrev = NULL;

	if (!pCommand)
	{
		return;
	}

	pCur = icvar->GetCommands();

	if (!m_TopConCommandBase || !pCur)
	{
		return;
	}

	if (pCur == pCommand)
	{
		*m_TopConCommandBase = const_cast<ConCommandBase *>(pCommand->GetNext());
		pCommand->SetNext(NULL);
		return;
	}
	
	pPrev = pCur;
	pCur = const_cast<ConCommandBase *>(pCur->GetNext());

	while (pCur)
	{
		if (pCur == pCommand)
		{
			pPrev->SetNext(const_cast<ConCommandBase *>(pCommand->GetNext()));
			pCommand->SetNext(NULL);
		}

		pPrev = pCur;
		pCur = const_cast<ConCommandBase *>(pCur->GetNext());
	}
#endif
}
コード例 #2
0
void SMConVarAccessor::Unregister(ConCommandBase *pCommand)
{
	ConCommandBase *pCur = NULL;
	ConCommandBase *pPrev = NULL;

	if (!pCommand || !pCommand->IsRegistered())
	{
		return;
	}

	pCur = g_Engine.icvar->GetCommands();
	pCommand->SetRegistered(false);

	if (!m_TopConCommandBase || !pCur)
	{
		return;
	}

	if (pCur == pCommand)
	{
		*m_TopConCommandBase = const_cast<ConCommandBase *>(pCommand->GetNext());
		pCommand->SetNext(NULL);
		return;
	}
	
	pPrev = pCur;
	pCur = const_cast<ConCommandBase *>(pCur->GetNext());

	while (pCur)
	{
		if (pCur == pCommand)
		{
			pPrev->SetNext(const_cast<ConCommandBase *>(pCommand->GetNext()));
			pCommand->SetNext(NULL);
		}

		pPrev = pCur;
		pCur = const_cast<ConCommandBase *>(pCur->GetNext());
	}
}