Skip to content

Commit 5fb5afa

Browse files
committed
2 parents 69d7560 + 8290512 commit 5fb5afa

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

src/ballistica/classic/python/methods/python_methods_classic.cc

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "ballistica/classic/python/classic_python.h"
1414
#include "ballistica/classic/support/classic_app_mode.h"
1515
#include "ballistica/classic/support/stress_test.h"
16+
#include "ballistica/classic/support/v1_account.h"
17+
#include "ballistica/core/platform/platform.h"
1618
#include "ballistica/shared/foundation/event_loop.h"
1719
#include "ballistica/shared/foundation/exception.h"
1820
#include "ballistica/shared/python/python.h"
@@ -736,6 +738,41 @@ static PyMethodDef PyReloadHooksDef = {
736738
"Call this if you replace things in a hooks module to get the\n"
737739
"native layer to see your changes.",
738740
};
741+
742+
// ------------------------ set_server_device_name ----------------------------
743+
744+
static auto PySetServerDeviceName(PyObject* self, PyObject* args) -> PyObject* {
745+
BA_PYTHON_TRY;
746+
const char* name{};
747+
if (!PyArg_ParseTuple(args, "s", &name)) return nullptr;
748+
749+
BA_PRECONDITION(g_base->InLogicThread());
750+
751+
classic::V1AccountType acc_type = g_buildconfig.headless_build()
752+
? classic::V1AccountType::kServer
753+
: classic::V1AccountType::kDevice;
754+
755+
g_classic->v1_account->SetLogin(
756+
acc_type,
757+
classic::V1LoginState::kSignedIn,
758+
name,
759+
g_core->platform->GetDeviceV1AccountID()
760+
);
761+
762+
Py_RETURN_NONE;
763+
BA_PYTHON_CATCH;
764+
}
765+
766+
static PyMethodDef PySetServerDeviceNameDef = {
767+
"set_server_device_name", // name
768+
(PyCFunction)PySetServerDeviceName, // method
769+
METH_VARARGS | METH_KEYWORDS, // flags
770+
771+
"set_server_device_name(name: str) -> None\n"
772+
"\n"
773+
"Set the server/device account name directly.",
774+
};
775+
739776
// -----------------------------------------------------------------------------
740777

741778
auto PythonMethodsClassic::GetMethods() -> std::vector<PyMethodDef> {
@@ -754,6 +791,7 @@ auto PythonMethodsClassic::GetMethods() -> std::vector<PyMethodDef> {
754791
PySetAccountStateDef,
755792
PySetHaveLiveAccountValuesDef,
756793
PyReloadHooksDef,
794+
PySetServerDeviceNameDef,
757795
};
758796
}
759797

0 commit comments

Comments
 (0)