Merge branch 'dev' of git://github.com/jacksonmj/The-Powder-Toy

This commit is contained in:
Simon 2011-02-09 15:56:30 +00:00
commit 3de4d163a5
9 changed files with 290 additions and 243 deletions

View File

@ -99,7 +99,7 @@ int GRAV_G2;
int GRAV_B2; int GRAV_B2;
extern int legacy_enable; extern int legacy_enable;
extern int sound_enable;
extern int kiosk_enable; extern int kiosk_enable;
extern int sys_pause; extern int sys_pause;

View File

@ -447,16 +447,16 @@ static const part_type ptypes[PT_NUM] =
{"HSWC", PIXPACK(0x3B1010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Heat switch. Conducts Heat only when activated", ST_NONE, TYPE_SOLID, &update_HSWC}, {"HSWC", PIXPACK(0x3B1010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Heat switch. Conducts Heat only when activated", ST_NONE, TYPE_SOLID, &update_HSWC},
{"IRON", PIXPACK(0x707070), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 50, 1, 100, SC_CRACKER2, R_TEMP+0.0f +273.15f, 251, "Rusts with salt, can be used for electrolysis of WATR", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS, &update_IRON}, {"IRON", PIXPACK(0x707070), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 50, 1, 100, SC_CRACKER2, R_TEMP+0.0f +273.15f, 251, "Rusts with salt, can be used for electrolysis of WATR", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS, &update_IRON},
{"MORT", PIXPACK(0xE0E0E0), 0.0f, 0.00f * CFDS, 1.00f, 1.00f, -0.99f, 0.0f, 0.01f, 0.002f * CFDS, 0, 0, 0, 0, 0, 1, -1, SC_CRACKER2, R_TEMP+4.0f +273.15f, 60, "Steam Train.", ST_NONE, TYPE_PART, &update_MORT}, {"MORT", PIXPACK(0xE0E0E0), 0.0f, 0.00f * CFDS, 1.00f, 1.00f, -0.99f, 0.0f, 0.01f, 0.002f * CFDS, 0, 0, 0, 0, 0, 1, -1, SC_CRACKER2, R_TEMP+4.0f +273.15f, 60, "Steam Train.", ST_NONE, TYPE_PART, &update_MORT},
{"GOL ", PIXPACK(0x0CAC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Game Of Life! B3/S23", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"GOL", PIXPACK(0x0CAC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Game Of Life! B3/S23", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
{"HLIF", PIXPACK(0xFF0000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "High Life! B36/S23", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"HLIF", PIXPACK(0xFF0000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "High Life! B36/S23", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
{"ASIM", PIXPACK(0x0000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Assimilation! B345/S4567", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"ASIM", PIXPACK(0x0000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Assimilation! B345/S4567", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
{"2x2 ", PIXPACK(0xFFFF00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "2x2! B36/S125", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"2x2", PIXPACK(0xFFFF00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "2x2! B36/S125", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
{"DANI", PIXPACK(0x00FFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Day and Night! B3678/S34678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"DANI", PIXPACK(0x00FFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Day and Night! B3678/S34678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
{"AMOE", PIXPACK(0xFF00FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Amoeba! B357/S1358", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"AMOE", PIXPACK(0xFF00FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Amoeba! B357/S1358", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
{"MOVE", PIXPACK(0xFFFFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "'Move' particles! Does not move things.. it is a life type B368/S245", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"MOVE", PIXPACK(0xFFFFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "'Move' particles! Does not move things.. it is a life type B368/S245", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
{"PGOL", PIXPACK(0xE05010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Pseudo Life! B357/S238", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"PGOL", PIXPACK(0xE05010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Pseudo Life! B357/S238", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
{"DMOE", PIXPACK(0x500000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Diamoeba! B35678/S5678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"DMOE", PIXPACK(0x500000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Diamoeba! B35678/S5678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
{"34 ", PIXPACK(0x500050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "34! B34/S34)", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"34", PIXPACK(0x500050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "34! B34/S34)", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
{"LLIF", PIXPACK(0x505050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Long Life! B345/S5", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"LLIF", PIXPACK(0x505050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Long Life! B345/S5", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
{"STAN", PIXPACK(0x5000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Stains! B3678/S235678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"STAN", PIXPACK(0x5000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Stains! B3678/S235678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
{"SPNG", PIXPACK(0xFFBE30), 0.00f, 0.00f * CFDS, 0.00f, 1.00f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 1, 30, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "A sponge, absorbs water.", ST_SOLID, TYPE_SOLID, &update_SPNG}, {"SPNG", PIXPACK(0xFFBE30), 0.00f, 0.00f * CFDS, 0.00f, 1.00f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 1, 30, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "A sponge, absorbs water.", ST_SOLID, TYPE_SOLID, &update_SPNG},
@ -767,10 +767,11 @@ static int lolzrule[9][9] =
{0,1,0,0,0,0,0,1,0}, {0,1,0,0,0,0,0,1,0},
{0,1,0,0,0,0,0,1,0}, {0,1,0,0,0,0,0,1,0},
}; };
int portal[(int)(MAX_TEMP-73.15f)/100+2][8][80]; #define CHANNELS ((int)(MAX_TEMP-73.15f)/100+2)
float portaltemp[(int)(MAX_TEMP-73.15f)/100+2][8][80]; int portal[CHANNELS][8][80];
int portalctype[(int)(MAX_TEMP-73.15f)/100+2][8][80]; float portaltemp[CHANNELS][8][80];
int wireless[(int)(MAX_TEMP-73.15f)/100+2][2]; int portalctype[CHANNELS][8][80];
int wireless[CHANNELS][2];
extern int isplayer; extern int isplayer;
extern float player[27]; extern float player[27];

View File

@ -4,6 +4,8 @@ int update_PRTI(UPDATE_FUNC_ARGS) {
int r, nnx, rx, ry; int r, nnx, rx, ry;
int count =0; int count =0;
parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1);
if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1;
else if (parts[i].tmp<0) parts[i].tmp = 0;
for (rx=-1; rx<2; rx++) for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++) 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))

View File

@ -4,6 +4,8 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
int r, nnx, rx, ry, np; int r, nnx, rx, ry, np;
int count = 0; int count = 0;
parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1);
if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1;
else if (parts[i].tmp<0) parts[i].tmp = 0;
for (rx=-1; rx<2; rx++) for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++) 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))

View File

@ -3,6 +3,8 @@
int update_WIFI(UPDATE_FUNC_ARGS) { int update_WIFI(UPDATE_FUNC_ARGS) {
int r, rx, ry; int r, rx, ry;
parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1);
if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1;
else if (parts[i].tmp<0) parts[i].tmp = 0;
for (rx=-1; rx<2; rx++) for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++) 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))

View File

@ -855,49 +855,65 @@ int drawtextwrap(pixel *vid, int x, int y, int w, const char *s, int r, int g, i
int rh = 12; int rh = 12;
int rw = 0; int rw = 0;
int cw = x; int cw = x;
for (; *s; s++) int wordlen;
int charspace;
while (*s)
{ {
if (*s == '\n') wordlen = strcspn(s," .,!?\n");
charspace = textwidthx(s, w-(x-cw));
if (charspace<wordlen && wordlen && w-(x-cw)<w/3)
{ {
x = sx; x = sx;
rw = 0; rw = 0;
y += FONT_H+2; y+=FONT_H+2;
rh+=FONT_H+2;
} }
else if (*s == '\b') for (; *s && --wordlen>=-1; s++)
{ {
switch (s[1]) if (*s == '\n')
{ {
case 'w':
r = g = b = 255;
break;
case 'g':
r = g = b = 192;
break;
case 'o':
r = 255;
g = 216;
b = 32;
break;
case 'r':
r = 255;
g = b = 0;
break;
case 'b':
r = g = 0;
b = 255;
break;
}
s++;
}
else
{
if (x-cw>=w) {
x = sx; x = sx;
rw = 0; rw = 0;
y+=FONT_H+2; y += FONT_H+2;
rh+=FONT_H+2; }
else if (*s == '\b')
{
switch (s[1])
{
case 'w':
r = g = b = 255;
break;
case 'g':
r = g = b = 192;
break;
case 'o':
r = 255;
g = 216;
b = 32;
break;
case 'r':
r = 255;
g = b = 0;
break;
case 'b':
r = g = 0;
b = 255;
break;
}
s++;
}
else
{
if (x-cw>=w)
{
x = sx;
rw = 0;
y+=FONT_H+2;
rh+=FONT_H+2;
}
x = drawchar(vid, x, y, *(unsigned char *)s, r, g, b, a);
} }
x = drawchar(vid, x, y, *(unsigned char *)s, r, g, b, a);
} }
} }
#endif #endif
@ -1009,18 +1025,29 @@ void textnpos(char *s, int n, int w, int *cx, int *cy)
{ {
int x = 0; int x = 0;
int y = 0; int y = 0;
//TODO: Implement Textnheight for wrapped text int wordlen, charspace;
for (; *s; s++) while (*s&&n)
{ {
if (!n) { wordlen = strcspn(s," .,!?\n");
break; charspace = textwidthx(s, w-x);
} if (charspace<wordlen && wordlen && w-x<w/3)
x += font_data[font_ptrs[(int)(*(unsigned char *)s)]]; {
if (x>=w) {
x = 0; x = 0;
y += FONT_H+2; y += FONT_H+2;
} }
n--; for (; *s && --wordlen>=-1; s++)
{
if (!n) {
break;
}
x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
if (x>=w)
{
x = 0;
y += FONT_H+2;
}
n--;
}
} }
*cx = x-1; *cx = x-1;
*cy = y; *cy = y;
@ -1041,18 +1068,28 @@ int textwidthx(char *s, int w)
} }
int textposxy(char *s, int width, int w, int h) int textposxy(char *s, int width, int w, int h)
{ {
int x=0,y=0,n=0,cw; int x=0,y=0,n=0,cw, wordlen, charspace;
for (; *s; s++) while (*s)
{ {
cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]]; wordlen = strcspn(s," .,!?\n");
if (x+(cw/2) >= w && y+6 >= h) charspace = textwidthx(s, width-x);
break; if (charspace<wordlen && wordlen && width-x<width/3)
x += cw; {
if (x>=width) {
x = 0; x = 0;
y += FONT_H+2; y += FONT_H+2;
} }
n++; for (; *s && --wordlen>=-1; s++)
{
cw = font_data[font_ptrs[(int)(*(unsigned char *)s)]];
if ((x+(cw/2) >= w && y+6 >= h)||(y+6 >= h+FONT_H+2))
return n++;
x += cw;
if (x>=width) {
x = 0;
y += FONT_H+2;
}
n++;
}
} }
return n; return n;
} }
@ -1483,7 +1520,9 @@ void draw_parts(pixel *vid)
t!=PT_HFLM && t!=PT_SPRK && t!=PT_FIRW && t!=PT_HFLM && t!=PT_SPRK && t!=PT_FIRW &&
t!=PT_DUST && t!=PT_FIRW && t!=PT_FWRK && t!=PT_DUST && t!=PT_FIRW && t!=PT_FWRK &&
t!=PT_NEUT && t!=PT_LAVA && t!=PT_BOMB && t!=PT_NEUT && t!=PT_LAVA && t!=PT_BOMB &&
t!=PT_PHOT && t!=PT_THDR && t!=PT_SMKE) t!=PT_PHOT && t!=PT_THDR && t!=PT_SMKE &&
t!=PT_LCRY && t!=PT_SWCH && t!=PT_PCLN &&
t!=PT_PUMP && t!=PT_HSWC && t!=PT_FILT)
{ {
if (ptypes[parts[i].type].properties&TYPE_LIQUID) if (ptypes[parts[i].type].properties&TYPE_LIQUID)
{ {
@ -2907,7 +2946,7 @@ void render_signs(pixel *vid_buf)
sprintf(buff, "Temp: 0.00"); //...tempirature sprintf(buff, "Temp: 0.00"); //...tempirature
drawtext(vid_buf, x+3, y+3, buff, 255, 255, 255, 255); drawtext(vid_buf, x+3, y+3, buff, 255, 255, 255, 255);
} }
if(sregexp(signs[i].text, "^{c:[0-9]*|.*}$")==0) if(sregexp(signs[i].text, "^{c:[0-9]*|.*}$")==0)
{ {
int sldr, startm; int sldr, startm;

View File

@ -96,7 +96,7 @@ void get_sign_pos(int i, int *x0, int *y0, int *w, int *h)
memset(buff, 0, sizeof(buff)); memset(buff, 0, sizeof(buff));
for(sldr=3; signs[i].text[sldr-1] != '|'; sldr++) for(sldr=3; signs[i].text[sldr-1] != '|'; sldr++)
startm = sldr + 1; startm = sldr + 1;
sldr = startm; sldr = startm;
while(signs[i].text[sldr] != '}') 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; *w = textwidth(buff) + 5;
} }
//Ususal width //Ususal width
if (strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$")) if (strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$"))
*w = textwidth(signs[i].text) + 5; *w = textwidth(signs[i].text) + 5;
@ -874,13 +874,13 @@ void login_ui(pixel *vid_buf)
*(s_id++) = 0; *(s_id++) = 0;
u_e = strchr(s_id, ' '); u_e = strchr(s_id, ' ');
if (!u_e){ if (!u_e) {
u_e = malloc(1); u_e = malloc(1);
memset(u_e, 0, 1); memset(u_e, 0, 1);
} }
else else
*(u_e++) = 0; *(u_e++) = 0;
strcpy(svf_user_id, res+3); strcpy(svf_user_id, res+3);
strcpy(svf_session_id, s_id); strcpy(svf_session_id, s_id);
nres = mystrdup(u_e); 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? 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); 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" 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" "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 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 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" "You can now use particle names (ex. set type all deut)\n"
"Reset works with pressure, velocity, sparks, temp (ex. 'reset pressure')\n" "Reset works with pressure, velocity, sparks, temp (ex. 'reset pressure')\n"
"To load a save use load saveID (ex. load 1337)\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" "Create particles with 'create deut x,y' where x and y are the coords\n"
"Run scripts from file 'file filename'\n" "Run scripts from file 'file filename'\n"
"You can delete/kill a particle with 'kill x,y'" "You can delete/kill a particle with 'kill x,y'"
"Play a sound with (sound blah.wav)" "Play a sound with (sound blah.wav)"
,255, 187, 187, 255); ,255, 187, 187, 255);
cc = 0; cc = 0;
currentcommand = last_command; currentcommand = last_command;
while(cc < 10) while(cc < 10)
@ -3957,19 +3957,7 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show
int console_parse_type(char *txt, int *element, char *err) int console_parse_type(char *txt, int *element, char *err)
{ {
int i = atoi(txt); int i = -1;
char num[4];
if (i>=0 && i<PT_NUM)
{
sprintf(num,"%d",i);
if (strcmp(txt,num)==0)
{
*element = i;
strcpy(err,"");
return 1;
}
}
i = -1;
// alternative names for some elements // alternative names for some elements
if (strcasecmp(txt,"C4")==0) i = PT_PLEX; if (strcasecmp(txt,"C4")==0) i = PT_PLEX;
else if (strcasecmp(txt,"C5")==0) i = PT_C5; else if (strcasecmp(txt,"C5")==0) i = PT_C5;
@ -3995,13 +3983,7 @@ int console_parse_coords(char *txt, int *x, int *y, char *err)
{ {
// TODO: use regex? // TODO: use regex?
int nx = -1, ny = -1; int nx = -1, ny = -1;
sscanf(txt,"%d,%d",&nx,&ny); if (sscanf(txt,"%d,%d",&nx,&ny)!=2 || nx<0 || nx>=XRES || ny<0 || ny>=YRES)
if (nx<0 && nx>=XRES)
{
strcpy(err,"Invalid coordinates");
return 0;
}
if (ny<0 && ny>=YRES)
{ {
strcpy(err,"Invalid coordinates"); strcpy(err,"Invalid coordinates");
return 0; return 0;
@ -4012,9 +3994,10 @@ int console_parse_coords(char *txt, int *x, int *y, char *err)
} }
int console_parse_partref(char *txt, int *which, char *err) int console_parse_partref(char *txt, int *which, char *err)
{ {
strcpy(err,"");
// TODO: use regex? // TODO: use regex?
int i = -1, nx, ny; int i = -1, nx, ny;
if (console_parse_coords(txt, &nx, &ny, err)) if (strchr(txt,',') && console_parse_coords(txt, &nx, &ny, err))
{ {
i = pmap[ny][nx]; i = pmap[ny][nx];
if (!i || (i>>8)>=NPART) if (!i || (i>>8)>=NPART)
@ -4025,7 +4008,6 @@ int console_parse_partref(char *txt, int *which, char *err)
else if (txt) else if (txt)
{ {
char *num = (char*)malloc(strlen(txt)+3); char *num = (char*)malloc(strlen(txt)+3);
strcpy(err,""); // suppress error message from failed coordinate parsing
i = atoi(txt); i = atoi(txt);
sprintf(num,"%d",i); sprintf(num,"%d",i);
if (!txt || strcmp(txt,num)!=0) if (!txt || strcmp(txt,num)!=0)
@ -4038,6 +4020,6 @@ int console_parse_partref(char *txt, int *which, char *err)
strcpy(err,""); strcpy(err,"");
return 1; return 1;
} }
strcpy(err,"Particle does not exist"); if (strcmp(err,"")==0) strcpy(err,"Particle does not exist");
return 0; return 0;
} }

View File

@ -54,65 +54,67 @@
#define NUM_SOUNDS 2 #define NUM_SOUNDS 2
struct sample { struct sample {
Uint8 *data; Uint8 *data;
Uint32 dpos; Uint32 dpos;
Uint32 dlen; Uint32 dlen;
} sounds[NUM_SOUNDS]; } sounds[NUM_SOUNDS];
void mixaudio(void *unused, Uint8 *stream, int len) void mixaudio(void *unused, Uint8 *stream, int len)
{ {
int i; int i;
Uint32 amount; Uint32 amount;
for ( i=0; i<NUM_SOUNDS; ++i ) { for ( i=0; i<NUM_SOUNDS; ++i ) {
amount = (sounds[i].dlen-sounds[i].dpos); amount = (sounds[i].dlen-sounds[i].dpos);
if ( amount > len ) { if ( amount > len ) {
amount = len; amount = len;
} }
SDL_MixAudio(stream, &sounds[i].data[sounds[i].dpos], amount, SDL_MIX_MAXVOLUME); SDL_MixAudio(stream, &sounds[i].data[sounds[i].dpos], amount, SDL_MIX_MAXVOLUME);
sounds[i].dpos += amount; sounds[i].dpos += amount;
} }
} }
void play_sound(char *file) void play_sound(char *file)
{ {
int index; int index;
SDL_AudioSpec wave; SDL_AudioSpec wave;
Uint8 *data; Uint8 *data;
Uint32 dlen; Uint32 dlen;
SDL_AudioCVT cvt; SDL_AudioCVT cvt;
/* Look for an empty (or finished) sound slot */ if (!sound_enable) return;
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 */ /* Look for an empty (or finished) sound slot */
if ( SDL_LoadWAV(file, &wave, &data, &dlen) == NULL ) { for ( index=0; index<NUM_SOUNDS; ++index ) {
fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError()); if ( sounds[index].dpos == sounds[index].dlen ) {
return; break;
} }
SDL_BuildAudioCVT(&cvt, wave.format, wave.channels, wave.freq, }
AUDIO_S16, 2, 22050); if ( index == NUM_SOUNDS )
cvt.buf = malloc(dlen*cvt.len_mult); return;
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) */ /* Load the sound file and convert it to 16-bit stereo at 22kHz */
if ( sounds[index].data ) { if ( SDL_LoadWAV(file, &wave, &data, &dlen) == NULL ) {
free(sounds[index].data); fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
} return;
SDL_LockAudio(); }
sounds[index].data = cvt.buf; SDL_BuildAudioCVT(&cvt, wave.format, wave.channels, wave.freq,
sounds[index].dlen = cvt.len_cvt; AUDIO_S16, 2, 22050);
sounds[index].dpos = 0; cvt.buf = malloc(dlen*cvt.len_mult);
SDL_UnlockAudio(); 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 = static const char *it_msg =
@ -167,6 +169,7 @@ int FPSB = 0;
int MSIGN =-1; int MSIGN =-1;
//int CGOL = 0; //int CGOL = 0;
//int GSPEED = 1;//causes my .exe to crash.. //int GSPEED = 1;//causes my .exe to crash..
int sound_enable;
sign signs[MAXSIGNS]; sign signs[MAXSIGNS];
@ -1196,7 +1199,7 @@ int main(int argc, char *argv[])
pixel *load_img=NULL;//, *fbi_img=NULL; 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; int save_mode=0, save_x=0, save_y=0, save_w=0, save_h=0, copy_mode=0;
GSPEED = 1; GSPEED = 1;
SDL_AudioSpec fmt; SDL_AudioSpec fmt;
/* Set 16-bit stereo audio at 22Khz */ /* Set 16-bit stereo audio at 22Khz */
fmt.freq = 22050; fmt.freq = 22050;
@ -1209,9 +1212,12 @@ int main(int argc, char *argv[])
if ( SDL_OpenAudio(&fmt, NULL) < 0 ) if ( SDL_OpenAudio(&fmt, NULL) < 0 )
{ {
fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError()); fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError());
exit(1);
} }
SDL_PauseAudio(0); else
{
sound_enable = 1;
SDL_PauseAudio(0);
}
#ifdef MT #ifdef MT
numCores = core_count(); numCores = core_count();
#endif #endif
@ -1930,7 +1936,7 @@ int main(int argc, char *argv[])
int tctype = parts[cr>>8].ctype; int tctype = parts[cr>>8].ctype;
if (tctype>=PT_NUM) if (tctype>=PT_NUM)
tctype = 0; tctype = 0;
sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d, #%d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life, cr>>8);
//sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); //sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life);
} else } else
sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life);
@ -1941,7 +1947,6 @@ int main(int argc, char *argv[])
if (tctype>=PT_NUM) if (tctype>=PT_NUM)
tctype = 0; tctype = 0;
sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d, #%d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life ,cr>>8); sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d, #%d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life ,cr>>8);
sprintf(coordtext, "X:%d Y:%d", x/sdl_scale, y/sdl_scale);
//sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); //sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life);
} else { } else {
sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f); sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f);
@ -1950,10 +1955,10 @@ int main(int argc, char *argv[])
} }
else else
{ {
if (DEBUG_MODE)
sprintf(coordtext, "X:%d Y:%d", x/sdl_scale, y/sdl_scale);
sprintf(heattext, "Empty, Pressure: %3.2f", pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL]); sprintf(heattext, "Empty, Pressure: %3.2f", pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL]);
} }
if (DEBUG_MODE)
sprintf(coordtext, "X:%d Y:%d", x/sdl_scale, y/sdl_scale);
} }
mx = x; mx = x;
my = y; my = y;
@ -2340,10 +2345,10 @@ int main(int argc, char *argv[])
else if (y<YRES) else if (y<YRES)
{ {
int signi; int signi;
c = (b&1) ? sl : sr; c = (b&1) ? sl : sr;
su = c; su = c;
if(c!=WL_SIGN+100) if(c!=WL_SIGN+100)
{ {
if(!bq) if(!bq)
@ -2356,12 +2361,12 @@ int main(int argc, char *argv[])
{ {
char buff[256]; char buff[256];
int sldr; int sldr;
memset(buff, 0, sizeof(buff)); memset(buff, 0, sizeof(buff));
for(sldr=3; signs[signi].text[sldr] != '|'; sldr++) for(sldr=3; signs[signi].text[sldr] != '|'; sldr++)
buff[sldr-3] = signs[signi].text[sldr]; buff[sldr-3] = signs[signi].text[sldr];
char buff2[sldr-2]; //TODO: Fix this for Visual Studio char buff2[sldr-2]; //TODO: Fix this for Visual Studio
memset(buff2, 0, sizeof(buff2)); memset(buff2, 0, sizeof(buff2));
memcpy(&buff2, &buff, sldr-3); memcpy(&buff2, &buff, sldr-3);
@ -2369,7 +2374,7 @@ int main(int argc, char *argv[])
} }
} }
} }
if (c==WL_SIGN+100) if (c==WL_SIGN+100)
{ {
if (!bq) if (!bq)
@ -2697,7 +2702,7 @@ int main(int argc, char *argv[])
if(DEBUG_MODE) if(DEBUG_MODE)
{ {
fillrect(vid_buf, XRES-20-textwidth(coordtext), 26, textwidth(coordtext)+8, 11, 0, 0, 0, 140); 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); fillrect(vid_buf, 12, 12, textwidth(uitext)+8, 15, 0, 0, 0, 140);
@ -2826,7 +2831,8 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
} }
else if(strcmp(console2, "sound")==0 && console3) else if(strcmp(console2, "sound")==0 && console3)
{ {
play_sound(console3); if (sound_enable) play_sound(console3);
else strcpy(console_error, "Audio device not available - cannot play sounds");
} }
else if(strcmp(console2, "load")==0 && console3) else if(strcmp(console2, "load")==0 && console3)
{ {
@ -2856,7 +2862,7 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
else if (strcmp(console2, "create")==0 && console3 && console4) else if (strcmp(console2, "create")==0 && console3 && console4)
{ {
if (console_parse_type(console3, &j, console_error) 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) if (!j)
strcpy(console_error, "Cannot create particle with type NONE"); strcpy(console_error, "Cannot create particle with type NONE");
@ -2927,10 +2933,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{ {
k = atoi(console5); k = atoi(console5);
for(i=0; i<NPART; i++) for(i=0; i<NPART; i++)
{ {
if(parts[i].type == j) if(parts[i].type == j)
parts[i].life = k; parts[i].life = k;
} }
} }
else else
{ {
@ -2953,18 +2959,18 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
} }
} }
else if (console_parse_type(console4, &j, 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++) for(i=0; i<NPART; i++)
{ {
if(parts[i].type == j) if(parts[i].type == j)
parts[i].type = k; parts[i].type = k;
} }
} }
else else
{ {
if (console_parse_partref(console4, &i, console_error) 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; parts[i].type = j;
} }
@ -2985,10 +2991,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{ {
k = atoi(console5); k = atoi(console5);
for(i=0; i<NPART; i++) for(i=0; i<NPART; i++)
{ {
if(parts[i].type == j) if(parts[i].type == j)
parts[i].temp= k; parts[i].temp= k;
} }
} }
else else
{ {
@ -3014,10 +3020,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{ {
k = atoi(console5); k = atoi(console5);
for(i=0; i<NPART; i++) for(i=0; i<NPART; i++)
{ {
if(parts[i].type == j) if(parts[i].type == j)
parts[i].tmp = k; parts[i].tmp = k;
} }
} }
else else
{ {
@ -3043,10 +3049,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{ {
k = atoi(console5); k = atoi(console5);
for(i=0; i<NPART; i++) for(i=0; i<NPART; i++)
{ {
if(parts[i].type == j) if(parts[i].type == j)
parts[i].x = k; parts[i].x = k;
} }
} }
else else
{ {
@ -3072,10 +3078,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{ {
k = atoi(console5); k = atoi(console5);
for(i=0; i<NPART; i++) for(i=0; i<NPART; i++)
{ {
if(parts[i].type == j) if(parts[i].type == j)
parts[i].y = k; parts[i].y = k;
} }
} }
else else
{ {
@ -3098,18 +3104,18 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
} }
} }
else if (console_parse_type(console4, &j, 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++) for(i=0; i<NPART; i++)
{ {
if(parts[i].type == j) if(parts[i].type == j)
parts[i].ctype = k; parts[i].ctype = k;
} }
} }
else else
{ {
if (console_parse_partref(console4, &i, console_error) 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; parts[i].ctype = j;
} }
@ -3130,10 +3136,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{ {
k = atoi(console5); k = atoi(console5);
for(i=0; i<NPART; i++) for(i=0; i<NPART; i++)
{ {
if(parts[i].type == j) if(parts[i].type == j)
parts[i].vx = k; parts[i].vx = k;
} }
} }
else else
{ {
@ -3159,10 +3165,10 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
{ {
k = atoi(console5); k = atoi(console5);
for(i=0; i<NPART; i++) for(i=0; i<NPART; i++)
{ {
if(parts[i].type == j) if(parts[i].type == j)
parts[i].vy = k; parts[i].vy = k;
} }
} }
else else
{ {

View File

@ -255,11 +255,9 @@ int try_move(int i, int x, int y, int nx, int ny)
parts[e].x += x-nx; parts[e].x += x-nx;
parts[e].y += y-ny; parts[e].y += y-ny;
pmap[(int)(parts[e].y+0.5f)][(int)(parts[e].x+0.5f)] = (e<<8)|parts[e].type;
} }
pmap[ny][nx] = (i<<8)|parts[i].type;
pmap[y][x] = r;
return 1; return 1;
} }
@ -417,33 +415,31 @@ void kill_part(int i)
{ {
int x, y; int x, y;
if (parts[i].type != PT_PHOT) { x = (int)(parts[i].x+0.5f);
x = (int)(parts[i].x+0.5f); y = (int)(parts[i].y+0.5f);
y = (int)(parts[i].y+0.5f); if (parts[i].type == PT_STKM)
if (parts[i].type == PT_STKM) {
{ death = 1;
death = 1; isplayer = 0;
isplayer = 0; }
} if (parts[i].type == PT_STKM2)
if (parts[i].type == PT_STKM2) {
{ death2 = 1;
death2 = 1; isplayer2 = 0;
isplayer2 = 0; }
} if (parts[i].type == PT_SPAWN)
if (parts[i].type == PT_SPAWN) {
{ ISSPAWN1 = 0;
ISSPAWN1 = 0; }
} if (parts[i].type == PT_SPAWN2)
if (parts[i].type == PT_SPAWN2) {
{ ISSPAWN2 = 0;
ISSPAWN2 = 0; }
} if (x>=0 && y>=0 && x<XRES && y<YRES) {
if (x>=0 && y>=0 && x<XRES && y<YRES) { if ((pmap[y][x]>>8)==i)
if ((pmap[y][x]>>8)==i) pmap[y][x] = 0;
pmap[y][x] = 0; else if ((photons[y][x]>>8)==i)
else if ((photons[y][x]>>8)==i) photons[y][x] = 0;
photons[y][x] = 0;
}
} }
parts[i].type = PT_NONE; parts[i].type = PT_NONE;
@ -460,10 +456,18 @@ inline void part_change_type(int i, int x, int y, int t)
if (x<0 || y<0 || x>=XRES || y>=YRES || i>=NPART) if (x<0 || y<0 || x>=XRES || y>=YRES || i>=NPART)
return -1; return -1;
parts[i].type = t; parts[i].type = t;
if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT)// && t!=PT_NEUT) if (t==PT_PHOT)// || t==PT_NEUT)
{
photons[y][x] = t|(i<<8);
if ((pmap[y][x]>>8)==i)
pmap[y][x] = 0;
}
else
{
pmap[y][x] = t|(i<<8); pmap[y][x] = t|(i<<8);
else if ((pmap[y][x]>>8)==i) if ((photons[y][x]>>8)==i)
pmap[y][x] = 0; photons[y][x] = 0;
}
} }
#if defined(WIN32) && !defined(__GNUC__) #if defined(WIN32) && !defined(__GNUC__)
@ -502,6 +506,8 @@ inline int create_n_parts(int n, int x, int y, float vx, float vy, int t)
parts[i].tmp = 0; parts[i].tmp = 0;
if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT && !pmap[y][x])// && t!=PT_NEUT) if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT && !pmap[y][x])// && t!=PT_NEUT)
pmap[y][x] = t|(i<<8); pmap[y][x] = t|(i<<8);
else if (t==PT_PHOT && !photons[y][x])
photons[y][x] = t|(i<<8);
pv[y/CELL][x/CELL] += 6.0f * CFDS; pv[y/CELL][x/CELL] += 6.0f * CFDS;
} }
@ -1343,15 +1349,13 @@ void update_particles_i(pixel *vid, int start, int inc)
if(parts[r>>8].tmp==grule[golnum][9]-1) if(parts[r>>8].tmp==grule[golnum][9]-1)
parts[r>>8].tmp --; parts[r>>8].tmp --;
} }
if(parts[r>>8].tmp<=0) if (r && parts[r>>8].tmp<=0)
parts[r>>8].type = PT_NONE;//using kill_part makes it not work parts[r>>8].type = PT_NONE;//using kill_part makes it not work
} }
gol2[nx][ny][0] = 0;
for ( z = 1; z<=NGOL; z++)
gol2[nx][ny][z] = 0;
} }
if (createdsomething) if (createdsomething)
GENERATION ++; GENERATION ++;
memset(gol2, 0, sizeof(gol2));
} }
if (ISWIRE==1) if (ISWIRE==1)
{ {
@ -1527,10 +1531,10 @@ void update_particles_i(pixel *vid, int start, int inc)
ctemph = ctempl = pt; ctemph = ctempl = pt;
// change boiling point with pressure // 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) 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) || t==PT_LNTG || t==PT_SLTW)
ctemph -= 2.0f*pv[y/CELL][x/CELL]; 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) 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) || t==PT_WTRV)
ctempl -= 2.0f*pv[y/CELL][x/CELL]; ctempl -= 2.0f*pv[y/CELL][x/CELL];
s = 1; s = 1;
if (ctemph>ptransitions[t].thv&&ptransitions[t].tht>-1) { if (ctemph>ptransitions[t].thv&&ptransitions[t].tht>-1) {
@ -2032,10 +2036,19 @@ killed:
} }
nx = (int)(parts[i].x+0.5f); nx = (int)(parts[i].x+0.5f);
ny = (int)(parts[i].y+0.5f); ny = (int)(parts[i].y+0.5f);
if (nx<CELL || nx>=XRES-CELL || ny<CELL || ny>=YRES-CELL) if (ny!=y || nx!=x)
{ {
kill_part(i); if ((pmap[y][x]>>8)==i) pmap[y][x] = 0;
continue; else if (t==PT_PHOT&&(photons[y][x]>>8)==i) photons[y][x] = 0;
if (nx<CELL || nx>=XRES-CELL || ny<CELL || ny>=YRES-CELL)
{
kill_part(i);
continue;
}
if (t==PT_PHOT)
photons[ny][nx] = t|(i<<8);
else
pmap[ny][nx] = t|(i<<8);
} }
} }
if (framerender) { if (framerender) {