Skip to content

Commit

Permalink
Merge pull request #27 from ejt1/stability
Browse files Browse the repository at this point in the history
UTF8
  • Loading branch information
ejt1 authored Feb 17, 2024
2 parents 490c86e + 824a651 commit 22132a9
Show file tree
Hide file tree
Showing 21 changed files with 152 additions and 359 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ project(d2bs)

option(MOZJS_USE_PREBUILT "Use the prebuilt release library of mozjs (vendor/mozjs-prebuilt)" OFF)

#add_subdirectory(sandbox)
add_subdirectory(vendor)

if (NOT CMAKE_BUILD_TYPE)
Expand Down Expand Up @@ -106,7 +105,7 @@ set(D2BS_SRCS

add_library(D2BS SHARED ${D2BS_SRCS})

target_compile_options(D2BS PRIVATE /W4)
target_compile_options(D2BS PRIVATE /W4 /utf-8)

target_include_directories(D2BS PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/src"
Expand Down
8 changes: 5 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe",
"MOZJS_USE_PREBUILT": true
"CMAKE_CXX_COMPILER": "cl.exe"
},
"condition": {
"type": "equals",
Expand All @@ -35,7 +34,10 @@
"displayName": "x86 Distribute",
"description": "Target Windows (32-bit) with the Visual Studio development environment.",
"inherits": "x86-debug",
"cacheVariables": { "CMAKE_BUILD_TYPE": "Release" }
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"MOZJS_USE_PREBUILT": true
}
},
{
"name": "x86-relwithdebinfo",
Expand Down
5 changes: 4 additions & 1 deletion dist/d2bs/kolbot/libs/SoloPlay/Functions/AttackOverrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,10 @@ Attack.pwnDia = function () {
if (me.mp > manaStatic + manaTP + manaTP
&& diabloMissiles.length < 3 && !dia.attacking
&& dia.hpPercent > Config.CastStatic) {
let [x, y] = me;
// BUG: me is not iterable
//let [x, y] = me;
let x = me.x;
let y = me.y;
ClassAttack.switchCurse(dia, true); // curse him if we can
// re-check his mode
if (!dia.attacking) {
Expand Down
3 changes: 0 additions & 3 deletions sandbox/CMakeLists.txt

This file was deleted.

124 changes: 0 additions & 124 deletions sandbox/main.cpp

This file was deleted.

14 changes: 5 additions & 9 deletions src/Engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void Engine::OnGameEntered() {
if (!Vars.bUseProfileScript) {
const char* starter = GetStarterScriptName();
if (starter != NULL) {
Print("ÿc2D2BSÿc0 :: Starting %s", starter);
Print("\u00FFc2D2BS\u00FFc0 :: Starting %s", starter);
if (StartScript(starter, GetStarterScriptState()))
Print("ÿc2D2BSÿc0 :: %s running.", starter);
else
Expand All @@ -240,7 +240,7 @@ void Engine::OnMenuEntered(bool beginStarter) {
if (beginStarter && !Vars.bUseProfileScript) {
const char* starter = GetStarterScriptName();
if (starter != NULL) {
Print("ÿc2D2BSÿc0 :: Starting %s", starter);
Print("\u00FFc2D2BS\u00FFc0 :: Starting %s", starter);
if (StartScript(starter, GetStarterScriptState()))
Print("ÿc2D2BSÿc0 :: %s running.", starter);
else
Expand Down Expand Up @@ -281,14 +281,10 @@ void Engine::FlushPrint() {
std::wstring wstr = AnsiToWide(*it);
D2CLIENT_PrintGameString(wstr.c_str(), 0);
}
/*} else if (Vars.bUseGamePrint && ClientState() == ClientStateMenu && findControl(4, (const wchar_t*)NULL, -1, 28, 410, 354, 298)) {
while (getline(ss, temp))
SplitLines(temp, Console::MaxWidth() - 100, ' ', lines);
// TODO: Double check this function, make sure it is working as intended.
for (list<string>::iterator it = lines.begin(); it != lines.end(); ++it)
D2MULTI_PrintChannelText((char*)it->c_str(), 0);*/
} else {
while (getline(ss, temp)) Console::AddLine(temp);
while (getline(ss, temp)) {
Console::AddLine(temp);
}
}

clean.pop();
Expand Down
7 changes: 3 additions & 4 deletions src/Spidermonkey Engine/Core/JS/JSControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "Bindings.h"
#include "D2Helpers.h" // ClientState
#include "StringWrap.h"

JSObject* ControlWrap::Instantiate(JSContext* ctx, D2WinControlStrc* control) {
JS::RootedObject global(ctx, JS::CurrentGlobalOrNull(ctx));
Expand Down Expand Up @@ -100,12 +101,11 @@ bool ControlWrap::SetText(JSContext* ctx, JS::CallArgs& args) {
UNWRAP_CONTROL_OR_ERROR(ctx, &ctrl, args.thisv());

if (ctrl->dwType == 1 && args[0].isString()) {
char* szText = JS_EncodeString(ctx, args[0].toString());
StringWrap szText(ctx, args[0]);
if (!szText) {
THROW_ERROR(ctx, "failed to encode string");
}
setControlText(ctrl, szText);
JS_free(ctx, szText);
}
args.rval().setUndefined();
return true;
Expand Down Expand Up @@ -362,13 +362,12 @@ bool ControlWrap::FreeSetText(JSContext* ctx, JS::CallArgs& args) {
return true;
}

char* szText = JS_EncodeString(ctx, args[0].toString());
StringWrap szText(ctx, args[0]);
if (!szText) {
args.rval().setUndefined();
return true;
}
setControlText(pControl, szText);
JS_free(ctx, szText);
args.rval().setUndefined();
return true;
}
Expand Down
Loading

0 comments on commit 22132a9

Please sign in to comment.