Permalink
Browse files

CONV tmp value can now be used to restrict which elements get convert…

…ed. Requires version bump to 92.
  • Loading branch information...
jacksonmj committed Oct 12, 2015
1 parent d88c18a commit d0445258c5b4109de0b90e70ece559d938cd519a
Showing with 37 additions and 12 deletions.
  1. +20 −0 src/client/GameSave.cpp
  2. +2 −2 src/gui/game/GameView.cpp
  3. +7 −2 src/simulation/Simulation.cpp
  4. +8 −8 src/simulation/elements/CONV.cpp
@@ -1085,6 +1085,15 @@ void GameSave::readOPS(char * data, int dataLength)
particles[newIndex].tmp2 = 0;
}
}
case PT_CONV:
if (savedVersion < 92)
{
if (particles[newIndex].tmp)
{
particles[newIndex].ctype |= particles[newIndex].tmp<<8;
particles[newIndex].tmp = 0;
}
}
}
//note: PSv was used in version 77.0 and every version before, add something in PSv too if the element is that old
newIndex++;
@@ -1738,6 +1747,17 @@ void GameSave::readPSv(char * data, int dataLength)
if (particles[i-1].type == PT_VINE)
particles[i-1].tmp = 1;
}
if (ver < 92)
{
if (particles[i-1].type == PT_CONV)
{
if (particles[i-1].tmp)
{
particles[i-1].ctype |= particles[i-1].tmp<<8;
particles[i-1].tmp = 0;
}
}
}
}
}
@@ -2267,8 +2267,8 @@ void GameView::OnDraw()
sampleInfo << c->ElementResolve(sample.particle.type, sample.particle.ctype);
if (wavelengthGfx)
sampleInfo << " (" << ctype << ")";
// CRAY and DRAY store extra LIFE info in upper bits of ctype, instead of tmp2
else if (sample.particle.type == PT_CRAY || sample.particle.type == PT_DRAY)
// Some elements store extra LIFE info in upper bits of ctype, instead of tmp/tmp2
else if (sample.particle.type == PT_CRAY || sample.particle.type == PT_DRAY || sample.particle.type == PT_CONV)
sampleInfo << " (" << c->ElementResolve(ctype&0xFF, ctype>>8) << ")";
else if (c->IsValidElement(ctype))
sampleInfo << " (" << c->ElementResolve(ctype, -1) << ")";
@@ -2847,8 +2847,13 @@ int Simulation::create_part(int p, int x, int y, int tv)
&& (!(elements[t].Properties & PROP_NOCTYPEDRAW)))
{
parts[pmap[y][x]>>8].ctype = t;
if (t == PT_LIFE && v >= 0 && v < NGOL && drawOn != PT_STOR)
parts[pmap[y][x]>>8].tmp = v;
if (t == PT_LIFE && v >= 0 && v < NGOL)
{
if (drawOn == PT_CONV)
parts[pmap[y][x]>>8].ctype |= v<<8;
else if (drawOn != PT_STOR)
parts[pmap[y][x]>>8].tmp = v;
}
}
else if ((drawOn == PT_DTEC || (drawOn == PT_PSTN && t != PT_FRME) || drawOn == PT_DRAY) && drawOn != t)
{
@@ -50,7 +50,8 @@ Element_CONV::Element_CONV()
int Element_CONV::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !sim->elements[parts[i].ctype].Enabled || parts[i].ctype==PT_CONV || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOL)))
int ctype = parts[i].ctype&0xFF, ctypeExtra = parts[i].ctype>>8;
if (ctype<=0 || ctype>=PT_NUM || !sim->elements[ctype].Enabled || ctype==PT_CONV || (ctype==PT_LIFE && (ctypeExtra<0 || ctypeExtra>=NGOL)))
{
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
@@ -68,26 +69,25 @@ int Element_CONV::update(UPDATE_FUNC_ARGS)
{
parts[i].ctype = r&0xFF;
if ((r&0xFF)==PT_LIFE)
parts[i].tmp = parts[r>>8].ctype;
parts[i].ctype |= (parts[r>>8].ctype << 8);
}
}
}
else
{
bool life = parts[i].ctype==PT_LIFE;
int restrictElement = sim->IsValidElement(parts[i].tmp) ? parts[i].tmp : 0;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES)
{
r = sim->photons[y+ry][x+rx];
if (!r)
if (!r || (restrictElement && (r&0xFF)!=restrictElement))
r = pmap[y+ry][x+rx];
if (!r)
if (!r || (restrictElement && (r&0xFF)!=restrictElement))
continue;
if((r&0xFF)!=PT_CONV && (r&0xFF)!=PT_DMND && (r&0xFF)!=parts[i].ctype)
if((r&0xFF)!=PT_CONV && (r&0xFF)!=PT_DMND && (r&0xFF)!=ctype)
{
if (life) sim->create_part(r>>8, x+rx, y+ry, parts[i].ctype|(parts[i].tmp<<8));
else sim->create_part(r>>8, x+rx, y+ry, parts[i].ctype);
sim->create_part(r>>8, x+rx, y+ry, parts[i].ctype);
}
}
}

0 comments on commit d044525

Please sign in to comment.