summaryrefslogtreecommitdiff
path: root/src/sky.cpp
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2015-01-17 20:05:45 +0100
committerKahrl <kahrl@gmx.net>2015-01-18 13:16:01 +0100
commite80a044818714da480fe6f108f0439f67380fca6 (patch)
tree3fd92af0f03dcfcccb28bf958b15bca4366c6ee8 /src/sky.cpp
parent29514918f81e50e9a87659dd930f4e8369d73041 (diff)
downloadminetest-e80a044818714da480fe6f108f0439f67380fca6.tar.gz
minetest-e80a044818714da480fe6f108f0439f67380fca6.tar.bz2
minetest-e80a044818714da480fe6f108f0439f67380fca6.zip
Fix use of uninit data in Sky and (potentially) GUIChatConsole constructors
Clean up nearby code a bit As a small side effect, it is now possible to add a background texture to the chat console by simply providing background_chat.jpg, it is no longer necessary to also add "console_color =" to minetest.conf.
Diffstat (limited to 'src/sky.cpp')
-rw-r--r--src/sky.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/sky.cpp b/src/sky.cpp
index 00072f17f..664ed694b 100644
--- a/src/sky.cpp
+++ b/src/sky.cpp
@@ -3,7 +3,7 @@
#include "ISceneManager.h"
#include "ICameraSceneNode.h"
#include "S3DVertex.h"
-#include "tile.h" // getTexturePath
+#include "tile.h"
#include "noise.h" // easeCurve
#include "main.h" // g_profiler
#include "profiler.h"
@@ -13,7 +13,8 @@
#include "camera.h" // CameraModes
//! constructor
-Sky::Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id):
+Sky::Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id,
+ ITextureSource *tsrc):
scene::ISceneNode(parent, mgr, id),
m_visible(true),
m_fallback_bg_color(255,255,255,255),
@@ -46,19 +47,18 @@ Sky::Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id):
m_materials[1].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
m_materials[2] = mat;
- m_materials[2].setTexture(0, mgr->getVideoDriver()->getTexture(
- getTexturePath("sunrisebg.png").c_str()));
+ m_materials[2].setTexture(0, tsrc->getTexture("sunrisebg.png"));
m_materials[2].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
//m_materials[2].MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
- m_sun_texture = mgr->getVideoDriver()->getTexture(
- getTexturePath("sun.png").c_str());
- m_moon_texture = mgr->getVideoDriver()->getTexture(
- getTexturePath("moon.png").c_str());
- m_sun_tonemap = mgr->getVideoDriver()->getTexture(
- getTexturePath("sun_tonemap.png").c_str());
- m_moon_tonemap = mgr->getVideoDriver()->getTexture(
- getTexturePath("moon_tonemap.png").c_str());
+ m_sun_texture = tsrc->isKnownSourceImage("sun.png") ?
+ tsrc->getTexture("sun.png") : NULL;
+ m_moon_texture = tsrc->isKnownSourceImage("moon.png") ?
+ tsrc->getTexture("moon.png") : NULL;
+ m_sun_tonemap = tsrc->isKnownSourceImage("sun_tonemap.png") ?
+ tsrc->getTexture("sun_tonemap.png") : NULL;
+ m_moon_tonemap = tsrc->isKnownSourceImage("moon_tonemap.png") ?
+ tsrc->getTexture("moon_tonemap.png") : NULL;
if (m_sun_texture){
m_materials[3] = mat;