Skip to content

Commit

Permalink
Fix DLAY delay changing during save+load
Browse files Browse the repository at this point in the history
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 72329af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/client/GameSave.cpp
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/DLAY.cpp
Expand Up @@ -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)
{
Expand Down

0 comments on commit 72329af

Please sign in to comment.