Use xoroshiro128+ random generator (everywhere besides BSON code).
This commit is contained in:
parent
fbe81baca3
commit
cda029ff42
@ -16,6 +16,7 @@
|
||||
#include <numeric>
|
||||
#include <cstdlib>
|
||||
#include "Probability.h"
|
||||
#include "common/tpt-rand.h"
|
||||
|
||||
namespace Probability
|
||||
{
|
||||
@ -25,11 +26,6 @@ float binomial_gte1(int n, float p)
|
||||
return 1.0f - std::pow(1.0f-p, n);
|
||||
}
|
||||
|
||||
float randFloat()
|
||||
{
|
||||
return static_cast<float>(rand())/RAND_MAX;
|
||||
}
|
||||
|
||||
SmallKBinomialGenerator::SmallKBinomialGenerator(unsigned int n, float p, unsigned int maxK_)
|
||||
{
|
||||
maxK = maxK_;
|
||||
|
@ -25,7 +25,6 @@ namespace Probability
|
||||
// X ~ binomial(n,p), returns P(X>=1)
|
||||
// e.g. If a reaction has n chances of occurring, each time with probability p, this returns the probability that it occurs at least once.
|
||||
float binomial_gte1(int n, float p);
|
||||
float randFloat();
|
||||
|
||||
class SmallKBinomialGenerator
|
||||
{
|
||||
|
51
src/common/tpt-rand.cpp
Normal file
51
src/common/tpt-rand.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
#include "tpt-rand.h"
|
||||
#include <cstdlib>
|
||||
|
||||
/* xoroshiro128+ by David Blackman and Sebastiano Vigna */
|
||||
|
||||
static inline uint64_t rotl(const uint64_t x, int k) {
|
||||
return (x << k) | (x >> (64 - k));
|
||||
}
|
||||
|
||||
uint64_t RandomGen::next(void) {
|
||||
const uint64_t s0 = s[0];
|
||||
uint64_t s1 = s[1];
|
||||
const uint64_t result = s0 + s1;
|
||||
|
||||
s1 ^= s0;
|
||||
s[0] = rotl(s0, 55) ^ s1 ^ (s1 << 14); // a, b
|
||||
s[1] = rotl(s1, 36); // c
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned int RandomGen::operator()()
|
||||
{
|
||||
return next()&0xFFFFFFFF;
|
||||
}
|
||||
|
||||
unsigned int RandomGen::between(unsigned int lower, unsigned int upper)
|
||||
{
|
||||
unsigned int r = (*this)();
|
||||
|
||||
return r % (upper - lower + 1) + lower;
|
||||
}
|
||||
|
||||
float RandomGen::uniform01()
|
||||
{
|
||||
return static_cast<float>(random_gen())/(float)0xFFFFFFFF;
|
||||
}
|
||||
|
||||
RandomGen::RandomGen()
|
||||
{
|
||||
s[0] = 1;
|
||||
s[1] = 2;
|
||||
}
|
||||
|
||||
void RandomGen::seed(unsigned int sd)
|
||||
{
|
||||
s[0] = sd;
|
||||
s[1] = sd;
|
||||
}
|
||||
|
||||
RandomGen random_gen;
|
22
src/common/tpt-rand.h
Normal file
22
src/common/tpt-rand.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef TPT_RAND_
|
||||
#define TPT_RAND_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
class RandomGen
|
||||
{
|
||||
private:
|
||||
uint64_t s[2];
|
||||
uint64_t next(void);
|
||||
public:
|
||||
unsigned int operator()();
|
||||
unsigned int between(unsigned int lower, unsigned int upper);
|
||||
float uniform01();
|
||||
|
||||
RandomGen();
|
||||
void seed(unsigned int sd);
|
||||
};
|
||||
|
||||
extern RandomGen random_gen;
|
||||
|
||||
#endif /* TPT_RAND_ */
|
@ -8,6 +8,7 @@
|
||||
#include "Renderer.h"
|
||||
#include "Graphics.h"
|
||||
#include "common/tpt-math.h"
|
||||
#include "common/tpt-rand.h"
|
||||
#include "common/tpt-minmax.h"
|
||||
#include "gui/game/RenderPreset.h"
|
||||
#include "simulation/Elements.h"
|
||||
@ -1774,7 +1775,7 @@ void Renderer::render_parts()
|
||||
}
|
||||
if(pixel_mode & PMODE_SPARK)
|
||||
{
|
||||
flicker = rand()%20;
|
||||
flicker = random_gen()%20;
|
||||
#ifdef OGLR
|
||||
//Oh god, this is awful
|
||||
lineC[clineC++] = ((float)colr)/255.0f;
|
||||
@ -1838,7 +1839,7 @@ void Renderer::render_parts()
|
||||
}
|
||||
if(pixel_mode & PMODE_FLARE)
|
||||
{
|
||||
flicker = rand()%20;
|
||||
flicker = random_gen()%20;
|
||||
#ifdef OGLR
|
||||
//Oh god, this is awful
|
||||
lineC[clineC++] = ((float)colr)/255.0f;
|
||||
@ -1911,7 +1912,7 @@ void Renderer::render_parts()
|
||||
}
|
||||
if(pixel_mode & PMODE_LFLARE)
|
||||
{
|
||||
flicker = rand()%20;
|
||||
flicker = random_gen()%20;
|
||||
#ifdef OGLR
|
||||
//Oh god, this is awful
|
||||
lineC[clineC++] = ((float)colr)/255.0f;
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include "gui/interface/AvatarButton.h"
|
||||
#include "gui/interface/Keys.h"
|
||||
#include "gui/dialogues/ErrorMessage.h"
|
||||
#include "common/tpt-math.h"
|
||||
#include "common/tpt-rand.h"
|
||||
|
||||
class PreviewView::LoginAction: public ui::ButtonAction
|
||||
{
|
||||
@ -297,7 +299,7 @@ void PreviewView::CheckComment()
|
||||
{
|
||||
if (!commentHelpText)
|
||||
{
|
||||
if (rand()%2)
|
||||
if (random_gen()%2)
|
||||
commentWarningLabel->SetText("Stolen? Report the save instead");
|
||||
else
|
||||
commentWarningLabel->SetText("Please report stolen saves");
|
||||
@ -313,7 +315,7 @@ void PreviewView::CheckComment()
|
||||
{
|
||||
if (!commentHelpText)
|
||||
{
|
||||
if (rand()%2)
|
||||
if (random_gen()%2)
|
||||
commentWarningLabel->SetText("Please do not swear");
|
||||
else
|
||||
commentWarningLabel->SetText("Bad language may be deleted");
|
||||
|
@ -6,6 +6,7 @@
|
||||
//#include <powder.h>
|
||||
//#include <defines.h>
|
||||
#include "Gravity.h"
|
||||
#include "common/tpt-rand.h"
|
||||
|
||||
/*float kernel[9];
|
||||
|
||||
@ -373,7 +374,7 @@ void Air::RecalculateBlockAirMaps()
|
||||
}
|
||||
}
|
||||
// mostly accurate insulator blocking, besides checking GEL
|
||||
else if ((type == PT_HSWC && sim.parts[i].life != 10) || sim.elements[type].HeatConduct <= (rand()%250))
|
||||
else if ((type == PT_HSWC && sim.parts[i].life != 10) || sim.elements[type].HeatConduct <= (random_gen()%250))
|
||||
{
|
||||
int x = ((int)(sim.parts[i].x+0.5f))/CELL, y = ((int)(sim.parts[i].y+0.5f))/CELL;
|
||||
if (sim.InBounds(x, y) && !(bmap_blockairh[y][x]&0x8))
|
||||
|
@ -70,6 +70,7 @@
|
||||
struct playerst;
|
||||
|
||||
#include "ElementClasses.h"
|
||||
#include "common/tpt-rand.h"
|
||||
|
||||
|
||||
#endif /* ELEMENTS_H_ */
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "common/tpt-compat.h"
|
||||
#include "common/tpt-math.h"
|
||||
#include "common/tpt-minmax.h"
|
||||
#include "common/tpt-rand.h"
|
||||
#include "gui/game/Brush.h"
|
||||
|
||||
#ifdef LUACONSOLE
|
||||
@ -1974,7 +1975,7 @@ int Simulation::get_wavelength_bin(int *wm)
|
||||
if (wM - w0 < 5)
|
||||
return wM + w0;
|
||||
|
||||
r = rand();
|
||||
r = random_gen();
|
||||
i = (r >> 1) % (wM-w0-4);
|
||||
i += w0;
|
||||
|
||||
@ -2098,8 +2099,8 @@ void Simulation::create_arc(int sx, int sy, int dx, int dy, int midpoints, int v
|
||||
{
|
||||
if(i!=midpoints)
|
||||
{
|
||||
xmid[i+1] += (rand()%variance)-voffset;
|
||||
ymid[i+1] += (rand()%variance)-voffset;
|
||||
xmid[i+1] += (random_gen()%variance)-voffset;
|
||||
ymid[i+1] += (random_gen()%variance)-voffset;
|
||||
}
|
||||
CreateLine(xmid[i], ymid[i], xmid[i+1], ymid[i+1], type);
|
||||
}
|
||||
@ -2415,7 +2416,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
|
||||
|
||||
/* half-silvered mirror */
|
||||
if (!e && parts[i].type==PT_PHOT &&
|
||||
((TYP(r)==PT_BMTL && rand()<RAND_MAX/2) ||
|
||||
((TYP(r)==PT_BMTL && random_gen()%2) ||
|
||||
TYP(pmap[y][x])==PT_BMTL))
|
||||
e = 2;
|
||||
|
||||
@ -2475,7 +2476,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
|
||||
switch (TYP(r))
|
||||
{
|
||||
case PT_GLOW:
|
||||
if (!parts[ID(r)].life && rand() < RAND_MAX/30)
|
||||
if (!parts[ID(r)].life && random_gen()%30)
|
||||
{
|
||||
parts[ID(r)].life = 120;
|
||||
create_gain_photon(i);
|
||||
@ -2564,7 +2565,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
|
||||
}
|
||||
case PT_NEUT:
|
||||
if (TYP(r) == PT_GLAS || TYP(r) == PT_BGLA)
|
||||
if (rand() < RAND_MAX/10)
|
||||
if (random_gen()%10)
|
||||
create_cherenkov_photon(i);
|
||||
break;
|
||||
case PT_ELEC:
|
||||
@ -3235,7 +3236,7 @@ int Simulation::create_part(int p, int x, int y, int t, int v)
|
||||
parts[i].life = 75;
|
||||
break;
|
||||
case PT_WARP:
|
||||
parts[i].life = rand()%95+70;
|
||||
parts[i].life = random_gen()%95+70;
|
||||
break;
|
||||
case PT_FUSE:
|
||||
parts[i].life = 50;
|
||||
@ -3261,14 +3262,14 @@ int Simulation::create_part(int p, int x, int y, int t, int v)
|
||||
parts[i].life = 10;
|
||||
break;
|
||||
case PT_SING:
|
||||
parts[i].life = rand()%50+60;
|
||||
parts[i].life = random_gen()%50+60;
|
||||
break;
|
||||
case PT_QRTZ:
|
||||
case PT_PQRT:
|
||||
parts[i].tmp2 = (rand()%11);
|
||||
parts[i].tmp2 = (random_gen()%11);
|
||||
break;
|
||||
case PT_CLST:
|
||||
parts[i].tmp = (rand()%7);
|
||||
parts[i].tmp = (random_gen()%7);
|
||||
break;
|
||||
case PT_FSEP:
|
||||
parts[i].life = 50;
|
||||
@ -3291,16 +3292,16 @@ int Simulation::create_part(int p, int x, int y, int t, int v)
|
||||
parts[i].life = 110;
|
||||
break;
|
||||
case PT_FIRE:
|
||||
parts[i].life = rand()%50+120;
|
||||
parts[i].life = random_gen()%50+120;
|
||||
break;
|
||||
case PT_PLSM:
|
||||
parts[i].life = rand()%150+50;
|
||||
parts[i].life = random_gen()%150+50;
|
||||
break;
|
||||
case PT_CFLM:
|
||||
parts[i].life = rand()%150+50;
|
||||
parts[i].life = random_gen()%150+50;
|
||||
break;
|
||||
case PT_LAVA:
|
||||
parts[i].life = rand()%120+240;
|
||||
parts[i].life = random_gen()%120+240;
|
||||
break;
|
||||
case PT_NBLE:
|
||||
parts[i].life = 0;
|
||||
@ -3340,7 +3341,7 @@ int Simulation::create_part(int p, int x, int y, int t, int v)
|
||||
parts[i].pavg[1] = 250;
|
||||
break;
|
||||
case PT_CRMC:
|
||||
parts[i].tmp2 = (rand() % 5);
|
||||
parts[i].tmp2 = (random_gen() % 5);
|
||||
break;
|
||||
case PT_ETRD:
|
||||
etrd_life0_count++;
|
||||
@ -3403,7 +3404,7 @@ int Simulation::create_part(int p, int x, int y, int t, int v)
|
||||
}
|
||||
case PT_PHOT:
|
||||
{
|
||||
float a = (rand()%8) * 0.78540f;
|
||||
float a = (random_gen()%8) * 0.78540f;
|
||||
parts[i].life = 680;
|
||||
parts[i].ctype = 0x3FFFFFFF;
|
||||
parts[i].vx = 3.0f*cosf(a);
|
||||
@ -3414,7 +3415,7 @@ int Simulation::create_part(int p, int x, int y, int t, int v)
|
||||
}
|
||||
case PT_ELEC:
|
||||
{
|
||||
float a = (rand()%360)*3.14159f/180.0f;
|
||||
float a = (random_gen()%360)*3.14159f/180.0f;
|
||||
parts[i].life = 680;
|
||||
parts[i].vx = 2.0f*cosf(a);
|
||||
parts[i].vy = 2.0f*sinf(a);
|
||||
@ -3422,16 +3423,16 @@ int Simulation::create_part(int p, int x, int y, int t, int v)
|
||||
}
|
||||
case PT_NEUT:
|
||||
{
|
||||
float r = (rand()%128+128)/127.0f;
|
||||
float a = (rand()%360)*3.14159f/180.0f;
|
||||
parts[i].life = rand()%480+480;
|
||||
float r = (random_gen()%128+128)/127.0f;
|
||||
float a = (random_gen()%360)*3.14159f/180.0f;
|
||||
parts[i].life = random_gen()%480+480;
|
||||
parts[i].vx = r*cosf(a);
|
||||
parts[i].vy = r*sinf(a);
|
||||
break;
|
||||
}
|
||||
case PT_PROT:
|
||||
{
|
||||
float a = (rand()%36)* 0.17453f;
|
||||
float a = (random_gen()%36)* 0.17453f;
|
||||
parts[i].life = 680;
|
||||
parts[i].vx = 2.0f*cosf(a);
|
||||
parts[i].vy = 2.0f*sinf(a);
|
||||
@ -3439,8 +3440,8 @@ int Simulation::create_part(int p, int x, int y, int t, int v)
|
||||
}
|
||||
case PT_GRVT:
|
||||
{
|
||||
float a = (rand()%360)*3.14159f/180.0f;
|
||||
parts[i].life = 250 + rand()%200;
|
||||
float a = (random_gen()%360)*3.14159f/180.0f;
|
||||
parts[i].life = 250 + random_gen()%200;
|
||||
parts[i].vx = 2.0f*cosf(a);
|
||||
parts[i].vy = 2.0f*sinf(a);
|
||||
parts[i].tmp = 7;
|
||||
@ -3448,8 +3449,8 @@ int Simulation::create_part(int p, int x, int y, int t, int v)
|
||||
}
|
||||
case PT_TRON:
|
||||
{
|
||||
int randhue = rand()%360;
|
||||
int randomdir = rand()%4;
|
||||
int randhue = random_gen()%360;
|
||||
int randomdir = random_gen()%4;
|
||||
parts[i].tmp = 1|(randomdir<<5)|(randhue<<7);//set as a head and a direction
|
||||
parts[i].tmp2 = 4;//tail
|
||||
parts[i].life = 5;
|
||||
@ -3472,13 +3473,13 @@ int Simulation::create_part(int p, int x, int y, int t, int v)
|
||||
gsize = gx*gx+gy*gy;
|
||||
if (gsize<0.0016f)
|
||||
{
|
||||
float angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi)
|
||||
float angle = (random_gen()%6284)*0.001f;//(in radians, between 0 and 2*pi)
|
||||
gsize = sqrtf(gsize);
|
||||
// randomness in weak gravity fields (more randomness with weaker fields)
|
||||
gx += cosf(angle)*(0.04f-gsize);
|
||||
gy += sinf(angle)*(0.04f-gsize);
|
||||
}
|
||||
parts[i].tmp = (((int)(atan2f(-gy, gx)*(180.0f/M_PI)))+rand()%40-20+360)%360;
|
||||
parts[i].tmp = (((int)(atan2f(-gy, gx)*(180.0f/M_PI)))+random_gen()%40-20+360)%360;
|
||||
parts[i].tmp2 = 4;
|
||||
break;
|
||||
}
|
||||
@ -3498,13 +3499,13 @@ int Simulation::create_part(int p, int x, int y, int t, int v)
|
||||
if((elements[t].Properties & TYPE_PART) && pretty_powder)
|
||||
{
|
||||
int colr, colg, colb;
|
||||
colr = PIXR(elements[t].Colour)+sandcolour*1.3+(rand()%40)-20+(rand()%30)-15;
|
||||
colg = PIXG(elements[t].Colour)+sandcolour*1.3+(rand()%40)-20+(rand()%30)-15;
|
||||
colb = PIXB(elements[t].Colour)+sandcolour*1.3+(rand()%40)-20+(rand()%30)-15;
|
||||
colr = PIXR(elements[t].Colour)+sandcolour*1.3+(random_gen()%40)-20+(random_gen()%30)-15;
|
||||
colg = PIXG(elements[t].Colour)+sandcolour*1.3+(random_gen()%40)-20+(random_gen()%30)-15;
|
||||
colb = PIXB(elements[t].Colour)+sandcolour*1.3+(random_gen()%40)-20+(random_gen()%30)-15;
|
||||
colr = colr>255 ? 255 : (colr<0 ? 0 : colr);
|
||||
colg = colg>255 ? 255 : (colg<0 ? 0 : colg);
|
||||
colb = colb>255 ? 255 : (colb<0 ? 0 : colb);
|
||||
parts[i].dcolour = ((rand()%150)<<24) | (colr<<16) | (colg<<8) | colb;
|
||||
parts[i].dcolour = ((random_gen()%150)<<24) | (colr<<16) | (colg<<8) | colb;
|
||||
}
|
||||
elementCount[t]++;
|
||||
return i;
|
||||
@ -3541,7 +3542,7 @@ void Simulation::create_gain_photon(int pp)//photons from PHOT going through GLO
|
||||
return;
|
||||
i = pfree;
|
||||
|
||||
lr = rand() % 2;
|
||||
lr = random_gen() % 2;
|
||||
|
||||
if (lr) {
|
||||
xx = parts[pp].x - 0.3*parts[pp].vy;
|
||||
@ -3600,7 +3601,7 @@ void Simulation::create_cherenkov_photon(int pp)//photons from NEUT going throug
|
||||
pfree = parts[i].life;
|
||||
if (i>parts_lastActiveIndex) parts_lastActiveIndex = i;
|
||||
|
||||
lr = rand() % 2;
|
||||
lr = random_gen() % 2;
|
||||
|
||||
parts[i].type = PT_PHOT;
|
||||
parts[i].ctype = 0x00000F80;
|
||||
@ -3774,11 +3775,11 @@ void Simulation::UpdateParticles(int start, int end)
|
||||
{
|
||||
#ifdef REALISTIC
|
||||
//The magic number controls diffusion speed
|
||||
parts[i].vx += 0.05*sqrtf(parts[i].temp)*elements[t].Diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
|
||||
parts[i].vy += 0.05*sqrtf(parts[i].temp)*elements[t].Diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
|
||||
parts[i].vx += 0.05*sqrtf(parts[i].temp)*elements[t].Diffusion*(2.0f*random_gen.uniform01()-1.0f);
|
||||
parts[i].vy += 0.05*sqrtf(parts[i].temp)*elements[t].Diffusion*(2.0f*random_gen.uniform01()-1.0f);
|
||||
#else
|
||||
parts[i].vx += elements[t].Diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
|
||||
parts[i].vy += elements[t].Diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
|
||||
parts[i].vx += elements[t].Diffusion*(2.0f*random_gen.uniform01()-1.0f);
|
||||
parts[i].vy += elements[t].Diffusion*(2.0f*random_gen.uniform01()-1.0f);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -3803,7 +3804,7 @@ void Simulation::UpdateParticles(int start, int end)
|
||||
|
||||
if (!legacy_enable)
|
||||
{
|
||||
if (y-2 >= 0 && y-2 < YRES && (elements[t].Properties&TYPE_LIQUID) && (t!=PT_GEL || gel_scale>(1+rand()%255))) {//some heat convection for liquids
|
||||
if (y-2 >= 0 && y-2 < YRES && (elements[t].Properties&TYPE_LIQUID) && (t!=PT_GEL || gel_scale>(1+random_gen()%255))) {//some heat convection for liquids
|
||||
r = pmap[y-2][x];
|
||||
if (!(!r || parts[i].type != TYP(r))) {
|
||||
if (parts[i].temp>parts[ID(r)].temp) {
|
||||
@ -3819,7 +3820,7 @@ void Simulation::UpdateParticles(int start, int end)
|
||||
#ifdef REALISTIC
|
||||
if (t&&(t!=PT_HSWC||parts[i].life==10)&&(elements[t].HeatConduct*gel_scale))
|
||||
#else
|
||||
if (t&&(t!=PT_HSWC||parts[i].life==10)&&(elements[t].HeatConduct*gel_scale)>(rand()%250))
|
||||
if (t&&(t!=PT_HSWC||parts[i].life==10)&&(elements[t].HeatConduct*gel_scale)>(random_gen()%250))
|
||||
#endif
|
||||
{
|
||||
if (aheat_enable && !(elements[t].Properties&PROP_NOAMBHEAT))
|
||||
@ -3976,7 +3977,7 @@ void Simulation::UpdateParticles(int start, int end)
|
||||
{
|
||||
pt = (c_heat - platent[t])/c_Cm;
|
||||
|
||||
if (rand()%4==0) t = PT_SALT;
|
||||
if (random_gen()%4==0) t = PT_SALT;
|
||||
else t = PT_WTRV;
|
||||
}
|
||||
else
|
||||
@ -3985,7 +3986,7 @@ void Simulation::UpdateParticles(int start, int end)
|
||||
s = 0;
|
||||
}
|
||||
#else
|
||||
if (rand()%4 == 0)
|
||||
if (random_gen()%4 == 0)
|
||||
t = PT_SALT;
|
||||
else
|
||||
t = PT_WTRV;
|
||||
@ -4137,14 +4138,14 @@ void Simulation::UpdateParticles(int start, int end)
|
||||
goto killed;
|
||||
|
||||
if (t==PT_FIRE || t==PT_PLSM || t==PT_CFLM)
|
||||
parts[i].life = rand()%50+120;
|
||||
parts[i].life = random_gen()%50+120;
|
||||
if (t == PT_LAVA)
|
||||
{
|
||||
if (parts[i].ctype == PT_BRMT) parts[i].ctype = PT_BMTL;
|
||||
else if (parts[i].ctype == PT_SAND) parts[i].ctype = PT_GLAS;
|
||||
else if (parts[i].ctype == PT_BGLA) parts[i].ctype = PT_GLAS;
|
||||
else if (parts[i].ctype == PT_PQRT) parts[i].ctype = PT_QRTZ;
|
||||
parts[i].life = rand()%120+240;
|
||||
parts[i].life = random_gen()%120+240;
|
||||
}
|
||||
transitionOccurred = true;
|
||||
}
|
||||
@ -4218,7 +4219,7 @@ void Simulation::UpdateParticles(int start, int end)
|
||||
//the basic explosion, from the .explosive variable
|
||||
if ((elements[t].Explosive&2) && pv[y/CELL][x/CELL]>2.5f)
|
||||
{
|
||||
parts[i].life = rand()%80+180;
|
||||
parts[i].life = random_gen()%80+180;
|
||||
parts[i].temp = restrict_flt(elements[PT_FIRE].Temperature + (elements[t].Flammable/2), MIN_TEMP, MAX_TEMP);
|
||||
t = PT_FIRE;
|
||||
part_change_type(i,x,y,t);
|
||||
@ -4274,7 +4275,7 @@ void Simulation::UpdateParticles(int start, int end)
|
||||
if (part_change_type(i,x,y,t))
|
||||
goto killed;
|
||||
if (t == PT_FIRE)
|
||||
parts[i].life = rand()%50+120;
|
||||
parts[i].life = random_gen()%50+120;
|
||||
transitionOccurred = true;
|
||||
}
|
||||
|
||||
@ -4547,7 +4548,7 @@ killed:
|
||||
continue;
|
||||
// reflection
|
||||
parts[i].flags |= FLAG_STAGNANT;
|
||||
if (t==PT_NEUT && 100>(rand()%1000))
|
||||
if (t==PT_NEUT && 100>(random_gen()%1000))
|
||||
{
|
||||
kill_part(i);
|
||||
continue;
|
||||
@ -4572,7 +4573,7 @@ killed:
|
||||
{
|
||||
if (TYP(r) == PT_CRMC)
|
||||
{
|
||||
float r = (rand() % 101 - 50) * 0.01f, rx, ry, anrx, anry;
|
||||
float r = (random_gen() % 101 - 50) * 0.01f, rx, ry, anrx, anry;
|
||||
r = r * r * r;
|
||||
rx = cosf(r); ry = sinf(r);
|
||||
anrx = rx * nrx + ry * nry;
|
||||
@ -4633,7 +4634,7 @@ killed:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (water_equal_test && elements[t].Falldown == 2 && 1>= rand()%400)//checking stagnant is cool, but then it doesn't update when you change it later.
|
||||
if (water_equal_test && elements[t].Falldown == 2 && 1>= random_gen()%400)//checking stagnant is cool, but then it doesn't update when you change it later.
|
||||
{
|
||||
if (!flood_water(x,y,i,y, parts[i].flags&FLAG_WATEREQUAL))
|
||||
goto movedone;
|
||||
@ -4656,7 +4657,7 @@ killed:
|
||||
else
|
||||
{
|
||||
s = 1;
|
||||
r = (rand()%2)*2-1;// position search direction (left/right first)
|
||||
r = (random_gen()%2)*2-1;// position search direction (left/right first)
|
||||
if ((clear_x!=x || clear_y!=y || nt || surround_space) &&
|
||||
(fabsf(parts[i].vx)>0.01f || fabsf(parts[i].vy)>0.01f))
|
||||
{
|
||||
@ -5136,7 +5137,7 @@ void Simulation::CheckStacking()
|
||||
excessive_stacking_found = 1;
|
||||
}
|
||||
}
|
||||
else if (pmap_count[y][x]>1500 || (rand()%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;
|
||||
@ -5236,7 +5237,7 @@ void Simulation::BeforeSim()
|
||||
}
|
||||
|
||||
// check for stacking and create BHOL if found
|
||||
if (force_stacking_check || (rand()%10)==0)
|
||||
if (force_stacking_check || (random_gen()%10)==0)
|
||||
{
|
||||
CheckStacking();
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <cstring>
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
#include <random>
|
||||
|
||||
#include "Config.h"
|
||||
#include "Elements.h"
|
||||
|
@ -69,14 +69,14 @@ int Element_ACID::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (rt == PT_WTRV)
|
||||
{
|
||||
if(!(rand()%250))
|
||||
if(!(random_gen()%250))
|
||||
{
|
||||
sim->part_change_type(i, x, y, PT_CAUS);
|
||||
parts[i].life = (rand()%50)+25;
|
||||
parts[i].life = (random_gen()%50)+25;
|
||||
sim->kill_part(ID(r));
|
||||
}
|
||||
}
|
||||
else if ((rt != PT_CLNE && rt != PT_PCLN && sim->elements[rt].Hardness>(rand()%1000))&&parts[i].life>=50)
|
||||
else if ((rt != PT_CLNE && rt != PT_PCLN && 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
|
||||
{
|
||||
@ -98,8 +98,8 @@ int Element_ACID::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
for (trade = 0; trade<2; trade++)
|
||||
{
|
||||
rx = rand()%5-2;
|
||||
ry = rand()%5-2;
|
||||
rx = random_gen()%5-2;
|
||||
ry = random_gen()%5-2;
|
||||
if (BOUNDS_CHECK && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
|
@ -65,7 +65,7 @@ int Element_AMTR::update(UPDATE_FUNC_ARGS)
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
}
|
||||
if (!(rand()%10))
|
||||
if (!(random_gen()%10))
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_PHOT);
|
||||
else
|
||||
sim->kill_part(ID(r));
|
||||
|
@ -58,10 +58,10 @@ int Element_ANAR::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if (TYP(r)==PT_CFLM && !(rand()%4))
|
||||
if (TYP(r)==PT_CFLM && !(random_gen()%4))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_CFLM);
|
||||
parts[i].life = rand()%150+50;
|
||||
parts[i].life = random_gen()%150+50;
|
||||
parts[ID(r)].temp = parts[i].temp = 0;
|
||||
sim->pv[y/CELL][x/CELL] -= 0.5;
|
||||
}
|
||||
|
@ -87,29 +87,29 @@ int Element_BANG::update(UPDATE_FUNC_ARGS)
|
||||
//Explode!!
|
||||
sim->pv[y/CELL][x/CELL] += 0.5f;
|
||||
parts[i].tmp = 0;
|
||||
if(!(rand()%3))
|
||||
if(!(random_gen()%3))
|
||||
{
|
||||
if(!(rand()%2))
|
||||
if(!(random_gen()%2))
|
||||
{
|
||||
sim->create_part(i, x, y, PT_FIRE);
|
||||
}
|
||||
else
|
||||
{
|
||||
sim->create_part(i, x, y, PT_SMKE);
|
||||
parts[i].life = rand()%50+500;
|
||||
parts[i].life = random_gen()%50+500;
|
||||
}
|
||||
parts[i].temp = restrict_flt((MAX_TEMP/4)+otemp, MIN_TEMP, MAX_TEMP);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!(rand()%15))
|
||||
if(!(random_gen()%15))
|
||||
{
|
||||
sim->create_part(i, x, y, PT_EMBR);
|
||||
parts[i].tmp = 0;
|
||||
parts[i].life = 50;
|
||||
parts[i].temp = restrict_flt((MAX_TEMP/3)+otemp, MIN_TEMP, MAX_TEMP);
|
||||
parts[i].vx = rand()%20-10;
|
||||
parts[i].vy = rand()%20-10;
|
||||
parts[i].vx = random_gen()%20-10;
|
||||
parts[i].vy = random_gen()%20-10;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ Element_BCLN::Element_BCLN()
|
||||
int Element_BCLN::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (!parts[i].life && sim->pv[y/CELL][x/CELL]>4.0f)
|
||||
parts[i].life = rand()%40+80;
|
||||
parts[i].life = random_gen()%40+80;
|
||||
if (parts[i].life)
|
||||
{
|
||||
parts[i].vx += ADVECTION*sim->vx[y/CELL][x/CELL];
|
||||
@ -81,10 +81,10 @@ int Element_BCLN::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_LIFE, parts[i].tmp);
|
||||
else if (parts[i].ctype!=PT_LIGH || (rand()%30)==0)
|
||||
if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x+random_gen()%3-1, y+random_gen()%3-1, PT_LIFE, parts[i].tmp);
|
||||
else if (parts[i].ctype!=PT_LIGH || (random_gen()%30)==0)
|
||||
{
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, TYP(parts[i].ctype));
|
||||
int np = sim->create_part(-1, x+random_gen()%3-1, y+random_gen()%3-1, TYP(parts[i].ctype));
|
||||
if (np>=0)
|
||||
{
|
||||
if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmp<PT_NUM && sim->elements[parts[i].tmp].HighTemperatureTransition==PT_LAVA)
|
||||
|
@ -58,14 +58,14 @@ int Element_BMTL::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((TYP(r)==PT_METL || TYP(r)==PT_IRON) && !(rand()%100))
|
||||
if ((TYP(r)==PT_METL || TYP(r)==PT_IRON) && !(random_gen()%100))
|
||||
{
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_BMTL);
|
||||
parts[ID(r)].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100;
|
||||
parts[ID(r)].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(random_gen()%5);//random_gen()/(RAND_MAX/300)+100;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (parts[i].tmp==1 && !(rand()%1000))
|
||||
else if (parts[i].tmp==1 && !(random_gen()%1000))
|
||||
{
|
||||
parts[i].tmp = 0;
|
||||
sim->part_change_type(i,x,y,PT_BRMT);
|
||||
|
@ -97,8 +97,8 @@ int Element_BOMB::update(UPDATE_FUNC_ARGS)
|
||||
parts[nb].tmp = 0;
|
||||
parts[nb].life = 50;
|
||||
parts[nb].temp = MAX_TEMP;
|
||||
parts[nb].vx = rand()%40-20;
|
||||
parts[nb].vy = rand()%40-20;
|
||||
parts[nb].vx = random_gen()%40-20;
|
||||
parts[nb].vy = random_gen()%40-20;
|
||||
}
|
||||
}
|
||||
sim->kill_part(i);
|
||||
|
@ -70,12 +70,12 @@ int Element_BOYL::update(UPDATE_FUNC_ARGS)
|
||||
continue;
|
||||
if (TYP(r)==PT_WATR)
|
||||
{
|
||||
if (!(rand()%30))
|
||||
if (!(random_gen()%30))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_FOG);
|
||||
}
|
||||
else if (TYP(r)==PT_O2)
|
||||
{
|
||||
if (!(rand()%9))
|
||||
if (!(random_gen()%9))
|
||||
{
|
||||
sim->kill_part(ID(r));
|
||||
sim->part_change_type(i,x,y,PT_WATR);
|
||||
|
@ -51,7 +51,7 @@ int Element_BREC::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (sim->pv[y/CELL][x/CELL]>10.0f)
|
||||
{
|
||||
if (parts[i].temp>9000 && sim->pv[y/CELL][x/CELL]>30.0f && !(rand()%200))
|
||||
if (parts[i].temp>9000 && sim->pv[y/CELL][x/CELL]>30.0f && !(random_gen()%200))
|
||||
{
|
||||
sim->part_change_type(i, x ,y ,PT_EXOT);
|
||||
parts[i].life = 1000;
|
||||
|
@ -60,16 +60,16 @@ int Element_BRMT::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if (TYP(r)==PT_BREC && !(rand()%tempFactor))
|
||||
if (TYP(r)==PT_BREC && !(random_gen()%tempFactor))
|
||||
{
|
||||
if(rand()%2)
|
||||
if(random_gen()%2)
|
||||
{
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_THRM);
|
||||
}
|
||||
else
|
||||
sim->create_part(i, x, y, PT_THRM);
|
||||
//part_change_type(ID(r),x+rx,y+ry,PT_BMTL);
|
||||
//parts[ID(r)].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100;
|
||||
//parts[ID(r)].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(random_gen()%5);//random_gen()/(RAND_MAX/300)+100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,11 +58,11 @@ int Element_C5::update(UPDATE_FUNC_ARGS)
|
||||
continue;
|
||||
if ((TYP(r)!=PT_C5 && parts[ID(r)].temp<100 && sim->elements[TYP(r)].HeatConduct && (TYP(r)!=PT_HSWC||parts[ID(r)].life==10)) || TYP(r)==PT_CFLM)
|
||||
{
|
||||
if (!(rand()%6))
|
||||
if (!(random_gen()%6))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_CFLM);
|
||||
parts[ID(r)].temp = parts[i].temp = 0;
|
||||
parts[i].life = rand()%150+50;
|
||||
parts[i].life = random_gen()%150+50;
|
||||
sim->pv[y/CELL][x/CELL] += 1.5;
|
||||
}
|
||||
}
|
||||
|
@ -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 > (rand()%1000)) && parts[i].life >= 50)
|
||||
if ((TYP(r) != PT_CLNE && TYP(r) != PT_PCLN && 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)
|
||||
|
@ -51,7 +51,7 @@ int Element_CBNW::update(UPDATE_FUNC_ARGS)
|
||||
int r, rx, ry;
|
||||
if (sim->pv[y/CELL][x/CELL]<=3)
|
||||
{
|
||||
if (sim->pv[y/CELL][x/CELL] <= -0.5 || !(rand()%4000))
|
||||
if (sim->pv[y/CELL][x/CELL] <= -0.5 || !(random_gen()%4000))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_CO2);
|
||||
parts[i].ctype = 5;
|
||||
@ -61,15 +61,15 @@ int Element_CBNW::update(UPDATE_FUNC_ARGS)
|
||||
if (parts[i].tmp2!=20) {
|
||||
parts[i].tmp2 -= (parts[i].tmp2>20)?1:-1;
|
||||
}
|
||||
else if(!(rand()%200))
|
||||
else if(!(random_gen()%200))
|
||||
{
|
||||
parts[i].tmp2 = rand()%40;
|
||||
parts[i].tmp2 = random_gen()%40;
|
||||
}
|
||||
|
||||
if(parts[i].tmp>0)
|
||||
{
|
||||
//Explode
|
||||
if(parts[i].tmp==1 && rand()%4)
|
||||
if(parts[i].tmp==1 && random_gen()%4)
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_CO2);
|
||||
parts[i].ctype = 5;
|
||||
@ -84,12 +84,12 @@ int Element_CBNW::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((sim->elements[TYP(r)].Properties&TYPE_PART) && parts[i].tmp == 0 && !(rand()%83))
|
||||
if ((sim->elements[TYP(r)].Properties&TYPE_PART) && parts[i].tmp == 0 && !(random_gen()%83))
|
||||
{
|
||||
//Start explode
|
||||
parts[i].tmp = rand()%25;//(rand()%100)+50;
|
||||
parts[i].tmp = random_gen()%25;//(random_gen()%100)+50;
|
||||
}
|
||||
else if((sim->elements[TYP(r)].Properties&TYPE_SOLID) && TYP(r)!=PT_DMND && TYP(r)!=PT_GLAS && parts[i].tmp == 0 && (2-sim->pv[y/CELL][x/CELL])>(rand()%6667))
|
||||
else if((sim->elements[TYP(r)].Properties&TYPE_SOLID) && TYP(r)!=PT_DMND && TYP(r)!=PT_GLAS && parts[i].tmp == 0 && (2-sim->pv[y/CELL][x/CELL])>(random_gen()%6667))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_CO2);
|
||||
parts[i].ctype = 5;
|
||||
@ -115,7 +115,7 @@ int Element_CBNW::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (TYP(r)==PT_RBDM||TYP(r)==PT_LRBD)
|
||||
{
|
||||
if ((sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(rand()%166))
|
||||
if ((sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(random_gen()%166))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_FIRE);
|
||||
parts[i].life = 4;
|
||||
@ -124,7 +124,7 @@ int Element_CBNW::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (TYP(r)==PT_FIRE && parts[ID(r)].ctype!=PT_WATR){
|
||||
sim->kill_part(ID(r));
|
||||
if(!(rand()%50)){
|
||||
if(!(random_gen()%50)){
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
}
|
||||
|
@ -72,10 +72,10 @@ int Element_CLNE::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_LIFE, parts[i].tmp);
|
||||
else if (parts[i].ctype!=PT_LIGH || (rand()%30)==0)
|
||||
if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x+random_gen()%3-1, y+random_gen()%3-1, PT_LIFE, parts[i].tmp);
|
||||
else if (parts[i].ctype!=PT_LIGH || (random_gen()%30)==0)
|
||||
{
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, TYP(parts[i].ctype));
|
||||
int np = sim->create_part(-1, x+random_gen()%3-1, y+random_gen()%3-1, TYP(parts[i].ctype));
|
||||
if (np>=0)
|
||||
{
|
||||
if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmp<PT_NUM && sim->elements[parts[i].tmp].HighTemperatureTransition==PT_LAVA)
|
||||
|
@ -59,7 +59,7 @@ int Element_CLST::update(UPDATE_FUNC_ARGS)
|
||||
continue;
|
||||
if (TYP(r)==PT_WATR)
|
||||
{
|
||||
if (!(rand()%1500))
|
||||
if (!(random_gen()%1500))
|
||||
{
|
||||
sim->create_part(i, x, y, PT_PSTS);
|
||||
sim->kill_part(ID(r));
|
||||
|
@ -55,7 +55,7 @@ int Element_CO2::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
{
|
||||
if (parts[i].ctype==5 && !(rand()%2000))
|
||||
if (parts[i].ctype==5 && !(random_gen()%2000))
|
||||
{
|
||||
if (sim->create_part(-1, x+rx, y+ry, PT_WATR)>=0)
|
||||
parts[i].ctype = 0;
|
||||
@ -64,12 +64,12 @@ int Element_CO2::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
if (TYP(r)==PT_FIRE){
|
||||
sim->kill_part(ID(r));
|
||||
if(!(rand()%30)){
|
||||
if(!(random_gen()%30)){
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if ((TYP(r)==PT_WATR || TYP(r)==PT_DSTW) && !(rand()%50))
|
||||
else if ((TYP(r)==PT_WATR || TYP(r)==PT_DSTW) && !(random_gen()%50))
|
||||
{
|
||||
sim->part_change_type(ID(r), x+rx, y+ry, PT_CBNW);
|
||||
if (parts[i].ctype==5) //conserve number of water particles - ctype=5 means this CO2 hasn't released the water particle from BUBW yet
|
||||
@ -86,14 +86,14 @@ int Element_CO2::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
if (parts[i].temp > 9773.15 && sim->pv[y/CELL][x/CELL] > 200.0f)
|
||||
{
|
||||
if (!(rand()%5))
|
||||
if (!(random_gen()%5))
|
||||
{
|
||||
int j;
|
||||
sim->create_part(i,x,y,PT_O2);
|
||||
j = sim->create_part(-3,x,y,PT_NEUT);
|
||||
if (j != -1)
|
||||
parts[j].temp = MAX_TEMP;
|
||||
if (!(rand()%50))
|
||||
if (!(random_gen()%50))
|
||||
{
|
||||
j = sim->create_part(-3,x,y,PT_ELEC);
|
||||
if (j != -1)
|
||||
|
@ -54,7 +54,7 @@ int Element_COAL::update(UPDATE_FUNC_ARGS)
|
||||
return 1;
|
||||
} else if (parts[i].life < 100) {
|
||||
parts[i].life--;
|
||||
sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE);
|
||||
sim->create_part(-1, x+random_gen()%3-1, y+random_gen()%3-1, PT_FIRE);
|
||||
}
|
||||
if (parts[i].type == PT_COAL)
|
||||
{
|
||||
|
@ -48,8 +48,8 @@ Element_DEST::Element_DEST()
|
||||
//#TPT-Directive ElementHeader Element_DEST static int update(UPDATE_FUNC_ARGS)
|
||||
int Element_DEST::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
int rx = rand()%5-2;
|
||||
int ry = rand()%5-2;
|
||||
int rx = random_gen()%5-2;
|
||||
int ry = random_gen()%5-2;
|
||||
int r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
return 0;
|
||||
@ -59,13 +59,13 @@ int Element_DEST::update(UPDATE_FUNC_ARGS)
|
||||
|
||||
if (parts[i].life<=0 || parts[i].life>37)
|
||||
{
|
||||
parts[i].life=30+rand()%20;
|
||||
parts[i].life=30+random_gen()%20;
|
||||
sim->pv[y/CELL][x/CELL]+=60.0f;
|
||||
}
|
||||
if (rt == PT_PLUT || rt == PT_DEUT)
|
||||
{
|
||||
sim->pv[y/CELL][x/CELL]+=20.0f;
|
||||
if (rand()%2)
|
||||
if (random_gen()%2)
|
||||
{
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_NEUT);
|
||||
parts[ID(r)].temp = MAX_TEMP;
|
||||
@ -77,7 +77,7 @@ int Element_DEST::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_PLSM);
|
||||
}
|
||||
else if (!(rand()%3))
|
||||
else if (!(random_gen()%3))
|
||||
{
|
||||
sim->kill_part(ID(r));
|
||||
parts[i].life -= 4*((sim->elements[rt].Properties&TYPE_SOLID)?3:1);
|
||||
|
@ -51,7 +51,7 @@ int Element_DEUT::update(UPDATE_FUNC_ARGS)
|
||||
int r, rx, ry, trade, np;
|
||||
float gravtot = fabs(sim->gravy[(y/CELL)*(XRES/CELL)+(x/CELL)])+fabs(sim->gravx[(y/CELL)*(XRES/CELL)+(x/CELL)]);
|
||||
int maxlife = ((10000/(parts[i].temp + 1))-1);
|
||||
if ((10000%((int)parts[i].temp + 1))>rand()%((int)parts[i].temp + 1))
|
||||
if ((10000%((int)parts[i].temp + 1))>random_gen()%((int)parts[i].temp + 1))
|
||||
maxlife ++;
|
||||
// Compress when Newtonian gravity is applied
|
||||
// multiplier=1 when gravtot=0, multiplier -> 5 as gravtot -> inf
|
||||
@ -65,7 +65,7 @@ int Element_DEUT::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r || (parts[i].life >=maxlife))
|
||||
continue;
|
||||
if (TYP(r)==PT_DEUT&& !(rand()%3))
|
||||
if (TYP(r)==PT_DEUT&& !(random_gen()%3))
|
||||
{
|
||||
// If neighbour life+1 fits in the free capacity for this particle, absorb neighbour
|
||||
// Condition is written in this way so that large neighbour life values don't cause integer overflow
|
||||
@ -98,8 +98,8 @@ int Element_DEUT::update(UPDATE_FUNC_ARGS)
|
||||
trade:
|
||||
for ( trade = 0; trade<4; trade ++)
|
||||
{
|
||||
rx = rand()%5-2;
|
||||
ry = rand()%5-2;
|
||||
rx = random_gen()%5-2;
|
||||
ry = random_gen()%5-2;
|
||||
if (BOUNDS_CHECK && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
|
@ -56,29 +56,29 @@ int Element_DSTW::update(UPDATE_FUNC_ARGS)
|
||||
switch (TYP(r))
|
||||
{
|
||||
case PT_SALT:
|
||||
if (!(rand()%50))
|
||||
if (!(random_gen()%50))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SLTW);
|
||||
// on average, convert 3 DSTW to SLTW before SALT turns into SLTW
|
||||
if (!(rand()%3))
|
||||
if (!(random_gen()%3))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW);
|
||||
}
|
||||
break;
|
||||
case PT_SLTW:
|
||||
if (!(rand()%2000))
|
||||
if (!(random_gen()%2000))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SLTW);
|
||||
break;
|
||||
}
|
||||
case PT_WATR:
|
||||
if (!(rand()%100))
|
||||
if (!(random_gen()%100))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_WATR);
|
||||
}
|
||||
break;
|
||||
case PT_RBDM:
|
||||
case PT_LRBD:
|
||||
if ((sim->legacy_enable||parts[i].temp>12.0f) && !(rand()%100))
|
||||
if ((sim->legacy_enable||parts[i].temp>12.0f) && !(random_gen()%100))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_FIRE);
|
||||
parts[i].life = 4;
|
||||
@ -86,7 +86,7 @@ int Element_DSTW::update(UPDATE_FUNC_ARGS)
|
||||
break;
|
||||
case PT_FIRE:
|
||||
sim->kill_part(ID(r));
|
||||
if(!(rand()%30)){
|
||||
if(!(random_gen()%30)){
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
}
|
||||
|
@ -69,20 +69,20 @@ int Element_ELEC::update(UPDATE_FUNC_ARGS)
|
||||
parts[nb].tmp = 0;
|
||||
parts[nb].life = 50;
|
||||
parts[nb].temp = parts[i].temp*0.8f;
|
||||
parts[nb].vx = rand()%20-10;
|
||||
parts[nb].vy = rand()%20-10;
|
||||
parts[nb].vx = random_gen()%20-10;
|
||||
parts[nb].vy = random_gen()%20-10;
|
||||
}
|
||||
}
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
case PT_LCRY:
|
||||
parts[ID(r)].tmp2 = 5+rand()%5;
|
||||
parts[ID(r)].tmp2 = 5+random_gen()%5;
|
||||
break;
|
||||
case PT_WATR:
|
||||
case PT_DSTW:
|
||||
case PT_SLTW:
|
||||
case PT_CBNW:
|
||||
if(!(rand()%3))
|
||||
if(!(random_gen()%3))
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_O2);
|
||||
else
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_H2);
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
}
|
||||
void apply(Simulation *sim, Particle &p)
|
||||
{
|
||||
p.temp = restrict_flt(p.temp+getDelta(Probability::randFloat()), MIN_TEMP, MAX_TEMP);
|
||||
p.temp = restrict_flt(p.temp+getDelta(random_gen.uniform01()), MIN_TEMP, MAX_TEMP);
|
||||
}
|
||||
};
|
||||
|
||||
@ -120,9 +120,9 @@ int Element_EMP::Trigger(Simulation *sim, int triggerCount)
|
||||
{
|
||||
is_elec = true;
|
||||
temp_center.apply(sim, parts[r]);
|
||||
if (Probability::randFloat() < prob_changeCenter)
|
||||
if (random_gen.uniform01() < prob_changeCenter)
|
||||
{
|
||||
if (rand()%5 < 2)
|
||||
if (random_gen()%5 < 2)
|
||||
sim->part_change_type(r, rx, ry, PT_BREC);
|
||||
else
|
||||
sim->part_change_type(r, rx, ry, PT_NTCT);
|
||||
@ -145,10 +145,10 @@ int Element_EMP::Trigger(Simulation *sim, int triggerCount)
|
||||
{
|
||||
case PT_METL:
|
||||
temp_metal.apply(sim, parts[n]);
|
||||
if (Probability::randFloat() < prob_breakMETL)
|
||||
if (random_gen.uniform01() < prob_breakMETL)
|
||||
{
|
||||
sim->part_change_type(n, rx+nx, ry+ny, PT_BMTL);
|
||||
if (Probability::randFloat() < prob_breakMETLMore)
|
||||
if (random_gen.uniform01() < prob_breakMETLMore)
|
||||
{
|
||||
sim->part_change_type(n, rx+nx, ry+ny, PT_BRMT);
|
||||
parts[n].temp = restrict_flt(parts[n].temp+1000.0f, MIN_TEMP, MAX_TEMP);
|
||||
@ -157,19 +157,19 @@ int Element_EMP::Trigger(Simulation *sim, int triggerCount)
|
||||
break;
|
||||
case PT_BMTL:
|
||||
temp_metal.apply(sim, parts[n]);
|
||||
if (Probability::randFloat() < prob_breakBMTL)
|
||||
if (random_gen.uniform01() < prob_breakBMTL)
|
||||
{
|
||||
sim->part_change_type(n, rx+nx, ry+ny, PT_BRMT);
|
||||
parts[n].temp = restrict_flt(parts[n].temp+1000.0f, MIN_TEMP, MAX_TEMP);
|
||||
}
|
||||
break;
|
||||
case PT_WIFI:
|
||||
if (Probability::randFloat() < prob_randWIFI)
|
||||
if (random_gen.uniform01() < prob_randWIFI)
|
||||
{
|
||||
// Randomize channel
|
||||
parts[n].temp = rand()%MAX_TEMP;
|
||||
parts[n].temp = random_gen()%MAX_TEMP;
|
||||
}
|
||||
if (Probability::randFloat() < prob_breakWIFI)
|
||||
if (random_gen.uniform01() < prob_breakWIFI)
|
||||
{
|
||||
sim->create_part(n, rx+nx, ry+ny, PT_BREC);
|
||||
parts[n].temp = restrict_flt(parts[n].temp+1000.0f, MIN_TEMP, MAX_TEMP);
|
||||
@ -182,22 +182,22 @@ int Element_EMP::Trigger(Simulation *sim, int triggerCount)
|
||||
switch (ntype)
|
||||
{
|
||||
case PT_SWCH:
|
||||
if (Probability::randFloat() < prob_breakSWCH)
|
||||
if (random_gen.uniform01() < prob_breakSWCH)
|
||||
sim->part_change_type(n, rx+nx, ry+ny, PT_BREC);
|
||||
temp_SWCH.apply(sim, parts[n]);
|
||||
break;
|
||||
case PT_ARAY:
|
||||
if (Probability::randFloat() < prob_breakARAY)
|
||||
if (random_gen.uniform01() < prob_breakARAY)
|
||||
{
|
||||
sim->create_part(n, rx+nx, ry+ny, PT_BREC);
|
||||
parts[n].temp = restrict_flt(parts[n].temp+1000.0f, MIN_TEMP, MAX_TEMP);
|
||||
}
|
||||
break;
|
||||
case PT_DLAY:
|
||||
if (Probability::randFloat() < prob_randDLAY)
|
||||
if (random_gen.uniform01() < prob_randDLAY)
|
||||
{
|
||||
// Randomize delay
|
||||
parts[n].temp = (rand()%256) + 273.15f;
|
||||
parts[n].temp = (random_gen()%256) + 273.15f;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -59,7 +59,7 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS)
|
||||
rt = TYP(r);
|
||||
if (rt == PT_WARP)
|
||||
{
|
||||
if (parts[ID(r)].tmp2>2000 && !(rand()%100))
|
||||
if (parts[ID(r)].tmp2>2000 && !(random_gen()%100))
|
||||
{
|
||||
parts[i].tmp2 += 100;
|
||||
}
|
||||
@ -68,7 +68,7 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (parts[ID(r)].ctype == PT_PROT)
|
||||
parts[i].ctype = PT_PROT;
|
||||
if (parts[ID(r)].life == 1500 && !(rand()%1000))
|
||||
if (parts[ID(r)].life == 1500 && !(random_gen()%1000))
|
||||
parts[i].life = 1500;
|
||||
}
|
||||
else if (rt == PT_LAVA)
|
||||
@ -76,7 +76,7 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS)
|
||||
//turn molten TTAN or molten GOLD to molten VIBR
|
||||
if (parts[ID(r)].ctype == PT_TTAN || parts[ID(r)].ctype == PT_GOLD)
|
||||
{
|
||||
if (!(rand()%10))
|
||||
if (!(random_gen()%10))
|
||||
{
|
||||
parts[ID(r)].ctype = PT_VIBR;
|
||||
sim->kill_part(i);
|
||||
@ -86,7 +86,7 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS)
|
||||
//molten VIBR will kill the leftover EXOT though, so the VIBR isn't killed later
|
||||
else if (parts[ID(r)].ctype == PT_VIBR)
|
||||
{
|
||||
if (!(rand()%1000))
|
||||
if (!(random_gen()%1000))
|
||||
{
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
@ -131,8 +131,8 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
for (trade = 0; trade < 9; trade++)
|
||||
{
|
||||
rx = rand()%5-2;
|
||||
ry = rand()%5-2;
|
||||
rx = random_gen()%5-2;
|
||||
ry = random_gen()%5-2;
|
||||
if (BOUNDS_CHECK && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
@ -186,7 +186,7 @@ int Element_EXOT::graphics(GRAPHICS_FUNC_ARGS)
|
||||
int c = cpart->tmp2;
|
||||
if (cpart->life < 1001)
|
||||
{
|
||||
if ((cpart->tmp2 - 1)>rand()%1000)
|
||||
if ((cpart->tmp2 - 1)>random_gen()%1000)
|
||||
{
|
||||
float frequency = 0.04045;
|
||||
*colr = (sin(frequency*c + 4) * 127 + 150);
|
||||
|
@ -99,15 +99,15 @@ int Element::legacyUpdate(UPDATE_FUNC_ARGS) {
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((TYP(r)==PT_WATR||TYP(r)==PT_DSTW||TYP(r)==PT_SLTW) && 1>(rand()%1000))
|
||||
if ((TYP(r)==PT_WATR||TYP(r)==PT_DSTW||TYP(r)==PT_SLTW) && 1>(random_gen()%1000))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_WATR);
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_WATR);
|
||||
}
|
||||
if ((TYP(r)==PT_ICEI || TYP(r)==PT_SNOW) && 1>(rand()%1000))
|
||||
if ((TYP(r)==PT_ICEI || TYP(r)==PT_SNOW) && 1>(random_gen()%1000))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_WATR);
|
||||
if (1>(rand()%1000))
|
||||
if (1>(random_gen()%1000))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_WATR);
|
||||
}
|
||||
}
|
||||
@ -121,7 +121,7 @@ int Element::legacyUpdate(UPDATE_FUNC_ARGS) {
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((TYP(r)==PT_FIRE || TYP(r)==PT_LAVA) && 1>(rand()%10))
|
||||
if ((TYP(r)==PT_FIRE || TYP(r)==PT_LAVA) && 1>(random_gen()%10))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_WTRV);
|
||||
}
|
||||
@ -136,9 +136,9 @@ int Element::legacyUpdate(UPDATE_FUNC_ARGS) {
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((TYP(r)==PT_FIRE || TYP(r)==PT_LAVA) && 1>(rand()%10))
|
||||
if ((TYP(r)==PT_FIRE || TYP(r)==PT_LAVA) && 1>(random_gen()%10))
|
||||
{
|
||||
if (rand()%4==0) sim->part_change_type(i,x,y,PT_SALT);
|
||||
if (random_gen()%4==0) sim->part_change_type(i,x,y,PT_SALT);
|
||||
else sim->part_change_type(i,x,y,PT_WTRV);
|
||||
}
|
||||
}
|
||||
@ -152,7 +152,7 @@ int Element::legacyUpdate(UPDATE_FUNC_ARGS) {
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((TYP(r)==PT_FIRE || TYP(r)==PT_LAVA) && 1>(rand()%10))
|
||||
if ((TYP(r)==PT_FIRE || TYP(r)==PT_LAVA) && 1>(random_gen()%10))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_WTRV);
|
||||
}
|
||||
@ -166,7 +166,7 @@ int Element::legacyUpdate(UPDATE_FUNC_ARGS) {
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((TYP(r)==PT_WATR || TYP(r)==PT_DSTW) && 1>(rand()%1000))
|
||||
if ((TYP(r)==PT_WATR || TYP(r)==PT_DSTW) && 1>(random_gen()%1000))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_ICEI);
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_ICEI);
|
||||
@ -181,12 +181,12 @@ int Element::legacyUpdate(UPDATE_FUNC_ARGS) {
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((TYP(r)==PT_WATR || TYP(r)==PT_DSTW) && 1>(rand()%1000))
|
||||
if ((TYP(r)==PT_WATR || TYP(r)==PT_DSTW) && 1>(random_gen()%1000))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_ICEI);
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_ICEI);
|
||||
}
|
||||
if ((TYP(r)==PT_WATR || TYP(r)==PT_DSTW) && 15>(rand()%1000))
|
||||
if ((TYP(r)==PT_WATR || TYP(r)==PT_DSTW) && 15>(random_gen()%1000))
|
||||
sim->part_change_type(i,x,y,PT_WATR);
|
||||
}
|
||||
}
|
||||
@ -199,7 +199,7 @@ int Element::legacyUpdate(UPDATE_FUNC_ARGS) {
|
||||
if (t==PT_DESL && sim->pv[y/CELL][x/CELL]>12.0f)
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_FIRE);
|
||||
parts[i].life = rand()%50+120;
|
||||
parts[i].life = random_gen()%50+120;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -108,9 +108,9 @@ int Element_FILT::interactWavelengths(Particle* cpart, int origWl)
|
||||
return (~origWl) & mask; // Invert colours
|
||||
case 9:
|
||||
{
|
||||
int t1 = (origWl & 0x0000FF)+(rand()%5)-2;
|
||||
int t2 = ((origWl & 0x00FF00)>>8)+(rand()%5)-2;
|
||||
int t3 = ((origWl & 0xFF0000)>>16)+(rand()%5)-2;
|
||||
int t1 = (origWl & 0x0000FF)+(random_gen()%5)-2;
|
||||
int t2 = ((origWl & 0x00FF00)>>8)+(random_gen()%5)-2;
|
||||
int t3 = ((origWl & 0xFF0000)>>16)+(random_gen()%5)-2;
|
||||
return (origWl & 0xFF000000) | (t3<<16) | (t2<<8) | t1;
|
||||
}
|
||||
case 10:
|
||||
|
@ -79,7 +79,7 @@ int Element_FIRE::update(UPDATE_FUNC_ARGS)
|
||||
else if (parts[i].temp<625)
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SMKE);
|
||||
parts[i].life = rand()%20+250;
|
||||
parts[i].life = random_gen()%20+250;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -98,7 +98,7 @@ int Element_FIRE::update(UPDATE_FUNC_ARGS)
|
||||
//THRM burning
|
||||
if (rt==PT_THRM && (t==PT_FIRE || t==PT_PLSM || t==PT_LAVA))
|
||||
{
|
||||
if (!(rand()%500)) {
|
||||
if (!(random_gen()%500)) {
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_LAVA);
|
||||
parts[ID(r)].ctype = PT_BMTL;
|
||||
parts[ID(r)].temp = 3500.0f;
|
||||
@ -117,13 +117,13 @@ int Element_FIRE::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if ((t==PT_FIRE || t==PT_PLSM))
|
||||
{
|
||||
if (parts[ID(r)].life>100 && !(rand()%500)) {
|
||||
if (parts[ID(r)].life>100 && !(random_gen()%500)) {
|
||||
parts[ID(r)].life = 99;
|
||||
}
|
||||
}
|
||||
else if (t==PT_LAVA)
|
||||
{
|
||||
if (parts[i].ctype == PT_IRON && !(rand()%500)) {
|
||||
if (parts[i].ctype == PT_IRON && !(random_gen()%500)) {
|
||||
parts[i].ctype = PT_METL;
|
||||
sim->kill_part(ID(r));
|
||||
}
|
||||
@ -144,7 +144,7 @@ int Element_FIRE::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (rt == PT_HEAC && parts[i].ctype == PT_HEAC)
|
||||
{
|
||||
if (parts[ID(r)].temp > sim->elements[PT_HEAC].HighTemperature && rand()%200)
|
||||
if (parts[ID(r)].temp > sim->elements[PT_HEAC].HighTemperature && random_gen()%200)
|
||||
{
|
||||
sim->part_change_type(ID(r), x+rx, y+ry, PT_LAVA);
|
||||
parts[ID(r)].ctype = PT_HEAC;
|
||||
@ -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)) > (rand()%1000) &&
|
||||
sim->elements[rt].Flammable && (sim->elements[rt].Flammable + (int)(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) &&
|
||||
@ -161,7 +161,7 @@ int Element_FIRE::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
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)].life = rand()%80+180;
|
||||
parts[ID(r)].life = random_gen()%80+180;
|
||||
parts[ID(r)].tmp = parts[ID(r)].ctype = 0;
|
||||
if (sim->elements[rt].Explosive)
|
||||
sim->pv[y/CELL][x/CELL] += 0.25f * CFDS;
|
||||
@ -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>(rand()%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)) &&sim->elements[rt].Meltable*lpv>(random_gen()%1000))
|
||||
{
|
||||
if (t!=PT_LAVA || parts[i].life>0)
|
||||
{
|
||||
@ -199,7 +199,7 @@ int Element_FIRE::updateLegacy(UPDATE_FUNC_ARGS) {
|
||||
else
|
||||
parts[ID(r)].ctype = rt;
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_LAVA);
|
||||
parts[ID(r)].life = rand()%120+240;
|
||||
parts[ID(r)].life = random_gen()%120+240;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -68,12 +68,12 @@ int Element_FIRW::update(UPDATE_FUNC_ARGS)
|
||||
sim->GetGravityField(x, y, sim->elements[PT_FIRW].Gravity, 1.0f, gx, gy);
|
||||
if (gx*gx+gy*gy < 0.001f)
|
||||
{
|
||||
float angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi)
|
||||
float angle = (random_gen()%6284)*0.001f;//(in radians, between 0 and 2*pi)
|
||||
gx += sinf(angle)*sim->elements[PT_FIRW].Gravity*0.5f;
|
||||
gy += cosf(angle)*sim->elements[PT_FIRW].Gravity*0.5f;
|
||||
}
|
||||
parts[i].tmp = 1;
|
||||
parts[i].life = rand()%10+20;
|
||||
parts[i].life = random_gen()%10+20;
|
||||
multiplier = (parts[i].life+20)*0.2f/sqrtf(gx*gx+gy*gy);
|
||||
parts[i].vx -= gx*multiplier;
|
||||
parts[i].vy -= gy*multiplier;
|
||||
@ -91,7 +91,7 @@ int Element_FIRW::update(UPDATE_FUNC_ARGS)
|
||||
else //if (parts[i].tmp>=2)
|
||||
{
|
||||
float angle, magnitude;
|
||||
int caddress = (rand()%200)*3;
|
||||
int caddress = (random_gen()%200)*3;
|
||||
int n;
|
||||
unsigned col = (((firw_data[caddress]))<<16) | (((firw_data[caddress+1]))<<8) | ((firw_data[caddress+2]));
|
||||
for (n=0; n<40; n++)
|
||||
@ -99,14 +99,14 @@ int Element_FIRW::update(UPDATE_FUNC_ARGS)
|
||||
np = sim->create_part(-3, x, y, PT_EMBR);
|
||||
if (np>-1)
|
||||
{
|
||||
magnitude = ((rand()%60)+40)*0.05f;
|
||||
angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi)
|
||||
magnitude = ((random_gen()%60)+40)*0.05f;
|
||||
angle = (random_gen()%6284)*0.001f;//(in radians, between 0 and 2*pi)
|
||||
parts[np].vx = parts[i].vx*0.5f + cosf(angle)*magnitude;
|
||||
parts[np].vy = parts[i].vy*0.5f + sinf(angle)*magnitude;
|
||||
parts[np].ctype = col;
|
||||
parts[np].tmp = 1;
|
||||
parts[np].life = rand()%40+70;
|
||||
parts[np].temp = (rand()%500)+5750.0f;
|
||||
parts[np].life = random_gen()%40+70;
|
||||
parts[np].temp = (random_gen()%500)+5750.0f;
|
||||
parts[np].dcolour = parts[i].dcolour;
|
||||
}
|
||||
}
|
||||
|
@ -55,13 +55,13 @@ int Element_FOG::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((sim->elements[TYP(r)].Properties&TYPE_SOLID) && !(rand()%10) && parts[i].life==0 && !(TYP(r)==PT_CLNE || TYP(r)==PT_PCLN)) // TODO: should this also exclude BCLN?
|
||||
if ((sim->elements[TYP(r)].Properties&TYPE_SOLID) && !(random_gen()%10) && parts[i].life==0 && !(TYP(r)==PT_CLNE || TYP(r)==PT_PCLN)) // TODO: should this also exclude BCLN?
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_RIME);
|
||||
}
|
||||
if (TYP(r)==PT_SPRK)
|
||||
{
|
||||
parts[i].life += rand()%20;
|
||||
parts[i].life += random_gen()%20;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -55,12 +55,12 @@ int Element_FRZW::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if (TYP(r)==PT_WATR && !(rand()%14))
|
||||
if (TYP(r)==PT_WATR && !(random_gen()%14))
|
||||
{
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_FRZW);
|
||||
}
|
||||
}
|
||||
if ((parts[i].life==0 && !(rand()%192)) || (100-(parts[i].life))>rand()%50000 )
|
||||
if ((parts[i].life==0 && !(random_gen()%192)) || (100-(parts[i].life))>random_gen()%50000 )
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_ICEI);
|
||||
parts[i].ctype=PT_FRZW;
|
||||
|
@ -55,7 +55,7 @@ int Element_FRZZ::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if (TYP(r)==PT_WATR && !(rand()%20))
|
||||
if (TYP(r)==PT_WATR && !(random_gen()%20))
|
||||
{
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_FRZW);
|
||||
parts[ID(r)].life = 100;
|
||||
|
@ -56,8 +56,8 @@ int Element_FSEP::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (parts[i].life < 40) {
|
||||
parts[i].life--;
|
||||
if (!(rand()%10)) {
|
||||
r = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_PLSM);
|
||||
if (!(random_gen()%10)) {
|
||||
r = sim->create_part(-1, x+random_gen()%3-1, y+random_gen()%3-1, PT_PLSM);
|
||||
if (r>-1)
|
||||
parts[r].life = 50;
|
||||
}
|
||||
@ -70,7 +70,7 @@ int Element_FSEP::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((TYP(r)==PT_SPRK || (parts[i].temp>=(273.15+400.0f))) && parts[i].life>40 && !(rand()%15))
|
||||
if ((TYP(r)==PT_SPRK || (parts[i].temp>=(273.15+400.0f))) && parts[i].life>40 && !(random_gen()%15))
|
||||
{
|
||||
parts[i].life = 39;
|
||||
}
|
||||
|
@ -56,8 +56,8 @@ int Element_FUSE::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (parts[i].life < 40) {
|
||||
parts[i].life--;
|
||||
if (!(rand()%100)) {
|
||||
r = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_PLSM);
|
||||
if (!(random_gen()%100)) {
|
||||
r = sim->create_part(-1, x+random_gen()%3-1, y+random_gen()%3-1, PT_PLSM);
|
||||
if (r>-1)
|
||||
parts[r].life = 50;
|
||||
}
|
||||
@ -78,7 +78,7 @@ int Element_FUSE::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if (TYP(r)==PT_SPRK || (parts[i].temp>=(273.15+700.0f) && !(rand()%20)))
|
||||
if (TYP(r)==PT_SPRK || (parts[i].temp>=(273.15+700.0f) && !(random_gen()%20)))
|
||||
{
|
||||
if (parts[i].life > 40)
|
||||
parts[i].life = 39;
|
||||
|
@ -49,14 +49,14 @@ Element_FWRK::Element_FWRK()
|
||||
//#TPT-Directive ElementHeader Element_FWRK static int update(UPDATE_FUNC_ARGS)
|
||||
int Element_FWRK::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (parts[i].life == 0 && ((surround_space && parts[i].temp>400 && (9+parts[i].temp/40)>rand()%100000) || parts[i].ctype == PT_DUST))
|
||||
if (parts[i].life == 0 && ((surround_space && parts[i].temp>400 && (9+parts[i].temp/40)>random_gen()%100000) || parts[i].ctype == PT_DUST))
|
||||
{
|
||||
float gx, gy, multiplier, gmax;
|
||||
int randTmp;
|
||||
sim->GetGravityField(x, y, sim->elements[PT_FWRK].Gravity, 1.0f, gx, gy);
|
||||
if (gx*gx+gy*gy < 0.001f)
|
||||
{
|
||||
float angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi)
|
||||
float angle = (random_gen()%6284)*0.001f;//(in radians, between 0 and 2*pi)
|
||||
gx += sinf(angle)*sim->elements[PT_FWRK].Gravity*0.5f;
|
||||
gy += cosf(angle)*sim->elements[PT_FWRK].Gravity*0.5f;
|
||||
}
|
||||
@ -66,15 +66,15 @@ int Element_FWRK::update(UPDATE_FUNC_ARGS)
|
||||
multiplier = 15.0f/sqrtf(gx*gx+gy*gy);
|
||||
|
||||
//Some variation in speed parallel to gravity direction
|
||||
randTmp = (rand()%200)-100;
|
||||
randTmp = (random_gen()%200)-100;
|
||||
gx += gx*randTmp*0.002f;
|
||||
gy += gy*randTmp*0.002f;
|
||||
//and a bit more variation in speed perpendicular to gravity direction
|
||||
randTmp = (rand()%200)-100;
|
||||
randTmp = (random_gen()%200)-100;
|
||||
gx += -gy*randTmp*0.005f;
|
||||
gy += gx*randTmp*0.005f;
|
||||
|
||||
parts[i].life=rand()%10+18;
|
||||
parts[i].life=random_gen()%10+18;
|
||||
parts[i].ctype=0;
|
||||
parts[i].vx -= gx*multiplier;
|
||||
parts[i].vy -= gy*multiplier;
|
||||
@ -83,9 +83,9 @@ int Element_FWRK::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
if (parts[i].life<3&&parts[i].life>0)
|
||||
{
|
||||
int r = (rand()%245+11);
|
||||
int g = (rand()%245+11);
|
||||
int b = (rand()%245+11);
|
||||
int r = (random_gen()%245+11);
|
||||
int g = (random_gen()%245+11);
|
||||
int b = (random_gen()%245+11);
|
||||
int n;
|
||||
float angle, magnitude;
|
||||
unsigned col = (r<<16) | (g<<8) | b;
|
||||
@ -94,14 +94,14 @@ int Element_FWRK::update(UPDATE_FUNC_ARGS)
|
||||
int np = sim->create_part(-3, x, y, PT_EMBR);
|
||||
if (np>-1)
|
||||
{
|
||||
magnitude = ((rand()%60)+40)*0.05f;
|
||||
angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi)
|
||||
magnitude = ((random_gen()%60)+40)*0.05f;
|
||||
angle = (random_gen()%6284)*0.001f;//(in radians, between 0 and 2*pi)
|
||||
parts[np].vx = parts[i].vx*0.5f + cosf(angle)*magnitude;
|
||||
parts[np].vy = parts[i].vy*0.5f + sinf(angle)*magnitude;
|
||||
parts[np].ctype = col;
|
||||
parts[np].tmp = 1;
|
||||
parts[np].life = rand()%40+70;
|
||||
parts[np].temp = (rand()%500)+5750.0f;
|
||||
parts[np].life = random_gen()%40+70;
|
||||
parts[np].temp = (random_gen()%500)+5750.0f;
|
||||
parts[np].dcolour = parts[i].dcolour;
|
||||
}
|
||||
}
|
||||
|
@ -69,31 +69,31 @@ int Element_GEL::update(UPDATE_FUNC_ARGS)
|
||||
case PT_WATR:
|
||||
case PT_DSTW:
|
||||
case PT_FRZW:
|
||||
if (parts[i].tmp<100 && 500>rand()%absorbChanceDenom)
|
||||
if (parts[i].tmp<100 && 500>random_gen()%absorbChanceDenom)
|
||||
{
|
||||
parts[i].tmp++;
|
||||
sim->kill_part(ID(r));
|
||||
}
|
||||
break;
|
||||
case PT_PSTE:
|
||||
if (parts[i].tmp<100 && 20>rand()%absorbChanceDenom)
|
||||
if (parts[i].tmp<100 && 20>random_gen()%absorbChanceDenom)
|
||||
{
|
||||
parts[i].tmp++;
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_CLST);
|
||||
}
|
||||
break;
|
||||
case PT_SLTW:
|
||||
if (parts[i].tmp<100 && 50>rand()%absorbChanceDenom)
|
||||
if (parts[i].tmp<100 && 50>random_gen()%absorbChanceDenom)
|
||||
{
|
||||
parts[i].tmp++;
|
||||
if (rand()%4)
|
||||
if (random_gen()%4)
|
||||
sim->kill_part(ID(r));
|
||||
else
|
||||
sim->part_change_type(ID(r), x+rx, y+ry, PT_SALT);
|
||||
}
|
||||
break;
|
||||
case PT_CBNW:
|
||||
if (parts[i].tmp<100 && 100>rand()%absorbChanceDenom)
|
||||
if (parts[i].tmp<100 && 100>random_gen()%absorbChanceDenom)
|
||||
{
|
||||
parts[i].tmp++;
|
||||
sim->part_change_type(ID(r), x+rx, y+ry, PT_CO2);
|
||||
|
@ -56,7 +56,7 @@ int Element_GLOW::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if (TYP(r)==PT_WATR && !(rand()%400))
|
||||
if (TYP(r)==PT_WATR && !(random_gen()%400))
|
||||
{
|
||||
sim->kill_part(i);
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_DEUT);
|
||||
|
@ -55,7 +55,7 @@ int Element_GOLD::update(UPDATE_FUNC_ARGS)
|
||||
static int checkCoordsY[] = { 0, 0, -4, 4 };
|
||||
//Find nearby rusted iron (BMTL with tmp 1+)
|
||||
for(int j = 0; j < 8; j++){
|
||||
rndstore = rand();
|
||||
rndstore = random_gen();
|
||||
rx = (rndstore % 9)-4;
|
||||
rndstore >>= 4;
|
||||
ry = (rndstore % 9)-4;
|
||||
@ -89,7 +89,7 @@ int Element_GOLD::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
if (TYP(sim->photons[y][x]) == PT_NEUT)
|
||||
{
|
||||
if (!(rand()%7))
|
||||
if (!(random_gen()%7))
|
||||
{
|
||||
sim->kill_part(ID(sim->photons[y][x]));
|
||||
}
|
||||
@ -100,7 +100,7 @@ int Element_GOLD::update(UPDATE_FUNC_ARGS)
|
||||
//#TPT-Directive ElementHeader Element_GOLD static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
int Element_GOLD::graphics(GRAPHICS_FUNC_ARGS)
|
||||
{
|
||||
int rndstore = rand();
|
||||
int rndstore = random_gen();
|
||||
*colr += (rndstore % 10) - 5;
|
||||
rndstore >>= 4;
|
||||
*colg += (rndstore % 10)- 5;
|
||||
|
@ -51,7 +51,7 @@ Element_GOO::Element_GOO()
|
||||
int Element_GOO::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (!parts[i].life && sim->pv[y/CELL][x/CELL]>1.0f)
|
||||
parts[i].life = rand()%80+300;
|
||||
parts[i].life = random_gen()%80+300;
|
||||
if (parts[i].life)
|
||||
{
|
||||
parts[i].vx += ADVECTION*sim->vx[y/CELL][x/CELL];
|
||||
|
@ -50,7 +50,7 @@ Element_GRAV::Element_GRAV()
|
||||
//#TPT-Directive ElementHeader Element_GRAV static int update(UPDATE_FUNC_ARGS)
|
||||
int Element_GRAV::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (parts[i].vx*parts[i].vx + parts[i].vy*parts[i].vy >= 0.1f && (rand() % 512) == 0)
|
||||
if (parts[i].vx*parts[i].vx + parts[i].vy*parts[i].vy >= 0.1f && (random_gen() % 512) == 0)
|
||||
{
|
||||
if (!parts[i].life)
|
||||
parts[i].life = 48;
|
||||
|
@ -77,14 +77,14 @@ int Element_H2::update(UPDATE_FUNC_ARGS)
|
||||
parts[ID(r)].temp=2473.15f;
|
||||
parts[ID(r)].tmp |= 1;
|
||||
sim->create_part(i,x,y,PT_FIRE);
|
||||
parts[i].temp+=(rand()%100);
|
||||
parts[i].temp+=(random_gen()%100);
|
||||
parts[i].tmp |= 1;
|
||||
return 1;
|
||||
}
|
||||
else if ((rt==PT_PLSM && !(parts[ID(r)].tmp&4)) || (rt==PT_LAVA && parts[ID(r)].ctype != PT_BMTL))
|
||||
{
|
||||
sim->create_part(i,x,y,PT_FIRE);
|
||||
parts[i].temp+=(rand()%100);
|
||||
parts[i].temp+=(random_gen()%100);
|
||||
parts[i].tmp |= 1;
|
||||
return 1;
|
||||
}
|
||||
@ -92,7 +92,7 @@ int Element_H2::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
if (parts[i].temp > 2273.15 && sim->pv[y/CELL][x/CELL] > 50.0f)
|
||||
{
|
||||
if (!(rand()%5))
|
||||
if (!(random_gen()%5))
|
||||
{
|
||||
int j;
|
||||
float temp = parts[i].temp;
|
||||
@ -102,7 +102,7 @@ int Element_H2::update(UPDATE_FUNC_ARGS)
|
||||
j = sim->create_part(-3,x,y,PT_NEUT);
|
||||
if (j>-1)
|
||||
parts[j].temp = temp;
|
||||
if (!(rand()%10))
|
||||
if (!(random_gen()%10))
|
||||
{
|
||||
j = sim->create_part(-3,x,y,PT_ELEC);
|
||||
if (j>-1)
|
||||
@ -115,7 +115,7 @@ int Element_H2::update(UPDATE_FUNC_ARGS)
|
||||
parts[j].temp = temp;
|
||||
parts[j].tmp = 0x1;
|
||||
}
|
||||
rx = x+rand()%3-1, ry = y+rand()%3-1, rt = TYP(pmap[ry][rx]);
|
||||
rx = x+random_gen()%3-1, ry = y+random_gen()%3-1, rt = TYP(pmap[ry][rx]);
|
||||
if (sim->can_move[PT_PLSM][rt] || rt == PT_H2)
|
||||
{
|
||||
j = sim->create_part(-3,rx,ry,PT_PLSM);
|
||||
@ -125,7 +125,7 @@ int Element_H2::update(UPDATE_FUNC_ARGS)
|
||||
parts[j].tmp |= 4;
|
||||
}
|
||||
}
|
||||
parts[i].temp = temp+750+rand()%500;
|
||||
parts[i].temp = temp+750+random_gen()%500;
|
||||
sim->pv[y/CELL][x/CELL] += 30;
|
||||
return 1;
|
||||
}
|
||||
|
@ -61,14 +61,14 @@ int Element_ICEI::update(UPDATE_FUNC_ARGS)
|
||||
continue;
|
||||
if (TYP(r)==PT_SALT || TYP(r)==PT_SLTW)
|
||||
{
|
||||
if (parts[i].temp > sim->elements[PT_SLTW].LowTemperature && !(rand()%200))
|
||||
if (parts[i].temp > sim->elements[PT_SLTW].LowTemperature && !(random_gen()%200))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SLTW);
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if ((TYP(r)==PT_FRZZ) && !(rand()%200))
|
||||
else if ((TYP(r)==PT_FRZZ) && !(random_gen()%200))
|
||||
{
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_ICEI);
|
||||
parts[ID(r)].ctype = PT_FRZW;
|
||||
|
@ -66,20 +66,20 @@ int Element_IGNT::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if(parts[i].life > 0)
|
||||
{
|
||||
if(rand()%3)
|
||||
if(random_gen()%3)
|
||||
{
|
||||
int nb = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_EMBR);
|
||||
int nb = sim->create_part(-1, x+random_gen()%3-1, y+random_gen()%3-1, PT_EMBR);
|
||||
if (nb!=-1) {
|
||||
parts[nb].tmp = 0;
|
||||
parts[nb].life = 30;
|
||||
parts[nb].vx = rand()%20-10;
|
||||
parts[nb].vy = rand()%20-10;
|
||||
parts[nb].vx = random_gen()%20-10;
|
||||
parts[nb].vy = random_gen()%20-10;
|
||||
parts[nb].temp = restrict_flt(parts[i].temp-273.15f+400.0f, MIN_TEMP, MAX_TEMP);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE);
|
||||
sim->create_part(-1, x+random_gen()%3-1, y+random_gen()%3-1, PT_FIRE);
|
||||
}
|
||||
parts[i].life--;
|
||||
}
|
||||
|
@ -58,19 +58,19 @@ int Element_IRON::update(UPDATE_FUNC_ARGS)
|
||||
switch TYP(r)
|
||||
{
|
||||
case PT_SALT:
|
||||
if (!(rand()%47))
|
||||
if (!(random_gen()%47))
|
||||
goto succ;
|
||||
break;
|
||||
case PT_SLTW:
|
||||
if (!(rand()%67))
|
||||
if (!(random_gen()%67))
|
||||
goto succ;
|
||||
break;
|
||||
case PT_WATR:
|
||||
if (!(rand()%1200))
|
||||
if (!(random_gen()%1200))
|
||||
goto succ;
|
||||
break;
|
||||
case PT_O2:
|
||||
if (!(rand()%250))
|
||||
if (!(random_gen()%250))
|
||||
goto succ;
|
||||
break;
|
||||
case PT_LO2:
|
||||
@ -82,7 +82,7 @@ int Element_IRON::update(UPDATE_FUNC_ARGS)
|
||||
return 0;
|
||||
succ:
|
||||
sim->part_change_type(i,x,y,PT_BMTL);
|
||||
parts[i].tmp=(rand()%10)+20;
|
||||
parts[i].tmp=(random_gen()%10)+20;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -48,11 +48,11 @@ Element_ISOZ::Element_ISOZ()
|
||||
int Element_ISOZ::update(UPDATE_FUNC_ARGS)
|
||||
{ // for both ISZS and ISOZ
|
||||
float rr, rrr;
|
||||
if (!(rand()%200) && ((int)(-4.0f*(sim->pv[y/CELL][x/CELL])))>(rand()%1000))
|
||||
if (!(random_gen()%200) && ((int)(-4.0f*(sim->pv[y/CELL][x/CELL])))>(random_gen()%1000))
|
||||
{
|
||||
sim->create_part(i, x, y, PT_PHOT);
|
||||
rr = (rand()%228+128)/127.0f;
|
||||
rrr = (rand()%360)*3.14159f/180.0f;
|
||||
rr = (random_gen()%228+128)/127.0f;
|
||||
rrr = (random_gen()%360)*3.14159f/180.0f;
|
||||
parts[i].vx = rr*cosf(rrr);
|
||||
parts[i].vy = rr*sinf(rrr);
|
||||
}
|
||||
|
@ -48,11 +48,11 @@ Element_ISZS::Element_ISZS()
|
||||
int Element_ISZS::update(UPDATE_FUNC_ARGS)
|
||||
{ // for both ISZS and ISOZ
|
||||
float rr, rrr;
|
||||
if (!(rand()%200) && ((int)(-4.0f*(sim->pv[y/CELL][x/CELL])))>(rand()%1000))
|
||||
if (!(random_gen()%200) && ((int)(-4.0f*(sim->pv[y/CELL][x/CELL])))>(random_gen()%1000))
|
||||
{
|
||||
sim->create_part(i, x, y, PT_PHOT);
|
||||
rr = (rand()%228+128)/127.0f;
|
||||
rrr = (rand()%360)*3.14159f/180.0f;
|
||||
rr = (random_gen()%228+128)/127.0f;
|
||||
rrr = (random_gen()%360)*3.14159f/180.0f;
|
||||
parts[i].vx = rr*cosf(rrr);
|
||||
parts[i].vy = rr*sinf(rrr);
|
||||
}
|
||||
|
@ -91,11 +91,11 @@ 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))>(rand()%1000))
|
||||
sim->elements[rt].Flammable && (sim->elements[rt].Flammable + (int)(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);
|
||||
parts[ID(r)].life = rand()%80+180;
|
||||
parts[ID(r)].life = random_gen()%80+180;
|
||||
parts[ID(r)].tmp = parts[ID(r)].ctype = 0;
|
||||
if (sim->elements[rt].Explosive)
|
||||
sim->pv[y/CELL][x/CELL] += 0.25f * CFDS;
|
||||
@ -115,12 +115,12 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS)
|
||||
case PT_PLUT:
|
||||
parts[ID(r)].temp = restrict_flt(parts[ID(r)].temp+powderful, MIN_TEMP, MAX_TEMP);
|
||||
sim->pv[y/CELL][x/CELL] +=powderful/35;
|
||||
if (!(rand()%3))
|
||||
if (!(random_gen()%3))
|
||||
{
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_NEUT);
|
||||
parts[ID(r)].life = rand()%480+480;
|
||||
parts[ID(r)].vx=rand()%10-5;
|
||||
parts[ID(r)].vy=rand()%10-5;
|
||||
parts[ID(r)].life = random_gen()%480+480;
|
||||
parts[ID(r)].vx=random_gen()%10-5;
|
||||
parts[ID(r)].vy=random_gen()%10-5;
|
||||
}
|
||||
break;
|
||||
case PT_COAL:
|
||||
@ -208,15 +208,15 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS)
|
||||
}*/
|
||||
|
||||
//if (parts[i].tmp2==1/* || near!=-1*/)
|
||||
//angle=0;//parts[i].tmp-30+rand()%60;
|
||||
angle = (parts[i].tmp-30+rand()%60)%360;
|
||||
multipler=parts[i].life*1.5+rand()%((int)(parts[i].life+1));
|
||||
//angle=0;//parts[i].tmp-30+random_gen()%60;
|
||||
angle = (parts[i].tmp-30+random_gen()%60)%360;
|
||||
multipler=parts[i].life*1.5+random_gen()%((int)(parts[i].life+1));
|
||||
rx=cos(angle*M_PI/180)*multipler;
|
||||
ry=-sin(angle*M_PI/180)*multipler;
|
||||
create_line_par(sim, x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, angle, parts[i].tmp2);
|
||||
if (parts[i].tmp2==2)// && pNear==-1)
|
||||
{
|
||||
angle2= ((int)angle+100-rand()%200)%360;
|
||||
angle2= ((int)angle+100-random_gen()%200)%360;
|
||||
rx=cos(angle2*M_PI/180)*multipler;
|
||||
ry=-sin(angle2*M_PI/180)*multipler;
|
||||
create_line_par(sim, x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, angle2, parts[i].tmp2);
|
||||
@ -278,8 +278,8 @@ 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+(rand()%200>tmp2*tmp2/10+60);
|
||||
sim->parts[p].life=(int)(life/1.5-rand()%2);
|
||||
sim->parts[p].tmp2=1+(random_gen()%200>tmp2*tmp2/10+60);
|
||||
sim->parts[p].life=(int)(life/1.5-random_gen()%2);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ int Element_MERC::update(UPDATE_FUNC_ARGS)
|
||||
if (parts[i].temp + 1 == 0)
|
||||
parts[i].temp = 0;
|
||||
int maxtmp = ((absorbScale/(parts[i].temp + 1))-1);
|
||||
if ((absorbScale%((int)parts[i].temp+1))>rand()%((int)parts[i].temp+1))
|
||||
if ((absorbScale%((int)parts[i].temp+1))>random_gen()%((int)parts[i].temp+1))
|
||||
maxtmp ++;
|
||||
|
||||
if (parts[i].tmp < 0)
|
||||
@ -75,7 +75,7 @@ int Element_MERC::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r || (parts[i].tmp >=maxtmp))
|
||||
continue;
|
||||
if (TYP(r)==PT_MERC&& !(rand()%3))
|
||||
if (TYP(r)==PT_MERC&& !(random_gen()%3))
|
||||
{
|
||||
if ((parts[i].tmp + parts[ID(r)].tmp + 1) <= maxtmp)
|
||||
{
|
||||
@ -105,8 +105,8 @@ int Element_MERC::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
for ( trade = 0; trade<4; trade ++)
|
||||
{
|
||||
rx = rand()%5-2;
|
||||
ry = rand()%5-2;
|
||||
rx = random_gen()%5-2;
|
||||
ry = random_gen()%5-2;
|
||||
if (BOUNDS_CHECK && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
|
@ -51,7 +51,7 @@ int Element_NBLE::update(UPDATE_FUNC_ARGS)
|
||||
if (parts[i].temp > 5273.15 && sim->pv[y/CELL][x/CELL] > 100.0f)
|
||||
{
|
||||
parts[i].tmp |= 0x1;
|
||||
if (!(rand()%5))
|
||||
if (!(random_gen()%5))
|
||||
{
|
||||
int j;
|
||||
float temp = parts[i].temp;
|
||||
@ -60,7 +60,7 @@ int Element_NBLE::update(UPDATE_FUNC_ARGS)
|
||||
j = sim->create_part(-3,x,y,PT_NEUT);
|
||||
if (j != -1)
|
||||
parts[j].temp = temp;
|
||||
if (!(rand()%25))
|
||||
if (!(random_gen()%25))
|
||||
{
|
||||
j = sim->create_part(-3,x,y,PT_ELEC);
|
||||
if (j != -1)
|
||||
@ -73,7 +73,7 @@ int Element_NBLE::update(UPDATE_FUNC_ARGS)
|
||||
parts[j].temp = temp;
|
||||
parts[j].tmp = 0x1;
|
||||
}
|
||||
int rx = x+rand()%3-1, ry = y+rand()%3-1, rt = TYP(pmap[ry][rx]);
|
||||
int rx = x+random_gen()%3-1, ry = y+random_gen()%3-1, rt = TYP(pmap[ry][rx]);
|
||||
if (sim->can_move[PT_PLSM][rt] || rt == PT_NBLE)
|
||||
{
|
||||
j = sim->create_part(-3,rx,ry,PT_PLSM);
|
||||
@ -83,7 +83,7 @@ int Element_NBLE::update(UPDATE_FUNC_ARGS)
|
||||
parts[j].tmp |= 4;
|
||||
}
|
||||
}
|
||||
parts[i].temp = temp+1750+rand()%500;
|
||||
parts[i].temp = temp+1750+random_gen()%500;
|
||||
sim->pv[y/CELL][x/CELL] += 50;
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS)
|
||||
switch (TYP(r))
|
||||
{
|
||||
case PT_WATR:
|
||||
if (3>(rand()%20))
|
||||
if (3>(random_gen()%20))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_DSTW);
|
||||
case PT_ICEI:
|
||||
case PT_SNOW:
|
||||
@ -66,11 +66,11 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS)
|
||||
parts[i].vy *= 0.995;
|
||||
break;
|
||||
case PT_PLUT:
|
||||
if (pressureFactor>(rand()%1000))
|
||||
if (pressureFactor>(random_gen()%1000))
|
||||
{
|
||||
if (!(rand()%3))
|
||||
if (!(random_gen()%3))
|
||||
{
|
||||
sim->create_part(ID(r), x+rx, y+ry, rand()%3 ? PT_LAVA : PT_URAN);
|
||||
sim->create_part(ID(r), x+rx, y+ry, random_gen()%3 ? PT_LAVA : PT_URAN);
|
||||
parts[ID(r)].temp = MAX_TEMP;
|
||||
if (parts[ID(r)].type==PT_LAVA) {
|
||||
parts[ID(r)].tmp = 100;
|
||||
@ -89,7 +89,7 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS)
|
||||
break;
|
||||
#ifdef SDEUT
|
||||
case PT_DEUT:
|
||||
if ((pressureFactor+1+(parts[ID(r)].life/100))>(rand()%1000))
|
||||
if ((pressureFactor+1+(parts[ID(r)].life/100))>(random_gen()%1000))
|
||||
{
|
||||
DeutExplosion(sim, parts[ID(r)].life, x+rx, y+ry, restrict_flt(parts[ID(r)].temp + parts[ID(r)].life*500.0f, MIN_TEMP, MAX_TEMP), PT_NEUT);
|
||||
sim->kill_part(ID(r));
|
||||
@ -97,7 +97,7 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS)
|
||||
break;
|
||||
#else
|
||||
case PT_DEUT:
|
||||
if ((pressureFactor+1)>(rand()%1000))
|
||||
if ((pressureFactor+1)>(random_gen()%1000))
|
||||
{
|
||||
create_part(ID(r), x+rx, y+ry, PT_NEUT);
|
||||
parts[ID(r)].vx = 0.25f*parts[ID(r)].vx + parts[i].vx;
|
||||
@ -110,66 +110,66 @@ int Element_NEUT::update(UPDATE_FUNC_ARGS)
|
||||
break;
|
||||
#endif
|
||||
case PT_GUNP:
|
||||
if (3>(rand()%200))
|
||||
if (3>(random_gen()%200))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_DUST);
|
||||
break;
|
||||
case PT_DYST:
|
||||
if (3>(rand()%200))
|
||||
if (3>(random_gen()%200))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_YEST);
|
||||
break;
|
||||
case PT_YEST:
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_DYST);
|
||||
break;
|
||||
case PT_PLEX:
|
||||
if (3>(rand()%200))
|
||||
if (3>(random_gen()%200))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_GOO);
|
||||
break;
|
||||
case PT_NITR:
|
||||
if (3>(rand()%200))
|
||||
if (3>(random_gen()%200))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_DESL);
|
||||
break;
|
||||
case PT_PLNT:
|
||||
if (!(rand()%20))
|
||||
if (!(random_gen()%20))
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_WOOD);
|
||||
break;
|
||||
case PT_DESL:
|
||||
case PT_OIL:
|
||||
if (3>(rand()%200))
|
||||
if (3>(random_gen()%200))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_GAS);
|
||||
break;
|
||||
case PT_COAL:
|
||||
if (!(rand()%20))
|
||||
if (!(random_gen()%20))
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_WOOD);
|
||||
break;
|
||||
case PT_BCOL:
|
||||
if (!(rand()%20))
|
||||
if (!(random_gen()%20))
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_SAWD);
|
||||
break;
|
||||
case PT_DUST:
|
||||
if (!(rand()%20))
|
||||
if (!(random_gen()%20))
|
||||
sim->part_change_type(ID(r), x+rx, y+ry, PT_FWRK);
|
||||
break;
|
||||
case PT_FWRK:
|
||||
if (!(rand()%20))
|
||||
if (!(random_gen()%20))
|
||||
parts[ID(r)].ctype = PT_DUST;
|
||||
break;
|
||||
case PT_ACID:
|
||||
if (!(rand()%20))
|
||||
if (!(random_gen()%20))
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_ISOZ);
|
||||
break;
|
||||
case PT_TTAN:
|
||||
if (!(rand()%20))
|
||||
if (!(random_gen()%20))
|
||||
{
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case PT_EXOT:
|
||||
if (!(rand()%20))
|
||||
if (!(random_gen()%20))
|
||||
parts[ID(r)].life = 1500;
|
||||
break;
|
||||
case PT_RFRG:
|
||||
if (rand()%2)
|
||||
if (random_gen()%2)
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_GAS);
|
||||
else
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_CAUS);
|
||||
|
@ -58,19 +58,19 @@ int Element_O2::update(UPDATE_FUNC_ARGS)
|
||||
|
||||
if (TYP(r)==PT_FIRE)
|
||||
{
|
||||
parts[ID(r)].temp+=(rand()%100);
|
||||
parts[ID(r)].temp+=(random_gen()%100);
|
||||
if(parts[ID(r)].tmp&0x01)
|
||||
parts[ID(r)].temp=3473;
|
||||
parts[ID(r)].tmp |= 2;
|
||||
|
||||
sim->create_part(i,x,y,PT_FIRE);
|
||||
parts[i].temp+=(rand()%100);
|
||||
parts[i].temp+=(random_gen()%100);
|
||||
parts[i].tmp |= 2;
|
||||
}
|
||||
else if (TYP(r)==PT_PLSM && !(parts[ID(r)].tmp&4))
|
||||
{
|
||||
sim->create_part(i,x,y,PT_FIRE);
|
||||
parts[i].temp+=(rand()%100);
|
||||
parts[i].temp+=(random_gen()%100);
|
||||
parts[i].tmp |= 2;
|
||||
}
|
||||
}
|
||||
@ -81,7 +81,7 @@ int Element_O2::update(UPDATE_FUNC_ARGS)
|
||||
float gravy = sim->gravy[gravPos];
|
||||
if (gravx*gravx + gravy*gravy > 400)
|
||||
{
|
||||
if (!(rand()%5))
|
||||
if (!(random_gen()%5))
|
||||
{
|
||||
int j;
|
||||
sim->create_part(i,x,y,PT_BRMT);
|
||||
@ -95,7 +95,7 @@ int Element_O2::update(UPDATE_FUNC_ARGS)
|
||||
parts[j].temp = MAX_TEMP;
|
||||
parts[j].tmp = 0x1;
|
||||
}
|
||||
rx = x+rand()%3-1, ry = y+rand()%3-1, r = TYP(pmap[ry][rx]);
|
||||
rx = x+random_gen()%3-1, ry = y+random_gen()%3-1, r = TYP(pmap[ry][rx]);
|
||||
if (sim->can_move[PT_PLSM][r] || r == PT_O2)
|
||||
{
|
||||
j = sim->create_part(-3,rx,ry,PT_PLSM);
|
||||
|
@ -52,7 +52,7 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
int r, rx, ry, rt;
|
||||
if (!parts[i].tmp2 && sim->pv[y/CELL][x/CELL]>4.0f)
|
||||
parts[i].tmp2 = rand()%40+80;
|
||||
parts[i].tmp2 = random_gen()%40+80;
|
||||
if (parts[i].tmp2)
|
||||
{
|
||||
parts[i].vx += ADVECTION*sim->vx[y/CELL][x/CELL];
|
||||
@ -132,9 +132,9 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS)
|
||||
for (ry=-1; ry<2; ry++)
|
||||
sim->create_part(-1, x+rx, y+ry, PT_LIFE, parts[i].tmp);
|
||||
|
||||
else if (parts[i].ctype!=PT_LIGH || !(rand()%30))
|
||||
else if (parts[i].ctype!=PT_LIGH || !(random_gen()%30))
|
||||
{
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, TYP(parts[i].ctype));
|
||||
int np = sim->create_part(-1, x+random_gen()%3-1, y+random_gen()%3-1, TYP(parts[i].ctype));
|
||||
if (np>-1)
|
||||
{
|
||||
if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmp<PT_NUM && sim->elements[parts[i].tmp].HighTemperatureTransition==PT_LAVA)
|
||||
|
@ -123,9 +123,9 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS)
|
||||
for (ry=-1; ry<2; ry++)
|
||||
sim->create_part(-1, x+rx, y+ry, PT_LIFE, parts[i].tmp);
|
||||
|
||||
else if (parts[i].ctype!=PT_LIGH || (rand()%30)==0)
|
||||
else if (parts[i].ctype!=PT_LIGH || (random_gen()%30)==0)
|
||||
{
|
||||
int np = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, TYP(parts[i].ctype));
|
||||
int np = sim->create_part(-1, x+random_gen()%3-1, y+random_gen()%3-1, TYP(parts[i].ctype));
|
||||
if (np>=0)
|
||||
{
|
||||
if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmp<PT_NUM && sim->elements[parts[i].tmp].HighTemperatureTransition==PT_LAVA)
|
||||
|
@ -55,7 +55,7 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS)
|
||||
return 1;
|
||||
}
|
||||
if (parts[i].temp > 506)
|
||||
if (!(rand()%10)) Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS);
|
||||
if (!(random_gen()%10)) Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS);
|
||||
for (rx=-1; rx<2; rx++)
|
||||
for (ry=-1; ry<2; ry++)
|
||||
if (BOUNDS_CHECK) {
|
||||
@ -64,16 +64,16 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS)
|
||||
continue;
|
||||
if (TYP(r)==PT_ISOZ || TYP(r)==PT_ISZS)
|
||||
{
|
||||
if (!(rand()%400))
|
||||
if (!(random_gen()%400))
|
||||
{
|
||||
parts[i].vx *= 0.90;
|
||||
parts[i].vy *= 0.90;
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_PHOT);
|
||||
rrr = (rand()%360)*3.14159f/180.0f;
|
||||
rrr = (random_gen()%360)*3.14159f/180.0f;
|
||||
if (TYP(r) == PT_ISOZ)
|
||||
rr = (rand()%128+128)/127.0f;
|
||||
rr = (random_gen()%128+128)/127.0f;
|
||||
else
|
||||
rr = (rand()%228+128)/127.0f;
|
||||
rr = (random_gen()%228+128)/127.0f;
|
||||
parts[ID(r)].vx = rr*cosf(rrr);
|
||||
parts[ID(r)].vy = rr*sinf(rrr);
|
||||
sim->pv[y/CELL][x/CELL] -= 15.0f * CFDS;
|
||||
@ -81,17 +81,17 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if((TYP(r) == PT_QRTZ || TYP(r) == PT_PQRT) && !ry && !rx)//if on QRTZ
|
||||
{
|
||||
float a = (rand()%360)*3.14159f/180.0f;
|
||||
float a = (random_gen()%360)*3.14159f/180.0f;
|
||||
parts[i].vx = 3.0f*cosf(a);
|
||||
parts[i].vy = 3.0f*sinf(a);
|
||||
if(parts[i].ctype == 0x3FFFFFFF)
|
||||
parts[i].ctype = 0x1F<<(rand()%26);
|
||||
parts[i].ctype = 0x1F<<(random_gen()%26);
|
||||
if (parts[i].life)
|
||||
parts[i].life++; //Delay death
|
||||
}
|
||||
else if(TYP(r) == PT_BGLA && !ry && !rx)//if on BGLA
|
||||
{
|
||||
float a = (rand()%101 - 50) * 0.001f;
|
||||
float a = (random_gen()%101 - 50) * 0.001f;
|
||||
float rx = cosf(a), ry = sinf(a), vx, vy;
|
||||
vx = rx * parts[i].vx + ry * parts[i].vy;
|
||||
vy = rx * parts[i].vy - ry * parts[i].vx;
|
||||
@ -100,8 +100,8 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (TYP(r) == PT_FILT && parts[ID(r)].tmp==9)
|
||||
{
|
||||
parts[i].vx += ((float)(rand()%1000-500))/1000.0f;
|
||||
parts[i].vy += ((float)(rand()%1000-500))/1000.0f;
|
||||
parts[i].vx += ((float)(random_gen()%1000-500))/1000.0f;
|
||||
parts[i].vy += ((float)(random_gen()%1000-500))/1000.0f;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -191,7 +191,7 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS)
|
||||
|
||||
if (nt)//there is something besides PIPE around current particle
|
||||
{
|
||||
rndstore = rand();
|
||||
rndstore = random_gen();
|
||||
rnd = rndstore&7;
|
||||
//rndstore = rndstore>>3;
|
||||
rx = pos_1_rx[rnd];
|
||||
@ -433,7 +433,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
|
||||
if( !(sim->parts[i].tmp&0x200) )
|
||||
{
|
||||
//normal random push
|
||||
rndstore = rand();
|
||||
rndstore = random_gen();
|
||||
// RAND_MAX is at least 32767 on all platforms i.e. pow(8,5)-1
|
||||
// so can go 5 cycles without regenerating rndstore
|
||||
for (q=0; q<3; q++)//try to push 3 times
|
||||
|
@ -60,7 +60,7 @@ int Element_PLNT::update(UPDATE_FUNC_ARGS)
|
||||
switch (TYP(r))
|
||||
{
|
||||
case PT_WATR:
|
||||
if (!(rand()%50))
|
||||
if (!(random_gen()%50))
|
||||
{
|
||||
np = sim->create_part(ID(r),x+rx,y+ry,PT_PLNT);
|
||||
if (np<0) continue;
|
||||
@ -68,7 +68,7 @@ int Element_PLNT::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
break;
|
||||
case PT_LAVA:
|
||||
if (!(rand()%50))
|
||||
if (!(random_gen()%50))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_FIRE);
|
||||
parts[i].life = 4;
|
||||
@ -76,14 +76,14 @@ int Element_PLNT::update(UPDATE_FUNC_ARGS)
|
||||
break;
|
||||
case PT_SMKE:
|
||||
case PT_CO2:
|
||||
if (!(rand()%50))
|
||||
if (!(random_gen()%50))
|
||||
{
|
||||
sim->kill_part(ID(r));
|
||||
parts[i].life = rand()%60 + 60;
|
||||
parts[i].life = random_gen()%60 + 60;
|
||||
}
|
||||
break;
|
||||
case PT_WOOD:
|
||||
rndstore = rand();
|
||||
rndstore = random_gen();
|
||||
if (surround_space && !(rndstore%4) && parts[i].tmp==1)
|
||||
{
|
||||
rndstore >>= 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 (!(rand()%100) && ((int)(5.0f*sim->pv[y/CELL][x/CELL]))>(rand()%1000))
|
||||
if (!(random_gen()%100) && ((int)(5.0f*sim->pv[y/CELL][x/CELL]))>(random_gen()%1000))
|
||||
{
|
||||
sim->create_part(i, x, y, PT_NEUT);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ int Element_POLO::update(UPDATE_FUNC_ARGS)
|
||||
int r = sim->photons[y][x];
|
||||
if (parts[i].tmp < LIMIT && !parts[i].life)
|
||||
{
|
||||
if (!(rand()%10000) && !parts[i].tmp)
|
||||
if (!(random_gen()%10000) && !parts[i].tmp)
|
||||
{
|
||||
int s = sim->create_part(-3, x, y, PT_NEUT);
|
||||
if (s >= 0)
|
||||
@ -68,7 +68,7 @@ int Element_POLO::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
}
|
||||
|
||||
if (r && !(rand()%100))
|
||||
if (r && !(random_gen()%100))
|
||||
{
|
||||
int s = sim->create_part(-3, x, y, PT_NEUT);
|
||||
if (s >= 0)
|
||||
|
@ -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)) > rand() % 200)
|
||||
if ((-((int)sim->pv[y / CELL][x / CELL] - 4) + (parts[uID].life / 100)) > 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);
|
||||
@ -76,7 +76,7 @@ int Element_PROT::update(UPDATE_FUNC_ARGS)
|
||||
break;
|
||||
case PT_LCRY:
|
||||
//Powered LCRY reaction: PROT->PHOT
|
||||
if (parts[uID].life > 5 && !(rand() % 10))
|
||||
if (parts[uID].life > 5 && !(random_gen() % 10))
|
||||
{
|
||||
sim->part_change_type(i, x, y, PT_PHOT);
|
||||
parts[i].life *= 2;
|
||||
@ -143,7 +143,7 @@ int Element_PROT::update(UPDATE_FUNC_ARGS)
|
||||
element = PT_CO2;
|
||||
else
|
||||
element = PT_NBLE;
|
||||
newID = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, element);
|
||||
newID = sim->create_part(-1, x+random_gen()%3-1, y+random_gen()%3-1, element);
|
||||
if (newID >= 0)
|
||||
parts[newID].temp = restrict_flt(100.0f*parts[i].tmp, MIN_TEMP, MAX_TEMP);
|
||||
sim->kill_part(i);
|
||||
|
@ -116,22 +116,22 @@ 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 = rand()*rand()*rand();
|
||||
if (!sim->parts[i].ctype) parts[i].ctype = rand()*rand()*rand();
|
||||
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();
|
||||
sim->orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
|
||||
for (int r = 0; r < 4; r++) {
|
||||
if (orbd[r]>1) {
|
||||
orbd[r] -= 12;
|
||||
if (orbd[r]<1) {
|
||||
orbd[r] = (rand()%128)+128;
|
||||
orbl[r] = rand()%255;
|
||||
orbd[r] = (random_gen()%128)+128;
|
||||
orbl[r] = random_gen()%255;
|
||||
} else {
|
||||
orbl[r] += 2;
|
||||
orbl[r] = orbl[r]%255;
|
||||
}
|
||||
} else {
|
||||
orbd[r] = (rand()%128)+128;
|
||||
orbl[r] = rand()%255;
|
||||
orbd[r] = (random_gen()%128)+128;
|
||||
orbl[r] = random_gen()%255;
|
||||
}
|
||||
}
|
||||
sim->orbitalparts_set(&parts[i].life, &parts[i].ctype, orbd, orbl);
|
||||
|
@ -73,7 +73,7 @@ int Element_PRTO::update(UPDATE_FUNC_ARGS)
|
||||
fe = 1;
|
||||
for ( nnx =0 ; nnx<80; nnx++)
|
||||
{
|
||||
int randomness = (count + rand()%3-1 + 4)%8;//add -1,0,or 1 to count
|
||||
int randomness = (count + random_gen()%3-1 + 4)%8;//add -1,0,or 1 to count
|
||||
if (sim->portalp[parts[i].tmp][randomness][nnx].type==PT_SPRK)// TODO: make it look better, spark creation
|
||||
{
|
||||
sim->create_part(-1,x+1,y,PT_SPRK);
|
||||
@ -141,15 +141,15 @@ 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 = rand()*rand()*rand();
|
||||
if (!sim->parts[i].ctype) parts[i].ctype = rand()*rand()*rand();
|
||||
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();
|
||||
sim->orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
|
||||
for (r = 0; r < 4; r++) {
|
||||
if (orbd[r]<254) {
|
||||
orbd[r] += 16;
|
||||
if (orbd[r]>254) {
|
||||
orbd[r] = 0;
|
||||
orbl[r] = rand()%255;
|
||||
orbl[r] = random_gen()%255;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -160,7 +160,7 @@ int Element_PRTO::update(UPDATE_FUNC_ARGS)
|
||||
//orbl[r] = orbl[r]%255;
|
||||
} else {
|
||||
orbd[r] = 0;
|
||||
orbl[r] = rand()%255;
|
||||
orbl[r] = random_gen()%255;
|
||||
}
|
||||
}
|
||||
sim->orbitalparts_set(&parts[i].life, &parts[i].ctype, orbd, orbl);
|
||||
|
@ -70,7 +70,7 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
else if (TYP(r)==PT_SLTW && !(rand()%500))
|
||||
else if (TYP(r)==PT_SLTW && !(random_gen()%500))
|
||||
{
|
||||
sim->kill_part(ID(r));
|
||||
parts[i].tmp++;
|
||||
@ -83,7 +83,7 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS)
|
||||
int rnd, sry, srx;
|
||||
for (trade = 0; trade < 9; trade++)
|
||||
{
|
||||
rnd = rand()%0x3FF;
|
||||
rnd = random_gen()%0x3FF;
|
||||
rx = (rnd%5)-2;
|
||||
srx = (rnd%3)-1;
|
||||
rnd >>= 3;
|
||||
@ -106,11 +106,11 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS)
|
||||
// If PQRT is stationary and has started growing particles of QRTZ, the PQRT is basically part of a new QRTZ crystal. So turn it back into QRTZ so that it behaves more like part of the crystal.
|
||||
sim->part_change_type(i,x,y,PT_QRTZ);
|
||||
}
|
||||
if (rand()%2)
|
||||
if (random_gen()%2)
|
||||
{
|
||||
parts[np].tmp=-1;//dead qrtz
|
||||
}
|
||||
else if (!parts[i].tmp && !(rand()%15))
|
||||
else if (!parts[i].tmp && !(random_gen()%15))
|
||||
{
|
||||
parts[i].tmp=-1;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ int Element_RIME::update(UPDATE_FUNC_ARGS)
|
||||
if (TYP(r)==PT_SPRK)
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_FOG);
|
||||
parts[i].life = rand()%50 + 60;
|
||||
parts[i].life = random_gen()%50 + 60;
|
||||
}
|
||||
else if (TYP(r)==PT_FOG&&parts[ID(r)].life>0)
|
||||
{
|
||||
|
@ -50,8 +50,8 @@ int Element_RPEL::update(UPDATE_FUNC_ARGS)
|
||||
int r, rx, ry, ri;
|
||||
for(ri = 0; ri <= 10; ri++)
|
||||
{
|
||||
rx = (rand()%21)-10;
|
||||
ry = (rand()%21)-10;
|
||||
rx = (random_gen()%21)-10;
|
||||
ry = (random_gen()%21)-10;
|
||||
if (x+rx >= 0 && x+rx < XRES && y+ry >= 0 && y+ry < YRES && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
|
@ -57,7 +57,7 @@ int Element_SHLD1::update(UPDATE_FUNC_ARGS)
|
||||
continue;
|
||||
else if (TYP(r)==PT_SPRK&&parts[i].life==0)
|
||||
{
|
||||
if (11>rand()%40)
|
||||
if (11>random_gen()%40)
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SHLD2);
|
||||
parts[i].life = 7;
|
||||
@ -72,7 +72,7 @@ int Element_SHLD1::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (TYP(r)==PT_SHLD3&&2>rand()%5)
|
||||
else if (TYP(r)==PT_SHLD3&&2>random_gen()%5)
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SHLD2);
|
||||
parts[i].life = 7;
|
||||
|
@ -61,7 +61,7 @@ int Element_SHLD2::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (TYP(r)==PT_SPRK&&parts[i].life==0)
|
||||
{
|
||||
if (!(rand()%8))
|
||||
if (!(random_gen()%8))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SHLD3);
|
||||
parts[i].life = 7;
|
||||
@ -77,7 +77,7 @@ int Element_SHLD2::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (TYP(r)==PT_SHLD4&&2>rand()%5)
|
||||
else if (TYP(r)==PT_SHLD4&&2>random_gen()%5)
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SHLD3);
|
||||
parts[i].life = 7;
|
||||
|
@ -55,7 +55,7 @@ int Element_SHLD3::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
{
|
||||
if (!(rand()%2500))
|
||||
if (!(random_gen()%2500))
|
||||
{
|
||||
np = sim->create_part(-1,x+rx,y+ry,PT_SHLD1);
|
||||
if (np<0) continue;
|
||||
@ -71,7 +71,7 @@ int Element_SHLD3::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (TYP(r)==PT_SPRK&&parts[i].life==0)
|
||||
{
|
||||
if (3>rand()%500)
|
||||
if (3>random_gen()%500)
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SHLD4);
|
||||
parts[i].life = 7;
|
||||
|
@ -55,7 +55,7 @@ int Element_SHLD4::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
{
|
||||
if (!(rand()%5500))
|
||||
if (!(random_gen()%5500))
|
||||
{
|
||||
np = sim->create_part(-1,x+rx,y+ry,PT_SHLD1);
|
||||
if (np<0) continue;
|
||||
|
@ -78,7 +78,7 @@ int Element_SING::update(UPDATE_FUNC_ARGS)
|
||||
spawncount = (spawncount>255) ? 3019 : std::pow((double)(spawncount/8), 2)*M_PI;
|
||||
for (int j = 0;j < spawncount; j++)
|
||||
{
|
||||
switch(rand()%3)
|
||||
switch(random_gen()%3)
|
||||
{
|
||||
case 0:
|
||||
nb = sim->create_part(-3, x, y, PT_PHOT);
|
||||
@ -91,10 +91,10 @@ int Element_SING::update(UPDATE_FUNC_ARGS)
|
||||
break;
|
||||
}
|
||||
if (nb!=-1) {
|
||||
parts[nb].life = (rand()%300);
|
||||
parts[nb].life = (random_gen()%300);
|
||||
parts[nb].temp = MAX_TEMP/2;
|
||||
angle = rand()*2.0f*M_PI/RAND_MAX;
|
||||
v = (float)(rand())*5.0f/RAND_MAX;
|
||||
angle = random_gen.uniform01()*2.0f*M_PI;
|
||||
v = random_gen.uniform01()*5.0f;
|
||||
parts[nb].vx = v*cosf(angle);
|
||||
parts[nb].vy = v*sinf(angle);
|
||||
}
|
||||
@ -111,7 +111,7 @@ int Element_SING::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if (TYP(r)!=PT_DMND&& !(rand()%3))
|
||||
if (TYP(r)!=PT_DMND&& !(random_gen()%3))
|
||||
{
|
||||
if (TYP(r)==PT_SING && parts[ID(r)].life >10)
|
||||
{
|
||||
@ -123,11 +123,11 @@ int Element_SING::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (parts[i].life+3 > 255)
|
||||
{
|
||||
if (parts[ID(r)].type!=PT_SING && !(rand()%100))
|
||||
if (parts[ID(r)].type!=PT_SING && !(random_gen()%100))
|
||||
{
|
||||
int np;
|
||||
np = sim->create_part(ID(r),x+rx,y+ry,PT_SING);
|
||||
parts[np].life = rand()%50+60;
|
||||
parts[np].life = random_gen()%50+60;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -56,16 +56,16 @@ int Element_SLTW::update(UPDATE_FUNC_ARGS)
|
||||
switch TYP(r)
|
||||
{
|
||||
case PT_SALT:
|
||||
if (!(rand()%2000))
|
||||
if (!(random_gen()%2000))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW);
|
||||
break;
|
||||
case PT_PLNT:
|
||||
if (!(rand()%40))
|
||||
if (!(random_gen()%40))
|
||||
sim->kill_part(ID(r));
|
||||
break;
|
||||
case PT_RBDM:
|
||||
case PT_LRBD:
|
||||
if ((sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(rand()%100))
|
||||
if ((sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(random_gen()%100))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_FIRE);
|
||||
parts[i].life = 4;
|
||||
@ -76,7 +76,7 @@ int Element_SLTW::update(UPDATE_FUNC_ARGS)
|
||||
if (parts[ID(r)].ctype!=PT_WATR)
|
||||
{
|
||||
sim->kill_part(ID(r));
|
||||
if(!(rand()%30)){
|
||||
if(!(random_gen()%30)){
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ int Element_SNOW::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((TYP(r)==PT_SALT || TYP(r)==PT_SLTW) && !(rand()%333))
|
||||
if ((TYP(r)==PT_SALT || TYP(r)==PT_SLTW) && !(random_gen()%333))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SLTW);
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW);
|
||||
|
@ -63,31 +63,31 @@ int Element_SPNG::update(UPDATE_FUNC_ARGS)
|
||||
case PT_WATR:
|
||||
case PT_DSTW:
|
||||
case PT_FRZW:
|
||||
if (parts[i].life<limit && 500>rand()%absorbChanceDenom)
|
||||
if (parts[i].life<limit && 500>random_gen()%absorbChanceDenom)
|
||||
{
|
||||
parts[i].life++;
|
||||
sim->kill_part(ID(r));
|
||||
}
|
||||
break;
|
||||
case PT_SLTW:
|
||||
if (parts[i].life<limit && 50>rand()%absorbChanceDenom)
|
||||
if (parts[i].life<limit && 50>random_gen()%absorbChanceDenom)
|
||||
{
|
||||
parts[i].life++;
|
||||
if (rand()%4)
|
||||
if (random_gen()%4)
|
||||
sim->kill_part(ID(r));
|
||||
else
|
||||
sim->part_change_type(ID(r), x+rx, y+ry, PT_SALT);
|
||||
}
|
||||
break;
|
||||
case PT_CBNW:
|
||||
if (parts[i].life<limit && 100>rand()%absorbChanceDenom)
|
||||
if (parts[i].life<limit && 100>random_gen()%absorbChanceDenom)
|
||||
{
|
||||
parts[i].life++;
|
||||
sim->part_change_type(ID(r), x+rx, y+ry, PT_CO2);
|
||||
}
|
||||
break;
|
||||
case PT_PSTE:
|
||||
if (parts[i].life<limit && 20>rand()%absorbChanceDenom)
|
||||
if (parts[i].life<limit && 20>random_gen()%absorbChanceDenom)
|
||||
{
|
||||
parts[i].life++;
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_CLST);
|
||||
@ -112,8 +112,8 @@ int Element_SPNG::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
for ( trade = 0; trade<9; trade ++)
|
||||
{
|
||||
rx = rand()%5-2;
|
||||
ry = rand()%5-2;
|
||||
rx = random_gen()%5-2;
|
||||
ry = random_gen()%5-2;
|
||||
if (BOUNDS_CHECK && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
|
@ -99,7 +99,7 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
|
||||
case PT_NBLE:
|
||||
if (parts[i].life<=1 && !(parts[i].tmp&0x1))
|
||||
{
|
||||
parts[i].life = rand()%150+50;
|
||||
parts[i].life = random_gen()%150+50;
|
||||
sim->part_change_type(i,x,y,PT_PLSM);
|
||||
parts[i].ctype = PT_NBLE;
|
||||
if (parts[i].temp > 5273.15)
|
||||
@ -118,12 +118,12 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (r)
|
||||
continue;
|
||||
if (parts[i].tmp>4 && rand()%(parts[i].tmp*parts[i].tmp/20+6)==0)
|
||||
if (parts[i].tmp>4 && random_gen()%(parts[i].tmp*parts[i].tmp/20+6)==0)
|
||||
{
|
||||
int p = sim->create_part(-1, x+rx*2, y+ry*2, PT_LIGH);
|
||||
if (p!=-1)
|
||||
{
|
||||
parts[p].life=rand()%(2+parts[i].tmp/15)+parts[i].tmp/7;
|
||||
parts[p].life=random_gen()%(2+parts[i].tmp/15)+parts[i].tmp/7;
|
||||
if (parts[i].life>60)
|
||||
parts[i].life=60;
|
||||
parts[p].temp=parts[p].life*parts[i].tmp/2.5;
|
||||
@ -151,7 +151,7 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
|
||||
continue;
|
||||
if (TYP(r)==PT_DSTW || TYP(r)==PT_SLTW || TYP(r)==PT_WATR)
|
||||
{
|
||||
int rnd = rand()%100;
|
||||
int rnd = random_gen()%100;
|
||||
if (!rnd)
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_O2);
|
||||
else if (3>rnd)
|
||||
@ -161,7 +161,7 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
|
||||
break;
|
||||
case PT_TUNG:
|
||||
if(parts[i].temp < 3595.0){
|
||||
parts[i].temp += (rand()%20)-4;
|
||||
parts[i].temp += (random_gen()%20)-4;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
@ -403,7 +403,7 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) {
|
||||
//Spawn
|
||||
if (((int)(playerp->comm)&0x08) == 0x08)
|
||||
{
|
||||
ry -= 2*(rand()%2)+1;
|
||||
ry -= 2*(random_gen()%2)+1;
|
||||
r = pmap[ry][rx];
|
||||
if (sim->elements[TYP(r)].Properties&TYPE_SOLID)
|
||||
{
|
||||
@ -439,7 +439,7 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) {
|
||||
{
|
||||
if (playerp->elem == PT_PHOT)
|
||||
{
|
||||
int random = abs(rand()%3-1)*3;
|
||||
int random = abs(random_gen()%3-1)*3;
|
||||
if (random==0)
|
||||
{
|
||||
sim->kill_part(np);
|
||||
@ -460,7 +460,7 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) {
|
||||
if (gvx!=0 || gvy!=0)
|
||||
angle = atan2(gvx, gvy)*180.0f/M_PI;
|
||||
else
|
||||
angle = rand()%360;
|
||||
angle = random_gen()%360;
|
||||
if (((int)playerp->pcomm)&0x01)
|
||||
angle += 180;
|
||||
if (angle>360)
|
||||
@ -468,7 +468,7 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) {
|
||||
if (angle<0)
|
||||
angle+=360;
|
||||
parts[np].tmp = angle;
|
||||
parts[np].life=rand()%(2+power/15)+power/7;
|
||||
parts[np].life=random_gen()%(2+power/15)+power/7;
|
||||
parts[np].temp=parts[np].life*power/2.5;
|
||||
parts[np].tmp2=1;
|
||||
}
|
||||
@ -592,7 +592,7 @@ void Element_STKM::STKM_interact(Simulation *sim, playerst *playerp, int i, int
|
||||
{
|
||||
if (TYP(r)==PT_SPRK && playerp->elem!=PT_LIGH) //If on charge
|
||||
{
|
||||
sim->parts[i].life -= (int)(rand()*20/RAND_MAX)+32;
|
||||
sim->parts[i].life -= random_gen.between(32, 52);
|
||||
}
|
||||
|
||||
if (sim->elements[TYP(r)].HeatConduct && (TYP(r)!=PT_HSWC||sim->parts[ID(r)].life==10) && ((playerp->elem!=PT_LIGH && sim->parts[ID(r)].temp>=323) || sim->parts[ID(r)].temp<=243) && (!playerp->rocketBoots || TYP(r)!=PT_PLSM))
|
||||
|
@ -68,9 +68,9 @@ int Element_THDR::update(UPDATE_FUNC_ARGS)
|
||||
else if (rt!=PT_CLNE&&rt!=PT_THDR&&rt!=PT_SPRK&&rt!=PT_DMND&&rt!=PT_FIRE)
|
||||
{
|
||||
sim->pv[y/CELL][x/CELL] += 100.0f;
|
||||
if (sim->legacy_enable&&1>(rand()%200))
|
||||
if (sim->legacy_enable&&1>(random_gen()%200))
|
||||
{
|
||||
parts[i].life = rand()%50+120;
|
||||
parts[i].life = random_gen()%50+120;
|
||||
sim->part_change_type(i,x,y,PT_FIRE);
|
||||
}
|
||||
else
|
||||
|
@ -102,7 +102,7 @@ int Element_TRON::update(UPDATE_FUNC_ARGS)
|
||||
int originaldir = direction;
|
||||
|
||||
//random turn
|
||||
int random = rand()%340;
|
||||
int random = random_gen()%340;
|
||||
if ((random==1 || random==3) && !(parts[i].tmp & TRON_NORANDOM))
|
||||
{
|
||||
//randomly turn left(3) or right(1)
|
||||
@ -126,7 +126,7 @@ int Element_TRON::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
seconddir = (direction + ((rand()%2)*2)+1)% 4;
|
||||
seconddir = (direction + ((random_gen()%2)*2)+1)% 4;
|
||||
lastdir = (seconddir + 2)%4;
|
||||
}
|
||||
seconddircheck = trymovetron(sim,x,y,seconddir,i,parts[i].tmp2);
|
||||
|
@ -66,16 +66,16 @@ int Element_TUNG::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
}
|
||||
}
|
||||
if((parts[i].temp > MELTING_POINT && !(rand()%20)) || splode)
|
||||
if((parts[i].temp > MELTING_POINT && !(random_gen()%20)) || splode)
|
||||
{
|
||||
if(!(rand()%50))
|
||||
if(!(random_gen()%50))
|
||||
{
|
||||
sim->pv[y/CELL][x/CELL] += 50.0f;
|
||||
}
|
||||
else if(!(rand()%100))
|
||||
else if(!(random_gen()%100))
|
||||
{
|
||||
sim->part_change_type(i, x, y, PT_FIRE);
|
||||
parts[i].life = rand()%500;
|
||||
parts[i].life = random_gen()%500;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@ -86,10 +86,10 @@ int Element_TUNG::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
if(splode)
|
||||
{
|
||||
parts[i].temp = restrict_flt(MELTING_POINT + (rand()%600) + 200, MIN_TEMP, MAX_TEMP);
|
||||
parts[i].temp = restrict_flt(MELTING_POINT + (random_gen()%600) + 200, MIN_TEMP, MAX_TEMP);
|
||||
}
|
||||
parts[i].vx += (rand()%100)-50;
|
||||
parts[i].vy += (rand()%100)-50;
|
||||
parts[i].vx += (random_gen()%100)-50;
|
||||
parts[i].vy += (random_gen()%100)-50;
|
||||
return 1;
|
||||
}
|
||||
parts[i].pavg[0] = parts[i].pavg[1];
|
||||
|
@ -80,7 +80,7 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
|
||||
else //if it is exploding
|
||||
{
|
||||
//Release sparks before explode
|
||||
rndstore = rand();
|
||||
rndstore = random_gen();
|
||||
if (parts[i].life < 300)
|
||||
{
|
||||
rx = rndstore%3-1;
|
||||
@ -114,7 +114,7 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
|
||||
{
|
||||
if (!parts[i].tmp2)
|
||||
{
|
||||
rndstore = rand();
|
||||
rndstore = random_gen();
|
||||
int index = sim->create_part(-3,x+((rndstore>>4)&3)-1,y+((rndstore>>6)&3)-1,PT_ELEC);
|
||||
if (index != -1)
|
||||
parts[index].temp = 7000;
|
||||
@ -122,7 +122,7 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
|
||||
if (index != -1)
|
||||
parts[index].temp = 7000;
|
||||
int rx = ((rndstore>>12)&3)-1;
|
||||
rndstore = rand();
|
||||
rndstore = random_gen();
|
||||
index = sim->create_part(-1,x+rx-1,y+rndstore%3-1,PT_BREC);
|
||||
if (index != -1)
|
||||
parts[index].temp = 7000;
|
||||
@ -156,7 +156,7 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
|
||||
{
|
||||
if (!parts[ID(r)].life)
|
||||
parts[ID(r)].tmp += 45;
|
||||
else if (parts[i].tmp2 && parts[i].life > 75 && rand()%2)
|
||||
else if (parts[i].tmp2 && parts[i].life > 75 && random_gen()%2)
|
||||
{
|
||||
parts[ID(r)].tmp2 = 1;
|
||||
parts[i].tmp = 0;
|
||||
@ -171,7 +171,7 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
|
||||
else
|
||||
{
|
||||
//Melts into EXOT
|
||||
if (TYP(r) == PT_EXOT && !(rand()%25))
|
||||
if (TYP(r) == PT_EXOT && !(random_gen()%25))
|
||||
{
|
||||
sim->part_change_type(i, x, y, PT_EXOT);
|
||||
return 1;
|
||||
@ -187,7 +187,7 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
|
||||
for (trade = 0; trade < 9; trade++)
|
||||
{
|
||||
if (!(trade%2))
|
||||
rndstore = rand();
|
||||
rndstore = random_gen();
|
||||
rx = rndstore%7-3;
|
||||
rndstore >>= 3;
|
||||
ry = rndstore%7-3;
|
||||
|
@ -49,7 +49,7 @@ Element_VINE::Element_VINE()
|
||||
//#TPT-Directive ElementHeader Element_VINE static int update(UPDATE_FUNC_ARGS)
|
||||
int Element_VINE::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
int r, np, rx, ry, rndstore = rand();
|
||||
int r, np, rx, ry, rndstore = random_gen();
|
||||
rx = (rndstore % 3) - 1;
|
||||
rndstore >>= 2;
|
||||
ry = (rndstore % 3) - 1;
|
||||
|
@ -50,7 +50,7 @@ int Element_VIRS::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
//pavg[0] measures how many frames until it is cured (0 if still actively spreading and not being cured)
|
||||
//pavg[1] measures how many frames until it dies
|
||||
int r, rx, ry, rndstore = rand();
|
||||
int r, rx, ry, rndstore = random_gen();
|
||||
if (parts[i].pavg[0])
|
||||
{
|
||||
parts[i].pavg[0] -= (rndstore & 0x1) ? 0:1;
|
||||
@ -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]) > (rand()%100))
|
||||
if (surround_space && 10 + (int)(sim->pv[(y+ry)/CELL][(x+rx)/CELL]) > (random_gen()%100))
|
||||
{
|
||||
sim->create_part(i, x, y, PT_PLSM);
|
||||
return 1;
|
||||
@ -135,7 +135,7 @@ int Element_VIRS::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
//reset rndstore only once, halfway through
|
||||
else if (!rx && !ry)
|
||||
rndstore = rand();
|
||||
rndstore = random_gen();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -53,13 +53,13 @@ int Element_WARP::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
parts[i].temp = 10000;
|
||||
sim->pv[y/CELL][x/CELL] += (parts[i].tmp2/5000) * CFDS;
|
||||
if (!(rand()%50))
|
||||
if (!(random_gen()%50))
|
||||
sim->create_part(-3, x, y, PT_ELEC);
|
||||
}
|
||||
for ( trade = 0; trade<5; trade ++)
|
||||
{
|
||||
rx = rand()%3-1;
|
||||
ry = rand()%3-1;
|
||||
rx = random_gen()%3-1;
|
||||
ry = random_gen()%3-1;
|
||||
if (BOUNDS_CHECK && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
@ -71,8 +71,8 @@ int Element_WARP::update(UPDATE_FUNC_ARGS)
|
||||
parts[i].y = parts[ID(r)].y;
|
||||
parts[ID(r)].x = x;
|
||||
parts[ID(r)].y = y;
|
||||
parts[ID(r)].vx = (rand()%4)-1.5;
|
||||
parts[ID(r)].vy = (rand()%4)-2;
|
||||
parts[ID(r)].vx = (random_gen()%4)-1.5;
|
||||
parts[ID(r)].vy = (random_gen()%4)-2;
|
||||
parts[i].life += 4;
|
||||
pmap[y][x] = r;
|
||||
pmap[y+ry][x+rx] = PMAP(i, parts[i].type);
|
||||
|
@ -55,14 +55,14 @@ int Element_WATR::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if (TYP(r)==PT_SALT && !(rand()%50))
|
||||
if (TYP(r)==PT_SALT && !(random_gen()%50))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SLTW);
|
||||
// on average, convert 3 WATR to SLTW before SALT turns into SLTW
|
||||
if (!(rand()%3))
|
||||
if (!(random_gen()%3))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW);
|
||||
}
|
||||
else if ((TYP(r)==PT_RBDM||TYP(r)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(rand()%100))
|
||||
else if ((TYP(r)==PT_RBDM||TYP(r)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(random_gen()%100))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_FIRE);
|
||||
parts[i].life = 4;
|
||||
@ -70,16 +70,16 @@ int Element_WATR::update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (TYP(r)==PT_FIRE && parts[ID(r)].ctype!=PT_WATR){
|
||||
sim->kill_part(ID(r));
|
||||
if(!(rand()%30)){
|
||||
if(!(random_gen()%30)){
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (TYP(r)==PT_SLTW && !(rand()%2000))
|
||||
else if (TYP(r)==PT_SLTW && !(random_gen()%2000))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SLTW);
|
||||
}
|
||||
/*if (TYP(r)==PT_CNCT && !(rand()%100)) Concrete+Water to paste, not very popular
|
||||
/*if (TYP(r)==PT_CNCT && !(random_gen()%100)) Concrete+Water to paste, not very popular
|
||||
{
|
||||
part_change_type(i,x,y,PT_PSTE);
|
||||
sim.kill_part(ID(r));
|
||||
|
@ -55,7 +55,7 @@ int Element_WTRV::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((TYP(r)==PT_RBDM||TYP(r)==PT_LRBD) && !sim->legacy_enable && parts[i].temp>(273.15f+12.0f) && !(rand()%100))
|
||||
if ((TYP(r)==PT_RBDM||TYP(r)==PT_LRBD) && !sim->legacy_enable && parts[i].temp>(273.15f+12.0f) && !(random_gen()%100))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_FIRE);
|
||||
parts[i].life = 4;
|
||||
|
@ -55,13 +55,13 @@ int Element_YEST::update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if (TYP(r)==PT_DYST && !(rand()%6) && !sim->legacy_enable)
|
||||
if (TYP(r)==PT_DYST && !(random_gen()%6) && !sim->legacy_enable)
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_DYST);
|
||||
}
|
||||
}
|
||||
if (parts[i].temp>303&&parts[i].temp<317) {
|
||||
sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_YEST);
|
||||
sim->create_part(-1, x+random_gen()%3-1, y+random_gen()%3-1, PT_YEST);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ int Tool_Mix::Perform(Simulation * sim, Particle * cpart, int x, int y, int brus
|
||||
if(!thisPart)
|
||||
return 0;
|
||||
|
||||
if(rand() % 100 != 0)
|
||||
if(random_gen() % 100 != 0)
|
||||
return 0;
|
||||
|
||||
int distance = (int)(std::pow(strength, .5f) * 10);
|
||||
@ -22,8 +22,8 @@ int Tool_Mix::Perform(Simulation * sim, Particle * cpart, int x, int y, int brus
|
||||
if(!(sim->elements[TYP(thisPart)].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS)))
|
||||
return 0;
|
||||
|
||||
int newX = x + (rand() % distance) - (distance/2);
|
||||
int newY = y + (rand() % distance) - (distance/2);
|
||||
int newX = x + (random_gen() % distance) - (distance/2);
|
||||
int newY = y + (random_gen() % distance) - (distance/2);
|
||||
|
||||
if(newX < 0 || newY < 0 || newX >= XRES || newY >= YRES)
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user