Added assert to material_manager to catch if unintentionally

temporary materials are made permanent (while this is not
a memory leak, the code should use the right functions to
indicate which materials will stay around). Fixed some
materials that became permanently even though the code
called 'pushTempMaterial' (but the materials stayed
permanent). Moved icons_frame into commong race gui
base class, and made race gui textures permanent (so
that they don't cause any false texture-leaked messasges,
and also to avoid loading them again at each race).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8514 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk
2011-05-04 00:15:46 +00:00
parent 91432cd658
commit 9c127322f2
9 changed files with 28 additions and 22 deletions

View File

@@ -237,7 +237,11 @@ Material *MaterialManager::getMaterial(const std::string& fname,
// Add the new material
Material* m=new Material(fname, m_materials.size(), is_full_path);
m_materials.push_back(m);
if(make_permanent) m_shared_material_index = (int)m_materials.size();
if(make_permanent)
{
assert(m_shared_material_index==m_materials.size()-1);
m_shared_material_index = (int)m_materials.size();
}
return m ;
} // getMaterial

View File

@@ -40,10 +40,8 @@ void ProjectileManager::loadData()
void ProjectileManager::removeTextures()
{
cleanup();
//ssgDeRefDelete(m_explosion_model);
// Only the explosion is here, all other models are actually managed
// by powerup_manager.
//callback_manager->clear(CB_EXPLOSION);
} // removeTextures
//-----------------------------------------------------------------------------

View File

@@ -923,13 +923,16 @@ int main(int argc, char *argv[] )
file_manager->pushTextureSearchPath(file_manager->getModelFile(""));
const std::string materials_file = file_manager->getModelFile("materials.xml");
if(materials_file!="")
material_manager->pushTempMaterial(materials_file);
{
powerup_manager -> loadAllPowerups ();
item_manager -> loadDefaultItems();
// Some of the materials might be needed later, so just add
// them all permanently (i.e. as shared). Adding them temporary
// will actually not be possible: powerup_manager adds some
// permanent icon materials, which would (with the current
// implementation) make the temporary materials permanent anyway.
material_manager->addSharedMaterial(materials_file);
}
if(materials_file!="")
material_manager->popTempMaterial();
powerup_manager -> loadAllPowerups ();
item_manager -> loadDefaultItems();
GUIEngine::addLoadingIcon( irr_driver->getTexture(file_manager->getGUIDir() + "/gift.png") );

View File

@@ -106,7 +106,6 @@ MinimalRaceGUI::MinimalRaceGUI()
m_font_scale = 1.0f; //race_manager->getNumLocalPlayers()==1 ? 1.2f : 1.0f;
//read icon frame picture
m_icons_frame=material_manager->getMaterial("icons-frame.png");
// Determine maximum length of the rank/lap text, in order to
// align those texts properly on the right side of the viewport.

View File

@@ -97,7 +97,6 @@ private:
/** previous position of icons */
std::vector< core::vector2d<s32> > m_previous_icons_position;
Material *m_icons_frame;
/* Display informat for one player on the screen. */
void drawEnergyMeter (const Kart *kart,

View File

@@ -95,9 +95,6 @@ RaceGUI::RaceGUI()
m_dist_show_overlap=2;
m_icons_inertia=2;
//read icon frame picture
m_icons_frame=material_manager->getMaterial("icons-frame.png");
// Determine maximum length of the rank/lap text, in order to
// align those texts properly on the right side of the viewport.
gui::ScalableFont* font = GUIEngine::getFont();

View File

@@ -99,7 +99,6 @@ private:
/** previous position of icons */
std::vector< core::vector2d<s32> > m_previous_icons_position;
Material *m_icons_frame;
/* Display informat for one player on the screen. */
void drawEnergyMeter (int x, int y, const Kart *kart,

View File

@@ -51,13 +51,19 @@ RaceGUIBase::RaceGUIBase()
m_string_ready = _("Ready!");
m_string_set = _("Set!");
m_string_go = _("Go!");
m_plunger_face = material_manager->getMaterial("plungerface.png");
const std::string &guidir = file_manager->getGUIDir();
m_gauge_full = irr_driver->getTexture(guidir+"gauge_full.png" );
m_gauge_empty = irr_driver->getTexture(guidir+"gauge_empty.png");
m_gauge_goal = irr_driver->getTexture(guidir+"gauge_goal.png" );
// Make the two materials permanent (in case that they are not listed
// in the textures/materials.xml file).
m_plunger_face = material_manager->getMaterial("plungerface.png",
/*full path*/false,
/*permanent*/true);
//read frame picture for icons in the mini map.
m_icons_frame = material_manager->getMaterial("icons-frame.png",
/*full_path*/false,
/*permanent*/true);
const std::string &guid = file_manager->getGUIDir();
m_gauge_full = irr_driver->getTexture(guid+"gauge_full.png" );
m_gauge_empty = irr_driver->getTexture(guid+"gauge_empty.png");
m_gauge_goal = irr_driver->getTexture(guid+"gauge_goal.png" );
} // RaceGUIBase

View File

@@ -120,7 +120,8 @@ protected:
video::ITexture *m_gauge_full;
video::ITexture *m_gauge_goal;
/** The frame around player karts in the mini map. */
Material *m_icons_frame;
void cleanupMessages(const float dt);
void createMarkerTexture();