mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-19 15:11:04 +00:00
- replaced some full loops over the sprite array with iterators.
This commit is contained in:
parent
a0b13ce785
commit
a418d8b53e
5 changed files with 32 additions and 21 deletions
|
@ -383,14 +383,17 @@ static void goblinWar(PLAYER& plr, DWHActor* actor)
|
|||
{
|
||||
int olddist = 1024 << 4;
|
||||
boolean found = false;
|
||||
for (k = 0; k < MAXSPRITES; k++) {
|
||||
if (sprite[k].picnum == GOBLIN && spr.pal != sprite[k].pal && spr.hitag == sprite[k].hitag) {
|
||||
int dist = abs(spr.x - sprite[k].x) + abs(spr.y - sprite[k].y);
|
||||
WHSpriteIterator it;
|
||||
while (auto itActor = it.Next())
|
||||
{
|
||||
auto& spk = itActor->s();
|
||||
if (spk.picnum == GOBLIN && spr.pal != spk.pal && spr.hitag == spk.hitag) {
|
||||
int dist = abs(spr.x - spk.x) + abs(spr.y - spk.y);
|
||||
if (dist < olddist) {
|
||||
found = true;
|
||||
olddist = dist;
|
||||
spr.owner = k;
|
||||
spr.ang = getangle(sprite[k].x - spr.x, sprite[k].y - spr.y);
|
||||
spr.owner = itActor->GetSpriteIndex();
|
||||
spr.ang = getangle(spk.x - spr.x, spk.y - spr.y);
|
||||
spr.extra = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -235,12 +235,15 @@ static void castkatie(PLAYER& plr, DWHActor* actor)
|
|||
|
||||
if (spr.picnum == KATIEAT + 6) {
|
||||
if (spr.extra == 1) {
|
||||
for (short j = 0; j < MAXSPRITES; j++) {
|
||||
if (sprite[j].pal == 8) {
|
||||
sprite[j].picnum--;
|
||||
sprite[j].pal = 0;
|
||||
sprite[j].shade = 0;
|
||||
changespritestat(j, FACE);
|
||||
WHSpriteIterator it;
|
||||
while (auto itActor = it.Next())
|
||||
{
|
||||
auto& spk = itActor->s();
|
||||
if (spk.pal == 8) {
|
||||
spk.picnum--;
|
||||
spk.pal = 0;
|
||||
spk.shade = 0;
|
||||
ChangeActorStat(itActor, FACE);
|
||||
}
|
||||
}
|
||||
spr.picnum = KATIE;
|
||||
|
|
|
@ -648,9 +648,10 @@ bool playrunning()
|
|||
|
||||
static void recordoldspritepos()
|
||||
{
|
||||
for (int i = 0; i < MAXSPRITES; i++)
|
||||
WHSpriteIterator it;
|
||||
while (auto itActor = it.Next())
|
||||
{
|
||||
sprite[i].backuploc();
|
||||
itActor->s().backuploc();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,9 +70,10 @@ void precacheTiles()
|
|||
addTile(wall[i].overpicnum);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < MAXSPRITES; i++) {
|
||||
if (sprite[i].statnum < MAXSTATUS)
|
||||
cachespritenum(i);
|
||||
WHSpriteIterator it;
|
||||
while (auto itActor = it.Next())
|
||||
{
|
||||
cachespritenum(itActor->GetSpriteIndex());
|
||||
}
|
||||
|
||||
addTile(BAT);
|
||||
|
|
|
@ -941,11 +941,14 @@ void cracks() {
|
|||
|
||||
if (datag == 3001) {
|
||||
sector[plr.sector].lotag = 0;
|
||||
for (short k = 0; k < MAXSPRITES; k++) {
|
||||
if (sector[plr.sector].hitag == sprite[k].hitag) {
|
||||
sprite[k].lotag = 36;
|
||||
sprite[k].zvel = (short) (krand() & 1024 + 512);
|
||||
newstatus(k, SHOVE);
|
||||
WHSpriteIterator it;
|
||||
while (auto itActor = it.Next())
|
||||
{
|
||||
auto& spk = itActor->s();
|
||||
if (sector[plr.sector].hitag == spk.hitag) {
|
||||
spk.lotag = 36;
|
||||
spk.zvel = (short) (krand() & 1024 + 512);
|
||||
SetNewStatus(itActor, SHOVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue