mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
- added sprite iterator classes.
The code base currently contains roughly 600 iterator loops directly referencing Build's global variables. That state of things is not refactorable - these iterator wrappers are supposed to get rid of these explicit references.
This commit is contained in:
parent
bca29ed402
commit
b6149f88f7
1 changed files with 62 additions and 0 deletions
|
@ -995,4 +995,66 @@ extern void(*PolymostProcessVoxels_Callback)(void);
|
|||
#endif
|
||||
|
||||
|
||||
class StatIterator
|
||||
{
|
||||
int next;
|
||||
public:
|
||||
StatIterator(int stat)
|
||||
{
|
||||
assert(stat >= 0 && stat < MAXSTATUS);
|
||||
next = headspritestat[stat];
|
||||
}
|
||||
|
||||
void Reset(int stat)
|
||||
{
|
||||
assert(stat >= 0 && stat < MAXSTATUS);
|
||||
next = headspritestat[stat];
|
||||
}
|
||||
|
||||
int NextIndex()
|
||||
{
|
||||
int n = next;
|
||||
next = nextspritestat[next];
|
||||
return n;
|
||||
}
|
||||
|
||||
spritetype *Next()
|
||||
{
|
||||
int n = next;
|
||||
next = nextspritestat[next];
|
||||
return n < 0? nullptr : &sprite[n];
|
||||
}
|
||||
};
|
||||
|
||||
class SectIterator
|
||||
{
|
||||
int next;
|
||||
public:
|
||||
SectIterator(int stat)
|
||||
{
|
||||
assert(stat >= 0 && stat < MAXSECTORS);
|
||||
next = headspritesect[stat];
|
||||
}
|
||||
|
||||
void Reset(int stat)
|
||||
{
|
||||
assert(stat >= 0 && stat < MAXSECTORS);
|
||||
next = headspritesect[stat];
|
||||
}
|
||||
|
||||
int NextIndex()
|
||||
{
|
||||
int n = next;
|
||||
next = nextspritesect[next];
|
||||
return n;
|
||||
}
|
||||
|
||||
spritetype *Next()
|
||||
{
|
||||
int n = next;
|
||||
next = nextspritestat[next];
|
||||
return n < 0? nullptr : &sprite[n];
|
||||
}
|
||||
};
|
||||
|
||||
#endif // build_h_
|
||||
|
|
Loading…
Reference in a new issue