move QRTZ .tmp into .tmp2 and .ctype into .tmp, fixes bug where sparking QRTZ resets .ctype and stops it from growing

This commit is contained in:
jacob1 2013-08-29 22:18:35 -04:00
parent b17ef7f938
commit d38af2764c
3 changed files with 34 additions and 19 deletions

View File

@ -972,7 +972,16 @@ void GameSave::readOPS(char * data, int dataLength)
particles[newIndex].tmp = 6;
particles[newIndex].ctype = 0;
}
case PT_QRTZ:
case PT_PQRT:
if (savedVersion < 89)
{
particles[newIndex].tmp2 = particles[newIndex].tmp;
particles[newIndex].tmp = particles[newIndex].ctype;
particles[newIndex].ctype = 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++;
}
}
@ -1602,6 +1611,12 @@ void GameSave::readPSv(char * data, int dataLength)
particles[i-1].tmp = 6;
particles[i-1].ctype = 0;
}
else if (particles[i-1].type == PT_QRTZ || particles[i-1].type == PT_PQRT)
{
particles[i-1].tmp2 = particles[i-1].tmp;
particles[i-1].tmp = particles[i-1].ctype;
particles[i-1].ctype = 0;
}
}
}
}

View File

@ -2835,7 +2835,7 @@ int Simulation::create_part(int p, int x, int y, int tv)
break;
case PT_QRTZ:
case PT_PQRT:
parts[i].tmp = (rand()%11);
parts[i].tmp2 = (rand()%11);
break;
case PT_CLST:
parts[i].tmp = (rand()%7);

View File

@ -60,7 +60,7 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS)
}
}
// absorb SLTW
if (parts[i].ctype!=-1)
if (parts[i].tmp != -1)
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
@ -71,15 +71,15 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS)
else if ((r&0xFF)==PT_SLTW && !(rand()%500))
{
sim->kill_part(r>>8);
parts[i].ctype ++;
parts[i].tmp++;
}
}
// grow and diffuse
if (parts[i].ctype>0)
if (parts[i].tmp > 0)
{
bool stopgrow=false;
bool stopgrow = false;
int rnd, sry, srx;
for ( trade = 0; trade<9; trade ++)
for (trade = 0; trade < 9; trade++)
{
rnd = rand()%0x3FF;
rx = (rnd%5)-2;
@ -91,20 +91,20 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS)
{
if (!stopgrow)//try to grow
{
if (!pmap[y+sry][x+srx] && parts[i].ctype!=0)
if (!pmap[y+sry][x+srx] && parts[i].tmp!=0)
{
np = sim->create_part(-1,x+srx,y+sry,PT_QRTZ);
if (np>-1)
{
parts[np].tmp = parts[i].tmp;
parts[i].ctype--;
parts[np].tmp2 = parts[i].tmp2;
parts[i].tmp--;
if (rand()%2)
{
parts[np].ctype=-1;//dead qrtz
parts[np].tmp=-1;//dead qrtz
}
else if (!parts[i].ctype && !(rand()%15))
else if (!parts[i].tmp && !(rand()%15))
{
parts[i].ctype=-1;
parts[i].tmp=-1;
}
stopgrow=true;
}
@ -114,19 +114,19 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
else if ((r&0xFF)==PT_QRTZ && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0)
else if ((r&0xFF)==PT_QRTZ && (parts[i].tmp>parts[r>>8].tmp) && parts[r>>8].tmp>=0)
{
tmp = parts[i].ctype - parts[r>>8].ctype;
tmp = parts[i].tmp - parts[r>>8].tmp;
if (tmp ==1)
{
parts[r>>8].ctype ++;
parts[i].ctype --;
parts[r>>8].tmp++;
parts[i].tmp--;
break;
}
if (tmp>0)
{
parts[r>>8].ctype += tmp/2;
parts[i].ctype -= tmp/2;
parts[r>>8].tmp += tmp/2;
parts[i].tmp -= tmp/2;
break;
}
}
@ -141,7 +141,7 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS)
int Element_QRTZ::graphics(GRAPHICS_FUNC_ARGS)
//QRTZ and PQRT
{
int t = cpart->type, z = cpart->tmp - 5;//speckles!
int t = cpart->type, z = cpart->tmp2 - 5;//speckles!
/*if (cpart->temp>(ptransitions[t].thv-800.0f))//hotglow for quartz
{
float frequency = 3.1415/(2*ptransitions[t].thv-(ptransitions[t].thv-800.0f));