summaryrefslogtreecommitdiff
path: root/src/simulation
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-05-12 12:21:04 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-05-12 12:21:04 (GMT)
commit16d3895e9c054e908ca8b230719f4294e824a4a2 (patch)
tree8246b0ebc3b94ed05427b8ffa5ea1e1764c7a37a /src/simulation
parent1c993435efc7fe6702d21c892e1d4dd8347d2e7f (diff)
downloadpowder-16d3895e9c054e908ca8b230719f4294e824a4a2.zip
powder-16d3895e9c054e908ca8b230719f4294e824a4a2.tar.gz
Redo Wall IDs
Diffstat (limited to 'src/simulation')
-rw-r--r--src/simulation/Elements.h23
-rw-r--r--src/simulation/SaveLoader.cpp35
-rw-r--r--src/simulation/Simulation.cpp348
-rw-r--r--src/simulation/Simulation.h16
-rw-r--r--src/simulation/SimulationData.cpp17
-rw-r--r--src/simulation/SimulationData.h59
-rw-r--r--src/simulation/elements/BOMB.cpp4
-rw-r--r--src/simulation/elements/SPRK.cpp4
-rw-r--r--src/simulation/elements/STKM.cpp2
9 files changed, 334 insertions, 174 deletions
diff --git a/src/simulation/Elements.h b/src/simulation/Elements.h
index 2753b52..cfea1af 100644
--- a/src/simulation/Elements.h
+++ b/src/simulation/Elements.h
@@ -51,26 +51,6 @@
#define GRAPHICS_FUNC_ARGS Renderer * ren, 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 ren, cpart, nx, ny, pixel_mode, cola, colr, colg, colb, firea, firer, fireg, fireb
-#define UI_WALLSTART 222
-#define UI_ACTUALSTART 122
-#define UI_WALLCOUNT 25
-
-#define WL_WALLELEC 122
-#define WL_EWALL 123
-#define WL_DETECT 124
-#define WL_STREAM 125
-#define WL_SIGN 126
-#define WL_FAN 127
-#define WL_FANHELPER 255
-#define WL_ALLOWLIQUID 128
-#define WL_DESTROYALL 129
-#define WL_ERASE 130
-#define WL_WALL 131
-#define WL_ALLOWAIR 132
-#define WL_ALLOWSOLID 133
-#define WL_ALLOWALLELEC 134
-#define WL_EHOLE 135
-
#define SPC_AIR 236
#define SPC_HEAT 237
#define SPC_COOL 238
@@ -80,9 +60,6 @@
#define SPC_NGRV 244
#define SPC_PROP 246
-#define WL_ALLOWGAS 140
-#define WL_GRAV 142
-#define WL_ALLOWENERGY 145
#define NGT_GOL 0
#define NGT_HLIF 1
diff --git a/src/simulation/SaveLoader.cpp b/src/simulation/SaveLoader.cpp
index 7989d38..9bfb131 100644
--- a/src/simulation/SaveLoader.cpp
+++ b/src/simulation/SaveLoader.cpp
@@ -194,7 +194,7 @@ int SaveLoader::PSVLoad(unsigned char * data, int dataLength, Simulation * sim,
{
//In old saves, ignore walls created by sign tool bug
//Not ignoring other invalid walls or invalid walls in new saves, so that any other bugs causing them are easier to notice, find and fix
- if (ver<71 && d[p]==WL_SIGN)
+ if (ver<71 && d[p]==O_WL_SIGN)
{
p++;
continue;
@@ -227,6 +227,39 @@ int SaveLoader::PSVLoad(unsigned char * data, int dataLength, Simulation * sim,
sim->bmap[y][x]=WL_EHOLE;
if (sim->bmap[y][x]==13)
sim->bmap[y][x]=WL_ALLOWGAS;
+
+ if (sim->bmap[y][x]==O_WL_WALLELEC)
+ sim->bmap[y][x]=WL_WALLELEC;
+ if (sim->bmap[y][x]==O_WL_EWALL)
+ sim->bmap[y][x]=WL_EWALL;
+ if (sim->bmap[y][x]==O_WL_DETECT)
+ sim->bmap[y][x]=WL_DETECT;
+ if (sim->bmap[y][x]==O_WL_STREAM)
+ sim->bmap[y][x]=WL_STREAM;
+ if (sim->bmap[y][x]==O_WL_FAN||sim->bmap[y][x]==O_WL_FANHELPER)
+ sim->bmap[y][x]=WL_FAN;
+ if (sim->bmap[y][x]==O_WL_ALLOWLIQUID)
+ sim->bmap[y][x]=WL_ALLOWLIQUID;
+ if (sim->bmap[y][x]==O_WL_DESTROYALL)
+ sim->bmap[y][x]=WL_DESTROYALL;
+ if (sim->bmap[y][x]==O_WL_ERASE)
+ sim->bmap[y][x]=WL_ERASE;
+ if (sim->bmap[y][x]==O_WL_WALL)
+ sim->bmap[y][x]=WL_WALL;
+ if (sim->bmap[y][x]==O_WL_ALLOWAIR)
+ sim->bmap[y][x]=WL_ALLOWAIR;
+ if (sim->bmap[y][x]==O_WL_ALLOWSOLID)
+ sim->bmap[y][x]=WL_ALLOWSOLID;
+ if (sim->bmap[y][x]==O_WL_ALLOWALLELEC)
+ sim->bmap[y][x]=WL_ALLOWALLELEC;
+ if (sim->bmap[y][x]==O_WL_EHOLE)
+ sim->bmap[y][x]=WL_EHOLE;
+ if (sim->bmap[y][x]==O_WL_ALLOWGAS)
+ sim->bmap[y][x]=WL_ALLOWGAS;
+ if (sim->bmap[y][x]==O_WL_GRAV)
+ sim->bmap[y][x]=WL_GRAV;
+ if (sim->bmap[y][x]==O_WL_ALLOWENERGY)
+ sim->bmap[y][x]=WL_ALLOWENERGY;
}
p++;
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp
index 89295f4..354c759 100644
--- a/src/simulation/Simulation.cpp
+++ b/src/simulation/Simulation.cpp
@@ -46,7 +46,7 @@ void Simulation::clear_area(int area_x, int area_y, int area_w, int area_h)
}
}
-void Simulation::create_box(int x1, int y1, int x2, int y2, int c, int flags)
+void Simulation::CreateBox(int x1, int y1, int x2, int y2, int c, int flags)
{
int i, j;
if (c==SPC_PROP)
@@ -65,7 +65,27 @@ void Simulation::create_box(int x1, int y1, int x2, int y2, int c, int flags)
}
for (j=y1; j<=y2; j++)
for (i=x1; i<=x2; i++)
- create_parts(i, j, 0, 0, c, flags);
+ CreateParts(i, j, 0, 0, c, flags);
+}
+
+void Simulation::CreateWallBox(int x1, int y1, int x2, int y2, int c, int flags)
+{
+ int i, j;
+ if (x1>x2)
+ {
+ i = x2;
+ x2 = x1;
+ x1 = i;
+ }
+ if (y1>y2)
+ {
+ j = y2;
+ y2 = y1;
+ y1 = j;
+ }
+ for (j=y1; j<=y2; j++)
+ for (i=x1; i<=x2; i++)
+ CreateWalls(i, j, 0, 0, c, flags);
}
int Simulation::flood_prop_2(int x, int y, size_t propoffset, void * propvalue, int proptype, int parttype, char * bitmap)
@@ -133,10 +153,10 @@ Particle Simulation::Get(int x, int y)
return Particle();
}
-int Simulation::flood_parts(int x, int y, int fullc, int cm, int bm, int flags)
+int Simulation::FloodParts(int x, int y, int fullc, int cm, int bm, int flags)
{
int c = fullc&0xFF;
- int x1, x2, dy = (c<PT_NUM)?1:CELL;
+ int x1, x2, dy = 1;
int co = c;
if (c==SPC_PROP)
return 0;
@@ -169,10 +189,10 @@ int Simulation::flood_parts(int x, int y, int fullc, int cm, int bm, int flags)
else
bm = 0;
}
-
+
if (((pmap[y][x]&0xFF)!=cm || bmap[y/CELL][x/CELL]!=bm )/*||( (flags&BRUSH_SPECIFIC_DELETE) && cm!=SLALT)*/)
return 1;
-
+
// go left as far as possible
x1 = x2 = x;
while (x1>=CELL)
@@ -191,7 +211,7 @@ int Simulation::flood_parts(int x, int y, int fullc, int cm, int bm, int flags)
}
x2++;
}
-
+
// fill span
for (x=x1; x<=x2; x++)
{
@@ -200,40 +220,40 @@ int Simulation::flood_parts(int x, int y, int fullc, int cm, int bm, int flags)
if (create_part(-1,x, y, fullc)==-1)
return 0;
}
- else if (!create_parts(x, y, 0, 0, fullc, flags))
+ else if (!CreateParts(x, y, 0, 0, fullc, flags))
return 0;
}
// fill children
if (cm==PT_INST&&co==PT_SPRK)//wire crossing for INST
{
if (y>=CELL+dy && x1==x2 &&
- ((pmap[y-1][x1-1]&0xFF)==PT_INST||(pmap[y-1][x1-1]&0xFF)==PT_SPRK) && ((pmap[y-1][x1]&0xFF)==PT_INST||(pmap[y-1][x1]&0xFF)==PT_SPRK) && ((pmap[y-1][x1+1]&0xFF)==PT_INST || (pmap[y-1][x1+1]&0xFF)==PT_SPRK) &&
- (pmap[y-2][x1-1]&0xFF)!=PT_INST && ((pmap[y-2][x1]&0xFF)==PT_INST ||(pmap[y-2][x1]&0xFF)==PT_SPRK) && (pmap[y-2][x1+1]&0xFF)!=PT_INST)
- flood_parts(x1, y-2, fullc, cm, bm, flags);
+ ((pmap[y-1][x1-1]&0xFF)==PT_INST||(pmap[y-1][x1-1]&0xFF)==PT_SPRK) && ((pmap[y-1][x1]&0xFF)==PT_INST||(pmap[y-1][x1]&0xFF)==PT_SPRK) && ((pmap[y-1][x1+1]&0xFF)==PT_INST || (pmap[y-1][x1+1]&0xFF)==PT_SPRK) &&
+ (pmap[y-2][x1-1]&0xFF)!=PT_INST && ((pmap[y-2][x1]&0xFF)==PT_INST ||(pmap[y-2][x1]&0xFF)==PT_SPRK) && (pmap[y-2][x1+1]&0xFF)!=PT_INST)
+ FloodParts(x1, y-2, fullc, cm, bm, flags);
else if (y>=CELL+dy)
for (x=x1; x<=x2; x++)
if ((pmap[y-1][x]&0xFF)!=PT_SPRK)
{
if (x==x1 || x==x2 || y>=YRES-CELL-1 ||
- (pmap[y-1][x-1]&0xFF)==PT_INST || (pmap[y-1][x+1]&0xFF)==PT_INST ||
- (pmap[y+1][x-1]&0xFF)==PT_INST || ((pmap[y+1][x]&0xFF)!=PT_INST&&(pmap[y+1][x]&0xFF)!=PT_SPRK) || (pmap[y+1][x+1]&0xFF)==PT_INST)
- flood_parts(x, y-dy, fullc, cm, bm, flags);
-
+ (pmap[y-1][x-1]&0xFF)==PT_INST || (pmap[y-1][x+1]&0xFF)==PT_INST ||
+ (pmap[y+1][x-1]&0xFF)==PT_INST || ((pmap[y+1][x]&0xFF)!=PT_INST&&(pmap[y+1][x]&0xFF)!=PT_SPRK) || (pmap[y+1][x+1]&0xFF)==PT_INST)
+ FloodParts(x, y-dy, fullc, cm, bm, flags);
+
}
-
+
if (y<YRES-CELL-dy && x1==x2 &&
- ((pmap[y+1][x1-1]&0xFF)==PT_INST||(pmap[y+1][x1-1]&0xFF)==PT_SPRK) && ((pmap[y+1][x1]&0xFF)==PT_INST||(pmap[y+1][x1]&0xFF)==PT_SPRK) && ((pmap[y+1][x1+1]&0xFF)==PT_INST || (pmap[y+1][x1+1]&0xFF)==PT_SPRK) &&
- (pmap[y+2][x1-1]&0xFF)!=PT_INST && ((pmap[y+2][x1]&0xFF)==PT_INST ||(pmap[y+2][x1]&0xFF)==PT_SPRK) && (pmap[y+2][x1+1]&0xFF)!=PT_INST)
- flood_parts(x1, y+2, fullc, cm, bm, flags);
+ ((pmap[y+1][x1-1]&0xFF)==PT_INST||(pmap[y+1][x1-1]&0xFF)==PT_SPRK) && ((pmap[y+1][x1]&0xFF)==PT_INST||(pmap[y+1][x1]&0xFF)==PT_SPRK) && ((pmap[y+1][x1+1]&0xFF)==PT_INST || (pmap[y+1][x1+1]&0xFF)==PT_SPRK) &&
+ (pmap[y+2][x1-1]&0xFF)!=PT_INST && ((pmap[y+2][x1]&0xFF)==PT_INST ||(pmap[y+2][x1]&0xFF)==PT_SPRK) && (pmap[y+2][x1+1]&0xFF)!=PT_INST)
+ FloodParts(x1, y+2, fullc, cm, bm, flags);
else if (y<YRES-CELL-dy)
for (x=x1; x<=x2; x++)
if ((pmap[y+1][x]&0xFF)!=PT_SPRK)
{
if (x==x1 || x==x2 || y<0 ||
- (pmap[y+1][x-1]&0xFF)==PT_INST || (pmap[y+1][x+1]&0xFF)==PT_INST ||
- (pmap[y-1][x-1]&0xFF)==PT_INST || ((pmap[y-1][x]&0xFF)!=PT_INST&&(pmap[y-1][x]&0xFF)!=PT_SPRK) || (pmap[y-1][x+1]&0xFF)==PT_INST)
- flood_parts(x, y+dy, fullc, cm, bm, flags);
-
+ (pmap[y+1][x-1]&0xFF)==PT_INST || (pmap[y+1][x+1]&0xFF)==PT_INST ||
+ (pmap[y-1][x-1]&0xFF)==PT_INST || ((pmap[y-1][x]&0xFF)!=PT_INST&&(pmap[y-1][x]&0xFF)!=PT_SPRK) || (pmap[y-1][x+1]&0xFF)==PT_INST)
+ FloodParts(x, y+dy, fullc, cm, bm, flags);
+
}
}
else
@@ -241,12 +261,12 @@ int Simulation::flood_parts(int x, int y, int fullc, int cm, int bm, int flags)
if (y>=CELL+dy)
for (x=x1; x<=x2; x++)
if ((pmap[y-dy][x]&0xFF)==cm && bmap[(y-dy)/CELL][x/CELL]==bm)
- if (!flood_parts(x, y-dy, fullc, cm, bm, flags))
+ if (!FloodParts(x, y-dy, fullc, cm, bm, flags))
return 0;
if (y<YRES-CELL-dy)
for (x=x1; x<=x2; x++)
if ((pmap[y+dy][x]&0xFF)==cm && bmap[(y+dy)/CELL][x/CELL]==bm)
- if (!flood_parts(x, y+dy, fullc, cm, bm, flags))
+ if (!FloodParts(x, y+dy, fullc, cm, bm, flags))
return 0;
}
if (!(cm==PT_INST&&co==PT_SPRK))
@@ -254,6 +274,78 @@ int Simulation::flood_parts(int x, int y, int fullc, int cm, int bm, int flags)
return 0;
}
+int Simulation::FloodWalls(int x, int y, int c, int cm, int bm, int flags)
+{
+ int x1, x2, dy = CELL;
+ int co = c;
+ if (cm==-1)
+ {
+ if (c==0)
+ {
+ cm = pmap[y][x]&0xFF;
+ if (!cm)
+ return 0;
+ //if ((flags&BRUSH_REPLACEMODE) && cm!=SLALT)
+ // return 0;
+ }
+ else
+ cm = 0;
+ }
+ if (bm==-1)
+ {
+ if (c==WL_ERASE)
+ {
+ bm = bmap[y/CELL][x/CELL];
+ if (!bm)
+ return 0;
+ if (bm==WL_WALL)
+ cm = 0xFF;
+ }
+ else
+ bm = 0;
+ }
+
+ if (((pmap[y][x]&0xFF)!=cm || bmap[y/CELL][x/CELL]!=bm )/*||( (flags&BRUSH_SPECIFIC_DELETE) && cm!=SLALT)*/)
+ return 1;
+
+ // go left as far as possible
+ x1 = x2 = x;
+ while (x1>=CELL)
+ {
+ if ((pmap[y][x1-1]&0xFF)!=cm || bmap[y/CELL][(x1-1)/CELL]!=bm)
+ {
+ break;
+ }
+ x1--;
+ }
+ while (x2<XRES-CELL)
+ {
+ if ((pmap[y][x2+1]&0xFF)!=cm || bmap[y/CELL][(x2+1)/CELL]!=bm)
+ {
+ break;
+ }
+ x2++;
+ }
+
+ // fill span
+ for (x=x1; x<=x2; x++)
+ {
+ if (!CreateWalls(x, y, 0, 0, c, flags))
+ return 0;
+ }
+ // fill children
+ if (y>=CELL+dy)
+ for (x=x1; x<=x2; x++)
+ if ((pmap[y-dy][x]&0xFF)==cm && bmap[(y-dy)/CELL][x/CELL]==bm)
+ if (!FloodWalls(x, y-dy, c, cm, bm, flags))
+ return 0;
+ if (y<YRES-CELL-dy)
+ for (x=x1; x<=x2; x++)
+ if ((pmap[y+dy][x]&0xFF)==cm && bmap[(y+dy)/CELL][x/CELL]==bm)
+ if (!FloodWalls(x, y+dy, c, cm, bm, flags))
+ return 0;
+ return 0;
+}
int Simulation::flood_water(int x, int y, int i, int originaly, int check)
{
int x1 = 0,x2 = 0;
@@ -517,46 +609,20 @@ void Simulation::ApplyDecorationLine(int x1, int y1, int x2, int y2, int rx, int
}
//this creates particles from a brush, don't use if you want to create one particle
-int Simulation::create_parts(int x, int y, int rx, int ry, int c, int flags, Brush * cBrush)
+int Simulation::CreateParts(int x, int y, int rx, int ry, int c, int flags, Brush * cBrush)
{
int i, j, r, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0, p;//n;
-
+
if(cBrush)
{
rx = cBrush->GetRadius().X;
ry = cBrush->GetRadius().Y;
}
-
+
int wall = c - 100;
if (c==SPC_WIND || c==PT_FIGH)
return 0;
-
- //if(c==SPC_PROP){
- // prop_edit_ui(vid_buf, x, y);
- // return 0;
- //}
- for (r=UI_ACTUALSTART; r<=UI_ACTUALSTART+UI_WALLCOUNT; r++)
- {
- if (wall==r)
- {
- if (c == SPC_AIR || c == SPC_HEAT || c == SPC_COOL || c == SPC_VACUUM || c == SPC_PGRV || c == SPC_NGRV || wall == WL_SIGN)
- break;
- if (wall == WL_ERASE)
- b = 0;
- else
- b = wall;
- dw = 1;
- }
- }
- if (c == WL_FANHELPER)
- {
- b = WL_FANHELPER;
- dw = 1;
- }
- if (wall == WL_GRAV)
- {
- gravwl_timeout = 60;
- }
+
if (c==PT_LIGH)
{
if (lighting_recreate>0 && rx+ry>0)
@@ -573,49 +639,7 @@ int Simulation::create_parts(int x, int y, int rx, int ry, int c, int flags, Bru
}
else return 0;
}
-
- if (dw==1)
- {
- ry = ry/CELL;
- rx = rx/CELL;
- x = x/CELL;
- y = y/CELL;
- x -= rx/2;
- y -= ry/2;
- for (ox=x; ox<=x+rx; ox++)
- {
- for (oy=y; oy<=y+rx; oy++)
- {
- if (ox>=0&&ox<XRES/CELL&&oy>=0&&oy<YRES/CELL)
- {
- i = ox;
- j = oy;
- if (b==WL_FAN)
- {
- fvx[j][i] = 0.0f;
- fvy[j][i] = 0.0f;
- }
- if (b==WL_STREAM)
- {
- i = x + rx/2;
- j = y + ry/2;
- for (v=-1; v<2; v++)
- for (u=-1; u<2; u++)
- if (i+u>=0 && i+u<XRES/CELL &&
- j+v>=0 && j+v<YRES/CELL &&
- bmap[j+v][i+u] == WL_STREAM)
- return 1;
- bmap[j][i] = WL_STREAM;
- continue;
- }
- if (b==0 && bmap[j][i]==WL_GRAV) gravwl_timeout = 60;
- bmap[j][i] = b;
- }
- }
- }
- return 1;
- }
-
+
//eraser
if (c == 0)
{
@@ -639,7 +663,7 @@ int Simulation::create_parts(int x, int y, int rx, int ry, int c, int flags, Bru
}
return 1;
}
-
+
if (c == SPC_AIR || c == SPC_HEAT || c == SPC_COOL || c == SPC_VACUUM || c == SPC_PGRV || c == SPC_NGRV)
{
if (rx==0&&ry==0)
@@ -670,7 +694,7 @@ int Simulation::create_parts(int x, int y, int rx, int ry, int c, int flags, Bru
}
return 1;
}
-
+
//else, no special modes, draw element like normal.
if (rx==0&&ry==0)//workaround for 1pixel brush/floodfill crashing. todo: find a better fix later.
{
@@ -696,7 +720,64 @@ int Simulation::create_parts(int x, int y, int rx, int ry, int c, int flags, Bru
return !f;
}
-void Simulation::create_line(int x1, int y1, int x2, int y2, int rx, int ry, int c, int flags, Brush * cBrush)
+int Simulation::CreateWalls(int x, int y, int rx, int ry, int c, int flags, Brush * cBrush)
+{
+ int i, j, r, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0, p;//n;
+
+ if(cBrush)
+ {
+ rx = cBrush->GetRadius().X;
+ ry = cBrush->GetRadius().Y;
+ }
+
+ int wall = c;
+
+ if (wall == WL_ERASE)
+ b = 0;
+ else
+ b = wall;
+
+ ry = ry/CELL;
+ rx = rx/CELL;
+ x = x/CELL;
+ y = y/CELL;
+ x -= rx/2;
+ y -= ry/2;
+ for (ox=x; ox<=x+rx; ox++)
+ {
+ for (oy=y; oy<=y+rx; oy++)
+ {
+ if (ox>=0&&ox<XRES/CELL&&oy>=0&&oy<YRES/CELL)
+ {
+ i = ox;
+ j = oy;
+ if (b==WL_FAN)
+ {
+ fvx[j][i] = 0.0f;
+ fvy[j][i] = 0.0f;
+ }
+ if (b==WL_STREAM)
+ {
+ i = x + rx/2;
+ j = y + ry/2;
+ for (v=-1; v<2; v++)
+ for (u=-1; u<2; u++)
+ if (i+u>=0 && i+u<XRES/CELL &&
+ j+v>=0 && j+v<YRES/CELL &&
+ bmap[j+v][i+u] == WL_STREAM)
+ return 1;
+ bmap[j][i] = WL_STREAM;
+ continue;
+ }
+ if (b==0 && bmap[j][i]==WL_GRAV) gravwl_timeout = 60;
+ bmap[j][i] = b;
+ }
+ }
+ }
+ return 1;
+}
+
+void Simulation::CreateLine(int x1, int y1, int x2, int y2, int rx, int ry, int c, int flags, Brush * cBrush)
{
int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy;
float e, de;
@@ -732,20 +813,73 @@ void Simulation::create_line(int x1, int y1, int x2, int y2, int rx, int ry, int
for (x=x1; x<=x2; x++)
{
if (cp)
- create_parts(y, x, rx, ry, c, flags, cBrush);
+ CreateParts(y, x, rx, ry, c, flags, cBrush);
else
- create_parts(x, y, rx, ry, c, flags, cBrush);
+ CreateParts(x, y, rx, ry, c, flags, cBrush);
e += de;
if (e >= 0.5f)
{
y += sy;
if ((c==WL_EHOLE+100 || c==WL_ALLOWGAS+100 || c==WL_ALLOWENERGY+100 || c==WL_ALLOWALLELEC+100 || c==WL_ALLOWSOLID+100 || c==WL_ALLOWAIR+100 || c==WL_WALL+100 || c==WL_DESTROYALL+100 || c==WL_ALLOWLIQUID+100 || c==WL_FAN+100 || c==WL_STREAM+100 || c==WL_DETECT+100 || c==WL_EWALL+100 || c==WL_WALLELEC+100 || !(rx+ry))
- && ((y1<y2) ? (y<=y2) : (y>=y2)))
+ && ((y1<y2) ? (y<=y2) : (y>=y2)))
+ {
+ if (cp)
+ CreateParts(y, x, rx, ry, c, flags, cBrush);
+ else
+ CreateParts(x, y, rx, ry, c, flags, cBrush);
+ }
+ e -= 1.0f;
+ }
+ }
+}
+
+void Simulation::CreateWallLine(int x1, int y1, int x2, int y2, int rx, int ry, int c, int flags, Brush * cBrush)
+{
+ int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy;
+ float e, de;
+ if (cp)
+ {
+ y = x1;
+ x1 = y1;
+ y1 = y;
+ y = x2;
+ x2 = y2;
+ y2 = y;
+ }
+ if (x1 > x2)
+ {
+ y = x1;
+ x1 = x2;
+ x2 = y;
+ y = y1;
+ y1 = y2;
+ y2 = y;
+ }
+ dx = x2 - x1;
+ dy = abs(y2 - y1);
+ e = 0.0f;
+ if (dx)
+ de = dy/(float)dx;
+ else
+ de = 0.0f;
+ y = y1;
+ sy = (y1<y2) ? 1 : -1;
+ for (x=x1; x<=x2; x++)
+ {
+ if (cp)
+ CreateWalls(y, x, rx, ry, c, flags, cBrush);
+ else
+ CreateWalls(x, y, rx, ry, c, flags, cBrush);
+ e += de;
+ if (e >= 0.5f)
+ {
+ y += sy;
+ if (!(rx+ry) && ((y1<y2) ? (y<=y2) : (y>=y2)))
{
if (cp)
- create_parts(y, x, rx, ry, c, flags, cBrush);
+ CreateWalls(y, x, rx, ry, c, flags, cBrush);
else
- create_parts(x, y, rx, ry, c, flags, cBrush);
+ CreateWalls(x, y, rx, ry, c, flags, cBrush);
}
e -= 1.0f;
}
@@ -1097,7 +1231,7 @@ void Simulation::create_arc(int sx, int sy, int dx, int dy, int midpoints, int v
xmid[i+1] += (rand()%variance)-voffset;
ymid[i+1] += (rand()%variance)-voffset;
}
- create_line(xmid[i], ymid[i], xmid[i+1], ymid[i+1], 0, 0, type, flags);
+ CreateLine(xmid[i], ymid[i], xmid[i+1], ymid[i+1], 0, 0, type, flags);
}
free(xmid);
free(ymid);
diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h
index 62427fc..9ed763a 100644
--- a/src/simulation/Simulation.h
+++ b/src/simulation/Simulation.h
@@ -244,14 +244,22 @@ public:
void update_particles();
void rotate_area(int area_x, int area_y, int area_w, int area_h, int invert);
void clear_area(int area_x, int area_y, int area_w, int area_h);
- void create_box(int x1, int y1, int x2, int y2, int c, int flags);
- int flood_parts(int x, int y, int c, int cm, int bm, int flags);
- int create_parts(int x, int y, int rx, int ry, int c, int flags, Brush * cBrush = NULL);
- void create_line(int x1, int y1, int x2, int y2, int rx, int ry, int c, int flags, Brush * cBrush = NULL);
+
+ void CreateBox(int x1, int y1, int x2, int y2, int c, int flags);
+ int FloodParts(int x, int y, int c, int cm, int bm, int flags);
+ int CreateParts(int x, int y, int rx, int ry, int c, int flags, Brush * cBrush = NULL);
+ void CreateLine(int x1, int y1, int x2, int y2, int rx, int ry, int c, int flags, Brush * cBrush = NULL);
+
+ void CreateWallBox(int x1, int y1, int x2, int y2, int c, int flags);
+ int FloodWalls(int x, int y, int c, int cm, int bm, int flags);
+ int CreateWalls(int x, int y, int rx, int ry, int c, int flags, Brush * cBrush = NULL);
+ void CreateWallLine(int x1, int y1, int x2, int y2, int rx, int ry, int c, int flags, Brush * cBrush = NULL);
+
void ApplyDecoration(int x, int y, int colR, int colG, int colB, int colA, int mode);
void ApplyDecorationPoint(int x, int y, int rx, int ry, int colR, int colG, int colB, int colA, int mode, Brush * cBrush = NULL);
void ApplyDecorationLine(int x1, int y1, int x2, int y2, int rx, int ry, int colR, int colG, int colB, int colA, int mode, Brush * cBrush = NULL);
void ApplyDecorationBox(int x1, int y1, int x2, int y2, int colR, int colG, int colB, int colA, int mode);
+
void *transform_save(void *odata, int *size, matrix2d transform, vector2d translate);
inline void orbitalparts_get(int block1, int block2, int resblock1[], int resblock2[]);
inline void orbitalparts_set(int *block1, int *block2, int resblock1[], int resblock2[]);
diff --git a/src/simulation/SimulationData.cpp b/src/simulation/SimulationData.cpp
index 60def19..fd0c4a5 100644
--- a/src/simulation/SimulationData.cpp
+++ b/src/simulation/SimulationData.cpp
@@ -132,35 +132,26 @@ wall_type * LoadWalls(int & wallCount)
{
wall_type wtypes[] =
{
+ {PIXPACK(0x808080), PIXPACK(0x000000), 0, "Erases walls."},
{PIXPACK(0xC0C0C0), PIXPACK(0x101010), 0, "Wall. Indestructible. Blocks everything. Conductive."},
{PIXPACK(0x808080), PIXPACK(0x808080), 0, "E-Wall. Becomes transparent when electricity is connected."},
{PIXPACK(0xFF8080), PIXPACK(0xFF2008), 1, "Detector. Generates electricity when a particle is inside."},
{PIXPACK(0x808080), PIXPACK(0x000000), 0, "Streamline. Set start point of a streamline."},
- {PIXPACK(0x808080), PIXPACK(0x000000), 0, "Sign. Click on a sign to edit it or anywhere else to place a new one."},
{PIXPACK(0x8080FF), PIXPACK(0x000000), 1, "Fan. Accelerates air. Use line tool to set direction and strength."},
{PIXPACK(0xC0C0C0), PIXPACK(0x101010), 2, "Wall. Blocks most particles but lets liquids through. Conductive."},
{PIXPACK(0x808080), PIXPACK(0x000000), 1, "Wall. Absorbs particles but lets air currents through."},
- {PIXPACK(0x808080), PIXPACK(0x000000), 0, "Erases walls."},
{PIXPACK(0x808080), PIXPACK(0x000000), 3, "Wall. Indestructible. Blocks everything."},
{PIXPACK(0x3C3C3C), PIXPACK(0x000000), 1, "Wall. Indestructible. Blocks particles, allows air"},
{PIXPACK(0x575757), PIXPACK(0x000000), 1, "Wall. Indestructible. Blocks liquids and gasses, allows powders"},
{PIXPACK(0xFFFF22), PIXPACK(0x101010), 2, "Conductor, allows particles, conducts electricity"},
{PIXPACK(0x242424), PIXPACK(0x101010), 0, "E-Hole, absorbs particles, release them when powered"},
- {PIXPACK(0xFFFFFF), PIXPACK(0x000000), -1, "Air, creates airflow and pressure"},
- {PIXPACK(0xFFBB00), PIXPACK(0x000000), -1, "Heats the targetted element."},
- {PIXPACK(0x00BBFF), PIXPACK(0x000000), -1, "Cools the targetted element."},
- {PIXPACK(0x303030), PIXPACK(0x000000), -1, "Vacuum, reduces air pressure."},
{PIXPACK(0x579777), PIXPACK(0x000000), 1, "Wall. Indestructible. Blocks liquids and solids, allows gasses"},
- {PIXPACK(0x000000), PIXPACK(0x000000), -1, "Drag tool"},
{PIXPACK(0xFFEE00), PIXPACK(0xAA9900), 4, "Gravity wall"},
- {PIXPACK(0x0000BB), PIXPACK(0x000000), -1, "Postive gravity tool."},
- {PIXPACK(0x000099), PIXPACK(0x000000), -1, "Negative gravity tool."},
{PIXPACK(0xFFAA00), PIXPACK(0xAA5500), 4, "Energy wall, allows only energy type particles to pass"},
- {PIXPACK(0xFFAA00), PIXPACK(0xAA5500), -1, "Property edit tool"},
};
- wallCount = SC_TOTAL;
- wall_type * wtypesT = (wall_type*)malloc(SC_TOTAL*sizeof(wall_type));
- memcpy(wtypesT, wtypes, SC_TOTAL*sizeof(wall_type));
+ wallCount = UI_WALLCOUNT;
+ wall_type * wtypesT = (wall_type*)malloc(UI_WALLCOUNT*sizeof(wall_type));
+ memcpy(wtypesT, wtypes, UI_WALLCOUNT*sizeof(wall_type));
return wtypesT;
}
diff --git a/src/simulation/SimulationData.h b/src/simulation/SimulationData.h
index 0624322..5e48e94 100644
--- a/src/simulation/SimulationData.h
+++ b/src/simulation/SimulationData.h
@@ -27,23 +27,44 @@
#define UI_WALLSTART 222
#define UI_ACTUALSTART 122
-#define UI_WALLCOUNT 25
-
-#define WL_WALLELEC 122
-#define WL_EWALL 123
-#define WL_DETECT 124
-#define WL_STREAM 125
-#define WL_SIGN 126
-#define WL_FAN 127
-#define WL_FANHELPER 255
-#define WL_ALLOWLIQUID 128
-#define WL_DESTROYALL 129
-#define WL_ERASE 130
-#define WL_WALL 131
-#define WL_ALLOWAIR 132
-#define WL_ALLOWSOLID 133
-#define WL_ALLOWALLELEC 134
-#define WL_EHOLE 135
+#define UI_WALLCOUNT 16
+
+#define O_WL_WALLELEC 122
+#define O_WL_EWALL 123
+#define O_WL_DETECT 124
+#define O_WL_STREAM 125
+#define O_WL_SIGN 126
+#define O_WL_FAN 127
+#define O_WL_FANHELPER 255
+#define O_WL_ALLOWLIQUID 128
+#define O_WL_DESTROYALL 129
+#define O_WL_ERASE 130
+#define O_WL_WALL 131
+#define O_WL_ALLOWAIR 132
+#define O_WL_ALLOWSOLID 133
+#define O_WL_ALLOWALLELEC 134
+#define O_WL_EHOLE 135
+#define O_WL_ALLOWGAS 140
+#define O_WL_GRAV 142
+#define O_WL_ALLOWENERGY 145
+
+
+#define WL_ERASE 0
+#define WL_WALLELEC 1
+#define WL_EWALL 2
+#define WL_DETECT 3
+#define WL_STREAM 4
+#define WL_FAN 5
+#define WL_ALLOWLIQUID 6
+#define WL_DESTROYALL 7
+#define WL_WALL 8
+#define WL_ALLOWAIR 9
+#define WL_ALLOWSOLID 10
+#define WL_ALLOWALLELEC 11
+#define WL_EHOLE 12
+#define WL_ALLOWGAS 13
+#define WL_GRAV 14
+#define WL_ALLOWENERGY 15
#define SPC_AIR 236
#define SPC_HEAT 237
@@ -54,10 +75,6 @@
#define SPC_NGRV 244
#define SPC_PROP 246
-#define WL_ALLOWGAS 140
-#define WL_GRAV 142
-#define WL_ALLOWENERGY 145
-
#define DECO_DRAW 0
#define DECO_ADD 1
#define DECO_SUBTRACT 2
diff --git a/src/simulation/elements/BOMB.cpp b/src/simulation/elements/BOMB.cpp
index ca3be8d..b21be19 100644
--- a/src/simulation/elements/BOMB.cpp
+++ b/src/simulation/elements/BOMB.cpp
@@ -102,8 +102,8 @@ int Element_BOMB::update(UPDATE_FUNC_ARGS)
parts[nb].temp = MAX_TEMP;
}
}
- //create_parts(x, y, 9, 9, PT_BOMB);
- //create_parts(x, y, 8, 8, PT_NONE);
+ //CreateParts(x, y, 9, 9, PT_BOMB);
+ //CreateParts(x, y, 8, 8, PT_NONE);
sim->kill_part(i);
return 1;
}
diff --git a/src/simulation/elements/SPRK.cpp b/src/simulation/elements/SPRK.cpp
index 95f928b..feb825b 100644
--- a/src/simulation/elements/SPRK.cpp
+++ b/src/simulation/elements/SPRK.cpp
@@ -83,7 +83,7 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
nearp = sim->nearest_part(i, PT_ETRD, -1);
if (nearp!=-1 && sim->parts_avg(i, nearp, PT_INSL)!=PT_INSL)
{
- sim->create_line(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), 0, 0, PT_PLSM, 0);
+ sim->CreateLine(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), 0, 0, PT_PLSM, 0);
sim->part_change_type(i,x,y,ct);
ct = parts[i].ctype = PT_NONE;
parts[i].life = 20;
@@ -243,7 +243,7 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
else if (rt==PT_INST) {
if (parts[r>>8].life==0 && parts[i].life<4)
{
- sim->flood_parts(x+rx,y+ry,PT_SPRK,PT_INST,-1, 0);//spark the wire
+ sim->FloodParts(x+rx,y+ry,PT_SPRK,PT_INST,-1, 0);//spark the wire
}
}
else if (parts[r>>8].life==0 && parts[i].life<4) {
diff --git a/src/simulation/elements/STKM.cpp b/src/simulation/elements/STKM.cpp
index e554892..772a3e5 100644
--- a/src/simulation/elements/STKM.cpp
+++ b/src/simulation/elements/STKM.cpp
@@ -304,7 +304,7 @@ int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) {
{
int np = -1;
if (playerp->elem == SPC_AIR)
- sim->create_parts(rx + 3*((((int)playerp->pcomm)&0x02) == 0x02) - 3*((((int)playerp->pcomm)&0x01) == 0x01), ry, 4, 4, SPC_AIR, 0);
+ sim->CreateParts(rx + 3*((((int)playerp->pcomm)&0x02) == 0x02) - 3*((((int)playerp->pcomm)&0x01) == 0x01), ry, 4, 4, SPC_AIR, 0);
else if (playerp->elem==PT_LIGH && playerp->frames<30)//limit lightning creation rate
np = -1;
else