From e35234c15bf050bc043991747c9c93d5c8a68b5c Mon Sep 17 00:00:00 2001 From: subject9x Date: Tue, 11 Jun 2024 20:19:56 -0400 Subject: [PATCH] update: TransferAPI - PlayerSaveDTOService is go, added refactor of WeaponEntry getArmor(), getStructure(), + fixed bugs with some files missing their setDir() call for the new path-out config. + --- TransferApi/pom.xml | 2 +- .../file/sys/sav/PlayerSavePilotDataDTO.java | 12 +++--- .../dto/struct/shell/HercHardpointDTO.java | 30 ++------------- .../dto/struct/sys/WeaponEntryDTO.java | 29 ++++++++++----- .../svc/impl/PlayerSaveDTOServiceImpl.java | 37 +++++++++---------- .../impl/dbsim/FlightModelDTOServiceImpl.java | 1 + .../impl/dbsim/GunLayoutDTOServiceImpl.java | 1 + .../impl/shell/InitHercDTOServiceImpl.java | 5 ++- .../shell/StartingHercsDTOServiceImpl.java | 5 ++- .../shell/TrainingHercsDTOServiceImpl.java | 9 +++-- pom.xml | 2 +- 11 files changed, 62 insertions(+), 71 deletions(-) diff --git a/TransferApi/pom.xml b/TransferApi/pom.xml index 42df371..982fdaf 100644 --- a/TransferApi/pom.xml +++ b/TransferApi/pom.xml @@ -9,7 +9,7 @@ Data Transfer API wrapper library for core that exports/imports data to other modern formats. jar - 0.2.3 + 0.3.0 diff --git a/TransferApi/src/main/java/org/hercworks/transfer/dto/file/sys/sav/PlayerSavePilotDataDTO.java b/TransferApi/src/main/java/org/hercworks/transfer/dto/file/sys/sav/PlayerSavePilotDataDTO.java index 2cce3f2..17ae416 100644 --- a/TransferApi/src/main/java/org/hercworks/transfer/dto/file/sys/sav/PlayerSavePilotDataDTO.java +++ b/TransferApi/src/main/java/org/hercworks/transfer/dto/file/sys/sav/PlayerSavePilotDataDTO.java @@ -18,8 +18,8 @@ public class PlayerSavePilotDataDTO { @JsonProperty(value = "assigned_herc_bay", index = 2) private int bayId; - @JsonProperty(value = "unk1_uint8", index = 3) - private int unk1_uint8; + @JsonProperty(value = "active", index = 3) + private boolean activeFlag; @JsonProperty(value = "rank", index = 4) private String rank; @@ -59,8 +59,8 @@ public int getBayId() { return bayId; } - public int getUnk1_uint8() { - return unk1_uint8; + public boolean getActiveFlag() { + return activeFlag; } public String getRank() { @@ -107,8 +107,8 @@ public void setBayId(int bayId) { this.bayId = bayId; } - public void setUnk1_uint8(int unk1_uint8) { - this.unk1_uint8 = unk1_uint8; + public void setActiveFlag(boolean activeFlag) { + this.activeFlag = activeFlag; } public void setRank(String rank) { diff --git a/TransferApi/src/main/java/org/hercworks/transfer/dto/struct/shell/HercHardpointDTO.java b/TransferApi/src/main/java/org/hercworks/transfer/dto/struct/shell/HercHardpointDTO.java index f88fc83..5591918 100644 --- a/TransferApi/src/main/java/org/hercworks/transfer/dto/struct/shell/HercHardpointDTO.java +++ b/TransferApi/src/main/java/org/hercworks/transfer/dto/struct/shell/HercHardpointDTO.java @@ -1,26 +1,20 @@ package org.hercworks.transfer.dto.struct.shell; -import org.hercworks.core.data.struct.MissileType; import org.hercworks.core.data.struct.WeaponLUT; +import org.hercworks.transfer.dto.struct.sys.WeaponEntryDTO; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("") -public class HercHardpointDTO { +public class HercHardpointDTO extends WeaponEntryDTO { - @JsonProperty(index = 1) + @JsonProperty(index = 0) private short hardpoint; - @JsonProperty(index = 2) + @JsonProperty(index = 1) private WeaponLUT item; - @JsonProperty(value="hp_perc", index = 3) - private short healthPercent; - - @JsonProperty(value = "msl_num", index = 4) - private MissileType missileType; - public HercHardpointDTO() {} public short getHardpoint() { @@ -31,14 +25,6 @@ public WeaponLUT getItem() { return item; } - public short getHealthPercent() { - return healthPercent; - } - - public MissileType getMissileType() { - return missileType; - } - public void setHardpoint(short hardpoint) { this.hardpoint = hardpoint; } @@ -46,12 +32,4 @@ public void setHardpoint(short hardpoint) { public void setItem(WeaponLUT item) { this.item = item; } - - public void setHealthPercent(short healthPercent) { - this.healthPercent = healthPercent; - } - - public void setMissileType(MissileType missileType) { - this.missileType = missileType; - } } diff --git a/TransferApi/src/main/java/org/hercworks/transfer/dto/struct/sys/WeaponEntryDTO.java b/TransferApi/src/main/java/org/hercworks/transfer/dto/struct/sys/WeaponEntryDTO.java index 86994a7..663e40d 100644 --- a/TransferApi/src/main/java/org/hercworks/transfer/dto/struct/sys/WeaponEntryDTO.java +++ b/TransferApi/src/main/java/org/hercworks/transfer/dto/struct/sys/WeaponEntryDTO.java @@ -8,24 +8,35 @@ @JsonRootName("") public class WeaponEntryDTO { - @JsonProperty(value = "health", index = 0) - private int health = 100; + @JsonProperty(value = "armor", index = 2) + private int armor; + + @JsonProperty(value = "structure", index = 3) + private int structure; - @JsonProperty(value = "missile_type", index = 1) + @JsonProperty(value = "missile_type", index = 4) private MissileType missileType; public WeaponEntryDTO() {} - public int getHealth() { - return health; + public int getArmor() { + return armor; } - public MissileType getMissileType() { - return missileType; + public int getStructure() { + return structure; + } + + public void setArmor(int armor) { + this.armor = armor; } - public void setHealth(int health) { - this.health = health; + public void setStructure(int structure) { + this.structure = structure; + } + + public MissileType getMissileType() { + return missileType; } public void setMissileType(MissileType missileType) { diff --git a/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/PlayerSaveDTOServiceImpl.java b/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/PlayerSaveDTOServiceImpl.java index dc808f5..941e4e1 100644 --- a/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/PlayerSaveDTOServiceImpl.java +++ b/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/PlayerSaveDTOServiceImpl.java @@ -47,10 +47,11 @@ public TransferObject convertToDTO(DataFile source) { for(int q=0; q < itemDTO.getData().length; q++) { ShellWeaponEntry entry = item.getData()[q]; WeaponEntryDTO weapon = new WeaponEntryDTO(); - + + weapon.setArmor(entry.getHealthArmor()); + weapon.setStructure(entry.getHealthInteral()); weapon.setMissileType(entry.getMissileType()); - //TODO - I'm not sure why weapons get 2 64 00 (100) percentage values here. - weapon.setHealth((entry.getHealth()[0] + entry.getHealth()[1]) / 2); + itemDTO.getData()[q] = weapon; } @@ -112,7 +113,7 @@ private PlayerSavePilotDataDTO exportPilotData(PlayerSavePilotDataDTO pilotDTO, pilotDTO.setSquadmateId(data.getSquadmateId()); pilotDTO.setName(data.getName()); pilotDTO.setBayId(data.getBayId()); - pilotDTO.setUnk1_uint8(data.getUnk1_uint8()); + pilotDTO.setActiveFlag(data.getActive()==(byte)1 ? true : false); pilotDTO.setRank(data.getRank().getLabel()); pilotDTO.setCrewRowNum(data.getCrewRowNum()); pilotDTO.setUnk2_uint16(data.getUnk2_uint16()); @@ -166,13 +167,12 @@ private HercBayEntryDTO exportHercBayEntry(HercBayEntryDTO hercDTO, HercBayEntry int idx = 0; //harpdoint list actually can be any order. for(Short wepSlot : entry.getWeapons().keySet()) { ShellWeaponEntry weapon = entry.getWeapons().get(wepSlot); - HercHardpointDTO wpnDTO = new HercHardpointDTO(); - wpnDTO.setHardpoint(wepSlot); - short hp = (short)((weapon.getHealth()[0] + weapon.getHealth()[1]) /2); - wpnDTO.setHealthPercent(hp); + wpnDTO.setHardpoint(wepSlot); wpnDTO.setItem(weapon.getId()); + wpnDTO.setArmor(weapon.getHealthArmor()); + wpnDTO.setStructure(weapon.getHealthInteral()); wpnDTO.setMissileType(weapon.getMissileType()); hercDTO.getWeapons()[idx] = wpnDTO; @@ -217,11 +217,8 @@ public DataFile fromDTO(TransferObject source) { entryStock.setId(weapon); entryStock.setMissileType(dtoStock.getMissileType()); entryStock.setNameId((short)weapon.getId()); - - // new short[2]; - int half = dtoStock.getHealth() / 2; - int half2 = dtoStock.getHealth() - half; - entryStock.setHealth(new short[] {(short)half, (short)half2}); + entryStock.setHealthArmor((short)dtoStock.getArmor()); + entryStock.setHealthInternal((short)dtoStock.getStructure()); entry.getData()[q] = entryStock; } @@ -300,7 +297,9 @@ private PilotEntry importPilotData(PilotEntry pilot, PlayerSavePilotDataDTO dtoP pilot.setSquadmateId((short)dtoPilot.getSquadmateId()); pilot.setName(dtoPilot.getName()); pilot.setBayId((short)dtoPilot.getBayId()); - pilot.setUnk1_uint8((byte)dtoPilot.getUnk1_uint8()); + + pilot.setActive((byte)(dtoPilot.getActiveFlag() ? 1 : 0)); + pilot.setRank(PilotRank.getByName(dtoPilot.getRank())); pilot.setCrewRowNum((short)dtoPilot.getCrewRowNum()); pilot.setUnk2_uint16((short)dtoPilot.getUnk2_uint16()); @@ -323,6 +322,7 @@ private PilotEntry importPilotData(PilotEntry pilot, PlayerSavePilotDataDTO dtoP private HercBayEntry importHercBayEntry(HercBayEntry hercBay, HercBayEntryDTO hercDTO) { hercBay.setId(HercLUT.getByName(hercDTO.getId())); + hercBay.setNameId(hercBay.getId().getId()); hercBay.setHardpointMax(hercBay.getId().getHardpointMax()); hercBay.setHealthExternals(new HashMap()); @@ -355,8 +355,8 @@ private HercBayEntry importHercBayEntry(HercBayEntry hercBay, HercBayEntryDTO he hercBay.setBuildPercent((short)hercDTO.getBuildPercent()); hercBay.setBuildStepNum((short)hercDTO.getBuildStepNum()); hercBay.setActiveSockets((short)hercDTO.getWeapons().length); - hercBay.setWeapons(new HashMap()); + for(int w=0; w < hercBay.getActiveSockets(); w++) { HercHardpointDTO hardpointDTO = hercDTO.getWeapons()[w]; ShellWeaponEntry weapon = new ShellWeaponEntry(); @@ -364,11 +364,8 @@ private HercBayEntry importHercBayEntry(HercBayEntry hercBay, HercBayEntryDTO he weapon.setId(hardpointDTO.getItem()); weapon.setMissileType(hardpointDTO.getMissileType()); weapon.setNameId((short)hardpointDTO.getItem().getId()); - - short perc = (short)(hardpointDTO.getHealthPercent() / 2); - short half = (short)(hardpointDTO.getHealthPercent() - perc); - - weapon.setHealth(new short[] {perc, half}); + weapon.setHealthArmor((short)hardpointDTO.getArmor()); + weapon.setHealthInternal((short)hardpointDTO.getStructure()); hercBay.getWeapons().put((short)w, weapon); } diff --git a/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/dbsim/FlightModelDTOServiceImpl.java b/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/dbsim/FlightModelDTOServiceImpl.java index 5ad694a..a73f063 100644 --- a/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/dbsim/FlightModelDTOServiceImpl.java +++ b/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/dbsim/FlightModelDTOServiceImpl.java @@ -45,6 +45,7 @@ public DataFile fromDTO(TransferObject source) { FlightModel fm = new FlightModel(); fm.setExt(FileType.FM); + fm.setDir(FileType.FM); FlightModelDTO dto = (FlightModelDTO)source; diff --git a/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/dbsim/GunLayoutDTOServiceImpl.java b/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/dbsim/GunLayoutDTOServiceImpl.java index fe634bc..4af2783 100644 --- a/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/dbsim/GunLayoutDTOServiceImpl.java +++ b/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/dbsim/GunLayoutDTOServiceImpl.java @@ -54,6 +54,7 @@ public DataFile fromDTO(TransferObject source) { GunLayout data = new GunLayout(); data.setExt(FileType.GL); + data.setDir(FileType.GL); data.setTotalGuns((short)dto.getHardpoints().length); diff --git a/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/shell/InitHercDTOServiceImpl.java b/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/shell/InitHercDTOServiceImpl.java index 729b0f1..7b7388a 100644 --- a/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/shell/InitHercDTOServiceImpl.java +++ b/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/shell/InitHercDTOServiceImpl.java @@ -34,7 +34,8 @@ public TransferObject convertToDTO(DataFile source) { hardpoint.setHardpoint(id); hardpoint.setItem(WeaponLUT.getById(entry.getItemId())); - hardpoint.setHealthPercent(entry.getHealthPercent()); + hardpoint.setArmor(entry.getHealthPercent()); + hardpoint.setStructure(entry.getHealthPercent()); hardpoint.setMissileType(entry.getMissileType()); hardpoints[idx] = hardpoint; @@ -65,7 +66,7 @@ public DataFile fromDTO(TransferObject source) { for(HercHardpointDTO slotDTO : srcData.getHardpoints()) { UiWeaponEntry entry = new UiWeaponEntry(); entry.setItemId((short)slotDTO.getItem().getId()); - entry.setHealthPercent(slotDTO.getHealthPercent()); + entry.setHealthPercent((short)slotDTO.getArmor()); entry.setMissileType(slotDTO.getMissileType()); herc.getHardpoints().put(slotDTO.getHardpoint(), entry); } diff --git a/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/shell/StartingHercsDTOServiceImpl.java b/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/shell/StartingHercsDTOServiceImpl.java index 5d9c220..b24b60a 100644 --- a/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/shell/StartingHercsDTOServiceImpl.java +++ b/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/shell/StartingHercsDTOServiceImpl.java @@ -47,8 +47,9 @@ public TransferObject convertToDTO(DataFile source) { slot.setHardpoint((short)h); slot.setItem(WeaponLUT.getById(item.getItemId())); - slot.setHealthPercent(item.getHealthPercent()); + slot.setArmor(item.getHealthPercent()); slot.setMissileType(item.getMissileType()); + hardpoints[h] = slot; } hercDTO.setHardpoints(hardpoints); @@ -85,7 +86,7 @@ public DataFile fromDTO(TransferObject source) { UiWeaponEntry item = new UiWeaponEntry(); item.setItemId((short)dtoSlot.getItem().getId()); - item.setHealthPercent(dtoSlot.getHealthPercent()); + item.setHealthPercent((short)dtoSlot.getArmor()); item.setMissileType(dtoSlot.getMissileType()); hercsEntry.getHerc().getHardpoints().put((short)h, item); diff --git a/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/shell/TrainingHercsDTOServiceImpl.java b/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/shell/TrainingHercsDTOServiceImpl.java index 5ad54f9..8e2a712 100644 --- a/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/shell/TrainingHercsDTOServiceImpl.java +++ b/TransferApi/src/main/java/org/hercworks/transfer/svc/impl/shell/TrainingHercsDTOServiceImpl.java @@ -43,8 +43,9 @@ public TransferObject convertToDTO(DataFile source) { dtoSlot.setHardpoint(id); dtoSlot.setItem(WeaponLUT.getById(item.getItemId())); - dtoSlot.setHealthPercent(item.getHealthPercent()); + dtoSlot.setArmor(item.getHealthPercent()); dtoSlot.setMissileType(item.getMissileType()); + hardpoints[h] = dtoSlot; h++; } @@ -79,8 +80,9 @@ public DataFile fromDTO(TransferObject source) { UiWeaponEntry item = new UiWeaponEntry(); item.setItemId((short)slot.getItem().getId()); - item.setHealthPercent(slot.getHealthPercent()); + item.setHealthPercent((short)slot.getArmor()); item.setMissileType(slot.getMissileType()); + hardpoints.put((short)h, item); } herc.setHardpoints(hardpoints); @@ -91,5 +93,4 @@ public DataFile fromDTO(TransferObject source) { return trainHercs; } - -} +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index ac97e3e..3f3bfd3 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ 1.8 0.0.4 0.3.0 - 0.2.3 + 0.3.0 0.2.1 UTF-8 9