X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FCompiler.cpp;h=b583aabb298a46017fb87d23d1772e1e79fed12e;hb=7b3710c47f24e64e0d01378a4564730bcb2f6ef2;hp=95d41ccadceb3ab6a5dc3b558cb1ceaa2716463c;hpb=5f9a1893c0db8f53889a390e4c4b95d57abd4384;p=l2e.git diff --git a/src/loader/Compiler.cpp b/src/loader/Compiler.cpp index 95d41cc..b583aab 100644 --- a/src/loader/Compiler.cpp +++ b/src/loader/Compiler.cpp @@ -141,6 +141,7 @@ void Compiler::WriteArrays(ostream &out) { i(intp.Arrays().begin()), end(intp.Arrays().end()); i != end; ++i) { Array array; + array.typeId = i->typeId; array.size = i->size; array.ref = i->ref; Write(out, &array, sizeof(Array)); @@ -210,19 +211,23 @@ void Compiler::Relocate(iostream &out) { Array array; for (; out && out.tellg() < fileHeader.arraysEnd;) { out.read(reinterpret_cast(&array), sizeof(Array)); - if (!array.ref) { - out.seekg(array.size); - continue; + if (array.ref) { + buffer = new char[array.size]; + unsigned int pos = out.tellg(); + out.seekg(pos); + out.read(buffer, array.size); + RelocateArray(buffer, array.size); + out.seekp(pos); + out.write(buffer, array.size); + out.seekg(out.tellp()); + delete[] buffer; + } else { + const TypeDescription &td = TypeDescription::Get(array.typeId); + for (char *i = array.Data(), *end = array.Data() + array.size; + i < end; i += td.Size()) { + Relocate(i, td); + } } - buffer = new char[array.size]; - unsigned int pos = out.tellg(); - out.seekg(pos); - out.read(buffer, array.size); - RelocateArray(buffer, array.size); - out.seekp(pos); - out.write(buffer, array.size); - out.seekg(out.tellp()); - delete[] buffer; } }