mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-26 12:01:47 +00:00
Only iterate blockmap once for Random Items and Eggboxes.
This commit is contained in:
parent
84f277c323
commit
56226fae45
1 changed files with 8 additions and 37 deletions
45
src/k_bot.c
45
src/k_bot.c
|
|
@ -554,11 +554,12 @@ fixed_t eggboxx, eggboxy;
|
||||||
UINT8 randomitems = 0;
|
UINT8 randomitems = 0;
|
||||||
UINT8 eggboxes = 0;
|
UINT8 eggboxes = 0;
|
||||||
|
|
||||||
static boolean K_FindRandomItems(mobj_t *thing)
|
static boolean K_FindRandomItemsAndEggboxes(mobj_t *thing)
|
||||||
{
|
{
|
||||||
fixed_t dist;
|
fixed_t dist;
|
||||||
|
boolean egg = (thing->type == MT_EGGMANITEM);
|
||||||
|
|
||||||
if (thing->type != MT_RANDOMITEM)
|
if (!egg && thing->type != MT_RANDOMITEM)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -575,32 +576,10 @@ static boolean K_FindRandomItems(mobj_t *thing)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
randomitems++;
|
if (egg)
|
||||||
return true;
|
eggboxes++;
|
||||||
}
|
else
|
||||||
|
randomitems++;
|
||||||
static boolean K_FindEggboxes(mobj_t *thing)
|
|
||||||
{
|
|
||||||
fixed_t dist;
|
|
||||||
|
|
||||||
if (thing->type != MT_EGGMANITEM)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!thing->health)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
dist = P_AproxDistance(thing->x - eggboxx, thing->y - eggboxy);
|
|
||||||
|
|
||||||
if (dist > distancetocheck)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
eggboxes++;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -625,15 +604,7 @@ static UINT8 K_EggboxStealth(fixed_t x, fixed_t y)
|
||||||
{
|
{
|
||||||
for (by = yl; by <= yh; by++)
|
for (by = yl; by <= yh; by++)
|
||||||
{
|
{
|
||||||
P_BlockThingsIterator(bx, by, K_FindRandomItems);
|
P_BlockThingsIterator(bx, by, K_FindRandomItemsAndEggboxes);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (bx = xl; bx <= xh; bx++)
|
|
||||||
{
|
|
||||||
for (by = yl; by <= yh; by++)
|
|
||||||
{
|
|
||||||
P_BlockThingsIterator(bx, by, K_FindEggboxes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue