summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon <simon@hardwired.org.uk>2011-01-31 22:10:34 (GMT)
committer Simon <simon@hardwired.org.uk>2011-01-31 22:10:34 (GMT)
commitb033a9655d8a6670d207a172329b54daa8f30493 (patch)
treee15f94c374f3ad9b372359b2bc414e0993c04e88
parent5ec884993f62a37ded46ff1008c31dc8e0b4e8f4 (diff)
parentd52fa30a45f24ad8cb5e8669c7128b193b517590 (diff)
downloadpowder-b033a9655d8a6670d207a172329b54daa8f30493.zip
powder-b033a9655d8a6670d207a172329b54daa8f30493.tar.gz
Fix for liquids - jacksonmj
-rw-r--r--includes/defines.h4
-rw-r--r--includes/interface.h3
-rw-r--r--includes/powder.h4
-rw-r--r--src/interface.c137
-rw-r--r--src/main.c562
-rw-r--r--src/powder.c14
6 files changed, 436 insertions, 288 deletions
diff --git a/includes/defines.h b/includes/defines.h
index 95302fa..b3b604f 100644
--- a/includes/defines.h
+++ b/includes/defines.h
@@ -61,7 +61,7 @@ extern unsigned char ZSIZE;
#define STAMP_Y 4
#define STAMP_MAX 120
-#define NGOL 26
+#define NGOL 25
#define CIRCLE_BRUSH 0
#define SQUARE_BRUSH 1
@@ -136,7 +136,7 @@ int GSPEED;
int love[XRES/9][YRES/9];
int lolz[XRES/9][YRES/9];
int gol[XRES][YRES];
-int gol2[XRES][YRES][NGOL];
+int gol2[XRES][YRES][NGOL+1];
int SEC;
int SEC2;
int console_mode;
diff --git a/includes/interface.h b/includes/interface.h
index de1c955..2cb64dd 100644
--- a/includes/interface.h
+++ b/includes/interface.h
@@ -227,6 +227,9 @@ void open_link(char *uri);
int report_ui(pixel *vid_buf, char *save_id);
char *console_ui(pixel *vid_buf, char error[255]);
+int console_parse_coords(char *txt, int *x, int *y, char *err);
+int console_parse_type(char *txt, int *element, char *err);
+int console_parse_partref(char *txt, int *which, char *err);
#endif
diff --git a/includes/powder.h b/includes/powder.h
index 91d8f1f..b09ad5e 100644
--- a/includes/powder.h
+++ b/includes/powder.h
@@ -405,7 +405,7 @@ static const part_type ptypes[PT_NUM] =
{"WAX", PIXPACK(0xF0F0BB), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 10, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 44, "Wax. Melts at moderately high temperatures.", ST_SOLID, TYPE_SOLID, NULL},
{"MWAX", PIXPACK(0xE0E0AA), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.000001f* CFDS,2, 5, 0, 0, 2, 1, 25, SC_LIQUID, R_TEMP+28.0f+273.15f, 44, "Liquid Wax.", ST_LIQUID, TYPE_LIQUID, NULL},
{"PSCN", PIXPACK(0x805050), 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, "P-Type Silicon, Will transfer current to any conductor.", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS, NULL},
- {"NSCN", PIXPACK(0x505080), 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, "N-Type Silicon, Will only transfer current to P-Type Silicon.", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS, NULL},
+ {"NSCN", PIXPACK(0x505080), 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, "N-Type Silicon, Will not transfer current to P-Type Silicon.", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS, NULL},
{"LN2", PIXPACK(0x80A0DF), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 0, 1, 30, SC_LIQUID, 70.15f, 70, "Liquid Nitrogen. Very cold.", ST_SOLID, TYPE_LIQUID, NULL},
{"INSL", PIXPACK(0x9EA3B6), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 7, 0, 0, 10, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 0, "Insulator, does not conduct heat or electricity.", ST_SOLID, TYPE_SOLID, NULL},
{"BHOL", PIXPACK(0x202020), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, -0.01f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SPECIAL, R_TEMP+70.0f+273.15f, 255, "Black hole, sucks in other particles and heats up.", ST_NONE, TYPE_SOLID, NULL},
@@ -687,7 +687,7 @@ static part_transition ptransitions[PT_NUM] =
#undef ST
-static int grule[NGOL][10] =
+static int grule[NGOL+1][10] =
{
// 0,1,2,3,4,5,6,7,8,STATES live=1 spawn=2 spawn&live=3 States are kind of how long until it dies, normal ones use two states(living,dead) for others the intermediate states live but do nothing
{0,0,0,0,0,0,0,0,0,2},//blank
diff --git a/src/interface.c b/src/interface.c
index 43c66e8..5d23a5d 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -872,7 +872,7 @@ void login_ui(pixel *vid_buf)
if (!s_id)
goto fail;
*(s_id++) = 0;
-
+
u_e = strchr(s_id, ' ');
if (!u_e){
u_e = malloc(1);
@@ -884,9 +884,9 @@ void login_ui(pixel *vid_buf)
strcpy(svf_user_id, res+3);
strcpy(svf_session_id, s_id);
nres = mystrdup(u_e);
-
+
printf("\n{%s} {%s} {%s}\n", svf_user_id, svf_session_id, nres);
-
+
if (!strncmp(nres, "ADMIN", 5))
{
svf_admin = 1;
@@ -3862,17 +3862,20 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show
mx /= sdl_scale;
my /= sdl_scale;
ed.focus = 1;
-
+
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, 15, 15, "Welcome to The Powder Toy console v.1 (by cracker64)\n"
- "Current commands are quit, set, reset, load\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"
- "Reset works with pressure, velocity, sparks, temp (ex. 'reset pressure')\n"
- "To load a save use load saveID (ex. load 1337)"
- ,255, 187, 187, 255);
-
+ 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\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'"
+ ,255, 187, 187, 255);
+
cc = 0;
currentcommand = last_command;
while(cc < 10)
@@ -3884,18 +3887,18 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show
{
if(cc<9) {
currentcommand = currentcommand->prev_command;
- } else if(currentcommand->prev_command!=NULL){
+ } else if(currentcommand->prev_command!=NULL) {
free(currentcommand->prev_command);
currentcommand->prev_command = NULL;
}
cc++;
- }
+ }
else
{
break;
}
}
-
+
if(error)
drawtext(vid_buf, 15, 190, error,255, 187, 187, 255);
ui_edit_draw(vid_buf, &ed);
@@ -3927,18 +3930,18 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show
}
else
{
- if(last_command!=NULL){
+ if(last_command!=NULL) {
currentcommand = last_command;
for (cc = 0; cc<ci; cc++) {
if(currentcommand->prev_command==NULL)
ci = cc;
- else
+ else
currentcommand = currentcommand->prev_command;
}
strcpy(ed.str, currentcommand->command);
ed.cursor = strlen(ed.str);
}
- else
+ else
{
ci = -1;
strcpy(ed.str, "");
@@ -3946,9 +3949,101 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show
}
}
}
-
}
-
-
+ return NULL;
}
+int console_parse_type(char *txt, int *element, char *err)
+{
+ int i = atoi(txt);
+ char num[4];
+ if (i>=0 && i<PT_NUM)
+ {
+ sprintf(num,"%d",i);
+ if (strcmp(txt,num)==0)
+ {
+ *element = i;
+ return 1;
+ }
+ }
+ i = -1;
+ // alternative names for some elements
+ if (strcasecmp(txt,"C4")==0) i = PT_PLEX;
+ else if (strcasecmp(txt,"C5")==0) i = PT_C5;
+ else if (strcasecmp(txt,"NONE")==0) i = PT_NONE;
+ if (i>=0)
+ {
+ *element = i;
+ return 1;
+ }
+ for (i=1; i<PT_NUM; i++) {
+ if (strcasecmp(txt,ptypes[i].name)==0)
+ {
+ *element = i;
+ return 1;
+ }
+ }
+ strcpy(err, "Particle type not recognised");
+ return 0;
+}
+int console_parse_coords(char *txt, int *x, int *y, char *err)
+{
+ // TODO: use regex?
+ char *coordtxt;
+ char num[10] = "";
+ int nx = -1, ny = -1;
+ txt = mystrdup(txt);
+ coordtxt = strtok(txt, ",");
+ if (coordtxt) nx = atoi(coordtxt);
+ if (nx>=0 && nx<XRES) sprintf(num,"%d",nx);
+ if (!coordtxt || strcmp(coordtxt, num)!=0)
+ {
+ strcpy(err,"Invalid coordinates");
+ free(txt);
+ return 0;
+ }
+ strcpy(num,"");
+ coordtxt = strtok(NULL, ",");
+ if (coordtxt) ny = atoi(coordtxt);
+ if (ny>=0 && ny<YRES) sprintf(num,"%d",ny);
+ if (!coordtxt || strcmp(coordtxt, num)!=0)
+ {
+ strcpy(err,"Invalid coordinates");
+ free(txt);
+ return 0;
+ }
+ *x = nx;
+ *y = ny;
+ free(txt);
+ return 1;
+}
+int console_parse_partref(char *txt, int *which, char *err)
+{
+ // TODO: use regex?
+ int i = -1, nx, ny;
+ if (console_parse_coords(txt, &nx, &ny, err))
+ {
+ i = pmap[ny][nx];
+ if (!i || (i>>8)>=NPART)
+ i = -1;
+ else
+ i = i>>8;
+ }
+ else if (txt)
+ {
+ char *num = (char*)malloc(strlen(txt)+3);
+ strcpy(err,""); // suppress error message from failed coordinate parsing
+ i = atoi(txt);
+ sprintf(num,"%d",i);
+ if (!txt || strcmp(txt,num)!=0)
+ i = -1;
+ free(num);
+ }
+ if (i>=0 && i<NPART && parts[i].type)
+ {
+ *which = i;
+ return 1;
+ }
+ strcpy(err,"Particle does not exist");
+ return 0;
+}
diff --git a/src/main.c b/src/main.c
index 94d42cb..4c60d3f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -718,7 +718,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
ttv |= (d[p++]);
parts[i-1].tmp = ttv;
if(ptypes[parts[i-1].type].properties&PROP_LIFE && !parts[i-1].tmp)
- for(q = 1; q<NGOL ; q++) {
+ for(q = 1; q<=NGOL ; q++) {
if(parts[i-1].type==goltype[q-1] && grule[q][9]==2)
parts[i-1].tmp = grule[q][9]-1;
}
@@ -1121,7 +1121,7 @@ int main(int argc, char *argv[])
pixel *pers_bg=calloc((XRES+BARSIZE)*YRES, PIXELSIZE);
void *http_ver_check;
char *ver_data=NULL, *tmp;
- char error[255] = "";
+ char console_error[255] = "";
int i, j, bq, fire_fc=0, do_check=0, old_version=0, http_ret=0, major, minor, old_ver_len;
#ifdef INTERNAL
int vs = 0;
@@ -1698,264 +1698,16 @@ int main(int argc, char *argv[])
}
if(console_mode)
{
- int nx,ny;
char *console;
- char *console2;
- char *console3;
- char *console4;
- char *console5;
//char error[255] = "error!";
sys_pause = 1;
- console = console_ui(vid_buf,error);
+ console = console_ui(vid_buf,console_error);
console = mystrdup(console);
- strcpy(error,"");
- if(console && strcmp(console, "")!=0 && strncmp(console, " ", 1)!=0)
- {
- console2 = strtok(console, " ");
- console3 = strtok(NULL, " ");
- console4 = strtok(NULL, " ");
- console5 = strtok(NULL, " ");
- if(strcmp(console2, "quit")==0)
- {
- free(console);
- break;
- }
- else if(strcmp(console2, "load")==0 && console3)
- {
- j = atoi(console3);
- if(j)
- {
- open_ui(vid_buf, console3, NULL);
- console_mode = 0;
- }
- }
- else if(strcmp(console2, "reset")==0 && console3)
- {
- if(strcmp(console3, "pressure")==0)
- {
- for (nx = 0; nx<XRES/CELL; nx++)
- for (ny = 0; ny<YRES/CELL; ny++)
- {
- pv[ny][nx] = 0;
- }
-
- }
- else if(strcmp(console3, "velocity")==0)
- {
- for (nx = 0; nx<XRES/CELL; nx++)
- for (ny = 0; ny<YRES/CELL; ny++)
- {
- vx[ny][nx] = 0;
- vy[ny][nx] = 0;
- }
- }
- else if(strcmp(console3, "sparks")==0)
- {
- for(i=0;i<NPART;i++)
- {
- if(parts[i].type==PT_SPRK)
- {
- parts[i].type = parts[i].ctype;
- parts[i].life = 4;
- }
- }
- }
- else if(strcmp(console3, "temp")==0)
- {
- for(i=0;i<NPART;i++)
- {
- if(parts[i].type)
- {
- parts[i].temp = ptypes[parts[i].type].heat;
- }
- }
- }
- }
- else if(strcmp(console2, "set")==0 && console3 && console4 && console5)
- {
- if(strcmp(console3, "life")==0)
- {
- if(strcmp(console4, "all")==0)
- {
- j = atoi(console5);
- for(i=0;i<NPART;i++)
- {
- if(parts[i].type)
- parts[i].life = j;
- }
- } else
- {
- i = atoi(console4);
- if(parts[i].type)
- {
- j = atoi(console5);
- parts[i].life = j;
- }
- }
- }
- if(strcmp(console3, "type")==0)
- {
- if(strcmp(console4, "all")==0)
- {
- j = atoi(console5);
- for(i=0;i<NPART;i++)
- {
- if(parts[i].type)
- parts[i].type = j;
- }
- } else
- {
- i = atoi(console4);
- if(parts[i].type)
- {
- j = atoi(console5);
- parts[i].type = j;
- }
- }
- }
- if(strcmp(console3, "temp")==0)
- {
- if(strcmp(console4, "all")==0)
- {
- j = atoi(console5);
- for(i=0;i<NPART;i++)
- {
- if(parts[i].type)
- parts[i].temp = j;
- }
- } else
- {
- i = atoi(console4);
- if(parts[i].type)
- {
- j = atoi(console5);
- parts[i].temp = j;
- }
- }
- }
- if(strcmp(console3, "tmp")==0)
- {
- if(strcmp(console4, "all")==0)
- {
- j = atoi(console5);
- for(i=0;i<NPART;i++)
- {
- if(parts[i].type)
- parts[i].tmp = j;
- }
- } else
- {
- i = atoi(console4);
- if(parts[i].type)
- {
- j = atoi(console5);
- parts[i].tmp = j;
- }
- }
- }
- if(strcmp(console3, "x")==0)
- {
- if(strcmp(console4, "all")==0)
- {
- j = atoi(console5);
- for(i=0;i<NPART;i++)
- {
- if(parts[i].type)
- parts[i].x = j;
- }
- } else
- {
- i = atoi(console4);
- if(parts[i].type)
- {
- j = atoi(console5);
- parts[i].x = j;
- }
- }
- }
- if(strcmp(console3, "y")==0)
- {
- if(strcmp(console4, "all")==0)
- {
- j = atoi(console5);
- for(i=0;i<NPART;i++)
- {
- if(parts[i].type)
- parts[i].y = j;
- }
- } else
- {
- i = atoi(console4);
- if(parts[i].type)
- {
- j = atoi(console5);
- parts[i].y = j;
- }
- }
- }
- if(strcmp(console3, "ctype")==0)
- {
- if(strcmp(console4, "all")==0)
- {
- j = atoi(console5);
- for(i=0;i<NPART;i++)
- {
- if(parts[i].type)
- parts[i].ctype = j;
- }
- } else
- {
- i = atoi(console4);
- if(parts[i].type)
- {
- j = atoi(console5);
- parts[i].ctype = j;
- }
- }
- }
- if(strcmp(console3, "vx")==0)
- {
- if(strcmp(console4, "all")==0)
- {
- j = atoi(console5);
- for(i=0;i<NPART;i++)
- {
- if(parts[i].type)
- parts[i].vx = j;
- }
- } else
- {
- i = atoi(console4);
- if(parts[i].type)
- {
- j = atoi(console5);
- parts[i].vx = j;
- }
- }
- }
- if(strcmp(console3, "vy")==0)
- {
- if(strcmp(console4, "all")==0)
- {
- j = atoi(console5);
- for(i=0;i<NPART;i++)
- {
- if(parts[i].type)
- parts[i].vy = j;
- }
- } else
- {
- i = atoi(console4);
- if(parts[i].type)
- {
- j = atoi(console5);
- parts[i].vy = j;
- }
- }
- }
- }
- else
- sprintf(error, "Invalid Command", console2);
+ strcpy(console_error,"");
+ if(process_command(vid_buf,console,&console_error)==0)
+ {
+ free(console);
+ break;
}
free(console);
if(!console_mode)
@@ -2780,4 +2532,302 @@ int main(int argc, char *argv[])
http_done();
return 0;
}
+int process_command(pixel *vid_buf,char *console,char *console_error) {
+
+ int nx,ny,i,j;
+ char *console2;
+ char *console3;
+ char *console4;
+ char *console5;
+ //sprintf(console_error, "%s", console);
+ if(console && strcmp(console, "")!=0 && strncmp(console, " ", 1)!=0)
+ {
+ console2 = strtok(console, " ");
+ console3 = strtok(NULL, " ");
+ console4 = strtok(NULL, " ");
+ console5 = strtok(NULL, " ");
+ if(strcmp(console2, "quit")==0)
+ {
+ return 0;
+ }
+ else if(strcmp(console2, "file")==0 && console3)
+ {
+ FILE *f=fopen(console3, "r");
+ if(f)
+ {
+ char fileread[5000];//TODO: make this change with file size
+ char pch[5000];
+ fread(fileread,1,5000,f);
+ j = 0;
+ for(i=0; i<strlen(fileread); i++)
+ {
+ if(fileread[i] != '\n')
+ pch[i-j] = fileread[i];
+ else
+ {
+ process_command(vid_buf, pch, console_error);
+ memset(pch,0,sizeof(pch));
+ j = i+1;
+ }
+ }
+ //sprintf(console_error, "%s exists", console3);
+ fclose(f);
+ }
+ else
+ sprintf(console_error, "%s does not exist", console3);
+ }
+ else if(strcmp(console2, "load")==0 && console3)
+ {
+ j = atoi(console3);
+ if(j)
+ {
+ open_ui(vid_buf, console3, NULL);
+ console_mode = 0;
+ }
+ }
+ else if (strcmp(console2, "create")==0 && console3 && console4)
+ {
+ if (console_parse_type(console3, &j, console_error)
+ && console_parse_coords(console4, &nx, &ny, console_error))
+ {
+ if (!j)
+ strcpy(console_error, "Cannot create particle with type NONE");
+ else if (create_part(-1,nx,ny,j)<0)
+ strcpy(console_error, "Could not create particle");
+ }
+ }
+ else if ((strcmp(console2, "delete")==0 || strcmp(console2, "kill")==0) && console3)
+ {
+ if (console_parse_partref(console3, &i, console_error))
+ kill_part(i);
+ }
+ else if(strcmp(console2, "reset")==0 && console3)
+ {
+ if(strcmp(console3, "pressure")==0)
+ {
+ for (nx = 0; nx<XRES/CELL; nx++)
+ for (ny = 0; ny<YRES/CELL; ny++)
+ {
+ pv[ny][nx] = 0;
+ }
+ }
+ else if(strcmp(console3, "velocity")==0)
+ {
+ for (nx = 0; nx<XRES/CELL; nx++)
+ for (ny = 0; ny<YRES/CELL; ny++)
+ {
+ vx[ny][nx] = 0;
+ vy[ny][nx] = 0;
+ }
+ }
+ else if(strcmp(console3, "sparks")==0)
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type==PT_SPRK)
+ {
+ parts[i].type = parts[i].ctype;
+ parts[i].life = 4;
+ }
+ }
+ }
+ else if(strcmp(console3, "temp")==0)
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ {
+ parts[i].temp = ptypes[parts[i].type].heat;
+ }
+ }
+ }
+ }
+ else if(strcmp(console2, "set")==0 && console3 && console4 && console5)
+ {
+ if(strcmp(console3, "life")==0)
+ {
+ if(strcmp(console4, "all")==0)
+ {
+ j = atoi(console5);
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].life = j;
+ }
+ }
+ else
+ {
+ if (console_parse_partref(console4, &i, console_error))
+ {
+ j = atoi(console5);
+ parts[i].life = j;
+ }
+ }
+ }
+ if(strcmp(console3, "type")==0)
+ {
+ if(strcmp(console4, "all")==0)
+ {
+ if (console_parse_type(console5, &j, console_error))
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].type = j;
+ }
+ }
+ else
+ {
+ if (console_parse_partref(console4, &i, console_error)
+ && console_parse_type(console5, &j, console_error))
+ {
+ parts[i].type = j;
+ }
+ }
+ }
+ if(strcmp(console3, "temp")==0)
+ {
+ if(strcmp(console4, "all")==0)
+ {
+ j = atoi(console5);
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].temp = j;
+ }
+ }
+ else
+ {
+ if (console_parse_partref(console4, &i, console_error))
+ {
+ j = atoi(console5);
+ parts[i].temp = j;
+ }
+ }
+ }
+ if(strcmp(console3, "tmp")==0)
+ {
+ if(strcmp(console4, "all")==0)
+ {
+ j = atoi(console5);
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].tmp = j;
+ }
+ }
+ else
+ {
+ if (console_parse_partref(console4, &i, console_error))
+ {
+ j = atoi(console5);
+ parts[i].tmp = j;
+ }
+ }
+ }
+ if(strcmp(console3, "x")==0)
+ {
+ if(strcmp(console4, "all")==0)
+ {
+ j = atoi(console5);
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].x = j;
+ }
+ }
+ else
+ {
+ if (console_parse_partref(console4, &i, console_error))
+ {
+ j = atoi(console5);
+ parts[i].x = j;
+ }
+ }
+ }
+ if(strcmp(console3, "y")==0)
+ {
+ if(strcmp(console4, "all")==0)
+ {
+ j = atoi(console5);
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].y = j;
+ }
+ }
+ else
+ {
+ if (console_parse_partref(console4, &i, console_error))
+ {
+ j = atoi(console5);
+ parts[i].y = j;
+ }
+ }
+ }
+ if(strcmp(console3, "ctype")==0)
+ {
+ if(strcmp(console4, "all")==0)
+ {
+ if (console_parse_type(console5, &j, console_error))
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].ctype = j;
+ }
+ }
+ else
+ {
+ if (console_parse_partref(console4, &i, console_error)
+ && console_parse_type(console5, &j, console_error))
+ {
+ parts[i].ctype = j;
+ }
+ }
+ }
+ if(strcmp(console3, "vx")==0)
+ {
+ if(strcmp(console4, "all")==0)
+ {
+ j = atoi(console5);
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].vx = j;
+ }
+ }
+ else
+ {
+ if (console_parse_partref(console4, &i, console_error))
+ {
+ j = atoi(console5);
+ parts[i].vx = j;
+ }
+ }
+ }
+ if(strcmp(console3, "vy")==0)
+ {
+ if(strcmp(console4, "all")==0)
+ {
+ j = atoi(console5);
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].vy = j;
+ }
+ }
+ else
+ {
+ if (console_parse_partref(console4, &i, console_error))
+ {
+ j = atoi(console5);
+ parts[i].vy = j;
+ }
+ }
+ }
+ }
+ else
+ sprintf(console_error, "Invalid Command", console2);
+ }
+ return 1;
+}
diff --git a/src/powder.c b/src/powder.c
index b2932d1..493dec7 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -1328,7 +1328,7 @@ void update_particles_i(pixel *vid, int start, int inc)
neighbors = gol2[nx][ny][0];
if(neighbors==0 || !(ptypes[r&0xFF].properties&PROP_LIFE || !r&0xFF) || (r>>8)>=NPART)
continue;
- for ( golnum = 1; golnum<NGOL; golnum++)
+ for ( golnum = 1; golnum<=NGOL; golnum++)
for ( goldelete = 0; goldelete<9; goldelete++)
{
if (neighbors==goldelete&&gol[nx][ny]==0&&grule[golnum][goldelete]>=2&&gol2[nx][ny][golnum]>=(goldelete%2)+goldelete/2)
@@ -1345,7 +1345,7 @@ void update_particles_i(pixel *vid, int start, int inc)
parts[r>>8].type = PT_NONE;//using kill_part makes it not work
}
gol2[nx][ny][0] = 0;
- for ( z = 1; z<NGOL; z++)
+ for ( z = 1; z<=NGOL; z++)
gol2[nx][ny][z] = 0;
}
if (createdsomething)
@@ -1963,15 +1963,15 @@ killed:
{
parts[i].x = clear_xf+(j-clear_x);
parts[i].y = fin_yf;
- x = j;
- y = fin_y;
+ nx = j;
+ ny = fin_y;
s = 1;
break;
}
if (try_move(i, x, y, j, clear_y))
{
parts[i].x = clear_xf+(j-clear_x);
- x = j;
+ nx = j;
s = 1;
break;
}
@@ -1985,12 +1985,12 @@ killed:
if (s)
for (j=clear_y+r; j>=0 && j<YRES && j>=clear_y-rt && j<clear_y+rt; j+=r)
{
- if (try_move(i, x, y, clear_x, j))
+ if (try_move(i, x, y, nx, j))
{
parts[i].y = clear_yf+(j-clear_y);
break;
}
- if ((pmap[j][x]&255)!=t || (bmap[j/CELL][x/CELL] && bmap[j/CELL][x/CELL]!=WL_STREAM))
+ if ((pmap[j][nx]&255)!=t || (bmap[j/CELL][nx/CELL] && bmap[j/CELL][nx/CELL]!=WL_STREAM))
{
s = 0;
break;