QUEUE.CPP
资源名称:tc3d.zip [点击查看]
上传用户:abcdshs
上传日期:2007-01-07
资源大小:1858k
文件大小:2k
源码类别:
游戏
开发平台:
Visual C++
- // (C) Copyright 1996 by Anthony J. Carin. All Rights Reserved.
- #include "stdafx.h"
- #include "queue.h"
- #include "3dwrap.h"
- void drawqueue::add(qentry *q)
- {
- if (First)
- {
- First->Prev = q;
- q->Next = First;
- }
- First = q;
- }
- void drawqueue::run()
- {
- qentry *Curr = First;
- while (Curr)
- {
- Curr->draw();
- Curr = Curr->Next;
- }
- if (mdead)
- {
- delete mdead;
- mdead = 0;
- }
- }
- void * drawqueue::first(short qtype)
- {
- searchpos = First;
- return next(qtype);
- }
- void * drawqueue::next(short qtype)
- {
- while (searchpos)
- {
- if (searchpos->type() & qtype)
- {
- qentry *tmp = searchpos;
- searchpos = searchpos->Next;
- return (void *) tmp;
- }
- searchpos = searchpos->Next;
- }
- return NULL;
- }
- void drawqueue::purge(queuetype p)
- {
- qentry *Curr = First;
- if (p == NONE)
- {
- while (Curr)
- {
- First = Curr;
- Curr = Curr->Next;
- delete First;
- }
- First = searchpos = 0;
- }
- else
- {
- qentry *Qtmp;
- while (Curr)
- {
- if (Curr->type() == p)
- {
- Qtmp = Curr->Next;
- Curr->detach();
- delete Curr;
- Curr = Qtmp;
- }
- else
- Curr = Curr->Next;
- }
- searchpos = First;
- }
- }
- void qentry::detach()
- {
- if (Game->DrawQueue()->First == this)
- Game->DrawQueue()->First = Next;
- if (Next)
- Next->Prev = Prev;
- if (Prev)
- Prev->Next = Next;
- Next = Prev = 0;
- }