mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-21 23:45:20 +02:00
Fix pause with gravity and test deuterium improvements
This commit is contained in:
@@ -103,6 +103,8 @@ typedef unsigned int pixel;
|
||||
#define strcasecmp stricmp
|
||||
#endif
|
||||
|
||||
#define SDEUT
|
||||
|
||||
typedef unsigned char uint8;
|
||||
|
||||
extern int amd;
|
||||
|
@@ -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);
|
||||
}
|
||||
#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))
|
||||
{
|
||||
#ifdef SDEUT
|
||||
create_n_parts(parts[r>>8].life, x+rx, y+ry, parts[i].vx, parts[i].vy, PT_NEUT);
|
||||
#else
|
||||
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))
|
||||
|
13
src/main.c
13
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
|
||||
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)
|
||||
|
44
src/powder.c
44
src/powder.c
@@ -497,50 +497,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
|
||||
|
Reference in New Issue
Block a user