From 7c123cdb00427c8a1b0070c134cf17d2f8b313ee Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Fri, 18 Feb 2011 08:03:14 +0800 Subject: [PATCH 1/7] NEUT fixed to dust and fwrk reaction. --- src/elements/neut.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/elements/neut.c b/src/elements/neut.c index aa3ddf0d5..a97701dc4 100644 --- a/src/elements/neut.c +++ b/src/elements/neut.c @@ -72,9 +72,9 @@ int update_NEUT(UPDATE_FUNC_ARGS) { else if ((r&0xFF)==PT_COAL && 5>(rand()%100)) create_part(r>>8, x+rx, y+ry, PT_WOOD); else if ((r&0xFF)==PT_DUST && 5>(rand()%100)) - create_part(r>>8, x+rx, y+ry, PT_FWRK); + part_change_type(r>>8, x+rx, y+ry, PT_FWRK); else if ((r&0xFF)==PT_FWRK && 5>(rand()%100)) - create_part(r>>8, x+rx, y+ry, PT_DUST); + parts[r>>8].ctype = PT_DUST; else if ((r&0xFF)==PT_ACID && 5>(rand()%100)) create_part(r>>8, x+rx, y+ry, PT_ISOZ); /*if(parts[r>>8].type>1 && parts[r>>8].type!=PT_NEUT && parts[r>>8].type-1!=PT_NEUT && parts[r>>8].type-1!=PT_STKM && From dab9f85024b8adcfdcec28c7651c20f5b344ac2e Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Mon, 14 Feb 2011 05:43:19 +0800 Subject: [PATCH 2/7] Fix incorrect liquids movement --- src/powder.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/powder.c b/src/powder.c index dc360549f..c302a82a7 100644 --- a/src/powder.c +++ b/src/powder.c @@ -253,6 +253,7 @@ int try_move(int i, int x, int y, int nx, int ny) if (parts[e].type == PT_PHOT) return 1; + if ((pmap[ny][nx]>>8)==e) pmap[ny][nx] = 0; parts[e].x += x-nx; parts[e].y += y-ny; pmap[(int)(parts[e].y+0.5f)][(int)(parts[e].x+0.5f)] = (e<<8)|parts[e].type; From 1b2330251395faef9f5b9f47094af205ed6acbbe Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Mon, 14 Feb 2011 05:59:45 +0800 Subject: [PATCH 3/7] FLAG_STAGNANT usage lost during rewrite --- src/powder.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/powder.c b/src/powder.c index c302a82a7..77dc305cf 100644 --- a/src/powder.c +++ b/src/powder.c @@ -1780,6 +1780,9 @@ killed: } } + rt = parts[i].flags & FLAG_STAGNANT; + parts[i].flags &= ~FLAG_STAGNANT; + if ((t==PT_PHOT||t==PT_NEUT)) { if (t == PT_PHOT) { rt = pmap[fin_y][fin_x] & 0xFF; @@ -2008,24 +2011,25 @@ killed: break; } } - else if (clear_x!=x&&clear_y!=y && try_move(i, x, y, clear_x, clear_y)) { + else if ((clear_x!=x||clear_y!=y) && try_move(i, x, y, clear_x, clear_y)) { // if interpolation was done and haven't yet moved, try moving to last clear position parts[i].x = clear_xf; parts[i].y = clear_yf; } + else + parts[i].flags |= FLAG_STAGNANT; parts[i].vx *= ptypes[t].collision; parts[i].vy *= ptypes[t].collision; - if (!s) - parts[i].flags |= FLAG_STAGNANT; } else { - if (clear_x!=x&&clear_y!=y && try_move(i, x, y, clear_x, clear_y)) { + if ((clear_x!=x||clear_y!=y) && try_move(i, x, y, clear_x, clear_y)) { // if interpolation was done, try moving to last clear position parts[i].x = clear_xf; parts[i].y = clear_yf; } - parts[i].flags |= FLAG_STAGNANT; + else + parts[i].flags |= FLAG_STAGNANT; parts[i].vx *= ptypes[t].collision; parts[i].vy *= ptypes[t].collision; } From 81ce5d74cc2ccbeb462ea5af7d87e7f24b8bf0f1 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Wed, 16 Feb 2011 06:20:15 +0800 Subject: [PATCH 4/7] Crash when element with invalid type is created Generally due to an invalid ctype for clone. --- src/powder.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/powder.c b/src/powder.c index 77dc305cf..873935b29 100644 --- a/src/powder.c +++ b/src/powder.c @@ -454,7 +454,7 @@ _inline void part_change_type(int i, int x, int y, int t) inline void part_change_type(int i, int x, int y, int t) #endif { - if (x<0 || y<0 || x>=XRES || y>=YRES || i>=NPART) + if (x<0 || y<0 || x>=XRES || y>=YRES || i>=NPART || t<0 || t>=PT_NUM) return; parts[i].type = t; if (t==PT_PHOT)// || t==PT_NEUT) @@ -485,7 +485,7 @@ inline int create_n_parts(int n, int x, int y, float vx, float vy, int t) if (n>680) { n = 680; } - if (x<0 || y<0 || x>=XRES || y>=YRES) + if (x<0 || y<0 || x>=XRES || y>=YRES || t<0 || t>=PT_NUM) return -1; for (c; c=XRES || y>=YRES) + if (x<0 || y<0 || x>=XRES || y>=YRES || t<0 || t>=PT_NUM) return -1; if (t==SPC_HEAT||t==SPC_COOL) From df8c13cc58ba9e3f27f63ba21f3b1f8cfb1c1ad5 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Thu, 17 Feb 2011 05:19:21 +0800 Subject: [PATCH 5/7] create_box improvements Boxes now have sharp corners - they fill only the specified rectangle and not 1 pixel extra on all sides. --- src/powder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/powder.c b/src/powder.c index 873935b29..986a678c9 100644 --- a/src/powder.c +++ b/src/powder.c @@ -2712,7 +2712,7 @@ void create_box(int x1, int y1, int x2, int y2, int c) } for (j=y1; j<=y2; j++) for (i=x1; i<=x2; i++) - create_parts(i, j, 1, 1, c); + create_parts(i, j, 0, 0, c); } int flood_parts(int x, int y, int c, int cm, int bm) From 8c6f93cd206056985288ef7baad6faf8220e7760 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Wed, 16 Feb 2011 06:07:24 +0800 Subject: [PATCH 6/7] Makefile - libregex for mingw32, and change icc spaces to tab --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 3a61b1183..de180d74b 100644 --- a/Makefile +++ b/Makefile @@ -47,23 +47,23 @@ powder-64-sse2: $(SOURCES) mv $@ build powder-icc: $(SOURCES) - /opt/intel/Compiler/11.1/073/bin/intel64/icc -m64 -o$@ -Iincludes/ -O2 -march=core2 -msse3 -mfpmath=sse -lSDL -lbz2 -lm -xW $(SOURCES) -std=c99 -D_POSIX_C_SOURCE=200112L + /opt/intel/Compiler/11.1/073/bin/intel64/icc -m64 -o$@ -Iincludes/ -O2 -march=core2 -msse3 -mfpmath=sse -lSDL -lbz2 -lm -xW $(SOURCES) -std=c99 -D_POSIX_C_SOURCE=200112L powder-res.o: powder-res.rc powder.ico i586-mingw32msvc-windres powder-res.rc powder-res.o powder-sse3.exe: $(SOURCES) powder-res.o - i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE3) $(SOURCES) powder-res.o -lmingw32 -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32 + i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE3) $(SOURCES) powder-res.o -lmingw32 -llibregex -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32 strip $@ chmod 0644 $@ mv $@ build powder-sse2.exe: $(SOURCES) powder-res.o - i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE2) $(SOURCES) powder-res.o -lmingw32 -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32 + i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE2) $(SOURCES) powder-res.o -lmingw32 -llibregex -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32 strip $@ chmod 0644 $@ mv $@ build powder-sse.exe: $(SOURCES) powder-res.o - i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE) $(SOURCES) powder-res.o -lmingw32 -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32 + i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE) $(SOURCES) powder-res.o -lmingw32 -llibregex -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32 strip $@ chmod 0644 $@ mv $@ build From 72e6fdd9f645e2d490fba7dd520851314b161cab Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Thu, 17 Feb 2011 04:56:43 +0800 Subject: [PATCH 7/7] Preventing creation of invalid types also prevented use of air/temp tools --- src/powder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/powder.c b/src/powder.c index 986a678c9..78562b8fb 100644 --- a/src/powder.c +++ b/src/powder.c @@ -523,7 +523,7 @@ inline int create_part(int p, int x, int y, int t) { int i; - if (x<0 || y<0 || x>=XRES || y>=YRES || t<0 || t>=PT_NUM) + if (x<0 || y<0 || x>=XRES || y>=YRES || ((t<0 || t>=PT_NUM)&&t!=SPC_HEAT&&t!=SPC_COOL&&t!=SPC_AIR&&t!=SPC_VACUUM)) return -1; if (t==SPC_HEAT||t==SPC_COOL)