summaryrefslogtreecommitdiff
path: root/src/client/GameSave.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-07-25 16:12:15 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-07-25 16:12:15 (GMT)
commit6585a4640b9d1d24d821fb2147fe6182a709f088 (patch)
tree4ccbd35c1776955c2933991af5181babe2332f9a /src/client/GameSave.cpp
parent0afecb5b77442d770f5ebb149f574d87859ebde7 (diff)
downloadpowder-6585a4640b9d1d24d821fb2147fe6182a709f088.zip
powder-6585a4640b9d1d24d821fb2147fe6182a709f088.tar.gz
TPT: Replace all explosion sparks with new element (EMBR) 1d5b081942
Diffstat (limited to 'src/client/GameSave.cpp')
-rw-r--r--src/client/GameSave.cpp57
1 files changed, 56 insertions, 1 deletions
diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp
index c03536c..7e3fbe7 100644
--- a/src/client/GameSave.cpp
+++ b/src/client/GameSave.cpp
@@ -12,6 +12,10 @@
#include "bson/BSON.h"
#include "GameSave.h"
#include "simulation/SimulationData.h"
+extern "C"
+{
+ #include "hmap.h"
+}
GameSave::GameSave(GameSave & save) :
waterEEnabled(save.waterEEnabled),
@@ -262,6 +266,7 @@ void GameSave::readOPS(char * data, int dataLength)
int i, freeIndicesCount, x, y, j;
int *freeIndices = NULL;
int blockX, blockY, blockW, blockH, fullX, fullY, fullW, fullH;
+ int savedVersion = inputData[4];
bson b;
bson_iterator iter;
@@ -278,7 +283,7 @@ void GameSave::readOPS(char * data, int dataLength)
fullH = blockH*CELL;
//From newer version
- if(inputData[4] > SAVE_VERSION)
+ if(savedVersion > SAVE_VERSION)
throw ParseException(ParseException::WrongVersion, "Save from newer version");
//Incompatible cell size
@@ -716,6 +721,32 @@ void GameSave::readOPS(char * data, int dataLength)
//Clear soap links, links will be added back in if soapLinkData is present
particles[newIndex].ctype &= ~6;
break;
+ case PT_BOMB:
+ if (particles[newIndex].tmp!=0 && savedVersion < 81)
+ {
+ particles[newIndex].type = PT_EMBR;
+ particles[newIndex].ctype = 0;
+ if (particles[newIndex].tmp==1)
+ particles[newIndex].tmp = 0;
+ }
+ break;
+ case PT_DUST:
+ if (particles[newIndex].life>0 && savedVersion < 81)
+ {
+ particles[newIndex].type = PT_EMBR;
+ particles[newIndex].ctype = (particles[newIndex].tmp2<<16) | (particles[newIndex].tmp<<8) | particles[newIndex].ctype;
+ particles[newIndex].tmp = 1;
+ }
+ break;
+ case PT_FIRW:
+ if (particles[newIndex].tmp>=2 && savedVersion < 81)
+ {
+ int caddress = restrict_flt(restrict_flt((float)(particles[newIndex].tmp-4), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3);
+ particles[newIndex].type = PT_EMBR;
+ particles[newIndex].tmp = 1;
+ particles[newIndex].ctype = (((unsigned char)(firw_data[caddress]))<<16) | (((unsigned char)(firw_data[caddress+1]))<<8) | ((unsigned char)(firw_data[caddress+2]));
+ }
+ break;
}
newIndex++;
}
@@ -1291,6 +1322,30 @@ void GameSave::readPSv(char * data, int dataLength)
particles[i-1].tmp2 = particles[i-1].life;
}
}
+
+ if (ver<81)
+ {
+ if (particles[i-1].type==PT_BOMB && particles[i-1].tmp!=0)
+ {
+ particles[i-1].type = PT_EMBR;
+ particles[i-1].ctype = 0;
+ if (particles[i-1].tmp==1)
+ particles[i-1].tmp = 0;
+ }
+ if (particles[i-1].type==PT_DUST && particles[i-1].life>0)
+ {
+ particles[i-1].type = PT_EMBR;
+ particles[i-1].ctype = (particles[i-1].tmp2<<16) | (particles[i-1].tmp<<8) | particles[i-1].ctype;
+ particles[i-1].tmp = 1;
+ }
+ if (particles[i-1].type==PT_FIRW && particles[i-1].tmp>=2)
+ {
+ int caddress = restrict_flt(restrict_flt((float)(particles[i-1].tmp-4), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3);
+ particles[i-1].type = PT_EMBR;
+ particles[i-1].tmp = 1;
+ particles[i-1].ctype = (((unsigned char)(firw_data[caddress]))<<16) | (((unsigned char)(firw_data[caddress+1]))<<8) | ((unsigned char)(firw_data[caddress+2]));
+ }
+ }
}
}