From 3befb9070b02b52f90b34de6bc36c4f200e05ea4 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 16 Mar 2022 00:30:52 -0400 Subject: [PATCH] Export some simple data from EXD --- include/exdparser.h | 16 +++++++++++++++- src/exdparser.cpp | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/include/exdparser.h b/include/exdparser.h index 16cb415..deed40a 100644 --- a/include/exdparser.h +++ b/include/exdparser.h @@ -1,8 +1,22 @@ #pragma once #include +#include +#include struct EXH; struct ExcelDataPagination; -void readEXD(EXH& exh, ExcelDataPagination& page); \ No newline at end of file +struct Column { + std::string data; +}; + +struct Row { + std::vector data; +}; + +struct EXD { + std::vector rows; +}; + +EXD readEXD(EXH& exh, ExcelDataPagination& page); \ No newline at end of file diff --git a/src/exdparser.cpp b/src/exdparser.cpp index 7f41e1b..d46f281 100644 --- a/src/exdparser.cpp +++ b/src/exdparser.cpp @@ -26,7 +26,9 @@ struct ExcelDataRowHeader { uint16_t rowCount; }; -void readEXD(EXH& exh, ExcelDataPagination& page) { +EXD readEXD(EXH& exh, ExcelDataPagination& page) { + EXD exd; + auto path = fmt::format("{}_{}.exd", "map", page.startId); FILE* file = fopen(path.data(), "rb"); @@ -50,6 +52,8 @@ void readEXD(EXH& exh, ExcelDataPagination& page) { } for(auto& offset : dataOffsets) { + Row row; + fseek(file, exh.header.dataOffset + offset.offset, SEEK_SET); ExcelDataRowHeader rowHeader; @@ -61,6 +65,8 @@ void readEXD(EXH& exh, ExcelDataPagination& page) { const int rowOffset = offset.offset + 6; for(auto column : exh.columnDefinitions) { + Column c; + switch(column.type) { case String: { @@ -79,11 +85,19 @@ void readEXD(EXH& exh, ExcelDataPagination& page) { } fmt::print("{}\n", string.data()); + + c.data = string; } break; default: break; } + + row.data.push_back(c); } + + exd.rows.push_back(row); } + + return exd; } \ No newline at end of file