Skip to content

Commit

Permalink
more accurate O2 fusion calculation, fixes #505
Browse files Browse the repository at this point in the history
seemed to only be 3% slower in my tests with a full screen of heated pressurized O2
  • Loading branch information
jacob1 committed Mar 4, 2018
1 parent 2adae64 commit d666559
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions src/simulation/elements/O2.cpp
Expand Up @@ -74,37 +74,42 @@ int Element_O2::update(UPDATE_FUNC_ARGS)
parts[i].tmp |= 2;
}
}
if (parts[i].temp > 9973.15 && sim->pv[y/CELL][x/CELL] > 250.0f && abs(sim->gravx[((y/CELL)*(XRES/CELL))+(x/CELL)]) + abs(sim->gravy[((y/CELL)*(XRES/CELL))+(x/CELL)]) > 20)
if (parts[i].temp > 9973.15 && sim->pv[y/CELL][x/CELL] > 250.0f)
{
if (!(rand()%5))
float gravx = sim->gravx[((y/CELL)*(XRES/CELL))+(x/CELL)];
float gravy = sim->gravy[((y/CELL)*(XRES/CELL))+(x/CELL)];
if (gravx*gravx + gravy*gravy > 400)
{
int j;
sim->create_part(i,x,y,PT_BRMT);

j = sim->create_part(-3,x,y,PT_NEUT);
if (j != -1)
parts[j].temp = MAX_TEMP;
j = sim->create_part(-3,x,y,PT_PHOT);
if (j != -1)
{
parts[j].temp = MAX_TEMP;
parts[j].tmp = 0x1;
}
rx = x+rand()%3-1, ry = y+rand()%3-1, r = TYP(pmap[ry][rx]);
if (sim->can_move[PT_PLSM][r] || r == PT_O2)
if (!(rand()%5))
{
j = sim->create_part(-3,rx,ry,PT_PLSM);
if (j > -1)
int j;
sim->create_part(i,x,y,PT_BRMT);

j = sim->create_part(-3,x,y,PT_NEUT);
if (j != -1)
parts[j].temp = MAX_TEMP;
j = sim->create_part(-3,x,y,PT_PHOT);
if (j != -1)
{
parts[j].temp = MAX_TEMP;
parts[j].tmp |= 4;
parts[j].tmp = 0x1;
}
rx = x+rand()%3-1, ry = y+rand()%3-1, r = TYP(pmap[ry][rx]);
if (sim->can_move[PT_PLSM][r] || r == PT_O2)
{
j = sim->create_part(-3,rx,ry,PT_PLSM);
if (j > -1)
{
parts[j].temp = MAX_TEMP;
parts[j].tmp |= 4;
}
}
j = sim->create_part(-3,x,y,PT_GRVT);
if (j != -1)
parts[j].temp = MAX_TEMP;
parts[i].temp = MAX_TEMP;
sim->pv[y/CELL][x/CELL] = 256;
}
j = sim->create_part(-3,x,y,PT_GRVT);
if (j != -1)
parts[j].temp = MAX_TEMP;
parts[i].temp = MAX_TEMP;
sim->pv[y/CELL][x/CELL] = 256;
}
}
return 0;
Expand Down

0 comments on commit d666559

Please sign in to comment.