diff --git a/2006Redone Server/src/redone/game/bots/Bot.java b/2006Redone Server/src/redone/game/bots/Bot.java index 72dac92f..1df1608e 100644 --- a/2006Redone Server/src/redone/game/bots/Bot.java +++ b/2006Redone Server/src/redone/game/bots/Bot.java @@ -3,12 +3,8 @@ package redone.game.bots; import redone.Server; import redone.game.items.ItemAssistant; import redone.game.players.Client; -import redone.game.players.Player; -import redone.game.players.PlayerHandler; -import redone.util.GameLogger; import redone.util.Misc; -import java.nio.charset.StandardCharsets; import java.text.DecimalFormat; import java.util.*; @@ -68,23 +64,20 @@ public class Bot { String item_name = ItemAssistant.getItemName(item_id).toLowerCase(); int value = BotHandler.getItemPrice(botClient.myShopId, item_id); if (value <= 0) return; - botClient.forcedChat("Selling " + item_name + " " + formatSellPrice(value) + " ea"); - /* - Real chat - Disabled for now, can't get it to function correctly - // Add some color and effects - botClient.setChatTextColor(9); - botClient.setChatTextEffects(2); + String _message = "Selling " + item_name + " " + formatSellPrice(value) + " ea - " + botClient.playerName; - String message = "Selling " + item_name + " " + formatSellPrice(value) + " ea - " + botClient.playerName; - // Need to figure out how to calculate this - botClient.setChatTextSize((byte) 29); - // This is wrong too - botClient.setChatText(message.getBytes(StandardCharsets.UTF_8)); - // Not a clue what this does - botClient.inStream.readBytes_reverseA(botClient.getChatText(), botClient.getChatTextSize(), 0); + // Disable the force chat for now, maybe use that instead, maybe not + //botClient.forcedChat("Selling " + item_name + " " + formatSellPrice(value) + " ea"); + + // Normal chat from here down: + botClient.setChatTextColor(Misc.random(11)); + botClient.setChatTextEffects(Misc.random(5)); + Misc.textPack(botClient.inStream, _message); + botClient.setChatTextSize((byte) botClient.inStream.currentOffset); + botClient.setChatText(botClient.inStream.buffer); + botClient.inStream.currentOffset = 0; botClient.setChatTextUpdateRequired(true); - */ } private String formatSellPrice(int price) { diff --git a/2006Redone Server/src/redone/util/Misc.java b/2006Redone Server/src/redone/util/Misc.java index 311fa4b5..7c6caf06 100644 --- a/2006Redone Server/src/redone/util/Misc.java +++ b/2006Redone Server/src/redone/util/Misc.java @@ -218,14 +218,14 @@ public class Misc { return new String(buf, 0, buf.length); } - public static void textPack(byte packedData[], java.lang.String text) { + public static void textPack(Stream inStream, String text) { if (text.length() > 80) { text = text.substring(0, 80); } text = text.toLowerCase(); int carryOverNibble = -1; - int ofs = 0; + inStream.currentOffset = 0; for (int idx = 0; idx < text.length(); idx++) { char c = text.charAt(idx); int tableIdx = 0; @@ -242,19 +242,19 @@ public class Misc { if (tableIdx < 13) { carryOverNibble = tableIdx; } else { - packedData[ofs++] = (byte) tableIdx; + inStream.buffer[inStream.currentOffset++] = (byte) tableIdx; } } else if (tableIdx < 13) { - packedData[ofs++] = (byte) ((carryOverNibble << 4) + tableIdx); + inStream.buffer[inStream.currentOffset++] = (byte) ((carryOverNibble << 4) + tableIdx); carryOverNibble = -1; } else { - packedData[ofs++] = (byte) ((carryOverNibble << 4) + (tableIdx >> 4)); + inStream.buffer[inStream.currentOffset++] = (byte) ((carryOverNibble << 4) + (tableIdx >> 4)); carryOverNibble = tableIdx & 0xf; } } if (carryOverNibble != -1) { - packedData[ofs++] = (byte) (carryOverNibble << 4); + inStream.buffer[inStream.currentOffset++] = (byte) (carryOverNibble << 4); } } diff --git a/2006Redone Server/src/redone/util/Stream.java b/2006Redone Server/src/redone/util/Stream.java index 00c33293..3047baba 100644 --- a/2006Redone Server/src/redone/util/Stream.java +++ b/2006Redone Server/src/redone/util/Stream.java @@ -161,7 +161,6 @@ public class Stream { for (int k = j + i - 1; k >= j; k--) { buffer[currentOffset++] = abyte0[k]; } - } public void readBytes_reverseA(byte abyte0[], int i, int j) { diff --git a/CompiledServer/production/2006rebotted/redone/game/bots/Bot$TradeChat.class b/CompiledServer/production/2006rebotted/redone/game/bots/Bot$TradeChat.class index 427a389f..60466775 100644 Binary files a/CompiledServer/production/2006rebotted/redone/game/bots/Bot$TradeChat.class and b/CompiledServer/production/2006rebotted/redone/game/bots/Bot$TradeChat.class differ diff --git a/CompiledServer/production/2006rebotted/redone/game/bots/Bot.class b/CompiledServer/production/2006rebotted/redone/game/bots/Bot.class index 30e49ec9..626ebff0 100644 Binary files a/CompiledServer/production/2006rebotted/redone/game/bots/Bot.class and b/CompiledServer/production/2006rebotted/redone/game/bots/Bot.class differ diff --git a/CompiledServer/production/2006rebotted/redone/util/Misc.class b/CompiledServer/production/2006rebotted/redone/util/Misc.class index b4ef0eb7..b8712011 100644 Binary files a/CompiledServer/production/2006rebotted/redone/util/Misc.class and b/CompiledServer/production/2006rebotted/redone/util/Misc.class differ diff --git a/CompiledServer/production/2006rebotted/redone/util/Stream.class b/CompiledServer/production/2006rebotted/redone/util/Stream.class index f15ce7fb..daefadd8 100644 Binary files a/CompiledServer/production/2006rebotted/redone/util/Stream.class and b/CompiledServer/production/2006rebotted/redone/util/Stream.class differ