Skip to content

Commit

Permalink
update: TransferAPI - PlayerSaveDTOService is go, added refactor of W…
Browse files Browse the repository at this point in the history
…eaponEntry getArmor(), getStructure(),

+ fixed bugs with some files missing their setDir() call for the new path-out config.
+
  • Loading branch information
Subject9x committed Jun 12, 2024
1 parent 1c82d6e commit e35234c
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 71 deletions.
2 changes: 1 addition & 1 deletion TransferApi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<name>Data Transfer API</name>
<description>wrapper library for core that exports/imports data to other modern formats.</description>
<packaging>jar</packaging>
<version>0.2.3</version>
<version>0.3.0</version>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,8 +59,8 @@ public int getBayId() {
return bayId;
}

public int getUnk1_uint8() {
return unk1_uint8;
public boolean getActiveFlag() {
return activeFlag;
}

public String getRank() {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -31,27 +25,11 @@ public WeaponLUT getItem() {
return item;
}

public short getHealthPercent() {
return healthPercent;
}

public MissileType getMissileType() {
return missileType;
}

public void setHardpoint(short hardpoint) {
this.hardpoint = 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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());
Expand All @@ -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<HercExternals, ShellHercPart>());
Expand Down Expand Up @@ -355,20 +355,17 @@ 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<Short, ShellWeaponEntry>());

for(int w=0; w < hercBay.getActiveSockets(); w++) {
HercHardpointDTO hardpointDTO = hercDTO.getWeapons()[w];
ShellWeaponEntry weapon = new ShellWeaponEntry();

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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down Expand Up @@ -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);
Expand All @@ -91,5 +93,4 @@ public DataFile fromDTO(TransferObject source) {

return trainHercs;
}

}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<jdk.version>1.8</jdk.version>
<es2.vol.version>0.0.4</es2.vol.version>
<es2.core.version>0.3.0</es2.core.version>
<es2.transfr.version>0.2.3</es2.transfr.version>
<es2.transfr.version>0.3.0</es2.transfr.version>
<es2.excavate.version>0.2.1</es2.excavate.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>9</maven.compiler.release>
Expand Down

0 comments on commit e35234c

Please sign in to comment.