summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-10-11 09:34:33 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-10-11 09:34:33 (GMT)
commit6178bb4605a24193a2049aa109f49b88a1a69ca5 (patch)
tree2ece2535a927ceef67399c85c3734e4a06ba4ff3 /src
parent51aab692e98d19f6a5adf6f558c4ac8226a5f3fd (diff)
downloadpowder-6178bb4605a24193a2049aa109f49b88a1a69ca5.zip
powder-6178bb4605a24193a2049aa109f49b88a1a69ca5.tar.gz
Fixes for LIGH and TESC, LIGH observes gravity setting
Diffstat (limited to 'src')
-rw-r--r--src/elements/ligh.c50
-rw-r--r--src/elements/sprk.c2
-rw-r--r--src/main.c4
-rw-r--r--src/powder.c32
4 files changed, 69 insertions, 19 deletions
diff --git a/src/elements/ligh.c b/src/elements/ligh.c
index 8f9c80e..188ff97 100644
--- a/src/elements/ligh.c
+++ b/src/elements/ligh.c
@@ -1,5 +1,7 @@
#include <element.h>
+#define LIGHTING_POWER 0.65
+
int contact_part(int i, int tp)
{
int x=parts[i].x, y=parts[i].y;
@@ -75,13 +77,22 @@ void create_line_par(int x1, int y1, int x2, int y2, int c, int temp, int life,
int update_LIGH(UPDATE_FUNC_ARGS)
{
- /*tmp2:
- -1 - part will be removed
- 0 -
- 1 -
- 2 -
+ /*
+ *
+ * tmp2:
+ * -1 - part will be removed
+ * 0 - "branches" of the lightning
+ * 1 - bending
+ * 2 - branching
+ * 3 - transfer spark or make destruction
+ * 4 - first pixel
+ *
+ * life - "thickness" of lighting (but anyway one pixel)
+ *
+ * tmp - angle of lighting
+ *
*/
- int r,rx,ry, multipler, powderful=parts[i].temp*(1+parts[i].life/40)/2;
+ int r,rx,ry, multipler, powderful=parts[i].temp*(1+parts[i].life/40)*LIGHTING_POWER;
hv[y/CELL][x/CELL]+=powderful/40;
if (hv[y/CELL][x/CELL]>MAX_TEMP)
hv[y/CELL][x/CELL]=MAX_TEMP;
@@ -92,7 +103,7 @@ int update_LIGH(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
continue;
- if ((r&0xFF)!=PT_LIGH)
+ if ((r&0xFF)!=PT_LIGH && (r&0xFF)!=PT_TESC)
{
if (parts[i].tmp2==3)
{
@@ -140,7 +151,6 @@ int update_LIGH(UPDATE_FUNC_ARGS)
if (parts[i].tmp2==-1)
{
kill_part(i);
- update_PYRO(UPDATE_FUNC_SUBCALL_ARGS);
return 0;
}
if (parts[i].tmp2<=0 || parts[i].life<=1)
@@ -157,7 +167,7 @@ int update_LIGH(UPDATE_FUNC_ARGS)
}
if (parts[i].tmp2<=-2)
{
- killpart(i);
+ kill_part(i);
return 0;
}
@@ -200,7 +210,19 @@ int update_LIGH(UPDATE_FUNC_ARGS)
}
//if (parts[i].tmp2==1/* || near!=-1*/)
- angle=parts[i].tmp-30+rand()%60;
+ switch (gravityMode)
+ {
+ default:
+ case 0:
+ angle = parts[i].tmp-30+rand()%60;
+ break;
+ case 1:
+ angle = rand()%360;
+ break;
+ case 2:
+ angle = atan2(x-XCNTR, y-YCNTR)*(180.0f/M_PI)+90;
+ }
+ //angle=0;//parts[i].tmp-30+rand()%60;
if (angle<0)
angle+=360;
if (angle>=360)
@@ -227,7 +249,9 @@ int update_LIGH(UPDATE_FUNC_ARGS)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
- if (!((r>>8)>=NPART || !r))
+ /*if ((r&0xFF)!=PT_LIGH && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_UDMT && (r&0xFF)!=PT_TESC)
+ part_change_type(r>>8, x+rx, y+ry, PT_LIGH);*/
+ if ((r&0xFF)==PT_LIGH && !((r>>8)>=NPART || !r))
{
parts[r>>8].tmp2=1+(rand()%200>parts[i].tmp2*parts[i].tmp2/10+60);
parts[r>>8].life=(int)(1.0*parts[i].life/1.5-rand()%2);
@@ -246,7 +270,9 @@ int update_LIGH(UPDATE_FUNC_ARGS)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
- if (!((r>>8)>=NPART || !r))
+ /*if ((r&0xFF)!=PT_LIGH && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_UDMT && (r&0xFF)!=PT_TESC)
+ part_change_type(r>>8, x+rx, y+ry, PT_LIGH);*/
+ if ((r&0xFF)==PT_LIGH && !((r>>8)>=NPART || !r))
{
parts[r>>8].tmp2=1+(rand()%200>parts[i].tmp2*parts[i].tmp2/10+40);
parts[r>>8].life=(int)(1.0*parts[i].life/1.5-rand()%2);
diff --git a/src/elements/sprk.c b/src/elements/sprk.c
index ac86467..2633a65 100644
--- a/src/elements/sprk.c
+++ b/src/elements/sprk.c
@@ -68,7 +68,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
int p=create_part(-1, x+rx*2, y+ry*2, PT_LIGH);
if (p!=-1)
{
- if(!parts[i].tmp) //Prevent Arithmetic errors with zero values
+ if(parts[i].tmp<=4) //Prevent Arithmetic errors with zero values
continue;
parts[p].life=rand()%(2+parts[i].tmp/15)+4+parts[i].tmp/7;
if (parts[i].life>60)
diff --git a/src/main.c b/src/main.c
index 97f4d38..dacda26 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2627,13 +2627,13 @@ int main(int argc, char *argv[])
}
if (DEBUG_MODE)
{
- sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d", nametext, 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, Tmp:%d", nametext, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life, parts[cr>>8].tmp);
sprintf(coordtext, "#%d, X:%d Y:%d", cr>>8, x/sdl_scale, y/sdl_scale);
}
else
{
#ifdef BETA
- sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d", nametext, 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, Tmp:%d", nametext, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life, parts[cr>>8].tmp);
#else
sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", nametext, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f);
#endif
diff --git a/src/powder.c b/src/powder.c
index 5547ddd..3fe4ef5 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -846,9 +846,9 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
}
if (t==PT_LIGH)
{
- parts[i].tmp=270;
+ parts[i].tmp = 270;
if (p==-2)
- parts[i].tmp2=4;
+ parts[i].tmp2 = 4;
}
if (t==PT_SOAP)
{
@@ -2806,7 +2806,7 @@ int flood_water(int x, int y, int i, int originaly, int check)
//this creates particles from a brush, don't use if you want to create one particle
int create_parts(int x, int y, int rx, int ry, int c, int flags)
{
- int i, j, r, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0;//n;
+ int i, j, r, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0, p;//n;
int wall = c - 100;
if (c==SPC_WIND){
@@ -2838,7 +2838,6 @@ int create_parts(int x, int y, int rx, int ry, int c, int flags)
{
gravwl_timeout = 60;
}
-
if (c==PT_LIGH)
{
if (lighting_recreate>0 && rx+ry>0)
@@ -2994,6 +2993,31 @@ int create_parts(int x, int y, int rx, int ry, int c, int flags)
}
//else, no special modes, draw element like normal.
+ if(c==PT_TESC)
+ {
+ if (rx==0&&ry==0)//workaround for 1pixel brush/floodfill crashing. todo: find a better fix later.
+ {
+ if (create_part(-2, x, y, c)==-1)
+ f = 1;
+ }
+ else
+ for (j=-ry; j<=ry; j++)
+ for (i=-rx; i<=rx; i++)
+ if (InCurrentBrush(i ,j ,rx ,ry))
+ {
+ p = create_part(-2, x+i, y+j, c);
+ if (p==-1)
+ {
+ f = 1;
+ } else {
+ parts[p].tmp=rx*4+ry*4+7;
+ if (parts[p].tmp>300)
+ parts[p].tmp=300;
+ }
+ }
+ return !f;
+ }
+
if (rx==0&&ry==0)//workaround for 1pixel brush/floodfill crashing. todo: find a better fix later.
{
if (create_part(-2, x, y, c)==-1)