Working Well in MP
This commit is contained in:
@@ -21,6 +21,7 @@ import org.objectweb.asm.tree.VarInsnNode;
|
|||||||
*/
|
*/
|
||||||
public final class BaseVehicleConstraintPatch {
|
public final class BaseVehicleConstraintPatch {
|
||||||
private static final String TARGET_NAME = "addPointConstraint";
|
private static final String TARGET_NAME = "addPointConstraint";
|
||||||
|
private static final String UPDATE_NAME = "update";
|
||||||
private static final String CONSTRAINT_CHANGED_NAME = "constraintChanged";
|
private static final String CONSTRAINT_CHANGED_NAME = "constraintChanged";
|
||||||
private static final String AUTHORIZATION_CHANGED_NAME = "authorizationChanged";
|
private static final String AUTHORIZATION_CHANGED_NAME = "authorizationChanged";
|
||||||
private static final String AUTHORIZATION_CLIENT_COLLIDE_NAME = "authorizationClientCollide";
|
private static final String AUTHORIZATION_CLIENT_COLLIDE_NAME = "authorizationClientCollide";
|
||||||
@@ -49,6 +50,9 @@ public final class BaseVehicleConstraintPatch {
|
|||||||
private static final String BULLET_ADD_POINT = "addPointConstraint";
|
private static final String BULLET_ADD_POINT = "addPointConstraint";
|
||||||
private static final String BULLET_ADD_ROPE_DESC = "(IIFFFFFFF)I";
|
private static final String BULLET_ADD_ROPE_DESC = "(IIFFFFFFF)I";
|
||||||
private static final String BULLET_ADD_POINT_DESC = "(IIFFFFFF)I";
|
private static final String BULLET_ADD_POINT_DESC = "(IIFFFFFF)I";
|
||||||
|
private static final String CAR_CONTROLLER_OWNER = "zombie/core/physics/CarController";
|
||||||
|
private static final String CAR_CONTROLLER_PARK = "park";
|
||||||
|
private static final String CAR_CONTROLLER_PARK_DESC = "()V";
|
||||||
private static final String GET_DRIVER_DESC = "()Lzombie/characters/IsoGameCharacter;";
|
private static final String GET_DRIVER_DESC = "()Lzombie/characters/IsoGameCharacter;";
|
||||||
private static final String HELPER_OWNER = "zombie/vehicles/LandtrainConstraintAuthHelper";
|
private static final String HELPER_OWNER = "zombie/vehicles/LandtrainConstraintAuthHelper";
|
||||||
private static final String HELPER_METHOD = "resolveConstraintDriver";
|
private static final String HELPER_METHOD = "resolveConstraintDriver";
|
||||||
@@ -75,6 +79,9 @@ public final class BaseVehicleConstraintPatch {
|
|||||||
"authorizationServerOnSeatLandtrain";
|
"authorizationServerOnSeatLandtrain";
|
||||||
private static final String HELPER_AUTHORIZATION_SERVER_ON_SEAT_DESC =
|
private static final String HELPER_AUTHORIZATION_SERVER_ON_SEAT_DESC =
|
||||||
"(Lzombie/vehicles/BaseVehicle;Lzombie/characters/IsoPlayer;Z)V";
|
"(Lzombie/vehicles/BaseVehicle;Lzombie/characters/IsoPlayer;Z)V";
|
||||||
|
private static final String HELPER_SAFE_PARK = "safeParkControllerLandtrain";
|
||||||
|
private static final String HELPER_SAFE_PARK_DESC =
|
||||||
|
"(Lzombie/core/physics/CarController;)V";
|
||||||
|
|
||||||
private static final class AddPointPatchStats {
|
private static final class AddPointPatchStats {
|
||||||
int removedBreakCalls;
|
int removedBreakCalls;
|
||||||
@@ -107,6 +114,7 @@ public final class BaseVehicleConstraintPatch {
|
|||||||
int patchedAuthorizationClientCollideMethods = 0;
|
int patchedAuthorizationClientCollideMethods = 0;
|
||||||
int patchedAuthorizationServerCollideMethods = 0;
|
int patchedAuthorizationServerCollideMethods = 0;
|
||||||
int patchedAuthorizationServerOnSeatMethods = 0;
|
int patchedAuthorizationServerOnSeatMethods = 0;
|
||||||
|
int patchedSafeParkCalls = 0;
|
||||||
|
|
||||||
for (MethodNode method : classNode.methods) {
|
for (MethodNode method : classNode.methods) {
|
||||||
if (TARGET_NAME.equals(method.name) && isTargetAddPointConstraint(method.desc)) {
|
if (TARGET_NAME.equals(method.name) && isTargetAddPointConstraint(method.desc)) {
|
||||||
@@ -114,6 +122,8 @@ public final class BaseVehicleConstraintPatch {
|
|||||||
AddPointPatchStats stats = patchAddPointConstraint(method);
|
AddPointPatchStats stats = patchAddPointConstraint(method);
|
||||||
removedCalls += stats.removedBreakCalls;
|
removedCalls += stats.removedBreakCalls;
|
||||||
forcedRigidCalls += stats.forcedRigidCalls;
|
forcedRigidCalls += stats.forcedRigidCalls;
|
||||||
|
} else if (UPDATE_NAME.equals(method.name) && VOID_NOARG_DESC.equals(method.desc)) {
|
||||||
|
patchedSafeParkCalls += patchNullSafeParkCalls(method);
|
||||||
} else if (CONSTRAINT_CHANGED_NAME.equals(method.name)
|
} else if (CONSTRAINT_CHANGED_NAME.equals(method.name)
|
||||||
&& VOID_NOARG_DESC.equals(method.desc)) {
|
&& VOID_NOARG_DESC.equals(method.desc)) {
|
||||||
patchedConstraintDriverCalls += patchConstraintChangedDriverCalls(method);
|
patchedConstraintDriverCalls += patchConstraintChangedDriverCalls(method);
|
||||||
@@ -198,6 +208,11 @@ public final class BaseVehicleConstraintPatch {
|
|||||||
"Expected to patch authorizationServerOnSeat, patched "
|
"Expected to patch authorizationServerOnSeat, patched "
|
||||||
+ patchedAuthorizationServerOnSeatMethods);
|
+ patchedAuthorizationServerOnSeatMethods);
|
||||||
}
|
}
|
||||||
|
if (patchedSafeParkCalls < 1) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"Expected to patch at least 1 CarController.park call, patched "
|
||||||
|
+ patchedSafeParkCalls);
|
||||||
|
}
|
||||||
if (patchedEnterBlockedCalls < 1) {
|
if (patchedEnterBlockedCalls < 1) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Expected to patch isEnterBlocked call, patched " + patchedEnterBlockedCalls);
|
"Expected to patch isEnterBlocked call, patched " + patchedEnterBlockedCalls);
|
||||||
@@ -230,6 +245,8 @@ public final class BaseVehicleConstraintPatch {
|
|||||||
+ patchedAuthorizationServerCollideMethods
|
+ patchedAuthorizationServerCollideMethods
|
||||||
+ "/"
|
+ "/"
|
||||||
+ patchedAuthorizationServerOnSeatMethods
|
+ patchedAuthorizationServerOnSeatMethods
|
||||||
|
+ ", safe park hooks: "
|
||||||
|
+ patchedSafeParkCalls
|
||||||
+ ", enter-block hooks: "
|
+ ", enter-block hooks: "
|
||||||
+ patchedEnterBlockedCalls
|
+ patchedEnterBlockedCalls
|
||||||
+ "/"
|
+ "/"
|
||||||
@@ -318,6 +335,36 @@ public final class BaseVehicleConstraintPatch {
|
|||||||
return patched;
|
return patched;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int patchNullSafeParkCalls(MethodNode method) {
|
||||||
|
int patched = 0;
|
||||||
|
InsnList insns = method.instructions;
|
||||||
|
for (AbstractInsnNode node = insns.getFirst(); node != null; ) {
|
||||||
|
AbstractInsnNode next = node.getNext();
|
||||||
|
if (!(node instanceof MethodInsnNode call)) {
|
||||||
|
node = next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!CAR_CONTROLLER_OWNER.equals(call.owner)
|
||||||
|
|| !CAR_CONTROLLER_PARK.equals(call.name)
|
||||||
|
|| !CAR_CONTROLLER_PARK_DESC.equals(call.desc)) {
|
||||||
|
node = next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
MethodInsnNode replacement =
|
||||||
|
new MethodInsnNode(
|
||||||
|
Opcodes.INVOKESTATIC,
|
||||||
|
HELPER_OWNER,
|
||||||
|
HELPER_SAFE_PARK,
|
||||||
|
HELPER_SAFE_PARK_DESC,
|
||||||
|
false);
|
||||||
|
insns.set(call, replacement);
|
||||||
|
patched++;
|
||||||
|
node = next;
|
||||||
|
}
|
||||||
|
return patched;
|
||||||
|
}
|
||||||
|
|
||||||
private static int patchMethodDelegateToHelper(
|
private static int patchMethodDelegateToHelper(
|
||||||
MethodNode method, String helperMethod, String helperDesc) {
|
MethodNode method, String helperMethod, String helperDesc) {
|
||||||
InsnList insns = new InsnList();
|
InsnList insns = new InsnList();
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.util.List;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import zombie.characters.IsoGameCharacter;
|
import zombie.characters.IsoGameCharacter;
|
||||||
import zombie.characters.IsoPlayer;
|
import zombie.characters.IsoPlayer;
|
||||||
|
import zombie.core.physics.CarController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves the effective driver for constraint auth in chained towing.
|
* Resolves the effective driver for constraint auth in chained towing.
|
||||||
@@ -195,4 +196,10 @@ public final class LandtrainConstraintAuthHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void safeParkControllerLandtrain(CarController controller) {
|
||||||
|
if (controller != null) {
|
||||||
|
controller.park();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user