v3.0.0: added a saving check on pause for alchemy to prevent exploits
This commit is contained in:
@@ -531,6 +531,7 @@ public class AlchemyScene extends PixelScene {
|
||||
|
||||
fadeIn();
|
||||
|
||||
saveNeeded = false;
|
||||
try {
|
||||
Dungeon.saveAll();
|
||||
Badges.saveGlobal();
|
||||
@@ -754,8 +755,11 @@ public class AlchemyScene extends PixelScene {
|
||||
Statistics.itemsCrafted++;
|
||||
Badges.validateItemsCrafted();
|
||||
|
||||
saveNeeded = false;
|
||||
try {
|
||||
Dungeon.saveAll();
|
||||
Badges.saveGlobal();
|
||||
Journal.saveGlobal();
|
||||
} catch (IOException e) {
|
||||
ShatteredPixelDungeon.reportException(e);
|
||||
}
|
||||
@@ -804,6 +808,23 @@ public class AlchemyScene extends PixelScene {
|
||||
updateState();
|
||||
}
|
||||
|
||||
private boolean saveNeeded = false;
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
if (saveNeeded) {
|
||||
saveNeeded = false;
|
||||
clearSlots();
|
||||
try {
|
||||
Dungeon.saveAll();
|
||||
Badges.saveGlobal();
|
||||
Journal.saveGlobal();
|
||||
} catch (IOException e) {
|
||||
ShatteredPixelDungeon.reportException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
synchronized ( inputs ) {
|
||||
@@ -813,6 +834,7 @@ public class AlchemyScene extends PixelScene {
|
||||
}
|
||||
}
|
||||
|
||||
saveNeeded = false;
|
||||
try {
|
||||
Dungeon.saveAll();
|
||||
Badges.saveGlobal();
|
||||
@@ -863,6 +885,9 @@ public class AlchemyScene extends PixelScene {
|
||||
sparkEmitter.burst(SparkParticle.FACTORY, 20);
|
||||
Sample.INSTANCE.play( Assets.Sounds.LIGHTNING );
|
||||
|
||||
//queue a save here, as items may be in the input windows and we don't want to clear them
|
||||
// but if the game becomes paused we do this to prevent exploits
|
||||
saveNeeded = true;
|
||||
updateState();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user