summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/air.c32
-rw-r--r--src/elements/fwrk.c20
-rw-r--r--src/elements/phot.c3
-rw-r--r--src/elements/sprk.c8
-rw-r--r--src/graphics.c2
-rw-r--r--src/interface.c32
-rw-r--r--src/main.c200
-rw-r--r--src/powder.c22
8 files changed, 166 insertions, 153 deletions
diff --git a/src/air.c b/src/air.c
index 33a4913..e9a8b9e 100644
--- a/src/air.c
+++ b/src/air.c
@@ -86,8 +86,8 @@ void update_air(void)
dp = 0.0f;
dp += vx[y][x-1] - vx[y][x];
dp += vy[y-1][x] - vy[y][x];
- pv[y][x] *= PLOSS;
- pv[y][x] += dp*TSTEPP;
+ pv[y][x] *= AIR_PLOSS;
+ pv[y][x] += dp*AIR_TSTEPP;
}
for (y=0; y<YRES/CELL-1; y++)
@@ -96,10 +96,10 @@ void update_air(void)
dx = dy = 0.0f;
dx += pv[y][x] - pv[y][x+1];
dy += pv[y][x] - pv[y+1][x];
- vx[y][x] *= VLOSS;
- vy[y][x] *= VLOSS;
- vx[y][x] += dx*TSTEPV;
- vy[y][x] += dy*TSTEPV;
+ vx[y][x] *= AIR_VLOSS;
+ vy[y][x] *= AIR_VLOSS;
+ vx[y][x] += dx*AIR_TSTEPV;
+ vy[y][x] += dy*AIR_TSTEPV;
if (bmap[y][x]==WL_WALL || bmap[y][x+1]==WL_WALL ||
bmap[y][x]==WL_WALLELEC || bmap[y][x+1]==WL_WALLELEC ||
(bmap[y][x]==WL_EWALL && !emap[y][x]) ||
@@ -148,20 +148,20 @@ void update_air(void)
if (i>=2 && i<XRES/CELL-3 &&
j>=2 && j<YRES/CELL-3)
{
- dx *= 1.0f - VADV;
- dy *= 1.0f - VADV;
+ dx *= 1.0f - AIR_VADV;
+ dy *= 1.0f - AIR_VADV;
- dx += VADV*(1.0f-tx)*(1.0f-ty)*vx[j][i];
- dy += VADV*(1.0f-tx)*(1.0f-ty)*vy[j][i];
+ dx += AIR_VADV*(1.0f-tx)*(1.0f-ty)*vx[j][i];
+ dy += AIR_VADV*(1.0f-tx)*(1.0f-ty)*vy[j][i];
- dx += VADV*tx*(1.0f-ty)*vx[j][i+1];
- dy += VADV*tx*(1.0f-ty)*vy[j][i+1];
+ dx += AIR_VADV*tx*(1.0f-ty)*vx[j][i+1];
+ dy += AIR_VADV*tx*(1.0f-ty)*vy[j][i+1];
- dx += VADV*(1.0f-tx)*ty*vx[j+1][i];
- dy += VADV*(1.0f-tx)*ty*vy[j+1][i];
+ dx += AIR_VADV*(1.0f-tx)*ty*vx[j+1][i];
+ dy += AIR_VADV*(1.0f-tx)*ty*vy[j+1][i];
- dx += VADV*tx*ty*vx[j+1][i+1];
- dy += VADV*tx*ty*vy[j+1][i+1];
+ dx += AIR_VADV*tx*ty*vx[j+1][i+1];
+ dy += AIR_VADV*tx*ty*vy[j+1][i+1];
}
if (bmap[y][x] == WL_FAN)
diff --git a/src/elements/fwrk.c b/src/elements/fwrk.c
index def28e4..06390c5 100644
--- a/src/elements/fwrk.c
+++ b/src/elements/fwrk.c
@@ -7,9 +7,9 @@ int update_FWRK(UPDATE_FUNC_ARGS) {
np = create_part(-1, x , y-1 , PT_FWRK);
if (np!=-1)
{
- parts[r>>8].vy = rand()%8-22;
- parts[r>>8].vx = rand()%20-rand()%20;
- parts[r>>8].life=rand()%15+25;
+ parts[np].vy = rand()%8-22;
+ parts[np].vx = rand()%20-rand()%20;
+ parts[np].life=rand()%15+25;
kill_part(i);
return 1;
}
@@ -33,13 +33,13 @@ int update_FWRK(UPDATE_FUNC_ARGS) {
pv[y/CELL][x/CELL] += 2.00f*CFDS;
if (np!=-1)
{
- parts[r>>8].vy = -(rand()%10-1);
- parts[r>>8].vx = ((rand()%2)*2-1)*rand()%(5+5)+(parts[i].vx)*2 ;
- parts[r>>8].life= rand()%37+18;
- parts[r>>8].tmp=q;
- parts[r>>8].flags=w;
- parts[r>>8].ctype=e;
- parts[r>>8].temp= rand()%20+6000;
+ parts[np].vy = -(rand()%10-1);
+ parts[np].vx = ((rand()%2)*2-1)*rand()%(5+5)+(parts[i].vx)*2 ;
+ parts[np].life= rand()%37+18;
+ parts[np].tmp=q;
+ parts[np].flags=w;
+ parts[np].ctype=e;
+ parts[np].temp= rand()%20+6000;
}
}
}
diff --git a/src/elements/phot.c b/src/elements/phot.c
index 11585f9..a6a5d07 100644
--- a/src/elements/phot.c
+++ b/src/elements/phot.c
@@ -6,7 +6,8 @@ int update_PHOT(UPDATE_FUNC_ARGS) {
if (1>rand()%10) update_PYRO(UPDATE_FUNC_SUBCALL_ARGS);
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; 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)) {
+ r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
continue;
if ((r&0xFF)==PT_ISOZ && 5>(rand()%2000))
diff --git a/src/elements/sprk.c b/src/elements/sprk.c
index ddac968..f107b9a 100644
--- a/src/elements/sprk.c
+++ b/src/elements/sprk.c
@@ -25,6 +25,10 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
kill_part(i);
return 1;
}
+ else if (ct==PT_NTCT || ct==PT_PTCT)
+ {
+ update_NPTCT(UPDATE_FUNC_SUBCALL_ARGS);
+ }
else if (ct==PT_ETRD&&parts[i].life==1)
{
nearp = nearest_part(i, PT_ETRD);
@@ -97,12 +101,12 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
// ct = spark from material, rt = spark to material. Make conduct_sprk = 0 if conduction not allowed
if (pavg == PT_INSL) conduct_sprk = 0;
- if (!(ptypes[rt].properties&PROP_CONDUCTS||rt==PT_INST)) conduct_sprk = 0;
+ if (!(ptypes[rt].properties&PROP_CONDUCTS||rt==PT_INST||rt==PT_QRTZ)) conduct_sprk = 0;
if (abs(rx)+abs(ry)>=4 &&ct!=PT_SWCH&&rt!=PT_SWCH)
conduct_sprk = 0;
- if (ct==PT_METL && (rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR||(rt==PT_SPRK&&(parts[r>>8].ctype==PT_NTCT||parts[r>>8].ctype==PT_PTCT))))
+ if (ct==PT_METL && (rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR||(rt==PT_SPRK&&(parts[r>>8].ctype==PT_NTCT||parts[r>>8].ctype==PT_PTCT))) && pavg!=PT_INSL)
{
parts[r>>8].temp = 473.0f;
if (rt==PT_NTCT||rt==PT_PTCT)
diff --git a/src/graphics.c b/src/graphics.c
index 786bdca..2d9989f 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -2907,7 +2907,7 @@ void render_signs(pixel *vid_buf)
sprintf(buff, "Temp: 0.00"); //...tempirature
drawtext(vid_buf, x+3, y+3, buff, 255, 255, 255, 255);
}
-
+
if(sregexp(signs[i].text, "^{c:[0-9]*|.*}$")==0)
{
int sldr, startm;
diff --git a/src/interface.c b/src/interface.c
index ab4fa3a..570755d 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -96,7 +96,7 @@ void get_sign_pos(int i, int *x0, int *y0, int *w, int *h)
memset(buff, 0, sizeof(buff));
for(sldr=3; signs[i].text[sldr-1] != '|'; sldr++)
startm = sldr + 1;
-
+
sldr = startm;
while(signs[i].text[sldr] != '}')
{
@@ -105,7 +105,7 @@ void get_sign_pos(int i, int *x0, int *y0, int *w, int *h)
}
*w = textwidth(buff) + 5;
}
-
+
//Ususal width
if (strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$"))
*w = textwidth(signs[i].text) + 5;
@@ -874,13 +874,13 @@ void login_ui(pixel *vid_buf)
*(s_id++) = 0;
u_e = strchr(s_id, ' ');
- if (!u_e){
+ if (!u_e) {
u_e = malloc(1);
memset(u_e, 0, 1);
}
else
*(u_e++) = 0;
-
+
strcpy(svf_user_id, res+3);
strcpy(svf_session_id, s_id);
nres = mystrdup(u_e);
@@ -3866,18 +3866,18 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show
clearrect(vid_buf, 0, 0, XRES+BARSIZE, 220);//anyway to make it transparent?
draw_line(vid_buf, 1, 219, XRES, 219, 228, 228, 228, XRES+BARSIZE);
drawtext(vid_buf, 100, 15, "Welcome to The Powder Toy console v.2 (by cracker64)\n"
- "Current commands are quit, set, reset, load, create, file, kill, sound\n"
- "You can set type, temp, ctype, life, x, y, vx, vy using this format ('set life particle# 9001')\n"
- "You can also use 'all' instead of a particle number to do it to everything.\n"
- "You can now use particle names (ex. set type all deut)\n"
- "Reset works with pressure, velocity, sparks, temp (ex. 'reset pressure')\n"
- "To load a save use load saveID (ex. load 1337)\n"
- "Create particles with 'create deut x,y' where x and y are the coords\n"
- "Run scripts from file 'file filename'\n"
- "You can delete/kill a particle with 'kill x,y'"
- "Play a sound with (sound blah.wav)"
- ,255, 187, 187, 255);
-
+ "Current commands are quit, set, reset, load, create, file, kill, sound\n"
+ "You can set type, temp, ctype, life, x, y, vx, vy using this format ('set life particle# 9001')\n"
+ "You can also use 'all' instead of a particle number to do it to everything.\n"
+ "You can now use particle names (ex. set type all deut)\n"
+ "Reset works with pressure, velocity, sparks, temp (ex. 'reset pressure')\n"
+ "To load a save use load saveID (ex. load 1337)\n"
+ "Create particles with 'create deut x,y' where x and y are the coords\n"
+ "Run scripts from file 'file filename'\n"
+ "You can delete/kill a particle with 'kill x,y'"
+ "Play a sound with (sound blah.wav)"
+ ,255, 187, 187, 255);
+
cc = 0;
currentcommand = last_command;
while(cc < 10)
diff --git a/src/main.c b/src/main.c
index 0ae2aab..7a91952 100644
--- a/src/main.c
+++ b/src/main.c
@@ -54,65 +54,65 @@
#define NUM_SOUNDS 2
struct sample {
- Uint8 *data;
- Uint32 dpos;
- Uint32 dlen;
+ Uint8 *data;
+ Uint32 dpos;
+ Uint32 dlen;
} sounds[NUM_SOUNDS];
void mixaudio(void *unused, Uint8 *stream, int len)
{
- int i;
- Uint32 amount;
-
- for ( i=0; i<NUM_SOUNDS; ++i ) {
- amount = (sounds[i].dlen-sounds[i].dpos);
- if ( amount > len ) {
- amount = len;
- }
- SDL_MixAudio(stream, &sounds[i].data[sounds[i].dpos], amount, SDL_MIX_MAXVOLUME);
- sounds[i].dpos += amount;
- }
+ int i;
+ Uint32 amount;
+
+ for ( i=0; i<NUM_SOUNDS; ++i ) {
+ amount = (sounds[i].dlen-sounds[i].dpos);
+ if ( amount > len ) {
+ amount = len;
+ }
+ SDL_MixAudio(stream, &sounds[i].data[sounds[i].dpos], amount, SDL_MIX_MAXVOLUME);
+ sounds[i].dpos += amount;
+ }
}
void play_sound(char *file)
{
- int index;
- SDL_AudioSpec wave;
- Uint8 *data;
- Uint32 dlen;
- SDL_AudioCVT cvt;
-
- /* Look for an empty (or finished) sound slot */
- for ( index=0; index<NUM_SOUNDS; ++index ) {
- if ( sounds[index].dpos == sounds[index].dlen ) {
- break;
- }
- }
- if ( index == NUM_SOUNDS )
- return;
-
- /* Load the sound file and convert it to 16-bit stereo at 22kHz */
- if ( SDL_LoadWAV(file, &wave, &data, &dlen) == NULL ) {
- fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
- return;
- }
- SDL_BuildAudioCVT(&cvt, wave.format, wave.channels, wave.freq,
- AUDIO_S16, 2, 22050);
- cvt.buf = malloc(dlen*cvt.len_mult);
- memcpy(cvt.buf, data, dlen);
- cvt.len = dlen;
- SDL_ConvertAudio(&cvt);
- SDL_FreeWAV(data);
-
- /* Put the sound data in the slot (it starts playing immediately) */
- if ( sounds[index].data ) {
- free(sounds[index].data);
- }
- SDL_LockAudio();
- sounds[index].data = cvt.buf;
- sounds[index].dlen = cvt.len_cvt;
- sounds[index].dpos = 0;
- SDL_UnlockAudio();
+ int index;
+ SDL_AudioSpec wave;
+ Uint8 *data;
+ Uint32 dlen;
+ SDL_AudioCVT cvt;
+
+ /* Look for an empty (or finished) sound slot */
+ for ( index=0; index<NUM_SOUNDS; ++index ) {
+ if ( sounds[index].dpos == sounds[index].dlen ) {
+ break;
+ }
+ }
+ if ( index == NUM_SOUNDS )
+ return;
+
+ /* Load the sound file and convert it to 16-bit stereo at 22kHz */
+ if ( SDL_LoadWAV(file, &wave, &data, &dlen) == NULL ) {
+ fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
+ return;
+ }
+ SDL_BuildAudioCVT(&cvt, wave.format, wave.channels, wave.freq,
+ AUDIO_S16, 2, 22050);
+ cvt.buf = malloc(dlen*cvt.len_mult);
+ memcpy(cvt.buf, data, dlen);
+ cvt.len = dlen;
+ SDL_ConvertAudio(&cvt);
+ SDL_FreeWAV(data);
+
+ /* Put the sound data in the slot (it starts playing immediately) */
+ if ( sounds[index].data ) {
+ free(sounds[index].data);
+ }
+ SDL_LockAudio();
+ sounds[index].data = cvt.buf;
+ sounds[index].dlen = cvt.len_cvt;
+ sounds[index].dpos = 0;
+ SDL_UnlockAudio();
}
static const char *it_msg =
@@ -1195,7 +1195,7 @@ int main(int argc, char *argv[])
pixel *load_img=NULL;//, *fbi_img=NULL;
int save_mode=0, save_x=0, save_y=0, save_w=0, save_h=0, copy_mode=0;
GSPEED = 1;
-
+
SDL_AudioSpec fmt;
/* Set 16-bit stereo audio at 22Khz */
fmt.freq = 22050;
@@ -2239,10 +2239,10 @@ int main(int argc, char *argv[])
else if (y<YRES)
{
int signi;
-
+
c = (b&1) ? sl : sr;
su = c;
-
+
if(c!=WL_SIGN+100)
{
if(!bq)
@@ -2255,12 +2255,12 @@ int main(int argc, char *argv[])
{
char buff[256];
int sldr;
-
+
memset(buff, 0, sizeof(buff));
-
+
for(sldr=3; signs[signi].text[sldr] != '|'; sldr++)
buff[sldr-3] = signs[signi].text[sldr];
-
+
char buff2[sldr-2]; //TODO: Fix this for Visual Studio
memset(buff2, 0, sizeof(buff2));
memcpy(&buff2, &buff, sldr-3);
@@ -2268,7 +2268,7 @@ int main(int argc, char *argv[])
}
}
}
-
+
if (c==WL_SIGN+100)
{
if (!bq)
@@ -2596,7 +2596,7 @@ int main(int argc, char *argv[])
if(DEBUG_MODE)
{
fillrect(vid_buf, XRES-20-textwidth(coordtext), 26, textwidth(coordtext)+8, 11, 0, 0, 0, 140);
- drawtext(vid_buf, XRES-16-textwidth(coordtext), 27, coordtext, 255, 255, 255, 200);
+ drawtext(vid_buf, XRES-16-textwidth(coordtext), 27, coordtext, 255, 255, 255, 200);
}
}
fillrect(vid_buf, 12, 12, textwidth(uitext)+8, 15, 0, 0, 0, 140);
@@ -2684,7 +2684,7 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
else if (strcmp(console2, "create")==0 && console3 && console4)
{
if (console_parse_type(console3, &j, console_error)
- && console_parse_coords(console4, &nx, &ny, console_error))
+ && console_parse_coords(console4, &nx, &ny, console_error))
{
if (!j)
strcpy(console_error, "Cannot create particle with type NONE");
@@ -2755,10 +2755,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{
k = atoi(console5);
for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].life = k;
- }
+ {
+ if(parts[i].type == j)
+ parts[i].life = k;
+ }
}
else
{
@@ -2781,18 +2781,18 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
}
}
else if (console_parse_type(console4, &j, console_error)
- && console_parse_type(console5, &k, console_error))
+ && console_parse_type(console5, &k, console_error))
{
for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].type = k;
- }
+ {
+ if(parts[i].type == j)
+ parts[i].type = k;
+ }
}
else
{
if (console_parse_partref(console4, &i, console_error)
- && console_parse_type(console5, &j, console_error))
+ && console_parse_type(console5, &j, console_error))
{
parts[i].type = j;
}
@@ -2813,10 +2813,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{
k = atoi(console5);
for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].temp= k;
- }
+ {
+ if(parts[i].type == j)
+ parts[i].temp= k;
+ }
}
else
{
@@ -2842,10 +2842,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{
k = atoi(console5);
for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].tmp = k;
- }
+ {
+ if(parts[i].type == j)
+ parts[i].tmp = k;
+ }
}
else
{
@@ -2871,10 +2871,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{
k = atoi(console5);
for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].x = k;
- }
+ {
+ if(parts[i].type == j)
+ parts[i].x = k;
+ }
}
else
{
@@ -2900,10 +2900,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{
k = atoi(console5);
for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].y = k;
- }
+ {
+ if(parts[i].type == j)
+ parts[i].y = k;
+ }
}
else
{
@@ -2926,18 +2926,18 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
}
}
else if (console_parse_type(console4, &j, console_error)
- && console_parse_type(console5, &k, console_error))
+ && console_parse_type(console5, &k, console_error))
{
for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].ctype = k;
- }
+ {
+ if(parts[i].type == j)
+ parts[i].ctype = k;
+ }
}
else
{
if (console_parse_partref(console4, &i, console_error)
- && console_parse_type(console5, &j, console_error))
+ && console_parse_type(console5, &j, console_error))
{
parts[i].ctype = j;
}
@@ -2958,10 +2958,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{
k = atoi(console5);
for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].vx = k;
- }
+ {
+ if(parts[i].type == j)
+ parts[i].vx = k;
+ }
}
else
{
@@ -2987,10 +2987,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{
k = atoi(console5);
for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].vy = k;
- }
+ {
+ if(parts[i].type == j)
+ parts[i].vy = k;
+ }
}
else
{
diff --git a/src/powder.c b/src/powder.c
index 6897cb1..4d8ba45 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