Selaa lähdekoodia

Merge pull request #1264 from dgough/next

Changed Bundle, Font, Properties and SceneLoader to use GP_WARN instead of GP_ERROR
Sean Taylor 12 vuotta sitten
vanhempi
sitoutus
58fc993fcd

+ 6 - 6
gameplay/src/Bundle.cpp

@@ -189,7 +189,7 @@ Bundle* Bundle::create(const char* path)
     Stream* stream = FileSystem::open(path);
     if (!stream)
     {
-        GP_ERROR("Failed to open file '%s'.", path);
+        GP_WARN("Failed to open file '%s'.", path);
         return NULL;
     }
 
@@ -198,7 +198,7 @@ Bundle* Bundle::create(const char* path)
     if (stream->read(sig, 1, 9) != 9 || memcmp(sig, "\xABGPB\xBB\r\n\x1A\n", 9) != 0)
     {
         SAFE_DELETE(stream);
-        GP_ERROR("Invalid GPB header for bundle '%s'.", path);
+        GP_WARN("Invalid GPB header for bundle '%s'.", path);
         return NULL;
     }
 
@@ -207,14 +207,14 @@ Bundle* Bundle::create(const char* path)
     if (stream->read(version, 1, 2) != 2)
     {
         SAFE_DELETE(stream);
-        GP_ERROR("Failed to read GPB version for bundle '%s'.", path);
+        GP_WARN("Failed to read GPB version for bundle '%s'.", path);
         return NULL;
     }
     // Check for the minimal 
     if (version[0] != BUNDLE_VERSION_MAJOR_REQUIRED || version[1] < BUNDLE_VERSION_MINOR_REQUIRED)
     {
         SAFE_DELETE(stream);
-        GP_ERROR("Unsupported version (%d.%d) for bundle '%s' (expected %d.%d).", (int)version[0], (int)version[1], path, BUNDLE_VERSION_MAJOR_REQUIRED, BUNDLE_VERSION_MINOR_REQUIRED);
+        GP_WARN("Unsupported version (%d.%d) for bundle '%s' (expected %d.%d).", (int)version[0], (int)version[1], path, BUNDLE_VERSION_MAJOR_REQUIRED, BUNDLE_VERSION_MINOR_REQUIRED);
         return NULL;
     }
 
@@ -223,7 +223,7 @@ Bundle* Bundle::create(const char* path)
     if (stream->read(&refCount, 4, 1) != 1)
     {
         SAFE_DELETE(stream);
-        GP_ERROR("Failed to read ref table for bundle '%s'.", path);
+        GP_WARN("Failed to read ref table for bundle '%s'.", path);
         return NULL;
     }
 
@@ -236,7 +236,7 @@ Bundle* Bundle::create(const char* path)
             stream->read(&refs[i].offset, 4, 1) != 1)
         {
             SAFE_DELETE(stream);
-            GP_ERROR("Failed to read ref number %d for bundle '%s'.", i, path);
+            GP_WARN("Failed to read ref number %d for bundle '%s'.", i, path);
             SAFE_DELETE_ARRAY(refs);
             return NULL;
         }

+ 2 - 0
gameplay/src/Bundle.h

@@ -29,6 +29,8 @@ public:
      * release() method must be called. Note that calling release() does
      * NOT free any actual game objects created/returned from the Bundle
      * instance and those objects must be released separately.
+     * 
+     * @return The new Bundle or NULL if there was an error.
      * @script{create}
      */
     static Bundle* create(const char* path);

+ 4 - 4
gameplay/src/Font.cpp

@@ -55,7 +55,7 @@ Font* Font::create(const char* path, const char* id)
     Bundle* bundle = Bundle::create(path);
     if (bundle == NULL)
     {
-        GP_ERROR("Failed to load font bundle '%s'.", path);
+        GP_WARN("Failed to load font bundle '%s'.", path);
         return NULL;
     }
 
@@ -66,7 +66,7 @@ Font* Font::create(const char* path, const char* id)
         const char* id;
         if ((id = bundle->getObjectId(0)) == NULL)
         {
-            GP_ERROR("Failed to load font without explicit id; the first object in the font bundle has a null id.");
+            GP_WARN("Failed to load font without explicit id; the first object in the font bundle has a null id.");
             return NULL;
         }
 
@@ -105,7 +105,7 @@ Font* Font::create(const char* family, Style style, unsigned int size, Glyph* gl
         __fontEffect = Effect::createFromFile(FONT_VSH, FONT_FSH, defines);
         if (__fontEffect == NULL)
         {
-            GP_ERROR("Failed to create effect for font.");
+            GP_WARN("Failed to create effect for font.");
             SAFE_RELEASE(texture);
             return NULL;
         }
@@ -123,7 +123,7 @@ Font* Font::create(const char* family, Style style, unsigned int size, Glyph* gl
 
     if (batch == NULL)
     {
-        GP_ERROR("Failed to create batch for font.");
+        GP_WARN("Failed to create batch for font.");
         return NULL;
     }
 

+ 2 - 2
gameplay/src/Font.h

@@ -114,7 +114,7 @@ public:
      * @param path The path to a bundle file containing a font resource.
      * @param id An optional ID of the font resource within the bundle (NULL for the first/only resource).
      * 
-     * @return The specified font.
+     * @return The specified Font or NULL if there was an error.
      * @script{create}
      */
     static Font* create(const char* path, const char* id = NULL);
@@ -351,7 +351,7 @@ private:
      * @param texture A texture map containing rendered glyphs.
      * @param format The format of the font (bitmap or distance fields)
      * 
-     * @return The new Font.
+     * @return The new Font or NULL if there was an error.
      */
     static Font* create(const char* family, Style style, unsigned int size, Glyph* glyphs, int glyphCount, Texture* texture, Font::Format format);
 

+ 1 - 1
gameplay/src/Properties.cpp

@@ -84,7 +84,7 @@ Properties* Properties::create(const char* url)
     std::auto_ptr<Stream> stream(FileSystem::open(fileString.c_str()));
     if (stream.get() == NULL)
     {
-        GP_ERROR("Failed to open file '%s'.", fileString.c_str());
+        GP_WARN("Failed to open file '%s'.", fileString.c_str());
         return NULL;
     }
 

+ 5 - 5
gameplay/src/SceneLoader.cpp

@@ -65,7 +65,7 @@ Scene* SceneLoader::loadInternal(const char* url)
         _scene = loadMainSceneData(sceneProperties);
         if (!_scene)
         {
-            GP_ERROR("Failed to load main scene from bundle.");
+            GP_WARN("Failed to load main scene from bundle.");
             SAFE_DELETE(properties);
             return NULL;
         }
@@ -919,7 +919,7 @@ Scene* SceneLoader::loadMainSceneData(const Properties* sceneProperties)
     Bundle* bundle = Bundle::create(_gpbPath.c_str());
     if (!bundle)
     {
-        GP_ERROR("Failed to load scene GPB file '%s'.", _gpbPath.c_str());
+        GP_WARN("Failed to load scene GPB file '%s'.", _gpbPath.c_str());
         return NULL;
     }
 
@@ -927,7 +927,7 @@ Scene* SceneLoader::loadMainSceneData(const Properties* sceneProperties)
     Scene* scene = bundle->loadScene(NULL);
     if (!scene)
     {
-        GP_ERROR("Failed to load scene from '%s'.", _gpbPath.c_str());
+        GP_WARN("Failed to load scene from '%s'.", _gpbPath.c_str());
         SAFE_RELEASE(bundle);
         return NULL;
     }
@@ -1068,7 +1068,7 @@ void SceneLoader::loadReferencedFiles()
                 properties = Properties::create(fileString.c_str());
                 if (properties == NULL)
                 {
-                    GP_ERROR("Failed to load referenced properties file '%s'.", fileString.c_str());
+                    GP_WARN("Failed to load referenced properties file '%s'.", fileString.c_str());
                     continue;
                 }
 
@@ -1079,7 +1079,7 @@ void SceneLoader::loadReferencedFiles()
             Properties* p = getPropertiesFromNamespacePath(properties, namespacePath);
             if (!p)
             {
-                GP_ERROR("Failed to load referenced properties from url '%s'.", iter->first.c_str());
+                GP_WARN("Failed to load referenced properties from url '%s'.", iter->first.c_str());
                 continue;
             }
             iter->second = p;