瀏覽代碼

fixes for Code/CryEngine

Signed-off-by: Esteban Papp <[email protected]>
pappeste 4 年之前
父節點
當前提交
f6cdcddc52

+ 2 - 1
Code/Framework/AzCore/Tests/Memory/HphaSchemaErrorDetection.cpp

@@ -17,6 +17,7 @@
 #include <AzCore/Debug/StackTracer.h>
 #include <AzCore/Debug/StackTracer.h>
 #include <AzCore/Debug/Trace.h>
 #include <AzCore/Debug/Trace.h>
 #include <AzCore/Math/Sfmt.h>
 #include <AzCore/Math/Sfmt.h>
+#include <AzCore/Casting/lossy_cast.h>
 
 
 
 
 namespace Internal
 namespace Internal
@@ -297,7 +298,7 @@ AZ_POP_DISABLE_WARNING
         // the overflow guard is generated out of rand, so we set a fixed seed before doing the allocation
         // the overflow guard is generated out of rand, so we set a fixed seed before doing the allocation
         // to get a deterministic guard
         // to get a deterministic guard
         srand(0);
         srand(0);
-        const unsigned char expectedInitialGuard = rand();
+        const unsigned char expectedInitialGuard = azlossy_cast<unsigned char>(rand());
 
 
         srand(0);
         srand(0);
         TestClass<16>* someObject = aznew TestClass<16>();
         TestClass<16>* someObject = aznew TestClass<16>();

+ 1 - 1
Code/Legacy/CryCommon/ISplines.h

@@ -466,7 +466,7 @@ namespace spline
         ILINE void flag_clr(int flag) { m_flags &= ~flag; };
         ILINE void flag_clr(int flag) { m_flags &= ~flag; };
         ILINE int  flag(int flag)  { return m_flags & flag; };
         ILINE int  flag(int flag)  { return m_flags & flag; };
 
 
-        ILINE void ORT(int ort) { m_ORT = ort; };
+        ILINE void ORT(int ort) { m_ORT = static_cast<uint8>(ort); };
         ILINE int  ORT() const { return m_ORT; };
         ILINE int  ORT() const { return m_ORT; };
         ILINE int  isORT(int o) const { return (m_ORT == o); };
         ILINE int  isORT(int o) const { return (m_ORT == o); };
 
 

+ 2 - 2
Code/Legacy/CryCommon/PNoise3.h

@@ -205,7 +205,7 @@ public:
 
 
         // Initialize the permutation table
         // Initialize the permutation table
         for(i = 0; i < NOISE_TABLE_SIZE; i++)
         for(i = 0; i < NOISE_TABLE_SIZE; i++)
-            m_p[i] = i;
+            m_p[i] = static_cast<unsigned char>(i);
 
 
         for(i = 0; i < NOISE_TABLE_SIZE; i++)
         for(i = 0; i < NOISE_TABLE_SIZE; i++)
         {        
         {        
@@ -213,7 +213,7 @@ public:
 
 
             nSwap = m_p[i];
             nSwap = m_p[i];
             m_p[i]  = m_p[j];
             m_p[i]  = m_p[j];
-            m_p[j]  = nSwap;
+            m_p[j]  = static_cast<unsigned char>(nSwap);
         }
         }
 
 
         // Generate the gradient lookup tables
         // Generate the gradient lookup tables

+ 1 - 1
Code/Legacy/CryCommon/Vertex.h

@@ -1037,7 +1037,7 @@ namespace AZ
                 }
                 }
                 AZ_Assert(stride < (0x1 << (sizeof(m_stride) * 8)), "Vertex stride is larger than the maximum supported, update the type for m_stride in Vertex.h");
                 AZ_Assert(stride < (0x1 << (sizeof(m_stride) * 8)), "Vertex stride is larger than the maximum supported, update the type for m_stride in Vertex.h");
 
 
-                m_stride = stride;
+                m_stride = static_cast<uint8>(stride);
             }
             }
             
             
 
 

+ 1 - 1
Code/Legacy/CrySystem/LocalizedStringManager.cpp

@@ -473,7 +473,7 @@ void CLocalizedStringsManager::ParseFirstLine(IXmlTableReader* pXmlTableReader,
             const char* pFind = strstr(sCellContent.c_str(), sLocalizedColumnNames[i]);
             const char* pFind = strstr(sCellContent.c_str(), sLocalizedColumnNames[i]);
             if (pFind != 0)
             if (pFind != 0)
             {
             {
-                nCellIndexToType[nCellIndex] = i;
+                nCellIndexToType[nCellIndex] = static_cast<char>(i);
 
 
                 // find SoundMood
                 // find SoundMood
                 if (i == ELOCALIZED_COLUMN_SOUNDMOOD)
                 if (i == ELOCALIZED_COLUMN_SOUNDMOOD)

+ 1 - 1
Code/Legacy/CrySystem/Log.cpp

@@ -1227,7 +1227,7 @@ void CLog::CreateBackupFile() const
 
 
         while (!fileSystem->Eof(inFileHandle))
         while (!fileSystem->Eof(inFileHandle))
         {
         {
-            uint8 c = AZ::IO::GetC(inFileHandle);
+            uint8 c = static_cast<uint8>(AZ::IO::GetC(inFileHandle));
 
 
             if (c == '\"')
             if (c == '\"')
             {
             {

+ 3 - 2
Code/Legacy/CrySystem/XConsole.cpp

@@ -2464,8 +2464,9 @@ void CXConsole::DisplayVarValue(ICVar* pVar)
             sValue += " (";
             sValue += " (";
             if (nonAlphaBits != 0)
             if (nonAlphaBits != 0)
             {
             {
-                char nonAlphaChars[3];  // 1..63 + '\0'
-                sValue += azitoa(nonAlphaBits, nonAlphaChars, AZ_ARRAY_SIZE(nonAlphaChars), 10);
+                char nonAlphaChars[3] = { 0 };  // 1..63 + '\0'
+                azitoa(nonAlphaBits, nonAlphaChars, AZ_ARRAY_SIZE(nonAlphaChars), 10);
+                sValue += nonAlphaChars;
                 sValue += ", ";
                 sValue += ", ";
             }
             }
             sValue += alphaChars;
             sValue += alphaChars;

+ 1 - 1
Code/Legacy/CrySystem/XML/SerializeXMLReader.cpp

@@ -44,7 +44,7 @@ bool CSerializeXMLReaderImpl::Value(const char* name, int8& value)
     }
     }
     else
     else
     {
     {
-        value = temp;
+        value = static_cast<int8>(temp);
     }
     }
     return bResult;
     return bResult;
 }
 }

+ 1 - 1
Code/Legacy/CrySystem/XML/XMLBinaryNode.cpp

@@ -320,7 +320,7 @@ bool CBinaryXmlNode::getAttr(const char* key, ColorB& value) const
             // If we only found 3 values, a should be unchanged, and still be 255
             // If we only found 3 values, a should be unchanged, and still be 255
             if (r < 256 && g < 256 && b < 256 && a < 256)
             if (r < 256 && g < 256 && b < 256 && a < 256)
             {
             {
-                value = ColorB(r, g, b, a);
+                value = ColorB(static_cast<uint8>(r), static_cast<uint8>(g), static_cast<uint8>(b), static_cast<uint8>(a));
                 return true;
                 return true;
             }
             }
         }
         }

+ 2 - 2
Code/Legacy/CrySystem/XML/XMLBinaryWriter.cpp

@@ -244,7 +244,7 @@ bool XMLBinary::CXMLBinaryWriter::CompileTablesForNode(XmlNodeRef node, int nPar
         nd.nContentStringOffset = nContentStringOffset;
         nd.nContentStringOffset = nContentStringOffset;
         nd.nParentIndex = nParentIndex;
         nd.nParentIndex = nParentIndex;
         nd.nFirstAttributeIndex = nFirstAttributeIndex;
         nd.nFirstAttributeIndex = nFirstAttributeIndex;
-        nd.nAttributeCount = nAttributeCount;
+        nd.nAttributeCount = static_cast<uint16>(nAttributeCount);
 
 
         m_nodes.push_back(nd);
         m_nodes.push_back(nd);
     }
     }
@@ -271,7 +271,7 @@ bool XMLBinary::CXMLBinaryWriter::CompileTablesForNode(XmlNodeRef node, int nPar
         }
         }
     }
     }
 
 
-    m_nodes[nIndex].nChildCount = nChildCount;
+    m_nodes[nIndex].nChildCount = static_cast<uint16>(nChildCount);
 
 
     return true;
     return true;
 }
 }

+ 1 - 1
Code/Legacy/CrySystem/XML/xml.cpp

@@ -641,7 +641,7 @@ bool CXmlNode::getAttr(const char* key, ColorB& value) const
             // If we only found 3 values, a should be unchanged, and still be 255
             // If we only found 3 values, a should be unchanged, and still be 255
             if (r < 256 && g < 256 && b < 256 && a < 256)
             if (r < 256 && g < 256 && b < 256 && a < 256)
             {
             {
-                value = ColorB(r, g, b, a);
+                value = ColorB(static_cast<uint8>(r), static_cast<uint8>(g), static_cast<uint8>(b), static_cast<uint8>(a));
                 return true;
                 return true;
             }
             }
         }
         }

+ 2 - 2
Code/Tools/SceneAPI/SceneBuilder/Importers/AssImpAnimationImporter.cpp

@@ -49,7 +49,7 @@ namespace AZ
                 double totalFramesAtDefaultTimeStep = totalTicks / AssImpAnimationImporter::s_defaultTimeStepBetweenFrames + 1;
                 double totalFramesAtDefaultTimeStep = totalTicks / AssImpAnimationImporter::s_defaultTimeStepBetweenFrames + 1;
                 if (!AZ::IsClose(totalFramesAtDefaultTimeStep, numKeys, 1))
                 if (!AZ::IsClose(totalFramesAtDefaultTimeStep, numKeys, 1))
                 {
                 {
-                    numKeys = AZStd::ceilf(totalFramesAtDefaultTimeStep);
+                    numKeys = AZStd::ceilf(static_cast<float>(totalFramesAtDefaultTimeStep));
                 }
                 }
                 return numKeys;
                 return numKeys;
             }
             }
@@ -620,7 +620,7 @@ namespace AZ
                     for (unsigned int valIdx = 0; valIdx < key.mNumValuesAndWeights; ++valIdx)
                     for (unsigned int valIdx = 0; valIdx < key.mNumValuesAndWeights; ++valIdx)
                     {
                     {
                         int currentValue = key.mValues[valIdx];
                         int currentValue = key.mValues[valIdx];
-                        KeyData thisKey(key.mWeights[valIdx], key.mTime);
+                        KeyData thisKey(static_cast<float>(key.mWeights[valIdx]), key.mTime);
                         valueToKeyDataMap[currentValue].insert(
                         valueToKeyDataMap[currentValue].insert(
                         AZStd::upper_bound(valueToKeyDataMap[currentValue].begin(), valueToKeyDataMap[currentValue].end(),thisKey),
                         AZStd::upper_bound(valueToKeyDataMap[currentValue].begin(), valueToKeyDataMap[currentValue].end(),thisKey),
                             thisKey);
                             thisKey);