ソースを参照

Merge branch 'master' of github.com:q-gears/q-gears

myst6re 11 年 前
コミット
683e2ce2ac

+ 1 - 1
.travis.yml

@@ -80,7 +80,7 @@ script:
 language: cpp
 after_success: 
 - if [[ "$CXX" == "g++" && "${COVERAGE}" == 1 && "$TRAVIS_OS_NAME" == "linux" ]]; then lcov --directory . --capture --output-file coverage.info; fi
-- if [[ "$CXX" == "g++" && "${COVERAGE}" == 1 && "$TRAVIS_OS_NAME" == "linux" ]]; then lcov --remove coverage.info '*/googlemock/*' '/usr/*' --output-file coverage.info; fi
+- if [[ "$CXX" == "g++" && "${COVERAGE}" == 1 && "$TRAVIS_OS_NAME" == "linux" ]]; then lcov --remove coverage.info '*/dependencies/*' '/usr/*' --output-file coverage.info; fi
 - if [[ "$CXX" == "g++" && "${COVERAGE}" == 1 && "$TRAVIS_OS_NAME" == "linux" ]]; then lcov --list coverage.info; fi
 - if [[ "$CXX" == "g++" && "${COVERAGE}" == 1 && "$TRAVIS_OS_NAME" == "linux" ]]; then coveralls-lcov coverage.info; fi
 - hash=`git rev-parse HEAD`

+ 1 - 1
QGearsMain/src/common/FileSystem.cpp

@@ -39,7 +39,7 @@ FileSystem::ReadFile(const Ogre::String &path, void* buffer, const unsigned int
     fseek(file, start, SEEK_SET);
     const auto ret = fread(buffer, sizeof(char), length, file);
     fclose(file);
-    if (ret != sizeof(char))
+    if (ret != sizeof(char) * length)
     {
         LOG_ERROR("Failed to read all data\n");
         return false;

+ 3 - 2
QGearsMain/src/data/QGearsBackgroundFile.cpp

@@ -206,8 +206,9 @@ namespace QGears
                 }
                 const PaletteFile::Page& palette_page(palette->getPage(it->palette_page));
                 bool firstColorHidden(false);
-                if (it->palette_page < PALETTE_ENTRY_COUNT) {
-                    firstColorHidden = bool(m_palette[it->palette_page]);
+                if (it->palette_page < PALETTE_ENTRY_COUNT) 
+                {
+                    firstColorHidden = m_palette[it->palette_page] > 0;
                 }
                 for (uint16 y(SPRITE_HEIGHT); y--;)
                 {

+ 2 - 2
utilities/common/FontFile.cpp

@@ -88,7 +88,7 @@ FontFile::GetSurface(void)
                 color.g = (((data >> i) & 0x01) == 1) ? 0 : 255;
                 color.b = (((data >> i) & 0x01) == 1) ? 0 : 255;
                 color.a = (((data >> i) & 0x01) == 1) ? 255 : 255;
-                memcpy(glyth->pixels + 64 * y + j, &color, sizeof(ClutColor));
+                memcpy(glyth->pixels.data() + 64 * y + j, &color, sizeof(ClutColor));
                 j += 4;
             }
 
@@ -100,7 +100,7 @@ FontFile::GetSurface(void)
                 color.g = ((data >> i) & 0x01 == 1) ? 0 : 255;
                 color.b = ((data >> i) & 0x01 == 1) ? 0 : 255;
                 color.a = ((data >> i) & 0x01 == 1) ? 255 : 255;
-                memcpy(glyth->pixels + 64 * y + j, &color, sizeof(ClutColor));
+                memcpy(glyth->pixels.data() + 64 * y + j, &color, sizeof(ClutColor));
                 j += 4;
             }
         }

+ 7 - 42
utilities/common/Surface.cpp

@@ -23,8 +23,7 @@ Surface::Surface( const Surface &copy ):
 {
     if( width && height )
     {
-        pixels = new unsigned char[ width * height * 4 ];
-        memcpy( pixels, copy.pixels, width * height * 4 );
+        pixels = copy.pixels;
     }
 }
 
@@ -33,18 +32,12 @@ Surface::Surface( const Surface &copy ):
 Surface&
 Surface::operator =( const Surface &copy )
 {
-    if( width && height )
-    {
-        delete[] pixels;
-    }
-
     if( copy.width && copy.height )
     {
         width  = copy.width;
         height = copy.height;
 
-        pixels = new unsigned char[ width * height * 4 ];
-        memcpy( pixels, copy.pixels, width * height * 4 );
+        pixels = copy.pixels;
     }
 
     return *this;
@@ -54,10 +47,7 @@ Surface::operator =( const Surface &copy )
 
 Surface::~Surface()
 {
-    if( width && height )
-    {
-        delete[] pixels;
-    }
+
 }
 
 
@@ -69,7 +59,7 @@ CreateSurface( const int width, const int height )
 
     image->width   = width;
     image->height  = height;
-    image->pixels  = new unsigned char[ width * height * 4 ];
+    image->pixels.resize( width * height * 4 );
 
     return image;
 }
@@ -86,7 +76,7 @@ CopyToSurface( Surface* dest, const int x_d, const int y_d, Surface* src )
 
     for( int y_from = y_d, y_to = y_d + src->height; y_from < y_to; ++y_from )
     {
-        memcpy( dest->pixels + y_from * dest->width * 4 + x_d * 4, src->pixels + ( y_from - y_d ) * src->width * 4, src->width * 4 );
+        memcpy( dest->pixels.data() + y_from * dest->width * 4 + x_d * 4, src->pixels.data() + ( y_from - y_d ) * src->width * 4, src->width * 4 );
     }
 }
 
@@ -101,7 +91,7 @@ CreateSubSurface( const int x, const int y, const int width, const int height, S
     {
         for( int y_from = y, y_to = y + image->height; y_from < y_to; ++y_from )
         {
-            memcpy( image->pixels + ( y_from - y ) * image->width * 4, surface->pixels + ( y_from * surface->width + x ) * 4, image->width * 4) ;
+            memcpy( image->pixels.data() + ( y_from - y ) * image->width * 4, surface->pixels.data() + ( y_from * surface->width + x ) * 4, image->width * 4) ;
         }
     }
 
@@ -114,34 +104,9 @@ Surface*
 CreateSurfaceFrom( const int width, const int height, unsigned char* pixels )
 {
     Surface* image = CreateSurface( width, height );
-
     if( pixels != NULL )
     {
-        memcpy( image->pixels, pixels, width * height * 4 );
+        memcpy( image->pixels.data(), pixels, width * height * 4 );
     }
-
     return image;
 }
-
-
-
-void
-SetSurfaceSize( Surface* &surface, const int &width, const int &height )
-{
-    unsigned char* pixels = new unsigned char[ width * height * 4 ];
-    memset( pixels, 0x00, width * height * 4 );
-
-    for( int y = 0; y < height; y++ )
-    {
-        if( y < surface->height )
-        {
-            int size_to_copy = ( surface->width < width ) ? surface->width * 4 : width * 4;
-            memcpy( pixels + y * width * 4, surface->pixels + y * surface->width * 4, size_to_copy );
-        }
-    }
-
-    delete surface;
-    surface = CreateSurfaceFrom( width, height, pixels );
-
-    delete[] pixels;
-}

+ 1 - 4
utilities/common/Surface.h

@@ -13,7 +13,7 @@ struct Surface
     ~Surface();
 
 
-    unsigned char *pixels;
+    std::vector<unsigned char> pixels;
     int            width;
     int            height;
 };
@@ -25,8 +25,5 @@ void     CopyToSurface( Surface* dest, const int x_d, const int y_d, Surface* sr
 Surface* CreateSubSurface( const int x, const int y, const int width, const int height, Surface* surface );
 Surface* CreateSurfaceFrom( const int width, const int height, unsigned char* pixels );
 
-void     SetSurfaceSize( Surface* &surface, const int &width, const int &height );
-
-
 
 #endif

+ 2 - 0
utilities/ffvii_field_dat_dumper/src/DatFile.cpp

@@ -2840,6 +2840,8 @@ DatFile::DumpBackground( const Ogre::String& export_path, const Field& field, Mi
     export_text->Log( " clip=\"" + IntToString( 320 * 3 ) + " " + IntToString( 240 * 3 ) + "\"" );
     export_text->Log( ">\n" );
 
+    assert(width != 0);
+    assert(height != 0);
     full_image = CreateSurface( width, height );
     x_32 = 0; y_32 = 0; x_16 = 0; y_16 = 0; n_16 = 0;
 

+ 9 - 1
utilities/ffvii_field_dat_dumper/src/Main.cpp

@@ -168,9 +168,17 @@ main( int argc, char *argv[] )
 
     fill_names();
 
+    /*
+    // can use this for debugging if not using export.cfg
     Field f = {};
-    f.name = "C:\\Users\\paul\\Downloads\\data\\data\\en\\nmkin_1";
+    f.tex_width = 1024;
+    f.tex_height = 512;
+    // Note: Must create path CWD\export_en\maps\ffvii_field
+    f.name = "md1_2"; // DO NOT put a full path here, else it will attempt to save with full output path and fail
     fields.push_back(f);
+    */
+
+
 /*
     for (int f = 0; f < fields.size(); ++f)
     {

+ 3 - 3
utilities/ffvii_field_dat_dumper/src/MimFile.cpp

@@ -96,7 +96,7 @@ MimFile::GetSurface( const u16 page_x, const u16 page_y, const u16 clut_x, const
                     color.a = 255;
                 }
 
-                memcpy( ret->pixels + x * 8 + ret->width * 4 * y + 0x00, &color, sizeof( ClutColor ) );
+                memcpy( ret->pixels.data() + x * 8 + ret->width * 4 * y + 0x00, &color, sizeof( ClutColor ) );
 
 
 
@@ -129,7 +129,7 @@ MimFile::GetSurface( const u16 page_x, const u16 page_y, const u16 clut_x, const
                     color.a = 255;
                 }
 
-                memcpy( ret->pixels + x * 8 + ret->width * 4 * y + 0x04, &color, sizeof( ClutColor ) );
+                memcpy( ret->pixels.data() + x * 8 + ret->width * 4 * y + 0x04, &color, sizeof( ClutColor ) );
             }
         }
     }
@@ -175,7 +175,7 @@ MimFile::GetSurface( const u16 page_x, const u16 page_y, const u16 clut_x, const
                     color.a = 255;
                 }
 
-                memcpy( ret->pixels + x * 4 + ret->width * 4 * y, &color, sizeof( ClutColor ) );
+                memcpy( ret->pixels.data() + x * 4 + ret->width * 4 * y, &color, sizeof( ClutColor ) );
             }
         }
     }

+ 4 - 3
utilities/q-gears-launcher/src/ff7DataInstaller.cpp

@@ -163,17 +163,18 @@ static void FF7PcFieldToQGearsField(QGears::FLevelFilePtr& field, const std::str
         // Decompile to LUA
         FF7FieldScriptFormatter formatter;
         std::string luaScript = SUDM::FF7::Field::Decompile(field->getName(), rawFieldData, formatter);
+        std::cout << luaScript << std::endl;
     }
     catch (const ::InternalDecompilerError& ex)
     {
         std::cerr << "InternalDecompilerError: " << ex.what() << std::endl;
     }
 
-    /*
+    
     const QGears::PaletteFilePtr& pal = field->getPalette();
     std::unique_ptr<Ogre::Image> bgImage(bg->createImage(pal));
     bgImage->save(outDir + "/" + field->getName() + ".png");
-    */
+
     {
         TiXmlDocument doc;
         std::unique_ptr<TiXmlElement> element(new TiXmlElement("background2d"));
@@ -241,7 +242,7 @@ void FF7DataInstaller::ConvertFields(std::string archive, std::string outDir)
         if (!QGears::StringUtil::endsWith(resourceName, ".tex")
          && !QGears::StringUtil::endsWith(resourceName, ".tut")
          && !QGears::StringUtil::endsWith(resourceName, ".siz")
-         && resourceName != "maplist" && resourceName == "md1_1")
+         && resourceName != "maplist" && resourceName == "md1_2")
         {
             //try
             {