summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacksonmj <jacksonmj@jacksonmj.none>2011-01-15 16:23:51 (GMT)
committer jacksonmj <jacksonmj@jacksonmj.none>2011-01-15 16:23:51 (GMT)
commit1833be451f1bb57b6b0f2709a4c98da9356542d4 (patch)
tree18f0aabdef426e33c6428e5af9a15c3de138ae9a /src
parentc7213127e52b0484b9b4b87fd57877ff0c523a59 (diff)
parent2d79fa5cfe104e6067818f13e3486ca45fe23815 (diff)
downloadpowder-1833be451f1bb57b6b0f2709a4c98da9356542d4.zip
powder-1833be451f1bb57b6b0f2709a4c98da9356542d4.tar.gz
Merge branch 'cracker64' into dev
Conflicts: includes/powder.h src/graphics.c src/main.c src/powder.c
Diffstat (limited to 'src')
-rw-r--r--src/graphics.c32
-rw-r--r--src/main.c18
-rw-r--r--src/powder.c76
3 files changed, 108 insertions, 18 deletions
diff --git a/src/graphics.c b/src/graphics.c
index b541711..06cd6fb 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -1667,7 +1667,7 @@ void draw_parts(pixel *vid)
}
else if (t==PT_QRTZ || t==PT_PQRT)
{
- int z = parts[i].tmp;
+ int z = parts[i].tmp - 5;
if (parts[i].temp>(ptransitions[t].thv-800.0f))
{
float frequency = 3.1415/(2*ptransitions[t].thv-(ptransitions[t].thv-800.0f));
@@ -1834,6 +1834,36 @@ void draw_parts(pixel *vid)
}
}
}
+ else if (t==PT_PRTI && DEBUG_MODE)
+ {
+ blendpixel(vid,nx,ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors),255);
+ if (mousex==(nx) && mousey==(ny))
+ {
+ int z;
+ for (z = 0; z<NPART; z++) {
+ if (parts[z].type)
+ {
+ if (parts[z].type==PT_PRTO&&parts[z].tmp==parts[i].tmp)
+ xor_line(nx,ny,(int)(parts[z].x+0.5f),(int)(parts[z].y+0.5f),vid);
+ }
+ }
+ }
+ }
+ else if (t==PT_PRTO && DEBUG_MODE)
+ {
+ blendpixel(vid,nx,ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors),255);
+ if (mousex==(nx) && mousey==(ny))
+ {
+ int z;
+ for (z = 0; z<NPART; z++) {
+ if (parts[z].type)
+ {
+ if (parts[z].type==PT_PRTI&&parts[z].tmp==parts[i].tmp)
+ xor_line(nx,ny,(int)(parts[z].x+0.5f),(int)(parts[z].y+0.5f),vid);
+ }
+ }
+ }
+ }
else if ((t==PT_BIZR||t==PT_BIZRG)&&parts[i].ctype)
{
cg = 0;
diff --git a/src/main.c b/src/main.c
index 3f49df6..6663e99 100644
--- a/src/main.c
+++ b/src/main.c
@@ -732,7 +732,11 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
if (new_format) {
ttv = (d[p++])<<8;
ttv |= (d[p++]);
- parts[i-1].temp = ttv + 0.15;
+ if (parts[i-1].type==PT_PUMP) {
+ parts[i-1].temp = ttv + 0.15;//fix PUMP saved at 0, so that it loads at 0.
+ } else {
+ parts[i-1].temp = ttv;
+ }
} else {
parts[i-1].temp = (d[p++]*((MAX_TEMP+(-MIN_TEMP))/255))+MIN_TEMP;
}
@@ -1688,7 +1692,11 @@ int main(int argc, char *argv[])
if (y>0 && y<sdl_scale*YRES && x>0 && x<sdl_scale*XRES)
{
int cr;
- cr = pmap[y/sdl_scale][x/sdl_scale];
+ if (photons[y/sdl_scale][x/sdl_scale]) {
+ cr = photons[y/sdl_scale][x/sdl_scale];
+ } else {
+ cr = pmap[y/sdl_scale][x/sdl_scale];
+ }
if (!((cr>>8)>=NPART || !cr))
{
#ifdef BETA
@@ -2075,6 +2083,10 @@ int main(int argc, char *argv[])
if (x>=19 && x<=35 && svf_last && svf_open && !bq) {
//int tpval = sys_pause;
parse_save(svf_last, svf_lsize, 1, 0, 0);
+ for (j= 0; j<99; j++) { //reset wifi on reload
+ wireless[j][0] = 0;
+ wireless[j][1] = 0;
+ }
//sys_pause = tpval;
}
if (x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq)
@@ -2161,6 +2173,8 @@ int main(int argc, char *argv[])
c = 0;
if (c!=WL_STREAM+100&&c!=SPC_AIR&&c!=SPC_HEAT&&c!=SPC_COOL&&c!=SPC_VACUUM&&!REPLACE_MODE)
flood_parts(x, y, c, -1, -1);
+ if (c==SPC_HEAT || c==SPC_COOL)
+ create_parts(x, y, bsx, bsy, c);
lx = x;
ly = y;
lb = 0;
diff --git a/src/powder.c b/src/powder.c
index 09c21ff..3578154 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -24,6 +24,7 @@ int pfree;
unsigned pmap[YRES][XRES];
unsigned cb_pmap[YRES][XRES];
+unsigned photons[YRES][XRES];
static int pn_junction_sprk(int x, int y, int pt)
{
@@ -33,6 +34,8 @@ static int pn_junction_sprk(int x, int y, int pt)
r >>= 8;
if (parts[r].type != pt)
return 0;
+ if (parts[r].life != 0)
+ return 0;
parts[r].ctype = pt;
parts[r].type = PT_SPRK;
@@ -147,7 +150,7 @@ int try_move(int i, int x, int y, int nx, int ny)
if (!e)
{
- if (!legacy_enable && parts[i].type==PT_PHOT)
+ if (!legacy_enable && parts[i].type==PT_PHOT && r)
{
if ((r & 0xFF) == PT_COAL || (r & 0xFF) == PT_BCOL)
parts[r>>8].temp = parts[i].temp;
@@ -266,7 +269,7 @@ static unsigned direction_to_map(float dx, float dy, int t)
// For now, don't add them.
// Solution may involve more intelligent setting of initial i0 value in find_next_boundary?
// or rewriting normal/boundary finding code
-
+
return (dx >= 0) |
(((dx + dy) >= 0) << 1) | /* 567 */
((dy >= 0) << 2) | /* 4+0 */
@@ -514,17 +517,23 @@ inline int create_part(int p, int x, int y, int t)
{
if (t==SPC_HEAT&&parts[pmap[y][x]>>8].temp<MAX_TEMP)
{
- if ((pmap[y][x]&0xFF)==PT_PUMP)
+ if ((pmap[y][x]&0xFF)==PT_PUMP) {
parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 0.1f, MIN_TEMP, MAX_TEMP);
- else
+ } else if ((sdl_mod & (KMOD_SHIFT)) && (sdl_mod & (KMOD_CTRL))) {
+ parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 50.0f, MIN_TEMP, MAX_TEMP);
+ } else {
parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp + 4.0f, MIN_TEMP, MAX_TEMP);
+ }
}
if (t==SPC_COOL&&parts[pmap[y][x]>>8].temp>MIN_TEMP)
{
- if ((pmap[y][x]&0xFF)==PT_PUMP)
+ if ((pmap[y][x]&0xFF)==PT_PUMP) {
parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 0.1f, MIN_TEMP, MAX_TEMP);
- else
+ } else if ((sdl_mod & (KMOD_SHIFT)) && (sdl_mod & (KMOD_CTRL))) {
+ parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 50.0f, MIN_TEMP, MAX_TEMP);
+ } else {
parts[pmap[y][x]>>8].temp = restrict_flt(parts[pmap[y][x]>>8].temp - 4.0f, MIN_TEMP, MAX_TEMP);
+ }
}
return pmap[y][x]>>8;
}
@@ -603,6 +612,8 @@ inline int create_part(int p, int x, int y, int t)
}
}
}
+ if (photons[y][x] && t==PT_PHOT)
+ return -1;
if (pfree == -1)
return -1;
i = pfree;
@@ -618,6 +629,8 @@ inline int create_part(int p, int x, int y, int t)
}
return -1;
}
+ if (photons[y][x] && t==PT_PHOT)
+ return -1;
if (pfree == -1)
return -1;
i = pfree;
@@ -671,9 +684,9 @@ inline int create_part(int p, int x, int y, int t)
if (t==PT_SING)
parts[i].life = rand()%50+60;
if (t==PT_QRTZ)
- parts[i].tmp = (rand()%11) -5;
+ parts[i].tmp = (rand()%11);
if (t==PT_PQRT)
- parts[i].tmp = (rand()%11) -5;
+ parts[i].tmp = (rand()%11);
if (t==PT_FSEP)
parts[i].life = 50;
if (t==PT_COAL) {
@@ -718,6 +731,8 @@ inline int create_part(int p, int x, int y, int t)
parts[i].vx = 3.0f*cosf(a);
parts[i].vy = 3.0f*sinf(a);
}
+ if (t==PT_PHOT)
+ photons[y][x] = t|(i<<8);
if (t==PT_STKM)
{
if (isplayer==0)
@@ -940,7 +955,12 @@ inline void delete_part(int x, int y)
if (x<0 || y<0 || x>=XRES || y>=YRES)
return;
- i = pmap[y][x];
+ if (photons[y][x]) {
+ i = photons[y][x];
+ } else {
+ i = pmap[y][x];
+ }
+
if (!i || (i>>8)>=NPART)
return;
if ((parts[i>>8].type==SLALT)||SLALT==0)
@@ -2013,6 +2033,7 @@ void update_particles(pixel *vid)
isplayer = 0; //Needed for player spawning
isplayer2 = 0;
memset(pmap, 0, sizeof(pmap));
+ memset(photons, 0, sizeof(photons));
r = rand()%2;
NUM_PARTS = 0;
for (j=0; j<NPART; j++)
@@ -2027,6 +2048,8 @@ void update_particles(pixel *vid)
if (t!=PT_NEUT || (pmap[y][x]&0xFF)!=PT_GLAS)
pmap[y][x] = t|(i<<8);
}
+ if (t==PT_PHOT)
+ photons[y][x] = t|(i<<8);
NUM_PARTS ++;
}
else
@@ -2546,16 +2569,25 @@ void rotate_area(int area_x, int area_y, int area_w, int area_h, int invert)
unsigned rtpmap[area_w][area_h];
unsigned char tbmap[area_h/CELL][area_w/CELL];
unsigned char rtbmap[area_w/CELL][area_h/CELL];
+ float tfvy[area_h/CELL][area_w/CELL];
+ float tfvx[area_h/CELL][area_w/CELL];
for (cy=0; cy<area_h; cy++)
{
for (cx=0; cx<area_w; cx++)//save walls to temp
{
if (area_x + cx<XRES&&area_y + cy<YRES)
{
- if (bmap[(cy+area_y)/CELL][(cx+area_x)/CELL])
+ if (bmap[(cy+area_y)/CELL][(cx+area_x)/CELL]) {
tbmap[cy/CELL][cx/CELL] = bmap[(cy+area_y)/CELL][(cx+area_x)/CELL];
- else
+ if (bmap[(cy+area_y)/CELL][(cx+area_x)/CELL]==WL_FAN) {
+ tfvx[cy/CELL][cx/CELL] = fvx[(cy+area_y)/CELL][(cx+area_x)/CELL];
+ tfvy[cy/CELL][cx/CELL] = fvy[(cy+area_y)/CELL][(cx+area_x)/CELL];
+ }
+ } else {
tbmap[cy/CELL][cx/CELL] = 0;
+ tfvx[cy/CELL][cx/CELL] = 0;
+ tfvy[cy/CELL][cx/CELL] = 0;
+ }
}
}
}
@@ -2579,11 +2611,15 @@ void rotate_area(int area_x, int area_y, int area_w, int area_h, int invert)
{
rtbmap[cy/CELL][((area_h-1)-cx)/CELL] = tbmap[cy/CELL][cx/CELL];
rtpmap[cy][(area_h-1)-cx] = tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)];
+ tfvx[cy/CELL][((area_h-1)-cx)/CELL] = -tfvx[cy/CELL][cx/CELL];
+ tfvy[cy/CELL][((area_h-1)-cx)/CELL] = tfvy[cy/CELL][cx/CELL];
}
else
{
rtbmap[((area_h-1)-cx)/CELL][cy/CELL] = tbmap[cy/CELL][cx/CELL];
rtpmap[(area_h-1)-cx][cy] = tpmap[(int)(cy+0.5f)][(int)(cx+0.5f)];
+ tfvy[((area_h-1)-cx)/CELL][cy/CELL] = -tfvx[cy/CELL][cx/CELL];
+ tfvx[((area_h-1)-cx)/CELL][cy/CELL] = tfvy[cy/CELL][cx/CELL];
}
}
}
@@ -2599,6 +2635,8 @@ void rotate_area(int area_x, int area_y, int area_w, int area_h, int invert)
parts[rtpmap[(int)(cy+0.5f)][(int)(cx+0.5f)]>>8].y = area_y +cy;
}
bmap[(area_y+cy)/CELL][(area_x+cx)/CELL] = rtbmap[cy/CELL][cx/CELL];
+ fvy[(area_y+cy)/CELL][(area_x+cx)/CELL] = tfvy[cy/CELL][cx/CELL];
+ fvx[(area_y+cy)/CELL][(area_x+cx)/CELL] = tfvx[cy/CELL][cx/CELL];
}
}
}
@@ -2642,13 +2680,13 @@ void create_box(int x1, int y1, int x2, int y2, int c)
int flood_parts(int x, int y, int c, int cm, int bm)
{
int x1, x2, dy = (c<PT_NUM)?1:CELL;
- int co = c;
+ int co = c, wall;
if (cm==PT_INST&&co==PT_SPRK)
if ((pmap[y][x]&0xFF)==PT_SPRK)
return 0;
if (c>=UI_WALLSTART&&c<=UI_WALLSTART+UI_WALLCOUNT)
{
- c = c-100;
+ wall = c-100;
}
if (cm==-1)
{
@@ -2665,7 +2703,7 @@ int flood_parts(int x, int y, int c, int cm, int bm)
}
if (bm==-1)
{
- if (c==WL_ERASE)
+ if (wall==WL_ERASE)
{
bm = bmap[y/CELL][x/CELL];
if (!bm)
@@ -2876,7 +2914,15 @@ int create_parts(int x, int y, int rx, int ry, int c)
{
if (rx==0&&ry==0)
{
- create_part(-2, x, y, c);
+ if ((pmap[y][x]&0xFF)==SLALT || SLALT==0)
+ {
+ if ((pmap[y][x]))
+ {
+ delete_part(x, y);
+ if (c!=0)
+ create_part(-2, x, y, c);
+ }
+ }
}
else
for (j=-ry; j<=ry; j++)