Skip to content

Commit

Permalink
Add maxschematicpreviews
Browse files Browse the repository at this point in the history
  • Loading branch information
buthed010203 committed Jan 19, 2024
1 parent a5f3438 commit 312add8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/src/mindustry/game/Schematics.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,10 @@ public boolean hasPreview(Schematic schematic){
public FrameBuffer getBuffer(Schematic schematic){
//dispose unneeded previews to prevent memory outage errors.
//only runs every 2 seconds
if(mobile && Time.timeSinceMillis(lastClearTime) > 1000 * 2 && previews.size > maxPreviewsMobile){
int max = Core.settings.getInt("maxschematicpreviews", mobile ? maxPreviewsMobile : 0);
if(max > 0 && Time.timeSinceMillis(lastClearTime) > 1000 * 2 && previews.size > max){
Seq<Schematic> keys = previews.orderedKeys().copy();
for(int i = 0; i < previews.size - maxPreviewsMobile; i++){
for(int i = 0; i < previews.size - max; i++){
//dispose and remove unneeded previews
previews.get(keys.get(i)).dispose();
previews.remove(keys.get(i));
Expand Down

0 comments on commit 312add8

Please sign in to comment.