Skip to content

Commit

Permalink
Allow PHOT deco, in old saves only
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksonmj committed Aug 5, 2014
1 parent 10a2600 commit c83945e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/client/GameSave.cpp
Expand Up @@ -1003,6 +1003,11 @@ void GameSave::readOPS(char * data, int dataLength)
particles[newIndex].ctype = 0;
}
break;
case PT_PHOT:
if (savedVersion < 90)
{
particles[newIndex].flags |= FLAG_PHOTDECO;
}
}
//note: PSv was used in version 77.0 and every version before, add something in PSv too if the element is that old
newIndex++;
Expand Down Expand Up @@ -1550,6 +1555,10 @@ void GameSave::readPSv(char * data, int dataLength)
// no more particle properties to load, so we can change type here without messing up loading
if (i && i<=NPART)
{
if (ver<90 && particles[i-1].type == PT_PHOT)
{
particles[i-1].flags |= FLAG_PHOTDECO;
}
if (ver<79 && particles[i-1].type == PT_SPNG)
{
if (fabs(particles[i-1].vx)>0.0f || fabs(particles[i-1].vy)>0.0f)
Expand Down
1 change: 1 addition & 0 deletions src/lua/LuaScriptInterface.cpp
Expand Up @@ -1910,6 +1910,7 @@ void LuaScriptInterface::initElementsAPI()
SETCONST(l, FLAG_STAGNANT);
SETCONST(l, FLAG_SKIPMOVE);
SETCONST(l, FLAG_MOVABLE);
SETCONST(l, FLAG_PHOTDECO);
SETCONST(l, ST_NONE);
SETCONST(l, ST_SOLID);
SETCONST(l, ST_LIQUID);
Expand Down
4 changes: 3 additions & 1 deletion src/simulation/Elements.h
Expand Up @@ -35,7 +35,9 @@
#define FLAG_STAGNANT 0x1
#define FLAG_SKIPMOVE 0x2 // skip movement for one frame, only implemented for PHOT
#define FLAG_WATEREQUAL 0x4 //if a liquid was already checked during equalization
#define FLAG_MOVABLE 0x8 // if can move
#define FLAG_MOVABLE 0x8 // compatibility with old saves (moving SPNG), only applies to SPNG
#define FLAG_PHOTDECO 0x8 // compatibility with old saves (decorated photons), only applies to PHOT. Having the same value as FLAG_MOVABLE is fine because they apply to different elements, and this saves space for future flags,


#define ST_NONE 0
#define ST_SOLID 1
Expand Down
4 changes: 4 additions & 0 deletions src/simulation/elements/PHOT.cpp
Expand Up @@ -121,6 +121,10 @@ int Element_PHOT::graphics(GRAPHICS_FUNC_ARGS)

*pixel_mode &= ~PMODE_FLAT;
*pixel_mode |= FIRE_ADD | PMODE_ADD | NO_DECO;
if (cpart->flags & FLAG_PHOTDECO)
{
*pixel_mode &= ~NO_DECO;
}
return 0;
}

Expand Down

0 comments on commit c83945e

Please sign in to comment.