Fix RNG usage
Mostly boils down to having graphics functions use Renderer's RNG, update and similar functions Simulation's.
This commit is contained in:
parent
c23eba1921
commit
eee42b2ea3
@ -164,7 +164,6 @@ struct ExplicitSingletons
|
||||
http::RequestManagerPtr requestManager;
|
||||
std::unique_ptr<Client> client;
|
||||
std::unique_ptr<SaveRenderer> saveRenderer;
|
||||
std::unique_ptr<RNG> rng;
|
||||
std::unique_ptr<Favorite> favorite;
|
||||
std::unique_ptr<ui::Engine> engine;
|
||||
std::unique_ptr<GameController> gameController;
|
||||
@ -344,7 +343,6 @@ int main(int argc, char * argv[])
|
||||
Client::Ref().Initialize();
|
||||
|
||||
explicitSingletons->saveRenderer = std::make_unique<SaveRenderer>();
|
||||
explicitSingletons->rng = std::make_unique<RNG>();
|
||||
explicitSingletons->favorite = std::make_unique<Favorite>();
|
||||
explicitSingletons->engine = std::make_unique<ui::Engine>();
|
||||
|
||||
|
@ -28,7 +28,6 @@ void TickClient()
|
||||
struct ExplicitSingletons
|
||||
{
|
||||
// These need to be listed in the order they are populated in main.
|
||||
std::unique_ptr<RNG> rng;
|
||||
std::unique_ptr<ui::Engine> engine;
|
||||
};
|
||||
static std::unique_ptr<ExplicitSingletons> explicitSingletons;
|
||||
@ -61,7 +60,6 @@ int main(int argc, char * argv[])
|
||||
if(scale < 1 || scale > 10)
|
||||
scale = 1;
|
||||
|
||||
explicitSingletons->rng = std::make_unique<RNG>();
|
||||
explicitSingletons->engine = std::make_unique<ui::Engine>();
|
||||
|
||||
SDLOpen();
|
||||
|
@ -39,7 +39,6 @@ int main(int argc, char *argv[])
|
||||
throw e;
|
||||
}
|
||||
|
||||
auto rng = std::make_unique<RNG>();
|
||||
Simulation * sim = new Simulation();
|
||||
Renderer * ren = new Renderer(sim);
|
||||
|
||||
|
@ -76,7 +76,7 @@ bool WriteFile(const std::vector<char> &fileData, ByteString filename)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
writeFileName = ByteString::Build(filename, ".temp.", Format::Width(5), Format::Fill('0'), random_gen() % 100000);
|
||||
writeFileName = ByteString::Build(filename, ".temp.", Format::Width(5), Format::Fill('0'), interfaceRng() % 100000);
|
||||
if (!FileExists(writeFileName))
|
||||
{
|
||||
break;
|
||||
|
@ -9,7 +9,7 @@ static inline uint64_t rotl(const uint64_t x, int k)
|
||||
return (x << k) | (x >> (64 - k));
|
||||
}
|
||||
|
||||
uint64_t RNGType::next()
|
||||
uint64_t RNG::next()
|
||||
{
|
||||
const uint64_t s0 = s[0];
|
||||
uint64_t s1 = s[1];
|
||||
@ -22,44 +22,44 @@ uint64_t RNGType::next()
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned int RNGType::gen()
|
||||
unsigned int RNG::gen()
|
||||
{
|
||||
return next() & 0x7FFFFFFF;
|
||||
}
|
||||
|
||||
unsigned int RNGType::operator()()
|
||||
unsigned int RNG::operator()()
|
||||
{
|
||||
return next()&0xFFFFFFFF;
|
||||
}
|
||||
|
||||
int RNGType::between(int lower, int upper)
|
||||
int RNG::between(int lower, int upper)
|
||||
{
|
||||
unsigned int r = next();
|
||||
return static_cast<int>(r % (upper - lower + 1)) + lower;
|
||||
}
|
||||
|
||||
bool RNGType::chance(int nominator, unsigned int denominator)
|
||||
bool RNG::chance(int nominator, unsigned int denominator)
|
||||
{
|
||||
if (nominator < 0)
|
||||
return false;
|
||||
return next() % denominator < static_cast<unsigned int>(nominator);
|
||||
}
|
||||
|
||||
float RNGType::uniform01()
|
||||
float RNG::uniform01()
|
||||
{
|
||||
return static_cast<float>(next()&0xFFFFFFFF)/(float)0xFFFFFFFF;
|
||||
}
|
||||
|
||||
RNGType::RNGType()
|
||||
RNG::RNG()
|
||||
{
|
||||
s[0] = time(NULL);
|
||||
s[1] = 614;
|
||||
}
|
||||
|
||||
void RNGType::seed(unsigned int sd)
|
||||
void RNG::seed(unsigned int sd)
|
||||
{
|
||||
s[0] = sd;
|
||||
s[1] = sd;
|
||||
}
|
||||
|
||||
RNGType random_gen;
|
||||
RNG interfaceRng;
|
||||
|
@ -1,11 +1,12 @@
|
||||
#pragma once
|
||||
#include "ExplicitSingleton.h"
|
||||
#include <stdint.h>
|
||||
#include <array>
|
||||
|
||||
class RNGType
|
||||
class RNG
|
||||
{
|
||||
private:
|
||||
uint64_t s[2];
|
||||
std::array<uint64_t, 2> s;
|
||||
uint64_t next();
|
||||
public:
|
||||
unsigned int operator()();
|
||||
@ -14,13 +15,11 @@ public:
|
||||
bool chance(int nominator, unsigned int denominator);
|
||||
float uniform01();
|
||||
|
||||
RNGType();
|
||||
RNG();
|
||||
void seed(unsigned int sd);
|
||||
};
|
||||
|
||||
// Needed because we also have random_gen, and that would take the singleton role if RNGType had an ExplicitSingleton base.
|
||||
class RNG : public RNGType, public ExplicitSingleton<RNG>
|
||||
{
|
||||
};
|
||||
|
||||
extern RNGType random_gen;
|
||||
// Please only use this on the main thread and never for simulation stuff.
|
||||
// For simulation stuff, use Simulation::rng. For renderer stuff, use Renderer::rng.
|
||||
// For anything else, prefer a dedicated RNG instance over this one.
|
||||
extern RNG interfaceRng;
|
||||
|
@ -589,7 +589,7 @@ void Renderer::render_parts()
|
||||
}
|
||||
if(pixel_mode & PMODE_SPARK)
|
||||
{
|
||||
flicker = float(random_gen()%20);
|
||||
flicker = float(rng()%20);
|
||||
gradv = 4*sim->parts[i].life + flicker;
|
||||
for (x = 0; gradv>0.5; x++) {
|
||||
addpixel(nx+x, ny, colr, colg, colb, int(gradv));
|
||||
@ -602,7 +602,7 @@ void Renderer::render_parts()
|
||||
}
|
||||
if(pixel_mode & PMODE_FLARE)
|
||||
{
|
||||
flicker = float(random_gen()%20);
|
||||
flicker = float(rng()%20);
|
||||
gradv = flicker + fabs(parts[i].vx)*17 + fabs(sim->parts[i].vy)*17;
|
||||
blendpixel(nx, ny, colr, colg, colb, int((gradv*4)>255?255:(gradv*4)) );
|
||||
blendpixel(nx+1, ny, colr, colg, colb,int( (gradv*2)>255?255:(gradv*2)) );
|
||||
@ -624,7 +624,7 @@ void Renderer::render_parts()
|
||||
}
|
||||
if(pixel_mode & PMODE_LFLARE)
|
||||
{
|
||||
flicker = float(random_gen()%20);
|
||||
flicker = float(rng()%20);
|
||||
gradv = flicker + fabs(parts[i].vx)*17 + fabs(parts[i].vy)*17;
|
||||
blendpixel(nx, ny, colr, colg, colb, int((gradv*4)>255?255:(gradv*4)) );
|
||||
blendpixel(nx+1, ny, colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) );
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <vector>
|
||||
#include "Graphics.h"
|
||||
#include "gui/interface/Point.h"
|
||||
#include "common/tpt-rand.h"
|
||||
#include "SimulationConfig.h"
|
||||
|
||||
class RenderPreset;
|
||||
@ -58,6 +59,8 @@ public:
|
||||
return video.data();
|
||||
}
|
||||
|
||||
RNG rng;
|
||||
|
||||
Simulation * sim;
|
||||
gcache_item *graphicscache;
|
||||
|
||||
|
@ -111,13 +111,13 @@ GOLWindow::GOLWindow(GameModel &gameModel_, Simulation *sim_, int toolSelection,
|
||||
auto &prefs = GlobalPrefs::Ref();
|
||||
ruleField->SetText(prefs.Get("CustomGOL.Rule", String("B3/S23")));
|
||||
nameField->SetText(prefs.Get("CustomGOL.Name", String("CGOL")));
|
||||
highColour.Red = RNG::Ref().between(0x80, 0xFF);
|
||||
highColour.Green = RNG::Ref().between(0x80, 0xFF);
|
||||
highColour.Blue = RNG::Ref().between(0x80, 0xFF);
|
||||
highColour.Red = interfaceRng.between(0x80, 0xFF);
|
||||
highColour.Green = interfaceRng.between(0x80, 0xFF);
|
||||
highColour.Blue = interfaceRng.between(0x80, 0xFF);
|
||||
highColour.Alpha = 0xFF;
|
||||
lowColour.Red = RNG::Ref().between(0x00, 0x7F);
|
||||
lowColour.Green = RNG::Ref().between(0x00, 0x7F);
|
||||
lowColour.Blue = RNG::Ref().between(0x00, 0x7F);
|
||||
lowColour.Red = interfaceRng.between(0x00, 0x7F);
|
||||
lowColour.Green = interfaceRng.between(0x00, 0x7F);
|
||||
lowColour.Blue = interfaceRng.between(0x00, 0x7F);
|
||||
lowColour.Alpha = 0xFF;
|
||||
}
|
||||
updateGradient();
|
||||
|
@ -222,7 +222,7 @@ void PreviewView::CheckComment()
|
||||
{
|
||||
if (!commentHelpText)
|
||||
{
|
||||
if (random_gen()%2)
|
||||
if (interfaceRng()%2)
|
||||
commentWarningLabel->SetText("Stolen? Report the save instead");
|
||||
else
|
||||
commentWarningLabel->SetText("Please report stolen saves");
|
||||
@ -238,7 +238,7 @@ void PreviewView::CheckComment()
|
||||
{
|
||||
if (!commentHelpText)
|
||||
{
|
||||
if (random_gen()%2)
|
||||
if (interfaceRng()%2)
|
||||
commentWarningLabel->SetText("Please do not swear");
|
||||
else
|
||||
commentWarningLabel->SetText("Bad language may be deleted");
|
||||
|
@ -376,7 +376,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 <= (random_gen()%250))
|
||||
else if ((type == PT_HSWC && sim.parts[i].life != 10) || sim.elements[type].HeatConduct <= (sim.rng()%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))
|
||||
|
@ -107,15 +107,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) && RNG::Ref().chance(1, 1000))
|
||||
if ((TYP(r)==PT_WATR||TYP(r)==PT_DSTW||TYP(r)==PT_SLTW) && sim->rng.chance(1, 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) && RNG::Ref().chance(1, 1000))
|
||||
if ((TYP(r)==PT_ICEI || TYP(r)==PT_SNOW) && sim->rng.chance(1, 1000))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_WATR);
|
||||
if (RNG::Ref().chance(1, 1000))
|
||||
if (sim->rng.chance(1, 1000))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_WATR);
|
||||
}
|
||||
}
|
||||
@ -129,7 +129,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) && RNG::Ref().chance(1, 10))
|
||||
if ((TYP(r)==PT_FIRE || TYP(r)==PT_LAVA) && sim->rng.chance(1, 10))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_WTRV);
|
||||
}
|
||||
@ -144,9 +144,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) && RNG::Ref().chance(1, 10))
|
||||
if ((TYP(r)==PT_FIRE || TYP(r)==PT_LAVA) && sim->rng.chance(1, 10))
|
||||
{
|
||||
if (RNG::Ref().chance(1, 4))
|
||||
if (sim->rng.chance(1, 4))
|
||||
sim->part_change_type(i,x,y,PT_SALT);
|
||||
else
|
||||
sim->part_change_type(i,x,y,PT_WTRV);
|
||||
@ -162,7 +162,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) && RNG::Ref().chance(1, 10))
|
||||
if ((TYP(r)==PT_FIRE || TYP(r)==PT_LAVA) && sim->rng.chance(1, 10))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_WTRV);
|
||||
}
|
||||
@ -176,7 +176,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) && RNG::Ref().chance(1, 1000))
|
||||
if ((TYP(r)==PT_WATR || TYP(r)==PT_DSTW) && sim->rng.chance(1, 1000))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_ICEI);
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_ICEI);
|
||||
@ -191,12 +191,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) && RNG::Ref().chance(1, 1000))
|
||||
if ((TYP(r)==PT_WATR || TYP(r)==PT_DSTW) && sim->rng.chance(1, 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) && RNG::Ref().chance(3, 200))
|
||||
if ((TYP(r)==PT_WATR || TYP(r)==PT_DSTW) && sim->rng.chance(3, 200))
|
||||
sim->part_change_type(i,x,y,PT_WATR);
|
||||
}
|
||||
}
|
||||
@ -209,7 +209,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 = RNG::Ref().between(120, 169);
|
||||
parts[i].life = sim->rng.between(120, 169);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -760,7 +760,7 @@ bool Simulation::flood_water(int x, int y, int i)
|
||||
if ((y - 1) > originalY && !pmap[y - 1][x])
|
||||
{
|
||||
// Try to move the water to a random position on this line, because there's probably a free location somewhere
|
||||
int randPos = RNG::Ref().between(x, x2);
|
||||
int randPos = rng.between(x, x2);
|
||||
if (!pmap[y - 1][randPos] && eval_move(parts[i].type, randPos, y - 1, nullptr))
|
||||
x = randPos;
|
||||
// Couldn't move to random position, so try the original position on the left
|
||||
@ -975,7 +975,7 @@ int Simulation::get_wavelength_bin(int *wm)
|
||||
if (wM - w0 < 5)
|
||||
return wM + w0;
|
||||
|
||||
r = RNG::Ref().gen();
|
||||
r = rng.gen();
|
||||
i = (r >> 1) % (wM-w0-4);
|
||||
i += w0;
|
||||
|
||||
@ -1387,7 +1387,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
|
||||
e = eval_move(parts[i].type, nx, ny, &r);
|
||||
|
||||
/* half-silvered mirror */
|
||||
if (!e && parts[i].type==PT_PHOT && ((TYP(r)==PT_BMTL && RNG::Ref().chance(1, 2)) || TYP(pmap[y][x])==PT_BMTL))
|
||||
if (!e && parts[i].type==PT_PHOT && ((TYP(r)==PT_BMTL && rng.chance(1, 2)) || TYP(pmap[y][x])==PT_BMTL))
|
||||
e = 2;
|
||||
|
||||
if (!e) //if no movement
|
||||
@ -1437,7 +1437,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Element_FILT_interactWavelengths(Particle* cpart, int origWl);
|
||||
int Element_FILT_interactWavelengths(Simulation *sim, Particle* cpart, int origWl);
|
||||
if (e == 2) //if occupy same space
|
||||
{
|
||||
switch (parts[i].type)
|
||||
@ -1447,14 +1447,14 @@ 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 && RNG::Ref().chance(29, 30))
|
||||
if (!parts[ID(r)].life && rng.chance(29, 30))
|
||||
{
|
||||
parts[ID(r)].life = 120;
|
||||
create_gain_photon(i);
|
||||
}
|
||||
break;
|
||||
case PT_FILT:
|
||||
parts[i].ctype = Element_FILT_interactWavelengths(&parts[ID(r)], parts[i].ctype);
|
||||
parts[i].ctype = Element_FILT_interactWavelengths(this, &parts[ID(r)], parts[i].ctype);
|
||||
break;
|
||||
case PT_C5:
|
||||
if (parts[ID(r)].life > 0 && (parts[ID(r)].ctype & parts[i].ctype & 0xFFFFFFC0))
|
||||
@ -1534,7 +1534,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 (RNG::Ref().chance(9, 10))
|
||||
if (rng.chance(9, 10))
|
||||
create_cherenkov_photon(i);
|
||||
break;
|
||||
case PT_ELEC:
|
||||
@ -1551,7 +1551,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
|
||||
case PT_BIZR:
|
||||
case PT_BIZRG:
|
||||
if (TYP(r) == PT_FILT)
|
||||
parts[i].ctype = Element_FILT_interactWavelengths(&parts[ID(r)], parts[i].ctype);
|
||||
parts[i].ctype = Element_FILT_interactWavelengths(this, &parts[ID(r)], parts[i].ctype);
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
@ -1611,7 +1611,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
|
||||
case PT_SOAP:
|
||||
if (parts[i].type == PT_OIL)
|
||||
{
|
||||
if (RNG::Ref().chance(19, 20) || std::abs(parts[i].x - nx) > 3 || std::abs(parts[i].y - ny) > 3)
|
||||
if (rng.chance(19, 20) || std::abs(parts[i].x - nx) > 3 || std::abs(parts[i].y - ny) > 3)
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
@ -2124,13 +2124,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) + int(sandcolour * 1.3) + RNG::Ref().between(-20, 20) + RNG::Ref().between(-15, 15);
|
||||
colg = PIXG(elements[t].Colour) + int(sandcolour * 1.3) + RNG::Ref().between(-20, 20) + RNG::Ref().between(-15, 15);
|
||||
colb = PIXB(elements[t].Colour) + int(sandcolour * 1.3) + RNG::Ref().between(-20, 20) + RNG::Ref().between(-15, 15);
|
||||
colr = PIXR(elements[t].Colour) + int(sandcolour * 1.3) + rng.between(-20, 20) + rng.between(-15, 15);
|
||||
colg = PIXG(elements[t].Colour) + int(sandcolour * 1.3) + rng.between(-20, 20) + rng.between(-15, 15);
|
||||
colb = PIXB(elements[t].Colour) + int(sandcolour * 1.3) + rng.between(-20, 20) + rng.between(-15, 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 = (RNG::Ref().between(0, 149)<<24) | (colr<<16) | (colg<<8) | colb;
|
||||
parts[i].dcolour = (rng.between(0, 149)<<24) | (colr<<16) | (colg<<8) | colb;
|
||||
}
|
||||
|
||||
// Set non-static properties (such as randomly generated ones)
|
||||
@ -2192,7 +2192,7 @@ void Simulation::create_gain_photon(int pp)//photons from PHOT going through GLO
|
||||
return;
|
||||
i = pfree;
|
||||
|
||||
lr = 2*RNG::Ref().between(0, 1) - 1; // -1 or 1
|
||||
lr = 2*rng.between(0, 1) - 1; // -1 or 1
|
||||
|
||||
xx = parts[pp].x - lr*0.3*parts[pp].vy;
|
||||
yy = parts[pp].y + lr*0.3*parts[pp].vx;
|
||||
@ -2247,7 +2247,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 = RNG::Ref().between(0, 1);
|
||||
lr = rng.between(0, 1);
|
||||
|
||||
parts[i].type = PT_PHOT;
|
||||
parts[i].ctype = 0x00000F80;
|
||||
@ -2398,11 +2398,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*(2.0f*RNG::Ref().uniform01()-1.0f);
|
||||
parts[i].vy += 0.05*sqrtf(parts[i].temp)*elements[t].Diffusion*(2.0f*RNG::Ref().uniform01()-1.0f);
|
||||
parts[i].vx += 0.05*sqrtf(parts[i].temp)*elements[t].Diffusion*(2.0f*rng.uniform01()-1.0f);
|
||||
parts[i].vy += 0.05*sqrtf(parts[i].temp)*elements[t].Diffusion*(2.0f*rng.uniform01()-1.0f);
|
||||
#else
|
||||
parts[i].vx += elements[t].Diffusion*(2.0f*RNG::Ref().uniform01()-1.0f);
|
||||
parts[i].vy += elements[t].Diffusion*(2.0f*RNG::Ref().uniform01()-1.0f);
|
||||
parts[i].vx += elements[t].Diffusion*(2.0f*rng.uniform01()-1.0f);
|
||||
parts[i].vy += elements[t].Diffusion*(2.0f*rng.uniform01()-1.0f);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -2425,7 +2425,7 @@ void Simulation::UpdateParticles(int start, int end)
|
||||
|
||||
if (!legacy_enable)
|
||||
{
|
||||
if ((elements[t].Properties&TYPE_LIQUID) && (t!=PT_GEL || gel_scale > (1 + RNG::Ref().between(0, 254))))
|
||||
if ((elements[t].Properties&TYPE_LIQUID) && (t!=PT_GEL || gel_scale > (1 + rng.between(0, 254))))
|
||||
{
|
||||
float convGravX, convGravY;
|
||||
GetGravityField(x, y, -2.0f, -2.0f, convGravX, convGravY);
|
||||
@ -2448,7 +2448,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) && RNG::Ref().chance(int(elements[t].HeatConduct*gel_scale), 250))
|
||||
if (t && (t!=PT_HSWC||parts[i].life==10) && rng.chance(int(elements[t].HeatConduct*gel_scale), 250))
|
||||
#endif
|
||||
{
|
||||
if (aheat_enable && !(elements[t].Properties&PROP_NOAMBHEAT))
|
||||
@ -2605,7 +2605,7 @@ void Simulation::UpdateParticles(int start, int end)
|
||||
{
|
||||
pt = (c_heat - platent[t])/c_Cm;
|
||||
|
||||
t = RNG::Ref().chance(1, 4) ? PT_SALT : PT_WTRV;
|
||||
t = rng.chance(1, 4) ? PT_SALT : PT_WTRV;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2613,7 +2613,7 @@ void Simulation::UpdateParticles(int start, int end)
|
||||
s = 0;
|
||||
}
|
||||
#else
|
||||
t = RNG::Ref().chance(1, 4) ? PT_SALT : PT_WTRV;
|
||||
t = rng.chance(1, 4) ? PT_SALT : PT_WTRV;
|
||||
#endif
|
||||
}
|
||||
else if (t == PT_BRMT)
|
||||
@ -2759,7 +2759,7 @@ void Simulation::UpdateParticles(int start, int end)
|
||||
goto killed;
|
||||
|
||||
if (t==PT_FIRE || t==PT_PLSM || t==PT_CFLM)
|
||||
parts[i].life = RNG::Ref().between(120, 169);
|
||||
parts[i].life = rng.between(120, 169);
|
||||
if (t == PT_LAVA)
|
||||
{
|
||||
if (parts[i].ctype == PT_BRMT) parts[i].ctype = PT_BMTL;
|
||||
@ -2767,7 +2767,7 @@ void Simulation::UpdateParticles(int start, int end)
|
||||
else if (parts[i].ctype == PT_BGLA) parts[i].ctype = PT_GLAS;
|
||||
else if (parts[i].ctype == PT_PQRT) parts[i].ctype = PT_QRTZ;
|
||||
else if (parts[i].ctype == PT_LITH && parts[i].tmp2 > 3) parts[i].ctype = PT_GLAS;
|
||||
parts[i].life = RNG::Ref().between(240, 359);
|
||||
parts[i].life = rng.between(240, 359);
|
||||
}
|
||||
transitionOccurred = true;
|
||||
}
|
||||
@ -2841,7 +2841,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 = RNG::Ref().between(180, 259);
|
||||
parts[i].life = rng.between(180, 259);
|
||||
parts[i].temp = restrict_flt(elements[PT_FIRE].DefaultProperties.temp + (elements[t].Flammable/2), MIN_TEMP, MAX_TEMP);
|
||||
t = PT_FIRE;
|
||||
part_change_type(i,x,y,t);
|
||||
@ -2897,7 +2897,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 = RNG::Ref().between(120, 169);
|
||||
parts[i].life = rng.between(120, 169);
|
||||
transitionOccurred = true;
|
||||
}
|
||||
|
||||
@ -3143,7 +3143,7 @@ killed:
|
||||
continue;
|
||||
// reflection
|
||||
parts[i].flags |= FLAG_STAGNANT;
|
||||
if (t==PT_NEUT && RNG::Ref().chance(1, 10))
|
||||
if (t==PT_NEUT && rng.chance(1, 10))
|
||||
{
|
||||
kill_part(i);
|
||||
continue;
|
||||
@ -3178,7 +3178,7 @@ killed:
|
||||
{
|
||||
if (TYP(r) == PT_CRMC)
|
||||
{
|
||||
float r = RNG::Ref().between(-50, 50) * 0.01f, rx, ry, anrx, anry;
|
||||
float r = rng.between(-50, 50) * 0.01f, rx, ry, anrx, anry;
|
||||
r = r * r * r;
|
||||
rx = cosf(r); ry = sinf(r);
|
||||
anrx = rx * nrx + ry * nry;
|
||||
@ -3240,7 +3240,7 @@ killed:
|
||||
else
|
||||
{
|
||||
// Checking stagnant is cool, but then it doesn't update when you change it later.
|
||||
if (water_equal_test && elements[t].Falldown == 2 && RNG::Ref().chance(1, 200))
|
||||
if (water_equal_test && elements[t].Falldown == 2 && rng.chance(1, 200))
|
||||
{
|
||||
if (flood_water(x, y, i))
|
||||
goto movedone;
|
||||
@ -3263,7 +3263,7 @@ killed:
|
||||
else
|
||||
{
|
||||
s = 1;
|
||||
r = RNG::Ref().between(0, 1) * 2 - 1;// position search direction (left/right first)
|
||||
r = rng.between(0, 1) * 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))
|
||||
{
|
||||
@ -3745,7 +3745,7 @@ void Simulation::CheckStacking()
|
||||
excessive_stacking_found = 1;
|
||||
}
|
||||
}
|
||||
else if (pmap_count[y][x]>1500 || (unsigned int)RNG::Ref().between(0, 1599) <= (pmap_count[y][x]+100))
|
||||
else if (pmap_count[y][x]>1500 || (unsigned int)rng.between(0, 1599) <= (pmap_count[y][x]+100))
|
||||
{
|
||||
pmap_count[y][x] = pmap_count[y][x] + NPART;
|
||||
excessive_stacking_found = true;
|
||||
@ -3846,7 +3846,7 @@ void Simulation::BeforeSim()
|
||||
}
|
||||
|
||||
// check for stacking and create BHOL if found
|
||||
if (force_stacking_check || RNG::Ref().chance(1, 10))
|
||||
if (force_stacking_check || rng.chance(1, 10))
|
||||
{
|
||||
CheckStacking();
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "MenuSection.h"
|
||||
#include "CoordStack.h"
|
||||
#include "gravity/GravityPtr.h"
|
||||
#include "common/tpt-rand.h"
|
||||
#include "Element.h"
|
||||
#include "SimulationConfig.h"
|
||||
#include <cstring>
|
||||
@ -38,6 +39,7 @@ public:
|
||||
|
||||
GravityPtr grav;
|
||||
Air * air;
|
||||
RNG rng;
|
||||
|
||||
std::vector<sign> signs;
|
||||
std::array<Element, PT_NUM> elements;
|
||||
|
@ -72,14 +72,14 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (rt == PT_WTRV)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 250))
|
||||
if (sim->rng.chance(1, 250))
|
||||
{
|
||||
sim->part_change_type(i, x, y, PT_CAUS);
|
||||
parts[i].life = RNG::Ref().between(25, 74);
|
||||
parts[i].life = sim->rng.between(25, 74);
|
||||
sim->kill_part(ID(r));
|
||||
}
|
||||
}
|
||||
else if (rt != PT_CLNE && rt != PT_PCLN && parts[i].life >= 50 && RNG::Ref().chance(sim->elements[rt].Hardness, 1000))
|
||||
else if (rt != PT_CLNE && rt != PT_PCLN && parts[i].life >= 50 && sim->rng.chance(sim->elements[rt].Hardness, 1000))
|
||||
{
|
||||
if (sim->parts_avg(i, ID(r),PT_GLAS)!= PT_GLAS)//GLAS protects stuff from acid
|
||||
{
|
||||
@ -110,8 +110,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
for (trade = 0; trade<2; trade++)
|
||||
{
|
||||
rx = RNG::Ref().between(-2, 2);
|
||||
ry = RNG::Ref().between(-2, 2);
|
||||
rx = sim->rng.between(-2, 2);
|
||||
ry = sim->rng.between(-2, 2);
|
||||
if (BOUNDS_CHECK && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
|
@ -66,7 +66,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
}
|
||||
if (RNG::Ref().chance(1, 10))
|
||||
if (sim->rng.chance(1, 10))
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_PHOT);
|
||||
else
|
||||
sim->kill_part(ID(r));
|
||||
|
@ -59,10 +59,10 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if (TYP(r)==PT_CFLM && RNG::Ref().chance(1, 4))
|
||||
if (TYP(r)==PT_CFLM && sim->rng.chance(1, 4))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_CFLM);
|
||||
parts[i].life = RNG::Ref().between(50, 199);
|
||||
parts[i].life = sim->rng.between(50, 199);
|
||||
parts[ID(r)].temp = parts[i].temp = 0;
|
||||
sim->pv[y/CELL][x/CELL] -= 0.5;
|
||||
}
|
||||
|
@ -128,8 +128,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (parts[r].tmp != 6)
|
||||
{
|
||||
int Element_FILT_interactWavelengths(Particle* cpart, int origWl);
|
||||
colored = Element_FILT_interactWavelengths(&parts[r], colored);
|
||||
int Element_FILT_interactWavelengths(Simulation *sim, Particle* cpart, int origWl);
|
||||
colored = Element_FILT_interactWavelengths(sim, &parts[r], colored);
|
||||
if (!colored)
|
||||
break;
|
||||
}
|
||||
|
@ -87,29 +87,29 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
//Explode!!
|
||||
sim->pv[y/CELL][x/CELL] += 0.5f;
|
||||
parts[i].tmp = 0;
|
||||
if (RNG::Ref().chance(1, 3))
|
||||
if (sim->rng.chance(1, 3))
|
||||
{
|
||||
if (RNG::Ref().chance(1, 2))
|
||||
if (sim->rng.chance(1, 2))
|
||||
{
|
||||
sim->create_part(i, x, y, PT_FIRE);
|
||||
}
|
||||
else
|
||||
{
|
||||
sim->create_part(i, x, y, PT_SMKE);
|
||||
parts[i].life = RNG::Ref().between(500, 549);
|
||||
parts[i].life = sim->rng.between(500, 549);
|
||||
}
|
||||
parts[i].temp = restrict_flt((MAX_TEMP/4)+otemp, MIN_TEMP, MAX_TEMP);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RNG::Ref().chance(1, 15))
|
||||
if (sim->rng.chance(1, 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 = float(RNG::Ref().between(-10, 10));
|
||||
parts[i].vy = float(RNG::Ref().between(-10, 10));
|
||||
parts[i].vx = float(sim->rng.between(-10, 10));
|
||||
parts[i].vy = float(sim->rng.between(-10, 10));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ constexpr float ADVECTION = 0.1f;
|
||||
static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (!parts[i].life && sim->pv[y/CELL][x/CELL]>4.0f)
|
||||
parts[i].life = RNG::Ref().between(80, 119);
|
||||
parts[i].life = sim->rng.between(80, 119);
|
||||
if (parts[i].life)
|
||||
{
|
||||
parts[i].vx += ADVECTION*sim->vx[y/CELL][x/CELL];
|
||||
@ -84,10 +84,10 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x + RNG::Ref().between(-1, 1), y + RNG::Ref().between(-1, 1), PT_LIFE, parts[i].tmp);
|
||||
else if (parts[i].ctype!=PT_LIGH || RNG::Ref().chance(1, 30))
|
||||
if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x + sim->rng.between(-1, 1), y + sim->rng.between(-1, 1), PT_LIFE, parts[i].tmp);
|
||||
else if (parts[i].ctype!=PT_LIGH || sim->rng.chance(1, 30))
|
||||
{
|
||||
int np = sim->create_part(-1, x + RNG::Ref().between(-1, 1), y + RNG::Ref().between(-1, 1), TYP(parts[i].ctype));
|
||||
int np = sim->create_part(-1, x + sim->rng.between(-1, 1), y + sim->rng.between(-1, 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 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((TYP(r)==PT_METL || TYP(r)==PT_IRON) && RNG::Ref().chance(1, 100))
|
||||
if ((TYP(r)==PT_METL || TYP(r)==PT_IRON) && sim->rng.chance(1, 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 - RNG::Ref().between(0, 4);
|
||||
parts[ID(r)].tmp = (parts[i].tmp<=7) ? parts[i].tmp=1 : parts[i].tmp - sim->rng.between(0, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (parts[i].tmp==1 && RNG::Ref().chance(1, 1000))
|
||||
else if (parts[i].tmp==1 && sim->rng.chance(1, 1000))
|
||||
{
|
||||
parts[i].tmp = 0;
|
||||
sim->part_change_type(i,x,y,PT_BRMT);
|
||||
|
@ -99,8 +99,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
parts[nb].tmp = 0;
|
||||
parts[nb].life = 50;
|
||||
parts[nb].temp = MAX_TEMP;
|
||||
parts[nb].vx = float(RNG::Ref().between(-20, 20));
|
||||
parts[nb].vy = float(RNG::Ref().between(-20, 20));
|
||||
parts[nb].vx = float(sim->rng.between(-20, 20));
|
||||
parts[nb].vy = float(sim->rng.between(-20, 20));
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
@ -71,12 +71,12 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
continue;
|
||||
if (TYP(r)==PT_WATR)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 30))
|
||||
if (sim->rng.chance(1, 30))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_FOG);
|
||||
}
|
||||
else if (TYP(r)==PT_O2)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 9))
|
||||
if (sim->rng.chance(1, 9))
|
||||
{
|
||||
sim->kill_part(ID(r));
|
||||
sim->part_change_type(i,x,y,PT_WATR);
|
||||
|
@ -51,7 +51,7 @@ static int 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 && RNG::Ref().chance(1, 200))
|
||||
if (parts[i].temp>9000 && sim->pv[y/CELL][x/CELL]>30.0f && sim->rng.chance(1, 200))
|
||||
{
|
||||
sim->part_change_type(i, x ,y ,PT_EXOT);
|
||||
parts[i].life = 1000;
|
||||
|
@ -60,9 +60,9 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if (TYP(r)==PT_BREC && RNG::Ref().chance(1, tempFactor))
|
||||
if (TYP(r)==PT_BREC && sim->rng.chance(1, tempFactor))
|
||||
{
|
||||
if (RNG::Ref().chance(1, 2))
|
||||
if (sim->rng.chance(1, 2))
|
||||
{
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_THRM);
|
||||
}
|
||||
|
@ -59,11 +59,11 @@ static int 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 (RNG::Ref().chance(1, 6))
|
||||
if (sim->rng.chance(1, 6))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_CFLM);
|
||||
parts[ID(r)].temp = parts[i].temp = 0;
|
||||
parts[i].life = RNG::Ref().between(50, 199);
|
||||
parts[i].life = sim->rng.between(50, 199);
|
||||
sim->pv[y/CELL][x/CELL] += 1.5;
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ static int 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 && RNG::Ref().chance(sim->elements[TYP(r)].Hardness, 1000)) && parts[i].life >= 50)
|
||||
if ((TYP(r) != PT_CLNE && TYP(r) != PT_PCLN && sim->rng.chance(sim->elements[TYP(r)].Hardness, 1000)) && parts[i].life >= 50)
|
||||
{
|
||||
// GLAS protects stuff from acid
|
||||
if (sim->parts_avg(i, ID(r),PT_GLAS) != PT_GLAS)
|
||||
|
@ -53,7 +53,7 @@ static int 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 || RNG::Ref().chance(1, 4000))
|
||||
if (sim->pv[y/CELL][x/CELL] <= -0.5 || sim->rng.chance(1, 4000))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_CO2);
|
||||
parts[i].ctype = 5;
|
||||
@ -63,15 +63,15 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
if (parts[i].tmp2!=20) {
|
||||
parts[i].tmp2 -= (parts[i].tmp2>20)?1:-1;
|
||||
}
|
||||
else if (RNG::Ref().chance(1, 200))
|
||||
else if (sim->rng.chance(1, 200))
|
||||
{
|
||||
parts[i].tmp2 = RNG::Ref().between(0, 39);
|
||||
parts[i].tmp2 = sim->rng.between(0, 39);
|
||||
}
|
||||
|
||||
if(parts[i].tmp>0)
|
||||
{
|
||||
//Explode
|
||||
if(parts[i].tmp==1 && RNG::Ref().chance(3, 4))
|
||||
if(parts[i].tmp==1 && sim->rng.chance(3, 4))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_CO2);
|
||||
parts[i].ctype = 5;
|
||||
@ -86,12 +86,12 @@ static int 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 && RNG::Ref().chance(1, 83))
|
||||
if ((sim->elements[TYP(r)].Properties&TYPE_PART) && parts[i].tmp == 0 && sim->rng.chance(1, 83))
|
||||
{
|
||||
//Start explode
|
||||
parts[i].tmp = RNG::Ref().between(0, 24);
|
||||
parts[i].tmp = sim->rng.between(0, 24);
|
||||
}
|
||||
else if((sim->elements[TYP(r)].Properties&TYPE_SOLID) && TYP(r)!=PT_DMND && TYP(r)!=PT_GLAS && parts[i].tmp == 0 && RNG::Ref().chance(int(2 - sim->pv[y/CELL][x/CELL]), 6667))
|
||||
else if((sim->elements[TYP(r)].Properties&TYPE_SOLID) && TYP(r)!=PT_DMND && TYP(r)!=PT_GLAS && parts[i].tmp == 0 && sim->rng.chance(int(2 - sim->pv[y/CELL][x/CELL]), 6667))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_CO2);
|
||||
parts[i].ctype = 5;
|
||||
@ -117,7 +117,7 @@ static int 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)) && RNG::Ref().chance(1, 166))
|
||||
if ((sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && sim->rng.chance(1, 166))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_FIRE);
|
||||
parts[i].life = 4;
|
||||
@ -126,7 +126,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (TYP(r)==PT_FIRE && parts[ID(r)].ctype!=PT_WATR){
|
||||
sim->kill_part(ID(r));
|
||||
if (RNG::Ref().chance(1, 50))
|
||||
if (sim->rng.chance(1, 50))
|
||||
{
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
|
@ -68,5 +68,5 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
{
|
||||
sim->parts[i].life = RNG::Ref().between(50, 199);
|
||||
sim->parts[i].life = sim->rng.between(50, 199);
|
||||
}
|
||||
|
@ -75,10 +75,10 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x + RNG::Ref().between(-1, 1), y + RNG::Ref().between(-1, 1), PT_LIFE, parts[i].tmp);
|
||||
else if (parts[i].ctype!=PT_LIGH || RNG::Ref().chance(1, 30))
|
||||
if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x + sim->rng.between(-1, 1), y + sim->rng.between(-1, 1), PT_LIFE, parts[i].tmp);
|
||||
else if (parts[i].ctype!=PT_LIGH || sim->rng.chance(1, 30))
|
||||
{
|
||||
int np = sim->create_part(-1, x + RNG::Ref().between(-1, 1), y + RNG::Ref().between(-1, 1), TYP(parts[i].ctype));
|
||||
int np = sim->create_part(-1, x + sim->rng.between(-1, 1), y + sim->rng.between(-1, 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)
|
||||
|
@ -62,7 +62,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
continue;
|
||||
if (TYP(r)==PT_WATR)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 1500))
|
||||
if (sim->rng.chance(1, 1500))
|
||||
{
|
||||
sim->create_part(i, x, y, PT_PSTS);
|
||||
sim->kill_part(ID(r));
|
||||
@ -101,5 +101,5 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
{
|
||||
sim->parts[i].tmp = RNG::Ref().between(0, 6);
|
||||
sim->parts[i].tmp = sim->rng.between(0, 6);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
{
|
||||
if (parts[i].ctype==5 && RNG::Ref().chance(1, 2000))
|
||||
if (parts[i].ctype==5 && sim->rng.chance(1, 2000))
|
||||
{
|
||||
if (sim->create_part(-1, x+rx, y+ry, PT_WATR)>=0)
|
||||
parts[i].ctype = 0;
|
||||
@ -65,13 +65,13 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
if (TYP(r)==PT_FIRE)
|
||||
{
|
||||
sim->kill_part(ID(r));
|
||||
if (RNG::Ref().chance(1, 30))
|
||||
if (sim->rng.chance(1, 30))
|
||||
{
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if ((TYP(r)==PT_WATR || TYP(r)==PT_DSTW) && RNG::Ref().chance(1, 50))
|
||||
else if ((TYP(r)==PT_WATR || TYP(r)==PT_DSTW) && sim->rng.chance(1, 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
|
||||
@ -88,14 +88,14 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
if (parts[i].temp > 9773.15 && sim->pv[y/CELL][x/CELL] > 200.0f)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 5))
|
||||
if (sim->rng.chance(1, 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 (RNG::Ref().chance(1, 50))
|
||||
if (sim->rng.chance(1, 50))
|
||||
{
|
||||
j = sim->create_part(-3,x,y,PT_ELEC);
|
||||
if (j != -1)
|
||||
|
@ -58,7 +58,7 @@ int Element_COAL_update(UPDATE_FUNC_ARGS)
|
||||
return 1;
|
||||
} else if (parts[i].life < 100) {
|
||||
parts[i].life--;
|
||||
sim->create_part(-1, x + RNG::Ref().between(-1, 1), y + RNG::Ref().between(-1, 1), PT_FIRE);
|
||||
sim->create_part(-1, x + sim->rng.between(-1, 1), y + sim->rng.between(-1, 1), PT_FIRE);
|
||||
}
|
||||
if (parts[i].type == PT_COAL)
|
||||
{
|
||||
|
@ -67,5 +67,5 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
{
|
||||
sim->parts[i].tmp2 = RNG::Ref().between(0, 4);
|
||||
sim->parts[i].tmp2 = sim->rng.between(0, 4);
|
||||
}
|
||||
|
@ -49,8 +49,8 @@ void Element::Element_DEST()
|
||||
|
||||
static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
int rx = RNG::Ref().between(-2, 2);
|
||||
int ry = RNG::Ref().between(-2, 2);
|
||||
int rx = sim->rng.between(-2, 2);
|
||||
int ry = sim->rng.between(-2, 2);
|
||||
int r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
return 0;
|
||||
@ -60,13 +60,13 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
|
||||
if (parts[i].life<=0 || parts[i].life>37)
|
||||
{
|
||||
parts[i].life = RNG::Ref().between(30, 49);
|
||||
parts[i].life = sim->rng.between(30, 49);
|
||||
sim->pv[y/CELL][x/CELL]+=60.0f;
|
||||
}
|
||||
if (rt == PT_PLUT || rt == PT_DEUT)
|
||||
{
|
||||
sim->pv[y/CELL][x/CELL]+=20.0f;
|
||||
if (RNG::Ref().chance(1, 2))
|
||||
if (sim->rng.chance(1, 2))
|
||||
{
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_NEUT);
|
||||
parts[ID(r)].temp = MAX_TEMP;
|
||||
@ -78,7 +78,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_PLSM);
|
||||
}
|
||||
else if (RNG::Ref().chance(1, 3))
|
||||
else if (sim->rng.chance(1, 3))
|
||||
{
|
||||
sim->kill_part(ID(r));
|
||||
parts[i].life -= 4*((sim->elements[rt].Properties&TYPE_SOLID)?3:1);
|
||||
|
@ -58,7 +58,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
// Prevent division by 0
|
||||
float temp = std::max(1.0f, (parts[i].temp + 1));
|
||||
auto maxlife = int(((10000/(temp + 1))-1));
|
||||
if (RNG::Ref().chance(10000 % static_cast<int>(temp + 1), static_cast<int>(temp + 1)))
|
||||
if (sim->rng.chance(10000 % static_cast<int>(temp + 1), static_cast<int>(temp + 1)))
|
||||
maxlife++;
|
||||
// Compress when Newtonian gravity is applied
|
||||
// multiplier=1 when gravtot=0, multiplier -> 5 as gravtot -> inf
|
||||
@ -72,7 +72,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r || (parts[i].life >=maxlife))
|
||||
continue;
|
||||
if (TYP(r)==PT_DEUT&& RNG::Ref().chance(1, 3))
|
||||
if (TYP(r)==PT_DEUT&& sim->rng.chance(1, 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
|
||||
@ -105,8 +105,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
trade:
|
||||
for ( trade = 0; trade<4; trade ++)
|
||||
{
|
||||
rx = RNG::Ref().between(-2, 2);
|
||||
ry = RNG::Ref().between(-2, 2);
|
||||
rx = sim->rng.between(-2, 2);
|
||||
ry = sim->rng.between(-2, 2);
|
||||
if (BOUNDS_CHECK && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
|
@ -57,29 +57,29 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
switch (TYP(r))
|
||||
{
|
||||
case PT_SALT:
|
||||
if (RNG::Ref().chance(1, 50))
|
||||
if (sim->rng.chance(1, 50))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SLTW);
|
||||
// on average, convert 3 DSTW to SLTW before SALT turns into SLTW
|
||||
if (RNG::Ref().chance(1, 3))
|
||||
if (sim->rng.chance(1, 3))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW);
|
||||
}
|
||||
break;
|
||||
case PT_SLTW:
|
||||
if (RNG::Ref().chance(1, 2000))
|
||||
if (sim->rng.chance(1, 2000))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SLTW);
|
||||
break;
|
||||
}
|
||||
case PT_WATR:
|
||||
if (RNG::Ref().chance(1, 100))
|
||||
if (sim->rng.chance(1, 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) && RNG::Ref().chance(1, 100))
|
||||
if ((sim->legacy_enable||parts[i].temp>12.0f) && sim->rng.chance(1, 100))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_FIRE);
|
||||
parts[i].life = 4;
|
||||
@ -87,7 +87,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
break;
|
||||
case PT_FIRE:
|
||||
sim->kill_part(ID(r));
|
||||
if (RNG::Ref().chance(1, 30))
|
||||
if (sim->rng.chance(1, 30))
|
||||
{
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
|
@ -73,20 +73,20 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
parts[nb].tmp = 0;
|
||||
parts[nb].life = 50;
|
||||
parts[nb].temp = parts[i].temp*0.8f;
|
||||
parts[nb].vx = float(RNG::Ref().between(-10, 10));
|
||||
parts[nb].vy = float(RNG::Ref().between(-10, 10));
|
||||
parts[nb].vx = float(sim->rng.between(-10, 10));
|
||||
parts[nb].vy = float(sim->rng.between(-10, 10));
|
||||
}
|
||||
}
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
case PT_LCRY:
|
||||
parts[ID(r)].tmp2 = RNG::Ref().between(5, 9);
|
||||
parts[ID(r)].tmp2 = sim->rng.between(5, 9);
|
||||
break;
|
||||
case PT_WATR:
|
||||
case PT_DSTW:
|
||||
case PT_SLTW:
|
||||
case PT_CBNW:
|
||||
if (RNG::Ref().chance(1, 3))
|
||||
if (sim->rng.chance(1, 3))
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_O2);
|
||||
else
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_H2);
|
||||
@ -139,7 +139,7 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
{
|
||||
float a = RNG::Ref().between(0, 359) * 3.14159f / 180.0f;
|
||||
float a = sim->rng.between(0, 359) * 3.14159f / 180.0f;
|
||||
sim->parts[i].life = 680;
|
||||
sim->parts[i].vx = 2.0f * cosf(a);
|
||||
sim->parts[i].vy = 2.0f * sinf(a);
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
}
|
||||
void apply(Simulation *sim, Particle &p)
|
||||
{
|
||||
p.temp = restrict_flt(p.temp+getDelta(RNG::Ref().uniform01()), MIN_TEMP, MAX_TEMP);
|
||||
p.temp = restrict_flt(p.temp+getDelta(sim->rng.uniform01()), MIN_TEMP, MAX_TEMP);
|
||||
}
|
||||
};
|
||||
|
||||
@ -118,9 +118,9 @@ void Element_EMP_Trigger(Simulation *sim, int triggerCount)
|
||||
{
|
||||
is_elec = true;
|
||||
temp_center.apply(sim, parts[r]);
|
||||
if (RNG::Ref().uniform01() < prob_changeCenter)
|
||||
if (sim->rng.uniform01() < prob_changeCenter)
|
||||
{
|
||||
if (RNG::Ref().chance(2, 5))
|
||||
if (sim->rng.chance(2, 5))
|
||||
sim->part_change_type(r, rx, ry, PT_BREC);
|
||||
else
|
||||
sim->part_change_type(r, rx, ry, PT_NTCT);
|
||||
@ -143,10 +143,10 @@ void Element_EMP_Trigger(Simulation *sim, int triggerCount)
|
||||
{
|
||||
case PT_METL:
|
||||
temp_metal.apply(sim, parts[n]);
|
||||
if (RNG::Ref().uniform01() < prob_breakMETL)
|
||||
if (sim->rng.uniform01() < prob_breakMETL)
|
||||
{
|
||||
sim->part_change_type(n, rx+nx, ry+ny, PT_BMTL);
|
||||
if (RNG::Ref().uniform01() < prob_breakMETLMore)
|
||||
if (sim->rng.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);
|
||||
@ -155,19 +155,19 @@ void Element_EMP_Trigger(Simulation *sim, int triggerCount)
|
||||
break;
|
||||
case PT_BMTL:
|
||||
temp_metal.apply(sim, parts[n]);
|
||||
if (RNG::Ref().uniform01() < prob_breakBMTL)
|
||||
if (sim->rng.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 (RNG::Ref().uniform01() < prob_randWIFI)
|
||||
if (sim->rng.uniform01() < prob_randWIFI)
|
||||
{
|
||||
// Randomize channel
|
||||
parts[n].temp = float(RNG::Ref().between(0, int(MAX_TEMP)-1));
|
||||
parts[n].temp = float(sim->rng.between(0, int(MAX_TEMP)-1));
|
||||
}
|
||||
if (RNG::Ref().uniform01() < prob_breakWIFI)
|
||||
if (sim->rng.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);
|
||||
@ -180,22 +180,22 @@ void Element_EMP_Trigger(Simulation *sim, int triggerCount)
|
||||
switch (ntype)
|
||||
{
|
||||
case PT_SWCH:
|
||||
if (RNG::Ref().uniform01() < prob_breakSWCH)
|
||||
if (sim->rng.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 (RNG::Ref().uniform01() < prob_breakARAY)
|
||||
if (sim->rng.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 (RNG::Ref().uniform01() < prob_randDLAY)
|
||||
if (sim->rng.uniform01() < prob_randDLAY)
|
||||
{
|
||||
// Randomize delay
|
||||
parts[n].temp = RNG::Ref().between(0, 255) + 273.15f;
|
||||
parts[n].temp = sim->rng.between(0, 255) + 273.15f;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -64,7 +64,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
rt = TYP(r);
|
||||
if (rt == PT_WARP)
|
||||
{
|
||||
if (parts[ID(r)].tmp2>2000 && RNG::Ref().chance(1, 100))
|
||||
if (parts[ID(r)].tmp2>2000 && sim->rng.chance(1, 100))
|
||||
{
|
||||
parts[i].tmp2 += 100;
|
||||
}
|
||||
@ -73,7 +73,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (parts[ID(r)].ctype == PT_PROT)
|
||||
parts[i].ctype = PT_PROT;
|
||||
if (parts[ID(r)].life == 1500 && RNG::Ref().chance(1, 1000))
|
||||
if (parts[ID(r)].life == 1500 && sim->rng.chance(1, 1000))
|
||||
parts[i].life = 1500;
|
||||
}
|
||||
else if (rt == PT_LAVA)
|
||||
@ -81,7 +81,7 @@ static int 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 (RNG::Ref().chance(1, 10))
|
||||
if (sim->rng.chance(1, 10))
|
||||
{
|
||||
parts[ID(r)].ctype = PT_VIBR;
|
||||
sim->kill_part(i);
|
||||
@ -91,7 +91,7 @@ static int 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 (RNG::Ref().chance(1, 1000))
|
||||
if (sim->rng.chance(1, 1000))
|
||||
{
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
@ -138,8 +138,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
for (trade = 0; trade < 9; trade++)
|
||||
{
|
||||
rx = RNG::Ref().between(-2, 2);
|
||||
ry = RNG::Ref().between(-2, 2);
|
||||
rx = sim->rng.between(-2, 2);
|
||||
ry = sim->rng.between(-2, 2);
|
||||
if (BOUNDS_CHECK && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
@ -193,7 +193,7 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
auto c = cpart->tmp2;
|
||||
if (cpart->life < 1001)
|
||||
{
|
||||
if (RNG::Ref().chance(cpart->tmp2 - 1, 1000))
|
||||
if (ren->rng.chance(cpart->tmp2 - 1, 1000))
|
||||
{
|
||||
float frequency = 0.04045f;
|
||||
*colr = int(sin(frequency*c + 4) * 127 + 150);
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
static int graphics(GRAPHICS_FUNC_ARGS);
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS);
|
||||
int Element_FILT_interactWavelengths(Particle* cpart, int origWl);
|
||||
int Element_FILT_interactWavelengths(Simulation *sim, Particle* cpart, int origWl);
|
||||
int Element_FILT_getWavelengths(Particle* cpart);
|
||||
|
||||
void Element::Element_FILT()
|
||||
@ -81,7 +81,7 @@ static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
|
||||
// Returns the wavelengths in a particle after FILT interacts with it (e.g. a photon)
|
||||
// cpart is the FILT particle, origWl the original wavelengths in the interacting particle
|
||||
int Element_FILT_interactWavelengths(Particle* cpart, int origWl)
|
||||
int Element_FILT_interactWavelengths(Simulation *sim, Particle* cpart, int origWl)
|
||||
{
|
||||
const int mask = 0x3FFFFFFF;
|
||||
int filtWl = Element_FILT_getWavelengths(cpart);
|
||||
@ -115,9 +115,9 @@ int Element_FILT_interactWavelengths(Particle* cpart, int origWl)
|
||||
return (~origWl) & mask; // Invert colours
|
||||
case 9:
|
||||
{
|
||||
int t1 = (origWl & 0x0000FF) + RNG::Ref().between(-2, 2);
|
||||
int t2 = ((origWl & 0x00FF00)>>8) + RNG::Ref().between(-2, 2);
|
||||
int t3 = ((origWl & 0xFF0000)>>16) + RNG::Ref().between(-2, 2);
|
||||
int t1 = (origWl & 0x0000FF) + sim->rng.between(-2, 2);
|
||||
int t2 = ((origWl & 0x00FF00)>>8) + sim->rng.between(-2, 2);
|
||||
int t3 = ((origWl & 0xFF0000)>>16) + sim->rng.between(-2, 2);
|
||||
return (origWl & 0xFF000000) | (t3<<16) | (t2<<8) | t1;
|
||||
}
|
||||
case 10:
|
||||
|
@ -83,7 +83,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 = RNG::Ref().between(250, 269);
|
||||
parts[i].life = sim->rng.between(250, 269);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -97,34 +97,34 @@ int Element_FIRE_update(UPDATE_FUNC_ARGS)
|
||||
break;
|
||||
}
|
||||
|
||||
if (pres >= 25 && RNG::Ref().chance(1, 12500))
|
||||
if (pres >= 25 && sim->rng.chance(1, 12500))
|
||||
{
|
||||
if (pres <= 50)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 2))
|
||||
if (sim->rng.chance(1, 2))
|
||||
parts[i].ctype = PT_BRMT;
|
||||
else
|
||||
parts[i].ctype = PT_CNCT;
|
||||
}
|
||||
else if (pres <= 75)
|
||||
{
|
||||
if (pres >= 73 || RNG::Ref().chance(1, 8))
|
||||
if (pres >= 73 || sim->rng.chance(1, 8))
|
||||
parts[i].ctype = PT_GOLD;
|
||||
else
|
||||
parts[i].ctype = PT_QRTZ;
|
||||
}
|
||||
else if (pres <= 100 && parts[i].temp >= 5000)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 5)) // 1 in 5 chance IRON to TTAN
|
||||
if (sim->rng.chance(1, 5)) // 1 in 5 chance IRON to TTAN
|
||||
parts[i].ctype = PT_TTAN;
|
||||
else
|
||||
parts[i].ctype = PT_IRON;
|
||||
}
|
||||
else if (parts[i].temp >= 5000 && RNG::Ref().chance(1, 5))
|
||||
else if (parts[i].temp >= 5000 && sim->rng.chance(1, 5))
|
||||
{
|
||||
if (RNG::Ref().chance(1, 5))
|
||||
if (sim->rng.chance(1, 5))
|
||||
parts[i].ctype = PT_URAN;
|
||||
else if (RNG::Ref().chance(1, 5))
|
||||
else if (sim->rng.chance(1, 5))
|
||||
parts[i].ctype = PT_PLUT;
|
||||
else
|
||||
parts[i].ctype = PT_TUNG;
|
||||
@ -133,7 +133,7 @@ int Element_FIRE_update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if ((parts[i].ctype == PT_STNE || !parts[i].ctype) && pres >= 30.0f && (parts[i].temp > sim->elements[PT_ROCK].HighTemperature || pres < sim->elements[PT_ROCK].HighPressure)) // Form ROCK with pressure, if it will stay molten or not immediately break
|
||||
{
|
||||
parts[i].tmp2 = RNG::Ref().between(0, 10); // Provide tmp2 for color noise
|
||||
parts[i].tmp2 = sim->rng.between(0, 10); // Provide tmp2 for color noise
|
||||
parts[i].ctype = PT_ROCK;
|
||||
}
|
||||
break;
|
||||
@ -153,7 +153,7 @@ int Element_FIRE_update(UPDATE_FUNC_ARGS)
|
||||
//THRM burning
|
||||
if (rt==PT_THRM && (t==PT_FIRE || t==PT_PLSM || t==PT_LAVA))
|
||||
{
|
||||
if (RNG::Ref().chance(1, 500)) {
|
||||
if (sim->rng.chance(1, 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;
|
||||
@ -172,20 +172,20 @@ int Element_FIRE_update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if ((t==PT_FIRE || t==PT_PLSM))
|
||||
{
|
||||
if (parts[ID(r)].life>100 && RNG::Ref().chance(1, 500))
|
||||
if (parts[ID(r)].life>100 && sim->rng.chance(1, 500))
|
||||
{
|
||||
parts[ID(r)].life = 99;
|
||||
}
|
||||
}
|
||||
else if (t==PT_LAVA)
|
||||
{
|
||||
if (parts[i].ctype == PT_IRON && RNG::Ref().chance(1, 500))
|
||||
if (parts[i].ctype == PT_IRON && sim->rng.chance(1, 500))
|
||||
{
|
||||
parts[i].ctype = PT_METL;
|
||||
sim->kill_part(ID(r));
|
||||
continue;
|
||||
}
|
||||
if ((parts[i].ctype == PT_STNE || parts[i].ctype == PT_NONE) && RNG::Ref().chance(1, 60))
|
||||
if ((parts[i].ctype == PT_STNE || parts[i].ctype == PT_NONE) && sim->rng.chance(1, 60))
|
||||
{
|
||||
parts[i].ctype = PT_SLCN;
|
||||
sim->kill_part(ID(r));
|
||||
@ -208,7 +208,7 @@ int Element_FIRE_update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (rt == PT_O2 && parts[i].ctype == PT_SLCN)
|
||||
{
|
||||
switch (RNG::Ref().between(0, 2))
|
||||
switch (sim->rng.between(0, 2))
|
||||
{
|
||||
case 0:
|
||||
parts[i].ctype = PT_SAND;
|
||||
@ -246,7 +246,7 @@ int Element_FIRE_update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
}
|
||||
else if (parts[i].ctype == PT_ROCK && rt == PT_LAVA && parts[ID(r)].ctype == PT_GOLD && parts[ID(r)].tmp == 0 &&
|
||||
sim->pv[y / CELL][x / CELL] >= 50 && RNG::Ref().chance(1, 10000)) // Produce GOLD veins/clusters
|
||||
sim->pv[y / CELL][x / CELL] >= 50 && sim->rng.chance(1, 10000)) // Produce GOLD veins/clusters
|
||||
{
|
||||
parts[i].ctype = PT_GOLD;
|
||||
if (rx > 1 || rx < -1) // Trend veins vertical
|
||||
@ -259,7 +259,7 @@ int Element_FIRE_update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
|
||||
if ((surround_space || sim->elements[rt].Explosive) &&
|
||||
sim->elements[rt].Flammable && RNG::Ref().chance(int(sim->elements[rt].Flammable + (sim->pv[(y+ry)/CELL][(x+rx)/CELL] * 10.0f)), 1000) &&
|
||||
sim->elements[rt].Flammable && sim->rng.chance(int(sim->elements[rt].Flammable + (sim->pv[(y+ry)/CELL][(x+rx)/CELL] * 10.0f)), 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) &&
|
||||
@ -267,7 +267,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].DefaultProperties.temp + (sim->elements[rt].Flammable/2), MIN_TEMP, MAX_TEMP);
|
||||
parts[ID(r)].life = RNG::Ref().between(180, 259);
|
||||
parts[ID(r)].life = sim->rng.between(180, 259);
|
||||
parts[ID(r)].tmp = parts[ID(r)].ctype = 0;
|
||||
if (sim->elements[rt].Explosive)
|
||||
sim->pv[y/CELL][x/CELL] += 0.25f * CFDS;
|
||||
@ -297,7 +297,7 @@ static int updateLegacy(UPDATE_FUNC_ARGS)
|
||||
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))
|
||||
&& RNG::Ref().chance(sim->elements[rt].Meltable*lpv, 1000))
|
||||
&& sim->rng.chance(sim->elements[rt].Meltable*lpv, 1000))
|
||||
{
|
||||
if (t!=PT_LAVA || parts[i].life>0)
|
||||
{
|
||||
@ -308,7 +308,7 @@ static int 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 = RNG::Ref().between(240, 359);
|
||||
parts[ID(r)].life = sim->rng.between(240, 359);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -371,5 +371,5 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
{
|
||||
sim->parts[i].life = RNG::Ref().between(120, 169);
|
||||
sim->parts[i].life = sim->rng.between(120, 169);
|
||||
}
|
||||
|
@ -65,12 +65,12 @@ static int 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 = RNG::Ref().between(0, 6283) * 0.001f;//(in radians, between 0 and 2*pi)
|
||||
float angle = sim->rng.between(0, 6283) * 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 = RNG::Ref().between(20, 29);
|
||||
parts[i].life = sim->rng.between(20, 29);
|
||||
multiplier = (parts[i].life+20)*0.2f/sqrtf(gx*gx+gy*gy);
|
||||
parts[i].vx -= gx*multiplier;
|
||||
parts[i].vy -= gy*multiplier;
|
||||
@ -87,20 +87,20 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else //if (parts[i].tmp>=2)
|
||||
{
|
||||
unsigned col = Renderer::firwTableAt(RNG::Ref().between(0, 199));
|
||||
unsigned col = Renderer::firwTableAt(sim->rng.between(0, 199));
|
||||
for (int n=0; n<40; n++)
|
||||
{
|
||||
np = sim->create_part(-3, x, y, PT_EMBR);
|
||||
if (np>-1)
|
||||
{
|
||||
auto magnitude = RNG::Ref().between(40, 99) * 0.05f;
|
||||
auto angle = RNG::Ref().between(0, 6283) * 0.001f;//(in radians, between 0 and 2*pi)
|
||||
auto magnitude = sim->rng.between(40, 99) * 0.05f;
|
||||
auto angle = sim->rng.between(0, 6283) * 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 = RNG::Ref().between(70, 109);
|
||||
parts[np].temp = float(RNG::Ref().between(5750, 6249));
|
||||
parts[np].life = sim->rng.between(70, 109);
|
||||
parts[np].temp = float(sim->rng.between(5750, 6249));
|
||||
parts[np].dcolour = parts[i].dcolour;
|
||||
}
|
||||
}
|
||||
|
@ -56,13 +56,13 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((sim->elements[TYP(r)].Properties&TYPE_SOLID) && RNG::Ref().chance(1, 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) && sim->rng.chance(1, 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 += RNG::Ref().between(0, 19);
|
||||
parts[i].life += sim->rng.between(0, 19);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -58,12 +58,12 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if (TYP(r)==PT_WATR && RNG::Ref().chance(1, 14))
|
||||
if (TYP(r)==PT_WATR && sim->rng.chance(1, 14))
|
||||
{
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_FRZW);
|
||||
}
|
||||
}
|
||||
if ((parts[i].life==0 && RNG::Ref().chance(1, 192)) || RNG::Ref().chance(100-parts[i].life, 50000))
|
||||
if ((parts[i].life==0 && sim->rng.chance(1, 192)) || sim->rng.chance(100-parts[i].life, 50000))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_ICEI);
|
||||
parts[i].ctype=PT_FRZW;
|
||||
|
@ -56,7 +56,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if (TYP(r)==PT_WATR && RNG::Ref().chance(1, 20))
|
||||
if (TYP(r)==PT_WATR && sim->rng.chance(1, 20))
|
||||
{
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_FRZW);
|
||||
parts[ID(r)].life = 100;
|
||||
|
@ -58,8 +58,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (parts[i].life < 40) {
|
||||
parts[i].life--;
|
||||
if (RNG::Ref().chance(1, 10)) {
|
||||
r = sim->create_part(-1, x + RNG::Ref().between(-1, 1), y + RNG::Ref().between(-1, 1), PT_PLSM);
|
||||
if (sim->rng.chance(1, 10)) {
|
||||
r = sim->create_part(-1, x + sim->rng.between(-1, 1), y + sim->rng.between(-1, 1), PT_PLSM);
|
||||
if (r>-1)
|
||||
parts[r].life = 50;
|
||||
}
|
||||
@ -72,7 +72,7 @@ static int 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 && RNG::Ref().chance(1, 15))
|
||||
if ((TYP(r)==PT_SPRK || (parts[i].temp>=(273.15+400.0f))) && parts[i].life>40 && sim->rng.chance(1, 15))
|
||||
{
|
||||
parts[i].life = 39;
|
||||
}
|
||||
|
@ -59,8 +59,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (parts[i].life < 40) {
|
||||
parts[i].life--;
|
||||
if (RNG::Ref().chance(1, 100)) {
|
||||
r = sim->create_part(-1, x + RNG::Ref().chance(-1, 1), y + RNG::Ref().chance(-1, 1), PT_PLSM);
|
||||
if (sim->rng.chance(1, 100)) {
|
||||
r = sim->create_part(-1, x + sim->rng.chance(-1, 1), y + sim->rng.chance(-1, 1), PT_PLSM);
|
||||
if (r>-1)
|
||||
parts[r].life = 50;
|
||||
}
|
||||
@ -81,7 +81,7 @@ static int 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) && RNG::Ref().chance(1, 20)))
|
||||
if (TYP(r)==PT_SPRK || (parts[i].temp>=(273.15+700.0f) && sim->rng.chance(1, 20)))
|
||||
{
|
||||
if (parts[i].life > 40)
|
||||
parts[i].life = 39;
|
||||
|
@ -48,14 +48,14 @@ void Element::Element_FWRK()
|
||||
|
||||
static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (parts[i].life == 0 && ((surround_space && parts[i].temp>400 && RNG::Ref().chance(int(9+parts[i].temp/40), 100000)) || parts[i].ctype == PT_DUST))
|
||||
if (parts[i].life == 0 && ((surround_space && parts[i].temp>400 && sim->rng.chance(int(9+parts[i].temp/40), 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 = RNG::Ref().between(0, 6283) * 0.001f;//(in radians, between 0 and 2*pi)
|
||||
float angle = sim->rng.between(0, 6283) * 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;
|
||||
}
|
||||
@ -65,15 +65,15 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
multiplier = 15.0f/sqrtf(gx*gx+gy*gy);
|
||||
|
||||
//Some variation in speed parallel to gravity direction
|
||||
randTmp = RNG::Ref().between(-100, 100);
|
||||
randTmp = sim->rng.between(-100, 100);
|
||||
gx += gx*randTmp*0.002f;
|
||||
gy += gy*randTmp*0.002f;
|
||||
//and a bit more variation in speed perpendicular to gravity direction
|
||||
randTmp = RNG::Ref().between(-100, 100);
|
||||
randTmp = sim->rng.between(-100, 100);
|
||||
gx += -gy*randTmp*0.005f;
|
||||
gy += gx*randTmp*0.005f;
|
||||
|
||||
parts[i].life = RNG::Ref().between(18, 27);
|
||||
parts[i].life = sim->rng.between(18, 27);
|
||||
parts[i].ctype=0;
|
||||
parts[i].vx -= gx*multiplier;
|
||||
parts[i].vy -= gy*multiplier;
|
||||
@ -82,9 +82,9 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
if (parts[i].life<3&&parts[i].life>0)
|
||||
{
|
||||
int r = RNG::Ref().between(11, 255);
|
||||
int g = RNG::Ref().between(11, 255);
|
||||
int b = RNG::Ref().between(11, 255);
|
||||
int r = sim->rng.between(11, 255);
|
||||
int g = sim->rng.between(11, 255);
|
||||
int b = sim->rng.between(11, 255);
|
||||
int n;
|
||||
float angle, magnitude;
|
||||
unsigned col = (r<<16) | (g<<8) | b;
|
||||
@ -93,14 +93,14 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
int np = sim->create_part(-3, x, y, PT_EMBR);
|
||||
if (np>-1)
|
||||
{
|
||||
magnitude = RNG::Ref().between(40, 99) * 0.05f;
|
||||
angle = RNG::Ref().between(0, 6283) * 0.001f;//(in radians, between 0 and 2*pi)
|
||||
magnitude = sim->rng.between(40, 99) * 0.05f;
|
||||
angle = sim->rng.between(0, 6283) * 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 = RNG::Ref().between(70, 109);
|
||||
parts[np].temp = float(RNG::Ref().between(5750, 6249));
|
||||
parts[np].life = sim->rng.between(70, 109);
|
||||
parts[np].temp = float(sim->rng.between(5750, 6249));
|
||||
parts[np].dcolour = parts[i].dcolour;
|
||||
}
|
||||
}
|
||||
|
@ -72,31 +72,31 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
case PT_WATR:
|
||||
case PT_DSTW:
|
||||
case PT_FRZW:
|
||||
if (parts[i].tmp<100 && RNG::Ref().chance(500, absorbChanceDenom))
|
||||
if (parts[i].tmp<100 && sim->rng.chance(500, absorbChanceDenom))
|
||||
{
|
||||
parts[i].tmp++;
|
||||
sim->kill_part(ID(r));
|
||||
}
|
||||
break;
|
||||
case PT_PSTE:
|
||||
if (parts[i].tmp<100 && RNG::Ref().chance(20, absorbChanceDenom))
|
||||
if (parts[i].tmp<100 && sim->rng.chance(20, absorbChanceDenom))
|
||||
{
|
||||
parts[i].tmp++;
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_CLST);
|
||||
}
|
||||
break;
|
||||
case PT_SLTW:
|
||||
if (parts[i].tmp<100 && RNG::Ref().chance(50, absorbChanceDenom))
|
||||
if (parts[i].tmp<100 && sim->rng.chance(50, absorbChanceDenom))
|
||||
{
|
||||
parts[i].tmp++;
|
||||
if (RNG::Ref().chance(3, 4))
|
||||
if (sim->rng.chance(3, 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 && RNG::Ref().chance(100, absorbChanceDenom))
|
||||
if (parts[i].tmp < 100 && sim->rng.chance(100, absorbChanceDenom))
|
||||
{
|
||||
parts[i].tmp++;
|
||||
sim->part_change_type(ID(r), x+rx, y+ry, PT_CO2);
|
||||
|
@ -58,7 +58,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if (TYP(r)==PT_WATR && RNG::Ref().chance(1, 400))
|
||||
if (TYP(r)==PT_WATR && sim->rng.chance(1, 400))
|
||||
{
|
||||
sim->kill_part(i);
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_DEUT);
|
||||
@ -87,7 +87,7 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
*colg = int(restrict_flt(64.0f+cpart->ctype, 0, 255));
|
||||
*colb = int(restrict_flt(64.0f+cpart->tmp, 0, 255));
|
||||
|
||||
int rng = RNG::Ref().between(1, 32); //
|
||||
int rng = ren->rng.between(1, 32); //
|
||||
if(((*colr) + (*colg) + (*colb)) > (256 + rng)) {
|
||||
*colr -= 54;
|
||||
*colg -= 54;
|
||||
|
@ -56,7 +56,7 @@ static int 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 = RNG::Ref().gen();
|
||||
rndstore = sim->rng.gen();
|
||||
rx = (rndstore % 9)-4;
|
||||
rndstore >>= 4;
|
||||
ry = (rndstore % 9)-4;
|
||||
@ -90,7 +90,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
if (TYP(sim->photons[y][x]) == PT_NEUT)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 7))
|
||||
if (sim->rng.chance(1, 7))
|
||||
{
|
||||
sim->kill_part(ID(sim->photons[y][x]));
|
||||
}
|
||||
@ -100,7 +100,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
|
||||
static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
{
|
||||
int rndstore = RNG::Ref().gen();
|
||||
int rndstore = ren->rng.gen();
|
||||
*colr += (rndstore % 10) - 5;
|
||||
rndstore >>= 4;
|
||||
*colg += (rndstore % 10)- 5;
|
||||
|
@ -51,7 +51,7 @@ constexpr float ADVECTION = 0.1f;
|
||||
static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (!parts[i].life && sim->pv[y/CELL][x/CELL]>1.0f)
|
||||
parts[i].life = RNG::Ref().between(300, 379);
|
||||
parts[i].life = sim->rng.between(300, 379);
|
||||
if (parts[i].life)
|
||||
{
|
||||
parts[i].vx += ADVECTION*sim->vx[y/CELL][x/CELL];
|
||||
|
@ -50,7 +50,7 @@ void Element::Element_GRAV()
|
||||
|
||||
static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (parts[i].vx*parts[i].vx + parts[i].vy*parts[i].vy >= 0.1f && RNG::Ref().chance(1, 512))
|
||||
if (parts[i].vx*parts[i].vx + parts[i].vy*parts[i].vy >= 0.1f && sim->rng.chance(1, 512))
|
||||
{
|
||||
if (!parts[i].life)
|
||||
parts[i].life = 48;
|
||||
|
@ -76,8 +76,8 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
{
|
||||
float a = RNG::Ref().between(0, 359) * 3.14159f / 180.0f;
|
||||
sim->parts[i].life = 250 + RNG::Ref().between(0, 199);
|
||||
float a = sim->rng.between(0, 359) * 3.14159f / 180.0f;
|
||||
sim->parts[i].life = 250 + sim->rng.between(0, 199);
|
||||
sim->parts[i].vx = 2.0f*cosf(a);
|
||||
sim->parts[i].vy = 2.0f*sinf(a);
|
||||
}
|
||||
|
@ -77,14 +77,14 @@ static int 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 += RNG::Ref().between(0, 99);
|
||||
parts[i].temp += sim->rng.between(0, 99);
|
||||
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 += RNG::Ref().between(0, 99);
|
||||
parts[i].temp += sim->rng.between(0, 99);
|
||||
parts[i].tmp |= 1;
|
||||
return 1;
|
||||
}
|
||||
@ -92,7 +92,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
if (parts[i].temp > 2273.15 && sim->pv[y/CELL][x/CELL] > 50.0f)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 5))
|
||||
if (sim->rng.chance(1, 5))
|
||||
{
|
||||
int j;
|
||||
float temp = parts[i].temp;
|
||||
@ -102,7 +102,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
j = sim->create_part(-3,x,y,PT_NEUT);
|
||||
if (j>-1)
|
||||
parts[j].temp = temp;
|
||||
if (RNG::Ref().chance(1, 10))
|
||||
if (sim->rng.chance(1, 10))
|
||||
{
|
||||
j = sim->create_part(-3,x,y,PT_ELEC);
|
||||
if (j>-1)
|
||||
@ -115,7 +115,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
parts[j].temp = temp;
|
||||
parts[j].tmp = 0x1;
|
||||
}
|
||||
rx = x + RNG::Ref().between(-1, 1), ry = y + RNG::Ref().between(-1, 1), rt = TYP(pmap[ry][rx]);
|
||||
rx = x + sim->rng.between(-1, 1), ry = y + sim->rng.between(-1, 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 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
parts[j].tmp |= 4;
|
||||
}
|
||||
}
|
||||
parts[i].temp = temp + RNG::Ref().between(750, 1249);
|
||||
parts[i].temp = temp + sim->rng.between(750, 1249);
|
||||
sim->pv[y/CELL][x/CELL] += 30;
|
||||
return 1;
|
||||
}
|
||||
|
@ -64,14 +64,14 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
continue;
|
||||
if (TYP(r)==PT_SALT || TYP(r)==PT_SLTW)
|
||||
{
|
||||
if (parts[i].temp > sim->elements[PT_SLTW].LowTemperature && RNG::Ref().chance(1, 200))
|
||||
if (parts[i].temp > sim->elements[PT_SLTW].LowTemperature && sim->rng.chance(1, 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) && RNG::Ref().chance(1, 200))
|
||||
else if ((TYP(r)==PT_FRZZ) && sim->rng.chance(1, 200))
|
||||
{
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_ICEI);
|
||||
parts[ID(r)].ctype = PT_FRZW;
|
||||
|
@ -68,20 +68,20 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if(parts[i].life > 0)
|
||||
{
|
||||
if (RNG::Ref().chance(2, 3))
|
||||
if (sim->rng.chance(2, 3))
|
||||
{
|
||||
int nb = sim->create_part(-1, x + RNG::Ref().between(-1, 1), y + RNG::Ref().between(-1, 1), PT_EMBR);
|
||||
int nb = sim->create_part(-1, x + sim->rng.between(-1, 1), y + sim->rng.between(-1, 1), PT_EMBR);
|
||||
if (nb!=-1) {
|
||||
parts[nb].tmp = 0;
|
||||
parts[nb].life = 30;
|
||||
parts[nb].vx = float(RNG::Ref().between(-10, 10));
|
||||
parts[nb].vy = float(RNG::Ref().between(-10, 10));
|
||||
parts[nb].vx = float(sim->rng.between(-10, 10));
|
||||
parts[nb].vy = float(sim->rng.between(-10, 10));
|
||||
parts[nb].temp = restrict_flt(parts[i].temp-273.15f+400.0f, MIN_TEMP, MAX_TEMP);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sim->create_part(-1, x + RNG::Ref().between(-1, 1), y + RNG::Ref().between(-1, 1), PT_FIRE);
|
||||
sim->create_part(-1, x + sim->rng.between(-1, 1), y + sim->rng.between(-1, 1), PT_FIRE);
|
||||
}
|
||||
parts[i].life--;
|
||||
}
|
||||
|
@ -58,19 +58,19 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
switch (TYP(r))
|
||||
{
|
||||
case PT_SALT:
|
||||
if (RNG::Ref().chance(1, 47))
|
||||
if (sim->rng.chance(1, 47))
|
||||
goto succ;
|
||||
break;
|
||||
case PT_SLTW:
|
||||
if (RNG::Ref().chance(1, 67))
|
||||
if (sim->rng.chance(1, 67))
|
||||
goto succ;
|
||||
break;
|
||||
case PT_WATR:
|
||||
if (RNG::Ref().chance(1, 1200))
|
||||
if (sim->rng.chance(1, 1200))
|
||||
goto succ;
|
||||
break;
|
||||
case PT_O2:
|
||||
if (RNG::Ref().chance(1, 250))
|
||||
if (sim->rng.chance(1, 250))
|
||||
goto succ;
|
||||
break;
|
||||
case PT_LO2:
|
||||
@ -82,6 +82,6 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
return 0;
|
||||
succ:
|
||||
sim->part_change_type(i,x,y,PT_BMTL);
|
||||
parts[i].tmp = RNG::Ref().between(20, 29);
|
||||
parts[i].tmp = sim->rng.between(20, 29);
|
||||
return 0;
|
||||
}
|
||||
|
@ -49,11 +49,11 @@ void Element::Element_ISOZ()
|
||||
static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
float rr, rrr;
|
||||
if (RNG::Ref().chance(1, 200) && RNG::Ref().chance(int(-4.0f * sim->pv[y/CELL][x/CELL]), 1000))
|
||||
if (sim->rng.chance(1, 200) && sim->rng.chance(int(-4.0f * sim->pv[y/CELL][x/CELL]), 1000))
|
||||
{
|
||||
sim->create_part(i, x, y, PT_PHOT);
|
||||
rr = RNG::Ref().between(128, 355) / 127.0f;
|
||||
rrr = RNG::Ref().between(0, 359) * 3.14159f / 180.0f;
|
||||
rr = sim->rng.between(128, 355) / 127.0f;
|
||||
rrr = sim->rng.between(0, 359) * 3.14159f / 180.0f;
|
||||
parts[i].vx = rr*cosf(rrr);
|
||||
parts[i].vy = rr*sinf(rrr);
|
||||
}
|
||||
|
@ -49,11 +49,11 @@ void Element::Element_ISZS()
|
||||
static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
float rr, rrr;
|
||||
if (RNG::Ref().chance(1, 200) && RNG::Ref().chance(int(-4.0f * sim->pv[y/CELL][x/CELL]), 1000))
|
||||
if (sim->rng.chance(1, 200) && sim->rng.chance(int(-4.0f * sim->pv[y/CELL][x/CELL]), 1000))
|
||||
{
|
||||
sim->create_part(i, x, y, PT_PHOT);
|
||||
rr = RNG::Ref().between(128, 355) / 127.0f;
|
||||
rrr = RNG::Ref().between(0, 359) * 3.14159f / 180.0f;
|
||||
rr = sim->rng.between(128, 355) / 127.0f;
|
||||
rrr = sim->rng.between(0, 359) * 3.14159f / 180.0f;
|
||||
parts[i].vx = rr*cosf(rrr);
|
||||
parts[i].vy = rr*sinf(rrr);
|
||||
}
|
||||
|
@ -72,5 +72,5 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
{
|
||||
sim->parts[i].life = RNG::Ref().between(240, 359);
|
||||
sim->parts[i].life = sim->rng.between(240, 359);
|
||||
}
|
||||
|
@ -91,11 +91,11 @@ static int 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 && RNG::Ref().chance(sim->elements[rt].Flammable + int(sim->pv[(y+ry)/CELL][(x+rx)/CELL] * 10.0f), 1000))
|
||||
sim->elements[rt].Flammable && sim->rng.chance(sim->elements[rt].Flammable + int(sim->pv[(y+ry)/CELL][(x+rx)/CELL] * 10.0f), 1000))
|
||||
{
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_FIRE);
|
||||
parts[ID(r)].temp = restrict_flt(sim->elements[PT_FIRE].DefaultProperties.temp + (sim->elements[rt].Flammable/2), MIN_TEMP, MAX_TEMP);
|
||||
parts[ID(r)].life = RNG::Ref().between(180, 259);
|
||||
parts[ID(r)].life = sim->rng.between(180, 259);
|
||||
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 @@ static int 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 (RNG::Ref().chance(1, 3))
|
||||
if (sim->rng.chance(1, 3))
|
||||
{
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_NEUT);
|
||||
parts[ID(r)].life = RNG::Ref().between(480, 959);
|
||||
parts[ID(r)].vx = float(RNG::Ref().between(-5, 5));
|
||||
parts[ID(r)].vy = float(RNG::Ref().between(-5, 5));
|
||||
parts[ID(r)].life = sim->rng.between(480, 959);
|
||||
parts[ID(r)].vx = float(sim->rng.between(-5, 5));
|
||||
parts[ID(r)].vy = float(sim->rng.between(-5, 5));
|
||||
}
|
||||
break;
|
||||
case PT_COAL:
|
||||
@ -167,14 +167,14 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
}
|
||||
angle = float((parts[i].tmp + RNG::Ref().between(-30, 30)) % 360);
|
||||
multipler = int(parts[i].life * 1.5) + RNG::Ref().between(0, parts[i].life);
|
||||
angle = float((parts[i].tmp + sim->rng.between(-30, 30)) % 360);
|
||||
multipler = int(parts[i].life * 1.5) + sim->rng.between(0, parts[i].life);
|
||||
rx=int(cos(angle*TPT_PI_FLT/180)*multipler);
|
||||
ry=int(-sin(angle*TPT_PI_FLT/180)*multipler);
|
||||
create_line_par(sim, x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, int(angle), parts[i].tmp2, i);
|
||||
if (parts[i].tmp2 == 2)// && pNear == -1)
|
||||
{
|
||||
angle2 = float(((int)angle + RNG::Ref().between(-100, 100)) % 360);
|
||||
angle2 = float(((int)angle + sim->rng.between(-100, 100)) % 360);
|
||||
rx=int(cos(angle2*TPT_PI_FLT/180)*multipler);
|
||||
ry=int(-sin(angle2*TPT_PI_FLT/180)*multipler);
|
||||
create_line_par(sim, x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, int(angle2), parts[i].tmp2, i);
|
||||
@ -193,12 +193,12 @@ static bool create_LIGH(Simulation * sim, int x, int y, int c, float temp, int l
|
||||
sim->parts[p].tmp = tmp;
|
||||
if (last)
|
||||
{
|
||||
int nextSegmentLife = (int)(life/1.5 - RNG::Ref().between(0, 1));
|
||||
int nextSegmentLife = (int)(life/1.5 - sim->rng.between(0, 1));
|
||||
sim->parts[p].life = nextSegmentLife;
|
||||
if (nextSegmentLife > 1)
|
||||
{
|
||||
// Decide whether to branch or to bend
|
||||
bool doBranch = RNG::Ref().chance(7, 10);
|
||||
bool doBranch = sim->rng.chance(7, 10);
|
||||
sim->parts[p].tmp2 = (doBranch ? 2 : 0) + (p > i && tmp2 != 4 ? 1 : 0);
|
||||
}
|
||||
// Not enough energy to continue
|
||||
@ -315,12 +315,12 @@ static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
gsize = gx * gx + gy * gy;
|
||||
if (gsize < 0.0016f)
|
||||
{
|
||||
float angle = RNG::Ref().between(0, 6283) * 0.001f; //(in radians, between 0 and 2*pi)
|
||||
float angle = sim->rng.between(0, 6283) * 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);
|
||||
}
|
||||
sim->parts[i].tmp = (static_cast<int>(atan2f(-gy, gx) * (180.0f / TPT_PI_FLT)) + RNG::Ref().between(-20, 20) + 360) % 360;
|
||||
sim->parts[i].tmp = (static_cast<int>(atan2f(-gy, gx) * (180.0f / TPT_PI_FLT)) + sim->rng.between(-20, 20) + 360) % 360;
|
||||
sim->parts[i].tmp2 = 4;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
int neighborData = pmap[y + ry][x + rx];
|
||||
if (!neighborData)
|
||||
{
|
||||
if (burnTimer > 1012 && RNG::Ref().chance(1, 10))
|
||||
if (burnTimer > 1012 && sim->rng.chance(1, 10))
|
||||
{
|
||||
sim->create_part(-1, x + rx, y + ry, PT_FIRE);
|
||||
}
|
||||
@ -163,7 +163,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
break;
|
||||
|
||||
case PT_FIRE:
|
||||
if (self.temp > 440.f && RNG::Ref().chance(1, 40) && hydrogenationFactor < 6)
|
||||
if (self.temp > 440.f && sim->rng.chance(1, 40) && hydrogenationFactor < 6)
|
||||
{
|
||||
burnTimer = 1013;
|
||||
hydrogenationFactor += 1;
|
||||
@ -171,7 +171,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
break;
|
||||
|
||||
case PT_O2:
|
||||
if (burnTimer > 1000 && RNG::Ref().chance(1, 10))
|
||||
if (burnTimer > 1000 && sim->rng.chance(1, 10))
|
||||
{
|
||||
sim->part_change_type(i, x, y, PT_PLSM);
|
||||
sim->part_change_type(ID(neighborData), x + rx, y + ry, PT_PLSM);
|
||||
@ -196,8 +196,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
|
||||
for (int trade = 0; trade < 9; ++trade)
|
||||
{
|
||||
int rx = RNG::Ref().between(-3, 3);
|
||||
int ry = RNG::Ref().between(-3, 3);
|
||||
int rx = sim->rng.between(-3, 3);
|
||||
int ry = sim->rng.between(-3, 3);
|
||||
if (BOUNDS_CHECK && (rx || ry))
|
||||
{
|
||||
int neighborData = pmap[y + ry][x + rx];
|
||||
@ -257,7 +257,7 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
// Charged lith
|
||||
else if (cpart->ctype > 0)
|
||||
{
|
||||
int mult = RNG::Ref().between(cpart->ctype / 3, cpart->ctype) / 15;
|
||||
int mult = ren->rng.between(cpart->ctype / 3, cpart->ctype) / 15;
|
||||
mult = std::min(6, mult);
|
||||
*colr -= 30 * mult;
|
||||
*colb += 20 * mult;
|
||||
|
@ -56,7 +56,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
if (parts[i].temp + 1 == 0)
|
||||
parts[i].temp = 0;
|
||||
int maxtmp = int(absorbScale/(parts[i].temp + 1))-1;
|
||||
if (RNG::Ref().chance(absorbScale%(int(parts[i].temp)+1), int(parts[i].temp)+1))
|
||||
if (sim->rng.chance(absorbScale%(int(parts[i].temp)+1), int(parts[i].temp)+1))
|
||||
maxtmp ++;
|
||||
|
||||
if (parts[i].tmp < 0)
|
||||
@ -77,7 +77,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r || (parts[i].tmp >=maxtmp))
|
||||
continue;
|
||||
if (TYP(r)==PT_MERC&& RNG::Ref().chance(1, 3))
|
||||
if (TYP(r)==PT_MERC&& sim->rng.chance(1, 3))
|
||||
{
|
||||
if ((parts[i].tmp + parts[ID(r)].tmp + 1) <= maxtmp)
|
||||
{
|
||||
@ -107,8 +107,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
for ( trade = 0; trade<4; trade ++)
|
||||
{
|
||||
rx = RNG::Ref().between(-2, 2);
|
||||
ry = RNG::Ref().between(-2, 2);
|
||||
rx = sim->rng.between(-2, 2);
|
||||
ry = sim->rng.between(-2, 2);
|
||||
if (BOUNDS_CHECK && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
|
@ -52,7 +52,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
if (parts[i].temp > 5273.15 && sim->pv[y/CELL][x/CELL] > 100.0f)
|
||||
{
|
||||
parts[i].tmp |= 0x1;
|
||||
if (RNG::Ref().chance(1, 5))
|
||||
if (sim->rng.chance(1, 5))
|
||||
{
|
||||
int j;
|
||||
float temp = parts[i].temp;
|
||||
@ -61,7 +61,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
j = sim->create_part(-3,x,y,PT_NEUT);
|
||||
if (j != -1)
|
||||
parts[j].temp = temp;
|
||||
if (RNG::Ref().chance(1, 25))
|
||||
if (sim->rng.chance(1, 25))
|
||||
{
|
||||
j = sim->create_part(-3,x,y,PT_ELEC);
|
||||
if (j != -1)
|
||||
@ -74,7 +74,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
parts[j].temp = temp;
|
||||
parts[j].tmp = 0x1;
|
||||
}
|
||||
int rx = x + RNG::Ref().between(-1, 1), ry = y + RNG::Ref().between(-1, 1), rt = TYP(pmap[ry][rx]);
|
||||
int rx = x + sim->rng.between(-1, 1), ry = y + sim->rng.between(-1, 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);
|
||||
@ -84,7 +84,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
parts[j].tmp |= 4;
|
||||
}
|
||||
}
|
||||
parts[i].temp = temp + 1750 + RNG::Ref().between(0, 499);
|
||||
parts[i].temp = temp + 1750 + sim->rng.between(0, 499);
|
||||
sim->pv[y/CELL][x/CELL] += 50;
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
switch (TYP(r))
|
||||
{
|
||||
case PT_WATR:
|
||||
if (RNG::Ref().chance(3, 20))
|
||||
if (sim->rng.chance(3, 20))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_DSTW);
|
||||
case PT_ICEI:
|
||||
case PT_SNOW:
|
||||
@ -72,11 +72,11 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
parts[i].vy *= 0.995f;
|
||||
break;
|
||||
case PT_PLUT:
|
||||
if (RNG::Ref().chance(pressureFactor, 1000))
|
||||
if (sim->rng.chance(pressureFactor, 1000))
|
||||
{
|
||||
if (RNG::Ref().chance(1, 3))
|
||||
if (sim->rng.chance(1, 3))
|
||||
{
|
||||
sim->create_part(ID(r), x+rx, y+ry, RNG::Ref().chance(2, 3) ? PT_LAVA : PT_URAN);
|
||||
sim->create_part(ID(r), x+rx, y+ry, sim->rng.chance(2, 3) ? PT_LAVA : PT_URAN);
|
||||
parts[ID(r)].temp = MAX_TEMP;
|
||||
if (parts[ID(r)].type==PT_LAVA) {
|
||||
parts[ID(r)].tmp = 100;
|
||||
@ -94,73 +94,73 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
break;
|
||||
case PT_DEUT:
|
||||
if (RNG::Ref().chance(pressureFactor + 1 + (parts[ID(r)].life/100), 1000))
|
||||
if (sim->rng.chance(pressureFactor + 1 + (parts[ID(r)].life/100), 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));
|
||||
}
|
||||
break;
|
||||
case PT_GUNP:
|
||||
if (RNG::Ref().chance(3, 200))
|
||||
if (sim->rng.chance(3, 200))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_DUST);
|
||||
break;
|
||||
case PT_DYST:
|
||||
if (RNG::Ref().chance(3, 200))
|
||||
if (sim->rng.chance(3, 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 (RNG::Ref().chance(3, 200))
|
||||
if (sim->rng.chance(3, 200))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_GOO);
|
||||
break;
|
||||
case PT_NITR:
|
||||
if (RNG::Ref().chance(3, 200))
|
||||
if (sim->rng.chance(3, 200))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_DESL);
|
||||
break;
|
||||
case PT_PLNT:
|
||||
if (RNG::Ref().chance(1, 20))
|
||||
if (sim->rng.chance(1, 20))
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_WOOD);
|
||||
break;
|
||||
case PT_DESL:
|
||||
case PT_OIL:
|
||||
if (RNG::Ref().chance(3, 200))
|
||||
if (sim->rng.chance(3, 200))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_GAS);
|
||||
break;
|
||||
case PT_COAL:
|
||||
if (RNG::Ref().chance(1, 20))
|
||||
if (sim->rng.chance(1, 20))
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_WOOD);
|
||||
break;
|
||||
case PT_BCOL:
|
||||
if (RNG::Ref().chance(1, 20))
|
||||
if (sim->rng.chance(1, 20))
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_SAWD);
|
||||
break;
|
||||
case PT_DUST:
|
||||
if (RNG::Ref().chance(1, 20))
|
||||
if (sim->rng.chance(1, 20))
|
||||
sim->part_change_type(ID(r), x+rx, y+ry, PT_FWRK);
|
||||
break;
|
||||
case PT_FWRK:
|
||||
if (RNG::Ref().chance(1, 20))
|
||||
if (sim->rng.chance(1, 20))
|
||||
parts[ID(r)].ctype = PT_DUST;
|
||||
break;
|
||||
case PT_ACID:
|
||||
if (RNG::Ref().chance(1, 20))
|
||||
if (sim->rng.chance(1, 20))
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_ISOZ);
|
||||
break;
|
||||
case PT_TTAN:
|
||||
if (RNG::Ref().chance(1, 20))
|
||||
if (sim->rng.chance(1, 20))
|
||||
{
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case PT_EXOT:
|
||||
if (RNG::Ref().chance(1, 20))
|
||||
if (sim->rng.chance(1, 20))
|
||||
parts[ID(r)].life = 1500;
|
||||
break;
|
||||
case PT_RFRG:
|
||||
if (RNG::Ref().chance(1, 2))
|
||||
if (sim->rng.chance(1, 2))
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_GAS);
|
||||
else
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_CAUS);
|
||||
@ -185,9 +185,9 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
{
|
||||
float r = RNG::Ref().between(128, 255) / 127.0f;
|
||||
float a = RNG::Ref().between(0, 359) * 3.14159f / 180.0f;
|
||||
sim->parts[i].life = RNG::Ref().between(480, 959);
|
||||
float r = sim->rng.between(128, 255) / 127.0f;
|
||||
float a = sim->rng.between(0, 359) * 3.14159f / 180.0f;
|
||||
sim->parts[i].life = sim->rng.between(480, 959);
|
||||
sim->parts[i].vx = r * cosf(a);
|
||||
sim->parts[i].vy = r * sinf(a);
|
||||
}
|
||||
|
@ -58,19 +58,19 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
|
||||
if (TYP(r)==PT_FIRE)
|
||||
{
|
||||
parts[ID(r)].temp += RNG::Ref().between(0, 99);
|
||||
parts[ID(r)].temp += sim->rng.between(0, 99);
|
||||
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 += RNG::Ref().between(0, 99);
|
||||
parts[i].temp += sim->rng.between(0, 99);
|
||||
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 += RNG::Ref().between(0, 99);
|
||||
parts[i].temp += sim->rng.between(0, 99);
|
||||
parts[i].tmp |= 2;
|
||||
}
|
||||
}
|
||||
@ -81,7 +81,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
float gravy = sim->gravy[gravPos];
|
||||
if (gravx*gravx + gravy*gravy > 400)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 5))
|
||||
if (sim->rng.chance(1, 5))
|
||||
{
|
||||
int j;
|
||||
sim->create_part(i,x,y,PT_BRMT);
|
||||
@ -95,7 +95,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
parts[j].temp = MAX_TEMP;
|
||||
parts[j].tmp = 0x1;
|
||||
}
|
||||
rx = x + RNG::Ref().between(-1, 1), ry = y + RNG::Ref().between(-1, 1), r = TYP(pmap[ry][rx]);
|
||||
rx = x + sim->rng.between(-1, 1), ry = y + sim->rng.between(-1, 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);
|
||||
|
@ -56,7 +56,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
int r, rx, ry, rt;
|
||||
if (!parts[i].tmp2 && sim->pv[y/CELL][x/CELL]>4.0f)
|
||||
parts[i].tmp2 = RNG::Ref().between(80, 119);
|
||||
parts[i].tmp2 = sim->rng.between(80, 119);
|
||||
if (parts[i].tmp2)
|
||||
{
|
||||
parts[i].vx += ADVECTION*sim->vx[y/CELL][x/CELL];
|
||||
@ -136,9 +136,9 @@ static int 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 || RNG::Ref().chance(1, 30))
|
||||
else if (parts[i].ctype!=PT_LIGH || sim->rng.chance(1, 30))
|
||||
{
|
||||
int np = sim->create_part(-1, x + RNG::Ref().between(-1, 1), y + RNG::Ref().between(-1, 1), TYP(parts[i].ctype));
|
||||
int np = sim->create_part(-1, x + sim->rng.between(-1, 1), y + sim->rng.between(-1, 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)
|
||||
|
@ -127,9 +127,9 @@ static int 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 || RNG::Ref().chance(1, 30))
|
||||
else if (parts[i].ctype != PT_LIGH || sim->rng.chance(1, 30))
|
||||
{
|
||||
int np = sim->create_part(-1, x + RNG::Ref().between(-1, 1), y + RNG::Ref().between(-1, 1), TYP(parts[i].ctype));
|
||||
int np = sim->create_part(-1, x + sim->rng.between(-1, 1), y + sim->rng.between(-1, 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)
|
||||
|
@ -63,7 +63,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
return 1;
|
||||
}
|
||||
if (parts[i].temp > 506)
|
||||
if (RNG::Ref().chance(1, 10))
|
||||
if (sim->rng.chance(1, 10))
|
||||
Element_FIRE_update(UPDATE_FUNC_SUBCALL_ARGS);
|
||||
for (rx=-1; rx<2; rx++)
|
||||
for (ry=-1; ry<2; ry++)
|
||||
@ -73,16 +73,16 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
continue;
|
||||
if (TYP(r)==PT_ISOZ || TYP(r)==PT_ISZS)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 400))
|
||||
if (sim->rng.chance(1, 400))
|
||||
{
|
||||
parts[i].vx *= 0.90f;
|
||||
parts[i].vy *= 0.90f;
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_PHOT);
|
||||
rrr = RNG::Ref().between(0, 359) * 3.14159f / 180.0f;
|
||||
rrr = sim->rng.between(0, 359) * 3.14159f / 180.0f;
|
||||
if (TYP(r) == PT_ISOZ)
|
||||
rr = RNG::Ref().between(128, 255) / 127.0f;
|
||||
rr = sim->rng.between(128, 255) / 127.0f;
|
||||
else
|
||||
rr = RNG::Ref().between(128, 355) / 127.0f;
|
||||
rr = sim->rng.between(128, 355) / 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;
|
||||
@ -90,17 +90,17 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if((TYP(r) == PT_QRTZ || TYP(r) == PT_PQRT) && !ry && !rx)//if on QRTZ
|
||||
{
|
||||
float a = RNG::Ref().between(0, 359) * 3.14159f / 180.0f;
|
||||
float a = sim->rng.between(0, 359) * 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 << RNG::Ref().between(0, 25);
|
||||
parts[i].ctype = 0x1F << sim->rng.between(0, 25);
|
||||
if (parts[i].life)
|
||||
parts[i].life++; //Delay death
|
||||
}
|
||||
else if(TYP(r) == PT_BGLA && !ry && !rx)//if on BGLA
|
||||
{
|
||||
float a = RNG::Ref().between(-50, 50) * 0.001f;
|
||||
float a = sim->rng.between(-50, 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;
|
||||
@ -109,8 +109,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (TYP(r) == PT_FILT && parts[ID(r)].tmp==9)
|
||||
{
|
||||
parts[i].vx += ((float)RNG::Ref().between(-500, 500))/1000.0f;
|
||||
parts[i].vy += ((float)RNG::Ref().between(-500, 500))/1000.0f;
|
||||
parts[i].vx += ((float)sim->rng.between(-500, 500))/1000.0f;
|
||||
parts[i].vy += ((float)sim->rng.between(-500, 500))/1000.0f;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -147,10 +147,10 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
{
|
||||
float a = RNG::Ref().between(0, 7) * 0.78540f;
|
||||
float a = sim->rng.between(0, 7) * 0.78540f;
|
||||
sim->parts[i].vx = 3.0f * cosf(a);
|
||||
sim->parts[i].vy = 3.0f * sinf(a);
|
||||
int Element_FILT_interactWavelengths(Particle* cpart, int origWl);
|
||||
int Element_FILT_interactWavelengths(Simulation *sim, Particle* cpart, int origWl);
|
||||
if (TYP(sim->pmap[y][x]) == PT_FILT)
|
||||
sim->parts[i].ctype = Element_FILT_interactWavelengths(&sim->parts[ID(sim->pmap[y][x])], sim->parts[i].ctype);
|
||||
sim->parts[i].ctype = Element_FILT_interactWavelengths(sim, &sim->parts[ID(sim->pmap[y][x])], sim->parts[i].ctype);
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ int Element_PIPE_update(UPDATE_FUNC_ARGS)
|
||||
|
||||
if (nt)//there is something besides PIPE around current particle
|
||||
{
|
||||
rndstore = RNG::Ref().gen();
|
||||
rndstore = sim->rng.gen();
|
||||
rnd = rndstore&7;
|
||||
//rndstore = rndstore>>3;
|
||||
rx = pos_1_rx[rnd];
|
||||
@ -495,7 +495,7 @@ static void pushParticle(Simulation * sim, int i, int count, int original)
|
||||
if( !(sim->parts[i].tmp&0x200) )
|
||||
{
|
||||
//normal random push
|
||||
rndstore = RNG::Ref().gen();
|
||||
rndstore = sim->rng.gen();
|
||||
// RAND_MAX is at least 32767 on all platforms i.e. pow(8,5)-1
|
||||
// so can go 5 cycles without regenerating rndstore
|
||||
// (although now we use our own randomizer so maybe should reevaluate all the rndstore usages in every element)
|
||||
|
@ -60,7 +60,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
switch (TYP(r))
|
||||
{
|
||||
case PT_WATR:
|
||||
if (RNG::Ref().chance(1, 50))
|
||||
if (sim->rng.chance(1, 50))
|
||||
{
|
||||
np = sim->create_part(ID(r),x+rx,y+ry,PT_PLNT);
|
||||
if (np<0) continue;
|
||||
@ -68,7 +68,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
break;
|
||||
case PT_LAVA:
|
||||
if (RNG::Ref().chance(1, 50))
|
||||
if (sim->rng.chance(1, 50))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_FIRE);
|
||||
parts[i].life = 4;
|
||||
@ -76,14 +76,14 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
break;
|
||||
case PT_SMKE:
|
||||
case PT_CO2:
|
||||
if (RNG::Ref().chance(1, 50))
|
||||
if (sim->rng.chance(1, 50))
|
||||
{
|
||||
sim->kill_part(ID(r));
|
||||
parts[i].life = RNG::Ref().between(60, 119);
|
||||
parts[i].life = sim->rng.between(60, 119);
|
||||
}
|
||||
break;
|
||||
case PT_WOOD:
|
||||
rndstore = RNG::Ref().gen();
|
||||
rndstore = sim->rng.gen();
|
||||
if (surround_space && !(rndstore%4) && parts[i].tmp==1)
|
||||
{
|
||||
rndstore >>= 3;
|
||||
|
@ -70,5 +70,5 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
{
|
||||
sim->parts[i].life = RNG::Ref().between(50, 199);
|
||||
sim->parts[i].life = sim->rng.between(50, 199);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ void Element::Element_PLUT()
|
||||
|
||||
static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 100) && RNG::Ref().chance(int(5.0f*sim->pv[y/CELL][x/CELL]), 1000))
|
||||
if (sim->rng.chance(1, 100) && sim->rng.chance(int(5.0f*sim->pv[y/CELL][x/CELL]), 1000))
|
||||
{
|
||||
sim->create_part(i, x, y, PT_NEUT);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
int r = sim->photons[y][x];
|
||||
if (parts[i].tmp < LIMIT && !parts[i].life)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 10000) && !parts[i].tmp)
|
||||
if (sim->rng.chance(1, 10000) && !parts[i].tmp)
|
||||
{
|
||||
int s = sim->create_part(-3, x, y, PT_NEUT);
|
||||
if (s >= 0)
|
||||
@ -70,7 +70,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
}
|
||||
|
||||
if (r && RNG::Ref().chance(1, 100))
|
||||
if (r && sim->rng.chance(1, 100))
|
||||
{
|
||||
int s = sim->create_part(-3, x, y, PT_NEUT);
|
||||
if (s >= 0)
|
||||
|
@ -51,5 +51,5 @@ void Element::Element_PQRT()
|
||||
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
{
|
||||
sim->parts[i].tmp2 = RNG::Ref().between(0, 10);
|
||||
sim->parts[i].tmp2 = sim->rng.between(0, 10);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
break;
|
||||
}
|
||||
case PT_DEUT:
|
||||
if (RNG::Ref().chance(-((int)sim->pv[y / CELL][x / CELL] - 4) + (parts[uID].life / 100), 200))
|
||||
if (sim->rng.chance(-((int)sim->pv[y / CELL][x / CELL] - 4) + (parts[uID].life / 100), 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);
|
||||
@ -82,7 +82,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
break;
|
||||
case PT_LCRY:
|
||||
//Powered LCRY reaction: PROT->PHOT
|
||||
if (parts[uID].life > 5 && RNG::Ref().chance(1, 10))
|
||||
if (parts[uID].life > 5 && sim->rng.chance(1, 10))
|
||||
{
|
||||
sim->part_change_type(i, x, y, PT_PHOT);
|
||||
parts[i].life *= 2;
|
||||
@ -149,7 +149,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
element = PT_CO2;
|
||||
else
|
||||
element = PT_NBLE;
|
||||
newID = sim->create_part(-1, x + RNG::Ref().between(-1, 1), y + RNG::Ref().between(-1, 1), element);
|
||||
newID = sim->create_part(-1, x + sim->rng.between(-1, 1), y + sim->rng.between(-1, 1), element);
|
||||
if (newID >= 0)
|
||||
parts[newID].temp = restrict_flt(100.0f*parts[i].tmp, MIN_TEMP, MAX_TEMP);
|
||||
sim->kill_part(i);
|
||||
@ -209,7 +209,7 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
{
|
||||
float a = RNG::Ref().between(0, 35) * 0.17453f;
|
||||
float a = sim->rng.between(0, 35) * 0.17453f;
|
||||
sim->parts[i].life = 680;
|
||||
sim->parts[i].vx = 2.0f * cosf(a);
|
||||
sim->parts[i].vy = 2.0f * sinf(a);
|
||||
|
@ -119,22 +119,22 @@ static int 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 = RNG::Ref().gen();
|
||||
if (!sim->parts[i].ctype) parts[i].ctype = RNG::Ref().gen();
|
||||
if (!sim->parts[i].life) parts[i].life = sim->rng.gen();
|
||||
if (!sim->parts[i].ctype) parts[i].ctype = sim->rng.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] = RNG::Ref().between(128, 255);
|
||||
orbl[r] = RNG::Ref().between(0, 254);
|
||||
orbd[r] = sim->rng.between(128, 255);
|
||||
orbl[r] = sim->rng.between(0, 254);
|
||||
} else {
|
||||
orbl[r] += 2;
|
||||
orbl[r] = orbl[r]%255;
|
||||
}
|
||||
} else {
|
||||
orbd[r] = RNG::Ref().between(128, 255);
|
||||
orbl[r] = RNG::Ref().between(0, 254);
|
||||
orbd[r] = sim->rng.between(128, 255);
|
||||
orbl[r] = sim->rng.between(0, 254);
|
||||
}
|
||||
}
|
||||
sim->orbitalparts_set(&parts[i].life, &parts[i].ctype, orbd, orbl);
|
||||
|
@ -74,7 +74,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
fe = 1;
|
||||
for ( nnx =0 ; nnx<80; nnx++)
|
||||
{
|
||||
int randomness = (count + RNG::Ref().between(-1, 1) + 4) % 8;//add -1,0,or 1 to count
|
||||
int randomness = (count + sim->rng.between(-1, 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);
|
||||
@ -142,15 +142,15 @@ static int 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 = RNG::Ref().gen();
|
||||
if (!sim->parts[i].ctype) parts[i].ctype = RNG::Ref().gen();
|
||||
if (!sim->parts[i].life) parts[i].life = sim->rng.gen();
|
||||
if (!sim->parts[i].ctype) parts[i].ctype = sim->rng.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] = RNG::Ref().between(0, 254);
|
||||
orbl[r] = sim->rng.between(0, 254);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -161,7 +161,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
//orbl[r] = orbl[r]%255;
|
||||
} else {
|
||||
orbd[r] = 0;
|
||||
orbl[r] = RNG::Ref().between(0, 254);
|
||||
orbl[r] = sim->rng.between(0, 254);
|
||||
}
|
||||
}
|
||||
sim->orbitalparts_set(&parts[i].life, &parts[i].ctype, orbd, orbl);
|
||||
|
@ -109,7 +109,7 @@ static void hygn_reactions(int hygn1_id, UPDATE_FUNC_ARGS)
|
||||
}
|
||||
|
||||
// Cold fusion: 2 hydrogen > 500 C has a chance to fuse
|
||||
if (rt == PT_H2 && RNG::Ref().chance(1, 1000) && parts[ID(r)].temp > 500.0f + 273.15f && parts[hygn1_id].temp > 500.0f + 273.15f)
|
||||
if (rt == PT_H2 && sim->rng.chance(1, 1000) && parts[ID(r)].temp > 500.0f + 273.15f && parts[hygn1_id].temp > 500.0f + 273.15f)
|
||||
{
|
||||
sim->part_change_type(ID(r), x + rx, y + ry, PT_NBLE);
|
||||
sim->part_change_type(hygn1_id, (int)(parts[hygn1_id].x + 0.5f), (int)(parts[hygn1_id].y + 0.5f), PT_NEUT);
|
||||
@ -125,7 +125,7 @@ static void hygn_reactions(int hygn1_id, UPDATE_FUNC_ARGS)
|
||||
parts[j].temp = parts[ID(r)].temp;
|
||||
parts[j].tmp = 0x1;
|
||||
}
|
||||
if (RNG::Ref().chance(1, 10))
|
||||
if (sim->rng.chance(1, 10))
|
||||
{
|
||||
int j = sim->create_part(-3, x + rx, y + ry, PT_ELEC);
|
||||
if (j > -1)
|
||||
@ -212,7 +212,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
float prob = std::min(1.0f, parts[i].temp / (273.15f + 1500.0f));
|
||||
prob *= prob;
|
||||
|
||||
if (RNG::Ref().uniform01() <= prob)
|
||||
if (sim->rng.uniform01() <= prob)
|
||||
{
|
||||
switch (rt)
|
||||
{
|
||||
@ -266,6 +266,6 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 15))
|
||||
if (sim->rng.chance(1, 15))
|
||||
sim->parts[i].tmp = 1;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ int Element_QRTZ_update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
else if (TYP(r)==PT_SLTW && RNG::Ref().chance(1, 500))
|
||||
else if (TYP(r)==PT_SLTW && sim->rng.chance(1, 500))
|
||||
{
|
||||
sim->kill_part(ID(r));
|
||||
parts[i].tmp++;
|
||||
@ -87,7 +87,7 @@ int Element_QRTZ_update(UPDATE_FUNC_ARGS)
|
||||
int rnd, sry, srx;
|
||||
for (trade = 0; trade < 9; trade++)
|
||||
{
|
||||
rnd = RNG::Ref().gen() % 0x3FF;
|
||||
rnd = sim->rng.gen() % 0x3FF;
|
||||
rx = (rnd%5)-2;
|
||||
srx = (rnd%3)-1;
|
||||
rnd >>= 3;
|
||||
@ -104,9 +104,9 @@ int Element_QRTZ_update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
parts[np].temp = parts[i].temp;
|
||||
parts[np].tmp2 = parts[i].tmp2;
|
||||
if (RNG::Ref().chance(1, 2))
|
||||
if (sim->rng.chance(1, 2))
|
||||
{
|
||||
parts[np].tmp2 = std::clamp(parts[np].tmp2 + RNG::Ref().between(-1, 1), 0, 10);
|
||||
parts[np].tmp2 = std::clamp(parts[np].tmp2 + sim->rng.between(-1, 1), 0, 10);
|
||||
}
|
||||
parts[i].tmp--;
|
||||
if (t == PT_PQRT)
|
||||
@ -114,11 +114,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 (RNG::Ref().chance(1, 2))
|
||||
if (sim->rng.chance(1, 2))
|
||||
{
|
||||
parts[np].tmp=-1;//dead qrtz
|
||||
}
|
||||
else if (!parts[i].tmp && RNG::Ref().chance(1, 15))
|
||||
else if (!parts[i].tmp && sim->rng.chance(1, 15))
|
||||
{
|
||||
parts[i].tmp=-1;
|
||||
}
|
||||
@ -164,6 +164,6 @@ int Element_QRTZ_graphics(GRAPHICS_FUNC_ARGS)
|
||||
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
{
|
||||
sim->parts[i].tmp2 = RNG::Ref().between(0, 10);
|
||||
sim->parts[i].tmp2 = sim->rng.between(0, 10);
|
||||
sim->parts[i].tmp3 = int(sim->pv[y/CELL][x/CELL] * 64);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
if (TYP(r)==PT_SPRK)
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_FOG);
|
||||
parts[i].life = RNG::Ref().between(60, 119);
|
||||
parts[i].life = sim->rng.between(60, 119);
|
||||
}
|
||||
else if (TYP(r)==PT_FOG&&parts[ID(r)].life>0)
|
||||
{
|
||||
|
@ -69,5 +69,5 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
{
|
||||
sim->parts[i].tmp2 = RNG::Ref().between(0, 10);
|
||||
sim->parts[i].tmp2 = sim->rng.between(0, 10);
|
||||
}
|
||||
|
@ -52,8 +52,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
int r, rx, ry, ri;
|
||||
for(ri = 0; ri <= 10; ri++)
|
||||
{
|
||||
rx = RNG::Ref().between(-10, 10);
|
||||
ry = RNG::Ref().between(-10, 10);
|
||||
rx = sim->rng.between(-10, 10);
|
||||
ry = sim->rng.between(-10, 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 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
continue;
|
||||
else if (TYP(r)==PT_SPRK&&parts[i].life==0)
|
||||
{
|
||||
if (RNG::Ref().chance(11, 40))
|
||||
if (sim->rng.chance(11, 40))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SHLD2);
|
||||
parts[i].life = 7;
|
||||
@ -72,7 +72,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (TYP(r) == PT_SHLD3 && RNG::Ref().chance(2, 5))
|
||||
else if (TYP(r) == PT_SHLD3 && sim->rng.chance(2, 5))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SHLD2);
|
||||
parts[i].life = 7;
|
||||
|
@ -61,7 +61,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (TYP(r)==PT_SPRK&&parts[i].life==0)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 8))
|
||||
if (sim->rng.chance(1, 8))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SHLD3);
|
||||
parts[i].life = 7;
|
||||
@ -77,7 +77,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (TYP(r) == PT_SHLD4 && RNG::Ref().chance(2, 5))
|
||||
else if (TYP(r) == PT_SHLD4 && sim->rng.chance(2, 5))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SHLD3);
|
||||
parts[i].life = 7;
|
||||
|
@ -55,7 +55,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 2500))
|
||||
if (sim->rng.chance(1, 2500))
|
||||
{
|
||||
np = sim->create_part(-1,x+rx,y+ry,PT_SHLD1);
|
||||
if (np<0) continue;
|
||||
@ -71,7 +71,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else if (TYP(r)==PT_SPRK&&parts[i].life==0)
|
||||
{
|
||||
if (RNG::Ref().chance(3, 500))
|
||||
if (sim->rng.chance(3, 500))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SHLD4);
|
||||
parts[i].life = 7;
|
||||
|
@ -55,7 +55,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 5500))
|
||||
if (sim->rng.chance(1, 5500))
|
||||
{
|
||||
np = sim->create_part(-1,x+rx,y+ry,PT_SHLD1);
|
||||
if (np<0) continue;
|
||||
|
@ -80,7 +80,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
spawncount = (spawncount>255) ? 3019 : int(std::pow((double)(spawncount/8), 2)*TPT_PI_FLT);
|
||||
for (int j = 0;j < spawncount; j++)
|
||||
{
|
||||
switch (RNG::Ref().gen() % 3)
|
||||
switch (sim->rng.gen() % 3)
|
||||
{
|
||||
case 0:
|
||||
nb = sim->create_part(-3, x, y, PT_PHOT);
|
||||
@ -93,10 +93,10 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
break;
|
||||
}
|
||||
if (nb!=-1) {
|
||||
parts[nb].life = RNG::Ref().between(0, 299);
|
||||
parts[nb].life = sim->rng.between(0, 299);
|
||||
parts[nb].temp = MAX_TEMP/2;
|
||||
angle = RNG::Ref().uniform01()*2.0f*TPT_PI_FLT;
|
||||
v = RNG::Ref().uniform01()*5.0f;
|
||||
angle = sim->rng.uniform01()*2.0f*TPT_PI_FLT;
|
||||
v = sim->rng.uniform01()*5.0f;
|
||||
parts[nb].vx = v*cosf(angle);
|
||||
parts[nb].vy = v*sinf(angle);
|
||||
}
|
||||
@ -113,7 +113,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if (TYP(r)!=PT_DMND&& RNG::Ref().chance(1, 3))
|
||||
if (TYP(r)!=PT_DMND&& sim->rng.chance(1, 3))
|
||||
{
|
||||
if (TYP(r)==PT_SING && parts[ID(r)].life >10)
|
||||
{
|
||||
@ -125,11 +125,11 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (parts[i].life+3 > 255)
|
||||
{
|
||||
if (parts[ID(r)].type!=PT_SING && RNG::Ref().chance(1, 1000))
|
||||
if (parts[ID(r)].type!=PT_SING && sim->rng.chance(1, 1000))
|
||||
{
|
||||
int np;
|
||||
np = sim->create_part(ID(r),x+rx,y+ry,PT_SING);
|
||||
parts[np].life = RNG::Ref().between(60, 109);
|
||||
parts[np].life = sim->rng.between(60, 109);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -145,5 +145,5 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
{
|
||||
sim->parts[i].life = RNG::Ref().between(60, 109);
|
||||
sim->parts[i].life = sim->rng.between(60, 109);
|
||||
}
|
||||
|
@ -56,26 +56,26 @@ static const int SLCN_COLOUR[16] = {
|
||||
PIXPACK(0x8594AD), PIXPACK(0x262F47), PIXPACK(0xA9AEBC), PIXPACK(0xC2E1F7),
|
||||
};
|
||||
|
||||
static void initSparkles(Particle &part)
|
||||
static void initSparkles(Simulation *sim, Particle &part)
|
||||
{
|
||||
// bits 31-20: phase increment (randomised to a value between 1 and 9)
|
||||
// bits 19-16: next colour index
|
||||
// bits 15-12: current colour index
|
||||
// bits 11-00: phase
|
||||
part.tmp = RNG::Ref().between(0x100000, 0x9FFFFF);
|
||||
part.tmp = sim->rng.between(0x100000, 0x9FFFFF);
|
||||
}
|
||||
|
||||
static int update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (!parts[i].tmp)
|
||||
{
|
||||
initSparkles(parts[i]);
|
||||
initSparkles(sim, parts[i]);
|
||||
}
|
||||
int phase = (parts[i].tmp & 0xFFF) + ((parts[i].tmp >> 20) & 0xFFF);
|
||||
if (phase & 0x1000)
|
||||
{
|
||||
// discard current, current <- next, next <- random, wrap phase
|
||||
parts[i].tmp = (parts[i].tmp & 0xFFF00000) | (phase & 0xFFF) | (RNG::Ref().between(0, 15) << 16) | ((parts[i].tmp >> 4) & 0xF000);
|
||||
parts[i].tmp = (parts[i].tmp & 0xFFF00000) | (phase & 0xFFF) | (sim->rng.between(0, 15) << 16) | ((parts[i].tmp >> 4) & 0xF000);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -137,5 +137,5 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
{
|
||||
initSparkles(sim->parts[i]);
|
||||
initSparkles(sim, sim->parts[i]);
|
||||
}
|
||||
|
@ -56,16 +56,16 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
switch (TYP(r))
|
||||
{
|
||||
case PT_SALT:
|
||||
if (RNG::Ref().chance(1, 2000))
|
||||
if (sim->rng.chance(1, 2000))
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW);
|
||||
break;
|
||||
case PT_PLNT:
|
||||
if (RNG::Ref().chance(1, 40))
|
||||
if (sim->rng.chance(1, 40))
|
||||
sim->kill_part(ID(r));
|
||||
break;
|
||||
case PT_RBDM:
|
||||
case PT_LRBD:
|
||||
if ((sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && RNG::Ref().chance(1, 100))
|
||||
if ((sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && sim->rng.chance(1, 100))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_FIRE);
|
||||
parts[i].life = 4;
|
||||
@ -76,7 +76,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
if (parts[ID(r)].ctype!=PT_WATR)
|
||||
{
|
||||
sim->kill_part(ID(r));
|
||||
if (RNG::Ref().chance(1, 30))
|
||||
if (sim->rng.chance(1, 30))
|
||||
{
|
||||
sim->kill_part(i);
|
||||
return 1;
|
||||
|
@ -61,7 +61,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if ((TYP(r)==PT_SALT || TYP(r)==PT_SLTW) && RNG::Ref().chance(1, 333))
|
||||
if ((TYP(r)==PT_SALT || TYP(r)==PT_SLTW) && sim->rng.chance(1, 333))
|
||||
{
|
||||
sim->part_change_type(i,x,y,PT_SLTW);
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW);
|
||||
|
@ -64,31 +64,31 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
case PT_WATR:
|
||||
case PT_DSTW:
|
||||
case PT_FRZW:
|
||||
if (parts[i].life<limit && RNG::Ref().chance(500, absorbChanceDenom))
|
||||
if (parts[i].life<limit && sim->rng.chance(500, absorbChanceDenom))
|
||||
{
|
||||
parts[i].life++;
|
||||
sim->kill_part(ID(r));
|
||||
}
|
||||
break;
|
||||
case PT_SLTW:
|
||||
if (parts[i].life<limit && RNG::Ref().chance(50, absorbChanceDenom))
|
||||
if (parts[i].life<limit && sim->rng.chance(50, absorbChanceDenom))
|
||||
{
|
||||
parts[i].life++;
|
||||
if (RNG::Ref().chance(3, 4))
|
||||
if (sim->rng.chance(3, 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 && RNG::Ref().chance(100, absorbChanceDenom))
|
||||
if (parts[i].life<limit && sim->rng.chance(100, 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 && RNG::Ref().chance(20, absorbChanceDenom))
|
||||
if (parts[i].life<limit && sim->rng.chance(20, absorbChanceDenom))
|
||||
{
|
||||
parts[i].life++;
|
||||
sim->create_part(ID(r), x+rx, y+ry, PT_CLST);
|
||||
@ -113,8 +113,8 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
for ( trade = 0; trade<9; trade ++)
|
||||
{
|
||||
rx = RNG::Ref().between(-2, 2);
|
||||
ry = RNG::Ref().between(-2, 2);
|
||||
rx = sim->rng.between(-2, 2);
|
||||
ry = sim->rng.between(-2, 2);
|
||||
if (BOUNDS_CHECK && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
|
@ -104,7 +104,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
case PT_NBLE:
|
||||
if (parts[i].life<=1 && !(parts[i].tmp&0x1))
|
||||
{
|
||||
parts[i].life = RNG::Ref().between(50, 199);
|
||||
parts[i].life = sim->rng.between(50, 199);
|
||||
sim->part_change_type(i,x,y,PT_PLSM);
|
||||
parts[i].ctype = PT_NBLE;
|
||||
if (parts[i].temp > 5273.15)
|
||||
@ -123,12 +123,12 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
r = pmap[y+ry][x+rx];
|
||||
if (r)
|
||||
continue;
|
||||
if (parts[i].tmp>4 && RNG::Ref().chance(1, parts[i].tmp*parts[i].tmp/20+6))
|
||||
if (parts[i].tmp>4 && sim->rng.chance(1, parts[i].tmp*parts[i].tmp/20+6))
|
||||
{
|
||||
int p = sim->create_part(-1, x+rx*2, y+ry*2, PT_LIGH);
|
||||
if (p!=-1)
|
||||
{
|
||||
parts[p].life = RNG::Ref().between(0, 2+parts[i].tmp/15) + parts[i].tmp/7;
|
||||
parts[p].life = sim->rng.between(0, 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;
|
||||
@ -156,7 +156,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
continue;
|
||||
if (TYP(r)==PT_DSTW || TYP(r)==PT_SLTW || TYP(r)==PT_WATR)
|
||||
{
|
||||
int rndstore = RNG::Ref().gen()%100;
|
||||
int rndstore = sim->rng.gen()%100;
|
||||
if (!rndstore)
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_O2);
|
||||
else if (3 > rndstore)
|
||||
@ -166,7 +166,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
break;
|
||||
case PT_TUNG:
|
||||
if(parts[i].temp < 3595.0){
|
||||
parts[i].temp += RNG::Ref().between(-4, 15);
|
||||
parts[i].temp += sim->rng.between(-4, 15);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
@ -445,7 +445,7 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
|
||||
//Spawn
|
||||
if (((int)(playerp->comm)&0x08) == 0x08)
|
||||
{
|
||||
ry -= 2 * RNG::Ref().between(0, 1) + 1;
|
||||
ry -= 2 * sim->rng.between(0, 1) + 1;
|
||||
r = pmap[ry][rx];
|
||||
if (sim->elements[TYP(r)].Properties&TYPE_SOLID)
|
||||
{
|
||||
@ -481,7 +481,7 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (playerp->elem == PT_PHOT)
|
||||
{
|
||||
int random = abs((RNG::Ref().between(-1, 1)))*3;
|
||||
int random = abs((sim->rng.between(-1, 1)))*3;
|
||||
if (random==0)
|
||||
{
|
||||
sim->kill_part(np);
|
||||
@ -502,7 +502,7 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
|
||||
if (gvx!=0 || gvy!=0)
|
||||
angle = int(atan2(mvx, mvy)*180.0f/TPT_PI_FLT);
|
||||
else
|
||||
angle = RNG::Ref().between(0, 359);
|
||||
angle = sim->rng.between(0, 359);
|
||||
if (((int)playerp->pcomm)&0x01)
|
||||
angle += 180;
|
||||
if (angle>360)
|
||||
@ -510,7 +510,7 @@ int Element_STKM_run_stickman(playerst *playerp, UPDATE_FUNC_ARGS)
|
||||
if (angle<0)
|
||||
angle+=360;
|
||||
parts[np].tmp = angle;
|
||||
parts[np].life = RNG::Ref().between(0, 1+power/15) + power/7;
|
||||
parts[np].life = sim->rng.between(0, 1+power/15) + power/7;
|
||||
parts[np].temp = parts[np].life*power/2.5;
|
||||
parts[np].tmp2 = 1;
|
||||
}
|
||||
@ -633,7 +633,7 @@ void Element_STKM_interact(Simulation *sim, playerst *playerp, int i, int x, int
|
||||
{
|
||||
if (TYP(r)==PT_SPRK && playerp->elem!=PT_LIGH) //If on charge
|
||||
{
|
||||
sim->parts[i].life -= RNG::Ref().between(32, 51);
|
||||
sim->parts[i].life -= sim->rng.between(32, 51);
|
||||
}
|
||||
|
||||
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))
|
||||
|
@ -70,9 +70,9 @@ static int 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 && RNG::Ref().chance(1, 200))
|
||||
if (sim->legacy_enable && sim->rng.chance(1, 200))
|
||||
{
|
||||
parts[i].life = RNG::Ref().between(120, 169);
|
||||
parts[i].life = sim->rng.between(120, 169);
|
||||
sim->part_change_type(i,x,y,PT_FIRE);
|
||||
}
|
||||
else
|
||||
|
@ -109,7 +109,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
int originaldir = direction;
|
||||
|
||||
//random turn
|
||||
int random = RNG::Ref().between(0, 339);
|
||||
int random = sim->rng.between(0, 339);
|
||||
if ((random==1 || random==3) && !(parts[i].tmp & TRON_NORANDOM))
|
||||
{
|
||||
//randomly turn left(3) or right(1)
|
||||
@ -133,7 +133,7 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
else
|
||||
{
|
||||
seconddir = (direction + (RNG::Ref().between(0, 1)*2)+1)% 4;
|
||||
seconddir = (direction + (sim->rng.between(0, 1)*2)+1)% 4;
|
||||
lastdir = (seconddir + 2)%4;
|
||||
}
|
||||
seconddircheck = trymovetron(sim,x,y,seconddir,i,parts[i].tmp2);
|
||||
@ -192,8 +192,8 @@ static int graphics(GRAPHICS_FUNC_ARGS)
|
||||
|
||||
static void create(ELEMENT_CREATE_FUNC_ARGS)
|
||||
{
|
||||
int randhue = RNG::Ref().between(0, 359);
|
||||
int randomdir = RNG::Ref().between(0, 3);
|
||||
int randhue = sim->rng.between(0, 359);
|
||||
int randomdir = sim->rng.between(0, 3);
|
||||
// Set as a head and a direction
|
||||
sim->parts[i].tmp = 1 | (randomdir << 5) | (randhue << 7);
|
||||
// Tail
|
||||
|
@ -69,16 +69,16 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
}
|
||||
}
|
||||
if((parts[i].temp > MELTING_POINT && RNG::Ref().chance(1, 20)) || splode)
|
||||
if((parts[i].temp > MELTING_POINT && sim->rng.chance(1, 20)) || splode)
|
||||
{
|
||||
if (RNG::Ref().chance(1, 50))
|
||||
if (sim->rng.chance(1, 50))
|
||||
{
|
||||
sim->pv[y/CELL][x/CELL] += 50.0f;
|
||||
}
|
||||
else if (RNG::Ref().chance(1, 100))
|
||||
else if (sim->rng.chance(1, 100))
|
||||
{
|
||||
sim->part_change_type(i, x, y, PT_FIRE);
|
||||
parts[i].life = RNG::Ref().between(0, 499);
|
||||
parts[i].life = sim->rng.between(0, 499);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@ -89,10 +89,10 @@ static int update(UPDATE_FUNC_ARGS)
|
||||
}
|
||||
if(splode)
|
||||
{
|
||||
parts[i].temp = restrict_flt(MELTING_POINT + RNG::Ref().between(200, 799), MIN_TEMP, MAX_TEMP);
|
||||
parts[i].temp = restrict_flt(MELTING_POINT + sim->rng.between(200, 799), MIN_TEMP, MAX_TEMP);
|
||||
}
|
||||
parts[i].vx += RNG::Ref().between(-50, 50);
|
||||
parts[i].vy += RNG::Ref().between(-50, 50);
|
||||
parts[i].vx += sim->rng.between(-50, 50);
|
||||
parts[i].vy += sim->rng.between(-50, 50);
|
||||
return 1;
|
||||
}
|
||||
auto press = int(sim->pv[y/CELL][x/CELL] * 64);
|
||||
|
@ -83,7 +83,7 @@ int Element_VIBR_update(UPDATE_FUNC_ARGS)
|
||||
else //if it is exploding
|
||||
{
|
||||
//Release sparks before explode
|
||||
rndstore = RNG::Ref().gen();
|
||||
rndstore = sim->rng.gen();
|
||||
if (parts[i].life < 300)
|
||||
{
|
||||
rx = rndstore%3-1;
|
||||
@ -117,7 +117,7 @@ int Element_VIBR_update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (!parts[i].tmp2)
|
||||
{
|
||||
rndstore = RNG::Ref().gen();
|
||||
rndstore = sim->rng.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;
|
||||
@ -125,7 +125,7 @@ int Element_VIBR_update(UPDATE_FUNC_ARGS)
|
||||
if (index != -1)
|
||||
parts[index].temp = 7000;
|
||||
int rx = ((rndstore>>12)&3)-1;
|
||||
rndstore = RNG::Ref().gen();
|
||||
rndstore = sim->rng.gen();
|
||||
index = sim->create_part(-1,x+rx-1,y+rndstore%3-1,PT_BREC);
|
||||
if (index != -1)
|
||||
parts[index].temp = 7000;
|
||||
@ -159,7 +159,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 && RNG::Ref().chance(1, 2))
|
||||
else if (parts[i].tmp2 && parts[i].life > 75 && sim->rng.chance(1, 2))
|
||||
{
|
||||
parts[ID(r)].tmp2 = 1;
|
||||
parts[i].tmp = 0;
|
||||
@ -174,7 +174,7 @@ int Element_VIBR_update(UPDATE_FUNC_ARGS)
|
||||
else
|
||||
{
|
||||
//Melts into EXOT
|
||||
if (TYP(r) == PT_EXOT && RNG::Ref().chance(1, 25))
|
||||
if (TYP(r) == PT_EXOT && sim->rng.chance(1, 25))
|
||||
{
|
||||
sim->part_change_type(i, x, y, PT_EXOT);
|
||||
return 1;
|
||||
@ -190,7 +190,7 @@ int Element_VIBR_update(UPDATE_FUNC_ARGS)
|
||||
for (trade = 0; trade < 9; trade++)
|
||||
{
|
||||
if (!(trade%2))
|
||||
rndstore = RNG::Ref().gen();
|
||||
rndstore = sim->rng.gen();
|
||||
rx = rndstore%7-3;
|
||||
rndstore >>= 3;
|
||||
ry = rndstore%7-3;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user