diff --git a/src/console.c b/src/console.c index 634e67925..e926328bf 100644 --- a/src/console.c +++ b/src/console.c @@ -1108,6 +1108,32 @@ int process_command_old(pixel *vid_buf, char *console, char *console_error) strcpy(console_error, "Could not create particle"); } } + else if (strcmp(console2, "bubble")==0 && console3[0]) + { + if (console_parse_coords(console3, &nx, &ny, console_error)) + { + int first, rem1, rem2; + + first = create_part(-1, nx+18, ny, PT_SOAP); + rem1 = first; + + for (i = 1; i<=30; i++) + { + rem2 = create_part(-1, nx+18*cosf(i/5.0), ny+18*sinf(i/5.0), PT_SOAP); + + parts[rem1].ctype = 7; + parts[rem1].tmp = rem2; + parts[rem2].tmp2 = rem1; + + rem1 = rem2; + } + + parts[rem1].ctype = 7; + parts[rem1].tmp = first; + parts[first].tmp2 = rem1; + parts[first].ctype = 7; + } + } else if ((strcmp(console2, "delete")==0 || strcmp(console2, "kill")==0) && console3[0]) { if (console_parse_partref(console3, &i, console_error)) diff --git a/src/elements/soap.c b/src/elements/soap.c index 838b16ce8..0496bd242 100644 --- a/src/elements/soap.c +++ b/src/elements/soap.c @@ -29,9 +29,6 @@ int update_SOAP(UPDATE_FUNC_ARGS) { if (parts[i].life<=0) { - if ((parts[i].ctype&6) == 0) - parts[i].ctype = 0; - if ((parts[i].ctype&6) != 6 && parts[i].ctype>1) { int target; @@ -54,9 +51,11 @@ int update_SOAP(UPDATE_FUNC_ARGS) } } + if ((parts[i].ctype&6) != 6) + parts[i].ctype = 0; + if ((parts[i].ctype&6) == 6 && (parts[parts[i].tmp].ctype&6) == 6 && parts[parts[i].tmp].tmp == i) detach(i); - } parts[i].vy -= 0.1f; @@ -74,12 +73,6 @@ int update_SOAP(UPDATE_FUNC_ARGS) if ((r>>8)>=NPART || !r) continue; - if ((r&0xFF) != PT_SOAP || (parts[r>>8].ctype == 0 && (r&0xFF) == PT_SOAP)) - { - detach(i); - continue; - } - if ((parts[r>>8].type == PT_SOAP) && ((parts[r>>8].ctype&1) == 1) && ((parts[r>>8].ctype&4) != 4)) { @@ -105,6 +98,49 @@ int update_SOAP(UPDATE_FUNC_ARGS) } } } + else + { + if (parts[i].life<=0) + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + + if (((r&0xFF) != PT_SOAP && (r&0xFF) != PT_GLAS) + || (parts[r>>8].ctype == 0 && (r&0xFF) == PT_SOAP + && (abs(parts[r>>8].vx)<2 || abs(parts[r>>8].vy)<2))) + { + detach(i); + continue; + } + + if ((r&0xFF) == PT_SOAP && parts[r>>8].ctype == 1) + { + int buf; + + buf = parts[i].tmp; + + parts[i].tmp = r>>8; + parts[buf].tmp2 = r>>8; + parts[r>>8].tmp2 = i; + parts[r>>8].tmp = buf; + parts[r>>8].ctype = 7; + } + + if ((r&0xFF) == PT_SOAP && parts[r>>8].ctype == 7 && parts[i].tmp != r>>8 && parts[i].tmp2 != r>>8) + { + int buf; + + parts[parts[i].tmp].tmp2 = parts[r>>8].tmp2; + parts[parts[r>>8].tmp2].tmp = parts[i].tmp; + parts[r>>8].tmp2 = i; + parts[i].tmp = r>>8; + } + } + } if((parts[i].ctype&2) == 2) { @@ -146,8 +182,35 @@ int update_SOAP(UPDATE_FUNC_ARGS) if (pv[y/CELL][x/CELL]>0.5f || pv[y/CELL][x/CELL]<(-0.5f)) { parts[i].ctype = 1; - parts[i].life = 5; + parts[i].life = 10; } + + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + + if ((r&0xFF) == PT_OIL) + { + parts[i].vy -= 0.1f; + + parts[i].vy *= 0.5f; + parts[i].vx *= 0.5f; + + float ax, ay; + + ax = (parts[i].vx + parts[r>>8].vx)/2; + ay = (parts[i].vy + parts[r>>8].vy)/2; + + parts[i].vx = ax; + parts[i].vy = ay; + parts[r>>8].vx = ax; + parts[r>>8].vy = ay; + } + } } return 0; diff --git a/src/main.c b/src/main.c index 92a9fdd40..e2bf9d094 100644 --- a/src/main.c +++ b/src/main.c @@ -667,6 +667,8 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char parts[k].type = j; if (j == PT_PHOT) parts[k].ctype = 0x3fffffff; + if (j == PT_SOAP) + parts[k].ctype = 0; parts[k].x = (float)x; parts[k].y = (float)y; m[(x-x0)+(y-y0)*w] = k+1; @@ -681,6 +683,8 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char parts[fp[i]].tmp = 50; if (j == PT_PHOT) parts[fp[i]].ctype = 0x3fffffff; + if (j == PT_SOAP) + parts[k].ctype = 0; parts[fp[i]].x = (float)x; parts[fp[i]].y = (float)y; m[(x-x0)+(y-y0)*w] = fp[i]+1;