summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon <simon@hardwired.org.uk>2011-04-08 10:09:42 (GMT)
committer Simon <simon@hardwired.org.uk>2011-04-08 10:09:42 (GMT)
commit767d73c5fc51647dcb5da4ed8349da2186c5060c (patch)
treee9cb3540858927af4887553068fd348a95195092 /src
parent1bdf72be1a306ac07641211adb2ec1539e3d0a48 (diff)
downloadpowder-767d73c5fc51647dcb5da4ed8349da2186c5060c.zip
powder-767d73c5fc51647dcb5da4ed8349da2186c5060c.tar.gz
astyle
Diffstat (limited to 'src')
-rw-r--r--src/air.c318
-rw-r--r--src/elements/O2.c62
-rw-r--r--src/elements/aray.c4
-rw-r--r--src/elements/glow.c2
-rw-r--r--src/elements/h2.c20
-rw-r--r--src/elements/prti.c16
-rw-r--r--src/elements/prto.c12
-rw-r--r--src/elements/qrtz.c36
-rw-r--r--src/elements/sing.c16
-rw-r--r--src/graphics.c68
-rw-r--r--src/http.c4
-rw-r--r--src/interface.c132
-rw-r--r--src/main.c3050
-rw-r--r--src/misc.c54
-rw-r--r--src/powder.c90
15 files changed, 1935 insertions, 1949 deletions
diff --git a/src/air.c b/src/air.c
index 9fbfc86..8c11f30 100644
--- a/src/air.c
+++ b/src/air.c
@@ -34,180 +34,180 @@ void update_air(void)
int x, y, i, j;
float dp, dx, dy, f, tx, ty;
-if (airMode != 4) { //airMode 4 is no air/pressure update
-
- for (i=0; i<YRES/CELL; i++) //reduces pressure/velocity on the edges every frame
- {
- pv[i][0] = pv[i][0]*0.8f;
- pv[i][1] = pv[i][1]*0.8f;
- pv[i][2] = pv[i][2]*0.8f;
- pv[i][XRES/CELL-2] = pv[i][XRES/CELL-2]*0.8f;
- pv[i][XRES/CELL-1] = pv[i][XRES/CELL-1]*0.8f;
- vx[i][0] = vx[i][1]*0.9f;
- vx[i][1] = vx[i][2]*0.9f;
- vx[i][XRES/CELL-2] = vx[i][XRES/CELL-3]*0.9f;
- vx[i][XRES/CELL-1] = vx[i][XRES/CELL-2]*0.9f;
- vy[i][0] = vy[i][1]*0.9f;
- vy[i][1] = vy[i][2]*0.9f;
- vy[i][XRES/CELL-2] = vy[i][XRES/CELL-3]*0.9f;
- vy[i][XRES/CELL-1] = vy[i][XRES/CELL-2]*0.9f;
- }
- for (i=0; i<XRES/CELL; i++) //reduces pressure/velocity on the edges every frame
- {
- pv[0][i] = pv[0][i]*0.8f;
- pv[1][i] = pv[1][i]*0.8f;
- pv[2][i] = pv[2][i]*0.8f;
- pv[YRES/CELL-2][i] = pv[YRES/CELL-2][i]*0.8f;
- pv[YRES/CELL-1][i] = pv[YRES/CELL-1][i]*0.8f;
- vx[0][i] = vx[1][i]*0.9f;
- vx[1][i] = vx[2][i]*0.9f;
- vx[YRES/CELL-2][i] = vx[YRES/CELL-3][i]*0.9f;
- vx[YRES/CELL-1][i] = vx[YRES/CELL-2][i]*0.9f;
- vy[0][i] = vy[1][i]*0.9f;
- vy[1][i] = vy[2][i]*0.9f;
- vy[YRES/CELL-2][i] = vy[YRES/CELL-3][i]*0.9f;
- vy[YRES/CELL-1][i] = vy[YRES/CELL-2][i]*0.9f;
- }
+ if (airMode != 4) { //airMode 4 is no air/pressure update
- for (j=1; j<YRES/CELL; j++) //clear some velocities near walls
- {
- for (i=1; i<XRES/CELL; i++)
+ for (i=0; i<YRES/CELL; i++) //reduces pressure/velocity on the edges every frame
{
- if (bmap[j][i]==WL_WALL || bmap[j][i]==WL_WALLELEC || (bmap[j][i]==WL_EWALL && !emap[j][i]))
- {
- vx[j][i] = 0.0f;
- vx[j][i-1] = 0.0f;
- vy[j][i] = 0.0f;
- vy[j-1][i] = 0.0f;
- }
+ pv[i][0] = pv[i][0]*0.8f;
+ pv[i][1] = pv[i][1]*0.8f;
+ pv[i][2] = pv[i][2]*0.8f;
+ pv[i][XRES/CELL-2] = pv[i][XRES/CELL-2]*0.8f;
+ pv[i][XRES/CELL-1] = pv[i][XRES/CELL-1]*0.8f;
+ vx[i][0] = vx[i][1]*0.9f;
+ vx[i][1] = vx[i][2]*0.9f;
+ vx[i][XRES/CELL-2] = vx[i][XRES/CELL-3]*0.9f;
+ vx[i][XRES/CELL-1] = vx[i][XRES/CELL-2]*0.9f;
+ vy[i][0] = vy[i][1]*0.9f;
+ vy[i][1] = vy[i][2]*0.9f;
+ vy[i][XRES/CELL-2] = vy[i][XRES/CELL-3]*0.9f;
+ vy[i][XRES/CELL-1] = vy[i][XRES/CELL-2]*0.9f;
}
- }
-
- for (y=1; y<YRES/CELL; y++) //pressure adjustments from velocity
- for (x=1; x<XRES/CELL; x++)
+ for (i=0; i<XRES/CELL; i++) //reduces pressure/velocity on the edges every frame
{
- dp = 0.0f;
- dp += vx[y][x-1] - vx[y][x];
- dp += vy[y-1][x] - vy[y][x];
- pv[y][x] *= AIR_PLOSS;
- pv[y][x] += dp*AIR_TSTEPP;
+ pv[0][i] = pv[0][i]*0.8f;
+ pv[1][i] = pv[1][i]*0.8f;
+ pv[2][i] = pv[2][i]*0.8f;
+ pv[YRES/CELL-2][i] = pv[YRES/CELL-2][i]*0.8f;
+ pv[YRES/CELL-1][i] = pv[YRES/CELL-1][i]*0.8f;
+ vx[0][i] = vx[1][i]*0.9f;
+ vx[1][i] = vx[2][i]*0.9f;
+ vx[YRES/CELL-2][i] = vx[YRES/CELL-3][i]*0.9f;
+ vx[YRES/CELL-1][i] = vx[YRES/CELL-2][i]*0.9f;
+ vy[0][i] = vy[1][i]*0.9f;
+ vy[1][i] = vy[2][i]*0.9f;
+ vy[YRES/CELL-2][i] = vy[YRES/CELL-3][i]*0.9f;
+ vy[YRES/CELL-1][i] = vy[YRES/CELL-2][i]*0.9f;
}
- for (y=0; y<YRES/CELL-1; y++) //velocity adjustments from pressure
- for (x=0; x<XRES/CELL-1; x++)
+ for (j=1; j<YRES/CELL; j++) //clear some velocities near walls
{
- dx = dy = 0.0f;
- dx += pv[y][x] - pv[y][x+1];
- dy += pv[y][x] - pv[y+1][x];
- vx[y][x] *= AIR_VLOSS;
- vy[y][x] *= AIR_VLOSS;
- vx[y][x] += dx*AIR_TSTEPV;
- vy[y][x] += dy*AIR_TSTEPV;
- if (bmap[y][x]==WL_WALL || bmap[y][x+1]==WL_WALL ||
- bmap[y][x]==WL_WALLELEC || bmap[y][x+1]==WL_WALLELEC ||
- (bmap[y][x]==WL_EWALL && !emap[y][x]) ||
- (bmap[y][x+1]==WL_EWALL && !emap[y][x+1]))
- vx[y][x] = 0;
- if (bmap[y][x]==WL_WALL || bmap[y+1][x]==WL_WALL ||
- bmap[y][x]==WL_WALLELEC || bmap[y+1][x]==WL_WALLELEC ||
- (bmap[y][x]==WL_EWALL && !emap[y][x]) ||
- (bmap[y+1][x]==WL_EWALL && !emap[y+1][x]))
- vy[y][x] = 0;
+ for (i=1; i<XRES/CELL; i++)
+ {
+ if (bmap[j][i]==WL_WALL || bmap[j][i]==WL_WALLELEC || (bmap[j][i]==WL_EWALL && !emap[j][i]))
+ {
+ vx[j][i] = 0.0f;
+ vx[j][i-1] = 0.0f;
+ vy[j][i] = 0.0f;
+ vy[j-1][i] = 0.0f;
+ }
+ }
}
- for (y=0; y<YRES/CELL; y++) //update velocity and pressure
- for (x=0; x<XRES/CELL; x++)
- {
- dx = 0.0f;
- dy = 0.0f;
- dp = 0.0f;
- for (j=-1; j<2; j++)
- for (i=-1; i<2; i++)
- if (y+j>0 && y+j<YRES/CELL-1 &&
- x+i>0 && x+i<XRES/CELL-1 &&
- bmap[y+j][x+i]!=WL_WALL &&
- bmap[y+j][x+i]!=WL_WALLELEC &&
- (bmap[y+j][x+i]!=WL_EWALL || emap[y+j][x+i]))
- {
- f = kernel[i+1+(j+1)*3];
- dx += vx[y+j][x+i]*f;
- dy += vy[y+j][x+i]*f;
- dp += pv[y+j][x+i]*f;
- }
- else
- {
- f = kernel[i+1+(j+1)*3];
- dx += vx[y][x]*f;
- dy += vy[y][x]*f;
- dp += pv[y][x]*f;
- }
-
- tx = x - dx*0.7f;
- ty = y - dy*0.7f;
- i = (int)tx;
- j = (int)ty;
- tx -= i;
- ty -= j;
- if (i>=2 && i<XRES/CELL-3 &&
- j>=2 && j<YRES/CELL-3)
+ for (y=1; y<YRES/CELL; y++) //pressure adjustments from velocity
+ for (x=1; x<XRES/CELL; x++)
{
- dx *= 1.0f - AIR_VADV;
- dy *= 1.0f - AIR_VADV;
-
- dx += AIR_VADV*(1.0f-tx)*(1.0f-ty)*vx[j][i];
- dy += AIR_VADV*(1.0f-tx)*(1.0f-ty)*vy[j][i];
-
- dx += AIR_VADV*tx*(1.0f-ty)*vx[j][i+1];
- dy += AIR_VADV*tx*(1.0f-ty)*vy[j][i+1];
-
- dx += AIR_VADV*(1.0f-tx)*ty*vx[j+1][i];
- dy += AIR_VADV*(1.0f-tx)*ty*vy[j+1][i];
-
- dx += AIR_VADV*tx*ty*vx[j+1][i+1];
- dy += AIR_VADV*tx*ty*vy[j+1][i+1];
+ dp = 0.0f;
+ dp += vx[y][x-1] - vx[y][x];
+ dp += vy[y-1][x] - vy[y][x];
+ pv[y][x] *= AIR_PLOSS;
+ pv[y][x] += dp*AIR_TSTEPP;
}
- if (bmap[y][x] == WL_FAN)
+ for (y=0; y<YRES/CELL-1; y++) //velocity adjustments from pressure
+ for (x=0; x<XRES/CELL-1; x++)
{
- dx += fvx[y][x];
- dy += fvy[y][x];
+ dx = dy = 0.0f;
+ dx += pv[y][x] - pv[y][x+1];
+ dy += pv[y][x] - pv[y+1][x];
+ vx[y][x] *= AIR_VLOSS;
+ vy[y][x] *= AIR_VLOSS;
+ vx[y][x] += dx*AIR_TSTEPV;
+ vy[y][x] += dy*AIR_TSTEPV;
+ if (bmap[y][x]==WL_WALL || bmap[y][x+1]==WL_WALL ||
+ bmap[y][x]==WL_WALLELEC || bmap[y][x+1]==WL_WALLELEC ||
+ (bmap[y][x]==WL_EWALL && !emap[y][x]) ||
+ (bmap[y][x+1]==WL_EWALL && !emap[y][x+1]))
+ vx[y][x] = 0;
+ if (bmap[y][x]==WL_WALL || bmap[y+1][x]==WL_WALL ||
+ bmap[y][x]==WL_WALLELEC || bmap[y+1][x]==WL_WALLELEC ||
+ (bmap[y][x]==WL_EWALL && !emap[y][x]) ||
+ (bmap[y+1][x]==WL_EWALL && !emap[y+1][x]))
+ vy[y][x] = 0;
}
- // pressure/velocity caps
- if (dp > 256.0f) dp = 256.0f;
- if (dp < -256.0f) dp = -256.0f;
- if (dx > 256.0f) dx = 256.0f;
- if (dx < -256.0f) dx = -256.0f;
- if (dy > 256.0f) dy = 256.0f;
- if (dy < -256.0f) dy = -256.0f;
-
- switch (airMode)
+ for (y=0; y<YRES/CELL; y++) //update velocity and pressure
+ for (x=0; x<XRES/CELL; x++)
{
- default:
- case 0: //Default
- break;
- case 1: //0 Pressure
- dp = 0.0f;
- break;
- case 2: //0 Velocity
- dx = 0.0f;
- dy = 0.0f;
- break;
- case 3: //0 Air
- dx = 0.0f;
- dy = 0.0f;
- dp = 0.0f;
- break;
- case 4: //No Update
- break;
+ dx = 0.0f;
+ dy = 0.0f;
+ dp = 0.0f;
+ for (j=-1; j<2; j++)
+ for (i=-1; i<2; i++)
+ if (y+j>0 && y+j<YRES/CELL-1 &&
+ x+i>0 && x+i<XRES/CELL-1 &&
+ bmap[y+j][x+i]!=WL_WALL &&
+ bmap[y+j][x+i]!=WL_WALLELEC &&
+ (bmap[y+j][x+i]!=WL_EWALL || emap[y+j][x+i]))
+ {
+ f = kernel[i+1+(j+1)*3];
+ dx += vx[y+j][x+i]*f;
+ dy += vy[y+j][x+i]*f;
+ dp += pv[y+j][x+i]*f;
+ }
+ else
+ {
+ f = kernel[i+1+(j+1)*3];
+ dx += vx[y][x]*f;
+ dy += vy[y][x]*f;
+ dp += pv[y][x]*f;
+ }
+
+ tx = x - dx*0.7f;
+ ty = y - dy*0.7f;
+ i = (int)tx;
+ j = (int)ty;
+ tx -= i;
+ ty -= j;
+ if (i>=2 && i<XRES/CELL-3 &&
+ j>=2 && j<YRES/CELL-3)
+ {
+ dx *= 1.0f - AIR_VADV;
+ dy *= 1.0f - AIR_VADV;
+
+ dx += AIR_VADV*(1.0f-tx)*(1.0f-ty)*vx[j][i];
+ dy += AIR_VADV*(1.0f-tx)*(1.0f-ty)*vy[j][i];
+
+ dx += AIR_VADV*tx*(1.0f-ty)*vx[j][i+1];
+ dy += AIR_VADV*tx*(1.0f-ty)*vy[j][i+1];
+
+ dx += AIR_VADV*(1.0f-tx)*ty*vx[j+1][i];
+ dy += AIR_VADV*(1.0f-tx)*ty*vy[j+1][i];
+
+ dx += AIR_VADV*tx*ty*vx[j+1][i+1];
+ dy += AIR_VADV*tx*ty*vy[j+1][i+1];
+ }
+
+ if (bmap[y][x] == WL_FAN)
+ {
+ dx += fvx[y][x];
+ dy += fvy[y][x];
+ }
+ // pressure/velocity caps
+ if (dp > 256.0f) dp = 256.0f;
+ if (dp < -256.0f) dp = -256.0f;
+ if (dx > 256.0f) dx = 256.0f;
+ if (dx < -256.0f) dx = -256.0f;
+ if (dy > 256.0f) dy = 256.0f;
+ if (dy < -256.0f) dy = -256.0f;
+
+
+ switch (airMode)
+ {
+ default:
+ case 0: //Default
+ break;
+ case 1: //0 Pressure
+ dp = 0.0f;
+ break;
+ case 2: //0 Velocity
+ dx = 0.0f;
+ dy = 0.0f;
+ break;
+ case 3: //0 Air
+ dx = 0.0f;
+ dy = 0.0f;
+ dp = 0.0f;
+ break;
+ case 4: //No Update
+ break;
+ }
+
+ ovx[y][x] = dx;
+ ovy[y][x] = dy;
+ opv[y][x] = dp;
}
-
- ovx[y][x] = dx;
- ovy[y][x] = dy;
- opv[y][x] = dp;
- }
- memcpy(vx, ovx, sizeof(vx));
- memcpy(vy, ovy, sizeof(vy));
- memcpy(pv, opv, sizeof(pv));
-}
+ memcpy(vx, ovx, sizeof(vx));
+ memcpy(vy, ovy, sizeof(vy));
+ memcpy(pv, opv, sizeof(pv));
+ }
}
diff --git a/src/elements/O2.c b/src/elements/O2.c
index f554d1f..a8be78b 100644
--- a/src/elements/O2.c
+++ b/src/elements/O2.c
@@ -2,47 +2,47 @@
int update_O2(UPDATE_FUNC_ARGS)
{
- int r,rx,ry;
- for(rx=-2; rx<3; rx++)
- for(ry=-2; ry<3; ry++)
+ int r,rx,ry;
+ for (rx=-2; rx<3; rx++)
+ for (ry=-2; ry<3; ry++)
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)
continue;
- if((r&0xFF)==PT_FIRE)
- {
- parts[r>>8].life+=(rand()/(RAND_MAX/100))*2;
- parts[r>>8].temp+=(rand()/(RAND_MAX/100));
- parts[i].tmp++;
- }
+ if ((r&0xFF)==PT_FIRE)
+ {
+ parts[r>>8].life+=(rand()/(RAND_MAX/100))*2;
+ parts[r>>8].temp+=(rand()/(RAND_MAX/100));
+ parts[i].tmp++;
+ }
- }
+ }
- if(pv[y/CELL][x/CELL] > 8.0f)
- {
- for(rx=-2; rx<3; rx++)
- for(ry=-2; ry<3; ry++)
- 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)
- continue;
- if((r&0xFF)==PT_H2)
- if(50<(rand()/(RAND_MAX/100))){
- part_change_type(i,x,y,PT_WATR);
+ if (pv[y/CELL][x/CELL] > 8.0f)
+ {
+ for (rx=-2; rx<3; rx++)
+ for (ry=-2; ry<3; ry++)
+ 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)
+ continue;
+ if ((r&0xFF)==PT_H2)
+ if (50<(rand()/(RAND_MAX/100))) {
+ part_change_type(i,x,y,PT_WATR);
part_change_type(r>>8,x+rx,y+ry,PT_WATR);
}
- }
- }
+ }
+ }
- if(parts[i].tmp>=50)
- {
- create_part(i,x,y,PT_FIRE);
- parts[i].life+=(rand()/(RAND_MAX/100))+50;
- parts[i].temp+=(rand()/(RAND_MAX/100));
- }
- return 0;
+ if (parts[i].tmp>=50)
+ {
+ create_part(i,x,y,PT_FIRE);
+ parts[i].life+=(rand()/(RAND_MAX/100))+50;
+ parts[i].temp+=(rand()/(RAND_MAX/100));
+ }
+ return 0;
}
diff --git a/src/elements/aray.c b/src/elements/aray.c
index ac51f66..4f94f00 100644
--- a/src/elements/aray.c
+++ b/src/elements/aray.c
@@ -44,7 +44,7 @@ int update_ARAY(UPDATE_FUNC_ARGS) {
}
else if ((r&0xFF)==PT_FILT) {//get color if passed through FILT
colored = parts[r>>8].ctype;
- //this if prevents BRAY from stopping on certain materials
+ //this if prevents BRAY from stopping on certain materials
} else if ((r&0xFF)!=PT_INWR && (r&0xFF)!=PT_ARAY && (r&0xFF)!=PT_WIFI && !((r&0xFF)==PT_SWCH && parts[r>>8].life>=10)) {
if (nyy!=0 || nxx!=0) {
create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_SPRK);
@@ -59,7 +59,7 @@ int update_ARAY(UPDATE_FUNC_ARGS) {
if ((r&0xFF)==PT_BRAY) {
parts[r>>8].life = 1;
docontinue = 1;
- //this if prevents red BRAY from stopping on certain materials
+ //this if prevents red BRAY from stopping on certain materials
} else if ((r&0xFF)==PT_INWR || (r&0xFF)==PT_ARAY || (r&0xFF)==PT_WIFI || (r&0xFF)==PT_FILT || ((r&0xFF)==PT_SWCH && parts[r>>8].life>=10)) {
docontinue = 1;
} else {
diff --git a/src/elements/glow.c b/src/elements/glow.c
index d692233..ecbb005 100644
--- a/src/elements/glow.c
+++ b/src/elements/glow.c
@@ -17,7 +17,7 @@ int update_GLOW(UPDATE_FUNC_ARGS) {
}
}
parts[i].ctype = pv[y/CELL][x/CELL]*16;
-
+
parts[i].tmp = abs((int)((vx[y/CELL][x/CELL]+vy[y/CELL][x/CELL])*16.0f)) + abs((int)((parts[i].vx+parts[i].vy)*64.0f));
//printf("%f %f\n", parts[i].vx, parts[i].vy);
if (parts[i].type==PT_NONE) {
diff --git a/src/elements/h2.c b/src/elements/h2.c
index 0b93242..e3fee78 100644
--- a/src/elements/h2.c
+++ b/src/elements/h2.c
@@ -2,20 +2,20 @@
int update_H2(UPDATE_FUNC_ARGS)
{
- int r,rx,ry,rt;
- for(rx=-2; rx<3; rx++)
- for(ry=-2; ry<3; ry++)
+ int r,rx,ry,rt;
+ for (rx=-2; rx<3; rx++)
+ for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
- rt = (r&0xFF);
+ rt = (r&0xFF);
if ((r>>8)>=NPART || !r)
continue;
- if(pv[y/CELL][x/CELL] > 8.0f && rt == PT_DESL) // This will not work. DESL turns to fire above 5.0 pressure
- {
- part_change_type(r>>8,x+rx,y+ry,PT_WATR);
- part_change_type(i,x,y,PT_OIL);
- }
- }
+ if (pv[y/CELL][x/CELL] > 8.0f && rt == PT_DESL) // This will not work. DESL turns to fire above 5.0 pressure
+ {
+ part_change_type(r>>8,x+rx,y+ry,PT_WATR);
+ part_change_type(i,x,y,PT_OIL);
+ }
+ }
return 0;
}
diff --git a/src/elements/prti.c b/src/elements/prti.c
index 5c34cf9..f51c21c 100644
--- a/src/elements/prti.c
+++ b/src/elements/prti.c
@@ -39,18 +39,18 @@ int update_PRTI(UPDATE_FUNC_ARGS) {
break;
}
}
-
-
- if(fe){
+
+
+ if (fe) {
int orbd[4] = {0, 0, 0, 0}; //Orbital distances
int orbl[4] = {0, 0, 0, 0}; //Orbital locations
- if(!parts[i].life) parts[i].life = rand();
- if(!parts[i].ctype) parts[i].life = rand();
+ if (!parts[i].life) parts[i].life = rand();
+ if (!parts[i].ctype) parts[i].life = rand();
orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
- for(r = 0; r < 4; r++){
- if(orbd[r]>1){
+ for (r = 0; r < 4; r++) {
+ if (orbd[r]>1) {
orbd[r] -= 12;
- if(orbd[r]<1){
+ if (orbd[r]<1) {
orbd[r] = (rand()%128)+128;
orbl[r] = rand()%255;
} else {
diff --git a/src/elements/prto.c b/src/elements/prto.c
index 40cf97c..46c7250 100644
--- a/src/elements/prto.c
+++ b/src/elements/prto.c
@@ -62,16 +62,16 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
}
}
}
- if(fe){
+ if (fe) {
int orbd[4] = {0, 0, 0, 0}; //Orbital distances
int orbl[4] = {0, 0, 0, 0}; //Orbital locations
- if(!parts[i].life) parts[i].life = rand();
- if(!parts[i].ctype) parts[i].life = rand();
+ if (!parts[i].life) parts[i].life = rand();
+ if (!parts[i].ctype) parts[i].life = rand();
orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
- for(r = 0; r < 4; r++){
- if(orbd[r]<254){
+ for (r = 0; r < 4; r++) {
+ if (orbd[r]<254) {
orbd[r] += 16;
- if(orbd[r]>254){
+ if (orbd[r]>254) {
orbd[r] = 0;
orbl[r] = rand()%255;
}
diff --git a/src/elements/qrtz.c b/src/elements/qrtz.c
index 4d3662f..f8312c1 100644
--- a/src/elements/qrtz.c
+++ b/src/elements/qrtz.c
@@ -3,7 +3,7 @@
int update_QRTZ(UPDATE_FUNC_ARGS) {
int r, tmp, trade, rx, ry, np, t;
t = parts[i].type;
- if(t == PT_QRTZ)
+ if (t == PT_QRTZ)
{
parts[i].pavg[0] = parts[i].pavg[1];
parts[i].pavg[1] = pv[y/CELL][x/CELL];
@@ -32,29 +32,29 @@ int update_QRTZ(UPDATE_FUNC_ARGS) {
{
rx = rand()%3-1;
ry = rand()%3-1;
- if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
+ 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 && parts[i].ctype!=0)
{
- r = pmap[y+ry][x+rx];
- if ((r>>8)<NPART && !r && parts[i].ctype!=0)
+ np = create_part(-1,x+rx,y+ry,PT_QRTZ);
+ if (np>0)
{
- np = create_part(-1,x+rx,y+ry,PT_QRTZ);
- if (np>0)
+ parts[np].tmp = parts[i].tmp;
+ parts[i].ctype = 0;
+ if (5>rand()%10)
{
- parts[np].tmp = parts[i].tmp;
- parts[i].ctype = 0;
- if(5>rand()%10)
- {
- parts[np].ctype=-1;//dead qrtz
- }
- else if(1>rand()%15)
- {
- parts[i].ctype=-1;
- }
-
- break;
+ parts[np].ctype=-1;//dead qrtz
}
+ else if (1>rand()%15)
+ {
+ parts[i].ctype=-1;
+ }
+
+ break;
}
}
+ }
}
}
for ( trade = 0; trade<9; trade ++)
diff --git a/src/elements/sing.c b/src/elements/sing.c
index 6d1fac3..0bed688 100644
--- a/src/elements/sing.c
+++ b/src/elements/sing.c
@@ -22,26 +22,26 @@ int update_SING(UPDATE_FUNC_ARGS) {
if (y+CELL>0)
pv[y/CELL-1][x/CELL-1] += 0.1f*(singularity-pv[y/CELL-1][x/CELL-1]);
}
- if(parts[i].life<1){
+ if (parts[i].life<1) {
//Pop!
- for(rx=-2; rx<3; rx++){
+ for (rx=-2; rx<3; rx++) {
crx = (x/CELL)+rx;
- for(ry=-2; ry<3; ry++){
+ for (ry=-2; ry<3; ry++) {
cry = (y/CELL)+ry;
- if(cry > 0 && crx > 0 && crx < (XRES/CELL) && cry < (YRES/CELL)){
- pv[cry][crx] += (float)parts[i].tmp;
+ if (cry > 0 && crx > 0 && crx < (XRES/CELL) && cry < (YRES/CELL)) {
+ pv[cry][crx] += (float)parts[i].tmp;
}
}
}
rad = (parts[i].tmp>255)?255:parts[i].tmp;
- if(rad>=1){
+ if (rad>=1) {
rad = (int)(((float)rad)/8.0f);
}
- if(rad>=1){
+ if (rad>=1) {
for (nxj=-(rad+1); nxj<=(rad+1); nxj++)
for (nxi=-(rad+1); nxi<=(rad+1); nxi++)
if ((pow(nxi,2))/(pow((rad+1),2))+(pow(nxj,2))/(pow((rad+1),2))<=1) {
- if(rand()%2){
+ if (rand()%2) {
nb = create_part(-1, x+nxi, y+nxj, PT_PHOT);
} else {
nb = create_part(-1, x+nxi, y+nxj, PT_NEUT);
diff --git a/src/graphics.c b/src/graphics.c
index b4cd51c..6270547 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -1632,7 +1632,7 @@ void draw_parts(pixel *vid)
fr = restrict_flt(parts[i].temp-(275.13f+32.0f), 0, 128)/50.0f;
fg = restrict_flt(parts[i].ctype, 0, 128)/50.0f;
fb = restrict_flt(parts[i].tmp, 0, 128)/50.0f;
-
+
cr = restrict_flt(64.0f+parts[i].temp-(275.13f+32.0f), 0, 255);
cg = restrict_flt(64.0f+parts[i].ctype, 0, 255);
cb = restrict_flt(64.0f+parts[i].tmp, 0, 255);
@@ -1808,45 +1808,45 @@ void draw_parts(pixel *vid)
blendpixel(vid, nx, ny, cr, cg, cb, 255);
}
- else if(t==PT_LOTE)//colors for life states
+ else if (t==PT_LOTE)//colors for life states
{
- if(parts[i].tmp==2)
+ if (parts[i].tmp==2)
blendpixel(vid, nx, ny, 255, 128, 0, 255);
- else if(parts[i].tmp==1)
+ else if (parts[i].tmp==1)
blendpixel(vid, nx, ny, 255, 255, 0, 255);
else
blendpixel(vid, nx, ny, 255, 0, 0, 255);
}
- else if(t==PT_FRG2)//colors for life states
+ else if (t==PT_FRG2)//colors for life states
{
- if(parts[i].tmp==2)
+ if (parts[i].tmp==2)
blendpixel(vid, nx, ny, 0, 100, 50, 255);
else
blendpixel(vid, nx, ny, 0, 255, 90, 255);
}
- else if(t==PT_STAR)//colors for life states
+ else if (t==PT_STAR)//colors for life states
{
- if(parts[i].tmp==4)
+ if (parts[i].tmp==4)
blendpixel(vid, nx, ny, 0, 0, 128, 255);
- else if(parts[i].tmp==3)
+ else if (parts[i].tmp==3)
blendpixel(vid, nx, ny, 0, 0, 150, 255);
- else if(parts[i].tmp==2)
+ else if (parts[i].tmp==2)
blendpixel(vid, nx, ny, 0, 0, 190, 255);
- else if(parts[i].tmp==1)
+ else if (parts[i].tmp==1)
blendpixel(vid, nx, ny, 0, 0, 230, 255);
else
blendpixel(vid, nx, ny, 0, 0, 70, 255);
}
- else if(t==PT_FROG)//colors for life states
+ else if (t==PT_FROG)//colors for life states
{
- if(parts[i].tmp==2)
+ if (parts[i].tmp==2)
blendpixel(vid, nx, ny, 0, 100, 0, 255);
else
blendpixel(vid, nx, ny, 0, 255, 0, 255);
}
- else if(t==PT_BRAN)//colors for life states
+ else if (t==PT_BRAN)//colors for life states
{
- if(parts[i].tmp==1)
+ if (parts[i].tmp==1)
blendpixel(vid, nx, ny, 150, 150, 0, 255);
else
blendpixel(vid, nx, ny, 255, 255, 0, 255);
@@ -1985,23 +1985,23 @@ void draw_parts(pixel *vid)
float drad = 0.0f;
float ddist = 0.0f;
orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
- for(r = 0; r < 4; r++){
+ for (r = 0; r < 4; r++) {
ddist = ((float)orbd[r])/16.0f;
drad = (M_PI * ((float)orbl[r]) / 180.0f)*1.41f;
nxo = ddist*cos(drad);
nyo = ddist*sin(drad);
- if(ny+nyo>0 && ny+nyo<YRES && nx+nxo>0 && nx+nxo<XRES){
+ if (ny+nyo>0 && ny+nyo<YRES && nx+nxo>0 && nx+nxo<XRES) {
addpixel(vid, nx+nxo, ny+nyo, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), 255-orbd[r]);
- if(cmode == CM_FIRE && r == 1){
+ if (cmode == CM_FIRE && r == 1) {
fire_rv = fire_r[(ny+nyo)/CELL][(nx+nxo)/CELL];
fire_rv += 1;
- if(fire_rv>255) fire_rv = 255;
+ if (fire_rv>255) fire_rv = 255;
fire_r[(ny+nyo)/CELL][(nx+nxo)/CELL] = fire_rv;
}
}
addpixel(vid, nx, ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), 200);
}
- if(DEBUG_MODE){//draw lines connecting portals
+ if (DEBUG_MODE) {//draw lines connecting portals
blendpixel(vid,nx,ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors),255);
if (mousex==(nx) && mousey==(ny))
{
@@ -2024,23 +2024,23 @@ void draw_parts(pixel *vid)
float drad = 0.0f;
float ddist = 0.0f;
orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
- for(r = 0; r < 4; r++){
+ for (r = 0; r < 4; r++) {
ddist = ((float)orbd[r])/16.0f;
drad = (M_PI * ((float)orbl[r]) / 180.0f)*1.41f;
nxo = ddist*cos(drad);
nyo = ddist*sin(drad);
- if(ny+nyo>0 && ny+nyo<YRES && nx+nxo>0 && nx+nxo<XRES){
+ if (ny+nyo>0 && ny+nyo<YRES && nx+nxo>0 && nx+nxo<XRES) {
addpixel(vid, nx+nxo, ny+nyo, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), 255-orbd[r]);
- if(cmode == CM_FIRE && r == 1){
+ if (cmode == CM_FIRE && r == 1) {
fire_bv = fire_b[(ny+nyo)/CELL][(nx+nxo)/CELL];
fire_bv += 1;
- if(fire_bv>255) fire_bv = 255;
+ if (fire_bv>255) fire_bv = 255;
fire_b[(ny+nyo)/CELL][(nx+nxo)/CELL] = fire_bv;
}
}
addpixel(vid, nx, ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), 200);
}
- if(DEBUG_MODE){//draw lines connecting portals
+ if (DEBUG_MODE) {//draw lines connecting portals
blendpixel(vid,nx,ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors),255);
if (mousex==(nx) && mousey==(ny))
{
@@ -2482,11 +2482,11 @@ void draw_parts(pixel *vid)
fr = restrict_flt(parts[i].temp-(275.13f+32.0f), 0, 128)/50.0f;
fg = restrict_flt(parts[i].ctype, 0, 128)/50.0f;
fb = restrict_flt(parts[i].tmp, 0, 128)/50.0f;
-
+
cr = restrict_flt(64.0f+parts[i].temp-(275.13f+32.0f), 0, 255);
cg = restrict_flt(64.0f+parts[i].ctype, 0, 255);
cb = restrict_flt(64.0f+parts[i].tmp, 0, 255);
-
+
vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(cr, cg, cb);
if (cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
{
@@ -2711,7 +2711,7 @@ void draw_parts(pixel *vid)
blendpixel(vid, nx-1, ny, cr, cg, cb, (gradv*2)>255?255:(gradv*2) );
blendpixel(vid, nx, ny+1, cr, cg, cb, (gradv*2)>255?255:(gradv*2) );
blendpixel(vid, nx, ny-1, cr, cg, cb, (gradv*2)>255?255:(gradv*2) );
- if(gradv>255) gradv=255;
+ if (gradv>255) gradv=255;
blendpixel(vid, nx+1, ny-1, cr, cg, cb, gradv);
blendpixel(vid, nx-1, ny-1, cr, cg, cb, gradv);
blendpixel(vid, nx+1, ny+1, cr, cg, cb, gradv);
@@ -3039,7 +3039,7 @@ void draw_wavelengths(pixel *vid, int x, int y, int h, int wl)
int i,cr,cg,cb,j;
int tmp;
fillrect(vid,x-1,y-1,30+1,h+1,64,64,64,255); // coords -1 size +1 to work around bug in fillrect - TODO: fix fillrect
- for (i=0;i<30;i++)
+ for (i=0; i<30; i++)
{
if ((wl>>i)&1)
{
@@ -3059,7 +3059,7 @@ void draw_wavelengths(pixel *vid, int x, int y, int h, int wl)
cr *= tmp;
cg *= tmp;
cb *= tmp;
- for (j=0;j<h;j++) blendpixel(vid,x+29-i,y+j,cr>255?255:cr,cg>255?255:cg,cb>255?255:cb,255);
+ for (j=0; j<h; j++) blendpixel(vid,x+29-i,y+j,cr>255?255:cr,cg>255?255:cg,cb>255?255:cb,255);
}
}
}
@@ -3090,14 +3090,14 @@ void render_signs(pixel *vid_buf)
drawtext(vid_buf, x+3, y+3, buff, 255, 255, 255, 255);
}
- if(sregexp(signs[i].text, "^{c:[0-9]*|.*}$")==0)
+ if (sregexp(signs[i].text, "^{c:[0-9]*|.*}$")==0)
{
int sldr, startm;
memset(buff, 0, sizeof(buff));
- for(sldr=3; signs[i].text[sldr-1] != '|'; sldr++)
+ for (sldr=3; signs[i].text[sldr-1] != '|'; sldr++)
startm = sldr + 1;
sldr = startm;
- while(signs[i].text[sldr] != '}')
+ while (signs[i].text[sldr] != '}')
{
buff[sldr - startm] = signs[i].text[sldr];
sldr++;
@@ -3106,7 +3106,7 @@ void render_signs(pixel *vid_buf)
}
//Usual text
- if(strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$"))
+ if (strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}") && sregexp(signs[i].text, "^{c:[0-9]*|.*}$"))
drawtext(vid_buf, x+3, y+3, signs[i].text, 255, 255, 255, 255);
x = signs[i].x;
diff --git a/src/http.c b/src/http.c
index a881c73..e35e1c0 100644
--- a/src/http.c
+++ b/src/http.c
@@ -709,7 +709,7 @@ void http_auth_headers(void *ctx, char *user, char *pass, char *session_id)
http_async_add_header(ctx, "X-Auth-Hash", tmp);
free(tmp);
}
- if(session_id)
+ if (session_id)
{
http_async_add_header(ctx, "X-Auth-User-Id", user);
http_async_add_header(ctx, "X-Auth-Session-Key", session_id);
@@ -1031,7 +1031,7 @@ retry:
http_async_add_header(ctx, "X-Auth-Hash", tmp);
free(tmp);
}
- if(session_id)
+ if (session_id)
{
http_async_add_header(ctx, "X-Auth-User-Id", user);
http_async_add_header(ctx, "X-Auth-Session-Key", session_id);
diff --git a/src/interface.c b/src/interface.c
index 98db488..e28cc33 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -89,16 +89,16 @@ void get_sign_pos(int i, int *x0, int *y0, int *w, int *h)
if (strcmp(signs[i].text, "{t}")==0)
*w = textwidth("Temp: 0000.00");
- if(sregexp(signs[i].text, "^{c:[0-9]*|.*}$")==0)
+ if (sregexp(signs[i].text, "^{c:[0-9]*|.*}$")==0)
{
int sldr, startm;
char buff[256];
memset(buff, 0, sizeof(buff));
- for(sldr=3; signs[i].text[sldr-1] != '|'; sldr++)
+ for (sldr=3; signs[i].text[sldr-1] != '|'; sldr++)
startm = sldr + 1;
sldr = startm;
- while(signs[i].text[sldr] != '}')
+ while (signs[i].text[sldr] != '}')
{
buff[sldr - startm] = signs[i].text[sldr];
sldr++;
@@ -462,7 +462,7 @@ void ui_checkbox_draw(pixel *vid_buf, ui_checkbox *ed)
void ui_checkbox_process(int mx, int my, int mb, int mbq, ui_checkbox *ed)
{
int w = 12;
-
+
if (mb && !mbq)
{
if (mx>=ed->x && mx<=ed->x+w && my>=ed->y && my<=ed->y+w)
@@ -486,8 +486,8 @@ void ui_checkbox_process(int mx, int my, int mb, int mbq, ui_checkbox *ed)
void ui_copytext_draw(pixel *vid_buf, ui_copytext *ed)
{
int g = 180, i = 0;
- if(!ed->state){
- if(ed->hover){
+ if (!ed->state) {
+ if (ed->hover) {
i = 0;
} else {
i = 100;
@@ -499,7 +499,7 @@ void ui_copytext_draw(pixel *vid_buf, ui_copytext *ed)
drawtext(vid_buf, (ed->x+(ed->width/2))-(textwidth("Copied!")/2), ed->y-12, "Copied!", 255, 255, 255, 255-i);
g = 190;
}
-
+
drawrect(vid_buf, ed->x, ed->y, ed->width, ed->height, g, 255, g, 255-i);
drawrect(vid_buf, ed->x+1, ed->y+1, ed->width-2, ed->height-2, g, 255, g, 100-i);
drawtext(vid_buf, ed->x+6, ed->y+5, ed->text, g, 255, g, 230-i);
@@ -507,8 +507,8 @@ void ui_copytext_draw(pixel *vid_buf, ui_copytext *ed)
void ui_copytext_process(int mx, int my, int mb, int mbq, ui_copytext *ed)
{
- if(my>=ed->y && my<=ed->y+ed->height && mx>=ed->x && mx<=ed->x+ed->width && !ed->state){
- if(mb && !mbq){
+ if (my>=ed->y && my<=ed->y+ed->height && mx>=ed->x && mx<=ed->x+ed->width && !ed->state) {
+ if (mb && !mbq) {
clipboard_push_text(ed->text);
ed->state = 1;
}
@@ -521,14 +521,14 @@ void ui_copytext_process(int mx, int my, int mb, int mbq, ui_copytext *ed)
void draw_svf_ui(pixel *vid_buf)// all the buttons at the bottom
{
int c;
-
+
//the open browser button
- drawtext(vid_buf, 4, YRES+(MENUSIZE-14), "\x81", 255, 255, 255, 255);
+ drawtext(vid_buf, 4, YRES+(MENUSIZE-14), "\x81", 255, 255, 255, 255);
drawrect(vid_buf, 1, YRES+(MENUSIZE-16), 16, 14, 255, 255, 255, 255);
// the reload button
c = svf_open ? 255 : 128;
- drawtext(vid_buf, 23, YRES+(MENUSIZE-14), "\x91", c, c, c, 255);
+ drawtext(vid_buf, 23, YRES+(MENUSIZE-14), "\x91", c, c, c, 255);
drawrect(vid_buf, 19, YRES+(MENUSIZE-16), 16, 14, c, c, c, 255);
// the save sim button
@@ -790,12 +790,12 @@ void copytext_ui(pixel *vid_buf, char *top, char *txt, char *copytxt)
int buttonwidth = 0;
int buttonheight = 0;
ui_copytext ed;
-
+
buttonwidth = textwidth(copytxt)+12;
buttonheight = 10+8;
buttony = y0+50;
buttonx = x0+(xsize/2)-(buttonwidth/2);
-
+
ed.x = buttonx;
ed.y = buttony;
ed.width = buttonwidth;
@@ -803,43 +803,43 @@ void copytext_ui(pixel *vid_buf, char *top, char *txt, char *copytxt)
ed.hover = 0;
ed.state = 0;
strcpy(ed.text, copytxt);
-
+
while (!sdl_poll())
{
b = SDL_GetMouseState(&mx, &my);
if (!b)
break;
}
-
+
while (!sdl_poll())
{
bq = b;
b = SDL_GetMouseState(&mx, &my);
mx /= sdl_scale;
my /= sdl_scale;
-
+
clearrect(vid_buf, x0-2, y0-2, xsize+4, ysize+4);
drawrect(vid_buf, x0, y0, xsize, ysize, 192, 192, 192, 255);
drawtext(vid_buf, x0+8, y0+8, top, 160, 160, 255, 255);
drawtext(vid_buf, x0+8, y0+26, txt, 255, 255, 255, 255);
-
+
ui_copytext_draw(vid_buf, &ed);
ui_copytext_process(mx, my, b, bq, &ed);
-
+
drawtext(vid_buf, x0+5, y0+ysize-11, "OK", 255, 255, 255, 255);
drawrect(vid_buf, x0, y0+ysize-16, xsize, 16, 192, 192, 192, 255);
-
+
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
-
+
if (b && !bq && mx>=x0 && mx<x0+xsize && my>=y0+ysize-16 && my<=y0+ysize)
break;
-
+
if (sdl_key==SDLK_RETURN)
break;
if (sdl_key==SDLK_ESCAPE)
break;
}
-
+
while (!sdl_poll())
{
b = SDL_GetMouseState(&mx, &my);
@@ -1382,7 +1382,7 @@ int save_name_ui(pixel *vid_buf)
ed2.cursor = strlen(svf_description);
ed2.multiline = 1;
strcpy(ed2.str, svf_description);
-
+
ctb.x = 0;
ctb.y = YRES+MENUSIZE-20;
ctb.width = textwidth(svf_id)+12;
@@ -1390,7 +1390,7 @@ int save_name_ui(pixel *vid_buf)
ctb.hover = 0;
ctb.state = 0;
strcpy(ctb.text, svf_id);
-
+
cb.x = x0+10;
cb.y = y0+53+YRES/4;
@@ -1399,7 +1399,7 @@ int save_name_ui(pixel *vid_buf)
fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192);
memcpy(old_vid, vid_buf, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE);
-
+
while (!sdl_poll())
{
bq = b;
@@ -1428,7 +1428,7 @@ int save_name_ui(pixel *vid_buf)
drawrect(vid_buf, x0, y0+74+YRES/4, 192, 16, 192, 192, 192, 255);
draw_line(vid_buf, x0+192, y0, x0+192, y0+90+YRES/4, 150, 150, 150, XRES+BARSIZE);
-
+
if (svf_id[0])
{
//Save ID text and copybox
@@ -1436,13 +1436,13 @@ int save_name_ui(pixel *vid_buf)
idtxtwidth += ctb.width;
ctb.x = textwidth("Current save ID: ")+(XRES+BARSIZE-idtxtwidth)/2;
drawtext(vid_buf, (XRES+BARSIZE-idtxtwidth)/2, YRES+MENUSIZE-15, "Current save ID: ", 255, 255, 255, 255);
-
+
ui_copytext_draw(vid_buf, &ctb);
ui_copytext_process(mx, my, b, bq, &ctb);
}
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
-
+
memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE);
ui_edit_process(mx, my, b, &ed);
@@ -1823,7 +1823,7 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx,
}
else //all other menus
{
- if (fwidth > XRES-BARSIZE){ //fancy scrolling
+ if (fwidth > XRES-BARSIZE) { //fancy scrolling
float overflow = fwidth-(XRES-BARSIZE), location = ((float)XRES-BARSIZE)/((float)(mx-(XRES-BARSIZE)));
xoff = (int)(overflow / location);
}
@@ -2930,7 +2930,7 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
ed.multiline = 1;
ed.cursor = 0;
strcpy(ed.str, "");
-
+
ctb.x = 100;
ctb.y = YRES+MENUSIZE-20;
ctb.width = textwidth(save_id)+12;
@@ -3114,12 +3114,12 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
drawrect(vid_buf, XRES+BARSIZE-100, YRES+MENUSIZE-68, 50, 18, 255, 255, 255, 255);
drawtext(vid_buf, XRES+BARSIZE-90, YRES+MENUSIZE-63, "Submit", 255, 255, 255, 255);
}
-
+
//Save ID text and copybox
cix = textwidth("Save ID: ");
cix += ctb.width;
ctb.x = textwidth("Save ID: ")+(XRES+BARSIZE-cix)/2;
- //ctb.x =
+ //ctb.x =
drawtext(vid_buf, (XRES+BARSIZE-cix)/2, YRES+MENUSIZE-15, "Save ID: ", 255, 255, 255, 255);
ui_copytext_draw(vid_buf, &ctb);
ui_copytext_process(mx, my, b, bq, &ctb);
@@ -4054,16 +4054,16 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) {
memcpy(old_buf,vid_buf,(XRES+BARSIZE)*YRES*PIXELSIZE);
fillrect(old_buf, -1, -1, XRES, 220, 0, 0, 0, 190);
-
+
currentcommand2 = malloc(sizeof(command_history));
memset(currentcommand2, 0, sizeof(command_history));
currentcommand2->prev_command = last_command2;
currentcommand2->command = mystrdup(error);
last_command2 = currentcommand2;
-
+
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);//enable keyrepeat for console (is disabled on console close later)
cc = 0;
- while(cc < 80){
+ while (cc < 80) {
fillrect(old_buf, -1, -1+cc, XRES+BARSIZE, 2, 0, 0, 0, 160-(cc*2));
cc++;
}
@@ -4077,30 +4077,30 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) {
memcpy(vid_buf,old_buf,(XRES+BARSIZE)*YRES*PIXELSIZE);
draw_line(vid_buf, 0, 219, XRES+BARSIZE-1, 219, 228, 228, 228, XRES+BARSIZE);
#ifdef PYCONSOLE
- if(pygood)
- i=255;
- else
- i=0;
- if(pyready)
- drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64, python by Doxin)", 255, i, i, 255);
- else
- drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64, python disabled)", 255, i, i, 255);
+ if (pygood)
+ i=255;
+ else
+ i=0;
+ if (pyready)
+ drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64, python by Doxin)", 255, i, i, 255);
+ else
+ drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64, python disabled)", 255, i, i, 255);
#else
drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64, python disabled)", 255, 255, 255, 255);
#endif
-
+
cc = 0;
currentcommand = last_command;
- while(cc < 10)
+ while (cc < 10)
{
- if(currentcommand==NULL)
+ if (currentcommand==NULL)
break;
drawtext(vid_buf, 15, 175-(cc*12), currentcommand->command, 255, 255, 255, 255);
- if(currentcommand->prev_command!=NULL)
+ if (currentcommand->prev_command!=NULL)
{
- if(cc<9) {
+ 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;
}
@@ -4113,16 +4113,16 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) {
}
cc = 0;
currentcommand2 = last_command2;
- while(cc < 10)
+ while (cc < 10)
{
- if(currentcommand2==NULL)
+ if (currentcommand2==NULL)
break;
drawtext(vid_buf, 215, 175-(cc*12), currentcommand2->command, 255, 225, 225, 255);
- if(currentcommand2->prev_command!=NULL)
+ if (currentcommand2->prev_command!=NULL)
{
- if(cc<9) {
+ if (cc<9) {
currentcommand2 = currentcommand2->prev_command;
- } else if(currentcommand2->prev_command!=NULL) {
+ } else if (currentcommand2->prev_command!=NULL) {
free(currentcommand2->prev_command);
currentcommand2->prev_command = NULL;
}
@@ -4135,12 +4135,12 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) {
}
//if(error && ed.str[0]=='\0')
- //drawtext(vid_buf, 20, 207, error, 255, 127, 127, 200);
- if(console_more==0)
- drawtext(vid_buf, 5, 207, ">", 255, 255, 255, 240);
- else
- drawtext(vid_buf, 5, 207, "...", 255, 255, 255, 240);
-
+ //drawtext(vid_buf, 20, 207, error, 255, 127, 127, 200);
+ if (console_more==0)
+ drawtext(vid_buf, 5, 207, ">", 255, 255, 255, 240);
+ else
+ drawtext(vid_buf, 5, 207, "...", 255, 255, 255, 240);
+
ui_edit_draw(vid_buf, &ed);
ui_edit_process(mx, my, b, &ed);
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
@@ -4162,22 +4162,22 @@ char *console_ui(pixel *vid_buf,char error[255],char console_more) {
SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
return NULL;
}
- if(sdl_key==SDLK_UP || sdl_key==SDLK_DOWN)
+ if (sdl_key==SDLK_UP || sdl_key==SDLK_DOWN)
{
ci += sdl_key==SDLK_UP?1:-1;
- if(ci<-1)
+ if (ci<-1)
ci = -1;
- if(ci==-1)
+ if (ci==-1)
{
strcpy(ed.str, "");
ed.cursor = strlen(ed.str);
}
else
{
- if(last_command!=NULL) {
+ if (last_command!=NULL) {
currentcommand = last_command;
for (cc = 0; cc<ci; cc++) {
- if(currentcommand->prev_command==NULL)
+ if (currentcommand->prev_command==NULL)
ci = cc;
else
currentcommand = currentcommand->prev_command;
diff --git a/src/main.c b/src/main.c
index c8f653c..c1be09f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -455,7 +455,7 @@ void *build_save(int *size, int x0, int y0, int w, int h, unsigned char bmap[YRE
//New file header uses PSv, replacing fuC. This is to detect if the client uses a new save format for temperatures
//This creates a problem for old clients, that display and "corrupt" error instead of a "newer version" error
-
+
c[0] = 0x50; //0x66;
c[1] = 0x53; //0x75;
c[2] = 0x76; //0x43;
@@ -516,7 +516,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char
if (!sys_pause) {
sys_pause = (c[3]>>1)&0x01;
}
- if(ver>=46 && replace) {
+ if (ver>=46 && replace) {
gravityMode = ((c[3]>>2)&0x03);// | ((c[3]>>2)&0x01);
airMode = ((c[3]>>4)&0x07);// | ((c[3]>>4)&0x02) | ((c[3]>>4)&0x01);
}
@@ -565,7 +565,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char
if (replace)
{
- if(ver<46){
+ if (ver<46) {
gravityMode = 0;
airMode = 0;
}
@@ -792,9 +792,9 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char
ttv = (d[p++])<<8;
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++) {
- if(parts[i-1].type==goltype[q-1] && grule[q][9]==2)
+ if (ptypes[parts[i-1].type].properties&PROP_LIFE && !parts[i-1].tmp)
+ 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;
}
} else {
@@ -1202,12 +1202,12 @@ char my_uri[] = "http://" SERVER "/Update.api?Action=Download&Architecture="
#endif
;
-
+
char console_error[255] = "";
char console_more=0;
#ifdef PYCONSOLE
-/*
+/*
* PYTHON FUNCTIONS
* instructions on making a function callable from python:
* first you make a function that accepts (PyObject *self, PyObject *args) as arguments
@@ -1223,111 +1223,111 @@ char console_more=0;
static PyObject* emb_create(PyObject *self, PyObject *args, PyObject *keywds)
{
- int x,y,t;
- char *name = "";
- char *kwlist[] = {"x","y","t","name", NULL};
- if(!PyArg_ParseTupleAndKeywords(args, keywds, "II|Is:create",kwlist, &x,&y,&t,&name))
- return NULL;
- //
- if(strcmp(name,"")!=0)
- console_parse_type(name, &t, console_error);
- return Py_BuildValue("i",create_part(-1,x,y,t));
+ int x,y,t;
+ char *name = "";
+ char *kwlist[] = {"x","y","t","name", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "II|Is:create",kwlist, &x,&y,&t,&name))
+ return NULL;
+ //
+ if (strcmp(name,"")!=0)
+ console_parse_type(name, &t, console_error);
+ return Py_BuildValue("i",create_part(-1,x,y,t));
}
static PyObject* emb_pause(PyObject *self, PyObject *args)
{
- int x,y,t;
- if(!PyArg_ParseTuple(args, ":unpause"))
- return NULL;
- //
- sys_pause=1;
- return Py_BuildValue("i",1);
+ int x,y,t;
+ if (!PyArg_ParseTuple(args, ":unpause"))
+ return NULL;
+ //
+ sys_pause=1;
+ return Py_BuildValue("i",1);
}
static PyObject* emb_unpause(PyObject *self, PyObject *args)
{
- int x,y,t;
- if(!PyArg_ParseTuple(args, ":pause"))
- return NULL;
- //
- sys_pause=0;
- return Py_BuildValue("i",1);
+ int x,y,t;
+ if (!PyArg_ParseTuple(args, ":pause"))
+ return NULL;
+ //
+ sys_pause=0;
+ return Py_BuildValue("i",1);
}
static PyObject* emb_toggle_pause(PyObject *self, PyObject *args)
{
- int x,y,t;
- if(!PyArg_ParseTuple(args, ":toggle_pause"))
- return NULL;
- //
- sys_pause=!sys_pause;
- return Py_BuildValue("i",1);
+ int x,y,t;
+ if (!PyArg_ParseTuple(args, ":toggle_pause"))
+ return NULL;
+ //
+ sys_pause=!sys_pause;
+ return Py_BuildValue("i",1);
}
//console_mode
static PyObject* emb_toggle_console(PyObject *self, PyObject *args)
{
- int x,y,t;
- if(!PyArg_ParseTuple(args, ":toggle_console"))
- return NULL;
- //
- console_mode=!console_mode;
- return Py_BuildValue("i",1);
+ int x,y,t;
+ if (!PyArg_ParseTuple(args, ":toggle_console"))
+ return NULL;
+ //
+ console_mode=!console_mode;
+ return Py_BuildValue("i",1);
}
static PyObject* emb_open_console(PyObject *self, PyObject *args)
{
- int x,y,t;
- if(!PyArg_ParseTuple(args, ":toggle_console"))
- return NULL;
- //
- console_mode=1;
- return Py_BuildValue("i",1);
+ int x,y,t;
+ if (!PyArg_ParseTuple(args, ":toggle_console"))
+ return NULL;
+ //
+ console_mode=1;
+ return Py_BuildValue("i",1);
}
static PyObject* emb_close_console(PyObject *self, PyObject *args)
{
- int x,y,t;
- if(!PyArg_ParseTuple(args, ":toggle_console"))
- return NULL;
- //
- console_mode=0;
- return Py_BuildValue("i",1);
+ int x,y,t;
+ if (!PyArg_ParseTuple(args, ":toggle_console"))
+ return NULL;
+ //
+ console_mode=0;
+ return Py_BuildValue("i",1);
}
static PyObject* emb_log(PyObject *self, PyObject *args)
{
- char *buffer;
- if(!PyArg_ParseTuple(args, "s:log",&buffer))
- return NULL;
- //
- strcpy(console_error,buffer);
- puts(buffer);
- return Py_BuildValue("i",1);
+ char *buffer;
+ if (!PyArg_ParseTuple(args, "s:log",&buffer))
+ return NULL;
+ //
+ strcpy(console_error,buffer);
+ puts(buffer);
+ return Py_BuildValue("i",1);
}
static PyObject* emb_console_more(PyObject *self, PyObject *args)
{
- if(!PyArg_ParseTuple(args, ":log"))
- return NULL;
- //
- console_more=1;
- return Py_BuildValue("i",1);
+ if (!PyArg_ParseTuple(args, ":log"))
+ return NULL;
+ //
+ console_more=1;
+ return Py_BuildValue("i",1);
}
static PyObject* emb_console_less(PyObject *self, PyObject *args)
{
- if(!PyArg_ParseTuple(args, ":log"))
- return NULL;
- //
- console_more=0;
- return Py_BuildValue("i",1);
+ if (!PyArg_ParseTuple(args, ":log"))
+ return NULL;
+ //
+ console_more=0;
+ return Py_BuildValue("i",1);
}
static PyObject* emb_reset_pressure(PyObject *self, PyObject *args)
{
int nx, ny;
- if(!PyArg_ParseTuple(args, ":reset_pressure"))
+ if (!PyArg_ParseTuple(args, ":reset_pressure"))
return NULL;
//
for (nx = 0; nx<XRES/CELL; nx++)
@@ -1341,7 +1341,7 @@ static PyObject* emb_reset_pressure(PyObject *self, PyObject *args)
static PyObject* emb_reset_velocity(PyObject *self, PyObject *args)
{
int nx, ny;
- if(!PyArg_ParseTuple(args, ":reset_velocity"))
+ if (!PyArg_ParseTuple(args, ":reset_velocity"))
return NULL;
//
for (nx = 0; nx<XRES/CELL; nx++)
@@ -1356,12 +1356,12 @@ static PyObject* emb_reset_velocity(PyObject *self, PyObject *args)
static PyObject* emb_reset_sparks(PyObject *self, PyObject *args)
{
int i;
- if(!PyArg_ParseTuple(args, ":reset_sparks"))
+ if (!PyArg_ParseTuple(args, ":reset_sparks"))
return NULL;
//
- for(i=0; i<NPART; i++)
+ for (i=0; i<NPART; i++)
{
- if(parts[i].type==PT_SPRK)
+ if (parts[i].type==PT_SPRK)
{
parts[i].type = parts[i].ctype;
parts[i].life = 4;
@@ -1372,595 +1372,595 @@ static PyObject* emb_reset_sparks(PyObject *self, PyObject *args)
static PyObject* emb_set_life(PyObject *self, PyObject *args, PyObject *keywds)
{
- int i = -1,life,j,x=-1,y=-1;
- char *name = "";
- char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
- if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
- return NULL;
- //
- if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
- return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
- if(strcmp(name,"all")==0)
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type)
- parts[i].life = life;
- }
- }
- else if(console_parse_type(name, &j, console_error))
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].life = life;
- }
- }
- else if(i!=-1)
+ int i = -1,life,j,x=-1,y=-1;
+ char *name = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if (strcmp(name,"all")==0)
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].life = life;
+ }
+ }
+ else if (console_parse_type(name, &j, console_error))
{
- if(parts[i].type != PT_NONE)
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].life = life;
+ }
+ }
+ else if (i!=-1)
+ {
+ if (parts[i].type != PT_NONE)
parts[i].life = life;
}
- else if(x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
{
- if(parts[pmap[y][x]>>8].type != PT_NONE)
+ if (parts[pmap[y][x]>>8].type != PT_NONE)
parts[pmap[y][x]>>8].life = life;
}
- return Py_BuildValue("i",1);
+ return Py_BuildValue("i",1);
}
static PyObject* emb_set_type(PyObject *self, PyObject *args, PyObject *keywds)
{
- int i = -1,life,j=-1,x=-1,y=-1;
- char *name = "";
- char *type = "";
- char *kwlist[] = {"setto", "settoint", "setfrom", "i", "x", "y", NULL};
- if(!PyArg_ParseTupleAndKeywords(args, keywds, "|sIsIII:set_type",kwlist ,&type,&life,&name,&i,&x,&y))
- return NULL;
- //
- if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1 && j==-1)
- return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ int i = -1,life,j=-1,x=-1,y=-1;
+ char *name = "";
+ char *type = "";
+ char *kwlist[] = {"setto", "settoint", "setfrom", "i", "x", "y", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "|sIsIII:set_type",kwlist ,&type,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1 && j==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
console_parse_type(type, &life, console_error);
- if(strcmp(name,"all")==0)
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type)
- parts[i].type = life;
- }
- }
- else if(console_parse_type(name, &j, console_error))
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].type = life;
- }
- }
- else if(i!=-1)
+ if (strcmp(name,"all")==0)
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].type = life;
+ }
+ }
+ else if (console_parse_type(name, &j, console_error))
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].type = life;
+ }
+ }
+ else if (i!=-1)
{
- if(parts[i].type != PT_NONE)
+ if (parts[i].type != PT_NONE)
parts[i].type = life;
}
- else if(x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
{
- if(parts[pmap[y][x]>>8].type != PT_NONE)
+ if (parts[pmap[y][x]>>8].type != PT_NONE)
parts[pmap[y][x]>>8].type = life;
}
- return Py_BuildValue("i",1);
+ return Py_BuildValue("i",1);
}
static PyObject* emb_set_temp(PyObject *self, PyObject *args, PyObject *keywds)
{
- int i = -1,j,x=-1,y=-1;
- float newval;
- char *name = "";
- char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
- if(!PyArg_ParseTupleAndKeywords(args, keywds, "f|sIII:set_type", kwlist, &newval, &name, &i, &x, &y))
- return NULL;
- //
- if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
- return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
- if(strcmp(name,"all")==0)
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type)
- parts[i].temp = newval;
- }
- }
- else if(console_parse_type(name, &j, console_error))
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].temp = newval;
- }
- }
- else if(i!=-1)
+ int i = -1,j,x=-1,y=-1;
+ float newval;
+ char *name = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "f|sIII:set_type", kwlist, &newval, &name, &i, &x, &y))
+ return NULL;
+ //
+ if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if (strcmp(name,"all")==0)
{
- if(parts[i].type != PT_NONE)
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].temp = newval;
+ }
+ }
+ else if (console_parse_type(name, &j, console_error))
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].temp = newval;
+ }
+ }
+ else if (i!=-1)
+ {
+ if (parts[i].type != PT_NONE)
parts[i].temp = newval;
}
- else if(x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
{
- if(parts[pmap[y][x]>>8].type != PT_NONE)
+ if (parts[pmap[y][x]>>8].type != PT_NONE)
parts[pmap[y][x]>>8].temp = newval;
}
- return Py_BuildValue("i",1);
+ return Py_BuildValue("i",1);
}
static PyObject* emb_set_tmp(PyObject *self, PyObject *args, PyObject *keywds)
{
- int i = -1,life,j,x=-1,y=-1;
- char *name = "";
- char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
- if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
- return NULL;
- //
- if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
- return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
- if(strcmp(name,"all")==0)
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type)
- parts[i].tmp = life;
- }
- }
- else if(console_parse_type(name, &j, console_error))
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].tmp = life;
- }
- }
- else if(i!=-1)
+ int i = -1,life,j,x=-1,y=-1;
+ char *name = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if (strcmp(name,"all")==0)
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].tmp = life;
+ }
+ }
+ else if (console_parse_type(name, &j, console_error))
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].tmp = life;
+ }
+ }
+ else if (i!=-1)
{
- if(parts[i].type != PT_NONE)
+ if (parts[i].type != PT_NONE)
parts[i].tmp = life;
}
- else if(x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
{
- if(parts[pmap[y][x]>>8].type != PT_NONE)
+ if (parts[pmap[y][x]>>8].type != PT_NONE)
parts[pmap[y][x]>>8].tmp = life;
}
- return Py_BuildValue("i",1);
+ return Py_BuildValue("i",1);
}
static PyObject* emb_set_x(PyObject *self, PyObject *args, PyObject *keywds)
{
- int i = -1,life,j,x=-1,y=-1;
- char *name = "";
- char *type = "";
- char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
- if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
- return NULL;
- //
- if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
- return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
- if(strcmp(name,"all")==0)
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type)
- parts[i].x = life;
- }
- }
- else if(console_parse_type(name, &j, console_error))
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].x = life;
- }
- }
- else if(i!=-1)
+ int i = -1,life,j,x=-1,y=-1;
+ char *name = "";
+ char *type = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if (strcmp(name,"all")==0)
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].x = life;
+ }
+ }
+ else if (console_parse_type(name, &j, console_error))
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].x = life;
+ }
+ }
+ else if (i!=-1)
{
- if(parts[i].type != PT_NONE)
+ if (parts[i].type != PT_NONE)
parts[i].x = life;
}
- else if(x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
{
- if(parts[pmap[y][x]>>8].type != PT_NONE)
+ if (parts[pmap[y][x]>>8].type != PT_NONE)
parts[pmap[y][x]>>8].x = life;
}
- return Py_BuildValue("i",1);
+ return Py_BuildValue("i",1);
}
static PyObject* emb_set_y(PyObject *self, PyObject *args, PyObject *keywds)
{
- int i = -1,life,j,x=-1,y=-1;
- char *name = "";
- char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
- if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
- return NULL;
- //
- if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
- return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
- if(strcmp(name,"all")==0)
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type)
- parts[i].y = life;
- }
- }
- else if(console_parse_type(name, &j, console_error))
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].y = life;
- }
- }
- else if(i!=-1)
+ int i = -1,life,j,x=-1,y=-1;
+ char *name = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if (strcmp(name,"all")==0)
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].y = life;
+ }
+ }
+ else if (console_parse_type(name, &j, console_error))
{
- if(parts[i].type != PT_NONE)
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].y = life;
+ }
+ }
+ else if (i!=-1)
+ {
+ if (parts[i].type != PT_NONE)
parts[i].y = life;
}
- else if(x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
{
- if(parts[pmap[y][x]>>8].type != PT_NONE)
+ if (parts[pmap[y][x]>>8].type != PT_NONE)
parts[pmap[y][x]>>8].y = life;
}
- return Py_BuildValue("i",1);
+ return Py_BuildValue("i",1);
}
static PyObject* emb_set_ctype(PyObject *self, PyObject *args, PyObject *keywds)
{
- int i = -1,life,j,x=-1,y=-1;
- char *name = "";
- char *type = "";
- char *kwlist[] = {"setto", "settoint", "setfrom", "i", "x", "y", NULL};
- if(!PyArg_ParseTupleAndKeywords(args, keywds, "|sIsIII:set_type",kwlist ,&type, &life, &name,&i,&x,&y))
- return NULL;
- //
- if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
- return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
- if(!life)
+ int i = -1,life,j,x=-1,y=-1;
+ char *name = "";
+ char *type = "";
+ char *kwlist[] = {"setto", "settoint", "setfrom", "i", "x", "y", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "|sIsIII:set_type",kwlist ,&type, &life, &name,&i,&x,&y))
+ return NULL;
+ //
+ if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if (!life)
console_parse_type(type, &life, console_error);
- if(strcmp(name,"all")==0)
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type)
- parts[i].ctype = life;
- }
- }
- else if(console_parse_type(name, &j, console_error))
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].ctype = life;
- }
- }
- else if(i!=-1)
+ if (strcmp(name,"all")==0)
{
- if(parts[i].type != PT_NONE)
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].ctype = life;
+ }
+ }
+ else if (console_parse_type(name, &j, console_error))
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].ctype = life;
+ }
+ }
+ else if (i!=-1)
+ {
+ if (parts[i].type != PT_NONE)
parts[i].ctype = life;
}
- else if(x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
{
- if(parts[pmap[y][x]>>8].type != PT_NONE)
+ if (parts[pmap[y][x]>>8].type != PT_NONE)
parts[pmap[y][x]>>8].ctype = life;
}
- return Py_BuildValue("i",1);
+ return Py_BuildValue("i",1);
}
static PyObject* emb_set_vx(PyObject *self, PyObject *args, PyObject *keywds)
{
- int i = -1,j,x=-1,y=-1;
- float life;
- char *name = "";
- char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
- if(!PyArg_ParseTupleAndKeywords(args, keywds, "f|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
- return NULL;
- //
- if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
- return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
- if(strcmp(name,"all")==0)
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type)
- parts[i].vx = life;
- }
- }
- else if(console_parse_type(name, &j, console_error))
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].vx = life;
- }
- }
- else if(i!=-1)
+ int i = -1,j,x=-1,y=-1;
+ float life;
+ char *name = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "f|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if (strcmp(name,"all")==0)
{
- if(parts[i].type != PT_NONE)
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].vx = life;
+ }
+ }
+ else if (console_parse_type(name, &j, console_error))
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].vx = life;
+ }
+ }
+ else if (i!=-1)
+ {
+ if (parts[i].type != PT_NONE)
parts[i].vx = life;
}
- else if(x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
{
- if(parts[pmap[y][x]>>8].type != PT_NONE)
+ if (parts[pmap[y][x]>>8].type != PT_NONE)
parts[pmap[y][x]>>8].vx = life;
}
- return Py_BuildValue("i",1);
+ return Py_BuildValue("i",1);
}
static PyObject* emb_set_vy(PyObject *self, PyObject *args, PyObject *keywds)
{
- int i = -1,j,x=-1,y=-1;
- float life;
- char *name = "";
- char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
- if(!PyArg_ParseTupleAndKeywords(args, keywds, "f|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
- return NULL;
- //
- if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
- return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
- if(strcmp(name,"all")==0)
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type)
- parts[i].vy = life;
- }
- }
- else if(console_parse_type(name, &j, console_error))
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].vy = life;
- }
- }
- else if(i!=-1)
+ int i = -1,j,x=-1,y=-1;
+ float life;
+ char *name = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "f|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if (strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if (strcmp(name,"all")==0)
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].vy = life;
+ }
+ }
+ else if (console_parse_type(name, &j, console_error))
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].vy = life;
+ }
+ }
+ else if (i!=-1)
{
- if(parts[i].type != PT_NONE)
+ if (parts[i].type != PT_NONE)
parts[i].vy = life;
}
- else if(x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ else if (x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
{
- if(parts[pmap[y][x]>>8].type != PT_NONE)
+ if (parts[pmap[y][x]>>8].type != PT_NONE)
parts[pmap[y][x]>>8].vy = life;
}
- return Py_BuildValue("i",1);
+ return Py_BuildValue("i",1);
}
static PyObject* emb_get_pmap(PyObject *self, PyObject *args)
{
- int x,y;
- if(!PyArg_ParseTuple(args, "II:get_pmap",&x,&y))
- return NULL;
- //
- if(x<0 || y<0 || x>=XRES || y>=YRES)
- return Py_BuildValue("i",-1);
+ int x,y;
+ if (!PyArg_ParseTuple(args, "II:get_pmap",&x,&y))
+ return NULL;
+ //
+ if (x<0 || y<0 || x>=XRES || y>=YRES)
+ return Py_BuildValue("i",-1);
- return Py_BuildValue("I",pmap[y][x]);
+ return Py_BuildValue("I",pmap[y][x]);
}
static PyObject* emb_get_prop(PyObject *self, PyObject *args)
{
- int i;
- char *prop = "";
- if(!PyArg_ParseTuple(args, "Is:get_pmap",&i,&prop))
- return NULL;
- //
- if(parts[i].type)
- {
- if(strcmp(prop,"type")==0)
- return Py_BuildValue("i",parts[i].type);
- if(strcmp(prop,"life")==0)
- return Py_BuildValue("i",parts[i].life);
- if(strcmp(prop,"ctype")==0)
- return Py_BuildValue("i",parts[i].ctype);
- if(strcmp(prop,"temp")==0)
- return Py_BuildValue("i",parts[i].temp);
- if(strcmp(prop,"tmp")==0)
- return Py_BuildValue("i",parts[i].tmp);
- if(strcmp(prop,"vy")==0)
- return Py_BuildValue("f",parts[i].vy);
- if(strcmp(prop,"vx")==0)
- return Py_BuildValue("f",parts[i].vx);
- if(strcmp(prop,"x")==0)
- return Py_BuildValue("i",parts[i].x);
- if(strcmp(prop,"y")==0)
- return Py_BuildValue("i",parts[i].y);
- }
-
- return Py_BuildValue("i",-1);
+ int i;
+ char *prop = "";
+ if (!PyArg_ParseTuple(args, "Is:get_pmap",&i,&prop))
+ return NULL;
+ //
+ if (parts[i].type)
+ {
+ if (strcmp(prop,"type")==0)
+ return Py_BuildValue("i",parts[i].type);
+ if (strcmp(prop,"life")==0)
+ return Py_BuildValue("i",parts[i].life);
+ if (strcmp(prop,"ctype")==0)
+ return Py_BuildValue("i",parts[i].ctype);
+ if (strcmp(prop,"temp")==0)
+ return Py_BuildValue("i",parts[i].temp);
+ if (strcmp(prop,"tmp")==0)
+ return Py_BuildValue("i",parts[i].tmp);
+ if (strcmp(prop,"vy")==0)
+ return Py_BuildValue("f",parts[i].vy);
+ if (strcmp(prop,"vx")==0)
+ return Py_BuildValue("f",parts[i].vx);
+ if (strcmp(prop,"x")==0)
+ return Py_BuildValue("i",parts[i].x);
+ if (strcmp(prop,"y")==0)
+ return Py_BuildValue("i",parts[i].y);
+ }
+
+ return Py_BuildValue("i",-1);
}
static PyObject* emb_draw_pixel(PyObject *self, PyObject *args)
{
- int x,y,r,g,b,a;
- a=255;
- if(!PyArg_ParseTuple(args, "IIIII|I:draw_pixel",&x,&y,&r,&g,&b,&a))
- return NULL;
-
- if(vid_buf!=NULL)
- {
- drawpixel(vid_buf,x,y,r,g,b,a);
- return Py_BuildValue("i",1);
- }
- return Py_BuildValue("i",-1);
-
+ int x,y,r,g,b,a;
+ a=255;
+ if (!PyArg_ParseTuple(args, "IIIII|I:draw_pixel",&x,&y,&r,&g,&b,&a))
+ return NULL;
+
+ if (vid_buf!=NULL)
+ {
+ drawpixel(vid_buf,x,y,r,g,b,a);
+ return Py_BuildValue("i",1);
+ }
+ return Py_BuildValue("i",-1);
+
}
static PyObject* emb_draw_text(PyObject *self, PyObject *args)
{
- int x,y,r,g,b,a;
- char *txt;
- a=255;
- if(!PyArg_ParseTuple(args, "IIsIII|I:draw_text",&x,&y,&txt,&r,&g,&b,&a))
- return NULL;
- if(vid_buf!=NULL)
- {
- drawtext(vid_buf,x,y,txt,r,g,b,a);
- return Py_BuildValue("i",1);
- }
- return Py_BuildValue("i",-1);
+ int x,y,r,g,b,a;
+ char *txt;
+ a=255;
+ if (!PyArg_ParseTuple(args, "IIsIII|I:draw_text",&x,&y,&txt,&r,&g,&b,&a))
+ return NULL;
+ if (vid_buf!=NULL)
+ {
+ drawtext(vid_buf,x,y,txt,r,g,b,a);
+ return Py_BuildValue("i",1);
+ }
+ return Py_BuildValue("i",-1);
}
static PyObject* emb_draw_rect(PyObject *self, PyObject *args)
{
- int x,y,w,h,r,g,b,a;
- a=255;
- if(!PyArg_ParseTuple(args, "IIIIIII|I:draw_rect",&x,&y,&w,&h,&r,&g,&b,&a))
- return NULL;
- if(vid_buf!=NULL)
- {
- drawrect(vid_buf,x,y,w,h,r,g,b,a);
- //fillrect
- return Py_BuildValue("i",1);
- }
- return Py_BuildValue("i",-1);
+ int x,y,w,h,r,g,b,a;
+ a=255;
+ if (!PyArg_ParseTuple(args, "IIIIIII|I:draw_rect",&x,&y,&w,&h,&r,&g,&b,&a))
+ return NULL;
+ if (vid_buf!=NULL)
+ {
+ drawrect(vid_buf,x,y,w,h,r,g,b,a);
+ //fillrect
+ return Py_BuildValue("i",1);
+ }
+ return Py_BuildValue("i",-1);
}
static PyObject* emb_draw_fillrect(PyObject *self, PyObject *args)
{
- int x,y,w,h,r,g,b,a;
- a=255;
- if(!PyArg_ParseTuple(args, "IIIIIII|I:draw_fillrect",&x,&y,&w,&h,&r,&g,&b,&a))
- return NULL;
- if(vid_buf!=NULL)
- {
- fillrect(vid_buf,x,y,w,h,r,g,b,a);
- //fillrect
- return Py_BuildValue("i",1);
- }
- return Py_BuildValue("i",-1);
+ int x,y,w,h,r,g,b,a;
+ a=255;
+ if (!PyArg_ParseTuple(args, "IIIIIII|I:draw_fillrect",&x,&y,&w,&h,&r,&g,&b,&a))
+ return NULL;
+ if (vid_buf!=NULL)
+ {
+ fillrect(vid_buf,x,y,w,h,r,g,b,a);
+ //fillrect
+ return Py_BuildValue("i",1);
+ }
+ return Py_BuildValue("i",-1);
}
static PyObject* emb_get_width(PyObject *self, PyObject *args)
{
- char *txt;
- if(!PyArg_ParseTuple(args, "s:get_width",&txt))
- return NULL;
- return Py_BuildValue("i",textwidth(txt));
+ char *txt;
+ if (!PyArg_ParseTuple(args, "s:get_width",&txt))
+ return NULL;
+ return Py_BuildValue("i",textwidth(txt));
}
static PyObject* emb_get_mouse(PyObject *self, PyObject *args)
{
- int x,y,mask,b1,b2,b3;
- if(!PyArg_ParseTuple(args, ":get_mouse"))
- return NULL;
- mask=SDL_GetMouseState(&x, &y);
- b1=mask&SDL_BUTTON(1);
- b2=mask&SDL_BUTTON(2);
- b3=mask&SDL_BUTTON(3);
- return Py_BuildValue("(ii(iii))",x,y,b1,b2,b3);
+ int x,y,mask,b1,b2,b3;
+ if (!PyArg_ParseTuple(args, ":get_mouse"))
+ return NULL;
+ mask=SDL_GetMouseState(&x, &y);
+ b1=mask&SDL_BUTTON(1);
+ b2=mask&SDL_BUTTON(2);
+ b3=mask&SDL_BUTTON(3);
+ return Py_BuildValue("(ii(iii))",x,y,b1,b2,b3);
}
static PyObject* emb_get_name(PyObject *self, PyObject *args)
{
- if(!PyArg_ParseTuple(args, ":get_name"))
- return NULL;
- if(svf_login)
- return Py_BuildValue("s",svf_user);
- else
- return Py_BuildValue("s","");
+ if (!PyArg_ParseTuple(args, ":get_name"))
+ return NULL;
+ if (svf_login)
+ return Py_BuildValue("s",svf_user);
+ else
+ return Py_BuildValue("s","");
}
static PyObject* emb_shortcuts_disable(PyObject *self, PyObject *args)
{
- if(!PyArg_ParseTuple(args, ":shortcuts_disable"))
- return NULL;
- //
- sys_shortcuts=0;
- return Py_BuildValue("i",1);
+ if (!PyArg_ParseTuple(args, ":shortcuts_disable"))
+ return NULL;
+ //
+ sys_shortcuts=0;
+ return Py_BuildValue("i",1);
}
static PyObject* emb_shortcuts_enable(PyObject *self, PyObject *args)
{
- if(!PyArg_ParseTuple(args, ":shortcuts_enable"))
- return NULL;
- //
- sys_shortcuts=1;
- return Py_BuildValue("i",1);
+ if (!PyArg_ParseTuple(args, ":shortcuts_enable"))
+ return NULL;
+ //
+ sys_shortcuts=1;
+ return Py_BuildValue("i",1);
}
static PyObject* emb_get_modifier(PyObject *self, PyObject *args)
{
- if(!PyArg_ParseTuple(args, ":get_modifier"))
- return NULL;
- return Py_BuildValue("(iiiiii)",sdl_mod&KMOD_LCTRL,sdl_mod&KMOD_RCTRL,sdl_mod&KMOD_LALT,sdl_mod&KMOD_RALT,sdl_mod&KMOD_LSHIFT,sdl_mod&KMOD_RSHIFT);
+ if (!PyArg_ParseTuple(args, ":get_modifier"))
+ return NULL;
+ return Py_BuildValue("(iiiiii)",sdl_mod&KMOD_LCTRL,sdl_mod&KMOD_RCTRL,sdl_mod&KMOD_LALT,sdl_mod&KMOD_RALT,sdl_mod&KMOD_LSHIFT,sdl_mod&KMOD_RSHIFT);
}
static PyObject* emb_set_keyrepeat(PyObject *self, PyObject *args)
{
- int keydelay,keyinterval;
- keydelay=SDL_DEFAULT_REPEAT_DELAY;
- keyinterval=SDL_DEFAULT_REPEAT_INTERVAL;
- if(!PyArg_ParseTuple(args, "|ii:set_keyrepeat",&keydelay,&keyinterval))
- return NULL;
- return Py_BuildValue("i",SDL_EnableKeyRepeat(keydelay,keyinterval));
+ int keydelay,keyinterval;
+ keydelay=SDL_DEFAULT_REPEAT_DELAY;
+ keyinterval=SDL_DEFAULT_REPEAT_INTERVAL;
+ if (!PyArg_ParseTuple(args, "|ii:set_keyrepeat",&keydelay,&keyinterval))
+ return NULL;
+ return Py_BuildValue("i",SDL_EnableKeyRepeat(keydelay,keyinterval));
}
//delete_part
static PyObject* emb_delete(PyObject *self, PyObject *args)
{
- int x,y;
- if(!PyArg_ParseTuple(args, "ii:delete",&x,&y))
- return NULL;
- delete_part(x,y);
- return Py_BuildValue("i",1);
+ int x,y;
+ if (!PyArg_ParseTuple(args, "ii:delete",&x,&y))
+ return NULL;
+ delete_part(x,y);
+ return Py_BuildValue("i",1);
}
static PyObject* emb_set_pressure(PyObject *self, PyObject *args)
{
- int x,y,press;
- if(!PyArg_ParseTuple(args, "iii:set_pressure",&x,&y,&press))
- return NULL;
- pv[y/CELL][x/CELL]=press;
- return Py_BuildValue("i",1);
+ int x,y,press;
+ if (!PyArg_ParseTuple(args, "iii:set_pressure",&x,&y,&press))
+ return NULL;
+ pv[y/CELL][x/CELL]=press;
+ return Py_BuildValue("i",1);
}
static PyObject* emb_set_velocity(PyObject *self, PyObject *args)
{
- int x,y,xv,yv;
- if(!PyArg_ParseTuple(args, "iiii:set_velocity",&x,&y,&xv,&yv))
- return NULL;
- vx[y/CELL][x/CELL]=xv;
- vy[y/CELL][x/CELL]=yv;
- return Py_BuildValue("i",1);
+ int x,y,xv,yv;
+ if (!PyArg_ParseTuple(args, "iiii:set_velocity",&x,&y,&xv,&yv))
+ return NULL;
+ vx[y/CELL][x/CELL]=xv;
+ vy[y/CELL][x/CELL]=yv;
+ return Py_BuildValue("i",1);
}
static PyObject* emb_disable_python(PyObject *self, PyObject *args)
{
- if(!PyArg_ParseTuple(args, ":disable_python"))
- return NULL;
- pyready=0;
- return Py_BuildValue("i",1);
+ if (!PyArg_ParseTuple(args, ":disable_python"))
+ return NULL;
+ pyready=0;
+ return Py_BuildValue("i",1);
}
int bsx = 2, bsy = 2, sl=1, sr=0;
static PyObject*
emb_get_tool(PyObject *self, PyObject *args)
{
- if(!PyArg_ParseTuple(args, ":get_tool"))
- return NULL;
- return Py_BuildValue("((ii)(ii)i)",bsx,bsy,sl,sr,CURRENT_BRUSH);
+ if (!PyArg_ParseTuple(args, ":get_tool"))
+ return NULL;
+ return Py_BuildValue("((ii)(ii)i)",bsx,bsy,sl,sr,CURRENT_BRUSH);
}
static PyObject*
emb_set_tool(PyObject *self, PyObject *args)
{
- if(!PyArg_ParseTuple(args, "((ii)(ii)i):set_tool",&bsx,&bsy,&sl,&sr,&CURRENT_BRUSH))
- return NULL;
- return Py_BuildValue("i",1);
+ if (!PyArg_ParseTuple(args, "((ii)(ii)i):set_tool",&bsx,&bsy,&sl,&sr,&CURRENT_BRUSH))
+ return NULL;
+ return Py_BuildValue("i",1);
}
/*
@@ -2004,48 +2004,48 @@ emb_release_mouse(PyObject *self, PyObject *args)
static PyMethodDef EmbMethods[] = { //WARNING! don't forget to register your function here!
- {"create", (PyCFunction)emb_create, METH_VARARGS|METH_KEYWORDS, "create a particle."},
- {"log", (PyCFunction)emb_log, METH_VARARGS, "logs an error string to the console."},
- {"reset_pressure", (PyCFunction)emb_reset_pressure, METH_VARARGS, "resets all the pressure."},
- {"reset_velocity", (PyCFunction)emb_reset_velocity, METH_VARARGS, "resets all the velocity."},
- {"reset_sparks", (PyCFunction)emb_reset_sparks, METH_VARARGS, "resets all the sparks."},
- {"set_life", (PyCFunction)emb_set_life, METH_VARARGS|METH_KEYWORDS, "sets life of a specified particle."},
- {"set_type", (PyCFunction)emb_set_type, METH_VARARGS|METH_KEYWORDS, "sets type of a specified particle."},
- {"set_temp", (PyCFunction)emb_set_temp, METH_VARARGS|METH_KEYWORDS, "sets temp of a specified particle."},
- {"set_tmp", (PyCFunction)emb_set_tmp, METH_VARARGS|METH_KEYWORDS, "sets tmp of a specified particle."},
- {"set_x", (PyCFunction)emb_set_x, METH_VARARGS|METH_KEYWORDS, "sets x of a specified particle."},
- {"set_y", (PyCFunction)emb_set_y, METH_VARARGS|METH_KEYWORDS, "sets y of a specified particle."},
- {"set_ctype", (PyCFunction)emb_set_ctype, METH_VARARGS|METH_KEYWORDS, "sets ctype of a specified particle."},
- {"set_vx", (PyCFunction)emb_set_vx, METH_VARARGS|METH_KEYWORDS, "sets vx of a specified particle."},
- {"set_vy", (PyCFunction)emb_set_vy, METH_VARARGS|METH_KEYWORDS, "sets vy of a specified particle."},
- {"pause", (PyCFunction)emb_pause, METH_VARARGS, "pause the game."},
- {"unpause", (PyCFunction)emb_unpause, METH_VARARGS, "unpause the game."},
- {"pause_toggle", (PyCFunction)emb_toggle_pause, METH_VARARGS, "toggle game pause."},
- {"console_open", (PyCFunction)emb_open_console, METH_VARARGS, "open the game console."},
- {"console_close", (PyCFunction)emb_close_console, METH_VARARGS, "close the game console."},
- {"console_toggle", (PyCFunction)emb_toggle_console, METH_VARARGS, "toggle the game console."},
- {"console_more", (PyCFunction)emb_console_more, METH_VARARGS, "turns the more indicator on."},
- {"console_less", (PyCFunction)emb_console_less, METH_VARARGS, "turns the more indicator off."},
- {"get_pmap", (PyCFunction)emb_get_pmap, METH_VARARGS, "get the pmap value."},
- {"get_prop", (PyCFunction)emb_get_prop, METH_VARARGS, "get some properties."},
- {"draw_pixel", (PyCFunction)emb_draw_pixel, METH_VARARGS, "draw a pixel."},
- {"draw_text", (PyCFunction)emb_draw_text, METH_VARARGS, "draw some text."},
- {"draw_rect", (PyCFunction)emb_draw_rect, METH_VARARGS, "draw a rect."},
- {"draw_fillrect", (PyCFunction)emb_draw_fillrect, METH_VARARGS, "draw a rect."},
- {"get_width", (PyCFunction)emb_get_width, METH_VARARGS, "get string width."},
- {"get_mouse", (PyCFunction)emb_get_mouse, METH_VARARGS, "get mouse status."},
- {"get_name", (PyCFunction)emb_get_name, METH_VARARGS, "get name of logged in user"},
- {"shortcuts_disable", (PyCFunction)emb_shortcuts_disable, METH_VARARGS, "disable keyboard shortcuts"},
- {"shortcuts_enable", (PyCFunction)emb_shortcuts_enable, METH_VARARGS, "enable keyboard shortcuts"},
- {"get_modifier", (PyCFunction)emb_get_modifier, METH_VARARGS, "get pressed modifier keys"},
- {"set_keyrepeat", (PyCFunction)emb_set_keyrepeat, METH_VARARGS, "set key repeat rate."},
- {"delete", (PyCFunction)emb_delete, METH_VARARGS, "delete a particle"},
- {"set_pressure", (PyCFunction)emb_set_pressure, METH_VARARGS, "set pressure"},
- {"set_velocity", (PyCFunction)emb_set_velocity, METH_VARARGS, "set velocity"},
- {"disable_python", (PyCFunction)emb_disable_python, METH_VARARGS, "switch back to the old console."},
- {"get_tool", (PyCFunction)emb_get_tool, METH_VARARGS, "get tool size/type and selected particles"},
- {"set_tool", (PyCFunction)emb_set_tool, METH_VARARGS, "set tool size/type and selected particles"},
- {NULL, NULL, 0, NULL}
+ {"create", (PyCFunction)emb_create, METH_VARARGS|METH_KEYWORDS, "create a particle."},
+ {"log", (PyCFunction)emb_log, METH_VARARGS, "logs an error string to the console."},
+ {"reset_pressure", (PyCFunction)emb_reset_pressure, METH_VARARGS, "resets all the pressure."},
+ {"reset_velocity", (PyCFunction)emb_reset_velocity, METH_VARARGS, "resets all the velocity."},
+ {"reset_sparks", (PyCFunction)emb_reset_sparks, METH_VARARGS, "resets all the sparks."},
+ {"set_life", (PyCFunction)emb_set_life, METH_VARARGS|METH_KEYWORDS, "sets life of a specified particle."},
+ {"set_type", (PyCFunction)emb_set_type, METH_VARARGS|METH_KEYWORDS, "sets type of a specified particle."},
+ {"set_temp", (PyCFunction)emb_set_temp, METH_VARARGS|METH_KEYWORDS, "sets temp of a specified particle."},
+ {"set_tmp", (PyCFunction)emb_set_tmp, METH_VARARGS|METH_KEYWORDS, "sets tmp of a specified particle."},
+ {"set_x", (PyCFunction)emb_set_x, METH_VARARGS|METH_KEYWORDS, "sets x of a specified particle."},
+ {"set_y", (PyCFunction)emb_set_y, METH_VARARGS|METH_KEYWORDS, "sets y of a specified particle."},
+ {"set_ctype", (PyCFunction)emb_set_ctype, METH_VARARGS|METH_KEYWORDS, "sets ctype of a specified particle."},
+ {"set_vx", (PyCFunction)emb_set_vx, METH_VARARGS|METH_KEYWORDS, "sets vx of a specified particle."},
+ {"set_vy", (PyCFunction)emb_set_vy, METH_VARARGS|METH_KEYWORDS, "sets vy of a specified particle."},
+ {"pause", (PyCFunction)emb_pause, METH_VARARGS, "pause the game."},
+ {"unpause", (PyCFunction)emb_unpause, METH_VARARGS, "unpause the game."},
+ {"pause_toggle", (PyCFunction)emb_toggle_pause, METH_VARARGS, "toggle game pause."},
+ {"console_open", (PyCFunction)emb_open_console, METH_VARARGS, "open the game console."},
+ {"console_close", (PyCFunction)emb_close_console, METH_VARARGS, "close the game console."},
+ {"console_toggle", (PyCFunction)emb_toggle_console, METH_VARARGS, "toggle the game console."},
+ {"console_more", (PyCFunction)emb_console_more, METH_VARARGS, "turns the more indicator on."},
+ {"console_less", (PyCFunction)emb_console_less, METH_VARARGS, "turns the more indicator off."},
+ {"get_pmap", (PyCFunction)emb_get_pmap, METH_VARARGS, "get the pmap value."},
+ {"get_prop", (PyCFunction)emb_get_prop, METH_VARARGS, "get some properties."},
+ {"draw_pixel", (PyCFunction)emb_draw_pixel, METH_VARARGS, "draw a pixel."},
+ {"draw_text", (PyCFunction)emb_draw_text, METH_VARARGS, "draw some text."},
+ {"draw_rect", (PyCFunction)emb_draw_rect, METH_VARARGS, "draw a rect."},
+ {"draw_fillrect", (PyCFunction)emb_draw_fillrect, METH_VARARGS, "draw a rect."},
+ {"get_width", (PyCFunction)emb_get_width, METH_VARARGS, "get string width."},
+ {"get_mouse", (PyCFunction)emb_get_mouse, METH_VARARGS, "get mouse status."},
+ {"get_name", (PyCFunction)emb_get_name, METH_VARARGS, "get name of logged in user"},
+ {"shortcuts_disable", (PyCFunction)emb_shortcuts_disable, METH_VARARGS, "disable keyboard shortcuts"},
+ {"shortcuts_enable", (PyCFunction)emb_shortcuts_enable, METH_VARARGS, "enable keyboard shortcuts"},
+ {"get_modifier", (PyCFunction)emb_get_modifier, METH_VARARGS, "get pressed modifier keys"},
+ {"set_keyrepeat", (PyCFunction)emb_set_keyrepeat, METH_VARARGS, "set key repeat rate."},
+ {"delete", (PyCFunction)emb_delete, METH_VARARGS, "delete a particle"},
+ {"set_pressure", (PyCFunction)emb_set_pressure, METH_VARARGS, "set pressure"},
+ {"set_velocity", (PyCFunction)emb_set_velocity, METH_VARARGS, "set velocity"},
+ {"disable_python", (PyCFunction)emb_disable_python, METH_VARARGS, "switch back to the old console."},
+ {"get_tool", (PyCFunction)emb_get_tool, METH_VARARGS, "get tool size/type and selected particles"},
+ {"set_tool", (PyCFunction)emb_set_tool, METH_VARARGS, "set tool size/type and selected particles"},
+ {NULL, NULL, 0, NULL}
};
#endif
@@ -2067,7 +2067,7 @@ int main(int argc, char *argv[])
void *http_ver_check;
void *http_session_check = NULL;
char *ver_data=NULL, *check_data=NULL, *tmp;
- //char console_error[255] = "";
+ //char console_error[255] = "";
int i, j, bq, fire_fc=0, do_check=0, do_s_check=0, old_version=0, http_ret=0,http_s_ret=0, major, minor, old_ver_len;
#ifdef INTERNAL
int vs = 0;
@@ -2097,71 +2097,71 @@ int main(int argc, char *argv[])
fmt.samples = 512;
fmt.callback = mixaudio;
fmt.userdata = NULL;
-
+
#ifdef PYCONSOLE
- //initialise python console
- Py_Initialize();
- PyRun_SimpleString("print 'python present.'");
- Py_InitModule("tpt", EmbMethods);
-
- //change the path to find all the correct modules
- PyRun_SimpleString("import sys\nsys.path.append('./tptPython.zip')\nsys.path.append('.')");
- //load the console module and whatnot
+ //initialise python console
+ Py_Initialize();
+ PyRun_SimpleString("print 'python present.'");
+ Py_InitModule("tpt", EmbMethods);
+
+ //change the path to find all the correct modules
+ PyRun_SimpleString("import sys\nsys.path.append('./tptPython.zip')\nsys.path.append('.')");
+ //load the console module and whatnot
#ifdef PYEXT
- PyRun_SimpleString(tpt_console_py);
- printf("using external python console file.\n");
- pname=PyString_FromString("tpt_console");//create string object
- pmodule = PyImport_Import(pname);//import module
- Py_DECREF(pname);//throw away string
+ PyRun_SimpleString(tpt_console_py);
+ printf("using external python console file.\n");
+ pname=PyString_FromString("tpt_console");//create string object
+ pmodule = PyImport_Import(pname);//import module
+ Py_DECREF(pname);//throw away string
#else
- tpt_console_obj = PyMarshal_ReadObjectFromString(tpt_console_pyc+8, sizeof(tpt_console_pyc)-8);
- pmodule=PyImport_ExecCodeModule("tpt_console", tpt_console_obj);
+ tpt_console_obj = PyMarshal_ReadObjectFromString(tpt_console_pyc+8, sizeof(tpt_console_pyc)-8);
+ pmodule=PyImport_ExecCodeModule("tpt_console", tpt_console_obj);
#endif
- if(pmodule!=NULL)
- {
- pfunc=PyObject_GetAttrString(pmodule,"handle");//get the handler function
- if(pfunc && PyCallable_Check(pfunc))//check if it's really a function
- {
- printf("python console ready to go.\n");
- }
- else
- {
- PyErr_Print();
- printf("unable to find handle function, mangled console.py?\n");
- pyready = 0;
- pygood = 0;
- }
-
- pstep=PyObject_GetAttrString(pmodule,"step");//get the handler function
- if(pstep && PyCallable_Check(pstep))//check if it's really a function
- {
- printf("step function found.\n");
- }
- else
- {
- printf("unable to find step function. ignoring.\n");
- }
-
- pkey=PyObject_GetAttrString(pmodule,"keypress");//get the handler function
- if(pstep && PyCallable_Check(pkey))//check if it's really a function
- {
- printf("key function found.\n");
- }
- else
- {
- printf("unable to find key function. ignoring.\n");
- }
- }
- else
- {
- //sys.stderr
- PyErr_Print();
- printf("unable to find console module, missing file or mangled console.py?\n");
- pyready = 0;
- pygood = 0;
- }
+ if (pmodule!=NULL)
+ {
+ pfunc=PyObject_GetAttrString(pmodule,"handle");//get the handler function
+ if (pfunc && PyCallable_Check(pfunc))//check if it's really a function
+ {
+ printf("python console ready to go.\n");
+ }
+ else
+ {
+ PyErr_Print();
+ printf("unable to find handle function, mangled console.py?\n");
+ pyready = 0;
+ pygood = 0;
+ }
+
+ pstep=PyObject_GetAttrString(pmodule,"step");//get the handler function
+ if (pstep && PyCallable_Check(pstep))//check if it's really a function
+ {
+ printf("step function found.\n");
+ }
+ else
+ {
+ printf("unable to find step function. ignoring.\n");
+ }
+
+ pkey=PyObject_GetAttrString(pmodule,"keypress");//get the handler function
+ if (pstep && PyCallable_Check(pkey))//check if it's really a function
+ {
+ printf("key function found.\n");
+ }
+ else
+ {
+ printf("unable to find key function. ignoring.\n");
+ }
+ }
+ else
+ {
+ //sys.stderr
+ PyErr_Print();
+ printf("unable to find console module, missing file or mangled console.py?\n");
+ pyready = 0;
+ pygood = 0;
+ }
#else
- printf("python console disabled at compile time.");
+ printf("python console disabled at compile time.");
#endif
#ifdef MT
@@ -2233,13 +2233,13 @@ int main(int argc, char *argv[])
file_script = 1;
}
else if (!strncmp(argv[i], "open:", 5))
- {
+ {
int size;
void *file_data;
char fn[64];
strncpy(fn, argv[i]+5, strlen(argv[i]+5));
file_data = file_load(fn, &size);
- if(file_data)
+ if (file_data)
{
it=0;
parse_save(file_data, size, 0, 0, 0, bmap, fvx, fvy, signs, parts, pmap);
@@ -2257,7 +2257,7 @@ int main(int argc, char *argv[])
sdl_open();
http_init(http_proxy_string[0] ? http_proxy_string : NULL);
-
+
if (cpu_check())
{
error_ui(vid_buf, 0, "Unsupported CPU. Try another version.");
@@ -2269,7 +2269,7 @@ int main(int argc, char *argv[])
#else
http_ver_check = http_async_req_start(NULL, "http://" SERVER "/Update.api?Action=CheckVersion", NULL, 0, 0);
#endif
- if(svf_login){
+ if (svf_login) {
http_session_check = http_async_req_start(NULL, "http://" SERVER "/Login.api?Action=CheckSession", NULL, 0, 0);
http_auth_headers(http_session_check, svf_user_id, NULL, svf_session_id);
}
@@ -2355,14 +2355,14 @@ int main(int argc, char *argv[])
}
do_check = (do_check+1) & 15;
}
- if(http_session_check)
+ if (http_session_check)
{
- if(!do_s_check && http_async_req_status(http_session_check))
+ if (!do_s_check && http_async_req_status(http_session_check))
{
check_data = http_async_req_stop(http_session_check, &http_s_ret, NULL);
- if(http_ret==200 && check_data)
+ if (http_ret==200 && check_data)
{
- if(!strncmp(check_data, "EXPIRED", 7))
+ if (!strncmp(check_data, "EXPIRED", 7))
{
//Session expired
strcpy(svf_user, "");
@@ -2374,7 +2374,7 @@ int main(int argc, char *argv[])
svf_admin = 0;
svf_mod = 0;
}
- else if(!strncmp(check_data, "BANNED", 6))
+ else if (!strncmp(check_data, "BANNED", 6))
{
//User banned
strcpy(svf_user, "");
@@ -2387,10 +2387,10 @@ int main(int argc, char *argv[])
svf_mod = 0;
error_ui(vid_buf, 0, "Unable to log in\nYour account has been suspended, consider reading the rules.");
}
- else if(!strncmp(check_data, "OK", 2))
+ else if (!strncmp(check_data, "OK", 2))
{
//Session valid
- if(strlen(check_data)>2){
+ if (strlen(check_data)>2) {
//User is elevated
if (!strncmp(check_data+3, "ADMIN", 5))
{
@@ -2401,8 +2401,8 @@ int main(int argc, char *argv[])
{
svf_admin = 0;
svf_mod = 1;
- }
- }
+ }
+ }
}
else
{
@@ -2434,10 +2434,10 @@ int main(int argc, char *argv[])
clearrect(vid_buf, XRES-125+BARSIZE/*385*/, YRES+(MENUSIZE-16), 91, 14);
drawrect(vid_buf, XRES-125+BARSIZE/*385*/, YRES+(MENUSIZE-16), 91, 14, 255, 255, 255, 255);
drawtext(vid_buf, XRES-122+BARSIZE/*388*/, YRES+(MENUSIZE-13), "\x84", 255, 255, 255, 255);
- if(username_flash>30){
+ if (username_flash>30) {
username_flash_t = -1;
username_flash = 30;
- } else if(username_flash<0) {
+ } else if (username_flash<0) {
username_flash_t = 1;
username_flash = 0;
}
@@ -2449,331 +2449,317 @@ int main(int argc, char *argv[])
}
do_s_check = (do_s_check+1) & 15;
}
-
- if(sys_shortcuts==1)//all shortcuts can be disabled by python scripts
- {
- if (sdl_key=='q' || sdl_key==SDLK_ESCAPE)
- {
- if (confirm_ui(vid_buf, "You are about to quit", "Are you sure you want to quit?", "Quit"))
- {
- break;
- }
- }
- if (sdl_key=='i' && (sdl_mod & KMOD_CTRL))
+
+ if (sys_shortcuts==1)//all shortcuts can be disabled by python scripts
+ {
+ if (sdl_key=='q' || sdl_key==SDLK_ESCAPE)
+ {
+ if (confirm_ui(vid_buf, "You are about to quit", "Are you sure you want to quit?", "Quit"))
+ {
+ break;
+ }
+ }
+ //if(sdl_key=='d' && isplayer)
+ //{
+ // death = 1;
+ // //death = !(death);
+ //}
+ if (sdl_key=='f')
+ {
+ framerender = 1;
+ }
+ if ((sdl_key=='l' || sdl_key=='k') && stamps[0].name[0])
{
- if(confirm_ui(vid_buf, "Install Powder Toy", "You are about to install The Powder Toy", "Install"))
+ if (load_mode)
{
- if(register_extension())
+ free(load_img);
+ free(load_data);
+ load_mode = 0;
+ load_data = NULL;
+ load_img = NULL;
+ }
+ if (it > 50)
+ it = 50;
+ if (sdl_key=='k' && stamps[1].name[0])
+ {
+ j = stamp_ui(vid_buf);
+ if (j>=0)
+ load_data = stamp_load(j, &load_size);
+ else
+ load_data = NULL;
+ }
+ else
+ load_data = stamp_load(0, &load_size);
+ if (load_data)
+ {
+ load_img = prerender_save(load_data, load_size, &load_w, &load_h);
+ if (load_img)
+ load_mode = 1;
+ else
+ free(load_data);
+ }
+ }
+ if (sdl_key=='s' && (sdl_mod & (KMOD_CTRL)) || (sdl_key=='s' && !isplayer2))
+ {
+ if (it > 50)
+ it = 50;
+ save_mode = 1;
+ }
+ if (sdl_key=='1')
+ {
+ set_cmode(CM_VEL);
+ }
+ if (sdl_key=='2')
+ {
+ set_cmode(CM_PRESS);
+ }
+ if (sdl_key=='3')
+ {
+ set_cmode(CM_PERS);
+ }
+ if (sdl_key=='4')
+ {
+ set_cmode(CM_FIRE);
+ }
+ if (sdl_key=='5')
+ {
+ set_cmode(CM_BLOB);
+ }
+ if (sdl_key=='6')
+ {
+ set_cmode(CM_HEAT);
+ }
+ if (sdl_key=='7')
+ {
+ set_cmode(CM_FANCY);
+ }
+ if (sdl_key=='8')
+ {
+ set_cmode(CM_NOTHING);
+ }
+ if (sdl_key=='9')
+ {
+ set_cmode(CM_GRAD);
+ }
+ if (sdl_key=='0')
+ {
+ set_cmode(CM_CRACK);
+ }
+ if (sdl_key=='1'&& (sdl_mod & (KMOD_SHIFT)) && DEBUG_MODE)
+ {
+ set_cmode(CM_LIFE);
+ }
+ if (sdl_key==SDLK_TAB)
+ {
+ CURRENT_BRUSH =(CURRENT_BRUSH + 1)%BRUSH_NUM ;
+ }
+ if (sdl_key==SDLK_LEFTBRACKET) {
+ if (sdl_zoom_trig==1)
+ {
+ ZSIZE -= 1;
+ if (ZSIZE>60)
+ ZSIZE = 60;
+ if (ZSIZE<2)
+ ZSIZE = 2;
+ ZFACTOR = 256/ZSIZE;
+ }
+ else
+ {
+ if (sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL)))
+ {
+ bsx -= 1;
+ bsy -= 1;
+ }
+ else if (sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL)))
+ {
+ bsx -= 1;
+ }
+ else if (sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT)))
+ {
+ bsy -= 1;
+ }
+ else
+ {
+ bsx -= ceil((bsx/5)+0.5f);
+ bsy -= ceil((bsy/5)+0.5f);
+ }
+ if (bsx>1180)
+ bsx = 1180;
+ if (bsy>1180)
+ bsy = 1180;
+ if (bsx<0)
+ bsx = 0;
+ if (bsy<0)
+ bsy = 0;
+ }
+ }
+ if (sdl_key==SDLK_RIGHTBRACKET) {
+ if (sdl_zoom_trig==1)
+ {
+ ZSIZE += 1;
+ if (ZSIZE>60)
+ ZSIZE = 60;
+ if (ZSIZE<2)
+ ZSIZE = 2;
+ ZFACTOR = 256/ZSIZE;
+ }
+ else
+ {
+ if (sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL)))
+ {
+ bsx += 1;
+ bsy += 1;
+ }
+ else if (sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL)))
+ {
+ bsx += 1;
+ }
+ else if (sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT)))
{
- info_ui(vid_buf, "Install success", "Powder Toy has been installed!");
+ bsy += 1;
}
else
{
- error_ui(vid_buf, 0, "Install failed - You may not have permission or you may be on a platform that does not support installation");
+ bsx += ceil((bsx/5)+0.5f);
+ bsy += ceil((bsy/5)+0.5f);
+ }
+ if (bsx>1180)
+ bsx = 1180;
+ if (bsy>1180)
+ bsy = 1180;
+ if (bsx<0)
+ bsx = 0;
+ if (bsy<0)
+ bsy = 0;
+ }
+ }
+ if (sdl_key=='d'&&(sdl_mod & (KMOD_CTRL)) || (sdl_key=='d' && !isplayer2))
+ DEBUG_MODE = !DEBUG_MODE;
+ if (sdl_key=='i')
+ {
+ int nx, ny;
+ for (nx = 0; nx<XRES/CELL; nx++)
+ for (ny = 0; ny<YRES/CELL; ny++)
+ {
+ pv[ny][nx] = -pv[ny][nx];
+ vx[ny][nx] = -vx[ny][nx];
+ vy[ny][nx] = -vy[ny][nx];
+ }
+ }
+ if ((sdl_mod & (KMOD_RCTRL) )&&( sdl_mod & (KMOD_RALT)))
+ active_menu = 11;
+ if (sdl_key==SDLK_INSERT)// || sdl_key==SDLK_BACKQUOTE)
+ REPLACE_MODE = !REPLACE_MODE;
+ if (sdl_key==SDLK_BACKQUOTE)
+ {
+ console_mode = !console_mode;
+ //hud_enable = !console_mode;
+ }
+ if (sdl_key=='g')
+ {
+ if (sdl_mod & (KMOD_SHIFT))
+ GRID_MODE = (GRID_MODE+9)%10;
+ else
+ GRID_MODE = (GRID_MODE+1)%10;
+ }
+ if (sdl_key=='=')
+ {
+ int nx, ny;
+ if (sdl_mod & (KMOD_CTRL))
+ {
+ for (i=0; i<NPART; i++)
+ if (parts[i].type==PT_SPRK)
+ {
+ parts[i].type = parts[i].ctype;
+ parts[i].life = 0;
+ }
+ }
+ else
+ {
+ for (nx = 0; nx<XRES/CELL; nx++)
+ for (ny = 0; ny<YRES/CELL; ny++)
+ {
+ pv[ny][nx] = 0;
+ vx[ny][nx] = 0;
+ vy[ny][nx] = 0;
+ }
+ }
+ }
+
+ if (sdl_key=='w' && (!isplayer2 || (sdl_mod & (KMOD_SHIFT)))) //Gravity, by Moach
+ {
+ ++gravityMode; // cycle gravity mode
+ itc = 51;
+
+ switch (gravityMode)
+ {
+ default:
+ gravityMode = 0;
+ case 0:
+ strcpy(itc_msg, "Gravity: Vertical");
+ break;
+ case 1:
+ strcpy(itc_msg, "Gravity: Off");
+ break;
+ case 2:
+ strcpy(itc_msg, "Gravity: Radial");
+ break;
+
+ }
+ }
+ if (sdl_key=='y')
+ {
+ ++airMode;
+ itc = 52;
+
+ switch (airMode)
+ {
+ default:
+ airMode = 0;
+ case 0:
+ strcpy(itc_msg, "Air: On");
+ break;
+ case 1:
+ strcpy(itc_msg, "Air: Pressure Off");
+ break;
+ case 2:
+ strcpy(itc_msg, "Air: Velocity Off");
+ break;
+ case 3:
+ strcpy(itc_msg, "Air: Off");
+ break;
+ case 4:
+ strcpy(itc_msg, "Air: No Update");
+ break;
+ }
+ }
+
+ if (sdl_key=='t')
+ VINE_MODE = !VINE_MODE;
+ if (sdl_key==SDLK_SPACE)
+ sys_pause = !sys_pause;
+ if (sdl_key=='h')
+ hud_enable = !hud_enable;
+ if (sdl_key=='p')
+ dump_frame(vid_buf, XRES, YRES, XRES+BARSIZE);
+ if (sdl_key=='v'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
+ {
+ if (clipboard_ready==1)
+ {
+ load_data = malloc(clipboard_length);
+ memcpy(load_data, clipboard_data, clipboard_length);
+ load_size = clipboard_length;
+ if (load_data)
+ {
+ load_img = prerender_save(load_data, load_size, &load_w, &load_h);
+ if (load_img)
+ load_mode = 1;
+ else
+ free(load_data);
}
}
}
- //if(sdl_key=='d' && isplayer)
- //{
- // death = 1;
- // //death = !(death);
- //}
- if (sdl_key=='f')
- {
- framerender = 1;
- }
- if ((sdl_key=='l' || sdl_key=='k') && stamps[0].name[0])
- {
- if (load_mode)
- {
- free(load_img);
- free(load_data);
- load_mode = 0;
- load_data = NULL;
- load_img = NULL;
- }
- if (it > 50)
- it = 50;
- if (sdl_key=='k' && stamps[1].name[0])
- {
- j = stamp_ui(vid_buf);
- if (j>=0)
- load_data = stamp_load(j, &load_size);
- else
- load_data = NULL;
- }
- else
- load_data = stamp_load(0, &load_size);
- if (load_data)
- {
- load_img = prerender_save(load_data, load_size, &load_w, &load_h);
- if (load_img)
- load_mode = 1;
- else
- free(load_data);
- }
- }
- if (sdl_key=='s' && (sdl_mod & (KMOD_CTRL)) || (sdl_key=='s' && !isplayer2))
- {
- if (it > 50)
- it = 50;
- save_mode = 1;
- }
- if (sdl_key=='1')
- {
- set_cmode(CM_VEL);
- }
- if (sdl_key=='2')
- {
- set_cmode(CM_PRESS);
- }
- if (sdl_key=='3')
- {
- set_cmode(CM_PERS);
- }
- if (sdl_key=='4')
- {
- set_cmode(CM_FIRE);
- }
- if (sdl_key=='5')
- {
- set_cmode(CM_BLOB);
- }
- if (sdl_key=='6')
- {
- set_cmode(CM_HEAT);
- }
- if (sdl_key=='7')
- {
- set_cmode(CM_FANCY);
- }
- if (sdl_key=='8')
- {
- set_cmode(CM_NOTHING);
- }
- if (sdl_key=='9')
- {
- set_cmode(CM_GRAD);
- }
- if (sdl_key=='0')
- {
- set_cmode(CM_CRACK);
- }
- if (sdl_key=='1'&& (sdl_mod & (KMOD_SHIFT)) && DEBUG_MODE)
- {
- set_cmode(CM_LIFE);
- }
- if (sdl_key==SDLK_TAB)
- {
- CURRENT_BRUSH =(CURRENT_BRUSH + 1)%BRUSH_NUM ;
- }
- if (sdl_key==SDLK_LEFTBRACKET) {
- if (sdl_zoom_trig==1)
- {
- ZSIZE -= 1;
- if (ZSIZE>60)
- ZSIZE = 60;
- if (ZSIZE<2)
- ZSIZE = 2;
- ZFACTOR = 256/ZSIZE;
- }
- else
- {
- if (sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL)))
- {
- bsx -= 1;
- bsy -= 1;
- }
- else if (sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL)))
- {
- bsx -= 1;
- }
- else if (sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT)))
- {
- bsy -= 1;
- }
- else
- {
- bsx -= ceil((bsx/5)+0.5f);
- bsy -= ceil((bsy/5)+0.5f);
- }
- if (bsx>1180)
- bsx = 1180;
- if (bsy>1180)
- bsy = 1180;
- if (bsx<0)
- bsx = 0;
- if (bsy<0)
- bsy = 0;
- }
- }
- if (sdl_key==SDLK_RIGHTBRACKET) {
- if (sdl_zoom_trig==1)
- {
- ZSIZE += 1;
- if (ZSIZE>60)
- ZSIZE = 60;
- if (ZSIZE<2)
- ZSIZE = 2;
- ZFACTOR = 256/ZSIZE;
- }
- else
- {
- if (sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL)))
- {
- bsx += 1;
- bsy += 1;
- }
- else if (sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL)))
- {
- bsx += 1;
- }
- else if (sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT)))
- {
- bsy += 1;
- }
- else
- {
- bsx += ceil((bsx/5)+0.5f);
- bsy += ceil((bsy/5)+0.5f);
- }
- if (bsx>1180)
- bsx = 1180;
- if (bsy>1180)
- bsy = 1180;
- if (bsx<0)
- bsx = 0;
- if (bsy<0)
- bsy = 0;
- }
- }
- if (sdl_key=='d'&&(sdl_mod & (KMOD_CTRL)) || (sdl_key=='d' && !isplayer2))
- DEBUG_MODE = !DEBUG_MODE;
- if (sdl_key=='i')
- {
- int nx, ny;
- for (nx = 0; nx<XRES/CELL; nx++)
- for (ny = 0; ny<YRES/CELL; ny++)
- {
- pv[ny][nx] = -pv[ny][nx];
- vx[ny][nx] = -vx[ny][nx];
- vy[ny][nx] = -vy[ny][nx];
- }
- }
- if ((sdl_mod & (KMOD_RCTRL) )&&( sdl_mod & (KMOD_RALT)))
- active_menu = 11;
- if (sdl_key==SDLK_INSERT)// || sdl_key==SDLK_BACKQUOTE)
- REPLACE_MODE = !REPLACE_MODE;
- if (sdl_key==SDLK_BACKQUOTE)
- {
- console_mode = !console_mode;
- //hud_enable = !console_mode;
- }
- if (sdl_key=='g')
- {
- if (sdl_mod & (KMOD_SHIFT))
- GRID_MODE = (GRID_MODE+9)%10;
- else
- GRID_MODE = (GRID_MODE+1)%10;
- }
- if (sdl_key=='=')
- {
- int nx, ny;
- if(sdl_mod & (KMOD_CTRL))
- {
- for(i=0; i<NPART; i++)
- if(parts[i].type==PT_SPRK)
- {
- parts[i].type = parts[i].ctype;
- parts[i].life = 0;
- }
- }
- else
- {
- for (nx = 0; nx<XRES/CELL; nx++)
- for (ny = 0; ny<YRES/CELL; ny++)
- {
- pv[ny][nx] = 0;
- vx[ny][nx] = 0;
- vy[ny][nx] = 0;
- }
- }
- }
-
- if (sdl_key=='w' && (!isplayer2 || (sdl_mod & (KMOD_SHIFT)))) //Gravity, by Moach
- {
- ++gravityMode; // cycle gravity mode
- itc = 51;
-
- switch (gravityMode)
- {
- default:
- gravityMode = 0;
- case 0:
- strcpy(itc_msg, "Gravity: Vertical");
- break;
- case 1:
- strcpy(itc_msg, "Gravity: Off");
- break;
- case 2:
- strcpy(itc_msg, "Gravity: Radial");
- break;
-
- }
- }
- if (sdl_key=='y')
- {
- ++airMode;
- itc = 52;
-
- switch (airMode)
- {
- default:
- airMode = 0;
- case 0:
- strcpy(itc_msg, "Air: On");
- break;
- case 1:
- strcpy(itc_msg, "Air: Pressure Off");
- break;
- case 2:
- strcpy(itc_msg, "Air: Velocity Off");
- break;
- case 3:
- strcpy(itc_msg, "Air: Off");
- break;
- case 4:
- strcpy(itc_msg, "Air: No Update");
- break;
- }
- }
-
- if (sdl_key=='t')
- VINE_MODE = !VINE_MODE;
- if (sdl_key==SDLK_SPACE)
- sys_pause = !sys_pause;
- if (sdl_key=='h')
- hud_enable = !hud_enable;
- if (sdl_key=='p')
- dump_frame(vid_buf, XRES, YRES, XRES+BARSIZE);
- if (sdl_key=='v'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
- {
- if (clipboard_ready==1)
- {
- load_data = malloc(clipboard_length);
- memcpy(load_data, clipboard_data, clipboard_length);
- load_size = clipboard_length;
- if (load_data)
- {
- load_img = prerender_save(load_data, load_size, &load_w, &load_h);
- if (load_img)
- load_mode = 1;
- else
- free(load_data);
- }
- }
- }
- if (load_mode==1)
+ if (load_mode==1)
{
matrix2d transform = m2d_identity;
vector2d translate = v2d_zero;
@@ -2809,57 +2795,57 @@ int main(int argc, char *argv[])
}
if (sdl_key=='r'&&!(sdl_mod & (KMOD_CTRL|KMOD_SHIFT)))
GENERATION = 0;
- if (sdl_key=='x'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
- {
- save_mode = 1;
- copy_mode = 2;
- }
- if (sdl_key=='c'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
- {
- save_mode = 1;
- copy_mode = 1;
- }
- else if (sdl_key=='c')
- {
- set_cmode((cmode+1) % CM_COUNT);
- if (it > 50)
- it = 50;
- }
- if (sdl_key=='z'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))) // Undo
- {
- int cbx, cby, cbi;
-
- for (cbi=0; cbi<NPART; cbi++)
- parts[cbi] = cb_parts[cbi];
-
- for (cby = 0; cby<YRES; cby++)
- for (cbx = 0; cbx<XRES; cbx++)
- pmap[cby][cbx] = cb_pmap[cby][cbx];
-
- for (cby = 0; cby<(YRES/CELL); cby++)
- for (cbx = 0; cbx<(XRES/CELL); cbx++)
- {
- vx[cby][cbx] = cb_vx[cby][cbx];
- vy[cby][cbx] = cb_vy[cby][cbx];
- pv[cby][cbx] = cb_pv[cby][cbx];
- bmap[cby][cbx] = cb_bmap[cby][cbx];
- emap[cby][cbx] = cb_emap[cby][cbx];
- }
- }
- }
- #ifdef PYCONSOLE
- if(pyready==1 && pygood==1)
- if(pkey!=NULL && sdl_key!=NULL)
- {
- pargs=Py_BuildValue("(c)",sdl_key);
- pvalue = PyObject_CallObject(pkey, pargs);
- Py_DECREF(pargs);
- pargs=NULL;
- if(pvalue==NULL)
- strcpy(console_error,"failed to execute key code.");
- pvalue=NULL;
- }
- #endif
+ if (sdl_key=='x'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
+ {
+ save_mode = 1;
+ copy_mode = 2;
+ }
+ if (sdl_key=='c'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
+ {
+ save_mode = 1;
+ copy_mode = 1;
+ }
+ else if (sdl_key=='c')
+ {
+ set_cmode((cmode+1) % CM_COUNT);
+ if (it > 50)
+ it = 50;
+ }
+ if (sdl_key=='z'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))) // Undo
+ {
+ int cbx, cby, cbi;
+
+ for (cbi=0; cbi<NPART; cbi++)
+ parts[cbi] = cb_parts[cbi];
+
+ for (cby = 0; cby<YRES; cby++)
+ for (cbx = 0; cbx<XRES; cbx++)
+ pmap[cby][cbx] = cb_pmap[cby][cbx];
+
+ for (cby = 0; cby<(YRES/CELL); cby++)
+ for (cbx = 0; cbx<(XRES/CELL); cbx++)
+ {
+ vx[cby][cbx] = cb_vx[cby][cbx];
+ vy[cby][cbx] = cb_vy[cby][cbx];
+ pv[cby][cbx] = cb_pv[cby][cbx];
+ bmap[cby][cbx] = cb_bmap[cby][cbx];
+ emap[cby][cbx] = cb_emap[cby][cbx];
+ }
+ }
+ }
+#ifdef PYCONSOLE
+ if (pyready==1 && pygood==1)
+ if (pkey!=NULL && sdl_key!=NULL)
+ {
+ pargs=Py_BuildValue("(c)",sdl_key);
+ pvalue = PyObject_CallObject(pkey, pargs);
+ Py_DECREF(pargs);
+ pargs=NULL;
+ if (pvalue==NULL)
+ strcpy(console_error,"failed to execute key code.");
+ pvalue=NULL;
+ }
+#endif
#ifdef INTERNAL
int counterthing;
if (sdl_key=='v'&&!(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))//frame capture
@@ -2999,7 +2985,7 @@ int main(int argc, char *argv[])
}
}
}
-
+
mx = x;
my = y;
if (update_flag)
@@ -3291,7 +3277,7 @@ int main(int argc, char *argv[])
svf_description[0] = 0;
gravityMode = 0;
airMode = 0;
-
+
death = death2 = 0;
isplayer2 = 0;
isplayer = 0;
@@ -3307,7 +3293,7 @@ int main(int argc, char *argv[])
if (x>=(XRES+BARSIZE-(510-385)) && x<=(XRES+BARSIZE-(510-476)))
{
login_ui(vid_buf);
- if (svf_login){
+ if (svf_login) {
save_presets(0);
http_session_check = NULL;
}
@@ -3316,9 +3302,9 @@ int main(int argc, char *argv[])
{
if (!svf_open || !svf_own || x>51)
{
- if (save_name_ui(vid_buf)){
+ if (save_name_ui(vid_buf)) {
execute_save(vid_buf);
- if(svf_id[0]){
+ if (svf_id[0]) {
copytext_ui(vid_buf, "Save ID", "Saved successfully!", svf_id);
}
}
@@ -3369,22 +3355,22 @@ int main(int argc, char *argv[])
c = (b&1) ? sl : sr; //c is element to be spawned
su = c;
- if(c!=WL_SIGN+100)
+ if (c!=WL_SIGN+100)
{
- if(!bq)
- for(signi=0; signi<MAXSIGNS; signi++)
- if(sregexp(signs[signi].text, "^{c:[0-9]*|.*}$")==0)
+ if (!bq)
+ for (signi=0; signi<MAXSIGNS; signi++)
+ if (sregexp(signs[signi].text, "^{c:[0-9]*|.*}$")==0)
{
int signx, signy, signw, signh;
get_sign_pos(signi, &signx, &signy, &signw, &signh);
- if(x>=signx && x<=signx+signw && y>=signy && y<=signy+signh)
+ if (x>=signx && x<=signx+signw && y>=signy && y<=signy+signh)
{
char buff[256];
int sldr;
memset(buff, 0, sizeof(buff));
- for(sldr=3; signs[signi].text[sldr] != '|'; sldr++)
+ for (sldr=3; signs[signi].text[sldr] != '|'; sldr++)
buff[sldr-3] = signs[signi].text[sldr];
buff[sldr-3] = '\0';
@@ -3456,7 +3442,7 @@ int main(int argc, char *argv[])
ly = y;
}
}
- else //it is the first click
+ else //it is the first click
{
//start line tool
if ((sdl_mod & (KMOD_LSHIFT|KMOD_RSHIFT)) && !(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL|KMOD_LALT)))
@@ -3718,7 +3704,7 @@ int main(int argc, char *argv[])
{
fillrect(vid_buf, XRES-20-textwidth(heattext), 266, textwidth(heattext)+8, 15, 0, 0, 0, 140);
drawtext(vid_buf, XRES-16-textwidth(heattext), 270, heattext, 255, 255, 255, 200);
- if(DEBUG_MODE)
+ if (DEBUG_MODE)
{
fillrect(vid_buf, XRES-20-textwidth(coordtext), 280, textwidth(coordtext)+8, 13, 0, 0, 0, 140);
drawtext(vid_buf, XRES-16-textwidth(coordtext), 282, coordtext, 255, 255, 255, 200);
@@ -3730,7 +3716,7 @@ int main(int argc, char *argv[])
{
fillrect(vid_buf, 12, 266, textwidth(heattext)+8, 15, 0, 0, 0, 140);
drawtext(vid_buf, 16, 270, heattext, 255, 255, 255, 200);
- if(DEBUG_MODE)
+ if (DEBUG_MODE)
{
fillrect(vid_buf, 12, 280, textwidth(coordtext)+8, 13, 0, 0, 0, 140);
drawtext(vid_buf, 16, 282, coordtext, 255, 255, 255, 200);
@@ -3743,7 +3729,7 @@ int main(int argc, char *argv[])
{
fillrect(vid_buf, XRES-20-textwidth(heattext), 12, textwidth(heattext)+8, 15, 0, 0, 0, 140);
drawtext(vid_buf, XRES-16-textwidth(heattext), 16, heattext, 255, 255, 255, 200);
- if(DEBUG_MODE)
+ if (DEBUG_MODE)
{
fillrect(vid_buf, XRES-20-textwidth(coordtext), 26, textwidth(coordtext)+8, 11, 0, 0, 0, 140);
drawtext(vid_buf, XRES-16-textwidth(coordtext), 27, coordtext, 255, 255, 255, 200);
@@ -3754,78 +3740,78 @@ int main(int argc, char *argv[])
wavelength_gfx = 0;
fillrect(vid_buf, 12, 12, textwidth(uitext)+8, 15, 0, 0, 0, 140);
drawtext(vid_buf, 16, 16, uitext, 32, 216, 255, 200);
-
+
}
-
- if(console_mode)
+
+ if (console_mode)
{
- #ifdef PYCONSOLE
- if(pyready==1 && pygood==1)
- {
- char *console;
- //char error[255] = "error!";
- sys_pause = 1;
- console = console_ui(vid_buf,console_error,console_more);
- console = mystrdup(console);
- strcpy(console_error,"");
- if(process_command(vid_buf,console,&console_error,pfunc)==-1)
- {
- free(console);
- break;
- }
- free(console);
- if(!console_mode)
- hud_enable = 1;
- }
- else
- {
- char *console;
- sys_pause = 1;
- console = console_ui(vid_buf,console_error,console_more);
- console = mystrdup(console);
- strcpy(console_error,"");
- if(process_command_old(vid_buf,console,&console_error)==-1)
- {
- free(console);
- break;
- }
- free(console);
- if(!console_mode)
- hud_enable = 1;
- }
- #else
- char *console;
- sys_pause = 1;
- console = console_ui(vid_buf,console_error,console_more);
- console = mystrdup(console);
- strcpy(console_error,"");
- if(process_command_old(vid_buf,console,&console_error)==-1)
- {
- free(console);
- break;
- }
- free(console);
- if(!console_mode)
- hud_enable = 1;
- #endif
+#ifdef PYCONSOLE
+ if (pyready==1 && pygood==1)
+ {
+ char *console;
+ //char error[255] = "error!";
+ sys_pause = 1;
+ console = console_ui(vid_buf,console_error,console_more);
+ console = mystrdup(console);
+ strcpy(console_error,"");
+ if (process_command(vid_buf,console,&console_error,pfunc)==-1)
+ {
+ free(console);
+ break;
+ }
+ free(console);
+ if (!console_mode)
+ hud_enable = 1;
+ }
+ else
+ {
+ char *console;
+ sys_pause = 1;
+ console = console_ui(vid_buf,console_error,console_more);
+ console = mystrdup(console);
+ strcpy(console_error,"");
+ if (process_command_old(vid_buf,console,&console_error)==-1)
+ {
+ free(console);
+ break;
+ }
+ free(console);
+ if (!console_mode)
+ hud_enable = 1;
+ }
+#else
+ char *console;
+ sys_pause = 1;
+ console = console_ui(vid_buf,console_error,console_more);
+ console = mystrdup(console);
+ strcpy(console_error,"");
+ if (process_command_old(vid_buf,console,&console_error)==-1)
+ {
+ free(console);
+ break;
+ }
+ free(console);
+ if (!console_mode)
+ hud_enable = 1;
+#endif
}
-
+
//execute python step hook
- #ifdef PYCONSOLE
- if(pyready==1 && pygood==1)
- if(pstep!=NULL)
- {
- pargs=Py_BuildValue("()");
- pvalue = PyObject_CallObject(pstep, pargs);
- Py_DECREF(pargs);
- pargs=NULL;
- if(pvalue==NULL)
- strcpy(console_error,"failed to execute step code.");
- //Py_DECREF(pvalue);
- //puts("a");
- pvalue=NULL;
- }
- #endif
+#ifdef PYCONSOLE
+ if (pyready==1 && pygood==1)
+ if (pstep!=NULL)
+ {
+ pargs=Py_BuildValue("()");
+ pvalue = PyObject_CallObject(pstep, pargs);
+ Py_DECREF(pargs);
+ pargs=NULL;
+ if (pvalue==NULL)
+ strcpy(console_error,"failed to execute step code.");
+ //Py_DECREF(pvalue);
+ //puts("a");
+ pvalue=NULL;
+ }
+#endif
sdl_blit(0, 0, XRES+BARSIZE, YRES+MENUSIZE, vid_buf, XRES+BARSIZE);
//Setting an element for the stick man
@@ -3846,14 +3832,14 @@ int main(int argc, char *argv[])
}
SDL_CloseAudio();
http_done();
-
+
#ifdef PYCONSOLE
-
- PyRun_SimpleString("import os,tempfile,os.path\ntry:\n os.remove(os.path.join(tempfile.gettempdir(),'tpt_console.py'))\nexcept:\n pass");
- PyRun_SimpleString("import os,tempfile,os.path\ntry:\n os.remove(os.path.join(tempfile.gettempdir(),'tpt_console.pyo'))\nexcept:\n pass");
- PyRun_SimpleString("import os,tempfile,os.path\ntry:\n os.remove(os.path.join(tempfile.gettempdir(),'tpt_console.pyc'))\nexcept:\n pass");
-
- Py_Finalize();//cleanup any python stuff.
+
+ PyRun_SimpleString("import os,tempfile,os.path\ntry:\n os.remove(os.path.join(tempfile.gettempdir(),'tpt_console.py'))\nexcept:\n pass");
+ PyRun_SimpleString("import os,tempfile,os.path\ntry:\n os.remove(os.path.join(tempfile.gettempdir(),'tpt_console.pyo'))\nexcept:\n pass");
+ PyRun_SimpleString("import os,tempfile,os.path\ntry:\n os.remove(os.path.join(tempfile.gettempdir(),'tpt_console.pyc'))\nexcept:\n pass");
+
+ Py_Finalize();//cleanup any python stuff.
#endif
return 0;
}
@@ -3867,494 +3853,494 @@ int process_command(pixel *vid_buf,char *console,char *console_error,PyObject *p
char console3[15];
char console4[15];
char console5[15];
- PyObject *pvalue,*pargs;
+ PyObject *pvalue,*pargs;
//sprintf(console_error, "%s", console);
- if(console && strcmp(console, "")!=0 && strncmp(console, " ", 1)!=0)
+ if (console && strcmp(console, "")!=0 && strncmp(console, " ", 1)!=0)
{
sscanf(console,"%14s %14s %14s %14s", console2, console3, console4, console5);//why didn't i know about this function?!
- if(strcmp(console2, "quit")==0)
+ if (strcmp(console2, "quit")==0)
{
return -1;
- }else {
+ } else {
//handle them command
pargs=Py_BuildValue("(s)",console);
pvalue = PyObject_CallObject(pfunc, pargs);
Py_DECREF(pargs);
pargs=NULL;
- if(pvalue==NULL)
+ if (pvalue==NULL)
strcpy(console_error,"failed to execute code.");
pvalue=NULL;
- }
+ }
}
return 1;
}
#endif
int process_command_old(pixel *vid_buf,char *console,char *console_error) {
- int y,x,nx,ny,i,j,k,m;
- float f;
- int do_next = 1;
- char xcoord[10] = "";
- char ycoord[10] = "";
- char console2[15] = "";
- char console3[15] = "";
- char console4[15] = "";
- char console5[15] = "";
- //sprintf(console_error, "%s", console);
- if(console && strcmp(console, "")!=0 && strncmp(console, " ", 1)!=0)
- {
- sscanf(console,"%14s %14s %14s %14s", console2, console3, console4, console5);//why didn't i know about this function?!
- if(strcmp(console2, "quit")==0)
- {
- return -1;
- }
- else if(strcmp(console2, "file")==0 && console3[0])
- {
- if(file_script){
- FILE *f=fopen(console3, "r");
- if(f)
- {
- char fileread[5000];//TODO: make this change with file size
- char pch[5000];
- char tokens[10];
- int tokensize;
- nx = 0;
- ny = 0;
- j = 0;
- m = 0;
- if(console4[0])
- console_parse_coords(console4, &nx , &ny, console_error);
- memset(pch,0,sizeof(pch));
- memset(fileread,0,sizeof(fileread));
- fread(fileread,1,5000,f);
- for(i=0; i<strlen(fileread); i++)
- {
- if(fileread[i] != '\n')
- {
- pch[i-j] = fileread[i];
- if(fileread[i] != ' ')
- tokens[i-m] = fileread[i];
- }
- if(fileread[i] == ' ' || fileread[i] == '\n')
- {
- if(sregexp(tokens,"^x.[0-9],y.[0-9]")==0)//TODO: fix regex matching to work with x,y ect, right now it has to have a +0 or -0
- {
- char temp[5];
- int starty = 0;
- tokensize = strlen(tokens);
- x = 0;
- y = 0;
- sscanf(tokens,"x%d,y%d",&x,&y);
- sscanf(tokens,"%9s,%9s",xcoord,ycoord);
- x += nx;
- y += ny;
- sprintf(xcoord,"%d",x);
- sprintf(ycoord,"%d",y);
- for(k = 0; k<strlen(xcoord);k++)//rewrite pch with numbers
- {
- pch[i-j-tokensize+k] = xcoord[k];
- starty = k+1;
- }
- pch[i-j-tokensize+starty] = ',';
- starty++;
- for(k=0;k<strlen(ycoord);k++)
- {
- pch[i-j-tokensize+starty+k] = ycoord[k];
-
- }
- pch[i-j-tokensize +strlen(xcoord) +1 +strlen(ycoord)] = ' ';
- j = j -tokensize +strlen(xcoord) +1 +strlen(ycoord);
- }
- memset(tokens,0,sizeof(tokens));
- m = i+1;
- }
- if(fileread[i] == '\n')
- {
-
- if(do_next)
- {
- if(strcmp(pch,"else")==0)
- do_next = 0;
- else
- do_next = process_command_old(vid_buf, pch, console_error);
- }
- else if(strcmp(pch,"endif")==0 || strcmp(pch,"else")==0)
- do_next = 1;
- 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
- {
- sprintf(console_error, "Scripts are not enabled");
- }
-
- }
- else if(strcmp(console2, "sound")==0 && console3[0])
- {
- if (sound_enable) play_sound(console3);
- else strcpy(console_error, "Audio device not available - cannot play sounds");
- }
- else if(strcmp(console2, "python")==0)
- if(pygood==1)
- pyready=1;
- else
- strcpy(console_error, "python not ready. check stdout for more info.");
- else if(strcmp(console2, "load")==0 && console3[0])
- {
- j = atoi(console3);
- if(j)
- {
- open_ui(vid_buf, console3, NULL);
- console_mode = 0;
- }
- }
- else if(strcmp(console2, "if")==0 && console3[0])
- {
- if(strcmp(console3, "type")==0)//TODO: add more than just type, and be able to check greater/less than
- {
- if (console_parse_partref(console4, &i, console_error)
- && console_parse_type(console5, &j, console_error))
- {
- if(parts[i].type==j)
- return 1;
- else
- return 0;
- }
- else
- return 0;
- }
- }
- else if (strcmp(console2, "create")==0 && console3[0] && console4[0])
- {
- 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[0])
- {
- if (console_parse_partref(console3, &i, console_error))
- kill_part(i);
- }
- else if(strcmp(console2, "reset")==0 && console3[0])
- {
- 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[0] && console4[0] && console5[0])
- {
- 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_type(console4, &j, console_error))
- {
- k = atoi(console5);
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].life = k;
- }
- }
- 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_type(console4, &j, console_error)
- && console_parse_type(console5, &k, console_error))
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].type = k;
- }
- }
- 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)
- {
- f = atof(console5);
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type)
- parts[i].temp = f;
- }
- }
- else if (console_parse_type(console4, &j, console_error))
- {
- f = atof(console5);
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].temp= f;
- }
- }
- else
- {
- if (console_parse_partref(console4, &i, console_error))
- {
- f = atof(console5);
- parts[i].temp = f;
- }
- }
- }
- 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_type(console4, &j, console_error))
- {
- k = atoi(console5);
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].tmp = k;
- }
- }
- 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_type(console4, &j, console_error))
- {
- k = atoi(console5);
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].x = k;
- }
- }
- 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_type(console4, &j, console_error))
- {
- k = atoi(console5);
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].y = k;
- }
- }
- 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_type(console4, &j, console_error)
- && console_parse_type(console5, &k, console_error))
- {
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].ctype = k;
- }
- }
- 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)
- {
- f = atof(console5);
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type)
- parts[i].vx = f;
- }
- }
- else if (console_parse_type(console4, &j, console_error))
- {
+ int y,x,nx,ny,i,j,k,m;
+ float f;
+ int do_next = 1;
+ char xcoord[10] = "";
+ char ycoord[10] = "";
+ char console2[15] = "";
+ char console3[15] = "";
+ char console4[15] = "";
+ char console5[15] = "";
+ //sprintf(console_error, "%s", console);
+ if (console && strcmp(console, "")!=0 && strncmp(console, " ", 1)!=0)
+ {
+ sscanf(console,"%14s %14s %14s %14s", console2, console3, console4, console5);//why didn't i know about this function?!
+ if (strcmp(console2, "quit")==0)
+ {
+ return -1;
+ }
+ else if (strcmp(console2, "file")==0 && console3[0])
+ {
+ if (file_script) {
+ FILE *f=fopen(console3, "r");
+ if (f)
+ {
+ char fileread[5000];//TODO: make this change with file size
+ char pch[5000];
+ char tokens[10];
+ int tokensize;
+ nx = 0;
+ ny = 0;
+ j = 0;
+ m = 0;
+ if (console4[0])
+ console_parse_coords(console4, &nx , &ny, console_error);
+ memset(pch,0,sizeof(pch));
+ memset(fileread,0,sizeof(fileread));
+ fread(fileread,1,5000,f);
+ for (i=0; i<strlen(fileread); i++)
+ {
+ if (fileread[i] != '\n')
+ {
+ pch[i-j] = fileread[i];
+ if (fileread[i] != ' ')
+ tokens[i-m] = fileread[i];
+ }
+ if (fileread[i] == ' ' || fileread[i] == '\n')
+ {
+ if (sregexp(tokens,"^x.[0-9],y.[0-9]")==0)//TODO: fix regex matching to work with x,y ect, right now it has to have a +0 or -0
+ {
+ char temp[5];
+ int starty = 0;
+ tokensize = strlen(tokens);
+ x = 0;
+ y = 0;
+ sscanf(tokens,"x%d,y%d",&x,&y);
+ sscanf(tokens,"%9s,%9s",xcoord,ycoord);
+ x += nx;
+ y += ny;
+ sprintf(xcoord,"%d",x);
+ sprintf(ycoord,"%d",y);
+ for (k = 0; k<strlen(xcoord); k++)//rewrite pch with numbers
+ {
+ pch[i-j-tokensize+k] = xcoord[k];
+ starty = k+1;
+ }
+ pch[i-j-tokensize+starty] = ',';
+ starty++;
+ for (k=0; k<strlen(ycoord); k++)
+ {
+ pch[i-j-tokensize+starty+k] = ycoord[k];
+
+ }
+ pch[i-j-tokensize +strlen(xcoord) +1 +strlen(ycoord)] = ' ';
+ j = j -tokensize +strlen(xcoord) +1 +strlen(ycoord);
+ }
+ memset(tokens,0,sizeof(tokens));
+ m = i+1;
+ }
+ if (fileread[i] == '\n')
+ {
+
+ if (do_next)
+ {
+ if (strcmp(pch,"else")==0)
+ do_next = 0;
+ else
+ do_next = process_command_old(vid_buf, pch, console_error);
+ }
+ else if (strcmp(pch,"endif")==0 || strcmp(pch,"else")==0)
+ do_next = 1;
+ 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
+ {
+ sprintf(console_error, "Scripts are not enabled");
+ }
+
+ }
+ else if (strcmp(console2, "sound")==0 && console3[0])
+ {
+ if (sound_enable) play_sound(console3);
+ else strcpy(console_error, "Audio device not available - cannot play sounds");
+ }
+ else if (strcmp(console2, "python")==0)
+ if (pygood==1)
+ pyready=1;
+ else
+ strcpy(console_error, "python not ready. check stdout for more info.");
+ else if (strcmp(console2, "load")==0 && console3[0])
+ {
+ j = atoi(console3);
+ if (j)
+ {
+ open_ui(vid_buf, console3, NULL);
+ console_mode = 0;
+ }
+ }
+ else if (strcmp(console2, "if")==0 && console3[0])
+ {
+ if (strcmp(console3, "type")==0)//TODO: add more than just type, and be able to check greater/less than
+ {
+ if (console_parse_partref(console4, &i, console_error)
+ && console_parse_type(console5, &j, console_error))
+ {
+ if (parts[i].type==j)
+ return 1;
+ else
+ return 0;
+ }
+ else
+ return 0;
+ }
+ }
+ else if (strcmp(console2, "create")==0 && console3[0] && console4[0])
+ {
+ 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[0])
+ {
+ if (console_parse_partref(console3, &i, console_error))
+ kill_part(i);
+ }
+ else if (strcmp(console2, "reset")==0 && console3[0])
+ {
+ 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[0] && console4[0] && console5[0])
+ {
+ 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_type(console4, &j, console_error))
+ {
+ k = atoi(console5);
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].life = k;
+ }
+ }
+ 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_type(console4, &j, console_error)
+ && console_parse_type(console5, &k, console_error))
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].type = k;
+ }
+ }
+ 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)
+ {
+ f = atof(console5);
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].temp = f;
+ }
+ }
+ else if (console_parse_type(console4, &j, console_error))
+ {
+ f = atof(console5);
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].temp= f;
+ }
+ }
+ else
+ {
+ if (console_parse_partref(console4, &i, console_error))
+ {
+ f = atof(console5);
+ parts[i].temp = f;
+ }
+ }
+ }
+ 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_type(console4, &j, console_error))
+ {
+ k = atoi(console5);
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].tmp = k;
+ }
+ }
+ 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_type(console4, &j, console_error))
+ {
+ k = atoi(console5);
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].x = k;
+ }
+ }
+ 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_type(console4, &j, console_error))
+ {
+ k = atoi(console5);
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].y = k;
+ }
+ }
+ 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_type(console4, &j, console_error)
+ && console_parse_type(console5, &k, console_error))
+ {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].ctype = k;
+ }
+ }
+ 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)
+ {
f = atof(console5);
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].vx = f;
- }
- }
- else
- {
- if (console_parse_partref(console4, &i, console_error))
- {
- f = atof(console5);
- parts[i].vx = f;
- }
- }
- }
- if(strcmp(console3, "vy")==0)
- {
- if(strcmp(console4, "all")==0)
- {
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].vx = f;
+ }
+ }
+ else if (console_parse_type(console4, &j, console_error))
+ {
f = atof(console5);
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type)
- parts[i].vy = f;
- }
- }
- else if (console_parse_type(console4, &j, console_error))
- {
- f = atof(console5);
- for(i=0; i<NPART; i++)
- {
- if(parts[i].type == j)
- parts[i].vy = f;
- }
- }
- else
- {
- if (console_parse_partref(console4, &i, console_error))
- {
- f = atof(console5);
- parts[i].vy = f;
- }
- }
- }
- }
- else
- strcpy(console_error, "Invalid Command");
- }
- return 1;
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].vx = f;
+ }
+ }
+ else
+ {
+ if (console_parse_partref(console4, &i, console_error))
+ {
+ f = atof(console5);
+ parts[i].vx = f;
+ }
+ }
+ }
+ if (strcmp(console3, "vy")==0)
+ {
+ if (strcmp(console4, "all")==0)
+ {
+ f = atof(console5);
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type)
+ parts[i].vy = f;
+ }
+ }
+ else if (console_parse_type(console4, &j, console_error))
+ {
+ f = atof(console5);
+ for (i=0; i<NPART; i++)
+ {
+ if (parts[i].type == j)
+ parts[i].vy = f;
+ }
+ }
+ else
+ {
+ if (console_parse_partref(console4, &i, console_error))
+ {
+ f = atof(console5);
+ parts[i].vy = f;
+ }
+ }
+ }
+ }
+ else
+ strcpy(console_error, "Invalid Command");
+ }
+ return 1;
}
diff --git a/src/misc.c b/src/misc.c
index 784edbe..09d50f2 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -128,7 +128,7 @@ int sregexp(const char *str, char *pattern)
{
int result;
regex_t patternc;
- if(regcomp(&patternc, pattern, 0)!=0)
+ if (regcomp(&patternc, pattern, 0)!=0)
return 1;
result = regexec(&patternc, str, 0, NULL, 0);
regfree(&patternc);
@@ -164,7 +164,7 @@ void load_presets(void)
remove("powder.def");
return;
}
- if(sig[3]==0x66){
+ if (sig[3]==0x66) {
if (load_string(f, svf_user, 63))
goto fail;
if (load_string(f, svf_pass, 63))
@@ -378,32 +378,32 @@ vector2d v2d_new(float x, float y)
void clipboard_push_text(char * text)
{
#ifdef MACOSX
- PasteboardRef newclipboard;
-
- if(PasteboardCreate(kPasteboardClipboard, &newclipboard)!=noErr) return;
- if(PasteboardClear(newclipboard)!=noErr) return;
+ PasteboardRef newclipboard;
+
+ if (PasteboardCreate(kPasteboardClipboard, &newclipboard)!=noErr) return;
+ if (PasteboardClear(newclipboard)!=noErr) return;
PasteboardSynchronize(newclipboard);
-
+
CFDataRef data = CFDataCreate(kCFAllocatorDefault, text, strlen(text));
- PasteboardPutItemFlavor(newclipboard, (PasteboardItemID)1, CFSTR("com.apple.traditional-mac-plain-text"), data, 0);
+ PasteboardPutItemFlavor(newclipboard, (PasteboardItemID)1, CFSTR("com.apple.traditional-mac-plain-text"), data, 0);
#elif defined WIN32
- if(OpenClipboard(NULL))
+ if (OpenClipboard(NULL))
{
HGLOBAL cbuffer;
char * glbuffer;
-
+
EmptyClipboard();
-
+
cbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(text)+1);
glbuffer = (char*)GlobalLock(cbuffer);
-
+
strcpy(glbuffer, text);
-
+
GlobalUnlock(cbuffer);
SetClipboardData(CF_TEXT, cbuffer);
CloseClipboard();
}
-#else
+#else
printf("Not implemented: put text on clipboard \"%s\"\n", text);
#endif
}
@@ -429,55 +429,55 @@ int register_extension()
opencommand = malloc(strlen(currentfilename)+13);
sprintf(iconname, "%s,-102", currentfilename);
sprintf(opencommand, "\"%s\" open:\"%%1\"", currentfilename);
-
+
//Create extension entry
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\.cps", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
- if(rresult != ERROR_SUCCESS){
+ if (rresult != ERROR_SUCCESS) {
return 0;
}
rresult = RegSetValueEx(newkey, 0, 0, REG_SZ, (LPBYTE)"PowderToySave", strlen("PowderToySave")+1);
- if(rresult != ERROR_SUCCESS){
+ if (rresult != ERROR_SUCCESS) {
RegCloseKey(newkey);
return 0;
}
RegCloseKey(newkey);
-
+
//Create program entry
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\PowderToySave", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
- if(rresult != ERROR_SUCCESS){
+ if (rresult != ERROR_SUCCESS) {
return 0;
}
rresult = RegSetValueEx(newkey, 0, 0, REG_SZ, (LPBYTE)"Powder Toy Save", strlen("Powder Toy Save")+1);
- if(rresult != ERROR_SUCCESS){
+ if (rresult != ERROR_SUCCESS) {
RegCloseKey(newkey);
return 0;
}
RegCloseKey(newkey);
-
+
//Set DefaultIcon
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\PowderToySave\\DefaultIcon", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
- if(rresult != ERROR_SUCCESS){
+ if (rresult != ERROR_SUCCESS) {
return 0;
}
rresult = RegSetValueEx(newkey, 0, 0, REG_SZ, (LPBYTE)iconname, strlen(iconname)+1);
- if(rresult != ERROR_SUCCESS){
+ if (rresult != ERROR_SUCCESS) {
RegCloseKey(newkey);
return 0;
}
RegCloseKey(newkey);
-
+
//Set Launch command
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\PowderToySave\\shell\\open\\command", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
- if(rresult != ERROR_SUCCESS){
+ if (rresult != ERROR_SUCCESS) {
return 0;
}
rresult = RegSetValueEx(newkey, 0, 0, REG_SZ, (LPBYTE)opencommand, strlen(opencommand)+1);
- if(rresult != ERROR_SUCCESS){
+ if (rresult != ERROR_SUCCESS) {
RegCloseKey(newkey);
return 0;
}
RegCloseKey(newkey);
-
+
return 1;
#elif defined LIN32
return 0;
diff --git a/src/powder.c b/src/powder.c
index deacfed..00ea068 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -13,7 +13,7 @@ particle *parts;
particle *cb_parts;
int gravityMode = 0; // starts enabled in "vertical" mode...
-int airMode = 0;
+int airMode = 0;
unsigned char bmap[YRES/CELL][XRES/CELL];
@@ -79,7 +79,7 @@ int eval_move(int pt, int nx, int ny, unsigned *rr)
if ((r&0xFF)==PT_VOID || (r&0xFF)==PT_BHOL)
return 1;
- if(pt==PT_SPRK)//spark shouldn't move
+ if (pt==PT_SPRK)//spark shouldn't move
return 0;
if (pt==PT_PHOT&&(
@@ -200,7 +200,7 @@ int try_move(int i, int x, int y, int nx, int ny)
}
return 1;
}
- //else e=1 , we are trying to swap the particles, return 0 no swap/move, 1 is still overlap/move, because the swap takes place later
+ //else e=1 , we are trying to swap the particles, return 0 no swap/move, 1 is still overlap/move, because the swap takes place later
if ((r&0xFF)==PT_VOID) //this is where void eats particles
{
@@ -702,8 +702,8 @@ inline int create_part(int p, int x, int y, int t)//the function for creating a
}
if (ptypes[t].properties&PROP_LIFE) {
int r;
- for(r = 0; r<NGOL; r++)
- if(t==goltype[r])
+ for (r = 0; r<NGOL; r++)
+ if (t==goltype[r])
parts[i].tmp = grule[r+1][9] - 1;
}
if (t==PT_DEUT)
@@ -1313,7 +1313,7 @@ void update_particles_i(pixel *vid, int start, int inc)
for ( golnum=1; golnum<=NGOL; golnum++)
if (parts[r>>8].type==goltype[golnum-1])
{
- if(parts[r>>8].tmp == grule[golnum][9]-1) {
+ if (parts[r>>8].tmp == grule[golnum][9]-1) {
gol[nx][ny] = golnum;
for ( nnx=-1; nnx<2; nnx++)
for ( nny=-1; nny<2; nny++)//it will count itself as its own neighbor, which is needed, but will have 1 extra for delete check
@@ -1327,7 +1327,7 @@ void update_particles_i(pixel *vid, int start, int inc)
}
} else {
parts[r>>8].tmp --;
- if(parts[r>>8].tmp<=0)
+ if (parts[r>>8].tmp<=0)
parts[r>>8].type = PT_NONE;//using kill_part makes it not work
}
}
@@ -1337,25 +1337,25 @@ void update_particles_i(pixel *vid, int start, int inc)
{
r = pmap[ny][nx];
neighbors = gol2[nx][ny][0];
- if(neighbors==0 || !(ptypes[r&0xFF].properties&PROP_LIFE || !(r&0xFF)) || (r>>8)>=NPART)
+ if (neighbors==0 || !(ptypes[r&0xFF].properties&PROP_LIFE || !(r&0xFF)) || (r>>8)>=NPART)
continue;
for ( golnum = 1; golnum<=NGOL; golnum++)
+ {
+ goldelete = neighbors;
+ if (gol[nx][ny]==0&&grule[golnum][goldelete]>=2&&gol2[nx][ny][golnum]>=(goldelete%2)+goldelete/2)
{
- goldelete = neighbors;
- if (gol[nx][ny]==0&&grule[golnum][goldelete]>=2&&gol2[nx][ny][golnum]>=(goldelete%2)+goldelete/2)
- {
- if (create_part(-1,nx,ny,goltype[golnum-1]))
- createdsomething = 1;
- }
- else if (gol[nx][ny]==golnum&&(grule[golnum][goldelete-1]==0||grule[golnum][goldelete-1]==2))//subtract 1 because it counted itself
- {
- if(parts[r>>8].tmp==grule[golnum][9]-1)
- parts[r>>8].tmp --;
- }
- if (r && parts[r>>8].tmp<=0)
- parts[r>>8].type = PT_NONE;//using kill_part makes it not work
+ if (create_part(-1,nx,ny,goltype[golnum-1]))
+ createdsomething = 1;
+ }
+ else if (gol[nx][ny]==golnum&&(grule[golnum][goldelete-1]==0||grule[golnum][goldelete-1]==2))//subtract 1 because it counted itself
+ {
+ if (parts[r>>8].tmp==grule[golnum][9]-1)
+ parts[r>>8].tmp --;
}
- for( z = 0;z<=NGOL;z++)
+ if (r && parts[r>>8].tmp<=0)
+ parts[r>>8].type = PT_NONE;//using kill_part makes it not work
+ }
+ for ( z = 0; z<=NGOL; z++)
gol2[nx][ny][z] = 0;//this improves performance A LOT compared to the memset, i was getting ~23 more fps with this.
}
if (createdsomething)
@@ -1450,18 +1450,18 @@ void update_particles_i(pixel *vid, int start, int inc)
//Gravity mode by Moach
switch (gravityMode)
{
- default:
- case 0:
- pGravX = 0.0f;
- pGravY = ptypes[t].gravity;
- break;
- case 1:
- pGravX = pGravY = 0.0f;
- break;
- case 2:
- pGravD = 0.01f - hypotf((x - XCNTR), (y - YCNTR));
- pGravX = ptypes[t].gravity * ((float)(x - XCNTR) / pGravD);
- pGravY = ptypes[t].gravity * ((float)(y - YCNTR) / pGravD);
+ default:
+ case 0:
+ pGravX = 0.0f;
+ pGravY = ptypes[t].gravity;
+ break;
+ case 1:
+ pGravX = pGravY = 0.0f;
+ break;
+ case 2:
+ pGravD = 0.01f - hypotf((x - XCNTR), (y - YCNTR));
+ pGravX = ptypes[t].gravity * ((float)(x - XCNTR) / pGravD);
+ pGravY = ptypes[t].gravity * ((float)(y - YCNTR) / pGravD);
}
//velocity updates for the particle
parts[i].vx *= ptypes[t].loss;
@@ -2704,9 +2704,9 @@ int flood_parts(int x, int y, int c, int cm, int bm)
// fill span
for (x=x1; x<=x2; x++)
{
- if(cm==PT_INST&&co==PT_SPRK)
+ if (cm==PT_INST&&co==PT_SPRK)
{
- if(create_part(-1,x, y, co)==-1)
+ if (create_part(-1,x, y, co)==-1)
return 0;
}
else if (!create_parts(x, y, 0, 0, co))
@@ -2864,7 +2864,7 @@ int create_parts(int x, int y, int rx, int ry, int c)
for (i=-rx; i<=rx; i++)
if ((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
{
- if( x+i<0 || y+j<0 || x+i>=XRES || y+j>=YRES)
+ if ( x+i<0 || y+j<0 || x+i>=XRES || y+j>=YRES)
continue;
if (!REPLACE_MODE)
create_part(-2, x+i, y+j, c);
@@ -2910,7 +2910,7 @@ int create_parts(int x, int y, int rx, int ry, int c)
for (i=-rx; i<=rx; i++)
if ((CURRENT_BRUSH==CIRCLE_BRUSH && (pow(i,2))/(pow(rx,2))+(pow(j,2))/(pow(ry,2))<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx))
{
- if( x+i<0 || y+j<0 || x+i>=XRES || y+j>=YRES)
+ if ( x+i<0 || y+j<0 || x+i>=XRES || y+j>=YRES)
continue;
if ((pmap[y+j][x+i]&0xFF)!=SLALT&&SLALT!=0)
continue;
@@ -3026,7 +3026,7 @@ void *transform_save(void *odata, int *size, matrix2d transform, vector2d transl
cornerso[1] = v2d_new(w-1,0);
cornerso[2] = v2d_new(0,h-1);
cornerso[3] = v2d_new(w-1,h-1);
- for (i=0;i<4;i++)
+ for (i=0; i<4; i++)
{
tmp = m2d_multiply_v2d(transform,cornerso[i]);
if (i==0) ctl = cbr = tmp; // top left, bottom right corner
@@ -3073,8 +3073,8 @@ void *transform_save(void *odata, int *size, matrix2d transform, vector2d transl
partst[i].x = nx;
partst[i].y = ny;
}
- for (y=0;y<YRES/CELL;y++)
- for (x=0;x<XRES/CELL;x++)
+ for (y=0; y<YRES/CELL; y++)
+ for (x=0; x<XRES/CELL; x++)
{
pos = v2d_new(x*CELL+CELL*0.4f, y*CELL+CELL*0.4f);
pos = v2d_add(m2d_multiply_v2d(transform,pos),translate);
@@ -3107,7 +3107,7 @@ inline void orbitalparts_get(int block1, int block2, int resblock1[], int resblo
resblock1[1] = (block1&0x0000FF00)>>8;
resblock1[2] = (block1&0x00FF0000)>>16;
resblock1[3] = (block1&0xFF000000)>>24;
-
+
resblock2[0] = (block2&0x000000FF);
resblock2[1] = (block2&0x0000FF00)>>8;
resblock2[2] = (block2&0x00FF0000)>>16;
@@ -3122,17 +3122,17 @@ inline void orbitalparts_set(int *block1, int *block2, int resblock1[], int resb
{
int block1tmp = 0;
int block2tmp = 0;
-
+
block1tmp = (resblock1[0]&0xFF);
block1tmp |= (resblock1[1]&0xFF)<<8;
block1tmp |= (resblock1[2]&0xFF)<<16;
block1tmp |= (resblock1[3]&0xFF)<<24;
-
+
block2tmp = (resblock2[0]&0xFF);
block2tmp |= (resblock2[1]&0xFF)<<8;
block2tmp |= (resblock2[2]&0xFF)<<16;
block2tmp |= (resblock2[3]&0xFF)<<24;
-
+
*block1 = block1tmp;
*block2 = block2tmp;
}