Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace 0xFF characters with escaped hex (\xFF) #520

Merged
merged 1 commit into from
Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion d2bs/kolbot/D2BotChannel.dbj
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ MainLoop:
D2Bot.updateStatus("Join Game");

if (joinInfo.gameName !== "") {
print("�c2Joining �c0" + joinInfo.gameName);
print("\xFFc2Joining \xFFc0" + joinInfo.gameName);
ControlAction.setText(1, 606, 148, 155, 20, joinInfo.gamePass);
ControlAction.setText(1, 432, 148, 155, 20, joinInfo.gameName);

Expand Down
2 changes: 1 addition & 1 deletion d2bs/kolbot/D2BotFollow.dbj
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ function main() {
while (me.ingame) { // returns true before actually in game so we can't only use this check
if (me.gameReady) { // returns false when switching acts so we can't use while
if (!ingame) {
print("�c4Updating Status");
print("\xFFc4Updating Status");
//D2Bot.updateStatus("Game: " + me.gamename);

lastGameStatus = "ingame";
Expand Down
2 changes: 1 addition & 1 deletion d2bs/kolbot/D2BotLead.dbj
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ MainSwitch:
if (ControlAction.joinChannel(chanInfo.joinChannel[i])) {
useChat = true;
} else {
print("�c1Unable to join channel, disabling chat messages.");
print("\xFFc1Unable to join channel, disabling chat messages.");

useChat = false;
}
Expand Down
4 changes: 2 additions & 2 deletions d2bs/kolbot/D2BotMuleLog.dbj
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ MainSwitch:
charList = chars[0];
obj.currAcc = currAcc[0];

print("�c4Mule Logger�c2: Login account: " + currAcc[0]);
print("\xFFc4Mule Logger\xFFc2: Login account: " + currAcc[0]);
FileTools.writeText("logs/MuleLog.json", JSON.stringify(obj));
ControlAction.loginAccount({account: currAcc[0], password: currAcc[1], realm: currAcc[2]});

Expand Down Expand Up @@ -443,7 +443,7 @@ MainSwitch:
currChar = charList.shift();
obj.currChar = currChar;

print("�c4Mule Logger�c2: Login character: " + currChar);
print("\xFFc4Mule Logger\xFFc2: Login character: " + currChar);
FileTools.writeText("logs/MuleLog.json", JSON.stringify(obj));
ControlAction.loginCharacter({charName: currChar});

Expand Down
2 changes: 1 addition & 1 deletion d2bs/kolbot/D2BotPubJoin.dbj
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ MainSwitch:

for (i = 0; i < gameList.length; i += 1) {
if (doneGames.indexOf(gameList[i].gameName) === -1 && includeCheck(gameList[i].gameName) && excludeCheck(gameList[i].gameName)) {
print("�c7Game: " + gameList[i].gameName + ", Players: " + gameList[i].players);
print("\xFFc7Game: " + gameList[i].gameName + ", Players: " + gameList[i].players);

gameToJoin = gameList[i].gameName;

Expand Down
2 changes: 1 addition & 1 deletion d2bs/kolbot/default.dbj
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function main() {
}

if (Config.FastPick) {
print("�c2Fast pickit active.");
print("\xFFc2Fast pickit active.");
addEventListener("itemaction", this.itemEvent);
}

Expand Down
6 changes: 3 additions & 3 deletions d2bs/kolbot/libs/AutoMule.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,15 @@ MainLoop:
sendCopyData(null, muleObj.muleProfile, 11, "begin");

if (this.torchAnniCheck === 2) {
print("�c4AutoMule�c0: In anni mule game.");
print("\xFFc4AutoMule\xFFc0: In anni mule game.");
D2Bot.updateStatus("AutoMule: In game.");
this.dropCharm(true);
} else if (this.torchAnniCheck === 1) {
print("�c4AutoMule�c0: In torch mule game.");
print("\xFFc4AutoMule\xFFc0: In torch mule game.");
D2Bot.updateStatus("AutoMule: In game.");
this.dropCharm(false);
} else {
print("�c4AutoMule�c0: In mule game.");
print("\xFFc4AutoMule\xFFc0: In mule game.");
D2Bot.updateStatus("AutoMule: In game.");
this.dropStuff();
}
Expand Down
8 changes: 4 additions & 4 deletions d2bs/kolbot/libs/MuleLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ var MuleLogger = {

i -= 1;
} else {
if (desc[i].match(/^(y|)c/)) {
if (desc[i].match(/^(y|\xFF)c/)) {
stringColor = desc[i].substring(0, 3);
} else {
desc[i] = stringColor + desc[i];
}
}

desc[i] = desc[i].replace(/(y|)c([0-9!"+<;.*])/g, "\\xffc$2").replace("\xFF", "\\xff", "g");
desc[i] = desc[i].replace(/(y|\xFF)c([0-9!"+<;.*])/g, "\\xffc$2").replace("\xFF", "\\xff", "g");
}

if (logIlvl && desc[desc.length - 1]) {
Expand All @@ -68,7 +68,7 @@ var MuleLogger = {

inGameCheck: function () {
if (getScript("D2BotMuleLog.dbj") && this.LogGame[0] && me.gamename.match(this.LogGame[0], "i")) {
print("�c4MuleLogger�c0: Logging items on " + me.name + ".");
print("\xFFc4MuleLogger\xFFc0: Logging items on " + me.name + ".");
D2Bot.printToConsole("MuleLogger: Logging items on " + me.name + ".", 7);
this.logChar();

Expand Down Expand Up @@ -98,7 +98,7 @@ var MuleLogger = {
var i, code, desc, sock,
header = "",
color = -1,
name = unit.itemType + "_" + unit.fname.split("\n").reverse().join(" ").replace(/(y|)c[0-9!"+<;.*]|\/|\\/, "").trim();
name = unit.itemType + "_" + unit.fname.split("\n").reverse().join(" ").replace(/(y|\xFF)c[0-9!"+<;.*]|\/|\\/, "").trim();

desc = this.getItemDesc(unit, logIlvl) + "$" + unit.gid;
color = unit.getColor();
Expand Down
2 changes: 1 addition & 1 deletion d2bs/kolbot/libs/OOG.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ var D2Bot = {
args: []
};

//print("�c1Heart beat " + this.handle);
//print("\xFFc1Heart beat " + this.handle);
sendCopyData(null, this.handle, 0, JSON.stringify(obj));
},

Expand Down
4 changes: 2 additions & 2 deletions d2bs/kolbot/libs/TorchSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ var TorchSystem = {

for (i = 0; i < farmers.length; i += 1) {
if (farmers[i].FarmGame.length > 0 && me.gamename.toLowerCase().match(farmers[i].FarmGame.toLowerCase())) {
print("�c4Torch System�c0: In Farm game.");
print("\xFFc4Torch System\xFFc0: In Farm game.");
D2Bot.printToConsole("Torch System: In Farm game.", 7);
Town.goToTown(1);

Expand Down Expand Up @@ -149,7 +149,7 @@ var TorchSystem = {

for (i = 0; i < farmers.length; i += 1) {
if (farmers[i].FarmGame.length > 0 && me.gamename.toLowerCase().match(farmers[i].FarmGame.toLowerCase())) {
print("�c4Torch System�c0: In Farm game.");
print("\xFFc4Torch System\xFFc0: In Farm game.");
D2Bot.printToConsole("Torch System: Transfering keys.", 7);
D2Bot.updateStatus("Torch System: In game.");
Town.goToTown(1);
Expand Down
6 changes: 3 additions & 3 deletions d2bs/kolbot/libs/bots/ShopBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ function ShopBot() {
filename = filepath.substring(filepath.lastIndexOf("/") + 1, filepath.length);

if (!FileTools.exists(filepath)) {
Misc.errorReport("ÿc1NIP file doesn't exist: ÿc0" + filepath);
Misc.errorReport("\xFFc1NIP file doesn't exist: \xFFc0" + filepath);
return false;
}

try {
nipfile = File.open(filepath, 0);
} catch (fileError) {
Misc.errorReport("ÿc1Failed to load NIP: ÿc0" + filename);
Misc.errorReport("\xFFc1Failed to load NIP: \xFFc0" + filename);
}

if (!nipfile) {
Expand Down Expand Up @@ -250,7 +250,7 @@ function ShopBot() {
if (NTIPAliasClassID.hasOwnProperty(Config.ShopBot.ScanIDs[i].replace(/\s+/g, "").toLowerCase())) {
Config.ShopBot.ScanIDs[i] = NTIPAliasClassID[Config.ShopBot.ScanIDs[i].replace(/\s+/g, "").toLowerCase()];
} else {
Misc.errorReport("ÿc1Invalid ShopBot entry:ÿc0 " + Config.ShopBot.ScanIDs[i]);
Misc.errorReport("\xFFc1Invalid ShopBot entry:\xFFc0 " + Config.ShopBot.ScanIDs[i]);
Config.ShopBot.ScanIDs.splice(i, 1);
i -= 1;
}
Expand Down
12 changes: 6 additions & 6 deletions d2bs/kolbot/libs/common/Attack.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var Attack = {

if (Config.AttackSkill[1] < 0 || Config.AttackSkill[3] < 0) {
showConsole();
print("�c1Bad attack config. Don't expect your bot to attack.");
print("\xFFc1Bad attack config. Don't expect your bot to attack.");
}

if (me.gametype === 1) {
Expand Down Expand Up @@ -425,7 +425,7 @@ var Attack = {

// Skip non-unique monsters after 15 attacks, except in Throne of Destruction
if (me.area !== 131 && !(target.spectype & 0x7) && gidAttack[i].attacks > 15) {
print("�c1Skipping " + target.name + " " + target.gid + " " + gidAttack[i].attacks);
print("\xFFc1Skipping " + target.name + " " + target.gid + " " + gidAttack[i].attacks);
monsterList.shift();
}

Expand Down Expand Up @@ -579,7 +579,7 @@ var Attack = {

// Skip non-unique monsters after 15 attacks, except in Throne of Destruction
if (me.area !== 131 && !(target.spectype & 0x7) && gidAttack[i].attacks > 15) {
print("�c1Skipping " + target.name + " " + target.gid + " " + gidAttack[i].attacks);
print("\xFFc1Skipping " + target.name + " " + target.gid + " " + gidAttack[i].attacks);
monsterList.shift();
}

Expand Down Expand Up @@ -1434,15 +1434,15 @@ AuraLoop: // Skip monsters with auras
}
}

//print("�c9potential spots: �c2" + coords.length);
//print("\xFFc9potential spots: \xFFc2" + coords.length);

if (coords.length > 0) {
coords.sort(Sort.units);

for (i = 0; i < coords.length; i += 1) {
// Valid position found
if (!CollMap.checkColl({x: coords[i].x, y: coords[i].y}, unit, coll, 1)) {
//print("�c9optimal pos build time: �c2" + (getTickCount() - t) + " �c9distance from target: �c2" + getDistance(cx, cy, unit.x, unit.y));
//print("\xFFc9optimal pos build time: \xFFc2" + (getTickCount() - t) + " \xFFc9distance from target: \xFFc2" + getDistance(cx, cy, unit.x, unit.y));

switch (walk) {
case 1:
Expand Down Expand Up @@ -1470,7 +1470,7 @@ AuraLoop: // Skip monsters with auras
}

if (name) {
print("�c4Attack�c0: No valid positions for: " + name);
print("\xFFc4Attack\xFFc0: No valid positions for: " + name);
}

return false;
Expand Down
14 changes: 7 additions & 7 deletions d2bs/kolbot/libs/common/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var Config = {
if (CustomConfig.hasOwnProperty(n)) {
if (CustomConfig[n].indexOf(me.profile) > -1) {
if (notify) {
print("�c2Loading custom config: �c9" + n + ".js");
print("\xFFc2Loading custom config: \xFFc9" + n + ".js");
}

configFilename = n + ".js";
Expand Down Expand Up @@ -67,30 +67,30 @@ var Config = {
}
} else {
if (notify) {
print("�c1" + classes[me.classid] + "." + me.charname + ".js not found!"); // Use the primary format
print("�c1Loading default config.");
print("\xFFc1" + classes[me.classid] + "." + me.charname + ".js not found!"); // Use the primary format
print("\xFFc1Loading default config.");
}

// Try to find default config
if (!FileTools.exists("libs/config/" + classes[me.classid] + ".js")) {
D2Bot.printToConsole("Not going well? Read the wiki: https://github.com/kolton/d2bot-with-kolbot/wiki");
throw new Error("�c1Default config not found. \n�c9 Try reading the kolbot wiki.");
throw new Error("\xFFc1Default config not found. \n\xFFc9 Try reading the kolbot wiki.");
}

try {
if (!include("config/" + classes[me.classid] + ".js")) {
throw new Error();
}
} catch (e) {
throw new Error("�c1Failed to load default config.");
throw new Error("\xFFc1Failed to load default config.");
}
}

try {
LoadConfig.call();
} catch (e2) {
if (notify) {
print("�c8Error in " + e2.fileName.substring(e2.fileName.lastIndexOf("\\") + 1, e2.fileName.length) + "(line " + e2.lineNumber + "): " + e2.message);
print("\xFFc8Error in " + e2.fileName.substring(e2.fileName.lastIndexOf("\\") + 1, e2.fileName.length) + "(line " + e2.lineNumber + "): " + e2.message);

throw new Error("Config.init: Error in character config.");
}
Expand All @@ -101,7 +101,7 @@ var Config = {
AutoBuild.initialize();
}
} catch (e3) {
print("�c8Error in libs/common/AutoBuild.js (AutoBuild system is not active!)");
print("\xFFc8Error in libs/common/AutoBuild.js (AutoBuild system is not active!)");
print(e3.toSource());
}
},
Expand Down
4 changes: 2 additions & 2 deletions d2bs/kolbot/libs/common/Cubing.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ var Cubing = {
if (NTIPAliasClassID.hasOwnProperty(Config.Recipes[i][1].replace(/\s+/g, "").toLowerCase())) {
Config.Recipes[i][1] = NTIPAliasClassID[Config.Recipes[i][1].replace(/\s+/g, "").toLowerCase()];
} else {
Misc.errorReport("�c1Invalid cubing entry:�c0 " + Config.Recipes[i][1]);
Misc.errorReport("\xFFc1Invalid cubing entry:\xFFc0 " + Config.Recipes[i][1]);
Config.Recipes.splice(i, 1);

i -= 1;
Expand Down Expand Up @@ -948,7 +948,7 @@ IngredientLoop:

transmute();
delay(700 + me.ping);
print("�c4Cubing: " + string);
print("\xFFc4Cubing: " + string);
D2Bot.printToConsole(string, 5);
this.update();

Expand Down
8 changes: 4 additions & 4 deletions d2bs/kolbot/libs/common/Loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,19 @@ var Loader = {
}

if (townCheck) {
print("�c2Starting script: �c9" + i);
print("\xFFc2Starting script: \xFFc9" + i);
//scriptBroadcast(JSON.stringify({currScript: i}));
Messaging.sendToScript("tools/toolsthread.js", JSON.stringify({currScript: i}));

if (reconfiguration) {
print("�c2Copying Config properties from " + i + " object.");
print("\xFFc2Copying Config properties from " + i + " object.");
this.copy(Scripts[i], Config);
}

global[i]();

if (reconfiguration) {
print("�c2Reverting back unmodified config properties.");
print("\xFFc2Reverting back unmodified config properties.");
this.copy(unmodifiedConfig, Config);
}
}
Expand All @@ -137,7 +137,7 @@ var Loader = {
}
}
} else {
Misc.errorReport("�c1Script " + i + " doesn't exist.");
Misc.errorReport("\xFFc1Script " + i + " doesn't exist.");
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions d2bs/kolbot/libs/common/Misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1162,14 +1162,14 @@ var Misc = {

i -= 1;
} else {
if (desc[i].match(/^(y|)c/)) {
if (desc[i].match(/^(y|\xFF)c/)) {
stringColor = desc[i].substring(0, 3);
} else {
desc[i] = stringColor + desc[i];
}
}

desc[i] = desc[i].replace(/(y|)c([0-9!"+<;.*])/g, "\\xffc$2");
desc[i] = desc[i].replace(/(y|\xFF)c([0-9!"+<;.*])/g, "\\xffc$2");
}

if (desc[desc.length - 1]) {
Expand Down Expand Up @@ -1268,7 +1268,7 @@ var Misc = {
return false;
}

desc = this.getItemDesc(unit).split("\n").join(" | ").replace(/(\\xff|)c[0-9!"+<;.*]/gi, "").trim();
desc = this.getItemDesc(unit).split("\n").join(" | ").replace(/(\\xff|\xFF)c[0-9!"+<;.*]/gi, "").trim();

break;
case "Kept":
Expand All @@ -1278,15 +1278,15 @@ var Misc = {
case "Shopped":
case "Gambled":
case "Dropped":
desc = this.getItemDesc(unit).split("\n").join(" | ").replace(/(\\xff|)c[0-9!"+<;.*]|\/|\\/gi, "").trim();
desc = this.getItemDesc(unit).split("\n").join(" | ").replace(/(\\xff|\xFF)c[0-9!"+<;.*]|\/|\\/gi, "").trim();

break;
case "No room for":
desc = unit.name;

break;
default:
desc = unit.fname.split("\n").reverse().join(" ").replace(/(\\xff|)c[0-9!"+<;.*]|\/|\\/gi, "").trim();
desc = unit.fname.split("\n").reverse().join(" ").replace(/(\\xff|\xFF)c[0-9!"+<;.*]|\/|\\/gi, "").trim();

break;
}
Expand All @@ -1302,7 +1302,7 @@ var Misc = {

var i, lastArea, code, desc, sock, itemObj,
color = -1,
name = unit.fname.split("\n").reverse().join(" ").replace(/�c[0-9!"+<;.*]|\/|\\/, "").trim();
name = unit.fname.split("\n").reverse().join(" ").replace(/\xFFc[0-9!"+<;.*]|\/|\\/, "").trim();

desc = this.getItemDesc(unit);
color = unit.getColor();
Expand Down Expand Up @@ -1757,13 +1757,13 @@ MainLoop:

if (typeof error === "string") {
msg = error;
oogmsg = error.replace(/�c[0-9!"+<;.*]/gi, "");
filemsg = "[" + (h < 10 ? "0" + h : h) + ":" + (m < 10 ? "0" + m : m) + ":" + (s < 10 ? "0" + s : s) + "] <" + me.profile + "> " + error.replace(/�c[0-9!"+<;.*]/gi, "") + "\n";
oogmsg = error.replace(/\xFFc[0-9!"+<;.*]/gi, "");
filemsg = "[" + (h < 10 ? "0" + h : h) + ":" + (m < 10 ? "0" + m : m) + ":" + (s < 10 ? "0" + s : s) + "] <" + me.profile + "> " + error.replace(/\xFFc[0-9!"+<;.*]/gi, "") + "\n";
} else {
source = error.fileName.substring(error.fileName.lastIndexOf("\\") + 1, error.fileName.length);
msg = "�c1Error in �c0" + script + " �c1(" + source + " line �c1" + error.lineNumber + "): �c1" + error.message;
msg = "\xFFc1Error in \xFFc0" + script + " \xFFc1(" + source + " line \xFFc1" + error.lineNumber + "): \xFFc1" + error.message;
oogmsg = " Error in " + script + " (" + source + " #" + error.lineNumber + ") " + error.message + " (Area: " + me.area + ", Ping:" + me.ping + ", Game: " + me.gamename + ")";
filemsg = "[" + (h < 10 ? "0" + h : h) + ":" + (m < 10 ? "0" + m : m) + ":" + (s < 10 ? "0" + s : s) + "] <" + me.profile + "> " + msg.replace(/�c[0-9!"+<;.*]/gi, "") + "\n";
filemsg = "[" + (h < 10 ? "0" + h : h) + ":" + (m < 10 ? "0" + m : m) + ":" + (s < 10 ? "0" + s : s) + "] <" + me.profile + "> " + msg.replace(/\xFFc[0-9!"+<;.*]/gi, "") + "\n";

if (error.hasOwnProperty("stack")) {
stack = error.stack;
Expand Down
Loading