From 3928d5844801352ab8a77f1d7b9f9a6fca36e8ec Mon Sep 17 00:00:00 2001 From: Treeku Date: Mon, 7 Apr 2014 18:43:31 +0100 Subject: [PATCH] cmdSvc now accounts for different cmdTable struct --- src/services/command/CommandService.java | 34 +++++++++++++++++++----- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index c6b5fab0..2b7a6877 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -258,7 +258,7 @@ public class CommandService implements INetworkDispatch { try { String[] tableArray = new String[] { "client_command_table", "command_table", "client_command_table_ground", "command_table_ground", - "client_command_table_space", "command_table_space", "command_table_atmospheric_flight" }; + "client_command_table_space", "command_table_space" }; for (int n = 0; n < tableArray.length; n++) { DatatableVisitor visitor = ClientFileManager.loadFile("datatables/command/" + tableArray[n] + ".iff", DatatableVisitor.class); @@ -268,8 +268,19 @@ public class CommandService implements INetworkDispatch { String name = ((String) visitor.getObject(i, 0)).toLowerCase(); if (CRC.StringtoCRC(name) == commandCRC) { - boolean hasCharacterAbility = (((String) visitor.getObject(i, 7)).length() > 0); - boolean isCombatCommand = (Boolean) visitor.getObject(i, 82); + int sub = 0; + + boolean hasCharacterAbility = (((String) visitor.getObject(i, 7-sub)).length() > 0); + + if (tableArray[n].startsWith("client_") && tableArray[n].startsWith("command_table_")) { + sub += 7; + } + + if (tableArray[n].equals("client_command_table_space")) { + sub += 5; + } + + boolean isCombatCommand = (Boolean) visitor.getObject(i, 82-sub); if (hasCharacterAbility || isCombatCommand) { CombatCommand command = new CombatCommand(name.toLowerCase()); @@ -305,7 +316,7 @@ public class CommandService implements INetworkDispatch { try { String[] tableArray = new String[] { "client_command_table", "command_table", "client_command_table_ground", "command_table_ground", - "client_command_table_space", "command_table_space", "command_table_atmospheric_flight" }; + "client_command_table_space", "command_table_space" }; for (int n = 0; n < tableArray.length; n++) { DatatableVisitor visitor = ClientFileManager.loadFile("datatables/command/" + tableArray[n] + ".iff", DatatableVisitor.class); @@ -315,8 +326,19 @@ public class CommandService implements INetworkDispatch { String commandName = ((String) visitor.getObject(i, 0)).toLowerCase(); if (commandName.equalsIgnoreCase(name)) { - boolean hasCharacterAbility = (((String) visitor.getObject(i, 7)).length() > 0); - boolean isCombatCommand = (Boolean) visitor.getObject(i, 82); + int sub = 0; + + boolean hasCharacterAbility = (((String) visitor.getObject(i, 7-sub)).length() > 0); + + if (tableArray[n].startsWith("client_") && tableArray[n].startsWith("command_table_")) { + sub += 7; + } + + if (tableArray[n].equals("client_command_table_space")) { + sub += 5; + } + + boolean isCombatCommand = (Boolean) visitor.getObject(i, 82-sub); if (hasCharacterAbility || isCombatCommand) { CombatCommand command = new CombatCommand(commandName);