From 26a1f2a556aae334323b7ffa9ae433a7c658b904 Mon Sep 17 00:00:00 2001 From: bobode Date: Sun, 22 Sep 2013 19:08:39 +0000 Subject: [PATCH] act map fixes re-add begin / end requests --- AutoRoot.cpp | 4 +- D2BS.h | 2 +- D2Helpers.cpp | 3 +- JSArea.cpp | 10 ++-- JSControl.cpp | 33 ++++++------ JSCore.cpp | 42 ++++++++-------- JSDirectory.cpp | 8 +-- JSFile.cpp | 16 +++--- JSFileTools.cpp | 4 +- JSGame.cpp | 112 ++++++++++++++++++++--------------------- JSMenu.cpp | 6 +-- JSParty.cpp | 10 ++-- JSPresetUnit.cpp | 14 +++--- JSRoom.cpp | 40 +++++++-------- JSSQLite.cpp | 4 +- JSScreenHook.cpp | 18 +++---- JSScript.cpp | 4 +- JSUnit.cpp | 82 +++++++++++++++--------------- Map/Diablo_II/ActMap.h | 2 +- Map/Path/AStarPath.h | 2 +- ScreenHook.cpp | 6 +-- Script.cpp | 8 +-- ScriptEngine.cpp | 54 ++++++++++---------- js32.cpp | 4 +- 24 files changed, 245 insertions(+), 243 deletions(-) diff --git a/AutoRoot.cpp b/AutoRoot.cpp index f8a3248a..019f30a5 100644 --- a/AutoRoot.cpp +++ b/AutoRoot.cpp @@ -11,9 +11,9 @@ AutoRoot::~AutoRoot() { exit(3); } //JS_RemoveRoot(cx, &var); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_RemoveValueRoot(cx, &var); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } void AutoRoot::Take() diff --git a/D2BS.h b/D2BS.h index 939bd047..7cb7538e 100644 --- a/D2BS.h +++ b/D2BS.h @@ -5,7 +5,7 @@ #define XP_WIN -#define D2BS_VERSION "1.5.1791" //uptodate with d branch 1765 ff 20b +#define D2BS_VERSION "1.5.1792" //uptodate with d branch 1765 ff 20b #include #include diff --git a/D2Helpers.cpp b/D2Helpers.cpp index 1345d9d4..5a7bb0d9 100644 --- a/D2Helpers.cpp +++ b/D2Helpers.cpp @@ -181,10 +181,11 @@ DWORD GetPlayerArea(void) Level* GetLevel(DWORD dwLevelNo) { + AutoCriticalRoom* cRoom = new AutoCriticalRoom; + if (!GameReady()) return nullptr; - AutoCriticalRoom* cRoom = new AutoCriticalRoom; Level* pLevel = D2CLIENT_GetPlayerUnit()->pAct->pMisc->pLevelFirst; while(pLevel) diff --git a/JSArea.cpp b/JSArea.cpp index 7d1071b0..286c7c5a 100644 --- a/JSArea.cpp +++ b/JSArea.cpp @@ -34,7 +34,7 @@ JSAPI_PROP(area_getProperty) { case AUNIT_EXITS: { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(pArea->ExitArray == NULL) { pArea->ExitArray = JS_NewArrayObject(cx, 0, NULL); @@ -60,7 +60,7 @@ JSAPI_PROP(area_getProperty) if(!pExit) { delete exit; - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); THROW_ERROR(cx, "Failed to create exit object!"); } jsval a = OBJECT_TO_JSVAL(pExit); @@ -72,7 +72,7 @@ JSAPI_PROP(area_getProperty) if(pArea->ExitArray) JS_RemoveRoot(cx, &pArea->ExitArray); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); break; case AUNIT_NAME: { @@ -115,9 +115,9 @@ JSAPI_FUNC(my_getArea) if(JSVAL_IS_INT(JS_ARGV(cx, vp)[0])) { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_ValueToECMAInt32(cx, JS_ARGV(cx, vp)[0], &nArea); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } else THROW_ERROR(cx, "Invalid parameter passed to getArea!"); diff --git a/JSControl.cpp b/JSControl.cpp index c30183da..da75e75b 100644 --- a/JSControl.cpp +++ b/JSControl.cpp @@ -31,7 +31,7 @@ JSAPI_PROP(control_getProperty) jsval ID; JS_IdToValue(cx,id,&ID); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JSType a = JS_TypeOfValue(cx, ID); @@ -96,7 +96,7 @@ JSAPI_PROP(control_getProperty) vp.setNumber((double) ctrl->dwDisabled); break; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return JS_TRUE; } @@ -133,27 +133,27 @@ JSAPI_STRICT_PROP(control_setProperty) if(vp.isInt32()) { int32 nState; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(!JS_ValueToECMAInt32(cx, vp.get(), &nState) || nState < 0 || nState > 3) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); THROW_ERROR(cx, "Invalid state value"); } memset((void*)&ctrl->dwDisabled, (nState + 2), sizeof(DWORD)); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } break; case CONTROL_CURSORPOS: if(vp.isInt32()) { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); uint32 dwPos; if(!JS_ValueToECMAUint32(cx, vp.get(), &dwPos)) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); THROW_ERROR(cx, "Invalid cursor position value"); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); memset((void*)&ctrl->dwCursorPos, dwPos, sizeof(DWORD)); } break; @@ -226,10 +226,10 @@ JSAPI_FUNC(control_click) if(argc > 1 && JSVAL_IS_INT(JS_ARGV(cx, vp)[0]) && JSVAL_IS_INT(JS_ARGV(cx, vp)[1])) { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[0], &x); JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[1], &y); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } clickControl(pControl, x, y); @@ -286,7 +286,7 @@ JSAPI_FUNC(control_getText) if(pControl->dwType != 4 || !pControl->pFirstText) return JS_TRUE; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JSObject* pReturnArray = JS_NewArrayObject(cx, 0, NULL); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(pReturnArray)); @@ -325,8 +325,9 @@ JSAPI_FUNC(control_getText) nArrayCount++; } + JS_EndRequest(cx); + - /* 22 JS_EndRequest(cx);*/ return JS_TRUE; } @@ -340,11 +341,11 @@ JSAPI_FUNC(my_getControl) int32 nType = -1, nX = -1, nY = -1, nXSize = -1, nYSize = -1; int32 *args[] = {&nType, &nX, &nY, &nXSize, &nYSize}; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); for(uintN i = 0; i < argc; i++) if(JSVAL_IS_INT(JS_ARGV(cx, vp)[i])) JS_ValueToECMAInt32(cx, JS_ARGV(cx, vp)[i], args[i]); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); Control* pControl = findControl(nType, (char*)NULL, -1, nX, nY, nXSize, nYSize); if(!pControl) @@ -375,7 +376,7 @@ JSAPI_FUNC(my_getControls) DWORD dwArrayCount = NULL; JSObject* pReturnArray = JS_NewArrayObject(cx, 0, NULL); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_AddRoot(cx, &pReturnArray); for(Control* pControl = *p_D2WIN_FirstControl; pControl; pControl = pControl->pNext) { @@ -394,7 +395,7 @@ JSAPI_FUNC(my_getControls) } JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(pReturnArray)); JS_RemoveRoot(cx, &pReturnArray); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return JS_TRUE; } diff --git a/JSCore.cpp b/JSCore.cpp index 052651fd..f56c5ef5 100644 --- a/JSCore.cpp +++ b/JSCore.cpp @@ -27,14 +27,14 @@ JSAPI_FUNC(my_print) { if(!JSVAL_IS_NULL(JS_ARGV(cx, vp)[i])) { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(!JS_ConvertValue(cx, JS_ARGV(cx, vp)[i], JSTYPE_STRING, &(JS_ARGV(cx, vp)[i]))) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); JS_ReportError(cx, "Converting to string failed"); return JS_FALSE; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); char* Text = JS_EncodeString(cx,JS_ValueToString(cx, JS_ARGV(cx, vp)[i])); if(Text == NULL) { @@ -116,13 +116,13 @@ JSAPI_FUNC(my_clearInterval) JSAPI_FUNC(my_delay) { uint32 nDelay = 0; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "u", &nDelay)) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return JS_FALSE; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); Script* script = (Script*)JS_GetContextPrivate(cx); DWORD start = GetTickCount(); @@ -260,11 +260,11 @@ JSAPI_FUNC(my_beep) JSAPI_FUNC(my_getTickCount) { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); jsval rval; rval = JS_NumberValue((jsdouble)GetTickCount()); JS_SET_RVAL(cx, vp, rval); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return JS_TRUE; } @@ -311,14 +311,14 @@ JSAPI_FUNC(my_debugLog) { if(!JSVAL_IS_NULL(JS_ARGV(cx, vp)[i])) { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(!JS_ConvertValue(cx, JS_ARGV(cx, vp)[i], JSTYPE_STRING, &(JS_ARGV(cx, vp)[i]))) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); JS_ReportError(cx, "Converting to string failed"); return JS_FALSE; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); char* Text = JS_EncodeString(cx,JS_ValueToString(cx, JS_ARGV(cx, vp)[i])); if(Text == NULL) { @@ -384,7 +384,7 @@ JSAPI_FUNC(my_sendCopyData) BOOL bwinNam = false, bdata = false, bWinClassName = false; jsint nModeId = NULL; HWND hWnd = NULL; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(argc > 1 && JSVAL_IS_NUMBER(JS_ARGV(cx, vp)[1]) && !JSVAL_IS_NULL(JS_ARGV(cx, vp)[1])) JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[1], (uint32*) &hWnd); @@ -408,7 +408,7 @@ JSAPI_FUNC(my_sendCopyData) data = JS_EncodeString(cx,JSVAL_TO_STRING(JS_ARGV(cx, vp)[3])); bdata = true; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); if(windowClassName && _strcmpi(windowClassName, "null") == 0) windowClassName = NULL; @@ -445,7 +445,7 @@ JSAPI_FUNC(my_sendDDE) { jsint mode; char *pszDDEServer = "\"\"", *pszTopic = "\"\"", *pszItem = "\"\"", *pszData = "\"\""; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if (JSVAL_IS_INT(JS_ARGV(cx, vp)[0])) JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[1], (uint32*) &mode); @@ -462,7 +462,7 @@ JSAPI_FUNC(my_sendDDE) if (JSVAL_IS_STRING(JS_ARGV(cx, vp)[4])) pszData = JS_EncodeString(cx,JSVAL_TO_STRING(JS_ARGV(cx, vp)[4])); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); char buffer[255] = ""; if(SendDDE(mode, pszDDEServer, pszTopic, pszItem, pszData, (char**)&buffer, 255)) { @@ -611,7 +611,7 @@ JSAPI_FUNC(my_sendPacket) BYTE* aPacket = new BYTE[20]; BYTE* pPacket = aPacket; uint type = 1; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); for(uint i = 0; i < argc; i++){ if(i%2 == 0){ JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[i], (uint32*)&type); ++i; @@ -619,7 +619,7 @@ JSAPI_FUNC(my_sendPacket) JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[i], (uint32*)aPacket); aPacket += type; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); D2NET_SendPacket(aPacket - pPacket, 1, pPacket); delete[] aPacket; JS_SET_RVAL(cx, vp, JSVAL_TRUE); @@ -638,7 +638,7 @@ JSAPI_FUNC(my_getPacket) BYTE* aPacket = new BYTE[20]; BYTE* pPacket = aPacket; uint type = 1; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); for(uint i = 0; i < argc; i++){ if(i%2 == 0) { @@ -647,7 +647,7 @@ JSAPI_FUNC(my_getPacket) JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[i], (uint32*)aPacket); aPacket += type; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); D2NET_ReceivePacket(pPacket, aPacket - pPacket); delete[] aPacket; JS_SET_RVAL(cx, vp, JSVAL_TRUE); @@ -668,8 +668,8 @@ JSAPI_FUNC(my_getIP) InternetCloseHandle(hFile); InternetCloseHandle(hInternet); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, (char *)buffer))); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return JS_TRUE; } \ No newline at end of file diff --git a/JSDirectory.cpp b/JSDirectory.cpp index fb11f5ab..a390c6d2 100644 --- a/JSDirectory.cpp +++ b/JSDirectory.cpp @@ -92,7 +92,7 @@ JSAPI_FUNC(dir_getFiles) if((hFile = _findfirst(search, &found)) != -1L) { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); jsint element = 0; do { @@ -101,7 +101,7 @@ JSAPI_FUNC(dir_getFiles) jsval file = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, found.name)); JS_SetElement(cx, jsarray, element++, &file); } while(_findnext(hFile, &found) == 0); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } JS_free(cx, search); _chdir(oldpath); @@ -135,7 +135,7 @@ JSAPI_FUNC(dir_getFolders) if((hFile = _findfirst(search, &found)) != -1L) { jsint element = 0; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); do { if(!strcmp(found.name, "..") || !strcmp(found.name, ".") || !(found.attrib & _A_SUBDIR)) @@ -143,7 +143,7 @@ JSAPI_FUNC(dir_getFolders) jsval file = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, found.name)); JS_SetElement(cx, jsarray, element++, &file); } while(_findnext(hFile, &found) == 0); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } diff --git a/JSFile.cpp b/JSFile.cpp index 903be292..875ab3d2 100644 --- a/JSFile.cpp +++ b/JSFile.cpp @@ -58,7 +58,7 @@ JSAPI_PROP(file_getProperty) { jsval ID; JS_IdToValue(cx,id,&ID); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); switch(JSVAL_TO_INT(ID)) { case FILE_READABLE: @@ -130,7 +130,7 @@ JSAPI_PROP(file_getProperty) else vp.setInt32(0); break; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } else THROW_ERROR(cx, "Couldn't get file object"); @@ -332,14 +332,14 @@ JSAPI_FUNC(file_read) JS_SET_RVAL(cx, vp, INT_TO_JSVAL(result[0])); else { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JSObject* arr = JS_NewArrayObject(cx, 0, NULL); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(arr)); for(int i = 0; i < count; i++) { jsval val = INT_TO_JSVAL(result[i]); JS_SetElement(cx, arr, i, &val); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } } else @@ -390,7 +390,7 @@ JSAPI_FUNC(file_readAllLines) JSObject* arr = JS_NewArrayObject(cx, 0, NULL); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(arr)); int i = 0; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); while(!feof(fdata->fptr)) { const char* line = readLine(fdata->fptr, fdata->locked); if(!line) @@ -399,7 +399,7 @@ JSAPI_FUNC(file_readAllLines) JS_SetElement(cx, arr, i++, &val); delete[] line; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } return JS_TRUE; } @@ -437,9 +437,9 @@ JSAPI_FUNC(file_readAll) delete[] contents; THROW_ERROR(cx, _strerror("Read failed")); } - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(JS_NewStringCopyN(cx, contents, strlen(contents)))); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); delete[] contents; } return JS_TRUE; diff --git a/JSFileTools.cpp b/JSFileTools.cpp index 9d7c34eb..ec7098b2 100644 --- a/JSFileTools.cpp +++ b/JSFileTools.cpp @@ -189,9 +189,9 @@ JSAPI_FUNC(filetools_readText) } // Convert to JSVAL cleanup and return - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(JS_NewStringCopyN(cx, contents, strlen(contents)))); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); delete[] contents; return JS_TRUE; } diff --git a/JSGame.cpp b/JSGame.cpp index 2059bc1e..b8dad11d 100644 --- a/JSGame.cpp +++ b/JSGame.cpp @@ -81,7 +81,7 @@ JSAPI_FUNC(my_clickMap) if(argc < 3) return JS_TRUE; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(JSVAL_IS_INT(JS_ARGV(cx, vp)[0])) JS_ValueToUint16(cx, JS_ARGV(cx, vp)[0], &nClickType); if(JSVAL_IS_INT(JS_ARGV(cx, vp)[1]) || JSVAL_IS_BOOLEAN(JS_ARGV(cx, vp)[1])) @@ -90,7 +90,7 @@ JSAPI_FUNC(my_clickMap) JS_ValueToUint16(cx, JS_ARGV(cx, vp)[2], &nX); if(JSVAL_IS_INT(JS_ARGV(cx, vp)[3])) JS_ValueToUint16(cx, JS_ARGV(cx, vp)[3], &nY); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); if(argc == 3 && JSVAL_IS_INT(JS_ARGV(cx, vp)[0]) && (JSVAL_IS_INT(JS_ARGV(cx, vp)[1]) || JSVAL_IS_BOOLEAN(JS_ARGV(cx, vp)[1])) && JSVAL_IS_OBJECT(JS_ARGV(cx, vp)[2]) && !JSVAL_IS_NULL(JS_ARGV(cx, vp)[2])) @@ -278,13 +278,13 @@ JSAPI_FUNC(my_getPath) uint lvl = 0, x = 0, y = 0, dx = 0, dy = 0, reductionType = 0, radius = 20; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "uuuuu/uu", &lvl, &x, &y, &dx, &dy, &reductionType, &radius)) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return JS_FALSE; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); if(reductionType == 3 && !(JSVAL_IS_FUNCTION(cx, JS_ARGV(cx, vp)[7]) && JSVAL_IS_FUNCTION(cx, JS_ARGV(cx, vp)[8]) && JSVAL_IS_FUNCTION(cx, JS_ARGV(cx, vp)[9]))) { @@ -370,13 +370,13 @@ JSAPI_FUNC(my_getCollision) } uint32 nLevelId, nX, nY; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "uuu", &nLevelId, &nX, &nY)) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return JS_FALSE; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); Point point(nX, nY); Level* level = GetLevel(nLevelId); @@ -388,9 +388,9 @@ JSAPI_FUNC(my_getCollision) { map->CleanUp(); THROW_ERROR(cx, "Invalid point!");} jsval rval; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); rval = JS_NumberValue(map->GetMapData(point, true)); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); JS_SET_RVAL(cx, vp,rval ); map->CleanUp(); @@ -726,12 +726,12 @@ JSAPI_FUNC(my_getLocaleString) return JS_TRUE; uint16 localeId; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_ValueToUint16(cx, JS_ARGV(cx, vp)[0], &localeId); wchar_t* wString = D2LANG_GetLocaleText(localeId); char* szTmp = UnicodeToAnsi(wString); JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, szTmp))); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); delete[] szTmp; return JS_TRUE; @@ -761,13 +761,13 @@ JSAPI_FUNC(my_rand) jsint high; jsint low; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp),"ii", &low, &high) == JS_FALSE) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); THROW_ERROR(cx, "Could not convert Rand aruments"); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); if(high > low+1) { @@ -798,10 +798,10 @@ JSAPI_FUNC(my_getDistance) { nX1 = D2CLIENT_GetUnitX(D2CLIENT_GetPlayerUnit()); nY1 = D2CLIENT_GetUnitY(D2CLIENT_GetPlayerUnit()); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_ValueToECMAInt32(cx, x1, &nX2); JS_ValueToECMAInt32(cx, y1, &nY2); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } } else if(argc == 2) @@ -810,10 +810,10 @@ JSAPI_FUNC(my_getDistance) { nX1 = D2CLIENT_GetUnitX(D2CLIENT_GetPlayerUnit()); nY1 = D2CLIENT_GetUnitY(D2CLIENT_GetPlayerUnit()); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_ValueToECMAInt32(cx, JS_ARGV(cx, vp)[0], &nX2); JS_ValueToECMAInt32(cx, JS_ARGV(cx, vp)[1], &nY2); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } else if(JSVAL_IS_OBJECT(JS_ARGV(cx, vp)[0]) && JSVAL_IS_OBJECT(JS_ARGV(cx, vp)[1])) { @@ -821,12 +821,12 @@ JSAPI_FUNC(my_getDistance) if(JS_GetProperty(cx, JSVAL_TO_OBJECT(JS_ARGV(cx, vp)[0]), "x", &x) && JS_GetProperty(cx, JSVAL_TO_OBJECT(JS_ARGV(cx, vp)[0]), "y", &y) && JS_GetProperty(cx, JSVAL_TO_OBJECT(JS_ARGV(cx, vp)[1]), "x", &x2) && JS_GetProperty(cx, JSVAL_TO_OBJECT(JS_ARGV(cx, vp)[1]), "y", &y2)) { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_ValueToECMAInt32(cx, x, &nX1); JS_ValueToECMAInt32(cx, y, &nY1); JS_ValueToECMAInt32(cx, x2, &nX2); JS_ValueToECMAInt32(cx, y2, &nY2); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } } } @@ -846,10 +846,10 @@ JSAPI_FUNC(my_getDistance) nX1 = D2CLIENT_GetUnitX(pUnitA); nY1 = D2CLIENT_GetUnitY(pUnitA); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_ValueToECMAInt32(cx, JS_ARGV(cx, vp)[1], &nX2); JS_ValueToECMAInt32(cx, JS_ARGV(cx, vp)[2], &nY2); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } else if(JSVAL_IS_INT(JS_ARGV(cx, vp)[0]) && JSVAL_IS_INT(JS_ARGV(cx, vp)[1]) && JSVAL_IS_OBJECT(JS_ARGV(cx, vp)[2])) { @@ -865,29 +865,29 @@ JSAPI_FUNC(my_getDistance) nX1 = D2CLIENT_GetUnitX(pUnitA); nY1 = D2CLIENT_GetUnitY(pUnitA); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_ValueToECMAInt32(cx, JS_ARGV(cx, vp)[0], &nX2); JS_ValueToECMAInt32(cx, JS_ARGV(cx, vp)[1], &nY2); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } } else if(argc == 4) { if(JSVAL_IS_INT(JS_ARGV(cx, vp)[0]) && JSVAL_IS_INT(JS_ARGV(cx, vp)[1]) && JSVAL_IS_INT(JS_ARGV(cx, vp)[2]) && JSVAL_IS_INT(JS_ARGV(cx, vp)[3])) { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_ValueToECMAInt32(cx, JS_ARGV(cx, vp)[0], &nX1); JS_ValueToECMAInt32(cx, JS_ARGV(cx, vp)[1], &nY1); JS_ValueToECMAInt32(cx, JS_ARGV(cx, vp)[2], &nX2); JS_ValueToECMAInt32(cx, JS_ARGV(cx, vp)[3], &nY2); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } } jsdouble jsdist = (jsdouble)abs(GetDistance(nX1, nY1, nX2, nY2)); jsval rval; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); rval = JS_NumberValue(jsdist); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); JS_SET_RVAL(cx, vp, rval); return JS_TRUE; } @@ -976,9 +976,9 @@ JSAPI_FUNC(my_getSkillById) return JS_TRUE; jsint nId = JSVAL_TO_INT(JS_ARGV(cx, vp)[0]); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(JS_NewStringCopyZ(cx, "Unknown"))); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); int row = 0; if(FillBaseStat("skills", nId, "skilldesc", &row, sizeof(int))) if(FillBaseStat("skilldesc", row, "str name", &row, sizeof(int))) @@ -1023,12 +1023,12 @@ JSAPI_FUNC(my_getTextSize) } else { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); pObj = JS_NewArrayObject(cx, NULL, NULL); JS_AddRoot(cx, &pObj); JS_SetElement(cx, pObj, 0, &x); JS_SetElement(cx, pObj, 1, &y); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(pObj)); JS_RemoveRoot(cx, &pObj); @@ -1158,10 +1158,10 @@ JSAPI_FUNC(my_say) { if(!JSVAL_IS_NULL(JS_ARGV(cx, vp)[i])) { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(!JS_ConvertValue(cx, JS_ARGV(cx, vp)[i], JSTYPE_STRING, &(JS_ARGV(cx, vp)[i]))) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); JS_ReportError(cx, "Converting to string failed"); return JS_FALSE; } @@ -1169,11 +1169,11 @@ JSAPI_FUNC(my_say) char* Text = JS_EncodeString(cx,JS_ValueToString(cx, JS_ARGV(cx, vp)[i])); if(Text == NULL) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); JS_ReportError(cx, "Could not get string for value"); return JS_FALSE; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); //box18jsrefcount depth = JS_SuspendRequest(cx); if(Text) Say(Text); @@ -1256,13 +1256,13 @@ JSAPI_FUNC(my_useStatPoint) WORD stat = 0; int32 count = 1; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "c/u", &stat, &count)) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return JS_FALSE; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); UseStatPoint(stat, count); return JS_TRUE; } @@ -1274,13 +1274,13 @@ JSAPI_FUNC(my_useSkillPoint) WORD skill = 0; int32 count = 1; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "c/u", &skill, &count)) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return JS_FALSE; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); UseSkillPoint(skill, count); return JS_TRUE; } @@ -1293,13 +1293,13 @@ JSAPI_FUNC(my_getBaseStat) jsint nBaseStat = 0; jsint nClassId = 0; jsint nStat = -1; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(JSVAL_IS_STRING(JS_ARGV(cx, vp)[0])) { szTableName = JS_EncodeString(cx,JS_ValueToString(cx, JS_ARGV(cx, vp)[0])); if(!szTableName) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); THROW_ERROR(cx, "Invalid table value"); } @@ -1308,7 +1308,7 @@ JSAPI_FUNC(my_getBaseStat) JS_ValueToECMAInt32(cx, JS_ARGV(cx, vp)[0], &nBaseStat); else { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); THROW_ERROR(cx, "Invalid table value"); } @@ -1319,7 +1319,7 @@ JSAPI_FUNC(my_getBaseStat) szStatName = JS_EncodeString(cx,JS_ValueToString(cx, JS_ARGV(cx, vp)[2])); if(!szStatName) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); THROW_ERROR(cx, "Invalid column value"); } } @@ -1327,13 +1327,13 @@ JSAPI_FUNC(my_getBaseStat) JS_ValueToECMAInt32(cx, JS_ARGV(cx, vp)[2], &nStat); else { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); THROW_ERROR(cx, "Invalid column value"); } jsval rval; FillBaseStat(cx, &rval, nBaseStat, nClassId, nStat, szTableName, szStatName); JS_SET_RVAL(cx, vp, rval); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } return JS_TRUE; @@ -1349,13 +1349,13 @@ JSAPI_FUNC(my_weaponSwitch) jsint nParameter = NULL; if(argc > 0) { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(JS_ValueToInt32(cx, JS_ARGV(cx, vp)[0], &nParameter) == JS_FALSE) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); THROW_ERROR(cx, "Could not convert value"); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } if(nParameter == NULL) @@ -1409,10 +1409,10 @@ JSAPI_FUNC(my_getPlayerFlag) uint32 nFirstUnitId = (uint32)-1; uint32 nSecondUnitId = (uint32)-1; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[0], &nFirstUnitId); JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[1], &nSecondUnitId); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); DWORD nFlag = JSVAL_TO_INT(JS_ARGV(cx, vp)[2]); @@ -1458,12 +1458,12 @@ JSAPI_FUNC(my_getMouseCoords) } else { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); pObj = JS_NewArrayObject(cx, NULL, NULL); JS_AddRoot(cx, &pObj); JS_SetElement(cx, pObj, 0, &jsX); JS_SetElement(cx, pObj, 1, &jsY); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } if(!pObj) diff --git a/JSMenu.cpp b/JSMenu.cpp index 61baa90e..1688766a 100644 --- a/JSMenu.cpp +++ b/JSMenu.cpp @@ -191,13 +191,13 @@ JSAPI_FUNC(my_createCharacter) jschar* jsname= NULL; int32 type = -1; JSBool hc = JS_FALSE, ladder = JS_FALSE; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "Wi/bb", &jsname, &type, &hc, &ladder)) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); THROW_ERROR(cx, "Failed to Convert Args createCharacter"); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); name = JS_EncodeString(cx,JSVAL_TO_STRING(JS_ARGV(cx, vp)[0])); JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(!!OOG_CreateCharacter(name, type, !!hc, !!ladder))); diff --git a/JSParty.cpp b/JSParty.cpp index 6c4cbb88..f50fe99c 100644 --- a/JSParty.cpp +++ b/JSParty.cpp @@ -16,7 +16,7 @@ JSAPI_PROP(party_getProperty) jsval ID; JS_IdToValue(cx,id,&ID); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); switch(JSVAL_TO_INT(ID)) { case PARTY_NAME: @@ -52,7 +52,7 @@ JSAPI_PROP(party_getProperty) default: break; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return JS_TRUE; } @@ -119,14 +119,14 @@ JSAPI_FUNC(my_getParty) } else if(JSVAL_IS_INT(JS_ARGV(cx, vp)[0])) { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "u", &nPlayerId)) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); THROW_ERROR(cx, "Unable to get ID"); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } else if(JSVAL_IS_OBJECT(JS_ARGV(cx, vp)[0])) { diff --git a/JSPresetUnit.cpp b/JSPresetUnit.cpp index 86bbbb0c..91f0b4f5 100644 --- a/JSPresetUnit.cpp +++ b/JSPresetUnit.cpp @@ -66,9 +66,9 @@ JSAPI_FUNC(my_getPresetUnits) } uint32 levelId; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[0], &levelId); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); Level* pLevel = GetLevel(levelId); if(!pLevel) @@ -88,7 +88,7 @@ JSAPI_FUNC(my_getPresetUnits) DWORD dwArrayCount = NULL; JSObject* pReturnArray = JS_NewArrayObject(cx, 0, NULL); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_AddRoot(cx, &pReturnArray); for(Room2 *pRoom = pLevel->pRoom2First; pRoom; pRoom = pRoom->pRoom2Next) { @@ -119,7 +119,7 @@ JSAPI_FUNC(my_getPresetUnits) if(!unit) { delete mypUnit; - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); delete cRoom; THROW_ERROR(cx, "Failed to build object?"); } @@ -140,7 +140,7 @@ JSAPI_FUNC(my_getPresetUnits) JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(pReturnArray)); JS_RemoveRoot(cx, &pReturnArray); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); delete cRoom; return JS_TRUE; } @@ -157,9 +157,9 @@ JSAPI_FUNC(my_getPresetUnit) } uint32 levelId; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[0], &levelId); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); Level* pLevel = GetLevel(levelId); if(!pLevel) diff --git a/JSRoom.cpp b/JSRoom.cpp index e11b1cea..7937a95e 100644 --- a/JSRoom.cpp +++ b/JSRoom.cpp @@ -127,9 +127,9 @@ JSAPI_FUNC(room_getPresetUnits) } jsval a = OBJECT_TO_JSVAL(jsUnit); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_SetElement(cx, pReturnArray, dwArrayCount, &a); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); dwArrayCount++; } } @@ -148,7 +148,7 @@ JSAPI_FUNC(room_getCollisionTypeArray) if(!pRoom2) return JS_TRUE; - JSObject* jsobjy = JS_NewInt16Array(cx, (pRoom2->dwSizeX * 5) * (pRoom2->dwSizeY*5)); + JSObject* jsobjy = JS_NewUint16Array(cx, (pRoom2->dwSizeX * 5) * (pRoom2->dwSizeY*5)); JS_AddRoot(cx, &jsobjy); if(!jsobjy) return JS_TRUE; @@ -187,7 +187,7 @@ JSAPI_FUNC(room_getCollisionTypeArray) int nCurrentArrayY = NULL; WORD* p = pCol->pMapStart; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); for(int j = y; j < nLimitY; j++) { @@ -202,7 +202,7 @@ JSAPI_FUNC(room_getCollisionTypeArray) if(bAdded) D2COMMON_RemoveRoomData(D2CLIENT_GetPlayerUnit()->pAct, pRoom2->pLevel->dwLevelNo, pRoom2->dwPosX, pRoom2->dwPosY, D2CLIENT_GetPlayerUnit()->pPath->pRoom1); JS_RemoveRoot(cx, &jsobjy); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); delete cRoom; return JS_TRUE; } @@ -218,7 +218,7 @@ JSAPI_FUNC(room_getCollisionTypeArray) JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobjy)); JS_RemoveRoot(cx, &jsobjy); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); delete cRoom; return JS_TRUE; @@ -268,7 +268,7 @@ JSAPI_FUNC(room_getCollision) int nCurrentArrayY = NULL; WORD* p = pCol->pMapStart; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); for(int j = y; j < nLimitY; j++) { JSObject* jsobjx = JS_NewArrayObject(cx, NULL, NULL); @@ -283,7 +283,7 @@ JSAPI_FUNC(room_getCollision) if(bAdded) D2COMMON_RemoveRoomData(D2CLIENT_GetPlayerUnit()->pAct, pRoom2->pLevel->dwLevelNo, pRoom2->dwPosX, pRoom2->dwPosY, D2CLIENT_GetPlayerUnit()->pPath->pRoom1); JS_RemoveRoot(cx, &jsobjy); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); delete cRoom; return JS_TRUE; } @@ -300,7 +300,7 @@ JSAPI_FUNC(room_getCollision) if(bAdded) D2COMMON_RemoveRoomData(D2CLIENT_GetPlayerUnit()->pAct, pRoom2->pLevel->dwLevelNo, pRoom2->dwPosX, pRoom2->dwPosY, D2CLIENT_GetPlayerUnit()->pPath->pRoom1); JS_RemoveRoot(cx, &jsobjy); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); delete cRoom; return JS_TRUE; } @@ -312,7 +312,7 @@ JSAPI_FUNC(room_getCollision) JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobjy)); JS_RemoveRoot(cx, &jsobjy); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); delete cRoom; return JS_TRUE; } @@ -326,24 +326,24 @@ JSAPI_FUNC(room_getNearby) if(!jsobj) return JS_TRUE; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); for(DWORD i = 0; i < pRoom2->dwRoomsNear; ++i) { JSObject* jsroom = BuildObject(cx, &room_class, room_methods, room_props, pRoom2->pRoom2Near[i]); if(!jsroom) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return JS_TRUE; } jsval jsu = OBJECT_TO_JSVAL(jsroom); if(!JS_SetElement(cx, jsobj, i, &jsu)) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return JS_TRUE; } } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(jsobj)); return JS_TRUE; } @@ -485,9 +485,9 @@ JSAPI_FUNC(my_getRoom) if(argc == 1 && JSVAL_IS_INT(JS_ARGV(cx, vp)[0])) { uint32 levelId; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[0], &levelId); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); if(levelId != 0) // 1 Parameter, AreaId { Level* pLevel = GetLevel(levelId); @@ -529,9 +529,9 @@ JSAPI_FUNC(my_getRoom) Level* pLevel = NULL; uint32 levelId; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[0], &levelId); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); if(argc == 3) pLevel = GetLevel(levelId); else if(D2CLIENT_GetPlayerUnit() && D2CLIENT_GetPlayerUnit()->pPath && D2CLIENT_GetPlayerUnit()->pPath->pRoom1 && D2CLIENT_GetPlayerUnit()->pPath->pRoom1->pRoom2) @@ -542,7 +542,7 @@ JSAPI_FUNC(my_getRoom) uint32 nX = NULL; uint32 nY = NULL; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(argc == 2) { JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[0], &nX); @@ -553,7 +553,7 @@ JSAPI_FUNC(my_getRoom) JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[1], &nX); JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[2], &nY); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); if(!nX || !nY) { delete cRoom; return JS_TRUE; } diff --git a/JSSQLite.cpp b/JSSQLite.cpp index 1b6cf2ec..fd3a7163 100644 --- a/JSSQLite.cpp +++ b/JSSQLite.cpp @@ -257,7 +257,7 @@ JSAPI_PROP(sqlite_getProperty) vp.setInt32(sqlite3_last_insert_rowid(dbobj->db)); break; case SQLITE_STMTS: { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JSObject *stmts = JS_NewArrayObject(cx, dbobj->stmts.size(), NULL); vp.set( OBJECT_TO_JSVAL(stmts)); int i = 0; @@ -268,7 +268,7 @@ JSAPI_PROP(sqlite_getProperty) JS_SetElement(cx, stmts, i, &tmp); } } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } break; case SQLITE_CHANGES: diff --git a/JSScreenHook.cpp b/JSScreenHook.cpp index 27fe05c8..79886bdd 100644 --- a/JSScreenHook.cpp +++ b/JSScreenHook.cpp @@ -829,25 +829,25 @@ JSAPI_FUNC(automapToScreen) if(!JSVAL_IS_INT(x) || !JSVAL_IS_INT(y)) THROW_ERROR(cx, "Input has an x or y, but they aren't the correct type!"); int32 ix, iy; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(JS_ValueToInt32(cx, x, &ix) == JS_FALSE || JS_ValueToInt32(cx, y, &iy)) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); THROW_ERROR(cx, "Failed to convert x and/or y values"); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); // convert the values POINT result = {ix,iy}; AutomapToScreen(&result); x = INT_TO_JSVAL(ix); y = INT_TO_JSVAL(iy); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(JS_SetProperty(cx, arg, "x", &x) == JS_FALSE || JS_SetProperty(cx, arg, "y", &y) == JS_FALSE) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); THROW_ERROR(cx, "Failed to set x and/or y values"); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(arg)); } else @@ -859,13 +859,13 @@ JSAPI_FUNC(automapToScreen) if(JSVAL_IS_INT(argv[0]) && JSVAL_IS_INT(argv[1])) { int32 ix, iy; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(JS_ValueToInt32(cx, argv[0], &ix) == JS_FALSE || JS_ValueToInt32(cx, argv[1], &iy) == JS_FALSE) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); THROW_ERROR(cx, "Failed to convert x and/or y values"); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); // convert the values POINT result = {ix,iy}; AutomapToScreen(&result); diff --git a/JSScript.cpp b/JSScript.cpp index c1af7479..e7d81b1b 100644 --- a/JSScript.cpp +++ b/JSScript.cpp @@ -200,7 +200,7 @@ JSAPI_FUNC(my_getScripts) DWORD dwArrayCount = NULL; JSObject* pReturnArray = JS_NewArrayObject(cx, 0, NULL); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_AddRoot(cx, &pReturnArray); for(ScriptMap::iterator it = ScriptEngine::scripts.begin(); it != ScriptEngine::scripts.end(); it++) { @@ -211,7 +211,7 @@ JSAPI_FUNC(my_getScripts) } JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(pReturnArray)); JS_RemoveRoot(cx, &pReturnArray); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return JS_TRUE; } bool __fastcall FindScriptByName(Script* script, void* argv, uint argc) diff --git a/JSUnit.cpp b/JSUnit.cpp index 691baa4c..b769a788 100644 --- a/JSUnit.cpp +++ b/JSUnit.cpp @@ -55,7 +55,7 @@ JSAPI_PROP(unit_getProperty) GameStructInfo* pInfo = *p_D2CLIENT_GameInfo; jsval ID; JS_IdToValue(cx,id,&ID); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); switch(JSVAL_TO_INT(ID)) { case ME_PID: @@ -174,7 +174,7 @@ JSAPI_PROP(unit_getProperty) default: break; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); if(ClientState() != ClientStateInGame) return JS_TRUE; //JSObject* obj ; @@ -221,9 +221,9 @@ JSAPI_PROP(unit_getProperty) vp.setInt32(pRoom->pRoom2->pLevel->dwLevelNo); break; case UNIT_ID: - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); vp.setNumber((jsdouble)pUnit->dwUnitId); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); break; case UNIT_XPOS: vp.setInt32(D2CLIENT_GetUnitX(pUnit)); @@ -610,7 +610,7 @@ JSAPI_FUNC(unit_getUnit) if(argc > 1 && JSVAL_IS_STRING(JS_ARGV(cx, vp)[1])) strcpy_s(szName, sizeof(szName), JS_EncodeString(cx,JS_ValueToString(cx, JS_ARGV(cx, vp)[1]))); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(argc > 1 && JSVAL_IS_NUMBER(JS_ARGV(cx, vp)[1]) && !JSVAL_IS_NULL(JS_ARGV(cx, vp)[1])) JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[1], &nClassId); @@ -619,7 +619,7 @@ JSAPI_FUNC(unit_getUnit) if(argc > 3 && JSVAL_IS_NUMBER(JS_ARGV(cx, vp)[3]) && !JSVAL_IS_NULL(JS_ARGV(cx, vp)[3])) JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[3], &nUnitId); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); UnitAny* pUnit = NULL; if(nType == 100) @@ -673,7 +673,7 @@ JSAPI_FUNC(unit_getNext) if(!pUnit) return JS_TRUE; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(argc > 0 && JSVAL_IS_STRING(JS_ARGV(cx, vp)[0])) strcpy_s(lpUnit->szName, 128, JS_EncodeString(cx,JS_ValueToString(cx, JS_ARGV(cx, vp)[0]))); @@ -682,7 +682,7 @@ JSAPI_FUNC(unit_getNext) if(argc > 1 && JSVAL_IS_NUMBER(JS_ARGV(cx, vp)[1]) && !JSVAL_IS_NULL(JS_ARGV(cx, vp)[2])) JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[1],(uint32*) &(lpUnit->dwMode)); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); pUnit = GetNextUnit(pUnit, lpUnit->szName, lpUnit->dwClassId, lpUnit->dwType, lpUnit->dwMode); if(!pUnit) @@ -710,7 +710,7 @@ JSAPI_FUNC(unit_getNext) UnitAny* pOwner = D2CLIENT_FindUnit(pmyUnit->dwOwnerId, pmyUnit->dwOwnerType); if(!pUnit || !pOwner) return JS_TRUE; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(argc > 0 && JSVAL_IS_STRING(JS_ARGV(cx, vp)[0])) strcpy_s(pmyUnit->szName, 128, JS_EncodeString(cx,JS_ValueToString(cx, JS_ARGV(cx, vp)[0]))); @@ -719,7 +719,7 @@ JSAPI_FUNC(unit_getNext) if(argc > 1 && JSVAL_IS_NUMBER(JS_ARGV(cx, vp)[1]) && !JSVAL_IS_NULL(JS_ARGV(cx, vp)[2])) JS_ValueToECMAUint32(cx, JS_ARGV(cx, vp)[1],(uint32*) &(pmyUnit->dwMode)); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); UnitAny* nextItem = GetInvNextUnit(pUnit, pOwner, pmyUnit->szName, pmyUnit->dwClassId, pmyUnit->dwMode); if(!nextItem) { @@ -857,13 +857,13 @@ JSAPI_FUNC(unit_interact) { // TODO: check the range on argv[0] to make sure it won't crash the game - Done! TechnoHunter jsint nWaypointID; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(!JS_ValueToECMAInt32(cx, JS_ARGV(cx, vp)[0], &nWaypointID)) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return JS_TRUE; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); int retVal = 0; if(FillBaseStat("levels", nWaypointID, "Waypoint", &retVal, sizeof(int))) if(retVal == 255) @@ -912,13 +912,13 @@ JSAPI_FUNC(unit_getStat) jsint nStat = 0; jsint nSubIndex = 0; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "i/i", &nStat, &nSubIndex)) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return JS_TRUE; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); if(nStat >= STAT_HP && nStat <= STAT_MAXSTAMINA) JS_SET_RVAL(cx, vp, INT_TO_JSVAL(D2COMMON_GetUnitStat(pUnit, nStat, nSubIndex)>>8)); @@ -961,7 +961,7 @@ JSAPI_FUNC(unit_getStat) } for(UINT i = 0; i < dwStats; i++) { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JSObject* pArrayInsert = JS_NewArrayObject(cx, 0, NULL); JS_AddRoot(cx, &pArrayInsert); @@ -980,7 +980,7 @@ JSAPI_FUNC(unit_getStat) JS_SetElement(cx, pReturnArray, i, &aObj); JS_RemoveRoot(cx, &pArrayInsert); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } } } @@ -1083,7 +1083,7 @@ void InsertStatsNow(Stat* pStat, int nStat, JSContext* cx, JSObject* pArray) if(!JS_IsArrayObject(cx, JSVAL_TO_OBJECT(index))) { // it's not an array, build one - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JSObject* arr = JS_NewArrayObject(cx, 0, NULL); JS_AddRoot(cx, &arr); JS_SetElement(cx, arr, 0, &index); @@ -1091,7 +1091,7 @@ void InsertStatsNow(Stat* pStat, int nStat, JSContext* cx, JSObject* pArray) jsval arr2 = OBJECT_TO_JSVAL(arr); JS_SetElement(cx, pArray, pStat[nStat].wStatIndex, &arr2); JS_RemoveRoot(cx, &arr); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } else { @@ -1101,15 +1101,15 @@ void InsertStatsNow(Stat* pStat, int nStat, JSContext* cx, JSObject* pArray) if(!JS_GetArrayLength(cx, arr, &len)) return; len++; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_SetElement(cx, arr, len, &obj); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } } else - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_SetElement(cx, pArray, pStat[nStat].wStatIndex, &obj); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } else { @@ -1125,17 +1125,17 @@ void InsertStatsNow(Stat* pStat, int nStat, JSContext* cx, JSObject* pArray) { // the array index doesn't exist, make it index = OBJECT_TO_JSVAL(JS_NewArrayObject(cx, 0, NULL)); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(!JS_SetElement(cx, pArray, pStat[nStat].wStatIndex, &index)){ - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } // index now points to the correct array index - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_SetElement(cx, JSVAL_TO_OBJECT(index), pStat[nStat].wSubIndex, &val); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } } @@ -1157,13 +1157,13 @@ JSAPI_FUNC(unit_getState) return JS_TRUE; jsint nState; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(JS_ValueToInt32(cx, JS_ARGV(cx, vp)[0], &nState) == JS_FALSE) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return JS_TRUE; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); // TODO: make these constants so we know what we're checking here if(nState > 159 || nState < 0) @@ -1312,13 +1312,13 @@ JSAPI_FUNC(item_getItemCost) } else if(JSVAL_IS_INT(JS_ARGV(cx, vp)[1]) && !JSVAL_IS_NULL(JS_ARGV(cx, vp)[1])) { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); if(!JS_ValueToECMAInt32(cx, JS_ARGV(cx, vp)[1], &nNpcClassId)) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return JS_TRUE; } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } //TODO:: validate the base stat table sizes to make sure the game doesn't crash with checking values past the end of the table int retVal = 0; @@ -1359,12 +1359,12 @@ JSAPI_FUNC(unit_getItems) if(!pUnit || !pUnit->pInventory || !pUnit->pInventory->pFirstItem) return JS_TRUE; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JSObject* pReturnArray = JS_NewArrayObject(cx, 0, NULL); if(!pReturnArray) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return JS_TRUE; } JS_AddRoot(cx, &pReturnArray); @@ -1390,7 +1390,7 @@ JSAPI_FUNC(unit_getItems) JSObject *jsunit = BuildObject(cx, &unit_class, unit_methods, unit_props, pmyUnit); if(!jsunit) { - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); JS_RemoveRoot(cx, &pReturnArray); THROW_ERROR(cx, "Failed to build item array"); } @@ -1400,7 +1400,7 @@ JSAPI_FUNC(unit_getItems) JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(pReturnArray)); JS_RemoveRoot(cx, &pReturnArray); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return JS_TRUE; } @@ -1487,7 +1487,7 @@ JSAPI_FUNC(unit_getSkill) jsval nId = INT_TO_JSVAL(pSkill->pSkillInfo->wSkillId); jsval nBase = INT_TO_JSVAL(pSkill->dwSkillLevel); jsval nTotal = INT_TO_JSVAL(D2COMMON_GetSkillLevel(pUnit, pSkill, 1)); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_SetElement(cx, pArrayInsert, 0, &nId); JS_SetElement(cx, pArrayInsert, 1, &nBase); JS_SetElement(cx, pArrayInsert, 2, &nTotal); @@ -1496,7 +1496,7 @@ JSAPI_FUNC(unit_getSkill) JS_SetElement(cx, pReturnArray, i, &aObj); JS_RemoveRoot(cx, &pArrayInsert); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); i++; } break; diff --git a/Map/Diablo_II/ActMap.h b/Map/Diablo_II/ActMap.h index 21f44332..50607fa4 100644 --- a/Map/Diablo_II/ActMap.h +++ b/Map/Diablo_II/ActMap.h @@ -88,7 +88,7 @@ class ActMap : public Map RoomList addedRooms; - Level* cachedLevel; + //Level* cachedLevel; CRITICAL_SECTION* lock; void Build(void); diff --git a/Map/Path/AStarPath.h b/Map/Path/AStarPath.h index 5d95fffa..b7a77900 100644 --- a/Map/Path/AStarPath.h +++ b/Map/Path/AStarPath.h @@ -99,7 +99,7 @@ class AStarPath : public Path map->AllowCritSpace(); ticks=GetTickCount(); } - if (startLvl != D2CLIENT_GetPlayerUnit()->pPath->pRoom1->pRoom2->pLevel->dwLevelNo){ + if (!GameReady() || startLvl != D2CLIENT_GetPlayerUnit()->pPath->pRoom1->pRoom2->pLevel->dwLevelNo){ Log("Pather lvl change while pathing"); return; } diff --git a/ScreenHook.cpp b/ScreenHook.cpp index 833a3b84..15a7b948 100644 --- a/ScreenHook.cpp +++ b/ScreenHook.cpp @@ -314,7 +314,7 @@ void Genhook::SetClickHandler(jsval handler) //if(JSVAL_IS_FUNCTION(cx, handler)) // JS_RemoveRoot(owner->GetContext(), &clicked); //JS_SetContextThread(cx); - //// 22 JS_BeginRequest(cx); + //JS_BeginRequest(cx); clicked = handler; // if(!JSVAL_IS_VOID(clicked)) @@ -322,12 +322,12 @@ void Genhook::SetClickHandler(jsval handler) // if(JS_AddRoot(owner->GetContext(),&clicked) == JS_FALSE) // { // Unlock(); -// /* 22 JS_EndRequest(cx);*/ +// JS_EndRequest(cx); ////bob1.8.8 JS_ClearContextThread(cx); // return; // } // } -// /* 22 JS_EndRequest(cx);*/ +// JS_EndRequest(cx); //JS_ClearContextThread(cx); Unlock(); } diff --git a/Script.cpp b/Script.cpp index 6df7ec88..39a8838c 100644 --- a/Script.cpp +++ b/Script.cpp @@ -335,7 +335,7 @@ bool Script::Include(const char* file) JSContext* cx = GetContext(); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JSScript* script = JS_CompileFile(cx, GetGlobalObject(), fname); if(script) @@ -351,7 +351,7 @@ bool Script::Include(const char* file) //JS_RemoveRoot(&scriptObj); } else JS_ReportPendingException(cx); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); //JS_RemoveScriptRoot(cx, &script); LeaveCriticalSection(&lock); free(fname); @@ -490,7 +490,7 @@ DWORD WINAPI RunCommandThread(void* data) { RUNCOMMANDSTRUCT* rcs = (RUNCOMMANDSTRUCT*) data; JSContext* cx = rcs->script->GetContext(); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); jsval rval; JS_AddNamedValueRoot(cx, &rval, "Cmd line rtl"); if(JS_EvaluateScript(cx, JS_GetGlobalObject(cx), rcs->command, strlen(rcs->command), "Command Line", 0, &rval)) @@ -505,7 +505,7 @@ DWORD WINAPI RunCommandThread(void* data) } } JS_RemoveRoot(cx, &rval); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); JS_TriggerOperationCallback(JS_GetRuntime(cx)); return 0; } diff --git a/ScriptEngine.cpp b/ScriptEngine.cpp index b53623a1..839a10fd 100644 --- a/ScriptEngine.cpp +++ b/ScriptEngine.cpp @@ -315,7 +315,7 @@ JSBool contextCallback(JSContext* cx, uintN contextOp) { if(contextOp == JSCONTEXT_NEW) { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JS_SetErrorReporter(cx, reportError); JS_SetOperationCallback(cx, operationCallback); @@ -331,7 +331,7 @@ JSBool contextCallback(JSContext* cx, uintN contextOp) //JS_SetGCZeal(cx, 2, 1); JSObject* globalObject = JS_NewGlobalObject(cx, &global_obj, NULL); - //JS_SetGCParameter(JS_GetRuntime(cx), JSGC_MODE, JSGC_MODE_INCREMENTAL); + JS_SetGCParameter(JS_GetRuntime(cx), JSGC_MODE, 2); if(JS_InitStandardClasses(cx, globalObject) == JS_FALSE) return JS_FALSE; @@ -365,7 +365,7 @@ JSBool contextCallback(JSContext* cx, uintN contextOp) DEFCONST(FILE_APPEND); #undef DEFCONST - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); } if(contextOp == JSCONTEXT_DESTROY) @@ -464,7 +464,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) bool* global = (bool*) evt->arg4; jsval* argv = new jsval[evt->argc]; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); argv[0] = JS_NumberValue(*gid); argv[1] = JS_NumberValue(*mode); @@ -479,7 +479,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) JS_CallFunctionValue(cx, JS_GetGlobalObject(cx), *(*it)->value(), 4, argv, &rval); block |= (JSVAL_IS_BOOLEAN(rval) && JSVAL_TO_BOOLEAN(rval)); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); for(int j = 0 ; j < 4; j++) JS_RemoveValueRoot(cx, &argv[j]); } @@ -494,7 +494,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) if(!clearList) { jsval* argv = new jsval[5]; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); argv[0] = JS_NumberValue(*(BYTE*) evt->arg1); argv[1] = JS_NumberValue(*(DWORD*) evt->arg2); argv[2] = JS_NumberValue(*(DWORD*) evt->arg3); @@ -509,7 +509,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) { JS_CallFunctionValue(cx, JS_GetGlobalObject(cx), *(*it)->value(), 5, argv, &rval); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); for(int j = 0 ; j < 5; j++) JS_RemoveValueRoot(cx, &argv[j]); } @@ -525,7 +525,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) if(!clearList) { jsval* argv = new jsval[2]; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); argv[0] = JS_NumberValue(*(DWORD*) evt->arg1); argv[1] = (STRING_TO_JSVAL(JS_NewStringCopyZ(cx, (char*) evt->arg2))); @@ -537,7 +537,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) { JS_CallFunctionValue(cx, JS_GetGlobalObject(cx), *(*it)->value(), 2, argv, &rval); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); for(int j = 0 ; j < 2; j++) JS_RemoveValueRoot(cx, &argv[j]); } @@ -551,7 +551,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) if(!clearList) { jsval* argv = new jsval[2]; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); argv[0] = (STRING_TO_JSVAL(JS_NewStringCopyZ(cx, (char*) evt->arg1))); argv[1] = (STRING_TO_JSVAL(JS_NewStringCopyZ(cx, (char*) evt->arg2))); @@ -564,7 +564,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) JS_CallFunctionValue(cx, JS_GetGlobalObject(cx), *(*it)->value(), 2, argv, &rval); block |= (JSVAL_IS_BOOLEAN(rval) && JSVAL_TO_BOOLEAN(rval)); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); for(int j = 0 ; j < 2; j++) JS_RemoveValueRoot(cx, &argv[j]); } @@ -583,7 +583,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) if(!clearList) { jsval* argv = new jsval[2]; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); argv[0] = JS_NumberValue(*(DWORD*) evt->arg1); argv[1] = JS_NumberValue(*(DWORD*) evt->arg2); @@ -599,7 +599,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) for(FunctionList::iterator it = evt->owner->functions[evtName].begin(); it != evt->owner->functions[evtName].end(); it++) JS_CallFunctionValue(cx, JS_GetGlobalObject(cx), *(*it)->value(), 2, argv, &rval); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); for(int j = 0 ; j < 2; j++) JS_RemoveValueRoot(cx, &argv[j]); } @@ -612,7 +612,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) if(!clearList) { jsval* argv = new jsval[4]; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); argv[0] = JS_NumberValue(*(DWORD*) evt->arg1); argv[1] = JS_NumberValue(*(DWORD*) evt->arg2); argv[2] = JS_NumberValue(*(DWORD*) evt->arg3); @@ -626,7 +626,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) { JS_CallFunctionValue(cx, JS_GetGlobalObject(cx), *(*it)->value(), 4, argv, &rval); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); for(int j = 0 ; j < 4; j++) JS_RemoveValueRoot(cx, &argv[j]); } @@ -642,7 +642,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) if(!clearList) { jsval* argv = new jsval[1]; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); argv[0] = JS_NumberValue(*(DWORD*) evt->arg1); JS_AddValueRoot(cx, &argv[0]); jsval rval; @@ -651,7 +651,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) JS_CallFunctionValue(cx, JS_GetGlobalObject(cx), *(*it)->value(), 1, argv, &rval); block |= (JSVAL_IS_BOOLEAN(rval) && JSVAL_TO_BOOLEAN(rval)); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); JS_RemoveValueRoot(cx, &argv[0]); } if (strcmp(evtName, "keydownblocker") == 0 ){ @@ -669,7 +669,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) if(!clearList) { jsval* argv = new jsval[3]; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); argv[0] = JS_NumberValue(*(DWORD*) evt->arg1); argv[1] = JS_NumberValue(*(DWORD*) evt->arg2); argv[2] = JS_NumberValue(*(DWORD*) evt->arg3); @@ -684,7 +684,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) block |= (JSVAL_IS_BOOLEAN(rval) && JSVAL_TO_BOOLEAN(rval)); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); for(int j = 0 ; j < 3; j++) JS_RemoveValueRoot(cx, &argv[j]); } @@ -702,7 +702,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) test.append( "try{ "); test.append( cmd ); test.append(" } catch (error){print(error)}"); - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); jsval rval; if(JS_EvaluateScript(cx, JS_GetGlobalObject(cx), test.data() , test.length(), "Command Line", 0, &rval)) @@ -716,7 +716,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) JS_free(cx, text); } } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); free(evt->arg1); delete evt; } @@ -724,7 +724,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) if(!clearList) { DWORD* argc = (DWORD*) evt->arg1; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); jsval* argv = new jsval[*argc]; for(uintN i = 0; i < *argc; i++) evt->argv[i]->read(cx, &argv[i]); @@ -737,7 +737,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) { JS_CallFunctionValue(cx, JS_GetGlobalObject(cx), *(*it)->value(), *argc, argv, &rval); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); for(int j = 0 ; j < *argc; j++) JS_RemoveValueRoot(cx, &argv[j]); } @@ -756,7 +756,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) BYTE* help = (BYTE*) evt->arg1; DWORD* size = (DWORD*) evt->arg2; DWORD* argc = (DWORD*) 1; - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); jsval* jsarr = new jsval[*size]; @@ -777,7 +777,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) *(DWORD*) evt->arg4 = block; SetEvent(Vars.eventSignal); - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); // for(int j = 0 ; j < *argc; j++) // JS_RemoveValueRoot(cx, &argv[j]); } @@ -790,7 +790,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) if (strcmp(evtName, "setTimeout") == 0 || strcmp(evtName, "setInterval") == 0) { if(!clearList) { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); jsval* argv = new jsval[evt->argc]; for(uintN i = 0; i < evt->argc; i++) evt->argv[i]->read(cx, &argv[i]); @@ -825,7 +825,7 @@ bool ExecScriptEvent(Event* evt, bool clearList) } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); for(int j = 0 ; j < evt->argc; j++) JS_RemoveValueRoot(cx, &argv[j]); } diff --git a/js32.cpp b/js32.cpp index 68ada2a1..d3d876b5 100644 --- a/js32.cpp +++ b/js32.cpp @@ -5,7 +5,7 @@ JSObject* BuildObject(JSContext* cx, JSClass* classp, JSFunctionSpec* funcs, JSPropertySpec* props, void* priv, JSObject* proto, JSObject* parent) { - // 22 JS_BeginRequest(cx); + JS_BeginRequest(cx); JSObject* obj = JS_NewObject(cx, classp, proto, parent); @@ -23,7 +23,7 @@ JSObject* BuildObject(JSContext* cx, JSClass* classp, JSFunctionSpec* funcs, JSP JS_SetPrivate(cx, obj, priv); JS_RemoveObjectRoot(cx, &obj); } - /* 22 JS_EndRequest(cx);*/ + JS_EndRequest(cx); return obj; } JSScript* JS_CompileFile(JSContext* cx, JSObject* globalObject, std::string fileName)