save pavg[] in saves, for VIRS, PIPE, and STOR
This commit is contained in:
parent
09c54b596b
commit
332aa25bf6
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user