Revision: 1715
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1715&view=rev
Author:   rorthomas
Date:     2011-03-01 13:58:43 +0000 (Tue, 01 Mar 2011)

Log Message:
-----------
added more checks to videocamera section

Modified Paths:
--------------
    trunk/source/main/gfx/vidcam.cpp
    trunk/source/main/utils/utils.cpp
    trunk/source/main/utils/utils.h

Modified: trunk/source/main/gfx/vidcam.cpp
===================================================================
--- trunk/source/main/gfx/vidcam.cpp    2011-03-01 13:34:32 UTC (rev 1714)
+++ trunk/source/main/gfx/vidcam.cpp    2011-03-01 13:58:43 UTC (rev 1715)
@@ -21,6 +21,8 @@
 #include "ResourceBuffer.h"
 #include <Ogre.h>
 
+#include "utils.h"
+
 using namespace Ogre;
 
 int VideoCamera::counter = 0;
@@ -115,6 +117,24 @@
                return 0;
        }
 
+       if (nx < 0 || nx >= truck->free_node || ny < 0 || ny >= 
truck->free_node || nref < 0 || nref >= truck->free_node)
+       {
+               LogManager::getSingleton().logMessage("Error parsing File 
(videocamera) " + String(fname) +" line " + 
StringConverter::toString(linecounter) + ". Wrong node definition. trying to 
continue ...");
+               return 0;
+       }
+
+       if (texx <= 0 || !isPowerOfTwo(texx) || texy <= 0 || 
!isPowerOfTwo(texy))
+       {
+               LogManager::getSingleton().logMessage("Error parsing File 
(videocamera) " + String(fname) +" line " + 
StringConverter::toString(linecounter) + ". Wrong texture size definition 
(needs to be 2^n). trying to continue ...");
+               return 0;
+       }
+
+       if (minclip < 0 || minclip > maxclip || maxclip < 0)
+       {
+               LogManager::getSingleton().logMessage("Error parsing File 
(videocamera) " + String(fname) +" line " + 
StringConverter::toString(linecounter) + ". Wrong clipping definition. trying 
to continue ...");
+               return 0;
+       }
+
        // TODO check for correct and resonable values
 
        VideoCamera *v = new VideoCamera(mSceneMgr, camera, truck);

Modified: trunk/source/main/utils/utils.cpp
===================================================================
--- trunk/source/main/utils/utils.cpp   2011-03-01 13:34:32 UTC (rev 1714)
+++ trunk/source/main/utils/utils.cpp   2011-03-01 13:58:43 UTC (rev 1715)
@@ -175,3 +175,8 @@
        file.open(filename.c_str());
        return file.is_open();
 }
+
+int isPowerOfTwo (unsigned int x)
+{
+  return ((x != 0) && ((x & (~x + 1)) == x));
+}
\ No newline at end of file

Modified: trunk/source/main/utils/utils.h
===================================================================
--- trunk/source/main/utils/utils.h     2011-03-01 13:34:32 UTC (rev 1714)
+++ trunk/source/main/utils/utils.h     2011-03-01 13:58:43 UTC (rev 1715)
@@ -45,4 +45,6 @@
 
 bool fileExists(std::string filename);
 
+int isPowerOfTwo (unsigned int x);
+
 #endif //UTILS_H_
\ No newline at end of file


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel

Reply via email to