From c83945e281719ce46cb1f46de26e62ac5c5330f2 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Tue, 5 Aug 2014 22:09:34 +0100 Subject: [PATCH] Allow PHOT deco, in old saves only --- src/client/GameSave.cpp | 9 +++++++++ src/lua/LuaScriptInterface.cpp | 1 + src/simulation/Elements.h | 4 +++- src/simulation/elements/PHOT.cpp | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp index f7ca37429a..33ebfa2999 100644 --- a/src/client/GameSave.cpp +++ b/src/client/GameSave.cpp @@ -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++; @@ -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) diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index cd415a5feb..618e641920 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -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); diff --git a/src/simulation/Elements.h b/src/simulation/Elements.h index 54f5483aa0..f00a3a6c3c 100644 --- a/src/simulation/Elements.h +++ b/src/simulation/Elements.h @@ -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 diff --git a/src/simulation/elements/PHOT.cpp b/src/simulation/elements/PHOT.cpp index cfb1043356..e792aaf6f2 100644 --- a/src/simulation/elements/PHOT.cpp +++ b/src/simulation/elements/PHOT.cpp @@ -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; }