Potential sector data carry-over fix

This commit is contained in:
Anuken 2025-09-19 23:09:37 -04:00
parent 71fbfffaec
commit 7c57211807
5 changed files with 18 additions and 33 deletions

View file

@ -434,19 +434,10 @@ public class Control implements ApplicationListener, Loadable{
//if there is no base, simulate a new game and place the right loadout at the spawn position
if(state.rules.defaultTeam.cores().isEmpty() || hadNoCore){
if(sector.planet.clearSectorOnLose){
//don't carry over the spawn position and plans if the sector preset name or map size changed
if(sector.planet.clearSectorOnLose || sector.info.spawnPosition == 0 || !sector.info.sectorDataMatches(sector)){
playNewSector(origin, sector, reloader);
}else{
//no spawn set -> delete the sector save
if(sector.info.spawnPosition == 0){
//delete old save
sector.save = null;
slot.delete();
//play again
playSector(origin, sector, reloader);
return;
}
int spawnPos = sector.info.spawnPosition;
//set spawn for sector damage to use

View file

@ -269,26 +269,6 @@ public class MapEditor{
editor.flushOp();
}
public void addFloorCliffs(){
for(Tile tile : world.tiles){
if(!tile.floor().hasSurface() || tile.block() == Blocks.cliff) continue;
int rotation = 0;
for(int i = 0; i < 8; i++){
Tile other = world.tiles.get(tile.x + Geometry.d8[i].x, tile.y + Geometry.d8[i].y);
if(other != null && !other.floor().hasSurface()){
rotation |= (1 << i);
}
}
if(rotation != 0){
tile.setBlock(Blocks.cliff);
}
tile.data = (byte)rotation;
}
}
public void drawCircle(int x, int y, Cons<Tile> drawer){
int clamped = (int)brushSize;
for(int rx = -clamped; rx <= clamped; rx++){

View file

@ -707,7 +707,6 @@ public class MapEditorDialog extends Dialog implements Disposable{
}
}).margin(0).left().growY();
cont.table(t -> t.add(view).grow()).grow();
cont.table(this::addBlockSelection).right().growY();

View file

@ -41,6 +41,10 @@ public class SectorInfo{
public int storageCapacity = 0;
/** Whether a core is available here. */
public boolean hasCore = true;
/** Last sector preset name set to this sector. */
public @Nullable String lastPresetName;
/** Last size of the map. */
public int lastWidth, lastHeight;
/** Whether this sector was ever fully captured. */
public boolean wasCaptured = false;
/** Sector that was launched from. */
@ -102,6 +106,14 @@ public class SectorInfo{
/** Core item storage input/output deltas. */
private @Nullable transient int[] productionDeltas;
/** @return whether the sector was last saved with the same preset. if false, this means the preset changed, and thus the spawn/plan data should be discarded. */
public boolean sectorDataMatches(Sector sector){
if(sector.preset != null && (sector.preset.generator.map.width != lastWidth || sector.preset.generator.map.width != lastHeight)){
return false;
}
return Structs.eq(sector.preset == null ? null : sector.preset.name, lastPresetName);
}
/** Handles core item changes. */
public void handleCoreItem(Item item, int amount){
if(coreDeltas == null) coreDeltas = new int[content.items().size];
@ -223,6 +235,9 @@ public class SectorInfo{
wavesPassed = 0;
damage = 0;
hasSpawns = spawner.countSpawns() > 0;
lastPresetName = sector.preset == null ? null : sector.preset.name;
lastWidth = world.width();
lastHeight = world.height();
lightCoverage = 0f;
for(var build : state.rules.defaultTeam.data().buildings){

View file

@ -996,8 +996,8 @@ public class MobileInput extends InputHandler implements GestureListener{
}
targetPos.set(Core.camera.position);
float attractDst = 15f;
float attractDst = 15f;
float speed = unit.speed();
float range = unit.hasWeapons() ? unit.range() : 0f;
float bulletSpeed = unit.hasWeapons() ? type.weapons.first().bullet.speed : 0f;