summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2013-05-26 11:34:53 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2013-05-26 11:34:53 +0200
commitb41957f2f95d8f62817705a1c82322d9463d28a2 (patch)
tree0ff331e8dd61039ecc193add91b05e5fe07c7651
parentff101c6973baeac63f8027118d4dad644354d869 (diff)
downloadcolobot-b41957f2f95d8f62817705a1c82322d9463d28a2.tar.gz
colobot-b41957f2f95d8f62817705a1c82322d9463d28a2.tar.bz2
colobot-b41957f2f95d8f62817705a1c82322d9463d28a2.zip
Corrected some valgrind issues
* fixed several uninitialized variable issues * fixed possible memory corruption in CEngine
-rw-r--r--src/graphics/engine/engine.cpp3
-rw-r--r--src/graphics/opengl/gldevice.cpp13
-rw-r--r--src/graphics/opengl/gldevice.h2
-rw-r--r--src/object/robotmain.cpp2
-rw-r--r--src/ui/maindialog.cpp3
5 files changed, 19 insertions, 4 deletions
diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp
index 5bd51fe..b697a37 100644
--- a/src/graphics/engine/engine.cpp
+++ b/src/graphics/engine/engine.cpp
@@ -998,7 +998,8 @@ void CEngine::ChangeSecondTexture(int objRank, const std::string& tex2Name)
continue; // already new
EngineBaseObjTexTier& newP2 = AddLevel2(p1, p2.tex1Name, tex2Name);
- newP2.next.swap(p2.next);
+ newP2.next.insert(newP2.next.end(), p2.next.begin(), p2.next.end());
+ p2.next.clear();
}
}
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp
index f351f22..9d5abc3 100644
--- a/src/graphics/opengl/gldevice.cpp
+++ b/src/graphics/opengl/gldevice.cpp
@@ -653,7 +653,7 @@ void CGLDevice::SetTexture(int index, const Texture &texture)
glBindTexture(GL_TEXTURE_2D, texture.id);
// Params need to be updated for the new bound texture
- SetTextureStageParams(index, m_textureStageParams[index]);
+ UpdateTextureParams(index);
}
void CGLDevice::SetTexture(int index, unsigned int textureId)
@@ -674,7 +674,7 @@ void CGLDevice::SetTexture(int index, unsigned int textureId)
glBindTexture(GL_TEXTURE_2D, textureId);
// Params need to be updated for the new bound texture
- SetTextureStageParams(index, m_textureStageParams[index]);
+ UpdateTextureParams(index);
}
/**
@@ -727,6 +727,13 @@ void CGLDevice::SetTextureStageParams(int index, const TextureStageParams &param
// Remember the settings
m_textureStageParams[index] = params;
+ UpdateTextureParams(index);
+}
+
+void CGLDevice::UpdateTextureParams(int index)
+{
+ assert(index >= 0 && index < static_cast<int>( m_currentTextures.size() ));
+
if (!m_multitextureAvailable && index != 0)
return;
@@ -734,6 +741,8 @@ void CGLDevice::SetTextureStageParams(int index, const TextureStageParams &param
if (! m_currentTextures[index].Valid())
return;
+ const TextureStageParams &params = m_textureStageParams[index];
+
if (m_multitextureAvailable)
glActiveTexture(GL_TEXTURE0 + index);
diff --git a/src/graphics/opengl/gldevice.h b/src/graphics/opengl/gldevice.h
index fe3f2a1..6f956cf 100644
--- a/src/graphics/opengl/gldevice.h
+++ b/src/graphics/opengl/gldevice.h
@@ -192,6 +192,8 @@ private:
void UpdateModelviewMatrix();
//! Updates position for given light based on transformation matrices
void UpdateLightPosition(int index);
+ //! Updates the texture params for given texture stage
+ void UpdateTextureParams(int index);
private:
//! Current config
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index 15250c6..47c8d7f 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -2116,7 +2116,7 @@ void CRobotMain::FlushDisplayInfo()
m_infoFilename[i][0] = 0;
m_infoPos[i] = 0;
}
- strcpy(m_infoFilename[SATCOM_OBJECT], "help/") + m_app->GetLanguageChar() + std::string("/objects.txt");
+ strcpy(m_infoFilename[SATCOM_OBJECT], "objects.txt");
m_infoIndex = 0;
}
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index 30538f3..14c1e82 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -5046,6 +5046,9 @@ void CMainDialog::UpdateSceneResume(int rank)
{
for ( i=0 ; i<500 ; i++ )
{
+ if (line[i] == 0)
+ break;
+
if ( line[i] == '\t' ) line[i] = ' '; // replaces tab by space
if ( line[i] == '/' && line[i+1] == '/' )
{