Browse Source

Message now uses enum

combat-2
MagicBot 7 months ago
parent
commit
30800478f2
  1. 15
      src/engine/mbEnums.java
  2. 59
      src/engine/net/client/msg/ItemProductionMsg.java

15
src/engine/mbEnums.java

@ -3024,5 +3024,20 @@ public class mbEnums { @@ -3024,5 +3024,20 @@ public class mbEnums {
}
}
public enum ProductionActionType {
NONE,
PRODUCE,
JUNK,
RECYCLE,
COMPLETE,
SETPRICE,
DEPOSIT,
TAKE,
CONFIRM_PRODUCE,
CONFIRM_SETPRICE,
CONFIRM_DEPOSIT,
CONFIRM_TAKE;
}
}

59
src/engine/net/client/msg/ItemProductionMsg.java

@ -11,6 +11,7 @@ package engine.net.client.msg; @@ -11,6 +11,7 @@ package engine.net.client.msg;
import engine.gameManager.BuildingManager;
import engine.gameManager.PowersManager;
import engine.mbEnums;
import engine.mbEnums.GameObjectType;
import engine.net.*;
import engine.objects.Building;
@ -23,18 +24,6 @@ import java.util.HashMap; @@ -23,18 +24,6 @@ import java.util.HashMap;
public class ItemProductionMsg extends ClientNetMsg {
private static final int ACTION_PRODUCE = 1;
private static final int ACTION_JUNK = 2;
private static final int ACTION_RECYCLE = 3;
private static final int ACTION_COMPLETE = 4;
private static final int ACTION_DEPOSIT = 6;
private static final int ACTION_SETPRICE = 5;
private static final int ACTION_TAKE = 7;
private static final int ACTION_CONFIRM_SETPRICE = 9;
private static final int ACTION_CONFIRM_DEPOSIT = 10;
private static final int ACTION_CONFIRM_TAKE = 11; // Unsure. Sent by client
private static final int ACTION_CONFIRM_PRODUCE = 8;
private int size;
private int buildingUUID;
private int unknown01;
@ -45,7 +34,7 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -45,7 +34,7 @@ public class ItemProductionMsg extends ClientNetMsg {
private int pToken;
private int sToken;
private String name;
private int actionType;
private mbEnums.ProductionActionType actionType;
private int npcUUID;
private boolean add;
private int itemPrice;
@ -57,7 +46,7 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -57,7 +46,7 @@ public class ItemProductionMsg extends ClientNetMsg {
public ItemProductionMsg() {
super(Protocol.ITEMPRODUCTION);
this.actionType = 0;
this.actionType = mbEnums.ProductionActionType.NONE;
this.size = 0;
this.buildingUUID = 0;
this.unknown01 = 0;
@ -76,7 +65,7 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -76,7 +65,7 @@ public class ItemProductionMsg extends ClientNetMsg {
public ItemProductionMsg(Building building, NPC vendor, Item item, int actionType, boolean add) {
super(Protocol.ITEMPRODUCTION);
this.actionType = actionType;
this.actionType = mbEnums.ProductionActionType.values()[actionType];
this.size = 0;
this.buildingUUID = building.getObjectUUID();
this.npcUUID = vendor.getObjectUUID();
@ -123,7 +112,7 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -123,7 +112,7 @@ public class ItemProductionMsg extends ClientNetMsg {
return;
// Common Header
writer.putInt(this.actionType);
writer.putInt(this.actionType.ordinal());
writer.putInt(GameObjectType.Building.ordinal());
writer.putInt(this.buildingUUID);
writer.putInt(GameObjectType.NPC.ordinal());
@ -131,7 +120,7 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -131,7 +120,7 @@ public class ItemProductionMsg extends ClientNetMsg {
switch (this.actionType) {
case ACTION_CONFIRM_DEPOSIT:
case CONFIRM_DEPOSIT:
writer.putInt(0); // Not item ordinal?
writer.putInt(0); // Not item uuid?
writer.putInt(1);
@ -164,7 +153,7 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -164,7 +153,7 @@ public class ItemProductionMsg extends ClientNetMsg {
writer.putInt(0);
writer.put((byte) 0);
break;
case ACTION_CONFIRM_TAKE:
case CONFIRM_TAKE:
writer.putInt(this.itemType);
writer.putInt(this.templateID);
writer.putInt(1);
@ -176,7 +165,7 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -176,7 +165,7 @@ public class ItemProductionMsg extends ClientNetMsg {
writer.putInt(0);
writer.put((byte) 0);
break;
case ACTION_SETPRICE:
case SETPRICE:
writer.putInt(this.itemType);
writer.putInt(this.templateID);
writer.putInt(1);
@ -189,7 +178,7 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -189,7 +178,7 @@ public class ItemProductionMsg extends ClientNetMsg {
writer.putInt(0);
writer.put((byte) 0);
break;
case ACTION_CONFIRM_SETPRICE:
case CONFIRM_SETPRICE:
writer.putInt(this.itemType);
writer.putInt(this.templateID);
writer.putInt(1);
@ -203,7 +192,7 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -203,7 +192,7 @@ public class ItemProductionMsg extends ClientNetMsg {
writer.putInt(0);
//writer.put((byte) 0);
break;
case ACTION_DEPOSIT:
case DEPOSIT:
writer.putInt(this.itemType);
writer.putInt(this.templateID);
writer.putInt(1);
@ -215,8 +204,8 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -215,8 +204,8 @@ public class ItemProductionMsg extends ClientNetMsg {
writer.putInt(0);
writer.put((byte) 0);
break;
case ACTION_TAKE:
case ACTION_RECYCLE:
case TAKE:
case RECYCLE:
writer.putInt(0);
writer.putInt(0);
@ -242,7 +231,7 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -242,7 +231,7 @@ public class ItemProductionMsg extends ClientNetMsg {
writer.putInt(0);
break;
case ACTION_CONFIRM_PRODUCE:
case CONFIRM_PRODUCE:
writer.putInt(0);
writer.putInt(0);
writer.putInt(1);
@ -320,7 +309,7 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -320,7 +309,7 @@ public class ItemProductionMsg extends ClientNetMsg {
//writer.putInt(0); //error popup
break;
case ACTION_COMPLETE:
case COMPLETE:
writer.putInt(this.itemType);
writer.putInt(this.templateID);
writer.putInt(this.total_to_produce);
@ -332,7 +321,7 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -332,7 +321,7 @@ public class ItemProductionMsg extends ClientNetMsg {
writer.putInt(0);
writer.put((byte) 0);
break;
case ACTION_JUNK:
case JUNK:
writer.putInt(this.itemType);
writer.putInt(this.templateID);
writer.putInt(this.total_to_produce);
@ -363,14 +352,14 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -363,14 +352,14 @@ public class ItemProductionMsg extends ClientNetMsg {
// Common header
this.actionType = reader.getInt();
this.actionType = mbEnums.ProductionActionType.values()[reader.getInt()];
reader.getInt(); // Building type padding
this.buildingUUID = reader.getInt();
reader.getInt(); // NPC type padding
this.npcUUID = reader.getInt();
switch (this.actionType) {
case ACTION_SETPRICE:
case SETPRICE:
this.itemType = reader.getInt();
this.templateID = reader.getInt();
reader.getInt();
@ -383,8 +372,8 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -383,8 +372,8 @@ public class ItemProductionMsg extends ClientNetMsg {
reader.getInt();
reader.get();
break;
case ACTION_RECYCLE:
case ACTION_TAKE:
case RECYCLE:
case TAKE:
reader.getInt();
reader.getInt();
reader.getInt();
@ -403,7 +392,7 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -403,7 +392,7 @@ public class ItemProductionMsg extends ClientNetMsg {
reader.getInt();
this.items = tempIDs;
break;
case ACTION_DEPOSIT:
case DEPOSIT:
this.itemType = reader.getInt();
this.templateID = reader.getInt();
reader.getInt();
@ -415,7 +404,7 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -415,7 +404,7 @@ public class ItemProductionMsg extends ClientNetMsg {
reader.getInt();
reader.get();
break;
case ACTION_JUNK:
case JUNK:
this.itemType = reader.getInt();
this.templateID = reader.getInt();
this.total_to_produce = reader.getInt();
@ -438,7 +427,7 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -438,7 +427,7 @@ public class ItemProductionMsg extends ClientNetMsg {
this.size = reader.getInt();
reader.getInt();
if (this.actionType == ACTION_COMPLETE || this.actionType == ACTION_JUNK)
if (this.actionType == mbEnums.ProductionActionType.COMPLETE || this.actionType == mbEnums.ProductionActionType.JUNK)
reader.get();
else
reader.getShort();
@ -516,11 +505,11 @@ public class ItemProductionMsg extends ClientNetMsg { @@ -516,11 +505,11 @@ public class ItemProductionMsg extends ClientNetMsg {
}
public int getActionType() {
return actionType;
return actionType.ordinal();
}
public final void setActionType(int actionType) {
this.actionType = actionType;
this.actionType = mbEnums.ProductionActionType.values()[actionType];
}
public int getNpcUUID() {

Loading…
Cancel
Save