This commit is contained in:
Anuken
2025-07-21 02:43:11 -04:00
3 changed files with 121 additions and 107 deletions

View File

@@ -103,8 +103,12 @@ public class LVar{
public void set(LVar other){
isobj = other.isobj;
objval = other.objval;
numval = other.numval;
// Setting a non-numeric value to @counter must preserve its numeric field
if(isobj){
objval = other.objval;
}else{
numval = other.numval;
}
}
public static boolean invalid(double d){

View File

@@ -46,6 +46,7 @@ public class ResearchDialog extends BaseDialog{
public ItemSeq items;
private final Seq<Planet> rootPlanets = new Seq<>(false, 4);
private boolean showTechSelect;
private boolean needsRebuild;
@@ -214,21 +215,30 @@ public class ResearchDialog extends BaseDialog{
ObjectMap<Sector, ItemSeq> cache = new ObjectMap<>();
{
//first, find a planet associated with the current tech tree
Planet rootPlanet = lastNode.planet != null ? lastNode.planet : content.planets().find(p -> p.techTree == lastNode);
//first, find a planets associated with the current tech tree
rootPlanets.clear();
for(var planet : content.planets()){
if(planet.techTree == lastNode){
rootPlanets.add(planet);
}
}
//if there is no root, fall back to serpulo
if(rootPlanet == null) rootPlanet = Planets.serpulo;
if(rootPlanets.size == 0){
rootPlanets.add(Planets.serpulo);
}
//add global counts of each sector
for(Sector sector : rootPlanet.sectors){
if(sector.hasBase()){
ItemSeq cached = sector.items();
cache.put(sector, cached);
cached.each((item, amount) -> {
values[item.id] += Math.max(amount, 0);
total += Math.max(amount, 0);
});
for(Planet planet : rootPlanets){
for(Sector sector : planet.sectors){
if(sector.hasBase()){
ItemSeq cached = sector.items();
cache.put(sector, cached);
cached.each((item, amount) -> {
values[item.id] += Math.max(amount, 0);
total += Math.max(amount, 0);
});
}
}
}
}