Skip to content

Commit

Permalink
Customizable FRAY and INVS (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
handicraftsman authored and jacob1 committed Apr 20, 2017
1 parent 3fbfb83 commit 7078d7e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -64,6 +64,5 @@ config.log
*.pyc
site_scons/site_tools/mfprogram/*.pyc
site_scons/site_tools/gch/*.pyc
others*

screenshot_*
15 changes: 13 additions & 2 deletions src/simulation/Simulation.cpp
Expand Up @@ -2187,7 +2187,13 @@ int Simulation::eval_move(int pt, int nx, int ny, unsigned *rr)
}
else if ((r&0xFF) == PT_INVIS)
{
if (pv[ny/CELL][nx/CELL]>4.0f || pv[ny/CELL][nx/CELL]<-4.0f)
float pressureResistance = 0.0f;
if (parts[r>>8].tmp > 0)
pressureResistance = (float)parts[r>>8].tmp;
else
pressureResistance = 4.0f;

if (pv[ny/CELL][nx/CELL] < -pressureResistance || pv[ny/CELL][nx/CELL] > pressureResistance)
result = 2;
else
result = 0;
Expand Down Expand Up @@ -2328,7 +2334,12 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
}
else if ((r&0xFF) == PT_INVIS)
{
if (pv[ny/CELL][nx/CELL]<=4.0f && pv[ny/CELL][nx/CELL]>=-4.0f)
float pressureResistance = 0.0f;
if (parts[r>>8].tmp > 0)
pressureResistance = (float)parts[r>>8].tmp;
else
pressureResistance = 4.0f;
if (pv[ny/CELL][nx/CELL] >= -pressureResistance && pv[ny/CELL][nx/CELL] <= pressureResistance)
{
part_change_type(i,x,y,PT_NEUT);
parts[i].ctype = 0;
Expand Down
7 changes: 6 additions & 1 deletion src/simulation/elements/FRAY.cpp
Expand Up @@ -47,6 +47,11 @@ Element_FRAY::Element_FRAY()
//#TPT-Directive ElementHeader Element_FRAY static int update(UPDATE_FUNC_ARGS)
int Element_FRAY::update(UPDATE_FUNC_ARGS)
{
int curlen;
if (parts[i].tmp > 0)
curlen = parts[i].tmp;
else
curlen = 10;
int r, nxx, nyy, len, nxi, nyi, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
Expand All @@ -57,7 +62,7 @@ int Element_FRAY::update(UPDATE_FUNC_ARGS)
continue;
if ((r&0xFF)==PT_SPRK) {
for (nxx = 0, nyy = 0, nxi = rx*-1, nyi = ry*-1, len = 0; ; nyy+=nyi, nxx+=nxi, len++) {
if (!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0) || len>10) {
if (!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0) || len>curlen) {
break;
}
r = pmap[y+nyi+nyy][x+nxi+nxx];
Expand Down
14 changes: 10 additions & 4 deletions src/simulation/elements/INVIS.cpp
Expand Up @@ -48,18 +48,24 @@ Element_INVIS::Element_INVIS()
//#TPT-Directive ElementHeader Element_INVIS static int update(UPDATE_FUNC_ARGS)
int Element_INVIS::update(UPDATE_FUNC_ARGS)
{
if (sim->pv[y/CELL][x/CELL]>4.0f || sim->pv[y/CELL][x/CELL]<-4.0f)
parts[i].tmp = 1;
float pressureResistance = 0.0f;
if (parts[i].tmp > 0)
pressureResistance = (float) parts[i].tmp;
else
parts[i].tmp = 0;
pressureResistance = 4.0f;

if (sim->pv[y/CELL][x/CELL] < -pressureResistance || sim->pv[y/CELL][x/CELL] > pressureResistance)
parts[i].tmp2 = 1;
else
parts[i].tmp2 = 0;
return 0;
}

//#TPT-Directive ElementHeader Element_INVIS static int graphics(GRAPHICS_FUNC_ARGS)
int Element_INVIS::graphics(GRAPHICS_FUNC_ARGS)
{
//pv[ny/CELL][nx/CELL]>4.0f || pv[ny/CELL][nx/CELL]<-4.0f
if(cpart->tmp)
if(cpart->tmp2)
{
*cola = 100;
*colr = 15;
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/TRON.cpp
Expand Up @@ -258,7 +258,7 @@ int Element_TRON::trymovetron(Simulation * sim, int x, int y, int dir, int i, in
//#TPT-Directive ElementHeader Element_TRON static bool canmovetron(Simulation * sim, int r, int len)
bool Element_TRON::canmovetron(Simulation * sim, int r, int len)
{
if (!r || ((r&0xFF) == PT_SWCH && sim->parts[r>>8].life >= 10) || ((r&0xFF) == PT_INVIS && sim->parts[r>>8].tmp == 1))
if (!r || ((r&0xFF) == PT_SWCH && sim->parts[r>>8].life >= 10) || ((r&0xFF) == PT_INVIS && sim->parts[r>>8].tmp2 == 1))
return true;
if ((((sim->elements[r&0xFF].Properties & PROP_LIFE_KILL_DEC) && sim->parts[r>>8].life > 0)|| ((sim->elements[r&0xFF].Properties & PROP_LIFE_KILL) && (sim->elements[r&0xFF].Properties & PROP_LIFE_DEC))) && sim->parts[r>>8].life < len)
return true;
Expand Down

0 comments on commit 7078d7e

Please sign in to comment.