mirror of
https://github.com/Retera/WarsmashModEngine.git
synced 2022-07-31 17:38:59 +02:00
Ignore repeat orders
This commit is contained in:
parent
d4245e2e65
commit
8111441f16
@ -64,4 +64,5 @@ public class AudioContext {
|
|||||||
public AudioBufferSource createBufferSource() {
|
public AudioBufferSource createBufferSource() {
|
||||||
return new AudioBufferSource();
|
return new AudioBufferSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public class CUnit extends CWidget {
|
|||||||
private boolean acceptingOrders = true;
|
private boolean acceptingOrders = true;
|
||||||
private boolean invulnerable = false;
|
private boolean invulnerable = false;
|
||||||
private CBehavior defaultBehavior;
|
private CBehavior defaultBehavior;
|
||||||
private COrder currentOrder = null;
|
private COrder lastStartedOrder = null;
|
||||||
private CUnit workerInside;
|
private CUnit workerInside;
|
||||||
private final War3ID[] buildQueue = new War3ID[WarsmashConstants.BUILD_QUEUE_SIZE];
|
private final War3ID[] buildQueue = new War3ID[WarsmashConstants.BUILD_QUEUE_SIZE];
|
||||||
private final QueueItemType[] buildQueueTypes = new QueueItemType[WarsmashConstants.BUILD_QUEUE_SIZE];
|
private final QueueItemType[] buildQueueTypes = new QueueItemType[WarsmashConstants.BUILD_QUEUE_SIZE];
|
||||||
@ -384,6 +384,12 @@ public class CUnit extends CWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((this.lastStartedOrder != null) && this.lastStartedOrder.equals(order)
|
||||||
|
&& (this.lastStartedOrder.getOrderId() == OrderIds.smart)) {
|
||||||
|
// I skip your spammed move orders, TODO this will probably break some repeat
|
||||||
|
// attack order or something later
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ((queue || !this.acceptingOrders) && ((this.currentBehavior != this.stopBehavior)
|
if ((queue || !this.acceptingOrders) && ((this.currentBehavior != this.stopBehavior)
|
||||||
&& (this.currentBehavior != this.holdPositionBehavior))) {
|
&& (this.currentBehavior != this.holdPositionBehavior))) {
|
||||||
this.orderQueue.add(order);
|
this.orderQueue.add(order);
|
||||||
@ -405,7 +411,7 @@ public class CUnit extends CWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private CBehavior beginOrder(final CSimulation game, final COrder order) {
|
private CBehavior beginOrder(final CSimulation game, final COrder order) {
|
||||||
this.currentOrder = order;
|
this.lastStartedOrder = order;
|
||||||
CBehavior nextBehavior;
|
CBehavior nextBehavior;
|
||||||
if (order != null) {
|
if (order != null) {
|
||||||
nextBehavior = order.begin(game, this);
|
nextBehavior = order.begin(game, this);
|
||||||
@ -1214,6 +1220,6 @@ public class CUnit extends CWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public COrder getCurrentOrder() {
|
public COrder getCurrentOrder() {
|
||||||
return this.currentOrder;
|
return this.lastStartedOrder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,4 +59,38 @@ public class COrderNoTarget implements COrder {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = (prime * result) + this.abilityHandleId;
|
||||||
|
result = (prime * result) + this.orderId;
|
||||||
|
result = (prime * result) + (this.queued ? 1231 : 1237);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final COrderNoTarget other = (COrderNoTarget) obj;
|
||||||
|
if (this.abilityHandleId != other.abilityHandleId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.orderId != other.orderId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.queued != other.queued) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -63,4 +63,47 @@ public class COrderTargetPoint implements COrder {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = (prime * result) + this.abilityHandleId;
|
||||||
|
result = (prime * result) + this.orderId;
|
||||||
|
result = (prime * result) + (this.queued ? 1231 : 1237);
|
||||||
|
result = (prime * result) + ((this.target == null) ? 0 : this.target.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final COrderTargetPoint other = (COrderTargetPoint) obj;
|
||||||
|
if (this.abilityHandleId != other.abilityHandleId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.orderId != other.orderId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.queued != other.queued) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.target == null) {
|
||||||
|
if (other.target != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!this.target.equals(other.target)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -64,4 +64,42 @@ public class COrderTargetWidget implements COrder {
|
|||||||
return caster.pollNextOrderBehavior(game);
|
return caster.pollNextOrderBehavior(game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = (prime * result) + this.abilityHandleId;
|
||||||
|
result = (prime * result) + this.orderId;
|
||||||
|
result = (prime * result) + (this.queued ? 1231 : 1237);
|
||||||
|
result = (prime * result) + this.targetHandleId;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final COrderTargetWidget other = (COrderTargetWidget) obj;
|
||||||
|
if (this.abilityHandleId != other.abilityHandleId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.orderId != other.orderId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.queued != other.queued) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.targetHandleId != other.targetHandleId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user