mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-25 09:11:09 +02:00
Large speed improvement for QRTZ
Also prevent growing when sparked.
This commit is contained in:
committed by
Simon Robertshaw
parent
7750cf8ccd
commit
4fd97b93b4
@@ -12,8 +12,9 @@ int update_QRTZ(UPDATE_FUNC_ARGS) {
|
|||||||
part_change_type(i,x,y,PT_PQRT);
|
part_change_type(i,x,y,PT_PQRT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//new QRTZ growth
|
// absorb SLTW
|
||||||
for (rx=-2; rx<3 && parts[i].ctype!=-1; rx++)
|
if (parts[i].ctype!=-1)
|
||||||
|
for (rx=-2; rx<3; rx++)
|
||||||
for (ry=-2; ry<3; ry++)
|
for (ry=-2; ry<3; ry++)
|
||||||
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
|
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
|
||||||
{
|
{
|
||||||
@@ -26,6 +27,7 @@ int update_QRTZ(UPDATE_FUNC_ARGS) {
|
|||||||
parts[i].ctype ++;
|
parts[i].ctype ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// grow if absorbed SLTW
|
||||||
if (parts[i].ctype>0)
|
if (parts[i].ctype>0)
|
||||||
{
|
{
|
||||||
for ( trade = 0; trade<5; trade ++)
|
for ( trade = 0; trade<5; trade ++)
|
||||||
@@ -38,15 +40,15 @@ int update_QRTZ(UPDATE_FUNC_ARGS) {
|
|||||||
if ((r>>8)<NPART && !r && parts[i].ctype!=0)
|
if ((r>>8)<NPART && !r && parts[i].ctype!=0)
|
||||||
{
|
{
|
||||||
np = create_part(-1,x+rx,y+ry,PT_QRTZ);
|
np = create_part(-1,x+rx,y+ry,PT_QRTZ);
|
||||||
if (np>0)
|
if (np>-1)
|
||||||
{
|
{
|
||||||
parts[np].tmp = parts[i].tmp;
|
parts[np].tmp = parts[i].tmp;
|
||||||
parts[i].ctype = 0;
|
parts[i].ctype--;
|
||||||
if (5>rand()%10)
|
if (5>rand()%10)
|
||||||
{
|
{
|
||||||
parts[np].ctype=-1;//dead qrtz
|
parts[np].ctype=-1;//dead qrtz
|
||||||
}
|
}
|
||||||
else if (1>rand()%15)
|
else if (!parts[i].ctype && 1>rand()%15)
|
||||||
{
|
{
|
||||||
parts[i].ctype=-1;
|
parts[i].ctype=-1;
|
||||||
}
|
}
|
||||||
@@ -57,6 +59,9 @@ int update_QRTZ(UPDATE_FUNC_ARGS) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// diffuse absorbed SLTW
|
||||||
|
if (parts[i].ctype>0)
|
||||||
|
{
|
||||||
for ( trade = 0; trade<9; trade ++)
|
for ( trade = 0; trade<9; trade ++)
|
||||||
{
|
{
|
||||||
rx = rand()%5-2;
|
rx = rand()%5-2;
|
||||||
@@ -66,20 +71,21 @@ int update_QRTZ(UPDATE_FUNC_ARGS) {
|
|||||||
r = pmap[y+ry][x+rx];
|
r = pmap[y+ry][x+rx];
|
||||||
if ((r>>8)>=NPART || !r)
|
if ((r>>8)>=NPART || !r)
|
||||||
continue;
|
continue;
|
||||||
if ((r&0xFF)==t && (parts[i].ctype>parts[r>>8].ctype) && parts[i].ctype>0 && parts[r>>8].ctype>=0 )//diffusion
|
if ((r&0xFF)==t && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 )//diffusion
|
||||||
{
|
{
|
||||||
tmp = parts[i].ctype - parts[r>>8].ctype;
|
tmp = parts[i].ctype - parts[r>>8].ctype;
|
||||||
if (tmp ==1)
|
if (tmp ==1)
|
||||||
{
|
{
|
||||||
parts[r>>8].ctype ++;
|
parts[r>>8].ctype ++;
|
||||||
parts[i].ctype --;
|
parts[i].ctype --;
|
||||||
trade = 9;
|
break;
|
||||||
}
|
}
|
||||||
if (tmp>0)
|
if (tmp>0)
|
||||||
{
|
{
|
||||||
parts[r>>8].ctype += tmp/2;
|
parts[r>>8].ctype += tmp/2;
|
||||||
parts[i].ctype -= tmp/2;
|
parts[i].ctype -= tmp/2;
|
||||||
trade = 9;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
|
|||||||
if (!ct)
|
if (!ct)
|
||||||
ct = PT_METL;
|
ct = PT_METL;
|
||||||
part_change_type(i,x,y,ct);
|
part_change_type(i,x,y,ct);
|
||||||
|
parts[i].ctype = PT_NONE;
|
||||||
parts[i].life = 4;
|
parts[i].life = 4;
|
||||||
if (ct == PT_WATR)
|
if (ct == PT_WATR)
|
||||||
parts[i].life = 64;
|
parts[i].life = 64;
|
||||||
|
Reference in New Issue
Block a user