Fixed some issues with sector positions not migrating correctly
This commit is contained in:
@@ -72,7 +72,32 @@ public class Saves{
|
|||||||
|
|
||||||
lastSectorSave = saves.find(s -> s.isSector() && s.getName().equals(Core.settings.getString("last-sector-save", "<none>")));
|
lastSectorSave = saves.find(s -> s.isSector() && s.getName().equals(Core.settings.getString("last-sector-save", "<none>")));
|
||||||
|
|
||||||
ObjectSet<Sector> infoToClear = new ObjectSet<>(), remapped = new ObjectSet<>();
|
class Remap{
|
||||||
|
//file in the temp folder
|
||||||
|
Fi sourceFile;
|
||||||
|
//slot of source sector to move file for
|
||||||
|
SaveSlot slot;
|
||||||
|
Sector sourceSector;
|
||||||
|
//sector info from source sector to move into
|
||||||
|
SectorInfo sourceInfo;
|
||||||
|
|
||||||
|
//file to copy to
|
||||||
|
Fi destFile;
|
||||||
|
//destination sector to move to
|
||||||
|
Sector destSector;
|
||||||
|
|
||||||
|
Remap(SaveSlot slot, Fi sourceFile, Sector sourceSector, SectorInfo sourceInfo, Fi destFile, Sector destSector){
|
||||||
|
this.slot = slot;
|
||||||
|
this.sourceFile = sourceFile;
|
||||||
|
this.sourceSector = sourceSector;
|
||||||
|
this.sourceInfo = sourceInfo;
|
||||||
|
this.destFile = destFile;
|
||||||
|
this.destSector = destSector;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Seq<Remap> remaps = new Seq<>();
|
||||||
|
ObjectSet<Sector> remapped = new ObjectSet<>();
|
||||||
|
|
||||||
//automatically assign sector save slots
|
//automatically assign sector save slots
|
||||||
for(SaveSlot slot : saves){
|
for(SaveSlot slot : saves){
|
||||||
@@ -97,29 +122,18 @@ public class Saves{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: sectors like Ruinous Shores get overwritten first and explode when getting remapped
|
|
||||||
|
|
||||||
if(remapTarget != null){
|
if(remapTarget != null){
|
||||||
//if the file name matches the destination of the remap, assume it has already been remapped, and skip the file movement procedure
|
//if the file name matches the destination of the remap, assume it has already been remapped, and skip the file movement procedure
|
||||||
if(!slot.file.equals(getSectorFile(remapTarget))){
|
if(!slot.file.equals(getSectorFile(remapTarget))){
|
||||||
Log.info("Remapping sector: @ -> @ (@)", sector.id, remapTarget.id, remapTarget.preset);
|
Log.info("Remapping sector: @ -> @ (@)", sector.id, remapTarget.id, remapTarget.preset);
|
||||||
|
|
||||||
sector.loadInfo();
|
|
||||||
//overwrite the target sector's info with the save's info
|
|
||||||
Core.settings.putJson(remapTarget.planet.name + "-s-" + remapTarget.id + "-info", sector.info);
|
|
||||||
remapTarget.loadInfo();
|
|
||||||
|
|
||||||
//queue a clear of the sector that had its data moved
|
|
||||||
infoToClear.add(sector);
|
|
||||||
//add to the remapped list (if it was remapped, don't clear it!)
|
|
||||||
remapped.add(remapTarget);
|
|
||||||
|
|
||||||
remapTarget.save = slot;
|
|
||||||
try{
|
try{
|
||||||
Fi target = getSectorFile(remapTarget);
|
SectorInfo info = Core.settings.getJson(sector.planet.name + "-s-" + sector.id + "-info", SectorInfo.class, SectorInfo::new);
|
||||||
//move over save file
|
Fi tmpRemapFile = saveDirectory.child("remap_" + sector.planet.name + "_" + sector.id + "." + saveExtension);
|
||||||
slot.file.moveTo(target);
|
slot.file.moveTo(tmpRemapFile);
|
||||||
slot.file = target;
|
|
||||||
|
remaps.add(new Remap(slot, tmpRemapFile, sector, info, getSectorFile(remapTarget), remapTarget));
|
||||||
|
remapped.add(remapTarget);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
Log.err("Failed to move sector files when remapping: " + sector.id + " -> " + remapTarget.id, e);
|
Log.err("Failed to move sector files when remapping: " + sector.id + " -> " + remapTarget.id, e);
|
||||||
}
|
}
|
||||||
@@ -127,6 +141,7 @@ public class Saves{
|
|||||||
|
|
||||||
remapTarget.save = slot;
|
remapTarget.save = slot;
|
||||||
slot.meta.rules.sector = remapTarget;
|
slot.meta.rules.sector = remapTarget;
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
if(sector.save != null){
|
if(sector.save != null){
|
||||||
Log.warn("Sector @ has two corresponding saves: @ and @", sector, sector.save.file, slot.file);
|
Log.warn("Sector @ has two corresponding saves: @ and @", sector, sector.save.file, slot.file);
|
||||||
@@ -136,10 +151,27 @@ public class Saves{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var sector : infoToClear){
|
//process remaps later to allow swaps of sectors
|
||||||
if(!remapped.contains(sector)){
|
for(var remap : remaps){
|
||||||
sector.clearInfo();
|
var remapTarget = remap.destSector;
|
||||||
}
|
|
||||||
|
//overwrite the target sector's info with the save's info
|
||||||
|
Core.settings.putJson(remapTarget.planet.name + "-s-" + remapTarget.id + "-info", remap.sourceInfo);
|
||||||
|
remapTarget.loadInfo();
|
||||||
|
|
||||||
|
remapTarget.save = remap.slot;
|
||||||
|
try{
|
||||||
|
//move file from tmp directory back into the correct location
|
||||||
|
remap.sourceFile.moveTo(remap.destFile);
|
||||||
|
remap.slot.file = remap.destFile;
|
||||||
|
}catch(Exception e){
|
||||||
|
Log.err("Failed to move back sector files when remapping: " + remap.sourceSector.id + " -> " + remapTarget.id, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
//clear the info, assuming it wasn't a sector that got mapped to
|
||||||
|
if(!remapped.contains(remap.sourceSector)){
|
||||||
|
remap.sourceSector.clearInfo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
|||||||
float freq = 0.05f;
|
float freq = 0.05f;
|
||||||
if(position.dst(basePos) < 0.55f ?
|
if(position.dst(basePos) < 0.55f ?
|
||||||
|
|
||||||
dst*metalDstScl + Simplex.noise3d(seed, 3, 0.4, 5.5f, position.x, position.y + 200f, position.z)*0.08f + ((basePos.dst(position) + 0.00f) % freq < freq/2f ? 1f : 0f) * 0.07f < 0.08f/* || dst <= 0.0001f*/ :
|
dst*metalDstScl + Simplex.noise3d(seed + 1, 3, 0.4, 5.5f, position.x, position.y + 200f, position.z)*0.08f + ((basePos.dst(position) + 0.00f) % freq < freq/2f ? 1f : 0f) * 0.07f < 0.08f/* || dst <= 0.0001f*/ :
|
||||||
dst*metalDstScl + Simplex.noise3d(seed, 3, 0.4, 9f, position.x, position.y + 370f, position.z)*0.06f < 0.045){
|
dst*metalDstScl + Simplex.noise3d(seed, 3, 0.4, 9f, position.x, position.y + 370f, position.z)*0.06f < 0.045){
|
||||||
|
|
||||||
out.set(Team.crux.color)
|
out.set(Team.crux.color)
|
||||||
|
|||||||
Reference in New Issue
Block a user