Skip to content

Commit

Permalink
Unicode basic support
Browse files Browse the repository at this point in the history
  • Loading branch information
CaiMiao committed May 1, 2021
1 parent 32d66ca commit f0ef109
Show file tree
Hide file tree
Showing 12 changed files with 141 additions and 141 deletions.
2 changes: 1 addition & 1 deletion BH/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#define BH_VERSION "BH 1.9.10-b3"

#define CODE_PAGE 1252 // windows-1252 ANSI Latin 1; Western European (Windows)
#define CODE_PAGE 65001 // windows-1252 ANSI Latin 1; Western European (Windows)

enum TextColor {
Disabled=-1,
Expand Down
2 changes: 1 addition & 1 deletion BH/D2Strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -4044,7 +4044,7 @@ enum D2ClassicStrings : unsigned short {
D2STR_NOWAYPOINTS = 3991, // No Other Waypoints Activated
D2STR_MAX = 3992, // MAX
D2STR_MAX2 = 3993, // MAX
D2STR_COLORCODE = 3994, // ÿc - also "\377c"
D2STR_COLORCODE = 3994, // ÿc - also "ÿc"
D2STR_SPACE = 3995, //
D2STR_DASH = 3996, // -
D2STR_COLON = 3997, // :
Expand Down
4 changes: 2 additions & 2 deletions BH/Drawing/Advanced/Inputhook/Inputhook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ unsigned int Inputhook::GetCharacterLimit() {


if (IsSelected()) {
drawnText.insert(GetSelectionPosition() + GetSelectionLength(), "ÿc0");
drawnText.insert(GetSelectionPosition(), "ÿc9");
drawnText.insert(GetSelectionPosition() + GetSelectionLength(), "ÿc0");
drawnText.insert(GetSelectionPosition(), "ÿc9");
}


Expand Down
6 changes: 3 additions & 3 deletions BH/Drawing/Advanced/Keyhook/Keyhook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ void Keyhook::OnDraw() {
bool IsInRange = InRange(*p_D2CLIENT_MouseX, *p_D2CLIENT_MouseY);
if (name.length() > 0) {
if(IsInRange)
prefix = name + "\377c7 ";
prefix = name + "ÿc7 ";
else
prefix = name + "\377c4 ";
prefix = name + "ÿc4 ";
}

string text = prefix + keyCode.literalName;
Expand Down Expand Up @@ -86,7 +86,7 @@ unsigned int Keyhook::GetXSize() {
KeyCode keyCode = GetKeyCode(GetKey());
string prefix = "";
if (name.length() > 0)
prefix = name + ":ÿc4 ";
prefix = name + ":�c4 ";
string text = prefix + keyCode.literalName;
DWORD width, fileNo;
wchar_t* wString = AnsiToUnicode(text.c_str());
Expand Down
74 changes: 37 additions & 37 deletions BH/Drawing/Stats/StatsDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ void StatsDisplay::OnDraw() {
Drawing::Framehook::DrawRectStub(&pRect);

Texthook::Draw(column1, (y += 8), None, 6, Gold,
"Name:\377c0 %s",
isMerc ? "\377c;Mercenary" : unit->pPlayerData->szName);
"Name:ÿc0 %s",
isMerc ? "ÿc;Mercenary" : unit->pPlayerData->szName);
Texthook::Draw(pRect.right - 5, y, Right, 6, Gold,
L"Level:\377c0 %d",
L"Level:ÿc0 %d",
(int)D2COMMON_GetUnitStat(unit, STAT_LEVEL, 0));
Texthook::Draw(pRect.right - 5, y + 12, Right, 6, Gold,
L"Additional XP:\377c: %d%%",
L"Additional XP:ÿc: %d%%",
(int)D2COMMON_GetUnitStat(unit, STAT_ADDEXPERIENCE, 0));

y += 8;
Expand All @@ -166,11 +166,11 @@ void StatsDisplay::OnDraw() {
int pMax = (int)D2COMMON_GetUnitStat(unit, STAT_MAXPOISONRESIST, 0) + 75;
int pLengthReduce = (int)D2COMMON_GetUnitStat(unit, STAT_POISONLENGTHREDUCTION, 0);

Texthook::Draw(column1, (y += 16), None, 6, Red, L"\377c4Fire Resist:\377c1 %d \377c0/ %d", (int)D2COMMON_GetUnitStat(unit, STAT_FIRERESIST, 0) + penalty, fMax);
Texthook::Draw(column1, (y += 16), None, 6, Blue, L"\377c4Cold Resist:\377c3 %d \377c0/ %d", (int)D2COMMON_GetUnitStat(unit, STAT_COLDRESIST, 0) + penalty, cMax);
Texthook::Draw(column1, (y += 16), None, 6, Yellow, L"\377c4Lightning Resist:\377c9 %d \377c0/ %d", (int)D2COMMON_GetUnitStat(unit, STAT_LIGHTNINGRESIST, 0) + penalty, lMax);
Texthook::Draw(column1, (y += 16), None, 6, Red, L"ÿc4Fire Resist:ÿc1 %d ÿc0/ %d", (int)D2COMMON_GetUnitStat(unit, STAT_FIRERESIST, 0) + penalty, fMax);
Texthook::Draw(column1, (y += 16), None, 6, Blue, L"ÿc4Cold Resist:ÿc3 %d ÿc0/ %d", (int)D2COMMON_GetUnitStat(unit, STAT_COLDRESIST, 0) + penalty, cMax);
Texthook::Draw(column1, (y += 16), None, 6, Yellow, L"ÿc4Lightning Resist:ÿc9 %d ÿc0/ %d", (int)D2COMMON_GetUnitStat(unit, STAT_LIGHTNINGRESIST, 0) + penalty, lMax);
Texthook::Draw(column1, (y += 16), None, 6, Gold,
L"Poison Resist:\377c2 %d \377c0/ %d \377c4Length:\377c: %d%%",
L"Poison Resist:ÿc2 %d ÿc0/ %d ÿc4Length:ÿc: %d%%",
(int)D2COMMON_GetUnitStat(unit, STAT_POISONRESIST, 0) + penalty,
pMax,
(100 - penalty - pLengthReduce)
Expand All @@ -185,13 +185,13 @@ void StatsDisplay::OnDraw() {
int lAbsorbPct = (int)D2COMMON_GetUnitStat(unit, STAT_LIGHTNINGABSORBPERCENT, 0);
int mAbsorb = (int)D2COMMON_GetUnitStat(unit, STAT_MAGICABSORB, 0);
int mAbsorbPct = (int)D2COMMON_GetUnitStat(unit, STAT_MAGICABSORBPERCENT, 0);
Texthook::Draw(column1, (y += 16), None, 6, Red, L"\377c4Absorption: \377c1%d\377c0/\377c1%d%c \377c3%d\377c0/\377c3%d%c \377c9%d\377c0/\377c9%d%c \377c8%d\377c0/\377c8%d%c", fAbsorb, fAbsorbPct, '%', cAbsorb, cAbsorbPct, '%', lAbsorb, lAbsorbPct, '%', mAbsorb, mAbsorbPct, '%');
Texthook::Draw(column1, (y += 16), None, 6, Red, L"ÿc4Absorption: ÿc1%dÿc0/ÿc1%d%c ÿc3%dÿc0/ÿc3%d%c ÿc9%dÿc0/ÿc9%d%c ÿc8%dÿc0/ÿc8%d%c", fAbsorb, fAbsorbPct, '%', cAbsorb, cAbsorbPct, '%', lAbsorb, lAbsorbPct, '%', mAbsorb, mAbsorbPct, '%');

int dmgReduction = (int)D2COMMON_GetUnitStat(unit, STAT_DMGREDUCTION, 0);
int dmgReductionPct = (int)D2COMMON_GetUnitStat(unit, STAT_DMGREDUCTIONPCT, 0);
int magReduction = (int)D2COMMON_GetUnitStat(unit, STAT_MAGICDMGREDUCTION, 0);
int magReductionPct = (int)D2COMMON_GetUnitStat(unit, STAT_MAGICDMGREDUCTIONPCT, 0);
Texthook::Draw(column1, (y += 16), None, 6, Tan, L"\377c4Damage Reduction: \377c7%d\377c0/\377c7%d%c \377c8%d\377c0/\377c8%d%c", dmgReduction, dmgReductionPct, '%', magReduction, magReductionPct, '%');
Texthook::Draw(column1, (y += 16), None, 6, Tan, L"ÿc4Damage Reduction: ÿc7%dÿc0/ÿc7%d%c ÿc8%dÿc0/ÿc8%d%c", dmgReduction, dmgReductionPct, '%', magReduction, magReductionPct, '%');
y += 8;

int fMastery = (int)D2COMMON_GetUnitStat(unit, STAT_FIREMASTERY, 0);
Expand All @@ -206,29 +206,29 @@ void StatsDisplay::OnDraw() {
int pPierce = (int)D2COMMON_GetUnitStat(unit, STAT_PSENEMYPSNRESREDUC, 0);
int mPierce = (int)D2COMMON_GetUnitStat(unit, STAT_PASSIVEMAGICRESREDUC, 0);
Texthook::Draw(column1, (y += 16), None, 6, Gold,
L"Elemental Mastery:\377c1 %d%%\377c3 %d%%\377c9 %d%%\377c2 %d%%\377c8 %d%%",
L"Elemental Mastery:ÿc1 %d%%ÿc3 %d%%ÿc9 %d%%ÿc2 %d%%ÿc8 %d%%",
fMastery, cMastery, lMastery, pMastery, mMastery);
Texthook::Draw(column1, (y += 16), None, 6, Gold,
L"Elemental Pierce:\377c1 %d%%\377c3 %d%%\377c9 %d%%\377c2 %d%%\377c8 %d%%",
L"Elemental Pierce:ÿc1 %d%%ÿc3 %d%%ÿc9 %d%%ÿc2 %d%%ÿc8 %d%%",
fPierce, cPierce, lPierce, pPierce, mPierce);
int classNum = pData->nCharClass;
auto classArMod = CharList[classNum]->toHitFactor - 35;
int dexAR = (int)D2COMMON_GetUnitStat(unit, STAT_DEXTERITY, 0) * 5 + classArMod;
int gearAR = (int)D2COMMON_GetUnitStat(unit, STAT_ATTACKRATING, 0);

Texthook::Draw(column1, (y += 16), None, 6, Gold,
L"Base AR:\377c5 dex:\377c0 %d\377c5 equip:\377c0% d\377c5 total:\377c0 %d",
L"Base AR:ÿc5 dex:ÿc0 %dÿc5 equip:ÿc0% dÿc5 total:ÿc0 %d",
dexAR, gearAR, dexAR + gearAR);

int gearDef = (int)D2COMMON_GetUnitStat(unit, STAT_DEFENSE, 0);
int dexDef = (int)D2COMMON_GetUnitStat(unit, STAT_DEXTERITY, 0) / 4;

Texthook::Draw(column1, (y += 16), None, 6, Gold,
L"Base Def:\377c5 dex:\377c0 %d\377c5 equip:\377c0 %d\377c5 total:\377c0 %d",
L"Base Def:ÿc5 dex:ÿc0 %dÿc5 equip:ÿc0 %dÿc5 total:ÿc0 %d",
dexDef, gearDef, dexDef + gearDef);

Texthook::Draw(column1, (y += 16), None, 6, Gold,
L"Base Damage:\377c5 1h:\377c0 %d-%d\377c5 2h:\377c0 %d-%d",
L"Base Damage:ÿc5 1h:ÿc0 %d-%dÿc5 2h:ÿc0 %d-%d",
(int)D2COMMON_GetUnitStat(unit, STAT_MINIMUMDAMAGE, 0),
(int)D2COMMON_GetUnitStat(unit, STAT_MAXIMUMDAMAGE, 0),
(int)D2COMMON_GetUnitStat(unit, STAT_SECONDARYMINIMUMDAMAGE, 0),
Expand All @@ -237,50 +237,50 @@ void StatsDisplay::OnDraw() {
y += 8;

Texthook::Draw(column1, (y += 16), None, 6, Gold,
L"Cast Rate:\377c0 %d",
L"Cast Rate:ÿc0 %d",
(int)D2COMMON_GetUnitStat(unit, STAT_FASTERCAST, 0)
);
Texthook::Draw(column2, y, None, 6, Gold,
L"Block Rate:\377c0 %d",
L"Block Rate:ÿc0 %d",
(int)D2COMMON_GetUnitStat(unit, STAT_FASTERBLOCK, 0)
);
Texthook::Draw(column1, (y += 16), None, 6, Gold,
L"Hit Recovery:\377c0 %d",
L"Hit Recovery:ÿc0 %d",
(int)D2COMMON_GetUnitStat(unit, STAT_FASTERHITRECOVERY, 0)
);
Texthook::Draw(column2, y, None, 6, Gold,
L"Run/Walk:\377c0 %d",
L"Run/Walk:ÿc0 %d",
(int)D2COMMON_GetUnitStat(unit, STAT_FASTERRUNWALK, 0)
);
Texthook::Draw(column1, (y += 16), None, 6, Gold,
L"Attack Rate:\377c0 %d",
L"Attack Rate:ÿc0 %d",
(int)D2COMMON_GetUnitStat(unit, STAT_ATTACKRATE, 0));
Texthook::Draw(column2, y, None, 6, Gold,
L"IAS:\377c0 %d",
L"IAS:ÿc0 %d",
(int)D2COMMON_GetUnitStat(unit, STAT_IAS, 0));

y += 8;

Texthook::Draw(column1, (y += 16), None, 6, Gold,
L"Crushing Blow:\377c0 %d",
L"Crushing Blow:ÿc0 %d",
(int)D2COMMON_GetUnitStat(unit, STAT_CRUSHINGBLOW, 0));
Texthook::Draw(column2, y, None, 6, Gold,
L"Open Wounds: \377c0%d",
L"Open Wounds: ÿc0%d",
(int)D2COMMON_GetUnitStat(unit, STAT_OPENWOUNDS, 0));
Texthook::Draw(column1, (y += 16), None, 6, Gold,
L"Deadly Strike:\377c0 %d",
L"Deadly Strike:ÿc0 %d",
(int)D2COMMON_GetUnitStat(unit, STAT_DEADLYSTRIKE, 0));
Texthook::Draw(column2, y, None, 6, Gold,
L"Critical Strike: \377c0%d",
L"Critical Strike: ÿc0%d",
(int)D2COMMON_GetUnitStat(unit, STAT_CRITICALSTRIKE, 0));
Texthook::Draw(column1, (y += 16), None, 6, Gold,
L"Life Leech:\377c1 %d",
L"Life Leech:ÿc1 %d",
(int)D2COMMON_GetUnitStat(unit, STAT_LIFELEECH, 0));
Texthook::Draw(column2, y, None, 6, Gold,
L"Mana Leech:\377c3 %d",
L"Mana Leech:ÿc3 %d",
(int)D2COMMON_GetUnitStat(unit, STAT_MANALEECH, 0));
Texthook::Draw(column1, (y += 16), None, 6, Gold,
L"Projectile Pierce:\377c0 %d",
L"Projectile Pierce:ÿc0 %d",
(int)D2COMMON_GetUnitStat(unit, STAT_PIERCINGATTACK, 0) +
(int)D2COMMON_GetUnitStat(unit, STAT_PIERCE, 0)
);
Expand All @@ -304,7 +304,7 @@ void StatsDisplay::OnDraw() {
int maxMagic = (int)D2COMMON_GetUnitStat(unit, STAT_MAXIMUMMAGICALDAMAGE, 0);
int addedPhys = (int)D2COMMON_GetUnitStat(unit, STAT_ADDSDAMAGE, 0);
Texthook::Draw(column1, (y += 16), None, 6, Gold,
L"Added Damage:\377c0 %d",
L"Added Damage:ÿc0 %d",
addedPhys);
Texthook::Draw(column2, y, None, 6, Orange,
"%d-%d",
Expand All @@ -327,43 +327,43 @@ void StatsDisplay::OnDraw() {
y += 8;

Texthook::Draw(column1, (y += 16), None, 6, Gold,
L"Magic Find:\377c3 %d",
L"Magic Find:ÿc3 %d",
(int)D2COMMON_GetUnitStat(unit, STAT_MAGICFIND, 0)
);
Texthook::Draw(column2, y, None, 6, Gold,
L"Gold Find:\377c9 %d",
L"Gold Find:ÿc9 %d",
(int)D2COMMON_GetUnitStat(unit, STAT_GOLDFIND, 0));

Texthook::Draw(column1, (y += 16), None, 6, Gold,
L"Stash Gold:\377c9 %d",
L"Stash Gold:ÿc9 %d",
(int)D2COMMON_GetUnitStat(unit, STAT_GOLDBANK, 0));

void* quests = D2CLIENT_GetQuestInfo();

Texthook::Draw(column2, y, None, 6, Gold,
L"Cow King:\377c0 %s", D2COMMON_GetQuestFlag(quests, THE_SEARCH_FOR_CAIN, QFLAG_CUSTOM_6) ? L"killed" : L"alive");
L"Cow King:ÿc0 %s", D2COMMON_GetQuestFlag(quests, THE_SEARCH_FOR_CAIN, QFLAG_CUSTOM_6) ? L"killed" : L"alive");

bool hasAndyQuest = D2COMMON_GetQuestFlag(quests, SISTERS_TO_THE_SLAUGHTER, QFLAG_UPDATE_QUEST_LOG)
| D2COMMON_GetQuestFlag(quests, SISTERS_TO_THE_SLAUGHTER, QFLAG_QUEST_COMPLETED_BEFORE);
bool hasDuryQuest = D2COMMON_GetQuestFlag(quests, THE_SEVEN_TOMBS, QFLAG_UPDATE_QUEST_LOG)
| D2COMMON_GetQuestFlag(quests, THE_SEVEN_TOMBS, QFLAG_QUEST_COMPLETED_BEFORE);

Texthook::Draw(column1, (y += 16), None, 6, Gold,
L"Andy Bugged:\377c0 %s", !hasAndyQuest ? L"n/a" : (D2COMMON_GetQuestFlag(quests, SISTERS_TO_THE_SLAUGHTER, QFLAG_QUEST_COMPLETED_BEFORE) ? L"no" : L"yes"));
L"Andy Bugged:ÿc0 %s", !hasAndyQuest ? L"n/a" : (D2COMMON_GetQuestFlag(quests, SISTERS_TO_THE_SLAUGHTER, QFLAG_QUEST_COMPLETED_BEFORE) ? L"no" : L"yes"));

Texthook::Draw(column2, y, None, 6, Gold,
L"Dury Bugged:\377c0 %s", !hasDuryQuest ? L"n/a" : (D2COMMON_GetQuestFlag(quests, THE_SEVEN_TOMBS, QFLAG_CUSTOM_1) ? L"no" : L"yes"));
L"Dury Bugged:ÿc0 %s", !hasDuryQuest ? L"n/a" : (D2COMMON_GetQuestFlag(quests, THE_SEVEN_TOMBS, QFLAG_CUSTOM_1) ? L"no" : L"yes"));

if (customStats.size() > 0) {
y += 8;
for (unsigned int i = 0; i < customStats.size(); i++) {
int secondary = customStats[i]->useValue ? customStats[i]->value : 0;
int stat = (int)D2COMMON_GetUnitStat(unit, STAT_NUMBER(customStats[i]->name), secondary);
if (secondary > 0) {
Texthook::Draw(column1, (y += 16), None, 6, Gold, "%s[%d]:\377c0 %d",
Texthook::Draw(column1, (y += 16), None, 6, Gold, "%s[%d]:ÿc0 %d",
customStats[i]->name.c_str(), secondary, stat);
} else {
Texthook::Draw(column1, (y += 16), None, 6, Gold, "%s:\377c0 %d",
Texthook::Draw(column1, (y += 16), None, 6, Gold, "%s:ÿc0 %d",
customStats[i]->name.c_str(), stat);
}
}
Expand Down
20 changes: 10 additions & 10 deletions BH/Modules/AutoTele/AutoTele.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void AutoTele::OnLoop() {
if(SetTele) {
if(!SetSkill(0x36, 0)) { //0x36 is teleport
TPath.RemoveAll();
PrintText(1, "ÿc4AutoTele:ÿc1 Failed to set teleport!");
PrintText(1, "ÿc4AutoTele:ÿc1 Failed to set teleport!");
}
_timer = GetTickCount();
SetTele = 0;
Expand All @@ -153,12 +153,12 @@ void AutoTele::OnLoop() {
if(TeleActive) {
TeleActive = 0;
TPath.RemoveAll();
PrintText(1, "ÿc4AutoTele:ÿc1 Aborting teleport, deselected teleport");
PrintText(1, "ÿc4AutoTele:ÿc1 Aborting teleport, deselected teleport");
return;
}
if((GetTickCount() - _timer) > 1000) {
TPath.RemoveAll();
PrintText(1, "ÿc4AutoTele:ÿc1 Failed to set teleport skill. Ping: %d", *p_D2CLIENT_Ping);
PrintText(1, "ÿc4AutoTele:ÿc1 Failed to set teleport skill. Ping: %d", *p_D2CLIENT_Ping);
return;
}
return;
Expand All @@ -175,7 +175,7 @@ void AutoTele::OnLoop() {

if((GetTickCount() - _timer2) > 500) {
if(Try >= 5) {
PrintText(1, "ÿc4AutoTele:ÿc1 Failed to teleport after 5 tries");
PrintText(1, "ÿc4AutoTele:ÿc1 Failed to teleport after 5 tries");
TPath.RemoveAll();
Try = 0;
DoInteract = 0;
Expand Down Expand Up @@ -379,7 +379,7 @@ void AutoTele::ManageTele(Vector T) {
}

if(!T.Id) {
PrintText(1, "ÿc4AutoTele:ÿc1 Invalid destination");
PrintText(1, "ÿc4AutoTele:ÿc1 Invalid destination");
return;
}

Expand Down Expand Up @@ -415,7 +415,7 @@ void AutoTele::ManageTele(Vector T) {
} else DoInteract = 0;

int nodes = MakePath(ExitArray[i]->ptPos.x, ExitArray[i]->ptPos.y, Areas, AreaCount, ExitArray[i]->dwType == EXIT_LEVEL ? 1: 0);
PrintText(1, "ÿc4AutoTele:ÿc1 Going to %s, %d nodes.", lvltext->szName, nodes);
PrintText(1, "ÿc4AutoTele:ÿc1 Going to %s, %d nodes.", lvltext->szName, nodes);
break;
}
}
Expand All @@ -425,11 +425,11 @@ void AutoTele::ManageTele(Vector T) {
if(T.dwType == XY) {
DoInteract = 0;
if(!T.Id || !T.Id2) {
PrintText(1, "ÿc4AutoTele:ÿc1 No X/Y value found");
PrintText(1, "ÿc4AutoTele:ÿc1 No X/Y value found");
return;
}
int nodes = MakePath(T.Id, T.Id2, Areas, AreaCount, 0);
PrintText(1, "ÿc4AutoTele:ÿc1 Going to X: %d, Y: %d, %d nodes", T.Id, T.Id2, nodes);
PrintText(1, "ÿc4AutoTele:ÿc1 Going to X: %d, Y: %d, %d nodes", T.Id, T.Id2, nodes);
return;
}

Expand All @@ -451,13 +451,13 @@ void AutoTele::ManageTele(Vector T) {
if(nodes = MakePath(PresetUnit.x,PresetUnit.y, Areas, AreaCount, 0)) {
if(T.dwType == UNIT_OBJECT) {
ObjectTxt * ObjTxt = D2COMMON_GetObjectTxt(T.Id);
PrintText(1, "ÿc4AutoTele:ÿc1 Going to %s, %d nodes", ObjTxt->szName, nodes);
PrintText(1, "ÿc4AutoTele:ÿc1 Going to %s, %d nodes", ObjTxt->szName, nodes);
}
InteractType = T.dwType;
}
else return;
} else {
PrintText(1, "ÿc4AutoTele:ÿc1 Can't find object");
PrintText(1, "ÿc4AutoTele:ÿc1 Can't find object");
return;
}
}
Expand Down
Loading

0 comments on commit f0ef109

Please sign in to comment.