Skip to content

Commit

Permalink
updating including profile object, revealLevel, and me.automap
Browse files Browse the repository at this point in the history
  • Loading branch information
bobode committed Dec 23, 2012
1 parent b3c03a7 commit 23b3425
Show file tree
Hide file tree
Showing 35 changed files with 974 additions and 1,773 deletions.
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.1757" //uptodate with d branch 1744
#define D2BS_VERSION "1.5.1764" //uptodate with d branch 1764

#include <windows.h>
#include <vector>
Expand Down
10 changes: 8 additions & 2 deletions D2BS.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<IgnoreImportLibrary Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</IgnoreImportLibrary>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Midl>
Expand Down Expand Up @@ -132,7 +133,7 @@
<ClCompile>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_NDEBUG;WIN32_LEAN_AND_MEAN;_MSVC_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;XP_WIN;_WINDOWS;NDEBUG;_NDEBUG;WIN32_LEAN_AND_MEAN;STATIC_JS_API;_MSVC_DEBUG;_LIB;MOZILLA_STRICT_API;-D_NSPR_BUILD_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<SmallerTypeCheck>false</SmallerTypeCheck>
Expand All @@ -156,7 +157,7 @@
<Culture>0x0407</Culture>
</ResourceCompile>
<Link>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;shlwapi.lib;advapi32.lib;dbghelp.lib;dependencies\libs\debug\mozjs.lib</AdditionalDependencies>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;shlwapi.lib;advapi32.lib;dbghelp.lib;Winmm.lib;dependencies\js_static.lib;dependencies\nspr4.lib</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<ModuleDefinitionFile>
</ModuleDefinitionFile>
Expand All @@ -178,6 +179,7 @@
</PostBuildEvent>
<ProjectReference>
<UseLibraryDependencyInputs>true</UseLibraryDependencyInputs>
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Packaging|Win32'">
Expand Down Expand Up @@ -253,7 +255,9 @@ XCOPY "$(ProjectDir)resources" "$(OutDir)release-pkg"
<ClCompile Include="Events.cpp" />
<ClCompile Include="Helpers.cpp" />
<ClCompile Include="js32.cpp" />
<ClCompile Include="JSProfile.cpp" />
<ClCompile Include="Offset.cpp" />
<ClCompile Include="Profile.cpp" />
<ClCompile Include="sqlite3.c">
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SmallerTypeCheck Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</SmallerTypeCheck>
Expand Down Expand Up @@ -316,6 +320,7 @@ XCOPY "$(ProjectDir)resources" "$(OutDir)release-pkg"
<ClInclude Include="D2Ptrs.h" />
<ClInclude Include="D2Skills.h" />
<ClInclude Include="D2Structs.h" />
<ClInclude Include="JSProfile.h" />
<ClInclude Include="Patch.h" />
<ClInclude Include="D2Intercepts.h" />
<ClInclude Include="D2Handlers.h" />
Expand All @@ -328,6 +333,7 @@ XCOPY "$(ProjectDir)resources" "$(OutDir)release-pkg"
<ClInclude Include="js32.h" />
<ClInclude Include="MapHeader.h" />
<ClInclude Include="Offset.h" />
<ClInclude Include="Profile.h" />
<ClInclude Include="sqlite3.h" />
<ClInclude Include="stringhash.h" />
<ClInclude Include="TimedAlloc.h" />
Expand Down
12 changes: 12 additions & 0 deletions D2BS.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@
<ClCompile Include="Map\Diablo_II\LevelMap.cpp">
<Filter>Map\Diablo II</Filter>
</ClCompile>
<ClCompile Include="JSProfile.cpp">
<Filter>Spidermonkey Engine\Core\JS</Filter>
</ClCompile>
<ClCompile Include="Profile.cpp">
<Filter>Spidermonkey Engine\Core\C</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="D2BS.h">
Expand Down Expand Up @@ -420,6 +426,12 @@
<ClInclude Include="ScriptEngine.h">
<Filter>Spidermonkey Engine\Engine</Filter>
</ClInclude>
<ClInclude Include="JSProfile.h">
<Filter>Spidermonkey Engine\Core\API</Filter>
</ClInclude>
<ClInclude Include="Profile.h">
<Filter>Spidermonkey Engine\Core\C</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="dependencies\include\jsproto.tbl">
Expand Down
23 changes: 2 additions & 21 deletions Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "D2Ptrs.h"
#include "Helpers.h"
#include "DbgHelp.h"
#include "Profile.h"

wchar_t* AnsiToUnicode(const char* str)
{
Expand Down Expand Up @@ -49,7 +50,7 @@ void StringReplace(char* str, const char find, const char replace, size_t buflen

bool SwitchToProfile(const char* profile)
{
if(Vars.bUseProfileScript != TRUE || !ProfileExists(profile))
if(Vars.bUseProfileScript != TRUE || !Profile::ProfileExists(profile))
return false;

char file[_MAX_FNAME+_MAX_PATH] = "",
Expand All @@ -74,26 +75,6 @@ bool SwitchToProfile(const char* profile)
return true;
}

bool ProfileExists(const char *profile)
{
char file[_MAX_FNAME+_MAX_PATH], profiles[65535] = "";
sprintf_s(file, sizeof(file), "%sd2bs.ini", Vars.szPath);

int count = GetPrivateProfileString(NULL, NULL, NULL, profiles, 65535, file);
if(count > 0)
{
int i = 0;
while(i < count)
{
if(_strcmpi(profiles+i, profile) == 0)
return true;

i += strlen(profiles+i)+1;
}
}
return false;
}

void InitSettings(void)
{
char fname[_MAX_FNAME+MAX_PATH], scriptPath[_MAX_PATH], defaultStarter[_MAX_FNAME], defaultGame[_MAX_FNAME],
Expand Down
1 change: 0 additions & 1 deletion Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ char* UnicodeToAnsi(const wchar_t* str);
bool StringToBool(const char* str);
void StringReplace(char* str, const char find, const char replace, size_t buflen);
bool SwitchToProfile(const char* profile);
bool ProfileExists(const char* profile);
void InitSettings(void);
bool InitHooks(void);
bool ExecCommand(const char* command);
Expand Down
2 changes: 1 addition & 1 deletion JSCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ JSAPI_FUNC(my_copy)
char* tempData;


strcpy_s(pText,strlen(data)+1, tempData);
// strcpy_s(pText,strlen(data)+1, tempData);
GlobalUnlock(hText);

OpenClipboard(NULL);
Expand Down
28 changes: 28 additions & 0 deletions JSGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "JSGlobalClasses.h"
#include "TimedAlloc.h"
#include "MapHeader.h"
#include "JSRoom.h"

#include <cassert>
#include <cmath>
Expand Down Expand Up @@ -1557,4 +1558,31 @@ JSAPI_FUNC(my_moveNPC)
D2NET_SendPacket(sizeof(aPacket), 1, aPacket);
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}

JSAPI_FUNC(my_revealLevel)
{
UnitAny* unit = D2CLIENT_GetPlayerUnit();

if (!unit) {
return JS_TRUE;
}

Level* level = unit->pPath->pRoom1->pRoom2->pLevel;

if (!level) {
return JS_TRUE;
}

BOOL bDrawPresets = false;

if (argc == 1 && JSVAL_IS_BOOLEAN(JS_ARGV(cx, vp)[0])) {
bDrawPresets = !!JSVAL_TO_BOOLEAN(JS_ARGV(cx, vp)[0]);
}

for(Room2* room = level->pRoom2First; room; room = room->pRoom2Next) {
RevealRoom(room, bDrawPresets);
}

return JS_TRUE;
}
1 change: 1 addition & 0 deletions JSGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ JSAPI_FUNC(my_getWaypoint);
JSAPI_FUNC(my_getBaseStat);
JSAPI_FUNC(my_getPlayerFlag);
JSAPI_FUNC(my_moveNPC);
JSAPI_FUNC(my_revealLevel);
#endif
17 changes: 15 additions & 2 deletions JSGlobalClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "JSExits.h"
#include "JSRoom.h"
#include "JSScript.h"
#include "JSProfile.h"

JSClass global_obj = {
"global", JSCLASS_GLOBAL_FLAGS,
Expand Down Expand Up @@ -127,7 +128,16 @@ JSClass unit_class = {
JSCLASS_SPEC(JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, unit_finalize, unit_ctor)};


JSClass profile_class = {
"Profile", JSCLASS_HAS_PRIVATE,
JSCLASS_SPEC(JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, profile_finalize, profile_ctor)};

JSClass profileType_class = {
"ProfileType", JSCLASS_HAS_PRIVATE,
JSCLASS_SPEC(JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, NULL, profileType_ctor)};



//JSExtendedClass unit_class_ex = {
Expand Down Expand Up @@ -159,7 +169,7 @@ JSClassSpec global_classes[] = {
{&exit_class, 0, exit_ctor, 0, NULL, exit_props, NULL, NULL},
{&party_class, 0, party_ctor, 0, party_methods, party_props, NULL, NULL},
{&room_class, 0, room_ctor, 0, room_methods, room_props, NULL, NULL},

{&file_class, 0, file_ctor, 0, file_methods, file_props, file_s_methods, NULL},
{&filetools_class, 0, filetools_ctor, 0, NULL, NULL, filetools_s_methods, NULL},
{&sqlite_db, 0, sqlite_ctor, 0, sqlite_methods, sqlite_props, NULL, NULL},
Expand Down Expand Up @@ -187,6 +197,9 @@ JSClassSpec global_classes[] = {
//{&exit_class, exit_props, NULL, NULL, NULL},
//{&party_class, party_props, party_methods, NULL, NULL},
//{&room_class, room_props, room_methods, NULL, NULL},
//{&profile_class, profile_props, profile_methods, NULL, NULL},
//{&profileType_class, NULL, NULL, profileType_props,
// NULL},

// utility objects
//{&file_class, file_props, file_methods, NULL, file_s_methods},
Expand Down
2 changes: 2 additions & 0 deletions JSGlobalClasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ extern JSClass folder_class;
extern JSClass control_class;
extern JSClass area_class;
extern JSClass unit_class;
extern JSClass profile_class;
extern JSClass profileType_class;

//extern JSExtendedClass unit_class_ex;
//extern JSExtendedClass file_class_ex;
Expand Down
1 change: 1 addition & 0 deletions JSGlobalFuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ static JSFunctionSpec global_funcs[] = {
{"getPacket", my_getPacket, 0},
{"sendPacket", my_sendPacket, 0},
{"getIP", my_getIP, 0},
{"revealLevel", my_revealLevel, 0},
// drawing functions
{"screenToAutomap", screenToAutomap, 1},
{"automapToScreen", automapToScreen, 1},
Expand Down
Loading

0 comments on commit 23b3425

Please sign in to comment.