summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-04-25 19:41:45 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-04-25 19:41:45 (GMT)
commitb26648e6aeb80f22c70e7ab551a3417bcdae8c6b (patch)
treee1fce618b2d4b45a6b6b36495fddba919bf28c25 /src
parent24f59050204017c641749c59a69e40d53074c028 (diff)
downloadpowder-b26648e6aeb80f22c70e7ab551a3417bcdae8c6b.zip
powder-b26648e6aeb80f22c70e7ab551a3417bcdae8c6b.tar.gz
Fix pause with gravity and test deuterium improvements
Diffstat (limited to 'src')
-rw-r--r--src/elements/neut.c54
-rw-r--r--src/main.c15
-rw-r--r--src/powder.c44
3 files changed, 59 insertions, 54 deletions
diff --git a/src/elements/neut.c b/src/elements/neut.c
index c91c98b..789a033 100644
--- a/src/elements/neut.c
+++ b/src/elements/neut.c
@@ -1,5 +1,49 @@
#include <element.h>
+#if defined(WIN32) && !defined(__GNUC__)
+_inline int create_n_parts(int n, int x, int y, float vx, float vy, int t)
+#else
+inline int create_n_parts(int n, int x, int y, float vx, float vy, int t)//testing a new deut create part
+#endif
+{
+ int i, c;
+ n = (n/50);
+ if (n<1) {
+ n = 1;
+ }
+ if (n>340) {
+ n = 340;
+ }
+ if (x<0 || y<0 || x>=XRES || y>=YRES || t<0 || t>=PT_NUM)
+ return -1;
+
+ for (c=0; c<n; c++) {
+ float r = (rand()%128+128)/127.0f;
+ float a = (rand()%360)*M_PI/180.0f;
+ if (pfree == -1)
+ return -1;
+ i = pfree;
+ pfree = parts[i].life;
+
+ parts[i].x = (float)x;
+ parts[i].y = (float)y;
+ parts[i].type = t;
+ parts[i].life = rand()%480+480;
+ parts[i].vx = r*cosf(a);
+ parts[i].vy = r*sinf(a);
+ parts[i].ctype = 0;
+ parts[i].temp += (n*170);
+ parts[i].tmp = 0;
+ if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT && t!=PT_NEUT && !pmap[y][x])
+ pmap[y][x] = t|(i<<8);
+ else if ((t==PT_PHOT||t==PT_NEUT) && !photons[y][x])
+ photons[y][x] = t|(i<<8);
+
+ pv[y/CELL][x/CELL] += 6.0f * CFDS;
+ }
+ return 0;
+}
+
int update_NEUT(UPDATE_FUNC_ARGS) {
int r, rx, ry, rt;
int pressureFactor = 3 + (int)pv[y/CELL][x/CELL];
@@ -35,11 +79,15 @@ int update_NEUT(UPDATE_FUNC_ARGS) {
pv[y/CELL][x/CELL] += 10.0f * CFDS; //Used to be 2, some people said nukes weren't powerful enough
update_PYRO(UPDATE_FUNC_SUBCALL_ARGS);
}
- else if ((r&0xFF)==PT_DEUT && (pressureFactor+1)>(rand()%1000))
- {
#ifdef SDEUT
+ else if ((r&0xFF)==PT_DEUT && (pressureFactor+1+(parts[i].life/100))>(rand()%1000))
+ {
create_n_parts(parts[r>>8].life, x+rx, y+ry, parts[i].vx, parts[i].vy, PT_NEUT);
+ kill_part(r>>8);
+ }
#else
+ else if ((r&0xFF)==PT_DEUT && (pressureFactor+1)>(rand()%1000))
+ {
create_part(r>>8, x+rx, y+ry, PT_NEUT);
parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx;
parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy;
@@ -51,8 +99,8 @@ int update_NEUT(UPDATE_FUNC_ARGS) {
}
else
kill_part(r>>8);
-#endif
}
+#endif
else if ((r&0xFF)==PT_GUNP && 15>(rand()%1000))
part_change_type(r>>8,x+rx,y+ry,PT_DUST);
else if ((r&0xFF)==PT_DYST && 15>(rand()%1000))
diff --git a/src/main.c b/src/main.c
index 0271e55..92a9fdd 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1540,7 +1540,6 @@ int main(int argc, char *argv[])
memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
}
#endif
- draw_grav(vid_buf);
//Can't be too sure (Limit the cursor size)
if (bsx>1180)
@@ -1552,21 +1551,23 @@ int main(int argc, char *argv[])
if (bsy<0)
bsy = 0;
- memset(gravmap, 0, sizeof(gravmap)); //Clear the old gravmap
- update_particles(vid_buf); //update everything
-
pthread_mutex_lock(&gravmutex);
result = grav_ready;
- //pthread_mutex_unlock(&gravmutex);
if(result) //Did the gravity thread finish?
{
memcpy(th_gravmap, gravmap, sizeof(gravmap)); //Move our current gravmap to be processed other thread
memcpy(gravy, th_gravy, sizeof(gravy)); //Hmm, Gravy
memcpy(gravx, th_gravx, sizeof(gravx)); //Move the processed velocity maps to be used
- grav_ready = 0; //Tell the other thread that we're ready for it to continue
+ if (!sys_pause||framerender) //Only update if not paused
+ grav_ready = 0; //Tell the other thread that we're ready for it to continue
}
pthread_mutex_unlock(&gravmutex);
- //update_grav();
+
+ if (!sys_pause||framerender) //Only update if not paused
+ memset(gravmap, 0, sizeof(gravmap)); //Clear the old gravmap
+
+ draw_grav(vid_buf);
+ update_particles(vid_buf); //update everything
draw_parts(vid_buf); //draw particles
if (cmode==CM_PERS)
diff --git a/src/powder.c b/src/powder.c
index 318dac1..8409d1b 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -498,50 +498,6 @@ inline void part_change_type(int i, int x, int y, int t)//changes the type of pa
}
#if defined(WIN32) && !defined(__GNUC__)
-_inline int create_n_parts(int n, int x, int y, float vx, float vy, int t)
-#else
-inline int create_n_parts(int n, int x, int y, float vx, float vy, int t)//testing a new deut create part
-#endif
-{
- int i, c;
- n = (n/10);
- if (n<1) {
- n = 1;
- }
- if (n>680) {
- n = 680;
- }
- if (x<0 || y<0 || x>=XRES || y>=YRES || t<0 || t>=PT_NUM)
- return -1;
-
- for (c=0; c<n; c++) {
- float r = (rand()%128+128)/127.0f;
- float a = (rand()%360)*3.14159f/180.0f;
- if (pfree == -1)
- return -1;
- i = pfree;
- pfree = parts[i].life;
-
- parts[i].x = (float)x;
- parts[i].y = (float)y;
- parts[i].type = t;
- parts[i].life = rand()%480+480;
- parts[i].vx = r*cosf(a);
- parts[i].vy = r*sinf(a);
- parts[i].ctype = 0;
- parts[i].temp += (n*17);
- parts[i].tmp = 0;
- if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT && t!=PT_NEUT && !pmap[y][x])
- pmap[y][x] = t|(i<<8);
- else if ((t==PT_PHOT||t==PT_NEUT) && !photons[y][x])
- photons[y][x] = t|(i<<8);
-
- pv[y/CELL][x/CELL] += 6.0f * CFDS;
- }
- return 0;
-}
-
-#if defined(WIN32) && !defined(__GNUC__)
_inline int create_part(int p, int x, int y, int t)
#else
inline int create_part(int p, int x, int y, int t)//the function for creating a particle, use p=-1 for creating a new particle, -2 is from a brush, or a particle number to replace a particle.