mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-05-15 01:42:07 +02:00
Use module names instead of indexes if they are available in User::_from_dict() and User::_to_dict().
This commit is contained in:
parent
abd7a0660e
commit
0b56f22f87
@ -218,6 +218,7 @@ Dictionary User::_to_dict() {
|
|||||||
|
|
||||||
m->read_lock();
|
m->read_lock();
|
||||||
mdict["index"] = i;
|
mdict["index"] = i;
|
||||||
|
mdict["module_name"] = m->get_module_name();
|
||||||
mdict["data"] = m->to_dict();
|
mdict["data"] = m->to_dict();
|
||||||
m->read_unlock();
|
m->read_unlock();
|
||||||
|
|
||||||
@ -246,15 +247,23 @@ void User::_from_dict(const Dictionary &dict) {
|
|||||||
for (int i = 0; i < marr.size(); ++i) {
|
for (int i = 0; i < marr.size(); ++i) {
|
||||||
Dictionary mdict = marr[i];
|
Dictionary mdict = marr[i];
|
||||||
|
|
||||||
if (!mdict.has("index") || !mdict.has("data")) {
|
String module_name;
|
||||||
continue;
|
|
||||||
|
if (mdict.has("module_name")) {
|
||||||
|
module_name = mdict["module_name"];
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = mdict["index"];
|
Ref<UserModule> m;
|
||||||
|
|
||||||
ERR_CONTINUE(index < 0 || index >= _modules.size());
|
if (module_name.empty()) {
|
||||||
|
int index = mdict["index"];
|
||||||
|
|
||||||
Ref<UserModule> m = _modules[index];
|
ERR_CONTINUE(index < 0 || index >= _modules.size());
|
||||||
|
|
||||||
|
m = _modules[index];
|
||||||
|
} else {
|
||||||
|
m = get_module_named(module_name);
|
||||||
|
}
|
||||||
|
|
||||||
ERR_CONTINUE(!m.is_valid());
|
ERR_CONTINUE(!m.is_valid());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user