Permalink
Browse files

Fix DLAY delay changing during save+load

by rounding temperatures to nearest instead of always flooring.

Effect on DLAY delay:
Room temperature offset - loaded as whole number of degrees C, so rounding to nearest deg C gives the same number as flooring.
Full - loaded as whole number of K = original whole deg C - 0.15. Rounding to nearest deg C means the whole deg C delay from before saving is used as the number of frames to delay, instead of deg C - 1 if flooring was used.
  • Loading branch information...
jacksonmj committed Mar 27, 2015
1 parent a9e2445 commit 72329af09dd6879d39a1230272818d3221077aa3
Showing with 3 additions and 3 deletions.
  1. +2 −2 src/client/GameSave.cpp
  2. +1 −1 src/simulation/elements/DLAY.cpp
@@ -1914,13 +1914,13 @@ char * GameSave::serialiseOPS(unsigned int & dataLength)
//Store temperature as an offset of 21C(294.15K) or go into a 16byte int and store the whole thing
if(fabs(particles[i].temp-294.15f)<127)
{
tempTemp = (particles[i].temp-294.15f);
tempTemp = floor(particles[i].temp-294.15f+0.5f);
partsData[partsDataLen++] = tempTemp;
}
else
{
fieldDesc |= 1;
tempTemp = particles[i].temp;
tempTemp = (int)(particles[i].temp+0.5f);
partsData[partsDataLen++] = tempTemp;
partsData[partsDataLen++] = tempTemp >> 8;
}
@@ -64,7 +64,7 @@ int Element_DLAY::update(UPDATE_FUNC_ARGS)
continue;
if ((r&0xFF)==PT_SPRK && parts[i].life==0 && parts[r>>8].life>0 && parts[r>>8].life<4 && parts[r>>8].ctype==PT_PSCN)
{
parts[i].life = (int)(parts[i].temp-273.15);
parts[i].life = (int)(parts[i].temp-273.15f+0.5f);
}
else if ((r&0xFF)==PT_DLAY)
{

0 comments on commit 72329af

Please sign in to comment.