Possible fix for #11758

This commit is contained in:
Anuken
2026-03-15 11:57:18 -04:00
parent ddfe45856f
commit 29b54f0a93
5 changed files with 20 additions and 5 deletions

View File

@@ -59,7 +59,7 @@ public class SectorSubmissions{
registerSerpuloSector(133, "wpx", "https://discord.com/channels/391020510269669376/1379926871227240770/1417920499761156126"); registerSerpuloSector(133, "wpx", "https://discord.com/channels/391020510269669376/1379926871227240770/1417920499761156126");
registerSerpuloSector(185, "quad", "https://discord.com/channels/391020510269669376/1379926892181983283/1419231958336016458"); registerSerpuloSector(185, "quad", "https://discord.com/channels/391020510269669376/1379926892181983283/1419231958336016458");
registerSerpuloSector(254, "wpx", "https://discord.com/channels/391020510269669376/1379928045577703424/1420456601667502193"); registerSerpuloSector(254, "wpx", "https://discord.com/channels/391020510269669376/1379928045577703424/1420456601667502193");
registerSerpuloSector(0, "iqtik123", "https://discord.com/channels/391020510269669376/1379926780860698784/1431356682834940115"); registerSerpuloSector(0, "iqtik123", "https://discord.com/channels/391020510269669376/1379926780860698784/1482671494268977341");
registerSerpuloSector(103, "enwyz", "https://discord.com/channels/391020510269669376/1379926839559979030/1429203869514207255"); registerSerpuloSector(103, "enwyz", "https://discord.com/channels/391020510269669376/1379926839559979030/1429203869514207255");
registerSerpuloSector(30, "cyan", "https://discord.com/channels/391020510269669376/1379926800854945823/1423932799647481910"); registerSerpuloSector(30, "cyan", "https://discord.com/channels/391020510269669376/1379926800854945823/1423932799647481910");
registerSerpuloSector(20, "Namero", "https://discord.com/channels/391020510269669376/1379926794114961634/1406768731471872162"); registerSerpuloSector(20, "Namero", "https://discord.com/channels/391020510269669376/1379926794114961634/1406768731471872162");

View File

@@ -286,8 +286,7 @@ public class DataPatcher{
} }
if(object instanceof Seq s){ if(object instanceof Seq s){
var copy = s.copy(); modifiedField(parentObject, parentField, s.copy());
reset(() -> s.set(copy));
assignValue(object, field, metadata, () -> s.get(i), val -> s.set(i, val), value, true); assignValue(object, field, metadata, () -> s.get(i), val -> s.set(i, val), value, true);
}else{ }else{
@@ -561,7 +560,7 @@ public class DataPatcher{
if(usedpatches.add(record)){ if(usedpatches.add(record)){
resetters.add(() -> { resetters.add(() -> {
try{ try{
record.field.set(record.target, record.value); record.field.set(record.target, value);
}catch(Exception e){ }catch(Exception e){
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@@ -570,6 +569,7 @@ public class DataPatcher{
}else if(target instanceof Seq<?> || target.getClass().isArray()){ }else if(target instanceof Seq<?> || target.getClass().isArray()){
int i = Integer.parseInt(field); int i = Integer.parseInt(field);
resetters.add(() -> { resetters.add(() -> {
if(target instanceof Seq seq){ if(target instanceof Seq seq){
seq.set(i, value); seq.set(i, value);
}else{ }else{

View File

@@ -149,11 +149,11 @@ public class DesktopLauncher extends ClientLauncher{
this.args = args; this.args = args;
if(useDiscord){ if(useDiscord){
Runtime.getRuntime().addShutdownHook(new Thread(DiscordRPC::close));
Threads.daemon(() -> { Threads.daemon(() -> {
try{ try{
DiscordRPC.connect(discordID); DiscordRPC.connect(discordID);
Log.info("Initialized Discord rich presence."); Log.info("Initialized Discord rich presence.");
Runtime.getRuntime().addShutdownHook(new Thread(DiscordRPC::close));
}catch(NoDiscordClientException none){ }catch(NoDiscordClientException none){
//don't log if no client is found //don't log if no client is found
useDiscord = false; useDiscord = false;

View File

@@ -578,6 +578,21 @@ public class PatcherTests{
assertEquals(UnitTypes.avert, ((Reconstructor)Blocks.shipRefabricator).upgrades.get(0)[1]); assertEquals(UnitTypes.avert, ((Reconstructor)Blocks.shipRefabricator).upgrades.get(0)[1]);
} }
@Test
void arrayMulti() throws Exception{
int size = UnitTypes.emanate.weapons.size;
Vars.state.patcher.apply(Seq.with("""
{"name":"Patch0","unit":{"emanate":{"weapons":{"0":{"type":"Weapon","name":"toxopid-cannon"}},"weapons.+":[{"name":"sei-launcher"}]}}}
"""));
assertEquals(UnitTypes.emanate.weapons.size, size + 1);
resetAfter();
assertEquals(UnitTypes.emanate.weapons.size, size);
}
@Test @Test
void customAttribute() throws Exception{ void customAttribute() throws Exception{
int amount = Attribute.all.length; int amount = Attribute.all.length;