fix compile warnings, remove ugly PRTI/PRTO hack
This commit is contained in:
parent
1c600249dc
commit
601af1feff
@ -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;
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -101,7 +101,7 @@ public:
|
||||
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;
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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) &&
|
||||
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
@ -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
|
||||
|
@ -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)
|
||||
@ -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))
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user