refactored package structure
This commit is contained in:
1 parent
981445a797
commit
acef6fd81f
10 files changed
+39
-22
No files matched your search
+1
@@ -1,5 +1,6 @@
|
||||
package dev.overlord.zomboidforge.compat.b42.patches;
|
||||
|
||||
import dev.overlord.zomboidforge.compat.b42.perf.IsoZombieVehiclePerformancePatch;
|
||||
import dev.overlord.zomboidforge.patcher.ClassPatch;
|
||||
import dev.overlord.zomboidforge.patcher.PatchSet;
|
||||
|
||||
|
||||
+2
-4
@@ -1,12 +1,10 @@
|
||||
package dev.overlord.zomboidforge.compat.b42.patches;
|
||||
package dev.overlord.zomboidforge.compat.b42.perf;
|
||||
|
||||
import dev.overlord.zomboidforge.patcher.Anchor;
|
||||
import dev.overlord.zomboidforge.patcher.GameVersion;
|
||||
import dev.overlord.zomboidforge.patcher.Hook;
|
||||
import dev.overlord.zomboidforge.patcher.Patches.PerformancePatch;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldInsnNode;
|
||||
@@ -75,7 +73,7 @@ public final class IsoZombieVehiclePerformancePatch extends PerformancePatch
|
||||
* stack map frame at the jump target is the one of the method entry; the class writer
|
||||
* computes it.
|
||||
*/
|
||||
private static @NotNull InsnList returnFalseWithoutVehicles()
|
||||
private static InsnList returnFalseWithoutVehicles()
|
||||
{
|
||||
LabelNode hasVehicles = new LabelNode();
|
||||
InsnList code = new InsnList();
|
||||
File renamed without changes.
+15
-8
@@ -19,8 +19,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
*/
|
||||
class NamingRulesTest
|
||||
{
|
||||
private static final String PATCHES_PACKAGE = "dev/overlord/zomboidforge/compat/b42/patches";
|
||||
private static final String HOOKS_PACKAGE = "dev/overlord/zomboidforge/compat/b42/hooks";
|
||||
private static final List<String> PATCH_PACKAGES = List.of(
|
||||
"dev/overlord/zomboidforge/compat/b42/patches",
|
||||
"dev/overlord/zomboidforge/compat/b42/perf"
|
||||
);
|
||||
private static final String HOOKS_PACKAGE = "dev/overlord/zomboidforge/compat/b42/hooks";
|
||||
|
||||
private static final String PATCH_SET = "B42PatchSet";
|
||||
|
||||
@@ -28,14 +31,18 @@ class NamingRulesTest
|
||||
void patchClassesEndInPatch() throws Exception
|
||||
{
|
||||
List<String> problems = new ArrayList<>();
|
||||
List<String> names = PackageScan.topLevelClassNames(NamingRulesTest.PATCHES_PACKAGE);
|
||||
|
||||
assertFalse(names.isEmpty(), "No classes found in '" + NamingRulesTest.PATCHES_PACKAGE + "'");
|
||||
|
||||
for (String name : names)
|
||||
for (String patchPackage : NamingRulesTest.PATCH_PACKAGES)
|
||||
{
|
||||
if (!name.equals(NamingRulesTest.PATCH_SET) && !name.endsWith("Patch")) {
|
||||
problems.add("'" + name + "' must end in 'Patch' (or be '" + NamingRulesTest.PATCH_SET + "')");
|
||||
List<String> names = PackageScan.topLevelClassNames(patchPackage);
|
||||
|
||||
assertFalse(names.isEmpty(), "No classes found in '" + patchPackage + "'.");
|
||||
|
||||
for (String name : names)
|
||||
{
|
||||
if (!name.equals(NamingRulesTest.PATCH_SET) && !name.endsWith("Patch")) {
|
||||
problems.add("'" + patchPackage + "/" + name + "' must end in 'Patch' (or be '" + NamingRulesTest.PATCH_SET + "').");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-6
@@ -19,7 +19,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
*/
|
||||
class PatchSetRegistrationTest
|
||||
{
|
||||
private static final String PATCHES_PACKAGE = "dev/overlord/zomboidforge/compat/b42/patches";
|
||||
private static final List<String> PATCH_PACKAGES = List.of(
|
||||
"dev/overlord/zomboidforge/compat/b42/patches",
|
||||
"dev/overlord/zomboidforge/compat/b42/perf"
|
||||
);
|
||||
|
||||
@Test
|
||||
void everyPatchClassIsRegisteredExactlyOnce() throws Exception
|
||||
@@ -30,15 +33,18 @@ class PatchSetRegistrationTest
|
||||
for (ClassPatch patch : new B42PatchSet().patches())
|
||||
{
|
||||
String name = patch.getClass().getSimpleName();
|
||||
if (!registered.add(name)) problems.add("'" + name + "' is registered more than once");
|
||||
if (!registered.add(name)) problems.add("'" + name + "' is registered more than once.");
|
||||
}
|
||||
|
||||
for (String name : PackageScan.topLevelClassNames(PatchSetRegistrationTest.PATCHES_PACKAGE))
|
||||
for (String patchPackage : PatchSetRegistrationTest.PATCH_PACKAGES)
|
||||
{
|
||||
boolean abstractClass = (PackageScan.read(PatchSetRegistrationTest.PATCHES_PACKAGE + "/" + name).access & Opcodes.ACC_ABSTRACT) != 0;
|
||||
for (String name : PackageScan.topLevelClassNames(patchPackage))
|
||||
{
|
||||
boolean abstractClass = (PackageScan.read(patchPackage + "/" + name).access & Opcodes.ACC_ABSTRACT) != 0;
|
||||
|
||||
if (name.endsWith("Patch") && !abstractClass && !registered.contains(name)) {
|
||||
problems.add("'" + name + "' is not registered in 'B42PatchSet'");
|
||||
if (name.endsWith("Patch") && !abstractClass && !registered.contains(name)) {
|
||||
problems.add("'" + name + "' is not registered in 'B42PatchSet'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package dev.overlord.zomboidforge.compat.b42.patches;
|
||||
package dev.overlord.zomboidforge.compat.b42.perf;
|
||||
|
||||
import dev.overlord.zomboidforge.patcher.GameVersion;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package dev.overlord.zomboidforge.compat.b42.hooks;
|
||||
|
||||
import dev.overlord.zomboidforge.compat.b42.perf.SegmentReach;
|
||||
import dev.overlord.zomboidforge.compat.b42.util.SegmentReach;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package dev.overlord.zomboidforge.compat.b42.perf;
|
||||
package dev.overlord.zomboidforge.compat.b42.util;
|
||||
|
||||
/** Distance checks in the XY plane. Uses no game classes, so it can be tested on its own. */
|
||||
public final class SegmentReach
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/** @noinspection UnstableApiUsage, RedundantSuppression */
|
||||
@NotNullByDefault
|
||||
package dev.overlord.zomboidforge.compat.b42.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNullByDefault;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package dev.overlord.zomboidforge.compat.b42.perf;
|
||||
package dev.overlord.zomboidforge.compat.b42.util;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
Reference in new issue
Block a user