summaryrefslogtreecommitdiff
path: root/scene/resources/packed_scene.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources/packed_scene.cpp')
-rw-r--r--scene/resources/packed_scene.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 5a2cd9a1c2..978d81d5c2 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -39,7 +39,7 @@
#include "scene/gui/control.h"
#include "scene/main/instance_placeholder.h"
-#define PACK_VERSION 2
+#define PACKED_SCENE_VERSION 2
bool SceneState::can_instance() const {
@@ -1095,7 +1095,15 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) {
if (p_dictionary.has("version"))
version = p_dictionary["version"];
- ERR_FAIL_COND_MSG(version > PACK_VERSION, "Save format version too new.");
+ ERR_FAIL_COND_MSG(version > PACKED_SCENE_VERSION, "Save format version too new.");
+
+ const int node_count = p_dictionary["node_count"];
+ const PoolVector<int> snodes = p_dictionary["nodes"];
+ ERR_FAIL_COND(snodes.size() != node_count);
+
+ const int conn_count = p_dictionary["conn_count"];
+ const PoolVector<int> sconns = p_dictionary["conns"];
+ ERR_FAIL_COND(sconns.size() != conn_count);
PoolVector<String> snames = p_dictionary["names"];
if (snames.size()) {
@@ -1121,13 +1129,11 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) {
variants.clear();
}
- nodes.resize(p_dictionary["node_count"]);
- int nc = nodes.size();
- if (nc) {
- PoolVector<int> snodes = p_dictionary["nodes"];
+ nodes.resize(node_count);
+ if (node_count) {
PoolVector<int>::Read r = snodes.read();
int idx = 0;
- for (int i = 0; i < nc; i++) {
+ for (int i = 0; i < node_count; i++) {
NodeData &nd = nodes.write[i];
nd.parent = r[idx++];
nd.owner = r[idx++];
@@ -1151,15 +1157,11 @@ void SceneState::set_bundled_scene(const Dictionary &p_dictionary) {
}
}
- connections.resize(p_dictionary["conn_count"]);
- int cc = connections.size();
-
- if (cc) {
-
- PoolVector<int> sconns = p_dictionary["conns"];
+ connections.resize(conn_count);
+ if (conn_count) {
PoolVector<int>::Read r = sconns.read();
int idx = 0;
- for (int i = 0; i < cc; i++) {
+ for (int i = 0; i < conn_count; i++) {
ConnectionData &cd = connections.write[i];
cd.from = r[idx++];
cd.to = r[idx++];
@@ -1283,9 +1285,7 @@ Dictionary SceneState::get_bundled_scene() const {
d["base_scene"] = base_scene_idx;
}
- d["version"] = PACK_VERSION;
-
- //d["path"]=path;
+ d["version"] = PACKED_SCENE_VERSION;
return d;
}