Remove blocking walls from pmap

2.5% speed increase on a screen full of water
This commit is contained in:
jacksonmj 2011-08-24 23:35:52 +08:00 committed by Simon Robertshaw
parent f97e8e5c7c
commit 42cfb74c2b
68 changed files with 132 additions and 166 deletions

View File

@ -56,7 +56,7 @@ int console_parse_partref(char *txt, int *which, char *err)
if (strchr(txt,',') && console_parse_coords(txt, &nx, &ny, err))
{
i = pmap[ny][nx];
if (!i || (i>>8)>=NPART)
if (!i)
i = -1;
else
i = i>>8;

View File

@ -8,7 +8,7 @@ int update_O2(UPDATE_FUNC_ARGS)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_FIRE)

View File

@ -7,7 +7,7 @@ int update_ACID(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)!=PT_ACID)
{

View File

@ -7,7 +7,7 @@ int update_AMTR(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)!=PT_AMTR && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_NONE && (r&0xFF)!=PT_PHOT && (r&0xFF)!=PT_VOID && (r&0xFF)!=PT_BHOL && (r&0xFF)!=PT_NBHL && (r&0xFF)!=PT_PRTI && (r&0xFF)!=PT_PRTO)
{

View File

@ -10,7 +10,7 @@ int update_ANAR(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_HFLM)
{

View File

@ -9,7 +9,7 @@ int update_ARAY(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_SPRK) {
int destroy = (parts[r>>8].ctype==PT_PSCN)?1:0;
@ -19,7 +19,6 @@ int update_ARAY(UPDATE_FUNC_ARGS) {
break;
}
r = pmap[y+nyi+nyy][x+nxi+nxx];
if (!((r>>8)>=NPART)) {
if (!r) {
int nr = create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_BRAY);
if (nr!=-1) {
@ -49,7 +48,7 @@ int update_ARAY(UPDATE_FUNC_ARGS) {
if (nyy!=0 || nxx!=0) {
create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_SPRK);
}
//if (!(nostop && (ptypes[r&0xFF].properties&PROP_CONDUCTS))) {//don't need to check r&0xFF<PT_NUM here because it should have been excluded by (r>>8)>=NPART //Not sure why you changed checking "ctype" to "type"
//if (!(nostop && (ptypes[r&0xFF].properties&PROP_CONDUCTS))) {
if (!(nostop && parts[r>>8].ctype >= 0 && parts[r>>8].ctype < PT_NUM && (ptypes[parts[r>>8].ctype].properties&PROP_CONDUCTS))) {
docontinue = 0;
} else {
@ -69,7 +68,6 @@ int update_ARAY(UPDATE_FUNC_ARGS) {
}
}
}
}
//parts[i].life = 4;
}
}

View File

@ -17,9 +17,9 @@ int update_BCLN(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES)
{
r = photons[y+ry][x+rx];
if (!r || (r>>8)>=NPART)
if (!r)
r = pmap[y+ry][x+rx];
if (!r || (r>>8)>=NPART)
if (!r)
continue;
if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN &&
(r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM &&

View File

@ -15,7 +15,7 @@ int update_BCOL(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500))
{
@ -42,7 +42,7 @@ int update_BCOL(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (((r&0xFF)==PT_COAL || (r&0xFF)==PT_BCOL)&&(parts[i].tmp2>parts[r>>8].tmp2)&&parts[i].tmp2>0)//diffusion
{

View File

@ -9,7 +9,7 @@ int update_BMTL(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
rt = parts[r>>8].type;
if ((rt==PT_METL || rt==PT_IRON) && 1>(rand()/(RAND_MAX/100)))

View File

@ -8,7 +8,7 @@ int update_BOMB(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)!=PT_BOMB) {
kill_part(i);
@ -21,7 +21,7 @@ int update_BOMB(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_BCLN) {
int rad = 8;

View File

@ -26,7 +26,7 @@ int update_BOYL(UPDATE_FUNC_ARGS) {
x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_WATR && 1>rand()%30)
{

View File

@ -7,7 +7,7 @@ int update_BTRY(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
rt = parts[r>>8].type;
if (parts_avg(i,r>>8,PT_INSL) != PT_INSL)

View File

@ -7,7 +7,7 @@ int update_C5(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (((r&0xFF)!=PT_C5 && parts[r>>8].temp<100)||(r&0xFF)==PT_HFLM)
{

View File

@ -9,9 +9,9 @@ int update_CLNE(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES)
{
r = photons[y+ry][x+rx];
if (!r || (r>>8)>=NPART)
if (!r)
r = pmap[y+ry][x+rx];
if (!r || (r>>8)>=NPART)
if (!r)
continue;
if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN &&
(r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM &&

View File

@ -8,7 +8,7 @@ int update_CLST(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_WATR && 1>(rand()%1500))
{

View File

@ -22,7 +22,7 @@ int update_COAL(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500))
{
@ -49,7 +49,7 @@ int update_COAL(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (((r&0xFF)==PT_COAL || (r&0xFF)==PT_BCOL)&&(parts[i].tmp2>parts[r>>8].tmp2)&&parts[i].tmp2>0)//diffusion
{

View File

@ -12,7 +12,7 @@ int update_DEUT(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r || (parts[i].life >=maxlife))
if (!r || (parts[i].life >=maxlife))
continue;
if ((r&0xFF)==PT_DEUT&&33>=rand()/(RAND_MAX/100)+1)
{
@ -30,7 +30,7 @@ int update_DEUT(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || (parts[i].life<=maxlife))
if (parts[i].life<=maxlife)
continue;
if ((bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALLELEC||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_EWALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_DESTROYALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALL||
bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWAIR||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWSOLID||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWGAS))
@ -51,7 +51,7 @@ int update_DEUT(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_DEUT&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion
{

View File

@ -17,7 +17,7 @@ int update_DLAY(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_SPRK && parts[i].life==0 && parts[r>>8].ctype==PT_PSCN)
{

View File

@ -7,7 +7,7 @@ int update_DSTW(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_SALT && 1>(rand()%250))
{

View File

@ -8,7 +8,7 @@ int update_FIRW(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
rt = parts[r>>8].type;
if (rt==PT_FIRE||rt==PT_PLSM||rt==PT_THDR)
@ -44,7 +44,7 @@ int update_FIRW(UPDATE_FUNC_ARGS) {
tmul = rand()%7;
create_part(-1, x+rx, y+ry, PT_FIRW);
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_FIRW) {
parts[r>>8].vx = (rand()%3-1)*tmul;

View File

@ -7,7 +7,7 @@ int update_FOG(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (ptypes[r&0xFF].state==ST_SOLID&&5>=rand()%50&&parts[i].life==0&&!((r&0xFF)==PT_CLNE||(r&0xFF)==PT_PCLN)) // TODO: should this also exclude BCLN?
{

View File

@ -7,7 +7,7 @@ int update_FRZW(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_WATR&&5>rand()%70)
{

View File

@ -7,7 +7,7 @@ int update_FRZZ(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_WATR&&5>rand()%100)
{

View File

@ -21,7 +21,7 @@ int update_FSEP(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (((r&0xFF)==PT_SPRK || (parts[i].temp>=(273.15+400.0f))) && 1>(rand()%15))
{

View File

@ -28,7 +28,7 @@ int update_FUSE(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_SPRK || ((parts[i].temp>=(273.15+700.0f)) && 1>(rand()%20)))
{

View File

@ -7,7 +7,7 @@ int update_GBMB(UPDATE_FUNC_ARGS) {
for (ry=-2; ry<3; ry++)
{
r = pmap[y+ry][x+rx];
if(!r || (r>>8)>=NPART)
if(!r)
continue;
if((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_GBMB &&
(r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN &&

View File

@ -7,7 +7,7 @@ int update_GLOW(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_WATR&&5>(rand()%2000))
{

View File

@ -19,7 +19,7 @@ int update_GPMP(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_GPMP)
{

View File

@ -9,7 +9,7 @@ int update_H2(UPDATE_FUNC_ARGS)
{
r = pmap[y+ry][x+rx];
rt = (r&0xFF);
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (pv[y/CELL][x/CELL] > 8.0f && rt == PT_DESL) // This will not work. DESL turns to fire above 5.0 pressure
{

View File

@ -11,7 +11,7 @@ int update_HSWC(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_HSWC)
{

View File

@ -11,7 +11,7 @@ int update_ICEI(UPDATE_FUNC_ARGS) { //currently used for snow as well
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW) && 1>(rand()%1000))
{

View File

@ -7,7 +7,7 @@ int update_IRON(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((((r&0xFF) == PT_SALT && 15>(rand()/(RAND_MAX/700))) ||
((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/2000))) ||

View File

@ -11,7 +11,7 @@ int update_LCRY(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_LCRY)
{

View File

@ -12,7 +12,7 @@ int update_legacy_all(UPDATE_FUNC_ARGS) {
x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (((r&0xFF)==PT_WATR||(r&0xFF)==PT_DSTW||(r&0xFF)==PT_SLTW) && 1>(rand()%1000))
{
@ -34,7 +34,7 @@ int update_legacy_all(UPDATE_FUNC_ARGS) {
x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10))
{
@ -49,7 +49,7 @@ int update_legacy_all(UPDATE_FUNC_ARGS) {
x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10))
{
@ -65,7 +65,7 @@ int update_legacy_all(UPDATE_FUNC_ARGS) {
x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10))
{
@ -79,7 +79,7 @@ int update_legacy_all(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000))
{
@ -94,7 +94,7 @@ int update_legacy_all(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000))
{

View File

@ -12,7 +12,7 @@ int update_MERC(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r || (parts[i].tmp >=maxtmp))
if (!r || (parts[i].tmp >=maxtmp))
continue;
if ((r&0xFF)==PT_MERC&&33>=rand()/(RAND_MAX/100)+1)
{
@ -30,7 +30,7 @@ int update_MERC(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || (parts[i].tmp<=maxtmp))
if (parts[i].tmp<=maxtmp)
continue;
if ((bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALLELEC||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_EWALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_DESTROYALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALL||
bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWAIR||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWSOLID||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWGAS))
@ -51,7 +51,7 @@ int update_MERC(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_MERC&&(parts[i].tmp>parts[r>>8].tmp)&&parts[i].tmp>0)//diffusion
{

View File

@ -50,7 +50,7 @@ int update_NEUT(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_WATR || (r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW)
{

View File

@ -23,9 +23,9 @@ int update_PBCN(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES)
{
r = photons[y+ry][x+rx];
if (!r || (r>>8)>=NPART)
if (!r)
r = pmap[y+ry][x+rx];
if (!r || (r>>8)>=NPART)
if (!r)
continue;
if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN &&
(r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_SPRK &&
@ -46,7 +46,7 @@ int update_PBCN(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_PBCN)
{

View File

@ -9,7 +9,7 @@ int update_PCLN(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_SPRK)
{
@ -32,9 +32,9 @@ int update_PCLN(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES)
{
r = photons[y+ry][x+rx];
if (!r || (r>>8)>=NPART)
if (!r)
r = pmap[y+ry][x+rx];
if (!r || (r>>8)>=NPART)
if (!r)
continue;
if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN &&
(r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_SPRK &&

View File

@ -14,7 +14,7 @@ int update_PHOT(UPDATE_FUNC_ARGS) {
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES && (rx || ry)) {
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_ISOZ && 5>(rand()%2000))
{

View File

@ -25,7 +25,7 @@ void pushParticle(int i, int count, int original)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES)
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
else if ((r&0xFF)==PT_PIPE && parts[r>>8].ctype!=notctype && (parts[r>>8].tmp&0xFF)==0)
{
@ -47,7 +47,7 @@ void pushParticle(int i, int count, int original)
{
int coords = 7 - (parts[i].tmp>>10);
r = pmap[y+ pos_1_ry[coords]][x+ pos_1_rx[coords]];
if ((r>>8)>=NPART || !r)
if (!r)
{
}
else if ((r&0xFF)==PT_PIPE && parts[r>>8].ctype!=notctype && (parts[r>>8].tmp&0xFF)==0)
@ -85,7 +85,7 @@ int update_PIPE(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_PIPE&&parts[r>>8].ctype==1)
{
@ -130,8 +130,6 @@ int update_PIPE(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES)
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART)
return 0;
if (surround_space && !r && (parts[i].tmp&0xFF)!=0) //creating at end
{
np = create_part(-1,x+rx,y+ry,parts[i].tmp&0xFF);

View File

@ -7,7 +7,7 @@ int update_PLNT(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_WATR && 1>(rand()%250))
{
@ -31,7 +31,7 @@ int update_PLNT(UPDATE_FUNC_ARGS) {
int nny = rand()%3 -1;
if (x+rx+nnx>=0 && y+ry+nny>0 && x+rx+nnx<XRES && y+ry+nny<YRES && (nnx || nny))
{
if ((pmap[y+ry+nny][x+rx+nnx]>>8)>=NPART||pmap[y+ry+nny][x+rx+nnx])
if (pmap[y+ry+nny][x+rx+nnx])
continue;
np = create_part(-1,x+rx+nnx,y+ry+nny,PT_VINE);
if (np<0) continue;
@ -46,8 +46,6 @@ int update_PLNT(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART)
continue;
if (!r)
create_part(-1,x+rx,y+ry,PT_O2);
}

View File

@ -24,13 +24,9 @@ int update_PRTI(UPDATE_FUNC_ARGS) {
r = pmap[y+ry][x+rx];
if (!r)
fe = 1;
if ((r>>8)>=NPART)
continue;
if (!r || (r&0xFF)==PT_PRTI || (r&0xFF)==PT_PRTO || (ptypes[r&0xFF].falldown== 0 && ptypes[r&0xFF].state != ST_GAS && (r&0xFF)!=PT_SPRK))
{
r = photons[y+ry][x+rx];
if ((r>>8)>=NPART)
continue;
if (!r || (r&0xFF)==PT_PRTI || (r&0xFF)==PT_PRTO || (ptypes[r&0xFF].falldown== 0 && ptypes[r&0xFF].state != ST_GAS && (r&0xFF)!=PT_SPRK))
continue;
}

View File

@ -21,7 +21,7 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
r = pmap[y+ry][x+rx];
if (!r)
fe = 1;
if ((r>>8)>=NPART || r)
if (r)
continue;
if (!r)
{

View File

@ -26,7 +26,7 @@ int update_PUMP(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_PUMP)
{

View File

@ -28,7 +28,7 @@ int update_PYRO(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (bmap[(y+ry)/CELL][(x+rx)/CELL] && bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_STREAM)
continue;
@ -58,7 +58,7 @@ int update_legacy_PYRO(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (bmap[(y+ry)/CELL][(x+rx)/CELL] && bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_STREAM)
continue;

View File

@ -19,7 +19,7 @@ int update_QRTZ(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
else if ((r&0xFF)==PT_SLTW && (1>rand()%2500))
{
@ -37,7 +37,7 @@ int update_QRTZ(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)<NPART && !r && parts[i].ctype!=0)
if (!r && parts[i].ctype!=0)
{
np = create_part(-1,x+rx,y+ry,PT_QRTZ);
if (np>-1)
@ -69,7 +69,7 @@ int update_QRTZ(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==t && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 )//diffusion
{

View File

@ -9,7 +9,7 @@ int update_RIME(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_SPRK)
{

View File

@ -7,7 +7,7 @@ int update_SHLD1(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
else if ((r&0xFF)==PT_SPRK&&parts[i].life==0)
{
@ -42,8 +42,6 @@ int update_SHLD2(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART)
continue;
if (!r && parts[i].life>0)
create_part(-1,x+rx,y+ry,PT_SHLD1);
if (!r)
@ -82,8 +80,6 @@ int update_SHLD3(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART)
continue;
if (!r)
{
if (1>rand()%2500)
@ -132,8 +128,6 @@ int update_SHLD4(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART)
continue;
if (!r)
{
if (1>rand()%5500)

View File

@ -64,7 +64,7 @@ int update_SING(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)!=PT_DMND&&33>=rand()/(RAND_MAX/100)+1)
{

View File

@ -7,7 +7,7 @@ int update_SLTW(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_SALT && 1>(rand()%10000))
kill_part(r>>8);

View File

@ -56,7 +56,7 @@ int update_SOAP(UPDATE_FUNC_ARGS)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((parts[r>>8].type == PT_SOAP) && ((parts[r>>8].ctype&1) == 1)
@ -92,7 +92,7 @@ int update_SOAP(UPDATE_FUNC_ARGS)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (((r>>8)>=NPART || !r) && !bmap[(y+ry)/CELL][(x+rx)/CELL])
if (!r && !bmap[(y+ry)/CELL][(x+rx)/CELL])
continue;
if (parts[i].temp>0)
@ -181,7 +181,7 @@ int update_SOAP(UPDATE_FUNC_ARGS)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF) == PT_OIL)

View File

@ -9,7 +9,7 @@ int update_SPNG(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r || parts[i].temp>374.0f)
if (!r)
continue;
if ((r&0xFF)==PT_WATR&&33>=rand()/(RAND_MAX/100)+1)
{
@ -24,8 +24,6 @@ int update_SPNG(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART)
continue;
if ((bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALLELEC||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_EWALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_DESTROYALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALL||
bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWAIR||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWSOLID||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWGAS))
continue;
@ -42,7 +40,7 @@ int update_SPNG(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_SPNG&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion
{
@ -70,7 +68,7 @@ int update_SPNG(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_FIRE)
{
@ -92,8 +90,6 @@ int update_SPNG(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART)
continue;
if ((bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALLELEC||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWLIQUID||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_DESTROYALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWSOLID))
continue;
if ((!r)&&parts[i].life>=1)//if nothing then create steam

View File

@ -58,7 +58,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (((r&0xFF) == PT_DSTW && 30>(rand()/(RAND_MAX/1000))) ||
((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/1000))) ||
@ -76,7 +76,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
rt = parts[r>>8].type;
conduct_sprk = 1;

View File

@ -188,10 +188,10 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r || (r>>8)>=NPART)
if (!r)
r = photons[y+ry][x+rx];
if ((!r || (r>>8)>=NPART) && !bmap[(y+ry)/CELL][(x+rx)/CELL])
if (!r && !bmap[(y+ry)/CELL][(x+rx)/CELL])
continue;
if (ptypes[r&0xFF].falldown!=0 || (r&0xFF) == PT_NEUT || (r&0xFF) == PT_PHOT)
@ -230,8 +230,6 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
{
ry -= 2*(rand()%2)+1;
r = pmap[ry][rx];
if (!((r>>8)>=NPART))
{
if (ptypes[r&0xFF].state == ST_SOLID)
{
create_part(-1, rx, ry, PT_SPRK);
@ -268,7 +266,6 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) {
}
}
}
//Simulation of joints
d = 25/(pow((playerp[3]-playerp[7]), 2) + pow((playerp[4]-playerp[8]), 2)+25) - 0.5; //Fast distance
@ -371,9 +368,9 @@ void STKM_interact(float* playerp, int i, int x, int y)
if (x<0 || y<0 || x>=XRES || y>=YRES || !parts[i].type)
return;
r = pmap[y][x];
if (r && (r>>8)<NPART)
if (r)
{
if ((r&0xFF)==PT_SPRK && r && (r>>8)<NPART) //If on charge
if ((r&0xFF)==PT_SPRK) //If on charge
{
parts[i].life -= (int)(rand()*20/RAND_MAX)+32;
}

View File

@ -9,7 +9,7 @@ int update_SWCH(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (parts_avg(i,r>>8,PT_INSL)!=PT_INSL) {
rt = r&0xFF;

View File

@ -7,7 +7,7 @@ int update_THDR(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((ptypes[r&0xFF].properties&PROP_CONDUCTS) && parts[r>>8].life==0 && !((r&0xFF)==PT_WATR||(r&0xFF)==PT_SLTW) && parts[r>>8].ctype!=PT_SPRK)
{

View File

@ -7,7 +7,7 @@ int update_THRM(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM || (r&0xFF)==PT_LAVA)) // TODO: could this go in update_PYRO?
{

View File

@ -5,8 +5,6 @@ int update_VINE(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART)
return 0;
if (1>rand()%15)
part_change_type(i,x,y,PT_PLNT);
else if (!r)

View File

@ -9,7 +9,7 @@ int update_WARP(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)!=PT_WARP&&(r&0xFF)!=PT_STKM&&(r&0xFF)!=PT_STKM2&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_BCLN&&(r&0xFF)!=PT_PCLN&&(10>=rand()%200))
{

View File

@ -7,7 +7,7 @@ int update_WATR(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_SALT && 1>(rand()%250))
{

View File

@ -10,7 +10,7 @@ int update_WIFI(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (wireless[parts[i].tmp][0])
{

View File

@ -27,7 +27,7 @@ int update_WIRE(UPDATE_FUNC_ARGS) {
if(x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if((r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_PSCN){parts[i].ctype=1; parts[r>>8].life=0; return 0;}
else if((r&0xFF)==PT_NSCN && parts[i].tmp==1){create_part(-1, x+rx, y+ry, PT_SPRK);}

View File

@ -7,7 +7,7 @@ int update_WTRV(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && !legacy_enable && parts[i].temp>(273.15f+12.0f) && 1>(rand()%500))
{

View File

@ -7,7 +7,7 @@ int update_YEST(UPDATE_FUNC_ARGS) {
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if ((r&0xFF)==PT_DYST && 1>(rand()%30) && !legacy_enable)
{

View File

@ -3885,7 +3885,7 @@ void create_decorations(int x, int y, int rx, int ry, int r, int g, int b, int c
if (rx==0 && ry==0)
{
rp = pmap[y][x];
if ((rp>>8)>=NPART || !rp)
if (!rp)
return;
if (click == 4)
parts[rp>>8].dcolour = 0;
@ -3898,7 +3898,7 @@ void create_decorations(int x, int y, int rx, int ry, int r, int g, int b, int c
if(y+j>=0 && x+i>=0 && x+i<XRES && y+j<YRES)
if (InCurrentBrush(i, j, rx, ry)){
rp = pmap[y+j][x+i];
if ((rp>>8)>=NPART || !rp)
if (!rp)
continue;
if (click == 4)
parts[rp>>8].dcolour = 0;
@ -4028,7 +4028,7 @@ void render_signs(pixel *vid_buf)
}
if (strcmp(signs[i].text, "{t}")==0)
{
if ((pmap[signs[i].y][signs[i].x]>>8)>0 && (pmap[signs[i].y][signs[i].x]>>8)<NPART)
if (pmap[signs[i].y][signs[i].x])
sprintf(buff, "Temp: %4.2f", parts[pmap[signs[i].y][signs[i].x]>>8].temp-273.15); //...tempirature
else
sprintf(buff, "Temp: 0.00"); //...tempirature

View File

@ -504,7 +504,7 @@ int luatpt_set_property(lua_State* l)
for (nx = x; nx<x+w; nx++)
for (ny = y; ny<y+h; ny++){
r = pmap[ny][nx];
if (!r || (r>>8) >= NPART || (partsel && partsel != parts[r>>8].type))
if (!r || (partsel && partsel != parts[r>>8].type))
{
r = photons[ny][nx];
if (!r || (partsel && partsel != parts[r>>8].type))
@ -523,9 +523,9 @@ int luatpt_set_property(lua_State* l)
if (i>=XRES || y>=YRES)
return luaL_error(l, "Coordinates out of range (%d,%d)", i, y);
r = pmap[y][i];
if (!r || (r>>8)>=NPART || (partsel && partsel != parts[r>>8].type))
if (!r || (partsel && partsel != parts[r>>8].type))
r = photons[y][i];
if (!r || (r>>8)>=NPART || (partsel && partsel != parts[r>>8].type))
if (!r || (partsel && partsel != parts[r>>8].type))
return 0;
i = r>>8;
}
@ -553,9 +553,9 @@ int luatpt_get_property(lua_State* l)
y = luaL_optint(l, 3, -1);
if(y!=-1 && y < YRES && y >= 0 && i < XRES && i >= 0){
r = pmap[y][i];
if (!r || (r>>8)>=NPART)
if (!r)
r = photons[y][i];
if (!r || (r>>8)>=NPART)
if (!r)
{
if (strcmp(prop,"type")==0){
lua_pushinteger(l, 0);

View File

@ -718,7 +718,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char
gol[x][y]=0;
if (j)
{
if (pmap[y][x] && (pmap[y][x]>>8)<NPART)
if (pmap[y][x])
{
k = pmap[y][x]>>8;
memset(parts+k, 0, sizeof(particle));
@ -2571,7 +2571,7 @@ int main(int argc, char *argv[])
} else {
cr = pmap[y/sdl_scale][x/sdl_scale];
}
if (!((cr>>8)>=NPART || !cr))
if (cr)
{
if ((cr&0xFF)==PT_LIFE && parts[cr>>8].ctype>=0 && parts[cr>>8].ctype<NGOLALT)
{
@ -3160,9 +3160,9 @@ int main(int argc, char *argv[])
{
int cr;
cr = pmap[y][x];
if ((cr>>8)>=NPART || !cr)
if (!cr)
cr = photons[y][x];
if (!((cr>>8)>=NPART || !cr))
if (cr)
{
c = sl = cr&0xFF;
if (c==PT_LIFE)

View File

@ -150,7 +150,7 @@ int eval_move(int pt, int nx, int ny, unsigned *rr)
return 0;
r = pmap[ny][nx];
if (r && (r>>8)<NPART)
if (r)
r = (r&~0xFF) | parts[r>>8].type;
if (rr)
*rr = r;
@ -175,8 +175,9 @@ int eval_move(int pt, int nx, int ny, unsigned *rr)
return 0;
if (bmap[ny/CELL][nx/CELL]==WL_ALLOWSOLID && ptypes[pt].falldown!=1)
return 0;
// blocking by WL_WALL, WL_WALLELEC and unpowered WL_EWALL is currently done by putting 0x7FFFFFFF in pmap
if (bmap[ny/CELL][nx/CELL]==WL_ALLOWAIR)
if (bmap[ny/CELL][nx/CELL]==WL_ALLOWAIR || bmap[ny/CELL][nx/CELL]==WL_WALL || bmap[ny/CELL][nx/CELL]==WL_WALLELEC)
return 0;
if (bmap[ny/CELL][nx/CELL]==WL_EWALL && !emap[ny/CELL][nx/CELL])
return 0;
if (bmap[ny/CELL][nx/CELL]==WL_EHOLE && !emap[ny/CELL][nx/CELL])
return 2;
@ -329,13 +330,12 @@ int try_move(int i, int x, int y, int nx, int ny)
return 0;
e = r >> 8; //e is now the particle number at r (pmap[ny][nx])
if (r && e<NPART)//the swap part, if we make it this far, swap
if (r)//the swap part, if we make it this far, swap
{
if (parts[i].type==PT_NEUT) {
// target material is NEUTPENETRATE, meaning it gets moved around when neutron passes
unsigned s = pmap[y][x];
if ((s>>8)>=NPART) return 0;
if ((s&0xFF) && (s&0xFF)<PT_NUM && !(ptypes[s&0xFF].properties&PROP_NEUTPENETRATE))
if (!(ptypes[s&0xFF].properties&PROP_NEUTPENETRATE))
return 1; // if the element currently underneath neutron isn't NEUTPENETRATE, don't move anything except the neutron
// if nothing is currently underneath neutron, only move target particle
if (s)
@ -716,7 +716,7 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
if((pmap[y][x]&0xFF)==PT_WIRE){
parts[pmap[y][x]>>8].ctype=PT_DUST;
}
if ((pmap[y][x]>>8)>=NPART || !((pmap[y][x]&0xFF)==PT_INST||(ptypes[pmap[y][x]&0xFF].properties&PROP_CONDUCTS)))
if (!((pmap[y][x]&0xFF)==PT_INST||(ptypes[pmap[y][x]&0xFF].properties&PROP_CONDUCTS)))
return -1;
if (parts[pmap[y][x]>>8].life!=0)
return -1;
@ -1072,7 +1072,7 @@ inline void delete_part(int x, int y, int flags)//calls kill_part with the parti
i = pmap[y][x];
}
if (!i || (i>>8)>=NPART)
if (!i)
return;
if (!(flags&BRUSH_SPECIFIC_DELETE) || parts[i>>8].type==SLALT || SLALT==0)//specific deletiom
{
@ -1195,7 +1195,7 @@ inline int parts_avg(int ci, int ni,int t)
if (t==PT_INSL)//to keep electronics working
{
int pmr = pmap[((int)(parts[ci].y+0.5f) + (int)(parts[ni].y+0.5f))/2][((int)(parts[ci].x+0.5f) + (int)(parts[ni].x+0.5f))/2];
if ((pmr>>8) < NPART && pmr)
if (pmr)
return parts[pmr>>8].type;
else
return PT_NONE;
@ -1203,7 +1203,7 @@ inline int parts_avg(int ci, int ni,int t)
else
{
int pmr2 = pmap[(int)((parts[ci].y + parts[ni].y)/2+0.5f)][(int)((parts[ci].x + parts[ni].x)/2+0.5f)];//seems to be more accurate.
if ((pmr2>>8) < NPART && pmr2)
if (pmr2)
{
if (parts[pmr2>>8].type==t)
return t;
@ -1344,7 +1344,7 @@ void update_particles_i(pixel *vid, int start, int inc)
for (nx=0; nx<XRES-4; nx++)
{
r=pmap[ny][nx];
if ((r>>8)>=NPART || !r)
if (!r)
{
continue;
}
@ -1369,10 +1369,6 @@ void update_particles_i(pixel *vid, int start, int inc)
if (ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES)
{
rt=pmap[ny+nny][nx+nnx];
if ((rt>>8)>=NPART)
{
continue;
}
if (!rt&&loverule[nnx][nny]==1)
create_part(-1,nx+nnx,ny+nny,PT_LOVE);
else if (!rt)
@ -1394,7 +1390,7 @@ void update_particles_i(pixel *vid, int start, int inc)
for (nx=0; nx<XRES-4; nx++)
{
r=pmap[ny][nx];
if ((r>>8)>=NPART || !r)
if (!r)
{
continue;
}
@ -1419,10 +1415,6 @@ void update_particles_i(pixel *vid, int start, int inc)
if (ny+nny>0&&ny+nny<YRES&&nx+nnx>=0&&nx+nnx<XRES)
{
rt=pmap[ny+nny][nx+nnx];
if ((rt>>8)>=NPART)
{
continue;
}
if (!rt&&lolzrule[nny][nnx]==1)
create_part(-1,nx+nnx,ny+nny,PT_LOLZ);
else if (!rt)
@ -1446,7 +1438,7 @@ void update_particles_i(pixel *vid, int start, int inc)
for (ny=0; ny<YRES; ny++)
{
r = pmap[ny][nx];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
if(parts[r>>8].type==PT_WIRE)
parts[r>>8].tmp=parts[r>>8].ctype;
@ -1464,7 +1456,7 @@ void update_particles_i(pixel *vid, int start, int inc)
for (ny=CELL; ny<YRES-CELL; ny++)
{
r = pmap[ny][nx];
if ((r>>8)>=NPART || !r)
if (!r)
{
gol[nx][ny] = 0;
continue;
@ -1510,7 +1502,7 @@ void update_particles_i(pixel *vid, int start, int inc)
{
r = pmap[ny][nx];
neighbors = gol2[nx][ny][0];
if (neighbors==0 || !((r&0xFF)==PT_LIFE || !(r&0xFF)) || (r>>8)>=NPART)
if (neighbors==0 || !((r&0xFF)==PT_LIFE || !(r&0xFF)))
continue;
for ( golnum = 1; golnum<=NGOL; golnum++)
{
@ -1689,7 +1681,7 @@ void update_particles_i(pixel *vid, int start, int inc)
{
if (y-2 >= 0 && y-2 < YRES && (ptypes[t].properties&TYPE_LIQUID)) {//some heat convection for liquids
r = pmap[y-2][x];
if (!((r>>8)>=NPART || !r || parts[i].type != (r&0xFF))) {
if (!(!r || parts[i].type != (r&0xFF))) {
if (parts[i].temp>parts[r>>8].temp) {
swappage = parts[i].temp;
parts[i].temp = parts[r>>8].temp;
@ -1720,7 +1712,7 @@ void update_particles_i(pixel *vid, int start, int inc)
{
surround_hconduct[j] = i;
r = surround[j];
if ((r>>8)>=NPART || !r)
if (!r)
continue;
rt = r&0xFF;
if (rt&&ptypes[rt].hconduct&&(rt!=PT_HSWC||parts[r>>8].life==10)
@ -2423,18 +2415,17 @@ void update_particles(pixel *vid)//doesn't update the particles themselves, but
else parts[lastPartUnused].life = parts_lastActiveIndex+1;
}
parts_lastActiveIndex = lastPartUsed;
if (!sys_pause||framerender)
{
for (y=0; y<YRES/CELL; y++)
{
for (x=0; x<XRES/CELL; x++)
{
if (bmap[y][x]==WL_WALL || bmap[y][x]==WL_WALLELEC || (bmap[y][x]==WL_EWALL&&!emap[y][x]))
for (j=0; j<CELL; j++)
for (i=0; i<CELL; i++)
pmap[y*CELL+j][x*CELL+i] = 0x7FFFFFFF;
if (emap[y][x] && (!sys_pause||framerender))
if (emap[y][x])
emap[y][x] --;
}
}
}
update_particles_i(vid, 0, 1);