Skip to content

Commit 13f2561

Browse files
author
Roberto De Ioris
committed
improved broadcast api
1 parent 8bda9d7 commit 13f2561

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

Source/UnrealEnginePython/Private/UEPyEngine.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,21 @@ PyObject *py_unreal_engine_convert_relative_path_to_full(PyObject * self, PyObje
143143
return PyUnicode_FromString(TCHAR_TO_UTF8(*FPaths::ConvertRelativePathToFull(UTF8_TO_TCHAR(path))));
144144
}
145145

146+
PyObject *py_unreal_engine_create_world(PyObject * self, PyObject * args) {
147+
int world_type = 0;
148+
if (!PyArg_ParseTuple(args, "|i:create_world", &world_type)) {
149+
return NULL;
150+
}
151+
152+
UWorld *world = UWorld::CreateWorld((EWorldType::Type)world_type, false);
153+
154+
ue_PyUObject *ret = ue_get_python_wrapper(world);
155+
if (!ret)
156+
return PyErr_Format(PyExc_Exception, "uobject is in invalid state");
157+
Py_INCREF(ret);
158+
return (PyObject *)ret;
159+
}
160+
146161
PyObject *py_unreal_engine_find_class(PyObject * self, PyObject * args) {
147162
char *name;
148163
if (!PyArg_ParseTuple(args, "s:find_class", &name)) {

Source/UnrealEnginePython/Private/UEPyEngine.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ PyObject *py_unreal_engine_convert_relative_path_to_full(PyObject *, PyObject *)
4545
PyObject *py_unreal_engine_get_viewport_screenshot(PyObject *, PyObject *);
4646
PyObject *py_unreal_engine_get_viewport_size(PyObject *, PyObject *);
4747

48+
PyObject *py_unreal_engine_create_world(PyObject *, PyObject *);
49+
4850

4951
#if WITH_EDITOR
5052
PyObject *py_unreal_engine_editor_get_active_viewport_screenshot(PyObject *, PyObject *);

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ static PyMethodDef unreal_engine_methods[] = {
155155
{ "create_checkerboard_texture", py_unreal_engine_create_checkerboard_texture, METH_VARARGS, "" },
156156
{ "create_transient_texture", py_unreal_engine_create_transient_texture, METH_VARARGS, "" },
157157

158+
{ "create_world", py_unreal_engine_create_world, METH_VARARGS, "" },
159+
158160
// slate
159161

160162
{ "register_nomad_tab_spawner", py_unreal_engine_register_nomad_tab_spawner, METH_VARARGS, "" },

Source/UnrealEnginePython/Private/UEPyObject.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,8 @@ PyObject *py_ue_broadcast(ue_PyUObject *self, PyObject *args) {
553553

554554
if (auto casted_prop = Cast<UMulticastDelegateProperty>(u_property)) {
555555
FMulticastScriptDelegate multiscript_delegate = casted_prop->GetPropertyValue_InContainer(self->ue_object);
556-
uint8 *parms = (uint8 *)FMemory_Alloca(0);
556+
uint8 *parms = (uint8 *)FMemory_Alloca(casted_prop->SignatureFunction->PropertiesSize);
557+
FMemory::Memzero(parms, casted_prop->SignatureFunction->PropertiesSize);
557558
multiscript_delegate.ProcessMulticastDelegate<UObject>(parms);
558559
}
559560
else {

0 commit comments

Comments
 (0)