From c5670d39c1e37c95d2faab64467a77738717f1cf Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Sat, 15 Jan 2011 18:37:27 +0000 Subject: [PATCH] Misc small fixes and tidyup --- src/elements/plnt.c | 2 -- src/elements/sprk.c | 6 ++--- src/elements/swch.c | 2 +- src/elements/thrm.c | 2 -- src/elements/wifi.c | 1 - src/powder.c | 61 +++++++++++++++++++++------------------------ 6 files changed, 32 insertions(+), 42 deletions(-) diff --git a/src/elements/plnt.c b/src/elements/plnt.c index 20b542a2f..79c9d8a19 100644 --- a/src/elements/plnt.c +++ b/src/elements/plnt.c @@ -38,8 +38,6 @@ int update_PLNT(UPDATE_FUNC_ARGS) { parts[np].temp = parts[i].temp; } } - //if(t==PT_SNOW && (r&0xFF)==PT_WATR && 15>(rand()%1000)) - //t = parts[i].type = PT_WATR; } if (parts[i].life==2) { diff --git a/src/elements/sprk.c b/src/elements/sprk.c index 27e309a8e..891be3a68 100644 --- a/src/elements/sprk.c +++ b/src/elements/sprk.c @@ -5,7 +5,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) { int r, rx, ry, rt, conduct_sprk, nearp, pavg, ct = parts[i].ctype; if (parts[i].life<=0) { - if (ct!=PT_METL&&ct!=PT_PTCT&&ct!=PT_NTCT&&ct!=PT_IRON&&ct!=PT_BMTL&&ct!=PT_BRMT&&ct!=PT_LRBD&&ct!=PT_RBDM&&ct!=PT_BTRY&&ct!=PT_NBLE&&ct!=PT_QRTZ) + if (ct==PT_WATR||ct==PT_SLTW||ct==PT_PSCN||ct==PT_NSCN||ct==PT_ETRD) parts[i].temp = R_TEMP + 273.15f; if (!ct) ct = PT_METL; @@ -33,7 +33,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) { part_change_type(i,x,y,ct); ct = parts[i].ctype = PT_NONE; parts[i].life = 20; - part_change_type(i,(int)(parts[nearp].x+0.5f),(int)(parts[nearp].y+0.5f),PT_SPRK); + part_change_type(nearp,(int)(parts[nearp].x+0.5f),(int)(parts[nearp].y+0.5f),PT_SPRK); parts[nearp].life = 9; parts[nearp].ctype = PT_ETRD; } @@ -89,7 +89,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) { else if ((ct==PT_PSCN||ct==PT_NSCN) && (rt==PT_PUMP||rt==PT_HSWC||(rt==PT_LCRY&&abs(rx)<2&&abs(ry)<2))) { if (ct==PT_PSCN) parts[r>>8].life = 10; - else if (ct==PT_NSCN) parts[r>>8].life = 9; + else if (ct==PT_NSCN && parts[r>>8].life>=10) parts[r>>8].life = 9; } diff --git a/src/elements/swch.c b/src/elements/swch.c index 5d623cd59..8a8e989b7 100644 --- a/src/elements/swch.c +++ b/src/elements/swch.c @@ -13,7 +13,7 @@ int update_SWCH(UPDATE_FUNC_ARGS) { rt = r&0xFF; if (rt==PT_SWCH) { - if (parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0) + if (parts[i].life>=10&&parts[r>>8].life<10&&parts[r>>8].life>0) parts[i].life = 9; else if (parts[i].life==0&&parts[r>>8].life==10) parts[i].life = 10; diff --git a/src/elements/thrm.c b/src/elements/thrm.c index 41ecf947b..3529c2ef2 100644 --- a/src/elements/thrm.c +++ b/src/elements/thrm.c @@ -24,8 +24,6 @@ int update_THRM(UPDATE_FUNC_ARGS) { parts[i].tmp = 20; } } - //if(t==PT_SNOW && (r&0xFF)==PT_WATR && 15>(rand()%1000)) - //t = parts[i].type = PT_WATR; } return 0; } diff --git a/src/elements/wifi.c b/src/elements/wifi.c index 0180b75ae..a6b9ab0cf 100644 --- a/src/elements/wifi.c +++ b/src/elements/wifi.c @@ -23,7 +23,6 @@ int update_WIFI(UPDATE_FUNC_ARGS) { { if ((r&0xFF)==PT_SPRK && parts[r>>8].ctype!=PT_NSCN && parts[r>>8].life>=3) { - //parts[r>>8].type = parts[r>>8].ctype; wireless[parts[i].tmp][0] = 1; wireless[parts[i].tmp][1] = 1; ISWIRE = 1; diff --git a/src/powder.c b/src/powder.c index 6f535b612..d595a5ab6 100644 --- a/src/powder.c +++ b/src/powder.c @@ -38,7 +38,7 @@ static int pn_junction_sprk(int x, int y, int pt) return 0; parts[r].ctype = pt; - parts[r].type = PT_SPRK; + part_change_type(r,x,y,PT_SPRK); parts[r].life = 4; return 1; } @@ -181,7 +181,7 @@ int try_move(int i, int x, int y, int nx, int ny) create_cherenkov_photon(i); } if (parts[i].type == PT_PHOT && (r&0xFF)==PT_INVIS) { - parts[i].type = PT_NEUT; + part_change_type(i,x,y,PT_NEUT); parts[i].ctype = 0; } if ((parts[i].type==PT_BIZR||parts[i].type==PT_BIZRG) && (r&0xFF)==PT_FILT) @@ -436,8 +436,12 @@ void kill_part(int i) { ISSPAWN2 = 0; } - if (x>=0 && y>=0 && x>8)==i) - pmap[y][x] = 0; + if (x>=0 && y>=0 && x>8)==i) + pmap[y][x] = 0; + else if ((photons[y][x]>>8)==i) + photons[y][x] = 0; + } } parts[i].type = PT_NONE; @@ -494,6 +498,8 @@ inline int create_n_parts(int n, int x, int y, float vx, float vy, int t) parts[i].ctype = 0; parts[i].temp += (n*17); parts[i].tmp = 0; + if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT && !pmap[y][x])// && t!=PT_NEUT) + pmap[y][x] = t|(i<<8); pv[y/CELL][x/CELL] += 6.0f * CFDS; } @@ -571,22 +577,8 @@ inline int create_part(int p, int x, int y, int t) if (t==PT_SPRK) { - if ((pmap[y][x]&0xFF)!=PT_METL && - (pmap[y][x]&0xFF)!=PT_PSCN && - (pmap[y][x]&0xFF)!=PT_NSCN && - (pmap[y][x]&0xFF)!=PT_NTCT && - (pmap[y][x]&0xFF)!=PT_PTCT && - (pmap[y][x]&0xFF)!=PT_WATR && - (pmap[y][x]&0xFF)!=PT_SLTW && - (pmap[y][x]&0xFF)!=PT_BMTL && - (pmap[y][x]&0xFF)!=PT_RBDM && - (pmap[y][x]&0xFF)!=PT_LRBD && - (pmap[y][x]&0xFF)!=PT_ETRD && - (pmap[y][x]&0xFF)!=PT_BRMT && - (pmap[y][x]&0xFF)!=PT_NBLE && - (pmap[y][x]&0xFF)!=PT_IRON && - (pmap[y][x]&0xFF)!=PT_INST && - (pmap[y][x]&0xFF)!=PT_INWR) + if (!((pmap[y][x]&0xFF)==PT_INST||(ptypes[pmap[y][x]&0xFF].properties&PROP_CONDUCTS)) + || (pmap[y][x]&0xFF)==PT_QRTZ) return -1; if (parts[pmap[y][x]>>8].life!=0) return -1; @@ -895,6 +887,7 @@ static void create_gain_photon(int pp) parts[i].vy = parts[pp].vy; parts[i].temp = parts[pmap[ny][nx] >> 8].temp; parts[i].tmp = 0; + photons[ny][nx] = PT_PHOT|(i<<8); temp_bin = (int)((parts[i].temp-273.0f)*0.25f); if (temp_bin < 0) temp_bin = 0; @@ -930,6 +923,7 @@ static void create_cherenkov_photon(int pp) parts[i].y = parts[pp].y; parts[i].temp = parts[pmap[ny][nx] >> 8].temp; parts[i].tmp = 0; + photons[ny][nx] = PT_PHOT|(i<<8); if (lr) { parts[i].vx = parts[pp].vx - 2.5f*parts[pp].vy; @@ -966,15 +960,14 @@ inline void delete_part(int x, int y) if ((parts[i>>8].type==SLALT)||SLALT==0) { kill_part(i>>8); - pmap[y][x] = 0; } else if (ptypes[parts[i>>8].type].menusection==SEC) { kill_part(i>>8); - pmap[y][x] = 0; } else return; + } #if defined(WIN32) && !defined(__GNUC__) @@ -1133,6 +1126,8 @@ void update_particles_i(pixel *vid, int start, int inc) { int i, j, x, y, t, nx, ny, r, surround_space, s, lt, rt, nt, nnx, nny, q, golnum, goldelete, z; float mv, dx, dy, ix, iy, lx, ly, nrx, nry, dp; + int fin_x, fin_y, clear_x, clear_y; + float fin_xf, fin_yf, clear_xf, clear_yf; float nn, ct1, ct2; float pt = R_TEMP; float c_heat = 0.0f; @@ -1203,7 +1198,7 @@ void update_particles_i(pixel *vid, int start, int inc) continue; } else if ((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&parts[r>>8].type==PT_LOVE) - parts[r>>8].type = PT_NONE; + kill_part(r>>8); else if (parts[r>>8].type==PT_LOVE) { love[nx/9][ny/9] = 1; @@ -1232,8 +1227,7 @@ void update_particles_i(pixel *vid, int start, int inc) else if (!rt) continue; else if (parts[rt>>8].type==PT_LOVE&&loverule[nnx][nny]==0) - parts[rt>>8].type=PT_NONE; - + kill_part(rt>>8); } } } @@ -1254,7 +1248,7 @@ void update_particles_i(pixel *vid, int start, int inc) continue; } else if ((ny<9||nx<9||ny>YRES-7||nx>XRES-10)&&parts[r>>8].type==PT_LOLZ) - parts[r>>8].type = PT_NONE; + kill_part(r>>8); else if (parts[r>>8].type==PT_LOLZ) { lolz[nx/9][ny/9] = 1; @@ -1283,7 +1277,7 @@ void update_particles_i(pixel *vid, int start, int inc) else if (!rt) continue; else if (parts[rt>>8].type==PT_LOLZ&&lolzrule[nny][nnx]==0) - parts[rt>>8].type=PT_NONE; + kill_part(rt>>8); } } @@ -1334,7 +1328,7 @@ void update_particles_i(pixel *vid, int start, int inc) createdsomething = 1; } else if (neighbors-1==goldelete&&gol[nx][ny]==golnum&&(grule[golnum][goldelete]==0||grule[golnum][goldelete]==2))//subtract 1 because it counted itself - parts[pmap[ny][nx]>>8].type = PT_NONE; + kill_part(pmap[ny][nx]>>8); } gol2[nx][ny][0] = 0; for ( z = 1; z