fix compile warnings, remove ugly PRTI/PRTO hack

This commit is contained in:
jacob1
2018-04-23 21:57:30 -04:00
parent 1c600249dc
commit 601af1feff
18 changed files with 27 additions and 25 deletions

View File

@@ -3,11 +3,13 @@
/* xoroshiro128+ by David Blackman and Sebastiano Vigna */ /* xoroshiro128+ by David Blackman and Sebastiano Vigna */
static inline uint64_t rotl(const uint64_t x, int k) { static inline uint64_t rotl(const uint64_t x, int k)
{
return (x << k) | (x >> (64 - k)); return (x << k) | (x >> (64 - k));
} }
uint64_t RandomGen::next(void) { uint64_t RandomGen::next()
{
const uint64_t s0 = s[0]; const uint64_t s0 = s[0];
uint64_t s1 = s[1]; uint64_t s1 = s[1];
const uint64_t result = s0 + s1; const uint64_t result = s0 + s1;
@@ -27,7 +29,7 @@ unsigned int RandomGen::operator()()
unsigned int RandomGen::between(unsigned int lower, unsigned int upper) unsigned int RandomGen::between(unsigned int lower, unsigned int upper)
{ {
unsigned int r = (*this)(); unsigned int r = (*this)();
return r % (upper - lower + 1) + lower; return r % (upper - lower + 1) + lower;
} }

View File

@@ -7,7 +7,7 @@ class RandomGen
{ {
private: private:
uint64_t s[2]; uint64_t s[2];
uint64_t next(void); uint64_t next();
public: public:
unsigned int operator()(); unsigned int operator()();
unsigned int between(unsigned int lower, unsigned int upper); unsigned int between(unsigned int lower, unsigned int upper);

View File

@@ -5137,7 +5137,7 @@ void Simulation::CheckStacking()
excessive_stacking_found = 1; excessive_stacking_found = 1;
} }
} }
else if (pmap_count[y][x]>1500 || (random_gen()%1600)<=(pmap_count[y][x]+100)) else if (pmap_count[y][x]>1500 || (random_gen()%1600) <= (pmap_count[y][x]+100))
{ {
pmap_count[y][x] = pmap_count[y][x] + NPART; pmap_count[y][x] = pmap_count[y][x] + NPART;
excessive_stacking_found = true; excessive_stacking_found = true;

View File

@@ -101,7 +101,7 @@ public:
Particle parts[NPART]; Particle parts[NPART];
int pmap[YRES][XRES]; int pmap[YRES][XRES];
int photons[YRES][XRES]; int photons[YRES][XRES];
int pmap_count[YRES][XRES]; unsigned int pmap_count[YRES][XRES];
//Simulation Settings //Simulation Settings
int edgeMode; int edgeMode;
int gravityMode; int gravityMode;

View File

@@ -76,7 +76,7 @@ int Element_ACID::update(UPDATE_FUNC_ARGS)
sim->kill_part(ID(r)); sim->kill_part(ID(r));
} }
} }
else if ((rt != PT_CLNE && rt != PT_PCLN && sim->elements[rt].Hardness>(random_gen()%1000))&&parts[i].life>=50) else if ((rt != PT_CLNE && rt != PT_PCLN && (unsigned int)sim->elements[rt].Hardness>(random_gen()%1000))&&parts[i].life>=50)
{ {
if (sim->parts_avg(i, ID(r),PT_GLAS)!= PT_GLAS)//GLAS protects stuff from acid if (sim->parts_avg(i, ID(r),PT_GLAS)!= PT_GLAS)//GLAS protects stuff from acid
{ {

View File

@@ -64,7 +64,7 @@ int Element_CAUS::update(UPDATE_FUNC_ARGS)
} }
else if (TYP(r) != PT_ACID && TYP(r) != PT_CAUS && TYP(r) != PT_RFRG && TYP(r) != PT_RFGL) else if (TYP(r) != PT_ACID && TYP(r) != PT_CAUS && TYP(r) != PT_RFRG && TYP(r) != PT_RFGL)
{ {
if ((TYP(r) != PT_CLNE && TYP(r) != PT_PCLN && sim->elements[TYP(r)].Hardness > (random_gen()%1000)) && parts[i].life >= 50) if ((TYP(r) != PT_CLNE && TYP(r) != PT_PCLN && (unsigned int)sim->elements[TYP(r)].Hardness > (random_gen()%1000)) && parts[i].life >= 50)
{ {
// GLAS protects stuff from acid // GLAS protects stuff from acid
if (sim->parts_avg(i, ID(r),PT_GLAS) != PT_GLAS) if (sim->parts_avg(i, ID(r),PT_GLAS) != PT_GLAS)

View File

@@ -186,7 +186,7 @@ int Element_EXOT::graphics(GRAPHICS_FUNC_ARGS)
int c = cpart->tmp2; int c = cpart->tmp2;
if (cpart->life < 1001) if (cpart->life < 1001)
{ {
if ((cpart->tmp2 - 1)>random_gen()%1000) if ((cpart->tmp2 - 1) > (int)(random_gen()%1000))
{ {
float frequency = 0.04045; float frequency = 0.04045;
*colr = (sin(frequency*c + 4) * 127 + 150); *colr = (sin(frequency*c + 4) * 127 + 150);

View File

@@ -153,7 +153,7 @@ int Element_FIRE::update(UPDATE_FUNC_ARGS)
} }
if ((surround_space || sim->elements[rt].Explosive) && if ((surround_space || sim->elements[rt].Explosive) &&
sim->elements[rt].Flammable && (sim->elements[rt].Flammable + (int)(sim->pv[(y+ry)/CELL][(x+rx)/CELL] * 10.0f)) > (random_gen()%1000) && sim->elements[rt].Flammable && (sim->elements[rt].Flammable + (sim->pv[(y+ry)/CELL][(x+rx)/CELL] * 10.0f)) > (random_gen()%1000) &&
//exceptions, t is the thing causing the spark and rt is what's burning //exceptions, t is the thing causing the spark and rt is what's burning
(t != PT_SPRK || (rt != PT_RBDM && rt != PT_LRBD && rt != PT_INSL)) && (t != PT_SPRK || (rt != PT_RBDM && rt != PT_LRBD && rt != PT_INSL)) &&
(t != PT_PHOT || rt != PT_INSL) && (t != PT_PHOT || rt != PT_INSL) &&
@@ -188,7 +188,7 @@ int Element_FIRE::updateLegacy(UPDATE_FUNC_ARGS) {
lpv = (int)sim->pv[(y+ry)/CELL][(x+rx)/CELL]; lpv = (int)sim->pv[(y+ry)/CELL][(x+rx)/CELL];
if (lpv < 1) lpv = 1; if (lpv < 1) lpv = 1;
if (sim->elements[rt].Meltable && ((rt!=PT_RBDM && rt!=PT_LRBD) || t!=PT_SPRK) && ((t!=PT_FIRE&&t!=PT_PLSM) || (rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT && rt!=PT_INWR)) &&sim->elements[rt].Meltable*lpv>(random_gen()%1000)) if (sim->elements[rt].Meltable && ((rt!=PT_RBDM && rt!=PT_LRBD) || t!=PT_SPRK) && ((t!=PT_FIRE&&t!=PT_PLSM) || (rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT && rt!=PT_INWR)) && (unsigned int)sim->elements[rt].Meltable*lpv>(random_gen()%1000))
{ {
if (t!=PT_LAVA || parts[i].life>0) if (t!=PT_LAVA || parts[i].life>0)
{ {

View File

@@ -60,7 +60,7 @@ int Element_FRZW::update(UPDATE_FUNC_ARGS)
sim->part_change_type(ID(r),x+rx,y+ry,PT_FRZW); sim->part_change_type(ID(r),x+rx,y+ry,PT_FRZW);
} }
} }
if ((parts[i].life==0 && !(random_gen()%192)) || (100-(parts[i].life))>random_gen()%50000 ) if ((parts[i].life==0 && !(random_gen()%192)) || (100-(parts[i].life)) > (int)(random_gen()%50000))
{ {
sim->part_change_type(i,x,y,PT_ICEI); sim->part_change_type(i,x,y,PT_ICEI);
parts[i].ctype=PT_FRZW; parts[i].ctype=PT_FRZW;

View File

@@ -48,7 +48,7 @@ Element_ISOZ::Element_ISOZ()
int Element_ISOZ::update(UPDATE_FUNC_ARGS) int Element_ISOZ::update(UPDATE_FUNC_ARGS)
{ // for both ISZS and ISOZ { // for both ISZS and ISOZ
float rr, rrr; float rr, rrr;
if (!(random_gen()%200) && ((int)(-4.0f*(sim->pv[y/CELL][x/CELL])))>(random_gen()%1000)) if (!(random_gen()%200) && (-4.0f*(sim->pv[y/CELL][x/CELL])) > (random_gen()%1000))
{ {
sim->create_part(i, x, y, PT_PHOT); sim->create_part(i, x, y, PT_PHOT);
rr = (random_gen()%228+128)/127.0f; rr = (random_gen()%228+128)/127.0f;

View File

@@ -48,7 +48,7 @@ Element_ISZS::Element_ISZS()
int Element_ISZS::update(UPDATE_FUNC_ARGS) int Element_ISZS::update(UPDATE_FUNC_ARGS)
{ // for both ISZS and ISOZ { // for both ISZS and ISOZ
float rr, rrr; float rr, rrr;
if (!(random_gen()%200) && ((int)(-4.0f*(sim->pv[y/CELL][x/CELL])))>(random_gen()%1000)) if (!(random_gen()%200) && (-4.0f*(sim->pv[y/CELL][x/CELL])) > (random_gen()%1000))
{ {
sim->create_part(i, x, y, PT_PHOT); sim->create_part(i, x, y, PT_PHOT);
rr = (random_gen()%228+128)/127.0f; rr = (random_gen()%228+128)/127.0f;

View File

@@ -91,7 +91,7 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS)
rt = TYP(r); rt = TYP(r);
if ((surround_space || sim->elements[rt].Explosive) && if ((surround_space || sim->elements[rt].Explosive) &&
(rt!=PT_SPNG || parts[ID(r)].life==0) && (rt!=PT_SPNG || parts[ID(r)].life==0) &&
sim->elements[rt].Flammable && (sim->elements[rt].Flammable + (int)(sim->pv[(y+ry)/CELL][(x+rx)/CELL]*10.0f))>(random_gen()%1000)) sim->elements[rt].Flammable && (sim->elements[rt].Flammable + (sim->pv[(y+ry)/CELL][(x+rx)/CELL]*10.0f)) > (random_gen()%1000))
{ {
sim->part_change_type(ID(r),x+rx,y+ry,PT_FIRE); sim->part_change_type(ID(r),x+rx,y+ry,PT_FIRE);
parts[ID(r)].temp = restrict_flt(sim->elements[PT_FIRE].Temperature + (sim->elements[rt].Flammable/2), MIN_TEMP, MAX_TEMP); parts[ID(r)].temp = restrict_flt(sim->elements[PT_FIRE].Temperature + (sim->elements[rt].Flammable/2), MIN_TEMP, MAX_TEMP);
@@ -278,7 +278,7 @@ bool Element_LIGH::create_LIGH(Simulation * sim, int x, int y, int c, int temp,
sim->parts[p].tmp = tmp; sim->parts[p].tmp = tmp;
if (last) if (last)
{ {
sim->parts[p].tmp2=1+(random_gen()%200>tmp2*tmp2/10+60); sim->parts[p].tmp2=1+((int)(random_gen()%200) > tmp2*tmp2/10+60);
sim->parts[p].life=(int)(life/1.5-random_gen()%2); sim->parts[p].life=(int)(life/1.5-random_gen()%2);
} }
else else

View File

@@ -49,7 +49,7 @@ Element_NEUT::Element_NEUT()
int Element_NEUT::update(UPDATE_FUNC_ARGS) int Element_NEUT::update(UPDATE_FUNC_ARGS)
{ {
int r, rx, ry; int r, rx, ry;
int pressureFactor = 3 + (int)sim->pv[y/CELL][x/CELL]; unsigned int pressureFactor = 3 + (int)sim->pv[y/CELL][x/CELL];
for (rx=-1; rx<2; rx++) for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++) for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK) if (BOUNDS_CHECK)
@@ -66,7 +66,7 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS)
parts[i].vy *= 0.995; parts[i].vy *= 0.995;
break; break;
case PT_PLUT: case PT_PLUT:
if (pressureFactor>(random_gen()%1000)) if (pressureFactor > (random_gen()%1000))
{ {
if (!(random_gen()%3)) if (!(random_gen()%3))
{ {

View File

@@ -48,7 +48,7 @@ Element_PLUT::Element_PLUT()
//#TPT-Directive ElementHeader Element_PLUT static int update(UPDATE_FUNC_ARGS) //#TPT-Directive ElementHeader Element_PLUT static int update(UPDATE_FUNC_ARGS)
int Element_PLUT::update(UPDATE_FUNC_ARGS) int Element_PLUT::update(UPDATE_FUNC_ARGS)
{ {
if (!(random_gen()%100) && ((int)(5.0f*sim->pv[y/CELL][x/CELL]))>(random_gen()%1000)) if (!(random_gen()%100) && (5.0f*sim->pv[y/CELL][x/CELL]) > (random_gen()%1000))
{ {
sim->create_part(i, x, y, PT_NEUT); sim->create_part(i, x, y, PT_NEUT);
} }

View File

@@ -68,7 +68,7 @@ int Element_PROT::update(UPDATE_FUNC_ARGS)
break; break;
} }
case PT_DEUT: case PT_DEUT:
if ((-((int)sim->pv[y / CELL][x / CELL] - 4) + (parts[uID].life / 100)) > random_gen() % 200) if ((-((int)sim->pv[y / CELL][x / CELL] - 4) + (parts[uID].life / 100)) > (int)(random_gen() % 200))
{ {
DeutImplosion(sim, parts[uID].life, x, y, restrict_flt(parts[uID].temp + parts[uID].life * 500, MIN_TEMP, MAX_TEMP), PT_PROT); DeutImplosion(sim, parts[uID].life, x, y, restrict_flt(parts[uID].temp + parts[uID].life * 500, MIN_TEMP, MAX_TEMP), PT_PROT);
sim->kill_part(uID); sim->kill_part(uID);

View File

@@ -116,8 +116,8 @@ int Element_PRTI::update(UPDATE_FUNC_ARGS)
if (fe) { if (fe) {
int orbd[4] = {0, 0, 0, 0}; //Orbital distances int orbd[4] = {0, 0, 0, 0}; //Orbital distances
int orbl[4] = {0, 0, 0, 0}; //Orbital locations int orbl[4] = {0, 0, 0, 0}; //Orbital locations
if (!sim->parts[i].life) parts[i].life = random_gen()*random_gen()*random_gen(); if (!sim->parts[i].life) parts[i].life = random_gen();
if (!sim->parts[i].ctype) parts[i].ctype = random_gen()*random_gen()*random_gen(); if (!sim->parts[i].ctype) parts[i].ctype = random_gen();
sim->orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); sim->orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
for (int r = 0; r < 4; r++) { for (int r = 0; r < 4; r++) {
if (orbd[r]>1) { if (orbd[r]>1) {

View File

@@ -141,8 +141,8 @@ int Element_PRTO::update(UPDATE_FUNC_ARGS)
if (fe) { if (fe) {
int orbd[4] = {0, 0, 0, 0}; //Orbital distances int orbd[4] = {0, 0, 0, 0}; //Orbital distances
int orbl[4] = {0, 0, 0, 0}; //Orbital locations int orbl[4] = {0, 0, 0, 0}; //Orbital locations
if (!sim->parts[i].life) parts[i].life = random_gen()*random_gen()*random_gen(); if (!sim->parts[i].life) parts[i].life = random_gen();
if (!sim->parts[i].ctype) parts[i].ctype = random_gen()*random_gen()*random_gen(); if (!sim->parts[i].ctype) parts[i].ctype = random_gen();
sim->orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); sim->orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
for (r = 0; r < 4; r++) { for (r = 0; r < 4; r++) {
if (orbd[r]<254) { if (orbd[r]<254) {

View File

@@ -101,7 +101,7 @@ int Element_VIRS::update(UPDATE_FUNC_ARGS)
} }
else if (TYP(r) == PT_PLSM) else if (TYP(r) == PT_PLSM)
{ {
if (surround_space && 10 + (int)(sim->pv[(y+ry)/CELL][(x+rx)/CELL]) > (random_gen()%100)) if (surround_space && 10 + sim->pv[(y+ry)/CELL][(x+rx)/CELL] > (random_gen()%100))
{ {
sim->create_part(i, x, y, PT_PLSM); sim->create_part(i, x, y, PT_PLSM);
return 1; return 1;