Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
Argent77 committed May 1, 2021
2 parents 5263258 + 6d0d1a5 commit 7155dba
Show file tree
Hide file tree
Showing 392 changed files with 52,954 additions and 4,109 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/Argent77/NearInfinity?color=darkred&include_prereleases&label=latest%20release)](https://GitHub.com/Argent77/NearInfinity/releases/latest)
[![GitHub release date (latest by date)](https://img.shields.io/github/release-date/Argent77/NearInfinity?color=gold)](https://GitHub.com/Argent77/NearInfinity/releases/latest)
[![Github downloads (total)](https://img.shields.io/github/downloads/Argent77/NearInfinity/total.svg?color=blueviolet)](https://GitHub.com/Argent77/NearInfinity/releases)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/b5d10ca2684c4e30b6632e34584f1241)](https://www.codacy.com/manual/Mingun/NearInfinity)

# Near Infinity
Expand Down
3 changes: 2 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@

<jar destfile="${jar.file}"
basedir="${build.path}"
includes="**/*">
includes="**/*"
level="9">
<zipgroupfileset dir="." includes="${jorbis.file}"/>
<zipgroupfileset dir="." includes="${rsyntaxtextarea.file}"/>
<zipgroupfileset dir="." includes="${jhexview.file}"/>
Expand Down
17 changes: 16 additions & 1 deletion src/org/infinity/NearInfinity.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -91,6 +92,9 @@
import org.infinity.resource.Viewable;
import org.infinity.resource.ViewableContainer;
import org.infinity.resource.bcs.Signatures;
import org.infinity.resource.cre.decoder.util.ItemInfo;
import org.infinity.resource.cre.decoder.util.SpriteUtils;
import org.infinity.resource.graphics.ColorConvert;
import org.infinity.resource.key.FileResourceEntry;
import org.infinity.resource.key.ResourceEntry;
import org.infinity.resource.key.ResourceTreeModel;
Expand Down Expand Up @@ -208,6 +212,8 @@ public static void printHelp(String jarFile)
System.out.println("\nOptions:");
System.out.println(" -v, -version Display version information.");
System.out.println(" -h, -help Display this help.");
System.out.println(" -i Disable support of case-sensitive filesystems");
System.out.println(" (temporary workaround for buggy file access on Linux systems)");
System.out.println(" -t type Force the current or specified game to be of");
System.out.println(" specific type. (Use with care!)");
System.out.println(" Supported game types:");
Expand All @@ -232,6 +238,12 @@ public static void advanceProgress(String note)

public static void main(String args[])
{
// TODO: remove option when detection of case-sensitive filesystems has been fixed
if (Arrays.asList(args).contains("-i")) {
// must be set before first file access through FileManager class
Profile.addProperty(Profile.Key.GET_GLOBAL_FILE_CASE_CHECK, Profile.Type.BOOLEAN, Boolean.valueOf(false));
}

Profile.Game forcedGame = null;
Path gameOverride = null;

Expand Down Expand Up @@ -1043,6 +1055,9 @@ private static void clearCache(boolean refreshOnly)
StringTable.resetAll();
ProRef.clearCache();
Signatures.clearCache();
ColorConvert.clearCache();
SpriteUtils.clearCache();
ItemInfo.clearCache();
}

private static void showProgress(String msg, int max)
Expand Down Expand Up @@ -1105,7 +1120,7 @@ private void storePreferences()

private void setAppIcon()
{
List<Image> list = new ArrayList<Image>();
List<Image> list = new ArrayList<>();
for (int i = 4; i < 8; i++) {
list.add(Icons.getImage(String.format("App%d.png", 1 << i)));
}
Expand Down
2 changes: 0 additions & 2 deletions src/org/infinity/check/AbstractChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ protected boolean runCheck(List<ResourceEntry> entries)
return runSearch("Checking", entries);
}

//<editor-fold defaultstate="collapsed" desc="ActionListener">
@Override
public void actionPerformed(ActionEvent event)
{
Expand All @@ -99,5 +98,4 @@ else if (event.getSource() == bCancel) {
settingsWindow.setVisible(false);
}
}
//</editor-fold>
}
3 changes: 2 additions & 1 deletion src/org/infinity/check/CreInvChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import org.infinity.NearInfinity;
import org.infinity.datatype.DecNumber;
import org.infinity.datatype.IsNumeric;
import org.infinity.gui.BrowserMenuBar;
import org.infinity.gui.Center;
import org.infinity.gui.ChildFrame;
Expand Down Expand Up @@ -199,7 +200,7 @@ private void checkCreature(CreResource cre)
{
final List<Item> items = new ArrayList<>();
final List<DecNumber> slots = new ArrayList<>();
final DecNumber slots_offset = (DecNumber)cre.getAttribute(CreResource.CRE_OFFSET_ITEM_SLOTS);
final IsNumeric slots_offset = (IsNumeric)cre.getAttribute(CreResource.CRE_OFFSET_ITEM_SLOTS);
for (final StructEntry entry : cre.getFields()) {
if (entry instanceof Item) {
items.add((Item)entry);
Expand Down
7 changes: 3 additions & 4 deletions src/org/infinity/check/EffectsIndexChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
package org.infinity.check;

import org.infinity.NearInfinity;
import org.infinity.datatype.DecNumber;
import org.infinity.datatype.SectionCount;
import org.infinity.datatype.IsNumeric;
import org.infinity.resource.AbstractAbility;
import org.infinity.resource.AbstractStruct;
import org.infinity.resource.Resource;
Expand Down Expand Up @@ -56,12 +55,12 @@ protected Runnable newWorker(ResourceEntry entry)

private void search(ResourceEntry entry, AbstractStruct struct)
{
final int numGlobalEffects = ((SectionCount) struct.getAttribute(SplResource.SPL_NUM_GLOBAL_EFFECTS)).getValue();
final int numGlobalEffects = ((IsNumeric) struct.getAttribute(SplResource.SPL_NUM_GLOBAL_EFFECTS)).getValue();
int expectedEffectsIndex = numGlobalEffects;
for (final StructEntry e : struct.getFields()) {
if (e instanceof AbstractAbility) {
final AbstractAbility abil = (AbstractAbility) e;
final int effectsIndex = ((DecNumber) abil.getAttribute(AbstractAbility.ABILITY_FIRST_EFFECT_INDEX)).getValue();
final int effectsIndex = ((IsNumeric) abil.getAttribute(AbstractAbility.ABILITY_FIRST_EFFECT_INDEX)).getValue();
if (effectsIndex != expectedEffectsIndex) {
synchronized (hitFrame) {
hitFrame.addHit(entry, entry.getSearchString(), abil);
Expand Down
2 changes: 1 addition & 1 deletion src/org/infinity/check/IDSRefChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private void search(ResourceEntry entry, AbstractStruct struct)
if (e instanceof IdsBitmap) {
final IdsBitmap ref = (IdsBitmap)e;
final long value = ref.getLongValue();
if (value != 0L && ref.getValueOf(value) == null) {
if (value != 0L && ref.getDataOf(value) == null) {
synchronized (hitFrame) {
hitFrame.addHit(entry, entry.getSearchString(), ref);
}
Expand Down
34 changes: 16 additions & 18 deletions src/org/infinity/check/StructChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@

import org.infinity.NearInfinity;
import org.infinity.datatype.DecNumber;
import org.infinity.datatype.Flag;
import org.infinity.datatype.ResourceRef;
import org.infinity.datatype.SectionCount;
import org.infinity.datatype.SectionOffset;
import org.infinity.datatype.IsNumeric;
import org.infinity.datatype.IsReference;
import org.infinity.datatype.TextString;
import org.infinity.gui.BrowserMenuBar;
import org.infinity.gui.Center;
Expand All @@ -50,7 +48,7 @@ public final class StructChecker extends AbstractChecker implements ListSelectio
{
private static final String[] FILETYPES = {"ARE", "CHR", "CHU", "CRE", "DLG", "EFF", "GAM", "ITM",
"PRO", "SPL", "STO", "VEF", "VVC", "WED", "WMP"};
private static final HashMap<String, StructInfo> fileInfo = new HashMap<String, StructInfo>();
private static final HashMap<String, StructInfo> fileInfo = new HashMap<>();
static {
fileInfo.put("ARE", new StructInfo("AREA", new String[]{"V1.0", "V9.1"}));
fileInfo.put("CHR", new StructInfo("CHR ", new String[]{"V1.0", "V1.2", "V2.0", "V2.1", "V2.2", "V9.0"}));
Expand Down Expand Up @@ -290,20 +288,20 @@ private List<Corruption> getWedCorruption(ResourceEntry entry, AbstractStruct st
final List<Corruption> list = new ArrayList<>();
if (entry.getExtension().equalsIgnoreCase("WED")) {
final int ovlSize = 0x18; // size of an Overlay structure
int ovlCount = ((SectionCount)struct.getAttribute(8, false)).getValue(); // # overlays
int ovlStartOfs = ((SectionOffset)struct.getAttribute(16, false)).getValue(); // Overlays offset
int ovlCount = ((IsNumeric)struct.getAttribute(8, false)).getValue(); // # overlays
int ovlStartOfs = ((IsNumeric)struct.getAttribute(16, false)).getValue(); // Overlays offset

for (int ovlIdx = 0; ovlIdx < ovlCount; ovlIdx++) {
int ovlOfs = ovlStartOfs + ovlIdx*ovlSize;
Overlay overlay = (Overlay)struct.getAttribute(ovlOfs, false); // Overlay
if (overlay == null) {
continue;
}
int width = ((DecNumber)overlay.getAttribute(ovlOfs + 0, false)).getValue();
int height = ((DecNumber)overlay.getAttribute(ovlOfs + 2, false)).getValue();
String tisName = ((ResourceRef)overlay.getAttribute(ovlOfs + 4, false)).getResourceName();
int tileStartOfs = ((SectionOffset)overlay.getAttribute(ovlOfs + 16, false)).getValue();
int indexStartOfs = ((SectionOffset)overlay.getAttribute(ovlOfs + 20, false)).getValue();
int width = ((IsNumeric)overlay.getAttribute(ovlOfs + 0, false)).getValue();
int height = ((IsNumeric)overlay.getAttribute(ovlOfs + 2, false)).getValue();
String tisName = ((IsReference)overlay.getAttribute(ovlOfs + 4, false)).getResourceName();
int tileStartOfs = ((IsNumeric)overlay.getAttribute(ovlOfs + 16, false)).getValue();
int indexStartOfs = ((IsNumeric)overlay.getAttribute(ovlOfs + 20, false)).getValue();
if (tisName == null || tisName.isEmpty() || !ResourceFactory.resourceExists(tisName)) {
continue;
}
Expand Down Expand Up @@ -359,7 +357,7 @@ private List<Corruption> getWedCorruption(ResourceEntry entry, AbstractStruct st
mapTiles.put(Integer.valueOf(index), (Tilemap)item);
} else if (item.getOffset() > indexStartOfs && curOfs < indexEndOfs && item instanceof DecNumber) {
int index = (curOfs - indexStartOfs) / 2;
mapIndices.put(Integer.valueOf(index), Integer.valueOf(((DecNumber)item).getValue()));
mapIndices.put(Integer.valueOf(index), Integer.valueOf(((IsNumeric)item).getValue()));
}
}
// checking indices
Expand All @@ -368,11 +366,11 @@ private List<Corruption> getWedCorruption(ResourceEntry entry, AbstractStruct st
if (tile != null) {
int tileOfs = tile.getOffset();
int tileIdx = (tileOfs - tileStartOfs) / tileSize;
int tileIdxPri = ((DecNumber)tile.getAttribute(tileOfs + 0, false)).getValue();
int tileCountPri = ((DecNumber)tile.getAttribute(tileOfs + 2, false)).getValue();
int tileIdxSec = ((DecNumber)tile.getAttribute(tileOfs + 4, false)).getValue();
Flag tileFlag = (Flag)tile.getAttribute(tileOfs + 6, false);
int tileFlagValue = (int)tileFlag.getValue();
int tileIdxPri = ((IsNumeric)tile.getAttribute(tileOfs + 0, false)).getValue();
int tileCountPri = ((IsNumeric)tile.getAttribute(tileOfs + 2, false)).getValue();
int tileIdxSec = ((IsNumeric)tile.getAttribute(tileOfs + 4, false)).getValue();
IsNumeric tileFlag = (IsNumeric)tile.getAttribute(tileOfs + 6, false);
int tileFlagValue = tileFlag.getValue();
for (int j = tileIdxPri, count = tileIdxPri + tileCountPri; j < count; j++) {
Integer tileLookupIndex = mapIndices.get(Integer.valueOf(j));
if (tileLookupIndex != null) {
Expand Down
Loading

0 comments on commit 7155dba

Please sign in to comment.