Skip to content

Commit

Permalink
act map fixes
Browse files Browse the repository at this point in the history
re-add begin / end requests
  • Loading branch information
bobode committed Sep 22, 2013
1 parent e4a752a commit 26a1f2a
Show file tree
Hide file tree
Showing 24 changed files with 245 additions and 243 deletions.
4 changes: 2 additions & 2 deletions AutoRoot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion D2BS.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <windows.h>
#include <vector>
Expand Down
3 changes: 2 additions & 1 deletion D2Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions JSArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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:
{
Expand Down Expand Up @@ -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!");
Expand Down
33 changes: 17 additions & 16 deletions JSControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -96,7 +96,7 @@ JSAPI_PROP(control_getProperty)
vp.setNumber((double) ctrl->dwDisabled);
break;
}
/* 22 JS_EndRequest(cx);*/
JS_EndRequest(cx);
return JS_TRUE;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -325,8 +325,9 @@ JSAPI_FUNC(control_getText)

nArrayCount++;
}
JS_EndRequest(cx);


/* 22 JS_EndRequest(cx);*/
return JS_TRUE;
}

Expand All @@ -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)
Expand Down Expand Up @@ -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)
{
Expand All @@ -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;

}
42 changes: 21 additions & 21 deletions JSCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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))
{
Expand Down Expand Up @@ -611,15 +611,15 @@ 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;
}
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);
Expand All @@ -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)
{
Expand All @@ -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);
Expand All @@ -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;
}
8 changes: 4 additions & 4 deletions JSDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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);
Expand Down Expand Up @@ -135,15 +135,15 @@ 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))
continue;
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);

}

Expand Down
Loading

0 comments on commit 26a1f2a

Please sign in to comment.