Skip to content
This repository was archived by the owner on Jan 1, 2025. It is now read-only.

Commit b97dce6

Browse files
committed
Add back in debug builds, fix script hook returns
1 parent 0ca9431 commit b97dce6

14 files changed

+62
-41
lines changed

Python/rando.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def randomize_branches(rng, branches, valid_skills, skill_map):
236236
valid_skills += anarchy_skills
237237
if skill_name == 'BloodyTwitch' or skill_name == 'BloodfilledGuns':
238238
if not added_bl:
239-
valid_skills = list(set(valid_skills + bloodlust_skills))
239+
valid_skills = list(valid_skills + bloodlust_skills)
240240
added_bl = True
241241
has_bloodlust = True
242242
if 'Hellborn' in skill_map[valid_skills[pos]].GetFullName():

Python/test.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
# import bl2sdk
1+
import bl2sdk
22

3-
# def process_hook(caller, stack, result, function):
4-
# code = stack.Code
5-
# OfferingId = stack.popInt()
6-
# print("{} {} {}".format(OfferingId))
7-
# stack.Code = code
8-
# stack.SkipFunction()
9-
# return True
3+
def process_hook(caller, stack, result, function):
4+
code = stack.Code
5+
OfferingId = stack.popFString()
6+
print("{} {}".format(OfferingId.Count, OfferingId.Max))
7+
stack.Code = code
8+
return True
109

1110

12-
# bl2sdk.RemoveScriptHook("Function WillowGame.MarketplaceGFxMovie.CreateContentItem", "Cheeky")
13-
# bl2sdk.RegisterScriptHook("Function WillowGame.MarketplaceGFxMovie.CreateContentItem", "Cheeky", process_hook)
14-
15-
trees = s
16-
for tree in trees:
17-
print(tree.GetFullName())
11+
bl2sdk.RemoveScriptHook("Function WillowGame.MarketplaceGFxMovie.CreateContentItem", "Cheeky")
12+
bl2sdk.RegisterScriptHook("Function WillowGame.MarketplaceGFxMovie.CreateContentItem", "Cheeky", process_hook)

bl2-sdk.sln

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Borderlands 2 SDK", "bl2-sd
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10-
Debug|x32 = Debug|x32
11-
Release|x32 = Release|x32
10+
Debug|x86 = Debug|x86
11+
Release|x86 = Release|x86
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{32794345-2BB2-45E0-A461-914D13B0279F}.Debug|x32.ActiveCfg = Debug|Win32
15-
{32794345-2BB2-45E0-A461-914D13B0279F}.Debug|x32.Build.0 = Debug|Win32
16-
{32794345-2BB2-45E0-A461-914D13B0279F}.Release|x32.ActiveCfg = Release|Win32
17-
{32794345-2BB2-45E0-A461-914D13B0279F}.Release|x32.Build.0 = Release|Win32
14+
{32794345-2BB2-45E0-A461-914D13B0279F}.Debug|x86.ActiveCfg = Debug|Win32
15+
{32794345-2BB2-45E0-A461-914D13B0279F}.Debug|x86.Build.0 = Debug|Win32
16+
{32794345-2BB2-45E0-A461-914D13B0279F}.Release|x86.ActiveCfg = Release|Win32
17+
{32794345-2BB2-45E0-A461-914D13B0279F}.Release|x86.Build.0 = Release|Win32
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE

bl2-sdk/CPythonInterface.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,15 @@ PYBIND11_EMBEDDED_MODULE(bl2sdk, m)
5959
Export_pystes_Engine_classes(m);
6060
Export_pystes_GameFramework_structs(m);
6161
Export_pystes_GameFramework_classes(m);
62+
#ifndef _DEBUG
6263
Export_pystes_GFxUI_structs(m);
6364
Export_pystes_GFxUI_classes(m);
65+
#endif
6466
Export_pystes_GearboxFramework_structs(m);
6567
Export_pystes_GearboxFramework_classes(m);
6668
Export_pystes_WillowGame_structs(m);
6769
Export_pystes_WillowGame_classes(m);
70+
#ifndef _DEBUG
6871
Export_pystes_AkAudio_structs(m);
6972
Export_pystes_AkAudio_classes(m);
7073
Export_pystes_IpDrv_structs(m);
@@ -75,6 +78,7 @@ PYBIND11_EMBEDDED_MODULE(bl2sdk, m)
7578
Export_pystes_XAudio2_classes(m);
7679
Export_pystes_OnlineSubsystemSteamworks_structs(m);
7780
Export_pystes_OnlineSubsystemSteamworks_classes(m);
81+
#endif
7882
Export_pystes_TArray(m);
7983
m.def("Log", [](std::string in) { Logging::Log(in.c_str(), in.length()); });
8084
m.def("LoadPackage", &BL2SDK::LoadPackage);
@@ -98,14 +102,16 @@ bool CheckPythonCommand(UObject* caller, FFrame& stack, void* const result, UFun
98102
BL2SDK::pFrameStep(&stack, stack.Object, command);
99103
char *input = command->AsString();
100104
if (strncmp("py ", input, 3) == 0) {
105+
Logging::LogF("\n>>> %s <<<\n", input);
101106
BL2SDK::Python->DoString(input + 3);
102107
stack.SkipFunction();
103-
return true;
108+
return false;
104109
}
105110
else if (strncmp("pyexec ", input, 7) == 0) {
111+
Logging::LogF("\n>>> %s <<<\n", input);
106112
BL2SDK::Python->DoFile(input + 7);
107113
stack.SkipFunction();
108-
return true;
114+
return false;
109115
}
110116
stack.Code = code;
111117
return true;

bl2-sdk/TypeMap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <map>
55

66
static std::map<std::string, const std::type_info *> uobject_type_map{
7+
#ifndef _DEBUG
78
{"_ModifyHealthParams", &typeid(F_ModifyHealthParams)},
89
{"AccelStateData", &typeid(FAccelStateData)},
910
{"AccessControl", &typeid(AAccessControl)},
@@ -4746,4 +4747,5 @@ static std::map<std::string, const std::type_info *> uobject_type_map{
47464747
{"XAudio2Device", &typeid(UXAudio2Device)},
47474748
{"XnaForceFeedbackManager", &typeid(UXnaForceFeedbackManager)},
47484749
{"ZoneInfo", &typeid(AZoneInfo)}
4750+
#endif
47494751
};

bl2-sdk/bl2-sdk.vcxproj

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
3131
<ConfigurationType>DynamicLibrary</ConfigurationType>
3232
<UseDebugLibraries>true</UseDebugLibraries>
33-
<PlatformToolset>v141</PlatformToolset>
33+
<PlatformToolset>v140</PlatformToolset>
3434
<CharacterSet>Unicode</CharacterSet>
35+
<WholeProgramOptimization>true</WholeProgramOptimization>
3536
</PropertyGroup>
3637
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
3738
<ConfigurationType>DynamicLibrary</ConfigurationType>
@@ -73,11 +74,11 @@
7374
<PropertyGroup Label="UserMacros" />
7475
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
7576
<LinkIncremental>true</LinkIncremental>
76-
<TargetName>binkw32</TargetName>
77+
<TargetName>PythonSDK</TargetName>
7778
<PreBuildEventUseInBuild>false</PreBuildEventUseInBuild>
7879
<IncludePath>$(PYTHONPATH)\include;$(IncludePath)</IncludePath>
7980
<LibraryPath>$(PYTHONPATH)\libs;$(LibraryPath)</LibraryPath>
80-
<OutDir>C:\Program Files (x86)\Steam\steamapps\common\Borderlands 2\Binaries\Win32\</OutDir>
81+
<OutDir>C:\Program Files (x86)\Steam\steamapps\common\Borderlands 2\Binaries\Win32\Plugins\</OutDir>
8182
</PropertyGroup>
8283
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
8384
<LinkIncremental>true</LinkIncremental>
@@ -98,7 +99,7 @@
9899
<ClCompile>
99100
<PrecompiledHeader>Use</PrecompiledHeader>
100101
<WarningLevel>Level3</WarningLevel>
101-
<Optimization>Disabled</Optimization>
102+
<Optimization>MinSpace</Optimization>
102103
<SDLCheck>false</SDLCheck>
103104
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;BL2SDK_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
104105
<ConformanceMode>true</ConformanceMode>
@@ -109,6 +110,10 @@
109110
<IntrinsicFunctions>true</IntrinsicFunctions>
110111
<WholeProgramOptimization>false</WholeProgramOptimization>
111112
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
113+
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
114+
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
115+
<MinimalRebuild />
116+
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
112117
</ClCompile>
113118
<Link>
114119
<SubSystem>Windows</SubSystem>

bl2-sdk/gamedefines.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,21 +272,21 @@ struct FFrame : public FOutputDevice
272272
struct FFrame* PreviousFrame;
273273
struct FOutParmRec* OutParms;
274274
void SkipFunction() {
275-
while (this->Code[0] != 0x16)
276-
this->Code = this->Code + 1;
275+
while ((this->Code++)[0] != 0x16)
276+
;
277277
}
278278
UObject *popObject() {
279279
UObject *obj = nullptr;
280280
BL2SDK::pFrameStep(this, this->Object, &obj);
281281
return obj;
282282
};
283283
struct FName *popFName() {
284-
FName *obj = &FName();
284+
FName *obj = new FName();
285285
BL2SDK::pFrameStep(this, this->Object, obj);
286286
return obj;
287287
};
288288
struct FString *popFString() {
289-
FString *obj = &FString();
289+
FString *obj = new FString();
290290
BL2SDK::pFrameStep(this, this->Object, obj);
291291
return obj;
292292
};
@@ -311,7 +311,7 @@ struct FFrame : public FOutputDevice
311311
return obj;
312312
};
313313
TArray<UObject *> *popTArrayObjects() {
314-
TArray<UObject *> *obj = &TArray<UObject *>();
314+
TArray<UObject *> *obj = new TArray<UObject *>();
315315
BL2SDK::pFrameStep(this, this->Object, obj);
316316
return obj;
317317
};

bl2-sdk/pydefs/Engine_classes.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,7 @@ void Export_pystes_Engine_classes(py::module &m)
11791179
py::class_< ABrushShape, ABrush >(m, "ABrushShape")
11801180
.def_static("StaticClass", &ABrushShape::StaticClass, py::return_value_policy::reference)
11811181
;
1182+
#ifndef _DEBUG
11821183
py::class_< AVolume, ABrush >(m, "AVolume")
11831184
.def_static("StaticClass", &AVolume::StaticClass, py::return_value_policy::reference)
11841185
.def_property("bForcePawnWalk", [](AVolume &self){return self.bForcePawnWalk;}, [](AVolume &self, bool value){self.bForcePawnWalk = value ? 1 : 0;})
@@ -3442,6 +3443,7 @@ void Export_pystes_Engine_classes(py::module &m)
34423443
py::class_< UVoiceChannel, UChannel >(m, "UVoiceChannel")
34433444
.def_static("StaticClass", &UVoiceChannel::StaticClass, py::return_value_policy::reference)
34443445
;
3446+
#endif
34453447
py::class_< AController, AActor >(m, "AController")
34463448
.def_static("StaticClass", &AController::StaticClass, py::return_value_policy::reference)
34473449
.def_property("bIsPlayer", [](AController &self){return self.bIsPlayer;}, [](AController &self, bool value){self.bIsPlayer = value ? 1 : 0;})
@@ -4357,6 +4359,7 @@ void Export_pystes_Engine_classes(py::module &m)
43574359
.def("TellPeerToTravelToSession", [](APlayerController &self , struct FUniqueNetId ToPeerNetId, struct FName SessionName, class UClass* SearchClass, int PlatformSpecificInfoSize) { unsigned char* pyPlatformSpecificInfo = (unsigned char*)malloc(sizeof(unsigned char)) ; self.TellPeerToTravelToSession(ToPeerNetId, SessionName, SearchClass, pyPlatformSpecificInfo, PlatformSpecificInfoSize); return py::make_tuple(*pyPlatformSpecificInfo); })
43584360
.def("EnableActorHeadTracking", [](APlayerController &self , class AActor* TargetActor, struct FName* TrackControllerName, unsigned long bLookAtPawns, float MinLookAtTime, float MaxLookAtTime, float MaxInterestTime, float LookAtActorRadius, struct FName* TargetBoneNames) { class UClass** pyActorClassesToLookAt = 0 ; self.EnableActorHeadTracking(TargetActor, TrackControllerName, pyActorClassesToLookAt, bLookAtPawns, MinLookAtTime, MaxLookAtTime, MaxInterestTime, LookAtActorRadius, TargetBoneNames); return py::make_tuple(*pyActorClassesToLookAt); })
43594361
;
4362+
#ifndef _DEBUG
43604363
py::class_< UCheatManager, UObject >(m, "UCheatManager")
43614364
.def_static("StaticClass", &UCheatManager::StaticClass, py::return_value_policy::reference)
43624365
.def_readwrite("DebugCameraControllerRef", &UCheatManager::DebugCameraControllerRef, py::return_value_policy::reference)
@@ -10713,6 +10716,7 @@ void Export_pystes_Engine_classes(py::module &m)
1071310716
.def("SetMeshAndPhysAsset", &AKAsset::SetMeshAndPhysAsset)
1071410717
.def("eventPostBeginPlay", &AKAsset::eventPostBeginPlay)
1071510718
;
10719+
#endif
1071610720
py::class_< APawn, AActor >(m, "APawn")
1071710721
.def_static("StaticClass", &APawn::StaticClass, py::return_value_policy::reference)
1071810722
.def_property("bScriptTickSpecial", [](APawn &self){return self.bScriptTickSpecial;}, [](APawn &self, bool value){self.bScriptTickSpecial = value ? 1 : 0;})
@@ -11309,6 +11313,7 @@ void Export_pystes_Engine_classes(py::module &m)
1130911313
.def("GetBestAnchor", [](APawn &self , class AActor* TestActor, struct FVector TestLocation, unsigned long bStartPoint, unsigned long bOnlyCheckVisible) { float* pyout_Dist = (float*)malloc(sizeof(float)) ; class ANavigationPoint* ret = self.GetBestAnchor(TestActor, TestLocation, bStartPoint, bOnlyCheckVisible, pyout_Dist); return py::make_tuple(ret, *pyout_Dist); })
1131011314
.def("GetExpInfo", [](APawn &self ) { int* pyExpLevelValue = (int*)malloc(sizeof(int)) ; self.GetExpInfo(pyExpLevelValue); return py::make_tuple(*pyExpLevelValue); })
1131111315
;
11316+
#ifndef _DEBUG
1131211317
py::class_< AVehicle, APawn >(m, "AVehicle")
1131311318
.def_static("StaticClass", &AVehicle::StaticClass, py::return_value_policy::reference)
1131411319
.def_property("bDriving", [](AVehicle &self){return self.bDriving;}, [](AVehicle &self, bool value){self.bDriving = value ? 1 : 0;})
@@ -18390,5 +18395,5 @@ void Export_pystes_Engine_classes(py::module &m)
1839018395
.def_static("StaticClass", &AWindDirectionalSource::StaticClass, py::return_value_policy::reference)
1839118396
.def_readwrite("Component", &AWindDirectionalSource::Component, py::return_value_policy::reference)
1839218397
;
18393-
18398+
#endif
1839418399
}

bl2-sdk/pydefs/Engine_structs.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace py = pybind11;
55
// Module ======================================================================
66
void Export_pystes_Engine_structs(py::module &m)
77
{
8+
#ifndef _DEBUG
89
py::class_< FStaticMeshLODElement >(m, "FStaticMeshLODElement")
910
.def_property("bEnableShadowCasting", [](FStaticMeshLODElement &self){return self.bEnableShadowCasting;}, [](FStaticMeshLODElement &self, bool value){self.bEnableShadowCasting = value ? 1 : 0;})
1011
.def_property("bEnableCollision", [](FStaticMeshLODElement &self){return self.bEnableCollision;}, [](FStaticMeshLODElement &self, bool value){self.bEnableCollision = value ? 1 : 0;})
@@ -3390,5 +3391,5 @@ void Export_pystes_Engine_structs(py::module &m)
33903391
.def_readwrite("Sources", &FWorldEventSource::Sources, py::return_value_policy::reference)
33913392
.def_readwrite("LastUpdateTime", &FWorldEventSource::LastUpdateTime)
33923393
;
3393-
3394+
#endif
33943395
}

bl2-sdk/pydefs/GameFramework_classes.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ void Export_pystes_GameFramework_classes(py::module &m)
2727
.def("DoForceFeedbackForScreenShake", &AGamePlayerController::DoForceFeedbackForScreenShake)
2828
.def("GetUIPlayerIndex", &AGamePlayerController::GetUIPlayerIndex)
2929
;
30+
#ifndef _DEBUG
3031
py::class_< UGameTypes, UObject >(m, "UGameTypes")
3132
.def_static("StaticClass", &UGameTypes::StaticClass, py::return_value_policy::reference)
3233
;
@@ -125,5 +126,5 @@ void Export_pystes_GameFramework_classes(py::module &m)
125126
.def_static("StaticClass", &UPMESTG_LeaveADecalBase::StaticClass, py::return_value_policy::reference)
126127
.def_readwrite("PhysicalMaterialPropertyClass", &UPMESTG_LeaveADecalBase::PhysicalMaterialPropertyClass, py::return_value_policy::reference)
127128
;
128-
129+
#endif
129130
}

0 commit comments

Comments
 (0)