Skip to content

Commit

Permalink
fix compile warnings, remove ugly PRTI/PRTO hack
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Apr 24, 2018
1 parent 1c60024 commit 601af1f
Show file tree
Hide file tree
Showing 18 changed files with 27 additions and 25 deletions.
8 changes: 5 additions & 3 deletions src/common/tpt-rand.cpp
Expand Up @@ -3,11 +3,13 @@

/* 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));
}

uint64_t RandomGen::next(void) {
uint64_t RandomGen::next()
{
const uint64_t s0 = s[0];
uint64_t s1 = s[1];
const uint64_t result = s0 + s1;
Expand All @@ -27,7 +29,7 @@ unsigned int RandomGen::operator()()
unsigned int RandomGen::between(unsigned int lower, unsigned int upper)
{
unsigned int r = (*this)();

return r % (upper - lower + 1) + lower;
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/tpt-rand.h
Expand Up @@ -7,7 +7,7 @@ class RandomGen
{
private:
uint64_t s[2];
uint64_t next(void);
uint64_t next();
public:
unsigned int operator()();
unsigned int between(unsigned int lower, unsigned int upper);
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/Simulation.cpp
Expand Up @@ -5137,7 +5137,7 @@ void Simulation::CheckStacking()
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;
excessive_stacking_found = true;
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/Simulation.h
Expand Up @@ -101,7 +101,7 @@ class Simulation
Particle parts[NPART];
int pmap[YRES][XRES];
int photons[YRES][XRES];
int pmap_count[YRES][XRES];
unsigned int pmap_count[YRES][XRES];
//Simulation Settings
int edgeMode;
int gravityMode;
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/ACID.cpp
Expand Up @@ -76,7 +76,7 @@ int Element_ACID::update(UPDATE_FUNC_ARGS)
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
{
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/CAUS.cpp
Expand Up @@ -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)
{
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
if (sim->parts_avg(i, ID(r),PT_GLAS) != PT_GLAS)
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/EXOT.cpp
Expand Up @@ -186,7 +186,7 @@ int Element_EXOT::graphics(GRAPHICS_FUNC_ARGS)
int c = cpart->tmp2;
if (cpart->life < 1001)
{
if ((cpart->tmp2 - 1)>random_gen()%1000)
if ((cpart->tmp2 - 1) > (int)(random_gen()%1000))
{
float frequency = 0.04045;
*colr = (sin(frequency*c + 4) * 127 + 150);
Expand Down
4 changes: 2 additions & 2 deletions src/simulation/elements/FIRE.cpp
Expand Up @@ -153,7 +153,7 @@ int Element_FIRE::update(UPDATE_FUNC_ARGS)
}

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
(t != PT_SPRK || (rt != PT_RBDM && rt != PT_LRBD && rt != PT_INSL)) &&
(t != PT_PHOT || rt != PT_INSL) &&
Expand Down Expand Up @@ -188,7 +188,7 @@ int Element_FIRE::updateLegacy(UPDATE_FUNC_ARGS) {

lpv = (int)sim->pv[(y+ry)/CELL][(x+rx)/CELL];
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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/FRZW.cpp
Expand Up @@ -60,7 +60,7 @@ int Element_FRZW::update(UPDATE_FUNC_ARGS)
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);
parts[i].ctype=PT_FRZW;
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/ISOZ.cpp
Expand Up @@ -48,7 +48,7 @@ Element_ISOZ::Element_ISOZ()
int Element_ISOZ::update(UPDATE_FUNC_ARGS)
{ // for both ISZS and ISOZ
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);
rr = (random_gen()%228+128)/127.0f;
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/ISZS.cpp
Expand Up @@ -48,7 +48,7 @@ Element_ISZS::Element_ISZS()
int Element_ISZS::update(UPDATE_FUNC_ARGS)
{ // for both ISZS and ISOZ
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);
rr = (random_gen()%228+128)/127.0f;
Expand Down
4 changes: 2 additions & 2 deletions src/simulation/elements/LIGH.cpp
Expand Up @@ -91,7 +91,7 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS)
rt = TYP(r);
if ((surround_space || sim->elements[rt].Explosive) &&
(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);
parts[ID(r)].temp = restrict_flt(sim->elements[PT_FIRE].Temperature + (sim->elements[rt].Flammable/2), MIN_TEMP, MAX_TEMP);
Expand Down Expand Up @@ -278,7 +278,7 @@ bool Element_LIGH::create_LIGH(Simulation * sim, int x, int y, int c, int temp,
sim->parts[p].tmp = tmp;
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);
}
else
Expand Down
4 changes: 2 additions & 2 deletions src/simulation/elements/NEUT.cpp
Expand Up @@ -49,7 +49,7 @@ Element_NEUT::Element_NEUT()
int Element_NEUT::update(UPDATE_FUNC_ARGS)
{
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 (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK)
Expand All @@ -66,7 +66,7 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS)
parts[i].vy *= 0.995;
break;
case PT_PLUT:
if (pressureFactor>(random_gen()%1000))
if (pressureFactor > (random_gen()%1000))
{
if (!(random_gen()%3))
{
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/PLUT.cpp
Expand Up @@ -48,7 +48,7 @@ Element_PLUT::Element_PLUT()
//#TPT-Directive ElementHeader Element_PLUT static int 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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/PROT.cpp
Expand Up @@ -68,7 +68,7 @@ int Element_PROT::update(UPDATE_FUNC_ARGS)
break;
}
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);
sim->kill_part(uID);
Expand Down
4 changes: 2 additions & 2 deletions src/simulation/elements/PRTI.cpp
Expand Up @@ -116,8 +116,8 @@ int Element_PRTI::update(UPDATE_FUNC_ARGS)
if (fe) {
int orbd[4] = {0, 0, 0, 0}; //Orbital distances
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].ctype) parts[i].ctype = 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();
sim->orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
for (int r = 0; r < 4; r++) {
if (orbd[r]>1) {
Expand Down
4 changes: 2 additions & 2 deletions src/simulation/elements/PRTO.cpp
Expand Up @@ -141,8 +141,8 @@ int Element_PRTO::update(UPDATE_FUNC_ARGS)
if (fe) {
int orbd[4] = {0, 0, 0, 0}; //Orbital distances
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].ctype) parts[i].ctype = 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();
sim->orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
for (r = 0; r < 4; r++) {
if (orbd[r]<254) {
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/VIRS.cpp
Expand Up @@ -101,7 +101,7 @@ int Element_VIRS::update(UPDATE_FUNC_ARGS)
}
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);
return 1;
Expand Down

0 comments on commit 601af1f

Please sign in to comment.