summaryrefslogtreecommitdiff
path: root/src/powder.c
diff options
context:
space:
mode:
authorCracker64 <cracker642@gmail.com>2011-02-04 06:00:03 (GMT)
committer Cracker64 <cracker642@gmail.com>2011-02-04 06:00:03 (GMT)
commit9064cabf288be8ecb2fbc1c15bb4071cf3df1c22 (patch)
treee19413ebf90d2958069b4d108e61983fbe3638c3 /src/powder.c
parentb6f1ba977cd1b33cf857816ede4dca883a989561 (diff)
downloadpowder-9064cabf288be8ecb2fbc1c15bb4071cf3df1c22.zip
powder-9064cabf288be8ecb2fbc1c15bb4071cf3df1c22.tar.gz
merge jacksonmj's and much better string parsing because of a function i found.
Diffstat (limited to 'src/powder.c')
-rw-r--r--src/powder.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/powder.c b/src/powder.c
index 6897cb1..5a60d0d 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -1080,7 +1080,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 + parts[ni].y)/2)][(int)((parts[ci].x + parts[ni].x)/2)];
+ 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)
return parts[pmr>>8].type;
else
@@ -1113,7 +1113,7 @@ int nearest_part(int ci, int t)
{
if (parts[i].type==t&&!parts[i].life&&i!=ci)
{
- ndistance = abs((cx-parts[i].x)+(cy-parts[i].y));// Faster but less accurate Older: sqrt(pow(cx-parts[i].x, 2)+pow(cy-parts[i].y, 2));
+ ndistance = abs(cx-parts[i].x)+abs(cy-parts[i].y);// Faster but less accurate Older: sqrt(pow(cx-parts[i].x, 2)+pow(cy-parts[i].y, 2));
if (ndistance<distance)
{
distance = ndistance;
@@ -1127,7 +1127,7 @@ int nearest_part(int ci, int t)
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, neighbors;
- float mv, dx, dy, ix, iy, lx, ly, nrx, nry, dp;
+ float mv, dx, dy, ix, iy, lx, ly, nrx, nry, dp, ctemph, ctempl;
int fin_x, fin_y, clear_x, clear_y;
float fin_xf, fin_yf, clear_xf, clear_yf;
float nn, ct1, ct2, swappage;
@@ -1290,9 +1290,9 @@ void update_particles_i(pixel *vid, int start, int inc)
}
if (ISGOL==1&&++CGOL>=GSPEED)//GSPEED is frames per generation
{
+ int createdsomething = 0;
CGOL=0;
ISGOL=0;
- int createdsomething = 0;
for (nx=CELL; nx<XRES-CELL; nx++)
for (ny=CELL; ny<YRES-CELL; ny++)
{
@@ -1522,8 +1522,16 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[surround_hconduct[j]].temp = pt;
}
+ ctemph = ctempl = pt;
+ // change boiling point with pressure
+ if ((ptypes[t].state==ST_LIQUID && ptransitions[t].tht>-1 && ptransitions[t].tht<PT_NUM && ptypes[ptransitions[t].tht].state==ST_GAS)
+ || t==PT_LNTG || t==PT_SLTW)
+ ctemph -= 2.0f*pv[y/CELL][x/CELL];
+ else if ((ptypes[t].state==ST_GAS && ptransitions[t].tlt>-1 && ptransitions[t].tlt<PT_NUM && ptypes[ptransitions[t].tlt].state==ST_LIQUID)
+ || t==PT_WTRV)
+ ctempl -= 2.0f*pv[y/CELL][x/CELL];
s = 1;
- if (pt>ptransitions[t].thv&&ptransitions[t].tht>-1) {
+ if (ctemph>ptransitions[t].thv&&ptransitions[t].tht>-1) {
// particle type change due to high temperature
if (ptransitions[t].tht!=PT_NUM)
t = ptransitions[t].tht;
@@ -1544,7 +1552,7 @@ void update_particles_i(pixel *vid, int start, int inc)
else t = PT_WTRV;
}
else s = 0;
- } else if (pt<ptransitions[t].tlv&&ptransitions[t].tlt>-1) {
+ } else if (ctempl<ptransitions[t].tlv&&ptransitions[t].tlt>-1) {
// particle type change due to low temperature
if (ptransitions[t].tlt!=PT_NUM)
t = ptransitions[t].tlt;
@@ -1553,7 +1561,7 @@ void update_particles_i(pixel *vid, int start, int inc)
else t = PT_DSTW;
}
else if (t==PT_LAVA) {
- if (parts[i].ctype&&parts[i].ctype!=PT_LAVA) {
+ if (parts[i].ctype && parts[i].ctype<PT_NUM && parts[i].ctype!=PT_LAVA) {
if (ptransitions[parts[i].ctype].tht==PT_LAVA&&pt>=ptransitions[parts[i].ctype].thv) s = 0;
else if (parts[i].ctype==PT_THRM&&pt>=ptransitions[PT_BMTL].thv) s = 0;
else if (pt>=973.0f) s = 0; // freezing point for lava with any other (not listed in ptransitions as turning into lava) ctype