diff --git a/D2BS.h b/D2BS.h index d9addab5..e17374f3 100644 --- a/D2BS.h +++ b/D2BS.h @@ -7,7 +7,7 @@ #define XP_WIN #endif -#define D2BS_VERSION "1.5.1876U" +#define D2BS_VERSION "1.5.1877U" #include #include diff --git a/D2BS.vcxproj b/D2BS.vcxproj index 5843cce9..038a299e 100644 --- a/D2BS.vcxproj +++ b/D2BS.vcxproj @@ -151,7 +151,7 @@ Level4 true ProgramDatabase - 4100;4127;4800;4480;4740;%(DisableSpecificWarnings) + 4100;4127;4800;4480;4740;4530;%(DisableSpecificWarnings) false false diff --git a/D2Intercepts.cpp b/D2Intercepts.cpp index fc954e96..4f31bbfd 100644 --- a/D2Intercepts.cpp +++ b/D2Intercepts.cpp @@ -382,7 +382,7 @@ LONG WINAPI MyUnhandledExceptionFilter(_In_ struct _EXCEPTION_POINTERS* Exceptio HANDLE hFile = INVALID_HANDLE_VALUE; for (int i = 0; hFile == INVALID_HANDLE_VALUE; ++i) { char fname[100]; - sprintf(fname, "Crash%03d.dump", i); + sprintf_s(fname, "Crash%03d.dump", i); hFile = CreateFile(fname, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); } DWORD ProcessId = GetCurrentProcessId(); diff --git a/File.cpp b/File.cpp index b5918fc7..24fa13c6 100644 --- a/File.cpp +++ b/File.cpp @@ -68,8 +68,9 @@ bool writeValue(FILE* fptr, JSContext* cx, jsval value, bool isBinary, bool lock result = fwrite(str, sizeof(char), strlen(str), fptr); else result = _fwrite_nolock(str, sizeof(char), strlen(str), fptr); - return (int)strlen(str) == result; + JS_free(cx, str); + return (int)strlen(str) == result; break; case JSTYPE_NUMBER: if (isBinary) { diff --git a/JSCore.cpp b/JSCore.cpp index 9ea6a39b..e25fb332 100644 --- a/JSCore.cpp +++ b/JSCore.cpp @@ -46,6 +46,7 @@ JSAPI_FUNC(my_utf8ToEuc) { JS_free(cx, Text); delete[] szText; delete[] euc; + return JS_TRUE; } JSAPI_FUNC(my_print) { @@ -339,7 +340,6 @@ JSAPI_FUNC(my_copy) { char* pText; hText = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, strlen(data) + 1); pText = (char*)GlobalLock(hText); - char* tempData; strcpy_s(pText, strlen(data) + 1, data); GlobalUnlock(hText); @@ -557,21 +557,19 @@ JSAPI_FUNC(my_sendPacket) { if (!Vars.bEnableUnsupported) { THROW_WARNING(cx, vp, "sendPacket requires EnableUnsupported = true in d2bs.ini"); - return JS_TRUE; } - JS_BeginRequest(cx); BYTE* aPacket; uint32 len = 0; + JS_BeginRequest(cx); if (JSVAL_IS_OBJECT(JS_ARGV(cx, vp)[0])) { JSObject* obj; JS_ValueToObject(cx, JS_ARGV(cx, vp)[0], &obj); if (!JS_IsArrayBufferObject(obj)) { - THROW_WARNING(cx, vp, "invalid ArrayBuffer parameter"); JS_EndRequest(cx); - return JS_TRUE; + THROW_WARNING(cx, vp, "invalid ArrayBuffer parameter"); } len = JS_GetArrayBufferByteLength(obj); @@ -579,9 +577,8 @@ JSAPI_FUNC(my_sendPacket) { memcpy(aPacket, JS_GetArrayBufferData(obj), len); } else { if (argc % 2 != 0) { - THROW_WARNING(cx, vp, "invalid packet format"); JS_EndRequest(cx); - return JS_TRUE; + THROW_WARNING(cx, vp, "invalid packet format"); } aPacket = new BYTE[2 * argc]; @@ -605,7 +602,6 @@ JSAPI_FUNC(my_getPacket) { if (!Vars.bEnableUnsupported) { THROW_WARNING(cx, vp, "getPacket requires EnableUnsupported = true in d2bs.ini"); - return JS_TRUE; } JS_BeginRequest(cx); @@ -617,9 +613,8 @@ JSAPI_FUNC(my_getPacket) { JS_ValueToObject(cx, JS_ARGV(cx, vp)[0], &obj); if (!JS_IsArrayBufferObject(obj)) { - THROW_WARNING(cx, vp, "invalid ArrayBuffer parameter"); JS_EndRequest(cx); - return JS_TRUE; + THROW_WARNING(cx, vp, "invalid ArrayBuffer parameter"); } len = JS_GetArrayBufferByteLength(obj); @@ -627,9 +622,8 @@ JSAPI_FUNC(my_getPacket) { memcpy(aPacket, JS_GetArrayBufferData(obj), len); } else { if (argc % 2 != 0) { - THROW_WARNING(cx, vp, "invalid packet format"); JS_EndRequest(cx); - return JS_TRUE; + THROW_WARNING(cx, vp, "invalid packet format"); } aPacket = new BYTE[2 * argc]; diff --git a/JSGame.cpp b/JSGame.cpp index 324fb4ce..1d1385e6 100644 --- a/JSGame.cpp +++ b/JSGame.cpp @@ -1424,14 +1424,12 @@ JSAPI_FUNC(my_moveNPC) { if (!Vars.bEnableUnsupported) { THROW_WARNING(cx, vp, "moveNPC requires EnableUnsupported = true in d2bs.ini"); - return JS_TRUE; } if (argc < 2) THROW_ERROR(cx, "Not enough parameters were passed to moveNPC!"); JS_SET_RVAL(cx, vp, JSVAL_FALSE); - myUnit* pNpc = (myUnit*)JS_GetPrivate(cx, JSVAL_TO_OBJECT(JS_ARGV(cx, vp)[0])); if (!pNpc || pNpc->dwType != 1) diff --git a/JSSocket.cpp b/JSSocket.cpp index 6468796d..539721c0 100644 --- a/JSSocket.cpp +++ b/JSSocket.cpp @@ -124,9 +124,8 @@ JSAPI_FUNC(socket_close) { JSAPI_FUNC(socket_send) { SocketData* sData = (SocketData*)JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx, vp), &socket_class, NULL); - char* msg = NULL; - int32 port = 0; + if (JSVAL_IS_STRING(JS_ARGV(cx, vp)[0])) msg = JS_EncodeString(cx, JSVAL_TO_STRING(JS_ARGV(cx, vp)[0])); @@ -159,7 +158,6 @@ JSAPI_FUNC(socket_read) { } void socket_finalize(JSFreeOp* fop, JSObject* obj) { - SocketData* sData = (SocketData*)JS_GetPrivate(obj); if (sData) { closesocket(sData->socket); diff --git a/ScriptEngine.cpp b/ScriptEngine.cpp index 79ab42a2..346e76a7 100644 --- a/ScriptEngine.cpp +++ b/ScriptEngine.cpp @@ -77,7 +77,7 @@ void ScriptEngine::DisposeScript(Script* script) { // bad things happen if we delete from another thread Event* evt = new Event; evt->owner = script; - evt->name = strdup("DisposeMe"); + evt->name = _strdup("DisposeMe"); script->FireEvent(evt); } } @@ -603,7 +603,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) { argv[2] = JS_NumberValue(*(DWORD*)evt->arg3); argv[3] = JS_NumberValue(*(DWORD*)evt->arg4); - for (int j = 0; j < evt->argc; j++) + for (uint j = 0; j < evt->argc; j++) JS_AddValueRoot(cx, &argv[j]); jsval rval; @@ -706,7 +706,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) { for (uint i = 0; i < *argc; i++) evt->argv[i]->read(cx, &argv[i]); - for (int j = 0; j < *argc; j++) + for (uint j = 0; j < *argc; j++) JS_AddValueRoot(cx, &argv[j]); jsval rval; @@ -715,7 +715,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) { } JS_EndRequest(cx); - for (int j = 0; j < *argc; j++) + for (uint j = 0; j < *argc; j++) JS_RemoveValueRoot(cx, &argv[j]); } for (uint i = 0; i < evt->argc; i++) { @@ -732,14 +732,14 @@ bool ExecScriptEvent(Event* evt, bool clearList) { if (!clearList) { BYTE* help = (BYTE*)evt->arg1; DWORD* size = (DWORD*)evt->arg2; - DWORD* argc = (DWORD*)1; + // DWORD* argc = (DWORD*)1; JS_BeginRequest(cx); JSObject* arr = JS_NewUint8Array(cx, *size); // JSObject* arr = JS_NewArrayObject(cx, 0, NULL); JS_AddRoot(cx, &arr); - for (int i = 0; i < *size; i++) { + for (uint i = 0; i < *size; i++) { jsval jsarr = UINT_TO_JSVAL(help[i]); JS_SetElement(cx, arr, i, &jsarr); }