From f93a829672c7aabb09ae9b958623a97105b8e28d Mon Sep 17 00:00:00 2001 From: savask Date: Thu, 19 Apr 2012 21:40:28 +0700 Subject: [PATCH] Fix sponge bug. --- includes/powder.h | 1 + src/elementdata.c | 2 +- src/powder.c | 7 +++++-- src/save.c | 5 +++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/includes/powder.h b/includes/powder.h index 5db61dbd6..99d3afc26 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -254,6 +254,7 @@ #define FLAG_STAGNANT 1 #define FLAG_SKIPMOVE 0x2 // skip movement for one frame, only implemented for PHOT +#define FLAG_MOVABLE 0x4 // if can move #define GRAPHICS_FUNC_ARGS particle *cpart, int nx, int ny, int *pixel_mode, int* cola, int *colr, int *colg, int *colb, int *firea, int *firer, int *fireg, int *fireb #define GRAPHICS_FUNC_SUBCALL_ARGS cpart, nx, ny, pixel_mode, cola, colr, colg, colb, firea, firer, fireg, fireb diff --git a/src/elementdata.c b/src/elementdata.c index f72efa3b5..aa2544eb9 100644 --- a/src/elementdata.c +++ b/src/elementdata.c @@ -104,7 +104,7 @@ part_type ptypes[PT_NUM] = {"LIGH", PIXPACK(0xFFFFC0), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 0, "More realistic lightning. Set pen size to set the size of the lightning.", ST_SOLID, TYPE_SOLID, &update_LIGH, &graphics_LIGH}, {"TESC", PIXPACK(0x707040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Tesla coil!", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW, NULL, NULL}, {"DEST", PIXPACK(0xFF3311), -0.05f, 0.00f * CFDS, 0.95f, 0.95f, -0.1f, 0.4f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 1, 101, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 150, "More destructive Bomb.", ST_SOLID, TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, &update_DEST, &graphics_DEST}, - {"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, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "A sponge, absorbs water.", ST_SOLID, TYPE_SOLID, &update_SPNG, &graphics_SPNG}, + {"SPNG", PIXPACK(0xFFBE30), 0.00f, 0.00f * CFDS, 0.00f, 0.0f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 1, 30, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "A sponge, absorbs water.", ST_SOLID, TYPE_SOLID, &update_SPNG, &graphics_SPNG}, {"RIME", PIXPACK(0xCCCCCC), 0.00f, 0.00f * CFDS, 0.00f, 1.00f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 1, 100, SC_CRACKER2, 243.15f, 100, "Not quite Ice", ST_SOLID, TYPE_SOLID, &update_RIME, NULL}, {"FOG", PIXPACK(0xAAAAAA), 0.8f, 0.00f * CFDS, 0.4f, 0.70f, -0.1f, 0.0f, 0.99f, 0.000f * CFDS, 0, 0, 0, 0, 30, 1, 1, 1, SC_CRACKER2, 243.15f, 100, "Not quite Steam", ST_GAS, TYPE_GAS|PROP_LIFE_DEC, &update_FOG, NULL}, {"BCLN", PIXPACK(0xFFD040), 0.0f, 0.00f * CFDS, 0.97f, 0.50f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 12, 1, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Breakable Clone.", ST_NONE, TYPE_SOLID|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, &update_BCLN, NULL}, diff --git a/src/powder.c b/src/powder.c index 98f023aa6..9c684e91d 100644 --- a/src/powder.c +++ b/src/powder.c @@ -1816,8 +1816,11 @@ void update_particles_i(pixel *vid, int start, int inc) pGravY += gravy[(y/CELL)*(XRES/CELL)+(x/CELL)]; } //velocity updates for the particle - parts[i].vx *= ptypes[t].loss; - parts[i].vy *= ptypes[t].loss; + if (!(parts[i].flags&FLAG_MOVABLE)) + { + parts[i].vx *= ptypes[t].loss; + parts[i].vy *= ptypes[t].loss; + } //particle gets velocity from the vx and vy maps parts[i].vx += ptypes[t].advection*vx[y/CELL][x/CELL] + pGravX; parts[i].vy += ptypes[t].advection*vy[y/CELL][x/CELL] + pGravY; diff --git a/src/save.c b/src/save.c index c56bdd319..a96cb052a 100644 --- a/src/save.c +++ b/src/save.c @@ -2136,6 +2136,11 @@ int parse_save_PSv(void *save, int size, int replace, int x0, int y0, unsigned c STKM_init_legs(&(fighters[fcount]), i-1); } } + else if (parts[i-1].type == PT_SPNG) + { + if (fabs(parts[i-1].vx)>0.0f || fabs(parts[i-1].vy)>0.0f) + parts[i-1].flags |= FLAG_MOVABLE; + } if (ver<48 && (ty==OLD_PT_WIND || (ty==PT_BRAY&&parts[i-1].life==0))) {