]> git.localhorst.tv Git - l2e.git/blobdiff - src/loader/Loader.cpp
activated the loader
[l2e.git] / src / loader / Loader.cpp
index 2403044ad20fb819a23fafc0b43c2ded125a317c..9c8739aabee00191584852973971f203fc8afa5e 100644 (file)
@@ -4,7 +4,9 @@
 #include <cstring>
 #include <fstream>
 #include <stdexcept>
+#include <utility>
 
+using std::make_pair;
 using std::map;
 using std::string;
 using std::vector;
@@ -52,6 +54,9 @@ void Loader::Load(const std::string &filePath) {
                LoadObjects(header->ident,
                                header->ObjectsBegin(),
                                header->ObjectsEnd());
+               LoadArrays(header->ident,
+                               header->ArraysBegin(),
+                               header->ArraysEnd());
        } catch (...) {
                delete[] block;
                throw;
@@ -65,6 +70,7 @@ void Loader::LoadExports(char *src, Export *begin, Export *end) {
                LoadedExport &exp(exports[identifier]);
                exp.typeId = i->typeId;
                exp.location = src + i->dataOffset;
+               exports.insert(make_pair(identifier, exp));
        }
 }
 
@@ -112,4 +118,17 @@ void Loader::LoadObject(char *src, char *object, const TypeDescription &td) {
        }
 }
 
+void Loader::LoadArrays(char *src, Array *begin, Array *end) {
+       for (Array *i = begin; i < end; i = i->Next()) {
+               if (!i->ref) {
+                       continue;
+               }
+               for (char *j = i->Data(), *end = i->Data() + i->size;
+                               j < end; j += sizeof(void *)) {
+                       *reinterpret_cast<char **>(j) =
+                                       src + *reinterpret_cast<unsigned int *>(j);
+               }
+       }
+}
+
 }