summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2013-09-12 00:41:43 (GMT)
committer jacob1 <jfu614@gmail.com>2013-09-12 00:41:43 (GMT)
commit332aa25bf6aa938fe3217a7a6622bf5f4c2f3201 (patch)
tree910075200d0eb324641f6df3e46b9a7cdd594756
parent09c54b596bfaa13ae5009bbe4d5e6a0131ba50d2 (diff)
downloadpowder-332aa25bf6aa938fe3217a7a6622bf5f4c2f3201.zip
powder-332aa25bf6aa938fe3217a7a6622bf5f4c2f3201.tar.gz
save pavg[] in saves, for VIRS, PIPE, and STOR
-rw-r--r--src/PowderToySDL.cpp11
-rw-r--r--src/client/GameSave.cpp27
-rw-r--r--src/simulation/Simulation.cpp4
-rw-r--r--src/simulation/elements/ELEC.cpp2
-rw-r--r--src/simulation/elements/PHOT.cpp4
5 files changed, 31 insertions, 17 deletions
diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp
index 9465e58..74cbb51 100644
--- a/src/PowderToySDL.cpp
+++ b/src/PowderToySDL.cpp
@@ -125,17 +125,16 @@ char * ClipboardPull()
//}
}
#elif defined(LIN) && defined(SDL_VIDEO_DRIVER_X11)
-
char *text = NULL;
- unsigned char *data = NULL;
- Atom type;
- int format, result;
- unsigned long len, bytesLeft, _;
Window selectionOwner;
sdl_wminfo.info.x11.lock_func();
selectionOwner = XGetSelectionOwner(sdl_wminfo.info.x11.display, XA_CLIPBOARD);
if (selectionOwner != None)
{
+ unsigned char *data = NULL;
+ Atom type;
+ int format, result;
+ unsigned long len, bytesLeft;
std::list<SDL_Event> evlist; // if there arrive any events while fetching keyboard
XConvertSelection(sdl_wminfo.info.x11.display, XA_CLIPBOARD, XA_UTF8_STRING, XA_CLIPBOARD, sdl_wminfo.info.x11.window, CurrentTime);
XFlush(sdl_wminfo.info.x11.display);
@@ -166,7 +165,7 @@ char * ClipboardPull()
}
if (bytesLeft)
{
- result = XGetWindowProperty(sdl_wminfo.info.x11.display, sdl_wminfo.info.x11.window, XA_CLIPBOARD, 0, bytesLeft, 0, AnyPropertyType, &type, &format, &len, &_, &data);
+ result = XGetWindowProperty(sdl_wminfo.info.x11.display, sdl_wminfo.info.x11.window, XA_CLIPBOARD, 0, bytesLeft, 0, AnyPropertyType, &type, &format, &len, &bytesLeft, &data);
if (result == Success)
{
text = strdup((const char*) data);
diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp
index ddb4ef4..9f52440 100644
--- a/src/client/GameSave.cpp
+++ b/src/client/GameSave.cpp
@@ -924,6 +924,19 @@ void GameSave::readOPS(char * data, int dataLength)
}
}
+ //Read pavg
+ if(fieldDescriptor & 0x2000)
+ {
+ if(i+3 >= partsDataLen) goto fail;
+ int pavg;
+ pavg = partsData[i++];
+ pavg |= (((unsigned)partsData[i++]) << 8);
+ particles[newIndex].pavg[0] = (float)pavg;
+ pavg = partsData[i++];
+ pavg |= (((unsigned)partsData[i++]) << 8);
+ particles[newIndex].pavg[1] = (float)pavg;
+ }
+
//Particle specific parsing:
switch(particles[newIndex].type)
{
@@ -1814,7 +1827,7 @@ char * GameSave::serialiseOPS(int & dataLength)
//Copy parts data
/* Field descriptor format:
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
- | tmp2[2] | tmp2 | ctype[2] | vy | vx | dcololour | ctype[1] | tmp[2] | tmp[1] | life[2] | life[1] | temp dbl len|
+ | pavg | tmp[3+4] | tmp2[2] | tmp2 | ctype[2] | vy | vx | dcololour | ctype[1] | tmp[2] | tmp[1] | life[2] | life[1] | temp dbl len|
life[2] means a second byte (for a 16 bit field) if life[1] is present
*/
partsData = (unsigned char *)malloc(NPART * (sizeof(Particle)+1));
@@ -1875,7 +1888,7 @@ char * GameSave::serialiseOPS(int & dataLength)
}
}
- //Tmp (optional), 1 to 2 bytes
+ //Tmp (optional), 1, 2, or 4 bytes
if(particles[i].tmp)
{
fieldDesc |= 1 << 3;
@@ -1949,6 +1962,16 @@ char * GameSave::serialiseOPS(int & dataLength)
}
}
+ //Don't save pavg for things that break under pressure, because then they will break when the save is loaded, since pressure isn't also loaded
+ if ((particles[i].pavg[0] || particles[i].pavg[1]) && !(particles[i].type == PT_QRTZ || particles[i].type == PT_GLAS || particles[i].type == PT_TUNG))
+ {
+ fieldDesc |= 1 << 13;
+ partsData[partsDataLen++] = (int)particles[i].pavg[0];
+ partsData[partsDataLen++] = ((int)particles[i].pavg[0])>>8;
+ partsData[partsDataLen++] = (int)particles[i].pavg[1];
+ partsData[partsDataLen++] = ((int)particles[i].pavg[1])>>8;
+ }
+
//Write the field descriptor;
partsData[fieldDescLoc] = fieldDesc;
partsData[fieldDescLoc+1] = fieldDesc>>8;
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp
index b090841..e46681d 100644
--- a/src/simulation/Simulation.cpp
+++ b/src/simulation/Simulation.cpp
@@ -140,10 +140,6 @@ int Simulation::Load(int fullX, int fullY, GameSave * save)
}
}
}
- if (parts[i].pavg[0] || parts[i].pavg[1])
- {
- parts[i].pavg[0] = parts[i].pavg[1] = 0;
- }
}
parts_lastActiveIndex = NPART-1;
force_stacking_check = 1;
diff --git a/src/simulation/elements/ELEC.cpp b/src/simulation/elements/ELEC.cpp
index 56e90b3..871b61e 100644
--- a/src/simulation/elements/ELEC.cpp
+++ b/src/simulation/elements/ELEC.cpp
@@ -50,8 +50,6 @@ Element_ELEC::Element_ELEC()
int Element_ELEC::update(UPDATE_FUNC_ARGS)
{
int r, rt, rx, ry, nb, rrx, rry;
- parts[i].pavg[0] = x;
- parts[i].pavg[1] = y;
for (rx=-2; rx<=2; rx++)
for (ry=-2; ry<=2; ry++)
if (BOUNDS_CHECK) {
diff --git a/src/simulation/elements/PHOT.cpp b/src/simulation/elements/PHOT.cpp
index 4fe5bbe..3c94351 100644
--- a/src/simulation/elements/PHOT.cpp
+++ b/src/simulation/elements/PHOT.cpp
@@ -49,10 +49,8 @@ Element_PHOT::Element_PHOT()
//#TPT-Directive ElementHeader Element_PHOT static int update(UPDATE_FUNC_ARGS)
int Element_PHOT::update(UPDATE_FUNC_ARGS)
{
- int r, rt, rx, ry;
+ int r, rx, ry;
float rr, rrr;
- parts[i].pavg[0] = x;
- parts[i].pavg[1] = y;
if (!(parts[i].ctype&0x3FFFFFFF)) {
sim->kill_part(i);
return 1;