summaryrefslogtreecommitdiff
path: root/src/scene.cpp
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-04-07 16:25:11 -0400
committerJonathan Bradley <jcb@pikum.xyz>2025-04-07 16:25:11 -0400
commit8c0dbef6b21a0331916ae96ea5cd3b5613e50b6b (patch)
treebfbc487de4bc212c00f57e1ba38e08cccac6978d /src/scene.cpp
parent7b43a9b51d9df0bc0e18102415f877772031f440 (diff)
pke: temp load scene by file path
Diffstat (limited to 'src/scene.cpp')
-rw-r--r--src/scene.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/scene.cpp b/src/scene.cpp
index f4df916..58e9c44 100644
--- a/src/scene.cpp
+++ b/src/scene.cpp
@@ -2,7 +2,10 @@
#include "scene.hpp"
#include "bucketed-array.hpp"
#include "ecs.hpp"
+#include "serialization.hpp"
+#include "game-settings.hpp"
+#include <fstream>
#include <string.h>
#include <filesystem>
@@ -49,6 +52,21 @@ struct pke_scene *pke_scene_get_by_handle(SceneHandle scene_handle) {
return &scene_mstr.bc.buckets[scene_handle.bucketIndex][scene_handle.itemIndex];
}
+ // TODO remove me? Need to decide if we always read from files or if we should have a serialized representation of a scene
+struct pke_scene *pke_scene_get_by_path(const char *file_path) {
+ std::ifstream f(file_path);
+ if (!f.is_open()) {
+ fprintf(stderr, "[pke_scene_get_by_name] Scene not found in memory nor filesystem: '%s'\n", file_path);
+ return nullptr;
+ }
+ srlztn_deserialize_helper *h = pke_deserialize_init(pkeSettings.mem.bkt);
+ h->i = &f;
+ h->scene = pke_scene_create(file_path);
+ pke_deserialize_file_scene(h);
+ pke_deserialize_teardown(h);
+ return h->scene;
+}
+
struct pke_scene *pke_scene_get_by_name(const char *scene_name) {
assert(scene_name != nullptr);
NULL_CHAR_ARR(safe_name, SCENE_NAME_MAX_LEN + 1);