Parcourir la Source

Added version check (does nothing) and test string

Eiyeron Fulmincendii il y a 10 ans
Parent
commit
42543973e6
5 fichiers modifiés avec 11 ajouts et 10 suppressions
  1. BIN
      data/out.wrf
  2. 1 1
      info/archive_structure.md
  3. 1 1
      src/engine/main.cpp
  4. 8 8
      src/piaf/Archive.cpp
  5. 1 0
      src/piaf/Archive.h

BIN
data/out.wrf


+ 1 - 1
info/archive_structure.md

@@ -4,7 +4,7 @@
 WRPG_PIAF_MAGIC_HEADER       : "WRPGPIAF"          <=> 8 bytes (not \0 terminated)
 WRPG_PIAF_HEADER_CHECKSUM    :  unsigned int       <=> 4 bytes (This checksum covers the version, number of files and the data size).
 WRPG_PIAF_FILETABLE_CHECKSUM :  unsigned int       <=> 4 bytes (This checksum covers the whole filetable data part).
-WRPG_PIAF_VERSION            :  unsigned int       <=> 4 bytes (Stored in this form : 0xAABBCCDDD, where A = major version, B = minor version, C = hotfix)
+WRPG_PIAF_VERSION            :  unsigned int       <=> 4 bytes (Stored in this form : 0xAABBCCDD, where A = major version, B = minor version, C = hotfix)
 WRPG_PIAF_NB_FILES           :  unsigned int       <=> 4 bytes
 WRPG_PIAF_DATA_SIZE          :  unsigned int       <=> 4 bytes
 <padding>                    :  <filler>           <=> 4 bytes

+ 1 - 1
src/engine/main.cpp

@@ -22,7 +22,7 @@ int main(int argc, char *argv[])
     // Archive arc(Quirks::solve_absolute_path("samples/one_file.wrf"));
     Archive arc(Quirks::solve_absolute_path("data/out.wrf").get());
     Texture tex(arc.get("ov.png"));
-
+    printf("%s\n", arc.get("test.txt").get());
     uint16_t dungeonTest[] = {
         21, 21,  1,   1,   1,   1,   21,  22,  21,  22, 21,  22,  21,  21,  1,   22,  21,
         1,  22,  22,  22,  1,   21,  2,   3,   3,   3,  3,   3,   4,   21,  1,   22,  21,

+ 8 - 8
src/piaf/Archive.cpp

@@ -6,6 +6,7 @@
 #include "Quirks.h"
 
 using tinystl::string;
+using WalrusRPG::PIAF::ARCHIVE_VERSION;
 using WalrusRPG::PIAF::Archive;
 using WalrusRPG::PIAF::File;
 using WalrusRPG::PIAF::FileType;
@@ -133,13 +134,13 @@ Archive::Archive(const char *filepath) : file(nullptr), entries(nullptr), files_
 
     // TODO : version checking
     version = read_big_endian_value<uint32_t>(&header_container[16]);
-    /* if (version != CURRENT_PIAF_VERSION)
-     * {
-     *      exception up;
-     *      throw up; // haha
-     * }
-     */
-
+    if (version != ARCHIVE_VERSION)
+    {
+         // std::exception up;
+         // throw up; // haha
+    }
+    
+    
     // At this point, the archive header looks unaltered and we finally can parse
     // and load the header.
 
@@ -199,7 +200,6 @@ Archive::~Archive()
     if (entries != nullptr)
         delete[] entries;
 
-    printf("Delete\n");
     if(files_data != nullptr)
     {
         for(unsigned i = 0; i < nb_files; i++)

+ 1 - 0
src/piaf/Archive.h

@@ -9,6 +9,7 @@ namespace WalrusRPG
 {
     namespace PIAF
     {
+        constexpr uint32_t ARCHIVE_VERSION = 0x01000000;
         enum FileType : uint32_t
         {
             UNKNOWN,