Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
240407d
Fix OutOfBounds exceptions
tdauth May 13, 2026
4ca9472
War3MapW3i for version 33 and unit test
tdauth May 14, 2026
f1ce2e8
War3MapW3e for version 12 and unit test
tdauth May 14, 2026
b9755c3
War3MapW3e for version 12 and unit test
tdauth May 14, 2026
e69d79d
War3MapW3e for version 12 and unit test
tdauth May 14, 2026
2c6ed5f
Fix IndexOutOfBoundsException
tdauth May 14, 2026
1a93d29
Make sure defaultRace is never null
tdauth May 14, 2026
72ee6fe
War3ObjectDataChangeset support version 3 sets on loading files
tdauth May 14, 2026
b298a08
fromId
tdauth May 14, 2026
b2c3918
WarcraftIIICASC.main to extract Reforged into a local directory
tdauth May 14, 2026
ffb782d
getPortraitModel fix StringIndexOutOfBoundsException
tdauth May 14, 2026
67522da
ModelViewer.load
tdauth May 14, 2026
c90f20d
Do not load abilities_main #70
tdauth May 14, 2026
932c163
War3ObjectDataChangesetTest
tdauth May 14, 2026
0ce626d
unit tests
tdauth May 14, 2026
2b6ebfb
War3ObjectDataChangeset
tdauth May 14, 2026
c0c8050
War3ObjectDataChangeset fix writing the object count
tdauth May 15, 2026
9363894
War3ObjectDataChangesetTest
tdauth May 15, 2026
e59ce68
Check string length
tdauth May 15, 2026
a394f44
MdxModel simple overloading of load instead of instanceof for type sa…
tdauth May 15, 2026
b7c46c1
Check if resource files exist before loading them to avoid exceptions
tdauth May 15, 2026
1161466
nullable
tdauth May 15, 2026
9e191fe
Native UnitInventorySize
tdauth May 15, 2026
9e9cbd7
Native KillDestructable nullable
tdauth May 15, 2026
65242ce
Native BlzCreateDestructableZWithSkin
tdauth May 15, 2026
689800e
Native Player checks playerIndex boundaries, GetPlayerController and …
tdauth May 15, 2026
6bb3377
Native TriggerRegisterEnterRegion allows null parameters
tdauth May 15, 2026
3158f6a
JASS type region supports handle ID
tdauth May 15, 2026
ba96034
getNullValue
tdauth May 15, 2026
9dcc1e6
Make JASS native GetHandleId more stable since many types do not impl…
tdauth May 15, 2026
3a722dc
Make JASS native GetHandleId more stable since many types do not impl…
tdauth May 15, 2026
be46273
Support native JASS function BlzSetUnitName and avoid ConcurrentModif…
tdauth May 15, 2026
1a6b50f
Support native JASS function GetHeroLevel
tdauth May 15, 2026
57a0e79
Support native JASS functions GetHeroProperName and BlzSetHeroProperName
tdauth May 15, 2026
3c50511
handleId for CHashtable
tdauth May 15, 2026
dfd2a41
BlzSetUnitName use empty string instead of null to avoid exceptions, …
tdauth May 15, 2026
a5428d2
CRect which supports handleId
tdauth May 15, 2026
012ff44
nullableWithWarning to show warnings in log for null parameters
tdauth May 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ project(":core") {
api "org.apache.commons:commons-compress:1.20"
api "net.nikr:dds:1.0.0"
api files(fileTree(dir:'../jars', includes: ['*.jar']))

testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.2"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.2"
}

test {
useJUnitPlatform()
}
}

Expand Down
11 changes: 9 additions & 2 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

sourceCompatibility = 1.17

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

sourceSets {
main {
java.srcDirs = [ "src/" ]
}
test {
java.srcDirs = [ "test/" ]
resources.srcDirs = [ "test/resources" ]
}
}

eclipse.project {
name = appName + "-core"
Expand Down
318 changes: 228 additions & 90 deletions core/src/com/etheller/warsmash/parsers/jass/Jass2.java

Large diffs are not rendered by default.

50 changes: 36 additions & 14 deletions core/src/com/etheller/warsmash/parsers/w3x/w3e/Corner.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/**
* A tile corner.
* https://github.com/ChiefOfGxBxL/WC3MapSpecification/blob/master/Terrain/12.md
*/
public class Corner {
private float groundHeight;
Expand Down Expand Up @@ -42,21 +43,32 @@ public Corner(final Corner other) {
this.layerHeight = other.layerHeight;
}

public void load(final LittleEndianDataInputStream stream) throws IOException {
public void load(final LittleEndianDataInputStream stream, int version) throws IOException {
this.groundHeight = (stream.readShort() - 8192) / (float) 512;

final short waterAndEdge = stream.readShort();
this.waterHeight = ((waterAndEdge & 0x3FFF) - 8192) / (float) 512;
this.mapEdge = waterAndEdge & 0x4000;

final short textureAndFlags = ParseUtils.readUInt8(stream);
if (version >= 12) {
final int textureAndFlags = ParseUtils.readUInt16(stream);

this.ramp = textureAndFlags & 0b00010000;
this.blight = textureAndFlags & 0b00100000;
this.water = textureAndFlags & 0b01000000;
this.boundary = textureAndFlags & 0b10000000;
this.ramp = textureAndFlags & 0b00000000_01000000;
this.blight = textureAndFlags & 0b00000000_10000000;
this.water = textureAndFlags & 0b00000001_00000000;
this.boundary = textureAndFlags & 0b00000010_00000000;

this.groundTexture = textureAndFlags & 0b00001111;
this.groundTexture = textureAndFlags & 0b00111111;
} else {
final short textureAndFlags = ParseUtils.readUInt8(stream);

this.ramp = textureAndFlags & 0b00010000;
this.blight = textureAndFlags & 0b00100000;
this.water = textureAndFlags & 0b01000000;
this.boundary = textureAndFlags & 0b10000000;

this.groundTexture = textureAndFlags & 0b00001111;
}

final short variation = ParseUtils.readUInt8(stream);

Expand All @@ -70,16 +82,26 @@ public void load(final LittleEndianDataInputStream stream) throws IOException {

}

public void save(final LittleEndianDataOutputStream stream) throws IOException {
public void save(final LittleEndianDataOutputStream stream, int version) throws IOException {
stream.writeShort((short) ((this.groundHeight * 512f) + 8192f));
final int mapEdgeWrite = (this.mapEdge != 0) ? 0x4000 : 0;
stream.writeShort((short) ((int) ((this.waterHeight * 512f) + 8192f) | (mapEdgeWrite)));
final int rampWrite = (this.ramp != 0) ? 0b00010000 : 0;
final int blightWrite = (this.blight != 0) ? 0b00100000 : 0;
final int waterWrite = (this.water != 0) ? 0b01000000 : 0;
final int boundaryWrite = (this.boundary != 0) ? 0b10000000 : 0;
ParseUtils.writeUInt8(stream,
(short) ((rampWrite) | (blightWrite) | (waterWrite) | (boundaryWrite) | this.groundTexture));
int rampWrite = (this.ramp != 0) ? 0b00010000 : 0;
int blightWrite = (this.blight != 0) ? 0b00100000 : 0;
int waterWrite = (this.water != 0) ? 0b01000000 : 0;
int boundaryWrite = (this.boundary != 0) ? 0b10000000 : 0;
if (version >= 12) {
rampWrite <<= 2;
blightWrite <<= 2;
waterWrite <<= 2;
boundaryWrite <<= 2;

ParseUtils.writeUInt16(stream,
(int) ((rampWrite) | (blightWrite) | (waterWrite) | (boundaryWrite) | this.groundTexture));
} else {
ParseUtils.writeUInt8(stream,
(short) ((rampWrite) | (blightWrite) | (waterWrite) | (boundaryWrite) | this.groundTexture));
}
ParseUtils.writeUInt8(stream, (short) ((this.cliffVariation << 5) | this.groundVariation));
ParseUtils.writeUInt8(stream, (short) ((this.cliffTexture << 4) + this.layerHeight));
}
Expand Down
10 changes: 3 additions & 7 deletions core/src/com/etheller/warsmash/parsers/w3x/w3e/War3MapW3e.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

/**
* war3map.w3e - the environment file.
* https://github.com/ChiefOfGxBxL/WC3MapSpecification/blob/master/Terrain/12.md
*/
public class War3MapW3e {
private static final War3ID MAGIC_NUMBER = War3ID.fromString("W3E!");
Expand Down Expand Up @@ -57,7 +58,7 @@ private boolean load(final LittleEndianDataInputStream stream) throws IOExceptio
for (int column = 0, columns = this.mapSize[0]; column < columns; column++) {
final Corner corner = new Corner();

corner.load(stream);
corner.load(stream, this.version);

this.corners[row][column] = corner;
}
Expand Down Expand Up @@ -88,16 +89,11 @@ public void save(final LittleEndianDataOutputStream stream) throws IOException {

for (final Corner[] row : this.corners) {
for (final Corner corner : row) {
corner.save(stream);
corner.save(stream, this.version);
}
}
}

public int getByteLength() {
return 37 + (this.groundTiles.size() * 4) + (this.cliffTiles.size() * 4)
+ (this.mapSize[0] * this.mapSize[1] * 7);
}

public int getVersion() {
return this.version;
}
Expand Down
12 changes: 6 additions & 6 deletions core/src/com/etheller/warsmash/parsers/w3x/w3i/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public void load(final LittleEndianDataInputStream stream, final int version) th
ParseUtils.readFloatArray(stream, this.startLocation);
this.allyLowPriorities = ParseUtils.readUInt32(stream);
this.allyHighPriorities = ParseUtils.readUInt32(stream);
if (version > 30) {
if (version >= 31) {
this.enemyLowPrioritiesFlags = ParseUtils.readUInt32(stream);
this.enemyHighPrioritiesFlags = ParseUtils.readUInt32(stream);
}
}

public void save(final LittleEndianDataOutputStream stream) throws IOException {
public void save(final LittleEndianDataOutputStream stream, int version) throws IOException {
ParseUtils.writeUInt32(stream, this.id);
stream.writeInt(this.type);
stream.writeInt(this.race);
Expand All @@ -45,10 +45,10 @@ public void save(final LittleEndianDataOutputStream stream) throws IOException {
ParseUtils.writeFloatArray(stream, this.startLocation);
ParseUtils.writeUInt32(stream, this.allyLowPriorities);
ParseUtils.writeUInt32(stream, this.allyHighPriorities);
}

public int getByteLength() {
return 33 + this.name.length();
if (version >= 31) {
ParseUtils.writeUInt32(stream, this.enemyLowPrioritiesFlags);
ParseUtils.writeUInt32(stream, this.enemyHighPrioritiesFlags);
}
}

public int getId() {
Expand Down
Loading