Skip to content

Commit

Permalink
Update DRMS with nashorn fix and some other fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Retera committed Jul 2, 2022
1 parent 4d5d164 commit 7e3a23c
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 116 deletions.
4 changes: 1 addition & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ repositories {
mavenCentral()
}



allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
Expand All @@ -31,7 +29,7 @@ allprojects {
lwjglVersion = '2.9.3'
image4jVersion = '0.7'
rsyntaxtextareaVersion = '3.0.2'
nashornVersion = '15.2'
nashornVersion = '15.3'
}

repositories {
Expand Down
2 changes: 2 additions & 0 deletions craft3data/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

sourceCompatibility = 1.17

sourceSets.main.java.srcDirs = [ "src/" ]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public ByteBuffer readFileData(final String filePath) throws IOException {
* @param useMemoryMapping If memory mapped IO should be used to read file data.
* @throws IOException If an exception occurs while mounting.
*/
public WarcraftIIICASC(final Path installFolder, final boolean useMemoryMapping) throws IOException {
public WarcraftIIICASC(final Path installFolder, final boolean useMemoryMapping, String product) throws IOException {
final Path infoFilePath = installFolder.resolve(Info.BUILD_INFO_FILE_NAME);
buildInfo = new Info(ByteBuffer.wrap(Files.readAllBytes(infoFilePath)));

Expand All @@ -195,10 +195,13 @@ public WarcraftIIICASC(final Path installFolder, final boolean useMemoryMapping)
if (activeFiledIndex == -1) {
throw new MalformedCASCStructureException("build info contains no active field");
}
int productFieldIndex = buildInfo.getFieldIndex("Product");
int recordIndex = 0;
for (; recordIndex < recordCount; recordIndex += 1) {
if (Integer.parseInt(buildInfo.getField(recordIndex, activeFiledIndex)) == 1) {
break;
if(productFieldIndex == -1 || product == null || product.equals(buildInfo.getField(recordIndex, productFieldIndex))) {
break;
}
}
}
if (recordIndex == recordCount) {
Expand Down
3 changes: 2 additions & 1 deletion craft3data/src/com/hiveworkshop/wc3/casc/Cascket.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.hiveworkshop.json.JSONArray;
import com.hiveworkshop.json.JSONObject;
import com.hiveworkshop.json.JSONTokener;
import com.hiveworkshop.wc3.gui.datachooser.CascDataSource;
import com.hiveworkshop.wc3.mpq.Codebase;
import com.hiveworkshop.wc3.user.WindowsRegistry;

Expand Down Expand Up @@ -73,7 +74,7 @@ public Cascket(final String warcraft3InstallPath) {
// final var localIndexFile = Paths.get("C:\\Program Files (x86)\\StarCraft
// II\\SC2Data\\data\\0000000139.idx");
try {
warcraftIIICASC = new WarcraftIIICASC(Paths.get(warcraft3InstallPath), true);
warcraftIIICASC = new WarcraftIIICASC(Paths.get(warcraft3InstallPath), true, CascDataSource.Product.WARCRAFT_III.getKey());
rootFileSystem = warcraftIIICASC.getRootFileSystem();
listFile = rootFileSystem.enumerateFiles();
final String locale = predictLocalization();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class CascDataSource implements DataSource {
private List<String> listFile;
private Map<String, String> fileAliases;

public CascDataSource(final String warcraft3InstallPath, final String[] prefixes) {
public CascDataSource(final String warcraft3InstallPath, final String[] prefixes, Product product) {
this.prefixes = prefixes;
for (int i = 0; i < (prefixes.length / 2); i++) {
final String temp = prefixes[i];
Expand All @@ -36,7 +36,7 @@ public CascDataSource(final String warcraft3InstallPath, final String[] prefixes
}

try {
warcraftIIICASC = new WarcraftIIICASC(Paths.get(warcraft3InstallPath), true);
warcraftIIICASC = new WarcraftIIICASC(Paths.get(warcraft3InstallPath), true, product.key);
rootFileSystem = warcraftIIICASC.getRootFileSystem();
listFile = rootFileSystem.enumerateFiles();
fileAliases = new HashMap<>();
Expand Down Expand Up @@ -221,4 +221,16 @@ public void close() throws IOException {
warcraftIIICASC.close();
}

public static enum Product {
WARCRAFT_III("w3"), WARCRAFT_III_PUBLIC_TEST("w3t");
private String key;

private Product(String key) {
this.key = key;
}

public String getKey() {
return key;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

import com.hiveworkshop.wc3.gui.datachooser.CascDataSource.Product;

public class CascDataSourceDescriptor implements DataSourceDescriptor {
/**
Expand All @@ -11,20 +14,26 @@ public class CascDataSourceDescriptor implements DataSourceDescriptor {
private static final long serialVersionUID = 832549098549298820L;
private final String gameInstallPath;
private final List<String> prefixes;
private final CascDataSource.Product product;

public CascDataSourceDescriptor(final String gameInstallPath, final List<String> prefixes) {
public CascDataSourceDescriptor(final String gameInstallPath, final List<String> prefixes, CascDataSource.Product product) {
this.gameInstallPath = gameInstallPath;
this.prefixes = prefixes;
this.product = product;
}

@Override
public DataSource createDataSource() {
return new CascDataSource(gameInstallPath, prefixes.toArray(new String[prefixes.size()]));
CascDataSource.Product product = this.product;
if(product == null) {
product = Product.WARCRAFT_III;
}
return new CascDataSource(gameInstallPath, prefixes.toArray(new String[prefixes.size()]), product);
}

@Override
public String getDisplayName() {
return "CASC: " + gameInstallPath;
return "CASC: " + gameInstallPath + " ("+ product+")";
}

public void addPrefix(final String prefix) {
Expand Down Expand Up @@ -57,44 +66,28 @@ public List<String> getPrefixes() {

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = (prime * result) + ((gameInstallPath == null) ? 0 : gameInstallPath.hashCode());
result = (prime * result) + ((prefixes == null) ? 0 : prefixes.hashCode());
return result;
return Objects.hash(gameInstallPath, prefixes, product);
}

@Override
public boolean equals(final Object obj) {
if (this == obj) {
public boolean equals(Object obj) {
if (this == obj)
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
if (obj == null)
return false;
}
final CascDataSourceDescriptor other = (CascDataSourceDescriptor) obj;
if (gameInstallPath == null) {
if (other.gameInstallPath != null) {
return false;
}
} else if (!gameInstallPath.equals(other.gameInstallPath)) {
return false;
}
if (prefixes == null) {
if (other.prefixes != null) {
return false;
}
} else if (!prefixes.equals(other.prefixes)) {
if (getClass() != obj.getClass())
return false;
}
return true;
CascDataSourceDescriptor other = (CascDataSourceDescriptor) obj;
return Objects.equals(gameInstallPath, other.gameInstallPath) && Objects.equals(prefixes, other.prefixes)
&& product == other.product;
}

@Override
public DataSourceDescriptor duplicate() {
return new CascDataSourceDescriptor(gameInstallPath, new ArrayList<>(prefixes));
return new CascDataSourceDescriptor(gameInstallPath, new ArrayList<>(prefixes), product);
}

public CascDataSource.Product getProduct() {
return product;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import com.hiveworkshop.blizzard.casc.io.WarcraftIIICASC.FileSystem;
import com.hiveworkshop.nio.ByteBufferInputStream;
import com.hiveworkshop.wc3.gui.ExceptionPopup;
import com.hiveworkshop.wc3.gui.datachooser.CascDataSource.Product;
import com.hiveworkshop.wc3.gui.icons.RMSIcons;
import com.hiveworkshop.wc3.user.WindowsRegistry;
import com.jtattoo.plaf.acryl.AcrylLookAndFeel;
Expand Down Expand Up @@ -322,8 +323,17 @@ public void actionPerformed(final ActionEvent e) {
if (result == JFileChooser.APPROVE_OPTION) {
final File selectedFile = fileChooser.getSelectedFile();
if (selectedFile != null) {
CascDataSource.Product product = Product.WARCRAFT_III;
int optionChoice = JOptionPane.showOptionDialog(DataSourceChooserPanel.this, "Choose version", "Version", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, new Object[] {"Warcraft III", "Warcraft III Public Test"}, "Warcraft III Public Test");
if(optionChoice < 0 || optionChoice > 1) {
return;
}
if(optionChoice == 1) {
product = Product.WARCRAFT_III_PUBLIC_TEST;
}

dataSourceDescriptors
.add(new CascDataSourceDescriptor(selectedFile.getPath(), new ArrayList<String>()));
.add(new CascDataSourceDescriptor(selectedFile.getPath(), new ArrayList<String>(), product));
reloadTree();
}
}
Expand Down Expand Up @@ -530,8 +540,18 @@ private void enterHDMode() {

private void addWarcraft3Installation(final Path installPathPath, final boolean allowPopup) {
if (Files.exists(installPathPath.resolve("Data/indices"))) {
CascDataSource.Product product = Product.WARCRAFT_III;
if(allowPopup) {
int optionChoice = JOptionPane.showOptionDialog(this, "Choose version", "Version", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, new Object[] {"Warcraft III", "Warcraft III Public Test"}, "Warcraft III Public Test");
if(optionChoice < 0 || optionChoice > 1) {
return;
}
if(optionChoice == 1) {
product = Product.WARCRAFT_III_PUBLIC_TEST;
}
}
final CascDataSourceDescriptor dataSourceDesc = new CascDataSourceDescriptor(installPathPath.toString(),
new ArrayList<String>());
new ArrayList<String>(), product);
dataSourceDescriptors.add(dataSourceDesc);
addDefaultCASCPrefixes(installPathPath, dataSourceDesc, allowPopup);
} else {
Expand Down Expand Up @@ -660,7 +680,7 @@ public static void main(final String[] args) {
private void addSpecificCASCPrefix(final Path installPathPath, final CascDataSourceDescriptor dataSourceDesc) {
// It's CASC. Now the question: what prefixes do we use?
try {
final WarcraftIIICASC tempCascReader = new WarcraftIIICASC(installPathPath, true);
final WarcraftIIICASC tempCascReader = new WarcraftIIICASC(installPathPath, true, dataSourceDesc.getProduct().getKey());
final DefaultComboBoxModel<String> prefixes = new DefaultComboBoxModel<String>();
try {
final FileSystem rootFileSystem = tempCascReader.getRootFileSystem();
Expand Down Expand Up @@ -712,7 +732,7 @@ private void addDefaultCASCPrefixes(final Path installPathPath, final CascDataSo
}
}
try {
final WarcraftIIICASC tempCascReader = new WarcraftIIICASC(installPathPath, true);
final WarcraftIIICASC tempCascReader = new WarcraftIIICASC(installPathPath, true, dataSourceDesc.getProduct().getKey());
try {
final String tags = tempCascReader.getBuildInfo().getField(tempCascReader.getActiveRecordIndex(),
"Tags");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class GetCascLanguageList {
public static void main(final String[] args) {
try {
final WarcraftIIICASC casc = new WarcraftIIICASC(Paths.get("C:/Program Files/Warcraft III"), true);
final WarcraftIIICASC casc = new WarcraftIIICASC(Paths.get("C:/Program Files/Warcraft III"), true, CascDataSource.Product.WARCRAFT_III.getKey());
final FileSystem rootFileSystem = casc.getRootFileSystem();
if (rootFileSystem.isFile("index") && rootFileSystem.isFileAvailable("index")) {
final ByteBuffer buffer = rootFileSystem.readFileData("index");
Expand Down
19 changes: 12 additions & 7 deletions craft3data/src/com/hiveworkshop/wc3/util/ModelUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ public static Mesh createBox(final Vertex max, final Vertex min, final int lengt
* @param max
* @param min
*/
public static void createGroundPlane(final EditableModel model, final Vertex max, final Vertex min, final int segments) {
public static void createGroundPlane(final EditableModel model, final Vertex max, final Vertex min,
final int segments) {
final Geoset geoset = new Geoset();
geoset.setMaterial(new Material(new Layer("None", new Bitmap("textures\\white.blp"))));

Expand All @@ -308,31 +309,35 @@ public static void createGroundPlane(final EditableModel model, final Vertex max
}

public static boolean isLevelOfDetailSupported(final int formatVersion) {
return (formatVersion == 900) || (formatVersion == 1000);
return (formatVersion == 900) || (formatVersion == 1000) || (formatVersion == 1100);
}

public static boolean isShaderStringSupported(final int formatVersion) {
return (formatVersion == 900) || (formatVersion == 1000);
}

public static boolean isTangentAndSkinSupported(final int formatVersion) {
return (formatVersion == 900) || (formatVersion == 1000);
return (formatVersion == 900) || (formatVersion == 1000) || (formatVersion == 1100);
}

public static boolean isBindPoseSupported(final int formatVersion) {
return (formatVersion == 900) || (formatVersion == 1000);
return (formatVersion == 900) || (formatVersion == 1000) || (formatVersion == 1100);
}

public static boolean isEmissiveLayerSupported(final int formatVersion) {
return (formatVersion == 900) || (formatVersion == 1000);
return (formatVersion == 900) || (formatVersion == 1000) || (formatVersion == 1100);
}

public static boolean isFresnelColorLayerSupported(final int formatVersion) {
return formatVersion == 1000;
return (formatVersion == 1000) || (formatVersion == 1100);
}

public static boolean isCornSupported(final int formatVersion) {
return (formatVersion == 900) || (formatVersion == 1000);
return (formatVersion == 900) || (formatVersion == 1000) || (formatVersion == 1100);
}

public static boolean isCombinedHDLayerSupported(final int formatVersion) {
return formatVersion == 1100;
}

private ModelUtils() {
Expand Down
2 changes: 2 additions & 0 deletions craft3editor/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

sourceCompatibility = 1.17

sourceSets.main.java.srcDirs = [ "src/" ]


Expand Down
2 changes: 2 additions & 0 deletions matrixeater/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ plugins {
id 'org.beryx.runtime' version '1.12.5'
}

sourceCompatibility = 1.17

[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

sourceSets.main.java.srcDirs = [ "src/" ]
Expand Down
Loading

0 comments on commit 7e3a23c

Please sign in to comment.