Skip to content

Commit

Permalink
Merge pull request #63 from apple1417/master
Browse files Browse the repository at this point in the history
upgrade unrealsdk, fix tps
  • Loading branch information
apple1417 authored Jan 1, 2025
2 parents b360085 + e570d04 commit 82269e4
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.25)

project(pyunrealsdk VERSION 1.5.0)
project(pyunrealsdk VERSION 1.5.1)

function(_pyunrealsdk_add_base_target_args target_name)
target_compile_features(${target_name} PUBLIC cxx_std_20)
Expand Down
22 changes: 22 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

## v1.5.1
- Changed type hinting of `unrealsdk.find_all` to return an `Iterable[UObject]`, instead of
`Iterator[UObject]`. This mirrors what was actually happening at runtime.

[fbe877ef](https://github.com/bl-sdk/pyunrealsdk/commit/fbe877ef)

### unrealsdk v1.6.0
For reference, the unrealsdk v1.6.0 changes this includes are:

> - Handled `UStruct` differing in size between BL2 and TPS.
>
> This affects all members on it's subclasses - `UClass::ClassDefaultObject`, `UClass::Interfaces`,
> `UFunction::FunctionFlags`, `UFunction::NumParams`, `UFunction::ParamsSize`,
> `UFunction::ReturnValueOffset`, and `UScriptStruct::StructFlags` have all now changed to methods
> which return a reference.
>
> [72579c18](https://github.com/bl-sdk/unrealsdk/commit/72579c18)
>
> - Fixed all BL3 console output being treated as console commands instead.
>
> [1432408f](https://github.com/bl-sdk/unrealsdk/commit/1432408f)
## v1.5.0

- Deprecated `unrealsdk.hooks.inject_next_call` in favour of a new
Expand Down
4 changes: 2 additions & 2 deletions src/pyunrealsdk/unreal_bindings/bound_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ namespace impl {
PyCallInfo::PyCallInfo(const UFunction* func, const py::args& args, const py::kwargs& kwargs)
// Start by initializing a null struct, to avoid allocations
: params(func, nullptr) {
if (func->NumParams < args.size()) {
if (func->NumParams() < args.size()) {
throw py::type_error(
unrealsdk::fmt::format("{}() takes {} positional args, but {} were given", func->Name,
func->NumParams, args.size()));
func->NumParams(), args.size()));
}

// If we're given exactly one arg, and it's a wrapped struct of our function type, take it as
Expand Down
26 changes: 19 additions & 7 deletions src/pyunrealsdk/unreal_bindings/uobject_children.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,12 @@ void register_uobject_children(py::module_& mod) {
"Returns:\n"
" True if this class implements the interface, false otherwise.",
"interface"_a)
.def_readwrite("ClassDefaultObject", &UClass::ClassDefaultObject)
.def_property(
"ClassDefaultObject", [](const UClass* self) { return self->ClassDefaultObject(); },
[](UClass* self, UObject* value) { self->ClassDefaultObject() = value; })
.def_property_readonly("Interfaces", [](const UClass* self) {
std::vector<UClass*> interfaces{};
for (const auto& iface : self->Interfaces) {
for (const auto& iface : self->Interfaces()) {
interfaces.push_back(iface.Class);
}
return interfaces;
Expand All @@ -179,10 +181,18 @@ void register_uobject_children(py::module_& mod) {
"\n"
"Returns:\n"
" The return param, or None if it doesn't exist.")
.def_readwrite("FunctionFlags", &UFunction::FunctionFlags)
.def_readwrite("NumParams", &UFunction::NumParams)
.def_readwrite("ParamsSize", &UFunction::ParamsSize)
.def_readwrite("ReturnValueOffset", &UFunction::ReturnValueOffset);
.def_property(
"FunctionFlags", [](const UFunction* self) { return self->FunctionFlags(); },
[](UFunction* self, uint32_t value) { self->FunctionFlags() = value; })
.def_property(
"NumParams", [](const UFunction* self) { return self->NumParams(); },
[](UFunction* self, uint8_t value) { self->NumParams() = value; })
.def_property(
"ParamsSize", [](const UFunction* self) { return self->ParamsSize(); },
[](UFunction* self, uint16_t value) { self->ParamsSize() = value; })
.def_property(
"ReturnValueOffset", [](const UFunction* self) { return self->ReturnValueOffset(); },
[](UFunction* self, uint16_t value) { self->ReturnValueOffset() = value; });

PyUEClass<UInt8Property, UProperty>(mod, "UInt8Property");

Expand All @@ -204,7 +214,9 @@ void register_uobject_children(py::module_& mod) {
.def_property_readonly("PropertyClass", &UObjectProperty::get_property_class);

PyUEClass<UScriptStruct, UStruct>(mod, "UScriptStruct")
.def_readwrite("StructFlags", &UScriptStruct::StructFlags);
.def_property(
"StructFlags", [](const UScriptStruct* self) { return self->StructFlags(); },
[](UScriptStruct* self, uint32_t value) { self->StructFlags() = value; });

PyUEClass<UStrProperty, UProperty>(mod, "UStrProperty");

Expand Down
4 changes: 2 additions & 2 deletions stubs/unrealsdk/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from collections.abc import Iterator, Mapping
from collections.abc import Iterable, Mapping
from typing import Any

from . import commands, hooks, logging, unreal
Expand Down Expand Up @@ -50,7 +50,7 @@ def construct_object(
The constructed object.
"""

def find_all(cls: UClass | str, exact: bool = True) -> Iterator[UObject]:
def find_all(cls: UClass | str, exact: bool = True) -> Iterable[UObject]:
"""
Finds all instances of a class.
Expand Down

0 comments on commit 82269e4

Please sign in to comment.