Improved code based on CppCheck results
None of this should change the engine's behavior, but the code is better this way. Former-commit-id: 0127769848fc1f7fc8006ee607985cfc0ead2965
This commit is contained in:
parent
0f27930467
commit
fc65b30f84
|
|
@ -19,8 +19,6 @@ namespace Ndk
|
|||
for (const Ndk::EntityHandle& camera : m_cameras)
|
||||
{
|
||||
CameraComponent& camComponent = camera->GetComponent<CameraComponent>();
|
||||
NodeComponent& cameraNode = camera->GetComponent<NodeComponent>();
|
||||
|
||||
camComponent.ApplyView();
|
||||
|
||||
NzScene dummyScene;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ struct NzMusicImpl
|
|||
std::vector<nzInt16> chunkSamples;
|
||||
NzThread thread;
|
||||
bool loop = false;
|
||||
bool paused = false;
|
||||
bool streaming = false;
|
||||
unsigned int sampleRate;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -551,7 +551,6 @@ NzString NzFile::AbsolutePath(const NzString& filePath)
|
|||
return path;
|
||||
|
||||
// Nous avons un chemin absolu, mais il nous faut un peu le nettoyer
|
||||
unsigned int pathLen = base.GetSize();
|
||||
for (unsigned int i = 0; i < sep.size(); ++i)
|
||||
{
|
||||
if (sep[i] == '.')
|
||||
|
|
@ -563,12 +562,8 @@ NzString NzFile::AbsolutePath(const NzString& filePath)
|
|||
|
||||
sep.erase(sep.begin() + i--);
|
||||
}
|
||||
else
|
||||
pathLen += sep[i].GetSize();
|
||||
}
|
||||
|
||||
pathLen += sep.size()-1;
|
||||
|
||||
NzStringStream stream(base);
|
||||
for (unsigned int i = 0; i < sep.size(); ++i)
|
||||
{
|
||||
|
|
@ -730,10 +725,9 @@ bool NzFile::FillHash(NzAbstractHash* hash) const
|
|||
nzUInt64 remainingSize = file.GetSize();
|
||||
|
||||
char buffer[NAZARA_CORE_FILE_BUFFERSIZE];
|
||||
unsigned int size;
|
||||
while (remainingSize > 0)
|
||||
{
|
||||
size = static_cast<unsigned int>(std::min(remainingSize, static_cast<nzUInt64>(NAZARA_CORE_FILE_BUFFERSIZE)));
|
||||
unsigned int size = static_cast<unsigned int>(std::min(remainingSize, static_cast<nzUInt64>(NAZARA_CORE_FILE_BUFFERSIZE)));
|
||||
if (file.Read(&buffer[0], sizeof(char), size) != sizeof(char)*size)
|
||||
{
|
||||
NazaraError("Unable to read file");
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ NzHashCRC32::NzHashCRC32(nzUInt32 polynomial)
|
|||
{
|
||||
table[i] = crc32_reflect(i, 8) << 24;
|
||||
for (unsigned int j = 0; j < 8; ++j)
|
||||
table[i] = (table[i] << 1) ^ (table[i] & (1 << 31) ? polynomial : 0);
|
||||
table[i] = (table[i] << 1) ^ (table[i] & ((1 << 31) ? polynomial : 0));
|
||||
|
||||
table[i] = crc32_reflect(table[i], 32);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -436,16 +436,15 @@ namespace
|
|||
|
||||
void SHA1_Update(SHA_CTX* context, const nzUInt8* data, std::size_t len)
|
||||
{
|
||||
unsigned int freespace, usedspace;
|
||||
if (len == 0)
|
||||
/* Calling with no data is valid - we do nothing */
|
||||
return;
|
||||
|
||||
usedspace = (context->s1.bitcount >> 3) % 64;
|
||||
unsigned int usedspace = (context->s1.bitcount >> 3) % 64;
|
||||
if (usedspace > 0)
|
||||
{
|
||||
/* Calculate how much free space is available in the buffer */
|
||||
freespace = 64 - usedspace;
|
||||
unsigned int freespace = 64 - usedspace;
|
||||
|
||||
if (len >= freespace)
|
||||
{
|
||||
|
|
@ -647,17 +646,15 @@ void SHA256_Internal_Transform(SHA_CTX* context, const nzUInt32* data)
|
|||
|
||||
void SHA256_Update(SHA_CTX* context, const nzUInt8 *data, std::size_t len)
|
||||
{
|
||||
unsigned int freespace, usedspace;
|
||||
|
||||
if (len == 0)
|
||||
/* Calling with no data is valid - we do nothing */
|
||||
return;
|
||||
|
||||
usedspace = (context->s256.bitcount >> 3) % 64;
|
||||
unsigned int usedspace = (context->s256.bitcount >> 3) % 64;
|
||||
if (usedspace > 0)
|
||||
{
|
||||
/* Calculate how much free space is available in the buffer */
|
||||
freespace = 64 - usedspace;
|
||||
unsigned int freespace = 64 - usedspace;
|
||||
|
||||
if (len >= freespace)
|
||||
{
|
||||
|
|
@ -905,17 +902,15 @@ void SHA512_Internal_Transform(SHA_CTX* context, const nzUInt64* data)
|
|||
|
||||
void SHA512_Update(SHA_CTX* context, const nzUInt8 *data, std::size_t len)
|
||||
{
|
||||
unsigned int freespace, usedspace;
|
||||
|
||||
if (len == 0)
|
||||
/* Calling with no data is valid - we do nothing */
|
||||
return;
|
||||
|
||||
usedspace = (context->s512.bitcount[0] >> 3) % 128;
|
||||
unsigned int usedspace = (context->s512.bitcount[0] >> 3) % 128;
|
||||
if (usedspace > 0)
|
||||
{
|
||||
/* Calculate how much free space is available in the buffer */
|
||||
freespace = 128 - usedspace;
|
||||
unsigned int freespace = 128 - usedspace;
|
||||
|
||||
if (len >= freespace)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -89,7 +89,6 @@ namespace
|
|||
pair.second.second.updated = false;
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -781,7 +781,7 @@ bool NzOpenGL::Initialize()
|
|||
major = version[0] - '0';
|
||||
minor = version[2] - '0';
|
||||
|
||||
if (major <= 0 || major > 9)
|
||||
if (major == 0 || major > 9)
|
||||
{
|
||||
NazaraError("Unable to retrieve OpenGL major version");
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1797,10 +1797,6 @@ bool NzRenderer::EnsureStateUpdate()
|
|||
|
||||
if (update)
|
||||
{
|
||||
const NzVertexDeclaration* vertexDeclaration;
|
||||
unsigned int bufferOffset;
|
||||
unsigned int stride;
|
||||
|
||||
// Pour éviter la duplication de code, on va utiliser une astuce via une boucle for
|
||||
for (unsigned int i = 0; i < (s_instancing ? 2 : 1); ++i)
|
||||
{
|
||||
|
|
@ -1810,9 +1806,9 @@ bool NzRenderer::EnsureStateUpdate()
|
|||
NzHardwareBuffer* vertexBufferImpl = static_cast<NzHardwareBuffer*>(vertexBuffer->GetBuffer()->GetImpl());
|
||||
glBindBuffer(NzOpenGL::BufferTarget[nzBufferType_Vertex], vertexBufferImpl->GetOpenGLID());
|
||||
|
||||
bufferOffset = vertexBuffer->GetStartOffset();
|
||||
vertexDeclaration = vertexBuffer->GetVertexDeclaration();
|
||||
stride = vertexDeclaration->GetStride();
|
||||
unsigned int bufferOffset = vertexBuffer->GetStartOffset();
|
||||
const NzVertexDeclaration* vertexDeclaration = vertexBuffer->GetVertexDeclaration();
|
||||
unsigned int stride = vertexDeclaration->GetStride();
|
||||
|
||||
// On définit les bornes (une fois de plus selon l'itération)
|
||||
unsigned int start = (i == 0) ? nzVertexComponent_FirstVertexData : nzVertexComponent_FirstInstanceData;
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ NzString NzShader::GetSourceCode(nzShaderStage stage) const
|
|||
totalLength += length - 1;
|
||||
}
|
||||
|
||||
totalLength += (m_attachedShaders[stage].size()-1)*(sizeof(sep)/sizeof(char));
|
||||
totalLength += (m_attachedShaders[stage].size()-1) * (sizeof(sep)/sizeof(char));
|
||||
|
||||
NzString source(totalLength, '\0');
|
||||
|
||||
|
|
@ -258,7 +258,7 @@ NzString NzShader::GetSourceCode(nzShaderStage stage) const
|
|||
{
|
||||
if (offset > 0)
|
||||
{
|
||||
std::memcpy(&source[offset], sep, sizeof(sep)/sizeof(char));
|
||||
std::memcpy(&source[offset], sep, sizeof(sep));
|
||||
offset += sizeof(sep)/sizeof(char);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -963,12 +963,9 @@ bool NzTexture::Update(const nzUInt8* pixels, const NzBoxui& box, unsigned int s
|
|||
NazaraError("Invalid box");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned int height = GetLevelSize(m_impl->height, level);
|
||||
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
|
||||
unsigned int width = GetLevelSize(m_impl->width, level);
|
||||
unsigned int height = GetLevelSize(m_impl->height, level);
|
||||
unsigned int depth = (m_impl->type == nzImageType_Cubemap) ? 6 : GetLevelSize(m_impl->depth, level);
|
||||
if (box.x+box.width > width || box.y+box.height > height || box.z+box.depth > depth ||
|
||||
(m_impl->type == nzImageType_Cubemap && box.depth > 1)) // Nous n'autorisons pas de modifier plus d'une face du cubemap à la fois
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace
|
|||
class IcoSphereBuilder
|
||||
{
|
||||
public:
|
||||
IcoSphereBuilder(const NzMatrix4f& matrix) :
|
||||
explicit IcoSphereBuilder(const NzMatrix4f& matrix) :
|
||||
m_matrix(matrix)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,7 +144,6 @@ namespace
|
|||
// "If you want to embolden the bitmap owned by a FT_GlyphSlot_Rec, you should call FT_GlyphSlot_Own_Bitmap on the slot first"
|
||||
FT_GlyphSlot_Own_Bitmap(glyph);
|
||||
FT_Bitmap_Embolden(s_library, &glyph->bitmap, boldStrength, boldStrength);
|
||||
embolden = false;
|
||||
}
|
||||
|
||||
dst->advance += glyph->metrics.horiAdvance >> 6;
|
||||
|
|
@ -173,7 +172,7 @@ namespace
|
|||
for (unsigned int y = 0; y < height; ++y)
|
||||
{
|
||||
for (unsigned int x = 0; x < width; ++x)
|
||||
*pixels++ = (data[x/8] & (1 << (7 - x%8)) ? 255 : 0);
|
||||
*pixels++ = (data[x/8] & ((1 << (7 - x%8)) ? 255 : 0));
|
||||
|
||||
data += glyph->bitmap.pitch;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -469,7 +469,7 @@ bool NzMD5AnimParser::ParseHierarchy()
|
|||
}
|
||||
|
||||
char name[64];
|
||||
if (std::sscanf(&m_currentLine[0], "%s %d %u %u", &name[0], &m_joints[i].parent, &m_joints[i].flags, &m_joints[i].index) != 4)
|
||||
if (std::sscanf(&m_currentLine[0], "%63s %d %u %u", &name[0], &m_joints[i].parent, &m_joints[i].flags, &m_joints[i].index) != 4)
|
||||
{
|
||||
UnrecognizedLine(true);
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -234,9 +234,9 @@ bool NzMD5MeshParser::ParseJoints()
|
|||
}
|
||||
|
||||
char name[64];
|
||||
if (std::sscanf(&m_currentLine[0], "%s %d ( %f %f %f ) ( %f %f %f )", &name[0], &m_joints[i].parent,
|
||||
&m_joints[i].bindPos.x, &m_joints[i].bindPos.y, &m_joints[i].bindPos.z,
|
||||
&m_joints[i].bindOrient.x, &m_joints[i].bindOrient.y, &m_joints[i].bindOrient.z) != 8)
|
||||
if (std::sscanf(&m_currentLine[0], "%63s %d ( %f %f %f ) ( %f %f %f )", &name[0], &m_joints[i].parent,
|
||||
&m_joints[i].bindPos.x, &m_joints[i].bindPos.y, &m_joints[i].bindPos.z,
|
||||
&m_joints[i].bindOrient.x, &m_joints[i].bindOrient.y, &m_joints[i].bindOrient.z) != 8)
|
||||
{
|
||||
UnrecognizedLine(true);
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -130,10 +130,6 @@ void NzSubMesh::GenerateTangents()
|
|||
dv[0] = positions[iterator[1]] - pos0;
|
||||
dv[1] = positions[iterator[2]] - pos0;
|
||||
|
||||
NzVector2f duv[2];
|
||||
duv[0] = uv1 - uv0;
|
||||
duv[1] = uv2 - uv0;
|
||||
|
||||
float ds[2];
|
||||
ds[0] = uv1.x - uv0.x;
|
||||
ds[1] = uv2.x - uv0.x;
|
||||
|
|
|
|||
Loading…
Reference in New Issue