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

📄 qvstate.cpp

📁 Windows上的MUD客户端程序
💻 CPP
字号:
#include <QvState.h>
#if defined(CH_MSW)
#include <windows.h>
#endif

const char *QvState::stackNames[NumStacks] = {
    "Camera",
    "Coordinate3",
    "Light",
    "MaterialBinding",
    "Material",
    "NormalBinding",
    "Normal",
    "ShapeHints",
    "Texture2",
    "Texture2Transformation",
    "TextureCoordinate2",
    "Transformation",
};

QvState::QvState()
{
    stacks = new QvElement * [NumStacks];

    for (int i = 0; i < NumStacks; i++)
	stacks[i] = NULL;

    depth = 0;
}

QvState::~QvState()
{
    while (depth > 0)
	pop();

    delete [] stacks;
}

void
QvState::addElement(StackIndex stackIndex, QvElement *elt)
{
    elt->depth = depth;
    elt->next = stacks[stackIndex];
    stacks[stackIndex] = elt;
}

void
QvState::push()
{
    depth++;
}

void
QvState::pop()
{
    depth--;

    for (int i = 0; i < NumStacks; i++)
	while (stacks[i] != NULL && stacks[i]->depth > depth)
	    popElement((StackIndex) i);
}

void
QvState::popElement(StackIndex stackIndex)
{
    QvElement *elt = stacks[stackIndex];
    stacks[stackIndex] = elt->next;
    delete elt;
}

void
QvState::print()
{
 	#if 0
   //OutputDebugString("Traversal state:\r\n");
    //TRACE("Traversal state:\r\n");
    for (int i = 0; i < NumStacks; i++) {
	char buf[500];
	wsprintf(buf, "\tStack [%2d] (%s):\r\n", i, stackNames[i]);
	//OutputDebugString(buf);
	TRACE(buf);
	if (stacks[i] == NULL)
	    //OutputDebugString("\t\tNULL\r\n");
	    TRACE("\t\tNULL\r\n");

	else
	    for (QvElement *elt = stacks[i]; elt != NULL; elt = elt->next)
		elt->print();
    }
	#endif
}

⌨️ 快捷键说明

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